@zango-core/crm-framework 0.2.2 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}.collapse{visibility:collapse}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.container{width:100%}.mx-auto{margin-inline:auto}.mb-\\[18px\\]{margin-bottom:18px}.\\!line-clamp-2{-webkit-line-clamp:2!important;-webkit-box-orient:vertical!important;display:-webkit-box!important;overflow:hidden!important}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.h-\\[42px\\]{height:42px}.h-auto{height:auto}.h-full{height:100%}.h-screen{height:100vh}.min-h-\\[8rem\\]{min-height:8rem}.min-h-\\[300px\\]{min-height:300px}.min-h-\\[400px\\]{min-height:400px}.min-h-screen{min-height:100vh}.w-full{width:100%}.max-w-\\[150px\\]{max-width:150px}.flex-1{flex:1}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.list-disc{list-style-type:disc}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-full{border-radius:3.40282e38px}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-none{--tw-border-style:none;border-style:none}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-clip-text{-webkit-background-clip:text;background-clip:text}.object-cover{object-fit:cover}.\\!text-center{text-align:center!important}.text-center{text-align:center}.text-left{text-align:left}.text-\\[12px\\]{font-size:12px}.text-\\[40px\\]{font-size:40px}.leading-none{--tw-leading:1;line-height:1}.break-all{word-break:break-all}.text-\\[var\\(--color-brand-500\\,\\#5048ED\\)\\]{color:var(--color-brand-500,#5048ed)}.text-\\[var\\(--color-gray-700\\,\\#414651\\)\\]{color:var(--color-gray-700,#414651)}.text-transparent{color:#0000}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.underline{text-decoration-line:underline}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.duration-300{--tw-duration:.3s;transition-duration:.3s}.last\\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.focus\\:shadow-\\[0_0_0_2px_rgba\\(106\\,138\\,18\\,0\\.2\\)\\]:focus{--tw-shadow:0 0 0 2px var(--tw-shadow-color,#6a8a1233);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.brand-500{background-color:var(--color-brand-500)!important}.border-brand-500{border-color:var(--color-brand-500)!important}.login-tabs .ant-tabs-tab-active{border-bottom-width:2px!important;border-bottom-color:var(--color-brand-500)!important}.login-tabs .ant-tabs-ink-bar{background-color:var(--color-brand-500)!important}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}.wide-sidebar{width:244px;display:flex;height:100dvh;font-size:14px;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-style:normal;font-weight:500;border-right:1px solid #D5D7DA;flex-direction:column;position:relative;background-color:#fff;z-index:10}.frame-logo-container{height:64px;display:flex;align-items:center;gap:8px;padding:20px}.frame-logo-container a{display:flex;align-items:center;text-decoration:none}.frame-logo-container img{height:28px;width:auto}.frame-menu-container{display:flex;flex-direction:column;gap:16px;flex-grow:1;overflow-y:scroll;padding:8px 12px}#wideSidebarMenu{color:#414651;padding:0;flex-grow:1;display:flex;flex-direction:column;gap:4px;list-style:none;margin:0}#wideSidebarMenu li{list-style:none;padding:12px;border-radius:6px;overflow:hidden;color:#414651;transition:all .3s ease-in-out;cursor:pointer}#wideSidebarMenu .menu-item{display:flex;align-items:center;gap:8px}#wideSidebarMenu li a{display:flex;align-items:center;color:var(--color-gray-700, #414651);text-decoration:none;padding:12px;margin:-12px;width:calc(100% + 24px);gap:8px;font-size:14px;font-weight:500;transition:all .3s ease-in-out}#wideSidebarMenu li:hover,#wideSidebarMenu li.active{background-color:var(--color-brand-50, #EAE8FF);color:var(--color-brand-500, #5048ED)}#wideSidebarMenu li:hover a,#wideSidebarMenu li:hover .menu-title{color:var(--color-brand-500, #5048ED)!important}#wideSidebarMenu li.active{background-color:var(--color-brand-50, #EAE8FF);color:var(--color-brand-500, #5048ED);font-weight:600}#wideSidebarMenu li.active .menu-title,#wideSidebarMenu li.active a{color:var(--color-brand-500, #5048ED)}.navbar-icon{width:16px;height:16px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.navbar-icon svg{width:16px;height:16px}.navbar-icon img{width:16px;height:16px;object-fit:contain}.navbar-icon-emoji{font-size:16px;line-height:1;width:auto;min-width:16px}#wideSidebarMenu .menu-title{flex-grow:1;color:var(--color-gray-700, #414651)}#wideSidebarMenu .menu-list-item{cursor:pointer}#wideSidebarMenu .downIcon{display:flex;justify-content:center;align-items:center;height:100%;transition:transform .3s ease}#wideSidebarMenu li.active .downIcon{transform:rotate(180deg)}#wideSidebarMenu .submenu-accordion-item{color:#414651}#wideSidebarMenu .submenu-list{padding:0;max-height:0;overflow:hidden;opacity:0;list-style:none;margin:0;border-radius:8px;transition:all .3s cubic-bezier(.16,1,.3,1);transform:translateY(-4px)}#wideSidebarMenu .submenu-list.active{padding:9px 0;max-height:500px;opacity:1;transform:translateY(0)}#wideSidebarMenu .submenu-list-item{padding:10px 36px;position:relative;color:var(--color-gray-700, #414651)}#wideSidebarMenu .submenu-list-item a{display:flex;align-items:center;color:inherit;text-decoration:none;padding:10px 36px;margin:-10px -36px;width:calc(100% + 72px);gap:8px;transition:all .3s ease-in-out}#wideSidebarMenu .submenu-list-item a .each-submenu-label{color:var(--color-gray-700, #414651);font-size:12px}#wideSidebarMenu .submenu-list-item a .each-submenu-label.active{color:var(--color-brand-500, #5048ED)}#wideSidebarMenu .submenu-item-icon{display:none}#wideSidebarMenu .submenu-item-icon-container{width:16px}#wideSidebarMenu .submenu-item-icon.active{display:block}.submenu-item-icon-container{width:16px;height:16px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.submenu-dot{display:none}.submenu-dot.active{display:inline-block;width:14px;height:10px}.navbar-menu-container::-webkit-scrollbar{width:4px}.navbar-menu-container::-webkit-scrollbar-track{background:transparent}.navbar-menu-container::-webkit-scrollbar-thumb{background:var(--color-gray-300, #dde2e5);border-radius:2px}.navbar-menu-container::-webkit-scrollbar-thumb:hover{background:var(--color-gray-400, #d5d7da)}@media(max-width:768px){.navbar,.wide-sidebar{position:fixed;left:-244px;z-index:1000}.navbar.open,.wide-sidebar.open{left:0}}.user-profile-drawer{position:fixed;top:0;right:-100%;width:100%;height:100vh;background-color:var(--zango-gray-50, #F9FAFB);transition:right .3s ease-in-out;z-index:1300;overflow:hidden;display:flex;flex-direction:column}.user-profile-drawer *{box-sizing:border-box}.user-profile-drawer.open{right:0}.profile-header-gradient{height:100px;background:linear-gradient(135deg,var(--color-brand-500, #5048ED) 0%,#7C3AED 50%,#EC4899 100%);position:relative}.profile-close-btn{position:absolute;top:16px;right:16px;background:#fff3;border:none;width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s ease;color:#fff}.profile-close-btn:hover{background:#ffffff4d}.profile-info-section{background:#fff;padding:0 40px 20px;text-align:center;position:relative;border-bottom:1px solid var(--zango-gray-300, #E5E7EB);width:100%;box-sizing:border-box}.profile-avatar-container{margin-top:-40px;margin-bottom:12px}.profile-avatar-circle{width:80px;height:80px;background:var(--zango-gray-100, #F3F4F6);border-radius:50%;display:inline-flex;align-items:center;justify-content:center;border:4px solid #FFFFFF;box-shadow:0 4px 6px #0000001a;position:relative}.profile-avatar-circle svg{width:40px;height:40px}.profile-avatar-img{width:100%;height:100%;border-radius:50%;object-fit:cover}.profile-avatar-edit{position:absolute;bottom:-4px;right:-4px;background:var(--color-brand-500, #5048ED);color:#fff;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s ease;border:2px solid white;box-shadow:0 2px 4px #0000001a}.profile-avatar-edit:hover{background:var(--color-brand-600, #433BD9);transform:scale(1.1)}.profile-avatar-edit svg{width:14px;height:14px}.profile-initials{font-size:32px;font-weight:600;color:var(--zango-gray-700, #4B5563)}.profile-name-section{margin-bottom:0}.profile-user-name{font-size:20px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 2px}.profile-user-role{font-size:14px;color:var(--zango-gray-600, #6B7280);margin:0}.profile-user-role-badge{display:inline-flex;align-items:center;gap:6px;background:linear-gradient(135deg,#5048ed1a,#7c3aed1a,#ec48991a);color:var(--color-brand-500, #5048ED);padding:6px 14px;border-radius:20px;font-size:13px;font-weight:500;border:1px solid rgba(80,72,237,.2);margin-top:6px;transition:all .2s ease}.profile-user-role-badge:hover{background:linear-gradient(135deg,#5048ed26,#7c3aed26,#ec489926);border-color:#5048ed4d;transform:translateY(-1px);box-shadow:0 2px 8px #5048ed33}.profile-user-role-badge svg{width:14px;height:14px;stroke:var(--color-brand-500, #5048ED);flex-shrink:0}.profile-user-role-badge span{letter-spacing:.3px;text-transform:capitalize}.profile-main-content{flex:1;overflow-y:auto;overflow-x:hidden;padding:20px;display:flex;justify-content:center;width:100%;box-sizing:border-box}.profile-content-wrapper{background:#fff;border-radius:12px;padding:20px;width:100%;max-width:700px;margin:0 auto;box-shadow:0 1px 3px #0000001a;box-sizing:border-box;height:fit-content}.profile-tabs{display:flex;border-bottom:1px solid var(--zango-gray-300, #E5E7EB);margin-bottom:20px;width:100%;box-sizing:border-box}.profile-tab{padding:10px 20px;background:none;border:none;font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280);cursor:pointer;position:relative;transition:all .2s ease}.profile-tab:hover{color:var(--zango-gray-700, #4B5563)}.profile-tab.active{color:var(--color-brand-500, #5048ED)}.profile-tab.active:after{content:"";position:absolute;bottom:-1px;left:0;right:0;height:2px;background:var(--color-brand-500, #5048ED)}.profile-tab-content{padding:0;width:100%;box-sizing:border-box}.account-section{display:flex;flex-direction:column;gap:24px}.profile-photo-edit:hover{background:var(--color-brand-600, #433BD9)}.profile-field-section{border-bottom:1px solid var(--zango-gray-300, #E5E7EB);padding-bottom:16px}.profile-field-section:last-child{border-bottom:none}.profile-field-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}.profile-field-label{font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280)}.profile-field-value{font-size:16px;color:var(--zango-gray-900, #111827);margin:0;display:flex;align-items:center;gap:8px}.profile-field-value.readonly{color:var(--zango-gray-600, #6B7280)}.profile-field-value .empty-value{color:#9ca3af;font-style:italic}.profile-field-value .field-icon{flex-shrink:0}.profile-field-edit-btn{background:none;border:none;color:var(--color-brand-500, #5048ED);font-size:14px;font-weight:500;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all .2s ease}.profile-field-edit-btn:hover{background:#5048ed1a}.profile-inline-form{width:100%}.profile-inline-actions{display:flex;gap:8px;margin-top:12px;justify-content:flex-end}.profile-save-btn{padding:8px 16px;font-size:14px;font-weight:500;color:#fff;background:var(--color-brand-500, #5048ED);border:none;border-radius:6px;cursor:pointer;transition:all .2s ease}.profile-save-btn:hover{background:var(--color-brand-600, #433BD9)}.profile-save-btn:disabled{opacity:.6;cursor:not-allowed}.roles-list{display:flex;flex-direction:column;gap:8px;margin-top:8px}.role-item{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#f9fafb;border-radius:8px;border:1px solid #E5E7EB;transition:all .2s ease}.role-item:hover{background:var(--zango-gray-100, #F3F4F6);border-color:#d1d5db}.role-item.active{background:#5048ed0d;border-color:var(--color-brand-500, #5048ED)}.role-info{display:flex;align-items:center;gap:10px}.role-info svg{width:16px;height:16px;stroke:#6b7280;flex-shrink:0}.role-item.active .role-info svg{stroke:var(--color-brand-500, #5048ED)}.role-name{font-size:14px;color:#374151;font-weight:500}.role-badge{font-size:12px;font-weight:500;color:var(--color-brand-500, #5048ED);background:#5048ed1a;padding:4px 12px;border-radius:12px}.role-switch-btn{font-size:12px;font-weight:500;color:var(--zango-gray-600, #6B7280);background:#fff;padding:4px 12px;border-radius:6px;border:1px solid #E5E7EB;cursor:pointer;transition:all .2s ease}.role-switch-btn:hover{color:var(--color-brand-500, #5048ED);border-color:var(--color-brand-500, #5048ED);background:#5048ed0d}.security-section{display:flex;flex-direction:column;gap:24px}.security-block{border:1px solid #E5E7EB;border-radius:8px;padding:20px}.security-header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:16px}.security-title{font-size:16px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 4px}.security-subtitle{font-size:14px;color:var(--zango-gray-600, #6B7280);margin:0}.toggle-btn{padding:8px 16px;font-size:14px;font-weight:500;border:1px solid #E5E7EB;border-radius:6px;background:#fff;color:#374151;cursor:pointer;transition:all .2s ease}.toggle-btn:hover{background:#f9fafb}.toggle-btn.enabled{background:var(--color-brand-500, #5048ED);color:#fff;border-color:var(--color-brand-500, #5048ED)}.toggle-btn.enabled:hover{background:var(--color-brand-600, #433BD9)}.password-form{margin-top:16px}.sessions-list{display:flex;flex-direction:column;gap:12px;margin-top:16px}.session-item{display:flex;justify-content:space-between;align-items:center;padding:16px;background:#f9fafb;border-radius:8px;border:1px solid #E5E7EB}.session-info{display:flex;align-items:center;gap:16px;flex:1}.session-device{display:flex;align-items:center;gap:12px}.session-device svg{color:var(--zango-gray-600, #6B7280)}.session-device-header{display:flex;align-items:center;gap:8px;margin-bottom:2px}.session-device-name{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0}.session-status-tag{font-size:11px;font-weight:500;padding:2px 8px;border-radius:12px;text-transform:uppercase;letter-spacing:.5px}.session-status-tag.current{background:#22c55e1a;color:#16a34a;border:1px solid rgba(34,197,94,.2)}.session-status-tag.inactive{background:transparent;padding:0;border:none}.logout-tag-btn{font-size:11px;font-weight:500;padding:2px 8px;border-radius:12px;text-transform:uppercase;letter-spacing:.5px;background:#ef44441a;color:#dc2626;border:1px solid rgba(239,68,68,.2);cursor:pointer;transition:all .2s ease}.logout-tag-btn:hover{background:#ef444426;border-color:#ef44444d}.logout-tag-btn-ghost{background:#9ca3af1a;color:#6b7280;border:1px solid rgba(156,163,175,.2)}.logout-tag-btn-ghost:hover{background:#9ca3af26;border-color:#9ca3af4d;color:#4b5563}.session-details{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.session-time{text-align:right}.session-time-info{display:flex;flex-direction:column;gap:4px;align-items:flex-end}.session-start-time{font-size:12px;color:var(--zango-gray-500, #9CA3AF);margin:0;font-weight:500}.session-last-active{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.session-logout-btn{padding:6px 12px;font-size:12px;font-weight:500;border:1px solid #E5E7EB;border-radius:4px;background:#fff;color:#dc2626;cursor:pointer;transition:all .2s ease}.session-logout-btn:hover{background:#fef2f2;border-color:#dc2626}.session-current{font-size:12px;color:var(--zango-gray-600, #6B7280);font-style:italic}.no-sessions{text-align:center;color:var(--zango-gray-600, #6B7280);font-size:14px;padding:20px}.logout-all-btn{width:100%;padding:12px 20px;font-size:14px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #DC2626;border-radius:8px;cursor:pointer;transition:all .2s ease;margin-top:16px}.logout-all-btn:hover{background:#fef2f2}.tokens-list{margin-top:16px}.token-item{display:flex;align-items:center;justify-content:space-between;padding:16px;background:#f9fafb;border-radius:8px;margin-bottom:12px;transition:all .2s ease}.token-item:hover{background:var(--zango-gray-100, #F3F4F6)}.token-info{display:flex;align-items:center;justify-content:space-between;width:100%;gap:16px}.token-details{display:flex;align-items:center;gap:12px}.token-details svg{color:var(--zango-gray-600, #6B7280)}.token-name{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0 0 4px}.token-created{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.token-revoke-btn{padding:6px 16px;font-size:13px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #FEE2E2;border-radius:6px;cursor:pointer;transition:all .2s ease}.token-revoke-btn:hover{background:#fef2f2;border-color:#fecaca}.no-tokens{text-align:center;padding:32px 16px;color:var(--zango-gray-600, #6B7280)}.no-tokens p{margin:0 0 8px;font-size:14px}.no-tokens-hint{font-size:12px;color:#9ca3af}.profile-form-group{margin-bottom:16px;width:100%;box-sizing:border-box}.profile-form-label{display:block;font-size:14px;font-weight:500;color:#374151;margin-bottom:6px}.profile-form-input{width:100%;padding:10px 14px;font-size:14px;border:1px solid #E5E7EB;border-radius:8px;background:#fff;transition:all .2s ease;box-sizing:border-box}.profile-form-input:focus{outline:none;border-color:var(--color-brand-500, #5048ED);background:#fff;box-shadow:0 0 0 3px #5048ed1a}.profile-form-input::placeholder{color:#9ca3af}.profile-form-error{color:#ef4444;font-size:12px;margin-top:4px}.profile-form-actions{display:flex;gap:12px;margin-top:20px;justify-content:flex-end}.profile-cancel-btn{padding:10px 20px;font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280);background:#fff;border:1px solid #E5E7EB;border-radius:8px;cursor:pointer;transition:all .2s ease}.profile-cancel-btn:hover{background:#f9fafb;color:var(--zango-gray-700, #4B5563)}.profile-submit-btn{padding:10px 20px;font-size:14px;font-weight:600;color:#fff;background:var(--color-brand-500, #5048ED);border:none;border-radius:8px;cursor:pointer;transition:all .2s ease}.profile-submit-btn:hover{background:var(--color-brand-600, #433BD9)}.profile-submit-btn:disabled{opacity:.6;cursor:not-allowed}.profile-alert{padding:12px 16px;border-radius:8px;margin-bottom:20px;font-size:14px;display:flex;align-items:center;gap:8px}.profile-alert.error{background:#fee2e2;color:#dc2626;border:1px solid #FECACA}.profile-alert.success{background:#5048ed1a;color:var(--color-brand-500, #5048ED);border:1px solid rgba(80,72,237,.2)}.password-requirements{background:#f9fafb;border:1px solid #E5E7EB;border-radius:8px;padding:16px;margin:16px 0;width:100%;box-sizing:border-box}.password-requirement{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--zango-gray-600, #6B7280);margin-bottom:8px;transition:color .2s ease}.password-requirement:last-child{margin-bottom:0}.password-requirement svg{flex-shrink:0}.password-requirement svg path{fill:#9ca3af;transition:fill .2s ease}.password-requirement.met{color:var(--color-brand-500, #5048ED)}.password-requirement.met svg path{fill:var(--color-brand-500, #5048ED)}.welcome-banner{background:linear-gradient(135deg,#5048ed0d,#7c3aed0d,#ec48990d);border:1px solid rgba(80,72,237,.2);border-radius:12px;padding:24px;text-align:center;margin-bottom:24px}.welcome-banner svg{margin-bottom:16px}.welcome-banner h3{font-size:18px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 8px}.welcome-banner p{font-size:14px;color:var(--zango-gray-600, #6B7280);max-width:400px;margin:0 auto}.empty-value{color:#9ca3af;font-style:italic;font-weight:400}.field-icon{width:16px;height:16px;flex-shrink:0}.profile-field-section{transition:background .2s ease;padding:0 0 16px}.profile-field-section:hover{background:#00000003}.logout-section{margin-top:20px;padding-top:20px;border-top:1px solid #E5E7EB}.logout-button{width:100%;display:flex;align-items:center;justify-content:center;gap:8px;padding:12px 20px;font-size:14px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #DC2626;border-radius:8px;cursor:pointer;transition:all .2s ease}.logout-button:hover{background:#fef2f2;color:#b91c1c;border-color:#b91c1c}.logout-button svg{width:16px;height:16px;stroke:currentColor}@media(max-width:768px){.profile-main-content{padding:16px}.profile-content-wrapper{padding:16px;max-width:100%}.profile-tabs{margin:0 -16px 20px;padding:0 16px}.profile-tab{flex:1;text-align:center}.session-info{flex-direction:column;align-items:flex-start;gap:8px}.session-item{flex-direction:column;align-items:flex-start;gap:12px}}.password-history-list{margin-top:16px}.password-history-item{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--zango-gray-50, #F9FAFB);border-radius:8px;margin-bottom:12px;transition:all .2s ease}.password-history-item:last-child{margin-bottom:0}.password-history-item:hover{background:var(--zango-gray-100, #F3F4F6)}.history-icon{width:40px;height:40px;background:var(--zango-brand-100, rgba(80, 72, 237, .1));border-radius:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.history-icon svg{color:var(--zango-brand-600, #5048ED)}.history-details{flex:1}.history-text{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0 0 2px}.history-time{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.no-password-history{text-align:center;padding:24px 16px;color:var(--zango-gray-600, #6B7280)}.no-password-history p{margin:0;font-size:14px}.password-disabled-badge{display:inline-block;margin-left:8px;padding:2px 8px;font-size:11px;font-weight:600;color:var(--zango-error-600, #DC2626);background:var(--zango-error-100, #FEE2E2);border-radius:12px;text-transform:uppercase;letter-spacing:.5px}.password-expired{color:var(--zango-error-600, #DC2626);font-weight:600}.token-type{font-size:12px;color:var(--color-brand-500, #5048ED);margin:2px 0 4px;font-weight:500}.token-expiry{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:4px 0 0}.header-container{height:56px;width:100%;background:#fff;justify-content:flex-end;border-bottom:1px solid #E9EAEB;align-items:center;padding:0 20px;display:flex;position:relative}.topbar-content{width:100%;display:flex;justify-content:space-between;align-items:center}.topbar-left,.topbar-right{display:flex;align-items:center;gap:16px}.dropdown{position:relative}.profile-dropdown-menu-button{display:flex;gap:20px;align-items:center;cursor:pointer;padding:8px 12px;border-radius:8px;transition:background-color .2s ease}.profile-dropdown-menu-button:hover{background-color:var(--color-gray-100, #f5f5f5)}.profile-info-wrapper{display:flex;align-items:center;gap:8px}.profile-avatar{width:24px;height:24px;border-radius:50%;overflow:hidden}.profile-name{font-size:14px;font-weight:500;color:var(--color-Gray-900, #252b37)}.dropdown-arrow{transition:transform .2s cubic-bezier(.16,1,.3,1)}.dropdown-arrow.open{transform:rotate(180deg)}.profile-dropdown-menu{border-radius:8px;border:1px solid var(--color-gray-200, #E9EAEB);background:var(--color-background, #FFFFFF);box-shadow:0 12px 12px -4px #0a0d1214,0 -4px 6px -2px #0a0d120f,0 -2px 2px -2px #0a0d120d;min-width:158px;position:absolute;right:0;top:calc(100% + 10px);z-index:1000;list-style:none;margin:0;padding:0;opacity:0;visibility:hidden;transform:translateY(-8px) scale(.95);transition:all .2s cubic-bezier(.16,1,.3,1);overflow:hidden}.profile-dropdown-menu *{cursor:pointer!important}.profile-dropdown-menu.show{opacity:1;visibility:visible;transform:translateY(0) scale(1)}.profile-dropdown-menu li{margin:0}.dropdown-item{display:flex;align-items:center;padding:8px 12px;color:#717680;text-decoration:none;font-size:14px;transition:all .2s ease;cursor:pointer!important;background:none;border:none;width:100%;text-align:left;gap:8px}.dropdown-item:hover{background-color:#f5f5f5;color:#252b37}.profile-dropdown-menu li:first-child .dropdown-item:hover{border-top-left-radius:8px;border-top-right-radius:8px}.profile-dropdown-menu li:last-child .dropdown-item:hover{border-bottom-left-radius:8px;border-bottom-right-radius:8px}.dropdown-item.profile-info{padding:8px 12px;cursor:pointer}.dropdown-item.profile-info:hover{background-color:transparent;cursor:pointer}.dropdown-item.profile-info.clickable:hover{background-color:var(--color-Gray-100, #f5f5f5);cursor:pointer;border-radius:4px}.user-info-content{display:flex;align-items:center;gap:8px;cursor:pointer}.profile-role{font-weight:500;color:var(--color-Gray-900, #252b37)}.role-arrow{display:flex;align-items:center;justify-content:center;transition:transform .2s cubic-bezier(.16,1,.3,1)}.role-arrow.expanded{transform:rotate(180deg)}.profile-roles{max-height:200px;overflow-y:auto;margin:0 -16px;padding:0 16px}.profile-each-role{display:flex;align-items:center;padding:8px 12px;gap:8px;cursor:pointer;transition:all .2s ease}.profile-each-role:hover{background-color:var(--color-Gray-100, #f5f5f5)}.profile-dropdown-menu .profile-each-role:hover{border-radius:4px}.profile-each-role .label{font-size:14px;color:var(--color-Gray-700, #717680)}.profile-dropdown-divider{border:none}.profile-menu-option{display:flex;align-items:center;gap:8px;cursor:pointer}.profile-menu-name,.profile-name{font-size:12px;font-weight:500;cursor:pointer}.flex-row{flex-direction:row!important}.justify-content-between{justify-content:space-between!important}@media(max-width:768px){.topbar{padding:0 16px}.profile-dropdown-menu{right:-16px}}.layout{width:100vw;height:100vh;overflow:hidden}.layout-wrapper{display:flex;height:100vh;background-color:var(--color-background, #ffffff)}.layout-main{display:flex;flex-direction:column;overflow:hidden;transition:width .3s ease;flex:1;position:relative}.layout-content{flex:1;overflow-y:auto;background-color:var(--color-background, #ffffff);position:relative}.layout-content:has(.content-spinner-container.active)>:not(.content-spinner-container){opacity:0;transition:opacity .2s ease-in}.layout-content>:not(.content-spinner-container){opacity:1;transition:opacity .3s ease-in}.layout-loading,.layout-error{display:flex;align-items:center;justify-content:center;height:100vh;font-size:18px;color:var(--color-Gray-700, #717680)}.layout-error{color:var(--color-error-500, #f04438)}@media(max-width:768px){.layout-content{padding:16px}.layout-main{width:100vw!important}}.content-spinner-container{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background-color:#fff;border-radius:18px;z-index:99;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .2s ease-out}.content-spinner-container.active{opacity:1;visibility:visible;pointer-events:all;transition:none}.spinner{width:64px;height:64px;animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.noselect{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.d-flex{display:flex!important}.flex-column{flex-direction:column!important}.flex-grow-1{flex-grow:1!important}.p-0{padding:0!important}.dvh-100{height:100dvh!important}.complete-hidden-scroll-style::-webkit-scrollbar{display:none}.complete-hidden-scroll-style{-ms-overflow-style:none;scrollbar-width:none}.zango-loading{display:flex;align-items:center;justify-content:center;height:100vh;font-size:16px;color:#6d7280}.zango-no-menu{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;padding:2rem;text-align:center;color:#374151}.zango-no-menu h2{font-size:1.5rem;font-weight:600;margin-bottom:.5rem;color:#1f2937}.zango-no-menu p{font-size:1rem;color:#6b7280;margin:0;max-width:400px}*{box-sizing:border-box}body{margin:0;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#root{height:100vh}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
- (function(q,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("react"),require("react-router-dom"),require("@zango-core/crud/table"),require("@zango-core/components")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-router-dom","@zango-core/crud/table","@zango-core/components"],s):(q=typeof globalThis<"u"?globalThis:q||self,s(q.ZangoCRMFramework={},q["react/jsx-runtime"],q.React,q.ReactRouterDOM,q.table,q.components))})(this,(function(q,s,g,G,Go,p){"use strict";const Ko="zango_app_logo_cache";class Jo{constructor(){this.cacheKey=Ko}getCachedLogo(){try{const t=localStorage.getItem(this.cacheKey);if(!t)return null;const r=JSON.parse(t);return this.isCacheExpired(r.timestamp)?(this.clearCache(),null):r}catch(t){return console.error("Error reading logo cache:",t),null}}async cacheLogoUrl(t,r){if(t)try{const o=await this.generateHash(t),a=this.getCachedLogo();if(a&&a.version===o)return a.timestamp=Date.now(),localStorage.setItem(this.cacheKey,JSON.stringify(a)),a;const n=await this.fetchAndConvertToBase64(t),i={url:t,base64Data:n,version:o,timestamp:Date.now(),appName:r||"Zango CRM"};return localStorage.setItem(this.cacheKey,JSON.stringify(i)),i}catch(o){return console.error("Error caching logo:",o),{url:t,base64Data:null,version:null,timestamp:Date.now(),appName:r||"Zango CRM"}}}async fetchAndConvertToBase64(t){try{const r=t.startsWith("http")?t:`${window.location.origin}${t}`,o=await fetch(r);if(!o.ok)throw new Error(`Failed to fetch logo: ${o.status}`);const a=await o.blob();return new Promise((n,i)=>{const c=new FileReader;c.onloadend=()=>n(c.result),c.onerror=i,c.readAsDataURL(a)})}catch(r){return console.error("Error converting logo to base64:",r),null}}async generateHash(t){let r=0;for(let o=0;o<t.length;o++){const a=t.charCodeAt(o);r=(r<<5)-r+a,r=r&r}return Math.abs(r).toString(36)}isCacheExpired(t){return Date.now()-t>864e5}clearCache(){try{localStorage.removeItem(this.cacheKey)}catch(t){console.error("Error clearing logo cache:",t)}}async needsUpdate(t){const r=this.getCachedLogo();return!!(!r||r.url!==t||this.isCacheExpired(r.timestamp))}async updateInBackground(t,r,o){try{if(!await this.needsUpdate(t))return;setTimeout(async()=>{const n=await this.cacheLogoUrl(t,r);n&&o&&o(n)},100)}catch(a){console.error("Error updating logo in background:",a)}}}const Ve=new Jo,Vt=()=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"62",height:"20",viewBox:"0 0 62 20",fill:"none",children:[s.jsx("path",{d:"M0 15.5495L0 13.7372L5.34244 6.80918L0.527365 6.80918L0.527365 4.17101L9.53843 4.17101L9.53843 5.96037L4.19599 12.9114L9.69894 12.9114V15.5495L0 15.5495Z",fill:"var(--Colours-Base-black, #000)"}),s.jsx("path",{d:"M16.605 15.8248C15.7949 15.8248 15.0382 15.6948 14.3351 15.4348C13.6319 15.1595 13.0205 14.7695 12.5007 14.2649C11.981 13.7449 11.5759 13.1178 11.2855 12.3837C10.9951 11.6496 10.8499 10.8085 10.8499 9.86027C10.8499 8.94265 11.0027 8.11679 11.3084 7.38269C11.6142 6.6333 12.0116 6.00626 12.5007 5.50156C13.0052 4.98158 13.5784 4.58394 14.2204 4.30865C14.8624 4.03337 15.5274 3.89573 16.2152 3.89573C17.0254 3.89573 17.7285 4.03337 18.3247 4.30865C18.9361 4.58394 19.4406 4.96628 19.838 5.45568C20.2507 5.94508 20.5564 6.52624 20.7552 7.19916C20.9539 7.85679 21.0532 8.5756 21.0532 9.35558C21.0532 9.66145 21.0379 9.95203 21.0074 10.2273C20.9768 10.5026 20.9462 10.7091 20.9157 10.8467L14.1058 10.8467C14.2586 11.6726 14.5949 12.2843 15.1146 12.682C15.6497 13.0643 16.2993 13.2555 17.0636 13.2555C17.8738 13.2555 18.6916 13.0031 19.517 12.4984L20.6405 14.5401C20.0596 14.9378 19.41 15.2513 18.6916 15.4807C17.9884 15.7101 17.2929 15.8248 16.605 15.8248ZM14.0828 8.62148L18.1871 8.62148C18.1871 7.97914 18.0419 7.45916 17.7515 7.06152C17.461 6.66389 16.9719 6.46507 16.284 6.46507C15.749 6.46507 15.2751 6.64094 14.8624 6.9927C14.465 7.34445 14.2051 7.88738 14.0828 8.62148Z",fill:"currentColor"}),s.jsx("path",{d:"M26.4777 15.8248C25.8969 15.8248 25.4077 15.7331 25.0103 15.5495C24.6128 15.366 24.2918 15.1137 24.0472 14.7925C23.818 14.456 23.6498 14.0584 23.5428 13.5996C23.4358 13.1255 23.3823 12.5978 23.3823 12.0167L23.3823 0L26.7529 0L26.7529 12.1543C26.7529 12.5061 26.814 12.7508 26.9363 12.8884C27.0739 13.0261 27.2114 13.0949 27.349 13.0949C27.4254 13.0949 27.4866 13.0949 27.5324 13.0949C27.5936 13.0949 27.67 13.0796 27.7617 13.049L28.1745 15.5495C27.991 15.626 27.7541 15.6872 27.4637 15.7331C27.1885 15.7942 26.8599 15.8248 26.4777 15.8248Z",fill:"currentColor"}),s.jsx("path",{d:"M34.3225 15.8248C33.6193 15.8248 33.0155 15.7178 32.5111 15.5036C32.0219 15.2895 31.6168 14.9913 31.2958 14.609C30.9901 14.2266 30.7608 13.7678 30.608 13.2325C30.4704 12.682 30.4016 12.0779 30.4016 11.4202L30.4016 6.80918L28.8424 6.80918V4.30865L30.585 4.17101L30.9748 1.14286L33.7722 1.14286V4.17101L36.5007 4.17101V6.80918L33.7722 6.80918V11.3743C33.7722 12.0167 33.9021 12.4831 34.162 12.7737C34.4371 13.049 34.7963 13.1867 35.2396 13.1867C35.423 13.1867 35.6065 13.1637 35.7899 13.1178C35.9886 13.0719 36.1644 13.0184 36.3173 12.9572L36.8446 15.4119C36.5389 15.5036 36.1797 15.5954 35.767 15.6872C35.3543 15.7789 34.8727 15.8248 34.3225 15.8248Z",fill:"currentColor"}),s.jsx("path",{d:"M38.7205 15.5495V0L42.0911 0V3.41397L41.9306 5.45568C42.3586 5.07334 42.8554 4.72158 43.4209 4.40042C43.9865 4.06396 44.6591 3.89573 45.4387 3.89573C46.6768 3.89573 47.5711 4.30101 48.1214 5.11157C48.687 5.92214 48.9697 7.04623 48.9697 8.48384V15.5495H45.5992V8.91971C45.5992 8.09385 45.4845 7.52798 45.2553 7.22211C45.0413 6.91623 44.6897 6.7633 44.2005 6.7633C43.7725 6.7633 43.4057 6.8627 43.0999 7.06152C42.7942 7.24505 42.4579 7.51269 42.0911 7.86444V15.5495H38.7205Z",fill:"currentColor"}),s.jsx("path",{d:"M53.0807 20C52.7291 20 52.431 19.9771 52.1864 19.9312C51.9418 19.9006 51.7049 19.8471 51.4756 19.7706L52.0718 17.2013C52.1788 17.2318 52.3011 17.2624 52.4386 17.293C52.5762 17.3236 52.7061 17.3389 52.8284 17.3389C53.394 17.3389 53.8297 17.2013 54.1354 16.926C54.4411 16.6507 54.6704 16.2913 54.8233 15.8478L54.9837 15.2513L50.6043 4.17101L53.9978 4.17101L55.6258 9.05735C55.7939 9.57734 55.9468 10.105 56.0843 10.6402C56.2219 11.1755 56.3671 11.7261 56.52 12.292H56.6117C56.734 11.7567 56.8563 11.2214 56.9786 10.6861C57.1161 10.1356 57.2537 9.59263 57.3913 9.05735L58.767 4.17101H62L58.0562 15.6642C57.7811 16.383 57.4906 17.0101 57.1849 17.5454C56.8945 18.0959 56.5506 18.5471 56.1531 18.8989C55.771 19.2659 55.3277 19.5412 54.8233 19.7247C54.3341 19.9082 53.7532 20 53.0807 20Z",fill:"currentColor"})]}),Pr=({logoUrl:e,appName:t,height:r="28px",linkTo:o="/"})=>{const[a,n]=g.useState(null),[i,c]=g.useState(!0),[d,l]=g.useState(!1);g.useEffect(()=>{(async()=>{try{const f=Ve.getCachedLogo();f&&(f.base64Data||f.url)?(n(f.base64Data||f.url),c(!1)):e?(n(e),c(!1)):(l(!0),c(!1)),e&&Ve.updateInBackground(e,t,x=>{x.base64Data&&n(x.base64Data)})}catch(f){console.error("Error initializing logo:",f),l(!0),c(!1)}})()},[e,t]);const u=g.useCallback(()=>{console.error("Logo failed to load"),l(!0);const w=Ve.getCachedLogo();w&&a===w.base64Data&&Ve.clearCache()},[a]),h=g.useCallback(()=>{c(!1),l(!1)},[]),m=()=>d||!a&&!i?s.jsx(Vt,{}):a?s.jsxs(s.Fragment,{children:[s.jsx("img",{src:a,height:r,alt:t||"Logo",onError:u,onLoad:h,style:{display:i?"none":"block",maxHeight:r,objectFit:"contain"}}),i&&s.jsx(Vt,{})]}):s.jsx(Vt,{});return s.jsx(G.Link,{to:o,className:"logo-link",children:m()})},pt=(e,t={})=>`${t.baseUrl||""}${e}`,Xo=(e,t={})=>t.endpoints?.[e]||"",Qo=(e={})=>e.timeout||3e4;function Ce(e,t){if(!e)return"/";const[r,o]=e.split("?"),a=r.replace(/\/+$/,"")+"/",n=new URLSearchParams;o&&new URLSearchParams(o).forEach((d,l)=>{n.set(l,d)}),t&&Object.keys(t).length>0&&Object.entries(t).forEach(([c,d])=>{d!=null&&n.set(c,String(d))});const i=n.toString();return i?`${a}?${i}`:a}const rt="";function Yo(e){const t=document.cookie.split("; ");for(const r of t){const[o,a]=r.split("=");if(o===e)return decodeURIComponent(a)}return null}const st=async()=>({"X-Csrftoken":Yo("csrftoken")}),Sr=async({fullUrl:e})=>{const t=`${rt}${e}${e.includes("?")?"&":"?"}_t=${Date.now()}`;return await fetch(t,{method:"GET",redirect:"follow",headers:{...await st(),"Content-Type":"application/json"}})},kr=async({fullUrl:e,payload:t})=>await fetch(rt+e,{method:"POST",redirect:"follow",headers:{...await st(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Ar=async({fullUrl:e,payload:t})=>await fetch(rt+e,{method:"PUT",redirect:"follow",headers:{...await st(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),_r=async({fullUrl:e,payload:t})=>await fetch(rt+e,{method:"DELETE",redirect:"follow",headers:{...await st(),"Content-Type":"application/json"},body:t instanceof FormData?t:JSON.stringify(t)}),Lr=async({fullUrl:e,payload:t})=>await fetch(rt+e,{method:"PATCH",redirect:"follow",headers:{...await st(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),ve=async e=>{let t;try{const r={message:"Calling API endpoint",data:{endpoint:e.url,method:e.type}},o=pt(e.url);switch(e.type){case"POST":t=await kr({fullUrl:o,payload:e.payload});break;case"PUT":t=await Ar({fullUrl:o,payload:e.payload});break;case"PATCH":t=await Lr({fullUrl:o,payload:e.payload});break;case"DELETE":t=await _r({fullUrl:o,payload:e.payload});break;case"GET":default:t=await Sr({fullUrl:o})}if(t.status===200)try{return{response:(await t.json()).response,success:!0,responseStatus:t.status}}catch{return{response:{message:"Server Error"},success:!1,responseStatus:t.status}}else return{response:(await t.json()).response||{message:"Server Error"},success:!1,responseStatus:t.status}}catch(r){return console.error("API Request Error:",r),{response:{message:"Network Error"},success:!1,responseStatus:500}}},Ro=e=>{if(!e||Object.keys(e).length===0)return"";const t=new URLSearchParams;Object.entries(e).forEach(([o,a])=>{a!=null&&t.append(o,String(a))});const r=t.toString();return r?`?${r}`:""},Tr=()=>{const t=typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",r=t.startsWith("/")?t:`/${t}`;return{url:Ce(r),type:"GET"}},Nr=()=>({url:Ce("/api/v1/profile"),type:"GET"}),Er=e=>({url:Ce("/api/v1/profile"),type:"PUT",payload:e}),Fr=e=>({url:Ce("/api/v1/profile/photo"),type:"POST",payload:e}),Or=e=>({url:Ce("/api/v1/appauth/password/change/"),type:"PUT",payload:e}),Mr=e=>({url:Ce("/api/v1/profile/two-factor"),type:"POST",payload:e}),Ur=e=>({url:Ce(`/api/v1/appauth/role/switch/?role=${encodeURIComponent(e)}`),type:"POST"}),Br=()=>({url:Ce("/api/v1/appauth/sessions/"),type:"GET"}),qr=e=>({url:Ce("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:[e]}}),Ir=e=>({url:Ce("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:e}}),$r=()=>({url:Ce("/api/v1/appauth/logout"),type:"DELETE"}),Vr=()=>({url:Ce("/logout"),type:"POST"}),jr=async()=>ve(Tr()),Dr=async()=>ve(Nr()),Hr=async()=>ve(Br()),gt=async e=>ve(Er(e)),ea=async e=>ve(Fr(e)),zr=async e=>ve(Or(e)),ta=async e=>ve(Mr({enabled:e})),Wr=async e=>ve(Ur(e)),Zr=async e=>ve(qr(e)),Gr=async e=>ve(Ir(e)),Kr=async()=>ve($r()),Jr=async()=>ve(Vr());function mt(e){"@babel/helpers - typeof";return mt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mt(e)}var ra=/^\s+/,sa=/\s+$/;function $(e,t){if(e=e||"",t=t||{},e instanceof $)return e;if(!(this instanceof $))return new $(e,t);var r=oa(e);this._originalInput=e,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||r.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=r.ok}$.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),r,o,a,n,i,c;return r=t.r/255,o=t.g/255,a=t.b/255,r<=.03928?n=r/12.92:n=Math.pow((r+.055)/1.055,2.4),o<=.03928?i=o/12.92:i=Math.pow((o+.055)/1.055,2.4),a<=.03928?c=a/12.92:c=Math.pow((a+.055)/1.055,2.4),.2126*n+.7152*i+.0722*c},setAlpha:function(t){return this._a=ts(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=Qr(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=Qr(this._r,this._g,this._b),r=Math.round(t.h*360),o=Math.round(t.s*100),a=Math.round(t.v*100);return this._a==1?"hsv("+r+", "+o+"%, "+a+"%)":"hsva("+r+", "+o+"%, "+a+"%, "+this._roundA+")"},toHsl:function(){var t=Xr(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=Xr(this._r,this._g,this._b),r=Math.round(t.h*360),o=Math.round(t.s*100),a=Math.round(t.l*100);return this._a==1?"hsl("+r+", "+o+"%, "+a+"%)":"hsla("+r+", "+o+"%, "+a+"%, "+this._roundA+")"},toHex:function(t){return Yr(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return la(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(ae(this._r,255)*100)+"%",g:Math.round(ae(this._g,255)*100)+"%",b:Math.round(ae(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(ae(this._r,255)*100)+"%, "+Math.round(ae(this._g,255)*100)+"%, "+Math.round(ae(this._b,255)*100)+"%)":"rgba("+Math.round(ae(this._r,255)*100)+"%, "+Math.round(ae(this._g,255)*100)+"%, "+Math.round(ae(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:Ca[Yr(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+Rr(this._r,this._g,this._b,this._a),o=r,a=this._gradientType?"GradientType = 1, ":"";if(t){var n=$(t);o="#"+Rr(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+r+",endColorstr="+o+")"},toString:function(t){var r=!!t;t=t||this._format;var o=!1,a=this._a<1&&this._a>=0,n=!r&&a&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(o=this.toRgbString()),t==="prgb"&&(o=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(o=this.toHexString()),t==="hex3"&&(o=this.toHexString(!0)),t==="hex4"&&(o=this.toHex8String(!0)),t==="hex8"&&(o=this.toHex8String()),t==="name"&&(o=this.toName()),t==="hsl"&&(o=this.toHslString()),t==="hsv"&&(o=this.toHsvString()),o||this.toHexString())},clone:function(){return $(this.toString())},_applyModification:function(t,r){var o=t.apply(null,[this].concat([].slice.call(r)));return this._r=o._r,this._g=o._g,this._b=o._b,this.setAlpha(o._a),this},lighten:function(){return this._applyModification(ha,arguments)},brighten:function(){return this._applyModification(fa,arguments)},darken:function(){return this._applyModification(pa,arguments)},desaturate:function(){return this._applyModification(ca,arguments)},saturate:function(){return this._applyModification(da,arguments)},greyscale:function(){return this._applyModification(ua,arguments)},spin:function(){return this._applyModification(ga,arguments)},_applyCombination:function(t,r){return t.apply(null,[this].concat([].slice.call(r)))},analogous:function(){return this._applyCombination(ya,arguments)},complement:function(){return this._applyCombination(ma,arguments)},monochromatic:function(){return this._applyCombination(ba,arguments)},splitcomplement:function(){return this._applyCombination(wa,arguments)},triad:function(){return this._applyCombination(es,[3])},tetrad:function(){return this._applyCombination(es,[4])}},$.fromRatio=function(e,t){if(mt(e)=="object"){var r={};for(var o in e)e.hasOwnProperty(o)&&(o==="a"?r[o]=e[o]:r[o]=ot(e[o]));e=r}return $(e,t)};function oa(e){var t={r:0,g:0,b:0},r=1,o=null,a=null,n=null,i=!1,c=!1;return typeof e=="string"&&(e=Sa(e)),mt(e)=="object"&&(Fe(e.r)&&Fe(e.g)&&Fe(e.b)?(t=aa(e.r,e.g,e.b),i=!0,c=String(e.r).substr(-1)==="%"?"prgb":"rgb"):Fe(e.h)&&Fe(e.s)&&Fe(e.v)?(o=ot(e.s),a=ot(e.v),t=ia(e.h,o,a),i=!0,c="hsv"):Fe(e.h)&&Fe(e.s)&&Fe(e.l)&&(o=ot(e.s),n=ot(e.l),t=na(e.h,o,n),i=!0,c="hsl"),e.hasOwnProperty("a")&&(r=e.a)),r=ts(r),{ok:i,format:e.format||c,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:r}}function aa(e,t,r){return{r:ae(e,255)*255,g:ae(t,255)*255,b:ae(r,255)*255}}function Xr(e,t,r){e=ae(e,255),t=ae(t,255),r=ae(r,255);var o=Math.max(e,t,r),a=Math.min(e,t,r),n,i,c=(o+a)/2;if(o==a)n=i=0;else{var d=o-a;switch(i=c>.5?d/(2-o-a):d/(o+a),o){case e:n=(t-r)/d+(t<r?6:0);break;case t:n=(r-e)/d+2;break;case r:n=(e-t)/d+4;break}n/=6}return{h:n,s:i,l:c}}function na(e,t,r){var o,a,n;e=ae(e,360),t=ae(t,100),r=ae(r,100);function i(l,u,h){return h<0&&(h+=1),h>1&&(h-=1),h<1/6?l+(u-l)*6*h:h<1/2?u:h<2/3?l+(u-l)*(2/3-h)*6:l}if(t===0)o=a=n=r;else{var c=r<.5?r*(1+t):r+t-r*t,d=2*r-c;o=i(d,c,e+1/3),a=i(d,c,e),n=i(d,c,e-1/3)}return{r:o*255,g:a*255,b:n*255}}function Qr(e,t,r){e=ae(e,255),t=ae(t,255),r=ae(r,255);var o=Math.max(e,t,r),a=Math.min(e,t,r),n,i,c=o,d=o-a;if(i=o===0?0:d/o,o==a)n=0;else{switch(o){case e:n=(t-r)/d+(t<r?6:0);break;case t:n=(r-e)/d+2;break;case r:n=(e-t)/d+4;break}n/=6}return{h:n,s:i,v:c}}function ia(e,t,r){e=ae(e,360)*6,t=ae(t,100),r=ae(r,100);var o=Math.floor(e),a=e-o,n=r*(1-t),i=r*(1-a*t),c=r*(1-(1-a)*t),d=o%6,l=[r,i,n,n,c,r][d],u=[c,r,r,i,n,n][d],h=[n,n,c,r,r,i][d];return{r:l*255,g:u*255,b:h*255}}function Yr(e,t,r,o){var a=[Se(Math.round(e).toString(16)),Se(Math.round(t).toString(16)),Se(Math.round(r).toString(16))];return o&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function la(e,t,r,o,a){var n=[Se(Math.round(e).toString(16)),Se(Math.round(t).toString(16)),Se(Math.round(r).toString(16)),Se(rs(o))];return a&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function Rr(e,t,r,o){var a=[Se(rs(o)),Se(Math.round(e).toString(16)),Se(Math.round(t).toString(16)),Se(Math.round(r).toString(16))];return a.join("")}$.equals=function(e,t){return!e||!t?!1:$(e).toRgbString()==$(t).toRgbString()},$.random=function(){return $.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function ca(e,t){t=t===0?0:t||10;var r=$(e).toHsl();return r.s-=t/100,r.s=wt(r.s),$(r)}function da(e,t){t=t===0?0:t||10;var r=$(e).toHsl();return r.s+=t/100,r.s=wt(r.s),$(r)}function ua(e){return $(e).desaturate(100)}function ha(e,t){t=t===0?0:t||10;var r=$(e).toHsl();return r.l+=t/100,r.l=wt(r.l),$(r)}function fa(e,t){t=t===0?0:t||10;var r=$(e).toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(255*-(t/100)))),r.g=Math.max(0,Math.min(255,r.g-Math.round(255*-(t/100)))),r.b=Math.max(0,Math.min(255,r.b-Math.round(255*-(t/100)))),$(r)}function pa(e,t){t=t===0?0:t||10;var r=$(e).toHsl();return r.l-=t/100,r.l=wt(r.l),$(r)}function ga(e,t){var r=$(e).toHsl(),o=(r.h+t)%360;return r.h=o<0?360+o:o,$(r)}function ma(e){var t=$(e).toHsl();return t.h=(t.h+180)%360,$(t)}function es(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var r=$(e).toHsl(),o=[$(e)],a=360/t,n=1;n<t;n++)o.push($({h:(r.h+n*a)%360,s:r.s,l:r.l}));return o}function wa(e){var t=$(e).toHsl(),r=t.h;return[$(e),$({h:(r+72)%360,s:t.s,l:t.l}),$({h:(r+216)%360,s:t.s,l:t.l})]}function ya(e,t,r){t=t||6,r=r||30;var o=$(e).toHsl(),a=360/r,n=[$(e)];for(o.h=(o.h-(a*t>>1)+720)%360;--t;)o.h=(o.h+a)%360,n.push($(o));return n}function ba(e,t){t=t||6;for(var r=$(e).toHsv(),o=r.h,a=r.s,n=r.v,i=[],c=1/t;t--;)i.push($({h:o,s:a,v:n})),n=(n+c)%1;return i}$.mix=function(e,t,r){r=r===0?0:r||50;var o=$(e).toRgb(),a=$(t).toRgb(),n=r/100,i={r:(a.r-o.r)*n+o.r,g:(a.g-o.g)*n+o.g,b:(a.b-o.b)*n+o.b,a:(a.a-o.a)*n+o.a};return $(i)},$.readability=function(e,t){var r=$(e),o=$(t);return(Math.max(r.getLuminance(),o.getLuminance())+.05)/(Math.min(r.getLuminance(),o.getLuminance())+.05)},$.isReadable=function(e,t,r){var o=$.readability(e,t),a,n;switch(n=!1,a=ka(r),a.level+a.size){case"AAsmall":case"AAAlarge":n=o>=4.5;break;case"AAlarge":n=o>=3;break;case"AAAsmall":n=o>=7;break}return n},$.mostReadable=function(e,t,r){var o=null,a=0,n,i,c,d;r=r||{},i=r.includeFallbackColors,c=r.level,d=r.size;for(var l=0;l<t.length;l++)n=$.readability(e,t[l]),n>a&&(a=n,o=$(t[l]));return $.isReadable(e,o,{level:c,size:d})||!i?o:(r.includeFallbackColors=!1,$.mostReadable(e,["#fff","#000"],r))};var jt=$.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Ca=$.hexNames=va(jt);function va(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r]]=r);return t}function ts(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function ae(e,t){xa(e)&&(e="100%");var r=Pa(e);return e=Math.min(t,Math.max(0,parseFloat(e))),r&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function wt(e){return Math.min(1,Math.max(0,e))}function xe(e){return parseInt(e,16)}function xa(e){return typeof e=="string"&&e.indexOf(".")!=-1&&parseFloat(e)===1}function Pa(e){return typeof e=="string"&&e.indexOf("%")!=-1}function Se(e){return e.length==1?"0"+e:""+e}function ot(e){return e<=1&&(e=e*100+"%"),e}function rs(e){return Math.round(parseFloat(e)*255).toString(16)}function ss(e){return xe(e)/255}var ke=(function(){var e="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",r="(?:"+t+")|(?:"+e+")",o="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",a="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{CSS_UNIT:new RegExp(r),rgb:new RegExp("rgb"+o),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+o),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+o),hsva:new RegExp("hsva"+a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function Fe(e){return!!ke.CSS_UNIT.exec(e)}function Sa(e){e=e.replace(ra,"").replace(sa,"").toLowerCase();var t=!1;if(jt[e])e=jt[e],t=!0;else if(e=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=ke.rgb.exec(e))?{r:r[1],g:r[2],b:r[3]}:(r=ke.rgba.exec(e))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=ke.hsl.exec(e))?{h:r[1],s:r[2],l:r[3]}:(r=ke.hsla.exec(e))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=ke.hsv.exec(e))?{h:r[1],s:r[2],v:r[3]}:(r=ke.hsva.exec(e))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=ke.hex8.exec(e))?{r:xe(r[1]),g:xe(r[2]),b:xe(r[3]),a:ss(r[4]),format:t?"name":"hex8"}:(r=ke.hex6.exec(e))?{r:xe(r[1]),g:xe(r[2]),b:xe(r[3]),format:t?"name":"hex"}:(r=ke.hex4.exec(e))?{r:xe(r[1]+""+r[1]),g:xe(r[2]+""+r[2]),b:xe(r[3]+""+r[3]),a:ss(r[4]+""+r[4]),format:t?"name":"hex8"}:(r=ke.hex3.exec(e))?{r:xe(r[1]+""+r[1]),g:xe(r[2]+""+r[2]),b:xe(r[3]+""+r[3]),format:t?"name":"hex"}:!1}function ka(e){var t,r;return e=e||{level:"AA",size:"small"},t=(e.level||"AA").toUpperCase(),r=(e.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),r!=="small"&&r!=="large"&&(r="small"),{level:t,size:r}}const je=e=>({25:$.mix(e,"#FFFFFF",95).toHexString(),50:$.mix(e,"#FFFFFF",90).toHexString(),100:$.mix(e,"#FFFFFF",80).toHexString(),200:$.mix(e,"#FFFFFF",65).toHexString(),300:$.mix(e,"#FFFFFF",50).toHexString(),400:$.mix(e,"#FFFFFF",30).toHexString(),500:$(e).toHexString(),600:$.mix(e,"#000000",10).toHexString(),700:$.mix(e,"#000000",20).toHexString(),800:$.mix(e,"#000000",30).toHexString(),900:$.mix(e,"#000000",45).toHexString(),950:$.mix(e,"#000000",60).toHexString()}),yt=e=>{let t="";const r={brand:je(e.colors.primary),success:je(e.colors.success),warning:je(e.colors.warning),gray:je(e.colors.gray),error:je(e.colors.error)};return t=Object.entries(r).map(([o,a])=>Object.entries(a).map(([n,i])=>`--color-${o}-${n}: ${i}`).join(`;
3
- `)).join(";"),e?.typography&&Object.entries(e.typography).forEach(([o,a])=>{const n=o.replace(/_/g,"-");t+=`--${n}: ${a}; `}),e?.borders&&Object.entries(e.borders).forEach(([o,a])=>{const n=o.replace(/_/g,"-");t+=`--${n}: ${a}; `}),e?.shadows&&Object.entries(e.shadows).forEach(([o,a])=>{const n=o.replace(/_/g,"-");t+=`--shadow-${n}: ${a}; `}),e?.spacing&&Object.entries(e.spacing).forEach(([o,a])=>{t+=`--spacing-${o}: ${a}px; `}),t},os=e=>$(e).isLight(),Aa=e=>os(e)?"#000000":"#FFFFFF",as=(e,t=500)=>{const r=`--color-${e}-${t}`;if(typeof window<"u"&&window.getComputedStyle){const h=window.getComputedStyle(document.documentElement).getPropertyValue(r).trim();if(h)return h}const o=document.documentElement,a=o.style.getPropertyValue("--color-brand-500")||"#5048ED",n=o.style.getPropertyValue("--color-success-500")||"#10B981",i=o.style.getPropertyValue("--color-error-500")||"#F04438",c=o.style.getPropertyValue("--color-warning-500")||"#F59E0B",d=o.style.getPropertyValue("--color-gray-500")||"#6B7280",l={brand:a,success:n,error:i,warning:c,gray:d};return l[e]?je(l[e])[t]||l[e]:"#5048ED"},Dt=(e={})=>e.baseUrl||"",ns=(e,t={})=>e?e.startsWith("http://")||e.startsWith("https://")?e:pt(e,t):Dt(t),at=()=>{const e=G.useLocation(),{routes:t,apiConfig:r}=Pe(),a=e.pathname.split("/").filter(Boolean)[0],n=[...t].sort((d,l)=>l.path.length-d.path.length);let i=null;for(const d of n){if(d.path===e.pathname){i=d;break}if(d.path?.includes(":")){const l=d.path.replace(/:[^/]+/g,"[^/]+");if(e.pathname.match(new RegExp(`^${l}$`))){i=d;break}}if(e.pathname.startsWith(d.path+"/")){i=d;break}}const c=i?.extra_params||i?.exta_params||{};return{baseUrl:Dt(r),apiUrl:c.api_endpoint||"",fullUrl:ns(c.api_endpoint||"",r),headers:c.headers||{},entity:a,...c}},_a=()=>{const e=G.useLocation(),{routes:t}=Pe(),r=[...t].sort((o,a)=>a.path.length-o.path.length);for(const o of r){if(o.path===e.pathname)return o;if(o.path?.includes(":")){const a=o.path.replace(/:[^/]+/g,"[^/]+");if(e.pathname.match(new RegExp(`^${a}$`)))return o}if(e.pathname.startsWith(o.path+"/"))return o}return null},La=(e,t={},r={})=>({baseUrl:Dt(t),apiUrl:e,fullUrl:ns(e,t),headers:r.headers||{},...r}),is=({basePath:e})=>{const t=at();return s.jsx("div",{className:"page-container",style:{height:"100%"},children:s.jsx(Go.CrudHandler,{api_endpoint:t.apiUrl})})},Ht={crud:{requiredPackage:"@zango-core/crud",component:is},training:{requiredPackage:"@zango-core/training",component:({basePath:e})=>{at();const[t,r]=g.useState(null),[o,a]=g.useState(null);return g.useEffect(()=>{(async()=>{try{const i=await import("@zango-core/training");r(()=>i.TrainingRouter)}catch(i){console.error("Failed to load training module:",i),a("Training module could not be loaded")}})()},[]),o?s.jsx("div",{className:"page-container",style:{height:"100%",padding:"20px"},children:s.jsxs("div",{className:"error-message",children:[s.jsx("h3",{children:"Training Module Error"}),s.jsx("p",{children:o})]})}):t?s.jsx("div",{className:"page-container",style:{height:"100%"},children:s.jsx(t,{})}):s.jsx("div",{className:"page-container",style:{height:"100%",padding:"20px"},children:s.jsx("div",{className:"loading-spinner",children:"Loading training module..."})})}}};Object.fromEntries(Object.entries(Ht).map(([e,t])=>[e,()=>import(t.requiredPackage)])),Object.fromEntries(Object.keys(Ht).map(e=>[e,[e]]));const ls=Object.fromEntries(Object.entries(Ht).map(([e,t])=>[e,t.component])),Ta=e=>e.filter(t=>t in ls),Na=e=>ls[e]||null,cs=({componentName:e,customPagesDir:t="src/custom/pages",fileExtension:r="js"})=>{const[o,a]=g.useState(null),n=(f,x)=>{navigator.clipboard.writeText(f).then(()=>{a(x),setTimeout(()=>a(null),2e3)})},i=e||"MyCustomPage",c=t,d=r,l=`import React from 'react';
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}.collapse{visibility:collapse}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.container{width:100%}.mx-auto{margin-inline:auto}.mb-\\[18px\\]{margin-bottom:18px}.\\!line-clamp-2{-webkit-line-clamp:2!important;-webkit-box-orient:vertical!important;display:-webkit-box!important;overflow:hidden!important}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.h-\\[42px\\]{height:42px}.h-auto{height:auto}.h-full{height:100%}.h-screen{height:100vh}.min-h-\\[8rem\\]{min-height:8rem}.min-h-\\[200px\\]{min-height:200px}.min-h-\\[300px\\]{min-height:300px}.min-h-\\[400px\\]{min-height:400px}.min-h-screen{min-height:100vh}.w-full{width:100%}.max-w-\\[150px\\]{max-width:150px}.flex-1{flex:1}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.\\!rounded-\\[8px\\]{border-radius:8px!important}.rounded-full{border-radius:3.40282e38px}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-none{--tw-border-style:none;border-style:none}.object-cover{object-fit:cover}.\\!text-center{text-align:center!important}.text-center{text-align:center}.text-left{text-align:left}.text-\\[12px\\]{font-size:12px}.text-\\[40px\\]{font-size:40px}.leading-none{--tw-leading:1;line-height:1}.break-all{word-break:break-all}.text-\\[var\\(--color-brand-500\\,\\#5048ED\\)\\]{color:var(--color-brand-500,#5048ed)}.text-\\[var\\(--color-gray-700\\,\\#414651\\)\\]{color:var(--color-gray-700,#414651)}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.underline{text-decoration-line:underline}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.duration-300{--tw-duration:.3s;transition-duration:.3s}.last\\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.focus\\:shadow-\\[0_0_0_2px_rgba\\(106\\,138\\,18\\,0\\.2\\)\\]:focus{--tw-shadow:0 0 0 2px var(--tw-shadow-color,#6a8a1233);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.brand-500{background-color:var(--color-brand-500)!important}.border-brand-500{border-color:var(--color-brand-500)!important}.login-tabs .ant-tabs-tab-active{border-bottom-width:2px!important;border-bottom-color:var(--color-brand-500)!important}.login-tabs .ant-tabs-ink-bar{background-color:var(--color-brand-500)!important}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}.wide-sidebar{width:244px;display:flex;height:100dvh;font-size:14px;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-style:normal;font-weight:500;border-right:1px solid #D5D7DA;flex-direction:column;position:relative;background-color:#fff;z-index:10}.frame-logo-container{height:64px;display:flex;align-items:center;gap:8px;padding:20px}.frame-logo-container a{display:flex;align-items:center;text-decoration:none}.frame-logo-container img{height:28px;width:auto}.frame-menu-container{display:flex;flex-direction:column;gap:16px;flex-grow:1;overflow-y:scroll;padding:8px 12px}#wideSidebarMenu{color:#414651;padding:0;flex-grow:1;display:flex;flex-direction:column;gap:4px;list-style:none;margin:0}#wideSidebarMenu li{list-style:none;padding:12px;border-radius:6px;overflow:hidden;color:#414651;transition:all .3s ease-in-out;cursor:pointer}#wideSidebarMenu .menu-item{display:flex;align-items:center;gap:8px}#wideSidebarMenu li a{display:flex;align-items:center;color:var(--color-gray-700, #414651);text-decoration:none;padding:12px;margin:-12px;width:calc(100% + 24px);gap:8px;font-size:14px;font-weight:500;transition:all .3s ease-in-out}#wideSidebarMenu li:hover,#wideSidebarMenu li.active{background-color:var(--color-brand-50, #EAE8FF);color:var(--color-brand-500, #5048ED)}#wideSidebarMenu li:hover a,#wideSidebarMenu li:hover .menu-title{color:var(--color-brand-500, #5048ED)!important}#wideSidebarMenu li.active{background-color:var(--color-brand-50, #EAE8FF);color:var(--color-brand-500, #5048ED);font-weight:600}#wideSidebarMenu li.active .menu-title,#wideSidebarMenu li.active a{color:var(--color-brand-500, #5048ED)}.navbar-icon{width:16px;height:16px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.navbar-icon svg{width:16px;height:16px}.navbar-icon img{width:16px;height:16px;object-fit:contain}.navbar-icon-emoji{font-size:16px;line-height:1;width:auto;min-width:16px}#wideSidebarMenu .menu-title{flex-grow:1;color:var(--color-gray-700, #414651)}#wideSidebarMenu .menu-list-item{cursor:pointer}#wideSidebarMenu .downIcon{display:flex;justify-content:center;align-items:center;height:100%;transition:transform .3s ease}#wideSidebarMenu li.active .downIcon{transform:rotate(180deg)}#wideSidebarMenu .submenu-accordion-item{color:#414651}#wideSidebarMenu .submenu-list{padding:0;max-height:0;overflow:hidden;opacity:0;list-style:none;margin:0;border-radius:8px;transition:all .3s cubic-bezier(.16,1,.3,1);transform:translateY(-4px)}#wideSidebarMenu .submenu-list.active{padding:9px 0;max-height:500px;opacity:1;transform:translateY(0)}#wideSidebarMenu .submenu-list-item{padding:10px 36px;position:relative;color:var(--color-gray-700, #414651)}#wideSidebarMenu .submenu-list-item a{display:flex;align-items:center;color:inherit;text-decoration:none;padding:10px 36px;margin:-10px -36px;width:calc(100% + 72px);gap:8px;transition:all .3s ease-in-out}#wideSidebarMenu .submenu-list-item a .each-submenu-label{color:var(--color-gray-700, #414651);font-size:12px}#wideSidebarMenu .submenu-list-item a .each-submenu-label.active{color:var(--color-brand-500, #5048ED)}#wideSidebarMenu .submenu-item-icon{display:none}#wideSidebarMenu .submenu-item-icon-container{width:16px}#wideSidebarMenu .submenu-item-icon.active{display:block}.submenu-item-icon-container{width:16px;height:16px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.submenu-dot{display:none}.submenu-dot.active{display:inline-block;width:14px;height:10px}.navbar-menu-container::-webkit-scrollbar{width:4px}.navbar-menu-container::-webkit-scrollbar-track{background:transparent}.navbar-menu-container::-webkit-scrollbar-thumb{background:var(--color-gray-300, #dde2e5);border-radius:2px}.navbar-menu-container::-webkit-scrollbar-thumb:hover{background:var(--color-gray-400, #d5d7da)}@media(max-width:768px){.navbar,.wide-sidebar{position:fixed;left:-244px;z-index:1000}.navbar.open,.wide-sidebar.open{left:0}}.user-profile-drawer{position:fixed;top:0;right:-100%;width:100%;height:100vh;background-color:var(--zango-gray-50, #F9FAFB);transition:right .3s ease-in-out;z-index:1300;overflow:hidden;display:flex;flex-direction:column}.user-profile-drawer *{box-sizing:border-box}.user-profile-drawer.open{right:0}.profile-header-gradient{height:100px;background:linear-gradient(135deg,var(--color-brand-500, #5048ED) 0%,#7C3AED 50%,#EC4899 100%);position:relative}.profile-close-btn{position:absolute;top:16px;right:16px;background:#fff3;border:none;width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s ease;color:#fff}.profile-close-btn:hover{background:#ffffff4d}.profile-info-section{background:#fff;padding:0 40px 20px;text-align:center;position:relative;border-bottom:1px solid var(--zango-gray-300, #E5E7EB);width:100%;box-sizing:border-box}.profile-avatar-container{margin-top:-40px;margin-bottom:12px}.profile-avatar-circle{width:80px;height:80px;background:var(--zango-gray-100, #F3F4F6);border-radius:50%;display:inline-flex;align-items:center;justify-content:center;border:4px solid #FFFFFF;box-shadow:0 4px 6px #0000001a;position:relative}.profile-avatar-circle svg{width:40px;height:40px}.profile-avatar-img{width:100%;height:100%;border-radius:50%;object-fit:cover}.profile-avatar-edit{position:absolute;bottom:-4px;right:-4px;background:var(--color-brand-500, #5048ED);color:#fff;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s ease;border:2px solid white;box-shadow:0 2px 4px #0000001a}.profile-avatar-edit:hover{background:var(--color-brand-600, #433BD9);transform:scale(1.1)}.profile-avatar-edit svg{width:14px;height:14px}.profile-initials{font-size:32px;font-weight:600;color:var(--zango-gray-700, #4B5563)}.profile-name-section{margin-bottom:0}.profile-user-name{font-size:20px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 2px}.profile-user-role{font-size:14px;color:var(--zango-gray-600, #6B7280);margin:0}.profile-user-role-badge{display:inline-flex;align-items:center;gap:6px;background:linear-gradient(135deg,#5048ed1a,#7c3aed1a,#ec48991a);color:var(--color-brand-500, #5048ED);padding:6px 14px;border-radius:20px;font-size:13px;font-weight:500;border:1px solid rgba(80,72,237,.2);margin-top:6px;transition:all .2s ease}.profile-user-role-badge:hover{background:linear-gradient(135deg,#5048ed26,#7c3aed26,#ec489926);border-color:#5048ed4d;transform:translateY(-1px);box-shadow:0 2px 8px #5048ed33}.profile-user-role-badge svg{width:14px;height:14px;stroke:var(--color-brand-500, #5048ED);flex-shrink:0}.profile-user-role-badge span{letter-spacing:.3px;text-transform:capitalize}.profile-main-content{flex:1;overflow-y:auto;overflow-x:hidden;padding:20px;display:flex;justify-content:center;width:100%;box-sizing:border-box}.profile-content-wrapper{background:#fff;border-radius:12px;padding:20px;width:100%;max-width:700px;margin:0 auto;box-shadow:0 1px 3px #0000001a;box-sizing:border-box;height:fit-content}.profile-tabs{display:flex;border-bottom:1px solid var(--zango-gray-300, #E5E7EB);margin-bottom:20px;width:100%;box-sizing:border-box}.profile-tab{padding:10px 20px;background:none;border:none;font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280);cursor:pointer;position:relative;transition:all .2s ease}.profile-tab:hover{color:var(--zango-gray-700, #4B5563)}.profile-tab.active{color:var(--color-brand-500, #5048ED)}.profile-tab.active:after{content:"";position:absolute;bottom:-1px;left:0;right:0;height:2px;background:var(--color-brand-500, #5048ED)}.profile-tab-content{padding:0;width:100%;box-sizing:border-box}.account-section{display:flex;flex-direction:column;gap:24px}.profile-photo-edit:hover{background:var(--color-brand-600, #433BD9)}.profile-field-section{border-bottom:1px solid var(--zango-gray-300, #E5E7EB);padding-bottom:16px}.profile-field-section:last-child{border-bottom:none}.profile-field-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}.profile-field-label{font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280)}.profile-field-value{font-size:16px;color:var(--zango-gray-900, #111827);margin:0;display:flex;align-items:center;gap:8px}.profile-field-value.readonly{color:var(--zango-gray-600, #6B7280)}.profile-field-value .empty-value{color:#9ca3af;font-style:italic}.profile-field-value .field-icon{flex-shrink:0}.profile-field-edit-btn{background:none;border:none;color:var(--color-brand-500, #5048ED);font-size:14px;font-weight:500;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all .2s ease}.profile-field-edit-btn:hover{background:#5048ed1a}.profile-inline-form{width:100%}.profile-inline-actions{display:flex;gap:8px;margin-top:12px;justify-content:flex-end}.profile-save-btn{padding:8px 16px;font-size:14px;font-weight:500;color:#fff;background:var(--color-brand-500, #5048ED);border:none;border-radius:6px;cursor:pointer;transition:all .2s ease}.profile-save-btn:hover{background:var(--color-brand-600, #433BD9)}.profile-save-btn:disabled{opacity:.6;cursor:not-allowed}.roles-list{display:flex;flex-direction:column;gap:8px;margin-top:8px}.role-item{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#f9fafb;border-radius:8px;border:1px solid #E5E7EB;transition:all .2s ease}.role-item:hover{background:var(--zango-gray-100, #F3F4F6);border-color:#d1d5db}.role-item.active{background:#5048ed0d;border-color:var(--color-brand-500, #5048ED)}.role-info{display:flex;align-items:center;gap:10px}.role-info svg{width:16px;height:16px;stroke:#6b7280;flex-shrink:0}.role-item.active .role-info svg{stroke:var(--color-brand-500, #5048ED)}.role-name{font-size:14px;color:#374151;font-weight:500}.role-badge{font-size:12px;font-weight:500;color:var(--color-brand-500, #5048ED);background:#5048ed1a;padding:4px 12px;border-radius:12px}.role-switch-btn{font-size:12px;font-weight:500;color:var(--zango-gray-600, #6B7280);background:#fff;padding:4px 12px;border-radius:6px;border:1px solid #E5E7EB;cursor:pointer;transition:all .2s ease}.role-switch-btn:hover{color:var(--color-brand-500, #5048ED);border-color:var(--color-brand-500, #5048ED);background:#5048ed0d}.security-section{display:flex;flex-direction:column;gap:24px}.security-block{border:1px solid #E5E7EB;border-radius:8px;padding:20px}.security-header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:16px}.security-title{font-size:16px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 4px}.security-subtitle{font-size:14px;color:var(--zango-gray-600, #6B7280);margin:0}.toggle-btn{padding:8px 16px;font-size:14px;font-weight:500;border:1px solid #E5E7EB;border-radius:6px;background:#fff;color:#374151;cursor:pointer;transition:all .2s ease}.toggle-btn:hover{background:#f9fafb}.toggle-btn.enabled{background:var(--color-brand-500, #5048ED);color:#fff;border-color:var(--color-brand-500, #5048ED)}.toggle-btn.enabled:hover{background:var(--color-brand-600, #433BD9)}.password-form{margin-top:16px}.sessions-list{display:flex;flex-direction:column;gap:12px;margin-top:16px}.session-item{display:flex;justify-content:space-between;align-items:center;padding:16px;background:#f9fafb;border-radius:8px;border:1px solid #E5E7EB}.session-info{display:flex;align-items:center;gap:16px;flex:1}.session-device{display:flex;align-items:center;gap:12px}.session-device svg{color:var(--zango-gray-600, #6B7280)}.session-device-header{display:flex;align-items:center;gap:8px;margin-bottom:2px}.session-device-name{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0}.session-status-tag{font-size:11px;font-weight:500;padding:2px 8px;border-radius:12px;text-transform:uppercase;letter-spacing:.5px}.session-status-tag.current{background:#22c55e1a;color:#16a34a;border:1px solid rgba(34,197,94,.2)}.session-status-tag.inactive{background:transparent;padding:0;border:none}.logout-tag-btn{font-size:11px;font-weight:500;padding:2px 8px;border-radius:12px;text-transform:uppercase;letter-spacing:.5px;background:#ef44441a;color:#dc2626;border:1px solid rgba(239,68,68,.2);cursor:pointer;transition:all .2s ease}.logout-tag-btn:hover{background:#ef444426;border-color:#ef44444d}.logout-tag-btn-ghost{background:#9ca3af1a;color:#6b7280;border:1px solid rgba(156,163,175,.2)}.logout-tag-btn-ghost:hover{background:#9ca3af26;border-color:#9ca3af4d;color:#4b5563}.session-details{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.session-time{text-align:right}.session-time-info{display:flex;flex-direction:column;gap:4px;align-items:flex-end}.session-start-time{font-size:12px;color:var(--zango-gray-500, #9CA3AF);margin:0;font-weight:500}.session-last-active{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.session-logout-btn{padding:6px 12px;font-size:12px;font-weight:500;border:1px solid #E5E7EB;border-radius:4px;background:#fff;color:#dc2626;cursor:pointer;transition:all .2s ease}.session-logout-btn:hover{background:#fef2f2;border-color:#dc2626}.session-current{font-size:12px;color:var(--zango-gray-600, #6B7280);font-style:italic}.no-sessions{text-align:center;color:var(--zango-gray-600, #6B7280);font-size:14px;padding:20px}.logout-all-btn{width:100%;padding:12px 20px;font-size:14px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #DC2626;border-radius:8px;cursor:pointer;transition:all .2s ease;margin-top:16px}.logout-all-btn:hover{background:#fef2f2}.tokens-list{margin-top:16px}.token-item{display:flex;align-items:center;justify-content:space-between;padding:16px;background:#f9fafb;border-radius:8px;margin-bottom:12px;transition:all .2s ease}.token-item:hover{background:var(--zango-gray-100, #F3F4F6)}.token-info{display:flex;align-items:center;justify-content:space-between;width:100%;gap:16px}.token-details{display:flex;align-items:center;gap:12px}.token-details svg{color:var(--zango-gray-600, #6B7280)}.token-name{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0 0 4px}.token-created{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.token-revoke-btn{padding:6px 16px;font-size:13px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #FEE2E2;border-radius:6px;cursor:pointer;transition:all .2s ease}.token-revoke-btn:hover{background:#fef2f2;border-color:#fecaca}.no-tokens{text-align:center;padding:32px 16px;color:var(--zango-gray-600, #6B7280)}.no-tokens p{margin:0 0 8px;font-size:14px}.no-tokens-hint{font-size:12px;color:#9ca3af}.profile-form-group{margin-bottom:16px;width:100%;box-sizing:border-box}.profile-form-label{display:block;font-size:14px;font-weight:500;color:#374151;margin-bottom:6px}.profile-form-input{width:100%;padding:10px 14px;font-size:14px;border:1px solid #E5E7EB;border-radius:8px;background:#fff;transition:all .2s ease;box-sizing:border-box}.profile-form-input:focus{outline:none;border-color:var(--color-brand-500, #5048ED);background:#fff;box-shadow:0 0 0 3px #5048ed1a}.profile-form-input::placeholder{color:#9ca3af}.profile-form-error{color:#ef4444;font-size:12px;margin-top:4px}.profile-form-actions{display:flex;gap:12px;margin-top:20px;justify-content:flex-end}.profile-cancel-btn{padding:10px 20px;font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280);background:#fff;border:1px solid #E5E7EB;border-radius:8px;cursor:pointer;transition:all .2s ease}.profile-cancel-btn:hover{background:#f9fafb;color:var(--zango-gray-700, #4B5563)}.profile-submit-btn{padding:10px 20px;font-size:14px;font-weight:600;color:#fff;background:var(--color-brand-500, #5048ED);border:none;border-radius:8px;cursor:pointer;transition:all .2s ease}.profile-submit-btn:hover{background:var(--color-brand-600, #433BD9)}.profile-submit-btn:disabled{opacity:.6;cursor:not-allowed}.profile-alert{padding:12px 16px;border-radius:8px;margin-bottom:20px;font-size:14px;display:flex;align-items:center;gap:8px}.profile-alert.error{background:#fee2e2;color:#dc2626;border:1px solid #FECACA}.profile-alert.success{background:#5048ed1a;color:var(--color-brand-500, #5048ED);border:1px solid rgba(80,72,237,.2)}.password-requirements{background:#f9fafb;border:1px solid #E5E7EB;border-radius:8px;padding:16px;margin:16px 0;width:100%;box-sizing:border-box}.password-requirement{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--zango-gray-600, #6B7280);margin-bottom:8px;transition:color .2s ease}.password-requirement:last-child{margin-bottom:0}.password-requirement svg{flex-shrink:0}.password-requirement svg path{fill:#9ca3af;transition:fill .2s ease}.password-requirement.met{color:var(--color-brand-500, #5048ED)}.password-requirement.met svg path{fill:var(--color-brand-500, #5048ED)}.welcome-banner{background:linear-gradient(135deg,#5048ed0d,#7c3aed0d,#ec48990d);border:1px solid rgba(80,72,237,.2);border-radius:12px;padding:24px;text-align:center;margin-bottom:24px}.welcome-banner svg{margin-bottom:16px}.welcome-banner h3{font-size:18px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 8px}.welcome-banner p{font-size:14px;color:var(--zango-gray-600, #6B7280);max-width:400px;margin:0 auto}.empty-value{color:#9ca3af;font-style:italic;font-weight:400}.field-icon{width:16px;height:16px;flex-shrink:0}.profile-field-section{transition:background .2s ease;padding:0 0 16px}.profile-field-section:hover{background:#00000003}.logout-section{margin-top:20px;padding-top:20px;border-top:1px solid #E5E7EB}.logout-button{width:100%;display:flex;align-items:center;justify-content:center;gap:8px;padding:12px 20px;font-size:14px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #DC2626;border-radius:8px;cursor:pointer;transition:all .2s ease}.logout-button:hover{background:#fef2f2;color:#b91c1c;border-color:#b91c1c}.logout-button svg{width:16px;height:16px;stroke:currentColor}@media(max-width:768px){.profile-main-content{padding:16px}.profile-content-wrapper{padding:16px;max-width:100%}.profile-tabs{margin:0 -16px 20px;padding:0 16px}.profile-tab{flex:1;text-align:center}.session-info{flex-direction:column;align-items:flex-start;gap:8px}.session-item{flex-direction:column;align-items:flex-start;gap:12px}}.password-history-list{margin-top:16px}.password-history-item{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--zango-gray-50, #F9FAFB);border-radius:8px;margin-bottom:12px;transition:all .2s ease}.password-history-item:last-child{margin-bottom:0}.password-history-item:hover{background:var(--zango-gray-100, #F3F4F6)}.history-icon{width:40px;height:40px;background:var(--zango-brand-100, rgba(80, 72, 237, .1));border-radius:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.history-icon svg{color:var(--zango-brand-600, #5048ED)}.history-details{flex:1}.history-text{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0 0 2px}.history-time{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.no-password-history{text-align:center;padding:24px 16px;color:var(--zango-gray-600, #6B7280)}.no-password-history p{margin:0;font-size:14px}.password-disabled-badge{display:inline-block;margin-left:8px;padding:2px 8px;font-size:11px;font-weight:600;color:var(--zango-error-600, #DC2626);background:var(--zango-error-100, #FEE2E2);border-radius:12px;text-transform:uppercase;letter-spacing:.5px}.password-expired{color:var(--zango-error-600, #DC2626);font-weight:600}.token-type{font-size:12px;color:var(--color-brand-500, #5048ED);margin:2px 0 4px;font-weight:500}.token-expiry{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:4px 0 0}.header-container{height:56px;width:100%;background:#fff;justify-content:flex-end;border-bottom:1px solid #E9EAEB;align-items:center;padding:0 20px;display:flex;position:relative}.topbar-content{width:100%;display:flex;justify-content:space-between;align-items:center}.topbar-left,.topbar-right{display:flex;align-items:center;gap:16px}.dropdown{position:relative}.profile-dropdown-menu-button{display:flex;gap:20px;align-items:center;cursor:pointer;padding:8px 12px;border-radius:8px;transition:background-color .2s ease}.profile-dropdown-menu-button:hover{background-color:var(--color-gray-100, #f5f5f5)}.profile-info-wrapper{display:flex;align-items:center;gap:8px}.profile-avatar{width:24px;height:24px;border-radius:50%;overflow:hidden}.profile-name{font-size:14px;font-weight:500;color:var(--color-Gray-900, #252b37)}.dropdown-arrow{transition:transform .2s cubic-bezier(.16,1,.3,1)}.dropdown-arrow.open{transform:rotate(180deg)}.profile-dropdown-menu{border-radius:8px;border:1px solid var(--color-gray-200, #E9EAEB);background:var(--color-background, #FFFFFF);box-shadow:0 12px 12px -4px #0a0d1214,0 -4px 6px -2px #0a0d120f,0 -2px 2px -2px #0a0d120d;min-width:158px;position:absolute;right:0;top:calc(100% + 10px);z-index:1000;list-style:none;margin:0;padding:0;opacity:0;visibility:hidden;transform:translateY(-8px) scale(.95);transition:all .2s cubic-bezier(.16,1,.3,1);overflow:hidden}.profile-dropdown-menu *{cursor:pointer!important}.profile-dropdown-menu.show{opacity:1;visibility:visible;transform:translateY(0) scale(1)}.profile-dropdown-menu li{margin:0}.dropdown-item{display:flex;align-items:center;padding:8px 12px;color:#717680;text-decoration:none;font-size:14px;transition:all .2s ease;cursor:pointer!important;background:none;border:none;width:100%;text-align:left;gap:8px}.dropdown-item:hover{background-color:#f5f5f5;color:#252b37}.profile-dropdown-menu li:first-child .dropdown-item:hover{border-top-left-radius:8px;border-top-right-radius:8px}.profile-dropdown-menu li:last-child .dropdown-item:hover{border-bottom-left-radius:8px;border-bottom-right-radius:8px}.dropdown-item.profile-info{padding:8px 12px;cursor:pointer}.dropdown-item.profile-info:hover{background-color:transparent;cursor:pointer}.dropdown-item.profile-info.clickable:hover{background-color:var(--color-Gray-100, #f5f5f5);cursor:pointer;border-radius:4px}.user-info-content{display:flex;align-items:center;gap:8px;cursor:pointer}.profile-role{font-weight:500;color:var(--color-Gray-900, #252b37)}.role-arrow{display:flex;align-items:center;justify-content:center;transition:transform .2s cubic-bezier(.16,1,.3,1)}.role-arrow.expanded{transform:rotate(180deg)}.profile-roles{max-height:200px;overflow-y:auto;margin:0 -16px;padding:0 16px}.profile-each-role{display:flex;align-items:center;padding:8px 12px;gap:8px;cursor:pointer;transition:all .2s ease}.profile-each-role:hover{background-color:var(--color-Gray-100, #f5f5f5)}.profile-dropdown-menu .profile-each-role:hover{border-radius:4px}.profile-each-role .label{font-size:14px;color:var(--color-Gray-700, #717680)}.profile-dropdown-divider{border:none}.profile-menu-option{display:flex;align-items:center;gap:8px;cursor:pointer}.profile-menu-name,.profile-name{font-size:12px;font-weight:500;cursor:pointer}.flex-row{flex-direction:row!important}.justify-content-between{justify-content:space-between!important}@media(max-width:768px){.topbar{padding:0 16px}.profile-dropdown-menu{right:-16px}}.layout{width:100vw;height:100vh;overflow:hidden}.layout-wrapper{display:flex;height:100vh;background-color:var(--color-background, #ffffff)}.layout-main{display:flex;flex-direction:column;overflow:hidden;transition:width .3s ease;flex:1;position:relative}.layout-content{flex:1;overflow-y:auto;background-color:var(--color-background, #ffffff);position:relative}.layout-content:has(.content-spinner-container.active)>:not(.content-spinner-container){opacity:0;transition:opacity .2s ease-in}.layout-content>:not(.content-spinner-container){opacity:1;transition:opacity .3s ease-in}.layout-loading,.layout-error{display:flex;align-items:center;justify-content:center;height:100vh;font-size:18px;color:var(--color-Gray-700, #717680)}.layout-error{color:var(--color-error-500, #f04438)}@media(max-width:768px){.layout-content{padding:16px}.layout-main{width:100vw!important}}.content-spinner-container{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background-color:#fff;border-radius:18px;z-index:99;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .2s ease-out}.content-spinner-container.active{opacity:1;visibility:visible;pointer-events:all;transition:none}.spinner{width:64px;height:64px;animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.noselect{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.d-flex{display:flex!important}.flex-column{flex-direction:column!important}.flex-grow-1{flex-grow:1!important}.p-0{padding:0!important}.dvh-100{height:100dvh!important}.complete-hidden-scroll-style::-webkit-scrollbar{display:none}.complete-hidden-scroll-style{-ms-overflow-style:none;scrollbar-width:none}.zango-loading{display:flex;align-items:center;justify-content:center;height:100vh;font-size:16px;color:#6d7280}.zango-no-menu{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;padding:2rem;text-align:center;color:#374151}.zango-no-menu h2{font-size:1.5rem;font-weight:600;margin-bottom:.5rem;color:#1f2937}.zango-no-menu p{font-size:1rem;color:#6b7280;margin:0;max-width:400px}*{box-sizing:border-box}body{margin:0;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#root{height:100vh}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
+ (function(B,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("react-router-dom"),require("@zango-core/components"),require("react-dom"),require("@zango-core/crud/table")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-router-dom","@zango-core/components","react-dom","@zango-core/crud/table"],o):(B=typeof globalThis<"u"?globalThis:B||self,o(B.ZangoCRMFramework={},B["react/jsx-runtime"],B.React,B.ReactRouterDOM,B.components,B.ReactDOM,B.table))})(this,(function(B,o,h,K,y,vs,Va){"use strict";function Cs(e){const t=Object.create(null);if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}}return t.default=e,Object.freeze(t)}const T=Cs(h),ja=Cs(vs),Ha="zango_app_logo_cache",za=1440*60*1e3;class Wa{constructor(){this.cacheKey=Ha}getCachedLogo(){try{const t=localStorage.getItem(this.cacheKey);if(!t)return null;const r=JSON.parse(t);return this.isCacheExpired(r.timestamp)?(this.clearCache(),null):r.base64Data&&!r.base64Data.startsWith("data:image/")?(console.warn("Invalid cached logo format, clearing cache"),this.clearCache(),null):r}catch(t){return console.error("Error reading logo cache:",t),null}}async cacheLogoUrl(t,r){if(t)try{const s=await this.generateHash(t),n=this.getCachedLogo();if(n&&n.version===s)return n.timestamp=Date.now(),localStorage.setItem(this.cacheKey,JSON.stringify(n)),n;const a=await this.fetchAndConvertToBase64(t),i={url:t,base64Data:a,version:s,timestamp:Date.now(),appName:r||"Zango CRM"};return localStorage.setItem(this.cacheKey,JSON.stringify(i)),i}catch(s){return console.error("Error caching logo:",s),{url:t,base64Data:null,version:null,timestamp:Date.now(),appName:r||"Zango CRM"}}}async fetchAndConvertToBase64(t){try{if(t.startsWith("data:"))return t.startsWith("data:image/")?t:(console.error("Invalid logo format: data URL must be an image"),null);const r=t.startsWith("http")?t:`${window.location.origin}${t}`,s=await fetch(r);if(!s.ok)throw new Error(`Failed to fetch logo: ${s.status}`);const n=s.headers.get("content-type");if(n&&!n.startsWith("image/"))throw new Error(`Invalid logo content type: ${n}`);const a=await s.blob();return new Promise((i,l)=>{const u=new FileReader;u.onloadend=()=>i(u.result),u.onerror=l,u.readAsDataURL(a)})}catch(r){return console.error("Error converting logo to base64:",r),null}}async generateHash(t){let r=0;for(let s=0;s<t.length;s++){const n=t.charCodeAt(s);r=(r<<5)-r+n,r=r&r}return Math.abs(r).toString(36)}isCacheExpired(t){return Date.now()-t>za}clearCache(){try{localStorage.removeItem(this.cacheKey)}catch(t){console.error("Error clearing logo cache:",t)}}async needsUpdate(t){const r=this.getCachedLogo();return!!(!r||r.url!==t||this.isCacheExpired(r.timestamp))}async updateInBackground(t,r,s){try{if(!await this.needsUpdate(t))return;setTimeout(async()=>{const a=await this.cacheLogoUrl(t,r);a&&s&&s(a)},100)}catch(n){console.error("Error updating logo in background:",n)}}}const tt=new Wa,Ka=()=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"62",height:"20",viewBox:"0 0 62 20",fill:"none",children:[o.jsx("path",{d:"M0 15.5495L0 13.7372L5.34244 6.80918L0.527365 6.80918L0.527365 4.17101L9.53843 4.17101L9.53843 5.96037L4.19599 12.9114L9.69894 12.9114V15.5495L0 15.5495Z",fill:"var(--Colours-Base-black, #000)"}),o.jsx("path",{d:"M16.605 15.8248C15.7949 15.8248 15.0382 15.6948 14.3351 15.4348C13.6319 15.1595 13.0205 14.7695 12.5007 14.2649C11.981 13.7449 11.5759 13.1178 11.2855 12.3837C10.9951 11.6496 10.8499 10.8085 10.8499 9.86027C10.8499 8.94265 11.0027 8.11679 11.3084 7.38269C11.6142 6.6333 12.0116 6.00626 12.5007 5.50156C13.0052 4.98158 13.5784 4.58394 14.2204 4.30865C14.8624 4.03337 15.5274 3.89573 16.2152 3.89573C17.0254 3.89573 17.7285 4.03337 18.3247 4.30865C18.9361 4.58394 19.4406 4.96628 19.838 5.45568C20.2507 5.94508 20.5564 6.52624 20.7552 7.19916C20.9539 7.85679 21.0532 8.5756 21.0532 9.35558C21.0532 9.66145 21.0379 9.95203 21.0074 10.2273C20.9768 10.5026 20.9462 10.7091 20.9157 10.8467L14.1058 10.8467C14.2586 11.6726 14.5949 12.2843 15.1146 12.682C15.6497 13.0643 16.2993 13.2555 17.0636 13.2555C17.8738 13.2555 18.6916 13.0031 19.517 12.4984L20.6405 14.5401C20.0596 14.9378 19.41 15.2513 18.6916 15.4807C17.9884 15.7101 17.2929 15.8248 16.605 15.8248ZM14.0828 8.62148L18.1871 8.62148C18.1871 7.97914 18.0419 7.45916 17.7515 7.06152C17.461 6.66389 16.9719 6.46507 16.284 6.46507C15.749 6.46507 15.2751 6.64094 14.8624 6.9927C14.465 7.34445 14.2051 7.88738 14.0828 8.62148Z",fill:"currentColor"}),o.jsx("path",{d:"M26.4777 15.8248C25.8969 15.8248 25.4077 15.7331 25.0103 15.5495C24.6128 15.366 24.2918 15.1137 24.0472 14.7925C23.818 14.456 23.6498 14.0584 23.5428 13.5996C23.4358 13.1255 23.3823 12.5978 23.3823 12.0167L23.3823 0L26.7529 0L26.7529 12.1543C26.7529 12.5061 26.814 12.7508 26.9363 12.8884C27.0739 13.0261 27.2114 13.0949 27.349 13.0949C27.4254 13.0949 27.4866 13.0949 27.5324 13.0949C27.5936 13.0949 27.67 13.0796 27.7617 13.049L28.1745 15.5495C27.991 15.626 27.7541 15.6872 27.4637 15.7331C27.1885 15.7942 26.8599 15.8248 26.4777 15.8248Z",fill:"currentColor"}),o.jsx("path",{d:"M34.3225 15.8248C33.6193 15.8248 33.0155 15.7178 32.5111 15.5036C32.0219 15.2895 31.6168 14.9913 31.2958 14.609C30.9901 14.2266 30.7608 13.7678 30.608 13.2325C30.4704 12.682 30.4016 12.0779 30.4016 11.4202L30.4016 6.80918L28.8424 6.80918V4.30865L30.585 4.17101L30.9748 1.14286L33.7722 1.14286V4.17101L36.5007 4.17101V6.80918L33.7722 6.80918V11.3743C33.7722 12.0167 33.9021 12.4831 34.162 12.7737C34.4371 13.049 34.7963 13.1867 35.2396 13.1867C35.423 13.1867 35.6065 13.1637 35.7899 13.1178C35.9886 13.0719 36.1644 13.0184 36.3173 12.9572L36.8446 15.4119C36.5389 15.5036 36.1797 15.5954 35.767 15.6872C35.3543 15.7789 34.8727 15.8248 34.3225 15.8248Z",fill:"currentColor"}),o.jsx("path",{d:"M38.7205 15.5495V0L42.0911 0V3.41397L41.9306 5.45568C42.3586 5.07334 42.8554 4.72158 43.4209 4.40042C43.9865 4.06396 44.6591 3.89573 45.4387 3.89573C46.6768 3.89573 47.5711 4.30101 48.1214 5.11157C48.687 5.92214 48.9697 7.04623 48.9697 8.48384V15.5495H45.5992V8.91971C45.5992 8.09385 45.4845 7.52798 45.2553 7.22211C45.0413 6.91623 44.6897 6.7633 44.2005 6.7633C43.7725 6.7633 43.4057 6.8627 43.0999 7.06152C42.7942 7.24505 42.4579 7.51269 42.0911 7.86444V15.5495H38.7205Z",fill:"currentColor"}),o.jsx("path",{d:"M53.0807 20C52.7291 20 52.431 19.9771 52.1864 19.9312C51.9418 19.9006 51.7049 19.8471 51.4756 19.7706L52.0718 17.2013C52.1788 17.2318 52.3011 17.2624 52.4386 17.293C52.5762 17.3236 52.7061 17.3389 52.8284 17.3389C53.394 17.3389 53.8297 17.2013 54.1354 16.926C54.4411 16.6507 54.6704 16.2913 54.8233 15.8478L54.9837 15.2513L50.6043 4.17101L53.9978 4.17101L55.6258 9.05735C55.7939 9.57734 55.9468 10.105 56.0843 10.6402C56.2219 11.1755 56.3671 11.7261 56.52 12.292H56.6117C56.734 11.7567 56.8563 11.2214 56.9786 10.6861C57.1161 10.1356 57.2537 9.59263 57.3913 9.05735L58.767 4.17101H62L58.0562 15.6642C57.7811 16.383 57.4906 17.0101 57.1849 17.5454C56.8945 18.0959 56.5506 18.5471 56.1531 18.8989C55.771 19.2659 55.3277 19.5412 54.8233 19.7247C54.3341 19.9082 53.7532 20 53.0807 20Z",fill:"currentColor"})]}),xs=({logoUrl:e,appName:t,height:r="28px",linkTo:s="/"})=>{const[n,a]=h.useState(()=>{const f=tt.getCachedLogo();return f&&(f.base64Data||f.url)?f.base64Data||f.url:e||null}),[i,l]=h.useState(!1);h.useEffect(()=>{e&&tt.updateInBackground(e,t,f=>{f.base64Data&&a(f.base64Data)})},[e,t]);const u=h.useCallback(()=>{console.error("Logo failed to load"),l(!0);const f=tt.getCachedLogo();f&&n===f.base64Data&&tt.clearCache()},[n]),c=h.useCallback(()=>{l(!1)},[]),d=()=>i||!n?o.jsx(Ka,{}):o.jsx("img",{src:n,height:r,alt:t||"Logo",onError:u,onLoad:c,style:{maxHeight:r,objectFit:"contain"}});return o.jsx(K.Link,{to:s,className:"logo-link",children:d()})},Dt=(e,t={})=>`${t.baseUrl||""}${e}`,Za=(e,t={})=>t.endpoints?.[e]||"",Ga=(e={})=>e.timeout||3e4;function xe(e,t){if(!e)return"/";const[r,s]=e.split("?"),n=r.replace(/\/+$/,"")+"/",a=new URLSearchParams;s&&new URLSearchParams(s).forEach((u,c)=>{a.set(c,u)}),t&&Object.keys(t).length>0&&Object.entries(t).forEach(([l,u])=>{u!=null&&a.set(l,String(u))});const i=a.toString();return i?`${n}?${i}`:n}const xt="";function Ja(e){const t=document.cookie.split("; ");for(const r of t){const[s,n]=r.split("=");if(s===e)return decodeURIComponent(n)}return null}const Pt=async()=>({"X-Csrftoken":Ja("csrftoken")}),Ps=async({fullUrl:e})=>{const t=`${xt}${e}${e.includes("?")?"&":"?"}_t=${Date.now()}`;return await fetch(t,{method:"GET",redirect:"follow",headers:{...await Pt(),"Content-Type":"application/json"}})},Ss=async({fullUrl:e,payload:t})=>await fetch(xt+e,{method:"POST",redirect:"follow",headers:{...await Pt(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),ks=async({fullUrl:e,payload:t})=>await fetch(xt+e,{method:"PUT",redirect:"follow",headers:{...await Pt(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Es=async({fullUrl:e,payload:t})=>await fetch(xt+e,{method:"DELETE",redirect:"follow",headers:{...await Pt(),"Content-Type":"application/json"},body:t instanceof FormData?t:JSON.stringify(t)}),As=async({fullUrl:e,payload:t})=>await fetch(xt+e,{method:"PATCH",redirect:"follow",headers:{...await Pt(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Pe=async e=>{let t;try{const r={message:"Calling API endpoint",data:{endpoint:e.url,method:e.type}},s=Dt(e.url);switch(e.type){case"POST":t=await Ss({fullUrl:s,payload:e.payload});break;case"PUT":t=await ks({fullUrl:s,payload:e.payload});break;case"PATCH":t=await As({fullUrl:s,payload:e.payload});break;case"DELETE":t=await Es({fullUrl:s,payload:e.payload});break;case"GET":default:t=await Ps({fullUrl:s})}if(t.status===200)try{return{response:(await t.json()).response,success:!0,responseStatus:t.status}}catch{return{response:{message:"Server Error"},success:!1,responseStatus:t.status}}else return{response:(await t.json()).response||{message:"Server Error"},success:!1,responseStatus:t.status}}catch(r){return console.error("API Request Error:",r),{response:{message:"Network Error"},success:!1,responseStatus:500}}},Xa=e=>{if(!e||Object.keys(e).length===0)return"";const t=new URLSearchParams;Object.entries(e).forEach(([s,n])=>{n!=null&&t.append(s,String(n))});const r=t.toString();return r?`?${r}`:""},_s=()=>{const t=typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",r=t.startsWith("/")?t:`/${t}`;return{url:xe(r),type:"GET"}},Ns=()=>({url:xe("/api/v1/profile"),type:"GET"}),Ls=e=>({url:xe("/api/v1/profile"),type:"PUT",payload:e}),Ts=e=>({url:xe("/api/v1/profile/photo"),type:"POST",payload:e}),Os=e=>({url:xe("/api/v1/appauth/password/change/"),type:"PUT",payload:e}),Fs=e=>({url:xe("/api/v1/profile/two-factor"),type:"POST",payload:e}),Ms=e=>({url:xe(`/api/v1/appauth/role/switch/?role=${encodeURIComponent(e)}`),type:"POST"}),Is=()=>({url:xe("/api/v1/appauth/sessions/"),type:"GET"}),Us=e=>({url:xe("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:[e]}}),Ds=e=>({url:xe("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:e}}),Bs=()=>({url:xe("/api/v1/appauth/logout"),type:"DELETE"}),$s=()=>({url:xe("/logout"),type:"POST"}),qs=(e,t)=>({url:xe(`${e}${e.includes("?")?"&":"?"}idleFor=${t}`),type:"GET"}),Vs=async()=>Pe(_s()),js=async()=>Pe(Ns()),Hs=async()=>Pe(Is()),Bt=async e=>Pe(Ls(e)),Ya=async e=>Pe(Ts(e)),zs=async e=>Pe(Os(e)),Qa=async e=>Pe(Fs({enabled:e})),Ws=async e=>Pe(Ms(e)),Ks=async e=>Pe(Us(e)),Zs=async e=>Pe(Ds(e)),Gs=async()=>Pe(Bs()),Js=async()=>Pe($s()),Xs=async(e,t)=>Pe(qs(e,t));function $t(e){"@babel/helpers - typeof";return $t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$t(e)}var Ra=/^\s+/,ei=/\s+$/;function z(e,t){if(e=e||"",t=t||{},e instanceof z)return e;if(!(this instanceof z))return new z(e,t);var r=ti(e);this._originalInput=e,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||r.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=r.ok}z.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),r,s,n,a,i,l;return r=t.r/255,s=t.g/255,n=t.b/255,r<=.03928?a=r/12.92:a=Math.pow((r+.055)/1.055,2.4),s<=.03928?i=s/12.92:i=Math.pow((s+.055)/1.055,2.4),n<=.03928?l=n/12.92:l=Math.pow((n+.055)/1.055,2.4),.2126*a+.7152*i+.0722*l},setAlpha:function(t){return this._a=ro(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=Qs(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=Qs(this._r,this._g,this._b),r=Math.round(t.h*360),s=Math.round(t.s*100),n=Math.round(t.v*100);return this._a==1?"hsv("+r+", "+s+"%, "+n+"%)":"hsva("+r+", "+s+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=Ys(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=Ys(this._r,this._g,this._b),r=Math.round(t.h*360),s=Math.round(t.s*100),n=Math.round(t.l*100);return this._a==1?"hsl("+r+", "+s+"%, "+n+"%)":"hsla("+r+", "+s+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return Rs(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return ni(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(le(this._r,255)*100)+"%",g:Math.round(le(this._g,255)*100)+"%",b:Math.round(le(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(le(this._r,255)*100)+"%, "+Math.round(le(this._g,255)*100)+"%, "+Math.round(le(this._b,255)*100)+"%)":"rgba("+Math.round(le(this._r,255)*100)+"%, "+Math.round(le(this._g,255)*100)+"%, "+Math.round(le(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:wi[Rs(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+eo(this._r,this._g,this._b,this._a),s=r,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=z(t);s="#"+eo(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+r+",endColorstr="+s+")"},toString:function(t){var r=!!t;t=t||this._format;var s=!1,n=this._a<1&&this._a>=0,a=!r&&n&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return a?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(s=this.toRgbString()),t==="prgb"&&(s=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(s=this.toHexString()),t==="hex3"&&(s=this.toHexString(!0)),t==="hex4"&&(s=this.toHex8String(!0)),t==="hex8"&&(s=this.toHex8String()),t==="name"&&(s=this.toName()),t==="hsl"&&(s=this.toHslString()),t==="hsv"&&(s=this.toHsvString()),s||this.toHexString())},clone:function(){return z(this.toString())},_applyModification:function(t,r){var s=t.apply(null,[this].concat([].slice.call(r)));return this._r=s._r,this._g=s._g,this._b=s._b,this.setAlpha(s._a),this},lighten:function(){return this._applyModification(ci,arguments)},brighten:function(){return this._applyModification(di,arguments)},darken:function(){return this._applyModification(ui,arguments)},desaturate:function(){return this._applyModification(ai,arguments)},saturate:function(){return this._applyModification(ii,arguments)},greyscale:function(){return this._applyModification(li,arguments)},spin:function(){return this._applyModification(fi,arguments)},_applyCombination:function(t,r){return t.apply(null,[this].concat([].slice.call(r)))},analogous:function(){return this._applyCombination(gi,arguments)},complement:function(){return this._applyCombination(hi,arguments)},monochromatic:function(){return this._applyCombination(mi,arguments)},splitcomplement:function(){return this._applyCombination(pi,arguments)},triad:function(){return this._applyCombination(to,[3])},tetrad:function(){return this._applyCombination(to,[4])}},z.fromRatio=function(e,t){if($t(e)=="object"){var r={};for(var s in e)e.hasOwnProperty(s)&&(s==="a"?r[s]=e[s]:r[s]=St(e[s]));e=r}return z(e,t)};function ti(e){var t={r:0,g:0,b:0},r=1,s=null,n=null,a=null,i=!1,l=!1;return typeof e=="string"&&(e=Ci(e)),$t(e)=="object"&&(ze(e.r)&&ze(e.g)&&ze(e.b)?(t=ri(e.r,e.g,e.b),i=!0,l=String(e.r).substr(-1)==="%"?"prgb":"rgb"):ze(e.h)&&ze(e.s)&&ze(e.v)?(s=St(e.s),n=St(e.v),t=oi(e.h,s,n),i=!0,l="hsv"):ze(e.h)&&ze(e.s)&&ze(e.l)&&(s=St(e.s),a=St(e.l),t=si(e.h,s,a),i=!0,l="hsl"),e.hasOwnProperty("a")&&(r=e.a)),r=ro(r),{ok:i,format:e.format||l,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:r}}function ri(e,t,r){return{r:le(e,255)*255,g:le(t,255)*255,b:le(r,255)*255}}function Ys(e,t,r){e=le(e,255),t=le(t,255),r=le(r,255);var s=Math.max(e,t,r),n=Math.min(e,t,r),a,i,l=(s+n)/2;if(s==n)a=i=0;else{var u=s-n;switch(i=l>.5?u/(2-s-n):u/(s+n),s){case e:a=(t-r)/u+(t<r?6:0);break;case t:a=(r-e)/u+2;break;case r:a=(e-t)/u+4;break}a/=6}return{h:a,s:i,l}}function si(e,t,r){var s,n,a;e=le(e,360),t=le(t,100),r=le(r,100);function i(c,d,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?c+(d-c)*6*f:f<1/2?d:f<2/3?c+(d-c)*(2/3-f)*6:c}if(t===0)s=n=a=r;else{var l=r<.5?r*(1+t):r+t-r*t,u=2*r-l;s=i(u,l,e+1/3),n=i(u,l,e),a=i(u,l,e-1/3)}return{r:s*255,g:n*255,b:a*255}}function Qs(e,t,r){e=le(e,255),t=le(t,255),r=le(r,255);var s=Math.max(e,t,r),n=Math.min(e,t,r),a,i,l=s,u=s-n;if(i=s===0?0:u/s,s==n)a=0;else{switch(s){case e:a=(t-r)/u+(t<r?6:0);break;case t:a=(r-e)/u+2;break;case r:a=(e-t)/u+4;break}a/=6}return{h:a,s:i,v:l}}function oi(e,t,r){e=le(e,360)*6,t=le(t,100),r=le(r,100);var s=Math.floor(e),n=e-s,a=r*(1-t),i=r*(1-n*t),l=r*(1-(1-n)*t),u=s%6,c=[r,i,a,a,l,r][u],d=[l,r,r,i,a,a][u],f=[a,a,l,r,r,i][u];return{r:c*255,g:d*255,b:f*255}}function Rs(e,t,r,s){var n=[Oe(Math.round(e).toString(16)),Oe(Math.round(t).toString(16)),Oe(Math.round(r).toString(16))];return s&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function ni(e,t,r,s,n){var a=[Oe(Math.round(e).toString(16)),Oe(Math.round(t).toString(16)),Oe(Math.round(r).toString(16)),Oe(so(s))];return n&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join("")}function eo(e,t,r,s){var n=[Oe(so(s)),Oe(Math.round(e).toString(16)),Oe(Math.round(t).toString(16)),Oe(Math.round(r).toString(16))];return n.join("")}z.equals=function(e,t){return!e||!t?!1:z(e).toRgbString()==z(t).toRgbString()},z.random=function(){return z.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function ai(e,t){t=t===0?0:t||10;var r=z(e).toHsl();return r.s-=t/100,r.s=qt(r.s),z(r)}function ii(e,t){t=t===0?0:t||10;var r=z(e).toHsl();return r.s+=t/100,r.s=qt(r.s),z(r)}function li(e){return z(e).desaturate(100)}function ci(e,t){t=t===0?0:t||10;var r=z(e).toHsl();return r.l+=t/100,r.l=qt(r.l),z(r)}function di(e,t){t=t===0?0:t||10;var r=z(e).toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(255*-(t/100)))),r.g=Math.max(0,Math.min(255,r.g-Math.round(255*-(t/100)))),r.b=Math.max(0,Math.min(255,r.b-Math.round(255*-(t/100)))),z(r)}function ui(e,t){t=t===0?0:t||10;var r=z(e).toHsl();return r.l-=t/100,r.l=qt(r.l),z(r)}function fi(e,t){var r=z(e).toHsl(),s=(r.h+t)%360;return r.h=s<0?360+s:s,z(r)}function hi(e){var t=z(e).toHsl();return t.h=(t.h+180)%360,z(t)}function to(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var r=z(e).toHsl(),s=[z(e)],n=360/t,a=1;a<t;a++)s.push(z({h:(r.h+a*n)%360,s:r.s,l:r.l}));return s}function pi(e){var t=z(e).toHsl(),r=t.h;return[z(e),z({h:(r+72)%360,s:t.s,l:t.l}),z({h:(r+216)%360,s:t.s,l:t.l})]}function gi(e,t,r){t=t||6,r=r||30;var s=z(e).toHsl(),n=360/r,a=[z(e)];for(s.h=(s.h-(n*t>>1)+720)%360;--t;)s.h=(s.h+n)%360,a.push(z(s));return a}function mi(e,t){t=t||6;for(var r=z(e).toHsv(),s=r.h,n=r.s,a=r.v,i=[],l=1/t;t--;)i.push(z({h:s,s:n,v:a})),a=(a+l)%1;return i}z.mix=function(e,t,r){r=r===0?0:r||50;var s=z(e).toRgb(),n=z(t).toRgb(),a=r/100,i={r:(n.r-s.r)*a+s.r,g:(n.g-s.g)*a+s.g,b:(n.b-s.b)*a+s.b,a:(n.a-s.a)*a+s.a};return z(i)},z.readability=function(e,t){var r=z(e),s=z(t);return(Math.max(r.getLuminance(),s.getLuminance())+.05)/(Math.min(r.getLuminance(),s.getLuminance())+.05)},z.isReadable=function(e,t,r){var s=z.readability(e,t),n,a;switch(a=!1,n=xi(r),n.level+n.size){case"AAsmall":case"AAAlarge":a=s>=4.5;break;case"AAlarge":a=s>=3;break;case"AAAsmall":a=s>=7;break}return a},z.mostReadable=function(e,t,r){var s=null,n=0,a,i,l,u;r=r||{},i=r.includeFallbackColors,l=r.level,u=r.size;for(var c=0;c<t.length;c++)a=z.readability(e,t[c]),a>n&&(n=a,s=z(t[c]));return z.isReadable(e,s,{level:l,size:u})||!i?s:(r.includeFallbackColors=!1,z.mostReadable(e,["#fff","#000"],r))};var Pr=z.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},wi=z.hexNames=yi(Pr);function yi(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r]]=r);return t}function ro(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function le(e,t){bi(e)&&(e="100%");var r=vi(e);return e=Math.min(t,Math.max(0,parseFloat(e))),r&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function qt(e){return Math.min(1,Math.max(0,e))}function Ae(e){return parseInt(e,16)}function bi(e){return typeof e=="string"&&e.indexOf(".")!=-1&&parseFloat(e)===1}function vi(e){return typeof e=="string"&&e.indexOf("%")!=-1}function Oe(e){return e.length==1?"0"+e:""+e}function St(e){return e<=1&&(e=e*100+"%"),e}function so(e){return Math.round(parseFloat(e)*255).toString(16)}function oo(e){return Ae(e)/255}var Fe=(function(){var e="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",r="(?:"+t+")|(?:"+e+")",s="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{CSS_UNIT:new RegExp(r),rgb:new RegExp("rgb"+s),rgba:new RegExp("rgba"+n),hsl:new RegExp("hsl"+s),hsla:new RegExp("hsla"+n),hsv:new RegExp("hsv"+s),hsva:new RegExp("hsva"+n),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function ze(e){return!!Fe.CSS_UNIT.exec(e)}function Ci(e){e=e.replace(Ra,"").replace(ei,"").toLowerCase();var t=!1;if(Pr[e])e=Pr[e],t=!0;else if(e=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=Fe.rgb.exec(e))?{r:r[1],g:r[2],b:r[3]}:(r=Fe.rgba.exec(e))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=Fe.hsl.exec(e))?{h:r[1],s:r[2],l:r[3]}:(r=Fe.hsla.exec(e))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=Fe.hsv.exec(e))?{h:r[1],s:r[2],v:r[3]}:(r=Fe.hsva.exec(e))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=Fe.hex8.exec(e))?{r:Ae(r[1]),g:Ae(r[2]),b:Ae(r[3]),a:oo(r[4]),format:t?"name":"hex8"}:(r=Fe.hex6.exec(e))?{r:Ae(r[1]),g:Ae(r[2]),b:Ae(r[3]),format:t?"name":"hex"}:(r=Fe.hex4.exec(e))?{r:Ae(r[1]+""+r[1]),g:Ae(r[2]+""+r[2]),b:Ae(r[3]+""+r[3]),a:oo(r[4]+""+r[4]),format:t?"name":"hex8"}:(r=Fe.hex3.exec(e))?{r:Ae(r[1]+""+r[1]),g:Ae(r[2]+""+r[2]),b:Ae(r[3]+""+r[3]),format:t?"name":"hex"}:!1}function xi(e){var t,r;return e=e||{level:"AA",size:"small"},t=(e.level||"AA").toUpperCase(),r=(e.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),r!=="small"&&r!=="large"&&(r="small"),{level:t,size:r}}const rt=e=>({25:z.mix(e,"#FFFFFF",95).toHexString(),50:z.mix(e,"#FFFFFF",90).toHexString(),100:z.mix(e,"#FFFFFF",80).toHexString(),200:z.mix(e,"#FFFFFF",65).toHexString(),300:z.mix(e,"#FFFFFF",50).toHexString(),400:z.mix(e,"#FFFFFF",30).toHexString(),500:z(e).toHexString(),600:z.mix(e,"#000000",10).toHexString(),700:z.mix(e,"#000000",20).toHexString(),800:z.mix(e,"#000000",30).toHexString(),900:z.mix(e,"#000000",45).toHexString(),950:z.mix(e,"#000000",60).toHexString()}),Vt=e=>{let t="";const r={brand:rt(e.colors.primary),success:rt(e.colors.success),warning:rt(e.colors.warning),gray:rt(e.colors.gray),error:rt(e.colors.error)};return t=Object.entries(r).map(([s,n])=>Object.entries(n).map(([a,i])=>`--color-${s}-${a}: ${i}`).join(`;
3
+ `)).join(";"),e?.typography&&Object.entries(e.typography).forEach(([s,n])=>{const a=s.replace(/_/g,"-");t+=`--${a}: ${n}; `}),e?.borders&&Object.entries(e.borders).forEach(([s,n])=>{const a=s.replace(/_/g,"-");t+=`--${a}: ${n}; `}),e?.shadows&&Object.entries(e.shadows).forEach(([s,n])=>{const a=s.replace(/_/g,"-");t+=`--shadow-${a}: ${n}; `}),e?.spacing&&Object.entries(e.spacing).forEach(([s,n])=>{t+=`--spacing-${s}: ${n}px; `}),t},no=e=>z(e).isLight(),Pi=e=>no(e)?"#000000":"#FFFFFF",ao=(e,t=500)=>{const r=`--color-${e}-${t}`;if(typeof window<"u"&&window.getComputedStyle){const f=window.getComputedStyle(document.documentElement).getPropertyValue(r).trim();if(f)return f}const s=document.documentElement,n=s.style.getPropertyValue("--color-brand-500")||"#5048ED",a=s.style.getPropertyValue("--color-success-500")||"#10B981",i=s.style.getPropertyValue("--color-error-500")||"#F04438",l=s.style.getPropertyValue("--color-warning-500")||"#F59E0B",u=s.style.getPropertyValue("--color-gray-500")||"#6B7280",c={brand:n,success:a,error:i,warning:l,gray:u};return c[e]?rt(c[e])[t]||c[e]:"#5048ED"},Sr=(e={})=>e.baseUrl||"",io=(e,t={})=>e?e.startsWith("http://")||e.startsWith("https://")?e:Dt(e,t):Sr(t),kt=()=>{const e=K.useLocation(),{routes:t,apiConfig:r}=Ne(),n=e.pathname.split("/").filter(Boolean)[0],a=[...t].sort((u,c)=>c.path.length-u.path.length);let i=null;for(const u of a){if(u.path===e.pathname){i=u;break}if(u.path?.includes(":")){const c=u.path.replace(/:[^/]+/g,"[^/]+");if(e.pathname.match(new RegExp(`^${c}$`))){i=u;break}}if(e.pathname.startsWith(u.path+"/")){i=u;break}}const l=i?.extra_params||i?.exta_params||{};return{baseUrl:Sr(r),apiUrl:l.api_endpoint||"",fullUrl:io(l.api_endpoint||"",r),headers:l.headers||{},entity:n,...l}},Si=()=>{const e=K.useLocation(),{routes:t}=Ne(),r=[...t].sort((s,n)=>n.path.length-s.path.length);for(const s of r){if(s.path===e.pathname)return s;if(s.path?.includes(":")){const n=s.path.replace(/:[^/]+/g,"[^/]+");if(e.pathname.match(new RegExp(`^${n}$`)))return s}if(e.pathname.startsWith(s.path+"/"))return s}return null},ki=(e,t={},r={})=>({baseUrl:Sr(t),apiUrl:e,fullUrl:io(e,t),headers:r.headers||{},...r}),kr=({basePath:e})=>{const t=kt();return o.jsx("div",{className:"page-container",style:{height:"100%"},children:o.jsx(Va.CrudHandler,{api_endpoint:t.apiUrl})})},lo=({basePath:e})=>{kt();const[t,r]=h.useState(null),[s,n]=h.useState(null);return h.useEffect(()=>{(async()=>{try{const i=await import("@zango-core/training");r(()=>i.TrainingRouter)}catch(i){console.error("Failed to load training module:",i),n("Training module could not be loaded")}})()},[]),s?o.jsx("div",{className:"page-container",style:{height:"100%",padding:"20px"},children:o.jsxs("div",{className:"error-message",children:[o.jsx("h3",{children:"Training Module Error"}),o.jsx("p",{children:s})]})}):t?o.jsx("div",{className:"page-container",style:{height:"100%"},children:o.jsx(t,{})}):o.jsx("div",{className:"page-container",style:{height:"100%",padding:"20px"},children:o.jsx("div",{className:"loading-spinner",children:"Loading training module..."})})},Er={crud:{requiredPackage:"@zango-core/crud",component:kr},training:{requiredPackage:"@zango-core/training",component:lo}};Object.fromEntries(Object.entries(Er).map(([e,t])=>[e,()=>import(t.requiredPackage)])),Object.fromEntries(Object.keys(Er).map(e=>[e,[e]]));const co=Object.fromEntries(Object.entries(Er).map(([e,t])=>[e,t.component])),Ei=e=>e.filter(t=>t in co),Ai=e=>co[e]||null,uo=({componentName:e,customPagesDir:t="src/custom/pages",fileExtension:r="js"})=>{const[s,n]=h.useState(null),a=(p,w)=>{navigator.clipboard.writeText(p).then(()=>{n(w),setTimeout(()=>n(null),2e3)})},i=e||"MyCustomPage",l=t,u=r,c=`import React from 'react';
4
4
 
5
5
  const ${i} = () => {
6
6
  return (
@@ -12,9 +12,9 @@ const ${i} = () => {
12
12
  );
13
13
  };
14
14
 
15
- export default ${i};`,u=`// ${c}/index.${d}
15
+ export default ${i};`,d=`// ${l}/index.${u}
16
16
  // Export all custom pages here
17
- export { default as ${i} } from './${i}';`,h=`import React from 'react';
17
+ export { default as ${i} } from './${i}';`,f=`import React from 'react';
18
18
  import { ZangoApp } from '@zango-core/crm-framework';
19
19
  import * as customPages from './custom/pages';
20
20
  import { Toaster } from '@zango-core/components';
@@ -31,87 +31,92 @@ const App = () => {
31
31
  )
32
32
  };
33
33
 
34
- export default App;`,m=`mkdir -p ${c}`,w={container:{padding:"32px",maxWidth:"900px",margin:"0 auto",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},header:{marginBottom:"24px",borderBottom:"2px solid #e5e7eb",paddingBottom:"16px"},title:{fontSize:"28px",fontWeight:"600",color:"#111827",marginBottom:"8px"},subtitle:{fontSize:"16px",color:"#6b7280",marginTop:"8px"},errorBox:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",padding:"16px",marginBottom:"24px"},errorText:{color:"#dc2626",fontWeight:"500",fontSize:"15px"},setupGuide:{backgroundColor:"#f9fafb",borderRadius:"8px",border:"1px solid #e5e7eb",padding:"24px",marginBottom:"24px"},sectionTitle:{fontSize:"20px",fontWeight:"600",color:"#111827",marginBottom:"16px",marginTop:"0"},stepTitle:{fontSize:"16px",fontWeight:"600",color:"#374151",marginBottom:"12px",marginTop:"20px"},stepList:{paddingLeft:"24px",color:"#4b5563",lineHeight:"1.8"},codeBlock:{position:"relative",marginTop:"12px",marginBottom:"20px"},pre:{backgroundColor:"#1f2937",color:"#f9fafb",padding:"16px",borderRadius:"6px",overflow:"auto",fontSize:"14px",lineHeight:"1.6",margin:"0",fontFamily:'"Fira Code", "Cascadia Code", Consolas, Monaco, "Courier New", monospace'},copyButton:{position:"absolute",top:"8px",right:"8px",backgroundColor:"#374151",color:"#f9fafb",border:"none",borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer",fontWeight:"500",transition:"background-color 0.2s"},copiedButton:{backgroundColor:"#10b981"},inlineCode:{backgroundColor:"#f3f4f6",color:"#1f2937",padding:"2px 6px",borderRadius:"3px",fontSize:"14px",fontFamily:"monospace"},note:{backgroundColor:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:"6px",padding:"12px 16px",marginTop:"16px",fontSize:"14px",color:"#1e40af"}};return s.jsxs("div",{style:w.container,children:[s.jsxs("div",{style:w.header,children:[s.jsx("h1",{style:w.title,children:"Custom Page Setup Guide"}),s.jsx("p",{style:w.subtitle,children:"Follow the steps below to create your custom page component"})]}),s.jsxs("div",{style:w.errorBox,children:[s.jsxs("p",{style:w.errorText,children:['⚠️ Custom page component "',i,'" could not be loaded']}),s.jsxs("p",{style:{fontSize:"13px",color:"#991b1b",marginTop:"8px",marginBottom:"0"},children:["Expected location: ",s.jsxs("code",{style:{...w.inlineCode,backgroundColor:"#fee2e2",color:"#991b1b"},children:[c,"/",i,".",d]})]})]}),s.jsxs("div",{style:w.setupGuide,children:[s.jsx("h2",{style:w.sectionTitle,children:"📋 Quick Setup Steps"}),s.jsxs("ol",{style:w.stepList,children:[s.jsx("li",{children:"Create the custom pages directory structure"}),s.jsx("li",{children:"Create your component file with the required code"}),s.jsx("li",{children:"Export your component from the main index file"}),s.jsx("li",{children:"Ensure your App.js imports and passes customPages to ZangoApp"}),s.jsx("li",{children:"Refresh the browser to load your new page"})]}),s.jsx("h3",{style:w.stepTitle,children:"Step 1: Create Directory Structure"}),s.jsx("p",{style:{color:"#4b5563",marginBottom:"12px"},children:"First, ensure the custom pages directory exists. Run this command in your terminal:"}),s.jsxs("div",{style:w.codeBlock,children:[s.jsx("button",{style:{...w.copyButton,...o===0?w.copiedButton:{}},onClick:()=>n(m,0),onMouseEnter:f=>{o!==0&&(f.target.style.backgroundColor="#4b5563")},onMouseLeave:f=>{o!==0&&(f.target.style.backgroundColor="#374151")},children:o===0?"✓ Copied!":"Copy"}),s.jsx("pre",{style:w.pre,children:m})]}),s.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"This creates the directory where all your custom page components will live."}),s.jsx("h3",{style:w.stepTitle,children:"Step 2: Create Your Component File"}),s.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Create a new file at ",s.jsxs("code",{style:w.inlineCode,children:[c,"/",i,".",d]})," and paste this code:"]}),s.jsxs("div",{style:w.codeBlock,children:[s.jsx("button",{style:{...w.copyButton,...o===1?w.copiedButton:{}},onClick:()=>n(l,1),onMouseEnter:f=>{o!==1&&(f.target.style.backgroundColor="#4b5563")},onMouseLeave:f=>{o!==1&&(f.target.style.backgroundColor="#374151")},children:o===1?"✓ Copied!":"Copy"}),s.jsx("pre",{style:w.pre,children:l})]}),s.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"This is a basic React component. You can customize it with your own content, styles, and logic."}),s.jsx("h3",{style:w.stepTitle,children:"Step 3: Export from Main Index File"}),s.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Add your component export to ",s.jsxs("code",{style:w.inlineCode,children:[c,"/index.",d]}),":"]}),s.jsxs("div",{style:w.codeBlock,children:[s.jsx("button",{style:{...w.copyButton,...o===2?w.copiedButton:{}},onClick:()=>n(u,2),onMouseEnter:f=>{o!==2&&(f.target.style.backgroundColor="#4b5563")},onMouseLeave:f=>{o!==2&&(f.target.style.backgroundColor="#374151")},children:o===2?"✓ Copied!":"Copy"}),s.jsx("pre",{style:w.pre,children:u})]}),s.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"The index file exports all custom pages, making them available to the ZangoApp component."}),s.jsx("h3",{style:w.stepTitle,children:"Step 4: Verify App.js Configuration"}),s.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Ensure your ",s.jsx("code",{style:w.inlineCode,children:"App.js"})," imports custom pages and passes them to ",s.jsx("code",{style:w.inlineCode,children:"ZangoApp"}),":"]}),s.jsxs("div",{style:w.codeBlock,children:[s.jsx("button",{style:{...w.copyButton,...o===3?w.copiedButton:{}},onClick:()=>n(h,3),onMouseEnter:f=>{o!==3&&(f.target.style.backgroundColor="#4b5563")},onMouseLeave:f=>{o!==3&&(f.target.style.backgroundColor="#374151")},children:o===3?"✓ Copied!":"Copy"}),s.jsx("pre",{style:w.pre,children:h})]}),s.jsxs("div",{style:{backgroundColor:"#fef3c7",border:"1px solid #fcd34d",borderRadius:"6px",padding:"12px 16px",marginTop:"12px",fontSize:"13px",color:"#92400e"},children:[s.jsx("strong",{children:"⚠️ Important:"})," The ",s.jsx("code",{style:{...w.inlineCode,backgroundColor:"#fde68a",color:"#78350f"},children:"customPages"})," prop is required for ZangoApp to load your custom page components."]}),s.jsx("h3",{style:w.stepTitle,children:"Step 5: Refresh Your Browser"}),s.jsx("p",{style:{color:"#4b5563",marginBottom:"12px"},children:"After saving all files, refresh your browser to load the new component. The custom page should now appear without errors."}),s.jsxs("div",{style:w.note,children:[s.jsx("strong",{children:"💡 Quick Reference:"}),s.jsx("br",{}),s.jsxs("div",{style:{marginTop:"8px",lineHeight:"2"},children:[s.jsx("strong",{children:"Component file:"})," ",s.jsxs("code",{style:{...w.inlineCode,marginLeft:"4px"},children:[c,"/",i,".",d]}),s.jsx("br",{}),s.jsx("strong",{children:"Export name:"})," ",s.jsx("code",{style:{...w.inlineCode,marginLeft:"4px"},children:i}),s.jsx("br",{}),s.jsx("strong",{children:"Index export:"})," ",s.jsxs("code",{style:{...w.inlineCode,marginLeft:"4px"},children:[c,"/index.",d]}),s.jsx("br",{}),s.jsx("strong",{children:"App import:"})," ",s.jsxs("code",{style:{...w.inlineCode,marginLeft:"4px"},children:["import * as customPages from './",c.replace("src/",""),"'"]})]})]})]}),s.jsxs("div",{style:{backgroundColor:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:"8px",padding:"16px",marginTop:"24px"},children:[s.jsx("h3",{style:{margin:"0 0 8px 0",color:"#15803d",fontSize:"16px"},children:"✅ Need Help?"}),s.jsx("p",{style:{margin:"0",color:"#166534",fontSize:"14px"},children:"Make sure the component name matches exactly between the filename, export statement, and route configuration. Check the browser console for any additional error messages."})]})]})},ds=({componentName:e,customPagesDir:t="src/custom/pages",customPagesGlob:r="../../custom/pages/*.js",fileExtension:o="js"})=>{const[a,n]=g.useState(null),[i,c]=g.useState(!1);return g.useEffect(()=>{if(n(null),c(!1),!e){c(!0);return}(async()=>{try{const l=Object.assign({}),u=`../../custom/pages/${e}.${o}`;if(l[u]){const h=await l[u]();n(()=>h.default)}else console.error(`Custom page not found: ${e} at ${u}`),c(!0)}catch(l){console.error("Error loading custom page:",l),c(!0)}})()},[e,o]),i?s.jsx(cs,{componentName:e,customPagesDir:t,fileExtension:o}):a?s.jsx(g.Suspense,{fallback:s.jsx("div",{style:{padding:"24px"},children:"Loading..."}),children:s.jsx(a,{})}):s.jsx("div",{style:{padding:"24px"},children:"Loading custom page..."})},zt=({message:e})=>s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",textAlign:"center",padding:"24px",backgroundColor:"#f5f5f5"},children:s.jsxs("div",{style:{backgroundColor:"white",borderRadius:"12px",padding:"48px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",maxWidth:"500px",width:"100%"},children:[s.jsx("h1",{style:{fontSize:"72px",margin:"0",color:"#e9eaeb",fontWeight:"bold",lineHeight:"1"},children:"404"}),s.jsx("h2",{style:{fontSize:"24px",margin:"16px 0",color:"#252b37",fontWeight:"600"},children:"Page Not Found"}),s.jsx("p",{style:{fontSize:"16px",color:"#717680",marginBottom:"32px",lineHeight:"1.5"},children:e||"The page you are looking for doesn't exist or has been moved."}),s.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[s.jsx("button",{onClick:()=>window.history.back(),style:{padding:"10px 24px",backgroundColor:"#5048ed",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"500",transition:"background-color 0.2s"},onMouseEnter:t=>t.target.style.backgroundColor="#4038d8",onMouseLeave:t=>t.target.style.backgroundColor="#5048ed",children:"Go Back"}),s.jsx("button",{onClick:()=>window.location.href="/",style:{padding:"10px 24px",backgroundColor:"transparent",color:"#5048ed",border:"1px solid #5048ed",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"500",transition:"all 0.2s"},onMouseEnter:t=>{const r=t.target;r.style.backgroundColor="#5048ed",r.style.color="white"},onMouseLeave:t=>{const r=t.target;r.style.backgroundColor="transparent",r.style.color="#5048ed"},children:"Go Home"})]})]})});/**
34
+ export default App;`,m=`mkdir -p ${l}`,g={container:{padding:"32px",maxWidth:"900px",margin:"0 auto",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},header:{marginBottom:"24px",borderBottom:"2px solid #e5e7eb",paddingBottom:"16px"},title:{fontSize:"28px",fontWeight:"600",color:"#111827",marginBottom:"8px"},subtitle:{fontSize:"16px",color:"#6b7280",marginTop:"8px"},errorBox:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",padding:"16px",marginBottom:"24px"},errorText:{color:"#dc2626",fontWeight:"500",fontSize:"15px"},setupGuide:{backgroundColor:"#f9fafb",borderRadius:"8px",border:"1px solid #e5e7eb",padding:"24px",marginBottom:"24px"},sectionTitle:{fontSize:"20px",fontWeight:"600",color:"#111827",marginBottom:"16px",marginTop:"0"},stepTitle:{fontSize:"16px",fontWeight:"600",color:"#374151",marginBottom:"12px",marginTop:"20px"},stepList:{paddingLeft:"24px",color:"#4b5563",lineHeight:"1.8"},codeBlock:{position:"relative",marginTop:"12px",marginBottom:"20px"},pre:{backgroundColor:"#1f2937",color:"#f9fafb",padding:"16px",borderRadius:"6px",overflow:"auto",fontSize:"14px",lineHeight:"1.6",margin:"0",fontFamily:'"Fira Code", "Cascadia Code", Consolas, Monaco, "Courier New", monospace'},copyButton:{position:"absolute",top:"8px",right:"8px",backgroundColor:"#374151",color:"#f9fafb",border:"none",borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer",fontWeight:"500",transition:"background-color 0.2s"},copiedButton:{backgroundColor:"#10b981"},inlineCode:{backgroundColor:"#f3f4f6",color:"#1f2937",padding:"2px 6px",borderRadius:"3px",fontSize:"14px",fontFamily:"monospace"},note:{backgroundColor:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:"6px",padding:"12px 16px",marginTop:"16px",fontSize:"14px",color:"#1e40af"}};return o.jsxs("div",{style:g.container,children:[o.jsxs("div",{style:g.header,children:[o.jsx("h1",{style:g.title,children:"Custom Page Setup Guide"}),o.jsx("p",{style:g.subtitle,children:"Follow the steps below to create your custom page component"})]}),o.jsxs("div",{style:g.errorBox,children:[o.jsxs("p",{style:g.errorText,children:['⚠️ Custom page component "',i,'" could not be loaded']}),o.jsxs("p",{style:{fontSize:"13px",color:"#991b1b",marginTop:"8px",marginBottom:"0"},children:["Expected location: ",o.jsxs("code",{style:{...g.inlineCode,backgroundColor:"#fee2e2",color:"#991b1b"},children:[l,"/",i,".",u]})]})]}),o.jsxs("div",{style:g.setupGuide,children:[o.jsx("h2",{style:g.sectionTitle,children:"📋 Quick Setup Steps"}),o.jsxs("ol",{style:g.stepList,children:[o.jsx("li",{children:"Create the custom pages directory structure"}),o.jsx("li",{children:"Create your component file with the required code"}),o.jsx("li",{children:"Export your component from the main index file"}),o.jsx("li",{children:"Ensure your App.js imports and passes customPages to ZangoApp"}),o.jsx("li",{children:"Refresh the browser to load your new page"})]}),o.jsx("h3",{style:g.stepTitle,children:"Step 1: Create Directory Structure"}),o.jsx("p",{style:{color:"#4b5563",marginBottom:"12px"},children:"First, ensure the custom pages directory exists. Run this command in your terminal:"}),o.jsxs("div",{style:g.codeBlock,children:[o.jsx("button",{style:{...g.copyButton,...s===0?g.copiedButton:{}},onClick:()=>a(m,0),onMouseEnter:p=>{s!==0&&(p.target.style.backgroundColor="#4b5563")},onMouseLeave:p=>{s!==0&&(p.target.style.backgroundColor="#374151")},children:s===0?"✓ Copied!":"Copy"}),o.jsx("pre",{style:g.pre,children:m})]}),o.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"This creates the directory where all your custom page components will live."}),o.jsx("h3",{style:g.stepTitle,children:"Step 2: Create Your Component File"}),o.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Create a new file at ",o.jsxs("code",{style:g.inlineCode,children:[l,"/",i,".",u]})," and paste this code:"]}),o.jsxs("div",{style:g.codeBlock,children:[o.jsx("button",{style:{...g.copyButton,...s===1?g.copiedButton:{}},onClick:()=>a(c,1),onMouseEnter:p=>{s!==1&&(p.target.style.backgroundColor="#4b5563")},onMouseLeave:p=>{s!==1&&(p.target.style.backgroundColor="#374151")},children:s===1?"✓ Copied!":"Copy"}),o.jsx("pre",{style:g.pre,children:c})]}),o.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"This is a basic React component. You can customize it with your own content, styles, and logic."}),o.jsx("h3",{style:g.stepTitle,children:"Step 3: Export from Main Index File"}),o.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Add your component export to ",o.jsxs("code",{style:g.inlineCode,children:[l,"/index.",u]}),":"]}),o.jsxs("div",{style:g.codeBlock,children:[o.jsx("button",{style:{...g.copyButton,...s===2?g.copiedButton:{}},onClick:()=>a(d,2),onMouseEnter:p=>{s!==2&&(p.target.style.backgroundColor="#4b5563")},onMouseLeave:p=>{s!==2&&(p.target.style.backgroundColor="#374151")},children:s===2?"✓ Copied!":"Copy"}),o.jsx("pre",{style:g.pre,children:d})]}),o.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"The index file exports all custom pages, making them available to the ZangoApp component."}),o.jsx("h3",{style:g.stepTitle,children:"Step 4: Verify App.js Configuration"}),o.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Ensure your ",o.jsx("code",{style:g.inlineCode,children:"App.js"})," imports custom pages and passes them to ",o.jsx("code",{style:g.inlineCode,children:"ZangoApp"}),":"]}),o.jsxs("div",{style:g.codeBlock,children:[o.jsx("button",{style:{...g.copyButton,...s===3?g.copiedButton:{}},onClick:()=>a(f,3),onMouseEnter:p=>{s!==3&&(p.target.style.backgroundColor="#4b5563")},onMouseLeave:p=>{s!==3&&(p.target.style.backgroundColor="#374151")},children:s===3?"✓ Copied!":"Copy"}),o.jsx("pre",{style:g.pre,children:f})]}),o.jsxs("div",{style:{backgroundColor:"#fef3c7",border:"1px solid #fcd34d",borderRadius:"6px",padding:"12px 16px",marginTop:"12px",fontSize:"13px",color:"#92400e"},children:[o.jsx("strong",{children:"⚠️ Important:"})," The ",o.jsx("code",{style:{...g.inlineCode,backgroundColor:"#fde68a",color:"#78350f"},children:"customPages"})," prop is required for ZangoApp to load your custom page components."]}),o.jsx("h3",{style:g.stepTitle,children:"Step 5: Refresh Your Browser"}),o.jsx("p",{style:{color:"#4b5563",marginBottom:"12px"},children:"After saving all files, refresh your browser to load the new component. The custom page should now appear without errors."}),o.jsxs("div",{style:g.note,children:[o.jsx("strong",{children:"💡 Quick Reference:"}),o.jsx("br",{}),o.jsxs("div",{style:{marginTop:"8px",lineHeight:"2"},children:[o.jsx("strong",{children:"Component file:"})," ",o.jsxs("code",{style:{...g.inlineCode,marginLeft:"4px"},children:[l,"/",i,".",u]}),o.jsx("br",{}),o.jsx("strong",{children:"Export name:"})," ",o.jsx("code",{style:{...g.inlineCode,marginLeft:"4px"},children:i}),o.jsx("br",{}),o.jsx("strong",{children:"Index export:"})," ",o.jsxs("code",{style:{...g.inlineCode,marginLeft:"4px"},children:[l,"/index.",u]}),o.jsx("br",{}),o.jsx("strong",{children:"App import:"})," ",o.jsxs("code",{style:{...g.inlineCode,marginLeft:"4px"},children:["import * as customPages from './",l.replace("src/",""),"'"]})]})]})]}),o.jsxs("div",{style:{backgroundColor:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:"8px",padding:"16px",marginTop:"24px"},children:[o.jsx("h3",{style:{margin:"0 0 8px 0",color:"#15803d",fontSize:"16px"},children:"✅ Need Help?"}),o.jsx("p",{style:{margin:"0",color:"#166534",fontSize:"14px"},children:"Make sure the component name matches exactly between the filename, export statement, and route configuration. Check the browser console for any additional error messages."})]})]})},Ar=({componentName:e,customPagesDir:t="src/custom/pages",customPagesGlob:r="../../custom/pages/*.js",fileExtension:s="js"})=>{const[n,a]=h.useState(null),[i,l]=h.useState(!1);return h.useEffect(()=>{if(a(null),l(!1),!e){l(!0);return}(async()=>{try{const c=Object.assign({"../../custom/pages/Dashboard.js":()=>Promise.resolve().then(function(){return pf}),"../../custom/pages/index.js":()=>Promise.resolve().then(function(){return gf})}),d=`../../custom/pages/${e}.${s}`;if(c[d]){const f=await c[d]();a(()=>f.default)}else console.error(`Custom page not found: ${e} at ${d}`),l(!0)}catch(c){console.error("Error loading custom page:",c),l(!0)}})()},[e,s]),i?o.jsx(uo,{componentName:e,customPagesDir:t,fileExtension:s}):n?o.jsx(h.Suspense,{fallback:o.jsx("div",{style:{padding:"24px"},children:"Loading..."}),children:o.jsx(n,{})}):o.jsx("div",{style:{padding:"24px"},children:"Loading custom page..."})},Et=({message:e})=>o.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",textAlign:"center",padding:"24px",backgroundColor:"#f5f5f5"},children:o.jsxs("div",{style:{backgroundColor:"white",borderRadius:"12px",padding:"48px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",maxWidth:"500px",width:"100%"},children:[o.jsx("h1",{style:{fontSize:"72px",margin:"0",color:"#e9eaeb",fontWeight:"bold",lineHeight:"1"},children:"404"}),o.jsx("h2",{style:{fontSize:"24px",margin:"16px 0",color:"#252b37",fontWeight:"600"},children:"Page Not Found"}),o.jsx("p",{style:{fontSize:"16px",color:"#717680",marginBottom:"32px",lineHeight:"1.5"},children:e||"The page you are looking for doesn't exist or has been moved."}),o.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[o.jsx("button",{onClick:()=>window.history.back(),style:{padding:"10px 24px",backgroundColor:"#5048ed",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"500",transition:"background-color 0.2s"},onMouseEnter:t=>t.target.style.backgroundColor="#4038d8",onMouseLeave:t=>t.target.style.backgroundColor="#5048ed",children:"Go Back"}),o.jsx("button",{onClick:()=>window.location.href="/",style:{padding:"10px 24px",backgroundColor:"transparent",color:"#5048ed",border:"1px solid #5048ed",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"500",transition:"all 0.2s"},onMouseEnter:t=>{const r=t.target;r.style.backgroundColor="#5048ed",r.style.color="white"},onMouseLeave:t=>{const r=t.target;r.style.backgroundColor="transparent",r.style.color="#5048ed"},children:"Go Home"})]})]})});/**
35
35
  * @license lucide-react v0.544.0 - ISC
36
36
  *
37
37
  * This source code is licensed under the ISC license.
38
38
  * See the LICENSE file in the root directory of this source tree.
39
- */const Ea=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Fa=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,o)=>o?o.toUpperCase():r.toLowerCase()),us=e=>{const t=Fa(e);return t.charAt(0).toUpperCase()+t.slice(1)},hs=(...e)=>e.filter((t,r,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===r).join(" ").trim(),Oa=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
39
+ */const _i=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ni=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,s)=>s?s.toUpperCase():r.toLowerCase()),fo=e=>{const t=Ni(e);return t.charAt(0).toUpperCase()+t.slice(1)},ho=(...e)=>e.filter((t,r,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===r).join(" ").trim(),Li=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
40
40
  * @license lucide-react v0.544.0 - ISC
41
41
  *
42
42
  * This source code is licensed under the ISC license.
43
43
  * See the LICENSE file in the root directory of this source tree.
44
- */var Ma={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
44
+ */var Ti={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
45
45
  * @license lucide-react v0.544.0 - ISC
46
46
  *
47
47
  * This source code is licensed under the ISC license.
48
48
  * See the LICENSE file in the root directory of this source tree.
49
- */const Ua=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:a="",children:n,iconNode:i,...c},d)=>g.createElement("svg",{ref:d,...Ma,width:t,height:t,stroke:e,strokeWidth:o?Number(r)*24/Number(t):r,className:hs("lucide",a),...!n&&!Oa(c)&&{"aria-hidden":"true"},...c},[...i.map(([l,u])=>g.createElement(l,u)),...Array.isArray(n)?n:[n]]));/**
49
+ */const Oi=h.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:n="",children:a,iconNode:i,...l},u)=>h.createElement("svg",{ref:u,...Ti,width:t,height:t,stroke:e,strokeWidth:s?Number(r)*24/Number(t):r,className:ho("lucide",n),...!a&&!Li(l)&&{"aria-hidden":"true"},...l},[...i.map(([c,d])=>h.createElement(c,d)),...Array.isArray(a)?a:[a]]));/**
50
50
  * @license lucide-react v0.544.0 - ISC
51
51
  *
52
52
  * This source code is licensed under the ISC license.
53
53
  * See the LICENSE file in the root directory of this source tree.
54
- */const Ae=(e,t)=>{const r=g.forwardRef(({className:o,...a},n)=>g.createElement(Ua,{ref:n,iconNode:t,className:hs(`lucide-${Ea(us(e))}`,`lucide-${e}`,o),...a}));return r.displayName=us(e),r};/**
54
+ */const Le=(e,t)=>{const r=h.forwardRef(({className:s,...n},a)=>h.createElement(Oi,{ref:a,iconNode:t,className:ho(`lucide-${_i(fo(e))}`,`lucide-${e}`,s),...n}));return r.displayName=fo(e),r};/**
55
55
  * @license lucide-react v0.544.0 - ISC
56
56
  *
57
57
  * This source code is licensed under the ISC license.
58
58
  * See the LICENSE file in the root directory of this source tree.
59
- */const Wt=Ae("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
59
+ */const ut=Le("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
60
60
  * @license lucide-react v0.544.0 - ISC
61
61
  *
62
62
  * This source code is licensed under the ISC license.
63
63
  * See the LICENSE file in the root directory of this source tree.
64
- */const Oe=Ae("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
64
+ */const Ze=Le("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
65
65
  * @license lucide-react v0.544.0 - ISC
66
66
  *
67
67
  * This source code is licensed under the ISC license.
68
68
  * See the LICENSE file in the root directory of this source tree.
69
- */const Ba=Ae("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/**
69
+ */const Fi=Le("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/**
70
70
  * @license lucide-react v0.544.0 - ISC
71
71
  *
72
72
  * This source code is licensed under the ISC license.
73
73
  * See the LICENSE file in the root directory of this source tree.
74
- */const qa=Ae("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
74
+ */const Mi=Le("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
75
75
  * @license lucide-react v0.544.0 - ISC
76
76
  *
77
77
  * This source code is licensed under the ISC license.
78
78
  * See the LICENSE file in the root directory of this source tree.
79
- */const bt=Ae("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
79
+ */const Ii=Le("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]);/**
80
80
  * @license lucide-react v0.544.0 - ISC
81
81
  *
82
82
  * This source code is licensed under the ISC license.
83
83
  * See the LICENSE file in the root directory of this source tree.
84
- */const Ct=Ae("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);/**
84
+ */const jt=Le("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
85
85
  * @license lucide-react v0.544.0 - ISC
86
86
  *
87
87
  * This source code is licensed under the ISC license.
88
88
  * See the LICENSE file in the root directory of this source tree.
89
- */const Ia=Ae("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);/**
89
+ */const Ht=Le("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);/**
90
90
  * @license lucide-react v0.544.0 - ISC
91
91
  *
92
92
  * This source code is licensed under the ISC license.
93
93
  * See the LICENSE file in the root directory of this source tree.
94
- */const fs=Ae("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
94
+ */const Ui=Le("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);/**
95
95
  * @license lucide-react v0.544.0 - ISC
96
96
  *
97
97
  * This source code is licensed under the ISC license.
98
98
  * See the LICENSE file in the root directory of this source tree.
99
- */const Zt=Ae("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
99
+ */const po=Le("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
100
100
  * @license lucide-react v0.544.0 - ISC
101
101
  *
102
102
  * This source code is licensed under the ISC license.
103
103
  * See the LICENSE file in the root directory of this source tree.
104
- */const Gt=Ae("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
104
+ */const _r=Le("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
105
105
  * @license lucide-react v0.544.0 - ISC
106
106
  *
107
107
  * This source code is licensed under the ISC license.
108
108
  * See the LICENSE file in the root directory of this source tree.
109
- */const $a=Ae("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);function ps(e,t){return function(){return e.apply(t,arguments)}}const{toString:Va}=Object.prototype,{getPrototypeOf:Kt}=Object,{iterator:vt,toStringTag:gs}=Symbol,xt=(e=>t=>{const r=Va.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),_e=e=>(e=e.toLowerCase(),t=>xt(t)===e),Pt=e=>t=>typeof t===e,{isArray:Ke}=Array,Je=Pt("undefined");function nt(e){return e!==null&&!Je(e)&&e.constructor!==null&&!Je(e.constructor)&&ye(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ms=_e("ArrayBuffer");function ja(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ms(e.buffer),t}const Da=Pt("string"),ye=Pt("function"),ws=Pt("number"),it=e=>e!==null&&typeof e=="object",Ha=e=>e===!0||e===!1,St=e=>{if(xt(e)!=="object")return!1;const t=Kt(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(gs in e)&&!(vt in e)},za=e=>{if(!it(e)||nt(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Wa=_e("Date"),Za=_e("File"),Ga=_e("Blob"),Ka=_e("FileList"),Ja=e=>it(e)&&ye(e.pipe),Xa=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||ye(e.append)&&((t=xt(e))==="formdata"||t==="object"&&ye(e.toString)&&e.toString()==="[object FormData]"))},Qa=_e("URLSearchParams"),[Ya,Ra,en,tn]=["ReadableStream","Request","Response","Headers"].map(_e),rn=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function lt(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let o,a;if(typeof e!="object"&&(e=[e]),Ke(e))for(o=0,a=e.length;o<a;o++)t.call(null,e[o],o,e);else{if(nt(e))return;const n=r?Object.getOwnPropertyNames(e):Object.keys(e),i=n.length;let c;for(o=0;o<i;o++)c=n[o],t.call(null,e[c],c,e)}}function ys(e,t){if(nt(e))return null;t=t.toLowerCase();const r=Object.keys(e);let o=r.length,a;for(;o-- >0;)if(a=r[o],t===a.toLowerCase())return a;return null}const De=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,bs=e=>!Je(e)&&e!==De;function Jt(){const{caseless:e,skipUndefined:t}=bs(this)&&this||{},r={},o=(a,n)=>{const i=e&&ys(r,n)||n;St(r[i])&&St(a)?r[i]=Jt(r[i],a):St(a)?r[i]=Jt({},a):Ke(a)?r[i]=a.slice():(!t||!Je(a))&&(r[i]=a)};for(let a=0,n=arguments.length;a<n;a++)arguments[a]&&lt(arguments[a],o);return r}const sn=(e,t,r,{allOwnKeys:o}={})=>(lt(t,(a,n)=>{r&&ye(a)?e[n]=ps(a,r):e[n]=a},{allOwnKeys:o}),e),on=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),an=(e,t,r,o)=>{e.prototype=Object.create(t.prototype,o),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},nn=(e,t,r,o)=>{let a,n,i;const c={};if(t=t||{},e==null)return t;do{for(a=Object.getOwnPropertyNames(e),n=a.length;n-- >0;)i=a[n],(!o||o(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=r!==!1&&Kt(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},ln=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const o=e.indexOf(t,r);return o!==-1&&o===r},cn=e=>{if(!e)return null;if(Ke(e))return e;let t=e.length;if(!ws(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},dn=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Kt(Uint8Array)),un=(e,t)=>{const o=(e&&e[vt]).call(e);let a;for(;(a=o.next())&&!a.done;){const n=a.value;t.call(e,n[0],n[1])}},hn=(e,t)=>{let r;const o=[];for(;(r=e.exec(t))!==null;)o.push(r);return o},fn=_e("HTMLFormElement"),pn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,o,a){return o.toUpperCase()+a}),Cs=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),gn=_e("RegExp"),vs=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),o={};lt(r,(a,n)=>{let i;(i=t(a,n,e))!==!1&&(o[n]=i||a)}),Object.defineProperties(e,o)},mn=e=>{vs(e,(t,r)=>{if(ye(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const o=e[r];if(ye(o)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},wn=(e,t)=>{const r={},o=a=>{a.forEach(n=>{r[n]=!0})};return Ke(e)?o(e):o(String(e).split(t)),r},yn=()=>{},bn=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Cn(e){return!!(e&&ye(e.append)&&e[gs]==="FormData"&&e[vt])}const vn=e=>{const t=new Array(10),r=(o,a)=>{if(it(o)){if(t.indexOf(o)>=0)return;if(nt(o))return o;if(!("toJSON"in o)){t[a]=o;const n=Ke(o)?[]:{};return lt(o,(i,c)=>{const d=r(i,a+1);!Je(d)&&(n[c]=d)}),t[a]=void 0,n}}return o};return r(e,0)},xn=_e("AsyncFunction"),Pn=e=>e&&(it(e)||ye(e))&&ye(e.then)&&ye(e.catch),xs=((e,t)=>e?setImmediate:t?((r,o)=>(De.addEventListener("message",({source:a,data:n})=>{a===De&&n===r&&o.length&&o.shift()()},!1),a=>{o.push(a),De.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",ye(De.postMessage)),Sn=typeof queueMicrotask<"u"?queueMicrotask.bind(De):typeof process<"u"&&process.nextTick||xs,b={isArray:Ke,isArrayBuffer:ms,isBuffer:nt,isFormData:Xa,isArrayBufferView:ja,isString:Da,isNumber:ws,isBoolean:Ha,isObject:it,isPlainObject:St,isEmptyObject:za,isReadableStream:Ya,isRequest:Ra,isResponse:en,isHeaders:tn,isUndefined:Je,isDate:Wa,isFile:Za,isBlob:Ga,isRegExp:gn,isFunction:ye,isStream:Ja,isURLSearchParams:Qa,isTypedArray:dn,isFileList:Ka,forEach:lt,merge:Jt,extend:sn,trim:rn,stripBOM:on,inherits:an,toFlatObject:nn,kindOf:xt,kindOfTest:_e,endsWith:ln,toArray:cn,forEachEntry:un,matchAll:hn,isHTMLForm:fn,hasOwnProperty:Cs,hasOwnProp:Cs,reduceDescriptors:vs,freezeMethods:mn,toObjectSet:wn,toCamelCase:pn,noop:yn,toFiniteNumber:bn,findKey:ys,global:De,isContextDefined:bs,isSpecCompliantForm:Cn,toJSONObject:vn,isAsyncFn:xn,isThenable:Pn,setImmediate:xs,asap:Sn,isIterable:e=>e!=null&&ye(e[vt])};function Y(e,t,r,o,a){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),r&&(this.config=r),o&&(this.request=o),a&&(this.response=a,this.status=a.status?a.status:null)}b.inherits(Y,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:b.toJSONObject(this.config),code:this.code,status:this.status}}});const Ps=Y.prototype,Ss={};["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=>{Ss[e]={value:e}}),Object.defineProperties(Y,Ss),Object.defineProperty(Ps,"isAxiosError",{value:!0}),Y.from=(e,t,r,o,a,n)=>{const i=Object.create(Ps);b.toFlatObject(e,i,function(u){return u!==Error.prototype},l=>l!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return Y.call(i,c,d,r,o,a),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",n&&Object.assign(i,n),i};const kn=null;function Xt(e){return b.isPlainObject(e)||b.isArray(e)}function ks(e){return b.endsWith(e,"[]")?e.slice(0,-2):e}function As(e,t,r){return e?e.concat(t).map(function(a,n){return a=ks(a),!r&&n?"["+a+"]":a}).join(r?".":""):t}function An(e){return b.isArray(e)&&!e.some(Xt)}const _n=b.toFlatObject(b,{},null,function(t){return/^is[A-Z]/.test(t)});function kt(e,t,r){if(!b.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=b.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,y){return!b.isUndefined(y[x])});const o=r.metaTokens,a=r.visitor||u,n=r.dots,i=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&b.isSpecCompliantForm(t);if(!b.isFunction(a))throw new TypeError("visitor must be a function");function l(f){if(f===null)return"";if(b.isDate(f))return f.toISOString();if(b.isBoolean(f))return f.toString();if(!d&&b.isBlob(f))throw new Y("Blob is not supported. Use a Buffer instead.");return b.isArrayBuffer(f)||b.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function u(f,x,y){let P=f;if(f&&!y&&typeof f=="object"){if(b.endsWith(x,"{}"))x=o?x:x.slice(0,-2),f=JSON.stringify(f);else if(b.isArray(f)&&An(f)||(b.isFileList(f)||b.endsWith(x,"[]"))&&(P=b.toArray(f)))return x=ks(x),P.forEach(function(B,N){!(b.isUndefined(B)||B===null)&&t.append(i===!0?As([x],N,n):i===null?x:x+"[]",l(B))}),!1}return Xt(f)?!0:(t.append(As(y,x,n),l(f)),!1)}const h=[],m=Object.assign(_n,{defaultVisitor:u,convertValue:l,isVisitable:Xt});function w(f,x){if(!b.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+x.join("."));h.push(f),b.forEach(f,function(P,A){(!(b.isUndefined(P)||P===null)&&a.call(t,P,b.isString(A)?A.trim():A,x,m))===!0&&w(P,x?x.concat(A):[A])}),h.pop()}}if(!b.isObject(e))throw new TypeError("data must be an object");return w(e),t}function _s(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(o){return t[o]})}function Qt(e,t){this._pairs=[],e&&kt(e,this,t)}const Ls=Qt.prototype;Ls.append=function(t,r){this._pairs.push([t,r])},Ls.toString=function(t){const r=t?function(o){return t.call(this,o,_s)}:_s;return this._pairs.map(function(a){return r(a[0])+"="+r(a[1])},"").join("&")};function Ln(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ts(e,t,r){if(!t)return e;const o=r&&r.encode||Ln;b.isFunction(r)&&(r={serialize:r});const a=r&&r.serialize;let n;if(a?n=a(t,r):n=b.isURLSearchParams(t)?t.toString():new Qt(t,r).toString(o),n){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+n}return e}class Ns{constructor(){this.handlers=[]}use(t,r,o){return this.handlers.push({fulfilled:t,rejected:r,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){b.forEach(this.handlers,function(o){o!==null&&t(o)})}}const Es={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Tn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Qt,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Yt=typeof window<"u"&&typeof document<"u",Rt=typeof navigator=="object"&&navigator||void 0,Nn=Yt&&(!Rt||["ReactNative","NativeScript","NS"].indexOf(Rt.product)<0),En=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Fn=Yt&&window.location.href||"http://localhost",de={...Object.freeze({__proto__:null,hasBrowserEnv:Yt,hasStandardBrowserEnv:Nn,hasStandardBrowserWebWorkerEnv:En,navigator:Rt,origin:Fn}),...Tn};function On(e,t){return kt(e,new de.classes.URLSearchParams,{visitor:function(r,o,a,n){return de.isNode&&b.isBuffer(r)?(this.append(o,r.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}function Mn(e){return b.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Un(e){const t={},r=Object.keys(e);let o;const a=r.length;let n;for(o=0;o<a;o++)n=r[o],t[n]=e[n];return t}function Fs(e){function t(r,o,a,n){let i=r[n++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=n>=r.length;return i=!i&&b.isArray(a)?a.length:i,d?(b.hasOwnProp(a,i)?a[i]=[a[i],o]:a[i]=o,!c):((!a[i]||!b.isObject(a[i]))&&(a[i]=[]),t(r,o,a[i],n)&&b.isArray(a[i])&&(a[i]=Un(a[i])),!c)}if(b.isFormData(e)&&b.isFunction(e.entries)){const r={};return b.forEachEntry(e,(o,a)=>{t(Mn(o),a,r,0)}),r}return null}function Bn(e,t,r){if(b.isString(e))try{return(t||JSON.parse)(e),b.trim(e)}catch(o){if(o.name!=="SyntaxError")throw o}return(r||JSON.stringify)(e)}const ct={transitional:Es,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const o=r.getContentType()||"",a=o.indexOf("application/json")>-1,n=b.isObject(t);if(n&&b.isHTMLForm(t)&&(t=new FormData(t)),b.isFormData(t))return a?JSON.stringify(Fs(t)):t;if(b.isArrayBuffer(t)||b.isBuffer(t)||b.isStream(t)||b.isFile(t)||b.isBlob(t)||b.isReadableStream(t))return t;if(b.isArrayBufferView(t))return t.buffer;if(b.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(n){if(o.indexOf("application/x-www-form-urlencoded")>-1)return On(t,this.formSerializer).toString();if((c=b.isFileList(t))||o.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return kt(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return n||a?(r.setContentType("application/json",!1),Bn(t)):t}],transformResponse:[function(t){const r=this.transitional||ct.transitional,o=r&&r.forcedJSONParsing,a=this.responseType==="json";if(b.isResponse(t)||b.isReadableStream(t))return t;if(t&&b.isString(t)&&(o&&!this.responseType||a)){const i=!(r&&r.silentJSONParsing)&&a;try{return JSON.parse(t,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?Y.from(c,Y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:de.classes.FormData,Blob:de.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};b.forEach(["delete","get","head","post","put","patch"],e=>{ct.headers[e]={}});const qn=b.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"]),In=e=>{const t={};let r,o,a;return e&&e.split(`
110
- `).forEach(function(i){a=i.indexOf(":"),r=i.substring(0,a).trim().toLowerCase(),o=i.substring(a+1).trim(),!(!r||t[r]&&qn[r])&&(r==="set-cookie"?t[r]?t[r].push(o):t[r]=[o]:t[r]=t[r]?t[r]+", "+o:o)}),t},Os=Symbol("internals");function dt(e){return e&&String(e).trim().toLowerCase()}function At(e){return e===!1||e==null?e:b.isArray(e)?e.map(At):String(e)}function $n(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=r.exec(e);)t[o[1]]=o[2];return t}const Vn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function er(e,t,r,o,a){if(b.isFunction(o))return o.call(this,t,r);if(a&&(t=r),!!b.isString(t)){if(b.isString(o))return t.indexOf(o)!==-1;if(b.isRegExp(o))return o.test(t)}}function jn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,o)=>r.toUpperCase()+o)}function Dn(e,t){const r=b.toCamelCase(" "+t);["get","set","has"].forEach(o=>{Object.defineProperty(e,o+r,{value:function(a,n,i){return this[o].call(this,t,a,n,i)},configurable:!0})})}let be=class{constructor(t){t&&this.set(t)}set(t,r,o){const a=this;function n(c,d,l){const u=dt(d);if(!u)throw new Error("header name must be a non-empty string");const h=b.findKey(a,u);(!h||a[h]===void 0||l===!0||l===void 0&&a[h]!==!1)&&(a[h||d]=At(c))}const i=(c,d)=>b.forEach(c,(l,u)=>n(l,u,d));if(b.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(b.isString(t)&&(t=t.trim())&&!Vn(t))i(In(t),r);else if(b.isObject(t)&&b.isIterable(t)){let c={},d,l;for(const u of t){if(!b.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[l=u[0]]=(d=c[l])?b.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}i(c,r)}else t!=null&&n(r,t,o);return this}get(t,r){if(t=dt(t),t){const o=b.findKey(this,t);if(o){const a=this[o];if(!r)return a;if(r===!0)return $n(a);if(b.isFunction(r))return r.call(this,a,o);if(b.isRegExp(r))return r.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=dt(t),t){const o=b.findKey(this,t);return!!(o&&this[o]!==void 0&&(!r||er(this,this[o],o,r)))}return!1}delete(t,r){const o=this;let a=!1;function n(i){if(i=dt(i),i){const c=b.findKey(o,i);c&&(!r||er(o,o[c],c,r))&&(delete o[c],a=!0)}}return b.isArray(t)?t.forEach(n):n(t),a}clear(t){const r=Object.keys(this);let o=r.length,a=!1;for(;o--;){const n=r[o];(!t||er(this,this[n],n,t,!0))&&(delete this[n],a=!0)}return a}normalize(t){const r=this,o={};return b.forEach(this,(a,n)=>{const i=b.findKey(o,n);if(i){r[i]=At(a),delete r[n];return}const c=t?jn(n):String(n).trim();c!==n&&delete r[n],r[c]=At(a),o[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return b.forEach(this,(o,a)=>{o!=null&&o!==!1&&(r[a]=t&&b.isArray(o)?o.join(", "):o)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
111
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const o=new this(t);return r.forEach(a=>o.set(a)),o}static accessor(t){const o=(this[Os]=this[Os]={accessors:{}}).accessors,a=this.prototype;function n(i){const c=dt(i);o[c]||(Dn(a,i),o[c]=!0)}return b.isArray(t)?t.forEach(n):n(t),this}};be.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),b.reduceDescriptors(be.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(o){this[r]=o}}}),b.freezeMethods(be);function tr(e,t){const r=this||ct,o=t||r,a=be.from(o.headers);let n=o.data;return b.forEach(e,function(c){n=c.call(r,n,a.normalize(),t?t.status:void 0)}),a.normalize(),n}function Ms(e){return!!(e&&e.__CANCEL__)}function Xe(e,t,r){Y.call(this,e??"canceled",Y.ERR_CANCELED,t,r),this.name="CanceledError"}b.inherits(Xe,Y,{__CANCEL__:!0});function Us(e,t,r){const o=r.config.validateStatus;!r.status||!o||o(r.status)?e(r):t(new Y("Request failed with status code "+r.status,[Y.ERR_BAD_REQUEST,Y.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Hn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function zn(e,t){e=e||10;const r=new Array(e),o=new Array(e);let a=0,n=0,i;return t=t!==void 0?t:1e3,function(d){const l=Date.now(),u=o[n];i||(i=l),r[a]=d,o[a]=l;let h=n,m=0;for(;h!==a;)m+=r[h++],h=h%e;if(a=(a+1)%e,a===n&&(n=(n+1)%e),l-i<t)return;const w=u&&l-u;return w?Math.round(m*1e3/w):void 0}}function Wn(e,t){let r=0,o=1e3/t,a,n;const i=(l,u=Date.now())=>{r=u,a=null,n&&(clearTimeout(n),n=null),e(...l)};return[(...l)=>{const u=Date.now(),h=u-r;h>=o?i(l,u):(a=l,n||(n=setTimeout(()=>{n=null,i(a)},o-h)))},()=>a&&i(a)]}const _t=(e,t,r=3)=>{let o=0;const a=zn(50,250);return Wn(n=>{const i=n.loaded,c=n.lengthComputable?n.total:void 0,d=i-o,l=a(d),u=i<=c;o=i;const h={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:l||void 0,estimated:l&&c&&u?(c-i)/l:void 0,event:n,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(h)},r)},Bs=(e,t)=>{const r=e!=null;return[o=>t[0]({lengthComputable:r,total:e,loaded:o}),t[1]]},qs=e=>(...t)=>b.asap(()=>e(...t)),Zn=de.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,de.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(de.origin),de.navigator&&/(msie|trident)/i.test(de.navigator.userAgent)):()=>!0,Gn=de.hasStandardBrowserEnv?{write(e,t,r,o,a,n,i){if(typeof document>"u")return;const c=[`${e}=${encodeURIComponent(t)}`];b.isNumber(r)&&c.push(`expires=${new Date(r).toUTCString()}`),b.isString(o)&&c.push(`path=${o}`),b.isString(a)&&c.push(`domain=${a}`),n===!0&&c.push("secure"),b.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Kn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Jn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Is(e,t,r){let o=!Kn(t);return e&&(o||r==!1)?Jn(e,t):t}const $s=e=>e instanceof be?{...e}:e;function He(e,t){t=t||{};const r={};function o(l,u,h,m){return b.isPlainObject(l)&&b.isPlainObject(u)?b.merge.call({caseless:m},l,u):b.isPlainObject(u)?b.merge({},u):b.isArray(u)?u.slice():u}function a(l,u,h,m){if(b.isUndefined(u)){if(!b.isUndefined(l))return o(void 0,l,h,m)}else return o(l,u,h,m)}function n(l,u){if(!b.isUndefined(u))return o(void 0,u)}function i(l,u){if(b.isUndefined(u)){if(!b.isUndefined(l))return o(void 0,l)}else return o(void 0,u)}function c(l,u,h){if(h in t)return o(l,u);if(h in e)return o(void 0,l)}const d={url:n,method:n,data:n,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(l,u,h)=>a($s(l),$s(u),h,!0)};return b.forEach(Object.keys({...e,...t}),function(u){const h=d[u]||a,m=h(e[u],t[u],u);b.isUndefined(m)&&h!==c||(r[u]=m)}),r}const Vs=e=>{const t=He({},e);let{data:r,withXSRFToken:o,xsrfHeaderName:a,xsrfCookieName:n,headers:i,auth:c}=t;if(t.headers=i=be.from(i),t.url=Ts(Is(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),b.isFormData(r)){if(de.hasStandardBrowserEnv||de.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(b.isFunction(r.getHeaders)){const d=r.getHeaders(),l=["content-type","content-length"];Object.entries(d).forEach(([u,h])=>{l.includes(u.toLowerCase())&&i.set(u,h)})}}if(de.hasStandardBrowserEnv&&(o&&b.isFunction(o)&&(o=o(t)),o||o!==!1&&Zn(t.url))){const d=a&&n&&Gn.read(n);d&&i.set(a,d)}return t},Xn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,o){const a=Vs(e);let n=a.data;const i=be.from(a.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:l}=a,u,h,m,w,f;function x(){w&&w(),f&&f(),a.cancelToken&&a.cancelToken.unsubscribe(u),a.signal&&a.signal.removeEventListener("abort",u)}let y=new XMLHttpRequest;y.open(a.method.toUpperCase(),a.url,!0),y.timeout=a.timeout;function P(){if(!y)return;const B=be.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),H={data:!c||c==="text"||c==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:B,config:e,request:y};Us(function(v){r(v),x()},function(v){o(v),x()},H),y=null}"onloadend"in y?y.onloadend=P:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(P)},y.onabort=function(){y&&(o(new Y("Request aborted",Y.ECONNABORTED,e,y)),y=null)},y.onerror=function(N){const H=N&&N.message?N.message:"Network Error",S=new Y(H,Y.ERR_NETWORK,e,y);S.event=N||null,o(S),y=null},y.ontimeout=function(){let N=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const H=a.transitional||Es;a.timeoutErrorMessage&&(N=a.timeoutErrorMessage),o(new Y(N,H.clarifyTimeoutError?Y.ETIMEDOUT:Y.ECONNABORTED,e,y)),y=null},n===void 0&&i.setContentType(null),"setRequestHeader"in y&&b.forEach(i.toJSON(),function(N,H){y.setRequestHeader(H,N)}),b.isUndefined(a.withCredentials)||(y.withCredentials=!!a.withCredentials),c&&c!=="json"&&(y.responseType=a.responseType),l&&([m,f]=_t(l,!0),y.addEventListener("progress",m)),d&&y.upload&&([h,w]=_t(d),y.upload.addEventListener("progress",h),y.upload.addEventListener("loadend",w)),(a.cancelToken||a.signal)&&(u=B=>{y&&(o(!B||B.type?new Xe(null,e,y):B),y.abort(),y=null)},a.cancelToken&&a.cancelToken.subscribe(u),a.signal&&(a.signal.aborted?u():a.signal.addEventListener("abort",u)));const A=Hn(a.url);if(A&&de.protocols.indexOf(A)===-1){o(new Y("Unsupported protocol "+A+":",Y.ERR_BAD_REQUEST,e));return}y.send(n||null)})},Qn=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let o=new AbortController,a;const n=function(l){if(!a){a=!0,c();const u=l instanceof Error?l:this.reason;o.abort(u instanceof Y?u:new Xe(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,n(new Y(`timeout ${t} of ms exceeded`,Y.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(n):l.removeEventListener("abort",n)}),e=null)};e.forEach(l=>l.addEventListener("abort",n));const{signal:d}=o;return d.unsubscribe=()=>b.asap(c),d}},Yn=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let o=0,a;for(;o<r;)a=o+t,yield e.slice(o,a),o=a},Rn=async function*(e,t){for await(const r of ei(e))yield*Yn(r,t)},ei=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:o}=await t.read();if(r)break;yield o}}finally{await t.cancel()}},js=(e,t,r,o)=>{const a=Rn(e,t);let n=0,i,c=d=>{i||(i=!0,o&&o(d))};return new ReadableStream({async pull(d){try{const{done:l,value:u}=await a.next();if(l){c(),d.close();return}let h=u.byteLength;if(r){let m=n+=h;r(m)}d.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(d){return c(d),a.return()}},{highWaterMark:2})},Ds=64*1024,{isFunction:Lt}=b,ti=(({Request:e,Response:t})=>({Request:e,Response:t}))(b.global),{ReadableStream:Hs,TextEncoder:zs}=b.global,Ws=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ri=e=>{e=b.merge.call({skipUndefined:!0},ti,e);const{fetch:t,Request:r,Response:o}=e,a=t?Lt(t):typeof fetch=="function",n=Lt(r),i=Lt(o);if(!a)return!1;const c=a&&Lt(Hs),d=a&&(typeof zs=="function"?(f=>x=>f.encode(x))(new zs):async f=>new Uint8Array(await new r(f).arrayBuffer())),l=n&&c&&Ws(()=>{let f=!1;const x=new r(de.origin,{body:new Hs,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!x}),u=i&&c&&Ws(()=>b.isReadableStream(new o("").body)),h={stream:u&&(f=>f.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(x,y)=>{let P=x&&x[f];if(P)return P.call(x);throw new Y(`Response type '${f}' is not supported`,Y.ERR_NOT_SUPPORT,y)})});const m=async f=>{if(f==null)return 0;if(b.isBlob(f))return f.size;if(b.isSpecCompliantForm(f))return(await new r(de.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(b.isArrayBufferView(f)||b.isArrayBuffer(f))return f.byteLength;if(b.isURLSearchParams(f)&&(f=f+""),b.isString(f))return(await d(f)).byteLength},w=async(f,x)=>{const y=b.toFiniteNumber(f.getContentLength());return y??m(x)};return async f=>{let{url:x,method:y,data:P,signal:A,cancelToken:B,timeout:N,onDownloadProgress:H,onUploadProgress:S,responseType:v,headers:C,withCredentials:F="same-origin",fetchOptions:D}=Vs(f),k=t||fetch;v=v?(v+"").toLowerCase():"text";let U=Qn([A,B&&B.toAbortSignal()],N),I=null;const j=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let L;try{if(S&&l&&y!=="get"&&y!=="head"&&(L=await w(C,P))!==0){let z=new r(x,{method:"POST",body:P,duplex:"half"}),_;if(b.isFormData(P)&&(_=z.headers.get("content-type"))&&C.setContentType(_),z.body){const[J,V]=Bs(L,_t(qs(S)));P=js(z.body,Ds,J,V)}}b.isString(F)||(F=F?"include":"omit");const T=n&&"credentials"in r.prototype,M={...D,signal:U,method:y.toUpperCase(),headers:C.normalize().toJSON(),body:P,duplex:"half",credentials:T?F:void 0};I=n&&new r(x,M);let E=await(n?k(I,D):k(x,M));const Z=u&&(v==="stream"||v==="response");if(u&&(H||Z&&j)){const z={};["status","statusText","headers"].forEach(K=>{z[K]=E[K]});const _=b.toFiniteNumber(E.headers.get("content-length")),[J,V]=H&&Bs(_,_t(qs(H),!0))||[];E=new o(js(E.body,Ds,J,()=>{V&&V(),j&&j()}),z)}v=v||"text";let Q=await h[b.findKey(h,v)||"text"](E,f);return!Z&&j&&j(),await new Promise((z,_)=>{Us(z,_,{data:Q,headers:be.from(E.headers),status:E.status,statusText:E.statusText,config:f,request:I})})}catch(T){throw j&&j(),T&&T.name==="TypeError"&&/Load failed|fetch/i.test(T.message)?Object.assign(new Y("Network Error",Y.ERR_NETWORK,f,I),{cause:T.cause||T}):Y.from(T,T&&T.code,f,I)}}},si=new Map,Zs=e=>{let t=e&&e.env||{};const{fetch:r,Request:o,Response:a}=t,n=[o,a,r];let i=n.length,c=i,d,l,u=si;for(;c--;)d=n[c],l=u.get(d),l===void 0&&u.set(d,l=c?new Map:ri(t)),u=l;return l};Zs();const rr={http:kn,xhr:Xn,fetch:{get:Zs}};b.forEach(rr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Gs=e=>`- ${e}`,oi=e=>b.isFunction(e)||e===null||e===!1;function ai(e,t){e=b.isArray(e)?e:[e];const{length:r}=e;let o,a;const n={};for(let i=0;i<r;i++){o=e[i];let c;if(a=o,!oi(o)&&(a=rr[(c=String(o)).toLowerCase()],a===void 0))throw new Y(`Unknown adapter '${c}'`);if(a&&(b.isFunction(a)||(a=a.get(t))))break;n[c||"#"+i]=a}if(!a){const i=Object.entries(n).map(([d,l])=>`adapter ${d} `+(l===!1?"is not supported by the environment":"is not available in the build"));let c=r?i.length>1?`since :
112
- `+i.map(Gs).join(`
113
- `):" "+Gs(i[0]):"as no adapter specified";throw new Y("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return a}const Ks={getAdapter:ai,adapters:rr};function sr(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Xe(null,e)}function Js(e){return sr(e),e.headers=be.from(e.headers),e.data=tr.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ks.getAdapter(e.adapter||ct.adapter,e)(e).then(function(o){return sr(e),o.data=tr.call(e,e.transformResponse,o),o.headers=be.from(o.headers),o},function(o){return Ms(o)||(sr(e),o&&o.response&&(o.response.data=tr.call(e,e.transformResponse,o.response),o.response.headers=be.from(o.response.headers))),Promise.reject(o)})}const Xs="1.13.0",Tt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Tt[e]=function(o){return typeof o===e||"a"+(t<1?"n ":" ")+e}});const Qs={};Tt.transitional=function(t,r,o){function a(n,i){return"[Axios v"+Xs+"] Transitional option '"+n+"'"+i+(o?". "+o:"")}return(n,i,c)=>{if(t===!1)throw new Y(a(i," has been removed"+(r?" in "+r:"")),Y.ERR_DEPRECATED);return r&&!Qs[i]&&(Qs[i]=!0,console.warn(a(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(n,i,c):!0}},Tt.spelling=function(t){return(r,o)=>(console.warn(`${o} is likely a misspelling of ${t}`),!0)};function ni(e,t,r){if(typeof e!="object")throw new Y("options must be an object",Y.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let a=o.length;for(;a-- >0;){const n=o[a],i=t[n];if(i){const c=e[n],d=c===void 0||i(c,n,e);if(d!==!0)throw new Y("option "+n+" must be "+d,Y.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Y("Unknown option "+n,Y.ERR_BAD_OPTION)}}const Nt={assertOptions:ni,validators:Tt},Le=Nt.validators;let ze=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ns,response:new Ns}}async request(t,r){try{return await this._request(t,r)}catch(o){if(o instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const n=a.stack?a.stack.replace(/^.+\n/,""):"";try{o.stack?n&&!String(o.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(o.stack+=`
114
- `+n):o.stack=n}catch{}}throw o}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=He(this.defaults,r);const{transitional:o,paramsSerializer:a,headers:n}=r;o!==void 0&&Nt.assertOptions(o,{silentJSONParsing:Le.transitional(Le.boolean),forcedJSONParsing:Le.transitional(Le.boolean),clarifyTimeoutError:Le.transitional(Le.boolean)},!1),a!=null&&(b.isFunction(a)?r.paramsSerializer={serialize:a}:Nt.assertOptions(a,{encode:Le.function,serialize:Le.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Nt.assertOptions(r,{baseUrl:Le.spelling("baseURL"),withXsrfToken:Le.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=n&&b.merge(n.common,n[r.method]);n&&b.forEach(["delete","get","head","post","put","patch","common"],f=>{delete n[f]}),r.headers=be.concat(i,n);const c=[];let d=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(r)===!1||(d=d&&x.synchronous,c.unshift(x.fulfilled,x.rejected))});const l=[];this.interceptors.response.forEach(function(x){l.push(x.fulfilled,x.rejected)});let u,h=0,m;if(!d){const f=[Js.bind(this),void 0];for(f.unshift(...c),f.push(...l),m=f.length,u=Promise.resolve(r);h<m;)u=u.then(f[h++],f[h++]);return u}m=c.length;let w=r;for(;h<m;){const f=c[h++],x=c[h++];try{w=f(w)}catch(y){x.call(this,y);break}}try{u=Js.call(this,w)}catch(f){return Promise.reject(f)}for(h=0,m=l.length;h<m;)u=u.then(l[h++],l[h++]);return u}getUri(t){t=He(this.defaults,t);const r=Is(t.baseURL,t.url,t.allowAbsoluteUrls);return Ts(r,t.params,t.paramsSerializer)}};b.forEach(["delete","get","head","options"],function(t){ze.prototype[t]=function(r,o){return this.request(He(o||{},{method:t,url:r,data:(o||{}).data}))}}),b.forEach(["post","put","patch"],function(t){function r(o){return function(n,i,c){return this.request(He(c||{},{method:t,headers:o?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}ze.prototype[t]=r(),ze.prototype[t+"Form"]=r(!0)});let ii=class Zo{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(n){r=n});const o=this;this.promise.then(a=>{if(!o._listeners)return;let n=o._listeners.length;for(;n-- >0;)o._listeners[n](a);o._listeners=null}),this.promise.then=a=>{let n;const i=new Promise(c=>{o.subscribe(c),n=c}).then(a);return i.cancel=function(){o.unsubscribe(n)},i},t(function(n,i,c){o.reason||(o.reason=new Xe(n,i,c),r(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=o=>{t.abort(o)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Zo(function(a){t=a}),cancel:t}}};function li(e){return function(r){return e.apply(null,r)}}function ci(e){return b.isObject(e)&&e.isAxiosError===!0}const or={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(or).forEach(([e,t])=>{or[t]=e});function Ys(e){const t=new ze(e),r=ps(ze.prototype.request,t);return b.extend(r,ze.prototype,t,{allOwnKeys:!0}),b.extend(r,t,null,{allOwnKeys:!0}),r.create=function(a){return Ys(He(e,a))},r}const te=Ys(ct);te.Axios=ze,te.CanceledError=Xe,te.CancelToken=ii,te.isCancel=Ms,te.VERSION=Xs,te.toFormData=kt,te.AxiosError=Y,te.Cancel=te.CanceledError,te.all=function(t){return Promise.all(t)},te.spread=li,te.isAxiosError=ci,te.mergeConfig=He,te.AxiosHeaders=be,te.formToJSON=e=>Fs(b.isHTMLForm(e)?new FormData(e):e),te.getAdapter=Ks.getAdapter,te.HttpStatusCode=or,te.default=te;const{Axios:ic,AxiosError:lc,CanceledError:cc,isCancel:dc,CancelToken:uc,VERSION:hc,all:fc,Cancel:pc,isAxiosError:gc,spread:mc,toFormData:wc,AxiosHeaders:yc,HttpStatusCode:bc,formToJSON:Cc,getAdapter:vc,mergeConfig:xc}=te,ce="/api/v1/appauth".replace(/\/+$/,"");class Me{constructor(t,r=ce,o=te){this.basePath=r,this.axios=o,t&&(this.configuration=t,this.basePath=t.basePath??r)}}class di extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}const ue={"UserProfileApi.getUserProfile":[{url:"/api/v1",description:"Profile API base URL"}],"UserProfileApi.updateUserProfile":[{url:"/api/v1",description:"Profile API base URL"}]},he="https://example.com",se=function(e,t,r){if(r==null)throw new di(t,`Required parameter ${t} was null or undefined when calling ${e}.`)};function ar(e,t,r=""){t!=null&&(typeof t=="object"?Array.isArray(t)?t.forEach(o=>ar(e,o,r)):Object.keys(t).forEach(o=>ar(e,t[o],`${r}${r!==""?".":""}${o}`)):e.has(r)?e.append(r,t):e.set(r,t))}const fe=function(e,...t){const r=new URLSearchParams(e.search);ar(r,t),e.search=r.toString()},Qe=function(e,t,r){const o=typeof e!="string";return(o&&r&&r.isJsonMime?r.isJsonMime(t.headers["Content-Type"]):o)?JSON.stringify(e!==void 0?e:{}):e||""},pe=function(e){return e.pathname+e.search+e.hash},ge=function(e,t,r,o){return(a=t,n=r)=>{const i={...e.options,url:(a.defaults.baseURL?"":o?.basePath??n)+e.url};return a.request(i)}},ui=function(e){return{getAppAuthConfig:async(t={})=>{const r="/config/",o=new URL(r,he);let a;e&&(a=e.baseOptions);const n={method:"GET",...a,...t},i={};fe(o,{});let d=a&&a.headers?a.headers:{};return n.headers={...i,...d,...t.headers},{url:pe(o),options:n}},updateAppAuthConfig:async(t,r,o={})=>{se("updateAppAuthConfig","xCSRFToken",t),se("updateAppAuthConfig","authConfig",r);const a="/config/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"PUT",...i,...o},d={},l={},u=new(e&&e.formDataCtor||FormData);r!==void 0&&u.append("auth_config",r),d["Content-Type"]="multipart/form-data",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let h=i&&i.headers?i.headers:{};return c.headers={...d,...h,...o.headers},c.data=u,{url:pe(n),options:c}}}},Rs=function(e){const t=ui(e);return{async getAppAuthConfig(r){const o=await t.getAppAuthConfig(r),a=e?.serverIndex??0,n=ue["ApplicationConfigurationApi.getAppAuthConfig"]?.[a]?.url;return(i,c)=>ge(o,te,ce,e)(i,n||c)},async updateAppAuthConfig(r,o,a){const n=await t.updateAppAuthConfig(r,o,a),i=e?.serverIndex??0,c=ue["ApplicationConfigurationApi.updateAppAuthConfig"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)}}};class hi extends Me{getAppAuthConfig(t){return Rs(this.configuration).getAppAuthConfig(t).then(r=>r(this.axios,this.basePath))}updateAppAuthConfig(t,r,o){return Rs(this.configuration).updateAppAuthConfig(t,r,o).then(a=>a(this.axios,this.basePath))}}const fi=function(e){return{loginUser:async(t,r,o={})=>{se("loginUser","xCSRFToken",t),se("loginUser","loginUserRequest",r);const a="/login/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}},logoutUser:async(t,r={})=>{se("logoutUser","xCSRFToken",t);const o="/logout/",a=new URL(o,he);let n;e&&(n=e.baseOptions);const i={method:"DELETE",...n,...r},c={},d={};t!=null&&(c["X-CSRFToken"]=String(t)),fe(a,d);let l=n&&n.headers?n.headers:{};return i.headers={...c,...l,...r.headers},{url:pe(a),options:i}}}},eo=function(e){const t=fi(e);return{async loginUser(r,o,a){const n=await t.loginUser(r,o,a),i=e?.serverIndex??0,c=ue["AuthenticationApi.loginUser"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)},async logoutUser(r,o){const a=await t.logoutUser(r,o),n=e?.serverIndex??0,i=ue["AuthenticationApi.logoutUser"]?.[n]?.url;return(c,d)=>ge(a,te,ce,e)(c,i||d)}}};class pi extends Me{loginUser(t,r,o){return eo(this.configuration).loginUser(t,r,o).then(a=>a(this.axios,this.basePath))}logoutUser(t,r){return eo(this.configuration).logoutUser(t,r).then(o=>o(this.axios,this.basePath))}}const gi=function(e){return{requestLoginOTP:async(t,r,o={})=>{se("requestLoginOTP","xCSRFToken",t),se("requestLoginOTP","loginOTPRequest",r);const a="/login/code/request/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}},verifyLoginOTP:async(t,r,o={})=>{se("verifyLoginOTP","xCSRFToken",t),se("verifyLoginOTP","loginOTPVerifyRequest",r);const a="/login/code/confirm/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}}}},to=function(e){const t=gi(e);return{async requestLoginOTP(r,o,a){const n=await t.requestLoginOTP(r,o,a),i=e?.serverIndex??0,c=ue["LoginWithOTPApi.requestLoginOTP"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)},async verifyLoginOTP(r,o,a){const n=await t.verifyLoginOTP(r,o,a),i=e?.serverIndex??0,c=ue["LoginWithOTPApi.verifyLoginOTP"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)}}};class mi extends Me{requestLoginOTP(t,r,o){return to(this.configuration).requestLoginOTP(t,r,o).then(a=>a(this.axios,this.basePath))}verifyLoginOTP(t,r,o){return to(this.configuration).verifyLoginOTP(t,r,o).then(a=>a(this.axios,this.basePath))}}const wi=function(e){return{getMfaCode:async(t={})=>{const r="/mfa/getcode/",o=new URL(r,he);let a;e&&(a=e.baseOptions);const n={method:"GET",...a,...t},i={};fe(o,{});let d=a&&a.headers?a.headers:{};return n.headers={...i,...d,...t.headers},{url:pe(o),options:n}},verifyMfaCode:async(t,r,o={})=>{se("verifyMfaCode","xCSRFToken",t),se("verifyMfaCode","mfaVerifyRequest",r);const a="/mfa/verify/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}}}},ro=function(e){const t=wi(e);return{async getMfaCode(r){const o=await t.getMfaCode(r),a=e?.serverIndex??0,n=ue["MultiFactorAuthenticationApi.getMfaCode"]?.[a]?.url;return(i,c)=>ge(o,te,ce,e)(i,n||c)},async verifyMfaCode(r,o,a){const n=await t.verifyMfaCode(r,o,a),i=e?.serverIndex??0,c=ue["MultiFactorAuthenticationApi.verifyMfaCode"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)}}};class yi extends Me{getMfaCode(t){return ro(this.configuration).getMfaCode(t).then(r=>r(this.axios,this.basePath))}verifyMfaCode(t,r,o){return ro(this.configuration).verifyMfaCode(t,r,o).then(a=>a(this.axios,this.basePath))}}const bi=function(e){return{oauthCallback:async(t,r,o,a,n,i,c,d,l={})=>{se("oauthCallback","provider",t),se("oauthCallback","state",r),se("oauthCallback","code",o),se("oauthCallback","scope",a),se("oauthCallback","xCSRFToken",n);const u="/oauth/{provider}/callback/".replace("{provider}",encodeURIComponent(String(t))),h=new URL(u,he);let m;e&&(m=e.baseOptions);const w={method:"POST",...m,...l},f={},x={};r!==void 0&&(x.state=r),o!==void 0&&(x.code=o),a!==void 0&&(x.scope=a),i!==void 0&&(x.authuser=i),c!==void 0&&(x.hd=c),d!==void 0&&(x.prompt=d),n!=null&&(f["X-CSRFToken"]=String(n)),fe(h,x);let y=m&&m.headers?m.headers:{};return w.headers={...f,...y,...l.headers},{url:pe(h),options:w}},oauthRedirect:async(t,r,o,a,n={})=>{se("oauthRedirect","xCsrftoken",t),se("oauthRedirect","provider",r),se("oauthRedirect","process",o),se("oauthRedirect","callbackUrl",a);const i="/oauth/redirect/",c=new URL(i,he);let d;e&&(d=e.baseOptions);const l={method:"POST",...d,...n},u={},h={},m=new URLSearchParams;r!==void 0&&m.set("provider",r),o!==void 0&&m.set("process",o),a!==void 0&&m.set("callback_url",a),u["Content-Type"]="application/x-www-form-urlencoded",t!=null&&(u["x-csrftoken"]=String(t)),fe(c,h);let w=d&&d.headers?d.headers:{};return l.headers={...u,...w,...n.headers},l.data=m.toString(),{url:pe(c),options:l}}}},so=function(e){const t=bi(e);return{async oauthCallback(r,o,a,n,i,c,d,l,u){const h=await t.oauthCallback(r,o,a,n,i,c,d,l,u),m=e?.serverIndex??0,w=ue["OAuthApi.oauthCallback"]?.[m]?.url;return(f,x)=>ge(h,te,ce,e)(f,w||x)},async oauthRedirect(r,o,a,n,i){const c=await t.oauthRedirect(r,o,a,n,i),d=e?.serverIndex??0,l=ue["OAuthApi.oauthRedirect"]?.[d]?.url;return(u,h)=>ge(c,te,ce,e)(u,l||h)}}};class Ci extends Me{oauthCallback(t,r,o,a,n,i,c,d,l){return so(this.configuration).oauthCallback(t,r,o,a,n,i,c,d,l).then(u=>u(this.axios,this.basePath))}oauthRedirect(t,r,o,a,n){return so(this.configuration).oauthRedirect(t,r,o,a,n).then(i=>i(this.axios,this.basePath))}}const vi=function(e){return{changePassword:async(t,r,o={})=>{se("changePassword","xCSRFToken",t),se("changePassword","passwordChangeRequest",r);const a="/password/change/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"PUT",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}},setPassword:async(t,r,o={})=>{se("setPassword","xCSRFToken",t),se("setPassword","passwordSetRequest",r);const a="/password/set/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}}}},oo=function(e){const t=vi(e);return{async changePassword(r,o,a){const n=await t.changePassword(r,o,a),i=e?.serverIndex??0,c=ue["PasswordManagementApi.changePassword"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)},async setPassword(r,o,a){const n=await t.setPassword(r,o,a),i=e?.serverIndex??0,c=ue["PasswordManagementApi.setPassword"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)}}};class xi extends Me{changePassword(t,r,o){return oo(this.configuration).changePassword(t,r,o).then(a=>a(this.axios,this.basePath))}setPassword(t,r,o){return oo(this.configuration).setPassword(t,r,o).then(a=>a(this.axios,this.basePath))}}const Pi=function(e){return{setRole:async(t,r,o={})=>{se("setRole","xCSRFToken",t),se("setRole","role",r);const a="/role/set/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};r!==void 0&&(l.role=r),t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},{url:pe(n),options:c}},switchRole:async(t,r,o={})=>{se("switchRole","xCSRFToken",t),se("switchRole","role",r);const a="/role/switch/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};r!==void 0&&(l.role=r),t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},{url:pe(n),options:c}}}},ao=function(e){const t=Pi(e);return{async setRole(r,o,a){const n=await t.setRole(r,o,a),i=e?.serverIndex??0,c=ue["RoleManagementApi.setRole"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)},async switchRole(r,o,a){const n=await t.switchRole(r,o,a),i=e?.serverIndex??0,c=ue["RoleManagementApi.switchRole"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)}}};class Si extends Me{setRole(t,r,o){return ao(this.configuration).setRole(t,r,o).then(a=>a(this.axios,this.basePath))}switchRole(t,r,o){return ao(this.configuration).switchRole(t,r,o).then(a=>a(this.axios,this.basePath))}}const ki=function(e){return{getUserProfile:async(t={})=>{const r="/profile/",o=new URL(r,he);let a;e&&(a=e.baseOptions);const n={method:"GET",...a,...t},i={};fe(o,{});let d=a&&a.headers?a.headers:{};return n.headers={...i,...d,...t.headers},{url:pe(o),options:n}},updateUserProfile:async(t,r,o,a,n,i={})=>{se("updateUserProfile","xCSRFToken",t);const c="/profile/",d=new URL(c,he);let l;e&&(l=e.baseOptions);const u={method:"PUT",...l,...i},h={},m={},w=new(e&&e.formDataCtor||FormData);r!==void 0&&w.append("name",r),o!==void 0&&w.append("mobile",o),a!==void 0&&w.append("auth_config",a),n!==void 0&&w.append("profile_pic",n),h["Content-Type"]="multipart/form-data",t!=null&&(h["X-CSRFToken"]=String(t)),fe(d,m);let f=l&&l.headers?l.headers:{};return u.headers={...h,...f,...i.headers},u.data=w,{url:pe(d),options:u}}}},no=function(e){const t=ki(e);return{async getUserProfile(r){const o=await t.getUserProfile(r),a=e?.serverIndex??0,n=ue["UserProfileApi.getUserProfile"]?.[a]?.url;return(i,c)=>ge(o,te,ce,e)(i,n||c)},async updateUserProfile(r,o,a,n,i,c){const d=await t.updateUserProfile(r,o,a,n,i,c),l=e?.serverIndex??0,u=ue["UserProfileApi.updateUserProfile"]?.[l]?.url;return(h,m)=>ge(d,te,ce,e)(h,u||m)}}};class io extends Me{getUserProfile(t){return no(this.configuration).getUserProfile(t).then(r=>r(this.axios,this.basePath))}updateUserProfile(t,r,o,a,n,i){return no(this.configuration).updateUserProfile(t,r,o,a,n,i).then(c=>c(this.axios,this.basePath))}}class lo{constructor(t={}){this.apiKey=t.apiKey,this.username=t.username,this.password=t.password,this.accessToken=t.accessToken,this.basePath=t.basePath,this.serverIndex=t.serverIndex,this.baseOptions={...t.baseOptions,headers:{...t.baseOptions?.headers}},this.formDataCtor=t.formDataCtor}isJsonMime(t){const r=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return t!==null&&(r.test(t)||t.toLowerCase()==="application/json-patch+json")}}const Ue=new lo({basePath:"/api/v1/appauth",baseOptions:{withCredentials:!0}}),co=new pi(Ue),Ai=new hi(Ue),uo=new mi(Ue),ho=new yi(Ue),fo=new xi(Ue),_i=new Si(Ue),po=new Ci(Ue);new io(Ue);const Te=()=>{const e=document.cookie.match(/csrftoken=([^;]+)/);if(e)return decodeURIComponent(e[1]);const t=document.querySelector('meta[name="csrf-token"]');if(t)return t.getAttribute("content");const r=document.cookie.match(/csrf_token=([^;]+)/);return r?decodeURIComponent(r[1]):(console.warn("CSRF token not found. OTP requests may fail."),"")};let re=null,We=null;const W={async getAuthConfig(){return re||We||(We=(async()=>{try{const t=(await Ai.getAppAuthConfig()).data;return t?.response?.auth_config?re=t.response.auth_config:t?.auth_config?re=t.auth_config:re=t,console.log("Auth configuration loaded:",re),re}catch(e){throw console.error("Failed to fetch auth config:",e),We=null,e}finally{We=null}})(),We)},getConfig(){return re},isPasswordLoginEnabled(){return re?.login_methods?.password?.enabled||!1},isOTPLoginEnabled(){return re?.login_methods?.otp?.enabled||!1},isSSOEnabled(){return re?.login_methods?.sso?.enabled||!1},isOIDCEnabled(){return re?.login_methods?.oidc?.enabled||!1},getOIDCProviders(){return console.log("OIDC providers:",re?.login_methods?.oidc?.providers),re?.login_methods?.oidc?.providers||[]},getAllowedUsernames(){return(re?.login_methods?.password?.allowed_usernames||re?.login_methods?.allowed_usernames||["email"]).map(t=>t==="phone"?"mobile":t)},isForgotPasswordEnabled(){return re?.password_policy?.reset?.enabled||!1},getPasswordResetLinkExpiry(){return re?.login_methods?.password?.password_reset_link_expiry_hours||24},getSessionPolicy(){return re?.session_policy||{}},isRememberMeEnabled(){return re?.session_policy?.remember_me_enabled!==!1},getRememberMeDurationDays(){return re?.session_policy?.remember_me_duration_days||30},getPasswordPolicy(){return re?.password_policy||{}},getPasswordResetMethods(){return re?.password_policy?.reset?.method||[]},isPasswordResetEnabled(){return re?.password_policy?.reset?.enabled||!1},getPasswordResetExpiry(){return re?.password_policy?.reset?.expiry_hours||24},isTwoFactorRequired(){return re?.two_factor_auth?.required||!1},getTwoFactorMethods(){return re?.two_factor_auth?.allowedMethods||[]},getTwoFactorHooks(){return{email:re?.two_factor_auth?.email_hook,sms:re?.two_factor_auth?.sms_hook}},async login(e,t={}){try{re||await this.getAuthConfig();const r=Te()||"";console.log("Login csrfToken:",r);const o=e,a=await co.loginUser(r,o);console.log("Login response:",a.data);const n=a.data;if(n?.success&&n?.response){const i=n.response;return i.status===401&&i.data?.next_step?(console.log("Multi-step authentication required:",i),i):i.data||i}return a.data}catch(r){if(console.error("Login error:",r),r.response?.status===401&&r.response?.data){const o=r.response.data;if(o?.success&&o?.response){const a=o.response;if(a.status===401&&a.data?.next_step)return console.log("Multi-step authentication required:",a),a}if(o?.response?.data?.next_step||o?.data?.next_step)return console.log("Multi-step authentication required:",o),o}throw r}},async logout(e={}){try{const t=Te()||"";await co.logoutUser(t)}catch(t){console.error("Logout error:",t)}},async getCurrentUser(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return Oo});if(!e())throw new Error("Not authenticated - no valid session cookie");return{id:1,username:"authenticated_user",email:"user@example.com",authenticated:!0}}catch(e){throw console.error("Get current user failed:",e),new Error("Authentication verification failed")}},async verifyToken(e,t={}){return this.getCurrentUser()},async forgotPassword(e){try{return{message:"Reset email sent"}}catch(t){throw t}},async resetPassword(e){try{return{message:"Password reset successful"}}catch(t){throw t}},async fetchLoginMethods(){try{return(await this.getAuthConfig())?.login_methods||{}}catch(e){throw e}},async requestOTP(e){try{const t=Te()||"";console.log("Requesting OTP for:",e,"CSRF token:",t?"present":"missing");const o=e.includes("@")?{email:e}:{phone:e};console.log("OTP request payload:",o);const a=await uo.requestLoginOTP(t,o),n=a.data;return n?.success&&n?.response?n.response.data||n.response:a.data}catch(t){if(console.error("Request OTP error:",t),t.response?.data){const r=t.response.data;if(r?.response?.data?.message)throw new Error(r.response.data.message);if(r?.message)throw new Error(r.message)}throw t}},async verifyOTP(e,t){try{const r=Te()||"";console.log("Verifying OTP for:",e,"code:",t,"CSRF token:",r?"present":"missing");const o={code:t};console.log("OTP verify payload:",o);const a=await uo.verifyLoginOTP(r,o),n=a.data;return n?.success&&n?.response?n.response.status===401&&n.response.data?.next_step?(console.log("Multi-step authentication required after OTP verification:",n),n.response):n.response.data||n.response:a.data}catch(r){if(console.error("Verify OTP error:",r),r.response?.status===401&&r.response?.data){const o=r.response.data;if(o?.success&&o?.response){const a=o.response;if(a.status===401&&a.data?.next_step)return console.log("Multi-step authentication required after OTP verification:",a),a}if(o?.response?.data?.next_step||o?.data?.next_step)return console.log("Multi-step authentication required after OTP verification:",o),o}if(r.response?.data){const o=r.response.data;if(o?.response?.data?.message)throw new Error(o.response.data.message);if(o?.message)throw new Error(o.message)}throw r}},async selectRole(e){try{const t=Te()||"",r=await _i.setRole(t,e),o=r.data;if(o?.success&&o?.response){const a=o.response;return a.status===401&&a.data?.next_step?(console.log("Multi-step authentication after role selection:",a),a):a.data||a}return r.data}catch(t){if(console.error("Select role error:",t),t.response?.status===401&&t.response?.data){const r=t.response.data;if(r?.success&&r?.response){const o=r.response;if(o.status===401&&o.data?.next_step)return console.log("Multi-step authentication after role selection:",o),o}if(r?.response?.data?.next_step||r?.data?.next_step)return console.log("Multi-step authentication after role selection:",r),r}throw t}},async sendTwoFactorCode(){try{return(await ho.getMfaCode()).data}catch(e){throw console.error("Send 2FA code error:",e),e}},async verifyTwoFactorCode(e){try{const t=Te()||"";return(await ho.verifyMfaCode(t,{code:e})).data}catch(t){throw console.error("Verify 2FA code error:",t),t}},async changePassword(e,t){try{const r=Te()||"";return(await fo.changePassword(r,{current_password:e,new_password:t})).data}catch(r){throw console.error("Change password error:",r),r}},async setPassword(e){try{const t=Te()||"",r=await fo.setPassword(t,{new_password:e});return console.log("Set password response:",r.data),r.data}catch(t){if(console.error("Set password error:",t),t.response?.status===401&&t.response?.data){const r=t.response.data;if(r?.response?.data?.next_step||r?.data?.next_step)return console.log("Multi-step authentication after password set:",r),r}throw t}},async processOAuthCallback(e,t,r,o,a,n,i,c){try{const d=Te()||"",l=await po.oauthCallback(e,t,r,o,d,a,n,i,c),u=l.data;if(u?.success&&u?.response){const h=u.response;return h.status===401&&h.data?.next_step?(console.log("Multi-step authentication required:",h),h):h.data||h}return l.data}catch(d){if(d.response?.status===401&&d.response?.data){const l=d.response.data;if(l?.success&&l?.response){const u=l.response;if(u.status===401&&u.data?.next_step)return console.log("Multi-step authentication required:",u),u}if(l?.response?.data?.next_step||l?.data?.next_step)return console.log("Multi-step authentication required:",l),l}throw d}},clearConfig(){re=null,We=null},async isAuthenticated(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return Oo});return e()}catch(e){return console.error("Authentication check failed:",e),!1}},validatePassword(e){const t=this.getPasswordPolicy(),r=[];return t.min_length&&e.length<t.min_length&&r.push(`Password must be at least ${t.min_length} characters long`),t.max_length&&e.length>t.max_length&&r.push(`Password must be at most ${t.max_length} characters long`),t.require_numbers&&!/\d/.test(e)&&r.push("Password must contain at least one number"),t.require_lowercase&&!/[a-z]/.test(e)&&r.push("Password must contain at least one lowercase letter"),t.require_uppercase&&!/[A-Z]/.test(e)&&r.push("Password must contain at least one uppercase letter"),t.require_special_chars&&!/[!@#$%^&*(),.?":{}|<>]/.test(e)&&r.push("Password must contain at least one special character"),{valid:r.length===0,errors:r}},async oauthRedirect(e,t){try{const r=Te()||"";return(await po.oauthRedirectPost(r,e,"login",t)).data}catch(r){throw r}},async getUserProfile(){try{const e=new lo({basePath:"/api/v1",baseOptions:{withCredentials:!0}});return(await new io(e).getUserProfile()).data}catch(e){throw console.error("Get user profile error:",e),e}}},go=e=>{let t;const r=new Set,o=(l,u)=>{const h=typeof l=="function"?l(t):l;if(!Object.is(h,t)){const m=t;t=u??(typeof h!="object"||h===null)?h:Object.assign({},t,h),r.forEach(w=>w(t,m))}},a=()=>t,c={setState:o,getState:a,getInitialState:()=>d,subscribe:l=>(r.add(l),()=>r.delete(l))},d=t=e(o,a,c);return c},Li=(e=>e?go(e):go),Ti=e=>e;function Ni(e,t=Ti){const r=g.useSyncExternalStore(e.subscribe,g.useCallback(()=>t(e.getState()),[e,t]),g.useCallback(()=>t(e.getInitialState()),[e,t]));return g.useDebugValue(r),r}const mo=e=>{const t=Li(e),r=o=>Ni(t,o);return Object.assign(r,t),r},Et=(e=>e?mo(e):mo)(e=>({basePath:"/login",setBasePath:t=>e({basePath:t})})),wo=g.createContext(void 0),Be=()=>{const e=g.useContext(wo);if(!e)throw new Error("useAuthConfig must be used within AuthConfigProvider");return e},Ei=({children:e,authConfig:t={}})=>{const r={theme:{background:{color:"#f0f2f5"},primaryColor:"#1890ff",secondaryColor:"#6d7280",borderRadius:"8px"},card:{backgroundColor:"#ffffff",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",maxWidth:"400px",padding:"40px"},logo:{position:"center",alt:"Logo"},login:{title:"Welcome Back",subtitle:"Please sign in to your account",submitButtonText:"Sign in",rememberMeText:"Remember me",forgotPasswordText:"Forgot password?",otpButtonText:"Sign in with OTP",showRememberMe:!0,enableTabSwitching:!0,defaultTab:"email",formLabels:{email:"Email",mobile:"Mobile",password:"Password"},formPlaceholders:{email:"Email address",mobile:"Mobile number (+919876543210)",password:"Password"},tabLabels:{email:"Email",mobile:"Mobile"}},roleSelection:{title:"Choose Your Role",subtitle:"Select the role that best matches your current responsibilities",continueButtonText:"Continue as {roleName}",recommendedBadgeText:"Recommended",emptyStateMessage:"No roles available",cardLayout:"grid",gridColumns:3,roleCardStyling:{backgroundColor:"#ffffff",selectedColor:"#1890ff",hoverColor:"#f0f2f5",borderRadius:"8px"}},twoFactor:{title:"Two-Factor Authentication",subtitle:"Please enter your verification code",instructionText:"Enter the verification code sent to your device",codeInputLabel:"Verification Code",submitButtonText:"Verify",resendButtonText:"Resend Code",backButtonText:"Back",resendCountdown:60,codeLength:6,methodLabels:{email:"Email",sms:"SMS",mobile:"Mobile"}},resetPassword:{forgotPassword:{title:"Forgot Password",subtitle:"Enter your email to reset your password",instructionText:"We will send you a reset link",emailLabel:"Email",emailPlaceholder:"Enter your email address",submitButtonText:"Send Reset Link",backToLoginText:"Back to Login",successMessage:"Reset email sent successfully",errorMessage:"Failed to send reset email"},resetForm:{title:"Reset Password",subtitle:"Enter your new password",passwordLabel:"New Password",confirmPasswordLabel:"Confirm Password",passwordPlaceholder:"Enter new password",confirmPasswordPlaceholder:"Confirm new password",submitButtonText:"Reset Password",successMessage:"Password reset successfully",showPasswordRequirements:!0,passwordRequirementsText:"Password requirements:"}},providers:{buttonStyle:"outline",showProviderIcons:!0,separatorText:"OR"},messages:{validation:{required:"This field is required",invalidEmail:"Please enter a valid email",invalidMobile:"Please enter a valid mobile number",passwordTooShort:"Password is too short",passwordsDoNotMatch:"Passwords do not match"},errors:{loginFailed:"Login failed. Please try again.",networkError:"Network error. Please check your connection.",invalidOTP:"Invalid verification code",expiredToken:"Token has expired"},success:{loginSuccess:"Login successful!",otpSent:"Verification code sent!",passwordReset:"Password reset successfully!",roleSelected:"Role selected successfully!"}}},o=(i,c)=>{const d={...i};for(const l in c)c[l]!==null&&typeof c[l]=="object"&&!Array.isArray(c[l])&&!g.isValidElement(c[l])?d[l]=o(i[l]||{},c[l]):d[l]=c[l];return d},a=o(r,t),n={authConfig:a,getLoginConfig:()=>a.login||{},getRoleSelectionConfig:()=>a.roleSelection||{},getTwoFactorConfig:()=>a.twoFactor||{},getResetPasswordConfig:()=>a.resetPassword||{},getThemeConfig:()=>a.theme||{},getCardConfig:()=>a.card||{},getLogoConfig:()=>a.logo||{},getProvidersConfig:()=>a.providers||{},getMessagesConfig:()=>a.messages||{},getCustomComponents:()=>a.customComponents||{}};return s.jsx(wo.Provider,{value:n,children:e})},Fi=e=>{const t=e?.theme||{},r=e?.card||{};let o="";return t.primaryColor&&(o+=`--auth-primary-color: ${t.primaryColor}; `),t.secondaryColor&&(o+=`--auth-secondary-color: ${t.secondaryColor}; `),t.fontFamily&&(o+=`--auth-font-family: ${t.fontFamily}; `),t.borderRadius&&(o+=`--auth-border-radius: ${t.borderRadius}; `),t.textColor&&(o+=`--auth-text-color: ${t.textColor}; `),t.secondaryTextColor&&(o+=`--auth-secondary-text-color: ${t.secondaryTextColor}; `),t.mutedTextColor&&(o+=`--auth-muted-text-color: ${t.mutedTextColor}; `),t.linkColor&&(o+=`--auth-link-color: ${t.linkColor}; `),t.linkHoverColor&&(o+=`--auth-link-hover-color: ${t.linkHoverColor}; `),t.background?.color&&(o+=`--auth-bg-color: ${t.background.color}; `),t.background?.gradient&&(o+=`--auth-bg-gradient: ${t.background.gradient}; `),t.background?.image&&(o+=`--auth-bg-image: url(${t.background.image}); `),r.backgroundColor&&(o+=`--auth-card-bg: ${r.backgroundColor}; `),r.borderRadius&&(o+=`--auth-card-border-radius: ${r.borderRadius}; `),r.boxShadow&&(o+=`--auth-card-shadow: ${r.boxShadow}; `),r.maxWidth&&(o+=`--auth-card-max-width: ${r.maxWidth}; `),r.padding&&(o+=`--auth-card-padding: ${r.padding}; `),r.border&&(o+=`--auth-card-border: ${r.border}; `),o},Oi=e=>{const t=Fi(e);if(e?.debug&&(console.log("🎨 Applying auth theme:",e),console.log("🎨 Generated CSS variables:",t)),!t){e?.debug&&console.log("🎨 No CSS variables generated from auth config");return}let r=document.getElementById("auth-theme-variables");r||(r=document.createElement("style"),r.id="auth-theme-variables",document.head.appendChild(r));const o=`
109
+ */const Nr=Le("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
110
+ * @license lucide-react v0.544.0 - ISC
111
+ *
112
+ * This source code is licensed under the ISC license.
113
+ * See the LICENSE file in the root directory of this source tree.
114
+ */const Di=Le("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);function go(e,t){return function(){return e.apply(t,arguments)}}const{toString:Bi}=Object.prototype,{getPrototypeOf:Lr}=Object,{iterator:zt,toStringTag:mo}=Symbol,Wt=(e=>t=>{const r=Bi.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Me=e=>(e=e.toLowerCase(),t=>Wt(t)===e),Kt=e=>t=>typeof t===e,{isArray:ft}=Array,ht=Kt("undefined");function At(e){return e!==null&&!ht(e)&&e.constructor!==null&&!ht(e.constructor)&&Se(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const wo=Me("ArrayBuffer");function $i(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&wo(e.buffer),t}const qi=Kt("string"),Se=Kt("function"),yo=Kt("number"),_t=e=>e!==null&&typeof e=="object",Vi=e=>e===!0||e===!1,Zt=e=>{if(Wt(e)!=="object")return!1;const t=Lr(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(mo in e)&&!(zt in e)},ji=e=>{if(!_t(e)||At(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Hi=Me("Date"),zi=Me("File"),Wi=Me("Blob"),Ki=Me("FileList"),Zi=e=>_t(e)&&Se(e.pipe),Gi=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Se(e.append)&&((t=Wt(e))==="formdata"||t==="object"&&Se(e.toString)&&e.toString()==="[object FormData]"))},Ji=Me("URLSearchParams"),[Xi,Yi,Qi,Ri]=["ReadableStream","Request","Response","Headers"].map(Me),el=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Nt(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let s,n;if(typeof e!="object"&&(e=[e]),ft(e))for(s=0,n=e.length;s<n;s++)t.call(null,e[s],s,e);else{if(At(e))return;const a=r?Object.getOwnPropertyNames(e):Object.keys(e),i=a.length;let l;for(s=0;s<i;s++)l=a[s],t.call(null,e[l],l,e)}}function bo(e,t){if(At(e))return null;t=t.toLowerCase();const r=Object.keys(e);let s=r.length,n;for(;s-- >0;)if(n=r[s],t===n.toLowerCase())return n;return null}const st=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,vo=e=>!ht(e)&&e!==st;function Tr(){const{caseless:e,skipUndefined:t}=vo(this)&&this||{},r={},s=(n,a)=>{const i=e&&bo(r,a)||a;Zt(r[i])&&Zt(n)?r[i]=Tr(r[i],n):Zt(n)?r[i]=Tr({},n):ft(n)?r[i]=n.slice():(!t||!ht(n))&&(r[i]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&Nt(arguments[n],s);return r}const tl=(e,t,r,{allOwnKeys:s}={})=>(Nt(t,(n,a)=>{r&&Se(n)?e[a]=go(n,r):e[a]=n},{allOwnKeys:s}),e),rl=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),sl=(e,t,r,s)=>{e.prototype=Object.create(t.prototype,s),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},ol=(e,t,r,s)=>{let n,a,i;const l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)i=n[a],(!s||s(i,e,t))&&!l[i]&&(t[i]=e[i],l[i]=!0);e=r!==!1&&Lr(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},nl=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const s=e.indexOf(t,r);return s!==-1&&s===r},al=e=>{if(!e)return null;if(ft(e))return e;let t=e.length;if(!yo(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},il=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Lr(Uint8Array)),ll=(e,t)=>{const s=(e&&e[zt]).call(e);let n;for(;(n=s.next())&&!n.done;){const a=n.value;t.call(e,a[0],a[1])}},cl=(e,t)=>{let r;const s=[];for(;(r=e.exec(t))!==null;)s.push(r);return s},dl=Me("HTMLFormElement"),ul=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,s,n){return s.toUpperCase()+n}),Co=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),fl=Me("RegExp"),xo=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),s={};Nt(r,(n,a)=>{let i;(i=t(n,a,e))!==!1&&(s[a]=i||n)}),Object.defineProperties(e,s)},hl=e=>{xo(e,(t,r)=>{if(Se(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const s=e[r];if(Se(s)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},pl=(e,t)=>{const r={},s=n=>{n.forEach(a=>{r[a]=!0})};return ft(e)?s(e):s(String(e).split(t)),r},gl=()=>{},ml=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function wl(e){return!!(e&&Se(e.append)&&e[mo]==="FormData"&&e[zt])}const yl=e=>{const t=new Array(10),r=(s,n)=>{if(_t(s)){if(t.indexOf(s)>=0)return;if(At(s))return s;if(!("toJSON"in s)){t[n]=s;const a=ft(s)?[]:{};return Nt(s,(i,l)=>{const u=r(i,n+1);!ht(u)&&(a[l]=u)}),t[n]=void 0,a}}return s};return r(e,0)},bl=Me("AsyncFunction"),vl=e=>e&&(_t(e)||Se(e))&&Se(e.then)&&Se(e.catch),Po=((e,t)=>e?setImmediate:t?((r,s)=>(st.addEventListener("message",({source:n,data:a})=>{n===st&&a===r&&s.length&&s.shift()()},!1),n=>{s.push(n),st.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Se(st.postMessage)),Cl=typeof queueMicrotask<"u"?queueMicrotask.bind(st):typeof process<"u"&&process.nextTick||Po,N={isArray:ft,isArrayBuffer:wo,isBuffer:At,isFormData:Gi,isArrayBufferView:$i,isString:qi,isNumber:yo,isBoolean:Vi,isObject:_t,isPlainObject:Zt,isEmptyObject:ji,isReadableStream:Xi,isRequest:Yi,isResponse:Qi,isHeaders:Ri,isUndefined:ht,isDate:Hi,isFile:zi,isBlob:Wi,isRegExp:fl,isFunction:Se,isStream:Zi,isURLSearchParams:Ji,isTypedArray:il,isFileList:Ki,forEach:Nt,merge:Tr,extend:tl,trim:el,stripBOM:rl,inherits:sl,toFlatObject:ol,kindOf:Wt,kindOfTest:Me,endsWith:nl,toArray:al,forEachEntry:ll,matchAll:cl,isHTMLForm:dl,hasOwnProperty:Co,hasOwnProp:Co,reduceDescriptors:xo,freezeMethods:hl,toObjectSet:pl,toCamelCase:ul,noop:gl,toFiniteNumber:ml,findKey:bo,global:st,isContextDefined:vo,isSpecCompliantForm:wl,toJSONObject:yl,isAsyncFn:bl,isThenable:vl,setImmediate:Po,asap:Cl,isIterable:e=>e!=null&&Se(e[zt])};function Q(e,t,r,s,n){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),r&&(this.config=r),s&&(this.request=s),n&&(this.response=n,this.status=n.status?n.status:null)}N.inherits(Q,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:N.toJSONObject(this.config),code:this.code,status:this.status}}});const So=Q.prototype,ko={};["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=>{ko[e]={value:e}}),Object.defineProperties(Q,ko),Object.defineProperty(So,"isAxiosError",{value:!0}),Q.from=(e,t,r,s,n,a)=>{const i=Object.create(So);N.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const l=e&&e.message?e.message:"Error",u=t==null&&e?e.code:t;return Q.call(i,l,u,r,s,n),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",a&&Object.assign(i,a),i};const xl=null;function Or(e){return N.isPlainObject(e)||N.isArray(e)}function Eo(e){return N.endsWith(e,"[]")?e.slice(0,-2):e}function Ao(e,t,r){return e?e.concat(t).map(function(n,a){return n=Eo(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function Pl(e){return N.isArray(e)&&!e.some(Or)}const Sl=N.toFlatObject(N,{},null,function(t){return/^is[A-Z]/.test(t)});function Gt(e,t,r){if(!N.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=N.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,b){return!N.isUndefined(b[w])});const s=r.metaTokens,n=r.visitor||d,a=r.dots,i=r.indexes,u=(r.Blob||typeof Blob<"u"&&Blob)&&N.isSpecCompliantForm(t);if(!N.isFunction(n))throw new TypeError("visitor must be a function");function c(p){if(p===null)return"";if(N.isDate(p))return p.toISOString();if(N.isBoolean(p))return p.toString();if(!u&&N.isBlob(p))throw new Q("Blob is not supported. Use a Buffer instead.");return N.isArrayBuffer(p)||N.isTypedArray(p)?u&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function d(p,w,b){let k=p;if(p&&!b&&typeof p=="object"){if(N.endsWith(w,"{}"))w=s?w:w.slice(0,-2),p=JSON.stringify(p);else if(N.isArray(p)&&Pl(p)||(N.isFileList(p)||N.endsWith(w,"[]"))&&(k=N.toArray(p)))return w=Eo(w),k.forEach(function(M,I){!(N.isUndefined(M)||M===null)&&t.append(i===!0?Ao([w],I,a):i===null?w:w+"[]",c(M))}),!1}return Or(p)?!0:(t.append(Ao(b,w,a),c(p)),!1)}const f=[],m=Object.assign(Sl,{defaultVisitor:d,convertValue:c,isVisitable:Or});function g(p,w){if(!N.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(p),N.forEach(p,function(k,C){(!(N.isUndefined(k)||k===null)&&n.call(t,k,N.isString(C)?C.trim():C,w,m))===!0&&g(k,w?w.concat(C):[C])}),f.pop()}}if(!N.isObject(e))throw new TypeError("data must be an object");return g(e),t}function _o(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return t[s]})}function Fr(e,t){this._pairs=[],e&&Gt(e,this,t)}const No=Fr.prototype;No.append=function(t,r){this._pairs.push([t,r])},No.toString=function(t){const r=t?function(s){return t.call(this,s,_o)}:_o;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};function kl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Lo(e,t,r){if(!t)return e;const s=r&&r.encode||kl;N.isFunction(r)&&(r={serialize:r});const n=r&&r.serialize;let a;if(n?a=n(t,r):a=N.isURLSearchParams(t)?t.toString():new Fr(t,r).toString(s),a){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}class To{constructor(){this.handlers=[]}use(t,r,s){return this.handlers.push({fulfilled:t,rejected:r,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){N.forEach(this.handlers,function(s){s!==null&&t(s)})}}const Oo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},El={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Fr,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Mr=typeof window<"u"&&typeof document<"u",Ir=typeof navigator=="object"&&navigator||void 0,Al=Mr&&(!Ir||["ReactNative","NativeScript","NS"].indexOf(Ir.product)<0),_l=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Nl=Mr&&window.location.href||"http://localhost",pe={...Object.freeze({__proto__:null,hasBrowserEnv:Mr,hasStandardBrowserEnv:Al,hasStandardBrowserWebWorkerEnv:_l,navigator:Ir,origin:Nl}),...El};function Ll(e,t){return Gt(e,new pe.classes.URLSearchParams,{visitor:function(r,s,n,a){return pe.isNode&&N.isBuffer(r)?(this.append(s,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function Tl(e){return N.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Ol(e){const t={},r=Object.keys(e);let s;const n=r.length;let a;for(s=0;s<n;s++)a=r[s],t[a]=e[a];return t}function Fo(e){function t(r,s,n,a){let i=r[a++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),u=a>=r.length;return i=!i&&N.isArray(n)?n.length:i,u?(N.hasOwnProp(n,i)?n[i]=[n[i],s]:n[i]=s,!l):((!n[i]||!N.isObject(n[i]))&&(n[i]=[]),t(r,s,n[i],a)&&N.isArray(n[i])&&(n[i]=Ol(n[i])),!l)}if(N.isFormData(e)&&N.isFunction(e.entries)){const r={};return N.forEachEntry(e,(s,n)=>{t(Tl(s),n,r,0)}),r}return null}function Fl(e,t,r){if(N.isString(e))try{return(t||JSON.parse)(e),N.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(r||JSON.stringify)(e)}const Lt={transitional:Oo,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const s=r.getContentType()||"",n=s.indexOf("application/json")>-1,a=N.isObject(t);if(a&&N.isHTMLForm(t)&&(t=new FormData(t)),N.isFormData(t))return n?JSON.stringify(Fo(t)):t;if(N.isArrayBuffer(t)||N.isBuffer(t)||N.isStream(t)||N.isFile(t)||N.isBlob(t)||N.isReadableStream(t))return t;if(N.isArrayBufferView(t))return t.buffer;if(N.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Ll(t,this.formSerializer).toString();if((l=N.isFileList(t))||s.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return Gt(l?{"files[]":t}:t,u&&new u,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),Fl(t)):t}],transformResponse:[function(t){const r=this.transitional||Lt.transitional,s=r&&r.forcedJSONParsing,n=this.responseType==="json";if(N.isResponse(t)||N.isReadableStream(t))return t;if(t&&N.isString(t)&&(s&&!this.responseType||n)){const i=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(l){if(i)throw l.name==="SyntaxError"?Q.from(l,Q.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:pe.classes.FormData,Blob:pe.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};N.forEach(["delete","get","head","post","put","patch"],e=>{Lt.headers[e]={}});const Ml=N.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"]),Il=e=>{const t={};let r,s,n;return e&&e.split(`
115
+ `).forEach(function(i){n=i.indexOf(":"),r=i.substring(0,n).trim().toLowerCase(),s=i.substring(n+1).trim(),!(!r||t[r]&&Ml[r])&&(r==="set-cookie"?t[r]?t[r].push(s):t[r]=[s]:t[r]=t[r]?t[r]+", "+s:s)}),t},Mo=Symbol("internals");function Tt(e){return e&&String(e).trim().toLowerCase()}function Jt(e){return e===!1||e==null?e:N.isArray(e)?e.map(Jt):String(e)}function Ul(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=r.exec(e);)t[s[1]]=s[2];return t}const Dl=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ur(e,t,r,s,n){if(N.isFunction(s))return s.call(this,t,r);if(n&&(t=r),!!N.isString(t)){if(N.isString(s))return t.indexOf(s)!==-1;if(N.isRegExp(s))return s.test(t)}}function Bl(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,s)=>r.toUpperCase()+s)}function $l(e,t){const r=N.toCamelCase(" "+t);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+r,{value:function(n,a,i){return this[s].call(this,t,n,a,i)},configurable:!0})})}let ke=class{constructor(t){t&&this.set(t)}set(t,r,s){const n=this;function a(l,u,c){const d=Tt(u);if(!d)throw new Error("header name must be a non-empty string");const f=N.findKey(n,d);(!f||n[f]===void 0||c===!0||c===void 0&&n[f]!==!1)&&(n[f||u]=Jt(l))}const i=(l,u)=>N.forEach(l,(c,d)=>a(c,d,u));if(N.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(N.isString(t)&&(t=t.trim())&&!Dl(t))i(Il(t),r);else if(N.isObject(t)&&N.isIterable(t)){let l={},u,c;for(const d of t){if(!N.isArray(d))throw TypeError("Object iterator must return a key-value pair");l[c=d[0]]=(u=l[c])?N.isArray(u)?[...u,d[1]]:[u,d[1]]:d[1]}i(l,r)}else t!=null&&a(r,t,s);return this}get(t,r){if(t=Tt(t),t){const s=N.findKey(this,t);if(s){const n=this[s];if(!r)return n;if(r===!0)return Ul(n);if(N.isFunction(r))return r.call(this,n,s);if(N.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Tt(t),t){const s=N.findKey(this,t);return!!(s&&this[s]!==void 0&&(!r||Ur(this,this[s],s,r)))}return!1}delete(t,r){const s=this;let n=!1;function a(i){if(i=Tt(i),i){const l=N.findKey(s,i);l&&(!r||Ur(s,s[l],l,r))&&(delete s[l],n=!0)}}return N.isArray(t)?t.forEach(a):a(t),n}clear(t){const r=Object.keys(this);let s=r.length,n=!1;for(;s--;){const a=r[s];(!t||Ur(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){const r=this,s={};return N.forEach(this,(n,a)=>{const i=N.findKey(s,a);if(i){r[i]=Jt(n),delete r[a];return}const l=t?Bl(a):String(a).trim();l!==a&&delete r[a],r[l]=Jt(n),s[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return N.forEach(this,(s,n)=>{s!=null&&s!==!1&&(r[n]=t&&N.isArray(s)?s.join(", "):s)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
116
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const s=new this(t);return r.forEach(n=>s.set(n)),s}static accessor(t){const s=(this[Mo]=this[Mo]={accessors:{}}).accessors,n=this.prototype;function a(i){const l=Tt(i);s[l]||($l(n,i),s[l]=!0)}return N.isArray(t)?t.forEach(a):a(t),this}};ke.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),N.reduceDescriptors(ke.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[r]=s}}}),N.freezeMethods(ke);function Dr(e,t){const r=this||Lt,s=t||r,n=ke.from(s.headers);let a=s.data;return N.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function Io(e){return!!(e&&e.__CANCEL__)}function pt(e,t,r){Q.call(this,e??"canceled",Q.ERR_CANCELED,t,r),this.name="CanceledError"}N.inherits(pt,Q,{__CANCEL__:!0});function Uo(e,t,r){const s=r.config.validateStatus;!r.status||!s||s(r.status)?e(r):t(new Q("Request failed with status code "+r.status,[Q.ERR_BAD_REQUEST,Q.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function ql(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Vl(e,t){e=e||10;const r=new Array(e),s=new Array(e);let n=0,a=0,i;return t=t!==void 0?t:1e3,function(u){const c=Date.now(),d=s[a];i||(i=c),r[n]=u,s[n]=c;let f=a,m=0;for(;f!==n;)m+=r[f++],f=f%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),c-i<t)return;const g=d&&c-d;return g?Math.round(m*1e3/g):void 0}}function jl(e,t){let r=0,s=1e3/t,n,a;const i=(c,d=Date.now())=>{r=d,n=null,a&&(clearTimeout(a),a=null),e(...c)};return[(...c)=>{const d=Date.now(),f=d-r;f>=s?i(c,d):(n=c,a||(a=setTimeout(()=>{a=null,i(n)},s-f)))},()=>n&&i(n)]}const Xt=(e,t,r=3)=>{let s=0;const n=Vl(50,250);return jl(a=>{const i=a.loaded,l=a.lengthComputable?a.total:void 0,u=i-s,c=n(u),d=i<=l;s=i;const f={loaded:i,total:l,progress:l?i/l:void 0,bytes:u,rate:c||void 0,estimated:c&&l&&d?(l-i)/c:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(f)},r)},Do=(e,t)=>{const r=e!=null;return[s=>t[0]({lengthComputable:r,total:e,loaded:s}),t[1]]},Bo=e=>(...t)=>N.asap(()=>e(...t)),Hl=pe.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,pe.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(pe.origin),pe.navigator&&/(msie|trident)/i.test(pe.navigator.userAgent)):()=>!0,zl=pe.hasStandardBrowserEnv?{write(e,t,r,s,n,a,i){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];N.isNumber(r)&&l.push(`expires=${new Date(r).toUTCString()}`),N.isString(s)&&l.push(`path=${s}`),N.isString(n)&&l.push(`domain=${n}`),a===!0&&l.push("secure"),N.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Wl(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Kl(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function $o(e,t,r){let s=!Wl(t);return e&&(s||r==!1)?Kl(e,t):t}const qo=e=>e instanceof ke?{...e}:e;function ot(e,t){t=t||{};const r={};function s(c,d,f,m){return N.isPlainObject(c)&&N.isPlainObject(d)?N.merge.call({caseless:m},c,d):N.isPlainObject(d)?N.merge({},d):N.isArray(d)?d.slice():d}function n(c,d,f,m){if(N.isUndefined(d)){if(!N.isUndefined(c))return s(void 0,c,f,m)}else return s(c,d,f,m)}function a(c,d){if(!N.isUndefined(d))return s(void 0,d)}function i(c,d){if(N.isUndefined(d)){if(!N.isUndefined(c))return s(void 0,c)}else return s(void 0,d)}function l(c,d,f){if(f in t)return s(c,d);if(f in e)return s(void 0,c)}const u={url:a,method:a,data:a,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(c,d,f)=>n(qo(c),qo(d),f,!0)};return N.forEach(Object.keys({...e,...t}),function(d){const f=u[d]||n,m=f(e[d],t[d],d);N.isUndefined(m)&&f!==l||(r[d]=m)}),r}const Vo=e=>{const t=ot({},e);let{data:r,withXSRFToken:s,xsrfHeaderName:n,xsrfCookieName:a,headers:i,auth:l}=t;if(t.headers=i=ke.from(i),t.url=Lo($o(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),N.isFormData(r)){if(pe.hasStandardBrowserEnv||pe.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(N.isFunction(r.getHeaders)){const u=r.getHeaders(),c=["content-type","content-length"];Object.entries(u).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(pe.hasStandardBrowserEnv&&(s&&N.isFunction(s)&&(s=s(t)),s||s!==!1&&Hl(t.url))){const u=n&&a&&zl.read(a);u&&i.set(n,u)}return t},Zl=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,s){const n=Vo(e);let a=n.data;const i=ke.from(n.headers).normalize();let{responseType:l,onUploadProgress:u,onDownloadProgress:c}=n,d,f,m,g,p;function w(){g&&g(),p&&p(),n.cancelToken&&n.cancelToken.unsubscribe(d),n.signal&&n.signal.removeEventListener("abort",d)}let b=new XMLHttpRequest;b.open(n.method.toUpperCase(),n.url,!0),b.timeout=n.timeout;function k(){if(!b)return;const M=ke.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),q={data:!l||l==="text"||l==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:M,config:e,request:b};Uo(function(_){r(_),w()},function(_){s(_),w()},q),b=null}"onloadend"in b?b.onloadend=k:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(k)},b.onabort=function(){b&&(s(new Q("Request aborted",Q.ECONNABORTED,e,b)),b=null)},b.onerror=function(I){const q=I&&I.message?I.message:"Network Error",E=new Q(q,Q.ERR_NETWORK,e,b);E.event=I||null,s(E),b=null},b.ontimeout=function(){let I=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const q=n.transitional||Oo;n.timeoutErrorMessage&&(I=n.timeoutErrorMessage),s(new Q(I,q.clarifyTimeoutError?Q.ETIMEDOUT:Q.ECONNABORTED,e,b)),b=null},a===void 0&&i.setContentType(null),"setRequestHeader"in b&&N.forEach(i.toJSON(),function(I,q){b.setRequestHeader(q,I)}),N.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),l&&l!=="json"&&(b.responseType=n.responseType),c&&([m,p]=Xt(c,!0),b.addEventListener("progress",m)),u&&b.upload&&([f,g]=Xt(u),b.upload.addEventListener("progress",f),b.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(d=M=>{b&&(s(!M||M.type?new pt(null,e,b):M),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(d),n.signal&&(n.signal.aborted?d():n.signal.addEventListener("abort",d)));const C=ql(n.url);if(C&&pe.protocols.indexOf(C)===-1){s(new Q("Unsupported protocol "+C+":",Q.ERR_BAD_REQUEST,e));return}b.send(a||null)})},Gl=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let s=new AbortController,n;const a=function(c){if(!n){n=!0,l();const d=c instanceof Error?c:this.reason;s.abort(d instanceof Q?d:new pt(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,a(new Q(`timeout ${t} of ms exceeded`,Q.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(a):c.removeEventListener("abort",a)}),e=null)};e.forEach(c=>c.addEventListener("abort",a));const{signal:u}=s;return u.unsubscribe=()=>N.asap(l),u}},Jl=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let s=0,n;for(;s<r;)n=s+t,yield e.slice(s,n),s=n},Xl=async function*(e,t){for await(const r of Yl(e))yield*Jl(r,t)},Yl=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:s}=await t.read();if(r)break;yield s}}finally{await t.cancel()}},jo=(e,t,r,s)=>{const n=Xl(e,t);let a=0,i,l=u=>{i||(i=!0,s&&s(u))};return new ReadableStream({async pull(u){try{const{done:c,value:d}=await n.next();if(c){l(),u.close();return}let f=d.byteLength;if(r){let m=a+=f;r(m)}u.enqueue(new Uint8Array(d))}catch(c){throw l(c),c}},cancel(u){return l(u),n.return()}},{highWaterMark:2})},Ho=64*1024,{isFunction:Yt}=N,Ql=(({Request:e,Response:t})=>({Request:e,Response:t}))(N.global),{ReadableStream:zo,TextEncoder:Wo}=N.global,Ko=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Rl=e=>{e=N.merge.call({skipUndefined:!0},Ql,e);const{fetch:t,Request:r,Response:s}=e,n=t?Yt(t):typeof fetch=="function",a=Yt(r),i=Yt(s);if(!n)return!1;const l=n&&Yt(zo),u=n&&(typeof Wo=="function"?(p=>w=>p.encode(w))(new Wo):async p=>new Uint8Array(await new r(p).arrayBuffer())),c=a&&l&&Ko(()=>{let p=!1;const w=new r(pe.origin,{body:new zo,method:"POST",get duplex(){return p=!0,"half"}}).headers.has("Content-Type");return p&&!w}),d=i&&l&&Ko(()=>N.isReadableStream(new s("").body)),f={stream:d&&(p=>p.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!f[p]&&(f[p]=(w,b)=>{let k=w&&w[p];if(k)return k.call(w);throw new Q(`Response type '${p}' is not supported`,Q.ERR_NOT_SUPPORT,b)})});const m=async p=>{if(p==null)return 0;if(N.isBlob(p))return p.size;if(N.isSpecCompliantForm(p))return(await new r(pe.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(N.isArrayBufferView(p)||N.isArrayBuffer(p))return p.byteLength;if(N.isURLSearchParams(p)&&(p=p+""),N.isString(p))return(await u(p)).byteLength},g=async(p,w)=>{const b=N.toFiniteNumber(p.getContentLength());return b??m(w)};return async p=>{let{url:w,method:b,data:k,signal:C,cancelToken:M,timeout:I,onDownloadProgress:q,onUploadProgress:E,responseType:_,headers:P,withCredentials:O="same-origin",fetchOptions:W}=Vo(p),S=t||fetch;_=_?(_+"").toLowerCase():"text";let U=Gl([C,M&&M.toAbortSignal()],I),A=null;const L=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let v;try{if(E&&c&&b!=="get"&&b!=="head"&&(v=await g(P,k))!==0){let J=new r(w,{method:"POST",body:k,duplex:"half"}),ee;if(N.isFormData(k)&&(ee=J.headers.get("content-type"))&&P.setContentType(ee),J.body){const[$,H]=Do(v,Xt(Bo(E)));k=jo(J.body,Ho,$,H)}}N.isString(O)||(O=O?"include":"omit");const x=a&&"credentials"in r.prototype,F={...W,signal:U,method:b.toUpperCase(),headers:P.normalize().toJSON(),body:k,duplex:"half",credentials:x?O:void 0};A=a&&new r(w,F);let D=await(a?S(A,W):S(w,F));const Y=d&&(_==="stream"||_==="response");if(d&&(q||Y&&L)){const J={};["status","statusText","headers"].forEach(G=>{J[G]=D[G]});const ee=N.toFiniteNumber(D.headers.get("content-length")),[$,H]=q&&Do(ee,Xt(Bo(q),!0))||[];D=new s(jo(D.body,Ho,$,()=>{H&&H(),L&&L()}),J)}_=_||"text";let Z=await f[N.findKey(f,_)||"text"](D,p);return!Y&&L&&L(),await new Promise((J,ee)=>{Uo(J,ee,{data:Z,headers:ke.from(D.headers),status:D.status,statusText:D.statusText,config:p,request:A})})}catch(x){throw L&&L(),x&&x.name==="TypeError"&&/Load failed|fetch/i.test(x.message)?Object.assign(new Q("Network Error",Q.ERR_NETWORK,p,A),{cause:x.cause||x}):Q.from(x,x&&x.code,p,A)}}},ec=new Map,Zo=e=>{let t=e&&e.env||{};const{fetch:r,Request:s,Response:n}=t,a=[s,n,r];let i=a.length,l=i,u,c,d=ec;for(;l--;)u=a[l],c=d.get(u),c===void 0&&d.set(u,c=l?new Map:Rl(t)),d=c;return c};Zo();const Br={http:xl,xhr:Zl,fetch:{get:Zo}};N.forEach(Br,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Go=e=>`- ${e}`,tc=e=>N.isFunction(e)||e===null||e===!1;function rc(e,t){e=N.isArray(e)?e:[e];const{length:r}=e;let s,n;const a={};for(let i=0;i<r;i++){s=e[i];let l;if(n=s,!tc(s)&&(n=Br[(l=String(s)).toLowerCase()],n===void 0))throw new Q(`Unknown adapter '${l}'`);if(n&&(N.isFunction(n)||(n=n.get(t))))break;a[l||"#"+i]=n}if(!n){const i=Object.entries(a).map(([u,c])=>`adapter ${u} `+(c===!1?"is not supported by the environment":"is not available in the build"));let l=r?i.length>1?`since :
117
+ `+i.map(Go).join(`
118
+ `):" "+Go(i[0]):"as no adapter specified";throw new Q("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return n}const Jo={getAdapter:rc,adapters:Br};function $r(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new pt(null,e)}function Xo(e){return $r(e),e.headers=ke.from(e.headers),e.data=Dr.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Jo.getAdapter(e.adapter||Lt.adapter,e)(e).then(function(s){return $r(e),s.data=Dr.call(e,e.transformResponse,s),s.headers=ke.from(s.headers),s},function(s){return Io(s)||($r(e),s&&s.response&&(s.response.data=Dr.call(e,e.transformResponse,s.response),s.response.headers=ke.from(s.response.headers))),Promise.reject(s)})}const Yo="1.13.0",Qt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Qt[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const Qo={};Qt.transitional=function(t,r,s){function n(a,i){return"[Axios v"+Yo+"] Transitional option '"+a+"'"+i+(s?". "+s:"")}return(a,i,l)=>{if(t===!1)throw new Q(n(i," has been removed"+(r?" in "+r:"")),Q.ERR_DEPRECATED);return r&&!Qo[i]&&(Qo[i]=!0,console.warn(n(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(a,i,l):!0}},Qt.spelling=function(t){return(r,s)=>(console.warn(`${s} is likely a misspelling of ${t}`),!0)};function sc(e,t,r){if(typeof e!="object")throw new Q("options must be an object",Q.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let n=s.length;for(;n-- >0;){const a=s[n],i=t[a];if(i){const l=e[a],u=l===void 0||i(l,a,e);if(u!==!0)throw new Q("option "+a+" must be "+u,Q.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Q("Unknown option "+a,Q.ERR_BAD_OPTION)}}const Rt={assertOptions:sc,validators:Qt},Be=Rt.validators;let nt=class{constructor(t){this.defaults=t||{},this.interceptors={request:new To,response:new To}}async request(t,r){try{return await this._request(t,r)}catch(s){if(s instanceof Error){let n={};Error.captureStackTrace?Error.captureStackTrace(n):n=new Error;const a=n.stack?n.stack.replace(/^.+\n/,""):"";try{s.stack?a&&!String(s.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(s.stack+=`
119
+ `+a):s.stack=a}catch{}}throw s}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ot(this.defaults,r);const{transitional:s,paramsSerializer:n,headers:a}=r;s!==void 0&&Rt.assertOptions(s,{silentJSONParsing:Be.transitional(Be.boolean),forcedJSONParsing:Be.transitional(Be.boolean),clarifyTimeoutError:Be.transitional(Be.boolean)},!1),n!=null&&(N.isFunction(n)?r.paramsSerializer={serialize:n}:Rt.assertOptions(n,{encode:Be.function,serialize:Be.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Rt.assertOptions(r,{baseUrl:Be.spelling("baseURL"),withXsrfToken:Be.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=a&&N.merge(a.common,a[r.method]);a&&N.forEach(["delete","get","head","post","put","patch","common"],p=>{delete a[p]}),r.headers=ke.concat(i,a);const l=[];let u=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(r)===!1||(u=u&&w.synchronous,l.unshift(w.fulfilled,w.rejected))});const c=[];this.interceptors.response.forEach(function(w){c.push(w.fulfilled,w.rejected)});let d,f=0,m;if(!u){const p=[Xo.bind(this),void 0];for(p.unshift(...l),p.push(...c),m=p.length,d=Promise.resolve(r);f<m;)d=d.then(p[f++],p[f++]);return d}m=l.length;let g=r;for(;f<m;){const p=l[f++],w=l[f++];try{g=p(g)}catch(b){w.call(this,b);break}}try{d=Xo.call(this,g)}catch(p){return Promise.reject(p)}for(f=0,m=c.length;f<m;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=ot(this.defaults,t);const r=$o(t.baseURL,t.url,t.allowAbsoluteUrls);return Lo(r,t.params,t.paramsSerializer)}};N.forEach(["delete","get","head","options"],function(t){nt.prototype[t]=function(r,s){return this.request(ot(s||{},{method:t,url:r,data:(s||{}).data}))}}),N.forEach(["post","put","patch"],function(t){function r(s){return function(a,i,l){return this.request(ot(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:a,data:i}))}}nt.prototype[t]=r(),nt.prototype[t+"Form"]=r(!0)});let oc=class qa{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=a});const s=this;this.promise.then(n=>{if(!s._listeners)return;let a=s._listeners.length;for(;a-- >0;)s._listeners[a](n);s._listeners=null}),this.promise.then=n=>{let a;const i=new Promise(l=>{s.subscribe(l),a=l}).then(n);return i.cancel=function(){s.unsubscribe(a)},i},t(function(a,i,l){s.reason||(s.reason=new pt(a,i,l),r(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=s=>{t.abort(s)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new qa(function(n){t=n}),cancel:t}}};function nc(e){return function(r){return e.apply(null,r)}}function ac(e){return N.isObject(e)&&e.isAxiosError===!0}const qr={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(qr).forEach(([e,t])=>{qr[t]=e});function Ro(e){const t=new nt(e),r=go(nt.prototype.request,t);return N.extend(r,nt.prototype,t,{allOwnKeys:!0}),N.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return Ro(ot(e,n))},r}const te=Ro(Lt);te.Axios=nt,te.CanceledError=pt,te.CancelToken=oc,te.isCancel=Io,te.VERSION=Yo,te.toFormData=Gt,te.AxiosError=Q,te.Cancel=te.CanceledError,te.all=function(t){return Promise.all(t)},te.spread=nc,te.isAxiosError=ac,te.mergeConfig=ot,te.AxiosHeaders=ke,te.formToJSON=e=>Fo(N.isHTMLForm(e)?new FormData(e):e),te.getAdapter=Jo.getAdapter,te.HttpStatusCode=qr,te.default=te;const{Axios:Zf,AxiosError:Gf,CanceledError:Jf,isCancel:Xf,CancelToken:Yf,VERSION:Qf,all:Rf,Cancel:eh,isAxiosError:th,spread:rh,toFormData:sh,AxiosHeaders:oh,HttpStatusCode:nh,formToJSON:ah,getAdapter:ih,mergeConfig:lh}=te,fe="/api/v1/appauth".replace(/\/+$/,"");class Ge{constructor(t,r=fe,s=te){this.basePath=r,this.axios=s,t&&(this.configuration=t,this.basePath=t.basePath??r)}}class ic extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}const ge={"UserProfileApi.getUserProfile":[{url:"/api/v1",description:"Profile API base URL"}],"UserProfileApi.updateUserProfile":[{url:"/api/v1",description:"Profile API base URL"}]},me="https://example.com",ae=function(e,t,r){if(r==null)throw new ic(t,`Required parameter ${t} was null or undefined when calling ${e}.`)};function Vr(e,t,r=""){t!=null&&(typeof t=="object"?Array.isArray(t)?t.forEach(s=>Vr(e,s,r)):Object.keys(t).forEach(s=>Vr(e,t[s],`${r}${r!==""?".":""}${s}`)):e.has(r)?e.append(r,t):e.set(r,t))}const we=function(e,...t){const r=new URLSearchParams(e.search);Vr(r,t),e.search=r.toString()},gt=function(e,t,r){const s=typeof e!="string";return(s&&r&&r.isJsonMime?r.isJsonMime(t.headers["Content-Type"]):s)?JSON.stringify(e!==void 0?e:{}):e||""},ye=function(e){return e.pathname+e.search+e.hash},be=function(e,t,r,s){return(n=t,a=r)=>{const i={...e.options,url:(n.defaults.baseURL?"":s?.basePath??a)+e.url};return n.request(i)}},lc=function(e){return{getAppAuthConfig:async(t={})=>{const r="/config/",s=new URL(r,me);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t},i={};we(s,{});let u=n&&n.headers?n.headers:{};return a.headers={...i,...u,...t.headers},{url:ye(s),options:a}},updateAppAuthConfig:async(t,r,s={})=>{ae("updateAppAuthConfig","xCSRFToken",t),ae("updateAppAuthConfig","authConfig",r);const n="/config/",a=new URL(n,me);let i;e&&(i=e.baseOptions);const l={method:"PUT",...i,...s},u={},c={},d=new(e&&e.formDataCtor||FormData);r!==void 0&&d.append("auth_config",r),u["Content-Type"]="multipart/form-data",t!=null&&(u["X-CSRFToken"]=String(t)),we(a,c);let f=i&&i.headers?i.headers:{};return l.headers={...u,...f,...s.headers},l.data=d,{url:ye(a),options:l}}}},en=function(e){const t=lc(e);return{async getAppAuthConfig(r){const s=await t.getAppAuthConfig(r),n=e?.serverIndex??0,a=ge["ApplicationConfigurationApi.getAppAuthConfig"]?.[n]?.url;return(i,l)=>be(s,te,fe,e)(i,a||l)},async updateAppAuthConfig(r,s,n){const a=await t.updateAppAuthConfig(r,s,n),i=e?.serverIndex??0,l=ge["ApplicationConfigurationApi.updateAppAuthConfig"]?.[i]?.url;return(u,c)=>be(a,te,fe,e)(u,l||c)}}};class cc extends Ge{getAppAuthConfig(t){return en(this.configuration).getAppAuthConfig(t).then(r=>r(this.axios,this.basePath))}updateAppAuthConfig(t,r,s){return en(this.configuration).updateAppAuthConfig(t,r,s).then(n=>n(this.axios,this.basePath))}}const dc=function(e){return{loginUser:async(t,r,s={})=>{ae("loginUser","xCSRFToken",t),ae("loginUser","loginUserRequest",r);const n="/login/",a=new URL(n,me);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},u={},c={};u["Content-Type"]="application/json",t!=null&&(u["X-CSRFToken"]=String(t)),we(a,c);let d=i&&i.headers?i.headers:{};return l.headers={...u,...d,...s.headers},l.data=gt(r,l,e),{url:ye(a),options:l}},logoutUser:async(t,r={})=>{ae("logoutUser","xCSRFToken",t);const s="/logout/",n=new URL(s,me);let a;e&&(a=e.baseOptions);const i={method:"DELETE",...a,...r},l={},u={};t!=null&&(l["X-CSRFToken"]=String(t)),we(n,u);let c=a&&a.headers?a.headers:{};return i.headers={...l,...c,...r.headers},{url:ye(n),options:i}}}},tn=function(e){const t=dc(e);return{async loginUser(r,s,n){const a=await t.loginUser(r,s,n),i=e?.serverIndex??0,l=ge["AuthenticationApi.loginUser"]?.[i]?.url;return(u,c)=>be(a,te,fe,e)(u,l||c)},async logoutUser(r,s){const n=await t.logoutUser(r,s),a=e?.serverIndex??0,i=ge["AuthenticationApi.logoutUser"]?.[a]?.url;return(l,u)=>be(n,te,fe,e)(l,i||u)}}};class uc extends Ge{loginUser(t,r,s){return tn(this.configuration).loginUser(t,r,s).then(n=>n(this.axios,this.basePath))}logoutUser(t,r){return tn(this.configuration).logoutUser(t,r).then(s=>s(this.axios,this.basePath))}}const fc=function(e){return{requestLoginOTP:async(t,r,s={})=>{ae("requestLoginOTP","xCSRFToken",t),ae("requestLoginOTP","loginOTPRequest",r);const n="/login/code/request/",a=new URL(n,me);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},u={},c={};u["Content-Type"]="application/json",t!=null&&(u["X-CSRFToken"]=String(t)),we(a,c);let d=i&&i.headers?i.headers:{};return l.headers={...u,...d,...s.headers},l.data=gt(r,l,e),{url:ye(a),options:l}},verifyLoginOTP:async(t,r,s={})=>{ae("verifyLoginOTP","xCSRFToken",t),ae("verifyLoginOTP","loginOTPVerifyRequest",r);const n="/login/code/confirm/",a=new URL(n,me);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},u={},c={};u["Content-Type"]="application/json",t!=null&&(u["X-CSRFToken"]=String(t)),we(a,c);let d=i&&i.headers?i.headers:{};return l.headers={...u,...d,...s.headers},l.data=gt(r,l,e),{url:ye(a),options:l}}}},rn=function(e){const t=fc(e);return{async requestLoginOTP(r,s,n){const a=await t.requestLoginOTP(r,s,n),i=e?.serverIndex??0,l=ge["LoginWithOTPApi.requestLoginOTP"]?.[i]?.url;return(u,c)=>be(a,te,fe,e)(u,l||c)},async verifyLoginOTP(r,s,n){const a=await t.verifyLoginOTP(r,s,n),i=e?.serverIndex??0,l=ge["LoginWithOTPApi.verifyLoginOTP"]?.[i]?.url;return(u,c)=>be(a,te,fe,e)(u,l||c)}}};class hc extends Ge{requestLoginOTP(t,r,s){return rn(this.configuration).requestLoginOTP(t,r,s).then(n=>n(this.axios,this.basePath))}verifyLoginOTP(t,r,s){return rn(this.configuration).verifyLoginOTP(t,r,s).then(n=>n(this.axios,this.basePath))}}const pc=function(e){return{getMfaCode:async(t={})=>{const r="/mfa/getcode/",s=new URL(r,me);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t},i={};we(s,{});let u=n&&n.headers?n.headers:{};return a.headers={...i,...u,...t.headers},{url:ye(s),options:a}},verifyMfaCode:async(t,r,s={})=>{ae("verifyMfaCode","xCSRFToken",t),ae("verifyMfaCode","mfaVerifyRequest",r);const n="/mfa/verify/",a=new URL(n,me);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},u={},c={};u["Content-Type"]="application/json",t!=null&&(u["X-CSRFToken"]=String(t)),we(a,c);let d=i&&i.headers?i.headers:{};return l.headers={...u,...d,...s.headers},l.data=gt(r,l,e),{url:ye(a),options:l}}}},sn=function(e){const t=pc(e);return{async getMfaCode(r){const s=await t.getMfaCode(r),n=e?.serverIndex??0,a=ge["MultiFactorAuthenticationApi.getMfaCode"]?.[n]?.url;return(i,l)=>be(s,te,fe,e)(i,a||l)},async verifyMfaCode(r,s,n){const a=await t.verifyMfaCode(r,s,n),i=e?.serverIndex??0,l=ge["MultiFactorAuthenticationApi.verifyMfaCode"]?.[i]?.url;return(u,c)=>be(a,te,fe,e)(u,l||c)}}};class gc extends Ge{getMfaCode(t){return sn(this.configuration).getMfaCode(t).then(r=>r(this.axios,this.basePath))}verifyMfaCode(t,r,s){return sn(this.configuration).verifyMfaCode(t,r,s).then(n=>n(this.axios,this.basePath))}}const mc=function(e){return{oauthCallback:async(t,r,s,n,a,i,l,u,c={})=>{ae("oauthCallback","provider",t),ae("oauthCallback","state",r),ae("oauthCallback","code",s),ae("oauthCallback","scope",n),ae("oauthCallback","xCSRFToken",a);const d="/oauth/{provider}/callback/".replace("{provider}",encodeURIComponent(String(t))),f=new URL(d,me);let m;e&&(m=e.baseOptions);const g={method:"POST",...m,...c},p={},w={};r!==void 0&&(w.state=r),s!==void 0&&(w.code=s),n!==void 0&&(w.scope=n),i!==void 0&&(w.authuser=i),l!==void 0&&(w.hd=l),u!==void 0&&(w.prompt=u),a!=null&&(p["X-CSRFToken"]=String(a)),we(f,w);let b=m&&m.headers?m.headers:{};return g.headers={...p,...b,...c.headers},{url:ye(f),options:g}},oauthRedirect:async(t,r,s,n,a={})=>{ae("oauthRedirect","xCsrftoken",t),ae("oauthRedirect","provider",r),ae("oauthRedirect","process",s),ae("oauthRedirect","callbackUrl",n);const i="/oauth/redirect/",l=new URL(i,me);let u;e&&(u=e.baseOptions);const c={method:"POST",...u,...a},d={},f={},m=new URLSearchParams;r!==void 0&&m.set("provider",r),s!==void 0&&m.set("process",s),n!==void 0&&m.set("callback_url",n),d["Content-Type"]="application/x-www-form-urlencoded",t!=null&&(d["x-csrftoken"]=String(t)),we(l,f);let g=u&&u.headers?u.headers:{};return c.headers={...d,...g,...a.headers},c.data=m.toString(),{url:ye(l),options:c}}}},on=function(e){const t=mc(e);return{async oauthCallback(r,s,n,a,i,l,u,c,d){const f=await t.oauthCallback(r,s,n,a,i,l,u,c,d),m=e?.serverIndex??0,g=ge["OAuthApi.oauthCallback"]?.[m]?.url;return(p,w)=>be(f,te,fe,e)(p,g||w)},async oauthRedirect(r,s,n,a,i){const l=await t.oauthRedirect(r,s,n,a,i),u=e?.serverIndex??0,c=ge["OAuthApi.oauthRedirect"]?.[u]?.url;return(d,f)=>be(l,te,fe,e)(d,c||f)}}};class wc extends Ge{oauthCallback(t,r,s,n,a,i,l,u,c){return on(this.configuration).oauthCallback(t,r,s,n,a,i,l,u,c).then(d=>d(this.axios,this.basePath))}oauthRedirect(t,r,s,n,a){return on(this.configuration).oauthRedirect(t,r,s,n,a).then(i=>i(this.axios,this.basePath))}}const yc=function(e){return{changePassword:async(t,r,s={})=>{ae("changePassword","xCSRFToken",t),ae("changePassword","passwordChangeRequest",r);const n="/password/change/",a=new URL(n,me);let i;e&&(i=e.baseOptions);const l={method:"PUT",...i,...s},u={},c={};u["Content-Type"]="application/json",t!=null&&(u["X-CSRFToken"]=String(t)),we(a,c);let d=i&&i.headers?i.headers:{};return l.headers={...u,...d,...s.headers},l.data=gt(r,l,e),{url:ye(a),options:l}},setPassword:async(t,r,s={})=>{ae("setPassword","xCSRFToken",t),ae("setPassword","passwordSetRequest",r);const n="/password/set/",a=new URL(n,me);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},u={},c={};u["Content-Type"]="application/json",t!=null&&(u["X-CSRFToken"]=String(t)),we(a,c);let d=i&&i.headers?i.headers:{};return l.headers={...u,...d,...s.headers},l.data=gt(r,l,e),{url:ye(a),options:l}}}},nn=function(e){const t=yc(e);return{async changePassword(r,s,n){const a=await t.changePassword(r,s,n),i=e?.serverIndex??0,l=ge["PasswordManagementApi.changePassword"]?.[i]?.url;return(u,c)=>be(a,te,fe,e)(u,l||c)},async setPassword(r,s,n){const a=await t.setPassword(r,s,n),i=e?.serverIndex??0,l=ge["PasswordManagementApi.setPassword"]?.[i]?.url;return(u,c)=>be(a,te,fe,e)(u,l||c)}}};class bc extends Ge{changePassword(t,r,s){return nn(this.configuration).changePassword(t,r,s).then(n=>n(this.axios,this.basePath))}setPassword(t,r,s){return nn(this.configuration).setPassword(t,r,s).then(n=>n(this.axios,this.basePath))}}const vc=function(e){return{setRole:async(t,r,s={})=>{ae("setRole","xCSRFToken",t),ae("setRole","role",r);const n="/role/set/",a=new URL(n,me);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},u={},c={};r!==void 0&&(c.role=r),t!=null&&(u["X-CSRFToken"]=String(t)),we(a,c);let d=i&&i.headers?i.headers:{};return l.headers={...u,...d,...s.headers},{url:ye(a),options:l}},switchRole:async(t,r,s={})=>{ae("switchRole","xCSRFToken",t),ae("switchRole","role",r);const n="/role/switch/",a=new URL(n,me);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},u={},c={};r!==void 0&&(c.role=r),t!=null&&(u["X-CSRFToken"]=String(t)),we(a,c);let d=i&&i.headers?i.headers:{};return l.headers={...u,...d,...s.headers},{url:ye(a),options:l}}}},an=function(e){const t=vc(e);return{async setRole(r,s,n){const a=await t.setRole(r,s,n),i=e?.serverIndex??0,l=ge["RoleManagementApi.setRole"]?.[i]?.url;return(u,c)=>be(a,te,fe,e)(u,l||c)},async switchRole(r,s,n){const a=await t.switchRole(r,s,n),i=e?.serverIndex??0,l=ge["RoleManagementApi.switchRole"]?.[i]?.url;return(u,c)=>be(a,te,fe,e)(u,l||c)}}};class Cc extends Ge{setRole(t,r,s){return an(this.configuration).setRole(t,r,s).then(n=>n(this.axios,this.basePath))}switchRole(t,r,s){return an(this.configuration).switchRole(t,r,s).then(n=>n(this.axios,this.basePath))}}const xc=function(e){return{getUserProfile:async(t={})=>{const r="/profile/",s=new URL(r,me);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t},i={};we(s,{});let u=n&&n.headers?n.headers:{};return a.headers={...i,...u,...t.headers},{url:ye(s),options:a}},updateUserProfile:async(t,r,s,n,a,i={})=>{ae("updateUserProfile","xCSRFToken",t);const l="/profile/",u=new URL(l,me);let c;e&&(c=e.baseOptions);const d={method:"PUT",...c,...i},f={},m={},g=new(e&&e.formDataCtor||FormData);r!==void 0&&g.append("name",r),s!==void 0&&g.append("mobile",s),n!==void 0&&g.append("auth_config",n),a!==void 0&&g.append("profile_pic",a),f["Content-Type"]="multipart/form-data",t!=null&&(f["X-CSRFToken"]=String(t)),we(u,m);let p=c&&c.headers?c.headers:{};return d.headers={...f,...p,...i.headers},d.data=g,{url:ye(u),options:d}}}},ln=function(e){const t=xc(e);return{async getUserProfile(r){const s=await t.getUserProfile(r),n=e?.serverIndex??0,a=ge["UserProfileApi.getUserProfile"]?.[n]?.url;return(i,l)=>be(s,te,fe,e)(i,a||l)},async updateUserProfile(r,s,n,a,i,l){const u=await t.updateUserProfile(r,s,n,a,i,l),c=e?.serverIndex??0,d=ge["UserProfileApi.updateUserProfile"]?.[c]?.url;return(f,m)=>be(u,te,fe,e)(f,d||m)}}};class cn extends Ge{getUserProfile(t){return ln(this.configuration).getUserProfile(t).then(r=>r(this.axios,this.basePath))}updateUserProfile(t,r,s,n,a,i){return ln(this.configuration).updateUserProfile(t,r,s,n,a,i).then(l=>l(this.axios,this.basePath))}}class dn{constructor(t={}){this.apiKey=t.apiKey,this.username=t.username,this.password=t.password,this.accessToken=t.accessToken,this.basePath=t.basePath,this.serverIndex=t.serverIndex,this.baseOptions={...t.baseOptions,headers:{...t.baseOptions?.headers}},this.formDataCtor=t.formDataCtor}isJsonMime(t){const r=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return t!==null&&(r.test(t)||t.toLowerCase()==="application/json-patch+json")}}const er="/api/v1/appauth",Je=new dn({basePath:er,baseOptions:{withCredentials:!0}}),jr=new uc(Je),un=new cc(Je),Hr=new hc(Je),zr=new gc(Je),mt=new bc(Je),fn=new Cc(Je),hn=new wc(Je);new cn(Je);const Ee=()=>{const e=document.cookie.match(/csrftoken=([^;]+)/);if(e)return decodeURIComponent(e[1]);const t=document.querySelector('meta[name="csrf-token"]');if(t)return t.getAttribute("content");const r=document.cookie.match(/csrf_token=([^;]+)/);return r?decodeURIComponent(r[1]):(console.warn("CSRF token not found. OTP requests may fail."),"")};let oe=null,at=null;const Te=e=>e.response?.data?.errors?.[0]?.message?e.response.data.errors[0].message:e.response?.data?.response?.errors?.[0]?.message?e.response.data.response.errors[0].message:e.response?.data?.response?.message?e.response.data.response.message:e.response?.data?.message?e.response.data.message:e.message?e.message:"An unexpected error occurred",j={async getAuthConfig(){return oe||at||(at=(async()=>{try{const t=(await un.getAppAuthConfig()).data;return t?.response?.auth_config?oe=t.response.auth_config:t?.auth_config?oe=t.auth_config:oe=t,oe}catch(e){throw console.error("Failed to fetch auth config:",e),at=null,e}finally{at=null}})(),at)},getConfig(){return oe},isPasswordLoginEnabled(){return oe?.login_methods?.password?.enabled||!1},isOTPLoginEnabled(){return oe?.login_methods?.otp?.enabled||!1},isSSOEnabled(){return oe?.login_methods?.sso?.enabled||!1},isOIDCEnabled(){return oe?.login_methods?.oidc?.enabled||!1},getOIDCProviders(){return oe?.login_methods?.oidc?.providers||[]},getSSOProviders(){return oe?.login_methods?.sso?.providers||[]},getAllowedUsernames(){return(oe?.login_methods?.password?.allowed_usernames||oe?.login_methods?.allowed_usernames||["email"]).map(t=>t==="phone"?"mobile":t)},isForgotPasswordEnabled(){return oe?.password_policy?.reset?.enabled||!1},getPasswordResetLinkExpiry(){return oe?.login_methods?.password?.password_reset_link_expiry_hours||24},getSessionPolicy(){return oe?.session_policy||{}},isRememberMeEnabled(){return oe?.session_policy?.remember_me_enabled!==!1},getRememberMeDurationDays(){return oe?.session_policy?.remember_me_duration_days||30},getPasswordPolicy(){return oe?.password_policy||{}},getPasswordResetMethods(){return oe?.password_policy?.reset?.method||[]},isPasswordResetEnabled(){return oe?.password_policy?.reset?.enabled||!1},getPasswordResetExpiry(){return oe?.password_policy?.reset?.expiry_hours||24},isTwoFactorRequired(){return oe?.two_factor_auth?.required||!1},getTwoFactorMethods(){return oe?.two_factor_auth?.allowedMethods||[]},getTwoFactorHooks(){return{email:oe?.two_factor_auth?.email_hook,sms:oe?.two_factor_auth?.sms_hook}},async login(e,t={}){try{oe||await this.getAuthConfig();const r=Ee()||"",s=e,n=await jr.loginUser(r,s),a=n.data;if(a?.success&&a?.response){const i=a.response;return i.status===401&&i.data?.next_step?i:i.data||i}return n.data}catch(r){if(console.error("Login error:",r),r.response?.data?.response?.error_code==="ACCOUNT_LOCKED")return window.location.href="/app/login",new Promise(()=>{});if(r.response?.status===401&&r.response?.data){const n=r.response.data;if(n?.success&&n?.response){const a=n.response;if(a.status===401&&a.data?.next_step)return a}if(n?.response?.data?.next_step||n?.data?.next_step)return n}const s=Te(r);throw s!=="An unexpected error occurred"?new Error(s):r}},async logout(e={}){try{const t=Ee()||"";await jr.logoutUser(t)}catch(t){console.error("Logout error:",t);const r=Te(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async getCurrentUser(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return Un});if(!e())throw new Error("Not authenticated - no valid session cookie");return{id:1,username:"authenticated_user",email:"user@example.com",authenticated:!0}}catch(e){console.error("Get current user failed:",e);const t=Te(e);throw t!=="An unexpected error occurred"?new Error(t):new Error("Authentication verification failed")}},async verifyToken(e,t={}){return this.getCurrentUser()},async forgotPassword(e){try{return typeof e=="string"?this.requestPasswordReset({email:e}):this.requestPasswordReset(e)}catch(t){throw t}},async requestPasswordReset(e){try{const t=Ee()||"";return(await mt.axios.post(`${er}/password/reset/request/`,e,{headers:{"X-CSRFToken":t}})).data}catch(t){console.error("Request password reset error:",t);const r=Te(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async validatePasswordResetKey(e){try{return(await mt.axios.get(`${er}/password/reset/`,{headers:{"x-password-reset-key":e}})).data}catch(t){console.error("Validate password reset key error:",t);const r=Te(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async confirmResetPassword(e){try{const t=Ee()||"";return(await mt.axios.post(`${er}/password/reset/`,e,{headers:{"X-CSRFToken":t}})).data}catch(t){if(console.error("Confirm reset password error:",t),t.response?.status===401&&t.response?.data){const s=t.response.data;if(s?.success&&s?.response){const n=s.response;if(n.status===401&&n.data?.next_step)return n}}const r=Te(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async fetchLoginMethods(){try{return(await this.getAuthConfig())?.login_methods||{}}catch(e){throw e}},async requestOTP(e){try{const t=Ee()||"",s=e.includes("@")?{email:e}:{phone:e},n=await Hr.requestLoginOTP(t,s),a=n.data;return a?.success&&a?.response?a.response.status===401&&a.response.data?.message?a.response:a.response.data||a.response:n.data}catch(t){if(console.error("Send Code error:",t),t.response?.status===401&&t.response?.data){const r=t.response.data;if(r?.success&&r?.response){const s=r.response;if(s.status===401&&s.data?.message)return s}}if(t.response?.status===401&&t.response?.data){const r=t.response.data;if(r?.success&&r?.response){const s=r.response;if(s.status===401&&s.data?.message)return console.log("OTP sent successfully (401 in error handler):",s.data.message),s}}if(t.response?.data){const r=t.response.data;if(r?.errors&&Array.isArray(r.errors)&&r.errors.length>0){const s=r.errors[0];throw new Error(s.message||"Failed to send OTP")}if(r?.response?.data?.message)throw new Error(r.response.data.message);if(r?.message)throw new Error(r.message)}throw t}},async verifyOTP(e,t){try{const r=Ee()||"",s={code:t},n=await Hr.verifyLoginOTP(r,s),a=n.data;return a?.success&&a?.response?(a.response.status===401&&a.response.data?.next_step,a.response):n.data}catch(r){if(console.error("Verify OTP error:",r),r.response?.data?.response?.error_code==="ACCOUNT_LOCKED")return window.location.href="/app/login",new Promise(()=>{});if(r.response?.status===401&&r.response?.data){const s=r.response.data;if(s?.success&&s?.response){const n=s.response;if(n.status===401&&n.data?.next_step)return n}if(s?.response?.data?.next_step||s?.data?.next_step)return s}if(r.response?.data){const s=r.response.data;if(s?.errors&&Array.isArray(s.errors)&&s.errors.length>0){const n=s.errors[0];throw new Error(n.message||"Verification failed")}if(s?.response?.data?.message)throw new Error(s.response.data.message);if(s?.message)throw new Error(s.message)}throw r}},async selectRole(e){try{const t=Ee()||"",r=await fn.setRole(t,e),s=r.data;if(s?.success&&s?.response){const n=s.response;return n.status===401&&n.data?.next_step?n:n.data||n}return r.data}catch(t){if(console.error("Select role error:",t),t.response?.status===401&&t.response?.data){const s=t.response.data;if(s?.success&&s?.response){const n=s.response;if(n.status===401&&n.data?.next_step)return n}if(s?.response?.data?.next_step||s?.data?.next_step)return s}const r=Te(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async sendTwoFactorCode(){try{return(await zr.getMfaCode()).data}catch(e){console.error("Send 2FA code error:",e);const t=Te(e);throw t!=="An unexpected error occurred"?new Error(t):e}},async verifyTwoFactorCode(e){try{const t=Ee()||"";return(await zr.verifyMfaCode(t,{code:e})).data}catch(t){console.error("Verify 2FA code error:",t);const r=Te(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async changePassword(e,t){try{const r=Ee()||"";return(await mt.changePassword(r,{current_password:e,new_password:t})).data}catch(r){console.error("Change password error:",r);const s=Te(r);throw s!=="An unexpected error occurred"?new Error(s):r}},async setPassword(e){try{const t=Ee()||"";return(await mt.setPassword(t,{new_password:e})).data}catch(t){if(console.error("Set password error:",t),t.response?.status===401&&t.response?.data){const s=t.response.data;if(s?.response?.data?.next_step||s?.data?.next_step)return s}const r=Te(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async processOAuthCallback(e,t,r,s,n,a,i,l){try{const u=Ee()||"",c=await hn.oauthCallback(e,t,r,s,u,n,a,i,l),d=c.data;if(d?.success&&d?.response){const f=d.response;return f.status===401&&f.data?.next_step?f:f.data||f}return c.data}catch(u){if(u.response?.status===401&&u.response?.data){const d=u.response.data;if(d?.success&&d?.response){const f=d.response;if(f.status===401&&f.data?.next_step)return f}if(d?.response?.data?.next_step||d?.data?.next_step)return d}const c=Te(u);throw c!=="An unexpected error occurred"?new Error(c):u}},clearConfig(){oe=null,at=null},async isAuthenticated(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return Un});return e()}catch(e){return console.error("Authentication check failed:",e),!1}},validatePassword(e){const t=this.getPasswordPolicy(),r=[];return t.min_length&&e.length<t.min_length&&r.push(`Password must be at least ${t.min_length} characters long`),t.max_length&&e.length>t.max_length&&r.push(`Password must be at most ${t.max_length} characters long`),t.require_numbers&&!/\d/.test(e)&&r.push("Password must contain at least one number"),t.require_lowercase&&!/[a-z]/.test(e)&&r.push("Password must contain at least one lowercase letter"),t.require_uppercase&&!/[A-Z]/.test(e)&&r.push("Password must contain at least one uppercase letter"),t.require_special_chars&&!/[!@#$%^&*(),.?":{}|<>]/.test(e)&&r.push("Password must contain at least one special character"),{valid:r.length===0,errors:r}},async oauthRedirect(e,t){try{const r=Ee()||"";return(await hn.oauthRedirect(r,e,"login",t)).data}catch(r){throw r}},async getUserProfile(){try{const e=new dn({basePath:"/api/v1",baseOptions:{withCredentials:!0}});return(await new cn(e).getUserProfile()).data}catch(e){throw console.error("Get user profile error:",e),e}},async initiateSAMLAuth(e){try{const t=Ee()||"",s=await fetch("/api/v1/appauth/saml/init/",{method:"POST",headers:{"Content-Type":"application/json","X-CSRFToken":t},credentials:"include",body:JSON.stringify({saml_id:e})}),n=await s.text();if(!s.ok){let i=`SAML init failed: ${s.status} ${s.statusText}`;try{const l=JSON.parse(n);(l.message||l.error||l.detail)&&(i+=` - ${l.message||l.error||l.detail}`)}catch{n&&n.length<500&&(i+=` - ${n}`)}throw new Error(i)}const a=JSON.parse(n);if(a?.success&&a?.response){if(typeof a.response=="string"&&a.response.startsWith("http"))return{redirect_url:a.response};if(a.response?.redirect_url)return{redirect_url:a.response.redirect_url}}else if(a?.redirect_url)return{redirect_url:a.redirect_url};return a}catch(t){throw console.error("SAML init error:",t),t}},async getSAMLAuthMeta(e,t){try{const r=await fetch(`/api/v1/appauth/saml/ops/?token=${encodeURIComponent(e)}&request_id=${encodeURIComponent(t)}&action=get_metadata`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!r.ok)throw new Error(`SAML auth meta failed: ${r.statusText}`);const s=await r.json();if(s?.success&&s?.response){const n=s.response;return n.status===401&&n.data?.next_step?n:n.data||n}return s}catch(r){throw console.error("SAML auth meta error:",r),r}},async setRole(e){try{const t=Ee()||"",r=await fetch(`/api/v1/appauth/role/set/?role=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json","X-CSRFToken":t},credentials:"include"});if(!r.ok){const n=await r.text();throw new Error(`Role set failed: ${r.status} ${r.statusText}`)}const s=await r.json();if(s?.success&&s?.response){const n=s.response;return n.status===401&&n.data?.next_step?n:n.data||n}return s}catch(t){throw console.error("Set role error:",t),t}}},pn=e=>{let t;const r=new Set,s=(c,d)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const m=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(g=>g(t,m))}},n=()=>t,l={setState:s,getState:n,getInitialState:()=>u,subscribe:c=>(r.add(c),()=>r.delete(c))},u=t=e(s,n,l);return l},Pc=(e=>e?pn(e):pn),Sc=e=>e;function kc(e,t=Sc){const r=h.useSyncExternalStore(e.subscribe,h.useCallback(()=>t(e.getState()),[e,t]),h.useCallback(()=>t(e.getInitialState()),[e,t]));return h.useDebugValue(r),r}const gn=e=>{const t=Pc(e),r=s=>kc(t,s);return Object.assign(r,t),r},tr=(e=>e?gn(e):gn)(e=>({basePath:"/login",setBasePath:t=>e({basePath:t})})),mn=h.createContext(void 0),_e=()=>{const e=h.useContext(mn);if(!e)throw new Error("useAuthConfig must be used within AuthConfigProvider");return e},wn=({children:e,authConfig:t={}})=>{const r={theme:{background:{color:"#f0f2f5"},primaryColor:"#1890ff",secondaryColor:"#6d7280",borderRadius:"8px"},card:{backgroundColor:"#ffffff",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",maxWidth:"400px",padding:"40px"},logo:{position:"center",alt:"Logo"},login:{title:"Welcome Back",subtitle:"Please sign in to your account",submitButtonText:"Sign in",rememberMeText:"Remember me",forgotPasswordText:"Forgot password?",otpButtonText:"Sign in with OTP",showRememberMe:!0,enableTabSwitching:!0,defaultTab:"email",formLabels:{email:"Email",mobile:"Mobile",password:"Password"},formPlaceholders:{email:"Email address",mobile:"Mobile number (+919876543210)",password:"Password"},tabLabels:{email:"Email",mobile:"Mobile"}},roleSelection:{title:"Choose Your Role",subtitle:"Select the role that best matches your current responsibilities",continueButtonText:"Continue as {roleName}",recommendedBadgeText:"Recommended",emptyStateMessage:"No roles available",cardLayout:"grid",gridColumns:3,roleCardStyling:{backgroundColor:"#ffffff",selectedColor:"#1890ff",hoverColor:"#f0f2f5",borderRadius:"8px"}},twoFactor:{title:"Two-Factor Authentication",subtitle:"Please enter your verification code",instructionText:"Enter the verification code sent to your device",codeInputLabel:"Verification Code",submitButtonText:"Verify",resendButtonText:"Resend Code",backButtonText:"Back",resendCountdown:60,codeLength:6,methodLabels:{email:"Email",sms:"SMS",mobile:"Mobile"}},resetPassword:{forgotPassword:{title:"Forgot Password",subtitle:"Enter your email address to reset your password",instructionText:"We will send you a reset link",emailLabel:"Email",emailPlaceholder:"Enter your email address",submitButtonText:"Send Reset Link",backToLoginText:"Back to Login",successMessage:"Reset email sent successfully",errorMessage:"Failed to send reset email"},resetForm:{title:"Reset Password",subtitle:"Enter your new password",passwordLabel:"New Password",confirmPasswordLabel:"Confirm Password",passwordPlaceholder:"Enter new password",confirmPasswordPlaceholder:"Confirm new password",submitButtonText:"Reset Password",successMessage:"Password reset successfully",showPasswordRequirements:!0,passwordRequirementsText:"Password requirements:"}},providers:{buttonStyle:"outline",showProviderIcons:!0,separatorText:"OR"},messages:{validation:{required:"This field is required",invalidEmail:"Please enter a valid email",invalidMobile:"Please enter a valid mobile number",passwordTooShort:"Password is too short",passwordsDoNotMatch:"Passwords do not match"},errors:{loginFailed:"Login failed. Please try again.",networkError:"Network error. Please check your connection.",invalidOTP:"Invalid verification code",expiredToken:"Token has expired"},success:{loginSuccess:"Login successful!",otpSent:"Verification code sent!",passwordReset:"Password reset successfully!",roleSelected:"Role selected successfully!"}}},s=(i,l)=>{const u={...i};for(const c in l)l[c]!==null&&typeof l[c]=="object"&&!Array.isArray(l[c])&&!h.isValidElement(l[c])?u[c]=s(i[c]||{},l[c]):u[c]=l[c];return u},n=s(r,t),a={authConfig:n,getLoginConfig:()=>n.login||{},getRoleSelectionConfig:()=>n.roleSelection||{},getTwoFactorConfig:()=>n.twoFactor||{},getResetPasswordConfig:()=>n.resetPassword||{},getThemeConfig:()=>n.theme||{},getCardConfig:()=>n.card||{},getLogoConfig:()=>n.logo||{},getProvidersConfig:()=>n.providers||{},getMessagesConfig:()=>n.messages||{},getCustomComponents:()=>n.customComponents||{}};return o.jsx(mn.Provider,{value:a,children:e})},Ec=e=>{const t=e?.theme||{},r=e?.card||{};let s="";return t.primaryColor&&(s+=`--auth-primary-color: ${t.primaryColor}; `),t.secondaryColor&&(s+=`--auth-secondary-color: ${t.secondaryColor}; `),t.fontFamily&&(s+=`--auth-font-family: ${t.fontFamily}; `),t.borderRadius&&(s+=`--auth-border-radius: ${t.borderRadius}; `),t.textColor&&(s+=`--auth-text-color: ${t.textColor}; `),t.secondaryTextColor&&(s+=`--auth-secondary-text-color: ${t.secondaryTextColor}; `),t.mutedTextColor&&(s+=`--auth-muted-text-color: ${t.mutedTextColor}; `),t.linkColor&&(s+=`--auth-link-color: ${t.linkColor}; `),t.linkHoverColor&&(s+=`--auth-link-hover-color: ${t.linkHoverColor}; `),t.background?.color&&(s+=`--auth-bg-color: ${t.background.color}; `),t.background?.gradient&&(s+=`--auth-bg-gradient: ${t.background.gradient}; `),t.background?.image&&(s+=`--auth-bg-image: url(${t.background.image}); `),r.backgroundColor&&(s+=`--auth-card-bg: ${r.backgroundColor}; `),r.borderRadius&&(s+=`--auth-card-border-radius: ${r.borderRadius}; `),r.boxShadow&&(s+=`--auth-card-shadow: ${r.boxShadow}; `),r.maxWidth&&(s+=`--auth-card-max-width: ${r.maxWidth}; `),r.padding&&(s+=`--auth-card-padding: ${r.padding}; `),r.border&&(s+=`--auth-card-border: ${r.border}; `),s},Ac=e=>{const t=Ec(e);if(!t)return;let r=document.getElementById("auth-theme-variables");r||(r=document.createElement("style"),r.id="auth-theme-variables",document.head.appendChild(r));const s=`
115
120
  :root { ${t} }
116
121
 
117
122
  /* Auth component text styling using CSS variables */
@@ -139,7 +144,7 @@ export default App;`,m=`mkdir -p ${c}`,w={container:{padding:"32px",maxWidth:"90
139
144
  .auth-link:hover {
140
145
  color: var(--auth-link-hover-color, #3b82f6) !important;
141
146
  }
142
- `;r.innerHTML=o,e?.debug&&console.log("🎨 Applied CSS to DOM:",o)},Mi=()=>{const e=document.getElementById("auth-theme-variables");e&&e.remove()},yo=e=>{const t=e?.theme?.background;if(!t)return{};const r={};return t.image?(r.backgroundImage=`url(${t.image})`,r.backgroundSize="cover",r.backgroundPosition="center",r.backgroundRepeat="no-repeat"):t.gradient?r.background=t.gradient:t.color&&(r.backgroundColor=t.color),e?.debug&&console.log("🎨 Generated background style:",r),r},qe=e=>{const t=e?.card;if(!t)return{};const r={};return t.backgroundColor&&(r.backgroundColor=t.backgroundColor),t.borderRadius&&(r.borderRadius=t.borderRadius),t.boxShadow&&(r.boxShadow=t.boxShadow),t.maxWidth&&(r.maxWidth=t.maxWidth),t.padding&&(r.padding=t.padding),t.border&&(r.border=t.border),e?.debug&&console.log("🎨 Generated card style:",r),r},nr=e=>{const t=e?.logo;if(!t)return{};const r={};return t.width&&(r.width=t.width),t.height&&(r.height=t.height),t.style&&Object.assign(r,t.style),r},Ui=e=>e?.logo?.position||"center",ir=e=>{const t=Ui(e),r=e?.logo;let o="flex items-center mb-6";const a={};switch(t){case"left":o+=" justify-start";break;case"right":o+=" justify-end";break;case"center":default:o+=" justify-center";break}return r?.className&&(o+=` ${r.className}`),e?.debug&&console.log("🎨 Generated logo container style:",{className:o,style:a,position:t}),{className:o,style:a}},lr=e=>{const t=e?.theme;if(!t)return{};const r={};return t.textColor&&(r.color=t.textColor),t.fontFamily&&(r.fontFamily=t.fontFamily),e?.debug&&console.log("🎨 Generated text style:",r),r},cr=e=>{const t=e?.theme;if(!t)return{};const r={};return t.secondaryTextColor&&(r.color=t.secondaryTextColor),t.fontFamily&&(r.fontFamily=t.fontFamily),r},Bi=e=>{const t=e?.theme;if(!t)return{};const r={};return t.linkColor&&(r.color=t.linkColor),t.fontFamily&&(r.fontFamily=t.fontFamily),r},qi=({onSubmit:e})=>{const[t,r]=g.useState(!1),[o,a]=g.useState(!1),[n,i]=g.useState(0),[c,d]=g.useState(["email"]),[l,u]=g.useState("email"),{basePath:h}=Et(),{authConfig:m,getResetPasswordConfig:w,getMessagesConfig:f}=Be(),x=w(),y=f(),P=qe(m);g.useEffect(()=>{(async()=>{try{await W.getAuthConfig();const v=W.getPasswordResetMethods();v&&v.length>0&&(d(v),u(v[0]))}catch(v){console.error("Failed to load reset configuration:",v)}})()},[]);const A=async S=>{r(!0);try{if(e){const v={method:l,email:l==="email"?S.contact:void 0,phone:l==="sms"?S.contact:void 0};await e(v)}a(!0),i(v=>v+1)}catch(v){const C=l==="email"?"email":"SMS",F=y?.errors?.networkError||v.message||`Failed to send reset ${C}. Please try again.`;p.toast.error(F)}finally{r(!1)}},B=()=>l==="email"?x?.forgotPassword?.emailPlaceholder||"Email address":"Phone number",N=()=>l==="email"?[{required:!0,message:y?.validation?.required||"Please input your email!"},{type:"email",message:y?.validation?.invalidEmail||"Please enter a valid email address!"}]:[{required:!0,message:y?.validation?.required||"Please input your phone number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:y?.validation?.invalidMobile||"Please enter a valid phone number!"}],H=()=>{const S=l==="email"?"Email":"SMS",v=l==="email"?"email":"phone";return{title:x?.forgotPassword?.successMessage||`${S} Sent!`,subTitle:`Please check your ${v} for password reset instructions.`}};if(o){const S=H();return s.jsx(p.Result,{status:"success",title:S.title,subTitle:S.subTitle,extra:[s.jsx(G.Link,{to:h,children:s.jsx(p.Button,{variant:"primary",children:x?.forgotPassword?.backToLoginText||"Back to Login"})},"login")]})}return s.jsxs("div",{className:"w-full max-w-md mx-auto",style:P,children:[s.jsx(G.Link,{to:h,className:"inline-block mb-6",children:s.jsx(p.Button,{variant:"link",size:"link",icon:s.jsx(Wt,{size:16}),children:x?.forgotPassword?.backToLoginText||"Back to Login"})}),s.jsx("h2",{className:"text-2xl font-semibold mb-3",style:lr(m),children:x?.forgotPassword?.title||"Forgot Password"}),s.jsx("p",{className:"text-sm mb-6",style:cr(m),children:x?.forgotPassword?.subtitle||x?.forgotPassword?.instructionText||`Enter your ${l==="email"?"email address":"phone number"} and we'll send you instructions to reset your password.`}),s.jsxs(p.Form,{name:"forgot-password",className:"space-y-4",onFinish:A,layout:"vertical",children:[c.length>1&&s.jsx(p.FormItem,{label:"Reset method",children:s.jsxs(p.Select,{value:l,onChange:S=>{u(S),i(v=>v+1)},children:["options=",c.map(S=>({value:S,label:s.jsxs(p.Space,{children:[S==="email"?s.jsx(Ct,{size:16}):s.jsx(Ia,{size:16}),S==="email"?"Email":"SMS"]})}))]})}),s.jsx(p.FormItem,{name:"contact",label:l==="email"?x?.forgotPassword?.emailLabel||"Email":"Phone",rules:N(),children:s.jsx(p.Input,{placeholder:B(),autoComplete:l==="email"?"email":"tel"})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:t,fullWidth:!0,children:x?.forgotPassword?.submitButtonText||`Send Reset ${l==="email"?"Email":"SMS"}`})})]},n)]})},Ii=({onSubmit:e,token:t})=>{const[r,o]=g.useState(!1),[a,n]=g.useState(!1),[i,c]=g.useState(0),{basePath:d}=Et(),{authConfig:l,getResetPasswordConfig:u,getMessagesConfig:h}=Be(),m=u(),w=h(),f=qe(l),x=(P,A)=>{if(!A){const N=w?.validation?.required||"Please input your new password!";return Promise.reject(new Error(N))}const B=W.validatePassword(A);if(!B.valid){const N=w?.validation?.passwordTooShort||B.errors.join(", ");return Promise.reject(new Error(N))}return Promise.resolve()},y=async P=>{o(!0);try{e&&await e({...P,token:t}),n(!0),c(A=>A+1)}catch(A){const B=w?.errors?.networkError||A.message||"Failed to reset password. Please try again.";p.toast.error(B)}finally{o(!1)}};return a?s.jsx(p.Result,{status:"success",title:m?.resetForm?.successMessage||"Password Reset Successful!",subTitle:"Your password has been successfully reset. You can now login with your new password.",extra:[s.jsx(G.Link,{to:d,children:s.jsx(p.Button,{variant:"primary",children:"Go to Login"})},"login")]}):s.jsxs("div",{className:"w-full max-w-md mx-auto",style:f,children:[s.jsx("h2",{className:"text-2xl font-semibold text-gray-900 mb-3",children:m?.resetForm?.title||"Reset Password"}),s.jsx("p",{className:"text-sm text-gray-600 mb-6",children:m?.resetForm?.subtitle||"Please enter your new password below."}),s.jsxs(p.Form,{name:"reset-password",className:"space-y-4",onFinish:y,layout:"vertical",children:[s.jsx(p.FormItem,{name:"password",label:m?.resetForm?.passwordLabel||"New Password",rules:[{validator:x}],children:s.jsx(p.PasswordInput,{prefix:s.jsx(bt,{size:16,className:"text-gray-400"}),placeholder:m?.resetForm?.passwordPlaceholder||"New Password",autoComplete:"new-password"})}),s.jsx(p.FormItem,{name:"confirmPassword",label:m?.resetForm?.confirmPasswordLabel||"Confirm Password",dependencies:["password"],rules:[{required:!0,message:w?.validation?.required||"Please confirm your password!"},({getFieldValue:P})=>({validator(A,B){if(!B||P("password")===B)return Promise.resolve();const N=w?.validation?.passwordsDoNotMatch||"The two passwords do not match!";return Promise.reject(new Error(N))}})],children:s.jsx(p.PasswordInput,{prefix:s.jsx(bt,{size:16,className:"text-gray-400"}),placeholder:m?.resetForm?.confirmPasswordPlaceholder||"Confirm Password",autoComplete:"new-password"})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:r,fullWidth:!0,children:m?.resetForm?.submitButtonText||"Reset Password"})})]},i)]})},$i=({onSuccess:e,onError:t,apiConfig:r={},redirectPath:o="/",title:a="Completing sign in...",errorTitle:n="Authentication Error",logo:i,roleSelectionTitle:c,roleSelectionSubtitle:d,twoFactorTitle:l,twoFactorSubtitle:u,passwordResetTitle:h,passwordResetSubtitle:m})=>{const[w,f]=g.useState(!0),[x,y]=g.useState(null),[P,A]=g.useState(!1),[B,N]=g.useState(null),[H,S]=g.useState("login"),[v,C]=g.useState({}),[F,D]=g.useState(["email"]),[k,U]=g.useState(""),I=g.useRef(!1),j=G.useLocation(),L=G.useNavigate(),{basePath:T,setAuthToken:M}=Et(),E=async _=>{console.log("Login success result:",_);let J=_,V=null;_?.status===401&&_?.data?(J=_.data,V=_.data?.next_step):(J=_?.response?.data||_?.data||_,V=J?.next_step);const K=_?.loginUser;(_?.token||J?.token)&&M(_.token||J.token);let ee=_?.user||J?.user||K||{};if((typeof ee!="object"||ee===null)&&(ee={}),K&&typeof K=="object"&&(ee={...ee,email:ee.email||K.email,username:ee.username||K.username,phone:ee.phone||K.phone,name:ee.name||K.display}),V&&V.is_pending)switch(V.id){case"role_selection":let ne=[];Array.isArray(V.metadata.roles)?ne=V.metadata.roles:typeof V.metadata.roles=="object"&&(ne=Object.entries(V.metadata.roles).map(([me,Ze])=>({id:me,name:Ze,is_default:!1}))),C({..._,roles:ne,user:ee,nextStep:V,loginUser:K}),S("roleSelection"),A(!0),f(!1);return;case"mfa_authenticate":M(_.token||J?.token),D(V.metadata?.methods||["email"]),S("twoFactor"),A(!0),f(!1);return;case"set_password":M(_.token||J?.token);const ie=V.metadata?.password_policy;U(V.metadata?.reason||"Password update required"),C({..._,passwordPolicy:ie,user:ee,loginUser:K}),S("passwordReset"),A(!0),f(!1);return;case"password_expiry":M(_.token||J?.token),U("Your password has expired"),C({..._,passwordPolicy:V.metadata?.password_policy,user:ee,loginUser:K}),S("passwordReset"),A(!0),f(!1);return;case"first_login":M(_.token||J?.token),U("Please set up your password for first login"),C({..._,passwordPolicy:V.metadata?.password_policy,user:ee,loginUser:K}),S("passwordReset"),A(!0),f(!1);return;case"login_by_code":M(_.token||J?.token),console.log("OTP login flow required"),p.toast.info("OTP verification required"),e&&e({..._,user:ee,requiresOTP:!0});return}if(_.requires2FA){M(_.token),D(_.twoFactorMethods||["email"]),C({..._,user:ee,loginUser:K}),S("twoFactor"),A(!0),f(!1);return}if(_.requiresPasswordReset){M(_.token),U(_.passwordResetReason||"Your password has expired"),C({..._,user:ee,loginUser:K}),S("passwordReset"),A(!0),f(!1);return}};g.useEffect(()=>{I.current||Z()},[]);const Z=async()=>{try{I.current=!0;const _=new URLSearchParams(j.search),J=new URLSearchParams(j.hash.slice(1)),V=_.get("error")||J.get("error"),K=_.get("error_description")||J.get("error_description");if(V)throw new Error(K||`Authentication failed: ${V}`);const ee=_.get("code"),ne=_.get("state"),ie=_.get("scope")||"",me=_.get("authuser"),Ze=_.get("hd"),$e=_.get("prompt"),Ge=_.get("provider")||ne?.split(":")[0];if(!ee||!Ge)throw new Error("Missing required OAuth parameters (code or provider)");const le=await W.processOAuthCallback(Ge,ne||"",ee,ie,me||void 0,Ze||void 0,$e||void 0);if(console.log("OAuth callback result:",le),await E(le),le?.status===401&&le?.data?.next_step){const Ee=le.data.next_step;if(Ee.is_pending){console.log("Additional authentication step required after OAuth callback:",Ee.id),f(!1),e?e(le):(N(le),A(!0));return}}f(!1),e?e(le):setTimeout(()=>{L(o,{replace:!0})},1e3)}catch(_){console.error("OAuth callback error:",_),y(_.message||"Authentication failed"),f(!1),t&&t(_)}},Q=()=>{L(T,{replace:!0})},z=async _=>{console.log("Authentication complete:",_),p.toast.success("Authentication complete!");try{let J="/dashboard";_?.response?.data?.redirect_url?J=_.response.data.redirect_url:_?.data?.redirect_url?J=_.data.redirect_url:_?.redirect_url&&(J=_.redirect_url),console.log("Redirecting to:",J),window.location.href=J}catch(J){console.error("Error handling auth completion:",J)}};return P?s.jsx(CompleteAuthFlow,{logo:i,apiConfig:r,initialAuthState:B||v,onAuthComplete:z,roleSelectionTitle:c,roleSelectionSubtitle:d,twoFactorTitle:l,twoFactorSubtitle:u,passwordResetTitle:h,passwordResetSubtitle:m,redirectPath:o}):w?s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:s.jsx(p.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:s.jsxs("div",{className:"text-center py-10 px-5",children:[s.jsx(p.Spin,{size:"large"}),s.jsx("h2",{className:"mt-6 mb-2 text-gray-800 text-xl font-medium",children:a}),s.jsx("p",{className:"text-gray-500 text-sm mb-0",children:"Please wait while we complete your authentication..."})]})})}):x?s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:s.jsx(p.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:s.jsx("div",{className:"text-center py-10 px-5",children:s.jsx(p.Alert,{message:n,description:x,type:"error",showIcon:!0,action:s.jsx("a",{onClick:Q,children:"Return to login"})})})})}):s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:s.jsx(p.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:s.jsx("div",{className:"text-center py-10 px-5",children:s.jsx(p.Alert,{message:"Authentication Successful",description:"You have been successfully authenticated. Redirecting...",type:"success",showIcon:!0})})})})},Vi=()=>s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),s.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),s.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),s.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),ji=()=>s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M11.4 24H0V12.6h11.4V24z",fill:"#f25022"}),s.jsx("path",{d:"M24 24H12.6V12.6H24V24z",fill:"#00a4ef"}),s.jsx("path",{d:"M11.4 11.4H0V0h11.4v11.4z",fill:"#7fba00"}),s.jsx("path",{d:"M24 11.4H12.6V0H24v11.4z",fill:"#ffb900"})]}),Di=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})}),Hi=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"#0077b5",children:s.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})}),zi=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"#1877f2",children:s.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Wi=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),Zi=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),Gi=()=>s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52z",fill:"#e01e5a"}),s.jsx("path",{d:"M6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313z",fill:"#e01e5a"}),s.jsx("path",{d:"M8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834z",fill:"#36c5f0"}),s.jsx("path",{d:"M8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312z",fill:"#36c5f0"}),s.jsx("path",{d:"M18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834z",fill:"#2eb67d"}),s.jsx("path",{d:"M17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312z",fill:"#2eb67d"}),s.jsx("path",{d:"M15.165 18.956a2.527 2.527 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52z",fill:"#ecb22e"}),s.jsx("path",{d:"M15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z",fill:"#ecb22e"})]}),Ki=e=>{const t=e?e.toLowerCase():"";return t.includes("google")?s.jsx(Vi,{}):t.includes("microsoft")||t.includes("azure")?s.jsx(ji,{}):t.includes("github")?s.jsx(Di,{}):t.includes("linkedin")?s.jsx(Hi,{}):t.includes("facebook")?s.jsx(zi,{}):t.includes("twitter")||t.includes("x.com")?s.jsx(Wi,{}):t.includes("apple")?s.jsx(Zi,{}):t.includes("slack")?s.jsx(Gi,{}):s.jsx(qa,{size:16})},bo=({provider:e,type:t="default"})=>{const r=async()=>{const a=await W.oauthRedirect(e.provider,window.location.href);console.log("redirect url:",a.response.redirect_url),a.success?window.location.href=a.response.redirect_url:console.error("Error authenticating:")},o=Ki(e.provider);return s.jsxs(p.Button,{className:`flex items-center justify-center gap-2 h-[42px] text-sm font-medium rounded-md transition-all duration-300 mb-2 last:mb-0 ${t==="oidc"?"bg-gray-100 border border-gray-200 text-gray-800 hover:bg-gray-200 hover:border-gray-300":t==="sso"?"bg-brand-500 border border-brand-500 text-white hover:bg-brand-600 hover:border-brand-600":"bg-white border border-gray-300 text-gray-800 hover:border-brand-500 hover:text-brand-500"}`,icon:o,block:!0,onClick:r,children:["Continue with ",e.provider]})},Co=({length:e=6,value:t="",onChange:r,disabled:o=!1})=>{const[a,n]=g.useState(new Array(e).fill("")),i=g.useRef([]);g.useEffect(()=>{if(t){const u=t.split("").slice(0,e),h=[...new Array(e).fill("")];u.forEach((m,w)=>{h[w]=m}),n(h)}},[t,e]);const c=(u,h)=>{const m=u.value;if(isNaN(m))return;const w=[...a];w[h]=m,n(w),r&&r(w.join("")),m&&h<e-1&&i.current[h+1].focus()},d=(u,h)=>{u.key==="Backspace"&&!a[h]&&h>0&&i.current[h-1].focus()},l=u=>{u.preventDefault();const m=u.clipboardData.getData("text/plain").slice(0,e).split(""),w=[...a];m.forEach((x,y)=>{!isNaN(x)&&y<e&&(w[y]=x)}),n(w),r&&r(w.join(""));const f=w.findIndex(x=>x==="");f!==-1?i.current[f].focus():i.current[e-1].focus()};return s.jsx(p.Space,{className:"flex justify-center gap-2",size:"small",children:a.map((u,h)=>s.jsx(p.Input,{ref:m=>i.current[h]=m,type:"text",inputMode:"numeric",maxLength:1,value:u,onChange:m=>c(m.target,h),onKeyDown:m=>d(m,h),onPaste:l,className:"!w-12 !h-12 text-center text-xl font-semibold rounded-lg transition-all duration-300 focus:border-brand-500 focus:shadow-[0_0_0_2px_rgba(106,138,18,0.2)] disabled:bg-gray-100 disabled:cursor-not-allowed",disabled:o},h))})},vo=g.createContext(null),Ye=()=>{const e=g.useContext(vo);if(!e)throw new Error("useAuthContext must be used within an AuthProvider");return e},Ji=({children:e,config:t={}})=>{const[r,o]=g.useState(null),[a,n]=g.useState(!0),[i,c]=g.useState(null),[d,l]=g.useState(null),[u,h]=g.useState(null),[m,w]=g.useState(null),f=g.useRef(!1);g.useEffect(()=>{f.current||(f.current=!0,x())},[]);const x=async()=>{try{const v=await W.getAuthConfig();w(v),await y()}catch(v){c(v.message),n(!1)}},y=async()=>{try{await W.isAuthenticated()?(o({id:1,username:"authenticated_user",email:"user@example.com",authenticated:!0}),c(null)):(o(null),c(null))}catch(v){console.error("Auth check failed:",v),o(null),c(null)}finally{n(!1)}},S={user:r,loading:a,error:i,login:async v=>{n(!0),c(null);try{const C=await W.login(v,t);let F=C,D=null;C?.status===401&&C?.data?(F=C.data,D=C.data?.next_step):(F=C?.response?.data||C?.data||C,D=F?.next_step);const k=C?.user||F?.user||{};if(k.email=k.email||v.email,k.username=k.username||v.username,k.phone=k.phone||v.phone,k.name=k.name||v.email||v.username||v.phone,l({user:k,token:C.token||F?.token,roles:C.roles,requires2FA:C.requires2FA,twoFactorMethods:C.twoFactorMethods,requiresPasswordReset:C.requiresPasswordReset,passwordResetReason:C.passwordResetReason}),D&&D.is_pending&&D.id==="role_selection")return{...C,user:k};if(C.roles&&C.roles.length>1)return h(C.roles),{requiresRoleSelection:!0,roles:C.roles,user:k,token:C.token};let U=C;return C.roles&&C.roles.length===1?U.user={...k,role:C.roles[0]}:U.user=k,C.requires2FA?{...U,requires2FA:!0,twoFactorMethods:C.twoFactorMethods||["email"]}:C.requiresPasswordReset?{...U,requiresPasswordReset:!0,passwordResetReason:C.passwordResetReason}:(o(U.user),l(null),h(null),{...U,user:k})}catch(C){throw console.error("AuthProvider login caught error:",C),console.error("AuthProvider error.message:",C.message),c(C.message),C}finally{n(!1)}},logout:async()=>{n(!0);try{await W.logout(t),o(null),l(null),h(null)}catch(v){console.error("Logout failed:",v)}finally{n(!1)}},selectRole:async v=>{if(!d)throw new Error("No pending authentication");n(!0);try{t.roleSelectionEndpoint&&await W.selectRole(v,d.token,t);const C={...d.user,role:v},F={...d,user:C};return F.requires2FA?(l(F),{...F,requires2FA:!0,twoFactorMethods:F.twoFactorMethods||["email"]}):F.requiresPasswordReset?(l(F),{...F,requiresPasswordReset:!0,passwordResetReason:F.passwordResetReason}):(o(C),l(null),h(null),{user:C,token:d.token})}catch(C){throw c(C.message),C}finally{n(!1)}},checkAuth:y,forgotPassword:async v=>W.forgotPassword(v),resetPassword:async v=>W.resetPassword(v),isAuthenticated:!!r,pendingAuth:d,availableRoles:u,authConfig:m,requiresRoleSelection:!!d&&!!u};return s.jsx(vo.Provider,{value:S,children:e})},{Text:dr,Title:Ft}=p.Typography,xo=({onSuccess:e,onBack:t})=>{const[r,o]=g.useState("request"),[a,n]=g.useState(!1),[i,c]=g.useState(""),[d,l]=g.useState("email"),[u,h]=g.useState(""),[m,w]=g.useState(0),[f,x]=g.useState(0),[y,P]=g.useState(null),[A,B]=g.useState(!1),[N,H]=g.useState(""),[S,v]=g.useState(""),[C,F]=g.useState(!1),{authConfig:D}=Ye(),k=async()=>{try{return await W.isAuthenticated()}catch{return!1}};g.useEffect(()=>{if(D){const _=W.getAllowedUsernames();_&&_.length>0&&l(_[0])}},[D]),g.useEffect(()=>{(async()=>{const J=await k();F(J),J&&r!=="success"&&o("success")})()},[r]),g.useEffect(()=>{if(m>0){const _=setTimeout(()=>w(m-1),1e3);return()=>clearTimeout(_)}},[m]);const U=_=>_==="email"?"Enter your email":"Enter your mobile number",I=_=>_==="email"?[{required:!0,message:"Please input your email!"},{type:"email",message:"Please enter a valid email!"}]:_==="mobile"?[{required:!0,message:"Please input your mobile number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid mobile number!"}]:[{required:!0,message:"Please input your username!"},{min:3,message:"Username must be at least 3 characters long"}],j=async _=>{n(!0);try{await W.requestOTP(_.username),c(_.username),o("verify"),w(30),p.toast.success("OTP sent successfully!")}catch(J){J?.response?.status===401?(c(_.username),o("verify"),w(30),p.toast.success("Please check your email/phone for the OTP code")):p.toast.error(J.message||"Failed to send OTP")}finally{n(!1)}},L=async()=>{if(u.length!==6){p.toast.error("Please enter 6 digit OTP");return}n(!0);try{const J=await W.verifyOTP(i,u);P(J),o("success"),p.toast.success("Login successful!")}catch(J){p.toast.error(J.message||"Invalid OTP"),h("")}finally{n(!1)}},T=async()=>{if(!N||!S){p.toast.error("Please fill in all password fields");return}if(N!==S){p.toast.error("Passwords do not match");return}if(N.length<8){p.toast.error("Password must be at least 8 characters long");return}n(!0);try{await W.setPassword(N),p.toast.success("Password changed successfully!"),B(!1),H(""),v("")}catch(_){p.toast.error(_.message||"Failed to change password")}finally{n(!1)}},M=()=>{y&&e(y)},E=async()=>{n(!0);try{await W.logout(),p.toast.success("Logged out successfully"),o("request"),P(null),c(""),h(""),F(!1)}catch(_){p.toast.error(_.message||"Failed to logout")}finally{n(!1)}},Z=async()=>{if(!(m>0)){n(!0);try{await W.requestOTP(i),w(30),p.toast.success("OTP resent successfully!")}catch(_){p.toast.error(_.message||"Failed to resend OTP")}finally{n(!1)}}};if(!D)return s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const Q=W.getAllowedUsernames(),z=6;return r==="success"&&C?s.jsxs("div",{className:"w-full",children:[s.jsx(Ft,{level:4,className:"!mb-2 text-center",children:y?"Login Successful!":"Already Logged In"}),s.jsx(dr,{className:"block text-center text-gray-500 mb-6",children:y?"You have successfully logged in.":"You are currently logged in."}),A?s.jsxs("div",{className:"space-y-4",children:[s.jsx(Ft,{level:5,className:"!mb-4",children:"Change Your Password"}),s.jsx(p.FormItem,{label:"New Password",children:s.jsx(p.Input.Password,{value:N,onChange:_=>H(_.target.value),placeholder:"Enter new password",disabled:a})}),s.jsx(p.FormItem,{label:"Confirm Password",children:s.jsx(p.Input.Password,{value:S,onChange:_=>v(_.target.value),placeholder:"Confirm new password",disabled:a})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(p.Button,{type:"primary",onClick:T,loading:a,className:"flex-1",children:"Change Password"}),s.jsx(p.Button,{onClick:()=>{B(!1),H(""),v("")},disabled:a,className:"flex-1",children:"Cancel"})]})]}):s.jsxs("div",{className:"space-y-4",children:[y&&s.jsx(p.Button,{type:"primary",block:!0,onClick:M,children:"Continue to Dashboard"}),s.jsx(p.Button,{block:!0,onClick:()=>B(!0),children:"Change Password"}),s.jsx(p.Button,{block:!0,danger:!0,onClick:E,loading:a,children:"Logout"})]})]}):r==="verify"?s.jsxs("div",{className:"w-full",children:[s.jsx(p.Button,{variant:"link",icon:s.jsx(Wt,{size:16}),onClick:()=>o("request"),className:"mb-4",children:"Back"}),s.jsx(Ft,{level:4,className:"!mb-2 text-center",children:"Verify OTP"}),s.jsxs(dr,{className:"block text-center text-gray-500 mb-6",children:["We've sent a ",z,"-digit code to ",i]}),s.jsx("div",{className:"my-8 flex justify-center",children:s.jsx(Co,{length:z,value:u,onChange:h,disabled:a})}),s.jsx(p.Button,{type:"primary",block:!0,loading:a,onClick:L,className:"mt-6",children:"Verify OTP"}),s.jsx("div",{className:"text-center mt-4",children:m>0?s.jsxs(dr,{type:"secondary",children:["Resend OTP in ",m,"s"]}):s.jsx(p.Button,{type:"link",onClick:Z,loading:a,children:"Resend OTP"})})]}):s.jsxs("div",{className:"w-full",children:[t&&s.jsx(p.Button,{variant:"link",icon:s.jsx(Wt,{size:16}),onClick:t,className:"mb-4",children:"Back to other methods"}),s.jsx(Ft,{level:4,className:"!mb-2 text-center",children:"Sign in with OTP"}),s.jsxs(p.Form,{name:"otp-request",onFinish:j,layout:"vertical",children:[Q.length>1&&s.jsx(p.FormItem,{children:s.jsx(p.Segmented,{options:Q.map(_=>({label:s.jsxs(p.Space,{children:[_==="email"?s.jsx(Ct,{size:16}):_==="mobile"?s.jsx(Zt,{size:16}):s.jsx(Gt,{size:16}),s.jsx("span",{children:_==="mobile"?"Phone":_==="email"?"Email":"Username"})]}),value:_})),value:d,onChange:_=>l(_),block:!0,className:"bg-gray-100 mb-2"})}),s.jsx(p.FormItem,{name:"username",rules:I(d),children:s.jsx(p.Input,{placeholder:U(d)})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",fullWidth:!0,disabled:a,children:"Send OTP"})})]},f)]})},Xi=({onLogin:e,showRememberMe:t=!0})=>{const[r,o]=g.useState(!1),[a,n]=g.useState(null),[i,c]=g.useState(null),[d,l]=g.useState("email"),[u,h]=g.useState(!1),[m,w]=g.useState(0),[f,x]=g.useState(!1),[y,P]=g.useState(!1),[A,B]=g.useState(""),[N,H]=g.useState(""),{authConfig:S}=Ye(),{getLoginConfig:v,getMessagesConfig:C,getProvidersConfig:F,authConfig:D}=Be(),k=D||S,U=lr(k),I=cr(k),j=Bi(k),L=async()=>{try{return await W.isAuthenticated()}catch{return!1}};if(g.useEffect(()=>{if(S){const V=W.getAllowedUsernames();if(V&&V.length>0){const K=V.includes("email"),ee=V.includes("mobile");K?l("email"):ee&&l("mobile")}W.isPasswordLoginEnabled()?c("password"):W.isOTPLoginEnabled()&&c("otp")}},[S]),g.useEffect(()=>{(async()=>{const K=await L();x(K)})()},[]),!S)return s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:s.jsx(p.Spin,{size:"large"})});const T=V=>{const K=C();return V==="email"?[{required:!0,message:K?.validation?.required||"Please input your email!"},{type:"email",message:K?.validation?.invalidEmail||"Please enter a valid email!"}]:V==="mobile"?[{required:!0,message:K?.validation?.required||"Please input your mobile number!"},{pattern:/^\+\d{7,15}$/,message:K?.validation?.invalidMobile||"Please enter a valid mobile number with country code (e.g., +919876543210)"}]:[{required:!0,message:K?.validation?.required||"Please input your email!"},{type:"email",message:K?.validation?.invalidEmail||"Please enter a valid email!"}]},M=async V=>{o(!0),n(null);try{const K=W.getAllowedUsernames(),ee=K.includes("email"),ne=K.includes("mobile"),ie=ee&&ne?d:ee?"email":"mobile",me={email:ie==="email"?V.username:void 0,phone:ie==="mobile"?V.username:void 0,password:V.password,remember_me:V.remember||!1};await e(me)}catch(K){const ee=C(),ne=K.message||ee?.errors?.loginFailed||"Login failed. Please try again.";n(ne)}finally{o(!1)}},E=async V=>{await e(V)},Z=async()=>{o(!0);try{await W.logout(),p.toast.success("Logged out successfully"),x(!1)}catch(V){p.toast.error(V.message||"Failed to logout")}finally{o(!1)}},Q=async()=>{if(!A||!N){p.toast.error("Please fill in all password fields");return}if(A!==N){p.toast.error("Passwords do not match");return}if(A.length<8){p.toast.error("Password must be at least 8 characters long");return}o(!0);try{await W.setPassword(A),p.toast.success("Password changed successfully!"),P(!1),B(""),H("")}catch(V){p.toast.error(V.message||"Failed to change password")}finally{o(!1)}},z=V=>{const K=v(),ee=C();return s.jsxs(p.Form,{name:`${V}-password-login`,className:"w-full",onFinish:M,onFinishFailed:()=>{const ne=ee?.validation?.required||"Please check your input and try again";n(ne)},layout:"vertical",initialValues:{remember:!1},children:[a&&s.jsx(p.Alert,{message:a,type:"error",showIcon:!0,closable:!0,onClose:()=>n(null),className:"mb-4"}),s.jsx(p.FormItem,{name:"username",rules:T(V),children:s.jsx(p.Input,{placeholder:V==="email"?K?.formPlaceholders?.email||"Email address":K?.formPlaceholders?.mobile||"Mobile number (+919876543210)",autoComplete:V==="email"?"email":"tel",onKeyDown:V==="mobile"?ne=>{const ie=["Backspace","Delete","Tab","Enter","ArrowLeft","ArrowRight"],me=ne.key;!ie.includes(me)&&!/[0-9+]/.test(me)&&ne.preventDefault()}:void 0})}),s.jsx(p.FormItem,{name:"password",rules:[{required:!0,message:ee?.validation?.required||"Please input your password!"},{min:S?.password_policy?.min_length||6,message:ee?.validation?.passwordTooShort||`Password must be at least ${S?.password_policy?.min_length||6} characters long`}],children:s.jsx(p.PasswordInput,{placeholder:K?.formPlaceholders?.password||"Password",autoComplete:"current-password"})}),s.jsx(p.FormItem,{children:s.jsxs("div",{className:"flex justify-between items-center w-full",children:[s.jsx("div",{children:K?.showRememberMe!==!1&&t&&W.isRememberMeEnabled()&&s.jsx(p.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:s.jsx("div",{className:"auth-remember-me",style:I,children:s.jsx(p.Checkbox,{label:K?.rememberMeText||"Remember me"})})})}),s.jsx("div",{children:W.isForgotPasswordEnabled()&&s.jsx(G.Link,{to:"forgot-password",className:"text-sm transition-colors duration-300",style:j,children:K?.forgotPasswordText||"Forgot password?"})})]})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full text-base font-medium",disabled:r,fullWidth:!0,children:K?.submitButtonText||"Sign in"})})]},`${V}-${m}`)},_=()=>{if(!W.isOTPLoginEnabled())return null;const V=v();return u?s.jsx(xo,{onSuccess:E,onBack:()=>h(!1)}):s.jsx(p.Button,{variant:"secondary",fullWidth:!0,onClick:()=>h(!0),className:"bg-gray-100 border-gray-300",children:V?.otpButtonText||"Sign in with OTP"})},J=()=>{if(!S)return null;const V=W.getAllowedUsernames(),K=V.includes("email"),ee=V.includes("mobile"),ne=W.isSSOEnabled()||W.isOIDCEnabled(),ie=W.isPasswordLoginEnabled(),me=W.isOTPLoginEnabled();if(!ie&&!me)return null;if(me&&!ie)return s.jsx("div",{className:"w-full",children:s.jsx(xo,{onSuccess:E})});if(!ie)return null;if(K&&ee&&ie){const $e=v(),Ge=F();return s.jsx("div",{className:"w-full",children:s.jsx(p.Tabs,{className:"login-tabs",activeKey:d,onChange:le=>{l(le),w(Ee=>Ee+1)},items:[{key:"email",label:s.jsxs("span",{className:"flex items-center gap-1",style:U,children:[s.jsx(Ct,{size:16}),$e?.tabLabels?.email||"Email"]}),children:s.jsxs(s.Fragment,{children:[z("email"),me&&ie&&!u&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:Ge?.separatorText||"OR"}),_()]}),u&&_(),!u&&ne&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:Ge?.separatorText||"OR"}),W.isSSOEnabled()&&s.jsx("div",{className:"mb-4"}),W.isOIDCEnabled()&&s.jsx("div",{className:"mt-4",children:s.jsx("div",{className:"space-y-2",children:W.getOIDCProviders().map((le,Ee)=>s.jsx(bo,{provider:le,type:"oidc"},`oidc-email-${Ee}`))})})]})]})},{key:"mobile",label:s.jsxs("span",{className:"flex items-center gap-1",style:U,children:[s.jsx(Zt,{size:16}),$e?.tabLabels?.mobile||"Mobile"]}),children:s.jsxs(s.Fragment,{children:[z("mobile"),me&&ie&&!u&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),_()]}),u&&_(),!u&&ne&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),W.isSSOEnabled()&&s.jsx("div",{className:"mb-4"}),W.isOIDCEnabled()&&s.jsx("div",{className:"mt-4",children:s.jsx("div",{className:"space-y-2",children:W.getOIDCProviders().map((le,Ee)=>s.jsx(bo,{provider:le,type:"oidc",onClick:br=>{console.log("OIDC provider clicked:",br)}},`oidc-${Ee}`))})})]})]})}]})})}else{const $e=K?"email":"mobile";return s.jsxs("div",{className:"w-full",children:[z($e),me&&ie&&!u&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),_()]}),u&&_(),!u&&ne&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),W.isSSOEnabled()&&s.jsx("div",{className:"mb-4"}),W.isOIDCEnabled()&&s.jsx("div",{className:"mt-4"})]})]})}};return S?f?s.jsx("div",{className:"w-full",children:y?s.jsxs("div",{className:"space-y-4",children:[s.jsx("h4",{className:"text-base font-medium mb-4",children:"Change Your Password"}),s.jsx(p.FormItem,{label:"New Password",children:s.jsx(p.PasswordInput,{value:A,onChange:V=>B(V.target.value),placeholder:"Enter new password",disabled:r})}),s.jsx(p.FormItem,{label:"Confirm Password",children:s.jsx(p.PasswordInput,{value:N,onChange:V=>H(V.target.value),placeholder:"Confirm new password",disabled:r})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(p.Button,{type:"primary",onClick:Q,loading:r,className:"flex-1",children:"Change Password"}),s.jsx(p.Button,{onClick:()=>{P(!1),B(""),H("")},disabled:r,className:"flex-1",children:"Cancel"})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"text-center mb-4",children:[s.jsx("h3",{className:"text-lg font-medium",style:U,children:"Already Logged In"}),s.jsx("p",{className:"text-sm mt-2",style:I,children:"You are currently logged in."})]}),s.jsx(p.Button,{block:!0,onClick:()=>P(!0),children:"Change Password"}),s.jsx(p.Button,{block:!0,danger:!0,onClick:Z,loading:r,children:"Logout"})]})}):J():s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:s.jsx(p.Spin,{size:"large"})})},Qi=({onLogin:e,showRememberMe:t=!0,showForgotPassword:r=!0})=>{const[o,a]=g.useState(!1),[n,i]=g.useState(0),[c,d]=g.useState("email"),{authConfig:l}=Ye();g.useEffect(()=>{if(l){const P=W.getAllowedUsernames();P&&P.length>0&&d(P[0])}},[l]);const u=async P=>{a(!0);try{if(e){const A={email:c==="email"?P.username:void 0,phone:c==="mobile"?P.username:void 0,username:P.username,password:P.password,remember_me:P.remember||!1};await e(A)}}catch(A){p.toast.error(A.message||"Login failed. Please try again.")}finally{a(!1)}},h=()=>{switch(c){case"email":return"Email address";case"mobile":return"Phone number";case"username":return"Username";default:return"Username"}},m=()=>{const P=[{required:!0,message:`Please input your ${c}!`}];switch(c){case"email":return[...P,{type:"email",message:"Please enter a valid email address!"}];case"mobile":return[...P,{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid phone number!"}];case"username":return[...P,{min:3,message:"Username must be at least 3 characters long"}];default:return P}};if(!l)return s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const w=W.getAllowedUsernames(),f=w.length>1,x=W.isRememberMeEnabled(),y=W.isForgotPasswordEnabled();return s.jsxs(p.Form,{name:"login",className:"w-full space-y-4",initialValues:{remember:!1},onFinish:u,autoComplete:"off",layout:"vertical",children:[f&&s.jsx(p.FormItem,{label:"Login with",className:"mb-4",children:s.jsx(p.Select,{value:c,onChange:d,options:w.map(P=>({value:P,label:P==="mobile"?"Phone":P.charAt(0).toUpperCase()+P.slice(1)}))})}),s.jsx(p.FormItem,{name:"username",rules:m(),children:s.jsx(p.Input,{placeholder:h(),autoComplete:c==="email"?"email":"username"})}),s.jsx(p.FormItem,{name:"password",rules:[{required:!0,message:"Please input your password!"},{min:l?.password_policy?.min_length||6,message:`Password must be at least ${l?.password_policy?.min_length||6} characters long`}],children:s.jsx(p.PasswordInput,{placeholder:"Password",autoComplete:"current-password"})}),s.jsx(p.FormItem,{children:s.jsxs(p.Space,{className:"flex justify-between items-center w-full",children:[t&&x&&s.jsx(p.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:s.jsx(p.Checkbox,{label:"Remember me"})}),r&&y&&s.jsx(G.Link,{to:"forgot-password",className:"text-brand-500 text-sm hover:text-brand-600 transition-colors",children:"Forgot password?"})]})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:o,fullWidth:!0,children:"Log in"})})]},n)},Yi=({onLogin:e,logo:t,title:r,subtitle:o,apiConfig:a={},useDynamicConfig:n=!0,staticConfig:i=null})=>{const[c,d]=g.useState(null),[l,u]=g.useState(n),[h,m]=g.useState(null),{authConfig:w}=Be(),f=qe(w),x=yo(w),y=lr(w),P=cr(w),A=ir(w),B=nr(w);g.useEffect(()=>{n&&!i?N():i&&(d(i),u(!1))},[n,i]);const N=async()=>{try{const S=await W.getAuthConfig();d(S),m(null)}catch(S){console.error("Failed to fetch login methods:",S),m("Failed to load login methods. Please refresh the page.")}finally{u(!1)}},H=()=>l?s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:s.jsx(p.Spin,{size:"large",tip:"Loading login methods..."})}):h?s.jsx(p.Alert,{message:"Error",description:h,type:"error",showIcon:!0,action:s.jsx("a",{onClick:N,children:"Retry"})}):c&&n?s.jsx(Xi,{onLogin:e}):s.jsx(Qi,{onLogin:e});return s.jsx(p.Layout,{className:"min-h-screen",style:x,children:s.jsx(p.Layout.Content,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsxs(p.Card,{className:"w-full max-w-md",bordered:!1,style:f,children:[t&&s.jsx("div",{className:A.className,style:A.style,children:typeof t=="string"?s.jsx("img",{src:t,alt:w?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:B}):t}),s.jsxs("div",{className:"text-center mb-[18px]",children:[s.jsx("h1",{className:"text-3xl font-semibold mb-2",style:y,children:r||"Welcome Back"}),o&&s.jsx("p",{className:"text-base",style:P,children:o})]}),H()]})})})},{Title:Po,Text:ut,Paragraph:Ri}=p.Typography,el=({size:e="default",icon:t,src:r,style:o,className:a,children:n})=>{const c=typeof e=="number"?e:{small:24,default:32,large:40}[e];return s.jsx("div",{className:`inline-flex items-center justify-center bg-blue-500 text-white rounded-full overflow-hidden ${a||""}`,style:{width:c,height:c,fontSize:c*.45,...o},children:r?s.jsx("img",{src:r,alt:"Avatar",className:"w-full h-full object-cover"}):t||n||s.jsx(Gt,{size:c*.6})})},tl=({description:e,className:t,image:r})=>s.jsxs("div",{className:`flex flex-col items-center justify-center py-8 ${t||""}`,children:[!r&&s.jsx("div",{className:"mb-4 text-gray-400",children:s.jsx("svg",{width:"64",height:"41",viewBox:"0 0 64 41",fill:"currentColor",children:s.jsxs("g",{transform:"translate(0 1)",fillRule:"evenodd",children:[s.jsx("ellipse",{fill:"#f5f5f5",cx:"32",cy:"33",rx:"32",ry:"7"}),s.jsxs("g",{fillRule:"nonzero",stroke:"#d9d9d9",children:[s.jsx("path",{d:"M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"}),s.jsx("path",{d:"M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z",fill:"#fafafa"})]})]})})}),e&&s.jsx("div",{className:"text-sm text-gray-500",children:e})]}),rl=e=>{const t=e.toLowerCase();return t.includes("admin")?s.jsx(Ba,{size:20}):t.includes("manager")||t.includes("supervisor")?s.jsx($a,{size:20}):t.includes("security")||t.includes("compliance")?s.jsx(fs,{size:20}):s.jsx(Gt,{size:20})},So=({user:e,roles:t,onRoleSelect:r,loading:o=!1,title:a="Choose Your Role",subtitle:n="Select the role that best matches your current responsibilities",logo:i})=>{const[c,d]=g.useState(null),[l,u]=g.useState(!1),{getRoleSelectionConfig:h,getCardConfig:m,authConfig:w}=Be(),f=h(),x=qe(w),y=ir(w),P=nr(w),A=async()=>{if(c){u(!0);try{await r(c)}catch(S){console.error("Role selection failed:",S)}finally{u(!1)}}};if(o)return s.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:s.jsx(p.Spin,{size:"large",tip:"Loading your available roles..."})});if(!t||t.length===0){const S=f?.customEmptyState;return S?s.jsx(S,{}):s.jsx("div",{className:"max-w-lg mx-auto p-5",children:s.jsx("div",{style:x,children:s.jsx(tl,{className:"text-center py-12 px-5 text-gray-500",description:s.jsxs("div",{children:[s.jsx(ut,{className:"text-gray-600 text-base block mb-2",children:f?.emptyStateMessage||"No roles available"}),s.jsx(ut,{type:"secondary",className:"text-sm",children:"Please contact your administrator for role assignment"})]})})})})}const B=g.isValidElement(f?.title)?f.title:f?.title||a,N=g.isValidElement(f?.subtitle)?f.subtitle:f?.subtitle||n,H=f?.gridColumns||(t.length<=2?2:3);return s.jsx("div",{className:"max-w-lg mx-auto p-5",children:s.jsxs("div",{style:x,children:[i&&s.jsx("div",{className:y.className,style:y.style,children:typeof i=="string"?s.jsx("img",{src:i,alt:w?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:P}):i}),s.jsxs("div",{className:"text-center mb-8",children:[g.isValidElement(B)?B:s.jsx(Po,{level:3,className:"!mb-3 !text-2xl !font-semibold !text-gray-800",children:B}),g.isValidElement(N)?N:s.jsx(Ri,{className:"!mb-6 text-base text-gray-600 !leading-relaxed",children:N}),e&&s.jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-3 bg-gray-50 rounded-xl border border-gray-200",children:[s.jsx(el,{size:"default",className:"bg-blue-500",children:(e.name||e.username||"U").split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2)}),s.jsxs("div",{className:"text-left",children:[s.jsx(ut,{strong:!0,className:"text-sm block text-gray-800",children:e.name||e.username||"User"}),e.email&&s.jsx(ut,{type:"secondary",className:"text-xs",children:e.email})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"max-h-96 overflow-y-auto px-2 py-2",style:{maxHeight:f?.maxHeight||"24rem"},children:s.jsx("div",{className:`grid gap-4 grid-cols-${H}`,children:t.map(S=>{const v=f?.customRoleCard;if(v)return s.jsx(v,{role:S,selected:c?.id===S.id,onSelect:()=>d(S)},S.id);const C=f?.roleCardStyling||{},F=c?.id===S.id;return s.jsxs("div",{className:"cursor-pointer transition-all duration-300 border relative p-4 hover:-translate-y-1 flex flex-col items-center h-32 min-h-[8rem]",style:{backgroundColor:F?C.selectedColor||"#e6f7ff":C.backgroundColor||"#ffffff",borderColor:F?C.selectedColor||"#1890ff":"#d9d9d9",borderRadius:C.borderRadius||"16px",...f?.roleCardStyling},onClick:()=>d(S),children:[c?.id===S.id&&s.jsx("div",{className:"absolute -top-2 -right-2 bg-brand-500 rounded-full p-2",children:s.jsx(Oe,{size:16,className:"text-white"})}),s.jsx("div",{className:"flex justify-center mt-2 mb-3",children:s.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-xl flex items-center justify-center",children:rl(S.name)})}),s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-1",children:[s.jsx(Po,{level:5,className:"!mb-0 !text-sm !font-semibold !text-gray-900 !leading-tight !line-clamp-2 !text-center",title:S.name,children:S.name}),S.is_default&&s.jsx("div",{className:"mt-1",children:s.jsx(p.Tag,{color:"warning",className:"bg-yellow-50 border-yellow-300 text-yellow-700 font-medium text-xs px-1",children:f?.recommendedBadgeText||"Recommended"})})]})]},S.id)})})})}),s.jsxs("div",{className:"pt-4 border-t border-gray-200",children:[s.jsx(p.Button,{type:"primary",block:!0,onClick:A,disabled:!c,loading:l,icon:c?s.jsx(Oe,{size:16}):null,className:"w-full",children:c?f?.continueButtonText?.replace("{roleName}",c.name)||`Continue as ${c.name}`:"Please select a role to continue"}),c?.is_default&&s.jsx(ut,{type:"secondary",className:"block text-center mt-3 text-sm",children:"This is your recommended role based on your permissions"})]})]})})},{Content:sl}=p.Layout,ol=({logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a=!0,staticConfig:n=null,onLoginSuccess:i,roleSelectionTitle:c,roleSelectionSubtitle:d})=>{const{pendingAuth:l,availableRoles:u,selectRole:h,login:m}=Ye(),[w,f]=g.useState(null),x=async P=>{f(null);try{const A=await m(P),B={email:P.email,username:P.username,phone:P.phone,display:P.email||P.username||P.phone};if(A.requiresRoleSelection)return;i&&i({...A,loginUser:B})}catch(A){throw f(A.message),A}},y=async P=>{try{const A=await h(P);i&&i(A)}catch(A){throw console.error("Role selection failed:",A),A}};return l&&u?s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(sl,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx(So,{user:l.user,roles:u,onRoleSelect:y,title:c,subtitle:d})})}):s.jsx(Yi,{onLogin:x,logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a,staticConfig:n})},{Title:al,Text:ur,Paragraph:nl}=p.Typography,il=({user:e,availableMethods:t=["email","sms"],onVerify:r,loading:o=!1,otpDigits:a=6,retryInterval:n=30,title:i="Two-Factor Authentication",subtitle:c="For your security, please verify your identity"})=>{const[d,l]=g.useState(t[0]||"email"),[u,h]=g.useState(""),[m,w]=g.useState(0),[f,x]=g.useState(!1),[y,P]=g.useState(!1),{authConfig:A,getTwoFactorConfig:B,getMessagesConfig:N}=Be(),H=B(),S=N(),v=qe(A);g.useEffect(()=>{if(m>0){const I=setTimeout(()=>w(m-1),1e3);return()=>clearTimeout(I)}},[m]);const C=I=>{if(I==="email"&&e?.email){const[j,L]=e.email.split("@");return`${j.substring(0,3)+"****"+j.substring(j.length-1)}@${L}`}return(I==="sms"||I==="mobile")&&e?.mobile?`****${e.mobile.substring(e.mobile.length-4)}`:I==="totp"?"your authenticator app":I==="email"?"your email":I==="sms"?"your mobile":"your authenticator app"},F=async()=>{x(!0);try{await W.sendTwoFactorCode(d),P(!0),w(H?.resendCountdown||n);const I=S?.success?.otpSent||`OTP sent to ${C(d)}`;p.toast.success(I)}catch(I){const j=S?.errors?.networkError||I.message||"Failed to send OTP";p.toast.error(j)}finally{x(!1)}},D=async()=>{const I=H?.codeLength||a;if(u.length!==I){const j=S?.validation?.required||`Please enter ${I} digit OTP`;p.toast.error(j);return}x(!0);try{const j=await W.verifyTwoFactorCode(u);await r(j)}catch(j){const L=S?.errors?.invalidOTP||j.message||"Invalid OTP";p.toast.error(L),h("")}finally{x(!1)}},k=async()=>{m>0||await F()},U=()=>{if(t.length<=1)return null;const I=t.map(j=>({label:s.jsxs(p.Space,{children:[j==="email"?s.jsx(Ct,{size:16}):j==="sms"?s.jsx(Zt,{size:16}):s.jsx(fs,{size:16}),s.jsx("span",{children:j==="email"?H?.methodLabels?.email||"Email":j==="sms"?H?.methodLabels?.sms||"SMS":H?.methodLabels?.mobile||"Authenticator"})]}),value:j}));return s.jsxs("div",{className:"mb-6",children:[s.jsx(ur,{type:"secondary",className:"block mb-2 text-xs",children:"Verification Method"}),s.jsx(p.Segmented,{options:I,value:d,onChange:j=>{l(j),P(!1),h("")},block:!0})]})};return s.jsx("div",{className:"w-full max-w-lg mx-auto",children:s.jsxs(p.Card,{className:"shadow-lg rounded-lg",bordered:!1,style:v,children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx(al,{level:3,className:"!mb-2",children:H?.title||i}),s.jsx(nl,{className:"!mb-0 text-sm",type:"secondary",children:H?.subtitle||c})]}),s.jsxs("div",{className:"mt-6",children:[U(),y?s.jsxs("div",{className:"mt-6",children:[s.jsx(ur,{className:"block text-center mb-6 text-gray-700",children:H?.instructionText||`Enter the ${H?.codeLength||a}-digit code sent to ${C(d)}`}),s.jsx("div",{className:"flex justify-center mb-6",children:s.jsx(Co,{length:H?.codeLength||a,value:u,onChange:h,disabled:f})}),s.jsx(p.Button,{variant:"primary",fullWidth:!0,disabled:f,onClick:D,className:"mb-4",children:H?.submitButtonText||"Verify"}),s.jsx("div",{className:"text-center",children:m>0?s.jsxs(ur,{type:"secondary",children:["Resend code in ",m,"s"]}):s.jsx(p.Button,{variant:"link",onClick:k,disabled:f,children:H?.resendButtonText||"Resend Code"})})]}):s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Alert,{message:H?.instructionText||`We'll send a verification code to ${C(d)}`,type:"info",showIcon:!0,className:"mb-6"}),s.jsx(p.Button,{variant:"primary",fullWidth:!0,disabled:f,onClick:F,children:"Send Verification Code"})]})]})]})})},{Title:ll,Text:Ie,Paragraph:cl}=p.Typography,dl=({reason:e="Your password has expired",onReset:t,loading:r=!1,title:o="Password Reset Required",subtitle:a="Please create a new password to continue",passwordRules:n})=>{const[i,c]=g.useState(0),[d,l]=g.useState(!1),[u,h]=g.useState(""),[m,w]=g.useState({minLength:8,requireUppercase:!0,requireLowercase:!0,requireNumbers:!0,requireSpecialChars:!0}),{authConfig:f,getResetPasswordConfig:x,getMessagesConfig:y}=Be(),P=x(),A=y(),B=qe(f);g.useEffect(()=>{if(n)w(n);else{const C=W.getPasswordPolicy();w({minLength:C.min_length||8,maxLength:C.max_length,requireUppercase:C.require_uppercase||!1,requireLowercase:C.require_lowercase||!1,requireNumbers:C.require_numbers||!1,requireSpecialChars:C.require_special_chars||!1})}},[n]);const N=C=>{if(!C)return{percent:0,status:"exception"};let F=0;return C.length>=m.minLength&&(F+=20),C.length>=12&&(F+=10),m.requireUppercase&&/[A-Z]/.test(C)&&(F+=20),m.requireLowercase&&/[a-z]/.test(C)&&(F+=20),m.requireNumbers&&/\d/.test(C)&&(F+=15),m.requireSpecialChars&&/[!@#$%^&*]/.test(C)&&(F+=15),F<40?{percent:F,status:"exception"}:F<70?{percent:F,status:"normal"}:{percent:F,status:"success"}},H=(C,F)=>{if(!F){const k=A?.validation?.required||"Please input your password!";return Promise.reject(new Error(k))}const D=W.validatePassword(F);if(!D.valid){const k=A?.validation?.passwordTooShort||D.errors.join(", ");return Promise.reject(new Error(k))}return Promise.resolve()},S=async C=>{l(!0);try{await W.setPassword(C.password),await t({password:C.password,confirmPassword:C.confirmPassword})}catch(F){throw F}finally{l(!1)}},v=N(u);return s.jsx("div",{className:"w-full max-w-lg mx-auto",children:s.jsxs(p.Card,{className:"shadow-lg rounded-lg",bordered:!1,style:B,children:[s.jsxs("div",{className:"text-center mb-6",children:[s.jsx(ll,{level:3,className:"!mb-2",children:P?.resetForm?.title||o}),s.jsx(cl,{className:"!mb-0 text-sm",type:"secondary",children:P?.resetForm?.subtitle||a})]}),s.jsx(p.Alert,{message:e,type:"warning",showIcon:!0,className:"mb-6"}),s.jsxs(p.Form,{name:"password-reset-required",onFinish:S,layout:"vertical",className:"mt-6",children:[s.jsx(p.FormItem,{name:"password",label:P?.resetForm?.passwordLabel||"New Password",rules:[{validator:H}],children:s.jsx(p.PasswordInput,{prefix:s.jsx(bt,{size:16}),placeholder:P?.resetForm?.passwordPlaceholder||"New Password",onChange:C=>h(C.target.value)})}),u&&s.jsxs("div",{className:"-mt-4 mb-4",children:[s.jsx(Ie,{type:"secondary",className:"text-xs block mb-1",children:"Password Strength"}),s.jsx(p.Progress,{percent:v.percent,status:v.status,showInfo:!1,strokeWidth:4})]}),s.jsx(p.FormItem,{name:"confirmPassword",label:P?.resetForm?.confirmPasswordLabel||"Confirm Password",dependencies:["password"],rules:[{required:!0,message:A?.validation?.required||"Please confirm your password!"},({getFieldValue:C})=>({validator(F,D){if(!D||C("password")===D)return Promise.resolve();const k=A?.validation?.passwordsDoNotMatch||"Passwords do not match!";return Promise.reject(new Error(k))}})],children:s.jsx(p.PasswordInput,{prefix:s.jsx(bt,{size:16}),placeholder:P?.resetForm?.confirmPasswordPlaceholder||"Confirm Password"})}),P?.resetForm?.showPasswordRequirements!==!1&&s.jsxs("div",{className:"bg-gray-50 p-4 rounded-md mb-6",children:[s.jsx(Ie,{type:"secondary",className:"block font-medium mb-2",children:P?.resetForm?.passwordRequirementsText||"Password Requirements:"}),s.jsxs(p.Space,{direction:"vertical",size:"small",children:[s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:u.length>=m.minLength?"text-green-500":"text-gray-300"}),"At least ",m.minLength," characters"]}),m.maxLength&&s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:u.length<=m.maxLength?"text-green-500":"text-gray-300"}),"At most ",m.maxLength," characters"]}),m.requireUppercase&&s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:/[A-Z]/.test(u)?"text-green-500":"text-gray-300"}),"One uppercase letter"]}),m.requireLowercase&&s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:/[a-z]/.test(u)?"text-green-500":"text-gray-300"}),"One lowercase letter"]}),m.requireNumbers&&s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:/\d/.test(u)?"text-green-500":"text-gray-300"}),"One number"]}),m.requireSpecialChars&&s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:/[!@#$%^&*]/.test(u)?"text-green-500":"text-gray-300"}),"One special character (!@#$%^&*)"]})]})]}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",fullWidth:!0,disabled:d||r,children:P?.resetForm?.submitButtonText||"Reset Password"})})]},i)]})})},{Content:Ot}=p.Layout,hr=({logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a=!0,staticConfig:n=null,onAuthComplete:i,roleSelectionTitle:c,roleSelectionSubtitle:d,twoFactorTitle:l,twoFactorSubtitle:u,passwordResetTitle:h,passwordResetSubtitle:m,initialAuthState:w=null})=>{const{user:f,pendingAuth:x}=Ye(),{authConfig:y}=Be();ir(y),nr(y);const[P,A]=g.useState(()=>{if(w){if(w.roles&&w.roles.length>1)return"roleSelection";if(w.requires2FA)return"twoFactor";if(w.requiresPasswordReset)return"passwordReset"}return"login"}),[B,N]=g.useState(w?.token||null),[H,S]=g.useState(w?.twoFactorMethods||null),[v,C]=g.useState(w?.passwordResetReason||null),[F,D]=g.useState(w||null),k=async L=>{console.log("Login success result:",L);let T=L,M=null;L?.status===401&&L?.data?(T=L.data,M=L.data?.next_step):L?.next_step?(T=L,M=L.next_step):(T=L?.response?.data||L?.data||L,M=T?.next_step);const E=L?.loginUser;(L?.token||T?.token)&&N(L.token||T.token);let Z=L?.user||T?.user||E||{};if((typeof Z!="object"||Z===null)&&(Z={}),E&&typeof E=="object"&&(Z={...Z,email:Z.email||E.email,username:Z.username||E.username,phone:Z.phone||E.phone,name:Z.name||E.display}),M&&M.is_pending)switch(M.id){case"role_selection":let Q=[];Array.isArray(M.metadata.roles)?Q=M.metadata.roles:typeof M.metadata.roles=="object"&&(Q=Object.entries(M.metadata.roles).map(([J,V])=>({id:J,name:V,is_default:!1}))),D({...L,roles:Q,user:Z,nextStep:M,loginUser:E}),A("roleSelection");return;case"mfa_authenticate":N(L.token||T?.token);const z=M.metadata?.type?[M.metadata.type]:M.metadata?.methods||["email"];S(z),A("twoFactor");return;case"set_password":N(L.token||T?.token);const _=M.metadata?.password_policy;C(M.metadata?.reason||"Password update required"),D({...L,passwordPolicy:_,user:Z,loginUser:E}),A("passwordReset");return;case"password_expiry":N(L.token||T?.token),C("Your password has expired"),D({...L,passwordPolicy:M.metadata?.password_policy,user:Z,loginUser:E}),A("passwordReset");return;case"first_login":N(L.token||T?.token),C("Please set up your password for first login"),D({...L,passwordPolicy:M.metadata?.password_policy,user:Z,loginUser:E}),A("passwordReset");return;case"login_by_code":N(L.token||T?.token),console.log("OTP login flow required"),p.toast.info("OTP verification required"),i&&i({...L,user:Z,requiresOTP:!0});return}if(L.requires2FA){N(L.token),S(L.twoFactorMethods||["email"]),D({...L,user:Z,loginUser:E}),A("twoFactor");return}if(L.requiresPasswordReset){N(L.token),C(L.passwordResetReason||"Your password has expired"),D({...L,user:Z,loginUser:E}),A("passwordReset");return}i&&i({...L,user:Z})},U=async L=>{try{console.log("2FA verification result:",L);let T=L,M=null,E=!1,Z=null;if(L?.status===401&&L?.data?(T=L.data,M=L.data?.next_step,Z=L.status,E=L?.meta?.is_authenticated||!1):L?.response?(Z=L.response.status,T=L.response.data,M=T?.next_step,E=L.response.meta?.is_authenticated||!1):(T=L?.data||L,M=T?.next_step,E=L?.meta?.is_authenticated||T?.meta?.is_authenticated||!1,Z=L?.status||T?.status),Z===200&&E){console.log("Authentication completed successfully after 2FA"),p.toast.success("Two-factor authentication successful!"),i&&i({...L,token:B,user:F?.user,authenticated:!0});return}if(M&&M.is_pending)switch(M.id){case"set_password":const Q=M.metadata?.password_policy;C(M.metadata?.reason||"Password reset required"),D({...F,passwordPolicy:Q}),A("passwordReset");return;default:console.warn("Unknown next step after 2FA:",M.id);break}if(L.requiresPasswordReset){C(L.passwordResetReason||"Your password has expired"),A("passwordReset");return}p.toast.success("Two-factor authentication successful!"),i&&i({...L,token:B,user:F?.user,authenticated:!0})}catch(T){throw T}},I=async L=>{try{const T=await W.setPassword(L.password);console.log("Password reset result:",T);let M=T,E=null,Z=!1,Q=null;if(T?.status===401&&T?.data?(M=T.data,E=T.data?.next_step,Q=T.status,Z=T?.meta?.is_authenticated||!1):T?.response?(Q=T.response.status,M=T.response.data,E=M?.next_step,Z=T.response.meta?.is_authenticated||!1):(M=T?.data||T,E=M?.next_step,Z=T?.meta?.is_authenticated||M?.meta?.is_authenticated||!1,Q=T?.status||M?.status),Q===200&&Z){console.log("Authentication completed successfully after password reset"),p.toast.success("Password reset successful!"),i&&i({...T,token:B,user:F?.user,authenticated:!0});return}if(E&&E.is_pending)switch(E.id){case"mfa_authenticate":const z=E.metadata?.type?[E.metadata.type]:E.metadata?.methods||["email"];S(z),A("twoFactor");return;default:console.warn("Unknown next step after password reset:",E.id);break}p.toast.success("Password reset successful!"),i&&i({...T,token:B,user:F?.user,authenticated:!0})}catch(T){throw p.toast.error(T.message||"Failed to reset password"),T}};return(()=>{switch(P){case"login":return s.jsx(ol,{onLoginSuccess:k,logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a,staticConfig:n,roleSelectionTitle:c,roleSelectionSubtitle:d});case"roleSelection":return F?.roles?s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Ot,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx("div",{className:"w-full",children:s.jsx(So,{user:F?.user,roles:F?.roles||[],logo:e,onRoleSelect:async M=>{try{const E=await W.selectRole(M.id);console.log("Role selection result:",E);let Z=E,Q=null,z=!1,_=null;if(E?.status===401&&E?.data?(Z=E.data,Q=E.data?.next_step,_=E.status,z=E?.meta?.is_authenticated||!1):E?.response?(_=E.response.status,Z=E.response.data,Q=Z?.next_step,z=E.response.meta?.is_authenticated||!1):(Z=E?.data||E,Q=Z?.next_step,z=E?.meta?.is_authenticated||Z?.meta?.is_authenticated||!1,_=E?.status||Z?.status),_===200&&z){console.log("Authentication completed successfully after role selection"),p.toast.success("Role selected successfully!"),i&&i({...E,user:{...F.user,role:M},authenticated:!0});return}if(Q&&Q.is_pending)switch(Q.id){case"mfa_authenticate":const J=Q.metadata?.type?[Q.metadata.type]:Q.metadata?.methods||["email"];S(J),A("twoFactor");return;case"set_password":const V=Q.metadata?.password_policy;C(Q.metadata?.reason||"Password update required"),D({...F,passwordPolicy:V}),A("passwordReset");return;case"password_expiry":C("Your password has expired"),D({...F,passwordPolicy:Q.metadata?.password_policy}),A("passwordReset");return;case"first_login":C("Please set up your password for first login"),D({...F,passwordPolicy:Q.metadata?.password_policy}),A("passwordReset");return;case"login_by_code":console.log("OTP login flow required after role selection"),p.toast.info("OTP verification required"),i&&i({...E,user:{...F.user,role:M},requiresOTP:!0});return;default:console.warn("Unknown next step:",Q.id);break}p.toast.success("Role selected successfully!"),i&&i({...E,user:{...F.user,role:M}})}catch(E){throw p.toast.error(E.message||"Failed to select role"),E}},title:c||"Select Your Role",subtitle:d||"Choose a role to continue"})})})}):s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Ot,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx("div",{className:"text-center py-16 px-5",children:s.jsx(p.Spin,{size:"large",tip:"Loading..."})})})});case"twoFactor":return s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Ot,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx(il,{user:F?.user||x?.user||f,availableMethods:H,onVerify:U,title:l,subtitle:u})})});case"passwordReset":const L=F?.passwordPolicy,T=L?{minLength:L.min_length||8,maxLength:L.max_length,requireUppercase:L.require_uppercase||!1,requireLowercase:L.require_lowercase||!1,requireNumbers:L.require_numbers||!1,requireSpecialChars:L.require_special_chars||!1}:void 0;return s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Ot,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx(dl,{reason:v,onReset:I,title:h,subtitle:m,passwordRules:T})})});default:return null}})()},{Content:ul}=p.Layout,hl=({logo:e,apiConfig:t,onAuthComplete:r,roleSelectionTitle:o,roleSelectionSubtitle:a,twoFactorTitle:n,twoFactorSubtitle:i,passwordResetTitle:c,passwordResetSubtitle:d,redirectPath:l="/"})=>{const[u,h]=g.useState(null),[m,w]=g.useState(!1),f=async P=>{P.requiresRoleSelection||P.requires2FA||P.requiresPasswordReset?(h(P),w(!0)):(P.token&&localStorage.setItem(t?.tokenKey||"authToken",P.token),r&&r(P))},x=P=>{console.error("OAuth callback error:",P)},y=P=>{const A={...u,...P,authMethod:"oauth",provider:u?.provider};r&&r(A)};return m&&u?s.jsx(hr,{logo:e,apiConfig:t,onAuthComplete:y,roleSelectionTitle:o,roleSelectionSubtitle:a,twoFactorTitle:n,twoFactorSubtitle:i,passwordResetTitle:c,passwordResetSubtitle:d,initialAuthState:{user:u.user,token:u.token,roles:u.roles,requires2FA:u.requires2FA,twoFactorMethods:u.twoFactorMethods,requiresPasswordReset:u.requiresPasswordReset,passwordResetReason:u.passwordResetReason}}):s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(ul,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx($i,{onSuccess:f,onError:x,apiConfig:t,redirectPath:l})})})},ko=()=>Ye(),{Header:Sc,Content:Ao}=p.Layout,fr={},pr={},gr={"admin@example.com":{requires2FA:!0,requiresPasswordReset:!1,twoFactorMethods:["email","mobile"]},"+919876543210":{requires2FA:!0,requiresPasswordReset:!0,passwordResetReason:"Your password will expire in 7 days",twoFactorMethods:["mobile"]},"test@example.com":{requires2FA:!1,requiresPasswordReset:!0,passwordResetReason:"Password has expired"}},ht={"admin@example.com":[{id:1,name:"Super Admin",description:"Full system access with all administrative privileges",permissions:["system.manage","users.manage","roles.manage","settings.manage"],is_default:!1},{id:2,name:"Organization Admin",description:"Manage organization settings and users",permissions:["org.manage","users.manage","reports.view"],is_default:!0},{id:3,name:"Compliance Officer",description:"Monitor compliance and security settings",permissions:["compliance.view","audit.view","reports.generate"],is_default:!1}],"+919876543210":[{id:4,name:"Team Manager",description:"Manage team members and projects",permissions:["team.manage","projects.manage","reports.view"],is_default:!0},{id:5,name:"Employee",description:"Standard employee access",permissions:["profile.edit","tasks.manage","reports.view"],is_default:!1}],default:[{id:6,name:"User",description:"Standard user access",permissions:["profile.view","profile.edit"],is_default:!0}]},mr=e=>({loginEndpoint:"/api/auth/login",logoutEndpoint:"/api/auth/logout",verifyEndpoint:"/api/auth/verify",forgotPasswordEndpoint:"/api/auth/forgot-password",resetPasswordEndpoint:"/api/auth/reset-password",loginMethodsEndpoint:"/api/v1/login/?action=fetch_methods",otpRequestEndpoint:"/api/auth/otp/request",otpVerifyEndpoint:"/api/auth/otp/verify",apiClient:{post:async(t,r)=>{if(console.log("Mock API POST:",t,r),await new Promise(o=>setTimeout(o,1e3)),t.includes("login")){const o=r.email||r.phone||r.username;if(["admin@example.com","+919876543210","test@example.com","admin"].includes(o)&&r.password==="password"){const i=ht[o]||ht.default,c=gr[o]||{};return{user:{id:1,username:o,email:o.includes("@")?o:"user@example.com",mobile:o.startsWith("+")?o:"+919876543210",name:o==="admin@example.com"?"John Admin":o.startsWith("+")?"Mobile User":"Test User"},token:"mock-jwt-token-12345",roles:i,...c}}throw new Error("Invalid credentials")}if(t.includes("otp/request")){const o=r.email_or_phone||r.email||r.phone||r.username,a=Math.floor(Math.random()*9e5+1e5).toString().slice(0,6);return fr[o]=a,console.log(`📱 Mock OTP for ${o}: ${a}`),p.toast.info(`Mock OTP sent! Check console for OTP: ${a}`),{success:!0,message:"OTP sent successfully"}}if(t.includes("otp/verify")){const o=r.email_or_phone||r.email||r.phone||r.username;if(fr[o]===r.otp){delete fr[o];const n=ht[o]||ht.default;return{user:{id:1,username:o,email:o.includes("@")?o:"user@example.com",mobile:o.startsWith("+")?o:"+919876543210",name:o.includes("@")?"OTP User":"Mobile User"},token:"mock-jwt-token-otp-12345",roles:n}}throw new Error("Invalid OTP")}if(t.includes("forgot-password"))return{message:"Reset email sent successfully"};if(t.includes("reset-password"))return{message:"Password reset successfully"};if(t.includes("role/select"))return console.log("Role selected:",r),{success:!0,...gr["admin@example.com"]||{}};if(t.includes("2fa/send")){const o=Math.floor(Math.random()*9e5+1e5).toString().slice(0,6);return pr[r.method]=o,console.log(`📱 2FA OTP for ${r.method}: ${o}`),p.toast.info(`2FA OTP sent! Check console for OTP: ${o}`),{success:!0,message:"2FA code sent successfully"}}if(t.includes("2fa/verify")){if(pr[r.method]===r.otp){delete pr[r.method];const n=gr["admin@example.com"]||{};return{success:!0,requiresPasswordReset:n.requiresPasswordReset,passwordResetReason:n.passwordResetReason}}throw new Error("Invalid 2FA code")}if(t.includes("password/change"))return console.log("Password changed:",r),{success:!0,message:"Password changed successfully"};if(t.includes("oauth/callback")){console.log("OAuth callback:",r);const o=r.provider||"google",a={id:1,email:`user@${o}.com`,name:`${o.charAt(0).toUpperCase()+o.slice(1)} User`,username:`user@${o}.com`};return o==="google"?{user:a,token:"mock-oauth-token-12345",roles:ht["admin@example.com"],requires2FA:!0,twoFactorMethods:["email"]}:o==="microsoft"?{user:a,token:"mock-oauth-token-12345",requiresPasswordReset:!0,passwordResetReason:"first_login"}:{user:a,token:"mock-oauth-token-12345"}}return{success:!0}},get:async t=>{if(console.log("Mock API GET:",t),await new Promise(r=>setTimeout(r,500)),t.includes("fetch_methods")||t.includes("config"))return{success:!0,response:{auth_config:{login_methods:{password:{enabled:!0,forgot_password_enabled:!0,allowed_usernames:["email","phone"]},otp:{enabled:!0,allowed_methods:["email","sms"]},sso:{enabled:!1},oidc:{enabled:!1}},password_policy:{min_length:8,require_numbers:!0,require_lowercase:!0,require_uppercase:!0,require_special_chars:!0,password_expiry_days:90,password_history_count:3,allow_change:!0,reset:{enabled:!0,method:["email"],expiry_hours:2}},session_policy:{remember_me_enabled:!0,remember_me_duration_days:30},two_factor_auth:{required:!0,allowed_methods:[]}}}};if(t.includes("verify")){console.log("Inside verify");const r=localStorage.getItem("authToken");if(r&&r.startsWith("mock-jwt-token"))return{id:1,username:"admin",email:"admin@example.com"};throw new Error("Invalid token")}return{}}}}),fl=({basePath:e="/login",apiConfig:t={},onAuthComplete:r,logo:o,title:a="Welcome Back",subtitle:n="Please sign in to your account",roleSelectionTitle:i="Select Your Role",roleSelectionSubtitle:c="Choose a role to continue",twoFactorTitle:d="Two-Factor Authentication",twoFactorSubtitle:l="Please enter your verification code",passwordResetTitle:u="Reset Password",passwordResetSubtitle:h="Please enter your new password"})=>{const{authConfig:m}=Pe();G.useLocation(),G.useNavigate();const[w,f]=g.useState(null),{setBasePath:x}=Et();g.useEffect(()=>{x(e)},[e,x]),g.useEffect(()=>(m&&Oi(m),()=>{Mi()}),[m]);const y=g.useMemo(()=>{const S=m?.login||{},v=m?.logo||{};return{logo:v.url?s.jsx("img",{src:v.url,alt:v.alt||"Logo",style:{width:v.width||"auto",height:v.height||"auto",...v.style},className:v.className}):o,title:S.title||a,subtitle:S.subtitle||n,roleSelectionTitle:m?.roleSelection?.title||i,roleSelectionSubtitle:m?.roleSelection?.subtitle||c,twoFactorTitle:m?.twoFactor?.title||d,twoFactorSubtitle:m?.twoFactor?.subtitle||l,passwordResetTitle:m?.resetPassword?.resetForm?.title||u,passwordResetSubtitle:m?.resetPassword?.resetForm?.subtitle||h}},[m,o,a,n,i,c,d,l,u,h]),P=g.useMemo(()=>yo(m),[m]);console.log("basePath",e),console.log("apiConfig",t);const A=S=>{f(S),r&&r(S)},B=()=>{G.useNavigate();const S=async v=>{console.log("Authentication complete:",v),p.toast.success("Authentication complete!");try{const F=new URLSearchParams(window.location.search).get("next");let D="/app";F&&(D=decodeURIComponent(F),console.log("Redirecting to 'next' parameter:",D)),console.log("Final redirect URL:",D),window.location.href=D}catch(C){console.error("Error handling auth completion:",C),window.location.href="/app"}};return s.jsx("div",{style:{...P,minHeight:"100vh"},children:s.jsx(hr,{onAuthComplete:S,logo:y.logo,title:y.title,subtitle:y.subtitle,apiConfig:mr(),useDynamicConfig:!0,roleSelectionTitle:y.roleSelectionTitle,roleSelectionSubtitle:y.roleSelectionSubtitle,twoFactorTitle:y.twoFactorTitle,twoFactorSubtitle:y.twoFactorSubtitle,passwordResetTitle:y.passwordResetTitle,passwordResetSubtitle:y.passwordResetSubtitle})})},N=()=>{const{forgotPassword:S}=ko(),v=qe(m),C=async F=>{try{await S(F);const D=m?.resetPassword?.forgotPassword?.successMessage||"Reset email sent successfully!";p.toast.success(D)}catch(D){const k=m?.resetPassword?.forgotPassword?.errorMessage||D.message||"Failed to send reset email";p.toast.error(k)}};return s.jsx(p.Layout,{style:{...P,minHeight:"100vh"},children:s.jsx(Ao,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:s.jsx("div",{style:{...v,width:"100%"},children:s.jsx(qi,{onSubmit:C,authConfig:m})})})})},H=()=>{const{resetPassword:S}=ko(),v=qe(m),C=async F=>{await S(F);const D=m?.resetPassword?.resetForm?.successMessage||"Password reset successfully!";p.toast.success(D)};return s.jsx(p.Layout,{style:{...P,minHeight:"100vh"},children:s.jsx(Ao,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:s.jsx("div",{style:{...v,width:"100%"},children:s.jsx(Ii,{onSubmit:C,token:"demo-reset-token",authConfig:m})})})})};return e.endsWith("/")&&e.slice(0,-1),s.jsx(Ei,{authConfig:m,children:s.jsx(Ji,{config:mr(),children:s.jsxs(G.Routes,{children:[s.jsx(G.Route,{path:"/",element:s.jsx(B,{})}),s.jsx(G.Route,{path:"forgot-password",element:s.jsx(N,{})}),s.jsx(G.Route,{path:"reset-password",element:s.jsx(H,{})}),s.jsx(G.Route,{path:"/oauth/callback",element:s.jsx("div",{style:{...P,minHeight:"100vh"},children:s.jsx(hl,{logo:y.logo,apiConfig:mr(),onAuthComplete:S=>{console.log("OAuth auth complete:",S),(async()=>{const C=S?.response?.data?.redirect_url;C&&(window.location.href=C)})()},roleSelectionTitle:y.roleSelectionTitle,roleSelectionSubtitle:y.roleSelectionSubtitle,twoFactorTitle:y.twoFactorTitle,twoFactorSubtitle:y.twoFactorSubtitle,passwordResetTitle:y.passwordResetTitle,passwordResetSubtitle:y.passwordResetSubtitle})})}),s.jsx(G.Route,{path:"/complete",element:s.jsx("div",{style:{...P,minHeight:"100vh"},children:s.jsx(hr,{authData:w,apiConfig:t,logo:y.logo,onComplete:A,roleSelectionTitle:y.roleSelectionTitle,roleSelectionSubtitle:y.roleSelectionSubtitle,twoFactorTitle:y.twoFactorTitle,twoFactorSubtitle:y.twoFactorSubtitle,passwordResetTitle:y.passwordResetTitle,passwordResetSubtitle:y.passwordResetSubtitle})})}),s.jsx(G.Route,{path:"*",element:s.jsx(G.Navigate,{to:"/404",replace:!0})})]})})})},wr=({basePath:e="/app"})=>{const t=at();return s.jsx("div",{className:"page-container",children:s.jsx(fl,{basePath:e,apiConfig:t})})},pl=async(e=[])=>{console.log("🚀 Creating dynamic page registry..."),console.log("📋 Requested page types:",e);const t=Ta(e);console.log("✅ Available page types:",t);const r={login:{component:wr,includeBasePath:!0,standalone:!0,propsBuilder:({matchedRoutePath:c})=>({basePath:c})},custom:{component:null,includeBasePath:!1,handler:({customPages:c,customPagePath:d,location:l})=>{const u=c[d];return u?g.createElement(u):g.createElement(ds,{componentName:d})}},404:{component:zt,standalone:!0,includeBasePath:!1,propsBuilder:()=>({})},default:{component:zt,includeBasePath:!1,standalone:!0,propsBuilder:({pageType:c})=>({message:`Unknown page type: ${c}`})}};for(const c of t){const d=Na(c);d?(r[c]={component:d,includeBasePath:!0,propsBuilder:({matchedRoutePath:l})=>({basePath:l})},console.log(`✅ Registered static page type: ${c}`)):console.warn(`⚠️ Failed to get component for page type: ${c}`)}const o=t.length,a=4,n=o+a;console.log(`📊 Registry created with ${n} page types:`),console.log(` • Dynamic framework pages (${o}): ${t.join(", ")||"none"}`),console.log(` • Static pages (${a}): login, custom, 404, default`);const i=e.filter(c=>!t.includes(c));return i.length>0&&console.warn(`⚠️ Unconfigured page types (not in PAGE_CONFIG): ${i.join(", ")}`),r},gl=e=>{const t=new Set;return e.forEach(r=>{r.page_type&&r.page_type!=="custom"&&r.page_type!=="login"&&t.add(r.page_type)}),Array.from(t)},ml=async e=>{const t=gl(e);return pl(t)},_o=g.createContext(void 0);let Re=!1;typeof window<"u"&&(Re=!1);const Pe=()=>{const e=g.useContext(_o);if(!e)throw new Error("useAppContext must be used within AppProvider");return e},Lo=({children:e,config:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},authConfig:i={}})=>{const c=G.useNavigate(),d=G.useLocation(),[l,u]=g.useState(null),[h,m]=g.useState(!0),[w,f]=g.useState(null),[x,y]=g.useState(null);g.useEffect(()=>{console.log("🔄 Loading state changed to:",h)},[h]);const[P,A]=g.useState(null),[B,N]=g.useState(!1),[H,S]=g.useState(null),v=()=>typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",C=t,F=C.apiConfig||{};g.useEffect(()=>{const k={colors:{primary:"#5048ed",secondary:"#6d7280",success:"#10b981",warning:"#f59e0b",error:"#f04438",gray:"#6d7280",background:"#f9fafb",text:"#252b37"}},U="default-theme-variables";let I=document.getElementById(U);I||(I=document.createElement("style"),I.id=U,document.head.appendChild(I)),I.innerHTML=`:root { ${yt(k)} }`},[]),g.useEffect(()=>{const k=Ve.getCachedLogo();k&&y(k.base64Data||k.url)},[]),g.useEffect(()=>{let k=!1;return(async()=>{const I=window.location.pathname,j=I.startsWith("/app/login");if(console.log("🔍 AppContext useEffect triggered:",{currentPath:I,isLoginPage:j,fetchInProgress:Re}),Re){console.log("⚠️ Fetch already in progress, skipping...");return}Re=!0,console.log("🚀 Starting fetchAppInitData...");try{const L=await jr(),T=L.success?L.response:null;if(console.log("✅ fetchAppInitData completed:",{success:L.success,hasMenu:T?.menu?.length>0,menuCount:T?.menu?.length,userRole:T?.profile_info?.user_role}),!L.success)throw new Error(L.response?.message||"Failed to fetch app data");if(console.log("📦 Setting app data"),u(T),T?.theme){console.log("🎨 Applying theme");const M=document.getElementById("default-theme-variables");if(M)M.innerHTML=`:root { ${yt(T.theme)} }`;else{const E=document.createElement("style");E.id="default-theme-variables",E.innerHTML=`:root { ${yt(T.theme)} }`,document.head.appendChild(E)}T?.app_logo&&Ve.updateInBackground(T.app_logo,T.app_name,E=>{E.base64Data&&y(E.base64Data)})}}catch(L){console.error("❌ fetchAppInitData error:",L),f(L.message)}finally{console.log("🏁 Finally block executing:",{cancelled:k,loading:h}),console.log("✅ Setting loading to FALSE (ignoring cancelled state)"),m(!1),Re=!1,console.log("✅ fetchAppInitData finally block completed:",{fetchInProgress:Re,cancelled:k})}})(),()=>{k=!0,console.log("🧹 AppContext cleanup - useEffect unmounting")}},[]),g.useEffect(()=>{if(h||!l)return;const k=d.pathname,U=k==="/app/configuration-error";if(k==="/app/logout")return;const j=l.menu&&l.menu.length>0,L=l.routes&&l.routes.length>0,T=l.profile_info?.user_role,M=l.is_user_anonymous,E=!l.is_user_anonymous,Z=L&&l.routes.some(Q=>{const z=Q.path;return k===z||k.startsWith(z+"/")});if(console.log("🔍 Redirect logic check:",{currentPath:k,hasMenu:j,hasRoutes:L,userRole:T,isAnonymous:M,isAuthenticated:E,isConfigPage:U,isValidPath:Z}),E&&!j&&!U){console.log("🚀 Flow 1: Authenticated user without menu → configuration-error"),c("/app/configuration-error",{replace:!0});return}if(M&&!j){console.log("🚀 Flow 2: Anonymous user without menu → login"),c("/app/login",{replace:!0});return}if(j&&l.menu){const Q=l.menu[0]?.path||l.menu[0]?.uri;if(Q&&(k==="/app"||k==="/app/"||!Z&&!U)){console.log("🚀 Flow 3/4: Redirecting to first menu item:",Q,{reason:k==="/app"||k==="/app/"?"/app root":"invalid path"}),c(Q,{replace:!0});return}}},[h,l,d.pathname,c]),g.useEffect(()=>{let k=!1;return(async()=>{if(h){console.log("⏳ Still loading app data, skipping registry creation");return}if(!l){console.log("⏳ No app data yet, skipping registry creation");return}if(console.log("🚀 Starting registry creation...",{isAnonymous:l.is_user_anonymous,hasRoutes:!!l.routes,routesLength:l.routes?.length}),l.is_user_anonymous){console.log("✅ Anonymous user - creating minimal registry"),k||(A({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),N(!1));return}if(!l.routes||l.routes.length===0){console.log("⚠️ No routes found - creating fallback registry"),k||(A({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),N(!1));return}try{k||(N(!0),S(null)),console.log("🚀 Creating dynamic page registry from routes...");const I=await ml(l.routes);k||(A(I),N(!1),console.log("✅ Dynamic page registry created successfully"))}catch(I){console.error("❌ Failed to create dynamic page registry:",I),k||(S(I.message||"Failed to create page registry"),A({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),N(!1))}})(),()=>{k=!0}},[l,h]);const D={appData:l,loading:h,error:w,config:C,apiConfig:F,menu:l?.menu||[],routes:l?.routes||[],profileInfo:l?.profile_info||{},appLogo:x||l?.app_logo||"",appName:l?.app_name||"Zango CRM",metadata:l?.metadata||{},theme:l?.theme||{},layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,authConfig:i,pageTypeRegistry:P,registryLoading:B,registryError:H,initializerEndpoint:v()};return s.jsx(_o.Provider,{value:D,children:e})},To=()=>{const e=G.useNavigate(),{routes:t}=Pe(),r=g.useCallback(a=>{if(!a)return!1;const n=a.endsWith("/")&&a!=="/"?a.slice(0,-1):a;return t.some(i=>{const c=i.path,d=c.endsWith("/")&&c!=="/"?c.slice(0,-1):c;if(d===n)return!0;if(d.includes(":")){const l=d.split("/").map(h=>h.startsWith(":")?"[^/]+":h).join("/");return new RegExp(`^${l}(/.*)?$`).test(n)}return i.exact===!1?n.startsWith(d):!1})},[t]);return{navigateTo:g.useCallback((a,n={})=>{if(a){if(a.startsWith("http://")||a.startsWith("https://")){n.newTab?window.open(a,"_blank"):window.location.href=a;return}r(a)?e(a,n):n.newTab?window.open(a,"_blank"):window.location.href=a}},[e,r]),isInternalRoute:r}},Mt=({to:e,children:t,className:r,onClick:o,...a})=>{const{isInternalRoute:n}=To(),i=d=>{o&&o(d)};return!(e&&(e.startsWith("http://")||e.startsWith("https://")))&&n(e)?s.jsx(G.Link,{to:e,className:r,onClick:i,...a,children:t}):s.jsx("a",{href:e,className:r,onClick:i,...a,children:t})},Ut=(e,t)=>{if(!e)return;e.querySelectorAll("svg").forEach(o=>{o.getAttribute("fill")&&o.getAttribute("fill")!=="none"&&o.setAttribute("fill",t),o.getAttribute("stroke")&&o.getAttribute("stroke")!=="none"&&o.setAttribute("stroke",t),o.querySelectorAll("*").forEach(n=>{n.getAttribute("fill")&&n.getAttribute("fill")!=="none"&&n.setAttribute("fill",t),n.getAttribute("stroke")&&n.getAttribute("stroke")!=="none"&&n.setAttribute("stroke",t)})})},wl=({appLogo:e,appName:t,linkTo:r="/app",collapsed:o=!1})=>{if(o){const a=t?t.charAt(0).toUpperCase():"A";return s.jsx("div",{className:"navbar-logo-container frame-logo-container",style:{padding:"16px",justifyContent:"center"},children:s.jsx(Mt,{to:r,style:{textDecoration:"none"},children:s.jsx("div",{className:"collapsed-logo-initial",style:{width:"32px",height:"32px",backgroundColor:"var(--color-brand-500, #5048ED)",color:"white",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",fontWeight:"bold"},children:a})})})}return s.jsx("div",{className:"navbar-logo-container frame-logo-container",children:s.jsx(Pr,{logoUrl:e,appName:t,height:"28px",linkTo:r})})},No=({menuItems:e=[],appLogo:t,theme:r={},config:o={}})=>{const a=G.useLocation(),[n,i]=g.useState({}),{appName:c}=Pe(),d=g.useRef(null);g.useEffect(()=>{if(!d.current)return;const k=d.current.querySelector("#wideSidebarMenu");if(!k)return;k.querySelectorAll("li").forEach(I=>{const j=I.classList.contains("active"),L="var(--color-gray-700, #414651)",T="var(--color-brand-500, #5048ED)";Ut(I,j?T:L);const M=()=>{I.classList.contains("active")||Ut(I,T)},E=()=>{I.classList.contains("active")||Ut(I,L)};return I.addEventListener("mouseenter",M),I.addEventListener("mouseleave",E),()=>{I.removeEventListener("mouseenter",M),I.removeEventListener("mouseleave",E)}})},[a.pathname,e]);const l=(k,U)=>{const I=k.url||k.uri,j=I?.endsWith("/")?I:`${I}/`,L=U.endsWith("/")?U:`${U}/`;return j===L?!0:k.children?.length?k.children.some(T=>{const M=T.url||T.uri;return(M?.endsWith("/")?M:`${M}/`)===L}):!1},u=k=>{i(U=>({...U,[k]:!U[k]}))};g.useEffect(()=>{const k={};e.forEach(U=>{U.children?.length&&l(U,a.pathname)&&(k[U.name]=!0)}),i(k)},[a.pathname,e]);const h=k=>k.icon?k.icon.includes("<svg")?s.jsx("span",{className:"navbar-icon",dangerouslySetInnerHTML:{__html:k.icon}}):/^[\u{1F300}-\u{1F9FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F1E0}-\u{1F1FF}]|[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u.test(k.icon)||k.icon.length<=4?s.jsx("span",{className:"navbar-icon navbar-icon-emoji",children:k.icon}):s.jsx("span",{className:"navbar-icon",children:s.jsx("img",{src:k.icon,alt:k.name,width:"16",height:"16"})}):s.jsx("span",{className:"navbar-icon",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("path",{d:"M1.66675 8.00002C1.66675 5.1802 1.66675 3.77029 2.46539 2.83519C2.5788 2.70241 2.70247 2.57874 2.83525 2.46533C3.77035 1.66669 5.18026 1.66669 8.00008 1.66669C10.8199 1.66669 12.2298 1.66669 13.1649 2.46533C13.2977 2.57874 13.4213 2.70241 13.5347 2.83519C14.3334 3.77029 14.3334 5.1802 14.3334 8.00002C14.3334 10.8198 14.3334 12.2298 13.5347 13.1648C13.4213 13.2976 13.2977 13.4213 13.1649 13.5347C12.2298 14.3334 10.8199 14.3334 8.00008 14.3334C5.18026 14.3334 3.77035 14.3334 2.83525 13.5347C2.70247 13.4213 2.5788 13.2976 2.46539 13.1648C1.66675 12.2298 1.66675 10.8198 1.66675 8.00002Z",stroke:"currentColor",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.69235 4.83562C7.83568 4.61038 8.16448 4.61038 8.30782 4.83562L8.72255 5.48724C9.18115 6.20782 9.79228 6.81896 10.5129 7.27756L11.1645 7.69229C11.3897 7.83562 11.3897 8.16442 11.1645 8.30776L10.5129 8.72249C9.79228 9.18109 9.18115 9.79222 8.72255 10.5128L8.30782 11.1644C8.16448 11.3897 7.83568 11.3897 7.69235 11.1644L7.27762 10.5128C6.81902 9.79222 6.20788 9.18109 5.4873 8.72249L4.83568 8.30776C4.61044 8.16442 4.61044 7.83562 4.83568 7.69229L5.4873 7.27756C6.20788 6.81896 6.81902 6.20782 7.27762 5.48724L7.69235 4.83562Z",stroke:"currentColor",strokeLinejoin:"round"})]})}),{showLogo:m=!0,showMenu:w=!0,isCollapsed:f=!1,collapsible:x=!1,customLogo:y=null,customMenuContent:P=null,customBottomContent:A=null,customNavbar:B=null,customMenu:N=null,menuConfig:H={},className:S="",style:v={}}=o,[C,F]=g.useState(f),D=C?"80px":"244px";return s.jsxs("nav",{ref:d,className:`navbar ${C?"collapsed-sidebar":"wide-sidebar"} ${S}`,style:{width:D,...v,display:"flex",flexDirection:"column",transition:"width 0.3s ease"},children:[m&&(y?s.jsx("div",{className:"navbar-logo-container frame-logo-container",children:y}):s.jsx(wl,{appLogo:t,appName:c,collapsed:C})),x&&s.jsx("div",{className:"navbar-toggle-container",style:{padding:"8px 16px",borderBottom:"1px solid var(--color-gray-200, #e5e7eb)"},children:s.jsx("button",{onClick:()=>F(!C),className:"navbar-toggle-btn",style:{width:"100%",padding:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",transition:"background-color 0.2s ease"},onMouseEnter:k=>k.target.style.backgroundColor="var(--color-gray-100, #f3f4f6)",onMouseLeave:k=>k.target.style.backgroundColor="transparent",title:C?"Expand navbar":"Collapse navbar",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:C?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:s.jsx("path",{d:"M6 4L10 8L6 12",stroke:"var(--color-gray-600, #4b5563)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),s.jsx("div",{className:"navbar-menu-container frame-menu-container complete-hidden-scroll-style",style:{flex:1,overflow:"auto"},children:w&&(N||s.jsxs(s.Fragment,{children:[s.jsx("ul",{className:"navbar-menu wide-sidebar-menu",id:"wideSidebarMenu",children:e.map(k=>{const U=k.url||k.uri,I=l(k,a.pathname),j=n[k.name]||!1,L=k.children&&k.children.length>0;return s.jsxs(g.Fragment,{children:[s.jsx("li",{className:`menu-list-item ${L?"menu-list-item-with-sub-menu":""} ${I?"active":""}`,children:L?s.jsxs("div",{className:"menu-item",onClick:()=>!C&&u(k.name),style:{justifyContent:C?"center":"flex-start",padding:C?"8px":void 0},title:C?k.name:void 0,children:[h(k),!C&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`menu-title ${I?"font-semibold":""}`,children:k.name}),s.jsx("div",{className:`flex justify-center items-center h-full transition-transform duration-300 ease-in-out ${I&&j?"rotate-180":""}`,children:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:s.jsx("path",{d:"M9.74976 3.99963C9.81538 3.99963 9.88053 4.01263 9.94116 4.03772C10.0018 4.06282 10.0569 4.09977 10.1033 4.14612C10.1496 4.19249 10.1865 4.24766 10.2117 4.30823C10.2368 4.36885 10.2497 4.43402 10.2498 4.49963C10.2498 4.56531 10.2368 4.63036 10.2117 4.69104C10.1865 4.75173 10.1497 4.8067 10.1033 4.85315L6.35327 8.60315C6.30685 8.64961 6.25184 8.68639 6.19116 8.71155C6.13048 8.73669 6.06544 8.75061 5.99976 8.75061C5.93412 8.75058 5.86899 8.73668 5.80835 8.71155C5.77819 8.69902 5.74944 8.6837 5.72241 8.66565L5.64624 8.60315L1.89624 4.85315C1.80256 4.75936 1.74976 4.6322 1.74976 4.49963C1.74981 4.36705 1.80248 4.23988 1.89624 4.14612C1.99 4.05236 2.11717 3.99969 2.24976 3.99963C2.38232 3.99963 2.50948 4.05244 2.60327 4.14612L5.99976 7.5426L9.39624 4.14612C9.44265 4.09971 9.49773 4.06286 9.55835 4.03772C9.61897 4.01261 9.68414 3.99966 9.74976 3.99963Z",fill:"#414651",stroke:"#414651",strokeWidth:"0.25"})})})]})]}):s.jsxs(Mt,{to:U,className:"menu-item",style:{justifyContent:C?"center":"flex-start",padding:C?"8px":void 0},title:C?k.name:void 0,children:[h(k),!C&&s.jsx("span",{className:`menu-title ${I?"font-semibold":""}`,children:k.name})]})}),L&&!C&&s.jsx("ul",{className:`submenu-list ${j?"active":""}`,children:k.children.map(T=>{const M=T.url||T.uri,E=a.pathname===M||a.pathname===`${M}/`;return s.jsx("li",{className:"submenu-list-item",children:s.jsxs(Mt,{to:M,className:`submenu-item d-flex ${E?"selected-each-wide-submenu":""}`,children:[s.jsx("span",{className:"submenu-item-icon-container",children:E?s.jsx("svg",{className:"w-3.5 h-2.5 inline-block",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"10",viewBox:"0 0 14 10",fill:"none",children:s.jsx("path",{d:"M13.3538 6.85375L10.3538 9.85375C10.2599 9.94757 10.1327 10.0003 10 10.0003C9.86732 10.0003 9.74007 9.94757 9.64625 9.85375C9.55243 9.75993 9.49972 9.63268 9.49972 9.5C9.49972 9.36732 9.55243 9.24007 9.64625 9.14625L11.7931 7H7C5.27665 6.99818 3.62441 6.31278 2.40582 5.09418C1.18722 3.87559 0.50182 2.22335 0.5 0.5C0.5 0.367392 0.552678 0.240215 0.646447 0.146447C0.740215 0.0526785 0.867392 0 1 0C1.13261 0 1.25979 0.0526785 1.35355 0.146447C1.44732 0.240215 1.5 0.367392 1.5 0.5C1.50165 1.95818 2.08165 3.35617 3.11274 4.38726C4.14383 5.41835 5.54182 5.99835 7 6H11.7931L9.64625 3.85375C9.55243 3.75993 9.49972 3.63268 9.49972 3.5C9.49972 3.36732 9.55243 3.24007 9.64625 3.14625C9.74007 3.05243 9.86732 2.99972 10 2.99972C10.1327 2.99972 10.2599 3.05243 10.3538 3.14625L13.3538 6.14625C13.4002 6.19269 13.4371 6.24783 13.4623 6.30853C13.4874 6.36923 13.5004 6.43429 13.5004 6.5C13.5004 6.56571 13.4874 6.63077 13.4623 6.69147C13.4371 6.75217 13.4002 6.80731 13.3538 6.85375Z",fill:"var(--color-brand-500, #5048ED)"})}):s.jsx("span",{className:"hidden"})}),s.jsx("span",{className:`text-xs ${E?"text-[var(--color-brand-500,#5048ED)]":"text-[var(--color-gray-700,#414651)]"}`,children:T.name})]})},M)})})]},k.name)})}),P&&!C&&s.jsx("div",{className:"custom-menu-content",style:{paddingTop:"8px"},children:P})]}))}),A&&s.jsx("div",{className:"navbar-bottom-content",style:{marginTop:"auto",flexShrink:0},children:A})]})},yl=(e=!0)=>{const[t,r]=g.useState(null),[o,a]=g.useState(!1),[n,i]=g.useState(null),[c,d]=g.useState(!1),[l,u]=g.useState(!1),h=async()=>{if(!(!e||t&&!c)){a(!0),i(null);try{const w=await Dr();if(w.success&&w.response){const f=w.response.profile_data||w.response;w.response.password_policy&&!f.password_policy&&(f.password_policy=w.response.password_policy),u(w.response.should_set_password||!1),r(f),i(null)}else{const f=w.response?.message||"Failed to fetch profile data";i(f),console.error("Profile API Error:",w)}}catch(w){const f=w.message||"Network error while fetching profile";i(f),console.error("Profile fetch error:",w)}finally{a(!1),d(!0)}}},m=()=>{d(!1),h()};return g.useEffect(()=>{e&&!c&&h()},[e]),{profileData:t,loading:o,error:n,refetch:m,shouldSetPassword:l}},Ne=(e,t="/",r=null)=>{let o=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t};`;r&&(o+=` domain=${r};`),document.cookie=o,r||(document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t}; domain=${window.location.hostname};`,document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t};`)},yr=e=>{const t=e+"=",r=document.cookie.split(";");for(let o=0;o<r.length;o++){let a=r[o];for(;a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return a.substring(t.length,a.length)}return null},Eo=(e,t,r=null,o="/",a=null)=>{let n="";if(r){const c=new Date;c.setTime(c.getTime()+r*24*60*60*1e3),n="; expires="+c.toUTCString()}let i=`${e}=${t}${n}; path=${o}`;a&&(i+=`; domain=${a}`),document.cookie=i},Fo=()=>{const e=yr("zangocookie");return e!==null&&e!==""},Oo=Object.freeze({__proto__:null,deleteCookie:Ne,getCookie:yr,isAuthenticatedViaCookie:Fo,setCookie:Eo}),Mo=async(e={})=>{try{const t=await Kr();if(t.success||t.responseStatus===401){Ne("zangocookie","/"),Ne("zangocookie","/app"),Ne("zangocookie","/app/"),Ne("zangocookie");const r=window.location.hostname;if(Ne("zangocookie","/",r),Ne("zangocookie","/app",r),r.includes(".")){const a="."+r.split(".").slice(-2).join(".");Ne("zangocookie","/",a),Ne("zangocookie","/app",a)}localStorage.removeItem("authToken"),localStorage.clear(),sessionStorage.clear();const o=e.redirectUrl||e.theme?.login_url||"/app/login";setTimeout(()=>{window.location.href=o},100)}else p.toast.error({title:"Logout Failed",description:t.response?.message||"Unable to logout. Please try again.",duration:5e3})}catch(t){console.error("Logout error:",t),p.toast.error({title:"Logout Error",description:"An error occurred while logging out. Please try again.",duration:5e3});const r=e.redirectUrl||e.theme?.login_url||"/app/login";setTimeout(()=>{window.location.href=r},100)}},Uo=e=>{const t=document.createElement("div");t.style.cssText=`
147
+ `;r.innerHTML=s},_c=()=>{const e=document.getElementById("auth-theme-variables");e&&e.remove()},We=e=>{const t=e?.theme?.background;if(!t)return{};const r={};return t.image?(r.backgroundImage=`url(${t.image})`,r.backgroundSize="cover",r.backgroundPosition="center",r.backgroundRepeat="no-repeat"):t.gradient?r.background=t.gradient:t.color&&(r.backgroundColor=t.color),r},Xe=e=>{const t=e?.card;if(!t)return{};const r={};return t.backgroundColor&&(r.backgroundColor=t.backgroundColor),t.borderRadius&&(r.borderRadius=t.borderRadius),t.boxShadow&&(r.boxShadow=t.boxShadow),t.maxWidth&&(r.maxWidth=t.maxWidth),t.padding&&(r.padding=t.padding),t.border&&(r.border=t.border),r},it=e=>{const t=e?.logo;if(!t)return{};const r={};return t.width&&(r.width=t.width),t.height&&(r.height=t.height),t.style&&Object.assign(r,t.style),r},Nc=e=>e?.logo?.position||"center",lt=e=>{const t=Nc(e),r=e?.logo;let s="flex items-center mb-6";const n={};switch(t){case"left":s+=" justify-start";break;case"right":s+=" justify-end";break;case"center":default:s+=" justify-center";break}return r?.className&&(s+=` ${r.className}`),{className:s,style:n}},Ie=e=>{const t=e?.theme;if(!t)return{};const r={};return t.textColor&&(r.color=t.textColor),t.fontFamily&&(r.fontFamily=t.fontFamily),r.textAlign=t.alignTitle||"center",r.textAlign=t.alignTitle||"center",r},$e=e=>{const t=e?.theme;if(!t)return{textAlign:"center"};const r={};return t.secondaryTextColor&&(r.color=t.secondaryTextColor),t.fontFamily&&(r.fontFamily=t.fontFamily),r.textAlign=t.alignTitle||"center",r},yn=e=>{const t=e?.theme;if(!t)return{};const r={};return t.linkColor&&(r.color=t.linkColor),t.fontFamily&&(r.fontFamily=t.fontFamily),r},Lc=({onSubmit:e,logo:t})=>{const[r,s]=h.useState(!1),[n,a]=h.useState(null),[i,l]=h.useState(!1),[u,c]=h.useState(0),[d,f]=h.useState(["email"]),[m,g]=h.useState("email"),{basePath:p}=tr(),{authConfig:w,getResetPasswordConfig:b,getMessagesConfig:k}=_e(),C=b(),M=k(),I=Xe(w),q=lt(w),E=it(w);h.useEffect(()=>{(async()=>{try{await j.getAuthConfig();const U=j.getPasswordResetMethods();U&&U.length>0&&(f(U),g(U[0]))}catch(U){console.error("Failed to load reset configuration:",U)}})()},[]);const _=async S=>{s(!0),a(null);try{if(e){const U={email:m==="email"?S.contact:void 0,phone:m==="sms"?S.contact:void 0};await e(U)}l(!0),c(U=>U+1)}catch(U){const A=m==="email"?"email":"SMS",L=U.message||M?.errors?.networkError||`Failed to send reset ${A}. Please try again.`;a(L)}finally{s(!1)}},P=()=>m==="email"?C?.forgotPassword?.emailPlaceholder||"Email address":"Phone number",O=()=>m==="email"?[{required:!0,message:M?.validation?.required||"Please enter your email address"},{type:"email",message:M?.validation?.invalidEmail||"Please enter a valid email address!"}]:[{required:!0,message:M?.validation?.required||"Please input your phone number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:M?.validation?.invalidMobile||"Please enter a valid phone number!"}],W=()=>{const S=m==="email"?"Email":"SMS",U=m==="email"?"email":"phone";return{title:C?.forgotPassword?.successMessage||`${S} Sent!`,subTitle:`Please check your ${U} for password reset instructions.`}};if(i){const S=W();return o.jsx(y.Result,{status:"success",title:S.title,subTitle:S.subTitle,extra:[o.jsx(K.Link,{to:p,children:o.jsx(y.Button,{variant:"primary",children:C?.forgotPassword?.backToLoginText||"Back to Login"})},"login")]})}return o.jsxs("div",{className:"w-full max-w-md mx-auto",style:I,children:[o.jsx(K.Link,{to:p,className:"inline-block mb-6",children:o.jsxs(y.Button,{variant:"link",size:"link",className:"flex gap-2",icon:o.jsx(ut,{size:16}),children:[o.jsx(ut,{className:"w-4 h-4"})," ",C?.forgotPassword?.backToLoginText||"Back to Login"]})}),t&&o.jsx("div",{className:q.className,style:q.style,children:typeof t=="string"?o.jsx("img",{src:t,alt:w?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:E}):t}),o.jsx("h2",{className:"text-2xl font-semibold mb-3",style:Ie(w),children:C?.forgotPassword?.title||"Forgot Password"}),o.jsx("p",{className:"text-sm mb-6",style:$e(w),children:C?.forgotPassword?.subtitle||C?.forgotPassword?.instructionText||`Enter your ${m==="email"?"email address":"phone number"} and we'll send you instructions to reset your password.`}),o.jsxs(y.Form,{name:"forgot-password",className:"space-y-4",onFinish:_,layout:"vertical",children:[n&&o.jsx(y.Alert,{message:n,type:"error",showIcon:!0,closable:!0,onClose:()=>a(null),className:"mb-4"}),d.length>1&&o.jsx(y.FormItem,{label:"Reset method",children:o.jsxs(y.Select,{value:m,onChange:S=>{g(S),c(U=>U+1)},children:["options=",d.map(S=>({value:S,label:o.jsxs(y.Space,{children:[S==="email"?o.jsx(Ht,{size:16}):o.jsx(Ui,{size:16}),S==="email"?"Email":"SMS"]})}))]})}),o.jsx(y.FormItem,{name:"contact",label:m==="email"?C?.forgotPassword?.emailLabel||"Email":"Phone",rules:O(),children:o.jsx(y.Input,{placeholder:P(),autoComplete:m==="email"?"email":"tel"})}),o.jsx(y.FormItem,{children:o.jsx(y.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:r,fullWidth:!0,children:C?.forgotPassword?.submitButtonText||`Send Reset ${m==="email"?"Email":"SMS"}`})})]},u)]})},Tc=({onSubmit:e,token:t,logo:r})=>{const[s,n]=h.useState(!1),[a,i]=h.useState(!0),[l,u]=h.useState(!1),[c,d]=h.useState(""),[f,m]=h.useState(!1),[g,p]=h.useState(0),[w,b]=h.useState(null),{basePath:k}=tr(),{authConfig:C,getResetPasswordConfig:M,getMessagesConfig:I}=_e(),q=M(),E=I(),_=Xe(C),P=lt(C),O=it(C);h.useEffect(()=>{t?(async()=>{try{const A=await j.validatePasswordResetKey(t);A?.data?.metadata?.password_policy&&b(A.data.metadata.password_policy),u(!0)}catch(A){console.error("Invalid reset key:",A),u(!1),d(A.message||"This password reset link is invalid or has expired.")}finally{i(!1)}})():(i(!1),u(!1),d("Invalid link."))},[t]);const W=(U,A)=>{if(!A){const L=E?.validation?.required||"Please input your new password!";return Promise.reject(new Error(L))}if(w){if(w.min_length&&A.length<w.min_length)return Promise.reject(new Error(`Password must be at least ${w.min_length} characters long`))}else{const L=j.validatePassword(A);if(!L.valid){const v=E?.validation?.passwordTooShort||L.errors.join(", ");return Promise.reject(new Error(v))}}return Promise.resolve()},S=async U=>{if(U.password!==U.confirmPassword){const A=E?.validation?.passwordsDoNotMatch||"The two passwords do not match!";y.toast.error(A);return}n(!0);try{if((await j.confirmResetPassword({key:t,password:U.password}))?.data?.next_step?.id==="login"){y.toast.success("Password reset successful! Redirecting to login..."),setTimeout(()=>{window.location.href="/app/login"},1500);return}m(!0),e&&await e({...U,token:t}),p(L=>L+1)}catch(A){const L=E?.errors?.networkError||A.message||"Failed to reset password. Please try again.";y.toast.error(L)}finally{n(!1)}};return a?o.jsxs("div",{className:"w-full max-w-md mx-auto p-8 text-center",style:_,children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-4"}),o.jsx("p",{children:"Validating reset link..."})]}):l?f?o.jsx(y.Result,{status:"success",title:q?.resetForm?.successMessage||"Password Reset Successful!",subTitle:"Your password has been successfully reset. You can now login with your new password.",extra:[o.jsx(K.Link,{to:k,children:o.jsx(y.Button,{variant:"primary",children:"Go to Login"})},"login")]}):o.jsxs("div",{className:"w-full max-w-md mx-auto",style:_,children:[r&&o.jsx("div",{className:P.className,style:P.style,children:typeof r=="string"?o.jsx("img",{src:r,alt:C?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:O}):r}),o.jsx("h2",{className:"text-2xl font-semibold mb-3",style:Ie(C),children:q?.resetForm?.title||"Reset Password"}),o.jsx("p",{className:"text-sm mb-6",style:$e(C),children:q?.resetForm?.subtitle||"Please enter your new password below."}),o.jsxs(y.Form,{name:"reset-password",className:"space-y-4",onFinish:S,layout:"vertical",children:[o.jsx(y.FormItem,{name:"password",label:q?.resetForm?.passwordLabel||"New Password",rules:[{validator:W}],children:o.jsx(y.PasswordInput,{prefix:o.jsx(jt,{size:16,className:"text-gray-400"}),placeholder:q?.resetForm?.passwordPlaceholder||"New Password",autoComplete:"new-password"})}),o.jsx(y.FormItem,{name:"confirmPassword",label:q?.resetForm?.confirmPasswordLabel||"Confirm Password",dependencies:["password"],rules:[{required:!0,message:E?.validation?.required||"Please confirm your password!"},({getFieldValue:U})=>({validator(A,L){if(!L||U("password")===L)return Promise.resolve();const v=E?.validation?.passwordsDoNotMatch||"The two passwords do not match!";return Promise.reject(new Error(v))}})],children:o.jsx(y.PasswordInput,{prefix:o.jsx(jt,{size:16,className:"text-gray-400"}),placeholder:q?.resetForm?.confirmPasswordPlaceholder||"Confirm Password",autoComplete:"new-password"})}),o.jsx(y.FormItem,{children:o.jsx(y.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:s,fullWidth:!0,children:q?.resetForm?.submitButtonText||"Reset Password"})})]},g)]}):o.jsx(y.Result,{status:"error",title:"Invalid Link",subTitle:c,extra:[o.jsx(K.Link,{to:k,children:o.jsx(y.Button,{variant:"primary",children:"Back to Login"})},"login")]})},Oc=({onSuccess:e,onError:t,apiConfig:r={},redirectPath:s="/",title:n="Completing sign in...",errorTitle:a="Authentication Error",logo:i,roleSelectionTitle:l,roleSelectionSubtitle:u,twoFactorTitle:c,twoFactorSubtitle:d,passwordResetTitle:f,passwordResetSubtitle:m})=>{const[g,p]=h.useState(!0),[w,b]=h.useState(null),[k,C]=h.useState(!1),[M,I]=h.useState(null),[q,E]=h.useState("login"),[_,P]=h.useState({}),[O,W]=h.useState(["email"]),[S,U]=h.useState(""),A=h.useRef(!1),L=K.useLocation(),v=K.useNavigate(),{basePath:x,setAuthToken:F}=tr(),{authConfig:D}=_e(),Y=async $=>{let H=$,G=null;$?.status===401&&$?.data?(H=$.data,G=$.data?.next_step):(H=$?.response?.data||$?.data||$,G=H?.next_step);const re=$?.loginUser;($?.token||H?.token)&&F($.token||H.token);let R=$?.user||H?.user||re||{};if((typeof R!="object"||R===null)&&(R={}),re&&typeof re=="object"&&(R={...R,email:R.email||re.email,username:R.username||re.username,phone:R.phone||re.phone,name:R.name||re.display}),G&&G.is_pending)switch(G.id){case"role_selection":let ie=[];Array.isArray(G.metadata.roles)?ie=G.metadata.roles:typeof G.metadata.roles=="object"&&(ie=Object.entries(G.metadata.roles).map(([De,ve])=>({id:De,name:ve,is_default:!1}))),P({...$,roles:ie,user:R,nextStep:G,loginUser:re}),E("roleSelection"),C(!0),p(!1);return;case"mfa_authenticate":F($.token||H?.token),W(G.metadata?.methods||["email"]),E("twoFactor"),C(!0),p(!1);return;case"set_password":F($.token||H?.token);const ue=G.metadata?.password_policy;U(G.metadata?.reason||"Password update required"),P({...$,passwordPolicy:ue,user:R,loginUser:re}),E("passwordReset"),C(!0),p(!1);return;case"password_expiry":F($.token||H?.token),U("Your password has expired"),P({...$,passwordPolicy:G.metadata?.password_policy,user:R,loginUser:re}),E("passwordReset"),C(!0),p(!1);return;case"first_login":F($.token||H?.token),U("Please set up your password for first login"),P({...$,passwordPolicy:G.metadata?.password_policy,user:R,loginUser:re}),E("passwordReset"),C(!0),p(!1);return;case"login_by_code":F($.token||H?.token),y.toast.info("OTP verification required"),e&&e({...$,user:R,requiresOTP:!0});return}if($.requires2FA){F($.token),W($.twoFactorMethods||["email"]),P({...$,user:R,loginUser:re}),E("twoFactor"),C(!0),p(!1);return}if($.requiresPasswordReset){F($.token),U($.passwordResetReason||"Your password has expired"),P({...$,user:R,loginUser:re}),E("passwordReset"),C(!0),p(!1);return}};h.useEffect(()=>{A.current||Z()},[]);const Z=async()=>{try{A.current=!0;const $=new URLSearchParams(L.search),H=new URLSearchParams(L.hash.slice(1)),G=$.get("error")||H.get("error"),re=$.get("error_description")||H.get("error_description");if(G)throw new Error(re||`Authentication failed: ${G}`);const R=$.get("code"),ie=$.get("state"),ue=$.get("scope")||"",De=$.get("authuser"),ve=$.get("hd"),he=$.get("prompt"),ce=$.get("provider")||ie?.split(":")[0];if(!R||!ce)throw new Error("Missing required OAuth parameters (code or provider)");const de=await j.processOAuthCallback(ce,ie||"",R,ue,De||void 0,ve||void 0,he||void 0);if(await Y(de),de?.status===401&&de?.data?.next_step&&de.data.next_step.is_pending){p(!1),e?e(de):(I(de),C(!0));return}p(!1),e?e(de):setTimeout(()=>{v(s,{replace:!0})},1e3)}catch($){console.error("OAuth callback error:",$),b($.message||"Authentication failed"),p(!1),t&&t($)}},J=()=>{v(x,{replace:!0})},ee=async $=>{y.toast.success("Authentication complete!");try{let H="/dashboard";$?.response?.data?.redirect_url?H=$.response.data.redirect_url:$?.data?.redirect_url?H=$.data.redirect_url:$?.redirect_url&&(H=$.redirect_url);const G=window.location.pathname,re=new URLSearchParams(window.location.search),R=re.get("code")!==null||re.get("token")!==null;G.startsWith("/app/login")&&R&&(window.location.href=H)}catch(H){console.error("Error handling auth completion:",H)}};return k?o.jsx(CompleteAuthFlow,{logo:i,apiConfig:r,initialAuthState:M||_,onAuthComplete:ee,roleSelectionTitle:l,roleSelectionSubtitle:u,twoFactorTitle:c,twoFactorSubtitle:d,passwordResetTitle:f,passwordResetSubtitle:m,redirectPath:s}):g?o.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:o.jsx(y.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:o.jsxs("div",{className:"text-center py-10 px-5",children:[o.jsx(y.Spin,{size:"large"}),o.jsx("h2",{className:"mt-6 mb-2 text-gray-800 text-xl font-medium",style:Ie(D),children:n}),o.jsx("p",{className:"text-gray-500 text-sm mb-0",style:$e(D),children:"Please wait while we complete your authentication..."})]})})}):w?o.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:o.jsx(y.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:o.jsx("div",{className:"text-center py-10 px-5",children:o.jsx(y.Alert,{message:a,description:w,type:"error",showIcon:!0,action:o.jsx("a",{onClick:J,children:"Return to login"})})})})}):o.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:o.jsx(y.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:o.jsx("div",{className:"text-center py-10 px-5",children:o.jsx(y.Alert,{message:"Authentication Successful",description:"You have been successfully authenticated. Redirecting...",type:"success",showIcon:!0})})})})},Fc=()=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),o.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),o.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),o.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),Mc=()=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("path",{d:"M11.4 24H0V12.6h11.4V24z",fill:"#f25022"}),o.jsx("path",{d:"M24 24H12.6V12.6H24V24z",fill:"#00a4ef"}),o.jsx("path",{d:"M11.4 11.4H0V0h11.4v11.4z",fill:"#7fba00"}),o.jsx("path",{d:"M24 11.4H12.6V0H24v11.4z",fill:"#ffb900"})]}),Ic=()=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})}),Uc=()=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"#0077b5",children:o.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})}),Dc=()=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"#1877f2",children:o.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Bc=()=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),$c=()=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),qc=()=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("path",{d:"M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52z",fill:"#e01e5a"}),o.jsx("path",{d:"M6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313z",fill:"#e01e5a"}),o.jsx("path",{d:"M8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834z",fill:"#36c5f0"}),o.jsx("path",{d:"M8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312z",fill:"#36c5f0"}),o.jsx("path",{d:"M18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834z",fill:"#2eb67d"}),o.jsx("path",{d:"M17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312z",fill:"#2eb67d"}),o.jsx("path",{d:"M15.165 18.956a2.527 2.527 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52z",fill:"#ecb22e"}),o.jsx("path",{d:"M15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z",fill:"#ecb22e"})]}),Vc=()=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 2l3.09 6.26L22 9l-5 4.87L18.18 22 12 18.27 5.82 22 7 13.87 2 9l6.91-.74L12 2z"})}),jc=()=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0z",fill:"#00D924"}),o.jsx("path",{d:"M12 18c-3.314 0-6-2.686-6-6s2.686-6 6-6 6 2.686 6 6-2.686 6-6 6z",fill:"#FFFFFF"})]}),Hc=(e,t="default")=>{const r=e?e.toLowerCase():"";return r.includes("google")?o.jsx(Fc,{}):r.includes("microsoft")||r.includes("azure")?o.jsx(Mc,{}):r.includes("github")?o.jsx(Ic,{}):r.includes("linkedin")?o.jsx(Uc,{}):r.includes("facebook")?o.jsx(Dc,{}):r.includes("twitter")||r.includes("x.com")?o.jsx(Bc,{}):r.includes("apple")?o.jsx($c,{}):r.includes("slack")?o.jsx(qc,{}):r.includes("okta")?o.jsx(jc,{}):r.includes("saml")||r.includes("sso")||t==="sso"?o.jsx(Vc,{}):o.jsx(Mi,{size:16})},qe=({provider:e,type:t="default",prefix:r="Continue with",postfix:s=""})=>{const n=async()=>{try{if(t==="sso"){console.log("Initiating SAML authentication with provider:",e);const c=e.id,d=await j.initiateSAMLAuth(c);d?.redirect_url?window.location.href=d.redirect_url:console.error("No redirect URL received from SAML init")}else{const c=await j.oauthRedirect(e.provider,window.location.href);console.log("OAuth redirect url:",c.response.redirect_url),c.success?window.location.href=c.response.redirect_url:console.error("Error authenticating with OAuth provider")}}catch(c){console.error(`Error authenticating with ${t} provider:`,c);let d=`Failed to authenticate with ${l}`;c.message?.includes("500")?d+=". The authentication service appears to be unavailable. Please try again later or contact support.":c.message?.includes("404")?d+=". The authentication service is not configured properly.":c.message?.includes("403")?d+=". You do not have permission to use this authentication method.":c.message?d+=`. ${c.message}`:d+=". Please try again or contact support.",y.toast.error(d)}},a=()=>{if(t==="sso"){const c=e.label||e.id;return c.toLowerCase().includes("azure")?"Azure AD":c.toLowerCase().includes("okta")?"Okta":c.toLowerCase().includes("google")?"Google":c.toLowerCase().includes("microsoft")?"Microsoft":c.toLowerCase().includes("saml")?"SSO":c.charAt(0).toUpperCase()+c.slice(1)}else return e.name||e.provider},i=t==="sso"?e.label||e.id:e.provider,l=a(),u=Hc(i,t);return o.jsxs(y.Button,{className:`flex w-full items-center justify-center gap-2 h-[42px] text-sm font-medium rounded-md transition-all duration-300 mb-2 last:mb-0 ${t==="oidc"?"bg-gray-100 border border-gray-200 text-gray-800 hover:bg-gray-200 hover:border-gray-300":t==="sso"?"bg-brand-500 border border-brand-500 text-white hover:bg-brand-600 hover:border-brand-600":"bg-white border border-gray-300 text-gray-800 hover:border-brand-500 hover:text-brand-500"}`,icon:u,block:!0,onClick:n,children:[r," ",l," ",s]})},bn=({length:e=6,value:t="",onChange:r,disabled:s=!1})=>{const[n,a]=h.useState(new Array(e).fill("")),i=h.useRef([]);h.useEffect(()=>{if(t){const d=t.split("").slice(0,e),f=[...new Array(e).fill("")];d.forEach((m,g)=>{f[g]=m}),a(f)}},[t,e]);const l=(d,f)=>{const m=d.value;if(isNaN(m))return;const g=[...n];g[f]=m,a(g),r&&r(g.join("")),m&&f<e-1&&i.current[f+1].focus()},u=(d,f)=>{d.key==="Backspace"&&!n[f]&&f>0&&i.current[f-1].focus()},c=d=>{d.preventDefault();const m=d.clipboardData.getData("text/plain").slice(0,e).split(""),g=[...n];m.forEach((w,b)=>{!isNaN(w)&&b<e&&(g[b]=w)}),a(g),r&&r(g.join(""));const p=g.findIndex(w=>w==="");p!==-1?i.current[p].focus():i.current[e-1].focus()};return o.jsx(y.Space,{className:"flex justify-center gap-2",size:"small",children:n.map((d,f)=>o.jsx(y.Input,{ref:m=>i.current[f]=m,type:"text",inputMode:"numeric",maxLength:1,value:d,onChange:m=>l(m.target,f),onKeyDown:m=>u(m,f),onPaste:c,className:"!w-12 !h-12 text-center text-xl font-semibold rounded-lg transition-all duration-300 focus:border-brand-500 focus:shadow-[0_0_0_2px_rgba(106,138,18,0.2)] disabled:bg-gray-100 disabled:cursor-not-allowed",disabled:s},f))})},vn=h.createContext(null),Ye=()=>{const e=h.useContext(vn);if(!e)throw new Error("useAuthContext must be used within an AuthProvider");return e},Cn=({children:e,config:t={}})=>{const[r,s]=h.useState(null),[n,a]=h.useState(!0),[i,l]=h.useState(null),[u,c]=h.useState(null),[d,f]=h.useState(null),[m,g]=h.useState(null),p=h.useRef(!1);h.useEffect(()=>{p.current||(p.current=!0,w())},[]);const w=async()=>{try{const _=await j.getAuthConfig();g(_),await b()}catch(_){l(_.message),a(!1)}},b=async()=>{try{await j.isAuthenticated()?(s({id:1,username:"authenticated_user",email:"user@example.com",authenticated:!0}),l(null)):(s(null),l(null))}catch(_){console.error("Auth check failed:",_),s(null),l(null)}finally{a(!1)}},E={user:r,loading:n,error:i,login:async _=>{a(!0),l(null);try{const P=await j.login(_,t);let O=P,W=null;P?.status===401&&P?.data?(O=P.data,W=P.data?.next_step):(O=P?.response?.data||P?.data||P,W=O?.next_step);const S=P?.user||O?.user||{};if(S.email=S.email||_.email,S.username=S.username||_.username,S.phone=S.phone||_.phone,S.name=S.name||_.email||_.username||_.phone,c({user:S,token:P.token||O?.token,roles:P.roles,requires2FA:P.requires2FA,twoFactorMethods:P.twoFactorMethods,requiresPasswordReset:P.requiresPasswordReset,passwordResetReason:P.passwordResetReason}),W&&W.is_pending&&W.id==="role_selection")return{...P,user:S};if(P.roles&&P.roles.length>1)return f(P.roles),{requiresRoleSelection:!0,roles:P.roles,user:S,token:P.token};let U=P;return P.roles&&P.roles.length===1?U.user={...S,role:P.roles[0]}:U.user=S,P.requires2FA?{...U,requires2FA:!0,twoFactorMethods:P.twoFactorMethods||["email"]}:P.requiresPasswordReset?{...U,requiresPasswordReset:!0,passwordResetReason:P.passwordResetReason}:(s(U.user),c(null),f(null),{...U,user:S})}catch(P){throw console.error("AuthProvider login caught error:",P),console.error("AuthProvider error.message:",P.message),l(P.message),P}finally{a(!1)}},logout:async()=>{a(!0);try{await j.logout(t),s(null),c(null),f(null)}catch(_){console.error("Logout failed:",_)}finally{a(!1)}},selectRole:async _=>{if(!u)throw new Error("No pending authentication");a(!0);try{t.roleSelectionEndpoint&&await j.selectRole(_,u.token,t);const P={...u.user,role:_},O={...u,user:P};return O.requires2FA?(c(O),{...O,requires2FA:!0,twoFactorMethods:O.twoFactorMethods||["email"]}):O.requiresPasswordReset?(c(O),{...O,requiresPasswordReset:!0,passwordResetReason:O.passwordResetReason}):(s(P),c(null),f(null),{user:P,token:u.token})}catch(P){throw l(P.message),P}finally{a(!1)}},checkAuth:b,forgotPassword:async _=>j.forgotPassword(_),resetPassword:async _=>j.resetPassword(_),isAuthenticated:!!r,pendingAuth:u,availableRoles:d,authConfig:m,requiresRoleSelection:!!u&&!!d};return o.jsx(vn.Provider,{value:E,children:e})},{Text:xn,Title:Pn}=y.Typography,Wr=({onSuccess:e,onBack:t,submitButtonText:r,verifyButtonText:s,resendButtonText:n})=>{const[a,i]=h.useState("request"),[l,u]=h.useState(!1),[c,d]=h.useState(""),[f,m]=h.useState("email"),[g,p]=h.useState(""),[w,b]=h.useState(""),[k,C]=h.useState(""),[M,I]=h.useState(0),[q,E]=h.useState(0),{authConfig:_}=Ye();h.useEffect(()=>{if(_){const v=j.getAllowedUsernames();v&&v.length>0&&m(v[0])}},[_]),h.useEffect(()=>{if(M>0){const v=setTimeout(()=>I(M-1),1e3);return()=>clearTimeout(v)}},[M]);const P=v=>v==="email"?"Enter your email address":"Enter your mobile number",O=v=>v==="email"?[{required:!0,message:"Please enter your email address"},{type:"email",message:"Please enter a valid email!"}]:v==="mobile"?[{required:!0,message:"Please input your mobile number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid mobile number!"}]:[{required:!0,message:"Please input your username!"},{min:3,message:"Username must be at least 3 characters long"}],W=async v=>{C(""),u(!0);try{const x=await j.requestOTP(v.username);x?.status===401&&x?.data?.message?(d(v.username),i("verify"),I(30),y.toast.success(x.data.message||"Code sent successfully!")):(d(v.username),i("verify"),I(30),y.toast.success("Code sent successfully!"))}catch(x){console.error("Failed to Send Code:",x),C(x.message||"Failed to Send Code")}finally{u(!1)}},S=async()=>{if(b(""),g.length!==6){b("Please enter 6 digit Code");return}u(!0);try{const F={...await j.verifyOTP(c,g),loginUser:{email:f==="email"?c:void 0,phone:f==="mobile"?c:void 0,username:c,display:c}};e(F)}catch(x){b(x.message||"Invalid Code")}finally{u(!1)}},U=async()=>{if(!(M>0)){u(!0);try{await j.requestOTP(c),I(30),y.toast.success("Code resent successfully!")}catch(v){y.toast.error(v.message||"Failed to resend Code")}finally{u(!1)}}};if(!_)return o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const A=j.getAllowedUsernames(),L=6;return a==="verify"?o.jsxs("div",{className:"w-full",children:[o.jsxs(y.Button,{variant:"link",icon:o.jsx(ut,{size:16}),onClick:()=>i("request"),className:"mb-4 flex gap-2",children:[o.jsx(ut,{className:"w-4 h-4"})," Change ",f?.slice(0,1).toUpperCase()+f?.slice(1)," ",f==="email"?"Address":"Number"]}),o.jsx(Pn,{level:4,className:"!mb-2 text-center",style:Ie(_),children:"Enter Verification Code"}),o.jsxs(xn,{className:"block text-center text-gray-500 mb-6",style:$e(_),children:["Please enter the ",L,"-digit code sent to ",c]}),w&&o.jsx(y.Alert,{message:w,type:"error",showIcon:!1,closable:!0,onClose:()=>b(""),className:"mb-4"}),o.jsx("div",{className:"my-8 flex justify-center",children:o.jsx(bn,{length:L,value:g,onChange:v=>{p(v),w&&b("")},disabled:l})}),o.jsx(y.Button,{type:"primary",block:!0,fullWidth:!0,loading:l,onClick:S,className:"mt-6",children:s||"Verify & Sign In"}),o.jsx("div",{className:"text-center mt-4",children:M>0?o.jsxs(xn,{type:"secondary",children:["Resend Code in ",M,"s"]}):o.jsx(y.Button,{variant:"link",onClick:U,loading:l,disabled:l,children:n||"Resend Code"})})]}):o.jsxs("div",{className:"w-full",children:[t&&o.jsxs(y.Button,{variant:"link",icon:o.jsx(ut,{size:16}),onClick:t,className:"mb-4",children:[o.jsx(ut,{className:"w-4 h-4"})," Back to login"]}),o.jsx(Pn,{level:4,className:"!mb-2 text-center",style:Ie(_),children:"Sign in with a One-Time Pin"}),k&&o.jsx(y.Alert,{message:k,type:"error",showIcon:!1,closable:!0,onClose:()=>C(""),className:"mb-4"}),o.jsxs(y.Form,{name:"otp-request",onFinish:W,layout:"vertical",children:[A.length>1&&o.jsx(y.FormItem,{children:o.jsx(y.Segmented,{options:A.map(v=>({label:o.jsxs(y.Space,{children:[v==="email"?o.jsx(Ht,{size:16}):v==="mobile"?o.jsx(_r,{size:16}):o.jsx(Nr,{size:16}),o.jsx("span",{children:v==="mobile"?"Phone":v==="email"?"Email":"Username"})]}),value:v})),value:f,onChange:v=>m(v),block:!0,className:"bg-gray-100 mb-2"})}),o.jsx(y.FormItem,{name:"username",rules:O(f),children:o.jsx(y.Input,{placeholder:P(f)})}),o.jsx(y.FormItem,{children:o.jsx(y.Button,{variant:"primary",type:"submit",fullWidth:!0,disabled:l,children:r||"Send Code"})})]},q)]})},zc=({onLogin:e,showRememberMe:t=!0})=>{const[r,s]=h.useState(!1),[n,a]=h.useState(null),[i,l]=h.useState(null),[u,c]=h.useState("email"),[d,f]=h.useState(!1),[m,g]=h.useState(0),[p,w]=h.useState(!1),[b,k]=h.useState(!1),[C,M]=h.useState(""),[I,q]=h.useState(""),{authConfig:E}=Ye(),{getLoginConfig:_,getMessagesConfig:P,getProvidersConfig:O,authConfig:W}=_e(),S=W||E,U=Ie(S),A=$e(S),L=yn(S),v=async()=>{try{return await j.isAuthenticated()}catch{return!1}};if(h.useEffect(()=>{if(E){const H=j.getAllowedUsernames();if(H&&H.length>0){const G=H.includes("email"),re=H.includes("mobile");G?c("email"):re&&c("mobile")}j.isPasswordLoginEnabled()?l("password"):j.isOTPLoginEnabled()&&l("otp")}},[E]),h.useEffect(()=>{(async()=>{const G=await v();w(G)})()},[]),!E)return o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:o.jsx(y.Spin,{size:"large"})});const x=H=>{const G=P();return H==="email"?[{required:!0,message:G?.validation?.required||"Please enter your email address"},{type:"email",message:G?.validation?.invalidEmail||"Please enter a valid email address!"}]:H==="mobile"?[{required:!0,message:G?.validation?.required||"Please input your mobile number!"},{pattern:/^\+\d{7,15}$/,message:G?.validation?.invalidMobile||"Please enter a valid mobile number with country code (e.g., +919876543210)"}]:[{required:!0,message:G?.validation?.required||"Please enter your email address"},{type:"email",message:G?.validation?.invalidEmail||"Please enter a valid email address!"}]},F=async H=>{s(!0),a(null);try{const G=j.getAllowedUsernames(),re=G.includes("email"),R=G.includes("mobile"),ie=re&&R?u:re?"email":"mobile",ue={email:ie==="email"?H.username:void 0,phone:ie==="mobile"?H.username:void 0,password:H.password,remember_me:H.remember||!1},De=await e(ue)}catch(G){const re=P(),R=G.message||re?.errors?.loginFailed||"Login failed. Please try again.";a(R)}finally{s(!1)}},D=async H=>{console.log("OTP success in DynamicLoginForm, passing to onLogin:",H),await e(H)},Y=async()=>{s(!0);try{await j.logout(),y.toast.success("Logged out successfully"),w(!1)}catch(H){y.toast.error(H.message||"Failed to logout")}finally{s(!1)}},Z=async()=>{if(!C||!I){y.toast.error("Please fill in all password fields");return}if(C!==I){y.toast.error("Passwords do not match");return}if(C.length<8){y.toast.error("Password must be at least 8 characters long");return}s(!0);try{await j.setPassword(C),y.toast.success("Password changed successfully!"),k(!1),M(""),q("")}catch(H){y.toast.error(H.message||"Failed to change password")}finally{s(!1)}},J=H=>{const G=_(),re=P();return o.jsxs(y.Form,{name:`${H}-password-login`,className:"w-full",onFinish:F,onFinishFailed:()=>{const R=re?.validation?.required||"Please check your input and try again";a(R)},layout:"vertical",initialValues:{remember:!1},children:[n&&o.jsx(y.Alert,{message:n,type:"error",showIcon:!0,closable:!0,onClose:()=>a(null),className:"mb-4"}),o.jsx(y.FormItem,{name:"username",rules:x(H),children:o.jsx(y.Input,{placeholder:H==="email"?G?.formPlaceholders?.email||"Email address":G?.formPlaceholders?.mobile||"Mobile number (+919876543210)",autoComplete:H==="email"?"email":"tel",onKeyDown:H==="mobile"?R=>{const ie=["Backspace","Delete","Tab","Enter","ArrowLeft","ArrowRight"],ue=R.key;!ie.includes(ue)&&!/[0-9+]/.test(ue)&&R.preventDefault()}:void 0})}),o.jsx(y.FormItem,{name:"password",rules:[{required:!0,message:re?.validation?.required||"Please input your password!"},{min:E?.password_policy?.min_length||6,message:re?.validation?.passwordTooShort||`Password must be at least ${E?.password_policy?.min_length||6} characters long`}],children:o.jsx(y.PasswordInput,{placeholder:G?.formPlaceholders?.password||"Password",autoComplete:"current-password"})}),o.jsx(y.FormItem,{children:o.jsxs("div",{className:"flex justify-between items-center w-full",children:[o.jsx("div",{children:G?.showRememberMe!==!1&&t&&j.isRememberMeEnabled()&&o.jsx(y.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:o.jsx("div",{className:"auth-remember-me",style:A,children:o.jsx(y.Checkbox,{label:G?.rememberMeText||"Remember me"})})})}),o.jsx("div",{children:j.isForgotPasswordEnabled()&&o.jsx(K.Link,{to:"forgot-password",className:"text-sm transition-colors duration-300",style:L,children:G?.forgotPasswordText||"Forgot password?"})})]})}),o.jsx(y.FormItem,{children:o.jsx(y.Button,{variant:"primary",type:"submit",className:"w-full text-base font-medium",disabled:r,fullWidth:!0,children:G?.submitButtonText||"Sign in"})})]},`${H}-${m}`)},ee=()=>{if(!j.isOTPLoginEnabled())return null;const H=_();return d?o.jsx(Wr,{onSuccess:D,onBack:()=>f(!1)}):o.jsx(y.Button,{variant:"secondary",fullWidth:!0,onClick:()=>f(!0),className:"bg-gray-100 border-gray-300",children:H?.otpButtonText||"Sign in with OTP"})},$=()=>{if(!E)return null;const H=j.getAllowedUsernames(),G=H.includes("email"),re=H.includes("mobile"),R=j.isSSOEnabled()||j.isOIDCEnabled(),ie=j.isPasswordLoginEnabled(),ue=j.isOTPLoginEnabled();if(!ie&&!ue&&!R)return null;if(R&&!ie&&!ue)return o.jsxs("div",{className:"w-full",children:[j.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:j.getSSOProviders().map((ve,he)=>o.jsx(qe,{provider:ve,type:"sso"},`sso-standalone-${he}`))})}),j.isOIDCEnabled()&&o.jsx("div",{className:"space-y-2",children:j.getOIDCProviders().map((ve,he)=>o.jsx(qe,{provider:ve,type:"oidc"},`oidc-standalone-${he}`))})]});if(ue&&!ie){const ve=O();return o.jsxs("div",{className:"w-full",children:[o.jsx(Wr,{onSuccess:D}),R&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:ve?.separatorText||"OR"}),j.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:j.getSSOProviders().map((he,ce)=>o.jsx(qe,{provider:he,type:"sso"},`sso-otp-${ce}`))})}),j.isOIDCEnabled()&&o.jsx("div",{className:"mt-4",children:o.jsx("div",{className:"space-y-2",children:j.getOIDCProviders().map((he,ce)=>o.jsx(qe,{provider:he,type:"oidc"},`oidc-otp-${ce}`))})})]})]})}if(G&&re&&ie){const ve=_(),he=O();return o.jsx("div",{className:"w-full",children:o.jsx(y.Tabs,{className:"login-tabs",activeKey:u,onChange:ce=>{c(ce),g(de=>de+1)},items:[{key:"email",label:o.jsxs("span",{className:"flex items-center gap-1",style:U,children:[o.jsx(Ht,{size:16}),ve?.tabLabels?.email||"Email"]}),children:o.jsxs(o.Fragment,{children:[J("email"),ue&&ie&&!d&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:he?.separatorText||"OR"}),ee()]}),d&&ee(),!d&&R&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:he?.separatorText||"OR"}),j.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:j.getSSOProviders().map((ce,de)=>o.jsx(qe,{provider:ce,type:"sso"},`sso-email-${de}`))})}),j.isOIDCEnabled()&&o.jsx("div",{className:"mt-4",children:o.jsx("div",{className:"space-y-2",children:j.getOIDCProviders().map((ce,de)=>o.jsx(qe,{provider:ce,type:"oidc"},`oidc-email-${de}`))})})]})]})},{key:"mobile",label:o.jsxs("span",{className:"flex items-center gap-1",style:U,children:[o.jsx(_r,{size:16}),ve?.tabLabels?.mobile||"Mobile"]}),children:o.jsxs(o.Fragment,{children:[J("mobile"),ue&&ie&&!d&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),ee()]}),d&&ee(),!d&&R&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),j.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:j.getSSOProviders().map((ce,de)=>o.jsx(qe,{provider:ce,type:"sso"},`sso-mobile-${de}`))})}),j.isOIDCEnabled()&&o.jsx("div",{className:"mt-4",children:o.jsx("div",{className:"space-y-2",children:j.getOIDCProviders().map((ce,de)=>o.jsx(qe,{provider:ce,type:"oidc",onClick:Ct=>{console.log("OIDC provider clicked:",Ct)}},`oidc-${de}`))})})]})]})}]})})}else{const ve=G?"email":"mobile";return o.jsxs("div",{className:"w-full",children:[J(ve),ue&&ie&&!d&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),ee()]}),d&&ee(),!d&&R&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),j.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:j.getSSOProviders().map((he,ce)=>o.jsx(qe,{provider:he,type:"sso"},`sso-single-${ce}`))})}),j.isOIDCEnabled()&&o.jsx("div",{className:"mt-4"})]})]})}};return E?p?o.jsx("div",{className:"w-full",children:b?o.jsxs("div",{className:"space-y-4",children:[o.jsx("h4",{className:"text-base font-medium mb-4",children:"Change Your Password"}),o.jsx(y.FormItem,{label:"New Password",children:o.jsx(y.PasswordInput,{value:C,onChange:H=>M(H.target.value),placeholder:"Enter new password",disabled:r})}),o.jsx(y.FormItem,{label:"Confirm Password",children:o.jsx(y.PasswordInput,{value:I,onChange:H=>q(H.target.value),placeholder:"Confirm new password",disabled:r})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(y.Button,{type:"primary",onClick:Z,loading:r,className:"flex-1",children:"Change Password"}),o.jsx(y.Button,{onClick:()=>{k(!1),M(""),q("")},disabled:r,className:"flex-1",children:"Cancel"})]})]}):o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"text-center mb-4",children:[o.jsx("h3",{className:"text-lg font-medium",style:U,children:"Already Logged In"}),o.jsx("p",{className:"text-sm mt-2",style:A,children:"You are currently logged in."})]}),o.jsx(y.Button,{block:!0,onClick:()=>k(!0),children:"Change Password"}),o.jsx(y.Button,{block:!0,danger:!0,onClick:Y,loading:r,children:"Logout"})]})}):$():o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:o.jsx(y.Spin,{size:"large"})})},Wc=({onLogin:e,showRememberMe:t=!0,showForgotPassword:r=!0})=>{const[s,n]=h.useState(!1),[a,i]=h.useState(0),[l,u]=h.useState("email"),{authConfig:c}=Ye();h.useEffect(()=>{if(c){const k=j.getAllowedUsernames();k&&k.length>0&&u(k[0])}},[c]);const d=async k=>{n(!0);try{if(e){const C={email:l==="email"?k.username:void 0,phone:l==="mobile"?k.username:void 0,username:k.username,password:k.password,remember_me:k.remember||!1};await e(C)}}catch(C){y.toast.error(C.message||"Login failed. Please try again.")}finally{n(!1)}},f=()=>{switch(l){case"email":return"Email address";case"mobile":return"Phone number";case"username":return"Username";default:return"Username"}},m=()=>{const k=[{required:!0,message:`Please input your ${l}!`}];switch(l){case"email":return[...k,{type:"email",message:"Please enter a valid email address!"}];case"mobile":return[...k,{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid phone number!"}];case"username":return[...k,{min:3,message:"Username must be at least 3 characters long"}];default:return k}};if(!c)return o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const g=j.getAllowedUsernames(),p=g.length>1,w=j.isRememberMeEnabled(),b=j.isForgotPasswordEnabled();return o.jsxs(y.Form,{name:"login",className:"w-full space-y-4",initialValues:{remember:!1},onFinish:d,autoComplete:"off",layout:"vertical",children:[p&&o.jsx(y.FormItem,{label:"Login with",className:"mb-4",children:o.jsx(y.Select,{value:l,onChange:u,options:g.map(k=>({value:k,label:k==="mobile"?"Phone":k.charAt(0).toUpperCase()+k.slice(1)}))})}),o.jsx(y.FormItem,{name:"username",rules:m(),children:o.jsx(y.Input,{placeholder:f(),autoComplete:l==="email"?"email":"username"})}),o.jsx(y.FormItem,{name:"password",rules:[{required:!0,message:"Please input your password!"},{min:c?.password_policy?.min_length||6,message:`Password must be at least ${c?.password_policy?.min_length||6} characters long`}],children:o.jsx(y.PasswordInput,{placeholder:"Password",autoComplete:"current-password"})}),o.jsx(y.FormItem,{children:o.jsxs(y.Space,{className:"flex justify-between items-center w-full",children:[t&&w&&o.jsx(y.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:o.jsx(y.Checkbox,{label:"Remember me"})}),r&&b&&o.jsx(K.Link,{to:"forgot-password",className:"text-brand-500 text-sm hover:text-brand-600 transition-colors",children:"Forgot password?"})]})}),o.jsx(y.FormItem,{children:o.jsx(y.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:s,fullWidth:!0,children:"Log in"})})]},a)},{Title:Sn,Text:Ot,Paragraph:Kc}=y.Typography,Zc=({size:e="default",icon:t,src:r,style:s,className:n,children:a})=>{const l=typeof e=="number"?e:{small:24,default:32,large:40}[e];return o.jsx("div",{className:`inline-flex items-center justify-center bg-blue-500 text-white rounded-full overflow-hidden ${n||""}`,style:{width:l,height:l,fontSize:l*.45,...s},children:r?o.jsx("img",{src:r,alt:"Avatar",className:"w-full h-full object-cover"}):t||a||o.jsx(Nr,{size:l*.6})})},Gc=({description:e,className:t,image:r})=>o.jsxs("div",{className:`flex flex-col items-center justify-center py-8 ${t||""}`,children:[!r&&o.jsx("div",{className:"mb-4 text-gray-400",children:o.jsx("svg",{width:"64",height:"41",viewBox:"0 0 64 41",fill:"currentColor",children:o.jsxs("g",{transform:"translate(0 1)",fillRule:"evenodd",children:[o.jsx("ellipse",{fill:"#f5f5f5",cx:"32",cy:"33",rx:"32",ry:"7"}),o.jsxs("g",{fillRule:"nonzero",stroke:"#d9d9d9",children:[o.jsx("path",{d:"M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"}),o.jsx("path",{d:"M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z",fill:"#fafafa"})]})]})})}),e&&o.jsx("div",{className:"text-sm text-gray-500",children:e})]}),Jc=e=>{const t=e.toLowerCase();return t.includes("admin")?o.jsx(Fi,{size:20}):t.includes("manager")||t.includes("supervisor")?o.jsx(Di,{size:20}):t.includes("security")||t.includes("compliance")?o.jsx(po,{size:20}):o.jsx(Nr,{size:20})},rr=({user:e,roles:t,onRoleSelect:r,loading:s=!1,title:n="Choose Your Role",subtitle:a="Select the role that best matches your current responsibilities",logo:i})=>{const[l,u]=h.useState(null),[c,d]=h.useState(!1),{getRoleSelectionConfig:f,getCardConfig:m,authConfig:g}=_e(),p=f(),w=Xe(g),b=lt(g),k=it(g),C=async()=>{if(l){d(!0);try{await r(l)}catch(E){console.error("Role selection failed:",E)}finally{d(!1)}}};if(s)return o.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:o.jsx(y.Spin,{size:"large",tip:"Loading your available roles..."})});if(!t||t.length===0){const E=p?.customEmptyState;return E?o.jsx(E,{}):o.jsx("div",{className:"max-w-lg mx-auto p-5",children:o.jsx("div",{style:w,children:o.jsx(Gc,{className:"text-center py-12 px-5 text-gray-500",description:o.jsxs("div",{children:[o.jsx(Ot,{className:"text-gray-600 text-base block mb-2",children:p?.emptyStateMessage||"No roles available"}),o.jsx(Ot,{type:"secondary",className:"text-sm",children:"Please contact your administrator for role assignment"})]})})})})}const M=h.isValidElement(p?.title)?p.title:p?.title||n,I=h.isValidElement(p?.subtitle)?p.subtitle:p?.subtitle||a,q=p?.gridColumns||(t.length<=2?2:3);return o.jsx("div",{className:"max-w-lg mx-auto p-5",children:o.jsxs("div",{style:w,children:[i&&o.jsx("div",{className:b.className,style:b.style,children:typeof i=="string"?o.jsx("img",{src:i,alt:g?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:k}):i}),o.jsxs("div",{className:"text-center mb-8",children:[h.isValidElement(M)?M:o.jsx(Sn,{level:3,className:"!mb-3 !text-2xl !font-semibold !text-gray-800",style:Ie(g),children:M}),h.isValidElement(I)?I:o.jsx(Kc,{className:"!mb-6 text-base text-gray-600 !leading-relaxed",style:$e(g),children:I}),e&&o.jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-3 bg-gray-50 rounded-xl border border-gray-200",children:[o.jsx(Zc,{size:"default",className:"bg-blue-500",children:(e.name||e.username||"U").split(" ").map(E=>E[0]).join("").toUpperCase().slice(0,2)}),o.jsxs("div",{className:"text-left",children:[o.jsx(Ot,{strong:!0,className:"text-sm block text-gray-800",children:e.name||e.username||"User"}),e.email&&o.jsx(Ot,{type:"secondary",className:"text-xs",children:e.email})]})]})]}),o.jsx("div",{className:"mb-8",children:o.jsx("div",{className:"max-h-96 overflow-y-auto px-2 py-2",style:{maxHeight:p?.maxHeight||"24rem"},children:o.jsx("div",{className:`grid gap-4 grid-cols-${q}`,children:t.map(E=>{const _=p?.customRoleCard;if(_)return o.jsx(_,{role:E,selected:l?.id===E.id,onSelect:()=>u(E)},E.id);const P=p?.roleCardStyling||{},O=l?.id===E.id;return o.jsxs("div",{className:"cursor-pointer transition-all duration-300 border relative p-4 hover:-translate-y-1 flex flex-col items-center h-32 min-h-[8rem]",style:{backgroundColor:O?P.selectedColor||"#e6f7ff":P.backgroundColor||"#ffffff",borderColor:O?P.selectedColor||"#1890ff":"#d9d9d9",borderRadius:P.borderRadius||"16px",...p?.roleCardStyling},onClick:()=>u(E),children:[l?.id===E.id&&o.jsx("div",{className:"absolute -top-2 -right-2 bg-brand-500 rounded-full p-2",children:o.jsx(Ze,{size:16,className:"text-white"})}),o.jsx("div",{className:"flex justify-center mt-2 mb-3",children:o.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-xl flex items-center justify-center",children:Jc(E.name)})}),o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-1",children:[o.jsx(Sn,{level:5,className:"!mb-0 !text-sm !font-semibold !text-gray-900 !leading-tight !line-clamp-2 !text-center",title:E.name,children:E.name}),E.is_default&&o.jsx("div",{className:"mt-1",children:o.jsx(y.Tag,{color:"warning",className:"bg-yellow-50 border-yellow-300 text-yellow-700 font-medium text-xs px-1",children:p?.recommendedBadgeText||"Recommended"})})]})]},E.id)})})})}),o.jsxs("div",{className:"pt-4 border-t border-gray-200",children:[o.jsx(y.Button,{type:"primary",block:!0,onClick:C,disabled:!l,loading:c,icon:l?o.jsx(Ze,{size:16}):null,className:"w-full",children:l?p?.continueButtonText?.replace("{roleName}",l.name)||`Continue as ${l.name}`:"Please select a role to continue"}),l?.is_default&&o.jsx(Ot,{type:"secondary",className:"block text-center mt-3 text-sm",children:"This is your recommended role based on your permissions"})]})]})})},{Title:Xc,Text:Kr,Paragraph:Yc}=y.Typography,kn=({user:e,availableMethods:t=["email","sms"],onVerify:r,loading:s=!1,otpDigits:n=6,retryInterval:a=30,title:i="Two-Factor Authentication",subtitle:l="For your security, please verify your identity",logo:u})=>{const[c,d]=h.useState(t[0]||"email"),[f,m]=h.useState(""),[g,p]=h.useState(0),[w,b]=h.useState(!1),[k,C]=h.useState(!1),{authConfig:M,getTwoFactorConfig:I,getMessagesConfig:q}=_e(),E=I(),_=q(),P=Xe(M),O=lt(M),W=it(M);h.useEffect(()=>{if(g>0){const x=setTimeout(()=>p(g-1),1e3);return()=>clearTimeout(x)}},[g]);const S=x=>{if(x==="email"&&e?.email){const[F,D]=e.email.split("@");return`${F.substring(0,3)+"****"+F.substring(F.length-1)}@${D}`}return(x==="sms"||x==="mobile")&&e?.mobile?`****${e.mobile.substring(e.mobile.length-4)}`:x==="totp"?"your authenticator app":x==="email"?"your email":x==="sms"?"your mobile":"your authenticator app"},U=async()=>{b(!0);try{await j.sendTwoFactorCode(c),C(!0),p(E?.resendCountdown||a);const x=_?.success?.otpSent||`OTP sent to ${S(c)}`;y.toast.success(x)}catch(x){const F=_?.errors?.networkError||x.message||"Failed to Request OTP";y.toast.error(F)}finally{b(!1)}},A=async()=>{const x=E?.codeLength||n;if(f.length!==x){const F=_?.validation?.required||`Please enter ${x} digit OTP`;y.toast.error(F);return}b(!0);try{const F=await j.verifyTwoFactorCode(f);await r(F)}catch(F){const D=_?.errors?.invalidOTP||F.message||"Invalid OTP";y.toast.error(D),m("")}finally{b(!1)}},L=async()=>{g>0||await U()},v=()=>{if(t.length<=1)return null;const x=t.map(F=>({label:o.jsxs(y.Space,{children:[F==="email"?o.jsx(Ht,{size:16}):F==="sms"?o.jsx(_r,{size:16}):o.jsx(po,{size:16}),o.jsx("span",{children:F==="email"?E?.methodLabels?.email||"Email":F==="sms"?E?.methodLabels?.sms||"SMS":E?.methodLabels?.mobile||"Authenticator"})]}),value:F}));return o.jsxs("div",{className:"mb-6",children:[o.jsx(Kr,{type:"secondary",className:"block mb-2 text-xs",children:"Verification Method"}),o.jsx(y.Segmented,{options:x,value:c,onChange:F=>{d(F),C(!1),m("")},block:!0})]})};return o.jsx("div",{className:"w-full max-w-lg mx-auto",children:o.jsxs(y.Card,{className:"shadow-lg rounded-lg",bordered:!1,style:P,children:[u&&o.jsx("div",{className:O.className,style:O.style,children:typeof u=="string"?o.jsx("img",{src:u,alt:M?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:W}):u}),o.jsxs("div",{className:"text-center mb-8",children:[o.jsx(Xc,{level:3,className:"!mb-2",style:Ie(M),children:E?.title||i}),o.jsx(Yc,{className:"!mb-0 text-sm",type:"secondary",style:$e(M),children:E?.subtitle||l})]}),o.jsxs("div",{className:"mt-6",children:[v(),k?o.jsxs("div",{className:"mt-6",children:[o.jsx(Kr,{className:"block text-center mb-6 text-gray-700",children:E?.instructionText||`Enter the ${E?.codeLength||n}-digit code sent to ${S(c)}`}),o.jsx("div",{className:"flex justify-center mb-6",children:o.jsx(bn,{length:E?.codeLength||n,value:f,onChange:m,disabled:w})}),o.jsx(y.Button,{variant:"primary",fullWidth:!0,disabled:w,onClick:A,className:"mb-4",children:E?.submitButtonText||"Verify"}),o.jsx("div",{className:"text-center",children:g>0?o.jsxs(Kr,{type:"secondary",children:["Resend code in ",g,"s"]}):o.jsx(y.Button,{variant:"link",onClick:L,disabled:w,children:E?.resendButtonText||"Resend Code"})})]}):o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Alert,{message:E?.instructionText||`We'll send a verification code to ${S(c)}`,type:"info",showIcon:!0,className:"mb-6"}),o.jsx(y.Button,{variant:"primary",fullWidth:!0,disabled:w,onClick:U,children:"Send Verification Code"})]})]})]})})},{Title:Qc,Text:Qe,Paragraph:Rc}=y.Typography,En=({reason:e="Your password has expired",onReset:t,loading:r=!1,title:s="Password Reset Required",subtitle:n="Please create a new password to continue",passwordRules:a,logo:i})=>{const[l,u]=h.useState(0),[c,d]=h.useState(!1),[f,m]=h.useState(""),[g,p]=h.useState(null),[w,b]=h.useState({minLength:8,requireUppercase:!0,requireLowercase:!0,requireNumbers:!0,requireSpecialChars:!0}),{authConfig:k,getResetPasswordConfig:C,getMessagesConfig:M}=_e(),I=C(),q=M(),E=Xe(k),_=lt(k),P=it(k);h.useEffect(()=>{if(a)b(a);else{const A=j.getPasswordPolicy();b({minLength:A.min_length||8,maxLength:A.max_length,requireUppercase:A.require_uppercase||!1,requireLowercase:A.require_lowercase||!1,requireNumbers:A.require_numbers||!1,requireSpecialChars:A.require_special_chars||!1})}},[a]);const O=A=>{if(!A)return{percent:0,status:"exception"};let L=0;return A.length>=w.minLength&&(L+=20),A.length>=12&&(L+=10),w.requireUppercase&&/[A-Z]/.test(A)&&(L+=20),w.requireLowercase&&/[a-z]/.test(A)&&(L+=20),w.requireNumbers&&/\d/.test(A)&&(L+=15),w.requireSpecialChars&&/[!@#$%^&*]/.test(A)&&(L+=15),L<40?{percent:L,status:"exception"}:L<70?{percent:L,status:"normal"}:{percent:L,status:"success"}},W=(A,L)=>{if(!L){const x=q?.validation?.required||"Please input your password!";return Promise.reject(new Error(x))}const v=j.validatePassword(L);if(!v.valid){const x=q?.validation?.passwordTooShort||v.errors.join(", ");return Promise.reject(new Error(x))}return Promise.resolve()},S=async A=>{if(p(null),A.password!==A.confirmPassword){const L=q?.validation?.passwordsDoNotMatch||"Passwords do not match!";p(L);return}d(!0);try{await t({password:A.password,confirmPassword:A.confirmPassword})}catch(L){const v=L?.message||"Failed to set password. Please try again.";p(v)}finally{d(!1)}},U=O(f);return o.jsx("div",{className:"w-full max-w-lg mx-auto",children:o.jsxs(y.Card,{className:"shadow-lg rounded-lg",bordered:!1,style:E,children:[i&&o.jsx("div",{className:_.className,style:_.style,children:typeof i=="string"?o.jsx("img",{src:i,alt:k?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:P}):i}),o.jsxs("div",{className:"text-center mb-6",children:[o.jsx(Qc,{level:3,className:"!mb-2",style:Ie(k),children:I?.resetForm?.title||s}),o.jsx(Rc,{className:"!mb-0 text-sm",type:"secondary",style:$e(k),children:I?.resetForm?.subtitle||n})]}),o.jsx(y.Alert,{message:e,type:"warning",showIcon:!0,className:"mb-6"}),g&&o.jsx(y.Alert,{message:g,type:"error",showIcon:!0,className:"mb-6"}),o.jsxs(y.Form,{name:"password-reset-required",onFinish:S,layout:"vertical",className:"mt-6",children:[o.jsx(y.FormItem,{name:"password",label:I?.resetForm?.passwordLabel||"New Password",rules:[{validator:W}],children:o.jsx(y.PasswordInput,{prefix:o.jsx(jt,{size:16}),placeholder:I?.resetForm?.passwordPlaceholder||"New Password",onChange:A=>m(A.target.value)})}),f&&o.jsxs("div",{className:"-mt-4 mb-4",children:[o.jsx(Qe,{type:"secondary",className:"text-xs block mb-1",children:"Password Strength"}),o.jsx(y.Progress,{percent:U.percent,status:U.status,showInfo:!1,strokeWidth:4})]}),o.jsx(y.FormItem,{name:"confirmPassword",label:I?.resetForm?.confirmPasswordLabel||"Confirm Password",dependencies:["password"],rules:[{required:!0,message:q?.validation?.required||"Please confirm your password!"},({getFieldValue:A})=>({validator(L,v){if(!v||A("password")===v)return Promise.resolve();const x=q?.validation?.passwordsDoNotMatch||"Passwords do not match!";return Promise.reject(new Error(x))}})],children:o.jsx(y.PasswordInput,{prefix:o.jsx(jt,{size:16}),placeholder:I?.resetForm?.confirmPasswordPlaceholder||"Confirm Password"})}),I?.resetForm?.showPasswordRequirements!==!1&&o.jsxs("div",{className:"bg-gray-50 p-4 rounded-md mb-6",children:[o.jsx(Qe,{type:"secondary",className:"block font-medium mb-2",children:I?.resetForm?.passwordRequirementsText||"Password Requirements:"}),o.jsxs(y.Space,{direction:"vertical",size:"small",children:[o.jsxs(Qe,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ze,{size:16,className:f.length>=w.minLength?"text-green-500":"text-gray-300"}),"At least ",w.minLength," characters"]}),w.maxLength&&o.jsxs(Qe,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ze,{size:16,className:f.length<=w.maxLength?"text-green-500":"text-gray-300"}),"At most ",w.maxLength," characters"]}),w.requireUppercase&&o.jsxs(Qe,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ze,{size:16,className:/[A-Z]/.test(f)?"text-green-500":"text-gray-300"}),"One uppercase letter"]}),w.requireLowercase&&o.jsxs(Qe,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ze,{size:16,className:/[a-z]/.test(f)?"text-green-500":"text-gray-300"}),"One lowercase letter"]}),w.requireNumbers&&o.jsxs(Qe,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ze,{size:16,className:/\d/.test(f)?"text-green-500":"text-gray-300"}),"One number"]}),w.requireSpecialChars&&o.jsxs(Qe,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ze,{size:16,className:/[!@#$%^&*]/.test(f)?"text-green-500":"text-gray-300"}),"One special character (!@#$%^&*)"]})]})]}),o.jsx(y.FormItem,{children:o.jsx(y.Button,{variant:"primary",type:"submit",fullWidth:!0,disabled:c||r,children:I?.resetForm?.submitButtonText||"Reset Password"})})]},l)]})})},{Content:ed}=y.Layout,An=({logo:e,title:t="Processing Authentication",subtitle:r="Please wait while we complete your login",onAuthComplete:s,roleSelectionTitle:n="Select Your Role",roleSelectionSubtitle:a="Choose a role to continue",twoFactorTitle:i="Two-Factor Authentication",twoFactorSubtitle:l="Please enter your verification code",passwordResetTitle:u="Reset Password",passwordResetSubtitle:c="Please enter your new password"})=>{const[d]=K.useSearchParams(),{authConfig:f}=_e(),m=K.useNavigate(),[g,p]=h.useState(!0),[w,b]=h.useState(null),[k,C]=h.useState(null),[M,I]=h.useState(null);h.useEffect(()=>{q()},[]);const q=async()=>{try{p(!0),b(null);const S=d.get("token"),U=d.get("request_id"),A=d.get("next");if(!S||!U)throw new Error("Missing required SAML parameters (token or request_id)");if(!window.location.pathname.startsWith("/app/login")){p(!1);return}const v=await j.getSAMLAuthMeta(S,U);if(v?.status===401&&v?.data?.next_step){if(v.data.next_step.id==="role_selection"&&v.data.next_step.metadata?.roles){let x=[];Array.isArray(v.data.next_step.metadata.roles)?x=v.data.next_step.metadata.roles:typeof v.data.next_step.metadata.roles=="object"&&(x=Object.entries(v.data.next_step.metadata.roles).map(([F,D])=>({id:F,name:D,is_default:!1}))),C({roles:x,token:S,requestId:U,samlMetadata:v.data}),I("role_selection"),p(!1);return}C(v.data),I(v.data.next_step.id),p(!1);return}if(v?.roles&&v.roles.length>1){C({roles:v.roles,token:S,requestId:U}),I("role_selection"),p(!1);return}if(s)s(v);else{const x=v?.redirect_url||"/app";window.location.href=x}}catch(S){console.error("SAML callback error:",S),b(S.message||"Failed to process SAML authentication"),p(!1)}},E=async S=>{try{p(!0);const U=await j.setRole(S.id);if(U?.status===401&&U?.data?.next_step){C(U.data),I(U.data.next_step.id),p(!1);return}if(s)s(U);else{const A=U?.redirect_url||"/app";window.location.href=A}}catch(U){console.error("Role selection error:",U),y.toast.error(`Failed to select role: ${U.message||"Please try again"}`),p(!1)}},_=async S=>{try{if(S?.status===401&&S?.data?.next_step){C(S.data),I(S.data.next_step);return}if(s)s(S);else{const U=S?.redirect_url||"/app";window.location.href=U}}catch(U){console.error("Two-factor completion error:",U),y.toast.error(U.message||"Failed to complete two-factor authentication")}},P=async S=>{try{if(S?.status===401&&S?.data?.next_step){C(S.data),I(S.data.next_step);return}if(s)s(S);else{const U=S?.redirect_url||"/app";window.location.href=U}}catch(U){console.error("Password reset completion error:",U),y.toast.error(U.message||"Failed to complete password reset")}},O=()=>{if(g)return o.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[300px] text-center",children:[o.jsx(y.Spin,{size:"large"}),o.jsx("p",{className:"mt-4 text-gray-600",children:r})]});if(w)return o.jsx(y.Alert,{message:"Authentication Error",description:w,type:"error",showIcon:!0,action:o.jsx("a",{onClick:()=>m("/app/login"),children:"Return to Login"})});switch(M){case"role_selection":return o.jsx(rr,{roles:k?.roles||[],onRoleSelect:E,title:n,subtitle:a,loading:g,logo:e});case"2fa_required":return o.jsx(kn,{user:k?.user,onVerify:_,title:i,subtitle:l,logo:e});case"password_reset_required":return o.jsx(En,{onReset:P,title:u,subtitle:c,reason:k?.metadata?.reason,logo:e});default:return o.jsxs(y.Card,{className:"w-full max-w-md shadow-lg rounded-lg",bordered:!1,children:[e&&o.jsx("div",{className:"text-center mb-6",children:typeof e=="string"?o.jsx("img",{src:e,alt:"Logo",className:"max-w-[150px] h-auto mx-auto"}):e}),o.jsx("div",{className:"text-center mb-[18px]",children:o.jsx("h1",{className:"text-3xl font-semibold text-gray-900 mb-2",children:t})}),o.jsx(y.Alert,{message:"Unknown authentication step",description:`Unhandled auth step: ${M}`,type:"warning",showIcon:!0})]})}},W=()=>g||w||!M;return o.jsx(y.Layout,{className:"min-h-screen",style:We(f),children:o.jsx(ed,{className:"flex justify-center items-center min-h-screen p-5",children:W()?o.jsxs(y.Card,{className:"w-full max-w-md shadow-lg rounded-lg",bordered:!1,children:[e&&o.jsx("div",{className:"text-center mb-6",children:typeof e=="string"?o.jsx("img",{src:e,alt:"Logo",className:"max-w-[150px] h-auto mx-auto"}):e}),o.jsx("div",{className:"text-center mb-[18px]",children:o.jsx("h1",{className:"text-3xl font-semibold text-gray-900 mb-2",children:t})}),O()]}):O()})})},Zr=h.createContext(null),Gr=()=>h.useContext(Zr),td=({onLogin:e,logo:t,title:r,subtitle:s,apiConfig:n={},useDynamicConfig:a=!0,staticConfig:i=null})=>{const[l]=K.useSearchParams(),[u,c]=h.useState(null),[d,f]=h.useState(a),[m,g]=h.useState(null),p=l.get("token"),w=l.get("request_id");if(l.get("next"),p&&w)return o.jsx(An,{logo:t,title:r||"Processing Authentication",subtitle:s||"Please wait while we complete your login",onAuthComplete:A=>{const L=A?.redirect_url||"/app";window.location.href=L},roleSelectionTitle:"Select Your Role",roleSelectionSubtitle:"Choose a role to continue",twoFactorTitle:"Two-Factor Authentication",twoFactorSubtitle:"For your security, please verify your identity",passwordResetTitle:"Password Update Required",passwordResetSubtitle:"Please create a new password to continue"});const{authConfig:b,getCustomComponents:k}=_e(),C=k(),M=Xe(b),I=We(b),q=Ie(b),E=$e(b),_=lt(b),P=it(b),O=C?.LoginPage,W=C?.LoginCard;h.useEffect(()=>{a&&!i?S():i&&(c(i),f(!1))},[a,i]);const S=async()=>{try{const A=await j.getAuthConfig();c(A),g(null)}catch(A){console.error("Failed to fetch login methods:",A),c({login_methods:{password:{enabled:!0,allowed_usernames:["email"]},otp:{enabled:!1},sso:{enabled:!1},oidc:{enabled:!1}},password_policy:{min_length:8,reset:{enabled:!0}},session_policy:{remember_me_enabled:!0,remember_me_duration_days:30}}),g(null),console.warn("Using default auth configuration due to config fetch failure")}finally{f(!1)}},U=()=>d?o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:o.jsx(y.Spin,{size:"large",tip:"Loading login methods..."})}):m?o.jsx(y.Alert,{message:"Error",description:m,type:"error",showIcon:!0,action:o.jsx("a",{onClick:S,children:"Retry"})}):u&&a?o.jsx(zc,{onLogin:e}):o.jsx(Wc,{onLogin:e});return O?o.jsx(O,{}):W?o.jsx(Zr.Provider,{value:{onLogin:e||(()=>{})},children:o.jsx(y.Layout,{className:"min-h-screen",style:I,children:o.jsx(y.Layout.Content,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(y.Card,{className:"w-full max-w-md",bordered:!1,style:M,children:o.jsx(W,{})})})})}):o.jsx(y.Layout,{className:"min-h-screen",style:I,children:o.jsx(y.Layout.Content,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsxs(y.Card,{className:"w-full max-w-md",bordered:!1,style:M,children:[t&&o.jsx("div",{className:_.className,style:_.style,children:typeof t=="string"?o.jsx("img",{src:t,alt:b?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:P}):t}),o.jsxs("div",{className:"text-center mb-[18px]",children:[o.jsx("h1",{className:"text-3xl font-semibold mb-2",style:q,children:r||"Welcome Back"}),s&&o.jsx("p",{className:"text-base",style:E,children:s})]}),U()]})})})},{Content:rd}=y.Layout,sd=({logo:e,title:t,subtitle:r,apiConfig:s,useDynamicConfig:n=!0,staticConfig:a=null,onLoginSuccess:i,roleSelectionTitle:l,roleSelectionSubtitle:u,initialAuthResult:c=null})=>{const{pendingAuth:d,availableRoles:f,selectRole:m,login:g}=Ye(),[p,w]=h.useState(null);h.useEffect(()=>{c&&b(c)},[c]);const b=async C=>{w(null);try{if(C&&(C.status||C.data||C.next_step||C.response)){i&&i(C);return}const M=await g(C),I={email:C.email,username:C.username,phone:C.phone,display:C.email||C.username||C.phone};if(M.requiresRoleSelection)return;i&&i({...M,loginUser:I})}catch(M){throw w(M.message),M}},k=async C=>{try{const M=await m(C);i&&i(M)}catch(M){throw console.error("Role selection failed:",M),M}};if(d&&f){const C=We(s||a||{});return o.jsx(y.Layout,{className:"min-h-screen",style:C,children:o.jsx(rd,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(rr,{user:d.user,roles:f,onRoleSelect:k,title:l,subtitle:u})})})}return o.jsx(td,{onLogin:b,logo:e,title:t,subtitle:r,apiConfig:s,useDynamicConfig:n,staticConfig:a})},{Content:sr}=y.Layout,Jr=({logo:e,title:t,subtitle:r,apiConfig:s,useDynamicConfig:n=!0,staticConfig:a=null,onAuthComplete:i,roleSelectionTitle:l,roleSelectionSubtitle:u,twoFactorTitle:c,twoFactorSubtitle:d,passwordResetTitle:f,passwordResetSubtitle:m,initialAuthState:g=null})=>{const{user:p,pendingAuth:w}=Ye(),{authConfig:b}=_e();lt(b),it(b);const[k,C]=h.useState(()=>{if(g){if(g.roles&&g.roles.length>1)return"roleSelection";if(g.requires2FA)return"twoFactor";if(g.requiresPasswordReset)return"passwordReset"}return"login"}),[M,I]=h.useState(g?.token||null),[q,E]=h.useState(g?.twoFactorMethods||null),[_,P]=h.useState(g?.passwordResetReason||null),[O,W]=h.useState(g||null),S=async v=>{let x=v,F=null,D=!1,Y=null;v?.status===401&&v?.data?(x=v.data,F=v.data?.next_step,Y=v.status,D=v?.meta?.is_authenticated||!1):v?.next_step?(x=v,F=v.next_step,D=v?.meta?.is_authenticated||!1,Y=v?.status):v?.response?(Y=v.response.status,x=v.response.data,F=x?.next_step,D=v.response.meta?.is_authenticated||!1):(x=v?.response?.data||v?.data||v,F=x?.next_step,D=v?.meta?.is_authenticated||x?.meta?.is_authenticated||!1,Y=v?.status||x?.status);const Z=v?.loginUser;(v?.token||x?.token)&&I(v.token||x.token);let J=v?.user||x?.user||Z||{};if((typeof J!="object"||J===null)&&(J={}),Z&&typeof Z=="object"&&(J={...J,email:J.email||Z.email,username:J.username||Z.username,phone:J.phone||Z.phone,name:J.name||Z.display}),Y===200&&D){y.toast.success("Login successful!"),i&&i({...v,user:J,authenticated:!0,redirect_url:x?.redirect_url||v?.redirect_url||"/app"});return}if(F&&F.is_pending)switch(F.id){case"role_selection":let ee=[];Array.isArray(F.metadata.roles)?ee=F.metadata.roles:typeof F.metadata.roles=="object"&&(ee=Object.entries(F.metadata.roles).map(([G,re])=>({id:G,name:re,is_default:!1}))),W({...v,roles:ee,user:J,nextStep:F,loginUser:Z}),C("roleSelection");return;case"mfa_authenticate":I(v.token||x?.token);const $=F.metadata?.type?[F.metadata.type]:F.metadata?.methods||["email"];E($),C("twoFactor");return;case"set_password":I(v.token||x?.token);const H=F.metadata?.password_policy;P(F.metadata?.reason||"Password update required"),W({...v,passwordPolicy:H,user:J,loginUser:Z}),C("passwordReset");return;case"password_expiry":I(v.token||x?.token),P("Your password has expired"),W({...v,passwordPolicy:F.metadata?.password_policy,user:J,loginUser:Z}),C("passwordReset");return;case"first_login":I(v.token||x?.token),P("Please set up your password for first login"),W({...v,passwordPolicy:F.metadata?.password_policy,user:J,loginUser:Z}),C("passwordReset");return;case"login_by_code":I(v.token||x?.token),y.toast.info("OTP verification required"),i&&i({...v,user:J,requiresOTP:!0});return}if(v.requires2FA){I(v.token),E(v.twoFactorMethods||["email"]),W({...v,user:J,loginUser:Z}),C("twoFactor");return}if(v.requiresPasswordReset){I(v.token),P(v.passwordResetReason||"Your password has expired"),W({...v,user:J,loginUser:Z}),C("passwordReset");return}i&&i({...v,user:J})},U=async v=>{try{let x=v,F=null,D=!1,Y=null;if(v?.status===401&&v?.data?(x=v.data,F=v.data?.next_step,Y=v.status,D=v?.meta?.is_authenticated||!1):v?.response?(Y=v.response.status,x=v.response.data,F=x?.next_step,D=v.response.meta?.is_authenticated||!1):(x=v?.data||v,F=x?.next_step,D=v?.meta?.is_authenticated||x?.meta?.is_authenticated||!1,Y=v?.status||x?.status),Y===200&&D){y.toast.success("Two-factor authentication successful!"),i&&i({...v,token:M,user:O?.user,authenticated:!0});return}if(F&&F.is_pending)switch(F.id){case"set_password":const Z=F.metadata?.password_policy;P(F.metadata?.reason||"Password reset required"),W({...O,passwordPolicy:Z}),C("passwordReset");return;default:console.warn("Unknown next step after 2FA:",F.id);break}if(v.requiresPasswordReset){P(v.passwordResetReason||"Your password has expired"),C("passwordReset");return}y.toast.success("Two-factor authentication successful!"),i&&i({...v,token:M,user:O?.user,authenticated:!0})}catch(x){throw x}},A=async v=>{try{const x=await j.setPassword(v.password);let F=x,D=null,Y=!1,Z=null;if(x?.status===401&&x?.data?(F=x.data,D=x.data?.next_step,Z=x.status,Y=x?.meta?.is_authenticated||!1):x?.response?(Z=x.response.status,F=x.response.data,D=F?.next_step,Y=x.response.meta?.is_authenticated||!1):(F=x?.data||x,D=F?.next_step,Y=x?.meta?.is_authenticated||F?.meta?.is_authenticated||!1,Z=x?.status||F?.status),Z===200&&Y){y.toast.success("Password reset successful!"),i&&i({...x,token:M,user:O?.user,authenticated:!0});return}if(D&&D.is_pending)switch(D.id){case"mfa_authenticate":const J=D.metadata?.type?[D.metadata.type]:D.metadata?.methods||["email"];E(J),C("twoFactor");return;default:console.warn("Unknown next step after password reset:",D.id);break}y.toast.success("Password reset successful!"),i&&i({...x,token:M,user:O?.user,authenticated:!0})}catch(x){throw y.toast.error(x.message||"Failed to reset password"),x}};return(()=>{switch(k){case"login":return o.jsx(sd,{onLoginSuccess:S,logo:e,title:t,subtitle:r,apiConfig:s,useDynamicConfig:n,staticConfig:a,roleSelectionTitle:l,roleSelectionSubtitle:u});case"roleSelection":return O?.roles?o.jsx(y.Layout,{className:"min-h-screen",style:We(b),children:o.jsx(sr,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx("div",{className:"w-full",children:o.jsx(rr,{user:O?.user,roles:O?.roles||[],logo:e,onRoleSelect:async F=>{try{const D=await j.selectRole(F.id);let Y=D,Z=null,J=!1,ee=null;if(D?.status===401&&D?.data?(Y=D.data,Z=D.data?.next_step,ee=D.status,J=D?.meta?.is_authenticated||!1):D?.response?(ee=D.response.status,Y=D.response.data,Z=Y?.next_step,J=D.response.meta?.is_authenticated||!1):(Y=D?.data||D,Z=Y?.next_step,J=D?.meta?.is_authenticated||Y?.meta?.is_authenticated||!1,ee=D?.status||Y?.status),ee===200&&J){y.toast.success("Role selected successfully!"),i&&i({...D,user:{...O.user,role:F},authenticated:!0});return}if(Z&&Z.is_pending)switch(Z.id){case"mfa_authenticate":const $=Z.metadata?.type?[Z.metadata.type]:Z.metadata?.methods||["email"];E($),C("twoFactor");return;case"set_password":const H=Z.metadata?.password_policy;P(Z.metadata?.reason||"Password update required"),W({...O,passwordPolicy:H}),C("passwordReset");return;case"password_expiry":P("Your password has expired"),W({...O,passwordPolicy:Z.metadata?.password_policy}),C("passwordReset");return;case"first_login":P("Please set up your password for first login"),W({...O,passwordPolicy:Z.metadata?.password_policy}),C("passwordReset");return;case"login_by_code":y.toast.info("OTP verification required"),i&&i({...D,user:{...O.user,role:F},requiresOTP:!0});return;default:console.warn("Unknown next step:",Z.id);break}y.toast.success("Role selected successfully!"),i&&i({...D,user:{...O.user,role:F}})}catch(D){throw y.toast.error(D.message||"Failed to select role"),D}},title:l||"Select Your Role",subtitle:u||"Choose a role to continue"})})})}):o.jsx(y.Layout,{className:"min-h-screen",style:We(b),children:o.jsx(sr,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx("div",{className:"text-center py-16 px-5",children:o.jsx(y.Spin,{size:"large",tip:"Loading..."})})})});case"twoFactor":return o.jsx(y.Layout,{className:"min-h-screen",style:We(b),children:o.jsx(sr,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(kn,{user:O?.user||w?.user||p,availableMethods:q,onVerify:U,title:c,subtitle:d})})});case"passwordReset":const v=O?.passwordPolicy,x=v?{minLength:v.min_length||8,maxLength:v.max_length,requireUppercase:v.require_uppercase||!1,requireLowercase:v.require_lowercase||!1,requireNumbers:v.require_numbers||!1,requireSpecialChars:v.require_special_chars||!1}:void 0;return o.jsx(y.Layout,{className:"min-h-screen",style:We(b),children:o.jsx(sr,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(En,{reason:_||void 0,onReset:A,title:f,subtitle:m,passwordRules:x})})});default:return null}})()},{Content:od}=y.Layout,nd=({logo:e,apiConfig:t,onAuthComplete:r,roleSelectionTitle:s,roleSelectionSubtitle:n,twoFactorTitle:a,twoFactorSubtitle:i,passwordResetTitle:l,passwordResetSubtitle:u,redirectPath:c="/"})=>{const[d,f]=h.useState(null),[m,g]=h.useState(!1),p=async k=>{k.requiresRoleSelection||k.requires2FA||k.requiresPasswordReset?(f(k),g(!0)):(k.token&&localStorage.setItem(t?.tokenKey||"authToken",k.token),r&&r(k))},w=k=>{console.error("OAuth callback error:",k)},b=k=>{const C={...d,...k,authMethod:"oauth",provider:d?.provider};r&&r(C)};return m&&d?o.jsx(Jr,{logo:e,apiConfig:t,onAuthComplete:b,roleSelectionTitle:s,roleSelectionSubtitle:n,twoFactorTitle:a,twoFactorSubtitle:i,passwordResetTitle:l,passwordResetSubtitle:u,initialAuthState:{user:d.user,token:d.token,roles:d.roles,requires2FA:d.requires2FA,twoFactorMethods:d.twoFactorMethods,requiresPasswordReset:d.requiresPasswordReset,passwordResetReason:d.passwordResetReason}}):o.jsx(y.Layout,{className:"min-h-screen",style:We(t||{}),children:o.jsx(od,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(Oc,{onSuccess:p,onError:w,apiConfig:t,redirectPath:c,logo:e,roleSelectionTitle:s,roleSelectionSubtitle:n,twoFactorTitle:a,twoFactorSubtitle:i,passwordResetTitle:l,passwordResetSubtitle:u})})})},Xr=()=>Ye(),{Header:dh,Content:_n}=y.Layout,Yr={},Qr={},Rr={"admin@example.com":{requires2FA:!0,requiresPasswordReset:!1,twoFactorMethods:["email","mobile"]},"+919876543210":{requires2FA:!0,requiresPasswordReset:!0,passwordResetReason:"Your password will expire in 7 days",twoFactorMethods:["mobile"]},"test@example.com":{requires2FA:!1,requiresPasswordReset:!0,passwordResetReason:"Password has expired"}},Ft={"admin@example.com":[{id:1,name:"Super Admin",description:"Full system access with all administrative privileges",permissions:["system.manage","users.manage","roles.manage","settings.manage"],is_default:!1},{id:2,name:"Organization Admin",description:"Manage organization settings and users",permissions:["org.manage","users.manage","reports.view"],is_default:!0},{id:3,name:"Compliance Officer",description:"Monitor compliance and security settings",permissions:["compliance.view","audit.view","reports.generate"],is_default:!1}],"+919876543210":[{id:4,name:"Team Manager",description:"Manage team members and projects",permissions:["team.manage","projects.manage","reports.view"],is_default:!0},{id:5,name:"Employee",description:"Standard employee access",permissions:["profile.edit","tasks.manage","reports.view"],is_default:!1}],default:[{id:6,name:"User",description:"Standard user access",permissions:["profile.view","profile.edit"],is_default:!0}]},es=e=>({loginEndpoint:"/api/auth/login",logoutEndpoint:"/api/auth/logout",verifyEndpoint:"/api/auth/verify",forgotPasswordEndpoint:"/api/auth/forgot-password",resetPasswordEndpoint:"/api/auth/reset-password",loginMethodsEndpoint:"/api/v1/login/?action=fetch_methods",otpRequestEndpoint:"/api/auth/otp/request",otpVerifyEndpoint:"/api/auth/otp/verify",apiClient:{post:async(t,r)=>{if(await new Promise(s=>setTimeout(s,1e3)),t.includes("login")){const s=r.email||r.phone||r.username;if(["admin@example.com","+919876543210","test@example.com","admin"].includes(s)&&r.password==="password"){const i=Ft[s]||Ft.default,l=Rr[s]||{};return{user:{id:1,username:s,email:s.includes("@")?s:"user@example.com",mobile:s.startsWith("+")?s:"+919876543210",name:s==="admin@example.com"?"John Admin":s.startsWith("+")?"Mobile User":"Test User"},token:"mock-jwt-token-12345",roles:i,...l}}throw new Error("Invalid credentials")}if(t.includes("otp/request")){const s=r.email_or_phone||r.email||r.phone||r.username,n=Math.floor(Math.random()*9e5+1e5).toString().slice(0,6);return Yr[s]=n,y.toast.info(`Mock OTP sent! Check console for OTP: ${n}`),{success:!0,message:"OTP sent successfully"}}if(t.includes("otp/verify")){const s=r.email_or_phone||r.email||r.phone||r.username;if(Yr[s]===r.otp){delete Yr[s];const a=Ft[s]||Ft.default;return{user:{id:1,username:s,email:s.includes("@")?s:"user@example.com",mobile:s.startsWith("+")?s:"+919876543210",name:s.includes("@")?"OTP User":"Mobile User"},token:"mock-jwt-token-otp-12345",roles:a}}throw new Error("Invalid OTP")}if(t.includes("forgot-password"))return{message:"Reset email sent successfully"};if(t.includes("reset-password"))return{message:"Password reset successfully"};if(t.includes("role/select"))return{success:!0,...Rr["admin@example.com"]||{}};if(t.includes("2fa/send")){const s=Math.floor(Math.random()*9e5+1e5).toString().slice(0,6);return Qr[r.method]=s,y.toast.info(`2FA OTP sent! Check console for OTP: ${s}`),{success:!0,message:"2FA code sent successfully"}}if(t.includes("2fa/verify")){if(Qr[r.method]===r.otp){delete Qr[r.method];const a=Rr["admin@example.com"]||{};return{success:!0,requiresPasswordReset:a.requiresPasswordReset,passwordResetReason:a.passwordResetReason}}throw new Error("Invalid 2FA code")}if(t.includes("password/change"))return{success:!0,message:"Password changed successfully"};if(t.includes("oauth/callback")){const s=r.provider||"google",n={id:1,email:`user@${s}.com`,name:`${s.charAt(0).toUpperCase()+s.slice(1)} User`,username:`user@${s}.com`};return s==="google"?{user:n,token:"mock-oauth-token-12345",roles:Ft["admin@example.com"],requires2FA:!0,twoFactorMethods:["email"]}:s==="microsoft"?{user:n,token:"mock-oauth-token-12345",requiresPasswordReset:!0,passwordResetReason:"first_login"}:{user:n,token:"mock-oauth-token-12345"}}return{success:!0}},get:async t=>{if(await new Promise(r=>setTimeout(r,500)),t.includes("fetch_methods")||t.includes("config"))return{success:!0,response:{auth_config:{login_methods:{password:{enabled:!0,forgot_password_enabled:!0,allowed_usernames:["email","phone"]},otp:{enabled:!0,allowed_methods:["email","sms"]},sso:{enabled:!0,providers:[{id:1,label:"zsaml"}]},oidc:{enabled:!1}},password_policy:{min_length:8,require_numbers:!0,require_lowercase:!0,require_uppercase:!0,require_special_chars:!0,password_expiry_days:90,password_history_count:3,allow_change:!0,reset:{enabled:!0,method:["email"],expiry_hours:2}},session_policy:{remember_me_enabled:!0,remember_me_duration_days:30},two_factor_auth:{required:!0,allowed_methods:[]}}}};if(t.includes("verify")){const r=localStorage.getItem("authToken");if(r&&r.startsWith("mock-jwt-token"))return{id:1,username:"admin",email:"admin@example.com"};throw new Error("Invalid token")}return{}}}}),ad=({basePath:e="/login",apiConfig:t={},onAuthComplete:r,logo:s,title:n="Welcome Back",subtitle:a="Please sign in to your account",roleSelectionTitle:i="Select Your Role",roleSelectionSubtitle:l="Choose a role to continue",twoFactorTitle:u="Two-Factor Authentication",twoFactorSubtitle:c="Please enter your verification code",passwordResetTitle:d="Reset Password",passwordResetSubtitle:f="Please enter your new password"})=>{const{authConfig:m}=Ne();K.useLocation(),K.useNavigate();const[g,p]=h.useState(null),{setBasePath:w}=tr();h.useEffect(()=>{w(e)},[e,w]),h.useEffect(()=>(m&&Ac(m),()=>{_c()}),[m]);const b=h.useMemo(()=>{const E=m?.login||{},_=m?.logo||{};return{logo:_.url?o.jsx("img",{src:_.url,alt:_.alt||"Logo",style:{width:_.width||"auto",height:_.height||"auto",..._.style},className:_.className}):s,title:E.title||n,subtitle:E.subtitle||a,roleSelectionTitle:m?.roleSelection?.title||i,roleSelectionSubtitle:m?.roleSelection?.subtitle||l,twoFactorTitle:m?.twoFactor?.title||u,twoFactorSubtitle:m?.twoFactor?.subtitle||c,passwordResetTitle:m?.resetPassword?.resetForm?.title||d,passwordResetSubtitle:m?.resetPassword?.resetForm?.subtitle||f}},[m,s,n,a,i,l,u,c,d,f]),k=h.useMemo(()=>We(m),[m]),C=E=>{p(E),r&&r(E)},M=()=>{K.useNavigate();const E=sessionStorage.getItem("pendingAuthResult");sessionStorage.getItem("pendingAuthStep");let _=null;if(E)try{_=JSON.parse(E),sessionStorage.removeItem("pendingAuthResult"),sessionStorage.removeItem("pendingAuthStep")}catch(O){console.error("Failed to parse pending auth result:",O)}const P=async O=>{y.toast.success("Authentication complete!");try{const S=new URLSearchParams(window.location.search).get("next");let U="/app";if(S){const L=decodeURIComponent(S);L.startsWith("/")&&!L.startsWith("//")&&!L.toLowerCase().startsWith("javascript:")&&!L.toLowerCase().startsWith("data:")&&!L.toLowerCase().includes("://")?U=L:console.warn("Invalid 'next' parameter blocked:",L)}window.location.pathname.startsWith("/app/login")&&(window.location.href=U)}catch(W){console.error("Error handling auth completion:",W),window.location.href="/app"}};return o.jsx("div",{style:{...k,minHeight:"100vh"},children:o.jsx(Jr,{onAuthComplete:P,logo:b.logo,title:b.title,subtitle:b.subtitle,apiConfig:es(),useDynamicConfig:!0,roleSelectionTitle:b.roleSelectionTitle,roleSelectionSubtitle:b.roleSelectionSubtitle,twoFactorTitle:b.twoFactorTitle,twoFactorSubtitle:b.twoFactorSubtitle,passwordResetTitle:b.passwordResetTitle,passwordResetSubtitle:b.passwordResetSubtitle,initialAuthState:_})})},I=()=>{const{forgotPassword:E}=Xr();Xe(m);const _=async P=>{try{await E(P);const O=m?.resetPassword?.forgotPassword?.successMessage||"Reset email sent successfully!";y.toast.success(O)}catch(O){const W=m?.resetPassword?.forgotPassword?.errorMessage||O.message||"Failed to send reset email";y.toast.error(W)}};return o.jsx(y.Layout,{style:{...k,minHeight:"100vh"},children:o.jsx(_n,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:o.jsx(Lc,{onSubmit:_,authConfig:m,logo:b.logo})})})},q=()=>{const{resetPassword:E}=Xr(),{key:_}=K.useParams();Xe(m);const P=K.useNavigate();if(h.useEffect(()=>{_||P(e)},[_,P]),!_)return null;const O=async W=>{console.log("Password reset submitted for key:",_)};return o.jsx(y.Layout,{style:{...k,minHeight:"100vh"},children:o.jsx(_n,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:o.jsx(Tc,{onSubmit:O,authConfig:m,token:_,logo:b.logo})})})};return e.endsWith("/")&&e.slice(0,-1),o.jsx(wn,{authConfig:m,children:o.jsx(Cn,{config:es(),children:o.jsxs(K.Routes,{children:[o.jsx(K.Route,{path:"/",element:o.jsx(M,{})}),o.jsx(K.Route,{path:"forgot-password",element:o.jsx(I,{})}),o.jsx(K.Route,{path:"reset-password/:key",element:o.jsx(q,{})}),o.jsx(K.Route,{path:"reset-password",element:o.jsx(K.Navigate,{to:"/app",replace:!0})}),o.jsx(K.Route,{path:"/oauth/callback",element:o.jsx("div",{style:{...k,minHeight:"100vh"},children:o.jsx(nd,{logo:b.logo,apiConfig:es(),onAuthComplete:E=>{(async()=>{const P=E?.response?.data?.redirect_url;P&&(window.location.href=P)})()},roleSelectionTitle:b.roleSelectionTitle,roleSelectionSubtitle:b.roleSelectionSubtitle,twoFactorTitle:b.twoFactorTitle,twoFactorSubtitle:b.twoFactorSubtitle,passwordResetTitle:b.passwordResetTitle,passwordResetSubtitle:b.passwordResetSubtitle})})}),o.jsx(K.Route,{path:"/saml",element:o.jsx(An,{logo:o.jsx(Ii,{size:48,style:{color:"#1890ff"}}),onAuthComplete:E=>{const P=new URLSearchParams(window.location.search).get("next");let O="/app";P&&(O=decodeURIComponent(P)),E?.redirect_url&&(O=E.redirect_url),window.location.href=O},roleSelectionTitle:"Select Your Role",roleSelectionSubtitle:"Choose a role to continue",twoFactorTitle:"Two-Factor Authentication",twoFactorSubtitle:"For your security, please verify your identity",passwordResetTitle:"Password Update Required",passwordResetSubtitle:"Please create a new password to continue"})}),o.jsx(K.Route,{path:"/complete",element:o.jsx(Jr,{authData:g,apiConfig:t,logo:s,onComplete:C,roleSelectionTitle:i,roleSelectionSubtitle:l,twoFactorTitle:u,twoFactorSubtitle:c,passwordResetTitle:d,passwordResetSubtitle:f})}),o.jsx(K.Route,{path:"*",element:o.jsx(K.Navigate,{to:"/404",replace:!0})})]})})})},id=({layout:e="column",gap:t,className:r,buttonTextPrefix:s="Continue with",buttonTextPostfix:n=""})=>{const[a,i]=h.useState(!0),[l,u]=h.useState(null),{getProvidersConfig:c,getCustomComponents:d}=_e();if(h.useEffect(()=>{(async()=>{try{const O=await j.getAuthConfig();u(O)}catch(O){console.error("Failed to load auth config:",O)}finally{i(!1)}})()},[]),a)return o.jsx("div",{className:"flex justify-center items-center p-4",children:o.jsx(y.Spin,{size:"small"})});if(!l)return null;const f=j.isSSOEnabled(),m=j.isOIDCEnabled(),g=j.getSSOProviders(),p=j.getOIDCProviders();if(!f&&!m||g.length===0&&p.length===0)return null;const b=d()?.ProviderButton,k=[...g.map(P=>({...P,providerType:"sso"})),...p.map(P=>({...P,providerType:"oidc"}))],M=k.length===1,q=`gap-${t??(e==="grid"?3:2)}`,_=`w-full ${(()=>{if(M)return"";switch(e){case"grid":return`grid grid-cols-1 sm:grid-cols-2 ${q}`;case"row":return`flex flex-row flex-wrap ${q}`;case"column":default:return`flex flex-col ${q}`}})()} ${r||""}`.trim();return o.jsx("div",{className:_,children:k.map((P,O)=>{const W=b||qe;return o.jsx(W,{provider:P,type:P.providerType,prefix:s,postfix:n},`${P.providerType}-${O}`)})})},ld=({onSuccess:e,showRememberMe:t=!0,submitButtonText:r})=>{const[s,n]=h.useState(!1),[a,i]=h.useState(null),[l,u]=h.useState("email"),[c,d]=h.useState(0),[f,m]=h.useState(!1),{authConfig:g}=Ye(),{getLoginConfig:p,getMessagesConfig:w,authConfig:b}=_e(),k=Gr(),C=b||g;Ie(C);const M=$e(C),I=yn(C);if(h.useEffect(()=>{(async()=>{try{await j.getAuthConfig();const L=j.getAllowedUsernames();if(L&&L.length>0){const v=L.includes("email"),x=L.includes("mobile");v?u("email"):x&&u("mobile")}m(!0)}catch(L){console.error("Failed to load auth config:",L),m(!0)}})()},[]),!f)return o.jsx("div",{className:"flex justify-center items-center min-h-[200px]",children:o.jsx(y.Spin,{size:"large"})});const q=j.getAllowedUsernames(),E=q.includes("email"),_=q.includes("mobile"),P=E&&_,O=A=>{const L=w();return A==="email"?[{required:!0,message:L?.validation?.required||"Please enter your email address"},{type:"email",message:L?.validation?.invalidEmail||"Please enter a valid email address!"}]:[{required:!0,message:L?.validation?.required||"Please input your mobile number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:L?.validation?.invalidMobile||"Please enter a valid mobile number with country code (e.g., +919876543210)"}]},W=async A=>{n(!0),i(null);try{const L=l==="email"?{email:A.username,password:A.password}:{phone:A.username,password:A.password},v=await j.login(L);if(e){e(v);return}if(k?.onLogin){k.onLogin(v);return}let x=null;v?.status===401&&v?.data?.next_step?x=v.data.next_step:v?.next_step?x=v.next_step:v?.response?.data?.next_step&&(x=v.response.data.next_step),x&&x.is_pending?(sessionStorage.setItem("pendingAuthResult",JSON.stringify(v)),sessionStorage.setItem("pendingAuthStep",x.id),window.location.href="/app/login"):window.location.href="/app"}catch(L){const v=w(),x=L?.response?.data?.message||L?.message||v?.error?.login||"Login failed. Please check your credentials and try again.";i(x)}finally{n(!1)}},S=A=>{const L=p(),v=w();return o.jsxs(y.Form,{name:`${A}-password-login`,className:"w-full",onFinish:W,onFinishFailed:()=>{const x=v?.validation?.required||"Please check your input and try again";i(x)},layout:"vertical",initialValues:{remember:!1,username:""},children:[a&&o.jsx(y.Alert,{message:a,type:"error",showIcon:!0,closable:!0,onClose:()=>i(null),className:"mb-4"}),o.jsx(y.FormItem,{name:"username",rules:O(A),children:o.jsx(y.Input,{placeholder:A==="email"?L?.formPlaceholders?.email||"Email address":L?.formPlaceholders?.mobile||"Mobile number (+919876543210)",autoComplete:A==="email"?"email":"tel",onKeyDown:A==="mobile"?x=>{const F=["Backspace","Delete","Tab","Enter","ArrowLeft","ArrowRight"],D=x.key;!F.includes(D)&&!/[0-9+]/.test(D)&&x.preventDefault()}:void 0})}),o.jsx(y.FormItem,{name:"password",rules:[{required:!0,message:v?.validation?.required||"Please input your password!"},{min:g?.password_policy?.min_length||6,message:v?.validation?.passwordTooShort||`Password must be at least ${g?.password_policy?.min_length||6} characters long`}],children:o.jsx(y.PasswordInput,{placeholder:L?.formPlaceholders?.password||"Password",autoComplete:"current-password"})}),o.jsx(y.FormItem,{children:o.jsxs("div",{className:"flex justify-between items-center w-full",children:[o.jsx("div",{children:L?.showRememberMe!==!1&&t&&j.isRememberMeEnabled()&&o.jsx(y.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:o.jsx("div",{className:"auth-remember-me",style:M,children:o.jsx(y.Checkbox,{label:L?.rememberMeText||"Remember me"})})})}),o.jsx("div",{children:j.isForgotPasswordEnabled()&&o.jsx(K.Link,{to:"forgot-password",className:"text-sm transition-colors duration-300",style:I,children:L?.forgotPasswordText||"Forgot password?"})})]})}),o.jsx(y.FormItem,{children:o.jsx(y.Button,{variant:"primary",type:"submit",className:"w-full text-base font-medium",disabled:s,fullWidth:!0,children:r||L?.submitButtonText||"Sign in"})})]},`${A}-${c}`)};if(P){const A=[...E?[{key:"email",label:"Email",children:S("email")}]:[],..._?[{key:"mobile",label:"Mobile",children:S("mobile")}]:[]];return o.jsx("div",{className:"w-full",children:o.jsx(y.Tabs,{activeKey:l,onChange:L=>{u(L),d(v=>v+1),i(null)},items:A,className:"password-login-tabs"})})}return S(E?"email":"mobile")},cd=({onSuccess:e,onBack:t,submitButtonText:r,verifyButtonText:s,resendButtonText:n})=>{const[a,i]=h.useState(!1),[l,u]=h.useState(null),c=Gr(),d=f=>{let m=null;if(f?.status===401&&f?.data?m=f.data?.next_step:f?.next_step?m=f.next_step:m=(f?.response?.data||f?.data||f)?.next_step,m&&m.is_pending){if(e){e(f);return}if(c?.onLogin){c.onLogin(f);return}console.warn("OTPLoginForm: Multi-step auth required but no parent handler found");return}const g=f?.meta?.is_authenticated||f?.response?.meta?.is_authenticated;if((f?.status||f?.response?.status)===200&&g){window.location.href="/app";return}if(e){e(f);return}if(c?.onLogin){c.onLogin(f);return}console.warn("OTPLoginForm: No onSuccess prop or LoginContext found. Authentication result not handled.")};return o.jsx(Wr,{onSuccess:d,onBack:t,submitButtonText:r,verifyButtonText:s,resendButtonText:n})},or=({basePath:e="/app"})=>{const t=kt();return o.jsx("div",{className:"page-container",children:o.jsx(ad,{basePath:e,apiConfig:t})})},dd=async(e=[])=>{const t=Ei(e),r={login:{component:or,includeBasePath:!0,standalone:!0,propsBuilder:({matchedRoutePath:n})=>({basePath:n})},custom:{component:null,includeBasePath:!1,handler:({customPages:n,customPagePath:a,location:i})=>{const l=n[a];return l?h.createElement(l):h.createElement(Ar,{componentName:a})}},404:{component:Et,standalone:!0,includeBasePath:!1,propsBuilder:()=>({})},default:{component:Et,includeBasePath:!1,standalone:!0,propsBuilder:({pageType:n})=>({message:`Unknown page type: ${n}`})}};for(const n of t){const a=Ai(n);a?r[n]={component:a,includeBasePath:!0,propsBuilder:({matchedRoutePath:i})=>({basePath:i})}:console.warn(`⚠️ Failed to get component for page type: ${n}`)}t.length;const s=e.filter(n=>!t.includes(n));return s.length>0&&console.warn(`⚠️ Unconfigured page types (not in PAGE_CONFIG): ${s.join(", ")}`),r},ud=e=>{const t=new Set;return e.forEach(r=>{r.page_type&&r.page_type!=="custom"&&r.page_type!=="login"&&t.add(r.page_type)}),Array.from(t)},Nn=async e=>{const t=ud(e);return dd(t)},Ln=h.createContext(void 0);let nr=!1;typeof window<"u"&&(nr=!1);const Ne=()=>{const e=h.useContext(Ln);if(!e)throw new Error("useAppContext must be used within AppProvider");return e},Tn=({children:e,config:t={},layoutConfig:r={},topbarConfig:s={},navbarConfig:n={},customComponents:a={},authConfig:i={}})=>{const l=K.useNavigate(),u=K.useLocation(),[c,d]=h.useState(null),[f,m]=h.useState(!0),[g,p]=h.useState(null),[w,b]=h.useState(null),[k,C]=h.useState(null),[M,I]=h.useState(!1),[q,E]=h.useState(null),_=()=>typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",P=t,O=P.apiConfig||{};h.useEffect(()=>{const S={colors:{primary:"#5048ed",secondary:"#6d7280",success:"#10b981",warning:"#f59e0b",error:"#f04438",gray:"#6d7280",background:"#f9fafb",text:"#252b37"}},U="default-theme-variables";let A=document.getElementById(U);A||(A=document.createElement("style"),A.id=U,document.head.appendChild(A)),A.innerHTML=`:root { ${Vt(S)} }`},[]),h.useEffect(()=>{const S=tt.getCachedLogo();S&&b(S.base64Data||S.url)},[]),h.useEffect(()=>((async()=>{if(window.location.pathname.startsWith("/app/login"),!nr){nr=!0;try{const A=await Vs(),L=A.success?A.response:null;if(!A.success)throw new Error(A.response?.message||"Failed to fetch app data");if(d(L),L?.theme){const v=document.getElementById("default-theme-variables");if(v)v.innerHTML=`:root { ${Vt(L.theme)} }`;else{const x=document.createElement("style");x.id="default-theme-variables",x.innerHTML=`:root { ${Vt(L.theme)} }`,document.head.appendChild(x)}L?.app_logo&&tt.updateInBackground(L.app_logo,L.app_name,x=>{x.base64Data&&b(x.base64Data)})}}catch(A){console.error("❌ fetchAppInitData error:",A),p(A.message)}finally{m(!1),nr=!1}}})(),()=>{}),[]),h.useEffect(()=>{if(f||!c)return;const S=u.pathname,U=u.search,A=S==="/app/configuration-error";if(S==="/app/logout")return;const v=c.menu&&c.menu.length>0,x=c.routes&&c.routes.length>0;c.profile_info?.user_role;const F=c.is_user_anonymous,D=!c.is_user_anonymous,Y=x&&c.routes.some(ee=>{const $=ee.path;return S===$||S.startsWith($+"/")}),Z=ee=>{const $=U?`${ee}${U}`:ee;l($,{replace:!0})};if(D&&!v&&!A){Z("/app/configuration-error");return}const J=S==="/app/login"||S.startsWith("/app/login/");if(F&&!v&&!J){const ee=window.location.search;l(`/app/login${ee}`,{replace:!0});return}if(v&&c.menu){const ee=c.menu[0]?.path||c.menu[0]?.uri;if(ee&&(S==="/app"||S==="/app/"||!Y&&!A)){Z(ee);return}}},[f,c,u.pathname,u.search,l]),h.useEffect(()=>{let S=!1;return(async()=>{if(!f&&c){if(c.is_user_anonymous){const{default:A}=await Promise.resolve().then(function(){return mf});if(c.routes&&c.routes.length>0)try{S||I(!0);const L=await Nn(c.routes);S||(C(L),I(!1));return}catch(L){console.error("❌ Failed to create registry from routes for anonymous user:",L)}S||(C(A),I(!1));return}if(!c.routes||c.routes.length===0){S||(C({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),I(!1));return}try{S||(I(!0),E(null));const A=await Nn(c.routes);S||(C(A),I(!1))}catch(A){console.error("❌ Failed to create dynamic page registry:",A),S||(E(A.message||"Failed to create page registry"),C({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),I(!1))}}})(),()=>{S=!0}},[c,f]);const W={appData:c,loading:f,error:g,config:P,apiConfig:O,menu:c?.menu||[],routes:c?.routes||[],profileInfo:c?.profile_info||{},appLogo:w||c?.app_logo||"",appName:c?.app_name||"Zango CRM",metadata:c?.metadata||{},theme:c?.theme||{},layoutConfig:r,topbarConfig:s,navbarConfig:n,customComponents:a,authConfig:i,sessionSecurity:c?.session_security_config||null,pageTypeRegistry:k,registryLoading:M,registryError:q,initializerEndpoint:_()};return o.jsx(Ln.Provider,{value:W,children:e})},On=()=>{const e=K.useNavigate(),{routes:t}=Ne(),r=h.useCallback(n=>{if(!n)return!1;const a=n.endsWith("/")&&n!=="/"?n.slice(0,-1):n;return t.some(i=>{const l=i.path,u=l.endsWith("/")&&l!=="/"?l.slice(0,-1):l;if(u===a)return!0;if(u.includes(":")){const c=u.split("/").map(f=>f.startsWith(":")?"[^/]+":f).join("/");return new RegExp(`^${c}(/.*)?$`).test(a)}return i.exact===!1?a.startsWith(u):!1})},[t]);return{navigateTo:h.useCallback((n,a={})=>{if(n){if(n.startsWith("http://")||n.startsWith("https://")){a.newTab?window.open(n,"_blank"):window.location.href=n;return}r(n)?e(n,a):a.newTab?window.open(n,"_blank"):window.location.href=n}},[e,r]),isInternalRoute:r}},ar=({to:e,children:t,className:r,onClick:s,...n})=>{const{isInternalRoute:a}=On(),i=u=>{s&&s(u)};return!(e&&(e.startsWith("http://")||e.startsWith("https://")))&&a(e)?o.jsx(K.Link,{to:e,className:r,onClick:i,...n,children:t}):o.jsx("a",{href:e,className:r,onClick:i,...n,children:t})},ir=(e,t)=>{if(!e)return;e.querySelectorAll("svg").forEach(s=>{s.getAttribute("fill")&&s.getAttribute("fill")!=="none"&&s.setAttribute("fill",t),s.getAttribute("stroke")&&s.getAttribute("stroke")!=="none"&&s.setAttribute("stroke",t),s.querySelectorAll("*").forEach(a=>{a.getAttribute("fill")&&a.getAttribute("fill")!=="none"&&a.setAttribute("fill",t),a.getAttribute("stroke")&&a.getAttribute("stroke")!=="none"&&a.setAttribute("stroke",t)})})},fd=({appLogo:e,appName:t,linkTo:r="/app",collapsed:s=!1})=>{if(s){const n=t?t.charAt(0).toUpperCase():"A";return o.jsx("div",{className:"navbar-logo-container frame-logo-container",style:{padding:"16px",justifyContent:"center"},children:o.jsx(ar,{to:r,style:{textDecoration:"none"},children:o.jsx("div",{className:"collapsed-logo-initial",style:{width:"32px",height:"32px",backgroundColor:"var(--color-brand-500, #5048ED)",color:"white",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",fontWeight:"bold"},children:n})})})}return o.jsx("div",{className:"navbar-logo-container frame-logo-container",children:o.jsx(xs,{logoUrl:e,appName:t,height:"28px",linkTo:r})})},Fn=({menuItems:e=[],appLogo:t,theme:r={},config:s={}})=>{const n=K.useLocation(),[a,i]=h.useState({}),{appName:l}=Ne(),u=h.useRef(null);h.useEffect(()=>{if(!u.current)return;const S=u.current.querySelector("#wideSidebarMenu");if(!S)return;S.querySelectorAll("li").forEach(A=>{const L=A.classList.contains("active"),v="var(--color-gray-700, #414651)",x="var(--color-brand-500, #5048ED)";ir(A,L?x:v);const F=()=>{A.classList.contains("active")||ir(A,x)},D=()=>{A.classList.contains("active")||ir(A,v)};return A.addEventListener("mouseenter",F),A.addEventListener("mouseleave",D),()=>{A.removeEventListener("mouseenter",F),A.removeEventListener("mouseleave",D)}})},[n.pathname,e]);const c=(S,U)=>{const A=S.url||S.uri,L=A?.endsWith("/")?A:`${A}/`,v=U.endsWith("/")?U:`${U}/`;return L===v?!0:S.children?.length?S.children.some(x=>{const F=x.url||x.uri;return(F?.endsWith("/")?F:`${F}/`)===v}):!1},d=S=>{i(U=>({...U,[S]:!U[S]}))};h.useEffect(()=>{const S={};e.forEach(U=>{U.children?.length&&c(U,n.pathname)&&(S[U.name]=!0)}),i(S)},[n.pathname,e]);const f=S=>S.icon?S.icon.includes("<svg")?o.jsx("span",{className:"navbar-icon",dangerouslySetInnerHTML:{__html:S.icon}}):/^[\u{1F300}-\u{1F9FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F1E0}-\u{1F1FF}]|[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u.test(S.icon)||S.icon.length<=4?o.jsx("span",{className:"navbar-icon navbar-icon-emoji",children:S.icon}):o.jsx("span",{className:"navbar-icon",children:o.jsx("img",{src:S.icon,alt:S.name,width:"16",height:"16"})}):o.jsx("span",{className:"navbar-icon",children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o.jsx("path",{d:"M1.66675 8.00002C1.66675 5.1802 1.66675 3.77029 2.46539 2.83519C2.5788 2.70241 2.70247 2.57874 2.83525 2.46533C3.77035 1.66669 5.18026 1.66669 8.00008 1.66669C10.8199 1.66669 12.2298 1.66669 13.1649 2.46533C13.2977 2.57874 13.4213 2.70241 13.5347 2.83519C14.3334 3.77029 14.3334 5.1802 14.3334 8.00002C14.3334 10.8198 14.3334 12.2298 13.5347 13.1648C13.4213 13.2976 13.2977 13.4213 13.1649 13.5347C12.2298 14.3334 10.8199 14.3334 8.00008 14.3334C5.18026 14.3334 3.77035 14.3334 2.83525 13.5347C2.70247 13.4213 2.5788 13.2976 2.46539 13.1648C1.66675 12.2298 1.66675 10.8198 1.66675 8.00002Z",stroke:"currentColor",strokeLinejoin:"round"}),o.jsx("path",{d:"M7.69235 4.83562C7.83568 4.61038 8.16448 4.61038 8.30782 4.83562L8.72255 5.48724C9.18115 6.20782 9.79228 6.81896 10.5129 7.27756L11.1645 7.69229C11.3897 7.83562 11.3897 8.16442 11.1645 8.30776L10.5129 8.72249C9.79228 9.18109 9.18115 9.79222 8.72255 10.5128L8.30782 11.1644C8.16448 11.3897 7.83568 11.3897 7.69235 11.1644L7.27762 10.5128C6.81902 9.79222 6.20788 9.18109 5.4873 8.72249L4.83568 8.30776C4.61044 8.16442 4.61044 7.83562 4.83568 7.69229L5.4873 7.27756C6.20788 6.81896 6.81902 6.20782 7.27762 5.48724L7.69235 4.83562Z",stroke:"currentColor",strokeLinejoin:"round"})]})}),{showLogo:m=!0,showMenu:g=!0,isCollapsed:p=!1,collapsible:w=!1,customLogo:b=null,customMenuContent:k=null,customBottomContent:C=null,customNavbar:M=null,customMenu:I=null,menuConfig:q={},className:E="",style:_={}}=s,[P,O]=h.useState(p),W=P?"80px":"244px";return o.jsxs("nav",{ref:u,className:`navbar ${P?"collapsed-sidebar":"wide-sidebar"} ${E}`,style:{width:W,..._,display:"flex",flexDirection:"column",transition:"width 0.3s ease"},children:[m&&(b?o.jsx("div",{className:"navbar-logo-container frame-logo-container",children:b}):o.jsx(fd,{appLogo:t,appName:l,collapsed:P})),w&&o.jsx("div",{className:"navbar-toggle-container",style:{padding:"8px 16px",borderBottom:"1px solid var(--color-gray-200, #e5e7eb)"},children:o.jsx("button",{onClick:()=>O(!P),className:"navbar-toggle-btn",style:{width:"100%",padding:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",transition:"background-color 0.2s ease"},onMouseEnter:S=>S.target.style.backgroundColor="var(--color-gray-100, #f3f4f6)",onMouseLeave:S=>S.target.style.backgroundColor="transparent",title:P?"Expand navbar":"Collapse navbar",children:o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:P?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:o.jsx("path",{d:"M6 4L10 8L6 12",stroke:"var(--color-gray-600, #4b5563)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),o.jsx("div",{className:"navbar-menu-container frame-menu-container complete-hidden-scroll-style",style:{flex:1,overflow:"auto"},children:g&&(I||o.jsxs(o.Fragment,{children:[o.jsx("ul",{className:"navbar-menu wide-sidebar-menu",id:"wideSidebarMenu",children:e.map(S=>{const U=S.url||S.uri,A=c(S,n.pathname),L=a[S.name]||!1,v=S.children&&S.children.length>0;return o.jsxs(h.Fragment,{children:[o.jsx("li",{className:`menu-list-item ${v?"menu-list-item-with-sub-menu":""} ${A?"active":""}`,children:v?o.jsxs("div",{className:"menu-item",onClick:()=>!P&&d(S.name),style:{justifyContent:P?"center":"flex-start",padding:P?"8px":void 0},title:P?S.name:void 0,children:[f(S),!P&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:`menu-title ${A?"font-semibold":""}`,children:S.name}),o.jsx("div",{className:`flex justify-center items-center h-full transition-transform duration-300 ease-in-out ${A&&L?"rotate-180":""}`,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:o.jsx("path",{d:"M9.74976 3.99963C9.81538 3.99963 9.88053 4.01263 9.94116 4.03772C10.0018 4.06282 10.0569 4.09977 10.1033 4.14612C10.1496 4.19249 10.1865 4.24766 10.2117 4.30823C10.2368 4.36885 10.2497 4.43402 10.2498 4.49963C10.2498 4.56531 10.2368 4.63036 10.2117 4.69104C10.1865 4.75173 10.1497 4.8067 10.1033 4.85315L6.35327 8.60315C6.30685 8.64961 6.25184 8.68639 6.19116 8.71155C6.13048 8.73669 6.06544 8.75061 5.99976 8.75061C5.93412 8.75058 5.86899 8.73668 5.80835 8.71155C5.77819 8.69902 5.74944 8.6837 5.72241 8.66565L5.64624 8.60315L1.89624 4.85315C1.80256 4.75936 1.74976 4.6322 1.74976 4.49963C1.74981 4.36705 1.80248 4.23988 1.89624 4.14612C1.99 4.05236 2.11717 3.99969 2.24976 3.99963C2.38232 3.99963 2.50948 4.05244 2.60327 4.14612L5.99976 7.5426L9.39624 4.14612C9.44265 4.09971 9.49773 4.06286 9.55835 4.03772C9.61897 4.01261 9.68414 3.99966 9.74976 3.99963Z",fill:"#414651",stroke:"#414651",strokeWidth:"0.25"})})})]})]}):o.jsxs(ar,{to:U,className:"menu-item",style:{justifyContent:P?"center":"flex-start",padding:P?"8px":void 0},title:P?S.name:void 0,children:[f(S),!P&&o.jsx("span",{className:`menu-title ${A?"font-semibold":""}`,children:S.name})]})}),v&&!P&&o.jsx("ul",{className:`submenu-list ${L?"active":""}`,children:S.children.map(x=>{const F=x.url||x.uri,D=n.pathname===F||n.pathname===`${F}/`;return o.jsx("li",{className:"submenu-list-item",children:o.jsxs(ar,{to:F,className:`submenu-item d-flex ${D?"selected-each-wide-submenu":""}`,children:[o.jsx("span",{className:"submenu-item-icon-container",children:D?o.jsx("svg",{className:"w-3.5 h-2.5 inline-block",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"10",viewBox:"0 0 14 10",fill:"none",children:o.jsx("path",{d:"M13.3538 6.85375L10.3538 9.85375C10.2599 9.94757 10.1327 10.0003 10 10.0003C9.86732 10.0003 9.74007 9.94757 9.64625 9.85375C9.55243 9.75993 9.49972 9.63268 9.49972 9.5C9.49972 9.36732 9.55243 9.24007 9.64625 9.14625L11.7931 7H7C5.27665 6.99818 3.62441 6.31278 2.40582 5.09418C1.18722 3.87559 0.50182 2.22335 0.5 0.5C0.5 0.367392 0.552678 0.240215 0.646447 0.146447C0.740215 0.0526785 0.867392 0 1 0C1.13261 0 1.25979 0.0526785 1.35355 0.146447C1.44732 0.240215 1.5 0.367392 1.5 0.5C1.50165 1.95818 2.08165 3.35617 3.11274 4.38726C4.14383 5.41835 5.54182 5.99835 7 6H11.7931L9.64625 3.85375C9.55243 3.75993 9.49972 3.63268 9.49972 3.5C9.49972 3.36732 9.55243 3.24007 9.64625 3.14625C9.74007 3.05243 9.86732 2.99972 10 2.99972C10.1327 2.99972 10.2599 3.05243 10.3538 3.14625L13.3538 6.14625C13.4002 6.19269 13.4371 6.24783 13.4623 6.30853C13.4874 6.36923 13.5004 6.43429 13.5004 6.5C13.5004 6.56571 13.4874 6.63077 13.4623 6.69147C13.4371 6.75217 13.4002 6.80731 13.3538 6.85375Z",fill:"var(--color-brand-500, #5048ED)"})}):o.jsx("span",{className:"hidden"})}),o.jsx("span",{className:`text-xs ${D?"text-[var(--color-brand-500,#5048ED)]":"text-[var(--color-gray-700,#414651)]"}`,children:x.name})]})},F)})})]},S.name)})}),k&&!P&&o.jsx("div",{className:"custom-menu-content",style:{paddingTop:"8px"},children:k})]}))}),C&&o.jsx("div",{className:"navbar-bottom-content",style:{marginTop:"auto",flexShrink:0},children:C})]})},hd=(e=!0)=>{const[t,r]=h.useState(null),[s,n]=h.useState(!1),[a,i]=h.useState(null),[l,u]=h.useState(!1),[c,d]=h.useState(!1),f=async()=>{if(!(!e||t&&!l)){n(!0),i(null);try{const g=await js();if(g.success&&g.response){const p=g.response.profile_data||g.response;g.response.password_policy&&!p.password_policy&&(p.password_policy=g.response.password_policy),d(g.response.should_set_password||!1),r(p),i(null)}else{const p=g.response?.message||"Failed to fetch profile data";i(p),console.error("Profile API Error:",g)}}catch(g){const p=g.message||"Network error while fetching profile";i(p),console.error("Profile fetch error:",g)}finally{n(!1),u(!0)}}},m=()=>{u(!1),f()};return h.useEffect(()=>{e&&!l&&f()},[e]),{profileData:t,loading:s,error:a,refetch:m,shouldSetPassword:c}},Ve=(e,t="/",r=null)=>{let s=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t};`;r&&(s+=` domain=${r};`),document.cookie=s,r||(document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t}; domain=${window.location.hostname};`,document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t};`)},ts=e=>{const t=e+"=",r=document.cookie.split(";");for(let s=0;s<r.length;s++){let n=r[s];for(;n.charAt(0)===" ";)n=n.substring(1,n.length);if(n.indexOf(t)===0)return n.substring(t.length,n.length)}return null},Mn=(e,t,r=null,s="/",n=null)=>{let a="";if(r){const l=new Date;l.setTime(l.getTime()+r*24*60*60*1e3),a="; expires="+l.toUTCString()}let i=`${e}=${t}${a}; path=${s}`;n&&(i+=`; domain=${n}`),document.cookie=i},In=()=>{const e=ts("zangocookie");return e!==null&&e!==""},Un=Object.freeze({__proto__:null,deleteCookie:Ve,getCookie:ts,isAuthenticatedViaCookie:In,setCookie:Mn}),rs=async(e={})=>{try{const t=await Gs();if(t.success||t.responseStatus===401){Ve("zangocookie","/"),Ve("zangocookie","/app"),Ve("zangocookie","/app/"),Ve("zangocookie");const r=window.location.hostname;if(Ve("zangocookie","/",r),Ve("zangocookie","/app",r),r.includes(".")){const a="."+r.split(".").slice(-2).join(".");Ve("zangocookie","/",a),Ve("zangocookie","/app",a)}localStorage.removeItem("authToken"),localStorage.clear(),sessionStorage.clear();const s=e.redirectUrl||e.theme?.login_url||"/app/login";let n=s;if(e.preserveCurrentPath){const a=window.location.pathname+window.location.search,i=s.includes("?")?"&":"?";n=`${s}${i}next=${encodeURIComponent(a)}`}setTimeout(()=>{window.location.href=n},100)}else y.toast.error({title:"Logout Failed",description:t.response?.message||"Unable to logout. Please try again.",duration:5e3})}catch(t){console.error("Logout error:",t),y.toast.error({title:"Logout Error",description:"An error occurred while logging out. Please try again.",duration:5e3});const r=e.redirectUrl||e.theme?.login_url||"/app/login";let s=r;if(e.preserveCurrentPath){const n=window.location.pathname+window.location.search,a=r.includes("?")?"&":"?";s=`${r}${a}next=${encodeURIComponent(n)}`}setTimeout(()=>{window.location.href=s},100)}},Dn=e=>{const t=document.createElement("div");t.style.cssText=`
143
148
  position: fixed;
144
149
  top: 0;
145
150
  left: 0;
@@ -187,10 +192,178 @@ export default App;`,m=`mkdir -p ${c}`,w={container:{padding:"32px",maxWidth:"90
187
192
  transition: all 0.2s;
188
193
  ">Log Out</button>
189
194
  </div>
190
- `;const o=r.querySelector("#cancel-logout"),a=r.querySelector("#confirm-logout");o.addEventListener("mouseenter",()=>{o.style.backgroundColor="#f9fafb",o.style.borderColor="#9ca3af"}),o.addEventListener("mouseleave",()=>{o.style.backgroundColor="white",o.style.borderColor="#d1d5db"}),a.addEventListener("mouseenter",()=>{a.style.backgroundColor="#b91c1c"}),a.addEventListener("mouseleave",()=>{a.style.backgroundColor="#dc2626"}),o.addEventListener("click",()=>{document.body.removeChild(t)}),a.addEventListener("click",()=>{document.body.removeChild(t),e()}),t.addEventListener("click",i=>{i.target===t&&document.body.removeChild(t)});const n=i=>{i.key==="Escape"&&(document.removeEventListener("keydown",n),document.body.contains(t)&&document.body.removeChild(t))};document.addEventListener("keydown",n),t.appendChild(r),document.body.appendChild(t),setTimeout(()=>o.focus(),100)},Bo=({isOpen:e,onClose:t})=>{const[r,o]=g.useState("account"),[a,n]=g.useState(!1),[i,c]=g.useState(!1),[d,l]=g.useState(null),[u,h]=g.useState(!1),[m,w]=g.useState([]),[f,x]=g.useState(!1),[y,P]=g.useState(null),[A,B]=g.useState([]),[N,H]=g.useState(null),{appData:S}=Pe(),{profileData:v,loading:C,error:F,refetch:D,shouldSetPassword:k}=yl(e),[U,I]=g.useState({name:"",email:"",mobile:"",roles:[],currentRole:"",lastPasswordChange:"Never",nextPasswordDue:null}),[j,L]=g.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[T,M]=g.useState({}),[E,Z]=g.useState({}),[Q,z]=g.useState(""),[_,J]=g.useState(!1),[V,K]=g.useState(null),[ee,ne]=g.useState({minLength:!1,hasUpperCase:!1,hasLowerCase:!1,hasNumber:!1,hasSpecialChar:!1}),ie=async()=>{x(!0),P(null);try{const O=await Hr();if(O.success&&O.response){const X=O.response.data||O.response;w(X),P(null)}else{const X=O.response?.message||"Failed to fetch sessions";P(X),console.error("Sessions API Error:",O)}}catch(O){const X=O.message||"Network error while fetching sessions";P(X),console.error("Sessions fetch error:",O)}finally{x(!1)}};g.useEffect(()=>{if(v){let O=v.last_password_changed||"Never",X=null;if(v.last_password_changed&&v?.password_policy?.password_expiry_days){const oe=new Date(v.last_password_changed),et=new Date(oe);et.setDate(et.getDate()+v.password_policy.password_expiry_days),et>new Date?X=et.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):X="Expired"}I({name:v.name||"",email:v.email||"",mobile:v.mobile||"",roles:v.roles||[],currentRole:S?.profile_info?.user_role||v.roles?.[0]?.name||"Admin",lastPasswordChange:O,nextPasswordDue:X}),h(v.auth_config?.two_factor_auth?.required||!1),v.profile_pic&&l(v.profile_pic);let R=null;v.auth_config?.password_policy?R=v.auth_config.password_policy:v.password_policy&&(R=v.password_policy),R?(console.log("Setting password policy from profileData.auth_config.password_policy:",R),H(R)):console.log("No password policy found in profileData:",{auth_config_password_policy:v.auth_config?.password_policy,password_policy:v.password_policy}),v.tokens&&B(v.tokens)}v&&v.tokens&&B(v.tokens),S?.sessions?.tokens&&B(S.sessions.tokens),S?.password_policy&&H(S.password_policy)},[v,S]);const me=(O,X)=>{const R=O.user_agent||O.browser_agent||"Unknown Browser",oe=O.ip||O.location||"Unknown Location",et=O.created_at,tt=O.last_seen_at,ql=we=>we.includes("Chrome")?"Chrome":we.includes("Firefox")?"Firefox":we.includes("Safari")?"Safari":we.includes("Edge")?"Edge":"Unknown Browser",Il=we=>we.includes("Mac")?"macOS":we.includes("Windows")?"Windows":we.includes("Linux")?"Linux":we.includes("iPhone")||we.includes("iOS")?"iOS":we.includes("Android")?"Android":"Unknown OS",zo=we=>{if(!we)return"Unknown";const Cr=we.replace(" IST",""),vr=new Date(Cr),jl=new Date().getTime()-vr.getTime(),qt=Math.floor(jl/1e3),It=Math.floor(qt/60),$t=Math.floor(It/60),xr=Math.floor($t/24);return xr>0?`${xr} day${xr>1?"s":""} ago`:$t>0?`${$t} hour${$t>1?"s":""} ago`:It>0?`${It} minute${It>1?"s":""} ago`:qt>0?`${qt} second${qt>1?"s":""} ago`:"Just now"},$l=ql(R),Wo=Il(R),Vl=()=>{if(O.is_current)return!0;if(!tt)return!1;const we=typeof tt=="string"?tt.replace(" IST",""):tt,Cr=new Date(we),vr=new Date(Date.now()-3600*1e3);return Cr>vr};return{...O,deviceName:`${$l} on ${Wo}`,os:Wo,location:oe==="127.0.0.1"?"Local Device":oe,sessionStartTime:zo(et),lastSeen:zo(tt),isActive:Vl()}};g.useEffect(()=>{const{newPassword:O}=j;console.log("Password validation useEffect triggered:",{newPassword:O,passwordPolicy:N}),N?(console.log("Using password policy for validation:",N),ne({minLength:O.length>=(N.min_length||8),hasUpperCase:N.require_uppercase?/[A-Z]/.test(O):!0,hasLowerCase:N.require_lowercase?/[a-z]/.test(O):!0,hasNumber:N.require_numbers?/[0-9]/.test(O):!0,hasSpecialChar:N.require_special_chars?/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(O):!0})):(console.log("No password policy found, using default validation"),ne({minLength:O.length>=8,hasUpperCase:/[A-Z]/.test(O),hasLowerCase:/[a-z]/.test(O),hasNumber:/[0-9]/.test(O),hasSpecialChar:/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(O)}))},[j.newPassword,N]);const[Ze,$e]=g.useState(e);g.useEffect(()=>{e&&!Ze&&(D&&D(),ie(),n(!1),c(!1),M({}),Z({}),z(""),L({currentPassword:"",newPassword:"",confirmPassword:""})),$e(e)},[e,Ze,D]),g.useEffect(()=>{r==="security"&&e&&ie()},[r,e]);const Ge=O=>{const{name:X,value:R}=O.target;I(oe=>({...oe,[X]:R})),M(oe=>({...oe,[X]:""}))},le=O=>{const{name:X,value:R}=O.target;L(oe=>({...oe,[X]:R})),Z(oe=>({...oe,[X]:""}))},Ee=()=>{const O={};return U.name.trim()||(O.name="Name is required"),O},br=async O=>{const X=O.target.files?.[0];if(X){const R=new FormData;R.append("profile_pic",X);try{const oe=await gt(R);oe.success?(l(oe.response?.profile_pic||URL.createObjectURL(X)),z("Profile photo updated successfully!")):z(oe.response?.message||"Failed to upload photo")}catch{z("Failed to upload photo")}}},Do=async()=>{try{const O=!u,X={two_factor_auth:{required:O}},R=new FormData;R.append("auth_config",JSON.stringify(X));const oe=await gt(R);oe.success?(h(O),z(`Two-factor authentication ${O?"enabled":"disabled"}`),p.toast.success({title:"Two-Factor Authentication Updated",description:`Two-factor authentication ${O?"enabled":"disabled"} successfully`,duration:3e3})):(z(oe.response?.message||"Failed to update two-factor authentication"),p.toast.error({title:"Update Failed",description:oe.response?.message||"Failed to update two-factor authentication",duration:5e3}))}catch{z("Failed to update two-factor authentication"),p.toast.error({title:"Update Error",description:"An error occurred while updating two-factor authentication",duration:5e3})}},Ho=async O=>{try{const X=await Zr(O);X.success?(ie(),z("Session logged out successfully")):z(X.response?.message||"Failed to logout session")}catch{z("Failed to logout session")}},El=async()=>{try{const O=m.filter(R=>!R.is_current).map(R=>R.id),X=await Gr(O);X.success?(z("All other sessions logged out successfully"),ie()):z(X.response?.message||"Failed to logout all sessions")}catch{z("Failed to logout all sessions")}},Fl=()=>{const O={};return!k&&!j.currentPassword&&(O.currentPassword="Current password is required"),j.newPassword?Object.values(ee).some(R=>!R)&&(O.newPassword="Password must meet all requirements"):O.newPassword=k?"Password is required":"New password is required",j.newPassword!==j.confirmPassword&&(O.confirmPassword="Passwords do not match"),O},Ol=async O=>{O.preventDefault();const X=Ee();if(Object.keys(X).length>0){M(X);return}J(!0),z("");try{const R=new FormData;R.append("name",U.name);const oe=await gt(R);oe.success?(z("Name updated successfully!"),n(!1),setTimeout(()=>{z("")},3e3)):z(oe.response?.message||"Failed to update name")}catch{z("An error occurred. Please try again.")}finally{J(!1)}},Ml=async O=>{O.preventDefault();const X=Fl();if(Object.keys(X).length>0){Z(X);return}J(!0),z("");try{const R={new_password:j.newPassword};k||(R.current_password=j.currentPassword);const oe=await zr(R);oe.success?(z(k?"Password set successfully!":"Password changed successfully!"),L({currentPassword:"",newPassword:"",confirmPassword:""}),c(!1),D&&D(),setTimeout(()=>{z("")},3e3)):z(oe.response?.message||"Failed to change password")}catch{z("An error occurred. Please try again.")}finally{J(!1)}},Ul=async O=>{K(O);try{const X=await Wr(O);X.success?(p.toast.success({title:"Role Switched",description:"Role switched successfully! Redirecting...",duration:2e3}),setTimeout(()=>{window.location.href="/app"},1e3)):(p.toast.error({title:"Role Switch Failed",description:X.response?.message||"Failed to switch role",duration:5e3}),K(null))}catch{p.toast.error({title:"Role Switch Error",description:"An error occurred while switching role",duration:5e3}),K(null)}},Bl=()=>{Uo(()=>{Mo({redirectUrl:"/app/login"})})};return s.jsxs("div",{className:`user-profile-drawer ${e?"open":""}`,children:[s.jsx("div",{className:"profile-header-gradient",children:s.jsx("button",{className:"profile-close-btn",onClick:t,children:s.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M18 6L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),C&&s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"2rem"},children:[s.jsx(p.Spin,{size:"large"}),s.jsx("span",{style:{marginLeft:"12px",color:"#6b7280"},children:"Loading profile..."})]}),_&&s.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:s.jsxs("div",{style:{backgroundColor:"white",padding:"2rem",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.1)"},children:[s.jsx(p.Spin,{size:"large"}),s.jsx("span",{style:{marginLeft:"12px",color:"#6b7280",fontSize:"16px"},children:"Updating password..."})]})}),F&&!C&&s.jsxs("div",{style:{margin:"1rem 1.5rem",padding:"1rem",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[s.jsx("svg",{style:{height:"20px",width:"20px",color:"#f87171",marginRight:"8px"},viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),s.jsx("span",{style:{color:"#b91c1c",fontWeight:"500"},children:"Failed to load profile"})]}),s.jsx("p",{style:{color:"#dc2626",fontSize:"14px",marginTop:"4px",marginBottom:"8px"},children:F}),s.jsx("button",{onClick:D,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}),!C&&!F&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"profile-info-section",children:[s.jsx("div",{className:"profile-avatar-container",children:s.jsxs("div",{className:"profile-avatar-circle",children:[d?s.jsx("img",{src:d,alt:"Profile",className:"profile-avatar-img"}):U.name?s.jsx("span",{className:"profile-initials",children:U.name.split(" ").map(O=>O[0]).join("").toUpperCase().slice(0,2)}):s.jsx("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M20 20C23.6819 20 26.6667 17.0152 26.6667 13.3333C26.6667 9.65143 23.6819 6.66667 20 6.66667C16.3181 6.66667 13.3333 9.65143 13.3333 13.3333C13.3333 17.0152 16.3181 20 20 20ZM20 20C13.3726 20 8 25.3726 8 32C8 33.1046 8.89543 34 10 34H30C31.1046 34 32 33.1046 32 32C32 25.3726 26.6274 20 20 20Z",stroke:"#6B7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),s.jsxs("label",{className:"profile-avatar-edit",children:[s.jsx("input",{type:"file",accept:"image/*",onChange:br,hidden:!0}),s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M2.52121 10.8728L2 14L5.12724 13.4788C5.67029 13.3883 6.1715 13.1304 6.56079 12.7411L13.6132 5.68859C14.1289 5.17281 14.1289 4.3366 13.6131 3.82084L12.1791 2.38682C11.6633 1.87105 10.8271 1.87106 10.3113 2.38685L3.25894 9.43933C2.86965 9.8286 2.61171 10.3298 2.52121 10.8728Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}),s.jsxs("div",{className:"profile-name-section",children:[s.jsx("h2",{className:"profile-user-name",children:U.name||"Welcome!"}),s.jsxs("div",{className:"profile-user-role-badge",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M9.5 6.5V4.5C9.5 3.39543 8.60457 2.5 7.5 2.5H6.5C5.39543 2.5 4.5 3.39543 4.5 4.5V6.5M3 6.5H11C11.5523 6.5 12 6.94772 12 7.5V10.5C12 11.0523 11.5523 11.5 11 11.5H3C2.44772 11.5 2 11.0523 2 10.5V7.5C2 6.94772 2.44772 6.5 3 6.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"7",cy:"9",r:"0.75",fill:"currentColor"})]}),s.jsx("span",{children:U.currentRole})]})]})]}),s.jsx("div",{className:"profile-main-content",children:s.jsxs("div",{className:"profile-content-wrapper",children:[s.jsxs("div",{className:"profile-tabs",children:[s.jsx("button",{className:`profile-tab ${r==="account"?"active":""}`,onClick:()=>{o("account"),n(!1),z("")},children:"Account"}),s.jsx("button",{className:`profile-tab ${r==="security"?"active":""}`,onClick:()=>{o("security"),c(!1),z("")},children:"Security"})]}),Q&&s.jsx("div",{className:`profile-alert ${Q.includes("successfully")?"success":"error"}`,children:s.jsx("span",{children:Q})}),T.general&&s.jsx("div",{className:"profile-alert error",children:s.jsx("span",{children:T.general})}),s.jsx("div",{className:"profile-tab-content",children:r==="account"?s.jsxs("div",{className:"account-section",children:[!U.name&&!U.email&&!U.mobile&&s.jsxs("div",{className:"welcome-banner",children:[s.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"rgba(80, 72, 237, 0.1)"}),s.jsx("path",{d:"M24 16V20M24 28H24.01M34 24C34 29.5228 29.5228 34 24 34C18.4772 34 14 29.5228 14 24C14 18.4772 18.4772 14 24 14C29.5228 14 34 18.4772 34 24Z",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("h3",{children:"Complete Your Profile"}),s.jsx("p",{children:"Add your name and other details to personalize your account. Click the edit button next to each field to get started."})]}),s.jsxs("div",{className:"profile-field-section",children:[s.jsxs("div",{className:"profile-field-header",children:[s.jsx("label",{className:"profile-field-label",children:"Name"}),!a&&s.jsx("button",{className:"profile-field-edit-btn",onClick:()=>n(!0),children:"Edit"})]}),a?s.jsxs("form",{onSubmit:Ol,className:"profile-inline-form",children:[s.jsx("input",{type:"text",name:"name",className:"profile-form-input",value:U.name,onChange:Ge,placeholder:"Enter your full name",autoFocus:!0}),s.jsxs("div",{className:"profile-inline-actions",children:[s.jsx("button",{type:"button",className:"profile-cancel-btn",onClick:()=>{n(!1),M({}),I(O=>({...O,name:v?.name||""}))},children:"Cancel"}),s.jsx("button",{type:"submit",className:"profile-save-btn",disabled:_,children:_?"Saving...":"Save"})]}),T.name&&s.jsx("div",{className:"profile-form-error",children:T.name})]}):s.jsx("div",{className:"profile-field-value",children:U.name||s.jsx("span",{className:"empty-value",children:"Click edit to add your name"})})]}),U.email&&s.jsxs("div",{className:"profile-field-section",children:[s.jsx("label",{className:"profile-field-label",children:"Email"}),s.jsxs("div",{className:"profile-field-value readonly",children:[s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"field-icon",children:s.jsx("path",{d:"M2.66667 5.33333L7.2786 8.60289C7.67788 8.86886 8.32212 8.86886 8.7214 8.60289L13.3333 5.33333M4 12H12C12.7364 12 13.3333 11.4031 13.3333 10.6667V5.33333C13.3333 4.59695 12.7364 4 12 4H4C3.26362 4 2.66667 4.59695 2.66667 5.33333V10.6667C2.66667 11.4031 3.26362 12 4 12Z",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})}),U.email]})]}),U.mobile&&s.jsxs("div",{className:"profile-field-section",children:[s.jsx("label",{className:"profile-field-label",children:"Mobile Number"}),s.jsxs("div",{className:"profile-field-value readonly",children:[s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"field-icon",children:s.jsx("path",{d:"M5.33333 2.66667H10.6667C11.4031 2.66667 12 3.26362 12 4V12C12 12.7364 11.4031 13.3333 10.6667 13.3333H5.33333C4.59695 13.3333 4 12.7364 4 12V4C4 3.26362 4.59695 2.66667 5.33333 2.66667ZM5.33333 2.66667V3.33333C5.33333 3.70152 5.63181 4 6 4H10C10.3682 4 10.6667 3.70152 10.6667 3.33333V2.66667M8 11.3333H8.00667",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})}),U.mobile]})]}),s.jsxs("div",{className:"profile-field-section",children:[s.jsx("label",{className:"profile-field-label",children:"Roles"}),s.jsx("div",{className:"roles-list",children:U.roles&&U.roles.length>0?U.roles.map((O,X)=>s.jsxs("div",{className:`role-item ${O.name===U.currentRole?"active":""}`,children:[s.jsxs("div",{className:"role-info",children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M10.6667 7V5C10.6667 3.89543 9.77124 3 8.66667 3H7.33333C6.22876 3 5.33333 3.89543 5.33333 5V7M4 7H12C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13H4C3.44772 13 3 12.5523 3 12V8C3 7.44772 3.44772 7 4 7Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"8",cy:"10",r:"0.75",fill:"currentColor"})]}),s.jsx("span",{className:"role-name",children:O.name})]}),O.name===U.currentRole?s.jsx("span",{className:"role-badge",children:"Current"}):s.jsx("button",{className:"role-switch-btn",onClick:()=>Ul(O.id),disabled:V!==null,children:V===O.id?"Switching...":"Switch"})]},O.id)):s.jsxs("div",{className:"role-item active",children:[s.jsxs("div",{className:"role-info",children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M10.6667 7V5C10.6667 3.89543 9.77124 3 8.66667 3H7.33333C6.22876 3 5.33333 3.89543 5.33333 5V7M4 7H12C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13H4C3.44772 13 3 12.5523 3 12V8C3 7.44772 3.44772 7 4 7Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"8",cy:"10",r:"0.75",fill:"currentColor"})]}),s.jsx("span",{className:"role-name",children:U.currentRole||"Admin"})]}),s.jsx("span",{className:"role-badge",children:"Current"})]})})]}),s.jsx("div",{className:"profile-field-section logout-section",children:s.jsxs("button",{className:"logout-button",onClick:Bl,children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M10 11.75C9.95093 12.9846 8.92207 14.0329 7.54373 13.9992C7.22307 13.9913 6.82673 13.8796 6.03408 13.656C4.12641 13.1179 2.47037 12.2135 2.07304 10.1877C2 9.81533 2 9.39627 2 8.5582V7.4418C2 6.60374 2 6.1847 2.07304 5.81231C2.47037 3.78643 4.12641 2.8821 6.03408 2.34402C6.82673 2.12042 7.22307 2.00863 7.54373 2.00079C8.92207 1.96707 9.95093 3.01538 10 4.25",stroke:"currentColor",strokeLinecap:"round"}),s.jsx("path",{d:"M14 7.99998H6.66663M14 7.99998C14 7.53318 12.6704 6.661 12.3333 6.33331M14 7.99998C14 8.46678 12.6704 9.33898 12.3333 9.66665",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("span",{children:"Log Out"})]})})]}):s.jsxs("div",{className:"security-section",children:[s.jsxs("div",{className:"security-block",children:[s.jsxs("div",{className:"security-header",children:[s.jsxs("div",{children:[s.jsxs("h4",{className:"security-title",children:["Password",N&&!N.allow_change&&s.jsx("span",{className:"password-disabled-badge",children:"Disabled"})]}),!k&&s.jsxs("p",{className:"security-subtitle",children:["Last changed: ",U.lastPasswordChange,U.nextPasswordDue&&s.jsxs(s.Fragment,{children:[" • ",s.jsxs("span",{className:U.nextPasswordDue==="Expired"?"password-expired":"",children:["Next due: ",U.nextPasswordDue]})]})]}),k&&s.jsx("p",{className:"security-subtitle",children:"Set your password to secure your account"})]}),!i&&N?.allow_change!==!1&&s.jsx("button",{className:"profile-field-edit-btn",onClick:()=>{c(!0),L({currentPassword:"",newPassword:"",confirmPassword:""}),Z({})},children:k?"Set Password":"Change Password"})]}),i&&s.jsxs("form",{onSubmit:Ml,className:"password-form",children:[!k&&s.jsxs("div",{className:"profile-form-group",children:[s.jsx("label",{className:"profile-form-label",children:"Current Password"}),s.jsx("input",{type:"password",name:"currentPassword",className:"profile-form-input",value:j.currentPassword,onChange:le,placeholder:"Enter current password",autoComplete:"new-password"}),E.currentPassword&&s.jsx("div",{className:"profile-form-error",children:E.currentPassword})]}),s.jsxs("div",{className:"profile-form-group",children:[s.jsx("label",{className:"profile-form-label",children:k?"Password":"New Password"}),s.jsx("input",{type:"password",name:"newPassword",className:"profile-form-input",value:j.newPassword,onChange:le,placeholder:k?"Enter password":"Enter new password",autoComplete:"new-password"}),E.newPassword&&s.jsx("div",{className:"profile-form-error",children:E.newPassword})]}),s.jsx("div",{className:"password-requirements",children:N&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`password-requirement ${ee.minLength?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsxs("span",{children:["Minimum ",N.min_length," characters"]})]}),N.require_uppercase&&s.jsxs("div",{className:`password-requirement ${ee.hasUpperCase?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One uppercase character"})]}),N.require_lowercase&&s.jsxs("div",{className:`password-requirement ${ee.hasLowerCase?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One lowercase character"})]}),N.require_numbers&&s.jsxs("div",{className:`password-requirement ${ee.hasNumber?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One number"})]}),N.require_special_chars&&s.jsxs("div",{className:`password-requirement ${ee.hasSpecialChar?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One special character"})]})]})}),s.jsxs("div",{className:"profile-form-group",children:[s.jsx("label",{className:"profile-form-label",children:"Confirm Password"}),s.jsx("input",{type:"password",name:"confirmPassword",className:"profile-form-input",value:j.confirmPassword,onChange:le,placeholder:k?"Confirm password":"Confirm new password",autoComplete:"new-password"}),E.confirmPassword&&s.jsx("div",{className:"profile-form-error",children:E.confirmPassword})]}),s.jsxs("div",{className:"profile-form-actions",children:[s.jsx("button",{type:"button",className:"profile-cancel-btn",onClick:()=>{c(!1),Z({}),L({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),s.jsx("button",{type:"submit",className:"profile-submit-btn",disabled:_,children:_?k?"Setting...":"Updating...":k?"Set Password":"Update Password"})]})]})]}),s.jsx("div",{className:"security-block",children:s.jsxs("div",{className:"security-header",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"security-title",children:"Two-Factor Authentication"}),s.jsxs("p",{className:"security-subtitle",children:[u?"Enabled":"Disabled"," ",u?"":" - Add an extra layer of security"]}),!u&&v?.auth_config?.two_factor_auth?.can_enable===!1&&v?.auth_config?.two_factor_auth?.issue&&s.jsx("p",{style:{color:"#dc2626",fontSize:"14px",marginTop:"8px"},children:v.auth_config.two_factor_auth.issue})]}),!u&&v?.auth_config?.two_factor_auth?.can_enable===!0&&s.jsx("button",{className:"toggle-btn",onClick:Do,children:"Enable"}),u&&v?.auth_config?.two_factor_auth?.can_disable===!0&&s.jsx("button",{className:"toggle-btn enabled",onClick:Do,children:"Disable"})]})}),s.jsxs("div",{className:"security-block",children:[s.jsx("div",{className:"security-header",children:s.jsxs("div",{children:[s.jsx("h4",{className:"security-title",children:"Where you're logged in"}),s.jsx("p",{className:"security-subtitle",children:"Manage your active sessions"})]})}),s.jsx("div",{className:"sessions-list",children:f?s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"2rem"},children:[s.jsx(p.Spin,{size:"small"}),s.jsx("span",{style:{marginLeft:"8px",color:"#6b7280"},children:"Loading sessions..."})]}):y?s.jsxs("div",{style:{padding:"1rem",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",textAlign:"center"},children:[s.jsx("p",{style:{color:"#b91c1c",margin:"0 0 8px 0"},children:"Failed to load sessions"}),s.jsx("p",{style:{color:"#dc2626",fontSize:"14px",margin:"0 0 8px 0"},children:y}),s.jsx("button",{onClick:ie,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}):m.length>0?m.map((O,X)=>{const R=me(O);return s.jsxs("div",{className:"session-item",children:[s.jsx("div",{className:"session-info",children:s.jsxs("div",{className:"session-device",children:[s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M2.5 4.16667C2.5 3.24619 3.24619 2.5 4.16667 2.5H15.8333C16.7538 2.5 17.5 3.24619 17.5 4.16667V12.5C17.5 13.4205 16.7538 14.1667 15.8333 14.1667H4.16667C3.24619 14.1667 2.5 13.4205 2.5 12.5V4.16667Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6.66667 17.5H13.3333",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 14.1667V17.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"session-device-header",children:[s.jsx("p",{className:"session-device-name",children:R.deviceName}),O.is_current?s.jsx("span",{className:"session-status-tag current",children:"Current"}):R.isActive?s.jsx("button",{className:"logout-tag-btn logout-tag-btn-ghost",onClick:()=>Ho(O.id),children:"Logout"}):s.jsx("button",{className:"logout-tag-btn",onClick:()=>Ho(O.id),children:"Logout"})]}),s.jsxs("p",{className:"session-details",children:[R.os," • ",R.location]})]})]})}),s.jsx("div",{className:"session-time",children:s.jsxs("div",{className:"session-time-info",children:[s.jsxs("p",{className:"session-start-time",children:["Started: ",R.sessionStartTime]}),s.jsx("p",{className:"session-last-active",children:R.isActive?"Active now":`Last seen: ${R.lastSeen}`})]})})]},O.id||X)}):s.jsx("p",{className:"no-sessions",children:"No active sessions found"})}),m.length>1&&s.jsx("button",{className:"logout-all-btn",onClick:El,children:"Sign me out of all other sessions"})]}),s.jsxs("div",{className:"security-block",children:[s.jsx("div",{className:"security-header",children:s.jsxs("div",{children:[s.jsx("h4",{className:"security-title",children:"Authentication Tokens"}),s.jsx("p",{className:"security-subtitle",children:"Manage your bearer tokens for API authentication"})]})}),s.jsx("div",{className:"tokens-list",children:A&&A.length>0?A.map((O,X)=>s.jsx("div",{className:"token-item",children:s.jsx("div",{className:"token-info",children:s.jsxs("div",{className:"token-details",children:[s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M15 8.33333V6.66667C15 4.08934 12.9107 2 10.3333 2H9.66667C7.08934 2 5 4.08934 5 6.66667V8.33333M6.66667 8.33333H13.3333C14.2538 8.33333 15 9.07953 15 10V15C15 15.9205 14.2538 16.6667 13.3333 16.6667H6.66667C5.74619 16.6667 5 15.9205 5 15V10C5 9.07953 5.74619 8.33333 6.66667 8.33333Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"10",cy:"12.5",r:"1.25",fill:"currentColor"})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"token-name",children:[O.role," - Bearer Token"]}),s.jsx("p",{className:"token-type",children:"Type: Bearer Authentication Token"}),s.jsxs("p",{className:"token-created",children:["Created: ",new Date(O.created).toLocaleDateString()]}),O.expiry?s.jsxs("p",{className:"token-expiry",children:["Expires: ",new Date(O.expiry).toLocaleDateString()]}):s.jsx("p",{className:"token-expiry",children:"Expires: Never"})]})]})})},X)):s.jsxs("div",{className:"no-tokens",children:[s.jsx("p",{children:"No authentication tokens found"}),s.jsx("p",{className:"no-tokens-hint",children:"Bearer tokens will appear here for API authentication"})]})})]})]})})]})})]})]})},bl=({onLogout:e,className:t=""})=>s.jsxs("a",{className:`dropdown-item profile-logout ${t}`,href:"#",onClick:r=>{r.preventDefault(),e()},children:[s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("path",{d:"M10 11.75C9.95093 12.9846 8.92207 14.0329 7.54373 13.9992C7.22307 13.9913 6.82673 13.8796 6.03408 13.656C4.12641 13.1179 2.47037 12.2135 2.07304 10.1877C2 9.81533 2 9.39627 2 8.5582V7.4418C2 6.60374 2 6.1847 2.07304 5.81231C2.47037 3.78643 4.12641 2.8821 6.03408 2.34402C6.82673 2.12042 7.22307 2.00863 7.54373 2.00079C8.92207 1.96707 9.95093 3.01538 10 4.25",stroke:"#717680",strokeLinecap:"round"}),s.jsx("path",{d:"M14 7.99998H6.66663M14 7.99998C14 7.53318 12.6704 6.661 12.3333 6.33331M14 7.99998C14 8.46678 12.6704 9.33898 12.3333 9.66665",stroke:"#717680",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("span",{className:"profile-name",children:"Log Out"})]}),Cl=({onViewProfile:e,className:t=""})=>s.jsxs("a",{className:`dropdown-item profile-view ${t}`,href:"#",onClick:r=>{r.preventDefault(),e()},children:[s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("path",{d:"M8.00004 7.33329C9.47281 7.33329 10.6667 6.13948 10.6667 4.66663C10.6667 3.19377 9.47281 1.99996 8.00004 1.99996C6.52719 1.99996 5.33337 3.19377 5.33337 4.66663C5.33337 6.13948 6.52719 7.33329 8.00004 7.33329Z",stroke:"#717680",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M4.00004 14V12.6666C4.00004 11.9594 4.28099 11.2811 4.78109 10.781C5.28119 10.2809 5.95947 9.99996 6.66671 9.99996H9.33337C10.0406 9.99996 10.7189 10.2809 11.219 10.781C11.7191 11.2811 12 11.9594 12 12.6666V14",stroke:"#717680",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("span",{className:"profile-name",children:"View Profile"})]}),qo=({profileInfo:e,theme:t={},config:r={}})=>{const[o,a]=g.useState(!1),[n,i]=g.useState(!1),[c,d]=g.useState(!1),[l,u]=g.useState(null),h=g.useRef(null);G.useNavigate(),g.useEffect(()=>{const T=M=>{h.current&&!h.current.contains(M.target)&&(a(!1),i(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const m=()=>{a(!o),o||i(!1)},w=()=>{Uo(()=>{Mo({theme:t})})},f=T=>{window.location.href=T},x=e?.current_role||e?.user_role,y=e?.other_roles||[],{showProfile:P=!0,showLeftSection:A=!0,showRightSection:B=!0,customLeftContent:N=null,customRightContent:H=null,customProfileMenu:S=null,customViewProfile:v=null,profileMenuConfig:C={},className:F="",style:D={}}=r,{showViewProfile:k=!0,showLogout:U=!0,showRoleSwitch:I=!0,customMenuItems:j=[]}=C,L=()=>{d(!0),a(!1)};return s.jsxs("header",{className:`topbar header-container ${F}`,style:D,children:[s.jsxs("div",{className:"topbar-content",children:[A&&s.jsx("div",{className:"topbar-left",children:N||null}),B&&s.jsxs("div",{className:"topbar-right",children:[H,P&&s.jsxs("div",{className:"dropdown profile-dropdown-container",ref:h,children:[s.jsxs("div",{className:"profile-dropdown-menu-button",onClick:m,children:[s.jsxs("div",{className:"profile-info-wrapper",children:[s.jsx("img",{src:e?.profile_pic||`https://ui-avatars.com/api/?name=${encodeURIComponent(e?.name||"User")}&background=${as("brand",500).split("#")[1]}&color=fff`,alt:"Profile",className:"profile-avatar"}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"profile-name",children:e?.name||"User"}),s.jsx("span",{className:"text-[12px] text-gray-600",children:x})]})]}),s.jsx("svg",{className:`dropdown-arrow ${o?"open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M13.3538 6.35354L8.35378 11.3535C8.30735 11.4 8.2522 11.4369 8.1915 11.4621C8.13081 11.4872 8.06574 11.5002 8.00003 11.5002C7.93433 11.5002 7.86926 11.4872 7.80856 11.4621C7.74786 11.4369 7.69272 11.4 7.64628 11.3535L2.64628 6.35354C2.55246 6.25972 2.49976 6.13247 2.49976 5.99979C2.49976 5.86711 2.55246 5.73986 2.64628 5.64604C2.7401 5.55222 2.86735 5.49951 3.00003 5.49951C3.13272 5.49951 3.25996 5.55222 3.35378 5.64604L8.00003 10.2929L12.6463 5.64604C12.6927 5.59958 12.7479 5.56273 12.8086 5.53759C12.8693 5.51245 12.9343 5.49951 13 5.49951C13.0657 5.49951 13.1308 5.51245 13.1915 5.53759C13.2522 5.56273 13.3073 5.59958 13.3538 5.64604C13.4002 5.69249 13.4371 5.74764 13.4622 5.80834C13.4874 5.86904 13.5003 5.93409 13.5003 5.99979C13.5003 6.06549 13.4874 6.13054 13.4622 6.19124C13.4371 6.25193 13.4002 6.30708 13.3538 6.35354Z",fill:"#414651"})})]}),s.jsxs("ul",{className:`profile-dropdown-menu ${o?"show":""}`,children:[y.length>0&&n&&s.jsx("li",{children:s.jsx("div",{className:"profile-roles complete-hidden-scroll-style",children:y.map((T,M)=>s.jsxs("div",{className:"dropdown-item profile-each-role",onClick:()=>f(T.url),children:[s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("g",{clipPath:"url(#clip0_1427_392)",children:s.jsx("path",{d:"M0.833374 7.99998C0.833374 4.04198 4.04204 0.833313 8.00004 0.833313C11.958 0.833313 15.1667 4.04198 15.1667 7.99998C15.1667 11.958 11.958 15.1666 8.00004 15.1666C4.04204 15.1666 0.833374 11.958 0.833374 7.99998ZM8.00004 1.83331C4.59404 1.83331 1.83337 4.59398 1.83337 7.99998C1.83337 9.58131 2.42804 11.0233 3.40671 12.1146L3.60604 11.7646C4.28871 10.5706 5.55871 9.83331 6.93471 9.83331H9.06604C10.4414 9.83331 11.7114 10.5706 12.394 11.7646L12.5934 12.114C13.572 11.0226 14.1667 9.58065 14.1667 7.99998C14.1667 4.59398 11.406 1.83331 8.00004 1.83331ZM11.8454 12.8206L11.5254 12.2606C11.0214 11.378 10.0827 10.8333 9.06604 10.8333H6.93471C5.91804 10.8333 4.97871 11.378 4.47471 12.2606L4.15471 12.8213C5.20871 13.6633 6.54537 14.1666 8.00004 14.1666C9.45471 14.1666 10.7914 13.6633 11.8454 12.8206ZM5.66671 6.33331C5.66671 5.04465 6.71137 3.99998 8.00004 3.99998C9.28871 3.99998 10.3334 5.04465 10.3334 6.33331C10.3334 7.62198 9.28871 8.66665 8.00004 8.66665C6.71137 8.66665 5.66671 7.62198 5.66671 6.33331ZM8.00004 4.99998C7.26337 4.99998 6.66671 5.59665 6.66671 6.33331C6.66671 7.06998 7.26337 7.66665 8.00004 7.66665C8.73671 7.66665 9.33337 7.06998 9.33337 6.33331C9.33337 5.59665 8.73671 4.99998 8.00004 4.99998Z",fill:"#717680"})}),s.jsx("defs",{children:s.jsx("clipPath",{id:"clip0_1427_392",children:s.jsx("rect",{width:"16",height:"16",fill:"white"})})})]}),s.jsx("span",{className:"label",children:T.label})]},M))})}),s.jsx("li",{children:s.jsx("hr",{className:"profile-dropdown-divider"})}),j.map((T,M)=>s.jsx("li",{children:T},M)),k&&s.jsx("li",{children:s.jsx(Cl,{onViewProfile:L})}),U&&s.jsx("li",{children:s.jsx(bl,{onLogout:w})})]})]})]})]}),v?v({user:e,isOpen:c,onClose:()=>d(!1)}):s.jsx(Bo,{isOpen:c,onClose:()=>d(!1),profileData:l})]})},vl={showTopbar:!0,showNavbar:!0,layoutType:"wide"},xl={showProfile:!0,showLeftSection:!0,showRightSection:!0,customLeftContent:null,customRightContent:null,customProfileMenu:null,customTopbar:null,customViewProfile:null,profileMenuConfig:{showViewProfile:!0,showLogout:!0,showRoleSwitch:!0,customMenuItems:[]},className:"",style:{}},Pl={showLogo:!0,showMenu:!0,isCollapsed:!1,collapsible:!1,customLogo:null,customMenuContent:null,customBottomContent:null,customNavbar:null,customMenu:null,menuConfig:{showIcons:!0,showSubmenus:!0,expandOnHover:!1,customMenuItemRenderer:null},className:"",style:{}},Bt=(e={},t={})=>{const r={...t};return Object.keys(e).forEach(o=>{if(e[o]===void 0||e[o]===null)return;e[o]&&(e[o].$$typeof||typeof e[o]=="function")||typeof e[o]=="function"||Array.isArray(e[o])?r[o]=e[o]:typeof e[o]=="object"&&typeof t[o]=="object"&&!Array.isArray(t[o])?r[o]=Bt(e[o],t[o]):r[o]=e[o]}),r},Io=()=>{const{loading:e,error:t,menu:r,profileInfo:o,appLogo:a,theme:n={},layoutConfig:i={},topbarConfig:c={},navbarConfig:d={},customComponents:l={}}=Pe(),u=G.useLocation(),h=Bt(i,vl),m=Bt(c,xl),w=Bt(d,Pl),f=()=>{const S=document.getElementById("contentSpinner");S&&S.classList.add("active")},x=()=>{const S=document.getElementById("contentSpinner");S&&S.classList.remove("active")};if(g.useEffect(()=>{f();const S=300,v=Date.now(),C=setTimeout(()=>{const F=Date.now()-v;F>=S?x():setTimeout(x,S-F)},500);return()=>{clearTimeout(C)}},[u.pathname]),g.useEffect(()=>(window.addEventListener("beforeunload",f),()=>{window.removeEventListener("beforeunload",f)}),[]),e)return s.jsx("div",{className:"layout-loading",children:"Loading..."});if(t)return s.jsxs("div",{className:"layout-error",children:["Error: ",t]});const y=h.layoutType||n?.layout||"wide",P=h.showNavbar&&n?.menu_config?.display_sidebar!==!1,A=h.showTopbar,B=l?.Layout,N=l?.Topbar||m.customTopbar,H=l?.Navbar||w.customNavbar;return B?s.jsx(B,{menu:r,profileInfo:o,appLogo:a,theme:n,layoutConfig:h,topbarConfig:m,navbarConfig:w,children:s.jsx(G.Outlet,{})}):s.jsx("div",{className:`layout layout-${y}`,children:s.jsxs("main",{className:"layout-wrapper",children:[P&&(H?s.jsx(H,{menuItems:r,appLogo:a,theme:n,config:w}):s.jsx(No,{menuItems:r,appLogo:a,theme:n,config:w})),s.jsxs("div",{className:"layout-main",style:{width:P?`calc(100vw - ${w.isCollapsed?"80px":"244px"})`:"100vw",transition:"width 0.3s ease"},children:[A&&(N?s.jsx(N,{profileInfo:o,theme:n,config:m}):s.jsx(qo,{profileInfo:o,theme:n,config:m})),s.jsxs("div",{className:"layout-content",children:[s.jsx("div",{className:"content-spinner-container",id:"contentSpinner",children:s.jsx("div",{className:"spinner",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[s.jsx("path",{d:"M32 5.33331V16",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 20.7999L50.9335 13.0665",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M48 32H58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 43.2L50.9335 50.9333",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M32 48V58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 50.9333L20.7997 43.2",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.33301 32H15.9997",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 13.0665L20.7997 20.7999",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),s.jsx(G.Outlet,{})]})]})]})})},Sl=(e,t,r)=>{const o=t[e]||t.default;if(o.handler)return o.handler(r);let a=o.propsBuilder?o.propsBuilder({...r,pageType:e}):{};o.includeBasePath!==!1&&r.matchedRoutePath&&(a={basePath:r.matchedRoutePath,...a});const i=o.component;return g.createElement(i,a)},ft=({customPages:e={},forceRoute:t})=>{const r=G.useLocation(),{routes:o,pageTypeRegistry:a,registryLoading:n,registryError:i,initializerEndpoint:c}=Pe(),d=at(),[l,u]=g.useState({pageType:null,customPagePath:null,matchedRoutePath:null,loading:!0});if(g.useEffect(()=>{u(y=>({...y,loading:!0})),(()=>{const y=r.pathname;if(t){u({pageType:t.page_type,customPagePath:t.component||null,matchedRoutePath:t.path,loading:!1});return}if(r.state&&r.state.page_type&&(r.state.page_type!=="custom"||r.state.custom_page_path)){let P=y;if(o&&o.length>0){for(const A of o)if(y===A.path||y.startsWith(A.path+"/")){P=A.path;break}}u({pageType:r.state.page_type,customPagePath:r.state.custom_page_path||null,matchedRoutePath:P,loading:!1});return}if(o&&o.length>0){const P=[...o].sort((A,B)=>{const N=A.path.split("/").filter(S=>S).length;return B.path.split("/").filter(S=>S).length-N});for(const A of P){let B=G.matchPath({path:A.path,exact:!0},y);if(!B&&y.startsWith(A.path+"/")){const N=A.path.endsWith("/*")?A.path:`${A.path}/*`;B=G.matchPath({path:N,exact:!1},y)}if(B){u({pageType:A.page_type,customPagePath:A.component||null,matchedRoutePath:A.path,loading:!1});return}}}u({pageType:"404",customPagePath:null,matchedRoutePath:null,loading:!1})})()},[r,o,t]),l.loading||n)return s.jsx("div",{className:"content-spinner-container active",children:s.jsx("div",{className:"spinner",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[s.jsx("path",{d:"M32 5.33331V16",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 20.7999L50.9335 13.0665",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M48 32H58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 43.2L50.9335 50.9333",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M32 48V58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 50.9333L20.7997 43.2",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.33301 32H15.9997",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 13.0665L20.7997 20.7999",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})})});if(i)return s.jsxs("div",{style:{padding:"24px",color:"#f04438"},children:["Failed to load page registry: ",i]});if(!a)return s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",textAlign:"center",padding:"24px"},children:s.jsxs("div",{style:{backgroundColor:"white",borderRadius:"12px",padding:"32px",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.05)",maxWidth:"500px",width:"100%",border:"1px solid #e1e3e6"},children:[s.jsx("h1",{style:{fontSize:"32px",margin:"0",color:"#f04438",fontWeight:"bold",lineHeight:"1"},children:"⚠️"}),s.jsx("h3",{style:{fontSize:"18px",margin:"12px 0",color:"#252b37",fontWeight:"600"},children:"Configuration Issue"}),s.jsx("p",{style:{fontSize:"14px",color:"#717680",marginBottom:"16px",lineHeight:"1.5"},children:"Unable to load page configuration from:"}),s.jsx("code",{style:{display:"block",backgroundColor:"#f9fafb",border:"1px solid #e1e3e6",borderRadius:"4px",padding:"8px 12px",fontSize:"12px",color:"#252b37",fontFamily:"Monaco, Menlo, monospace",marginBottom:"16px",wordBreak:"break-all"},children:c}),s.jsx("p",{style:{fontSize:"13px",color:"#8b909a",margin:"0"},children:"Please check your configuration or contact your administrator."})]})});const{pageType:h,customPagePath:m,matchedRoutePath:w}=l,f=`${h}-${m||"default"}-${w||"none"}`;return s.jsx("div",{className:"h-full",children:Sl(h,a,{matchedRoutePath:w,customPagePath:m,customPages:e,location:r,apiConfig:d})},f)},$o=()=>{const{metadata:e,appName:t,apiConfig:r,theme:o}=Pe(),a=g.useRef(new Set),n=()=>{a.current.forEach(d=>{d.parentNode&&d.parentNode.removeChild(d)}),a.current.clear()},i=(d,l,u)=>{let h=document.querySelector(d);return h||(h=l(),document.head.appendChild(h),a.current.add(h)),u(h),h},c=(d,l="image")=>new Promise((u,h)=>{const m=document.createElement("link");m.rel="preload",m.as=l,m.href=d,m.onload=()=>u(),m.onerror=()=>h(new Error(`Failed to preload ${l}: ${d}`)),a.current.add(m),document.head.appendChild(m),setTimeout(()=>{m.parentNode&&(m.parentNode.removeChild(m),a.current.delete(m))},1e4)});return g.useEffect(()=>{if(!e)return;n();const d=(l,u)=>{if(!l)return u||null;if(l.startsWith("http://")||l.startsWith("https://")||l.startsWith("//"))return l;try{return pt(l,r)}catch(h){return console.warn(`Failed to build asset URL for ${l}:`,h),u||null}};if(e.title?document.title=e.title:t&&(document.title=t),e.description&&i('meta[name="description"]',()=>{const l=document.createElement("meta");return l.name="description",l},l=>{l.content=e.description}),e.keywords&&i('meta[name="keywords"]',()=>{const l=document.createElement("meta");return l.name="keywords",l},l=>{l.content=e.keywords}),i('meta[name="viewport"]',()=>{const l=document.createElement("meta");return l.name="viewport",l},l=>{l.content="width=device-width, initial-scale=1.0"}),o?.colors?.primary&&i('meta[name="theme-color"]',()=>{const l=document.createElement("meta");return l.name="theme-color",l},l=>{l.content=o.colors.primary}),e.favicon){const l=d(e.favicon,"/favicon.ico");l&&i('link[rel="icon"][type="image/x-icon"], link[rel="shortcut icon"]',()=>{const u=document.createElement("link");return u.rel="icon",u.type="image/x-icon",u},u=>{u.href=l,c(l).catch(h=>console.warn("Failed to preload favicon:",h.message))})}if(e.favicon_png){const l=d(e.favicon_png,"/favicon-32x32.png");l&&i('link[rel="icon"][type="image/png"]',()=>{const u=document.createElement("link");return u.rel="icon",u.type="image/png",u.sizes="32x32",u},u=>{u.href=l,c(l).catch(h=>console.warn("Failed to preload PNG favicon:",h.message))})}if(e.apple_touch_icon){const l=d(e.apple_touch_icon,"/apple-touch-icon.png");l&&i('link[rel="apple-touch-icon"]',()=>{const u=document.createElement("link");return u.rel="apple-touch-icon",u},u=>{u.href=l,c(l).catch(h=>console.warn("Failed to preload Apple touch icon:",h.message))})}if(e.og_image){const l=d(e.og_image,"/og-image.png");l&&(c(l).catch(u=>console.warn("Failed to preload OG image:",u.message)),i('meta[property="og:image"]',()=>{const u=document.createElement("meta");return u.setAttribute("property","og:image"),u},u=>{u.content=l}),(e.og_image_alt||e.title)&&i('meta[property="og:image:alt"]',()=>{const u=document.createElement("meta");return u.setAttribute("property","og:image:alt"),u},u=>{u.content=e.og_image_alt||e.title||t||"Zango CRM"}))}if(i('meta[property="og:title"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:title"),l},l=>{l.content=e.title||t||"Zango CRM"}),e.description&&i('meta[property="og:description"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:description"),l},l=>{l.content=e.description}),i('meta[property="og:type"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:type"),l},l=>{l.content="website"}),i('meta[property="og:url"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:url"),l},l=>{l.content=window.location.href}),i('meta[name="twitter:card"]',()=>{const l=document.createElement("meta");return l.name="twitter:card",l},l=>{l.content=e.og_image?"summary_large_image":"summary"}),i('meta[name="twitter:title"]',()=>{const l=document.createElement("meta");return l.name="twitter:title",l},l=>{l.content=e.title||t||"Zango CRM"}),e.description&&i('meta[name="twitter:description"]',()=>{const l=document.createElement("meta");return l.name="twitter:description",l},l=>{l.content=e.description}),e.og_image){const l=d(e.og_image,"/og-image.png");l&&i('meta[name="twitter:image"]',()=>{const u=document.createElement("meta");return u.name="twitter:image",u},u=>{u.content=l})}if(i('link[rel="canonical"]',()=>{const l=document.createElement("link");return l.rel="canonical",l},l=>{l.href=window.location.href.split("?")[0]}),e.manifest||e.webmanifest){const l=d(e.manifest||e.webmanifest,"/manifest.json");l&&i('link[rel="manifest"]',()=>{const u=document.createElement("link");return u.rel="manifest",u},u=>{u.href=l})}return n},[e,t,o]),null},Vo=()=>{const e=G.useNavigate(),[t,r]=g.useState(null);return g.useEffect(()=>{(async()=>{try{const a=await Jr();a.success||a.responseStatus===401?setTimeout(()=>{e("/app/login")},1500):(r(a.response?.message||"An error occurred while logging out. Redirecting to login..."),setTimeout(()=>{e("/app/login")},2e3))}catch(a){console.error("Logout error:",a),r("An error occurred. Redirecting to login..."),setTimeout(()=>{e("/app/login")},2e3)}})()},[e]),s.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",backgroundColor:"#f5f5f5"},children:[s.jsx("div",{style:{backgroundColor:"white",padding:"40px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",textAlign:"center",maxWidth:"400px",width:"100%"},children:t?s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{marginBottom:"20px",color:"#ef4444"},children:s.jsx("svg",{width:"50",height:"50",fill:"none",viewBox:"0 0 24 24",style:{margin:"0 auto"},children:s.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsx("h2",{style:{fontSize:"24px",fontWeight:"600",marginBottom:"12px",color:"#333"},children:"Logout Error"}),s.jsx("p",{style:{fontSize:"16px",color:"#666",margin:0},children:t})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{marginBottom:"20px"},children:s.jsx("div",{style:{width:"50px",height:"50px",border:"3px solid #f3f3f3",borderTop:"3px solid var(--primary-color, #3b82f6)",borderRadius:"50%",margin:"0 auto",animation:"spin 1s linear infinite"}})}),s.jsx("h2",{style:{fontSize:"24px",fontWeight:"600",marginBottom:"12px",color:"#333"},children:"Logging you out..."}),s.jsx("p",{style:{fontSize:"16px",color:"#666",margin:0},children:"Please wait while we securely log you out."})]})}),s.jsx("style",{children:`
195
+ `;const s=r.querySelector("#cancel-logout"),n=r.querySelector("#confirm-logout");s.addEventListener("mouseenter",()=>{s.style.backgroundColor="#f9fafb",s.style.borderColor="#9ca3af"}),s.addEventListener("mouseleave",()=>{s.style.backgroundColor="white",s.style.borderColor="#d1d5db"}),n.addEventListener("mouseenter",()=>{n.style.backgroundColor="#b91c1c"}),n.addEventListener("mouseleave",()=>{n.style.backgroundColor="#dc2626"}),s.addEventListener("click",()=>{document.body.removeChild(t)}),n.addEventListener("click",()=>{document.body.removeChild(t),e()}),t.addEventListener("click",i=>{i.target===t&&document.body.removeChild(t)});const a=i=>{i.key==="Escape"&&(document.removeEventListener("keydown",a),document.body.contains(t)&&document.body.removeChild(t))};document.addEventListener("keydown",a),t.appendChild(r),document.body.appendChild(t),setTimeout(()=>s.focus(),100)},Bn=({isOpen:e,onClose:t})=>{const[r,s]=h.useState("account"),[n,a]=h.useState(!1),[i,l]=h.useState(!1),[u,c]=h.useState(null),[d,f]=h.useState(!1),[m,g]=h.useState(!0),[p,w]=h.useState([]),[b,k]=h.useState(!1),[C,M]=h.useState(null),[I,q]=h.useState([]),[E,_]=h.useState(null),{appData:P}=Ne(),{profileData:O,loading:W,error:S,refetch:U,shouldSetPassword:A}=hd(e),[L,v]=h.useState({name:"",email:"",mobile:"",roles:[],currentRole:"",lastPasswordChange:"Never",nextPasswordDue:null}),[x,F]=h.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[D,Y]=h.useState({}),[Z,J]=h.useState({}),[ee,$]=h.useState(""),[H,G]=h.useState(!1),[re,R]=h.useState(null),[ie,ue]=h.useState({minLength:!1,hasUpperCase:!1,hasLowerCase:!1,hasNumber:!1,hasSpecialChar:!1}),De=async()=>{k(!0),M(null);try{const V=await Hs();if(V.success&&V.response){const X=V.response.data||V.response;w(X),M(null)}else{const X=V.response?.message||"Failed to fetch sessions";M(X),console.error("Sessions API Error:",V)}}catch(V){const X=V.message||"Network error while fetching sessions";M(X),console.error("Sessions fetch error:",V)}finally{k(!1)}};h.useEffect(()=>{if(O){let V=O.last_password_changed||"Never",X=null;if(O.last_password_changed&&O?.password_policy?.password_expiry_days){const ms=new Date(O.last_password_changed),He=new Date(ms);He.setDate(He.getDate()+O.password_policy.password_expiry_days),He>new Date?X=He.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):X="Expired"}v({name:O.name||"",email:O.email||"",mobile:O.mobile||"",roles:O.roles||[],currentRole:P?.profile_info?.user_role||O.roles?.[0]?.name||"Admin",lastPasswordChange:V,nextPasswordDue:X}),f(O.auth_config?.two_factor_auth?.required||!1);const se=O?.can_set_password;g(se),O.profile_pic&&c(O.profile_pic);let ne=null;O.auth_config?.password_policy?ne=O.auth_config.password_policy:O.password_policy&&(ne=O.password_policy),ne&&_(ne),O.tokens&&q(O.tokens)}O&&O.tokens&&q(O.tokens),P?.sessions?.tokens&&q(P.sessions.tokens),P?.password_policy&&_(P.password_policy)},[O,P]);const ve=(V,X)=>{const se=V.user_agent||V.browser_agent||"Unknown Browser",ne=V.ip||V.location||"Unknown Location",ms=V.created_at,He=V.last_seen_at,Da=Ce=>Ce.includes("Chrome")?"Chrome":Ce.includes("Firefox")?"Firefox":Ce.includes("Safari")?"Safari":Ce.includes("Edge")?"Edge":"Unknown Browser",kf=Ce=>Ce.includes("Mac")?"macOS":Ce.includes("Windows")?"Windows":Ce.includes("Linux")?"Linux":Ce.includes("iPhone")||Ce.includes("iOS")?"iOS":Ce.includes("Android")?"Android":"Unknown OS",Ba=Ce=>{if(!Ce)return"Unknown";const ws=Ce.replace(" IST",""),ys=new Date(ws),_f=new Date().getTime()-ys.getTime(),vr=Math.floor(_f/1e3),Cr=Math.floor(vr/60),xr=Math.floor(Cr/60),bs=Math.floor(xr/24);return bs>0?`${bs} day${bs>1?"s":""} ago`:xr>0?`${xr} hour${xr>1?"s":""} ago`:Cr>0?`${Cr} minute${Cr>1?"s":""} ago`:vr>0?`${vr} second${vr>1?"s":""} ago`:"Just now"},Ef=Da(se),$a=kf(se),Af=()=>{if(V.is_current)return!0;if(!He)return!1;const Ce=typeof He=="string"?He.replace(" IST",""):He,ws=new Date(Ce),ys=new Date(Date.now()-3600*1e3);return ws>ys};return{...V,deviceName:`${Ef} on ${$a}`,os:$a,location:ne==="127.0.0.1"?"Local Device":ne,sessionStartTime:Ba(ms),lastSeen:Ba(He),isActive:Af()}};h.useEffect(()=>{const{newPassword:V}=x;ue(E?{minLength:V.length>=(E.min_length||8),hasUpperCase:E.require_uppercase?/[A-Z]/.test(V):!0,hasLowerCase:E.require_lowercase?/[a-z]/.test(V):!0,hasNumber:E.require_numbers?/[0-9]/.test(V):!0,hasSpecialChar:E.require_special_chars?/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(V):!0}:{minLength:V.length>=8,hasUpperCase:/[A-Z]/.test(V),hasLowerCase:/[a-z]/.test(V),hasNumber:/[0-9]/.test(V),hasSpecialChar:/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(V)})},[x.newPassword,E]);const[he,ce]=h.useState(e);h.useEffect(()=>{e&&!he&&(U&&U(),De(),a(!1),l(!1),Y({}),J({}),$(""),F({currentPassword:"",newPassword:"",confirmPassword:""})),ce(e)},[e,he,U]),h.useEffect(()=>{r==="security"&&e&&De()},[r,e]);const de=V=>{const{name:X,value:se}=V.target;v(ne=>({...ne,[X]:se})),Y(ne=>({...ne,[X]:""}))},Ct=V=>{const{name:X,value:se}=V.target;F(ne=>({...ne,[X]:se})),J(ne=>({...ne,[X]:""}))},wf=()=>{const V={};return L.name.trim()||(V.name="Name is required"),V},yf=async V=>{const X=V.target.files?.[0];if(X){const se=new FormData;se.append("profile_pic",X);try{const ne=await Bt(se);ne.success?(c(ne.response?.profile_pic||URL.createObjectURL(X)),$("Profile photo updated successfully!")):$(ne.response?.message||"Failed to upload photo")}catch{$("Failed to upload photo")}}},Ia=async()=>{try{const V=!d,X={two_factor_auth:{required:V}},se=new FormData;se.append("auth_config",JSON.stringify(X));const ne=await Bt(se);ne.success?(f(V),$(`Two-factor authentication ${V?"enabled":"disabled"}`),y.toast.success({title:"Two-Factor Authentication Updated",description:`Two-factor authentication ${V?"enabled":"disabled"} successfully`,duration:3e3})):($(ne.response?.message||"Failed to update two-factor authentication"),y.toast.error({title:"Update Failed",description:ne.response?.message||"Failed to update two-factor authentication",duration:5e3}))}catch{$("Failed to update two-factor authentication"),y.toast.error({title:"Update Error",description:"An error occurred while updating two-factor authentication",duration:5e3})}},Ua=async V=>{try{const X=await Ks(V);X.success?(De(),$("Session logged out successfully")):$(X.response?.message||"Failed to logout session")}catch{$("Failed to logout session")}},bf=async()=>{try{const V=p.filter(se=>!se.is_current).map(se=>se.id),X=await Zs(V);X.success?($("All other sessions logged out successfully"),De()):$(X.response?.message||"Failed to logout all sessions")}catch{$("Failed to logout all sessions")}},vf=()=>{const V={};return!A&&!x.currentPassword&&(V.currentPassword="Current password is required"),x.newPassword?Object.values(ie).some(se=>!se)&&(V.newPassword="Password must meet all requirements"):V.newPassword=A?"Password is required":"New password is required",x.newPassword!==x.confirmPassword&&(V.confirmPassword="Passwords do not match"),V},Cf=async V=>{V.preventDefault();const X=wf();if(Object.keys(X).length>0){Y(X);return}G(!0),$("");try{const se=new FormData;se.append("name",L.name);const ne=await Bt(se);ne.success?($("Name updated successfully!"),a(!1),setTimeout(()=>{$("")},3e3)):$(ne.response?.message||"Failed to update name")}catch{$("An error occurred. Please try again.")}finally{G(!1)}},xf=async V=>{V.preventDefault();const X=vf();if(Object.keys(X).length>0){J(X);return}G(!0),$("");try{const se={new_password:x.newPassword};A||(se.current_password=x.currentPassword);const ne=await zs(se);ne.success?($(A?"Password set successfully!":"Password changed successfully!"),F({currentPassword:"",newPassword:"",confirmPassword:""}),l(!1),U&&U(),setTimeout(()=>{$("")},3e3)):$(ne.response?.message||"Failed to change password")}catch{$("An error occurred. Please try again.")}finally{G(!1)}},Pf=async V=>{R(V);try{const X=await Ws(V);X.success?(y.toast.success({title:"Role Switched",description:"Role switched successfully! Redirecting...",duration:2e3}),setTimeout(()=>{window.location.href="/app"},1e3)):(y.toast.error({title:"Role Switch Failed",description:X.response?.message||"Failed to switch role",duration:5e3}),R(null))}catch{y.toast.error({title:"Role Switch Error",description:"An error occurred while switching role",duration:5e3}),R(null)}},Sf=()=>{Dn(()=>{rs({redirectUrl:"/app/login"})})};return o.jsxs("div",{className:`user-profile-drawer ${e?"open":""}`,children:[o.jsx("div",{className:"profile-header-gradient",children:o.jsx("button",{className:"profile-close-btn",onClick:t,children:o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M18 6L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),W&&o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"2rem"},children:[o.jsx(y.Spin,{size:"large"}),o.jsx("span",{style:{marginLeft:"12px",color:"#6b7280"},children:"Loading profile..."})]}),H&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:o.jsxs("div",{style:{backgroundColor:"white",padding:"2rem",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.1)"},children:[o.jsx(y.Spin,{size:"large"}),o.jsx("span",{style:{marginLeft:"12px",color:"#6b7280",fontSize:"16px"},children:"Updating password..."})]})}),S&&!W&&o.jsxs("div",{style:{margin:"1rem 1.5rem",padding:"1rem",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[o.jsx("svg",{style:{height:"20px",width:"20px",color:"#f87171",marginRight:"8px"},viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),o.jsx("span",{style:{color:"#b91c1c",fontWeight:"500"},children:"Failed to load profile"})]}),o.jsx("p",{style:{color:"#dc2626",fontSize:"14px",marginTop:"4px",marginBottom:"8px"},children:S}),o.jsx("button",{onClick:U,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}),!W&&!S&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"profile-info-section",children:[o.jsx("div",{className:"profile-avatar-container",children:o.jsxs("div",{className:"profile-avatar-circle",children:[u?o.jsx("img",{src:u,alt:"Profile",className:"profile-avatar-img"}):L.name?o.jsx("span",{className:"profile-initials",children:L.name.split(" ").map(V=>V[0]).join("").toUpperCase().slice(0,2)}):o.jsx("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M20 20C23.6819 20 26.6667 17.0152 26.6667 13.3333C26.6667 9.65143 23.6819 6.66667 20 6.66667C16.3181 6.66667 13.3333 9.65143 13.3333 13.3333C13.3333 17.0152 16.3181 20 20 20ZM20 20C13.3726 20 8 25.3726 8 32C8 33.1046 8.89543 34 10 34H30C31.1046 34 32 33.1046 32 32C32 25.3726 26.6274 20 20 20Z",stroke:"#6B7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),o.jsxs("label",{className:"profile-avatar-edit",children:[o.jsx("input",{type:"file",accept:"image/*",onChange:yf,hidden:!0}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M2.52121 10.8728L2 14L5.12724 13.4788C5.67029 13.3883 6.1715 13.1304 6.56079 12.7411L13.6132 5.68859C14.1289 5.17281 14.1289 4.3366 13.6131 3.82084L12.1791 2.38682C11.6633 1.87105 10.8271 1.87106 10.3113 2.38685L3.25894 9.43933C2.86965 9.8286 2.61171 10.3298 2.52121 10.8728Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}),o.jsxs("div",{className:"profile-name-section",children:[o.jsx("h2",{className:"profile-user-name",children:L.name||"Welcome!"}),o.jsxs("div",{className:"profile-user-role-badge",children:[o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M9.5 6.5V4.5C9.5 3.39543 8.60457 2.5 7.5 2.5H6.5C5.39543 2.5 4.5 3.39543 4.5 4.5V6.5M3 6.5H11C11.5523 6.5 12 6.94772 12 7.5V10.5C12 11.0523 11.5523 11.5 11 11.5H3C2.44772 11.5 2 11.0523 2 10.5V7.5C2 6.94772 2.44772 6.5 3 6.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("circle",{cx:"7",cy:"9",r:"0.75",fill:"currentColor"})]}),o.jsx("span",{children:L.currentRole})]})]})]}),o.jsx("div",{className:"profile-main-content",children:o.jsxs("div",{className:"profile-content-wrapper",children:[o.jsxs("div",{className:"profile-tabs",children:[o.jsx("button",{className:`profile-tab ${r==="account"?"active":""}`,onClick:()=>{s("account"),a(!1),$("")},children:"Account"}),o.jsx("button",{className:`profile-tab ${r==="security"?"active":""}`,onClick:()=>{s("security"),l(!1),$("")},children:"Security"})]}),ee&&o.jsx("div",{className:`profile-alert ${ee.includes("successfully")?"success":"error"}`,children:o.jsx("span",{children:ee})}),D.general&&o.jsx("div",{className:"profile-alert error",children:o.jsx("span",{children:D.general})}),o.jsx("div",{className:"profile-tab-content",children:r==="account"?o.jsxs("div",{className:"account-section",children:[!L.name&&!L.email&&!L.mobile&&o.jsxs("div",{className:"welcome-banner",children:[o.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"rgba(80, 72, 237, 0.1)"}),o.jsx("path",{d:"M24 16V20M24 28H24.01M34 24C34 29.5228 29.5228 34 24 34C18.4772 34 14 29.5228 14 24C14 18.4772 18.4772 14 24 14C29.5228 14 34 18.4772 34 24Z",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),o.jsx("h3",{children:"Complete Your Profile"}),o.jsx("p",{children:"Add your name and other details to personalize your account. Click the edit button next to each field to get started."})]}),o.jsxs("div",{className:"profile-field-section",children:[o.jsxs("div",{className:"profile-field-header",children:[o.jsx("label",{className:"profile-field-label",children:"Name"}),!n&&o.jsx("button",{className:"profile-field-edit-btn",onClick:()=>a(!0),children:"Edit"})]}),n?o.jsxs("form",{onSubmit:Cf,className:"profile-inline-form",children:[o.jsx("input",{type:"text",name:"name",className:"profile-form-input",value:L.name,onChange:de,placeholder:"Enter your full name",autoFocus:!0}),o.jsxs("div",{className:"profile-inline-actions",children:[o.jsx("button",{type:"button",className:"profile-cancel-btn",onClick:()=>{a(!1),Y({}),v(V=>({...V,name:O?.name||""}))},children:"Cancel"}),o.jsx("button",{type:"submit",className:"profile-save-btn",disabled:H,children:H?"Saving...":"Save"})]}),D.name&&o.jsx("div",{className:"profile-form-error",children:D.name})]}):o.jsx("div",{className:"profile-field-value",children:L.name||o.jsx("span",{className:"empty-value",children:"Click edit to add your name"})})]}),L.email&&o.jsxs("div",{className:"profile-field-section",children:[o.jsx("label",{className:"profile-field-label",children:"Email"}),o.jsxs("div",{className:"profile-field-value readonly",children:[o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"field-icon",children:o.jsx("path",{d:"M2.66667 5.33333L7.2786 8.60289C7.67788 8.86886 8.32212 8.86886 8.7214 8.60289L13.3333 5.33333M4 12H12C12.7364 12 13.3333 11.4031 13.3333 10.6667V5.33333C13.3333 4.59695 12.7364 4 12 4H4C3.26362 4 2.66667 4.59695 2.66667 5.33333V10.6667C2.66667 11.4031 3.26362 12 4 12Z",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})}),L.email]})]}),L.mobile&&o.jsxs("div",{className:"profile-field-section",children:[o.jsx("label",{className:"profile-field-label",children:"Mobile Number"}),o.jsxs("div",{className:"profile-field-value readonly",children:[o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"field-icon",children:o.jsx("path",{d:"M5.33333 2.66667H10.6667C11.4031 2.66667 12 3.26362 12 4V12C12 12.7364 11.4031 13.3333 10.6667 13.3333H5.33333C4.59695 13.3333 4 12.7364 4 12V4C4 3.26362 4.59695 2.66667 5.33333 2.66667ZM5.33333 2.66667V3.33333C5.33333 3.70152 5.63181 4 6 4H10C10.3682 4 10.6667 3.70152 10.6667 3.33333V2.66667M8 11.3333H8.00667",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})}),L.mobile]})]}),o.jsxs("div",{className:"profile-field-section",children:[o.jsx("label",{className:"profile-field-label",children:"Roles"}),o.jsx("div",{className:"roles-list",children:L.roles&&L.roles.length>0?L.roles.map((V,X)=>o.jsxs("div",{className:`role-item ${V.name===L.currentRole?"active":""}`,children:[o.jsxs("div",{className:"role-info",children:[o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M10.6667 7V5C10.6667 3.89543 9.77124 3 8.66667 3H7.33333C6.22876 3 5.33333 3.89543 5.33333 5V7M4 7H12C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13H4C3.44772 13 3 12.5523 3 12V8C3 7.44772 3.44772 7 4 7Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("circle",{cx:"8",cy:"10",r:"0.75",fill:"currentColor"})]}),o.jsx("span",{className:"role-name",children:V.name})]}),V.name===L.currentRole?o.jsx("span",{className:"role-badge",children:"Current"}):o.jsx("button",{className:"role-switch-btn",onClick:()=>Pf(V.id),disabled:re!==null,children:re===V.id?"Switching...":"Switch"})]},V.id)):o.jsxs("div",{className:"role-item active",children:[o.jsxs("div",{className:"role-info",children:[o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M10.6667 7V5C10.6667 3.89543 9.77124 3 8.66667 3H7.33333C6.22876 3 5.33333 3.89543 5.33333 5V7M4 7H12C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13H4C3.44772 13 3 12.5523 3 12V8C3 7.44772 3.44772 7 4 7Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("circle",{cx:"8",cy:"10",r:"0.75",fill:"currentColor"})]}),o.jsx("span",{className:"role-name",children:L.currentRole||"Admin"})]}),o.jsx("span",{className:"role-badge",children:"Current"})]})})]}),o.jsx("div",{className:"profile-field-section logout-section",children:o.jsxs("button",{className:"logout-button",onClick:Sf,children:[o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M10 11.75C9.95093 12.9846 8.92207 14.0329 7.54373 13.9992C7.22307 13.9913 6.82673 13.8796 6.03408 13.656C4.12641 13.1179 2.47037 12.2135 2.07304 10.1877C2 9.81533 2 9.39627 2 8.5582V7.4418C2 6.60374 2 6.1847 2.07304 5.81231C2.47037 3.78643 4.12641 2.8821 6.03408 2.34402C6.82673 2.12042 7.22307 2.00863 7.54373 2.00079C8.92207 1.96707 9.95093 3.01538 10 4.25",stroke:"currentColor",strokeLinecap:"round"}),o.jsx("path",{d:"M14 7.99998H6.66663M14 7.99998C14 7.53318 12.6704 6.661 12.3333 6.33331M14 7.99998C14 8.46678 12.6704 9.33898 12.3333 9.66665",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]}),o.jsx("span",{children:"Log Out"})]})})]}):o.jsxs("div",{className:"security-section",children:[m&&o.jsxs("div",{className:"security-block",children:[o.jsxs("div",{className:"security-header",children:[o.jsxs("div",{children:[o.jsxs("h4",{className:"security-title",children:["Password",E&&!E.allow_change&&o.jsx("span",{className:"password-disabled-badge",children:"Disabled"})]}),!A&&o.jsxs("p",{className:"security-subtitle",children:["Last changed: ",L.lastPasswordChange,L.nextPasswordDue&&o.jsxs(o.Fragment,{children:[" • ",o.jsxs("span",{className:L.nextPasswordDue==="Expired"?"password-expired":"",children:["Next due: ",L.nextPasswordDue]})]})]}),A&&o.jsx("p",{className:"security-subtitle",children:"Set your password to secure your account"})]}),!i&&E?.allow_change!==!1&&o.jsx("button",{className:"profile-field-edit-btn",onClick:()=>{l(!0),F({currentPassword:"",newPassword:"",confirmPassword:""}),J({})},children:A?"Set Password":"Change Password"})]}),i&&o.jsxs("form",{onSubmit:xf,className:"password-form",children:[!A&&o.jsxs("div",{className:"profile-form-group",children:[o.jsx("label",{className:"profile-form-label",children:"Current Password"}),o.jsx("input",{type:"password",name:"currentPassword",className:"profile-form-input",value:x.currentPassword,onChange:Ct,placeholder:"Enter current password",autoComplete:"new-password"}),Z.currentPassword&&o.jsx("div",{className:"profile-form-error",children:Z.currentPassword})]}),o.jsxs("div",{className:"profile-form-group",children:[o.jsx("label",{className:"profile-form-label",children:A?"Password":"New Password"}),o.jsx("input",{type:"password",name:"newPassword",className:"profile-form-input",value:x.newPassword,onChange:Ct,placeholder:A?"Enter password":"Enter new password",autoComplete:"new-password"}),Z.newPassword&&o.jsx("div",{className:"profile-form-error",children:Z.newPassword})]}),o.jsx("div",{className:"password-requirements",children:E&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`password-requirement ${ie.minLength?"met":""}`,children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),o.jsxs("span",{children:["Minimum ",E.min_length," characters"]})]}),E.require_uppercase&&o.jsxs("div",{className:`password-requirement ${ie.hasUpperCase?"met":""}`,children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),o.jsx("span",{children:"One uppercase character"})]}),E.require_lowercase&&o.jsxs("div",{className:`password-requirement ${ie.hasLowerCase?"met":""}`,children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),o.jsx("span",{children:"One lowercase character"})]}),E.require_numbers&&o.jsxs("div",{className:`password-requirement ${ie.hasNumber?"met":""}`,children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),o.jsx("span",{children:"One number"})]}),E.require_special_chars&&o.jsxs("div",{className:`password-requirement ${ie.hasSpecialChar?"met":""}`,children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),o.jsx("span",{children:"One special character"})]})]})}),o.jsxs("div",{className:"profile-form-group",children:[o.jsx("label",{className:"profile-form-label",children:"Confirm Password"}),o.jsx("input",{type:"password",name:"confirmPassword",className:"profile-form-input",value:x.confirmPassword,onChange:Ct,placeholder:A?"Confirm password":"Confirm new password",autoComplete:"new-password"}),Z.confirmPassword&&o.jsx("div",{className:"profile-form-error",children:Z.confirmPassword})]}),o.jsxs("div",{className:"profile-form-actions",children:[o.jsx("button",{type:"button",className:"profile-cancel-btn",onClick:()=>{l(!1),J({}),F({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),o.jsx("button",{type:"submit",className:"profile-submit-btn",disabled:H,children:H?A?"Setting...":"Updating...":A?"Set Password":"Update Password"})]})]})]}),o.jsx("div",{className:"security-block",children:o.jsxs("div",{className:"security-header",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"security-title",children:"Two-Factor Authentication"}),o.jsxs("p",{className:"security-subtitle",children:[d?"Enabled":"Disabled"," ",d?"":" - Add an extra layer of security"]}),!d&&O?.auth_config?.two_factor_auth?.can_enable===!1&&O?.auth_config?.two_factor_auth?.issue&&o.jsx("p",{style:{color:"#dc2626",fontSize:"14px",marginTop:"8px"},children:O.auth_config.two_factor_auth.issue})]}),!d&&O?.auth_config?.two_factor_auth?.can_enable===!0&&o.jsx("button",{className:"toggle-btn",onClick:Ia,children:"Enable"}),d&&O?.auth_config?.two_factor_auth?.can_disable===!0&&o.jsx("button",{className:"toggle-btn enabled",onClick:Ia,children:"Disable"})]})}),o.jsxs("div",{className:"security-block",children:[o.jsx("div",{className:"security-header",children:o.jsxs("div",{children:[o.jsx("h4",{className:"security-title",children:"Where you're logged in"}),o.jsx("p",{className:"security-subtitle",children:"Manage your active sessions"})]})}),o.jsx("div",{className:"sessions-list",children:b?o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"2rem"},children:[o.jsx(y.Spin,{size:"small"}),o.jsx("span",{style:{marginLeft:"8px",color:"#6b7280"},children:"Loading sessions..."})]}):C?o.jsxs("div",{style:{padding:"1rem",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",textAlign:"center"},children:[o.jsx("p",{style:{color:"#b91c1c",margin:"0 0 8px 0"},children:"Failed to load sessions"}),o.jsx("p",{style:{color:"#dc2626",fontSize:"14px",margin:"0 0 8px 0"},children:C}),o.jsx("button",{onClick:De,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}):p.length>0?p.map((V,X)=>{const se=ve(V);return o.jsxs("div",{className:"session-item",children:[o.jsx("div",{className:"session-info",children:o.jsxs("div",{className:"session-device",children:[o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M2.5 4.16667C2.5 3.24619 3.24619 2.5 4.16667 2.5H15.8333C16.7538 2.5 17.5 3.24619 17.5 4.16667V12.5C17.5 13.4205 16.7538 14.1667 15.8333 14.1667H4.16667C3.24619 14.1667 2.5 13.4205 2.5 12.5V4.16667Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M6.66667 17.5H13.3333",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M10 14.1667V17.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"session-device-header",children:[o.jsx("p",{className:"session-device-name",children:se.deviceName}),V.is_current?o.jsx("span",{className:"session-status-tag current",children:"Current"}):se.isActive?o.jsx("button",{className:"logout-tag-btn logout-tag-btn-ghost",onClick:()=>Ua(V.id),children:"Logout"}):o.jsx("button",{className:"logout-tag-btn",onClick:()=>Ua(V.id),children:"Logout"})]}),o.jsxs("p",{className:"session-details",children:[se.os," • ",se.location]})]})]})}),o.jsx("div",{className:"session-time",children:o.jsxs("div",{className:"session-time-info",children:[o.jsxs("p",{className:"session-start-time",children:["Started: ",se.sessionStartTime]}),o.jsx("p",{className:"session-last-active",children:se.isActive?"Active now":`Last seen: ${se.lastSeen}`})]})})]},V.id||X)}):o.jsx("p",{className:"no-sessions",children:"No active sessions found"})}),p.length>1&&o.jsx("button",{className:"logout-all-btn",onClick:bf,children:"Sign me out of all other sessions"})]}),o.jsxs("div",{className:"security-block",children:[o.jsx("div",{className:"security-header",children:o.jsxs("div",{children:[o.jsx("h4",{className:"security-title",children:"Authentication Tokens"}),o.jsx("p",{className:"security-subtitle",children:"Manage your bearer tokens for API authentication"})]})}),o.jsx("div",{className:"tokens-list",children:I&&I.length>0?I.map((V,X)=>o.jsx("div",{className:"token-item",children:o.jsx("div",{className:"token-info",children:o.jsxs("div",{className:"token-details",children:[o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M15 8.33333V6.66667C15 4.08934 12.9107 2 10.3333 2H9.66667C7.08934 2 5 4.08934 5 6.66667V8.33333M6.66667 8.33333H13.3333C14.2538 8.33333 15 9.07953 15 10V15C15 15.9205 14.2538 16.6667 13.3333 16.6667H6.66667C5.74619 16.6667 5 15.9205 5 15V10C5 9.07953 5.74619 8.33333 6.66667 8.33333Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("circle",{cx:"10",cy:"12.5",r:"1.25",fill:"currentColor"})]}),o.jsxs("div",{children:[o.jsxs("p",{className:"token-name",children:[V.role," - Bearer Token"]}),o.jsx("p",{className:"token-type",children:"Type: Bearer Authentication Token"}),o.jsxs("p",{className:"token-created",children:["Created: ",new Date(V.created).toLocaleDateString()]}),V.expiry?o.jsxs("p",{className:"token-expiry",children:["Expires: ",new Date(V.expiry).toLocaleDateString()]}):o.jsx("p",{className:"token-expiry",children:"Expires: Never"})]})]})})},X)):o.jsxs("div",{className:"no-tokens",children:[o.jsx("p",{children:"No authentication tokens found"}),o.jsx("p",{className:"no-tokens-hint",children:"Bearer tokens will appear here for API authentication"})]})})]})]})})]})})]})]})},pd=({onLogout:e,className:t=""})=>o.jsxs("a",{className:`dropdown-item profile-logout ${t}`,href:"#",onClick:r=>{r.preventDefault(),e()},children:[o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o.jsx("path",{d:"M10 11.75C9.95093 12.9846 8.92207 14.0329 7.54373 13.9992C7.22307 13.9913 6.82673 13.8796 6.03408 13.656C4.12641 13.1179 2.47037 12.2135 2.07304 10.1877C2 9.81533 2 9.39627 2 8.5582V7.4418C2 6.60374 2 6.1847 2.07304 5.81231C2.47037 3.78643 4.12641 2.8821 6.03408 2.34402C6.82673 2.12042 7.22307 2.00863 7.54373 2.00079C8.92207 1.96707 9.95093 3.01538 10 4.25",stroke:"#717680",strokeLinecap:"round"}),o.jsx("path",{d:"M14 7.99998H6.66663M14 7.99998C14 7.53318 12.6704 6.661 12.3333 6.33331M14 7.99998C14 8.46678 12.6704 9.33898 12.3333 9.66665",stroke:"#717680",strokeLinecap:"round",strokeLinejoin:"round"})]}),o.jsx("span",{className:"profile-name",children:"Log Out"})]}),gd=({onViewProfile:e,className:t=""})=>o.jsxs("a",{className:`dropdown-item profile-view ${t}`,href:"#",onClick:r=>{r.preventDefault(),e()},children:[o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o.jsx("path",{d:"M8.00004 7.33329C9.47281 7.33329 10.6667 6.13948 10.6667 4.66663C10.6667 3.19377 9.47281 1.99996 8.00004 1.99996C6.52719 1.99996 5.33337 3.19377 5.33337 4.66663C5.33337 6.13948 6.52719 7.33329 8.00004 7.33329Z",stroke:"#717680",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M4.00004 14V12.6666C4.00004 11.9594 4.28099 11.2811 4.78109 10.781C5.28119 10.2809 5.95947 9.99996 6.66671 9.99996H9.33337C10.0406 9.99996 10.7189 10.2809 11.219 10.781C11.7191 11.2811 12 11.9594 12 12.6666V14",stroke:"#717680",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})]}),o.jsx("span",{className:"profile-name",children:"View Profile"})]}),$n=({profileInfo:e,theme:t={},config:r={}})=>{const[s,n]=h.useState(!1),[a,i]=h.useState(!1),[l,u]=h.useState(!1),[c,d]=h.useState(null),f=h.useRef(null);K.useNavigate(),h.useEffect(()=>{const x=F=>{f.current&&!f.current.contains(F.target)&&(n(!1),i(!1))};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]);const m=()=>{n(!s),s||i(!1)},g=()=>{Dn(()=>{rs({theme:t})})},p=x=>{window.location.href=x},w=e?.current_role||e?.user_role,b=e?.other_roles||[],{showProfile:k=!0,showLeftSection:C=!0,showRightSection:M=!0,customLeftContent:I=null,customRightContent:q=null,customProfileMenu:E=null,customViewProfile:_=null,profileMenuConfig:P={},className:O="",style:W={}}=r,{showViewProfile:S=!0,showLogout:U=!0,showRoleSwitch:A=!0,customMenuItems:L=[]}=P,v=()=>{u(!0),n(!1)};return o.jsxs("header",{className:`topbar header-container ${O}`,style:W,children:[o.jsxs("div",{className:"topbar-content",children:[C&&o.jsx("div",{className:"topbar-left",children:I||null}),M&&o.jsxs("div",{className:"topbar-right",children:[q,k&&o.jsxs("div",{className:"dropdown profile-dropdown-container",ref:f,children:[o.jsxs("div",{className:"profile-dropdown-menu-button",onClick:m,children:[o.jsxs("div",{className:"profile-info-wrapper",children:[o.jsx("img",{src:e?.profile_pic||`https://ui-avatars.com/api/?name=${encodeURIComponent(e?.name||"User")}&background=${ao("brand",500).split("#")[1]}&color=fff`,alt:"Profile",className:"profile-avatar"}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"profile-name",children:e?.name||"User"}),o.jsx("span",{className:"text-[12px] text-gray-600",children:w})]})]}),o.jsx("svg",{className:`dropdown-arrow ${s?"open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M13.3538 6.35354L8.35378 11.3535C8.30735 11.4 8.2522 11.4369 8.1915 11.4621C8.13081 11.4872 8.06574 11.5002 8.00003 11.5002C7.93433 11.5002 7.86926 11.4872 7.80856 11.4621C7.74786 11.4369 7.69272 11.4 7.64628 11.3535L2.64628 6.35354C2.55246 6.25972 2.49976 6.13247 2.49976 5.99979C2.49976 5.86711 2.55246 5.73986 2.64628 5.64604C2.7401 5.55222 2.86735 5.49951 3.00003 5.49951C3.13272 5.49951 3.25996 5.55222 3.35378 5.64604L8.00003 10.2929L12.6463 5.64604C12.6927 5.59958 12.7479 5.56273 12.8086 5.53759C12.8693 5.51245 12.9343 5.49951 13 5.49951C13.0657 5.49951 13.1308 5.51245 13.1915 5.53759C13.2522 5.56273 13.3073 5.59958 13.3538 5.64604C13.4002 5.69249 13.4371 5.74764 13.4622 5.80834C13.4874 5.86904 13.5003 5.93409 13.5003 5.99979C13.5003 6.06549 13.4874 6.13054 13.4622 6.19124C13.4371 6.25193 13.4002 6.30708 13.3538 6.35354Z",fill:"#414651"})})]}),o.jsxs("ul",{className:`profile-dropdown-menu ${s?"show":""}`,children:[b.length>0&&a&&o.jsx("li",{children:o.jsx("div",{className:"profile-roles complete-hidden-scroll-style",children:b.map((x,F)=>o.jsxs("div",{className:"dropdown-item profile-each-role",onClick:()=>p(x.url),children:[o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o.jsx("g",{clipPath:"url(#clip0_1427_392)",children:o.jsx("path",{d:"M0.833374 7.99998C0.833374 4.04198 4.04204 0.833313 8.00004 0.833313C11.958 0.833313 15.1667 4.04198 15.1667 7.99998C15.1667 11.958 11.958 15.1666 8.00004 15.1666C4.04204 15.1666 0.833374 11.958 0.833374 7.99998ZM8.00004 1.83331C4.59404 1.83331 1.83337 4.59398 1.83337 7.99998C1.83337 9.58131 2.42804 11.0233 3.40671 12.1146L3.60604 11.7646C4.28871 10.5706 5.55871 9.83331 6.93471 9.83331H9.06604C10.4414 9.83331 11.7114 10.5706 12.394 11.7646L12.5934 12.114C13.572 11.0226 14.1667 9.58065 14.1667 7.99998C14.1667 4.59398 11.406 1.83331 8.00004 1.83331ZM11.8454 12.8206L11.5254 12.2606C11.0214 11.378 10.0827 10.8333 9.06604 10.8333H6.93471C5.91804 10.8333 4.97871 11.378 4.47471 12.2606L4.15471 12.8213C5.20871 13.6633 6.54537 14.1666 8.00004 14.1666C9.45471 14.1666 10.7914 13.6633 11.8454 12.8206ZM5.66671 6.33331C5.66671 5.04465 6.71137 3.99998 8.00004 3.99998C9.28871 3.99998 10.3334 5.04465 10.3334 6.33331C10.3334 7.62198 9.28871 8.66665 8.00004 8.66665C6.71137 8.66665 5.66671 7.62198 5.66671 6.33331ZM8.00004 4.99998C7.26337 4.99998 6.66671 5.59665 6.66671 6.33331C6.66671 7.06998 7.26337 7.66665 8.00004 7.66665C8.73671 7.66665 9.33337 7.06998 9.33337 6.33331C9.33337 5.59665 8.73671 4.99998 8.00004 4.99998Z",fill:"#717680"})}),o.jsx("defs",{children:o.jsx("clipPath",{id:"clip0_1427_392",children:o.jsx("rect",{width:"16",height:"16",fill:"white"})})})]}),o.jsx("span",{className:"label",children:x.label})]},F))})}),o.jsx("li",{children:o.jsx("hr",{className:"profile-dropdown-divider"})}),L.map((x,F)=>o.jsx("li",{children:x},F)),S&&o.jsx("li",{children:o.jsx(gd,{onViewProfile:v})}),U&&o.jsx("li",{children:o.jsx(pd,{onLogout:g})})]})]})]})]}),_?_({user:e,isOpen:l,onClose:()=>u(!1)}):o.jsx(Bn,{isOpen:l,onClose:()=>u(!1),profileData:c})]})},md={showTopbar:!0,showNavbar:!0,layoutType:"wide"},wd={showProfile:!0,showLeftSection:!0,showRightSection:!0,customLeftContent:null,customRightContent:null,customProfileMenu:null,customTopbar:null,customViewProfile:null,profileMenuConfig:{showViewProfile:!0,showLogout:!0,showRoleSwitch:!0,customMenuItems:[]},className:"",style:{}},yd={showLogo:!0,showMenu:!0,isCollapsed:!1,collapsible:!1,customLogo:null,customMenuContent:null,customBottomContent:null,customNavbar:null,customMenu:null,menuConfig:{showIcons:!0,showSubmenus:!0,expandOnHover:!1,customMenuItemRenderer:null},className:"",style:{}},lr=(e={},t={})=>{const r={...t};return Object.keys(e).forEach(s=>{if(e[s]===void 0||e[s]===null)return;e[s]&&(e[s].$$typeof||typeof e[s]=="function")||typeof e[s]=="function"||Array.isArray(e[s])?r[s]=e[s]:typeof e[s]=="object"&&typeof t[s]=="object"&&!Array.isArray(t[s])?r[s]=lr(e[s],t[s]):r[s]=e[s]}),r},qn=()=>{const{loading:e,error:t,menu:r,profileInfo:s,appLogo:n,theme:a={},layoutConfig:i={},topbarConfig:l={},navbarConfig:u={},customComponents:c={}}=Ne(),d=K.useLocation(),f=lr(i,md),m=lr(l,wd),g=lr(u,yd),p=()=>{const E=document.getElementById("contentSpinner");E&&E.classList.add("active")},w=()=>{const E=document.getElementById("contentSpinner");E&&E.classList.remove("active")};if(h.useEffect(()=>{p();const E=300,_=Date.now(),P=setTimeout(()=>{const O=Date.now()-_;O>=E?w():setTimeout(w,E-O)},500);return()=>{clearTimeout(P)}},[d.pathname]),h.useEffect(()=>(window.addEventListener("beforeunload",p),()=>{window.removeEventListener("beforeunload",p)}),[]),e)return o.jsx("div",{className:"layout-loading",children:"Loading..."});if(t)return o.jsxs("div",{className:"layout-error",children:["Error: ",t]});const b=f.layoutType||a?.layout||"wide",k=f.showNavbar&&a?.menu_config?.display_sidebar!==!1,C=f.showTopbar,M=c?.Layout,I=c?.Topbar||m.customTopbar,q=c?.Navbar||g.customNavbar;return M?o.jsx(M,{menu:r,profileInfo:s,appLogo:n,theme:a,layoutConfig:f,topbarConfig:m,navbarConfig:g,children:o.jsx(K.Outlet,{})}):o.jsx("div",{className:`layout layout-${b}`,children:o.jsxs("main",{className:"layout-wrapper",children:[k&&(q?o.jsx(q,{menuItems:r,appLogo:n,theme:a,config:g}):o.jsx(Fn,{menuItems:r,appLogo:n,theme:a,config:g})),o.jsxs("div",{className:"layout-main",style:{width:k?`calc(100vw - ${g.isCollapsed?"80px":"244px"})`:"100vw",transition:"width 0.3s ease"},children:[C&&(I?o.jsx(I,{profileInfo:s,theme:a,config:m}):o.jsx($n,{profileInfo:s,theme:a,config:m})),o.jsxs("div",{className:"layout-content",children:[o.jsx("div",{className:"content-spinner-container",id:"contentSpinner",children:o.jsx("div",{className:"spinner",children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[o.jsx("path",{d:"M32 5.33331V16",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M43.2002 20.7999L50.9335 13.0665",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M48 32H58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M43.2002 43.2L50.9335 50.9333",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M32 48V58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M13.0664 50.9333L20.7997 43.2",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M5.33301 32H15.9997",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M13.0664 13.0665L20.7997 20.7999",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),o.jsx(K.Outlet,{})]})]})]})})},bd=(e,t,r)=>{if(!e){const l=t.default;return l?.component?h.createElement(l.component,{message:"No page type specified"}):h.createElement("div",{style:{padding:"24px",color:"#f04438"}},"No page type specified")}const s=t[e]||t.default;if(!s)return h.createElement("div",{style:{padding:"24px",color:"#f04438"}},`Unknown page type: ${e}`);if(s.handler)return s.handler(r);if(!s.component){const l=t.default;if(l?.component){const u=l.propsBuilder?l.propsBuilder({...r,pageType:e}):{message:`No component configured for page type: ${e}`};return h.createElement(l.component,u)}return h.createElement("div",{style:{padding:"24px",color:"#f04438"}},`No component configured for page type: ${e}`)}let n=s.propsBuilder?s.propsBuilder({...r,pageType:e}):{};s.includeBasePath!==!1&&r.matchedRoutePath&&(n={basePath:r.matchedRoutePath,...n});const i=s.component;return h.createElement(i,n)},Mt=({customPages:e={},forceRoute:t})=>{const r=K.useLocation(),{routes:s,pageTypeRegistry:n,registryLoading:a,registryError:i,initializerEndpoint:l}=Ne(),u=kt(),[c,d]=h.useState({pageType:null,customPagePath:null,matchedRoutePath:null,loading:!0});if(h.useEffect(()=>{d(b=>({...b,loading:!0})),(()=>{const b=r.pathname;if(t){d({pageType:t.page_type,customPagePath:t.component||null,matchedRoutePath:t.path,loading:!1});return}if(r.state&&r.state.page_type&&(r.state.page_type!=="custom"||r.state.custom_page_path)){let k=b;if(s&&s.length>0){for(const C of s)if(b===C.path||b.startsWith(C.path+"/")){k=C.path;break}}d({pageType:r.state.page_type,customPagePath:r.state.custom_page_path||null,matchedRoutePath:k,loading:!1});return}if(s&&s.length>0){const k=[...s].sort((C,M)=>{const I=C.path.split("/").filter(E=>E).length;return M.path.split("/").filter(E=>E).length-I});for(const C of k){let M=K.matchPath({path:C.path,exact:!0},b);if(!M&&b.startsWith(C.path+"/")){const I=C.path.endsWith("/*")?C.path:`${C.path}/*`;M=K.matchPath({path:I,exact:!1},b)}if(M){d({pageType:C.page_type,customPagePath:C.component||null,matchedRoutePath:C.path,loading:!1});return}}}d({pageType:"404",customPagePath:null,matchedRoutePath:null,loading:!1})})()},[r,s,t]),c.loading||a)return o.jsx("div",{className:"content-spinner-container active",children:o.jsx("div",{className:"spinner",children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[o.jsx("path",{d:"M32 5.33331V16",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M43.2002 20.7999L50.9335 13.0665",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M48 32H58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M43.2002 43.2L50.9335 50.9333",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M32 48V58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M13.0664 50.9333L20.7997 43.2",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M5.33301 32H15.9997",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M13.0664 13.0665L20.7997 20.7999",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})})});if(i)return o.jsxs("div",{style:{padding:"24px",color:"#f04438"},children:["Failed to load page registry: ",i]});if(!n)return o.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",textAlign:"center",padding:"24px"},children:o.jsxs("div",{style:{backgroundColor:"white",borderRadius:"12px",padding:"32px",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.05)",maxWidth:"500px",width:"100%",border:"1px solid #e1e3e6"},children:[o.jsx("h1",{style:{fontSize:"32px",margin:"0",color:"#f04438",fontWeight:"bold",lineHeight:"1"},children:"⚠️"}),o.jsx("h3",{style:{fontSize:"18px",margin:"12px 0",color:"#252b37",fontWeight:"600"},children:"Configuration Issue"}),o.jsx("p",{style:{fontSize:"14px",color:"#717680",marginBottom:"16px",lineHeight:"1.5"},children:"Unable to load page configuration from:"}),o.jsx("code",{style:{display:"block",backgroundColor:"#f9fafb",border:"1px solid #e1e3e6",borderRadius:"4px",padding:"8px 12px",fontSize:"12px",color:"#252b37",fontFamily:"Monaco, Menlo, monospace",marginBottom:"16px",wordBreak:"break-all"},children:l}),o.jsx("p",{style:{fontSize:"13px",color:"#8b909a",margin:"0"},children:"Please check your configuration or contact your administrator."})]})});const{pageType:f,customPagePath:m,matchedRoutePath:g}=c,p=`${f}-${m||"default"}-${g||"none"}`;return o.jsx("div",{className:"h-full",children:bd(f,n,{matchedRoutePath:g,customPagePath:m,customPages:e,location:r,apiConfig:u})},p)},Vn=()=>{const{metadata:e,appName:t,apiConfig:r,theme:s}=Ne(),n=h.useRef(new Set),a=()=>{n.current.forEach(u=>{u.parentNode&&u.parentNode.removeChild(u)}),n.current.clear()},i=(u,c,d)=>{let f=document.querySelector(u);return f||(f=c(),document.head.appendChild(f),n.current.add(f)),d(f),f},l=(u,c="image")=>new Promise((d,f)=>{const m=document.createElement("link");m.rel="preload",m.as=c,m.href=u,m.onload=()=>d(),m.onerror=()=>f(new Error(`Failed to preload ${c}: ${u}`)),n.current.add(m),document.head.appendChild(m),setTimeout(()=>{m.parentNode&&(m.parentNode.removeChild(m),n.current.delete(m))},1e4)});return h.useEffect(()=>{if(!e)return;a();const u=(c,d)=>{if(!c)return d||null;if(c.startsWith("http://")||c.startsWith("https://")||c.startsWith("//"))return c;try{return Dt(c,r)}catch(f){return console.warn(`Failed to build asset URL for ${c}:`,f),d||null}};if(e.title?document.title=e.title:t&&(document.title=t),e.description&&i('meta[name="description"]',()=>{const c=document.createElement("meta");return c.name="description",c},c=>{c.content=e.description}),e.keywords&&i('meta[name="keywords"]',()=>{const c=document.createElement("meta");return c.name="keywords",c},c=>{c.content=e.keywords}),i('meta[name="viewport"]',()=>{const c=document.createElement("meta");return c.name="viewport",c},c=>{c.content="width=device-width, initial-scale=1.0"}),s?.colors?.primary&&i('meta[name="theme-color"]',()=>{const c=document.createElement("meta");return c.name="theme-color",c},c=>{c.content=s.colors.primary}),e.favicon){const c=u(e.favicon,"/favicon.ico");c&&i('link[rel="icon"][type="image/x-icon"], link[rel="shortcut icon"]',()=>{const d=document.createElement("link");return d.rel="icon",d.type="image/x-icon",d},d=>{d.href=c,l(c).catch(f=>console.warn("Failed to preload favicon:",f.message))})}if(e.favicon_png){const c=u(e.favicon_png,"/favicon-32x32.png");c&&i('link[rel="icon"][type="image/png"]',()=>{const d=document.createElement("link");return d.rel="icon",d.type="image/png",d.sizes="32x32",d},d=>{d.href=c,l(c).catch(f=>console.warn("Failed to preload PNG favicon:",f.message))})}if(e.apple_touch_icon){const c=u(e.apple_touch_icon,"/apple-touch-icon.png");c&&i('link[rel="apple-touch-icon"]',()=>{const d=document.createElement("link");return d.rel="apple-touch-icon",d},d=>{d.href=c,l(c).catch(f=>console.warn("Failed to preload Apple touch icon:",f.message))})}if(e.og_image){const c=u(e.og_image,"/og-image.png");c&&(l(c).catch(d=>console.warn("Failed to preload OG image:",d.message)),i('meta[property="og:image"]',()=>{const d=document.createElement("meta");return d.setAttribute("property","og:image"),d},d=>{d.content=c}),(e.og_image_alt||e.title)&&i('meta[property="og:image:alt"]',()=>{const d=document.createElement("meta");return d.setAttribute("property","og:image:alt"),d},d=>{d.content=e.og_image_alt||e.title||t||"Zango CRM"}))}if(i('meta[property="og:title"]',()=>{const c=document.createElement("meta");return c.setAttribute("property","og:title"),c},c=>{c.content=e.title||t||"Zango CRM"}),e.description&&i('meta[property="og:description"]',()=>{const c=document.createElement("meta");return c.setAttribute("property","og:description"),c},c=>{c.content=e.description}),i('meta[property="og:type"]',()=>{const c=document.createElement("meta");return c.setAttribute("property","og:type"),c},c=>{c.content="website"}),i('meta[property="og:url"]',()=>{const c=document.createElement("meta");return c.setAttribute("property","og:url"),c},c=>{c.content=window.location.href}),i('meta[name="twitter:card"]',()=>{const c=document.createElement("meta");return c.name="twitter:card",c},c=>{c.content=e.og_image?"summary_large_image":"summary"}),i('meta[name="twitter:title"]',()=>{const c=document.createElement("meta");return c.name="twitter:title",c},c=>{c.content=e.title||t||"Zango CRM"}),e.description&&i('meta[name="twitter:description"]',()=>{const c=document.createElement("meta");return c.name="twitter:description",c},c=>{c.content=e.description}),e.og_image){const c=u(e.og_image,"/og-image.png");c&&i('meta[name="twitter:image"]',()=>{const d=document.createElement("meta");return d.name="twitter:image",d},d=>{d.content=c})}if(i('link[rel="canonical"]',()=>{const c=document.createElement("link");return c.rel="canonical",c},c=>{c.href=window.location.href.split("?")[0]}),e.manifest||e.webmanifest){const c=u(e.manifest||e.webmanifest,"/manifest.json");c&&i('link[rel="manifest"]',()=>{const d=document.createElement("link");return d.rel="manifest",d},d=>{d.href=c})}return a},[e,t,s]),null},vd=({config:e,onExpire:t,onWarning:r,onActivity:s})=>{const[n,a]=h.useState(!1),[i,l]=h.useState(0),u=h.useRef(new Date),c=h.useRef(null),d=h.useRef(null),f=h.useRef(!1),m=h.useRef(!1),g=h.useRef(!1),p=h.useRef(t),w=h.useRef(r),b=h.useRef(s),k=h.useRef(()=>{}),C=h.useRef(()=>{}),M=h.useRef(()=>{}),I=h.useRef(()=>{});h.useEffect(()=>{p.current=t,w.current=r,b.current=s},[t,r,s]),h.useEffect(()=>{g.current=n},[n]);const q=["mousemove","scroll","keyup","click","touchstart","touchend","touchmove"],E=h.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),_=h.useCallback(()=>{f.current=!0,E(),d.current&&(clearInterval(d.current),d.current=null),p.current&&p.current(),rs({preserveCurrentPath:!0})},[E]),P=h.useCallback(()=>{a(!1),d.current&&(clearInterval(d.current),d.current=null),m.current=!1},[]),O=h.useCallback(()=>{const{warn_after:F,expire_after:D}=e,Y=D-F;if(m.current)return;l(Y),m.current=!0;const Z=new Date;Z.setSeconds(Z.getSeconds()+Y),d.current=setInterval(()=>{const J=new Date().getTime(),ee=Z.getTime()-J,$=Math.floor(ee/1e3);$>0?l($):(d.current&&(clearInterval(d.current),d.current=null),l(0))},1e3)},[e]),W=h.useCallback(()=>{d.current&&(clearInterval(d.current),d.current=null),m.current=!1;const F=e.expire_after-e.warn_after;l(F)},[e]),S=h.useCallback(F=>{if(F==="logout"||F?.response==="logout"){_();return}k.current()},[_]);h.useLayoutEffect(()=>{M.current=S},[S]);const U=h.useCallback(async()=>{const F=Math.floor((new Date().getTime()-u.current.getTime())/1e3);try{const D=await Xs(e.ping_url,F);D.success?M.current(D.response):k.current()}catch{k.current()}},[e.ping_url]);h.useLayoutEffect(()=>{C.current=U},[U]);const A=h.useCallback(()=>{E();const F=Math.floor((new Date().getTime()-u.current.getTime())/1e3),{warn_after:D,expire_after:Y}=e;let Z;if(F>=Y){_();return}else F>=D?(m.current||O(),a(!0),w.current&&w.current(),Z=Y-F):(P(),m.current&&W(),Z=D-F);const J=Math.min(Z*1e3,2147483647);c.current=setTimeout(()=>{C.current()},J)},[e,E,_,O,P,W]);h.useLayoutEffect(()=>{k.current=A},[A]);const L=h.useCallback(()=>{const F=new Date;if(F.getTime()-u.current.getTime()<1e3)return;const D=Math.floor((F.getTime()-u.current.getTime())/1e3);if(u.current=F,D>=e.expire_after){_();return}g.current&&(C.current(),P()),b.current&&b.current()},[e.expire_after,_,P]);h.useLayoutEffect(()=>{I.current=L},[L]);const v=h.useCallback(()=>{u.current=new Date,P(),C.current()},[P]),x=h.useCallback(()=>{_()},[_]);return h.useEffect(()=>{if(!e.enabled)return;const F=()=>I.current();return q.forEach(D=>{document.addEventListener(D,F,!0)}),k.current(),()=>{q.forEach(D=>{document.removeEventListener(D,F,!0)}),c.current&&(clearTimeout(c.current),c.current=null),d.current&&(clearInterval(d.current),d.current=null)}},[e.enabled]),{showWarning:n,countdown:i,hideWarning:P,renewSession:v,logoutNow:x}};function Re(e,t,{checkForDefaultPrevented:r=!0}={}){return function(n){if(e?.(n),r===!1||!n.defaultPrevented)return t?.(n)}}function jn(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Hn(...e){return t=>{let r=!1;const s=e.map(n=>{const a=jn(n,t);return!r&&typeof a=="function"&&(r=!0),a});if(r)return()=>{for(let n=0;n<s.length;n++){const a=s[n];typeof a=="function"?a():jn(e[n],null)}}}}function ct(...e){return T.useCallback(Hn(...e),e)}function Cd(e,t){const r=T.createContext(t),s=a=>{const{children:i,...l}=a,u=T.useMemo(()=>l,Object.values(l));return o.jsx(r.Provider,{value:u,children:i})};s.displayName=e+"Provider";function n(a){const i=T.useContext(r);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[s,n]}function xd(e,t=[]){let r=[];function s(a,i){const l=T.createContext(i),u=r.length;r=[...r,i];const c=f=>{const{scope:m,children:g,...p}=f,w=m?.[e]?.[u]||l,b=T.useMemo(()=>p,Object.values(p));return o.jsx(w.Provider,{value:b,children:g})};c.displayName=a+"Provider";function d(f,m){const g=m?.[e]?.[u]||l,p=T.useContext(g);if(p)return p;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${a}\``)}return[c,d]}const n=()=>{const a=r.map(i=>T.createContext(i));return function(l){const u=l?.[e]||a;return T.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return n.scopeName=e,[s,Pd(n,...t)]}function Pd(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const s=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(a){const i=s.reduce((l,{useScope:u,scopeName:c})=>{const f=u(a)[`__scope${c}`];return{...l,...f}},{});return T.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}var It=globalThis?.document?T.useLayoutEffect:()=>{},Sd=T[" useId ".trim().toString()]||(()=>{}),kd=0;function ss(e){const[t,r]=T.useState(Sd());return It(()=>{r(s=>s??String(kd++))},[e]),e||(t?`radix-${t}`:"")}var Ed=T[" useInsertionEffect ".trim().toString()]||It;function Ad({prop:e,defaultProp:t,onChange:r=()=>{},caller:s}){const[n,a,i]=_d({defaultProp:t,onChange:r}),l=e!==void 0,u=l?e:n;{const d=T.useRef(e!==void 0);T.useEffect(()=>{const f=d.current;f!==l&&console.warn(`${s} is changing from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=l},[l,s])}const c=T.useCallback(d=>{if(l){const f=Nd(d)?d(e):d;f!==e&&i.current?.(f)}else a(d)},[l,e,a,i]);return[u,c]}function _d({defaultProp:e,onChange:t}){const[r,s]=T.useState(e),n=T.useRef(r),a=T.useRef(t);return Ed(()=>{a.current=t},[t]),T.useEffect(()=>{n.current!==r&&(a.current?.(r),n.current=r)},[r,n]),[r,s,a]}function Nd(e){return typeof e=="function"}function zn(e){const t=Ld(e),r=T.forwardRef((s,n)=>{const{children:a,...i}=s,l=T.Children.toArray(a),u=l.find(Od);if(u){const c=u.props.children,d=l.map(f=>f===u?T.Children.count(c)>1?T.Children.only(null):T.isValidElement(c)?c.props.children:null:f);return o.jsx(t,{...i,ref:n,children:T.isValidElement(c)?T.cloneElement(c,void 0,d):null})}return o.jsx(t,{...i,ref:n,children:a})});return r.displayName=`${e}.Slot`,r}function Ld(e){const t=T.forwardRef((r,s)=>{const{children:n,...a}=r;if(T.isValidElement(n)){const i=Md(n),l=Fd(a,n.props);return n.type!==T.Fragment&&(l.ref=s?Hn(s,i):i),T.cloneElement(n,l)}return T.Children.count(n)>1?T.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Td=Symbol("radix.slottable");function Od(e){return T.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Td}function Fd(e,t){const r={...t};for(const s in t){const n=e[s],a=t[s];/^on[A-Z]/.test(s)?n&&a?r[s]=(...l)=>{const u=a(...l);return n(...l),u}:n&&(r[s]=n):s==="style"?r[s]={...n,...a}:s==="className"&&(r[s]=[n,a].filter(Boolean).join(" "))}return{...e,...r}}function Md(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Id=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ke=Id.reduce((e,t)=>{const r=zn(`Primitive.${t}`),s=T.forwardRef((n,a)=>{const{asChild:i,...l}=n,u=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(u,{...l,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function Ud(e,t){e&&ja.flushSync(()=>e.dispatchEvent(t))}function Ut(e){const t=T.useRef(e);return T.useEffect(()=>{t.current=e}),T.useMemo(()=>(...r)=>t.current?.(...r),[])}function Dd(e,t=globalThis?.document){const r=Ut(e);T.useEffect(()=>{const s=n=>{n.key==="Escape"&&r(n)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[r,t])}var Bd="DismissableLayer",os="dismissableLayer.update",$d="dismissableLayer.pointerDownOutside",qd="dismissableLayer.focusOutside",Wn,Kn=T.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Zn=T.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:n,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...u}=e,c=T.useContext(Kn),[d,f]=T.useState(null),m=d?.ownerDocument??globalThis?.document,[,g]=T.useState({}),p=ct(t,_=>f(_)),w=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(b),C=d?w.indexOf(d):-1,M=c.layersWithOutsidePointerEventsDisabled.size>0,I=C>=k,q=Hd(_=>{const P=_.target,O=[...c.branches].some(W=>W.contains(P));!I||O||(n?.(_),i?.(_),_.defaultPrevented||l?.())},m),E=zd(_=>{const P=_.target;[...c.branches].some(W=>W.contains(P))||(a?.(_),i?.(_),_.defaultPrevented||l?.())},m);return Dd(_=>{C===c.layers.size-1&&(s?.(_),!_.defaultPrevented&&l&&(_.preventDefault(),l()))},m),T.useEffect(()=>{if(d)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Wn=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Gn(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Wn)}},[d,m,r,c]),T.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Gn())},[d,c]),T.useEffect(()=>{const _=()=>g({});return document.addEventListener(os,_),()=>document.removeEventListener(os,_)},[]),o.jsx(Ke.div,{...u,ref:p,style:{pointerEvents:M?I?"auto":"none":void 0,...e.style},onFocusCapture:Re(e.onFocusCapture,E.onFocusCapture),onBlurCapture:Re(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Re(e.onPointerDownCapture,q.onPointerDownCapture)})});Zn.displayName=Bd;var Vd="DismissableLayerBranch",jd=T.forwardRef((e,t)=>{const r=T.useContext(Kn),s=T.useRef(null),n=ct(t,s);return T.useEffect(()=>{const a=s.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),o.jsx(Ke.div,{...e,ref:n})});jd.displayName=Vd;function Hd(e,t=globalThis?.document){const r=Ut(e),s=T.useRef(!1),n=T.useRef(()=>{});return T.useEffect(()=>{const a=l=>{if(l.target&&!s.current){let u=function(){Jn($d,r,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",n.current),n.current=u,t.addEventListener("click",n.current,{once:!0})):u()}else t.removeEventListener("click",n.current);s.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",n.current)}},[t,r]),{onPointerDownCapture:()=>s.current=!0}}function zd(e,t=globalThis?.document){const r=Ut(e),s=T.useRef(!1);return T.useEffect(()=>{const n=a=>{a.target&&!s.current&&Jn(qd,r,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",n),()=>t.removeEventListener("focusin",n)},[t,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function Gn(){const e=new CustomEvent(os);document.dispatchEvent(e)}function Jn(e,t,r,{discrete:s}){const n=r.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),s?Ud(n,a):n.dispatchEvent(a)}var ns="focusScope.autoFocusOnMount",as="focusScope.autoFocusOnUnmount",Xn={bubbles:!1,cancelable:!0},Wd="FocusScope",Yn=T.forwardRef((e,t)=>{const{loop:r=!1,trapped:s=!1,onMountAutoFocus:n,onUnmountAutoFocus:a,...i}=e,[l,u]=T.useState(null),c=Ut(n),d=Ut(a),f=T.useRef(null),m=ct(t,w=>u(w)),g=T.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;T.useEffect(()=>{if(s){let w=function(M){if(g.paused||!l)return;const I=M.target;l.contains(I)?f.current=I:et(f.current,{select:!0})},b=function(M){if(g.paused||!l)return;const I=M.relatedTarget;I!==null&&(l.contains(I)||et(f.current,{select:!0}))},k=function(M){if(document.activeElement===document.body)for(const q of M)q.removedNodes.length>0&&et(l)};document.addEventListener("focusin",w),document.addEventListener("focusout",b);const C=new MutationObserver(k);return l&&C.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",b),C.disconnect()}}},[s,l,g.paused]),T.useEffect(()=>{if(l){ea.add(g);const w=document.activeElement;if(!l.contains(w)){const k=new CustomEvent(ns,Xn);l.addEventListener(ns,c),l.dispatchEvent(k),k.defaultPrevented||(Kd(Yd(Qn(l)),{select:!0}),document.activeElement===w&&et(l))}return()=>{l.removeEventListener(ns,c),setTimeout(()=>{const k=new CustomEvent(as,Xn);l.addEventListener(as,d),l.dispatchEvent(k),k.defaultPrevented||et(w??document.body,{select:!0}),l.removeEventListener(as,d),ea.remove(g)},0)}}},[l,c,d,g]);const p=T.useCallback(w=>{if(!r&&!s||g.paused)return;const b=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(b&&k){const C=w.currentTarget,[M,I]=Zd(C);M&&I?!w.shiftKey&&k===I?(w.preventDefault(),r&&et(M,{select:!0})):w.shiftKey&&k===M&&(w.preventDefault(),r&&et(I,{select:!0})):k===C&&w.preventDefault()}},[r,s,g.paused]);return o.jsx(Ke.div,{tabIndex:-1,...i,ref:m,onKeyDown:p})});Yn.displayName=Wd;function Kd(e,{select:t=!1}={}){const r=document.activeElement;for(const s of e)if(et(s,{select:t}),document.activeElement!==r)return}function Zd(e){const t=Qn(e),r=Rn(t,e),s=Rn(t.reverse(),e);return[r,s]}function Qn(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const n=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||n?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Rn(e,t){for(const r of e)if(!Gd(r,{upTo:t}))return r}function Gd(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Jd(e){return e instanceof HTMLInputElement&&"select"in e}function et(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Jd(e)&&t&&e.select()}}var ea=Xd();function Xd(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=ta(e,t),e.unshift(t)},remove(t){e=ta(e,t),e[0]?.resume()}}}function ta(e,t){const r=[...e],s=r.indexOf(t);return s!==-1&&r.splice(s,1),r}function Yd(e){return e.filter(t=>t.tagName!=="A")}var Qd="Portal",ra=T.forwardRef((e,t)=>{const{container:r,...s}=e,[n,a]=T.useState(!1);It(()=>a(!0),[]);const i=r||n&&globalThis?.document?.body;return i?vs.createPortal(o.jsx(Ke.div,{...s,ref:t}),i):null});ra.displayName=Qd;function Rd(e,t){return T.useReducer((r,s)=>t[r][s]??r,e)}var cr=e=>{const{present:t,children:r}=e,s=eu(t),n=typeof r=="function"?r({present:s.isPresent}):T.Children.only(r),a=ct(s.ref,tu(n));return typeof r=="function"||s.isPresent?T.cloneElement(n,{ref:a}):null};cr.displayName="Presence";function eu(e){const[t,r]=T.useState(),s=T.useRef(null),n=T.useRef(e),a=T.useRef("none"),i=e?"mounted":"unmounted",[l,u]=Rd(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return T.useEffect(()=>{const c=dr(s.current);a.current=l==="mounted"?c:"none"},[l]),It(()=>{const c=s.current,d=n.current;if(d!==e){const m=a.current,g=dr(c);e?u("MOUNT"):g==="none"||c?.display==="none"?u("UNMOUNT"):u(d&&m!==g?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,u]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=g=>{const w=dr(s.current).includes(CSS.escape(g.animationName));if(g.target===t&&w&&(u("ANIMATION_END"),!n.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},m=g=>{g.target===t&&(a.current=dr(s.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:T.useCallback(c=>{s.current=c?getComputedStyle(c):null,r(c)},[])}}function dr(e){return e?.animationName||"none"}function tu(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var is=0;function ru(){T.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??sa()),document.body.insertAdjacentElement("beforeend",e[1]??sa()),is++,()=>{is===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),is--}},[])}function sa(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var je=function(){return je=Object.assign||function(t){for(var r,s=1,n=arguments.length;s<n;s++){r=arguments[s];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},je.apply(this,arguments)};function oa(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}function su(e,t,r){if(r||arguments.length===2)for(var s=0,n=t.length,a;s<n;s++)(a||!(s in t))&&(a||(a=Array.prototype.slice.call(t,0,s)),a[s]=t[s]);return e.concat(a||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var ur="right-scroll-bar-position",fr="width-before-scroll-bar",ou="with-scroll-bars-hidden",nu="--removed-body-scroll-bar-size";function ls(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function au(e,t){var r=h.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(s){var n=r.value;n!==s&&(r.value=s,r.callback(s,n))}}}})[0];return r.callback=t,r.facade}var iu=typeof window<"u"?T.useLayoutEffect:T.useEffect,na=new WeakMap;function lu(e,t){var r=au(null,function(s){return e.forEach(function(n){return ls(n,s)})});return iu(function(){var s=na.get(r);if(s){var n=new Set(s),a=new Set(e),i=r.current;n.forEach(function(l){a.has(l)||ls(l,null)}),a.forEach(function(l){n.has(l)||ls(l,i)})}na.set(r,e)},[e]),r}function cu(e){return e}function du(e,t){t===void 0&&(t=cu);var r=[],s=!1,n={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(a){var i=t(a,s);return r.push(i),function(){r=r.filter(function(l){return l!==i})}},assignSyncMedium:function(a){for(s=!0;r.length;){var i=r;r=[],i.forEach(a)}r={push:function(l){return a(l)},filter:function(){return r}}},assignMedium:function(a){s=!0;var i=[];if(r.length){var l=r;r=[],l.forEach(a),i=r}var u=function(){var d=i;i=[],d.forEach(a)},c=function(){return Promise.resolve().then(u)};c(),r={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),r}}}};return n}function uu(e){e===void 0&&(e={});var t=du(null);return t.options=je({async:!0,ssr:!1},e),t}var aa=function(e){var t=e.sideCar,r=oa(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return T.createElement(s,je({},r))};aa.isSideCarExport=!0;function fu(e,t){return e.useMedium(t),aa}var ia=uu(),cs=function(){},hr=T.forwardRef(function(e,t){var r=T.useRef(null),s=T.useState({onScrollCapture:cs,onWheelCapture:cs,onTouchMoveCapture:cs}),n=s[0],a=s[1],i=e.forwardProps,l=e.children,u=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,m=e.sideCar,g=e.noRelative,p=e.noIsolation,w=e.inert,b=e.allowPinchZoom,k=e.as,C=k===void 0?"div":k,M=e.gapMode,I=oa(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),q=m,E=lu([r,t]),_=je(je({},I),n);return T.createElement(T.Fragment,null,d&&T.createElement(q,{sideCar:ia,removeScrollBar:c,shards:f,noRelative:g,noIsolation:p,inert:w,setCallbacks:a,allowPinchZoom:!!b,lockRef:r,gapMode:M}),i?T.cloneElement(T.Children.only(l),je(je({},_),{ref:E})):T.createElement(C,je({},_,{className:u,ref:E}),l))});hr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hr.classNames={fullWidth:fr,zeroRight:ur};var hu=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function pu(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=hu();return t&&e.setAttribute("nonce",t),e}function gu(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function mu(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var wu=function(){var e=0,t=null;return{add:function(r){e==0&&(t=pu())&&(gu(t,r),mu(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},yu=function(){var e=wu();return function(t,r){T.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},la=function(){var e=yu(),t=function(r){var s=r.styles,n=r.dynamic;return e(s,n),null};return t},bu={left:0,top:0,right:0,gap:0},ds=function(e){return parseInt(e||"",10)||0},vu=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],n=t[e==="padding"?"paddingRight":"marginRight"];return[ds(r),ds(s),ds(n)]},Cu=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return bu;var t=vu(e),r=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-r+t[2]-t[0])}},xu=la(),wt="data-scroll-locked",Pu=function(e,t,r,s){var n=e.left,a=e.top,i=e.right,l=e.gap;return r===void 0&&(r="margin"),`
196
+ .`.concat(ou,` {
197
+ overflow: hidden `).concat(s,`;
198
+ padding-right: `).concat(l,"px ").concat(s,`;
199
+ }
200
+ body[`).concat(wt,`] {
201
+ overflow: hidden `).concat(s,`;
202
+ overscroll-behavior: contain;
203
+ `).concat([t&&"position: relative ".concat(s,";"),r==="margin"&&`
204
+ padding-left: `.concat(n,`px;
205
+ padding-top: `).concat(a,`px;
206
+ padding-right: `).concat(i,`px;
207
+ margin-left:0;
208
+ margin-top:0;
209
+ margin-right: `).concat(l,"px ").concat(s,`;
210
+ `),r==="padding"&&"padding-right: ".concat(l,"px ").concat(s,";")].filter(Boolean).join(""),`
211
+ }
212
+
213
+ .`).concat(ur,` {
214
+ right: `).concat(l,"px ").concat(s,`;
215
+ }
216
+
217
+ .`).concat(fr,` {
218
+ margin-right: `).concat(l,"px ").concat(s,`;
219
+ }
220
+
221
+ .`).concat(ur," .").concat(ur,` {
222
+ right: 0 `).concat(s,`;
223
+ }
224
+
225
+ .`).concat(fr," .").concat(fr,` {
226
+ margin-right: 0 `).concat(s,`;
227
+ }
228
+
229
+ body[`).concat(wt,`] {
230
+ `).concat(nu,": ").concat(l,`px;
231
+ }
232
+ `)},ca=function(){var e=parseInt(document.body.getAttribute(wt)||"0",10);return isFinite(e)?e:0},Su=function(){T.useEffect(function(){return document.body.setAttribute(wt,(ca()+1).toString()),function(){var e=ca()-1;e<=0?document.body.removeAttribute(wt):document.body.setAttribute(wt,e.toString())}},[])},ku=function(e){var t=e.noRelative,r=e.noImportant,s=e.gapMode,n=s===void 0?"margin":s;Su();var a=T.useMemo(function(){return Cu(n)},[n]);return T.createElement(xu,{styles:Pu(a,!t,n,r?"":"!important")})},us=!1;if(typeof window<"u")try{var pr=Object.defineProperty({},"passive",{get:function(){return us=!0,!0}});window.addEventListener("test",pr,pr),window.removeEventListener("test",pr,pr)}catch{us=!1}var yt=us?{passive:!1}:!1,Eu=function(e){return e.tagName==="TEXTAREA"},da=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!Eu(e)&&r[t]==="visible")},Au=function(e){return da(e,"overflowY")},_u=function(e){return da(e,"overflowX")},ua=function(e,t){var r=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var n=fa(e,s);if(n){var a=ha(e,s),i=a[1],l=a[2];if(i>l)return!0}s=s.parentNode}while(s&&s!==r.body);return!1},Nu=function(e){var t=e.scrollTop,r=e.scrollHeight,s=e.clientHeight;return[t,r,s]},Lu=function(e){var t=e.scrollLeft,r=e.scrollWidth,s=e.clientWidth;return[t,r,s]},fa=function(e,t){return e==="v"?Au(t):_u(t)},ha=function(e,t){return e==="v"?Nu(t):Lu(t)},Tu=function(e,t){return e==="h"&&t==="rtl"?-1:1},Ou=function(e,t,r,s,n){var a=Tu(e,window.getComputedStyle(t).direction),i=a*s,l=r.target,u=t.contains(l),c=!1,d=i>0,f=0,m=0;do{if(!l)break;var g=ha(e,l),p=g[0],w=g[1],b=g[2],k=w-b-a*p;(p||k)&&fa(e,l)&&(f+=k,m+=p);var C=l.parentNode;l=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(d&&Math.abs(f)<1||!d&&Math.abs(m)<1)&&(c=!0),c},gr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},pa=function(e){return[e.deltaX,e.deltaY]},ga=function(e){return e&&"current"in e?e.current:e},Fu=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Mu=function(e){return`
233
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
234
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
235
+ `)},Iu=0,bt=[];function Uu(e){var t=T.useRef([]),r=T.useRef([0,0]),s=T.useRef(),n=T.useState(Iu++)[0],a=T.useState(la)[0],i=T.useRef(e);T.useEffect(function(){i.current=e},[e]),T.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(n));var w=su([e.lockRef.current],(e.shards||[]).map(ga),!0).filter(Boolean);return w.forEach(function(b){return b.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),w.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(n))})}}},[e.inert,e.lockRef.current,e.shards]);var l=T.useCallback(function(w,b){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!i.current.allowPinchZoom;var k=gr(w),C=r.current,M="deltaX"in w?w.deltaX:C[0]-k[0],I="deltaY"in w?w.deltaY:C[1]-k[1],q,E=w.target,_=Math.abs(M)>Math.abs(I)?"h":"v";if("touches"in w&&_==="h"&&E.type==="range")return!1;var P=ua(_,E);if(!P)return!0;if(P?q=_:(q=_==="v"?"h":"v",P=ua(_,E)),!P)return!1;if(!s.current&&"changedTouches"in w&&(M||I)&&(s.current=q),!q)return!0;var O=s.current||q;return Ou(O,b,w,O==="h"?M:I)},[]),u=T.useCallback(function(w){var b=w;if(!(!bt.length||bt[bt.length-1]!==a)){var k="deltaY"in b?pa(b):gr(b),C=t.current.filter(function(q){return q.name===b.type&&(q.target===b.target||b.target===q.shadowParent)&&Fu(q.delta,k)})[0];if(C&&C.should){b.cancelable&&b.preventDefault();return}if(!C){var M=(i.current.shards||[]).map(ga).filter(Boolean).filter(function(q){return q.contains(b.target)}),I=M.length>0?l(b,M[0]):!i.current.noIsolation;I&&b.cancelable&&b.preventDefault()}}},[]),c=T.useCallback(function(w,b,k,C){var M={name:w,delta:b,target:k,should:C,shadowParent:Du(k)};t.current.push(M),setTimeout(function(){t.current=t.current.filter(function(I){return I!==M})},1)},[]),d=T.useCallback(function(w){r.current=gr(w),s.current=void 0},[]),f=T.useCallback(function(w){c(w.type,pa(w),w.target,l(w,e.lockRef.current))},[]),m=T.useCallback(function(w){c(w.type,gr(w),w.target,l(w,e.lockRef.current))},[]);T.useEffect(function(){return bt.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",u,yt),document.addEventListener("touchmove",u,yt),document.addEventListener("touchstart",d,yt),function(){bt=bt.filter(function(w){return w!==a}),document.removeEventListener("wheel",u,yt),document.removeEventListener("touchmove",u,yt),document.removeEventListener("touchstart",d,yt)}},[]);var g=e.removeScrollBar,p=e.inert;return T.createElement(T.Fragment,null,p?T.createElement(a,{styles:Mu(n)}):null,g?T.createElement(ku,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Du(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Bu=fu(ia,Uu);var ma=T.forwardRef(function(e,t){return T.createElement(hr,je({},e,{ref:t,sideCar:Bu}))});ma.classNames=hr.classNames;var $u=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},vt=new WeakMap,mr=new WeakMap,wr={},fs=0,wa=function(e){return e&&(e.host||wa(e.parentNode))},qu=function(e,t){return t.map(function(r){if(e.contains(r))return r;var s=wa(r);return s&&e.contains(s)?s:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},Vu=function(e,t,r,s){var n=qu(t,Array.isArray(e)?e:[e]);wr[r]||(wr[r]=new WeakMap);var a=wr[r],i=[],l=new Set,u=new Set(n),c=function(f){!f||l.has(f)||(l.add(f),c(f.parentNode))};n.forEach(c);var d=function(f){!f||u.has(f)||Array.prototype.forEach.call(f.children,function(m){if(l.has(m))d(m);else try{var g=m.getAttribute(s),p=g!==null&&g!=="false",w=(vt.get(m)||0)+1,b=(a.get(m)||0)+1;vt.set(m,w),a.set(m,b),i.push(m),w===1&&p&&mr.set(m,!0),b===1&&m.setAttribute(r,"true"),p||m.setAttribute(s,"true")}catch(k){console.error("aria-hidden: cannot operate on ",m,k)}})};return d(t),l.clear(),fs++,function(){i.forEach(function(f){var m=vt.get(f)-1,g=a.get(f)-1;vt.set(f,m),a.set(f,g),m||(mr.has(f)||f.removeAttribute(s),mr.delete(f)),g||f.removeAttribute(r)}),fs--,fs||(vt=new WeakMap,vt=new WeakMap,mr=new WeakMap,wr={})}},ju=function(e,t,r){r===void 0&&(r="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),n=$u(e);return n?(s.push.apply(s,Array.from(n.querySelectorAll("[aria-live], script"))),Vu(s,n,r,"aria-hidden")):function(){return null}},yr="Dialog",[ya]=xd(yr),[Hu,Ue]=ya(yr),ba=e=>{const{__scopeDialog:t,children:r,open:s,defaultOpen:n,onOpenChange:a,modal:i=!0}=e,l=T.useRef(null),u=T.useRef(null),[c,d]=Ad({prop:s,defaultProp:n??!1,onChange:a,caller:yr});return o.jsx(Hu,{scope:t,triggerRef:l,contentRef:u,contentId:ss(),titleId:ss(),descriptionId:ss(),open:c,onOpenChange:d,onOpenToggle:T.useCallback(()=>d(f=>!f),[d]),modal:i,children:r})};ba.displayName=yr;var va="DialogTrigger",zu=T.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,n=Ue(va,r),a=ct(t,n.triggerRef);return o.jsx(Ke.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":gs(n.open),...s,ref:a,onClick:Re(e.onClick,n.onOpenToggle)})});zu.displayName=va;var hs="DialogPortal",[Wu,Ca]=ya(hs,{forceMount:void 0}),xa=e=>{const{__scopeDialog:t,forceMount:r,children:s,container:n}=e,a=Ue(hs,t);return o.jsx(Wu,{scope:t,forceMount:r,children:T.Children.map(s,i=>o.jsx(cr,{present:r||a.open,children:o.jsx(ra,{asChild:!0,container:n,children:i})}))})};xa.displayName=hs;var br="DialogOverlay",Pa=T.forwardRef((e,t)=>{const r=Ca(br,e.__scopeDialog),{forceMount:s=r.forceMount,...n}=e,a=Ue(br,e.__scopeDialog);return a.modal?o.jsx(cr,{present:s||a.open,children:o.jsx(Zu,{...n,ref:t})}):null});Pa.displayName=br;var Ku=zn("DialogOverlay.RemoveScroll"),Zu=T.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,n=Ue(br,r);return o.jsx(ma,{as:Ku,allowPinchZoom:!0,shards:[n.contentRef],children:o.jsx(Ke.div,{"data-state":gs(n.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),dt="DialogContent",Sa=T.forwardRef((e,t)=>{const r=Ca(dt,e.__scopeDialog),{forceMount:s=r.forceMount,...n}=e,a=Ue(dt,e.__scopeDialog);return o.jsx(cr,{present:s||a.open,children:a.modal?o.jsx(Gu,{...n,ref:t}):o.jsx(Ju,{...n,ref:t})})});Sa.displayName=dt;var Gu=T.forwardRef((e,t)=>{const r=Ue(dt,e.__scopeDialog),s=T.useRef(null),n=ct(t,r.contentRef,s);return T.useEffect(()=>{const a=s.current;if(a)return ju(a)},[]),o.jsx(ka,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Re(e.onCloseAutoFocus,a=>{a.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Re(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:Re(e.onFocusOutside,a=>a.preventDefault())})}),Ju=T.forwardRef((e,t)=>{const r=Ue(dt,e.__scopeDialog),s=T.useRef(!1),n=T.useRef(!1);return o.jsx(ka,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(s.current||r.triggerRef.current?.focus(),a.preventDefault()),s.current=!1,n.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const i=a.target;r.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&n.current&&a.preventDefault()}})}),ka=T.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:a,...i}=e,l=Ue(dt,r),u=T.useRef(null),c=ct(t,u);return ru(),o.jsxs(o.Fragment,{children:[o.jsx(Yn,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:n,onUnmountAutoFocus:a,children:o.jsx(Zn,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":gs(l.open),...i,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(Qu,{titleId:l.titleId}),o.jsx(ef,{contentRef:u,descriptionId:l.descriptionId})]})]})}),ps="DialogTitle",Ea=T.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,n=Ue(ps,r);return o.jsx(Ke.h2,{id:n.titleId,...s,ref:t})});Ea.displayName=ps;var Aa="DialogDescription",Xu=T.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,n=Ue(Aa,r);return o.jsx(Ke.p,{id:n.descriptionId,...s,ref:t})});Xu.displayName=Aa;var _a="DialogClose",Yu=T.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,n=Ue(_a,r);return o.jsx(Ke.button,{type:"button",...s,ref:t,onClick:Re(e.onClick,()=>n.onOpenChange(!1))})});Yu.displayName=_a;function gs(e){return e?"open":"closed"}var Na="DialogTitleWarning",[uh,La]=Cd(Na,{contentName:dt,titleName:ps,docsSlug:"dialog"}),Qu=({titleId:e})=>{const t=La(Na),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
236
+
237
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
238
+
239
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return T.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},Ru="DialogDescriptionWarning",ef=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${La(Ru).contentName}}.`;return T.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},tf=ba,rf=xa,sf=Pa,of=Sa,nf=Ea;const af=({open:e,countdown:t,onContinue:r,onLogout:s})=>{const n=a=>{if(a>=60){const i=Math.floor(a/60),l=a%60;return l===0?`${i} min`:`${i} min ${l} sec`}return`${a} sec`};return o.jsxs(tf,{open:e,onOpenChange:()=>{},children:[o.jsxs(rf,{children:[o.jsx(sf,{className:"session-security-overlay"}),o.jsxs(of,{className:"session-security-modal","aria-describedby":"session-security-description",onEscapeKeyDown:a=>a.preventDefault(),onPointerDownOutside:a=>a.preventDefault(),children:[o.jsx(nf,{className:"session-security-title",children:"Your session is about to expire"}),o.jsxs("div",{id:"session-security-description",className:"session-security-content",children:[o.jsxs("p",{className:"session-security-countdown",children:[o.jsx("span",{id:"session_security_counter",children:n(t)})," remaining"]}),o.jsx("p",{className:"session-security-instruction",children:"Click or type to extend your session."})]}),o.jsxs("div",{className:"session-security-actions",children:[o.jsx("button",{onClick:r,className:"session-security-btn session-security-btn-primary",children:"Continue Session"}),o.jsx("button",{onClick:s,className:"session-security-btn session-security-btn-secondary",children:"Logout"})]})]})]}),o.jsx("style",{children:`
240
+ .session-security-overlay {
241
+ position: fixed;
242
+ inset: 0;
243
+ background-color: rgba(0, 0, 0, 0.75);
244
+ z-index: 10001;
245
+ animation: fadeIn 200ms ease-out;
246
+ }
247
+
248
+ .session-security-modal {
249
+ position: fixed;
250
+ top: 50%;
251
+ left: 50%;
252
+ transform: translate(-50%, -50%);
253
+ background: white;
254
+ border-radius: 8px;
255
+ padding: 24px;
256
+ max-width: 420px;
257
+ width: 90%;
258
+ z-index: 10002;
259
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
260
+ 0 10px 10px -5px rgba(0, 0, 0, 0.04);
261
+ animation: contentShow 200ms ease-out;
262
+ }
263
+
264
+ .session-security-modal:focus {
265
+ outline: none;
266
+ }
267
+
268
+ .session-security-title {
269
+ margin: 0 0 16px 0;
270
+ font-size: 18px;
271
+ font-weight: 600;
272
+ color: #111827;
273
+ text-align: center;
274
+ }
275
+
276
+ .session-security-content {
277
+ text-align: center;
278
+ margin-bottom: 20px;
279
+ }
280
+
281
+ .session-security-countdown {
282
+ font-size: 24px;
283
+ font-weight: 700;
284
+ color: #dc2626;
285
+ margin: 0 0 12px 0;
286
+ }
287
+
288
+ .session-security-countdown span {
289
+ font-variant-numeric: tabular-nums;
290
+ }
291
+
292
+ .session-security-instruction {
293
+ margin: 0;
294
+ color: #6b7280;
295
+ font-size: 14px;
296
+ }
297
+
298
+ .session-security-actions {
299
+ display: flex;
300
+ gap: 12px;
301
+ justify-content: center;
302
+ }
303
+
304
+ .session-security-btn {
305
+ padding: 10px 20px;
306
+ border-radius: 6px;
307
+ font-size: 14px;
308
+ font-weight: 500;
309
+ cursor: pointer;
310
+ transition: all 0.2s ease;
311
+ border: none;
312
+ }
313
+
314
+ .session-security-btn-primary {
315
+ background: var(--color-brand-500, #5048ed);
316
+ color: white;
317
+ }
318
+
319
+ .session-security-btn-primary:hover {
320
+ filter: brightness(0.9);
321
+ }
322
+
323
+ .session-security-btn-primary:focus {
324
+ outline: 2px solid var(--color-brand-500, #5048ed);
325
+ outline-offset: 2px;
326
+ }
327
+
328
+ .session-security-btn-secondary {
329
+ background: #f3f4f6;
330
+ color: #374151;
331
+ border: 1px solid #d1d5db;
332
+ }
333
+
334
+ .session-security-btn-secondary:hover {
335
+ background: #e5e7eb;
336
+ border-color: #9ca3af;
337
+ }
338
+
339
+ .session-security-btn-secondary:focus {
340
+ outline: 2px solid #6b7280;
341
+ outline-offset: 2px;
342
+ }
343
+
344
+ @keyframes fadeIn {
345
+ from {
346
+ opacity: 0;
347
+ }
348
+ to {
349
+ opacity: 1;
350
+ }
351
+ }
352
+
353
+ @keyframes contentShow {
354
+ from {
355
+ opacity: 0;
356
+ transform: translate(-50%, -48%) scale(0.96);
357
+ }
358
+ to {
359
+ opacity: 1;
360
+ transform: translate(-50%, -50%) scale(1);
361
+ }
362
+ }
363
+ `})]})},lf=({config:e,children:t})=>{const{showWarning:r,countdown:s,renewSession:n,logoutNow:a}=vd({config:e,onWarning:()=>{console.log("Session security warning displayed")},onExpire:()=>{console.log("Session expired")},onActivity:()=>{}});return!e||!e.enabled?o.jsx(o.Fragment,{children:t}):o.jsxs(o.Fragment,{children:[t,o.jsx(af,{open:r,countdown:s,onContinue:n,onLogout:a})]})},Ta=()=>{const e=K.useNavigate(),[t,r]=h.useState(null);return h.useEffect(()=>{(async()=>{try{const n=await Js();n.success||n.responseStatus===401?setTimeout(()=>{e("/app/login")},1500):(r(n.response?.message||"An error occurred while logging out. Redirecting to login..."),setTimeout(()=>{e("/app/login")},2e3))}catch(n){console.error("Logout error:",n),r("An error occurred. Redirecting to login..."),setTimeout(()=>{e("/app/login")},2e3)}})()},[e]),o.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",backgroundColor:"#f5f5f5"},children:[o.jsx("div",{style:{backgroundColor:"white",padding:"40px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",textAlign:"center",maxWidth:"400px",width:"100%"},children:t?o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{marginBottom:"20px",color:"#ef4444"},children:o.jsx("svg",{width:"50",height:"50",fill:"none",viewBox:"0 0 24 24",style:{margin:"0 auto"},children:o.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),o.jsx("h2",{style:{fontSize:"24px",fontWeight:"600",marginBottom:"12px",color:"#333"},children:"Logout Error"}),o.jsx("p",{style:{fontSize:"16px",color:"#666",margin:0},children:t})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{marginBottom:"20px"},children:o.jsx("div",{style:{width:"50px",height:"50px",border:"3px solid #f3f3f3",borderTop:"3px solid var(--primary-color, #3b82f6)",borderRadius:"50%",margin:"0 auto",animation:"spin 1s linear infinite"}})}),o.jsx("h2",{style:{fontSize:"24px",fontWeight:"600",marginBottom:"12px",color:"#333"},children:"Logging you out..."}),o.jsx("p",{style:{fontSize:"16px",color:"#666",margin:0},children:"Please wait while we securely log you out."})]})}),o.jsx("style",{children:`
191
364
  @keyframes spin {
192
365
  0% { transform: rotate(0deg); }
193
366
  100% { transform: rotate(360deg); }
194
367
  }
195
- `})]})},kl=()=>{const{menu:e,profileInfo:t,initializerEndpoint:r}=Pe();return e.length===0&&t?.user_role&&t.user_role,s.jsx("div",{className:"flex flex-col items-center justify-center h-screen text-center p-6 bg-gray-100",children:s.jsxs("div",{className:"bg-white rounded-xl p-12 shadow-md max-w-2xl w-full",children:[s.jsx("h1",{className:"text-[40px] m-0 text-red-500 font-bold leading-none",children:"⚙️"}),s.jsx("h2",{className:"text-2xl my-4 text-gray-800 font-semibold",children:"Configuration Error"}),s.jsx("p",{className:"text-base text-gray-600 mb-6 leading-relaxed",children:"The application is trying to fetch configuration from:"}),s.jsx("code",{className:"block bg-gray-50 border border-gray-200 rounded-md p-3 text-sm text-gray-800 font-mono mb-6 break-all",children:r}),s.jsxs("div",{className:"text-left mb-8 p-4 bg-gray-50 rounded-lg",children:[s.jsx("p",{className:"text-sm text-gray-600 mb-3 font-semibold",children:"The response is either missing or invalid. Please check:"}),s.jsxs("ul",{className:"text-sm text-gray-600 pl-5 m-0 list-disc space-y-2 pl-4",children:[s.jsx("li",{children:"Appbuilder package routes are configured correctly"}),s.jsx("li",{children:"Required policies are properly mapped"}),s.jsx("li",{children:"The endpoint is accessible and returns valid data"})]})]}),s.jsxs("div",{className:"flex gap-3 justify-center",children:[s.jsx(p.Button,{type:"primary",onClick:()=>window.location.reload(),children:"Retry"}),s.jsx(p.Button,{onClick:()=>window.location.href="/app",children:"Go Home"})]}),s.jsx("p",{className:"text-xs text-gray-500 mt-6",children:"Contact your administrator if this issue persists."})]})})},jo=({customPages:e})=>{const t=G.useParams(),o=`${G.useLocation().pathname}-${Object.values(t).join("-")}`;return s.jsx(ft,{customPages:e},o)},Al=({customPages:e})=>{const{routes:t,loading:r,menu:o,pageTypeRegistry:a,registryError:n}=Pe(),i=o.length>0?o[0].uri:null;if(r)return s.jsx("div",{className:"zango-loading",children:"Loading..."});if(n)return s.jsxs("div",{className:"zango-error",children:["Failed to load page registry: ",n]});const c=[],d=[];return a&&t.forEach(l=>{const u=a[l.page_type];u&&u.standalone?c.push(l):d.push(l)}),s.jsxs(G.Routes,{children:[s.jsx(G.Route,{path:"app/login/*",element:s.jsx(wr,{basePath:"/app/login"})}),s.jsx(G.Route,{path:"app/logout",element:s.jsx(Vo,{})}),s.jsx(G.Route,{path:"app/configuration-error",element:s.jsx(kl,{})}),c.map(l=>{const u=l.path.startsWith("/")?l.path.slice(1):l.path;return s.jsxs(g.Fragment,{children:[s.jsx(G.Route,{path:`${u}/*`,element:s.jsx(ft,{customPages:e,forceRoute:l})}),s.jsx(G.Route,{path:u,element:s.jsx(ft,{customPages:e,forceRoute:l})})]},l.path)}),s.jsxs(G.Route,{path:"/",element:s.jsx(Io,{}),children:[s.jsx(G.Route,{index:!0,element:i?s.jsx(G.Navigate,{to:i}):s.jsx("div",{children:"No menu items available"})}),s.jsx(G.Route,{path:"app",element:s.jsx("div",{className:"zango-loading",children:"Redirecting..."})}),d.map(l=>{const u=l.path.startsWith("/")?l.path.slice(1):l.path;return s.jsxs(g.Fragment,{children:[s.jsx(G.Route,{path:`${u}/*`,element:s.jsx(jo,{customPages:e})}),s.jsx(G.Route,{path:u,element:s.jsx(jo,{customPages:e})})]},l.path)})]}),s.jsx(G.Route,{path:"*",element:s.jsx(ft,{customPages:e,forceRoute:{path:"*",page_type:"404"}})}),s.jsx(G.Route,{path:"/404",element:s.jsx(ft,{customPages:e,forceRoute:{path:"/404",page_type:"404"}})})]})},_l=({customPages:e})=>s.jsxs(s.Fragment,{children:[s.jsx($o,{}),s.jsx(Al,{customPages:e})]}),Ll=({config:e={},customPages:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},authConfig:i={},appInitializerEndpoint:c})=>(c&&typeof window<"u"&&(console.log("app init endpoint here",c),window.app_initializer_endpoint=c),s.jsx(G.BrowserRouter,{children:s.jsx(Lo,{config:e,layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,authConfig:i,children:s.jsx(_l,{customPages:t})})})),Tl=({customPages:e={},config:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},authConfig:i={},appInitializerEndpoint:c})=>s.jsxs(s.Fragment,{children:[s.jsx(Ll,{config:t,customPages:e,layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,authConfig:i,appInitializerEndpoint:c}),s.jsx(p.Toaster,{position:"bottom-right"})]});class Nl{constructor(){this.setupInterceptors()}handleRedirect(t){if(t){const r=window.location.pathname+window.location.search+window.location.hash;if(r==="/app/logout/"||r==="/app/logout"){window.location.href=t;return}const o=encodeURIComponent(r),a=`${t}?next=${o}`;window.location.href=a}}setupInterceptors(){const t=window.fetch,r=this;window.fetch=async(...n)=>{try{const[i,c={}]=n,d=typeof i=="string"?i:i.toString();if(d.startsWith("http")&&!d.startsWith(window.location.origin))return await t(i,c);const u=Date.now().toString(),h=new Headers(c.headers||{});h.set("X-Client-Timestamp",u),h.set("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),h.set("X-Client-Platform",navigator.platform);const m={...c,headers:h},w=await t(i,m),f=window.location.origin+"/login/";return w.url&&w.url===f&&r.handleRedirect("/app/login/"),w}catch(i){throw i}};const o=XMLHttpRequest.prototype.open,a=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(...n){return this._requestUrl=n[1],o.apply(this,n)},XMLHttpRequest.prototype.send=function(...n){const i=this,c=this._requestUrl||"";if(!(c.startsWith("http")&&!c.startsWith(window.location.origin))){const l=Date.now().toString();this.setRequestHeader("X-Client-Timestamp",l),this.setRequestHeader("X-User-Agent",navigator.userAgent),this.setRequestHeader("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),this.setRequestHeader("X-Client-Platform",navigator.platform)}return this.addEventListener("load",function(){const l=i.responseURL||i._requestUrl,u=window.location.origin+"/login/";l&&l===u&&r.handleRedirect("/app/login/")}),a.apply(this,n)}}}new Nl,q.AppProvider=Lo,q.CachedLogo=Pr,q.CrudPage=is,q.CustomPageFallback=cs,q.CustomPageLoader=ds,q.DocumentHead=$o,q.Layout=Io,q.LoginPage=wr,q.LogoutPage=Vo,q.Navbar=No,q.NotFoundPage=zt,q.SmartLink=Mt,q.Topbar=qo,q.UserProfileDrawer=Bo,q.ZangoApp=Tl,q.buildApiUrl=Ce,q.callApi=ve,q.callDeleteApi=_r,q.callGetApi=Sr,q.callPatchApi=Lr,q.callPostApi=kr,q.callPutApi=Ar,q.changePassword=Or,q.changeRole=Wr,q.deleteCookie=Ne,q.fetchAppInitData=jr,q.fetchUserProfile=Dr,q.fetchUserSessions=Hr,q.generateCSSVariables=yt,q.generatePalette=je,q.generateQueryString=Ro,q.getApiConfig=La,q.getApiTimeout=Qo,q.getApiUrl=pt,q.getAppInitData=Tr,q.getColor=as,q.getContrastColor=Aa,q.getCookie=yr,q.getEndpoint=Xo,q.getUserProfile=Nr,q.getUserSessions=Br,q.isAuthenticatedViaCookie=Fo,q.isLightColor=os,q.logoCache=Ve,q.logout=$r,q.logoutAllSessions=Ir,q.logoutSession=qr,q.performAppLogout=Kr,q.performDirectLogout=Jr,q.performLogout=Vr,q.removeAllSessions=Gr,q.removeSession=Zr,q.saveUserProfile=gt,q.setCookie=Eo,q.setTwoFactor=ta,q.switchRole=Ur,q.toggleTwoFactor=Mr,q.updatePassword=zr,q.updateSvgColors=Ut,q.updateUserProfile=Er,q.uploadPhoto=ea,q.uploadProfilePhoto=Fr,q.useApiConfig=at,q.useAppContext=Pe,q.useRouteConfig=_a,q.useSmartNavigation=To}));
368
+ `})]})},cf=()=>{const{menu:e,profileInfo:t,initializerEndpoint:r}=Ne();return e.length===0&&t?.user_role&&t.user_role,o.jsx("div",{className:"flex flex-col items-center justify-center h-screen text-center p-6 bg-gray-100",children:o.jsxs("div",{className:"bg-white rounded-xl p-12 shadow-md max-w-2xl w-full",children:[o.jsx("h1",{className:"text-[40px] m-0 text-red-500 font-bold leading-none",children:"⚙️"}),o.jsx("h2",{className:"text-2xl my-4 text-gray-800 font-semibold",children:"Configuration Error"}),o.jsx("p",{className:"text-base text-gray-600 mb-6 leading-relaxed",children:"The application is trying to fetch configuration from:"}),o.jsx("code",{className:"block bg-gray-50 border border-gray-200 rounded-md p-3 text-sm text-gray-800 font-mono mb-6 break-all",children:r}),o.jsxs("div",{className:"text-left mb-8 p-4 bg-gray-50 rounded-lg",children:[o.jsx("p",{className:"text-sm text-gray-600 mb-3 font-semibold",children:"The response is either missing or invalid. Please check:"}),o.jsxs("ul",{className:"text-sm text-gray-600 pl-5 m-0 list-disc space-y-2 pl-4",children:[o.jsx("li",{children:"Appbuilder package routes are configured correctly"}),o.jsx("li",{children:"Required policies are properly mapped"}),o.jsx("li",{children:"The endpoint is accessible and returns valid data"})]})]}),o.jsxs("div",{className:"flex gap-3 justify-center",children:[o.jsx(y.Button,{type:"primary",onClick:()=>window.location.reload(),children:"Retry"}),o.jsx(y.Button,{onClick:()=>window.location.href="/app",children:"Go Home"})]}),o.jsx("p",{className:"text-xs text-gray-500 mt-6",children:"Contact your administrator if this issue persists."})]})})},Oa=({customPages:e})=>{const t=K.useParams(),s=`${K.useLocation().pathname}-${Object.values(t).join("-")}`;return o.jsx(Mt,{customPages:e},s)},Fa=({customPages:e})=>{const{routes:t,loading:r,menu:s,pageTypeRegistry:n,registryError:a}=Ne(),i=s.length>0?s[0].uri:null;if(r)return o.jsx("div",{className:"zango-loading",children:"Loading..."});if(a)return o.jsxs("div",{className:"zango-error",children:["Failed to load page registry: ",a]});const l=[],u=[];return n&&t.forEach(c=>{const d=n[c.page_type];d&&d.standalone?l.push(c):u.push(c)}),o.jsxs(K.Routes,{children:[o.jsx(K.Route,{path:"app/login/*",element:o.jsx(or,{basePath:"/app/login"})}),o.jsx(K.Route,{path:"app/logout",element:o.jsx(Ta,{})}),o.jsx(K.Route,{path:"app/configuration-error",element:o.jsx(cf,{})}),l.map(c=>{const d=c.path.startsWith("/")?c.path.slice(1):c.path;return o.jsxs(h.Fragment,{children:[o.jsx(K.Route,{path:`${d}/*`,element:o.jsx(Mt,{customPages:e,forceRoute:c})}),o.jsx(K.Route,{path:d,element:o.jsx(Mt,{customPages:e,forceRoute:c})})]},c.path)}),o.jsxs(K.Route,{path:"/",element:o.jsx(qn,{}),children:[o.jsx(K.Route,{index:!0,element:i?o.jsx(K.Navigate,{to:i}):o.jsx("div",{children:"No menu items available"})}),o.jsx(K.Route,{path:"app",element:o.jsx("div",{className:"zango-loading",children:"Redirecting..."})}),u.map(c=>{const d=c.path.startsWith("/")?c.path.slice(1):c.path;return o.jsxs(h.Fragment,{children:[o.jsx(K.Route,{path:`${d}/*`,element:o.jsx(Oa,{customPages:e})}),o.jsx(K.Route,{path:d,element:o.jsx(Oa,{customPages:e})})]},c.path)})]}),o.jsx(K.Route,{path:"*",element:o.jsx(Mt,{customPages:e,forceRoute:{path:"*",page_type:"404"}})}),o.jsx(K.Route,{path:"/404",element:o.jsx(Mt,{customPages:e,forceRoute:{path:"/404",page_type:"404"}})})]})},df=({customPages:e})=>{const{appData:t,sessionSecurity:r}=Ne(),s=t&&!t.is_user_anonymous,n={enabled:!0,ping_url:"/session_security/ping/",warn_after:1700,expire_after:1800},a=s?r?{...n,...r,enabled:!0}:n:null;return o.jsxs(o.Fragment,{children:[o.jsx(Vn,{}),s&&a?o.jsx(lf,{config:a,children:o.jsx(Fa,{customPages:e})}):o.jsx(Fa,{customPages:e})]})},uf=({config:e={},customPages:t={},layoutConfig:r={},topbarConfig:s={},navbarConfig:n={},customComponents:a={},authConfig:i={},appInitializerEndpoint:l})=>(l&&typeof window<"u"&&(window.app_initializer_endpoint=l),o.jsx(K.BrowserRouter,{children:o.jsx(Tn,{config:e,layoutConfig:r,topbarConfig:s,navbarConfig:n,customComponents:a,authConfig:i,children:o.jsx(df,{customPages:t})})})),ff=({customPages:e={},config:t={},layoutConfig:r={},topbarConfig:s={},navbarConfig:n={},customComponents:a={},authConfig:i={},appInitializerEndpoint:l})=>o.jsxs(o.Fragment,{children:[o.jsx(uf,{config:t,customPages:e,layoutConfig:r,topbarConfig:s,navbarConfig:n,customComponents:a,authConfig:i,appInitializerEndpoint:l}),o.jsx(y.Toaster,{position:"bottom-right",expand:!0,richColors:!0,toastOptions:{className:"!rounded-[8px]"}})]});class hf{constructor(){this.setupInterceptors()}handleRedirect(t){if(t){const r=window.location.pathname+window.location.search+window.location.hash;if(r==="/app/logout/"||r==="/app/logout"){window.location.href=t;return}const s=encodeURIComponent(r),n=`${t}?next=${s}`;window.location.href=n}}setupInterceptors(){const t=window.fetch,r=this;window.fetch=async(...a)=>{try{const[i,l={}]=a,u=typeof i=="string"?i:i.toString();if(u.startsWith("http")&&!u.startsWith(window.location.origin))return await t(i,l);const d=Date.now().toString(),f=new Headers(l.headers||{});f.set("X-Client-Timestamp",d),f.set("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),f.set("X-Client-Platform",navigator.platform);const m={...l,headers:f},g=await t(i,m),p=window.location.origin+"/login/";return g.url&&g.url===p&&r.handleRedirect("/app/login/"),g}catch(i){throw i}};const s=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(...a){return this._requestUrl=a[1],s.apply(this,a)},XMLHttpRequest.prototype.send=function(...a){const i=this,l=this._requestUrl||"";if(!(l.startsWith("http")&&!l.startsWith(window.location.origin))){const c=Date.now().toString();this.setRequestHeader("X-Client-Timestamp",c),this.setRequestHeader("X-User-Agent",navigator.userAgent),this.setRequestHeader("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),this.setRequestHeader("X-Client-Platform",navigator.platform)}return this.addEventListener("load",function(){const c=i.responseURL||i._requestUrl,d=window.location.origin+"/login/";c&&c===d&&r.handleRedirect("/app/login/")}),n.apply(this,a)}}}new hf;const Ma=()=>o.jsxs("div",{className:"p-6",children:[o.jsx("h1",{className:"text-3xl font-bold mb-4",children:"Welcome to Zango CRM Dashboard"}),o.jsxs("p",{className:"text-gray-600",children:["This is your custom dashboard page. You can modify this file at:",o.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded ml-2",children:"src/custom/pages/Dashboard.js"})]}),o.jsxs("div",{className:"mt-8 grid grid-cols-1 md:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"bg-white p-6 rounded-lg shadow",children:[o.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Custom Pages"}),o.jsx("p",{className:"text-gray-600",children:"Create custom pages in the src/custom/pages directory"})]}),o.jsxs("div",{className:"bg-white p-6 rounded-lg shadow",children:[o.jsx("h2",{className:"text-xl font-semibold mb-2",children:"CRUD Operations"}),o.jsx("p",{className:"text-gray-600",children:"Automatic CRUD pages based on API configuration"})]}),o.jsxs("div",{className:"bg-white p-6 rounded-lg shadow",children:[o.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Profile360"}),o.jsx("p",{className:"text-gray-600",children:"Comprehensive entity profile pages"})]})]})]}),pf=Object.freeze({__proto__:null,default:Ma}),gf=Object.freeze({__proto__:null,Dashboard:Ma}),mf=Object.freeze({__proto__:null,default:{crud:{component:kr,includeBasePath:!0,propsBuilder:({matchedRoutePath:e})=>({})},training:{component:lo,includeBasePath:!0,propsBuilder:({matchedRoutePath:e})=>({})},login:{component:or,includeBasePath:!0,standalone:!0,propsBuilder:({matchedRoutePath:e})=>({})},custom:{component:null,includeBasePath:!1,handler:({customPages:e,customPagePath:t,location:r})=>{const s=e[t];return s?h.createElement(s):h.createElement(Ar,{componentName:t})}},404:{component:Et,standalone:!0,includeBasePath:!1,propsBuilder:()=>({})},default:{component:Et,includeBasePath:!1,standalone:!0,propsBuilder:({pageType:e})=>({message:`Unknown page type: ${e}`})}}});B.AppProvider=Tn,B.AuthConfigProvider=wn,B.AuthProvider=Cn,B.CachedLogo=xs,B.CrudPage=kr,B.CustomPageFallback=uo,B.CustomPageLoader=Ar,B.DocumentHead=Vn,B.Layout=qn,B.LoginContext=Zr,B.LoginPage=or,B.LogoutPage=Ta,B.Navbar=Fn,B.NotFoundPage=Et,B.OTPLoginForm=cd,B.PasswordLoginForm=ld,B.RoleSelection=rr,B.SSOButtons=id,B.SmartLink=ar,B.Topbar=$n,B.UserProfileDrawer=Bn,B.ZangoApp=ff,B.authApi=jr,B.authService=j,B.buildApiUrl=xe,B.callApi=Pe,B.callDeleteApi=Es,B.callGetApi=Ps,B.callPatchApi=As,B.callPostApi=Ss,B.callPutApi=ks,B.changePassword=Os,B.changeRole=Ws,B.configApi=un,B.deleteCookie=Ve,B.fetchAppInitData=Vs,B.fetchUserProfile=js,B.fetchUserSessions=Hs,B.generateCSSVariables=Vt,B.generatePalette=rt,B.generateQueryString=Xa,B.getApiConfig=ki,B.getApiTimeout=Ga,B.getApiUrl=Dt,B.getAppInitData=_s,B.getColor=ao,B.getContrastColor=Pi,B.getCookie=ts,B.getEndpoint=Za,B.getUserProfile=Ns,B.getUserSessions=Is,B.isAuthenticatedViaCookie=In,B.isLightColor=no,B.logoCache=tt,B.logout=Bs,B.logoutAllSessions=Ds,B.logoutSession=Us,B.mfaApi=zr,B.otpApi=Hr,B.passwordApi=mt,B.performAppLogout=Gs,B.performDirectLogout=Js,B.performLogout=$s,B.pingSession=Xs,B.pingSessionSecurity=qs,B.removeAllSessions=Zs,B.removeSession=Ks,B.roleApi=fn,B.saveUserProfile=Bt,B.setCookie=Mn,B.setTwoFactor=Qa,B.switchRole=Ms,B.toggleTwoFactor=Fs,B.updatePassword=zs,B.updateSvgColors=ir,B.updateUserProfile=Ls,B.uploadPhoto=Ya,B.uploadProfilePhoto=Ts,B.useApiConfig=kt,B.useAppContext=Ne,B.useAuth=Xr,B.useAuthConfig=_e,B.useAuthContext=Ye,B.useLoginContext=Gr,B.useRouteConfig=Si,B.useSmartNavigation=On}));
196
369
  //# sourceMappingURL=zango-crm-framework.umd.cjs.map