@zango-core/crm-framework 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PageTypeRegistry-Cu_XV_iY.js → PageTypeRegistry-0yDAbJO_.js} +2 -2
- package/dist/{PageTypeRegistry-Cu_XV_iY.js.map → PageTypeRegistry-0yDAbJO_.js.map} +1 -1
- package/dist/{index.framework-Bu5-4Nwj.js → index.framework-C8rWvyqw.js} +4964 -4592
- package/dist/index.framework-C8rWvyqw.js.map +1 -0
- package/dist/zango-crm-framework.js +69 -65
- package/dist/zango-crm-framework.umd.cjs +40 -40
- package/dist/zango-crm-framework.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/index.framework-Bu5-4Nwj.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
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(q,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):(q=typeof globalThis<"u"?globalThis:q||self,o(q.ZangoCRMFramework={},q["react/jsx-runtime"],q.React,q.ReactRouterDOM,q.components,q.ReactDOM,q.table))})(this,(function(q,o,h,J,y,Es,Ka){"use strict";function _s(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=_s(h),Za=_s(Es),Ga="zango_app_logo_cache",Ja=1440*60*1e3;class Xa{constructor(){this.cacheKey=Ga}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>Ja}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 st=new Xa,Ya=()=>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"})]}),As=({logoUrl:e,appName:t,height:r="28px",linkTo:s="/"})=>{const[n,a]=h.useState(()=>{const f=st.getCachedLogo();return f&&(f.base64Data||f.url)?f.base64Data||f.url:e||null}),[i,l]=h.useState(!1);h.useEffect(()=>{e&&st.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=st.getCachedLogo();f&&n===f.base64Data&&st.clearCache()},[n]),c=h.useCallback(()=>{l(!1)},[]),d=()=>i||!n?o.jsx(Ya,{}):o.jsx("img",{src:n,height:r,alt:t||"Logo",onError:u,onLoad:c,style:{maxHeight:r,objectFit:"contain"}});return o.jsx(J.Link,{to:s,className:"logo-link",children:d()})},$t=(e,t={})=>`${t.baseUrl||""}${e}`,Qa=(e,t={})=>t.endpoints?.[e]||"",Ra=(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 Pt="";function ei(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 kt=async()=>({"X-Csrftoken":ei("csrftoken")}),Ns=async({fullUrl:e})=>{const t=`${Pt}${e}${e.includes("?")?"&":"?"}_t=${Date.now()}`;return await fetch(t,{method:"GET",redirect:"follow",headers:{...await kt(),"Content-Type":"application/json"}})},Ls=async({fullUrl:e,payload:t})=>await fetch(Pt+e,{method:"POST",redirect:"follow",headers:{...await kt(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Ts=async({fullUrl:e,payload:t})=>await fetch(Pt+e,{method:"PUT",redirect:"follow",headers:{...await kt(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Os=async({fullUrl:e,payload:t})=>await fetch(Pt+e,{method:"DELETE",redirect:"follow",headers:{...await kt(),"Content-Type":"application/json"},body:t instanceof FormData?t:JSON.stringify(t)}),Fs=async({fullUrl:e,payload:t})=>await fetch(Pt+e,{method:"PATCH",redirect:"follow",headers:{...await kt(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Se=async e=>{let t;try{const r=$t(e.url);switch(e.type){case"POST":t=await Ls({fullUrl:r,payload:e.payload});break;case"PUT":t=await Ts({fullUrl:r,payload:e.payload});break;case"PATCH":t=await Fs({fullUrl:r,payload:e.payload});break;case"DELETE":t=await Os({fullUrl:r,payload:e.payload});break;case"GET":default:t=await Ns({fullUrl:r})}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}}},ti=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}`:""},Ms=()=>{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"}},Is=()=>({url:xe("/api/v1/profile"),type:"GET"}),Us=e=>({url:xe("/api/v1/profile"),type:"PUT",payload:e}),Ds=e=>({url:xe("/api/v1/profile/photo"),type:"POST",payload:e}),Bs=e=>({url:xe("/api/v1/appauth/password/change/"),type:"PUT",payload:e}),$s=e=>({url:xe("/api/v1/profile/two-factor"),type:"POST",payload:e}),qs=e=>({url:xe(`/api/v1/appauth/role/switch/?role=${encodeURIComponent(e)}`),type:"POST"}),Vs=()=>({url:xe("/api/v1/appauth/sessions/"),type:"GET"}),js=e=>({url:xe("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:[e]}}),Hs=e=>({url:xe("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:e}}),zs=()=>({url:xe("/api/v1/appauth/logout"),type:"DELETE"}),Ws=()=>({url:xe("/logout"),type:"POST"}),Ks=(e,t)=>({url:xe(`${e}${e.includes("?")?"&":"?"}idleFor=${t}`),type:"GET"}),Zs=async()=>Se(Ms()),Gs=async()=>Se(Is()),Js=async()=>Se(Vs()),qt=async e=>Se(Us(e)),ri=async e=>Se(Ds(e)),Xs=async e=>Se(Bs(e)),si=async e=>Se($s({enabled:e})),Ys=async e=>Se(qs(e)),Qs=async e=>Se(js(e)),Rs=async e=>Se(Hs(e)),eo=async()=>Se(zs()),to=async()=>Se(Ws()),ro=async(e,t)=>Se(Ks(e,t));function Vt(e){"@babel/helpers - typeof";return Vt=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},Vt(e)}var oi=/^\s+/,ni=/\s+$/;function K(e,t){if(e=e||"",t=t||{},e instanceof K)return e;if(!(this instanceof K))return new K(e,t);var r=ai(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}K.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=lo(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=oo(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=oo(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=so(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=so(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 no(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return di(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(ce(this._r,255)*100)+"%",g:Math.round(ce(this._g,255)*100)+"%",b:Math.round(ce(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(ce(this._r,255)*100)+"%, "+Math.round(ce(this._g,255)*100)+"%, "+Math.round(ce(this._b,255)*100)+"%)":"rgba("+Math.round(ce(this._r,255)*100)+"%, "+Math.round(ce(this._g,255)*100)+"%, "+Math.round(ce(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:xi[no(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+ao(this._r,this._g,this._b,this._a),s=r,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=K(t);s="#"+ao(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 K(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(pi,arguments)},brighten:function(){return this._applyModification(gi,arguments)},darken:function(){return this._applyModification(mi,arguments)},desaturate:function(){return this._applyModification(ui,arguments)},saturate:function(){return this._applyModification(fi,arguments)},greyscale:function(){return this._applyModification(hi,arguments)},spin:function(){return this._applyModification(wi,arguments)},_applyCombination:function(t,r){return t.apply(null,[this].concat([].slice.call(r)))},analogous:function(){return this._applyCombination(vi,arguments)},complement:function(){return this._applyCombination(yi,arguments)},monochromatic:function(){return this._applyCombination(Ci,arguments)},splitcomplement:function(){return this._applyCombination(bi,arguments)},triad:function(){return this._applyCombination(io,[3])},tetrad:function(){return this._applyCombination(io,[4])}},K.fromRatio=function(e,t){if(Vt(e)=="object"){var r={};for(var s in e)e.hasOwnProperty(s)&&(s==="a"?r[s]=e[s]:r[s]=Et(e[s]));e=r}return K(e,t)};function ai(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=Ei(e)),Vt(e)=="object"&&(We(e.r)&&We(e.g)&&We(e.b)?(t=ii(e.r,e.g,e.b),i=!0,l=String(e.r).substr(-1)==="%"?"prgb":"rgb"):We(e.h)&&We(e.s)&&We(e.v)?(s=Et(e.s),n=Et(e.v),t=ci(e.h,s,n),i=!0,l="hsv"):We(e.h)&&We(e.s)&&We(e.l)&&(s=Et(e.s),a=Et(e.l),t=li(e.h,s,a),i=!0,l="hsl"),e.hasOwnProperty("a")&&(r=e.a)),r=lo(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 ii(e,t,r){return{r:ce(e,255)*255,g:ce(t,255)*255,b:ce(r,255)*255}}function so(e,t,r){e=ce(e,255),t=ce(t,255),r=ce(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 li(e,t,r){var s,n,a;e=ce(e,360),t=ce(t,100),r=ce(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 oo(e,t,r){e=ce(e,255),t=ce(t,255),r=ce(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 ci(e,t,r){e=ce(e,360)*6,t=ce(t,100),r=ce(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 no(e,t,r,s){var n=[Fe(Math.round(e).toString(16)),Fe(Math.round(t).toString(16)),Fe(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 di(e,t,r,s,n){var a=[Fe(Math.round(e).toString(16)),Fe(Math.round(t).toString(16)),Fe(Math.round(r).toString(16)),Fe(co(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 ao(e,t,r,s){var n=[Fe(co(s)),Fe(Math.round(e).toString(16)),Fe(Math.round(t).toString(16)),Fe(Math.round(r).toString(16))];return n.join("")}K.equals=function(e,t){return!e||!t?!1:K(e).toRgbString()==K(t).toRgbString()},K.random=function(){return K.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function ui(e,t){t=t===0?0:t||10;var r=K(e).toHsl();return r.s-=t/100,r.s=jt(r.s),K(r)}function fi(e,t){t=t===0?0:t||10;var r=K(e).toHsl();return r.s+=t/100,r.s=jt(r.s),K(r)}function hi(e){return K(e).desaturate(100)}function pi(e,t){t=t===0?0:t||10;var r=K(e).toHsl();return r.l+=t/100,r.l=jt(r.l),K(r)}function gi(e,t){t=t===0?0:t||10;var r=K(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)))),K(r)}function mi(e,t){t=t===0?0:t||10;var r=K(e).toHsl();return r.l-=t/100,r.l=jt(r.l),K(r)}function wi(e,t){var r=K(e).toHsl(),s=(r.h+t)%360;return r.h=s<0?360+s:s,K(r)}function yi(e){var t=K(e).toHsl();return t.h=(t.h+180)%360,K(t)}function io(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var r=K(e).toHsl(),s=[K(e)],n=360/t,a=1;a<t;a++)s.push(K({h:(r.h+a*n)%360,s:r.s,l:r.l}));return s}function bi(e){var t=K(e).toHsl(),r=t.h;return[K(e),K({h:(r+72)%360,s:t.s,l:t.l}),K({h:(r+216)%360,s:t.s,l:t.l})]}function vi(e,t,r){t=t||6,r=r||30;var s=K(e).toHsl(),n=360/r,a=[K(e)];for(s.h=(s.h-(n*t>>1)+720)%360;--t;)s.h=(s.h+n)%360,a.push(K(s));return a}function Ci(e,t){t=t||6;for(var r=K(e).toHsv(),s=r.h,n=r.s,a=r.v,i=[],l=1/t;t--;)i.push(K({h:s,s:n,v:a})),a=(a+l)%1;return i}K.mix=function(e,t,r){r=r===0?0:r||50;var s=K(e).toRgb(),n=K(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 K(i)},K.readability=function(e,t){var r=K(e),s=K(t);return(Math.max(r.getLuminance(),s.getLuminance())+.05)/(Math.min(r.getLuminance(),s.getLuminance())+.05)},K.isReadable=function(e,t,r){var s=K.readability(e,t),n,a;switch(a=!1,n=_i(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},K.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=K.readability(e,t[c]),a>n&&(n=a,s=K(t[c]));return K.isReadable(e,s,{level:l,size:u})||!i?s:(r.includeFallbackColors=!1,K.mostReadable(e,["#fff","#000"],r))};var Er=K.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"},xi=K.hexNames=Si(Er);function Si(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r]]=r);return t}function lo(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function ce(e,t){Pi(e)&&(e="100%");var r=ki(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 jt(e){return Math.min(1,Math.max(0,e))}function _e(e){return parseInt(e,16)}function Pi(e){return typeof e=="string"&&e.indexOf(".")!=-1&&parseFloat(e)===1}function ki(e){return typeof e=="string"&&e.indexOf("%")!=-1}function Fe(e){return e.length==1?"0"+e:""+e}function Et(e){return e<=1&&(e=e*100+"%"),e}function co(e){return Math.round(parseFloat(e)*255).toString(16)}function uo(e){return _e(e)/255}var Me=(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 We(e){return!!Me.CSS_UNIT.exec(e)}function Ei(e){e=e.replace(oi,"").replace(ni,"").toLowerCase();var t=!1;if(Er[e])e=Er[e],t=!0;else if(e=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=Me.rgb.exec(e))?{r:r[1],g:r[2],b:r[3]}:(r=Me.rgba.exec(e))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=Me.hsl.exec(e))?{h:r[1],s:r[2],l:r[3]}:(r=Me.hsla.exec(e))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=Me.hsv.exec(e))?{h:r[1],s:r[2],v:r[3]}:(r=Me.hsva.exec(e))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=Me.hex8.exec(e))?{r:_e(r[1]),g:_e(r[2]),b:_e(r[3]),a:uo(r[4]),format:t?"name":"hex8"}:(r=Me.hex6.exec(e))?{r:_e(r[1]),g:_e(r[2]),b:_e(r[3]),format:t?"name":"hex"}:(r=Me.hex4.exec(e))?{r:_e(r[1]+""+r[1]),g:_e(r[2]+""+r[2]),b:_e(r[3]+""+r[3]),a:uo(r[4]+""+r[4]),format:t?"name":"hex8"}:(r=Me.hex3.exec(e))?{r:_e(r[1]+""+r[1]),g:_e(r[2]+""+r[2]),b:_e(r[3]+""+r[3]),format:t?"name":"hex"}:!1}function _i(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 ot=e=>({25:K.mix(e,"#FFFFFF",95).toHexString(),50:K.mix(e,"#FFFFFF",90).toHexString(),100:K.mix(e,"#FFFFFF",80).toHexString(),200:K.mix(e,"#FFFFFF",65).toHexString(),300:K.mix(e,"#FFFFFF",50).toHexString(),400:K.mix(e,"#FFFFFF",30).toHexString(),500:K(e).toHexString(),600:K.mix(e,"#000000",10).toHexString(),700:K.mix(e,"#000000",20).toHexString(),800:K.mix(e,"#000000",30).toHexString(),900:K.mix(e,"#000000",45).toHexString(),950:K.mix(e,"#000000",60).toHexString()}),Ht=e=>{let t="";const r={brand:ot(e.colors.primary),success:ot(e.colors.success),warning:ot(e.colors.warning),gray:ot(e.colors.gray),error:ot(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},
|
|
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,p,J,y,As,Za){"use strict";function Ns(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 M=Ns(p),Ga=Ns(As),Ja="zango_app_logo_cache",Xa=1440*60*1e3;class Ya{constructor(){this.cacheKey=Ja}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 d=new FileReader;d.onloadend=()=>i(d.result),d.onerror=l,d.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>Xa}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 nt=new Ya,Qa=()=>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"})]}),Ls=({logoUrl:e,appName:t,height:r="28px",linkTo:s="/"})=>{const[n,a]=p.useState(()=>{const f=nt.getCachedLogo();return f&&(f.base64Data||f.url)?f.base64Data||f.url:e||null}),[i,l]=p.useState(!1);p.useEffect(()=>{e&&nt.updateInBackground(e,t,f=>{f.base64Data&&a(f.base64Data)})},[e,t]);const d=p.useCallback(()=>{console.error("Logo failed to load"),l(!0);const f=nt.getCachedLogo();f&&n===f.base64Data&&nt.clearCache()},[n]),c=p.useCallback(()=>{l(!1)},[]),u=()=>i||!n?o.jsx(Qa,{}):o.jsx("img",{src:n,height:r,alt:t||"Logo",onError:d,onLoad:c,style:{maxHeight:r,objectFit:"contain"}});return o.jsx(J.Link,{to:s,className:"logo-link",children:u()})},zt=(e,t={})=>`${t.baseUrl||""}${e}`,Ra=(e,t={})=>t.endpoints?.[e]||"",ei=(e={})=>e.timeout||3e4;function Se(e,t){if(!e)return"/";const[r,s]=e.split("?"),n=r.replace(/\/+$/,"")+"/",a=new URLSearchParams;s&&new URLSearchParams(s).forEach((d,c)=>{a.set(c,d)}),t&&Object.keys(t).length>0&&Object.entries(t).forEach(([l,d])=>{d!=null&&a.set(l,String(d))});const i=a.toString();return i?`${n}?${i}`:n}const Et="";function ti(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 At=async()=>({"X-Csrftoken":ti("csrftoken")}),Ts=async({fullUrl:e})=>{const t=`${Et}${e}${e.includes("?")?"&":"?"}_t=${Date.now()}`;return await fetch(t,{method:"GET",redirect:"follow",headers:{...await At(),"Content-Type":"application/json"}})},Ms=async({fullUrl:e,payload:t})=>await fetch(Et+e,{method:"POST",redirect:"follow",headers:{...await At(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Fs=async({fullUrl:e,payload:t})=>await fetch(Et+e,{method:"PUT",redirect:"follow",headers:{...await At(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Os=async({fullUrl:e,payload:t})=>await fetch(Et+e,{method:"DELETE",redirect:"follow",headers:{...await At(),"Content-Type":"application/json"},body:t instanceof FormData?t:JSON.stringify(t)}),Us=async({fullUrl:e,payload:t})=>await fetch(Et+e,{method:"PATCH",redirect:"follow",headers:{...await At(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Pe=async e=>{let t;try{const r=zt(e.url);switch(e.type){case"POST":t=await Ms({fullUrl:r,payload:e.payload});break;case"PUT":t=await Fs({fullUrl:r,payload:e.payload});break;case"PATCH":t=await Us({fullUrl:r,payload:e.payload});break;case"DELETE":t=await Os({fullUrl:r,payload:e.payload});break;case"GET":default:t=await Ts({fullUrl:r})}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}}},ri=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}`:""},Is=()=>{const t=typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",r=t.startsWith("/")?t:`/${t}`;return{url:Se(r),type:"GET"}},Ds=()=>({url:Se("/api/v1/profile"),type:"GET"}),$s=e=>({url:Se("/api/v1/profile"),type:"PUT",payload:e}),Bs=e=>({url:Se("/api/v1/profile/photo"),type:"POST",payload:e}),qs=e=>({url:Se("/api/v1/appauth/password/change/"),type:"PUT",payload:e}),Vs=e=>({url:Se("/api/v1/profile/two-factor"),type:"POST",payload:e}),js=e=>({url:Se(`/api/v1/appauth/role/switch/?role=${encodeURIComponent(e)}`),type:"POST"}),Hs=()=>({url:Se("/api/v1/appauth/sessions/"),type:"GET"}),zs=e=>({url:Se("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:[e]}}),Ws=e=>({url:Se("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:e}}),Ks=()=>({url:Se("/api/v1/appauth/logout"),type:"DELETE"}),Zs=()=>({url:Se("/logout"),type:"POST"}),Gs=(e,t)=>({url:Se(`${e}${e.includes("?")?"&":"?"}idleFor=${t}`),type:"GET"}),Js=async()=>Pe(Is()),Xs=async()=>Pe(Ds()),Ys=async()=>Pe(Hs()),Wt=async e=>Pe($s(e)),si=async e=>Pe(Bs(e)),Qs=async e=>Pe(qs(e)),oi=async e=>Pe(Vs({enabled:e})),Rs=async e=>Pe(js(e)),eo=async e=>Pe(zs(e)),to=async e=>Pe(Ws(e)),ro=async()=>Pe(Ks()),so=async()=>Pe(Zs()),oo=async(e,t)=>Pe(Gs(e,t));function Kt(e){"@babel/helpers - typeof";return Kt=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},Kt(e)}var ni=/^\s+/,ai=/\s+$/;function G(e,t){if(e=e||"",t=t||{},e instanceof G)return e;if(!(this instanceof G))return new G(e,t);var r=ii(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}G.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=uo(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=ao(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=ao(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=no(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=no(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 io(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return ui(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(ce(this._r,255)*100)+"%",g:Math.round(ce(this._g,255)*100)+"%",b:Math.round(ce(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(ce(this._r,255)*100)+"%, "+Math.round(ce(this._g,255)*100)+"%, "+Math.round(ce(this._b,255)*100)+"%)":"rgba("+Math.round(ce(this._r,255)*100)+"%, "+Math.round(ce(this._g,255)*100)+"%, "+Math.round(ce(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:Si[io(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+lo(this._r,this._g,this._b,this._a),s=r,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=G(t);s="#"+lo(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 G(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(gi,arguments)},brighten:function(){return this._applyModification(mi,arguments)},darken:function(){return this._applyModification(wi,arguments)},desaturate:function(){return this._applyModification(fi,arguments)},saturate:function(){return this._applyModification(hi,arguments)},greyscale:function(){return this._applyModification(pi,arguments)},spin:function(){return this._applyModification(yi,arguments)},_applyCombination:function(t,r){return t.apply(null,[this].concat([].slice.call(r)))},analogous:function(){return this._applyCombination(Ci,arguments)},complement:function(){return this._applyCombination(bi,arguments)},monochromatic:function(){return this._applyCombination(xi,arguments)},splitcomplement:function(){return this._applyCombination(vi,arguments)},triad:function(){return this._applyCombination(co,[3])},tetrad:function(){return this._applyCombination(co,[4])}},G.fromRatio=function(e,t){if(Kt(e)=="object"){var r={};for(var s in e)e.hasOwnProperty(s)&&(s==="a"?r[s]=e[s]:r[s]=Nt(e[s]));e=r}return G(e,t)};function ii(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=Ei(e)),Kt(e)=="object"&&(Ge(e.r)&&Ge(e.g)&&Ge(e.b)?(t=li(e.r,e.g,e.b),i=!0,l=String(e.r).substr(-1)==="%"?"prgb":"rgb"):Ge(e.h)&&Ge(e.s)&&Ge(e.v)?(s=Nt(e.s),n=Nt(e.v),t=di(e.h,s,n),i=!0,l="hsv"):Ge(e.h)&&Ge(e.s)&&Ge(e.l)&&(s=Nt(e.s),a=Nt(e.l),t=ci(e.h,s,a),i=!0,l="hsl"),e.hasOwnProperty("a")&&(r=e.a)),r=uo(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 li(e,t,r){return{r:ce(e,255)*255,g:ce(t,255)*255,b:ce(r,255)*255}}function no(e,t,r){e=ce(e,255),t=ce(t,255),r=ce(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 d=s-n;switch(i=l>.5?d/(2-s-n):d/(s+n),s){case e:a=(t-r)/d+(t<r?6:0);break;case t:a=(r-e)/d+2;break;case r:a=(e-t)/d+4;break}a/=6}return{h:a,s:i,l}}function ci(e,t,r){var s,n,a;e=ce(e,360),t=ce(t,100),r=ce(r,100);function i(c,u,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?c+(u-c)*6*f:f<1/2?u:f<2/3?c+(u-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,d=2*r-l;s=i(d,l,e+1/3),n=i(d,l,e),a=i(d,l,e-1/3)}return{r:s*255,g:n*255,b:a*255}}function ao(e,t,r){e=ce(e,255),t=ce(t,255),r=ce(r,255);var s=Math.max(e,t,r),n=Math.min(e,t,r),a,i,l=s,d=s-n;if(i=s===0?0:d/s,s==n)a=0;else{switch(s){case e:a=(t-r)/d+(t<r?6:0);break;case t:a=(r-e)/d+2;break;case r:a=(e-t)/d+4;break}a/=6}return{h:a,s:i,v:l}}function di(e,t,r){e=ce(e,360)*6,t=ce(t,100),r=ce(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),d=s%6,c=[r,i,a,a,l,r][d],u=[l,r,r,i,a,a][d],f=[a,a,l,r,r,i][d];return{r:c*255,g:u*255,b:f*255}}function io(e,t,r,s){var n=[Ue(Math.round(e).toString(16)),Ue(Math.round(t).toString(16)),Ue(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 ui(e,t,r,s,n){var a=[Ue(Math.round(e).toString(16)),Ue(Math.round(t).toString(16)),Ue(Math.round(r).toString(16)),Ue(fo(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 lo(e,t,r,s){var n=[Ue(fo(s)),Ue(Math.round(e).toString(16)),Ue(Math.round(t).toString(16)),Ue(Math.round(r).toString(16))];return n.join("")}G.equals=function(e,t){return!e||!t?!1:G(e).toRgbString()==G(t).toRgbString()},G.random=function(){return G.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function fi(e,t){t=t===0?0:t||10;var r=G(e).toHsl();return r.s-=t/100,r.s=Zt(r.s),G(r)}function hi(e,t){t=t===0?0:t||10;var r=G(e).toHsl();return r.s+=t/100,r.s=Zt(r.s),G(r)}function pi(e){return G(e).desaturate(100)}function gi(e,t){t=t===0?0:t||10;var r=G(e).toHsl();return r.l+=t/100,r.l=Zt(r.l),G(r)}function mi(e,t){t=t===0?0:t||10;var r=G(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)))),G(r)}function wi(e,t){t=t===0?0:t||10;var r=G(e).toHsl();return r.l-=t/100,r.l=Zt(r.l),G(r)}function yi(e,t){var r=G(e).toHsl(),s=(r.h+t)%360;return r.h=s<0?360+s:s,G(r)}function bi(e){var t=G(e).toHsl();return t.h=(t.h+180)%360,G(t)}function co(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var r=G(e).toHsl(),s=[G(e)],n=360/t,a=1;a<t;a++)s.push(G({h:(r.h+a*n)%360,s:r.s,l:r.l}));return s}function vi(e){var t=G(e).toHsl(),r=t.h;return[G(e),G({h:(r+72)%360,s:t.s,l:t.l}),G({h:(r+216)%360,s:t.s,l:t.l})]}function Ci(e,t,r){t=t||6,r=r||30;var s=G(e).toHsl(),n=360/r,a=[G(e)];for(s.h=(s.h-(n*t>>1)+720)%360;--t;)s.h=(s.h+n)%360,a.push(G(s));return a}function xi(e,t){t=t||6;for(var r=G(e).toHsv(),s=r.h,n=r.s,a=r.v,i=[],l=1/t;t--;)i.push(G({h:s,s:n,v:a})),a=(a+l)%1;return i}G.mix=function(e,t,r){r=r===0?0:r||50;var s=G(e).toRgb(),n=G(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 G(i)},G.readability=function(e,t){var r=G(e),s=G(t);return(Math.max(r.getLuminance(),s.getLuminance())+.05)/(Math.min(r.getLuminance(),s.getLuminance())+.05)},G.isReadable=function(e,t,r){var s=G.readability(e,t),n,a;switch(a=!1,n=Ai(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},G.mostReadable=function(e,t,r){var s=null,n=0,a,i,l,d;r=r||{},i=r.includeFallbackColors,l=r.level,d=r.size;for(var c=0;c<t.length;c++)a=G.readability(e,t[c]),a>n&&(n=a,s=G(t[c]));return G.isReadable(e,s,{level:l,size:d})||!i?s:(r.includeFallbackColors=!1,G.mostReadable(e,["#fff","#000"],r))};var Lr=G.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"},Si=G.hexNames=Pi(Lr);function Pi(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r]]=r);return t}function uo(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function ce(e,t){_i(e)&&(e="100%");var r=ki(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 Zt(e){return Math.min(1,Math.max(0,e))}function Ne(e){return parseInt(e,16)}function _i(e){return typeof e=="string"&&e.indexOf(".")!=-1&&parseFloat(e)===1}function ki(e){return typeof e=="string"&&e.indexOf("%")!=-1}function Ue(e){return e.length==1?"0"+e:""+e}function Nt(e){return e<=1&&(e=e*100+"%"),e}function fo(e){return Math.round(parseFloat(e)*255).toString(16)}function ho(e){return Ne(e)/255}var Ie=(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 Ge(e){return!!Ie.CSS_UNIT.exec(e)}function Ei(e){e=e.replace(ni,"").replace(ai,"").toLowerCase();var t=!1;if(Lr[e])e=Lr[e],t=!0;else if(e=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=Ie.rgb.exec(e))?{r:r[1],g:r[2],b:r[3]}:(r=Ie.rgba.exec(e))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=Ie.hsl.exec(e))?{h:r[1],s:r[2],l:r[3]}:(r=Ie.hsla.exec(e))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=Ie.hsv.exec(e))?{h:r[1],s:r[2],v:r[3]}:(r=Ie.hsva.exec(e))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=Ie.hex8.exec(e))?{r:Ne(r[1]),g:Ne(r[2]),b:Ne(r[3]),a:ho(r[4]),format:t?"name":"hex8"}:(r=Ie.hex6.exec(e))?{r:Ne(r[1]),g:Ne(r[2]),b:Ne(r[3]),format:t?"name":"hex"}:(r=Ie.hex4.exec(e))?{r:Ne(r[1]+""+r[1]),g:Ne(r[2]+""+r[2]),b:Ne(r[3]+""+r[3]),a:ho(r[4]+""+r[4]),format:t?"name":"hex8"}:(r=Ie.hex3.exec(e))?{r:Ne(r[1]+""+r[1]),g:Ne(r[2]+""+r[2]),b:Ne(r[3]+""+r[3]),format:t?"name":"hex"}:!1}function Ai(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 at=e=>({25:G.mix(e,"#FFFFFF",95).toHexString(),50:G.mix(e,"#FFFFFF",90).toHexString(),100:G.mix(e,"#FFFFFF",80).toHexString(),200:G.mix(e,"#FFFFFF",65).toHexString(),300:G.mix(e,"#FFFFFF",50).toHexString(),400:G.mix(e,"#FFFFFF",30).toHexString(),500:G(e).toHexString(),600:G.mix(e,"#000000",10).toHexString(),700:G.mix(e,"#000000",20).toHexString(),800:G.mix(e,"#000000",30).toHexString(),900:G.mix(e,"#000000",45).toHexString(),950:G.mix(e,"#000000",60).toHexString()}),Gt=e=>{let t="";const r={brand:at(e.colors.primary),success:at(e.colors.success),warning:at(e.colors.warning),gray:at(e.colors.gray),error:at(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},po=e=>G(e).isLight(),Ni=e=>po(e)?"#000000":"#FFFFFF",go=(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",d=s.style.getPropertyValue("--color-gray-500")||"#6B7280",c={brand:n,success:a,error:i,warning:l,gray:d};return c[e]?at(c[e])[t]||c[e]:"#5048ED"},Tr=(e={})=>e.baseUrl||"",mo=(e,t={})=>e?e.startsWith("http://")||e.startsWith("https://")?e:zt(e,t):Tr(t),Lt=()=>{const e=J.useLocation(),{routes:t,apiConfig:r}=Le(),n=e.pathname.split("/").filter(Boolean)[0],a=[...t].sort((d,c)=>c.path.length-d.path.length);let i=null;for(const d of a){if(d.path===e.pathname){i=d;break}if(d.path?.includes(":")){const c=d.path.replace(/:[^/]+/g,"[^/]+");if(e.pathname.match(new RegExp(`^${c}$`))){i=d;break}}if(e.pathname.startsWith(d.path+"/")){i=d;break}}const l=i?.extra_params||{};return{baseUrl:Tr(r),apiUrl:l.api_endpoint||"",fullUrl:mo(l.api_endpoint||"",r),headers:l.headers||{},entity:n,...l}},Li=()=>{const e=J.useLocation(),{routes:t}=Le(),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},Ti=(e,t={},r={})=>({baseUrl:Tr(t),apiUrl:e,fullUrl:mo(e,t),headers:r.headers||{},...r}),Mr=({basePath:e})=>{const t=Lt();return o.jsx("div",{className:"page-container",style:{height:"100%"},children:o.jsx(Za.CrudHandler,{api_endpoint:t.apiUrl})})},wo=({basePath:e})=>{Lt();const[t,r]=p.useState(null),[s,n]=p.useState(null);return p.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..."})})},Fr={crud:{requiredPackage:"@zango-core/crud",component:Mr},training:{requiredPackage:"@zango-core/training",component:wo}};Object.fromEntries(Object.entries(Fr).map(([e,t])=>[e,()=>import(t.requiredPackage)])),Object.fromEntries(Object.keys(Fr).map(e=>[e,[e]]));const yo=Object.fromEntries(Object.entries(Fr).map(([e,t])=>[e,t.component])),Mi=e=>e.filter(t=>t in yo),Fi=e=>yo[e]||null,bo=({componentName:e,customPagesDir:t="src/custom/pages",fileExtension:r="js"})=>{const[s,n]=p.useState(null),a=(m,w)=>{navigator.clipboard.writeText(m).then(()=>{n(w),setTimeout(()=>n(null),2e3)})},i=e||"MyCustomPage",l=t,d=r,c=`import React from 'react';
|
|
4
4
|
|
|
5
5
|
const ${i} = () => {
|
|
6
6
|
return (
|
|
@@ -12,7 +12,7 @@ const ${i} = () => {
|
|
|
12
12
|
);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export default ${i};`,
|
|
15
|
+
export default ${i};`,u=`// ${l}/index.${d}
|
|
16
16
|
// Export all custom pages here
|
|
17
17
|
export { default as ${i} } from './${i}';`,f=`import React from 'react';
|
|
18
18
|
import { ZangoApp } from '@zango-core/crm-framework';
|
|
@@ -31,92 +31,92 @@ const App = () => {
|
|
|
31
31
|
)
|
|
32
32
|
};
|
|
33
33
|
|
|
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."})]})]})},Lr=({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({}),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(wo,{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..."})},At=({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"})]})]})});/**
|
|
34
|
+
export default App;`,g=`mkdir -p ${l}`,h={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:h.container,children:[o.jsxs("div",{style:h.header,children:[o.jsx("h1",{style:h.title,children:"Custom Page Setup Guide"}),o.jsx("p",{style:h.subtitle,children:"Follow the steps below to create your custom page component"})]}),o.jsxs("div",{style:h.errorBox,children:[o.jsxs("p",{style:h.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:{...h.inlineCode,backgroundColor:"#fee2e2",color:"#991b1b"},children:[l,"/",i,".",d]})]})]}),o.jsxs("div",{style:h.setupGuide,children:[o.jsx("h2",{style:h.sectionTitle,children:"📋 Quick Setup Steps"}),o.jsxs("ol",{style:h.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:h.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:h.codeBlock,children:[o.jsx("button",{style:{...h.copyButton,...s===0?h.copiedButton:{}},onClick:()=>a(g,0),onMouseEnter:m=>{s!==0&&(m.target.style.backgroundColor="#4b5563")},onMouseLeave:m=>{s!==0&&(m.target.style.backgroundColor="#374151")},children:s===0?"✓ Copied!":"Copy"}),o.jsx("pre",{style:h.pre,children:g})]}),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:h.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:h.inlineCode,children:[l,"/",i,".",d]})," and paste this code:"]}),o.jsxs("div",{style:h.codeBlock,children:[o.jsx("button",{style:{...h.copyButton,...s===1?h.copiedButton:{}},onClick:()=>a(c,1),onMouseEnter:m=>{s!==1&&(m.target.style.backgroundColor="#4b5563")},onMouseLeave:m=>{s!==1&&(m.target.style.backgroundColor="#374151")},children:s===1?"✓ Copied!":"Copy"}),o.jsx("pre",{style:h.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:h.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:h.inlineCode,children:[l,"/index.",d]}),":"]}),o.jsxs("div",{style:h.codeBlock,children:[o.jsx("button",{style:{...h.copyButton,...s===2?h.copiedButton:{}},onClick:()=>a(u,2),onMouseEnter:m=>{s!==2&&(m.target.style.backgroundColor="#4b5563")},onMouseLeave:m=>{s!==2&&(m.target.style.backgroundColor="#374151")},children:s===2?"✓ Copied!":"Copy"}),o.jsx("pre",{style:h.pre,children:u})]}),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:h.stepTitle,children:"Step 4: Verify App.js Configuration"}),o.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Ensure your ",o.jsx("code",{style:h.inlineCode,children:"App.js"})," imports custom pages and passes them to ",o.jsx("code",{style:h.inlineCode,children:"ZangoApp"}),":"]}),o.jsxs("div",{style:h.codeBlock,children:[o.jsx("button",{style:{...h.copyButton,...s===3?h.copiedButton:{}},onClick:()=>a(f,3),onMouseEnter:m=>{s!==3&&(m.target.style.backgroundColor="#4b5563")},onMouseLeave:m=>{s!==3&&(m.target.style.backgroundColor="#374151")},children:s===3?"✓ Copied!":"Copy"}),o.jsx("pre",{style:h.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:{...h.inlineCode,backgroundColor:"#fde68a",color:"#78350f"},children:"customPages"})," prop is required for ZangoApp to load your custom page components."]}),o.jsx("h3",{style:h.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:h.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:{...h.inlineCode,marginLeft:"4px"},children:[l,"/",i,".",d]}),o.jsx("br",{}),o.jsx("strong",{children:"Export name:"})," ",o.jsx("code",{style:{...h.inlineCode,marginLeft:"4px"},children:i}),o.jsx("br",{}),o.jsx("strong",{children:"Index export:"})," ",o.jsxs("code",{style:{...h.inlineCode,marginLeft:"4px"},children:[l,"/index.",d]}),o.jsx("br",{}),o.jsx("strong",{children:"App import:"})," ",o.jsxs("code",{style:{...h.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."})]})]})},Or=({componentName:e,customPagesDir:t="src/custom/pages",customPagesGlob:r="../../custom/pages/*.js",fileExtension:s="js"})=>{const[n,a]=p.useState(null),[i,l]=p.useState(!1);return p.useEffect(()=>{if(a(null),l(!1),!e){l(!0);return}(async()=>{try{const c=Object.assign({}),u=`../../custom/pages/${e}.${s}`;if(c[u]){const f=await c[u]();a(()=>f.default)}else console.error(`Custom page not found: ${e} at ${u}`),l(!0)}catch(c){console.error("Error loading custom page:",c),l(!0)}})()},[e,s]),i?o.jsx(bo,{componentName:e,customPagesDir:t,fileExtension:s}):n?o.jsx(p.Suspense,{fallback:o.jsx("div",{style:{padding:"24px"},children:"Loading..."}),children:o.jsx(n,{})}):o.jsx("div",{style:{padding:"24px"},children:"Loading custom page..."})},Tt=({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
|
|
39
|
+
*/const Oi=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ui=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,s)=>s?s.toUpperCase():r.toLowerCase()),vo=e=>{const t=Ui(e);return t.charAt(0).toUpperCase()+t.slice(1)},Co=(...e)=>e.filter((t,r,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===r).join(" ").trim(),Ii=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
|
|
44
|
+
*/var Di={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
|
|
49
|
+
*/const $i=p.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:n="",children:a,iconNode:i,...l},d)=>p.createElement("svg",{ref:d,...Di,width:t,height:t,stroke:e,strokeWidth:s?Number(r)*24/Number(t):r,className:Co("lucide",n),...!a&&!Ii(l)&&{"aria-hidden":"true"},...l},[...i.map(([c,u])=>p.createElement(c,u)),...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
|
|
54
|
+
*/const Me=(e,t)=>{const r=p.forwardRef(({className:s,...n},a)=>p.createElement($i,{ref:a,iconNode:t,className:Co(`lucide-${Oi(vo(e))}`,`lucide-${e}`,s),...n}));return r.displayName=vo(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
|
|
59
|
+
*/const mt=Me("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
|
|
64
|
+
*/const Ye=Me("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 Bi=
|
|
69
|
+
*/const Bi=Me("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
|
|
74
|
+
*/const qi=Me("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
|
|
79
|
+
*/const Vi=Me("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
|
|
84
|
+
*/const Jt=Me("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
|
|
89
|
+
*/const Xt=Me("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
|
|
94
|
+
*/const ji=Me("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
|
|
99
|
+
*/const xo=Me("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
|
|
104
|
+
*/const Ur=Me("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
|
|
109
|
+
*/const Ir=Me("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
110
|
* @license lucide-react v0.544.0 - ISC
|
|
111
111
|
*
|
|
112
112
|
* This source code is licensed under the ISC license.
|
|
113
113
|
* See the LICENSE file in the root directory of this source tree.
|
|
114
|
-
*/const ji=Te("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 Co(e,t){return function(){return e.apply(t,arguments)}}const{toString:Hi}=Object.prototype,{getPrototypeOf:Fr}=Object,{iterator:Kt,toStringTag:xo}=Symbol,Zt=(e=>t=>{const r=Hi.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Ie=e=>(e=e.toLowerCase(),t=>Zt(t)===e),Gt=e=>t=>typeof t===e,{isArray:gt}=Array,mt=Gt("undefined");function Nt(e){return e!==null&&!mt(e)&&e.constructor!==null&&!mt(e.constructor)&&Pe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const So=Ie("ArrayBuffer");function zi(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&So(e.buffer),t}const Wi=Gt("string"),Pe=Gt("function"),Po=Gt("number"),Lt=e=>e!==null&&typeof e=="object",Ki=e=>e===!0||e===!1,Jt=e=>{if(Zt(e)!=="object")return!1;const t=Fr(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(xo in e)&&!(Kt in e)},Zi=e=>{if(!Lt(e)||Nt(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Gi=Ie("Date"),Ji=Ie("File"),Xi=Ie("Blob"),Yi=Ie("FileList"),Qi=e=>Lt(e)&&Pe(e.pipe),Ri=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Pe(e.append)&&((t=Zt(e))==="formdata"||t==="object"&&Pe(e.toString)&&e.toString()==="[object FormData]"))},el=Ie("URLSearchParams"),[tl,rl,sl,ol]=["ReadableStream","Request","Response","Headers"].map(Ie),nl=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Tt(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let s,n;if(typeof e!="object"&&(e=[e]),gt(e))for(s=0,n=e.length;s<n;s++)t.call(null,e[s],s,e);else{if(Nt(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 ko(e,t){if(Nt(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 nt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Eo=e=>!mt(e)&&e!==nt;function Mr(){const{caseless:e,skipUndefined:t}=Eo(this)&&this||{},r={},s=(n,a)=>{const i=e&&ko(r,a)||a;Jt(r[i])&&Jt(n)?r[i]=Mr(r[i],n):Jt(n)?r[i]=Mr({},n):gt(n)?r[i]=n.slice():(!t||!mt(n))&&(r[i]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&Tt(arguments[n],s);return r}const al=(e,t,r,{allOwnKeys:s}={})=>(Tt(t,(n,a)=>{r&&Pe(n)?e[a]=Co(n,r):e[a]=n},{allOwnKeys:s}),e),il=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ll=(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)},cl=(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&&Fr(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},dl=(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},ul=e=>{if(!e)return null;if(gt(e))return e;let t=e.length;if(!Po(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},fl=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Fr(Uint8Array)),hl=(e,t)=>{const s=(e&&e[Kt]).call(e);let n;for(;(n=s.next())&&!n.done;){const a=n.value;t.call(e,a[0],a[1])}},pl=(e,t)=>{let r;const s=[];for(;(r=e.exec(t))!==null;)s.push(r);return s},gl=Ie("HTMLFormElement"),ml=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,s,n){return s.toUpperCase()+n}),_o=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),wl=Ie("RegExp"),Ao=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),s={};Tt(r,(n,a)=>{let i;(i=t(n,a,e))!==!1&&(s[a]=i||n)}),Object.defineProperties(e,s)},yl=e=>{Ao(e,(t,r)=>{if(Pe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const s=e[r];if(Pe(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+"'")})}})},bl=(e,t)=>{const r={},s=n=>{n.forEach(a=>{r[a]=!0})};return gt(e)?s(e):s(String(e).split(t)),r},vl=()=>{},Cl=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function xl(e){return!!(e&&Pe(e.append)&&e[xo]==="FormData"&&e[Kt])}const Sl=e=>{const t=new Array(10),r=(s,n)=>{if(Lt(s)){if(t.indexOf(s)>=0)return;if(Nt(s))return s;if(!("toJSON"in s)){t[n]=s;const a=gt(s)?[]:{};return Tt(s,(i,l)=>{const u=r(i,n+1);!mt(u)&&(a[l]=u)}),t[n]=void 0,a}}return s};return r(e,0)},Pl=Ie("AsyncFunction"),kl=e=>e&&(Lt(e)||Pe(e))&&Pe(e.then)&&Pe(e.catch),No=((e,t)=>e?setImmediate:t?((r,s)=>(nt.addEventListener("message",({source:n,data:a})=>{n===nt&&a===r&&s.length&&s.shift()()},!1),n=>{s.push(n),nt.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Pe(nt.postMessage)),El=typeof queueMicrotask<"u"?queueMicrotask.bind(nt):typeof process<"u"&&process.nextTick||No,N={isArray:gt,isArrayBuffer:So,isBuffer:Nt,isFormData:Ri,isArrayBufferView:zi,isString:Wi,isNumber:Po,isBoolean:Ki,isObject:Lt,isPlainObject:Jt,isEmptyObject:Zi,isReadableStream:tl,isRequest:rl,isResponse:sl,isHeaders:ol,isUndefined:mt,isDate:Gi,isFile:Ji,isBlob:Xi,isRegExp:wl,isFunction:Pe,isStream:Qi,isURLSearchParams:el,isTypedArray:fl,isFileList:Yi,forEach:Tt,merge:Mr,extend:al,trim:nl,stripBOM:il,inherits:ll,toFlatObject:cl,kindOf:Zt,kindOfTest:Ie,endsWith:dl,toArray:ul,forEachEntry:hl,matchAll:pl,isHTMLForm:gl,hasOwnProperty:_o,hasOwnProp:_o,reduceDescriptors:Ao,freezeMethods:yl,toObjectSet:bl,toCamelCase:ml,noop:vl,toFiniteNumber:Cl,findKey:ko,global:nt,isContextDefined:Eo,isSpecCompliantForm:xl,toJSONObject:Sl,isAsyncFn:Pl,isThenable:kl,setImmediate:No,asap:El,isIterable:e=>e!=null&&Pe(e[Kt])};function ee(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(ee,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 Lo=ee.prototype,To={};["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=>{To[e]={value:e}}),Object.defineProperties(ee,To),Object.defineProperty(Lo,"isAxiosError",{value:!0}),ee.from=(e,t,r,s,n,a)=>{const i=Object.create(Lo);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 ee.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 _l=null;function Ir(e){return N.isPlainObject(e)||N.isArray(e)}function Oo(e){return N.endsWith(e,"[]")?e.slice(0,-2):e}function Fo(e,t,r){return e?e.concat(t).map(function(n,a){return n=Oo(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function Al(e){return N.isArray(e)&&!e.some(Ir)}const Nl=N.toFlatObject(N,{},null,function(t){return/^is[A-Z]/.test(t)});function Xt(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 ee("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 x=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)&&Al(p)||(N.isFileList(p)||N.endsWith(w,"[]"))&&(x=N.toArray(p)))return w=Oo(w),x.forEach(function(L,M){!(N.isUndefined(L)||L===null)&&t.append(i===!0?Fo([w],M,a):i===null?w:w+"[]",c(L))}),!1}return Ir(p)?!0:(t.append(Fo(b,w,a),c(p)),!1)}const f=[],m=Object.assign(Nl,{defaultVisitor:d,convertValue:c,isVisitable:Ir});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(x,P){(!(N.isUndefined(x)||x===null)&&n.call(t,x,N.isString(P)?P.trim():P,w,m))===!0&&g(x,w?w.concat(P):[P])}),f.pop()}}if(!N.isObject(e))throw new TypeError("data must be an object");return g(e),t}function Mo(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return t[s]})}function Ur(e,t){this._pairs=[],e&&Xt(e,this,t)}const Io=Ur.prototype;Io.append=function(t,r){this._pairs.push([t,r])},Io.toString=function(t){const r=t?function(s){return t.call(this,s,Mo)}:Mo;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};function Ll(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Uo(e,t,r){if(!t)return e;const s=r&&r.encode||Ll;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 Ur(t,r).toString(s),a){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}class Do{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 Bo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Tl={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ur,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Dr=typeof window<"u"&&typeof document<"u",Br=typeof navigator=="object"&&navigator||void 0,Ol=Dr&&(!Br||["ReactNative","NativeScript","NS"].indexOf(Br.product)<0),Fl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ml=Dr&&window.location.href||"http://localhost",pe={...Object.freeze({__proto__:null,hasBrowserEnv:Dr,hasStandardBrowserEnv:Ol,hasStandardBrowserWebWorkerEnv:Fl,navigator:Br,origin:Ml}),...Tl};function Il(e,t){return Xt(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 Ul(e){return N.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Dl(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 $o(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]=Dl(n[i])),!l)}if(N.isFormData(e)&&N.isFunction(e.entries)){const r={};return N.forEachEntry(e,(s,n)=>{t(Ul(s),n,r,0)}),r}return null}function Bl(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 Ot={transitional:Bo,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($o(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 Il(t,this.formSerializer).toString();if((l=N.isFileList(t))||s.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return Xt(l?{"files[]":t}:t,u&&new u,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),Bl(t)):t}],transformResponse:[function(t){const r=this.transitional||Ot.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"?ee.from(l,ee.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=>{Ot.headers[e]={}});const $l=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"]),ql=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]
|
|
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[qo]=this[qo]={accessors:{}}).accessors,n=this.prototype;function a(i){const l=Ft(i);s[l]||(zl(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 qr(e,t){const r=this||Ot,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 Vo(e){return!!(e&&e.__CANCEL__)}function wt(e,t,r){ee.call(this,e??"canceled",ee.ERR_CANCELED,t,r),this.name="CanceledError"}N.inherits(wt,ee,{__CANCEL__:!0});function jo(e,t,r){const s=r.config.validateStatus;!r.status||!s||s(r.status)?e(r):t(new ee("Request failed with status code "+r.status,[ee.ERR_BAD_REQUEST,ee.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Wl(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Kl(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 Zl(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 Qt=(e,t,r=3)=>{let s=0;const n=Kl(50,250);return Zl(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)},Ho=(e,t)=>{const r=e!=null;return[s=>t[0]({lengthComputable:r,total:e,loaded:s}),t[1]]},zo=e=>(...t)=>N.asap(()=>e(...t)),Gl=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,Jl=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 Xl(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Yl(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Wo(e,t,r){let s=!Xl(t);return e&&(s||r==!1)?Yl(e,t):t}const Ko=e=>e instanceof ke?{...e}:e;function at(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(Ko(c),Ko(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 Zo=e=>{const t=at({},e);let{data:r,withXSRFToken:s,xsrfHeaderName:n,xsrfCookieName:a,headers:i,auth:l}=t;if(t.headers=i=ke.from(i),t.url=Uo(Wo(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&&Gl(t.url))){const u=n&&a&&Jl.read(a);u&&i.set(n,u)}return t},Ql=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,s){const n=Zo(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 x(){if(!b)return;const L=ke.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),B={data:!l||l==="text"||l==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:L,config:e,request:b};jo(function(_){r(_),w()},function(_){s(_),w()},B),b=null}"onloadend"in b?b.onloadend=x:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(x)},b.onabort=function(){b&&(s(new ee("Request aborted",ee.ECONNABORTED,e,b)),b=null)},b.onerror=function(M){const B=M&&M.message?M.message:"Network Error",E=new ee(B,ee.ERR_NETWORK,e,b);E.event=M||null,s(E),b=null},b.ontimeout=function(){let M=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const B=n.transitional||Bo;n.timeoutErrorMessage&&(M=n.timeoutErrorMessage),s(new ee(M,B.clarifyTimeoutError?ee.ETIMEDOUT:ee.ECONNABORTED,e,b)),b=null},a===void 0&&i.setContentType(null),"setRequestHeader"in b&&N.forEach(i.toJSON(),function(M,B){b.setRequestHeader(B,M)}),N.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),l&&l!=="json"&&(b.responseType=n.responseType),c&&([m,p]=Qt(c,!0),b.addEventListener("progress",m)),u&&b.upload&&([f,g]=Qt(u),b.upload.addEventListener("progress",f),b.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(d=L=>{b&&(s(!L||L.type?new wt(null,e,b):L),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(d),n.signal&&(n.signal.aborted?d():n.signal.addEventListener("abort",d)));const P=Wl(n.url);if(P&&pe.protocols.indexOf(P)===-1){s(new ee("Unsupported protocol "+P+":",ee.ERR_BAD_REQUEST,e));return}b.send(a||null)})},Rl=(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 ee?d:new wt(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,a(new ee(`timeout ${t} of ms exceeded`,ee.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}},ec=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},tc=async function*(e,t){for await(const r of rc(e))yield*ec(r,t)},rc=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()}},Go=(e,t,r,s)=>{const n=tc(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})},Jo=64*1024,{isFunction:Rt}=N,sc=(({Request:e,Response:t})=>({Request:e,Response:t}))(N.global),{ReadableStream:Xo,TextEncoder:Yo}=N.global,Qo=(e,...t)=>{try{return!!e(...t)}catch{return!1}},oc=e=>{e=N.merge.call({skipUndefined:!0},sc,e);const{fetch:t,Request:r,Response:s}=e,n=t?Rt(t):typeof fetch=="function",a=Rt(r),i=Rt(s);if(!n)return!1;const l=n&&Rt(Xo),u=n&&(typeof Yo=="function"?(p=>w=>p.encode(w))(new Yo):async p=>new Uint8Array(await new r(p).arrayBuffer())),c=a&&l&&Qo(()=>{let p=!1;const w=new r(pe.origin,{body:new Xo,method:"POST",get duplex(){return p=!0,"half"}}).headers.has("Content-Type");return p&&!w}),d=i&&l&&Qo(()=>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 x=w&&w[p];if(x)return x.call(w);throw new ee(`Response type '${p}' is not supported`,ee.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:x,signal:P,cancelToken:L,timeout:M,onDownloadProgress:B,onUploadProgress:E,responseType:_,headers:k,withCredentials:O="same-origin",fetchOptions:V}=Zo(p),v=t||fetch;_=_?(_+"").toLowerCase():"text";let I=Rl([P,L&&L.toAbortSignal()],M),A=null;const C=I&&I.unsubscribe&&(()=>{I.unsubscribe()});let $;try{if(E&&c&&b!=="get"&&b!=="head"&&($=await g(k,x))!==0){let Y=new r(w,{method:"POST",body:x,duplex:"half"}),X;if(N.isFormData(x)&&(X=Y.headers.get("content-type"))&&k.setContentType(X),Y.body){const[G,W]=Ho($,Qt(zo(E)));x=Go(Y.body,Jo,G,W)}}N.isString(O)||(O=O?"include":"omit");const F=a&&"credentials"in r.prototype,S={...V,signal:I,method:b.toUpperCase(),headers:k.normalize().toJSON(),body:x,duplex:"half",credentials:F?O:void 0};A=a&&new r(w,S);let D=await(a?v(A,V):v(w,S));const z=d&&(_==="stream"||_==="response");if(d&&(B||z&&C)){const Y={};["status","statusText","headers"].forEach(U=>{Y[U]=D[U]});const X=N.toFiniteNumber(D.headers.get("content-length")),[G,W]=B&&Ho(X,Qt(zo(B),!0))||[];D=new s(Go(D.body,Jo,G,()=>{W&&W(),C&&C()}),Y)}_=_||"text";let Z=await f[N.findKey(f,_)||"text"](D,p);return!z&&C&&C(),await new Promise((Y,X)=>{jo(Y,X,{data:Z,headers:ke.from(D.headers),status:D.status,statusText:D.statusText,config:p,request:A})})}catch(F){throw C&&C(),F&&F.name==="TypeError"&&/Load failed|fetch/i.test(F.message)?Object.assign(new ee("Network Error",ee.ERR_NETWORK,p,A),{cause:F.cause||F}):ee.from(F,F&&F.code,p,A)}}},nc=new Map,Ro=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=nc;for(;l--;)u=a[l],c=d.get(u),c===void 0&&d.set(u,c=l?new Map:oc(t)),d=c;return c};Ro();const Vr={http:_l,xhr:Ql,fetch:{get:Ro}};N.forEach(Vr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const en=e=>`- ${e}`,ac=e=>N.isFunction(e)||e===null||e===!1;function ic(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,!ac(s)&&(n=Vr[(l=String(s)).toLowerCase()],n===void 0))throw new ee(`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(
|
|
118
|
-
`):" "+
|
|
119
|
-
`+a):s.stack=a}catch{}}throw s}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=at(this.defaults,r);const{transitional:s,paramsSerializer:n,headers:a}=r;s!==void 0&&tr.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}:tr.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),tr.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=[rn.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=rn.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=at(this.defaults,t);const r=Wo(t.baseURL,t.url,t.allowAbsoluteUrls);return Uo(r,t.params,t.paramsSerializer)}};N.forEach(["delete","get","head","options"],function(t){it.prototype[t]=function(r,s){return this.request(at(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(at(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:a,data:i}))}}it.prototype[t]=r(),it.prototype[t+"Form"]=r(!0)});let cc=class Wa{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 wt(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 Wa(function(n){t=n}),cancel:t}}};function dc(e){return function(r){return e.apply(null,r)}}function uc(e){return N.isObject(e)&&e.isAxiosError===!0}const Hr={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(Hr).forEach(([e,t])=>{Hr[t]=e});function nn(e){const t=new it(e),r=Co(it.prototype.request,t);return N.extend(r,it.prototype,t,{allOwnKeys:!0}),N.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return nn(at(e,n))},r}const se=nn(Ot);se.Axios=it,se.CanceledError=wt,se.CancelToken=cc,se.isCancel=Vo,se.VERSION=sn,se.toFormData=Xt,se.AxiosError=ee,se.Cancel=se.CanceledError,se.all=function(t){return Promise.all(t)},se.spread=dc,se.isAxiosError=uc,se.mergeConfig=at,se.AxiosHeaders=ke,se.formToJSON=e=>$o(N.isHTMLForm(e)?new FormData(e):e),se.getAdapter=tn.getAdapter,se.HttpStatusCode=Hr,se.default=se;const{Axios:Gf,AxiosError:Jf,CanceledError:Xf,isCancel:Yf,CancelToken:Qf,VERSION:Rf,all:eh,Cancel:th,isAxiosError:rh,spread:sh,toFormData:oh,AxiosHeaders:nh,HttpStatusCode:ah,formToJSON:ih,getAdapter:lh,mergeConfig:ch}=se,fe="/api/v1/appauth".replace(/\/+$/,"");class Xe{constructor(t,r=fe,s=se){this.basePath=r,this.axios=s,t&&(this.configuration=t,this.basePath=t.basePath??r)}}class fc 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",le=function(e,t,r){if(r==null)throw new fc(t,`Required parameter ${t} was null or undefined when calling ${e}.`)};function zr(e,t,r=""){t!=null&&(typeof t=="object"?Array.isArray(t)?t.forEach(s=>zr(e,s,r)):Object.keys(t).forEach(s=>zr(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);zr(r,t),e.search=r.toString()},yt=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)}},hc=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={})=>{le("updateAppAuthConfig","xCSRFToken",t),le("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}}}},an=function(e){const t=hc(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,se,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,se,fe,e)(u,l||c)}}};class pc extends Xe{getAppAuthConfig(t){return an(this.configuration).getAppAuthConfig(t).then(r=>r(this.axios,this.basePath))}updateAppAuthConfig(t,r,s){return an(this.configuration).updateAppAuthConfig(t,r,s).then(n=>n(this.axios,this.basePath))}}const gc=function(e){return{loginUser:async(t,r,s={})=>{le("loginUser","xCSRFToken",t),le("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=yt(r,l,e),{url:ye(a),options:l}},logoutUser:async(t,r={})=>{le("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}}}},ln=function(e){const t=gc(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,se,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,se,fe,e)(l,i||u)}}};class mc extends Xe{loginUser(t,r,s){return ln(this.configuration).loginUser(t,r,s).then(n=>n(this.axios,this.basePath))}logoutUser(t,r){return ln(this.configuration).logoutUser(t,r).then(s=>s(this.axios,this.basePath))}}const wc=function(e){return{requestLoginOTP:async(t,r,s={})=>{le("requestLoginOTP","xCSRFToken",t),le("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=yt(r,l,e),{url:ye(a),options:l}},verifyLoginOTP:async(t,r,s={})=>{le("verifyLoginOTP","xCSRFToken",t),le("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=yt(r,l,e),{url:ye(a),options:l}}}},cn=function(e){const t=wc(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,se,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,se,fe,e)(u,l||c)}}};class yc extends Xe{requestLoginOTP(t,r,s){return cn(this.configuration).requestLoginOTP(t,r,s).then(n=>n(this.axios,this.basePath))}verifyLoginOTP(t,r,s){return cn(this.configuration).verifyLoginOTP(t,r,s).then(n=>n(this.axios,this.basePath))}}const bc=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={})=>{le("verifyMfaCode","xCSRFToken",t),le("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=yt(r,l,e),{url:ye(a),options:l}}}},dn=function(e){const t=bc(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,se,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,se,fe,e)(u,l||c)}}};class vc extends Xe{getMfaCode(t){return dn(this.configuration).getMfaCode(t).then(r=>r(this.axios,this.basePath))}verifyMfaCode(t,r,s){return dn(this.configuration).verifyMfaCode(t,r,s).then(n=>n(this.axios,this.basePath))}}const Cc=function(e){return{oauthCallback:async(t,r,s,n,a,i,l,u,c={})=>{le("oauthCallback","provider",t),le("oauthCallback","state",r),le("oauthCallback","code",s),le("oauthCallback","scope",n),le("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={})=>{le("oauthRedirect","xCsrftoken",t),le("oauthRedirect","provider",r),le("oauthRedirect","process",s),le("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}}}},un=function(e){const t=Cc(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,se,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,se,fe,e)(d,c||f)}}};class xc extends Xe{oauthCallback(t,r,s,n,a,i,l,u,c){return un(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 un(this.configuration).oauthRedirect(t,r,s,n,a).then(i=>i(this.axios,this.basePath))}}const Sc=function(e){return{changePassword:async(t,r,s={})=>{le("changePassword","xCSRFToken",t),le("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=yt(r,l,e),{url:ye(a),options:l}},setPassword:async(t,r,s={})=>{le("setPassword","xCSRFToken",t),le("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=yt(r,l,e),{url:ye(a),options:l}}}},fn=function(e){const t=Sc(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,se,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,se,fe,e)(u,l||c)}}};class Pc extends Xe{changePassword(t,r,s){return fn(this.configuration).changePassword(t,r,s).then(n=>n(this.axios,this.basePath))}setPassword(t,r,s){return fn(this.configuration).setPassword(t,r,s).then(n=>n(this.axios,this.basePath))}}const kc=function(e){return{setRole:async(t,r,s={})=>{le("setRole","xCSRFToken",t),le("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={})=>{le("switchRole","xCSRFToken",t),le("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}}}},hn=function(e){const t=kc(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,se,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,se,fe,e)(u,l||c)}}};class Ec extends Xe{setRole(t,r,s){return hn(this.configuration).setRole(t,r,s).then(n=>n(this.axios,this.basePath))}switchRole(t,r,s){return hn(this.configuration).switchRole(t,r,s).then(n=>n(this.axios,this.basePath))}}const _c=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={})=>{le("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}}}},pn=function(e){const t=_c(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,se,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,se,fe,e)(f,d||m)}}};class gn extends Xe{getUserProfile(t){return pn(this.configuration).getUserProfile(t).then(r=>r(this.axios,this.basePath))}updateUserProfile(t,r,s,n,a,i){return pn(this.configuration).updateUserProfile(t,r,s,n,a,i).then(l=>l(this.axios,this.basePath))}}class mn{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 rr="/api/v1/appauth",Ye=new mn({basePath:rr,baseOptions:{withCredentials:!0}}),Wr=new mc(Ye),wn=new pc(Ye),Kr=new yc(Ye),Zr=new vc(Ye),bt=new Pc(Ye),yn=new Ec(Ye),bn=new xc(Ye);new gn(Ye);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 ae=null,lt=null;const Oe=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",H={async getAuthConfig(){return ae||lt||(lt=(async()=>{try{const t=(await wn.getAppAuthConfig()).data;return t?.response?.auth_config?ae=t.response.auth_config:t?.auth_config?ae=t.auth_config:ae=t,ae}catch(e){throw console.error("Failed to fetch auth config:",e),lt=null,e}finally{lt=null}})(),lt)},getConfig(){return ae},isPasswordLoginEnabled(){return ae?.login_methods?.password?.enabled||!1},isOTPLoginEnabled(){return ae?.login_methods?.otp?.enabled||!1},isSSOEnabled(){return ae?.login_methods?.sso?.enabled||!1},isOIDCEnabled(){return ae?.login_methods?.oidc?.enabled||!1},getOIDCProviders(){return ae?.login_methods?.oidc?.providers||[]},getSSOProviders(){return ae?.login_methods?.sso?.providers||[]},getAllowedUsernames(){return(ae?.login_methods?.password?.allowed_usernames||ae?.login_methods?.allowed_usernames||["email"]).map(t=>t==="phone"?"mobile":t)},isForgotPasswordEnabled(){return ae?.password_policy?.reset?.enabled||!1},getPasswordResetLinkExpiry(){return ae?.login_methods?.password?.password_reset_link_expiry_hours||24},getSessionPolicy(){return ae?.session_policy||{}},isRememberMeEnabled(){return ae?.session_policy?.remember_me_enabled!==!1},getRememberMeDurationDays(){return ae?.session_policy?.remember_me_duration_days||30},getPasswordPolicy(){return ae?.password_policy||{}},getPasswordResetMethods(){return ae?.password_policy?.reset?.method||[]},isPasswordResetEnabled(){return ae?.password_policy?.reset?.enabled||!1},getPasswordResetExpiry(){return ae?.password_policy?.reset?.expiry_hours||24},isTwoFactorRequired(){return ae?.two_factor_auth?.required||!1},getTwoFactorMethods(){return ae?.two_factor_auth?.allowedMethods||[]},getTwoFactorHooks(){return{email:ae?.two_factor_auth?.email_hook,sms:ae?.two_factor_auth?.sms_hook}},async login(e,t={}){try{ae||await this.getAuthConfig();const r=Ee()||"",s=e,n=await Wr.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=Oe(r);throw s!=="An unexpected error occurred"?new Error(s):r}},async logout(e={}){try{const t=Ee()||"";await Wr.logoutUser(t)}catch(t){console.error("Logout error:",t);const r=Oe(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async getCurrentUser(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return Hn});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=Oe(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 bt.axios.post(`${rr}/password/reset/request/`,e,{headers:{"X-CSRFToken":t}})).data}catch(t){console.error("Request password reset error:",t);const r=Oe(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async validatePasswordResetKey(e){try{return(await bt.axios.get(`${rr}/password/reset/`,{headers:{"x-password-reset-key":e}})).data}catch(t){console.error("Validate password reset key error:",t);const r=Oe(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async confirmResetPassword(e){try{const t=Ee()||"";return(await bt.axios.post(`${rr}/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=Oe(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 Kr.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 Kr.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 yn.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=Oe(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=Oe(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=Oe(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async changePassword(e,t){try{const r=Ee()||"";return(await bt.changePassword(r,{current_password:e,new_password:t})).data}catch(r){console.error("Change password error:",r);const s=Oe(r);throw s!=="An unexpected error occurred"?new Error(s):r}},async setPassword(e){try{const t=Ee()||"";return(await bt.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=Oe(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 bn.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=Oe(u);throw c!=="An unexpected error occurred"?new Error(c):u}},clearConfig(){ae=null,lt=null},async isAuthenticated(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return Hn});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 bn.oauthRedirect(r,e,"login",t)).data}catch(r){throw r}},async getUserProfile(){try{const e=new mn({basePath:"/api/v1",baseOptions:{withCredentials:!0}});return(await new gn(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?.error?.message?i=l.error.message:l?.message?i=l.message:l?.detail&&(i=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"}),s=await r.json();if(!r.ok){let n=`SAML auth meta failed: ${r.status} ${r.statusText}`;throw s?.error?.message?n=s.error.message:s?.message?n=s.message:s?.detail&&(n=s.detail),new Error(n)}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}}},vn=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},Ac=(e=>e?vn(e):vn),Nc=e=>e;function Lc(e,t=Nc){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 Cn=e=>{const t=Ac(e),r=s=>Lc(t,s);return Object.assign(r,t),r},sr=(e=>e?Cn(e):Cn)(e=>({basePath:"/login",setBasePath:t=>e({basePath:t})})),xn=h.createContext(void 0),Ae=()=>{const e=h.useContext(xn);if(!e)throw new Error("useAuthConfig must be used within AuthConfigProvider");return e},Sn=({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(xn.Provider,{value:a,children:e})},Tc=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},Oc=e=>{const t=Tc(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=`
|
|
114
|
+
*/const Hi=Me("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 So(e,t){return function(){return e.apply(t,arguments)}}const{toString:zi}=Object.prototype,{getPrototypeOf:Dr}=Object,{iterator:Yt,toStringTag:Po}=Symbol,Qt=(e=>t=>{const r=zi.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),De=e=>(e=e.toLowerCase(),t=>Qt(t)===e),Rt=e=>t=>typeof t===e,{isArray:wt}=Array,yt=Rt("undefined");function Mt(e){return e!==null&&!yt(e)&&e.constructor!==null&&!yt(e.constructor)&&_e(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const _o=De("ArrayBuffer");function Wi(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&_o(e.buffer),t}const Ki=Rt("string"),_e=Rt("function"),ko=Rt("number"),Ft=e=>e!==null&&typeof e=="object",Zi=e=>e===!0||e===!1,er=e=>{if(Qt(e)!=="object")return!1;const t=Dr(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Po in e)&&!(Yt in e)},Gi=e=>{if(!Ft(e)||Mt(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ji=De("Date"),Xi=De("File"),Yi=De("Blob"),Qi=De("FileList"),Ri=e=>Ft(e)&&_e(e.pipe),el=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_e(e.append)&&((t=Qt(e))==="formdata"||t==="object"&&_e(e.toString)&&e.toString()==="[object FormData]"))},tl=De("URLSearchParams"),[rl,sl,ol,nl]=["ReadableStream","Request","Response","Headers"].map(De),al=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ot(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let s,n;if(typeof e!="object"&&(e=[e]),wt(e))for(s=0,n=e.length;s<n;s++)t.call(null,e[s],s,e);else{if(Mt(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 Eo(e,t){if(Mt(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 it=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ao=e=>!yt(e)&&e!==it;function $r(){const{caseless:e,skipUndefined:t}=Ao(this)&&this||{},r={},s=(n,a)=>{const i=e&&Eo(r,a)||a;er(r[i])&&er(n)?r[i]=$r(r[i],n):er(n)?r[i]=$r({},n):wt(n)?r[i]=n.slice():(!t||!yt(n))&&(r[i]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&Ot(arguments[n],s);return r}const il=(e,t,r,{allOwnKeys:s}={})=>(Ot(t,(n,a)=>{r&&_e(n)?e[a]=So(n,r):e[a]=n},{allOwnKeys:s}),e),ll=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),cl=(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)},dl=(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&&Dr(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},ul=(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},fl=e=>{if(!e)return null;if(wt(e))return e;let t=e.length;if(!ko(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},hl=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Dr(Uint8Array)),pl=(e,t)=>{const s=(e&&e[Yt]).call(e);let n;for(;(n=s.next())&&!n.done;){const a=n.value;t.call(e,a[0],a[1])}},gl=(e,t)=>{let r;const s=[];for(;(r=e.exec(t))!==null;)s.push(r);return s},ml=De("HTMLFormElement"),wl=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,s,n){return s.toUpperCase()+n}),No=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),yl=De("RegExp"),Lo=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),s={};Ot(r,(n,a)=>{let i;(i=t(n,a,e))!==!1&&(s[a]=i||n)}),Object.defineProperties(e,s)},bl=e=>{Lo(e,(t,r)=>{if(_e(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const s=e[r];if(_e(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+"'")})}})},vl=(e,t)=>{const r={},s=n=>{n.forEach(a=>{r[a]=!0})};return wt(e)?s(e):s(String(e).split(t)),r},Cl=()=>{},xl=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Sl(e){return!!(e&&_e(e.append)&&e[Po]==="FormData"&&e[Yt])}const Pl=e=>{const t=new Array(10),r=(s,n)=>{if(Ft(s)){if(t.indexOf(s)>=0)return;if(Mt(s))return s;if(!("toJSON"in s)){t[n]=s;const a=wt(s)?[]:{};return Ot(s,(i,l)=>{const d=r(i,n+1);!yt(d)&&(a[l]=d)}),t[n]=void 0,a}}return s};return r(e,0)},_l=De("AsyncFunction"),kl=e=>e&&(Ft(e)||_e(e))&&_e(e.then)&&_e(e.catch),To=((e,t)=>e?setImmediate:t?((r,s)=>(it.addEventListener("message",({source:n,data:a})=>{n===it&&a===r&&s.length&&s.shift()()},!1),n=>{s.push(n),it.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",_e(it.postMessage)),El=typeof queueMicrotask<"u"?queueMicrotask.bind(it):typeof process<"u"&&process.nextTick||To,E={isArray:wt,isArrayBuffer:_o,isBuffer:Mt,isFormData:el,isArrayBufferView:Wi,isString:Ki,isNumber:ko,isBoolean:Zi,isObject:Ft,isPlainObject:er,isEmptyObject:Gi,isReadableStream:rl,isRequest:sl,isResponse:ol,isHeaders:nl,isUndefined:yt,isDate:Ji,isFile:Xi,isBlob:Yi,isRegExp:yl,isFunction:_e,isStream:Ri,isURLSearchParams:tl,isTypedArray:hl,isFileList:Qi,forEach:Ot,merge:$r,extend:il,trim:al,stripBOM:ll,inherits:cl,toFlatObject:dl,kindOf:Qt,kindOfTest:De,endsWith:ul,toArray:fl,forEachEntry:pl,matchAll:gl,isHTMLForm:ml,hasOwnProperty:No,hasOwnProp:No,reduceDescriptors:Lo,freezeMethods:bl,toObjectSet:vl,toCamelCase:wl,noop:Cl,toFiniteNumber:xl,findKey:Eo,global:it,isContextDefined:Ao,isSpecCompliantForm:Sl,toJSONObject:Pl,isAsyncFn:_l,isThenable:kl,setImmediate:To,asap:El,isIterable:e=>e!=null&&_e(e[Yt])};function ee(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)}E.inherits(ee,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:E.toJSONObject(this.config),code:this.code,status:this.status}}});const Mo=ee.prototype,Fo={};["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=>{Fo[e]={value:e}}),Object.defineProperties(ee,Fo),Object.defineProperty(Mo,"isAxiosError",{value:!0}),ee.from=(e,t,r,s,n,a)=>{const i=Object.create(Mo);E.toFlatObject(e,i,function(u){return u!==Error.prototype},c=>c!=="isAxiosError");const l=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return ee.call(i,l,d,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 Al=null;function Br(e){return E.isPlainObject(e)||E.isArray(e)}function Oo(e){return E.endsWith(e,"[]")?e.slice(0,-2):e}function Uo(e,t,r){return e?e.concat(t).map(function(n,a){return n=Oo(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function Nl(e){return E.isArray(e)&&!e.some(Br)}const Ll=E.toFlatObject(E,{},null,function(t){return/^is[A-Z]/.test(t)});function tr(e,t,r){if(!E.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=E.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,b){return!E.isUndefined(b[w])});const s=r.metaTokens,n=r.visitor||u,a=r.dots,i=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&E.isSpecCompliantForm(t);if(!E.isFunction(n))throw new TypeError("visitor must be a function");function c(m){if(m===null)return"";if(E.isDate(m))return m.toISOString();if(E.isBoolean(m))return m.toString();if(!d&&E.isBlob(m))throw new ee("Blob is not supported. Use a Buffer instead.");return E.isArrayBuffer(m)||E.isTypedArray(m)?d&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function u(m,w,b){let C=m;if(m&&!b&&typeof m=="object"){if(E.endsWith(w,"{}"))w=s?w:w.slice(0,-2),m=JSON.stringify(m);else if(E.isArray(m)&&Nl(m)||(E.isFileList(m)||E.endsWith(w,"[]"))&&(C=E.toArray(m)))return w=Oo(w),C.forEach(function(T,F){!(E.isUndefined(T)||T===null)&&t.append(i===!0?Uo([w],F,a):i===null?w:w+"[]",c(T))}),!1}return Br(m)?!0:(t.append(Uo(b,w,a),c(m)),!1)}const f=[],g=Object.assign(Ll,{defaultVisitor:u,convertValue:c,isVisitable:Br});function h(m,w){if(!E.isUndefined(m)){if(f.indexOf(m)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(m),E.forEach(m,function(C,S){(!(E.isUndefined(C)||C===null)&&n.call(t,C,E.isString(S)?S.trim():S,w,g))===!0&&h(C,w?w.concat(S):[S])}),f.pop()}}if(!E.isObject(e))throw new TypeError("data must be an object");return h(e),t}function Io(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return t[s]})}function qr(e,t){this._pairs=[],e&&tr(e,this,t)}const Do=qr.prototype;Do.append=function(t,r){this._pairs.push([t,r])},Do.toString=function(t){const r=t?function(s){return t.call(this,s,Io)}:Io;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};function Tl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function $o(e,t,r){if(!t)return e;const s=r&&r.encode||Tl;E.isFunction(r)&&(r={serialize:r});const n=r&&r.serialize;let a;if(n?a=n(t,r):a=E.isURLSearchParams(t)?t.toString():new qr(t,r).toString(s),a){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}class Bo{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){E.forEach(this.handlers,function(s){s!==null&&t(s)})}}const qo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ml={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:qr,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Vr=typeof window<"u"&&typeof document<"u",jr=typeof navigator=="object"&&navigator||void 0,Fl=Vr&&(!jr||["ReactNative","NativeScript","NS"].indexOf(jr.product)<0),Ol=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ul=Vr&&window.location.href||"http://localhost",me={...Object.freeze({__proto__:null,hasBrowserEnv:Vr,hasStandardBrowserEnv:Fl,hasStandardBrowserWebWorkerEnv:Ol,navigator:jr,origin:Ul}),...Ml};function Il(e,t){return tr(e,new me.classes.URLSearchParams,{visitor:function(r,s,n,a){return me.isNode&&E.isBuffer(r)?(this.append(s,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function Dl(e){return E.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function $l(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 Vo(e){function t(r,s,n,a){let i=r[a++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),d=a>=r.length;return i=!i&&E.isArray(n)?n.length:i,d?(E.hasOwnProp(n,i)?n[i]=[n[i],s]:n[i]=s,!l):((!n[i]||!E.isObject(n[i]))&&(n[i]=[]),t(r,s,n[i],a)&&E.isArray(n[i])&&(n[i]=$l(n[i])),!l)}if(E.isFormData(e)&&E.isFunction(e.entries)){const r={};return E.forEachEntry(e,(s,n)=>{t(Dl(s),n,r,0)}),r}return null}function Bl(e,t,r){if(E.isString(e))try{return(t||JSON.parse)(e),E.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(r||JSON.stringify)(e)}const Ut={transitional:qo,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const s=r.getContentType()||"",n=s.indexOf("application/json")>-1,a=E.isObject(t);if(a&&E.isHTMLForm(t)&&(t=new FormData(t)),E.isFormData(t))return n?JSON.stringify(Vo(t)):t;if(E.isArrayBuffer(t)||E.isBuffer(t)||E.isStream(t)||E.isFile(t)||E.isBlob(t)||E.isReadableStream(t))return t;if(E.isArrayBufferView(t))return t.buffer;if(E.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 Il(t,this.formSerializer).toString();if((l=E.isFileList(t))||s.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return tr(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),Bl(t)):t}],transformResponse:[function(t){const r=this.transitional||Ut.transitional,s=r&&r.forcedJSONParsing,n=this.responseType==="json";if(E.isResponse(t)||E.isReadableStream(t))return t;if(t&&E.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"?ee.from(l,ee.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:me.classes.FormData,Blob:me.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};E.forEach(["delete","get","head","post","put","patch"],e=>{Ut.headers[e]={}});const ql=E.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"]),Vl=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]&&ql[r])&&(r==="set-cookie"?t[r]?t[r].push(s):t[r]=[s]:t[r]=t[r]?t[r]+", "+s:s)}),t},jo=Symbol("internals");function It(e){return e&&String(e).trim().toLowerCase()}function rr(e){return e===!1||e==null?e:E.isArray(e)?e.map(rr):String(e)}function jl(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 Hl=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Hr(e,t,r,s,n){if(E.isFunction(s))return s.call(this,t,r);if(n&&(t=r),!!E.isString(t)){if(E.isString(s))return t.indexOf(s)!==-1;if(E.isRegExp(s))return s.test(t)}}function zl(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,s)=>r.toUpperCase()+s)}function Wl(e,t){const r=E.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,d,c){const u=It(d);if(!u)throw new Error("header name must be a non-empty string");const f=E.findKey(n,u);(!f||n[f]===void 0||c===!0||c===void 0&&n[f]!==!1)&&(n[f||d]=rr(l))}const i=(l,d)=>E.forEach(l,(c,u)=>a(c,u,d));if(E.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(E.isString(t)&&(t=t.trim())&&!Hl(t))i(Vl(t),r);else if(E.isObject(t)&&E.isIterable(t)){let l={},d,c;for(const u of t){if(!E.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[c=u[0]]=(d=l[c])?E.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}i(l,r)}else t!=null&&a(r,t,s);return this}get(t,r){if(t=It(t),t){const s=E.findKey(this,t);if(s){const n=this[s];if(!r)return n;if(r===!0)return jl(n);if(E.isFunction(r))return r.call(this,n,s);if(E.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=It(t),t){const s=E.findKey(this,t);return!!(s&&this[s]!==void 0&&(!r||Hr(this,this[s],s,r)))}return!1}delete(t,r){const s=this;let n=!1;function a(i){if(i=It(i),i){const l=E.findKey(s,i);l&&(!r||Hr(s,s[l],l,r))&&(delete s[l],n=!0)}}return E.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||Hr(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){const r=this,s={};return E.forEach(this,(n,a)=>{const i=E.findKey(s,a);if(i){r[i]=rr(n),delete r[a];return}const l=t?zl(a):String(a).trim();l!==a&&delete r[a],r[l]=rr(n),s[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return E.forEach(this,(s,n)=>{s!=null&&s!==!1&&(r[n]=t&&E.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[jo]=this[jo]={accessors:{}}).accessors,n=this.prototype;function a(i){const l=It(i);s[l]||(Wl(n,i),s[l]=!0)}return E.isArray(t)?t.forEach(a):a(t),this}};ke.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),E.reduceDescriptors(ke.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[r]=s}}}),E.freezeMethods(ke);function zr(e,t){const r=this||Ut,s=t||r,n=ke.from(s.headers);let a=s.data;return E.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function Ho(e){return!!(e&&e.__CANCEL__)}function bt(e,t,r){ee.call(this,e??"canceled",ee.ERR_CANCELED,t,r),this.name="CanceledError"}E.inherits(bt,ee,{__CANCEL__:!0});function zo(e,t,r){const s=r.config.validateStatus;!r.status||!s||s(r.status)?e(r):t(new ee("Request failed with status code "+r.status,[ee.ERR_BAD_REQUEST,ee.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Kl(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Zl(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(d){const c=Date.now(),u=s[a];i||(i=c),r[n]=d,s[n]=c;let f=a,g=0;for(;f!==n;)g+=r[f++],f=f%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),c-i<t)return;const h=u&&c-u;return h?Math.round(g*1e3/h):void 0}}function Gl(e,t){let r=0,s=1e3/t,n,a;const i=(c,u=Date.now())=>{r=u,n=null,a&&(clearTimeout(a),a=null),e(...c)};return[(...c)=>{const u=Date.now(),f=u-r;f>=s?i(c,u):(n=c,a||(a=setTimeout(()=>{a=null,i(n)},s-f)))},()=>n&&i(n)]}const sr=(e,t,r=3)=>{let s=0;const n=Zl(50,250);return Gl(a=>{const i=a.loaded,l=a.lengthComputable?a.total:void 0,d=i-s,c=n(d),u=i<=l;s=i;const f={loaded:i,total:l,progress:l?i/l:void 0,bytes:d,rate:c||void 0,estimated:c&&l&&u?(l-i)/c:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(f)},r)},Wo=(e,t)=>{const r=e!=null;return[s=>t[0]({lengthComputable:r,total:e,loaded:s}),t[1]]},Ko=e=>(...t)=>E.asap(()=>e(...t)),Jl=me.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,me.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(me.origin),me.navigator&&/(msie|trident)/i.test(me.navigator.userAgent)):()=>!0,Xl=me.hasStandardBrowserEnv?{write(e,t,r,s,n,a,i){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];E.isNumber(r)&&l.push(`expires=${new Date(r).toUTCString()}`),E.isString(s)&&l.push(`path=${s}`),E.isString(n)&&l.push(`domain=${n}`),a===!0&&l.push("secure"),E.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 Yl(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ql(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Zo(e,t,r){let s=!Yl(t);return e&&(s||r==!1)?Ql(e,t):t}const Go=e=>e instanceof ke?{...e}:e;function lt(e,t){t=t||{};const r={};function s(c,u,f,g){return E.isPlainObject(c)&&E.isPlainObject(u)?E.merge.call({caseless:g},c,u):E.isPlainObject(u)?E.merge({},u):E.isArray(u)?u.slice():u}function n(c,u,f,g){if(E.isUndefined(u)){if(!E.isUndefined(c))return s(void 0,c,f,g)}else return s(c,u,f,g)}function a(c,u){if(!E.isUndefined(u))return s(void 0,u)}function i(c,u){if(E.isUndefined(u)){if(!E.isUndefined(c))return s(void 0,c)}else return s(void 0,u)}function l(c,u,f){if(f in t)return s(c,u);if(f in e)return s(void 0,c)}const d={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,u,f)=>n(Go(c),Go(u),f,!0)};return E.forEach(Object.keys({...e,...t}),function(u){const f=d[u]||n,g=f(e[u],t[u],u);E.isUndefined(g)&&f!==l||(r[u]=g)}),r}const Jo=e=>{const t=lt({},e);let{data:r,withXSRFToken:s,xsrfHeaderName:n,xsrfCookieName:a,headers:i,auth:l}=t;if(t.headers=i=ke.from(i),t.url=$o(Zo(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),E.isFormData(r)){if(me.hasStandardBrowserEnv||me.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(E.isFunction(r.getHeaders)){const d=r.getHeaders(),c=["content-type","content-length"];Object.entries(d).forEach(([u,f])=>{c.includes(u.toLowerCase())&&i.set(u,f)})}}if(me.hasStandardBrowserEnv&&(s&&E.isFunction(s)&&(s=s(t)),s||s!==!1&&Jl(t.url))){const d=n&&a&&Xl.read(a);d&&i.set(n,d)}return t},Rl=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,s){const n=Jo(e);let a=n.data;const i=ke.from(n.headers).normalize();let{responseType:l,onUploadProgress:d,onDownloadProgress:c}=n,u,f,g,h,m;function w(){h&&h(),m&&m(),n.cancelToken&&n.cancelToken.unsubscribe(u),n.signal&&n.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(n.method.toUpperCase(),n.url,!0),b.timeout=n.timeout;function C(){if(!b)return;const T=ke.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),U={data:!l||l==="text"||l==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:T,config:e,request:b};zo(function(L){r(L),w()},function(L){s(L),w()},U),b=null}"onloadend"in b?b.onloadend=C:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(C)},b.onabort=function(){b&&(s(new ee("Request aborted",ee.ECONNABORTED,e,b)),b=null)},b.onerror=function(F){const U=F&&F.message?F.message:"Network Error",k=new ee(U,ee.ERR_NETWORK,e,b);k.event=F||null,s(k),b=null},b.ontimeout=function(){let F=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const U=n.transitional||qo;n.timeoutErrorMessage&&(F=n.timeoutErrorMessage),s(new ee(F,U.clarifyTimeoutError?ee.ETIMEDOUT:ee.ECONNABORTED,e,b)),b=null},a===void 0&&i.setContentType(null),"setRequestHeader"in b&&E.forEach(i.toJSON(),function(F,U){b.setRequestHeader(U,F)}),E.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),l&&l!=="json"&&(b.responseType=n.responseType),c&&([g,m]=sr(c,!0),b.addEventListener("progress",g)),d&&b.upload&&([f,h]=sr(d),b.upload.addEventListener("progress",f),b.upload.addEventListener("loadend",h)),(n.cancelToken||n.signal)&&(u=T=>{b&&(s(!T||T.type?new bt(null,e,b):T),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(u),n.signal&&(n.signal.aborted?u():n.signal.addEventListener("abort",u)));const S=Kl(n.url);if(S&&me.protocols.indexOf(S)===-1){s(new ee("Unsupported protocol "+S+":",ee.ERR_BAD_REQUEST,e));return}b.send(a||null)})},ec=(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 u=c instanceof Error?c:this.reason;s.abort(u instanceof ee?u:new bt(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,a(new ee(`timeout ${t} of ms exceeded`,ee.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:d}=s;return d.unsubscribe=()=>E.asap(l),d}},tc=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},rc=async function*(e,t){for await(const r of sc(e))yield*tc(r,t)},sc=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()}},Xo=(e,t,r,s)=>{const n=rc(e,t);let a=0,i,l=d=>{i||(i=!0,s&&s(d))};return new ReadableStream({async pull(d){try{const{done:c,value:u}=await n.next();if(c){l(),d.close();return}let f=u.byteLength;if(r){let g=a+=f;r(g)}d.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(d){return l(d),n.return()}},{highWaterMark:2})},Yo=64*1024,{isFunction:or}=E,oc=(({Request:e,Response:t})=>({Request:e,Response:t}))(E.global),{ReadableStream:Qo,TextEncoder:Ro}=E.global,en=(e,...t)=>{try{return!!e(...t)}catch{return!1}},nc=e=>{e=E.merge.call({skipUndefined:!0},oc,e);const{fetch:t,Request:r,Response:s}=e,n=t?or(t):typeof fetch=="function",a=or(r),i=or(s);if(!n)return!1;const l=n&&or(Qo),d=n&&(typeof Ro=="function"?(m=>w=>m.encode(w))(new Ro):async m=>new Uint8Array(await new r(m).arrayBuffer())),c=a&&l&&en(()=>{let m=!1;const w=new r(me.origin,{body:new Qo,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!w}),u=i&&l&&en(()=>E.isReadableStream(new s("").body)),f={stream:u&&(m=>m.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!f[m]&&(f[m]=(w,b)=>{let C=w&&w[m];if(C)return C.call(w);throw new ee(`Response type '${m}' is not supported`,ee.ERR_NOT_SUPPORT,b)})});const g=async m=>{if(m==null)return 0;if(E.isBlob(m))return m.size;if(E.isSpecCompliantForm(m))return(await new r(me.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(E.isArrayBufferView(m)||E.isArrayBuffer(m))return m.byteLength;if(E.isURLSearchParams(m)&&(m=m+""),E.isString(m))return(await d(m)).byteLength},h=async(m,w)=>{const b=E.toFiniteNumber(m.getContentLength());return b??g(w)};return async m=>{let{url:w,method:b,data:C,signal:S,cancelToken:T,timeout:F,onDownloadProgress:U,onUploadProgress:k,responseType:L,headers:A,withCredentials:D="same-origin",fetchOptions:Y}=Jo(m),_=t||fetch;L=L?(L+"").toLowerCase():"text";let $=ec([S,T&&T.toAbortSignal()],F),v=null;const x=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let q;try{if(k&&c&&b!=="get"&&b!=="head"&&(q=await h(A,C))!==0){let V=new r(w,{method:"POST",body:C,duplex:"half"}),K;if(E.isFormData(C)&&(K=V.headers.get("content-type"))&&A.setContentType(K),V.body){const[H,j]=Wo(q,sr(Ko(k)));C=Xo(V.body,Yo,H,j)}}E.isString(D)||(D=D?"include":"omit");const O=a&&"credentials"in r.prototype,I={...Y,signal:$,method:b.toUpperCase(),headers:A.normalize().toJSON(),body:C,duplex:"half",credentials:O?D:void 0};v=a&&new r(w,I);let X=await(a?_(v,Y):_(w,I));const oe=u&&(L==="stream"||L==="response");if(u&&(U||oe&&x)){const V={};["status","statusText","headers"].forEach(N=>{V[N]=X[N]});const K=E.toFiniteNumber(X.headers.get("content-length")),[H,j]=U&&Wo(K,sr(Ko(U),!0))||[];X=new s(Xo(X.body,Yo,H,()=>{j&&j(),x&&x()}),V)}L=L||"text";let P=await f[E.findKey(f,L)||"text"](X,m);return!oe&&x&&x(),await new Promise((V,K)=>{zo(V,K,{data:P,headers:ke.from(X.headers),status:X.status,statusText:X.statusText,config:m,request:v})})}catch(O){throw x&&x(),O&&O.name==="TypeError"&&/Load failed|fetch/i.test(O.message)?Object.assign(new ee("Network Error",ee.ERR_NETWORK,m,v),{cause:O.cause||O}):ee.from(O,O&&O.code,m,v)}}},ac=new Map,tn=e=>{let t=e&&e.env||{};const{fetch:r,Request:s,Response:n}=t,a=[s,n,r];let i=a.length,l=i,d,c,u=ac;for(;l--;)d=a[l],c=u.get(d),c===void 0&&u.set(d,c=l?new Map:nc(t)),u=c;return c};tn();const Wr={http:Al,xhr:Rl,fetch:{get:tn}};E.forEach(Wr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const rn=e=>`- ${e}`,ic=e=>E.isFunction(e)||e===null||e===!1;function lc(e,t){e=E.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,!ic(s)&&(n=Wr[(l=String(s)).toLowerCase()],n===void 0))throw new ee(`Unknown adapter '${l}'`);if(n&&(E.isFunction(n)||(n=n.get(t))))break;a[l||"#"+i]=n}if(!n){const i=Object.entries(a).map(([d,c])=>`adapter ${d} `+(c===!1?"is not supported by the environment":"is not available in the build"));let l=r?i.length>1?`since :
|
|
117
|
+
`+i.map(rn).join(`
|
|
118
|
+
`):" "+rn(i[0]):"as no adapter specified";throw new ee("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return n}const sn={getAdapter:lc,adapters:Wr};function Kr(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new bt(null,e)}function on(e){return Kr(e),e.headers=ke.from(e.headers),e.data=zr.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),sn.getAdapter(e.adapter||Ut.adapter,e)(e).then(function(s){return Kr(e),s.data=zr.call(e,e.transformResponse,s),s.headers=ke.from(s.headers),s},function(s){return Ho(s)||(Kr(e),s&&s.response&&(s.response.data=zr.call(e,e.transformResponse,s.response),s.response.headers=ke.from(s.response.headers))),Promise.reject(s)})}const nn="1.13.0",nr={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{nr[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const an={};nr.transitional=function(t,r,s){function n(a,i){return"[Axios v"+nn+"] Transitional option '"+a+"'"+i+(s?". "+s:"")}return(a,i,l)=>{if(t===!1)throw new ee(n(i," has been removed"+(r?" in "+r:"")),ee.ERR_DEPRECATED);return r&&!an[i]&&(an[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}},nr.spelling=function(t){return(r,s)=>(console.warn(`${s} is likely a misspelling of ${t}`),!0)};function cc(e,t,r){if(typeof e!="object")throw new ee("options must be an object",ee.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],d=l===void 0||i(l,a,e);if(d!==!0)throw new ee("option "+a+" must be "+d,ee.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new ee("Unknown option "+a,ee.ERR_BAD_OPTION)}}const ar={assertOptions:cc,validators:nr},Ve=ar.validators;let ct=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Bo,response:new Bo}}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=lt(this.defaults,r);const{transitional:s,paramsSerializer:n,headers:a}=r;s!==void 0&&ar.assertOptions(s,{silentJSONParsing:Ve.transitional(Ve.boolean),forcedJSONParsing:Ve.transitional(Ve.boolean),clarifyTimeoutError:Ve.transitional(Ve.boolean)},!1),n!=null&&(E.isFunction(n)?r.paramsSerializer={serialize:n}:ar.assertOptions(n,{encode:Ve.function,serialize:Ve.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),ar.assertOptions(r,{baseUrl:Ve.spelling("baseURL"),withXsrfToken:Ve.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=a&&E.merge(a.common,a[r.method]);a&&E.forEach(["delete","get","head","post","put","patch","common"],m=>{delete a[m]}),r.headers=ke.concat(i,a);const l=[];let d=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(r)===!1||(d=d&&w.synchronous,l.unshift(w.fulfilled,w.rejected))});const c=[];this.interceptors.response.forEach(function(w){c.push(w.fulfilled,w.rejected)});let u,f=0,g;if(!d){const m=[on.bind(this),void 0];for(m.unshift(...l),m.push(...c),g=m.length,u=Promise.resolve(r);f<g;)u=u.then(m[f++],m[f++]);return u}g=l.length;let h=r;for(;f<g;){const m=l[f++],w=l[f++];try{h=m(h)}catch(b){w.call(this,b);break}}try{u=on.call(this,h)}catch(m){return Promise.reject(m)}for(f=0,g=c.length;f<g;)u=u.then(c[f++],c[f++]);return u}getUri(t){t=lt(this.defaults,t);const r=Zo(t.baseURL,t.url,t.allowAbsoluteUrls);return $o(r,t.params,t.paramsSerializer)}};E.forEach(["delete","get","head","options"],function(t){ct.prototype[t]=function(r,s){return this.request(lt(s||{},{method:t,url:r,data:(s||{}).data}))}}),E.forEach(["post","put","patch"],function(t){function r(s){return function(a,i,l){return this.request(lt(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:a,data:i}))}}ct.prototype[t]=r(),ct.prototype[t+"Form"]=r(!0)});let dc=class Ka{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 bt(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 Ka(function(n){t=n}),cancel:t}}};function uc(e){return function(r){return e.apply(null,r)}}function fc(e){return E.isObject(e)&&e.isAxiosError===!0}const Zr={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(Zr).forEach(([e,t])=>{Zr[t]=e});function ln(e){const t=new ct(e),r=So(ct.prototype.request,t);return E.extend(r,ct.prototype,t,{allOwnKeys:!0}),E.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return ln(lt(e,n))},r}const se=ln(Ut);se.Axios=ct,se.CanceledError=bt,se.CancelToken=dc,se.isCancel=Ho,se.VERSION=nn,se.toFormData=tr,se.AxiosError=ee,se.Cancel=se.CanceledError,se.all=function(t){return Promise.all(t)},se.spread=uc,se.isAxiosError=fc,se.mergeConfig=lt,se.AxiosHeaders=ke,se.formToJSON=e=>Vo(E.isHTMLForm(e)?new FormData(e):e),se.getAdapter=sn.getAdapter,se.HttpStatusCode=Zr,se.default=se;const{Axios:rh,AxiosError:sh,CanceledError:oh,isCancel:nh,CancelToken:ah,VERSION:ih,all:lh,Cancel:ch,isAxiosError:dh,spread:uh,toFormData:fh,AxiosHeaders:hh,HttpStatusCode:ph,formToJSON:gh,getAdapter:mh,mergeConfig:wh}=se,pe="/api/v1/appauth".replace(/\/+$/,"");class Qe{constructor(t,r=pe,s=se){this.basePath=r,this.axios=s,t&&(this.configuration=t,this.basePath=t.basePath??r)}}class hc extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}const we={"UserProfileApi.getUserProfile":[{url:"/api/v1",description:"Profile API base URL"}],"UserProfileApi.updateUserProfile":[{url:"/api/v1",description:"Profile API base URL"}]},ye="https://example.com",le=function(e,t,r){if(r==null)throw new hc(t,`Required parameter ${t} was null or undefined when calling ${e}.`)};function Gr(e,t,r=""){t!=null&&(typeof t=="object"?Array.isArray(t)?t.forEach(s=>Gr(e,s,r)):Object.keys(t).forEach(s=>Gr(e,t[s],`${r}${r!==""?".":""}${s}`)):e.has(r)?e.append(r,t):e.set(r,t))}const be=function(e,...t){const r=new URLSearchParams(e.search);Gr(r,t),e.search=r.toString()},vt=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||""},ve=function(e){return e.pathname+e.search+e.hash},Ce=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)}},pc=function(e){return{getAppAuthConfig:async(t={})=>{const r="/config/",s=new URL(r,ye);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t},i={};be(s,{});let d=n&&n.headers?n.headers:{};return a.headers={...i,...d,...t.headers},{url:ve(s),options:a}},updateAppAuthConfig:async(t,r,s={})=>{le("updateAppAuthConfig","xCSRFToken",t),le("updateAppAuthConfig","authConfig",r);const n="/config/",a=new URL(n,ye);let i;e&&(i=e.baseOptions);const l={method:"PUT",...i,...s},d={},c={},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)),be(a,c);let f=i&&i.headers?i.headers:{};return l.headers={...d,...f,...s.headers},l.data=u,{url:ve(a),options:l}}}},cn=function(e){const t=pc(e);return{async getAppAuthConfig(r){const s=await t.getAppAuthConfig(r),n=e?.serverIndex??0,a=we["ApplicationConfigurationApi.getAppAuthConfig"]?.[n]?.url;return(i,l)=>Ce(s,se,pe,e)(i,a||l)},async updateAppAuthConfig(r,s,n){const a=await t.updateAppAuthConfig(r,s,n),i=e?.serverIndex??0,l=we["ApplicationConfigurationApi.updateAppAuthConfig"]?.[i]?.url;return(d,c)=>Ce(a,se,pe,e)(d,l||c)}}};class gc extends Qe{getAppAuthConfig(t){return cn(this.configuration).getAppAuthConfig(t).then(r=>r(this.axios,this.basePath))}updateAppAuthConfig(t,r,s){return cn(this.configuration).updateAppAuthConfig(t,r,s).then(n=>n(this.axios,this.basePath))}}const mc=function(e){return{loginUser:async(t,r,s={})=>{le("loginUser","xCSRFToken",t),le("loginUser","loginUserRequest",r);const n="/login/",a=new URL(n,ye);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},d={},c={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),be(a,c);let u=i&&i.headers?i.headers:{};return l.headers={...d,...u,...s.headers},l.data=vt(r,l,e),{url:ve(a),options:l}},logoutUser:async(t,r={})=>{le("logoutUser","xCSRFToken",t);const s="/logout/",n=new URL(s,ye);let a;e&&(a=e.baseOptions);const i={method:"DELETE",...a,...r},l={},d={};t!=null&&(l["X-CSRFToken"]=String(t)),be(n,d);let c=a&&a.headers?a.headers:{};return i.headers={...l,...c,...r.headers},{url:ve(n),options:i}}}},dn=function(e){const t=mc(e);return{async loginUser(r,s,n){const a=await t.loginUser(r,s,n),i=e?.serverIndex??0,l=we["AuthenticationApi.loginUser"]?.[i]?.url;return(d,c)=>Ce(a,se,pe,e)(d,l||c)},async logoutUser(r,s){const n=await t.logoutUser(r,s),a=e?.serverIndex??0,i=we["AuthenticationApi.logoutUser"]?.[a]?.url;return(l,d)=>Ce(n,se,pe,e)(l,i||d)}}};class wc extends Qe{loginUser(t,r,s){return dn(this.configuration).loginUser(t,r,s).then(n=>n(this.axios,this.basePath))}logoutUser(t,r){return dn(this.configuration).logoutUser(t,r).then(s=>s(this.axios,this.basePath))}}const yc=function(e){return{requestLoginOTP:async(t,r,s={})=>{le("requestLoginOTP","xCSRFToken",t),le("requestLoginOTP","loginOTPRequest",r);const n="/login/code/request/",a=new URL(n,ye);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},d={},c={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),be(a,c);let u=i&&i.headers?i.headers:{};return l.headers={...d,...u,...s.headers},l.data=vt(r,l,e),{url:ve(a),options:l}},verifyLoginOTP:async(t,r,s={})=>{le("verifyLoginOTP","xCSRFToken",t),le("verifyLoginOTP","loginOTPVerifyRequest",r);const n="/login/code/confirm/",a=new URL(n,ye);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},d={},c={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),be(a,c);let u=i&&i.headers?i.headers:{};return l.headers={...d,...u,...s.headers},l.data=vt(r,l,e),{url:ve(a),options:l}}}},un=function(e){const t=yc(e);return{async requestLoginOTP(r,s,n){const a=await t.requestLoginOTP(r,s,n),i=e?.serverIndex??0,l=we["LoginWithOTPApi.requestLoginOTP"]?.[i]?.url;return(d,c)=>Ce(a,se,pe,e)(d,l||c)},async verifyLoginOTP(r,s,n){const a=await t.verifyLoginOTP(r,s,n),i=e?.serverIndex??0,l=we["LoginWithOTPApi.verifyLoginOTP"]?.[i]?.url;return(d,c)=>Ce(a,se,pe,e)(d,l||c)}}};class bc extends Qe{requestLoginOTP(t,r,s){return un(this.configuration).requestLoginOTP(t,r,s).then(n=>n(this.axios,this.basePath))}verifyLoginOTP(t,r,s){return un(this.configuration).verifyLoginOTP(t,r,s).then(n=>n(this.axios,this.basePath))}}const vc=function(e){return{getMfaCode:async(t={})=>{const r="/mfa/getcode/",s=new URL(r,ye);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t},i={};be(s,{});let d=n&&n.headers?n.headers:{};return a.headers={...i,...d,...t.headers},{url:ve(s),options:a}},verifyMfaCode:async(t,r,s={})=>{le("verifyMfaCode","xCSRFToken",t),le("verifyMfaCode","mfaVerifyRequest",r);const n="/mfa/verify/",a=new URL(n,ye);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},d={},c={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),be(a,c);let u=i&&i.headers?i.headers:{};return l.headers={...d,...u,...s.headers},l.data=vt(r,l,e),{url:ve(a),options:l}}}},fn=function(e){const t=vc(e);return{async getMfaCode(r){const s=await t.getMfaCode(r),n=e?.serverIndex??0,a=we["MultiFactorAuthenticationApi.getMfaCode"]?.[n]?.url;return(i,l)=>Ce(s,se,pe,e)(i,a||l)},async verifyMfaCode(r,s,n){const a=await t.verifyMfaCode(r,s,n),i=e?.serverIndex??0,l=we["MultiFactorAuthenticationApi.verifyMfaCode"]?.[i]?.url;return(d,c)=>Ce(a,se,pe,e)(d,l||c)}}};class Cc extends Qe{getMfaCode(t){return fn(this.configuration).getMfaCode(t).then(r=>r(this.axios,this.basePath))}verifyMfaCode(t,r,s){return fn(this.configuration).verifyMfaCode(t,r,s).then(n=>n(this.axios,this.basePath))}}const xc=function(e){return{oauthCallback:async(t,r,s,n,a,i,l,d,c={})=>{le("oauthCallback","provider",t),le("oauthCallback","state",r),le("oauthCallback","code",s),le("oauthCallback","scope",n),le("oauthCallback","xCSRFToken",a);const u="/oauth/{provider}/callback/".replace("{provider}",encodeURIComponent(String(t))),f=new URL(u,ye);let g;e&&(g=e.baseOptions);const h={method:"POST",...g,...c},m={},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),d!==void 0&&(w.prompt=d),a!=null&&(m["X-CSRFToken"]=String(a)),be(f,w);let b=g&&g.headers?g.headers:{};return h.headers={...m,...b,...c.headers},{url:ve(f),options:h}},oauthRedirect:async(t,r,s,n,a={})=>{le("oauthRedirect","xCsrftoken",t),le("oauthRedirect","provider",r),le("oauthRedirect","process",s),le("oauthRedirect","callbackUrl",n);const i="/oauth/redirect/",l=new URL(i,ye);let d;e&&(d=e.baseOptions);const c={method:"POST",...d,...a},u={},f={},g=new URLSearchParams;r!==void 0&&g.set("provider",r),s!==void 0&&g.set("process",s),n!==void 0&&g.set("callback_url",n),u["Content-Type"]="application/x-www-form-urlencoded",t!=null&&(u["x-csrftoken"]=String(t)),be(l,f);let h=d&&d.headers?d.headers:{};return c.headers={...u,...h,...a.headers},c.data=g.toString(),{url:ve(l),options:c}}}},hn=function(e){const t=xc(e);return{async oauthCallback(r,s,n,a,i,l,d,c,u){const f=await t.oauthCallback(r,s,n,a,i,l,d,c,u),g=e?.serverIndex??0,h=we["OAuthApi.oauthCallback"]?.[g]?.url;return(m,w)=>Ce(f,se,pe,e)(m,h||w)},async oauthRedirect(r,s,n,a,i){const l=await t.oauthRedirect(r,s,n,a,i),d=e?.serverIndex??0,c=we["OAuthApi.oauthRedirect"]?.[d]?.url;return(u,f)=>Ce(l,se,pe,e)(u,c||f)}}};class Sc extends Qe{oauthCallback(t,r,s,n,a,i,l,d,c){return hn(this.configuration).oauthCallback(t,r,s,n,a,i,l,d,c).then(u=>u(this.axios,this.basePath))}oauthRedirect(t,r,s,n,a){return hn(this.configuration).oauthRedirect(t,r,s,n,a).then(i=>i(this.axios,this.basePath))}}const Pc=function(e){return{changePassword:async(t,r,s={})=>{le("changePassword","xCSRFToken",t),le("changePassword","passwordChangeRequest",r);const n="/password/change/",a=new URL(n,ye);let i;e&&(i=e.baseOptions);const l={method:"PUT",...i,...s},d={},c={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),be(a,c);let u=i&&i.headers?i.headers:{};return l.headers={...d,...u,...s.headers},l.data=vt(r,l,e),{url:ve(a),options:l}},setPassword:async(t,r,s={})=>{le("setPassword","xCSRFToken",t),le("setPassword","passwordSetRequest",r);const n="/password/set/",a=new URL(n,ye);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},d={},c={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),be(a,c);let u=i&&i.headers?i.headers:{};return l.headers={...d,...u,...s.headers},l.data=vt(r,l,e),{url:ve(a),options:l}}}},pn=function(e){const t=Pc(e);return{async changePassword(r,s,n){const a=await t.changePassword(r,s,n),i=e?.serverIndex??0,l=we["PasswordManagementApi.changePassword"]?.[i]?.url;return(d,c)=>Ce(a,se,pe,e)(d,l||c)},async setPassword(r,s,n){const a=await t.setPassword(r,s,n),i=e?.serverIndex??0,l=we["PasswordManagementApi.setPassword"]?.[i]?.url;return(d,c)=>Ce(a,se,pe,e)(d,l||c)}}};class _c extends Qe{changePassword(t,r,s){return pn(this.configuration).changePassword(t,r,s).then(n=>n(this.axios,this.basePath))}setPassword(t,r,s){return pn(this.configuration).setPassword(t,r,s).then(n=>n(this.axios,this.basePath))}}const kc=function(e){return{setRole:async(t,r,s={})=>{le("setRole","xCSRFToken",t),le("setRole","role",r);const n="/role/set/",a=new URL(n,ye);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},d={},c={};r!==void 0&&(c.role=r),t!=null&&(d["X-CSRFToken"]=String(t)),be(a,c);let u=i&&i.headers?i.headers:{};return l.headers={...d,...u,...s.headers},{url:ve(a),options:l}},switchRole:async(t,r,s={})=>{le("switchRole","xCSRFToken",t),le("switchRole","role",r);const n="/role/switch/",a=new URL(n,ye);let i;e&&(i=e.baseOptions);const l={method:"POST",...i,...s},d={},c={};r!==void 0&&(c.role=r),t!=null&&(d["X-CSRFToken"]=String(t)),be(a,c);let u=i&&i.headers?i.headers:{};return l.headers={...d,...u,...s.headers},{url:ve(a),options:l}}}},gn=function(e){const t=kc(e);return{async setRole(r,s,n){const a=await t.setRole(r,s,n),i=e?.serverIndex??0,l=we["RoleManagementApi.setRole"]?.[i]?.url;return(d,c)=>Ce(a,se,pe,e)(d,l||c)},async switchRole(r,s,n){const a=await t.switchRole(r,s,n),i=e?.serverIndex??0,l=we["RoleManagementApi.switchRole"]?.[i]?.url;return(d,c)=>Ce(a,se,pe,e)(d,l||c)}}};class Ec extends Qe{setRole(t,r,s){return gn(this.configuration).setRole(t,r,s).then(n=>n(this.axios,this.basePath))}switchRole(t,r,s){return gn(this.configuration).switchRole(t,r,s).then(n=>n(this.axios,this.basePath))}}const Ac=function(e){return{getUserProfile:async(t={})=>{const r="/profile/",s=new URL(r,ye);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t},i={};be(s,{});let d=n&&n.headers?n.headers:{};return a.headers={...i,...d,...t.headers},{url:ve(s),options:a}},updateUserProfile:async(t,r,s,n,a,i={})=>{le("updateUserProfile","xCSRFToken",t);const l="/profile/",d=new URL(l,ye);let c;e&&(c=e.baseOptions);const u={method:"PUT",...c,...i},f={},g={},h=new(e&&e.formDataCtor||FormData);r!==void 0&&h.append("name",r),s!==void 0&&h.append("mobile",s),n!==void 0&&h.append("auth_config",n),a!==void 0&&h.append("profile_pic",a),f["Content-Type"]="multipart/form-data",t!=null&&(f["X-CSRFToken"]=String(t)),be(d,g);let m=c&&c.headers?c.headers:{};return u.headers={...f,...m,...i.headers},u.data=h,{url:ve(d),options:u}}}},mn=function(e){const t=Ac(e);return{async getUserProfile(r){const s=await t.getUserProfile(r),n=e?.serverIndex??0,a=we["UserProfileApi.getUserProfile"]?.[n]?.url;return(i,l)=>Ce(s,se,pe,e)(i,a||l)},async updateUserProfile(r,s,n,a,i,l){const d=await t.updateUserProfile(r,s,n,a,i,l),c=e?.serverIndex??0,u=we["UserProfileApi.updateUserProfile"]?.[c]?.url;return(f,g)=>Ce(d,se,pe,e)(f,u||g)}}};class wn extends Qe{getUserProfile(t){return mn(this.configuration).getUserProfile(t).then(r=>r(this.axios,this.basePath))}updateUserProfile(t,r,s,n,a,i){return mn(this.configuration).updateUserProfile(t,r,s,n,a,i).then(l=>l(this.axios,this.basePath))}}class yn{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 ir="/api/v1/appauth",Re=new yn({basePath:ir,baseOptions:{withCredentials:!0}}),Jr=new wc(Re),bn=new gc(Re),Xr=new bc(Re),Yr=new Cc(Re),Ct=new _c(Re),Nc=new Ec(Re),vn=new Sc(Re);new wn(Re);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 ae=null,dt=null,je=null;const Fe=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",W={async getAuthConfig(){return ae||dt||(dt=(async()=>{try{const t=(await bn.getAppAuthConfig()).data;return t?.response?.auth_config?ae=t.response.auth_config:t?.auth_config?ae=t.auth_config:ae=t,ae}catch(e){throw console.error("Failed to fetch auth config:",e),dt=null,e}finally{dt=null}})(),dt)},getConfig(){return ae},isPasswordLoginEnabled(){return ae?.login_methods?.password?.enabled||!1},isOTPLoginEnabled(){return ae?.login_methods?.otp?.enabled||!1},isSSOEnabled(){return ae?.login_methods?.sso?.enabled||!1},isOIDCEnabled(){return ae?.login_methods?.oidc?.enabled||!1},getOIDCProviders(){return ae?.login_methods?.oidc?.providers||[]},getSSOProviders(){return ae?.login_methods?.sso?.providers||[]},getAllowedUsernames(){return(ae?.login_methods?.password?.allowed_usernames||ae?.login_methods?.allowed_usernames||["email"]).map(t=>t==="phone"?"mobile":t)},isForgotPasswordEnabled(){return ae?.password_policy?.reset?.enabled||!1},getPasswordResetLinkExpiry(){return ae?.login_methods?.password?.password_reset_link_expiry_hours||24},getSessionPolicy(){return ae?.session_policy||{}},isRememberMeEnabled(){return ae?.session_policy?.remember_me_enabled!==!1},getRememberMeDurationDays(){return ae?.session_policy?.remember_me_duration_days||30},getPasswordPolicy(){return ae?.password_policy||{}},getPasswordResetMethods(){return ae?.password_policy?.reset?.method||[]},isPasswordResetEnabled(){return ae?.password_policy?.reset?.enabled||!1},getPasswordResetExpiry(){return ae?.password_policy?.reset?.expiry_hours||24},isTwoFactorRequired(){return ae?.two_factor_auth?.required||!1},getTwoFactorMethods(){return ae?.two_factor_auth?.allowedMethods||[]},getTwoFactorHooks(){return{email:ae?.two_factor_auth?.email_hook,sms:ae?.two_factor_auth?.sms_hook}},async login(e,t={}){try{ae||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=Fe(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=Fe(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async getCurrentUser(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return zn});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=Fe(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 Ct.axios.post(`${ir}/password/reset/request/`,e,{headers:{"X-CSRFToken":t}})).data}catch(t){console.error("Request password reset error:",t);const r=Fe(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async validatePasswordResetKey(e){try{return(await Ct.axios.get(`${ir}/password/reset/`,{headers:{"x-password-reset-key":e}})).data}catch(t){console.error("Validate password reset key error:",t);const r=Fe(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async confirmResetPassword(e){try{const t=Ee()||"";return(await Ct.axios.post(`${ir}/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=Fe(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 Xr.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 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 Xr.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 r={"Content-Type":"application/json","X-CSRFToken":Ee()||""};je&&(r["X-Session-Token"]=je);const s=await fetch(`/api/v1/appauth/role/set/?role=${encodeURIComponent(e)}`,{method:"POST",headers:r,credentials:"include"}),n=await s.json();if(n?.success&&n?.response){const a=n.response;return a.status===401&&a.data?.next_step?a:((a.status===200||a.meta?.is_authenticated)&&(je=null),a.data||a)}if(!s.ok){if(s.status===401&&n&&(n?.response?.data?.next_step||n?.data?.next_step))return n;const a=n?.error?.message||n?.message||`Role selection failed: ${s.status}`;throw new Error(a)}return n}catch(t){console.error("Select role error:",t);const r=Fe(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async sendTwoFactorCode(){try{return(await Yr.getMfaCode()).data}catch(e){console.error("Send 2FA code error:",e);const t=Fe(e);throw t!=="An unexpected error occurred"?new Error(t):e}},async verifyTwoFactorCode(e){try{const t=Ee()||"";return(await Yr.verifyMfaCode(t,{code:e})).data}catch(t){console.error("Verify 2FA code error:",t);const r=Fe(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async changePassword(e,t){try{const r=Ee()||"";return(await Ct.changePassword(r,{current_password:e,new_password:t})).data}catch(r){console.error("Change password error:",r);const s=Fe(r);throw s!=="An unexpected error occurred"?new Error(s):r}},async setPassword(e){try{const t=Ee()||"";return(await Ct.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=Fe(t);throw r!=="An unexpected error occurred"?new Error(r):t}},async processOAuthCallback(e,t,r,s,n,a,i,l){try{const d=Ee()||"",c=await vn.oauthCallback(e,t,r,s,d,n,a,i,l),u=c.data;if(u?.success&&u?.response){const f=u.response;return f.status===401&&f.data?.next_step?f:f.data||f}return c.data}catch(d){if(d.response?.status===401&&d.response?.data){const u=d.response.data;if(u?.success&&u?.response){const f=u.response;if(f.status===401&&f.data?.next_step)return f}if(u?.response?.data?.next_step||u?.data?.next_step)return u}const c=Fe(d);throw c!=="An unexpected error occurred"?new Error(c):d}},clearConfig(){ae=null,dt=null},async isAuthenticated(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return zn});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,r){try{const s=Ee()||"",n=r?{transformRequest:[(i,l)=>{const d=new URLSearchParams(i);return r&&d.set("next",r),d.toString()}]}:void 0;return(await vn.oauthRedirect(s,e,"login",t,n)).data}catch(s){throw s}},async getUserProfile(){try{const e=new yn({basePath:"/api/v1",baseOptions:{withCredentials:!0}});return(await new wn(e).getUserProfile()).data}catch(e){throw console.error("Get user profile error:",e),e}},async initiateSAMLAuth(e,t){try{const r=Ee()||"",s={saml_id:e,...t&&{next:t}},n=await fetch("/api/v1/appauth/saml/init/",{method:"POST",headers:{"Content-Type":"application/json","X-CSRFToken":r},credentials:"include",body:JSON.stringify(s)}),a=await n.text();if(!n.ok){let l=`SAML init failed: ${n.status} ${n.statusText}`;try{const d=JSON.parse(a);d?.error?.message?l=d.error.message:d?.message?l=d.message:d?.detail&&(l=d.detail)}catch{a&&a.length<500&&(l+=` - ${a}`)}throw new Error(l)}const i=JSON.parse(a);if(i?.success&&i?.response){if(typeof i.response=="string"&&i.response.startsWith("http"))return{redirect_url:i.response};if(i.response?.redirect_url)return{redirect_url:i.response.redirect_url}}else if(i?.redirect_url)return{redirect_url:i.redirect_url};return i}catch(r){throw console.error("SAML init error:",r),r}},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"}),s=await r.json();if(!r.ok){let n=`SAML auth meta failed: ${r.status} ${r.statusText}`;throw s?.error?.message?n=s.error.message:s?.message?n=s.message:s?.detail&&(n=s.detail),new Error(n)}if(s?.success&&s?.response){const n=s.response;return n.meta?.session_token&&(je=n.meta.session_token),n.status===401&&n.data?.next_step?n:n.data||n}return s?.meta?.session_token&&(je=s.meta.session_token),s}catch(r){throw console.error("SAML auth meta error:",r),r}},async setRole(e){try{const r={"Content-Type":"application/json","X-CSRFToken":Ee()||""};je&&(r["X-Session-Token"]=je);const s=await fetch(`/api/v1/appauth/role/set/?role=${encodeURIComponent(e)}`,{method:"POST",headers:r,credentials:"include"});if(!s.ok){const a=await s.text();throw new Error(`Role set failed: ${s.status} ${s.statusText}`)}const n=await s.json();if(n?.success&&n?.response){const a=n.response;return a.status===401&&a.data?.next_step?a:((a.status===200||a.meta?.is_authenticated)&&(je=null),a.data||a)}return n}catch(t){throw console.error("Set role error:",t),t}},clearSamlSessionToken(){je=null},getSamlSessionToken(){return je}},Cn=e=>{let t;const r=new Set,s=(c,u)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const g=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(h=>h(t,g))}},n=()=>t,l={setState:s,getState:n,getInitialState:()=>d,subscribe:c=>(r.add(c),()=>r.delete(c))},d=t=e(s,n,l);return l},Lc=(e=>e?Cn(e):Cn),Tc=e=>e;function Mc(e,t=Tc){const r=p.useSyncExternalStore(e.subscribe,p.useCallback(()=>t(e.getState()),[e,t]),p.useCallback(()=>t(e.getInitialState()),[e,t]));return p.useDebugValue(r),r}const xn=e=>{const t=Lc(e),r=s=>Mc(t,s);return Object.assign(r,t),r},lr=(e=>e?xn(e):xn)(e=>({basePath:"/login",setBasePath:t=>e({basePath:t})})),Sn=p.createContext(void 0),Ae=()=>{const e=p.useContext(Sn);if(!e)throw new Error("useAuthConfig must be used within AuthConfigProvider");return e},Pn=({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 d={...i};for(const c in l)l[c]!==null&&typeof l[c]=="object"&&!Array.isArray(l[c])&&!p.isValidElement(l[c])?d[c]=s(i[c]||{},l[c]):d[c]=l[c];return d},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(Sn.Provider,{value:a,children:e})},Fc=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},Oc=e=>{const t=Fc(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=`
|
|
120
120
|
:root { ${t} }
|
|
121
121
|
|
|
122
122
|
/* Auth component text styling using CSS variables */
|
|
@@ -144,7 +144,7 @@ export default App;`,m=`mkdir -p ${l}`,g={container:{padding:"32px",maxWidth:"90
|
|
|
144
144
|
.auth-link:hover {
|
|
145
145
|
color: var(--auth-link-hover-color, #3b82f6) !important;
|
|
146
146
|
}
|
|
147
|
-
`;r.innerHTML=s},Fc=()=>{const e=document.getElementById("auth-theme-variables");e&&e.remove()},Ke=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},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),r},ct=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},Mc=e=>e?.logo?.position||"center",dt=e=>{const t=Mc(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}},Ue=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},Pn=e=>{const t=e?.theme;if(!t)return{};const r={};return t.linkColor&&(r.color=t.linkColor),t.fontFamily&&(r.fontFamily=t.fontFamily),r},Ic=({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}=sr(),{authConfig:w,getResetPasswordConfig:b,getMessagesConfig:x}=Ae(),P=b(),L=x(),M=Qe(w),B=dt(w),E=ct(w);h.useEffect(()=>{(async()=>{try{await H.getAuthConfig();const I=H.getPasswordResetMethods();I&&I.length>0&&(f(I),g(I[0]))}catch(I){console.error("Failed to load reset configuration:",I)}})()},[]);const _=async v=>{s(!0),a(null);try{if(e){const I={email:m==="email"?v.contact:void 0,phone:m==="sms"?v.contact:void 0};await e(I)}l(!0),c(I=>I+1)}catch(I){const A=m==="email"?"email":"SMS",C=I.message||L?.errors?.networkError||`Failed to send reset ${A}. Please try again.`;a(C)}finally{s(!1)}},k=()=>m==="email"?P?.forgotPassword?.emailPlaceholder||"Email address":"Phone number",O=()=>m==="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 phone number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:L?.validation?.invalidMobile||"Please enter a valid phone number!"}],V=()=>{const v=m==="email"?"Email":"SMS",I=m==="email"?"email":"phone";return{title:P?.forgotPassword?.successMessage||`${v} Sent!`,subTitle:`Please check your ${I} for password reset instructions.`}};if(i){const v=V();return o.jsx(y.Result,{status:"success",title:v.title,subTitle:v.subTitle,extra:[o.jsx(J.Link,{to:p,children:o.jsx(y.Button,{variant:"primary",children:P?.forgotPassword?.backToLoginText||"Back to Login"})},"login")]})}return o.jsxs("div",{className:"w-full max-w-md mx-auto",style:M,children:[o.jsx(J.Link,{to:p,className:"inline-block mb-6",children:o.jsxs(y.Button,{variant:"link",size:"link",className:"flex gap-2",icon:o.jsx(pt,{size:16}),children:[o.jsx(pt,{className:"w-4 h-4"})," ",P?.forgotPassword?.backToLoginText||"Back to Login"]})}),t&&o.jsx("div",{className:B.className,style:B.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:Ue(w),children:P?.forgotPassword?.title||"Forgot Password"}),o.jsx("p",{className:"text-sm mb-6",style:$e(w),children:P?.forgotPassword?.subtitle||P?.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:v=>{g(v),c(I=>I+1)},children:["options=",d.map(v=>({value:v,label:o.jsxs(y.Space,{children:[v==="email"?o.jsx(Wt,{size:16}):o.jsx(Vi,{size:16}),v==="email"?"Email":"SMS"]})}))]})}),o.jsx(y.FormItem,{name:"contact",label:m==="email"?P?.forgotPassword?.emailLabel||"Email":"Phone",rules:O(),children:o.jsx(y.Input,{placeholder:k(),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:P?.forgotPassword?.submitButtonText||`Send Reset ${m==="email"?"Email":"SMS"}`})})]},u)]})},Uc=({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:x}=sr(),{authConfig:P,getResetPasswordConfig:L,getMessagesConfig:M}=Ae(),B=L(),E=M(),_=Qe(P),k=dt(P),O=ct(P);h.useEffect(()=>{t?(async()=>{try{const A=await H.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 V=(I,A)=>{if(!A){const C=E?.validation?.required||"Please input your new password!";return Promise.reject(new Error(C))}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 C=H.validatePassword(A);if(!C.valid){const $=E?.validation?.passwordTooShort||C.errors.join(", ");return Promise.reject(new Error($))}}return Promise.resolve()},v=async I=>{if(I.password!==I.confirmPassword){const A=E?.validation?.passwordsDoNotMatch||"The two passwords do not match!";y.toast.error(A);return}n(!0);try{if((await H.confirmResetPassword({key:t,password:I.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({...I,token:t}),p(C=>C+1)}catch(A){const C=E?.errors?.networkError||A.message||"Failed to reset password. Please try again.";y.toast.error(C)}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:B?.resetForm?.successMessage||"Password Reset Successful!",subTitle:"Your password has been successfully reset. You can now login with your new password.",extra:[o.jsx(J.Link,{to:x,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:k.className,style:k.style,children:typeof r=="string"?o.jsx("img",{src:r,alt:P?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:O}):r}),o.jsx("h2",{className:"text-2xl font-semibold mb-3",style:Ue(P),children:B?.resetForm?.title||"Reset Password"}),o.jsx("p",{className:"text-sm mb-6",style:$e(P),children:B?.resetForm?.subtitle||"Please enter your new password below."}),o.jsxs(y.Form,{name:"reset-password",className:"space-y-4",onFinish:v,layout:"vertical",children:[o.jsx(y.FormItem,{name:"password",label:B?.resetForm?.passwordLabel||"New Password",rules:[{validator:V}],children:o.jsx(y.PasswordInput,{prefix:o.jsx(zt,{size:16,className:"text-gray-400"}),placeholder:B?.resetForm?.passwordPlaceholder||"New Password",autoComplete:"new-password"})}),o.jsx(y.FormItem,{name:"confirmPassword",label:B?.resetForm?.confirmPasswordLabel||"Confirm Password",dependencies:["password"],rules:[{required:!0,message:E?.validation?.required||"Please confirm your password!"},({getFieldValue:I})=>({validator(A,C){if(!C||I("password")===C)return Promise.resolve();const $=E?.validation?.passwordsDoNotMatch||"The two passwords do not match!";return Promise.reject(new Error($))}})],children:o.jsx(y.PasswordInput,{prefix:o.jsx(zt,{size:16,className:"text-gray-400"}),placeholder:B?.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:B?.resetForm?.submitButtonText||"Reset Password"})})]},g)]}):o.jsx(y.Result,{status:"error",title:"Invalid Link",subTitle:c,extra:[o.jsx(J.Link,{to:x,children:o.jsx(y.Button,{variant:"primary",children:"Back to Login"})},"login")]})};function Gr(e){if(!e||typeof e!="string")return!1;const t=e.trim();return!(!t.startsWith("/")||t.startsWith("//")||t.toLowerCase().includes("javascript:")||t.toLowerCase().includes("data:")||t.split("?")[0].includes("://")||t.startsWith("/app/login"))}function kn(e){if(!e)return null;try{const r=new URLSearchParams(e).get("next");return r?decodeURIComponent(r):null}catch(t){return console.error("Error parsing next parameter:",t),null}}function qe(e,t,r="/app"){return e&&Gr(e)?e:t&&Gr(t)?t:Gr(r)?r:"/app"}const Dc=({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),[x,P]=h.useState(!1),[L,M]=h.useState(null),[B,E]=h.useState("login"),[_,k]=h.useState({}),[O,V]=h.useState(["email"]),[v,I]=h.useState(""),[A,C]=h.useState(null),$=h.useRef(!1),F=J.useLocation(),S=J.useNavigate(),{basePath:D,setAuthToken:z}=sr(),{authConfig:Z}=Ae(),Y=async U=>{let Q=U,te=null;U?.status===401&&U?.data?(Q=U.data,te=U.data?.next_step):(Q=U?.response?.data||U?.data||U,te=Q?.next_step);const re=U?.loginUser;(U?.token||Q?.token)&&z(U.token||Q.token);let oe=U?.user||Q?.user||re||{};if((typeof oe!="object"||oe===null)&&(oe={}),re&&typeof re=="object"&&(oe={...oe,email:oe.email||re.email,username:oe.username||re.username,phone:oe.phone||re.phone,name:oe.name||re.display}),te&&te.is_pending)switch(te.id){case"role_selection":let ve=[];Array.isArray(te.metadata.roles)?ve=te.metadata.roles:typeof te.metadata.roles=="object"&&(ve=Object.entries(te.metadata.roles).map(([ue,de])=>({id:ue,name:de,is_default:!1}))),k({...U,roles:ve,user:oe,nextStep:te,loginUser:re}),E("roleSelection"),P(!0),p(!1);return;case"mfa_authenticate":z(U.token||Q?.token),V(te.metadata?.methods||["email"]),E("twoFactor"),P(!0),p(!1);return;case"set_password":z(U.token||Q?.token);const he=te.metadata?.password_policy;I(te.metadata?.reason||"Password update required"),k({...U,passwordPolicy:he,user:oe,loginUser:re}),E("passwordReset"),P(!0),p(!1);return;case"password_expiry":z(U.token||Q?.token),I("Your password has expired"),k({...U,passwordPolicy:te.metadata?.password_policy,user:oe,loginUser:re}),E("passwordReset"),P(!0),p(!1);return;case"first_login":z(U.token||Q?.token),I("Please set up your password for first login"),k({...U,passwordPolicy:te.metadata?.password_policy,user:oe,loginUser:re}),E("passwordReset"),P(!0),p(!1);return;case"login_by_code":z(U.token||Q?.token),y.toast.info("OTP verification required"),e&&e({...U,user:oe,requiresOTP:!0});return}if(U.requires2FA){z(U.token),V(U.twoFactorMethods||["email"]),k({...U,user:oe,loginUser:re}),E("twoFactor"),P(!0),p(!1);return}if(U.requiresPasswordReset){z(U.token),I(U.passwordResetReason||"Your password has expired"),k({...U,user:oe,loginUser:re}),E("passwordReset"),P(!0),p(!1);return}};h.useEffect(()=>{$.current||X()},[]);const X=async()=>{try{$.current=!0;const U=new URLSearchParams(F.search),Q=new URLSearchParams(F.hash.slice(1)),te=kn(F.search)||kn(F.hash.slice(1));C(te);const re=U.get("error")||Q.get("error"),oe=U.get("error_description")||Q.get("error_description");if(re)throw new Error(oe||`Authentication failed: ${re}`);const ve=U.get("code"),he=U.get("state"),ue=U.get("scope")||"",de=U.get("authuser"),Le=U.get("hd"),ht=U.get("prompt"),xr=U.get("provider")||he?.split(":")[0];if(!ve||!xr)throw new Error("Missing required OAuth parameters (code or provider)");const Ge=await H.processOAuthCallback(xr,he||"",ve,ue,de||void 0,Le||void 0,ht||void 0);if(await Y(Ge),Ge?.status===401&&Ge?.data?.next_step&&Ge.data.next_step.is_pending){p(!1),e?e(Ge):(M(Ge),P(!0));return}p(!1),e?e(Ge):setTimeout(()=>{S(s,{replace:!0})},1e3)}catch(U){console.error("OAuth callback error:",U),b(U.message||"Authentication failed"),p(!1),t&&t(U)}},G=()=>{S(D,{replace:!0})},W=async U=>{y.toast.success("Authentication complete!");try{const Q=U?.response?.data?.redirect_url||U?.data?.redirect_url||U?.redirect_url,te=qe(A,Q,"/app"),re=window.location.pathname,oe=new URLSearchParams(window.location.search),ve=oe.get("code")!==null||oe.get("token")!==null;re.startsWith("/app/login")&&ve&&(window.location.href=te)}catch(Q){console.error("Error handling auth completion:",Q)}};return x?o.jsx(CompleteAuthFlow,{logo:i,apiConfig:r,initialAuthState:L||_,onAuthComplete:W,roleSelectionTitle:l,roleSelectionSubtitle:u,twoFactorTitle:c,twoFactorSubtitle:d,passwordResetTitle:f,passwordResetSubtitle:m,redirectPath:s,initialRedirectUrl:A}):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:Ue(Z),children:n}),o.jsx("p",{className:"text-gray-500 text-sm mb-0",style:$e(Z),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:G,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})})})})},Bc=()=>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"})]}),$c=()=>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"})]}),qc=()=>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"})}),Vc=()=>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"})}),jc=()=>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"})}),Hc=()=>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"})}),zc=()=>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"})}),Wc=()=>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"})]}),Kc=()=>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"})}),Zc=()=>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"})]}),Gc=(e,t="default")=>{const r=e?e.toLowerCase():"";return r.includes("google")?o.jsx(Bc,{}):r.includes("microsoft")||r.includes("azure")?o.jsx($c,{}):r.includes("github")?o.jsx(qc,{}):r.includes("linkedin")?o.jsx(Vc,{}):r.includes("facebook")?o.jsx(jc,{}):r.includes("twitter")||r.includes("x.com")?o.jsx(Hc,{}):r.includes("apple")?o.jsx(zc,{}):r.includes("slack")?o.jsx(Wc,{}):r.includes("okta")?o.jsx(Zc,{}):r.includes("saml")||r.includes("sso")||t==="sso"?o.jsx(Kc,{}):o.jsx($i,{size:16})},Ve=({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 H.initiateSAMLAuth(c);d?.redirect_url?window.location.href=d.redirect_url:console.error("No redirect URL received from SAML init")}else{const c=await H.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=Gc(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]})},En=({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))})},_n=h.createContext(null),Re=()=>{const e=h.useContext(_n);if(!e)throw new Error("useAuthContext must be used within an AuthProvider");return e},An=({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 H.getAuthConfig();g(_),await b()}catch(_){l(_.message),a(!1)}},b=async()=>{try{await H.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 k=await H.login(_,t);let O=k,V=null;k?.status===401&&k?.data?(O=k.data,V=k.data?.next_step):(O=k?.response?.data||k?.data||k,V=O?.next_step);const v=k?.user||O?.user||{};if(v.email=v.email||_.email,v.username=v.username||_.username,v.phone=v.phone||_.phone,v.name=v.name||_.email||_.username||_.phone,c({user:v,token:k.token||O?.token,roles:k.roles,requires2FA:k.requires2FA,twoFactorMethods:k.twoFactorMethods,requiresPasswordReset:k.requiresPasswordReset,passwordResetReason:k.passwordResetReason}),V&&V.is_pending&&V.id==="role_selection")return{...k,user:v};if(k.roles&&k.roles.length>1)return f(k.roles),{requiresRoleSelection:!0,roles:k.roles,user:v,token:k.token};let I=k;return k.roles&&k.roles.length===1?I.user={...v,role:k.roles[0]}:I.user=v,k.requires2FA?{...I,requires2FA:!0,twoFactorMethods:k.twoFactorMethods||["email"]}:k.requiresPasswordReset?{...I,requiresPasswordReset:!0,passwordResetReason:k.passwordResetReason}:(s(I.user),c(null),f(null),{...I,user:v})}catch(k){throw console.error("AuthProvider login caught error:",k),console.error("AuthProvider error.message:",k.message),l(k.message),k}finally{a(!1)}},logout:async()=>{a(!0);try{await H.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 H.selectRole(_,u.token,t);const k={...u.user,role:_},O={...u,user:k};return O.requires2FA?(c(O),{...O,requires2FA:!0,twoFactorMethods:O.twoFactorMethods||["email"]}):O.requiresPasswordReset?(c(O),{...O,requiresPasswordReset:!0,passwordResetReason:O.passwordResetReason}):(s(k),c(null),f(null),{user:k,token:u.token})}catch(k){throw l(k.message),k}finally{a(!1)}},checkAuth:b,forgotPassword:async _=>H.forgotPassword(_),resetPassword:async _=>H.resetPassword(_),isAuthenticated:!!r,pendingAuth:u,availableRoles:d,authConfig:m,requiresRoleSelection:!!u&&!!d};return o.jsx(_n.Provider,{value:E,children:e})},{Text:Nn,Title:Ln}=y.Typography,Jr=({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(""),[x,P]=h.useState(""),[L,M]=h.useState(0),[B,E]=h.useState(0),{authConfig:_}=Re();h.useEffect(()=>{if(_){const $=H.getAllowedUsernames();$&&$.length>0&&m($[0])}},[_]),h.useEffect(()=>{if(L>0){const $=setTimeout(()=>M(L-1),1e3);return()=>clearTimeout($)}},[L]);const k=$=>$==="email"?"Enter your email address":"Enter your mobile number",O=$=>$==="email"?[{required:!0,message:"Please enter your email address"},{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"}],V=async $=>{P(""),u(!0);try{const F=await H.requestOTP($.username);F?.status===401&&F?.data?.message?(d($.username),i("verify"),M(30),y.toast.success(F.data.message||"Code sent successfully!")):(d($.username),i("verify"),M(30),y.toast.success("Code sent successfully!"))}catch(F){console.error("Failed to Send Code:",F),P(F.message||"Failed to Send Code")}finally{u(!1)}},v=async()=>{if(b(""),g.length!==6){b("Please enter 6 digit Code");return}u(!0);try{const S={...await H.verifyOTP(c,g),loginUser:{email:f==="email"?c:void 0,phone:f==="mobile"?c:void 0,username:c,display:c}};e(S)}catch(F){b(F.message||"Invalid Code")}finally{u(!1)}},I=async()=>{if(!(L>0)){u(!0);try{await H.requestOTP(c),M(30),y.toast.success("Code resent successfully!")}catch($){y.toast.error($.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=H.getAllowedUsernames(),C=6;return a==="verify"?o.jsxs("div",{className:"w-full",children:[o.jsxs(y.Button,{variant:"link",icon:o.jsx(pt,{size:16}),onClick:()=>i("request"),className:"mb-4 flex gap-2",children:[o.jsx(pt,{className:"w-4 h-4"})," Change ",f?.slice(0,1).toUpperCase()+f?.slice(1)," ",f==="email"?"Address":"Number"]}),o.jsx(Ln,{level:4,className:"!mb-2 text-center",style:Ue(_),children:"Enter Verification Code"}),o.jsxs(Nn,{className:"block text-center text-gray-500 mb-6",style:$e(_),children:["Please enter the ",C,"-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(En,{length:C,value:g,onChange:$=>{p($),w&&b("")},disabled:l})}),o.jsx(y.Button,{type:"primary",block:!0,fullWidth:!0,loading:l,onClick:v,className:"mt-6",children:s||"Verify & Sign In"}),o.jsx("div",{className:"text-center mt-4",children:L>0?o.jsxs(Nn,{type:"secondary",children:["Resend Code in ",L,"s"]}):o.jsx(y.Button,{variant:"link",onClick:I,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(pt,{size:16}),onClick:t,className:"mb-4",children:[o.jsx(pt,{className:"w-4 h-4"})," Back to login"]}),o.jsx(Ln,{level:4,className:"!mb-2 text-center",style:Ue(_),children:"Sign in with a One-Time Pin"}),x&&o.jsx(y.Alert,{message:x,type:"error",showIcon:!1,closable:!0,onClose:()=>P(""),className:"mb-4"}),o.jsxs(y.Form,{name:"otp-request",onFinish:V,layout:"vertical",children:[A.length>1&&o.jsx(y.FormItem,{children:o.jsx(y.Segmented,{options:A.map($=>({label:o.jsxs(y.Space,{children:[$==="email"?o.jsx(Wt,{size:16}):$==="mobile"?o.jsx(Tr,{size:16}):o.jsx(Or,{size:16}),o.jsx("span",{children:$==="mobile"?"Phone":$==="email"?"Email":"Username"})]}),value:$})),value:f,onChange:$=>m($),block:!0,className:"bg-gray-100 mb-2"})}),o.jsx(y.FormItem,{name:"username",rules:O(f),children:o.jsx(y.Input,{placeholder:k(f)})}),o.jsx(y.FormItem,{children:o.jsx(y.Button,{variant:"primary",type:"submit",fullWidth:!0,disabled:l,children:r||"Send Code"})})]},B)]})},Jc=({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,x]=h.useState(!1),[P,L]=h.useState(""),[M,B]=h.useState(""),{authConfig:E}=Re(),{getLoginConfig:_,getMessagesConfig:k,getProvidersConfig:O,authConfig:V}=Ae(),v=V||E,I=Ue(v),A=$e(v),C=Pn(v),$=async()=>{try{return await H.isAuthenticated()}catch{return!1}};if(h.useEffect(()=>{if(E){const W=H.getAllowedUsernames();if(W&&W.length>0){const U=W.includes("email"),Q=W.includes("mobile");U?c("email"):Q&&c("mobile")}H.isPasswordLoginEnabled()?l("password"):H.isOTPLoginEnabled()&&l("otp")}},[E]),h.useEffect(()=>{(async()=>{const U=await $();w(U)})()},[]),!E)return o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:o.jsx(y.Spin,{size:"large"})});const F=W=>{const U=k();return W==="email"?[{required:!0,message:U?.validation?.required||"Please enter your email address"},{type:"email",message:U?.validation?.invalidEmail||"Please enter a valid email address!"}]:W==="mobile"?[{required:!0,message:U?.validation?.required||"Please input your mobile number!"},{pattern:/^\+\d{7,15}$/,message:U?.validation?.invalidMobile||"Please enter a valid mobile number with country code (e.g., +919876543210)"}]:[{required:!0,message:U?.validation?.required||"Please enter your email address"},{type:"email",message:U?.validation?.invalidEmail||"Please enter a valid email address!"}]},S=async W=>{s(!0),a(null);try{const U=H.getAllowedUsernames(),Q=U.includes("email"),te=U.includes("mobile"),re=Q&&te?u:Q?"email":"mobile",oe={email:re==="email"?W.username:void 0,phone:re==="mobile"?W.username:void 0,password:W.password,remember_me:W.remember||!1},ve=await e(oe)}catch(U){const Q=k(),te=U.message||Q?.errors?.loginFailed||"Login failed. Please try again.";a(te)}finally{s(!1)}},D=async W=>{console.log("OTP success in DynamicLoginForm, passing to onLogin:",W),await e(W)},z=async()=>{s(!0);try{await H.logout(),y.toast.success("Logged out successfully"),w(!1)}catch(W){y.toast.error(W.message||"Failed to logout")}finally{s(!1)}},Z=async()=>{if(!P||!M){y.toast.error("Please fill in all password fields");return}if(P!==M){y.toast.error("Passwords do not match");return}if(P.length<8){y.toast.error("Password must be at least 8 characters long");return}s(!0);try{await H.setPassword(P),y.toast.success("Password changed successfully!"),x(!1),L(""),B("")}catch(W){y.toast.error(W.message||"Failed to change password")}finally{s(!1)}},Y=W=>{const U=_(),Q=k();return o.jsxs(y.Form,{name:`${W}-password-login`,className:"w-full",onFinish:S,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:F(W),children:o.jsx(y.Input,{placeholder:W==="email"?U?.formPlaceholders?.email||"Enter your email address":U?.formPlaceholders?.mobile||"Enter your mobile number (+919876543210)",autoComplete:W==="email"?"email":"tel",onKeyDown:W==="mobile"?te=>{const re=["Backspace","Delete","Tab","Enter","ArrowLeft","ArrowRight"],oe=te.key;!re.includes(oe)&&!/[0-9+]/.test(oe)&&te.preventDefault()}:void 0})}),o.jsx(y.FormItem,{name:"password",rules:[{required:!0,message:Q?.validation?.required||"Please input your password!"},{min:E?.password_policy?.min_length||6,message:Q?.validation?.passwordTooShort||`Password must be at least ${E?.password_policy?.min_length||6} characters long`}],children:o.jsx(y.PasswordInput,{placeholder:U?.formPlaceholders?.password||"Enter your 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:U?.showRememberMe!==!1&&t&&H.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:U?.rememberMeText||"Remember me"})})})}),o.jsx("div",{children:H.isForgotPasswordEnabled()&&o.jsx(J.Link,{to:"forgot-password",className:"text-sm transition-colors duration-300",style:C,children:U?.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:U?.submitButtonText||"Sign in"})})]},`${W}-${m}`)},X=()=>{if(!H.isOTPLoginEnabled())return null;const W=_();return d?o.jsx(Jr,{onSuccess:D,onBack:()=>f(!1)}):o.jsx(y.Button,{variant:"secondary",fullWidth:!0,onClick:()=>f(!0),className:"bg-gray-100 border-gray-300",children:W?.otpButtonText||"Sign in with OTP"})},G=()=>{if(!E)return null;const W=H.getAllowedUsernames(),U=W.includes("email"),Q=W.includes("mobile"),te=H.isSSOEnabled()||H.isOIDCEnabled(),re=H.isPasswordLoginEnabled(),oe=H.isOTPLoginEnabled();if(!re&&!oe&&!te)return null;if(te&&!re&&!oe)return o.jsxs("div",{className:"w-full",children:[H.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:H.getSSOProviders().map((he,ue)=>o.jsx(Ve,{provider:he,type:"sso"},`sso-standalone-${ue}`))})}),H.isOIDCEnabled()&&o.jsx("div",{className:"space-y-2",children:H.getOIDCProviders().map((he,ue)=>o.jsx(Ve,{provider:he,type:"oidc"},`oidc-standalone-${ue}`))})]});if(oe&&!re){const he=O();return o.jsxs("div",{className:"w-full",children:[o.jsx(Jr,{onSuccess:D}),te&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:he?.separatorText||"OR"}),H.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:H.getSSOProviders().map((ue,de)=>o.jsx(Ve,{provider:ue,type:"sso"},`sso-otp-${de}`))})}),H.isOIDCEnabled()&&o.jsx("div",{className:"mt-4",children:o.jsx("div",{className:"space-y-2",children:H.getOIDCProviders().map((ue,de)=>o.jsx(Ve,{provider:ue,type:"oidc"},`oidc-otp-${de}`))})})]})]})}if(U&&Q&&re){const he=_(),ue=O();return o.jsx("div",{className:"w-full",children:o.jsx(y.Tabs,{className:"login-tabs",activeKey:u,onChange:de=>{c(de),g(Le=>Le+1)},items:[{key:"email",label:o.jsxs("span",{className:"flex items-center gap-1",style:I,children:[o.jsx(Wt,{size:16}),he?.tabLabels?.email||"Email"]}),children:o.jsxs(o.Fragment,{children:[Y("email"),oe&&re&&!d&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:ue?.separatorText||"OR"}),X()]}),d&&X(),!d&&te&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:ue?.separatorText||"OR"}),H.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:H.getSSOProviders().map((de,Le)=>o.jsx(Ve,{provider:de,type:"sso"},`sso-email-${Le}`))})}),H.isOIDCEnabled()&&o.jsx("div",{className:"mt-4",children:o.jsx("div",{className:"space-y-2",children:H.getOIDCProviders().map((de,Le)=>o.jsx(Ve,{provider:de,type:"oidc"},`oidc-email-${Le}`))})})]})]})},{key:"mobile",label:o.jsxs("span",{className:"flex items-center gap-1",style:I,children:[o.jsx(Tr,{size:16}),he?.tabLabels?.mobile||"Mobile"]}),children:o.jsxs(o.Fragment,{children:[Y("mobile"),oe&&re&&!d&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),X()]}),d&&X(),!d&&te&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),H.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:H.getSSOProviders().map((de,Le)=>o.jsx(Ve,{provider:de,type:"sso"},`sso-mobile-${Le}`))})}),H.isOIDCEnabled()&&o.jsx("div",{className:"mt-4",children:o.jsx("div",{className:"space-y-2",children:H.getOIDCProviders().map((de,Le)=>o.jsx(Ve,{provider:de,type:"oidc",onClick:ht=>{console.log("OIDC provider clicked:",ht)}},`oidc-${Le}`))})})]})]})}]})})}else{const he=U?"email":"mobile";return o.jsxs("div",{className:"w-full",children:[Y(he),oe&&re&&!d&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),X()]}),d&&X(),!d&&te&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),H.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:H.getSSOProviders().map((ue,de)=>o.jsx(Ve,{provider:ue,type:"sso"},`sso-single-${de}`))})}),H.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:P,onChange:W=>L(W.target.value),placeholder:"Enter new password",disabled:r})}),o.jsx(y.FormItem,{label:"Confirm Password",children:o.jsx(y.PasswordInput,{value:M,onChange:W=>B(W.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:()=>{x(!1),L(""),B("")},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:I,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:()=>x(!0),children:"Change Password"}),o.jsx(y.Button,{block:!0,danger:!0,onClick:z,loading:r,children:"Logout"})]})}):G():o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:o.jsx(y.Spin,{size:"large"})})},Xc=({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}=Re();h.useEffect(()=>{if(c){const x=H.getAllowedUsernames();x&&x.length>0&&u(x[0])}},[c]);const d=async x=>{n(!0);try{if(e){const P={email:l==="email"?x.username:void 0,phone:l==="mobile"?x.username:void 0,username:x.username,password:x.password,remember_me:x.remember||!1};await e(P)}}catch(P){y.toast.error(P.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 x=[{required:!0,message:`Please input your ${l}!`}];switch(l){case"email":return[...x,{type:"email",message:"Please enter a valid email address!"}];case"mobile":return[...x,{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid phone number!"}];case"username":return[...x,{min:3,message:"Username must be at least 3 characters long"}];default:return x}};if(!c)return o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const g=H.getAllowedUsernames(),p=g.length>1,w=H.isRememberMeEnabled(),b=H.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(x=>({value:x,label:x==="mobile"?"Phone":x.charAt(0).toUpperCase()+x.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(J.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:Tn,Text:Mt,Paragraph:Yc}=y.Typography,Qc=({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(Or,{size:l*.6})})},Rc=({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})]}),ed=e=>{const t=e.toLowerCase();return t.includes("admin")?o.jsx(Bi,{size:20}):t.includes("manager")||t.includes("supervisor")?o.jsx(ji,{size:20}):t.includes("security")||t.includes("compliance")?o.jsx(vo,{size:20}):o.jsx(Or,{size:20})},or=({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}=Ae(),p=f(),w=Qe(g),b=dt(g),x=ct(g),P=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(Rc,{className:"text-center py-12 px-5 text-gray-500",description:o.jsxs("div",{children:[o.jsx(Mt,{className:"text-gray-600 text-base block mb-2",children:p?.emptyStateMessage||"No roles available"}),o.jsx(Mt,{type:"secondary",className:"text-sm",children:"Please contact your administrator for role assignment"})]})})})})}const L=h.isValidElement(p?.title)?p.title:p?.title||n,M=h.isValidElement(p?.subtitle)?p.subtitle:p?.subtitle||a,B=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:x}):i}),o.jsxs("div",{className:"text-center mb-8",children:[h.isValidElement(L)?L:o.jsx(Tn,{level:3,className:"!mb-3 !text-2xl !font-semibold !text-gray-800",style:Ue(g),children:L}),h.isValidElement(M)?M:o.jsx(Yc,{className:"!mb-6 text-base text-gray-600 !leading-relaxed",style:$e(g),children:M}),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(Qc,{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(Mt,{strong:!0,className:"text-sm block text-gray-800",children:e.name||e.username||"User"}),e.email&&o.jsx(Mt,{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-${B}`,children:t.map(E=>{const _=p?.customRoleCard;if(_)return o.jsx(_,{role:E,selected:l?.id===E.id,onSelect:()=>u(E)},E.id);const k=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?k.selectedColor||"#e6f7ff":k.backgroundColor||"#ffffff",borderColor:O?k.selectedColor||"#1890ff":"#d9d9d9",borderRadius:k.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(Je,{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:ed(E.name)})}),o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-1",children:[o.jsx(Tn,{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:P,disabled:!l,loading:c,icon:l?o.jsx(Je,{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(Mt,{type:"secondary",className:"block text-center mt-3 text-sm",children:"This is your recommended role based on your permissions"})]})]})})},{Title:td,Text:Xr,Paragraph:rd}=y.Typography,On=({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),[x,P]=h.useState(!1),{authConfig:L,getTwoFactorConfig:M,getMessagesConfig:B}=Ae(),E=M(),_=B(),k=Qe(L),O=dt(L),V=ct(L);h.useEffect(()=>{if(g>0){const F=setTimeout(()=>p(g-1),1e3);return()=>clearTimeout(F)}},[g]);const v=F=>{if(F==="email"&&e?.email){const[S,D]=e.email.split("@");return`${S.substring(0,3)+"****"+S.substring(S.length-1)}@${D}`}return(F==="sms"||F==="mobile")&&e?.mobile?`****${e.mobile.substring(e.mobile.length-4)}`:F==="totp"?"your authenticator app":F==="email"?"your email":F==="sms"?"your mobile":"your authenticator app"},I=async()=>{b(!0);try{await H.sendTwoFactorCode(c),P(!0),p(E?.resendCountdown||a);const F=_?.success?.otpSent||`OTP sent to ${v(c)}`;y.toast.success(F)}catch(F){const S=_?.errors?.networkError||F.message||"Failed to Request OTP";y.toast.error(S)}finally{b(!1)}},A=async()=>{const F=E?.codeLength||n;if(f.length!==F){const S=_?.validation?.required||`Please enter ${F} digit OTP`;y.toast.error(S);return}b(!0);try{const S=await H.verifyTwoFactorCode(f);await r(S)}catch(S){const D=_?.errors?.invalidOTP||S.message||"Invalid OTP";y.toast.error(D),m("")}finally{b(!1)}},C=async()=>{g>0||await I()},$=()=>{if(t.length<=1)return null;const F=t.map(S=>({label:o.jsxs(y.Space,{children:[S==="email"?o.jsx(Wt,{size:16}):S==="sms"?o.jsx(Tr,{size:16}):o.jsx(vo,{size:16}),o.jsx("span",{children:S==="email"?E?.methodLabels?.email||"Email":S==="sms"?E?.methodLabels?.sms||"SMS":E?.methodLabels?.mobile||"Authenticator"})]}),value:S}));return o.jsxs("div",{className:"mb-6",children:[o.jsx(Xr,{type:"secondary",className:"block mb-2 text-xs",children:"Verification Method"}),o.jsx(y.Segmented,{options:F,value:c,onChange:S=>{d(S),P(!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:k,children:[u&&o.jsx("div",{className:O.className,style:O.style,children:typeof u=="string"?o.jsx("img",{src:u,alt:L?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:V}):u}),o.jsxs("div",{className:"text-center mb-8",children:[o.jsx(td,{level:3,className:"!mb-2",style:Ue(L),children:E?.title||i}),o.jsx(rd,{className:"!mb-0 text-sm",type:"secondary",style:$e(L),children:E?.subtitle||l})]}),o.jsxs("div",{className:"mt-6",children:[$(),x?o.jsxs("div",{className:"mt-6",children:[o.jsx(Xr,{className:"block text-center mb-6 text-gray-700",children:E?.instructionText||`Enter the ${E?.codeLength||n}-digit code sent to ${v(c)}`}),o.jsx("div",{className:"flex justify-center mb-6",children:o.jsx(En,{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(Xr,{type:"secondary",children:["Resend code in ",g,"s"]}):o.jsx(y.Button,{variant:"link",onClick:C,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 ${v(c)}`,type:"info",showIcon:!0,className:"mb-6"}),o.jsx(y.Button,{variant:"primary",fullWidth:!0,disabled:w,onClick:I,children:"Send Verification Code"})]})]})]})})},{Title:sd,Text:et,Paragraph:od}=y.Typography,Yr=({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:x,getResetPasswordConfig:P,getMessagesConfig:L}=Ae(),M=P(),B=L(),E=Qe(x),_=dt(x),k=ct(x);h.useEffect(()=>{if(a)b(a);else{const A=H.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 C=0;return A.length>=w.minLength&&(C+=20),A.length>=12&&(C+=10),w.requireUppercase&&/[A-Z]/.test(A)&&(C+=20),w.requireLowercase&&/[a-z]/.test(A)&&(C+=20),w.requireNumbers&&/\d/.test(A)&&(C+=15),w.requireSpecialChars&&/[!@#$%^&*]/.test(A)&&(C+=15),C<40?{percent:C,status:"exception"}:C<70?{percent:C,status:"normal"}:{percent:C,status:"success"}},V=(A,C)=>{if(!C){const F=B?.validation?.required||"Please input your password!";return Promise.reject(new Error(F))}const $=H.validatePassword(C);if(!$.valid){const F=B?.validation?.passwordTooShort||$.errors.join(", ");return Promise.reject(new Error(F))}return Promise.resolve()},v=async A=>{if(p(null),A.password!==A.confirmPassword){const C=B?.validation?.passwordsDoNotMatch||"Passwords do not match!";p(C);return}d(!0);try{await t({password:A.password,confirmPassword:A.confirmPassword})}catch(C){const $=C?.message||"Failed to set password. Please try again.";p($)}finally{d(!1)}},I=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:x?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:k}):i}),o.jsxs("div",{className:"text-center mb-6",children:[o.jsx(sd,{level:3,className:"!mb-2",style:Ue(x),children:M?.resetForm?.title||s}),o.jsx(od,{className:"!mb-0 text-sm",type:"secondary",style:$e(x),children:M?.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:v,layout:"vertical",className:"mt-6",children:[o.jsx(y.FormItem,{name:"password",label:M?.resetForm?.passwordLabel||"New Password",rules:[{validator:V}],children:o.jsx(y.PasswordInput,{prefix:o.jsx(zt,{size:16}),placeholder:M?.resetForm?.passwordPlaceholder||"New Password",onChange:A=>m(A.target.value)})}),f&&o.jsxs("div",{className:"-mt-4 mb-4",children:[o.jsx(et,{type:"secondary",className:"text-xs block mb-1",children:"Password Strength"}),o.jsx(y.Progress,{percent:I.percent,status:I.status,showInfo:!1,strokeWidth:4})]}),o.jsx(y.FormItem,{name:"confirmPassword",label:M?.resetForm?.confirmPasswordLabel||"Confirm Password",dependencies:["password"],rules:[{required:!0,message:B?.validation?.required||"Please confirm your password!"},({getFieldValue:A})=>({validator(C,$){if(!$||A("password")===$)return Promise.resolve();const F=B?.validation?.passwordsDoNotMatch||"Passwords do not match!";return Promise.reject(new Error(F))}})],children:o.jsx(y.PasswordInput,{prefix:o.jsx(zt,{size:16}),placeholder:M?.resetForm?.confirmPasswordPlaceholder||"Confirm Password"})}),M?.resetForm?.showPasswordRequirements!==!1&&o.jsxs("div",{className:"bg-gray-50 p-4 rounded-md mb-6",children:[o.jsx(et,{type:"secondary",className:"block font-medium mb-2",children:M?.resetForm?.passwordRequirementsText||"Password Requirements:"}),o.jsxs(y.Space,{direction:"vertical",size:"small",children:[o.jsxs(et,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Je,{size:16,className:f.length>=w.minLength?"text-green-500":"text-gray-300"}),"At least ",w.minLength," characters"]}),w.maxLength&&o.jsxs(et,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Je,{size:16,className:f.length<=w.maxLength?"text-green-500":"text-gray-300"}),"At most ",w.maxLength," characters"]}),w.requireUppercase&&o.jsxs(et,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Je,{size:16,className:/[A-Z]/.test(f)?"text-green-500":"text-gray-300"}),"One uppercase letter"]}),w.requireLowercase&&o.jsxs(et,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Je,{size:16,className:/[a-z]/.test(f)?"text-green-500":"text-gray-300"}),"One lowercase letter"]}),w.requireNumbers&&o.jsxs(et,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Je,{size:16,className:/\d/.test(f)?"text-green-500":"text-gray-300"}),"One number"]}),w.requireSpecialChars&&o.jsxs(et,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Je,{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:M?.resetForm?.submitButtonText||"Reset Password"})})]},l)]})})},{Content:nd}=y.Layout,Fn=({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]=J.useSearchParams(),{authConfig:f}=Ae(),[m,g]=h.useState(!0),[p,w]=h.useState(null),[b,x]=h.useState(null),[P,L]=h.useState(null);h.useEffect(()=>{M()},[]);const M=async()=>{try{g(!0),w(null),sessionStorage.setItem("saml_auth_in_progress","true");const V=d.get("token"),v=d.get("request_id"),I=d.get("next");if(!V||!v)throw new Error("Missing required SAML parameters (token or request_id)");if(!window.location.pathname.startsWith("/app/login")){g(!1),sessionStorage.removeItem("saml_auth_in_progress");return}const C=await H.getSAMLAuthMeta(V,v);if(C?.code==="user_not_found"){sessionStorage.setItem("saml_error",JSON.stringify({message:C.message||"User does not exist",timestamp:Date.now()})),sessionStorage.removeItem("saml_auth_in_progress"),window.location.href="/app/login";return}if(C?.status===401&&C?.data?.next_step){if(C.data.next_step.id==="role_selection"&&C.data.next_step.metadata?.roles){let $=[];Array.isArray(C.data.next_step.metadata.roles)?$=C.data.next_step.metadata.roles:typeof C.data.next_step.metadata.roles=="object"&&($=Object.entries(C.data.next_step.metadata.roles).map(([F,S])=>({id:F,name:S,is_default:!1}))),x({roles:$,token:V,requestId:v,samlMetadata:C.data}),L("role_selection"),g(!1);return}x(C.data),L(C.data.next_step.id),g(!1);return}if(C?.roles&&C.roles.length>1){x({roles:C.roles,token:V,requestId:v}),L("role_selection"),g(!1);return}if(s)console.log("SAML callback complete, calling onAuthComplete:",C),sessionStorage.removeItem("saml_auth_in_progress"),s(C);else{console.log("SAML callback complete, redirecting to:",C?.redirect_url||"/app");const $=qe(I,C?.redirect_url,"/app");sessionStorage.removeItem("saml_auth_in_progress"),window.location.href=$}}catch(V){console.error("SAML callback error:",V),w(V.message||"Failed to process SAML authentication"),g(!1),sessionStorage.removeItem("saml_auth_in_progress")}},B=async V=>{try{g(!0);const v=await H.setRole(V.id);if(v?.status===401&&v?.data?.next_step){x(v.data),L(v.data.next_step.id),g(!1);return}if(s)sessionStorage.removeItem("saml_auth_in_progress"),s(v);else{const I=qe(next,v?.redirect_url,"/app");sessionStorage.removeItem("saml_auth_in_progress"),window.location.href=I}}catch(v){console.error("Role selection error:",v),y.toast.error(`Failed to select role: ${v.message||"Please try again"}`),g(!1),sessionStorage.removeItem("saml_auth_in_progress")}},E=async V=>{try{if(V?.status===401&&V?.data?.next_step){x(V.data),L(V.data.next_step);return}if(s)sessionStorage.removeItem("saml_auth_in_progress"),s(V);else{const v=qe(next,V?.redirect_url,"/app");sessionStorage.removeItem("saml_auth_in_progress"),window.location.href=v}}catch(v){console.error("Two-factor completion error:",v),y.toast.error(v.message||"Failed to complete two-factor authentication"),sessionStorage.removeItem("saml_auth_in_progress")}},_=async V=>{try{if(V?.status===401&&V?.data?.next_step){x(V.data),L(V.data.next_step);return}if(s)sessionStorage.removeItem("saml_auth_in_progress"),s(V);else{const v=qe(next,V?.redirect_url,"/app");sessionStorage.removeItem("saml_auth_in_progress"),window.location.href=v}}catch(v){console.error("Password reset completion error:",v),y.toast.error(v.message||"Failed to complete password reset"),sessionStorage.removeItem("saml_auth_in_progress")}},k=()=>{if(m)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(p)return o.jsx(y.Alert,{message:"Authentication Error",description:p,type:"error",showIcon:!0,action:o.jsx("a",{href:"/app/login",children:"Return to Login"})});switch(P){case"role_selection":return o.jsx(or,{roles:b?.roles||[],onRoleSelect:B,title:n,subtitle:a,loading:m,logo:e});case"2fa_required":return o.jsx(On,{user:b?.user,onVerify:E,title:i,subtitle:l,logo:e});case"password_reset_required":return o.jsx(Yr,{onReset:_,title:u,subtitle:c,reason:b?.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: ${P}`,type:"warning",showIcon:!0})]})}},O=()=>m||p||!P;return o.jsx(y.Layout,{className:"min-h-screen",style:Ke(f),children:o.jsx(nd,{className:"flex justify-center items-center min-h-screen p-5",children:O()?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})}),k()]}):k()})})},Qr=h.createContext(null),Rr=()=>h.useContext(Qr);let Mn=!1;const ad=({onLogin:e,logo:t,title:r,subtitle:s,apiConfig:n={},useDynamicConfig:a=!0,staticConfig:i=null})=>{const[l,u]=J.useSearchParams();J.useNavigate();const[c,d]=h.useState(null),[f,m]=h.useState(a),[g,p]=h.useState(null),w=l.get("token"),b=l.get("request_id");l.get("next"),h.useLayoutEffect(()=>{if(Mn)return;const C=sessionStorage.getItem("saml_error");if(C){Mn=!0,sessionStorage.removeItem("saml_error");try{const $=JSON.parse(C);y.toast.error($.message,{duration:5e3})}catch($){console.error("Failed to parse SAML error:",$)}}},[]);const{authConfig:x,getCustomComponents:P}=Ae(),L=P(),M=Qe(x),B=Ke(x),E=Ue(x),_=$e(x),k=dt(x),O=ct(x);if(w&&b)return o.jsx(Fn,{logo:t,title:r||"Processing Authentication",subtitle:s||"Please wait while we complete your login",onAuthComplete:C=>{const $=C?.redirect_url||"/app";try{const F=new URL($,window.location.origin);F.searchParams.delete("token"),F.searchParams.delete("request_id");const S=F.pathname+(F.search?F.search:"");window.location.href=S}catch{window.location.href=$}},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 V=L?.LoginPage,v=L?.LoginCard;h.useEffect(()=>{a&&!i?I():i&&(d(i),m(!1))},[a,i]);const I=async()=>{try{const C=await H.getAuthConfig();d(C),p(null)}catch(C){console.error("Failed to fetch login methods:",C),d({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}}),p(null),console.warn("Using default auth configuration due to config fetch failure")}finally{m(!1)}},A=()=>f?o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:o.jsx(y.Spin,{size:"large",tip:"Loading login methods..."})}):g?o.jsx(y.Alert,{message:"Error",description:g,type:"error",showIcon:!0,action:o.jsx("a",{onClick:I,children:"Retry"})}):c&&a?o.jsx(Jc,{onLogin:e}):o.jsx(Xc,{onLogin:e});return V?o.jsx(V,{}):v?o.jsx(Qr.Provider,{value:{onLogin:e||(()=>{})},children:o.jsx(y.Layout,{className:"min-h-screen",style:B,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(v,{})})})})}):o.jsx(y.Layout,{className:"min-h-screen",style:B,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:k.className,style:k.style,children:typeof t=="string"?o.jsx("img",{src:t,alt:x?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:O}):t}),o.jsxs("div",{className:"text-center mb-[18px]",children:[o.jsx("h1",{className:"text-3xl font-semibold mb-2",style:E,children:r||"Welcome Back"}),s&&o.jsx("p",{className:"text-base",style:_,children:s})]}),A()]})})})},{Content:id}=y.Layout,ld=({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}=Re(),[p,w]=h.useState(null);h.useEffect(()=>{c&&b(c)},[c]);const b=async P=>{w(null);try{if(P&&(P.status||P.data||P.next_step||P.response)){i&&i(P);return}const L=await g(P),M={email:P.email,username:P.username,phone:P.phone,display:P.email||P.username||P.phone};if(L.requiresRoleSelection)return;i&&i({...L,loginUser:M})}catch(L){throw w(L.message),L}},x=async P=>{try{const L=await m(P);i&&i(L)}catch(L){throw console.error("Role selection failed:",L),L}};if(d&&f){const P=Ke(s||a||{});return o.jsx(y.Layout,{className:"min-h-screen",style:P,children:o.jsx(id,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(or,{user:d.user,roles:f,onRoleSelect:x,title:l,subtitle:u})})})}return o.jsx(ad,{onLogin:b,logo:e,title:t,subtitle:r,apiConfig:s,useDynamicConfig:n,staticConfig:a})},{Content:nr}=y.Layout,es=({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,initialRedirectUrl:p=null})=>{const{user:w,pendingAuth:b}=Re(),{authConfig:x}=Ae();dt(x),ct(x);const[P,L]=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,B]=h.useState(g?.token||null),[E,_]=h.useState(g?.twoFactorMethods||null),[k,O]=h.useState(g?.passwordResetReason||null),[V,v]=h.useState(g||null),[I]=h.useState(p||null),A=async S=>{let D=S,z=null,Z=!1,Y=null;S?.status===401&&S?.data?(D=S.data,z=S.data?.next_step,Y=S.status,Z=S?.meta?.is_authenticated||!1):S?.next_step?(D=S,z=S.next_step,Z=S?.meta?.is_authenticated||!1,Y=S?.status):S?.response?(Y=S.response.status,D=S.response.data,z=D?.next_step,Z=S.response.meta?.is_authenticated||!1):(D=S?.response?.data||S?.data||S,z=D?.next_step,Z=S?.meta?.is_authenticated||D?.meta?.is_authenticated||!1,Y=S?.status||D?.status);const X=S?.loginUser;(S?.token||D?.token)&&B(S.token||D.token);let G=S?.user||D?.user||X||{};if((typeof G!="object"||G===null)&&(G={}),X&&typeof X=="object"&&(G={...G,email:G.email||X.email,username:G.username||X.username,phone:G.phone||X.phone,name:G.name||X.display}),Y===200&&Z){y.toast.success("Login successful!"),i&&i({...S,user:G,authenticated:!0,redirect_url:qe(I,D?.redirect_url||S?.redirect_url,"/app")});return}if(z&&z.is_pending)switch(z.id){case"role_selection":let W=[];Array.isArray(z.metadata.roles)?W=z.metadata.roles:typeof z.metadata.roles=="object"&&(W=Object.entries(z.metadata.roles).map(([te,re])=>({id:te,name:re,is_default:!1}))),v({...S,roles:W,user:G,nextStep:z,loginUser:X}),L("roleSelection");return;case"mfa_authenticate":B(S.token||D?.token);const U=z.metadata?.type?[z.metadata.type]:z.metadata?.methods||["email"];_(U),L("twoFactor");return;case"set_password":B(S.token||D?.token);const Q=z.metadata?.password_policy;O(z.metadata?.reason||"Password update required"),v({...S,passwordPolicy:Q,user:G,loginUser:X}),L("passwordReset");return;case"password_expiry":B(S.token||D?.token),O("Your password has expired"),v({...S,passwordPolicy:z.metadata?.password_policy,user:G,loginUser:X}),L("passwordReset");return;case"first_login":B(S.token||D?.token),O("Please set up your password for first login"),v({...S,passwordPolicy:z.metadata?.password_policy,user:G,loginUser:X}),L("passwordReset");return;case"login_by_code":B(S.token||D?.token),y.toast.info("OTP verification required"),i&&i({...S,user:G,requiresOTP:!0});return}if(S.requires2FA){B(S.token),_(S.twoFactorMethods||["email"]),v({...S,user:G,loginUser:X}),L("twoFactor");return}if(S.requiresPasswordReset){B(S.token),O(S.passwordResetReason||"Your password has expired"),v({...S,user:G,loginUser:X}),L("passwordReset");return}i&&i({...S,user:G})},C=async S=>{try{let D=S,z=null,Z=!1,Y=null;if(S?.status===401&&S?.data?(D=S.data,z=S.data?.next_step,Y=S.status,Z=S?.meta?.is_authenticated||!1):S?.response?(Y=S.response.status,D=S.response.data,z=D?.next_step,Z=S.response.meta?.is_authenticated||!1):(D=S?.data||S,z=D?.next_step,Z=S?.meta?.is_authenticated||D?.meta?.is_authenticated||!1,Y=S?.status||D?.status),Y===200&&Z){y.toast.success("Two-factor authentication successful!"),i&&i({...S,token:M,user:V?.user,authenticated:!0,redirect_url:qe(I,D?.redirect_url||S?.redirect_url,"/app")});return}if(z&&z.is_pending)switch(z.id){case"set_password":const X=z.metadata?.password_policy;O(z.metadata?.reason||"Password reset required"),v({...V,passwordPolicy:X}),L("passwordReset");return;default:console.warn("Unknown next step after 2FA:",z.id);break}if(S.requiresPasswordReset){O(S.passwordResetReason||"Your password has expired"),L("passwordReset");return}y.toast.success("Two-factor authentication successful!"),i&&i({...S,token:M,user:V?.user,authenticated:!0})}catch(D){throw D}},$=async S=>{try{const D=await H.setPassword(S.password);let z=D,Z=null,Y=!1,X=null;if(D?.status===401&&D?.data?(z=D.data,Z=D.data?.next_step,X=D.status,Y=D?.meta?.is_authenticated||!1):D?.response?(X=D.response.status,z=D.response.data,Z=z?.next_step,Y=D.response.meta?.is_authenticated||!1):(z=D?.data||D,Z=z?.next_step,Y=D?.meta?.is_authenticated||z?.meta?.is_authenticated||!1,X=D?.status||z?.status),X===200&&Y){y.toast.success("Password reset successful!"),i&&i({...D,token:M,user:V?.user,authenticated:!0,redirect_url:qe(I,z?.redirect_url||D?.redirect_url,"/app")});return}if(Z&&Z.is_pending)switch(Z.id){case"mfa_authenticate":const G=Z.metadata?.type?[Z.metadata.type]:Z.metadata?.methods||["email"];_(G),L("twoFactor");return;default:console.warn("Unknown next step after password reset:",Z.id);break}y.toast.success("Password reset successful!"),i&&i({...D,token:M,user:V?.user,authenticated:!0})}catch(D){throw y.toast.error(D.message||"Failed to reset password"),D}};return(()=>{switch(P){case"login":return o.jsx(ld,{onLoginSuccess:A,logo:e,title:t,subtitle:r,apiConfig:s,useDynamicConfig:n,staticConfig:a,roleSelectionTitle:l,roleSelectionSubtitle:u});case"roleSelection":return V?.roles?o.jsx(y.Layout,{className:"min-h-screen",style:Ke(x),children:o.jsx(nr,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx("div",{className:"w-full",children:o.jsx(or,{user:V?.user,roles:V?.roles||[],logo:e,onRoleSelect:async z=>{try{const Z=await H.selectRole(z.id);let Y=Z,X=null,G=!1,W=null;if(Z?.status===401&&Z?.data?(Y=Z.data,X=Z.data?.next_step,W=Z.status,G=Z?.meta?.is_authenticated||!1):Z?.response?(W=Z.response.status,Y=Z.response.data,X=Y?.next_step,G=Z.response.meta?.is_authenticated||!1):(Y=Z?.data||Z,X=Y?.next_step,G=Z?.meta?.is_authenticated||Y?.meta?.is_authenticated||!1,W=Z?.status||Y?.status),W===200&&G){y.toast.success("Role selected successfully!"),i&&i({...Z,user:{...V.user,role:z},authenticated:!0,redirect_url:qe(I,Y?.redirect_url||Z?.redirect_url,"/app")});return}if(X&&X.is_pending)switch(X.id){case"mfa_authenticate":const U=X.metadata?.type?[X.metadata.type]:X.metadata?.methods||["email"];_(U),L("twoFactor");return;case"set_password":const Q=X.metadata?.password_policy;O(X.metadata?.reason||"Password update required"),v({...V,passwordPolicy:Q}),L("passwordReset");return;case"password_expiry":O("Your password has expired"),v({...V,passwordPolicy:X.metadata?.password_policy}),L("passwordReset");return;case"first_login":O("Please set up your password for first login"),v({...V,passwordPolicy:X.metadata?.password_policy}),L("passwordReset");return;case"login_by_code":y.toast.info("OTP verification required"),i&&i({...Z,user:{...V.user,role:z},requiresOTP:!0});return;default:console.warn("Unknown next step:",X.id);break}y.toast.success("Role selected successfully!"),i&&i({...Z,user:{...V.user,role:z}})}catch(Z){throw y.toast.error(Z.message||"Failed to select role"),Z}},title:l||"Select Your Role",subtitle:u||"Choose a role to continue"})})})}):o.jsx(y.Layout,{className:"min-h-screen",style:Ke(x),children:o.jsx(nr,{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:Ke(x),children:o.jsx(nr,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(On,{user:V?.user||b?.user||w,availableMethods:E,onVerify:C,title:c,subtitle:d})})});case"passwordReset":const S=V?.passwordPolicy,D=S?{minLength:S.min_length||8,maxLength:S.max_length,requireUppercase:S.require_uppercase||!1,requireLowercase:S.require_lowercase||!1,requireNumbers:S.require_numbers||!1,requireSpecialChars:S.require_special_chars||!1}:void 0;return o.jsx(y.Layout,{className:"min-h-screen",style:Ke(x),children:o.jsx(nr,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(Yr,{reason:k||void 0,onReset:$,title:f,subtitle:m,passwordRules:D})})});default:return null}})()},{Content:cd}=y.Layout,dd=({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 x=>{x.requiresRoleSelection||x.requires2FA||x.requiresPasswordReset?(f(x),g(!0)):(x.token&&localStorage.setItem(t?.tokenKey||"authToken",x.token),r&&r(x))},w=x=>{console.error("OAuth callback error:",x)},b=x=>{const P={...d,...x,authMethod:"oauth",provider:d?.provider};r&&r(P)};return m&&d?o.jsx(es,{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:Ke(t||{}),children:o.jsx(cd,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(Dc,{onSuccess:p,onError:w,apiConfig:t,redirectPath:c,logo:e,roleSelectionTitle:s,roleSelectionSubtitle:n,twoFactorTitle:a,twoFactorSubtitle:i,passwordResetTitle:l,passwordResetSubtitle:u})})})},ts=()=>Re(),{Header:uh,Content:In}=y.Layout,rs={},ss={},os={"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"}},It={"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}]},ns=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=It[s]||It.default,l=os[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 rs[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(rs[s]===r.otp){delete rs[s];const a=It[s]||It.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,...os["admin@example.com"]||{}};if(t.includes("2fa/send")){const s=Math.floor(Math.random()*9e5+1e5).toString().slice(0,6);return ss[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(ss[r.method]===r.otp){delete ss[r.method];const a=os["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:It["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{}}}}),ud=({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();J.useLocation(),J.useNavigate();const[g,p]=h.useState(null),{setBasePath:w}=sr();h.useEffect(()=>{w(e)},[e,w]),h.useEffect(()=>(m&&Oc(m),()=>{Fc()}),[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]),x=h.useMemo(()=>Ke(m),[m]),P=E=>{p(E),r&&r(E)},L=()=>{J.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 k=async O=>{y.toast.success("Authentication complete!");try{const v=new URLSearchParams(window.location.search).get("next");let I="/app";if(v){const C=decodeURIComponent(v);C.startsWith("/")&&!C.startsWith("//")&&!C.toLowerCase().startsWith("javascript:")&&!C.toLowerCase().startsWith("data:")&&!C.toLowerCase().includes("://")?I=C:console.warn("Invalid 'next' parameter blocked:",C)}window.location.pathname.startsWith("/app/login")&&(window.location.href=I)}catch(V){console.error("Error handling auth completion:",V),window.location.href="/app"}};return o.jsx("div",{style:{...x,minHeight:"100vh"},children:o.jsx(es,{onAuthComplete:k,logo:b.logo,title:b.title,subtitle:b.subtitle,apiConfig:ns(),useDynamicConfig:!0,roleSelectionTitle:b.roleSelectionTitle,roleSelectionSubtitle:b.roleSelectionSubtitle,twoFactorTitle:b.twoFactorTitle,twoFactorSubtitle:b.twoFactorSubtitle,passwordResetTitle:b.passwordResetTitle,passwordResetSubtitle:b.passwordResetSubtitle,initialAuthState:_})})},M=()=>{const{forgotPassword:E}=ts();Qe(m);const _=async k=>{try{await E(k);const O=m?.resetPassword?.forgotPassword?.successMessage||"Reset email sent successfully!";y.toast.success(O)}catch(O){const V=m?.resetPassword?.forgotPassword?.errorMessage||O.message||"Failed to send reset email";y.toast.error(V)}};return o.jsx(y.Layout,{style:{...x,minHeight:"100vh"},children:o.jsx(In,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:o.jsx(Ic,{onSubmit:_,authConfig:m,logo:b.logo})})})},B=()=>{const{resetPassword:E}=ts(),{key:_}=J.useParams();Qe(m);const k=J.useNavigate();if(h.useEffect(()=>{_||k(e)},[_,k]),!_)return null;const O=async V=>{console.log("Password reset submitted for key:",_)};return o.jsx(y.Layout,{style:{...x,minHeight:"100vh"},children:o.jsx(In,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:o.jsx(Uc,{onSubmit:O,authConfig:m,token:_,logo:b.logo})})})};return e.endsWith("/")&&e.slice(0,-1),o.jsx(Sn,{authConfig:m,children:o.jsx(An,{config:ns(),children:o.jsxs(J.Routes,{children:[o.jsx(J.Route,{path:"/",element:o.jsx(L,{})}),o.jsx(J.Route,{path:"forgot-password",element:o.jsx(M,{})}),o.jsx(J.Route,{path:"reset-password/:key",element:o.jsx(B,{})}),o.jsx(J.Route,{path:"reset-password",element:o.jsx(J.Navigate,{to:"/app",replace:!0})}),o.jsx(J.Route,{path:"/oauth/callback",element:o.jsx("div",{style:{...x,minHeight:"100vh"},children:o.jsx(dd,{logo:b.logo,apiConfig:ns(),onAuthComplete:E=>{(async()=>{const k=E?.response?.data?.redirect_url;k&&(window.location.href=k)})()},roleSelectionTitle:b.roleSelectionTitle,roleSelectionSubtitle:b.roleSelectionSubtitle,twoFactorTitle:b.twoFactorTitle,twoFactorSubtitle:b.twoFactorSubtitle,passwordResetTitle:b.passwordResetTitle,passwordResetSubtitle:b.passwordResetSubtitle})})}),o.jsx(J.Route,{path:"/saml",element:o.jsx(Fn,{logo:o.jsx(qi,{size:48,style:{color:"#1890ff"}}),onAuthComplete:E=>{const k=new URLSearchParams(window.location.search).get("next"),O=qe(k,E?.redirect_url,"/app");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(J.Route,{path:"/complete",element:o.jsx(es,{authData:g,apiConfig:t,logo:s,onComplete:P,roleSelectionTitle:i,roleSelectionSubtitle:l,twoFactorTitle:u,twoFactorSubtitle:c,passwordResetTitle:d,passwordResetSubtitle:f})}),o.jsx(J.Route,{path:"*",element:o.jsx(J.Navigate,{to:"/404",replace:!0})})]})})})},fd=({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}=Ae();if(h.useEffect(()=>{(async()=>{try{const O=await H.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=H.isSSOEnabled(),m=H.isOIDCEnabled(),g=H.getSSOProviders(),p=H.getOIDCProviders();if(!f&&!m||g.length===0&&p.length===0)return null;const b=d()?.ProviderButton,x=[...g.map(k=>({...k,providerType:"sso"})),...p.map(k=>({...k,providerType:"oidc"}))],L=x.length===1,B=`gap-${t??(e==="grid"?3:2)}`,_=`w-full ${(()=>{if(L)return"";switch(e){case"grid":return`grid grid-cols-1 sm:grid-cols-2 ${B}`;case"row":return`flex flex-row flex-wrap ${B}`;case"column":default:return`flex flex-col ${B}`}})()} ${r||""}`.trim();return o.jsx("div",{className:_,children:x.map((k,O)=>{const V=b||Ve;return o.jsx(V,{provider:k,type:k.providerType,prefix:s,postfix:n},`${k.providerType}-${O}`)})})},hd=({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}=Re(),{getLoginConfig:p,getMessagesConfig:w,authConfig:b}=Ae(),x=Rr(),P=b||g;Ue(P);const L=$e(P),M=Pn(P);if(h.useEffect(()=>{(async()=>{try{await H.getAuthConfig();const C=H.getAllowedUsernames();if(C&&C.length>0){const $=C.includes("email"),F=C.includes("mobile");$?u("email"):F&&u("mobile")}m(!0)}catch(C){console.error("Failed to load auth config:",C),m(!0)}})()},[]),!f)return o.jsx("div",{className:"flex justify-center items-center min-h-[200px]",children:o.jsx(y.Spin,{size:"large"})});const B=H.getAllowedUsernames(),E=B.includes("email"),_=B.includes("mobile"),k=E&&_,O=A=>{const C=w();return A==="email"?[{required:!0,message:C?.validation?.required||"Please enter your email address"},{type:"email",message:C?.validation?.invalidEmail||"Please enter a valid email address!"}]:[{required:!0,message:C?.validation?.required||"Please input your mobile number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:C?.validation?.invalidMobile||"Please enter a valid mobile number with country code (e.g., +919876543210)"}]},V=async A=>{n(!0),i(null);try{const C=l==="email"?{email:A.username,password:A.password}:{phone:A.username,password:A.password},F={...await H.login(C),loginUser:{email:l==="email"?A.username:void 0,phone:l==="mobile"?A.username:void 0,username:A.username,display:A.username}};if(e){e(F);return}if(x?.onLogin){x.onLogin(F);return}console.warn("PasswordLoginForm: No onSuccess prop or LoginContext found. Authentication result not handled.")}catch(C){const $=w(),F=C?.response?.data?.message||C?.message||$?.error?.login||"Login failed. Please check your credentials and try again.";i(F)}finally{n(!1)}},v=A=>{const C=p(),$=w();return o.jsxs(y.Form,{name:`${A}-password-login`,className:"w-full",onFinish:V,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"?C?.formPlaceholders?.email||"Email address":C?.formPlaceholders?.mobile||"Mobile number (+919876543210)",autoComplete:A==="email"?"email":"tel",onKeyDown:A==="mobile"?F=>{const S=["Backspace","Delete","Tab","Enter","ArrowLeft","ArrowRight"],D=F.key;!S.includes(D)&&!/[0-9+]/.test(D)&&F.preventDefault()}:void 0})}),o.jsx(y.FormItem,{name:"password",rules:[{required:!0,message:$?.validation?.required||"Please input your password!"},{min:g?.password_policy?.min_length||6,message:$?.validation?.passwordTooShort||`Password must be at least ${g?.password_policy?.min_length||6} characters long`}],children:o.jsx(y.PasswordInput,{placeholder:C?.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:C?.showRememberMe!==!1&&t&&H.isRememberMeEnabled()&&o.jsx(y.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:o.jsx("div",{className:"auth-remember-me",style:L,children:o.jsx(y.Checkbox,{label:C?.rememberMeText||"Remember me"})})})}),o.jsx("div",{children:H.isForgotPasswordEnabled()&&o.jsx(J.Link,{to:"forgot-password",className:"text-sm transition-colors duration-300",style:M,children:C?.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||C?.submitButtonText||"Sign in"})})]},`${A}-${c}`)};if(k){const A=[...E?[{key:"email",label:"Email",children:v("email")}]:[],..._?[{key:"mobile",label:"Mobile",children:v("mobile")}]:[]];return o.jsx("div",{className:"w-full",children:o.jsx(y.Tabs,{activeKey:l,onChange:C=>{u(C),d($=>$+1),i(null)},items:A,className:"password-login-tabs"})})}return v(E?"email":"mobile")},pd=({onSuccess:e,onBack:t,submitButtonText:r,verifyButtonText:s,resendButtonText:n})=>{const[a,i]=h.useState(!1),[l,u]=h.useState(null),c=Rr(),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(Jr,{onSuccess:d,onBack:t,submitButtonText:r,verifyButtonText:s,resendButtonText:n})},ar=({basePath:e="/app"})=>{const t=_t();return o.jsx("div",{className:"page-container",children:o.jsx(ud,{basePath:e,apiConfig:t})})},gd=async(e=[])=>{const t=Ti(e),r={login:{component:ar,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(Lr,{componentName:a})}},404:{component:At,standalone:!0,includeBasePath:!1,propsBuilder:()=>({})},default:{component:At,includeBasePath:!1,standalone:!0,propsBuilder:({pageType:n})=>({message:`Unknown page type: ${n}`})}};for(const n of t){const a=Oi(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},md=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)},Un=async e=>{const t=md(e);return gd(t)},Dn=h.createContext(void 0);let ir=!1;typeof window<"u"&&(ir=!1);const Ne=()=>{const e=h.useContext(Dn);if(!e)throw new Error("useAppContext must be used within AppProvider");return e},Bn=({children:e,config:t={},layoutConfig:r={},topbarConfig:s={},navbarConfig:n={},customComponents:a={},authConfig:i={}})=>{const l=J.useNavigate(),u=J.useLocation(),[c,d]=h.useState(null),[f,m]=h.useState(!0),[g,p]=h.useState(null),[w,b]=h.useState(null),[x,P]=h.useState(null),[L,M]=h.useState(!1),[B,E]=h.useState(null),_=()=>typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",k=t,O=k.apiConfig||{};h.useEffect(()=>{const v={colors:{primary:"#5048ed",secondary:"#6d7280",success:"#10b981",warning:"#f59e0b",error:"#f04438",gray:"#6d7280",background:"#f9fafb",text:"#252b37"}},I="default-theme-variables";let A=document.getElementById(I);A||(A=document.createElement("style"),A.id=I,document.head.appendChild(A)),A.innerHTML=`:root { ${Ht(v)} }`},[]),h.useEffect(()=>{const v=st.getCachedLogo();v&&b(v.base64Data||v.url)},[]),h.useEffect(()=>((async()=>{if(window.location.pathname.startsWith("/app/login"),!ir){ir=!0;try{const A=await Zs(),C=A.success?A.response:null;if(!A.success)throw new Error(A.response?.message||"Failed to fetch app data");if(d(C),C?.theme){const $=document.getElementById("default-theme-variables");if($)$.innerHTML=`:root { ${Ht(C.theme)} }`;else{const F=document.createElement("style");F.id="default-theme-variables",F.innerHTML=`:root { ${Ht(C.theme)} }`,document.head.appendChild(F)}C?.app_logo&&st.updateInBackground(C.app_logo,C.app_name,F=>{F.base64Data&&b(F.base64Data)})}}catch(A){console.error("❌ fetchAppInitData error:",A),p(A.message)}finally{m(!1),ir=!1}}})(),()=>{}),[]),h.useEffect(()=>{if(f||!c)return;const v=u.pathname,I=u.search,A=v==="/app/configuration-error",C=v==="/app/logout",$=W=>{if(!W)return"";const U=new URLSearchParams(W);U.delete("token"),U.delete("request_id");const Q=U.toString();return Q?`?${Q}`:""},F=$(I);if(F!==I&&!C){l(v+F,{replace:!0});return}if(C)return;const S=c.menu&&c.menu.length>0,D=c.routes&&c.routes.length>0;c.profile_info?.user_role;const z=c.is_user_anonymous,Z=!c.is_user_anonymous,Y=D&&c.routes.some(W=>{const U=W.path;if(v===U)return!0;if(U?.includes(":")){const Q=U.replace(/:[^/]+/g,"[^/]+");if(new RegExp(`^${Q}(/.*)?$`).test(v))return!0}return!!v.startsWith(U+"/")}),X=W=>{const U=$(I),Q=U?`${W}${U}`:W;l(Q,{replace:!0})};if(Z&&!S&&!A){X("/app/configuration-error");return}const G=v==="/app/login"||v.startsWith("/app/login/");if(z&&!S&&!G){const W=new URLSearchParams(I);v!=="/app"&&v!=="/app/"&&W.set("next",v+I);const U=W.toString();l(`/app/login${U?`?${U}`:""}`,{replace:!0});return}if(S&&c.menu){if(sessionStorage.getItem("saml_auth_in_progress")){sessionStorage.removeItem("saml_auth_in_progress");return}const U=c.menu[0]?.path||c.menu[0]?.uri;if(U&&(v==="/app"||v==="/app/"||!Y&&!A)){X(U);return}}},[f,c,u.pathname,u.search,l]),h.useEffect(()=>{let v=!1;return(async()=>{if(!f&&c){if(c.is_user_anonymous){const{default:A}=await Promise.resolve().then(function(){return bf});if(c.routes&&c.routes.length>0)try{v||M(!0);const C=await Un(c.routes);v||(P(C),M(!1));return}catch(C){console.error("❌ Failed to create registry from routes for anonymous user:",C)}v||(P(A),M(!1));return}if(!c.routes||c.routes.length===0){v||(P({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),M(!1));return}try{v||(M(!0),E(null));const A=await Un(c.routes);v||(P(A),M(!1))}catch(A){console.error("❌ Failed to create dynamic page registry:",A),v||(E(A.message||"Failed to create page registry"),P({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),M(!1))}}})(),()=>{v=!0}},[c,f]);const V={appData:c,loading:f,error:g,config:k,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:x,registryLoading:L,registryError:B,initializerEndpoint:_()};return o.jsx(Dn.Provider,{value:V,children:e})},$n=()=>{const e=J.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}},lr=({to:e,children:t,className:r,onClick:s,...n})=>{const{isInternalRoute:a}=$n(),i=u=>{s&&s(u)};return!(e&&(e.startsWith("http://")||e.startsWith("https://")))&&a(e)?o.jsx(J.Link,{to:e,className:r,onClick:i,...n,children:t}):o.jsx("a",{href:e,className:r,onClick:i,...n,children:t})},cr=(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)})})},wd=({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(lr,{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(As,{logoUrl:e,appName:t,height:"28px",linkTo:r})})},qn=({menuItems:e=[],appLogo:t,theme:r={},config:s={}})=>{const n=J.useLocation(),[a,i]=h.useState({}),{appName:l}=Ne(),u=h.useRef(null);h.useEffect(()=>{if(!u.current)return;const v=u.current.querySelector("#wideSidebarMenu");if(!v)return;v.querySelectorAll("li").forEach(A=>{const C=A.classList.contains("active"),$="var(--color-gray-700, #414651)",F="var(--color-brand-500, #5048ED)";cr(A,C?F:$);const S=()=>{A.classList.contains("active")||cr(A,F)},D=()=>{A.classList.contains("active")||cr(A,$)};return A.addEventListener("mouseenter",S),A.addEventListener("mouseleave",D),()=>{A.removeEventListener("mouseenter",S),A.removeEventListener("mouseleave",D)}})},[n.pathname,e]);const c=(v,I)=>{const A=v.url||v.uri,C=A?.endsWith("/")?A:`${A}/`,$=I.endsWith("/")?I:`${I}/`;return C===$?!0:v.children?.length?v.children.some(F=>{const S=F.url||F.uri;return(S?.endsWith("/")?S:`${S}/`)===$}):!1},d=v=>{i(I=>({...I,[v]:!I[v]}))};h.useEffect(()=>{const v={};e.forEach(I=>{I.children?.length&&c(I,n.pathname)&&(v[I.name]=!0)}),i(v)},[n.pathname,e]);const f=v=>v.icon?v.icon.includes("<svg")?o.jsx("span",{className:"navbar-icon",dangerouslySetInnerHTML:{__html:v.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(v.icon)||v.icon.length<=4?o.jsx("span",{className:"navbar-icon navbar-icon-emoji",children:v.icon}):o.jsx("span",{className:"navbar-icon",children:o.jsx("img",{src:v.icon,alt:v.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:x=null,customBottomContent:P=null,customNavbar:L=null,customMenu:M=null,menuConfig:B={},className:E="",style:_={}}=s,[k,O]=h.useState(p),V=k?"80px":"244px";return o.jsxs("nav",{ref:u,className:`navbar ${k?"collapsed-sidebar":"wide-sidebar"} ${E}`,style:{width:V,..._,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(wd,{appLogo:t,appName:l,collapsed:k})),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(!k),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:v=>v.target.style.backgroundColor="var(--color-gray-100, #f3f4f6)",onMouseLeave:v=>v.target.style.backgroundColor="transparent",title:k?"Expand navbar":"Collapse navbar",children:o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:k?"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&&(M||o.jsxs(o.Fragment,{children:[o.jsx("ul",{className:"navbar-menu wide-sidebar-menu",id:"wideSidebarMenu",children:e.map(v=>{const I=v.url||v.uri,A=c(v,n.pathname),C=a[v.name]||!1,$=v.children&&v.children.length>0;return o.jsxs(h.Fragment,{children:[o.jsx("li",{className:`menu-list-item ${$?"menu-list-item-with-sub-menu":""} ${A?"active":""}`,children:$?o.jsxs("div",{className:"menu-item",onClick:()=>!k&&d(v.name),style:{justifyContent:k?"center":"flex-start",padding:k?"8px":void 0},title:k?v.name:void 0,children:[f(v),!k&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:`menu-title ${A?"font-semibold":""}`,children:v.name}),o.jsx("div",{className:`flex justify-center items-center h-full transition-transform duration-300 ease-in-out ${A&&C?"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(lr,{to:I,className:"menu-item",style:{justifyContent:k?"center":"flex-start",padding:k?"8px":void 0},title:k?v.name:void 0,children:[f(v),!k&&o.jsx("span",{className:`menu-title ${A?"font-semibold":""}`,children:v.name})]})}),$&&!k&&o.jsx("ul",{className:`submenu-list ${C?"active":""}`,children:v.children.map(F=>{const S=F.url||F.uri,D=n.pathname===S||n.pathname===`${S}/`;return o.jsx("li",{className:"submenu-list-item",children:o.jsxs(lr,{to:S,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:F.name})]})},S)})})]},v.name)})}),x&&!k&&o.jsx("div",{className:"custom-menu-content",style:{paddingTop:"8px"},children:x})]}))}),P&&o.jsx("div",{className:"navbar-bottom-content",style:{marginTop:"auto",flexShrink:0},children:P})]})},yd=(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 Gs();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}},je=(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};`)},as=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},Vn=(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},jn=()=>{const e=as("zangocookie");return e!==null&&e!==""},Hn=Object.freeze({__proto__:null,deleteCookie:je,getCookie:as,isAuthenticatedViaCookie:jn,setCookie:Vn}),is=async(e={})=>{try{const t=await eo();if(t.success||t.responseStatus===401){je("zangocookie","/"),je("zangocookie","/app"),je("zangocookie","/app/"),je("zangocookie");const r=window.location.hostname;if(je("zangocookie","/",r),je("zangocookie","/app",r),r.includes(".")){const a="."+r.split(".").slice(-2).join(".");je("zangocookie","/",a),je("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)}},zn=e=>{const t=document.createElement("div");t.style.cssText=`
|
|
147
|
+
`;r.innerHTML=s},Uc=()=>{const e=document.getElementById("auth-theme-variables");e&&e.remove()},$e=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},et=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},ut=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},Ic=e=>e?.logo?.position||"center",ft=e=>{const t=Ic(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}},Be=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},He=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},_n=e=>{const t=e?.theme;if(!t)return{};const r={};return t.linkColor&&(r.color=t.linkColor),t.fontFamily&&(r.fontFamily=t.fontFamily),r},Dc=({onSubmit:e,logo:t})=>{const[r,s]=p.useState(!1),[n,a]=p.useState(null),[i,l]=p.useState(!1),[d,c]=p.useState(0),[u,f]=p.useState(["email"]),[g,h]=p.useState("email"),{basePath:m}=lr(),{authConfig:w,getResetPasswordConfig:b,getMessagesConfig:C}=Ae(),S=b(),T=C(),F=et(w),U=ft(w),k=ut(w);p.useEffect(()=>{(async()=>{try{await W.getAuthConfig();const $=W.getPasswordResetMethods();$&&$.length>0&&(f($),h($[0]))}catch($){console.error("Failed to load reset configuration:",$)}})()},[]);const L=async _=>{s(!0),a(null);try{if(e){const $={email:g==="email"?_.contact:void 0,phone:g==="sms"?_.contact:void 0};await e($)}l(!0),c($=>$+1)}catch($){const v=g==="email"?"email":"SMS",x=$.message||T?.errors?.networkError||`Failed to send reset ${v}. Please try again.`;a(x)}finally{s(!1)}},A=()=>g==="email"?S?.forgotPassword?.emailPlaceholder||"Email address":"Phone number",D=()=>g==="email"?[{required:!0,message:T?.validation?.required||"Please enter your email address"},{type:"email",message:T?.validation?.invalidEmail||"Please enter a valid email address!"}]:[{required:!0,message:T?.validation?.required||"Please input your phone number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:T?.validation?.invalidMobile||"Please enter a valid phone number!"}],Y=()=>{const _=g==="email"?"Email":"SMS",$=g==="email"?"email":"phone";return{title:S?.forgotPassword?.successMessage||`${_} Sent!`,subTitle:`Please check your ${$} for password reset instructions.`}};if(i){const _=Y();return o.jsx(y.Result,{status:"success",title:_.title,subTitle:_.subTitle,extra:[o.jsx(J.Link,{to:m,children:o.jsx(y.Button,{variant:"primary",children:S?.forgotPassword?.backToLoginText||"Back to Login"})},"login")]})}return o.jsxs("div",{className:"w-full max-w-md mx-auto",style:F,children:[o.jsx(J.Link,{to:m,className:"inline-block mb-6",children:o.jsxs(y.Button,{variant:"link",size:"link",className:"flex gap-2",icon:o.jsx(mt,{size:16}),children:[o.jsx(mt,{className:"w-4 h-4"})," ",S?.forgotPassword?.backToLoginText||"Back to Login"]})}),t&&o.jsx("div",{className:U.className,style:U.style,children:typeof t=="string"?o.jsx("img",{src:t,alt:w?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:k}):t}),o.jsx("h2",{className:"text-2xl font-semibold mb-3",style:Be(w),children:S?.forgotPassword?.title||"Forgot Password"}),o.jsx("p",{className:"text-sm mb-6",style:He(w),children:S?.forgotPassword?.subtitle||S?.forgotPassword?.instructionText||`Enter your ${g==="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:L,layout:"vertical",children:[n&&o.jsx(y.Alert,{message:n,type:"error",showIcon:!0,closable:!0,onClose:()=>a(null),className:"mb-4"}),u.length>1&&o.jsx(y.FormItem,{label:"Reset method",children:o.jsxs(y.Select,{value:g,onChange:_=>{h(_),c($=>$+1)},children:["options=",u.map(_=>({value:_,label:o.jsxs(y.Space,{children:[_==="email"?o.jsx(Xt,{size:16}):o.jsx(ji,{size:16}),_==="email"?"Email":"SMS"]})}))]})}),o.jsx(y.FormItem,{name:"contact",label:g==="email"?S?.forgotPassword?.emailLabel||"Email":"Phone",rules:D(),children:o.jsx(y.Input,{placeholder:A(),autoComplete:g==="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:S?.forgotPassword?.submitButtonText||`Send Reset ${g==="email"?"Email":"SMS"}`})})]},d)]})},$c=({onSubmit:e,token:t,logo:r})=>{const[s,n]=p.useState(!1),[a,i]=p.useState(!0),[l,d]=p.useState(!1),[c,u]=p.useState(""),[f,g]=p.useState(!1),[h,m]=p.useState(0),[w,b]=p.useState(null),{basePath:C}=lr(),{authConfig:S,getResetPasswordConfig:T,getMessagesConfig:F}=Ae(),U=T(),k=F(),L=et(S),A=ft(S),D=ut(S);p.useEffect(()=>{t?(async()=>{try{const v=await W.validatePasswordResetKey(t);v?.data?.metadata?.password_policy&&b(v.data.metadata.password_policy),d(!0)}catch(v){console.error("Invalid reset key:",v),d(!1),u(v.message||"This password reset link is invalid or has expired.")}finally{i(!1)}})():(i(!1),d(!1),u("Invalid link."))},[t]);const Y=($,v)=>{if(!v){const x=k?.validation?.required||"Please input your new password!";return Promise.reject(new Error(x))}if(w){if(w.min_length&&v.length<w.min_length)return Promise.reject(new Error(`Password must be at least ${w.min_length} characters long`))}else{const x=W.validatePassword(v);if(!x.valid){const q=k?.validation?.passwordTooShort||x.errors.join(", ");return Promise.reject(new Error(q))}}return Promise.resolve()},_=async $=>{if($.password!==$.confirmPassword){const v=k?.validation?.passwordsDoNotMatch||"The two passwords do not match!";y.toast.error(v);return}n(!0);try{if((await W.confirmResetPassword({key:t,password:$.password}))?.data?.next_step?.id==="login"){y.toast.success("Password reset successful! Redirecting to login..."),setTimeout(()=>{window.location.href="/app/login"},1500);return}g(!0),e&&await e({...$,token:t}),m(x=>x+1)}catch(v){const x=k?.errors?.networkError||v.message||"Failed to reset password. Please try again.";y.toast.error(x)}finally{n(!1)}};return a?o.jsxs("div",{className:"w-full max-w-md mx-auto p-8 text-center",style:L,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:U?.resetForm?.successMessage||"Password Reset Successful!",subTitle:"Your password has been successfully reset. You can now login with your new password.",extra:[o.jsx(J.Link,{to:C,children:o.jsx(y.Button,{variant:"primary",children:"Go to Login"})},"login")]}):o.jsxs("div",{className:"w-full max-w-md mx-auto",style:L,children:[r&&o.jsx("div",{className:A.className,style:A.style,children:typeof r=="string"?o.jsx("img",{src:r,alt:S?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:D}):r}),o.jsx("h2",{className:"text-2xl font-semibold mb-3",style:Be(S),children:U?.resetForm?.title||"Reset Password"}),o.jsx("p",{className:"text-sm mb-6",style:He(S),children:U?.resetForm?.subtitle||"Please enter your new password below."}),o.jsxs(y.Form,{name:"reset-password",className:"space-y-4",onFinish:_,layout:"vertical",children:[o.jsx(y.FormItem,{name:"password",label:U?.resetForm?.passwordLabel||"New Password",rules:[{validator:Y}],children:o.jsx(y.PasswordInput,{prefix:o.jsx(Jt,{size:16,className:"text-gray-400"}),placeholder:U?.resetForm?.passwordPlaceholder||"New Password",autoComplete:"new-password"})}),o.jsx(y.FormItem,{name:"confirmPassword",label:U?.resetForm?.confirmPasswordLabel||"Confirm Password",dependencies:["password"],rules:[{required:!0,message:k?.validation?.required||"Please confirm your password!"},({getFieldValue:$})=>({validator(v,x){if(!x||$("password")===x)return Promise.resolve();const q=k?.validation?.passwordsDoNotMatch||"The two passwords do not match!";return Promise.reject(new Error(q))}})],children:o.jsx(y.PasswordInput,{prefix:o.jsx(Jt,{size:16,className:"text-gray-400"}),placeholder:U?.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:U?.resetForm?.submitButtonText||"Reset Password"})})]},h)]}):o.jsx(y.Result,{status:"error",title:"Invalid Link",subTitle:c,extra:[o.jsx(J.Link,{to:C,children:o.jsx(y.Button,{variant:"primary",children:"Back to Login"})},"login")]})};function xt(e){if(!e||typeof e!="string")return!1;const t=e.trim();return!(!t.startsWith("/")||t.startsWith("//")||t.toLowerCase().includes("javascript:")||t.toLowerCase().includes("data:")||t.split("?")[0].includes("://")||t.startsWith("/app/login"))}function Oe(e){if(!e)return null;try{const r=new URLSearchParams(e).get("next");return r?decodeURIComponent(r):null}catch(t){return console.error("Error parsing next parameter:",t),null}}function ge(e,t,r="/app"){return e&&xt(e)?e:t&&xt(t)?t:xt(r)?r:"/app"}const Bc=({onSuccess:e,onError:t,apiConfig:r={},redirectPath:s="/",title:n="Completing sign in...",errorTitle:a="Authentication Error",logo:i,roleSelectionTitle:l,roleSelectionSubtitle:d,twoFactorTitle:c,twoFactorSubtitle:u,passwordResetTitle:f,passwordResetSubtitle:g})=>{const[h,m]=p.useState(!0),[w,b]=p.useState(null),[C,S]=p.useState(!1),[T,F]=p.useState(null),[U,k]=p.useState("login"),[L,A]=p.useState({}),[D,Y]=p.useState(["email"]),[_,$]=p.useState(""),[v,x]=p.useState(null),q=p.useRef(!1),O=J.useLocation(),I=J.useNavigate(),{basePath:X,setAuthToken:oe}=lr(),{authConfig:P}=Ae(),V=async N=>{let Z=N,Q=null;N?.status===401&&N?.data?(Z=N.data,Q=N.data?.next_step):(Z=N?.response?.data||N?.data||N,Q=Z?.next_step);const te=N?.loginUser;(N?.token||Z?.token)&&oe(N.token||Z.token);let re=N?.user||Z?.user||te||{};if((typeof re!="object"||re===null)&&(re={}),te&&typeof te=="object"&&(re={...re,email:re.email||te.email,username:re.username||te.username,phone:re.phone||te.phone,name:re.name||te.display}),Q&&Q.is_pending)switch(Q.id){case"role_selection":let he=[];Array.isArray(Q.metadata.roles)?he=Q.metadata.roles:typeof Q.metadata.roles=="object"&&(he=Object.entries(Q.metadata.roles).map(([fe,de])=>({id:fe,name:de,is_default:!1}))),A({...N,roles:he,user:re,nextStep:Q,loginUser:te}),k("roleSelection"),S(!0),m(!1);return;case"mfa_authenticate":oe(N.token||Z?.token),Y(Q.metadata?.methods||["email"]),k("twoFactor"),S(!0),m(!1);return;case"set_password":oe(N.token||Z?.token);const ue=Q.metadata?.password_policy;$(Q.metadata?.reason||"Password update required"),A({...N,passwordPolicy:ue,user:re,loginUser:te}),k("passwordReset"),S(!0),m(!1);return;case"password_expiry":oe(N.token||Z?.token),$("Your password has expired"),A({...N,passwordPolicy:Q.metadata?.password_policy,user:re,loginUser:te}),k("passwordReset"),S(!0),m(!1);return;case"first_login":oe(N.token||Z?.token),$("Please set up your password for first login"),A({...N,passwordPolicy:Q.metadata?.password_policy,user:re,loginUser:te}),k("passwordReset"),S(!0),m(!1);return;case"login_by_code":oe(N.token||Z?.token),y.toast.info("OTP verification required"),e&&e({...N,user:re,requiresOTP:!0});return}if(N.requires2FA){oe(N.token),Y(N.twoFactorMethods||["email"]),A({...N,user:re,loginUser:te}),k("twoFactor"),S(!0),m(!1);return}if(N.requiresPasswordReset){oe(N.token),$(N.passwordResetReason||"Your password has expired"),A({...N,user:re,loginUser:te}),k("passwordReset"),S(!0),m(!1);return}};p.useEffect(()=>{q.current||K()},[]);const K=async()=>{try{q.current=!0;const N=new URLSearchParams(O.search),Z=new URLSearchParams(O.hash.slice(1)),Q=Oe(O.search)||Oe(O.hash.slice(1));x(Q);const te=N.get("error")||Z.get("error"),re=N.get("error_description")||Z.get("error_description");if(te)throw new Error(re||`Authentication failed: ${te}`);const he=N.get("code"),ue=N.get("state"),fe=N.get("scope")||"",de=N.get("authuser"),Te=N.get("hd"),gt=N.get("prompt"),kr=N.get("provider")||ue?.split(":")[0];if(!he||!kr)throw new Error("Missing required OAuth parameters (code or provider)");const Xe=await W.processOAuthCallback(kr,ue||"",he,fe,de||void 0,Te||void 0,gt||void 0);if(await V(Xe),Xe?.status===401&&Xe?.data?.next_step&&Xe.data.next_step.is_pending){m(!1),e?e(Xe):(F(Xe),S(!0));return}m(!1),e?e(Xe):setTimeout(()=>{I(s,{replace:!0})},1e3)}catch(N){console.error("OAuth callback error:",N),b(N.message||"Authentication failed"),m(!1),t&&t(N)}},H=()=>{I(X,{replace:!0})},j=async N=>{y.toast.success("Authentication complete!");try{const Z=N?.response?.data?.redirect_url||N?.data?.redirect_url||N?.redirect_url,Q=ge(v,Z,"/app"),te=window.location.pathname,re=new URLSearchParams(window.location.search),he=re.get("code")!==null||re.get("token")!==null;te.startsWith("/app/login")&&he&&(window.location.href=Q)}catch(Z){console.error("Error handling auth completion:",Z)}};return C?o.jsx(CompleteAuthFlow,{logo:i,apiConfig:r,initialAuthState:T||L,onAuthComplete:j,roleSelectionTitle:l,roleSelectionSubtitle:d,twoFactorTitle:c,twoFactorSubtitle:u,passwordResetTitle:f,passwordResetSubtitle:g,redirectPath:s,initialRedirectUrl:v}):h?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:Be(P),children:n}),o.jsx("p",{className:"text-gray-500 text-sm mb-0",style:He(P),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:H,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})})})})},qc=()=>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"})]}),Vc=()=>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"})]}),jc=()=>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"})}),Hc=()=>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"})}),zc=()=>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"})}),Wc=()=>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"})}),Kc=()=>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"})}),Zc=()=>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"})]}),Gc=()=>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"})]}),Xc=(e,t="default")=>{const r=e?e.toLowerCase():"";return r.includes("google")?o.jsx(qc,{}):r.includes("microsoft")||r.includes("azure")?o.jsx(Vc,{}):r.includes("github")?o.jsx(jc,{}):r.includes("linkedin")?o.jsx(Hc,{}):r.includes("facebook")?o.jsx(zc,{}):r.includes("twitter")||r.includes("x.com")?o.jsx(Wc,{}):r.includes("apple")?o.jsx(Kc,{}):r.includes("slack")?o.jsx(Zc,{}):r.includes("okta")?o.jsx(Jc,{}):r.includes("saml")||r.includes("sso")||t==="sso"?o.jsx(Gc,{}):o.jsx(qi,{size:16})},ze=({provider:e,type:t="default",prefix:r="Continue with",postfix:s=""})=>{const[n,a]=p.useState(!1),i=async()=>{try{a(!0);const g=Oe(window.location.search)||"/app";if(t==="sso"){const h=e.id,m=await W.initiateSAMLAuth(h,g);m?.redirect_url?window.location.href=m.redirect_url:console.error("No redirect URL received from SAML init")}else{const h=await W.oauthRedirect(e.provider,window.location.href,g);h.success?window.location.href=h.response.redirect_url:console.error("Error authenticating with OAuth provider")}}catch(f){console.error(`Error authenticating with ${t} provider:`,f);let g=`Failed to authenticate with ${c}`;f.message?.includes("500")?g+=". The authentication service appears to be unavailable. Please try again later or contact support.":f.message?.includes("404")?g+=". The authentication service is not configured properly.":f.message?.includes("403")?g+=". You do not have permission to use this authentication method.":f.message?g+=`. ${f.message}`:g+=". Please try again or contact support.",y.toast.error(g)}finally{a(!1)}},l=()=>{if(t==="sso"){const f=e.label||e.id;return f.toLowerCase().includes("azure")?"Azure AD":f.toLowerCase().includes("okta")?"Okta":f.toLowerCase().includes("google")?"Google":f.toLowerCase().includes("microsoft")?"Microsoft":f.toLowerCase().includes("saml")?"SSO":f.charAt(0).toUpperCase()+f.slice(1)}else return e.name||e.provider},d=t==="sso"?e.label||e.id:e.provider,c=l(),u=Xc(d,t);return o.jsx(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:i,disabled:n,loading:n,children:n?"Redirecting...":`${r} ${c} ${s}`})},kn=({length:e=6,value:t="",onChange:r,disabled:s=!1})=>{const[n,a]=p.useState(new Array(e).fill("")),i=p.useRef([]);p.useEffect(()=>{if(t){const u=t.split("").slice(0,e),f=[...new Array(e).fill("")];u.forEach((g,h)=>{f[h]=g}),a(f)}},[t,e]);const l=(u,f)=>{const g=u.value;if(isNaN(g))return;const h=[...n];h[f]=g,a(h),r&&r(h.join("")),g&&f<e-1&&i.current[f+1].focus()},d=(u,f)=>{u.key==="Backspace"&&!n[f]&&f>0&&i.current[f-1].focus()},c=u=>{u.preventDefault();const g=u.clipboardData.getData("text/plain").slice(0,e).split(""),h=[...n];g.forEach((w,b)=>{!isNaN(w)&&b<e&&(h[b]=w)}),a(h),r&&r(h.join(""));const m=h.findIndex(w=>w==="");m!==-1?i.current[m].focus():i.current[e-1].focus()};return o.jsx(y.Space,{className:"flex justify-center gap-2",size:"small",children:n.map((u,f)=>o.jsx(y.Input,{ref:g=>i.current[f]=g,type:"text",inputMode:"numeric",maxLength:1,value:u,onChange:g=>l(g.target,f),onKeyDown:g=>d(g,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))})},En=p.createContext(null),tt=()=>{const e=p.useContext(En);if(!e)throw new Error("useAuthContext must be used within an AuthProvider");return e},An=({children:e,config:t={}})=>{const[r,s]=p.useState(null),[n,a]=p.useState(!0),[i,l]=p.useState(null),[d,c]=p.useState(null),[u,f]=p.useState(null),[g,h]=p.useState(null),m=p.useRef(!1);p.useEffect(()=>{m.current||(m.current=!0,w())},[]);const w=async()=>{try{const L=await W.getAuthConfig();h(L),await b()}catch(L){l(L.message),a(!1)}},b=async()=>{try{await W.isAuthenticated()?(s({id:1,username:"authenticated_user",email:"user@example.com",authenticated:!0}),l(null)):(s(null),l(null))}catch(L){console.error("Auth check failed:",L),s(null),l(null)}finally{a(!1)}},k={user:r,loading:n,error:i,login:async L=>{a(!0),l(null);try{const A=await W.login(L,t);let D=A,Y=null;A?.status===401&&A?.data?(D=A.data,Y=A.data?.next_step):(D=A?.response?.data||A?.data||A,Y=D?.next_step);const _=A?.user||D?.user||{};if(_.email=_.email||L.email,_.username=_.username||L.username,_.phone=_.phone||L.phone,_.name=_.name||L.email||L.username||L.phone,c({user:_,token:A.token||D?.token,roles:A.roles,requires2FA:A.requires2FA,twoFactorMethods:A.twoFactorMethods,requiresPasswordReset:A.requiresPasswordReset,passwordResetReason:A.passwordResetReason}),Y&&Y.is_pending&&Y.id==="role_selection")return{...A,user:_};if(A.roles&&A.roles.length>1)return f(A.roles),{requiresRoleSelection:!0,roles:A.roles,user:_,token:A.token};let $=A;return A.roles&&A.roles.length===1?$.user={..._,role:A.roles[0]}:$.user=_,A.requires2FA?{...$,requires2FA:!0,twoFactorMethods:A.twoFactorMethods||["email"]}:A.requiresPasswordReset?{...$,requiresPasswordReset:!0,passwordResetReason:A.passwordResetReason}:(s($.user),c(null),f(null),{...$,user:_})}catch(A){throw console.error("AuthProvider login caught error:",A),console.error("AuthProvider error.message:",A.message),l(A.message),A}finally{a(!1)}},logout:async()=>{a(!0);try{await W.logout(t),s(null),c(null),f(null)}catch(L){console.error("Logout failed:",L)}finally{a(!1)}},selectRole:async L=>{if(!d)throw new Error("No pending authentication");a(!0);try{t.roleSelectionEndpoint&&await W.selectRole(L,d.token,t);const A={...d.user,role:L},D={...d,user:A};return D.requires2FA?(c(D),{...D,requires2FA:!0,twoFactorMethods:D.twoFactorMethods||["email"]}):D.requiresPasswordReset?(c(D),{...D,requiresPasswordReset:!0,passwordResetReason:D.passwordResetReason}):(s(A),c(null),f(null),{user:A,token:d.token})}catch(A){throw l(A.message),A}finally{a(!1)}},checkAuth:b,forgotPassword:async L=>W.forgotPassword(L),resetPassword:async L=>W.resetPassword(L),isAuthenticated:!!r,pendingAuth:d,availableRoles:u,authConfig:g,requiresRoleSelection:!!d&&!!u};return o.jsx(En.Provider,{value:k,children:e})},{Text:Nn,Title:Ln}=y.Typography,Qr=({onSuccess:e,onBack:t,submitButtonText:r,verifyButtonText:s,resendButtonText:n})=>{const[a,i]=p.useState("request"),[l,d]=p.useState(!1),[c,u]=p.useState(""),[f,g]=p.useState("email"),[h,m]=p.useState(""),[w,b]=p.useState(""),[C,S]=p.useState(""),[T,F]=p.useState(0),[U,k]=p.useState(0),{authConfig:L}=tt();p.useEffect(()=>{if(L){const q=W.getAllowedUsernames();q&&q.length>0&&g(q[0])}},[L]),p.useEffect(()=>{if(T>0){const q=setTimeout(()=>F(T-1),1e3);return()=>clearTimeout(q)}},[T]);const A=q=>q==="email"?"Enter your email address":"Enter your mobile number",D=q=>q==="email"?[{required:!0,message:"Please enter your email address"},{type:"email",message:"Please enter a valid email!"}]:q==="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"}],Y=async q=>{S(""),d(!0);try{const O=await W.requestOTP(q.username);O?.status===401&&O?.data?.message?(u(q.username),i("verify"),F(30),y.toast.success(O.data.message||"Code sent successfully!")):(u(q.username),i("verify"),F(30),y.toast.success("Code sent successfully!"))}catch(O){console.error("Failed to Send Code:",O),S(O.message||"Failed to Send Code")}finally{d(!1)}},_=async()=>{if(b(""),h.length!==6){b("Please enter 6 digit Code");return}d(!0);try{const I={...await W.verifyOTP(c,h),loginUser:{email:f==="email"?c:void 0,phone:f==="mobile"?c:void 0,username:c,display:c}};e(I)}catch(O){b(O.message||"Invalid Code")}finally{d(!1)}},$=async()=>{if(!(T>0)){d(!0);try{await W.requestOTP(c),F(30),y.toast.success("Code resent successfully!")}catch(q){y.toast.error(q.message||"Failed to resend Code")}finally{d(!1)}}};if(!L)return o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const v=W.getAllowedUsernames(),x=6;return a==="verify"?o.jsxs("div",{className:"w-full",children:[o.jsxs(y.Button,{variant:"link",icon:o.jsx(mt,{size:16}),onClick:()=>i("request"),className:"mb-4 flex gap-2",children:[o.jsx(mt,{className:"w-4 h-4"})," Change ",f?.slice(0,1).toUpperCase()+f?.slice(1)," ",f==="email"?"Address":"Number"]}),o.jsx(Ln,{level:4,className:"!mb-2 text-center",style:Be(L),children:"Enter Verification Code"}),o.jsxs(Nn,{className:"block text-center text-gray-500 mb-6",style:He(L),children:["Please enter the ",x,"-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(kn,{length:x,value:h,onChange:q=>{m(q),w&&b("")},disabled:l})}),o.jsx(y.Button,{type:"primary",block:!0,fullWidth:!0,loading:l,onClick:_,className:"mt-6",children:s||"Verify & Sign In"}),o.jsx("div",{className:"text-center mt-4",children:T>0?o.jsxs(Nn,{type:"secondary",children:["Resend Code in ",T,"s"]}):o.jsx(y.Button,{variant:"link",onClick:$,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(mt,{size:16}),onClick:t,className:"mb-4",children:[o.jsx(mt,{className:"w-4 h-4"})," Back to login"]}),o.jsx(Ln,{level:4,className:"!mb-2 text-center",style:Be(L),children:"Sign in with a One-Time Pin"}),C&&o.jsx(y.Alert,{message:C,type:"error",showIcon:!1,closable:!0,onClose:()=>S(""),className:"mb-4"}),o.jsxs(y.Form,{name:"otp-request",onFinish:Y,layout:"vertical",children:[v.length>1&&o.jsx(y.FormItem,{children:o.jsx(y.Segmented,{options:v.map(q=>({label:o.jsxs(y.Space,{children:[q==="email"?o.jsx(Xt,{size:16}):q==="mobile"?o.jsx(Ur,{size:16}):o.jsx(Ir,{size:16}),o.jsx("span",{children:q==="mobile"?"Phone":q==="email"?"Email":"Username"})]}),value:q})),value:f,onChange:q=>g(q),block:!0,className:"bg-gray-100 mb-2"})}),o.jsx(y.FormItem,{name:"username",rules:D(f),children:o.jsx(y.Input,{placeholder:A(f)})}),o.jsx(y.FormItem,{children:o.jsx(y.Button,{variant:"primary",type:"submit",fullWidth:!0,disabled:l,children:r||"Send Code"})})]},U)]})},Yc=({onLogin:e,showRememberMe:t=!0})=>{const[r,s]=p.useState(!1),[n,a]=p.useState(null),[i,l]=p.useState(null),[d,c]=p.useState("email"),[u,f]=p.useState(!1),[g,h]=p.useState(0),[m,w]=p.useState(!1),[b,C]=p.useState(!1),[S,T]=p.useState(""),[F,U]=p.useState(""),{authConfig:k}=tt(),{getLoginConfig:L,getMessagesConfig:A,getProvidersConfig:D,authConfig:Y}=Ae(),_=Y||k,$=Be(_),v=He(_),x=_n(_),q=async()=>{try{return await W.isAuthenticated()}catch{return!1}};if(p.useEffect(()=>{if(k){const j=W.getAllowedUsernames();if(j&&j.length>0){const N=j.includes("email"),Z=j.includes("mobile");N?c("email"):Z&&c("mobile")}W.isPasswordLoginEnabled()?l("password"):W.isOTPLoginEnabled()&&l("otp")}},[k]),p.useEffect(()=>{(async()=>{const N=await q();w(N)})()},[]),!k)return o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:o.jsx(y.Spin,{size:"large"})});const O=j=>{const N=A();return j==="email"?[{required:!0,message:N?.validation?.required||"Please enter your email address"},{type:"email",message:N?.validation?.invalidEmail||"Please enter a valid email address!"}]:j==="mobile"?[{required:!0,message:N?.validation?.required||"Please input your mobile number!"},{pattern:/^\+\d{7,15}$/,message:N?.validation?.invalidMobile||"Please enter a valid mobile number with country code (e.g., +919876543210)"}]:[{required:!0,message:N?.validation?.required||"Please enter your email address"},{type:"email",message:N?.validation?.invalidEmail||"Please enter a valid email address!"}]},I=async j=>{s(!0),a(null);try{const N=W.getAllowedUsernames(),Z=N.includes("email"),Q=N.includes("mobile"),te=Z&&Q?d:Z?"email":"mobile",re={email:te==="email"?j.username:void 0,phone:te==="mobile"?j.username:void 0,password:j.password,remember_me:j.remember||!1},he=await e(re)}catch(N){const Z=A(),Q=N.message||Z?.errors?.loginFailed||"Login failed. Please try again.";a(Q)}finally{s(!1)}},X=async j=>{console.log("OTP success in DynamicLoginForm, passing to onLogin:",j),await e(j)},oe=async()=>{s(!0);try{await W.logout(),y.toast.success("Logged out successfully"),w(!1)}catch(j){y.toast.error(j.message||"Failed to logout")}finally{s(!1)}},P=async()=>{if(!S||!F){y.toast.error("Please fill in all password fields");return}if(S!==F){y.toast.error("Passwords do not match");return}if(S.length<8){y.toast.error("Password must be at least 8 characters long");return}s(!0);try{await W.setPassword(S),y.toast.success("Password changed successfully!"),C(!1),T(""),U("")}catch(j){y.toast.error(j.message||"Failed to change password")}finally{s(!1)}},V=j=>{const N=L(),Z=A();return o.jsxs(y.Form,{name:`${j}-password-login`,className:"w-full",onFinish:I,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:O(j),children:o.jsx(y.Input,{placeholder:j==="email"?N?.formPlaceholders?.email||"Enter your email address":N?.formPlaceholders?.mobile||"Enter your mobile number (+919876543210)",autoComplete:j==="email"?"email":"tel",onKeyDown:j==="mobile"?Q=>{const te=["Backspace","Delete","Tab","Enter","ArrowLeft","ArrowRight"],re=Q.key;!te.includes(re)&&!/[0-9+]/.test(re)&&Q.preventDefault()}:void 0})}),o.jsx(y.FormItem,{name:"password",rules:[{required:!0,message:Z?.validation?.required||"Please input your password!"},{min:k?.password_policy?.min_length||6,message:Z?.validation?.passwordTooShort||`Password must be at least ${k?.password_policy?.min_length||6} characters long`}],children:o.jsx(y.PasswordInput,{placeholder:N?.formPlaceholders?.password||"Enter your 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:N?.showRememberMe!==!1&&t&&W.isRememberMeEnabled()&&o.jsx(y.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:o.jsx("div",{className:"auth-remember-me",style:v,children:o.jsx(y.Checkbox,{label:N?.rememberMeText||"Remember me"})})})}),o.jsx("div",{children:W.isForgotPasswordEnabled()&&o.jsx(J.Link,{to:"forgot-password",className:"text-sm transition-colors duration-300",style:x,children:N?.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:N?.submitButtonText||"Sign in"})})]},`${j}-${g}`)},K=()=>{if(!W.isOTPLoginEnabled())return null;const j=L();return u?o.jsx(Qr,{onSuccess:X,onBack:()=>f(!1)}):o.jsx(y.Button,{variant:"secondary",fullWidth:!0,onClick:()=>f(!0),className:"bg-gray-100 border-gray-300",children:j?.otpButtonText||"Sign in with OTP"})},H=()=>{if(!k)return null;const j=W.getAllowedUsernames(),N=j.includes("email"),Z=j.includes("mobile"),Q=W.isSSOEnabled()||W.isOIDCEnabled(),te=W.isPasswordLoginEnabled(),re=W.isOTPLoginEnabled();if(!te&&!re&&!Q)return null;if(Q&&!te&&!re)return o.jsxs("div",{className:"w-full",children:[W.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:W.getSSOProviders().map((ue,fe)=>o.jsx(ze,{provider:ue,type:"sso"},`sso-standalone-${fe}`))})}),W.isOIDCEnabled()&&o.jsx("div",{className:"space-y-2",children:W.getOIDCProviders().map((ue,fe)=>o.jsx(ze,{provider:ue,type:"oidc"},`oidc-standalone-${fe}`))})]});if(re&&!te){const ue=D();return o.jsxs("div",{className:"w-full",children:[o.jsx(Qr,{onSuccess:X}),Q&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:ue?.separatorText||"OR"}),W.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:W.getSSOProviders().map((fe,de)=>o.jsx(ze,{provider:fe,type:"sso"},`sso-otp-${de}`))})}),W.isOIDCEnabled()&&o.jsx("div",{className:"mt-4",children:o.jsx("div",{className:"space-y-2",children:W.getOIDCProviders().map((fe,de)=>o.jsx(ze,{provider:fe,type:"oidc"},`oidc-otp-${de}`))})})]})]})}if(N&&Z&&te){const ue=L(),fe=D();return o.jsx("div",{className:"w-full",children:o.jsx(y.Tabs,{className:"login-tabs",activeKey:d,onChange:de=>{c(de),h(Te=>Te+1)},items:[{key:"email",label:o.jsxs("span",{className:"flex items-center gap-1",style:$,children:[o.jsx(Xt,{size:16}),ue?.tabLabels?.email||"Email"]}),children:o.jsxs(o.Fragment,{children:[V("email"),re&&te&&!u&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:fe?.separatorText||"OR"}),K()]}),u&&K(),!u&&Q&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:fe?.separatorText||"OR"}),W.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:W.getSSOProviders().map((de,Te)=>o.jsx(ze,{provider:de,type:"sso"},`sso-email-${Te}`))})}),W.isOIDCEnabled()&&o.jsx("div",{className:"mt-4",children:o.jsx("div",{className:"space-y-2",children:W.getOIDCProviders().map((de,Te)=>o.jsx(ze,{provider:de,type:"oidc"},`oidc-email-${Te}`))})})]})]})},{key:"mobile",label:o.jsxs("span",{className:"flex items-center gap-1",style:$,children:[o.jsx(Ur,{size:16}),ue?.tabLabels?.mobile||"Mobile"]}),children:o.jsxs(o.Fragment,{children:[V("mobile"),re&&te&&!u&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),K()]}),u&&K(),!u&&Q&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),W.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:W.getSSOProviders().map((de,Te)=>o.jsx(ze,{provider:de,type:"sso"},`sso-mobile-${Te}`))})}),W.isOIDCEnabled()&&o.jsx("div",{className:"mt-4",children:o.jsx("div",{className:"space-y-2",children:W.getOIDCProviders().map((de,Te)=>o.jsx(ze,{provider:de,type:"oidc",onClick:gt=>{console.log("OIDC provider clicked:",gt)}},`oidc-${Te}`))})})]})]})}]})})}else{const ue=N?"email":"mobile";return o.jsxs("div",{className:"w-full",children:[V(ue),re&&te&&!u&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),K()]}),u&&K(),!u&&Q&&o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Divider,{children:"OR"}),W.isSSOEnabled()&&o.jsx("div",{className:"mb-4",children:o.jsx("div",{className:"space-y-2",children:W.getSSOProviders().map((fe,de)=>o.jsx(ze,{provider:fe,type:"sso"},`sso-single-${de}`))})}),W.isOIDCEnabled()&&o.jsx("div",{className:"mt-4"})]})]})}};return k?m?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:S,onChange:j=>T(j.target.value),placeholder:"Enter new password",disabled:r})}),o.jsx(y.FormItem,{label:"Confirm Password",children:o.jsx(y.PasswordInput,{value:F,onChange:j=>U(j.target.value),placeholder:"Confirm new password",disabled:r})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(y.Button,{type:"primary",onClick:P,loading:r,className:"flex-1",children:"Change Password"}),o.jsx(y.Button,{onClick:()=>{C(!1),T(""),U("")},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:$,children:"Already Logged In"}),o.jsx("p",{className:"text-sm mt-2",style:v,children:"You are currently logged in."})]}),o.jsx(y.Button,{block:!0,onClick:()=>C(!0),children:"Change Password"}),o.jsx(y.Button,{block:!0,danger:!0,onClick:oe,loading:r,children:"Logout"})]})}):H():o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:o.jsx(y.Spin,{size:"large"})})},Qc=({onLogin:e,showRememberMe:t=!0,showForgotPassword:r=!0})=>{const[s,n]=p.useState(!1),[a,i]=p.useState(0),[l,d]=p.useState("email"),{authConfig:c}=tt();p.useEffect(()=>{if(c){const C=W.getAllowedUsernames();C&&C.length>0&&d(C[0])}},[c]);const u=async C=>{n(!0);try{if(e){const S={email:l==="email"?C.username:void 0,phone:l==="mobile"?C.username:void 0,username:C.username,password:C.password,remember_me:C.remember||!1};await e(S)}}catch(S){y.toast.error(S.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"}},g=()=>{const C=[{required:!0,message:`Please input your ${l}!`}];switch(l){case"email":return[...C,{type:"email",message:"Please enter a valid email address!"}];case"mobile":return[...C,{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid phone number!"}];case"username":return[...C,{min:3,message:"Username must be at least 3 characters long"}];default:return C}};if(!c)return o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const h=W.getAllowedUsernames(),m=h.length>1,w=W.isRememberMeEnabled(),b=W.isForgotPasswordEnabled();return o.jsxs(y.Form,{name:"login",className:"w-full space-y-4",initialValues:{remember:!1},onFinish:u,autoComplete:"off",layout:"vertical",children:[m&&o.jsx(y.FormItem,{label:"Login with",className:"mb-4",children:o.jsx(y.Select,{value:l,onChange:d,options:h.map(C=>({value:C,label:C==="mobile"?"Phone":C.charAt(0).toUpperCase()+C.slice(1)}))})}),o.jsx(y.FormItem,{name:"username",rules:g(),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(J.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:Rc,Text:Rr,Paragraph:ed}=y.Typography,Tn=({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:d})=>{const[c,u]=p.useState(t[0]||"email"),[f,g]=p.useState(""),[h,m]=p.useState(0),[w,b]=p.useState(!1),[C,S]=p.useState(!1),{authConfig:T,getTwoFactorConfig:F,getMessagesConfig:U}=Ae(),k=F(),L=U(),A=et(T),D=ft(T),Y=ut(T);p.useEffect(()=>{if(h>0){const O=setTimeout(()=>m(h-1),1e3);return()=>clearTimeout(O)}},[h]);const _=O=>{if(O==="email"&&e?.email){const[I,X]=e.email.split("@");return`${I.substring(0,3)+"****"+I.substring(I.length-1)}@${X}`}return(O==="sms"||O==="mobile")&&e?.mobile?`****${e.mobile.substring(e.mobile.length-4)}`:O==="totp"?"your authenticator app":O==="email"?"your email":O==="sms"?"your mobile":"your authenticator app"},$=async()=>{b(!0);try{await W.sendTwoFactorCode(c),S(!0),m(k?.resendCountdown||a);const O=L?.success?.otpSent||`OTP sent to ${_(c)}`;y.toast.success(O)}catch(O){const I=L?.errors?.networkError||O.message||"Failed to Request OTP";y.toast.error(I)}finally{b(!1)}},v=async()=>{const O=k?.codeLength||n;if(f.length!==O){const I=L?.validation?.required||`Please enter ${O} digit OTP`;y.toast.error(I);return}b(!0);try{const I=await W.verifyTwoFactorCode(f);await r(I)}catch(I){const X=L?.errors?.invalidOTP||I.message||"Invalid OTP";y.toast.error(X),g("")}finally{b(!1)}},x=async()=>{h>0||await $()},q=()=>{if(t.length<=1)return null;const O=t.map(I=>({label:o.jsxs(y.Space,{children:[I==="email"?o.jsx(Xt,{size:16}):I==="sms"?o.jsx(Ur,{size:16}):o.jsx(xo,{size:16}),o.jsx("span",{children:I==="email"?k?.methodLabels?.email||"Email":I==="sms"?k?.methodLabels?.sms||"SMS":k?.methodLabels?.mobile||"Authenticator"})]}),value:I}));return o.jsxs("div",{className:"mb-6",children:[o.jsx(Rr,{type:"secondary",className:"block mb-2 text-xs",children:"Verification Method"}),o.jsx(y.Segmented,{options:O,value:c,onChange:I=>{u(I),S(!1),g("")},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:A,children:[d&&o.jsx("div",{className:D.className,style:D.style,children:typeof d=="string"?o.jsx("img",{src:d,alt:T?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:Y}):d}),o.jsxs("div",{className:"text-center mb-8",children:[o.jsx(Rc,{level:3,className:"!mb-2",style:Be(T),children:k?.title||i}),o.jsx(ed,{className:"!mb-0 text-sm",type:"secondary",style:He(T),children:k?.subtitle||l})]}),o.jsxs("div",{className:"mt-6",children:[q(),C?o.jsxs("div",{className:"mt-6",children:[o.jsx(Rr,{className:"block text-center mb-6 text-gray-700",children:k?.instructionText||`Enter the ${k?.codeLength||n}-digit code sent to ${_(c)}`}),o.jsx("div",{className:"flex justify-center mb-6",children:o.jsx(kn,{length:k?.codeLength||n,value:f,onChange:g,disabled:w})}),o.jsx(y.Button,{variant:"primary",fullWidth:!0,disabled:w,onClick:v,className:"mb-4",children:k?.submitButtonText||"Verify"}),o.jsx("div",{className:"text-center",children:h>0?o.jsxs(Rr,{type:"secondary",children:["Resend code in ",h,"s"]}):o.jsx(y.Button,{variant:"link",onClick:x,disabled:w,children:k?.resendButtonText||"Resend Code"})})]}):o.jsxs("div",{className:"mt-6",children:[o.jsx(y.Alert,{message:k?.instructionText||`We'll send a verification code to ${_(c)}`,type:"info",showIcon:!0,className:"mb-6"}),o.jsx(y.Button,{variant:"primary",fullWidth:!0,disabled:w,onClick:$,children:"Send Verification Code"})]})]})]})})},{Title:td,Text:rt,Paragraph:rd}=y.Typography,es=({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,d]=p.useState(0),[c,u]=p.useState(!1),[f,g]=p.useState(""),[h,m]=p.useState(null),[w,b]=p.useState({minLength:8,requireUppercase:!0,requireLowercase:!0,requireNumbers:!0,requireSpecialChars:!0}),{authConfig:C,getResetPasswordConfig:S,getMessagesConfig:T}=Ae(),F=S(),U=T(),k=et(C),L=ft(C),A=ut(C);p.useEffect(()=>{if(a)b(a);else{const v=W.getPasswordPolicy();b({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})}},[a]);const D=v=>{if(!v)return{percent:0,status:"exception"};let x=0;return v.length>=w.minLength&&(x+=20),v.length>=12&&(x+=10),w.requireUppercase&&/[A-Z]/.test(v)&&(x+=20),w.requireLowercase&&/[a-z]/.test(v)&&(x+=20),w.requireNumbers&&/\d/.test(v)&&(x+=15),w.requireSpecialChars&&/[!@#$%^&*]/.test(v)&&(x+=15),x<40?{percent:x,status:"exception"}:x<70?{percent:x,status:"normal"}:{percent:x,status:"success"}},Y=(v,x)=>{if(!x){const O=U?.validation?.required||"Please input your password!";return Promise.reject(new Error(O))}const q=W.validatePassword(x);if(!q.valid){const O=U?.validation?.passwordTooShort||q.errors.join(", ");return Promise.reject(new Error(O))}return Promise.resolve()},_=async v=>{if(m(null),v.password!==v.confirmPassword){const x=U?.validation?.passwordsDoNotMatch||"Passwords do not match!";m(x);return}u(!0);try{await t({password:v.password,confirmPassword:v.confirmPassword})}catch(x){const q=x?.message||"Failed to set password. Please try again.";m(q)}finally{u(!1)}},$=D(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:k,children:[i&&o.jsx("div",{className:L.className,style:L.style,children:typeof i=="string"?o.jsx("img",{src:i,alt:C?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:A}):i}),o.jsxs("div",{className:"text-center mb-6",children:[o.jsx(td,{level:3,className:"!mb-2",style:Be(C),children:F?.resetForm?.title||s}),o.jsx(rd,{className:"!mb-0 text-sm",type:"secondary",style:He(C),children:F?.resetForm?.subtitle||n})]}),o.jsx(y.Alert,{message:e,type:"warning",showIcon:!0,className:"mb-6"}),h&&o.jsx(y.Alert,{message:h,type:"error",showIcon:!0,className:"mb-6"}),o.jsxs(y.Form,{name:"password-reset-required",onFinish:_,layout:"vertical",className:"mt-6",children:[o.jsx(y.FormItem,{name:"password",label:F?.resetForm?.passwordLabel||"New Password",rules:[{validator:Y}],children:o.jsx(y.PasswordInput,{prefix:o.jsx(Jt,{size:16}),placeholder:F?.resetForm?.passwordPlaceholder||"New Password",onChange:v=>g(v.target.value)})}),f&&o.jsxs("div",{className:"-mt-4 mb-4",children:[o.jsx(rt,{type:"secondary",className:"text-xs block mb-1",children:"Password Strength"}),o.jsx(y.Progress,{percent:$.percent,status:$.status,showInfo:!1,strokeWidth:4})]}),o.jsx(y.FormItem,{name:"confirmPassword",label:F?.resetForm?.confirmPasswordLabel||"Confirm Password",dependencies:["password"],rules:[{required:!0,message:U?.validation?.required||"Please confirm your password!"},({getFieldValue:v})=>({validator(x,q){if(!q||v("password")===q)return Promise.resolve();const O=U?.validation?.passwordsDoNotMatch||"Passwords do not match!";return Promise.reject(new Error(O))}})],children:o.jsx(y.PasswordInput,{prefix:o.jsx(Jt,{size:16}),placeholder:F?.resetForm?.confirmPasswordPlaceholder||"Confirm Password"})}),F?.resetForm?.showPasswordRequirements!==!1&&o.jsxs("div",{className:"bg-gray-50 p-4 rounded-md mb-6",children:[o.jsx(rt,{type:"secondary",className:"block font-medium mb-2",children:F?.resetForm?.passwordRequirementsText||"Password Requirements:"}),o.jsxs(y.Space,{direction:"vertical",size:"small",children:[o.jsxs(rt,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ye,{size:16,className:f.length>=w.minLength?"text-green-500":"text-gray-300"}),"At least ",w.minLength," characters"]}),w.maxLength&&o.jsxs(rt,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ye,{size:16,className:f.length<=w.maxLength?"text-green-500":"text-gray-300"}),"At most ",w.maxLength," characters"]}),w.requireUppercase&&o.jsxs(rt,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ye,{size:16,className:/[A-Z]/.test(f)?"text-green-500":"text-gray-300"}),"One uppercase letter"]}),w.requireLowercase&&o.jsxs(rt,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ye,{size:16,className:/[a-z]/.test(f)?"text-green-500":"text-gray-300"}),"One lowercase letter"]}),w.requireNumbers&&o.jsxs(rt,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ye,{size:16,className:/\d/.test(f)?"text-green-500":"text-gray-300"}),"One number"]}),w.requireSpecialChars&&o.jsxs(rt,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[o.jsx(Ye,{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:F?.resetForm?.submitButtonText||"Reset Password"})})]},l)]})})},{Content:sd}=y.Layout,Mn=({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:d="Reset Password",passwordResetSubtitle:c="Please enter your new password"})=>{const[u]=J.useSearchParams(),{authConfig:f}=Ae(),[g,h]=p.useState(!0),[m,w]=p.useState(null),[b,C]=p.useState(null),[S,T]=p.useState(null),[F,U]=p.useState(!1),[k,L]=p.useState(null);p.useEffect(()=>{A()},[]);const A=async()=>{try{h(!0),w(null),sessionStorage.setItem("saml_auth_in_progress","true");const v=u.get("token"),x=u.get("request_id"),q=u.get("next");if(!v||!x)throw new Error("Missing required SAML parameters (token or request_id)");if(!window.location.pathname.startsWith("/app/login")){h(!1),sessionStorage.removeItem("saml_auth_in_progress");return}const I=await W.getSAMLAuthMeta(v,x);if(I?.code==="user_not_found"){sessionStorage.setItem("saml_error",JSON.stringify({message:I.message||"User does not exist",timestamp:Date.now()})),sessionStorage.removeItem("saml_auth_in_progress"),window.location.href="/app/login";return}if(I?.status===401&&I?.data?.next_step){if(I.data.next_step.is_pending){let oe=u.get("email")||u.get("user_email")||null,P=u.get("name")||u.get("user_name")||oe;!oe&&I?.data?.user&&(oe=I.data.user.email||I.data.user.username,P=I.data.user.name||oe);const K={...I,loginUser:{email:oe,username:P||oe||"SAML User",display:P||oe||"SAML User"}};L(K),U(!0),h(!1);return}C(I.data),T(I.data.next_step.id),h(!1);return}if(I?.roles&&I.roles.length>1){const X={status:401,data:{next_step:{id:"role_selection",is_pending:!0,metadata:{roles:I.roles}}},loginUser:{email:u.get("email")||u.get("user_email")||"SAML User",username:u.get("name")||u.get("user_name")||"SAML User",display:u.get("name")||u.get("user_name")||"SAML User"}};L(X),U(!0),h(!1);return}if(s)console.log("SAML callback complete, calling onAuthComplete:",I),sessionStorage.removeItem("saml_auth_in_progress"),s(I);else{console.log("SAML callback complete, redirecting to:",I?.redirect_url||"/app");const X=ge(q,I?.redirect_url,"/app");sessionStorage.removeItem("saml_auth_in_progress"),window.location.href=X}}catch(v){console.error("SAML callback error:",v),w(v.message||"Failed to process SAML authentication"),h(!1),sessionStorage.removeItem("saml_auth_in_progress")}},D=async v=>{try{if(v?.status===401&&v?.data?.next_step){C(v.data),T(v.data.next_step);return}if(s)sessionStorage.removeItem("saml_auth_in_progress"),s(v);else{const x=ge(next,v?.redirect_url,"/app");sessionStorage.removeItem("saml_auth_in_progress"),window.location.href=x}}catch(x){console.error("Two-factor completion error:",x),y.toast.error(x.message||"Failed to complete two-factor authentication"),sessionStorage.removeItem("saml_auth_in_progress")}},Y=async v=>{try{if(v?.status===401&&v?.data?.next_step){C(v.data),T(v.data.next_step);return}if(s)sessionStorage.removeItem("saml_auth_in_progress"),s(v);else{const x=ge(next,v?.redirect_url,"/app");sessionStorage.removeItem("saml_auth_in_progress"),window.location.href=x}}catch(x){console.error("Password reset completion error:",x),y.toast.error(x.message||"Failed to complete password reset"),sessionStorage.removeItem("saml_auth_in_progress")}},_=()=>{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(m)return o.jsx(y.Alert,{message:"Authentication Error",description:m,type:"error",showIcon:!0,action:o.jsx("a",{href:"/app/login",children:"Return to Login"})});switch(S){case"2fa_required":return o.jsx(Tn,{user:b?.user,onVerify:D,title:i,subtitle:l,logo:e});case"password_reset_required":return o.jsx(es,{onReset:Y,title:d,subtitle:c,reason:b?.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: ${S}`,type:"warning",showIcon:!0})]})}},$=()=>g||m||!S;if(F&&k){const v=u.get("next");return o.jsx(Bt,{initialAuthState:k,onAuthComplete:x=>{const q=ge(v,x?.redirect_url,"/app");sessionStorage.removeItem("saml_auth_in_progress"),window.location.href=q},skipLoginStep:!0,logo:e,roleSelectionTitle:n,roleSelectionSubtitle:a,twoFactorTitle:i,twoFactorSubtitle:l,passwordResetTitle:d,passwordResetSubtitle:c,initialNextParam:v})}return o.jsx(y.Layout,{className:"min-h-screen",style:$e(f),children:o.jsx(sd,{className:"flex justify-center items-center min-h-screen p-5",children:$()?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})}),_()]}):_()})})},cr=p.createContext(null),ts=()=>p.useContext(cr);let Fn=!1;const od=({onLogin:e,logo:t,title:r,subtitle:s,apiConfig:n={},useDynamicConfig:a=!0,staticConfig:i=null})=>{const[l,d]=J.useSearchParams();J.useNavigate();const[c,u]=p.useState(null),[f,g]=p.useState(a),[h,m]=p.useState(null),w=l.get("token"),b=l.get("request_id");l.get("next"),p.useLayoutEffect(()=>{if(Fn)return;const x=sessionStorage.getItem("saml_error");if(x){Fn=!0,sessionStorage.removeItem("saml_error");try{const q=JSON.parse(x);y.toast.error(q.message,{duration:5e3})}catch(q){console.error("Failed to parse SAML error:",q)}}},[]);const{authConfig:C,getCustomComponents:S}=Ae(),T=S(),F=et(C),U=$e(C),k=Be(C),L=He(C),A=ft(C),D=ut(C);if(w&&b)return o.jsx(Mn,{logo:t,title:r||"Processing Authentication",subtitle:s||"Please wait while we complete your login",onAuthComplete:x=>{const q=x?.redirect_url||"/app";try{const O=new URL(q,window.location.origin);O.searchParams.delete("token"),O.searchParams.delete("request_id");const I=O.pathname+(O.search?O.search:"");window.location.href=I}catch{window.location.href=q}},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 Y=T?.LoginPage,_=T?.LoginCard;p.useEffect(()=>{a&&!i?$():i&&(u(i),g(!1))},[a,i]);const $=async()=>{try{const x=await W.getAuthConfig();u(x),m(null)}catch(x){console.error("Failed to fetch login methods:",x),u({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}}),m(null),console.warn("Using default auth configuration due to config fetch failure")}finally{g(!1)}},v=()=>f?o.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:o.jsx(y.Spin,{size:"large",tip:"Loading login methods..."})}):h?o.jsx(y.Alert,{message:"Error",description:h,type:"error",showIcon:!0,action:o.jsx("a",{onClick:$,children:"Retry"})}):c&&a?o.jsx(Yc,{onLogin:e}):o.jsx(Qc,{onLogin:e});return Y&&!w&&!b?o.jsx(Y,{}):_?o.jsx(cr.Provider,{value:{onLogin:e||(()=>{})},children:o.jsx(y.Layout,{className:"min-h-screen",style:U,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:F,children:o.jsx(_,{})})})})}):o.jsx(y.Layout,{className:"min-h-screen",style:U,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:F,children:[t&&o.jsx("div",{className:A.className,style:A.style,children:typeof t=="string"?o.jsx("img",{src:t,alt:C?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:D}):t}),o.jsxs("div",{className:"text-center mb-[18px]",children:[o.jsx("h1",{className:"text-3xl font-semibold mb-2",style:k,children:r||"Welcome Back"}),s&&o.jsx("p",{className:"text-base",style:L,children:s})]}),v()]})})})},{Title:On,Text:Dt,Paragraph:nd}=y.Typography,ad=({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(Ir,{size:l*.6})})},id=({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})]}),ld=e=>{const t=e.toLowerCase();return t.includes("admin")?o.jsx(Bi,{size:20}):t.includes("manager")||t.includes("supervisor")?o.jsx(Hi,{size:20}):t.includes("security")||t.includes("compliance")?o.jsx(xo,{size:20}):o.jsx(Ir,{size:20})},rs=({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,d]=p.useState(null),[c,u]=p.useState(!1),{getRoleSelectionConfig:f,getCardConfig:g,authConfig:h}=Ae(),m=f(),w=et(h),b=ft(h),C=ut(h),S=async()=>{if(l){u(!0);try{await r(l)}catch(k){console.error("Role selection failed:",k)}finally{u(!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 k=m?.customEmptyState;return k?o.jsx(k,{}):o.jsx("div",{className:"max-w-lg mx-auto p-5",children:o.jsx("div",{style:w,children:o.jsx(id,{className:"text-center py-12 px-5 text-gray-500",description:o.jsxs("div",{children:[o.jsx(Dt,{className:"text-gray-600 text-base block mb-2",children:m?.emptyStateMessage||"No roles available"}),o.jsx(Dt,{type:"secondary",className:"text-sm",children:"Please contact your administrator for role assignment"})]})})})})}const T=p.isValidElement(m?.title)?m.title:m?.title||n,F=p.isValidElement(m?.subtitle)?m.subtitle:m?.subtitle||a,U=m?.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:h?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:C}):i}),o.jsxs("div",{className:"text-center mb-8",children:[p.isValidElement(T)?T:o.jsx(On,{level:3,className:"!mb-3 !text-2xl !font-semibold !text-gray-800",style:Be(h),children:T}),p.isValidElement(F)?F:o.jsx(nd,{className:"!mb-6 text-base text-gray-600 !leading-relaxed",style:He(h),children:F}),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(ad,{size:"default",className:"bg-blue-500",children:(e.name||e.username||"U").split(" ").map(k=>k[0]).join("").toUpperCase().slice(0,2)}),o.jsxs("div",{className:"text-left",children:[o.jsx(Dt,{strong:!0,className:"text-sm block text-gray-800",children:e.name||e.username||"User"}),e.email&&o.jsx(Dt,{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:m?.maxHeight||"24rem"},children:o.jsx("div",{className:`grid gap-4 grid-cols-${U}`,children:t.map(k=>{const L=m?.customRoleCard;if(L)return o.jsx(L,{role:k,selected:l?.id===k.id,onSelect:()=>d(k)},k.id);const A=m?.roleCardStyling||{},D=l?.id===k.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:D?A.selectedColor||"#e6f7ff":A.backgroundColor||"#ffffff",borderColor:D?A.selectedColor||"#1890ff":"#d9d9d9",borderRadius:A.borderRadius||"16px",...m?.roleCardStyling},onClick:()=>d(k),children:[l?.id===k.id&&o.jsx("div",{className:"absolute -top-2 -right-2 bg-brand-500 rounded-full p-2",children:o.jsx(Ye,{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:ld(k.name)})}),o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-1",children:[o.jsx(On,{level:5,className:"!mb-0 !text-sm !font-semibold !text-gray-900 !leading-tight !line-clamp-2 !text-center",title:k.name,children:k.name}),k.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:m?.recommendedBadgeText||"Recommended"})})]})]},k.id)})})})}),o.jsxs("div",{className:"pt-4 border-t border-gray-200",children:[o.jsx(y.Button,{type:"primary",block:!0,onClick:S,disabled:!l,loading:c,icon:l?o.jsx(Ye,{size:16}):null,className:"w-full",children:l?m?.continueButtonText?.replace("{roleName}",l.name)||`Continue as ${l.name}`:"Please select a role to continue"}),l?.is_default&&o.jsx(Dt,{type:"secondary",className:"block text-center mt-3 text-sm",children:"This is your recommended role based on your permissions"})]})]})})},{Content:cd}=y.Layout,dd=({logo:e,title:t,subtitle:r,apiConfig:s,useDynamicConfig:n=!0,staticConfig:a=null,onLoginSuccess:i,roleSelectionTitle:l,roleSelectionSubtitle:d,initialAuthResult:c=null})=>{const{pendingAuth:u,availableRoles:f,selectRole:g,login:h}=tt(),[m,w]=p.useState(null);p.useEffect(()=>{c&&b(c)},[c]);const b=async S=>{w(null);try{if(S&&(S.status||S.data||S.next_step||S.response)){i&&i(S);return}const T=await h(S),F={email:S.email,username:S.username,phone:S.phone,display:S.email||S.username||S.phone};if(T.requiresRoleSelection)return;i&&i({...T,loginUser:F})}catch(T){throw w(T.message),T}},C=async S=>{try{const T=await g(S);i&&i(T)}catch(T){throw console.error("Role selection failed:",T),T}};if(u&&f){const S=$e(s||a||{});return o.jsx(y.Layout,{className:"min-h-screen",style:S,children:o.jsx(cd,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(rs,{user:u.user,roles:f,onRoleSelect:C,title:l,subtitle:d})})})}return o.jsx(od,{onLogin:b,logo:e,title:t,subtitle:r,apiConfig:s,useDynamicConfig:n,staticConfig:a})},{Content:$t}=y.Layout,Bt=({logo:e,title:t,subtitle:r,apiConfig:s,useDynamicConfig:n=!0,staticConfig:a=null,onAuthComplete:i,roleSelectionTitle:l,roleSelectionSubtitle:d,twoFactorTitle:c,twoFactorSubtitle:u,passwordResetTitle:f,passwordResetSubtitle:g,initialAuthState:h=null,initialRedirectUrl:m=null,skipLoginStep:w=!1,initialNextParam:b=null})=>{const{user:C,pendingAuth:S}=tt(),{authConfig:T}=Ae();ft(T),ut(T);const[F,U]=p.useState(()=>{if(h){let P=null;if(h?.status===401&&h?.data?P=h.data?.next_step:h?.response?.status===401&&h?.response?.data?P=h.response.data?.next_step:h?.next_step?P=h.next_step:P=(h?.response?.data||h?.data||h)?.next_step,P&&P.is_pending)switch(P.id){case"role_selection":return"roleSelection";case"mfa_authenticate":return"twoFactor";case"set_password":case"password_expiry":case"first_login":return"passwordReset"}if(h.roles&&h.roles.length>1)return"roleSelection";if(h.requires2FA)return"twoFactor";if(h.requiresPasswordReset)return"passwordReset"}return"login"}),[k,L]=p.useState(h?.token||null),[A,D]=p.useState(h?.twoFactorMethods||null),[Y,_]=p.useState(h?.passwordResetReason||null),[$]=p.useState(b||null);p.useEffect(()=>{if(h&&F==="login"){let P=null;if(h?.status===401&&h?.data?P=h.data?.next_step:h?.response?.status===401&&h?.response?.data?P=h.response.data?.next_step:h?.next_step?P=h.next_step:P=(h?.response?.data||h?.data||h)?.next_step,P&&P.is_pending)switch(P.id){case"role_selection":let V=[];Array.isArray(P.metadata?.roles)?V=P.metadata.roles:typeof P.metadata?.roles=="object"&&(V=Object.entries(P.metadata.roles).map(([N,Z])=>({id:N,name:Z,is_default:!1})));const K=h?.loginUser,H=h?.user||h?.data?.user||K||{};x({...h,roles:V,user:H,nextStep:P,loginUser:K}),U("roleSelection");break;case"mfa_authenticate":const j=P.metadata?.type?[P.metadata.type]:P.metadata?.methods||["email"];D(j),U("twoFactor");break;case"set_password":case"password_expiry":case"first_login":_(P.metadata?.reason||"Password update required"),x({...h,passwordPolicy:P.metadata?.password_policy}),U("passwordReset");break}else h.roles&&h.roles.length>1?U("roleSelection"):h.requires2FA?(D(h.twoFactorMethods||["email"]),U("twoFactor")):h.requiresPasswordReset&&(_(h.passwordResetReason||"Password reset required"),U("passwordReset"))}},[h,F]);const[v,x]=p.useState(()=>{if(h){let P=null;if(h?.status===401&&h?.data?P=h.data?.next_step:h?.response?.status===401&&h?.response?.data?P=h.response.data?.next_step:h?.next_step?P=h.next_step:P=(h?.response?.data||h?.data||h)?.next_step,P&&P.id==="role_selection"){let V=[];Array.isArray(P.metadata?.roles)?V=P.metadata.roles:typeof P.metadata?.roles=="object"?V=Object.entries(P.metadata.roles).map(([N,Z])=>({id:N,name:Z,is_default:!1})):console.warn("[CompleteAuthFlow] No valid roles found in metadata");const K=h?.loginUser;let H=h?.user||h?.data?.user||K||{};return{...h,roles:V,user:H,nextStep:P,loginUser:K}}}return h||null}),[q]=p.useState(m||null),O=async P=>{let V=P,K=null,H=!1,j=null;P?.status===401&&P?.data?(V=P.data,K=P.data?.next_step,j=P.status,H=P?.meta?.is_authenticated||!1):P?.next_step?(V=P,K=P.next_step,H=P?.meta?.is_authenticated||!1,j=P?.status):P?.response?(j=P.response.status,V=P.response.data,K=V?.next_step,H=P.response.meta?.is_authenticated||!1):(V=P?.response?.data||P?.data||P,K=V?.next_step,H=P?.meta?.is_authenticated||V?.meta?.is_authenticated||!1,j=P?.status||V?.status);const N=P?.loginUser;(P?.token||V?.token)&&L(P.token||V.token);let Z=P?.user||V?.user||N||{};if((typeof Z!="object"||Z===null)&&(Z={}),N&&typeof N=="object"&&(Z={...Z,email:Z.email||N.email,username:Z.username||N.username,phone:Z.phone||N.phone,name:Z.name||N.display}),j===200&&H){y.toast.success("Login successful!"),i&&i({...P,user:Z,authenticated:!0,redirect_url:ge($,V?.redirect_url||P?.redirect_url,"/app")});return}if(K&&K.is_pending)switch(K.id){case"role_selection":let Q=[];Array.isArray(K.metadata.roles)?Q=K.metadata.roles:typeof K.metadata.roles=="object"&&(Q=Object.entries(K.metadata.roles).map(([he,ue])=>({id:he,name:ue,is_default:!1}))),x({...P,roles:Q,user:Z,nextStep:K,loginUser:N}),U("roleSelection");return;case"mfa_authenticate":L(P.token||V?.token);const te=K.metadata?.type?[K.metadata.type]:K.metadata?.methods||["email"];D(te),U("twoFactor");return;case"set_password":L(P.token||V?.token);const re=K.metadata?.password_policy;_(K.metadata?.reason||"Password update required"),x({...P,passwordPolicy:re,user:Z,loginUser:N}),U("passwordReset");return;case"password_expiry":L(P.token||V?.token),_("Your password has expired"),x({...P,passwordPolicy:K.metadata?.password_policy,user:Z,loginUser:N}),U("passwordReset");return;case"first_login":L(P.token||V?.token),_("Please set up your password for first login"),x({...P,passwordPolicy:K.metadata?.password_policy,user:Z,loginUser:N}),U("passwordReset");return;case"login_by_code":L(P.token||V?.token),y.toast.info("OTP verification required"),i&&i({...P,user:Z,requiresOTP:!0});return}if(P.requires2FA){L(P.token),D(P.twoFactorMethods||["email"]),x({...P,user:Z,loginUser:N}),U("twoFactor");return}if(P.requiresPasswordReset){L(P.token),_(P.passwordResetReason||"Your password has expired"),x({...P,user:Z,loginUser:N}),U("passwordReset");return}i&&i({...P,user:Z})},I=async P=>{try{let V=P,K=null,H=!1,j=null;if(P?.status===401&&P?.data?(V=P.data,K=P.data?.next_step,j=P.status,H=P?.meta?.is_authenticated||!1):P?.response?(j=P.response.status,V=P.response.data,K=V?.next_step,H=P.response.meta?.is_authenticated||!1):(V=P?.data||P,K=V?.next_step,H=P?.meta?.is_authenticated||V?.meta?.is_authenticated||!1,j=P?.status||V?.status),j===200&&H){y.toast.success("Two-factor authentication successful!"),i&&i({...P,token:k,user:v?.user,authenticated:!0,redirect_url:ge($,V?.redirect_url||P?.redirect_url,"/app")});return}if(K&&K.is_pending)switch(K.id){case"set_password":const N=K.metadata?.password_policy;_(K.metadata?.reason||"Password reset required"),x({...v,passwordPolicy:N}),U("passwordReset");return;default:console.warn("Unknown next step after 2FA:",K.id);break}if(P.requiresPasswordReset){_(P.passwordResetReason||"Your password has expired"),U("passwordReset");return}y.toast.success("Two-factor authentication successful!"),i&&i({...P,token:k,user:v?.user,authenticated:!0})}catch(V){throw V}},X=async P=>{try{const V=await W.setPassword(P.password);let K=V,H=null,j=!1,N=null;if(V?.status===401&&V?.data?(K=V.data,H=V.data?.next_step,N=V.status,j=V?.meta?.is_authenticated||!1):V?.response?(N=V.response.status,K=V.response.data,H=K?.next_step,j=V.response.meta?.is_authenticated||!1):(K=V?.data||V,H=K?.next_step,j=V?.meta?.is_authenticated||K?.meta?.is_authenticated||!1,N=V?.status||K?.status),N===200&&j){y.toast.success("Password reset successful!"),i&&i({...V,token:k,user:v?.user,authenticated:!0,redirect_url:ge($,K?.redirect_url||V?.redirect_url,"/app")});return}if(H&&H.is_pending)switch(H.id){case"mfa_authenticate":const Z=H.metadata?.type?[H.metadata.type]:H.metadata?.methods||["email"];D(Z),U("twoFactor");return;default:console.warn("Unknown next step after password reset:",H.id);break}y.toast.success("Password reset successful!"),i&&i({...V,token:k,user:v?.user,authenticated:!0})}catch(V){throw y.toast.error(V.message||"Failed to reset password"),V}};return(()=>{if(h&&F==="login"){let P=null;if(h?.status===401&&h?.data?P=h.data?.next_step:h?.response?.status===401&&h?.response?.data?P=h.response.data?.next_step:h?.next_step?P=h.next_step:P=(h?.response?.data||h?.data||h)?.next_step,P&&P.is_pending)return o.jsx(y.Layout,{className:"min-h-screen",style:$e(T),children:o.jsx($t,{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:"Processing authentication..."})})})})}switch(F){case"login":return w?(console.warn("CompleteAuthFlow: in login step but skipLoginStep=true"),null):o.jsx(dd,{onLoginSuccess:O,logo:e,title:t,subtitle:r,apiConfig:s,useDynamicConfig:n,staticConfig:a,roleSelectionTitle:l,roleSelectionSubtitle:d});case"roleSelection":return Array.isArray(v?.roles)&&v.roles.length>0?o.jsx(y.Layout,{className:"min-h-screen",style:$e(T),children:o.jsx($t,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx("div",{className:"w-full",children:o.jsx(rs,{user:v?.user,roles:v?.roles||[],logo:e,onRoleSelect:async K=>{try{const H=await W.selectRole(K.id);let j=H,N=null,Z=!1,Q=null;if(H?.status===401&&H?.data?(j=H.data,N=H.data?.next_step,Q=H.status,Z=H?.meta?.is_authenticated||!1):H?.response?(Q=H.response.status,j=H.response.data,N=j?.next_step,Z=H.response.meta?.is_authenticated||!1):(j=H?.data||H,N=j?.next_step,Z=H?.meta?.is_authenticated||j?.meta?.is_authenticated||!1,Q=H?.status||j?.status),Q===200&&Z){y.toast.success("Role selected successfully!"),i&&i({...H,user:{...v.user,role:K},authenticated:!0,redirect_url:ge($,j?.redirect_url||H?.redirect_url,"/app")});return}if(N&&N.is_pending)switch(N.id){case"mfa_authenticate":const te=N.metadata?.type?[N.metadata.type]:N.metadata?.methods||["email"];D(te),U("twoFactor");return;case"set_password":const re=N.metadata?.password_policy;_(N.metadata?.reason||"Password update required"),x({...v,passwordPolicy:re}),U("passwordReset");return;case"password_expiry":_("Your password has expired"),x({...v,passwordPolicy:N.metadata?.password_policy}),U("passwordReset");return;case"first_login":_("Please set up your password for first login"),x({...v,passwordPolicy:N.metadata?.password_policy}),U("passwordReset");return;case"login_by_code":y.toast.info("OTP verification required"),i&&i({...H,user:{...v.user,role:K},requiresOTP:!0});return;default:console.warn("Unknown next step:",N.id);break}y.toast.success("Role selected successfully!"),i&&i({...H,user:{...v.user,role:K}})}catch(H){throw y.toast.error(H.message||"Failed to select role"),H}},title:l||"Select Your Role",subtitle:d||"Choose a role to continue"})})})}):o.jsx(y.Layout,{className:"min-h-screen",style:$e(T),children:o.jsx($t,{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:$e(T),children:o.jsx($t,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(Tn,{user:v?.user||S?.user||C,availableMethods:A,onVerify:I,title:c,subtitle:u})})});case"passwordReset":const P=v?.passwordPolicy,V=P?{minLength:P.min_length||8,maxLength:P.max_length,requireUppercase:P.require_uppercase||!1,requireLowercase:P.require_lowercase||!1,requireNumbers:P.require_numbers||!1,requireSpecialChars:P.require_special_chars||!1}:void 0;return o.jsx(y.Layout,{className:"min-h-screen",style:$e(T),children:o.jsx($t,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(es,{reason:Y||void 0,onReset:X,title:f,subtitle:g,passwordRules:V})})});default:return null}})()},{Content:ud}=y.Layout,fd=({logo:e,apiConfig:t,onAuthComplete:r,roleSelectionTitle:s,roleSelectionSubtitle:n,twoFactorTitle:a,twoFactorSubtitle:i,passwordResetTitle:l,passwordResetSubtitle:d,redirectPath:c="/"})=>{const[u,f]=p.useState(null),[g,h]=p.useState(!1),m=async C=>{C.requiresRoleSelection||C.requires2FA||C.requiresPasswordReset?(f(C),h(!0)):(C.token&&localStorage.setItem(t?.tokenKey||"authToken",C.token),r&&r(C))},w=C=>{console.error("OAuth callback error:",C)},b=C=>{const S={...u,...C,authMethod:"oauth",provider:u?.provider};r&&r(S)};return g&&u?o.jsx(Bt,{logo:e,apiConfig:t,onAuthComplete:b,roleSelectionTitle:s,roleSelectionSubtitle:n,twoFactorTitle:a,twoFactorSubtitle:i,passwordResetTitle:l,passwordResetSubtitle:d,initialAuthState:{user:u.user,token:u.token,roles:u.roles,requires2FA:u.requires2FA,twoFactorMethods:u.twoFactorMethods,requiresPasswordReset:u.requiresPasswordReset,passwordResetReason:u.passwordResetReason}}):o.jsx(y.Layout,{className:"min-h-screen",style:$e(t||{}),children:o.jsx(ud,{className:"flex justify-center items-center min-h-screen p-5",children:o.jsx(Bc,{onSuccess:m,onError:w,apiConfig:t,redirectPath:c,logo:e,roleSelectionTitle:s,roleSelectionSubtitle:n,twoFactorTitle:a,twoFactorSubtitle:i,passwordResetTitle:l,passwordResetSubtitle:d})})})},ss=()=>tt(),{Header:bh,Content:os}=y.Layout,hd=({backgroundStyle:e,mergedConfig:t,apiConfig:r})=>{J.useNavigate();const[s,n]=p.useState(!1),[a,i]=p.useState(null);p.useEffect(()=>{let f=!0;return(async()=>{const h=new URLSearchParams(window.location.search),m=h.get("token"),w=h.get("request_id");if(m&&w){if(!f)return;n(!0);try{const b=await W.getSAMLAuthMeta(m,w);if(!f)return;if(b?.code==="user_not_found"){sessionStorage.setItem("saml_error",JSON.stringify({message:b.message||"User does not exist",timestamp:Date.now()})),window.location.href="/app/login";return}i(b)}catch(b){if(!f)return;console.error("[LoginWrapper] SAML callback error:",b),y.toast.error("Failed to process SSO authentication")}finally{f&&n(!1)}}})(),()=>{f=!1}},[]);const l=sessionStorage.getItem("pendingAuthResult");sessionStorage.getItem("pendingAuthStep");let d=a;if(!d&&l)try{d=JSON.parse(l),sessionStorage.removeItem("pendingAuthResult"),sessionStorage.removeItem("pendingAuthStep")}catch(f){console.error("Failed to parse pending auth result:",f)}const c=async f=>{y.toast.success("Authentication complete!");try{const g=Oe(window.location.search),h=f?.redirect_url||f?.response?.data?.redirect_url,m=ge(g,h,"/app");console.log("[LoginRouter] Redirecting to:",m),window.location.pathname.startsWith("/app/login")&&(window.location.href=m)}catch(g){console.error("[LoginRouter] Error handling auth completion:",g),window.location.href="/app"}},u=p.useMemo(()=>{const g=new URLSearchParams(window.location.search).get("next");return g?decodeURIComponent(g):null},[]);return s?o.jsx("div",{style:{...e,minHeight:"100vh"},children:o.jsx(y.Layout,{className:"min-h-screen",style:e,children:o.jsx(os,{className:"flex justify-center items-center min-h-screen",children:o.jsx(y.Card,{className:"w-full max-w-md shadow-lg rounded-lg",bordered:!1,children: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:"Processing SSO authentication..."})]})})})})}):o.jsx("div",{style:{...e,minHeight:"100vh"},children:o.jsx(Bt,{onAuthComplete:c,logo:t.logo,title:t.title,subtitle:t.subtitle,apiConfig:r,useDynamicConfig:!0,roleSelectionTitle:t.roleSelectionTitle,roleSelectionSubtitle:t.roleSelectionSubtitle,twoFactorTitle:t.twoFactorTitle,twoFactorSubtitle:t.twoFactorSubtitle,passwordResetTitle:t.passwordResetTitle,passwordResetSubtitle:t.passwordResetSubtitle,initialAuthState:d,skipLoginStep:!!a,initialNextParam:u})})},pd=({authConfig:e,backgroundStyle:t,mergedConfig:r})=>{const{forgotPassword:s}=ss();et(e);const n=async a=>{try{await s(a);const i=e?.resetPassword?.forgotPassword?.successMessage||"Reset email sent successfully!";y.toast.success(i)}catch(i){const l=e?.resetPassword?.forgotPassword?.errorMessage||i.message||"Failed to send reset email";y.toast.error(l)}};return o.jsx(y.Layout,{style:{...t,minHeight:"100vh"},children:o.jsx(os,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:o.jsx(Dc,{onSubmit:n,authConfig:e,logo:r.logo})})})},gd=({authConfig:e,backgroundStyle:t,mergedConfig:r,basePath:s})=>{const{resetPassword:n}=ss(),{key:a}=J.useParams();et(e);const i=J.useNavigate();if(p.useEffect(()=>{a||i(s)},[a,i,s]),!a)return null;const l=async d=>{};return o.jsx(y.Layout,{style:{...t,minHeight:"100vh"},children:o.jsx(os,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:o.jsx($c,{onSubmit:l,authConfig:e,token:a,logo:r.logo})})})},ns={},as={},is={"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"}},qt={"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}]},Un=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=qt[s]||qt.default,l=is[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 ns[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(ns[s]===r.otp){delete ns[s];const a=qt[s]||qt.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,...is["admin@example.com"]||{}};if(t.includes("2fa/send")){const s=Math.floor(Math.random()*9e5+1e5).toString().slice(0,6);return as[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(as[r.method]===r.otp){delete as[r.method];const a=is["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:qt["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{}}}}),md=({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:d="Two-Factor Authentication",twoFactorSubtitle:c="Please enter your verification code",passwordResetTitle:u="Reset Password",passwordResetSubtitle:f="Please enter your new password"})=>{const{authConfig:g}=Le();J.useLocation(),J.useNavigate();const[h,m]=p.useState(null),{setBasePath:w}=lr();p.useEffect(()=>{w(e)},[e,w]),p.useEffect(()=>(g&&Oc(g),()=>{Uc()}),[g]);const b=p.useMemo(()=>{const F=g?.login||{},U=g?.logo||{};return{logo:U.url?o.jsx("img",{src:U.url,alt:U.alt||"Logo",style:{width:U.width||"auto",height:U.height||"auto",...U.style},className:U.className}):s,title:F.title||n,subtitle:F.subtitle||a,roleSelectionTitle:g?.roleSelection?.title||i,roleSelectionSubtitle:g?.roleSelection?.subtitle||l,twoFactorTitle:g?.twoFactor?.title||d,twoFactorSubtitle:g?.twoFactor?.subtitle||c,passwordResetTitle:g?.resetPassword?.resetForm?.title||u,passwordResetSubtitle:g?.resetPassword?.resetForm?.subtitle||f}},[g,s,n,a,i,l,d,c,u,f]),C=p.useMemo(()=>$e(g),[g]),S=F=>{m(F),r&&r(F)},T=p.useMemo(()=>Un(),[]);return e.endsWith("/")&&e.slice(0,-1),o.jsx(Pn,{authConfig:g,children:o.jsx(An,{config:T,children:o.jsxs(J.Routes,{children:[o.jsx(J.Route,{path:"/",element:o.jsx(hd,{backgroundStyle:C,mergedConfig:b,apiConfig:T})}),o.jsx(J.Route,{path:"forgot-password",element:o.jsx(pd,{authConfig:g,backgroundStyle:C,mergedConfig:b})}),o.jsx(J.Route,{path:"reset-password/:key",element:o.jsx(gd,{authConfig:g,backgroundStyle:C,mergedConfig:b,basePath:e})}),o.jsx(J.Route,{path:"reset-password",element:o.jsx(J.Navigate,{to:"/app",replace:!0})}),o.jsx(J.Route,{path:"/oauth/callback",element:o.jsx("div",{style:{...C,minHeight:"100vh"},children:o.jsx(fd,{logo:b.logo,apiConfig:Un(),onAuthComplete:F=>{(async()=>{const k=F?.response?.data?.redirect_url;k&&(window.location.href=k)})()},roleSelectionTitle:b.roleSelectionTitle,roleSelectionSubtitle:b.roleSelectionSubtitle,twoFactorTitle:b.twoFactorTitle,twoFactorSubtitle:b.twoFactorSubtitle,passwordResetTitle:b.passwordResetTitle,passwordResetSubtitle:b.passwordResetSubtitle})})}),o.jsx(J.Route,{path:"/saml",element:o.jsx(Mn,{logo:o.jsx(Vi,{size:48,style:{color:"#1890ff"}}),onAuthComplete:F=>{const k=new URLSearchParams(window.location.search).get("next"),L=ge(k,F?.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"})}),o.jsx(J.Route,{path:"/complete",element:o.jsx(Bt,{authData:h,apiConfig:t,logo:s,onComplete:S,roleSelectionTitle:i,roleSelectionSubtitle:l,twoFactorTitle:d,twoFactorSubtitle:c,passwordResetTitle:u,passwordResetSubtitle:f})}),o.jsx(J.Route,{path:"*",element:o.jsx(J.Navigate,{to:"/404",replace:!0})})]})})})},wd=({layout:e="column",gap:t,className:r,buttonTextPrefix:s="Continue with",buttonTextPostfix:n=""})=>{const[a,i]=p.useState(!0),[l,d]=p.useState(null),{getProvidersConfig:c,getCustomComponents:u}=Ae();if(p.useEffect(()=>{(async()=>{try{const D=await W.getAuthConfig();d(D)}catch(D){console.error("Failed to load auth config:",D)}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=W.isSSOEnabled(),g=W.isOIDCEnabled(),h=W.getSSOProviders(),m=W.getOIDCProviders();if(!f&&!g||h.length===0&&m.length===0)return null;const b=u()?.ProviderButton,C=[...h.map(A=>({...A,providerType:"sso"})),...m.map(A=>({...A,providerType:"oidc"}))],T=C.length===1,U=`gap-${t??(e==="grid"?3:2)}`,L=`w-full ${(()=>{if(T)return"";switch(e){case"grid":return`grid grid-cols-1 sm:grid-cols-2 ${U}`;case"row":return`flex flex-row flex-wrap ${U}`;case"column":default:return`flex flex-col ${U}`}})()} ${r||""}`.trim();return o.jsx("div",{className:L,children:C.map((A,D)=>{const Y=b||ze;return o.jsx(Y,{provider:A,type:A.providerType,prefix:s,postfix:n},`${A.providerType}-${D}`)})})},In=e=>{if(e?.status===401&&e?.data?.next_step)return e.data.next_step;if(e?.next_step)return e.next_step;const t=e?.response?.data||e?.data||e;return t?.next_step?t.next_step:null},yd=({onSuccess:e,showRememberMe:t=!0,submitButtonText:r})=>{const[s,n]=p.useState(!1),[a,i]=p.useState(null),[l,d]=p.useState("email"),[c,u]=p.useState(0),[f,g]=p.useState(!1),{authConfig:h}=tt(),{getLoginConfig:m,getMessagesConfig:w,authConfig:b}=Ae(),C=ts(),S=b||h;Be(S);const T=He(S),F=_n(S);if(p.useEffect(()=>{(async()=>{try{await W.getAuthConfig();const x=W.getAllowedUsernames();if(x&&x.length>0){const q=x.includes("email"),O=x.includes("mobile");q?d("email"):O&&d("mobile")}g(!0)}catch(x){console.error("Failed to load auth config:",x),g(!0)}})()},[]),!f)return o.jsx("div",{className:"flex justify-center items-center min-h-[200px]",children:o.jsx(y.Spin,{size:"large"})});const U=W.getAllowedUsernames(),k=U.includes("email"),L=U.includes("mobile"),A=k&&L,D=v=>{const x=w();return v==="email"?[{required:!0,message:x?.validation?.required||"Please enter your email address"},{type:"email",message:x?.validation?.invalidEmail||"Please enter a valid email address!"}]:[{required:!0,message:x?.validation?.required||"Please input your mobile number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:x?.validation?.invalidMobile||"Please enter a valid mobile number with country code (e.g., +919876543210)"}]},Y=async v=>{n(!0),i(null);try{const x=l==="email"?{email:v.username,password:v.password}:{phone:v.username,password:v.password},O={...await W.login(x),loginUser:{email:l==="email"?v.username:void 0,phone:l==="mobile"?v.username:void 0,username:v.username,display:v.username}},I=In(O);if(I&&I.is_pending){if(e){e(O);return}if(C?.onLogin){C.onLogin(O);return}console.warn("PasswordLoginForm: Multi-step auth required but no parent handler found");return}const X=O?.meta?.is_authenticated||O?.response?.meta?.is_authenticated;if((O?.status||O?.response?.status)===200&&X){if(e){e(O);return}if(C?.onLogin){C.onLogin(O);return}const P=Oe(window.location.search),V=O?.redirect_url||O?.response?.data?.redirect_url,K=ge(P,V,"/app");window.location.href=K;return}if(e){e(O);return}if(C?.onLogin){C.onLogin(O);return}console.warn("PasswordLoginForm: No onSuccess prop or LoginContext found. Authentication result not handled.")}catch(x){const q=w(),O=x?.response?.data?.message||x?.message||q?.error?.login||"Login failed. Please check your credentials and try again.";i(O)}finally{n(!1)}},_=v=>{const x=m(),q=w();return o.jsxs(y.Form,{name:`${v}-password-login`,className:"w-full",onFinish:Y,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:D(v),children:o.jsx(y.Input,{placeholder:v==="email"?x?.formPlaceholders?.email||"Email address":x?.formPlaceholders?.mobile||"Mobile number (+919876543210)",autoComplete:v==="email"?"email":"tel",onKeyDown:v==="mobile"?O=>{const I=["Backspace","Delete","Tab","Enter","ArrowLeft","ArrowRight"],X=O.key;!I.includes(X)&&!/[0-9+]/.test(X)&&O.preventDefault()}:void 0})}),o.jsx(y.FormItem,{name:"password",rules:[{required:!0,message:q?.validation?.required||"Please input your password!"},{min:h?.password_policy?.min_length||6,message:q?.validation?.passwordTooShort||`Password must be at least ${h?.password_policy?.min_length||6} characters long`}],children:o.jsx(y.PasswordInput,{placeholder:x?.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:x?.showRememberMe!==!1&&t&&W.isRememberMeEnabled()&&o.jsx(y.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:o.jsx("div",{className:"auth-remember-me",style:T,children:o.jsx(y.Checkbox,{label:x?.rememberMeText||"Remember me"})})})}),o.jsx("div",{children:W.isForgotPasswordEnabled()&&o.jsx(J.Link,{to:"forgot-password",className:"text-sm transition-colors duration-300",style:F,children:x?.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||x?.submitButtonText||"Sign in"})})]},`${v}-${c}`)};if(A){const v=[...k?[{key:"email",label:"Email",children:_("email")}]:[],...L?[{key:"mobile",label:"Mobile",children:_("mobile")}]:[]];return o.jsx("div",{className:"w-full",children:o.jsx(y.Tabs,{activeKey:l,onChange:x=>{d(x),u(q=>q+1),i(null)},items:v,className:"password-login-tabs"})})}return _(k?"email":"mobile")},bd=({onSuccess:e,onBack:t,submitButtonText:r,verifyButtonText:s,resendButtonText:n})=>{const[a,i]=p.useState(!1),[l,d]=p.useState(null),c=ts(),u=f=>{const g=In(f);if(g&&g.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 h=f?.meta?.is_authenticated||f?.response?.meta?.is_authenticated;if((f?.status||f?.response?.status)===200&&h){const w=Oe(window.location.search),b=f?.redirect_url||f?.response?.data?.redirect_url,C=ge(w,b,"/app");window.location.href=C;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(Qr,{onSuccess:u,onBack:t,submitButtonText:r,verifyButtonText:s,resendButtonText:n})},dr=({basePath:e="/app"})=>{const t=Lt();return o.jsx("div",{className:"page-container",children:o.jsx(md,{basePath:e,apiConfig:t})})},vd=async(e=[])=>{const t=Mi(e),r={login:{component:dr,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?p.createElement(l):p.createElement(Or,{componentName:a})}},404:{component:Tt,standalone:!0,includeBasePath:!1,propsBuilder:()=>({})},default:{component:Tt,includeBasePath:!1,standalone:!0,propsBuilder:({pageType:n})=>({message:`Unknown page type: ${n}`})}};for(const n of t){const a=Fi(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},Cd=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)},Dn=async e=>{const t=Cd(e);return vd(t)},$n=p.createContext(void 0);let ur=!1;typeof window<"u"&&(ur=!1);const Le=()=>{const e=p.useContext($n);if(!e)throw new Error("useAppContext must be used within AppProvider");return e},Bn=({children:e,config:t={},layoutConfig:r={},topbarConfig:s={},navbarConfig:n={},customComponents:a={},authConfig:i={}})=>{const l=J.useNavigate(),d=J.useLocation(),[c,u]=p.useState(null),[f,g]=p.useState(!0),[h,m]=p.useState(null),[w,b]=p.useState(null),[C,S]=p.useState(null),[T,F]=p.useState(!1),[U,k]=p.useState(null),L=()=>typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",A=t,D=A.apiConfig||{};p.useEffect(()=>{const _={colors:{primary:"#5048ed",secondary:"#6d7280",success:"#10b981",warning:"#f59e0b",error:"#f04438",gray:"#6d7280",background:"#f9fafb",text:"#252b37"}},$="default-theme-variables";let v=document.getElementById($);v||(v=document.createElement("style"),v.id=$,document.head.appendChild(v)),v.innerHTML=`:root { ${Gt(_)} }`},[]),p.useEffect(()=>{const _=nt.getCachedLogo();_&&b(_.base64Data||_.url)},[]),p.useEffect(()=>((async()=>{if(window.location.pathname.startsWith("/app/login"),!ur){ur=!0;try{const v=await Js(),x=v.success?v.response:null;if(!v.success)throw new Error(v.response?.message||"Failed to fetch app data");if(u(x),x?.theme){const q=document.getElementById("default-theme-variables");if(q)q.innerHTML=`:root { ${Gt(x.theme)} }`;else{const O=document.createElement("style");O.id="default-theme-variables",O.innerHTML=`:root { ${Gt(x.theme)} }`,document.head.appendChild(O)}x?.app_logo&&nt.updateInBackground(x.app_logo,x.app_name,O=>{O.base64Data&&b(O.base64Data)})}}catch(v){console.error("❌ fetchAppInitData error:",v),m(v.message)}finally{g(!1),ur=!1}}})(),()=>{}),[]),p.useEffect(()=>{if(f||!c)return;const _=d.pathname,$=d.search,v=_==="/app/configuration-error",x=_==="/app/logout",q=j=>{if(!j)return"";const N=new URLSearchParams(j);N.delete("token"),N.delete("request_id");const Z=N.toString();return Z?`?${Z}`:""},O=q($);if(O!==$&&!x){l(_+O,{replace:!0});return}if(x)return;const I=c.menu&&c.menu.length>0,X=c.routes&&c.routes.length>0;c.profile_info?.user_role;const oe=c.is_user_anonymous,P=!c.is_user_anonymous,V=X&&c.routes.some(j=>{const N=j.path;if(_===N)return!0;if(N?.includes(":")){const Z=N.replace(/:[^/]+/g,"[^/]+");if(new RegExp(`^${Z}(/.*)?$`).test(_))return!0}return!!_.startsWith(N+"/")}),K=j=>{const N=q($),Z=N?`${j}${N}`:j;l(Z,{replace:!0})};if(P&&!I&&!v){K("/app/configuration-error");return}const H=_==="/app/login"||_.startsWith("/app/login/");if(oe&&!I&&!H){const j=new URLSearchParams($);_!=="/app"&&_!=="/app/"&&j.set("next",_+$);const N=j.toString();l(`/app/login${N?`?${N}`:""}`,{replace:!0});return}if(I&&c.menu){if(sessionStorage.getItem("saml_auth_in_progress")){sessionStorage.removeItem("saml_auth_in_progress");return}const N=c.menu[0]?.path||c.menu[0]?.uri;if(_==="/app"||_==="/app/"||!V&&!v){const Q=Oe($);if(Q&&xt(Q)){l(Q,{replace:!0});return}if(N){K(N);return}}}},[f,c,d.pathname,d.search,l]),p.useEffect(()=>{let _=!1;return(async()=>{if(!f&&c){if(c.is_user_anonymous){const{default:v}=await Promise.resolve().then(function(){return Ef});if(c.routes&&c.routes.length>0)try{_||F(!0);const x=await Dn(c.routes);_||(S(x),F(!1));return}catch(x){console.error("❌ Failed to create registry from routes for anonymous user:",x)}_||(S(v),F(!1));return}if(!c.routes||c.routes.length===0){_||(S({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),F(!1));return}try{_||(F(!0),k(null));const v=await Dn(c.routes);_||(S(v),F(!1))}catch(v){console.error("❌ Failed to create dynamic page registry:",v),_||(k(v.message||"Failed to create page registry"),S({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),F(!1))}}})(),()=>{_=!0}},[c,f]);const Y={appData:c,loading:f,error:h,config:A,apiConfig:D,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:C,registryLoading:T,registryError:U,initializerEndpoint:L()};return o.jsx($n.Provider,{value:Y,children:e})},qn=()=>{const e=J.useNavigate(),{routes:t}=Le(),r=p.useCallback(n=>{if(!n)return!1;const a=n.endsWith("/")&&n!=="/"?n.slice(0,-1):n;return t.some(i=>{const l=i.path,d=l.endsWith("/")&&l!=="/"?l.slice(0,-1):l;if(d===a)return!0;if(d.includes(":")){const c=d.split("/").map(f=>f.startsWith(":")?"[^/]+":f).join("/");return new RegExp(`^${c}(/.*)?$`).test(a)}return i.exact===!1?a.startsWith(d):!1})},[t]);return{navigateTo:p.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}},fr=({to:e,children:t,className:r,onClick:s,...n})=>{const{isInternalRoute:a}=qn(),i=d=>{s&&s(d)};return!(e&&(e.startsWith("http://")||e.startsWith("https://")))&&a(e)?o.jsx(J.Link,{to:e,className:r,onClick:i,...n,children:t}):o.jsx("a",{href:e,className:r,onClick:i,...n,children:t})},hr=(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)})})},xd=({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(fr,{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(Ls,{logoUrl:e,appName:t,height:"28px",linkTo:r})})},Vn=({menuItems:e=[],appLogo:t,theme:r={},config:s={}})=>{const n=J.useLocation(),[a,i]=p.useState({}),{appName:l}=Le(),d=p.useRef(null);p.useEffect(()=>{if(!d.current)return;const _=d.current.querySelector("#wideSidebarMenu");if(!_)return;_.querySelectorAll("li").forEach(v=>{const x=v.classList.contains("active"),q="var(--color-gray-700, #414651)",O="var(--color-brand-500, #5048ED)";hr(v,x?O:q);const I=()=>{v.classList.contains("active")||hr(v,O)},X=()=>{v.classList.contains("active")||hr(v,q)};return v.addEventListener("mouseenter",I),v.addEventListener("mouseleave",X),()=>{v.removeEventListener("mouseenter",I),v.removeEventListener("mouseleave",X)}})},[n.pathname,e]);const c=(_,$)=>{const v=_.url||_.uri,x=v?.endsWith("/")?v:`${v}/`,q=$.endsWith("/")?$:`${$}/`;return x===q?!0:_.children?.length?_.children.some(O=>{const I=O.url||O.uri;return(I?.endsWith("/")?I:`${I}/`)===q}):!1},u=_=>{i($=>({...$,[_]:!$[_]}))};p.useEffect(()=>{const _={};e.forEach($=>{$.children?.length&&c($,n.pathname)&&(_[$.name]=!0)}),i(_)},[n.pathname,e]);const f=_=>_.icon?_.icon.includes("<svg")?o.jsx("span",{className:"navbar-icon",dangerouslySetInnerHTML:{__html:_.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(_.icon)||_.icon.length<=4?o.jsx("span",{className:"navbar-icon navbar-icon-emoji",children:_.icon}):o.jsx("span",{className:"navbar-icon",children:o.jsx("img",{src:_.icon,alt:_.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:g=!0,showMenu:h=!0,isCollapsed:m=!1,collapsible:w=!1,customLogo:b=null,customMenuContent:C=null,customBottomContent:S=null,customNavbar:T=null,customMenu:F=null,menuConfig:U={},className:k="",style:L={}}=s,[A,D]=p.useState(m),Y=A?"80px":"244px";return o.jsxs("nav",{ref:d,className:`navbar ${A?"collapsed-sidebar":"wide-sidebar"} ${k}`,style:{width:Y,...L,display:"flex",flexDirection:"column",transition:"width 0.3s ease"},children:[g&&(b?o.jsx("div",{className:"navbar-logo-container frame-logo-container",children:b}):o.jsx(xd,{appLogo:t,appName:l,collapsed:A})),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:()=>D(!A),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:_=>_.target.style.backgroundColor="var(--color-gray-100, #f3f4f6)",onMouseLeave:_=>_.target.style.backgroundColor="transparent",title:A?"Expand navbar":"Collapse navbar",children:o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:A?"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:h&&(F||o.jsxs(o.Fragment,{children:[o.jsx("ul",{className:"navbar-menu wide-sidebar-menu",id:"wideSidebarMenu",children:e.map(_=>{const $=_.url||_.uri,v=c(_,n.pathname),x=a[_.name]||!1,q=_.children&&_.children.length>0;return o.jsxs(p.Fragment,{children:[o.jsx("li",{className:`menu-list-item ${q?"menu-list-item-with-sub-menu":""} ${v?"active":""}`,children:q?o.jsxs("div",{className:"menu-item",onClick:()=>!A&&u(_.name),style:{justifyContent:A?"center":"flex-start",padding:A?"8px":void 0},title:A?_.name:void 0,children:[f(_),!A&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:`menu-title ${v?"font-semibold":""}`,children:_.name}),o.jsx("div",{className:`flex justify-center items-center h-full transition-transform duration-300 ease-in-out ${v&&x?"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(fr,{to:$,className:"menu-item",style:{justifyContent:A?"center":"flex-start",padding:A?"8px":void 0},title:A?_.name:void 0,children:[f(_),!A&&o.jsx("span",{className:`menu-title ${v?"font-semibold":""}`,children:_.name})]})}),q&&!A&&o.jsx("ul",{className:`submenu-list ${x?"active":""}`,children:_.children.map(O=>{const I=O.url||O.uri,X=n.pathname===I||n.pathname===`${I}/`;return o.jsx("li",{className:"submenu-list-item",children:o.jsxs(fr,{to:I,className:`submenu-item d-flex ${X?"selected-each-wide-submenu":""}`,children:[o.jsx("span",{className:"submenu-item-icon-container",children:X?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 ${X?"text-[var(--color-brand-500,#5048ED)]":"text-[var(--color-gray-700,#414651)]"}`,children:O.name})]})},I)})})]},_.name)})}),C&&!A&&o.jsx("div",{className:"custom-menu-content",style:{paddingTop:"8px"},children:C})]}))}),S&&o.jsx("div",{className:"navbar-bottom-content",style:{marginTop:"auto",flexShrink:0},children:S})]})},Sd=(e=!0)=>{const[t,r]=p.useState(null),[s,n]=p.useState(!1),[a,i]=p.useState(null),[l,d]=p.useState(!1),[c,u]=p.useState(!1),f=async()=>{if(!(!e||t&&!l)){n(!0),i(null);try{const h=await Xs();if(h.success&&h.response){const m=h.response.profile_data||h.response;h.response.password_policy&&!m.password_policy&&(m.password_policy=h.response.password_policy),u(h.response.should_set_password||!1),r(m),i(null)}else{const m=h.response?.message||"Failed to fetch profile data";i(m),console.error("Profile API Error:",h)}}catch(h){const m=h.message||"Network error while fetching profile";i(m),console.error("Profile fetch error:",h)}finally{n(!1),d(!0)}}},g=()=>{d(!1),f()};return p.useEffect(()=>{e&&!l&&f()},[e]),{profileData:t,loading:s,error:a,refetch:g,shouldSetPassword:c}},We=(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};`)},ls=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},jn=(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},Hn=()=>{const e=ls("zangocookie");return e!==null&&e!==""},zn=Object.freeze({__proto__:null,deleteCookie:We,getCookie:ls,isAuthenticatedViaCookie:Hn,setCookie:jn}),cs=async(e={})=>{try{const t=await ro();if(t.success||t.responseStatus===401){We("zangocookie","/"),We("zangocookie","/app"),We("zangocookie","/app/"),We("zangocookie");const r=window.location.hostname;if(We("zangocookie","/",r),We("zangocookie","/app",r),r.includes(".")){const a="."+r.split(".").slice(-2).join(".");We("zangocookie","/",a),We("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)}},Wn=e=>{const t=document.createElement("div");t.style.cssText=`
|
|
148
148
|
position: fixed;
|
|
149
149
|
top: 0;
|
|
150
150
|
left: 0;
|
|
@@ -192,12 +192,12 @@ export default App;`,m=`mkdir -p ${l}`,g={container:{padding:"32px",maxWidth:"90
|
|
|
192
192
|
transition: all 0.2s;
|
|
193
193
|
">Log Out</button>
|
|
194
194
|
</div>
|
|
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)},Wn=({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,x]=h.useState(!1),[P,L]=h.useState(null),[M,B]=h.useState([]),[E,_]=h.useState(null),{appData:k}=Ne(),{profileData:O,loading:V,error:v,refetch:I,shouldSetPassword:A}=yd(e),[C,$]=h.useState({name:"",email:"",mobile:"",roles:[],currentRole:"",lastPasswordChange:"Never",nextPasswordDue:null}),[F,S]=h.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[D,z]=h.useState({}),[Z,Y]=h.useState({}),[X,G]=h.useState(""),[W,U]=h.useState(!1),[Q,te]=h.useState(null),[re,oe]=h.useState({minLength:!1,hasUpperCase:!1,hasLowerCase:!1,hasNumber:!1,hasSpecialChar:!1}),ve=async()=>{x(!0),L(null);try{const j=await Js();if(j.success&&j.response){const R=j.response.data||j.response;w(R),L(null)}else{const R=j.response?.message||"Failed to fetch sessions";L(R),console.error("Sessions API Error:",j)}}catch(j){const R=j.message||"Network error while fetching sessions";L(R),console.error("Sessions fetch error:",j)}finally{x(!1)}};h.useEffect(()=>{if(O){let j=O.last_password_changed||"Never",R=null;if(O.last_password_changed&&O?.password_policy?.password_expiry_days){const xs=new Date(O.last_password_changed),ze=new Date(xs);ze.setDate(ze.getDate()+O.password_policy.password_expiry_days),ze>new Date?R=ze.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):R="Expired"}$({name:O.name||"",email:O.email||"",mobile:O.mobile||"",roles:O.roles||[],currentRole:k?.profile_info?.user_role||O.roles?.[0]?.name||"Admin",lastPasswordChange:j,nextPasswordDue:R}),f(O.auth_config?.two_factor_auth?.required||!1);const ne=O?.can_set_password;g(ne),O.profile_pic&&c(O.profile_pic);let ie=null;O.auth_config?.password_policy?ie=O.auth_config.password_policy:O.password_policy&&(ie=O.password_policy),ie&&_(ie),O.tokens&&B(O.tokens)}O&&O.tokens&&B(O.tokens),k?.sessions?.tokens&&B(k.sessions.tokens),k?.password_policy&&_(k.password_policy)},[O,k]);const he=(j,R)=>{const ne=j.user_agent||j.browser_agent||"Unknown Browser",ie=j.ip||j.location||"Unknown Location",xs=j.created_at,ze=j.last_seen_at,ja=Ce=>Ce.includes("Chrome")?"Chrome":Ce.includes("Firefox")?"Firefox":Ce.includes("Safari")?"Safari":Ce.includes("Edge")?"Edge":"Unknown Browser",Ef=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",Ha=Ce=>{if(!Ce)return"Unknown";const Ss=Ce.replace(" IST",""),Ps=new Date(Ss),Nf=new Date().getTime()-Ps.getTime(),Sr=Math.floor(Nf/1e3),Pr=Math.floor(Sr/60),kr=Math.floor(Pr/60),ks=Math.floor(kr/24);return ks>0?`${ks} day${ks>1?"s":""} ago`:kr>0?`${kr} hour${kr>1?"s":""} ago`:Pr>0?`${Pr} minute${Pr>1?"s":""} ago`:Sr>0?`${Sr} second${Sr>1?"s":""} ago`:"Just now"},_f=ja(ne),za=Ef(ne),Af=()=>{if(j.is_current)return!0;if(!ze)return!1;const Ce=typeof ze=="string"?ze.replace(" IST",""):ze,Ss=new Date(Ce),Ps=new Date(Date.now()-3600*1e3);return Ss>Ps};return{...j,deviceName:`${_f} on ${za}`,os:za,location:ie==="127.0.0.1"?"Local Device":ie,sessionStartTime:Ha(xs),lastSeen:Ha(ze),isActive:Af()}};h.useEffect(()=>{const{newPassword:j}=F;oe(E?{minLength:j.length>=(E.min_length||8),hasUpperCase:E.require_uppercase?/[A-Z]/.test(j):!0,hasLowerCase:E.require_lowercase?/[a-z]/.test(j):!0,hasNumber:E.require_numbers?/[0-9]/.test(j):!0,hasSpecialChar:E.require_special_chars?/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(j):!0}:{minLength:j.length>=8,hasUpperCase:/[A-Z]/.test(j),hasLowerCase:/[a-z]/.test(j),hasNumber:/[0-9]/.test(j),hasSpecialChar:/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(j)})},[F.newPassword,E]);const[ue,de]=h.useState(e);h.useEffect(()=>{e&&!ue&&(I&&I(),ve(),a(!1),l(!1),z({}),Y({}),G(""),S({currentPassword:"",newPassword:"",confirmPassword:""})),de(e)},[e,ue,I]),h.useEffect(()=>{r==="security"&&e&&ve()},[r,e]);const Le=j=>{const{name:R,value:ne}=j.target;$(ie=>({...ie,[R]:ne})),z(ie=>({...ie,[R]:""}))},ht=j=>{const{name:R,value:ne}=j.target;S(ie=>({...ie,[R]:ne})),Y(ie=>({...ie,[R]:""}))},xr=()=>{const j={};return C.name.trim()||(j.name="Name is required"),j},Ge=async j=>{const R=j.target.files?.[0];if(R){const ne=new FormData;ne.append("profile_pic",R);try{const ie=await qt(ne);ie.success?(c(ie.response?.profile_pic||URL.createObjectURL(R)),G("Profile photo updated successfully!")):G(ie.response?.message||"Failed to upload photo")}catch{G("Failed to upload photo")}}},Cs=async()=>{try{const j=!d,R={two_factor_auth:{required:j}},ne=new FormData;ne.append("auth_config",JSON.stringify(R));const ie=await qt(ne);ie.success?(f(j),G(`Two-factor authentication ${j?"enabled":"disabled"}`),y.toast.success({title:"Two-Factor Authentication Updated",description:`Two-factor authentication ${j?"enabled":"disabled"} successfully`,duration:3e3})):(G(ie.response?.message||"Failed to update two-factor authentication"),y.toast.error({title:"Update Failed",description:ie.response?.message||"Failed to update two-factor authentication",duration:5e3}))}catch{G("Failed to update two-factor authentication"),y.toast.error({title:"Update Error",description:"An error occurred while updating two-factor authentication",duration:5e3})}},Va=async j=>{try{const R=await Qs(j);R.success?(ve(),G("Session logged out successfully")):G(R.response?.message||"Failed to logout session")}catch{G("Failed to logout session")}},vf=async()=>{try{const j=p.filter(ne=>!ne.is_current).map(ne=>ne.id),R=await Rs(j);R.success?(G("All other sessions logged out successfully"),ve()):G(R.response?.message||"Failed to logout all sessions")}catch{G("Failed to logout all sessions")}},Cf=()=>{const j={};return!A&&!F.currentPassword&&(j.currentPassword="Current password is required"),F.newPassword?Object.values(re).some(ne=>!ne)&&(j.newPassword="Password must meet all requirements"):j.newPassword=A?"Password is required":"New password is required",F.newPassword!==F.confirmPassword&&(j.confirmPassword="Passwords do not match"),j},xf=async j=>{j.preventDefault();const R=xr();if(Object.keys(R).length>0){z(R);return}U(!0),G("");try{const ne=new FormData;ne.append("name",C.name);const ie=await qt(ne);ie.success?(G("Name updated successfully!"),a(!1),setTimeout(()=>{G("")},3e3)):G(ie.response?.message||"Failed to update name")}catch{G("An error occurred. Please try again.")}finally{U(!1)}},Sf=async j=>{j.preventDefault();const R=Cf();if(Object.keys(R).length>0){Y(R);return}U(!0),G("");try{const ne={new_password:F.newPassword};A||(ne.current_password=F.currentPassword);const ie=await Xs(ne);ie.success?(G(A?"Password set successfully!":"Password changed successfully!"),S({currentPassword:"",newPassword:"",confirmPassword:""}),l(!1),I&&I(),setTimeout(()=>{G("")},3e3)):G(ie.response?.message||"Failed to change password")}catch{G("An error occurred. Please try again.")}finally{U(!1)}},Pf=async j=>{te(j);try{const R=await Ys(j);R.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:R.response?.message||"Failed to switch role",duration:5e3}),te(null))}catch{y.toast.error({title:"Role Switch Error",description:"An error occurred while switching role",duration:5e3}),te(null)}},kf=()=>{zn(()=>{is({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"})]})})}),V&&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..."})]}),W&&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..."})]})}),v&&!V&&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:v}),o.jsx("button",{onClick:I,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}),!V&&!v&&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"}):C.name?o.jsx("span",{className:"profile-initials",children:C.name.split(" ").map(j=>j[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:Ge,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:C.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:C.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),G("")},children:"Account"}),o.jsx("button",{className:`profile-tab ${r==="security"?"active":""}`,onClick:()=>{s("security"),l(!1),G("")},children:"Security"})]}),X&&o.jsx("div",{className:`profile-alert ${X.includes("successfully")?"success":"error"}`,children:o.jsx("span",{children:X})}),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:[!C.name&&!C.email&&!C.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:xf,className:"profile-inline-form",children:[o.jsx("input",{type:"text",name:"name",className:"profile-form-input",value:C.name,onChange:Le,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),z({}),$(j=>({...j,name:O?.name||""}))},children:"Cancel"}),o.jsx("button",{type:"submit",className:"profile-save-btn",disabled:W,children:W?"Saving...":"Save"})]}),D.name&&o.jsx("div",{className:"profile-form-error",children:D.name})]}):o.jsx("div",{className:"profile-field-value",children:C.name||o.jsx("span",{className:"empty-value",children:"Click edit to add your name"})})]}),C.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"})}),C.email]})]}),C.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"})}),C.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:C.roles&&C.roles.length>0?C.roles.map((j,R)=>o.jsxs("div",{className:`role-item ${j.name===C.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:j.name})]}),j.name===C.currentRole?o.jsx("span",{className:"role-badge",children:"Current"}):o.jsx("button",{className:"role-switch-btn",onClick:()=>Pf(j.id),disabled:Q!==null,children:Q===j.id?"Switching...":"Switch"})]},j.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:C.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:kf,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: ",C.lastPasswordChange,C.nextPasswordDue&&o.jsxs(o.Fragment,{children:[" • ",o.jsxs("span",{className:C.nextPasswordDue==="Expired"?"password-expired":"",children:["Next due: ",C.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),S({currentPassword:"",newPassword:"",confirmPassword:""}),Y({})},children:A?"Set Password":"Change Password"})]}),i&&o.jsxs("form",{onSubmit:Sf,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:F.currentPassword,onChange:ht,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:F.newPassword,onChange:ht,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 ${re.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 ${re.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 ${re.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 ${re.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 ${re.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:F.confirmPassword,onChange:ht,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),Y({}),S({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),o.jsx("button",{type:"submit",className:"profile-submit-btn",disabled:W,children:W?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:Cs,children:"Enable"}),d&&O?.auth_config?.two_factor_auth?.can_disable===!0&&o.jsx("button",{className:"toggle-btn enabled",onClick:Cs,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..."})]}):P?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:P}),o.jsx("button",{onClick:ve,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}):p.length>0?p.map((j,R)=>{const ne=he(j);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:ne.deviceName}),j.is_current?o.jsx("span",{className:"session-status-tag current",children:"Current"}):ne.isActive?o.jsx("button",{className:"logout-tag-btn logout-tag-btn-ghost",onClick:()=>Va(j.id),children:"Logout"}):o.jsx("button",{className:"logout-tag-btn",onClick:()=>Va(j.id),children:"Logout"})]}),o.jsxs("p",{className:"session-details",children:[ne.os," • ",ne.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: ",ne.sessionStartTime]}),o.jsx("p",{className:"session-last-active",children:ne.isActive?"Active now":`Last seen: ${ne.lastSeen}`})]})})]},j.id||R)}):o.jsx("p",{className:"no-sessions",children:"No active sessions found"})}),p.length>1&&o.jsx("button",{className:"logout-all-btn",onClick:vf,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:M&&M.length>0?M.map((j,R)=>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:[j.role," - Bearer Token"]}),o.jsx("p",{className:"token-type",children:"Type: Bearer Authentication Token"}),o.jsxs("p",{className:"token-created",children:["Created: ",new Date(j.created).toLocaleDateString()]}),j.expiry?o.jsxs("p",{className:"token-expiry",children:["Expires: ",new Date(j.expiry).toLocaleDateString()]}):o.jsx("p",{className:"token-expiry",children:"Expires: Never"})]})]})})},R)):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"})]})})]})]})})]})})]})]})},bd=({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"})]}),vd=({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"})]}),Kn=({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);J.useNavigate(),h.useEffect(()=>{const F=S=>{f.current&&!f.current.contains(S.target)&&(n(!1),i(!1))};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[]);const m=()=>{n(!s),s||i(!1)},g=()=>{zn(()=>{is({theme:t})})},p=F=>{window.location.href=F},w=e?.current_role||e?.user_role,b=e?.other_roles||[],{showProfile:x=!0,showLeftSection:P=!0,showRightSection:L=!0,customLeftContent:M=null,customRightContent:B=null,customProfileMenu:E=null,customViewProfile:_=null,profileMenuConfig:k={},className:O="",style:V={}}=r,{showViewProfile:v=!0,showLogout:I=!0,showRoleSwitch:A=!0,customMenuItems:C=[]}=k,$=()=>{u(!0),n(!1)};return o.jsxs("header",{className:`topbar header-container ${O}`,style:V,children:[o.jsxs("div",{className:"topbar-content",children:[P&&o.jsx("div",{className:"topbar-left",children:M||null}),L&&o.jsxs("div",{className:"topbar-right",children:[B,x&&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=${ho("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((F,S)=>o.jsxs("div",{className:"dropdown-item profile-each-role",onClick:()=>p(F.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:F.label})]},S))})}),o.jsx("li",{children:o.jsx("hr",{className:"profile-dropdown-divider"})}),C.map((F,S)=>o.jsx("li",{children:F},S)),v&&o.jsx("li",{children:o.jsx(vd,{onViewProfile:$})}),I&&o.jsx("li",{children:o.jsx(bd,{onLogout:g})})]})]})]})]}),_?_({user:e,isOpen:l,onClose:()=>u(!1)}):o.jsx(Wn,{isOpen:l,onClose:()=>u(!1),profileData:c})]})},Cd={showTopbar:!0,showNavbar:!0,layoutType:"wide"},xd={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:{}},Sd={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:{}},dr=(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]=dr(e[s],t[s]):r[s]=e[s]}),r},Zn=()=>{const{loading:e,error:t,menu:r,profileInfo:s,appLogo:n,theme:a={},layoutConfig:i={},topbarConfig:l={},navbarConfig:u={},customComponents:c={}}=Ne(),d=J.useLocation(),f=dr(i,Cd),m=dr(l,xd),g=dr(u,Sd),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(),k=setTimeout(()=>{const O=Date.now()-_;O>=E?w():setTimeout(w,E-O)},500);return()=>{clearTimeout(k)}},[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",x=f.showNavbar&&a?.menu_config?.display_sidebar!==!1,P=f.showTopbar,L=c?.Layout,M=c?.Topbar||m.customTopbar,B=c?.Navbar||g.customNavbar;return L?o.jsx(L,{menu:r,profileInfo:s,appLogo:n,theme:a,layoutConfig:f,topbarConfig:m,navbarConfig:g,children:o.jsx(J.Outlet,{})}):o.jsx("div",{className:`layout layout-${b}`,children:o.jsxs("main",{className:"layout-wrapper",children:[x&&(B?o.jsx(B,{menuItems:r,appLogo:n,theme:a,config:g}):o.jsx(qn,{menuItems:r,appLogo:n,theme:a,config:g})),o.jsxs("div",{className:"layout-main",style:{width:x?`calc(100vw - ${g.isCollapsed?"80px":"244px"})`:"100vw",transition:"width 0.3s ease"},children:[P&&(M?o.jsx(M,{profileInfo:s,theme:a,config:m}):o.jsx(Kn,{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(J.Outlet,{})]})]})]})})},Pd=(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)},Ut=({customPages:e={},forceRoute:t})=>{const r=J.useLocation(),{routes:s,pageTypeRegistry:n,registryLoading:a,registryError:i,initializerEndpoint:l}=Ne(),u=_t(),[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 x=b;if(s&&s.length>0){for(const P of s)if(b===P.path||b.startsWith(P.path+"/")){x=P.path;break}}d({pageType:r.state.page_type,customPagePath:r.state.custom_page_path||null,matchedRoutePath:x,loading:!1});return}if(s&&s.length>0){const x=[...s].sort((P,L)=>{const M=P.path.split("/").filter(E=>E).length;return L.path.split("/").filter(E=>E).length-M});for(const P of x){let L=J.matchPath({path:P.path,exact:!0},b);if(!L&&b.startsWith(P.path+"/")){const M=P.path.endsWith("/*")?P.path:`${P.path}/*`;L=J.matchPath({path:M,exact:!1},b)}if(L){d({pageType:P.page_type,customPagePath:P.component||null,matchedRoutePath:P.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:Pd(f,n,{matchedRoutePath:g,customPagePath:m,customPages:e,location:r,apiConfig:u})},p)},Gn=()=>{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 $t(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},kd=({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),x=h.useRef(()=>{}),P=h.useRef(()=>{}),L=h.useRef(()=>{}),M=h.useRef(()=>{});h.useEffect(()=>{p.current=t,w.current=r,b.current=s},[t,r,s]),h.useEffect(()=>{g.current=n},[n]);const B=["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(),is({preserveCurrentPath:!0})},[E]),k=h.useCallback(()=>{a(!1),d.current&&(clearInterval(d.current),d.current=null),m.current=!1},[]),O=h.useCallback(()=>{const{warn_after:S,expire_after:D}=e,z=D-S;if(m.current)return;l(z),m.current=!0;const Z=new Date;Z.setSeconds(Z.getSeconds()+z),d.current=setInterval(()=>{const Y=new Date().getTime(),X=Z.getTime()-Y,G=Math.floor(X/1e3);G>0?l(G):(d.current&&(clearInterval(d.current),d.current=null),l(0))},1e3)},[e]),V=h.useCallback(()=>{d.current&&(clearInterval(d.current),d.current=null),m.current=!1;const S=e.expire_after-e.warn_after;l(S)},[e]),v=h.useCallback(S=>{if(S==="logout"||S?.response==="logout"){_();return}x.current()},[_]);h.useLayoutEffect(()=>{L.current=v},[v]);const I=h.useCallback(async()=>{const S=Math.floor((new Date().getTime()-u.current.getTime())/1e3);try{const D=await ro(e.ping_url,S);D.success?L.current(D.response):x.current()}catch{x.current()}},[e.ping_url]);h.useLayoutEffect(()=>{P.current=I},[I]);const A=h.useCallback(()=>{E();const S=Math.floor((new Date().getTime()-u.current.getTime())/1e3),{warn_after:D,expire_after:z}=e;let Z;if(S>=z){_();return}else S>=D?(m.current||O(),a(!0),w.current&&w.current(),Z=z-S):(k(),m.current&&V(),Z=D-S);const Y=Math.min(Z*1e3,2147483647);c.current=setTimeout(()=>{P.current()},Y)},[e,E,_,O,k,V]);h.useLayoutEffect(()=>{x.current=A},[A]);const C=h.useCallback(()=>{const S=new Date;if(S.getTime()-u.current.getTime()<1e3)return;const D=Math.floor((S.getTime()-u.current.getTime())/1e3);if(u.current=S,D>=e.expire_after){_();return}g.current&&(P.current(),k()),b.current&&b.current()},[e.expire_after,_,k]);h.useLayoutEffect(()=>{M.current=C},[C]);const $=h.useCallback(()=>{u.current=new Date,k(),P.current()},[k]),F=h.useCallback(()=>{_()},[_]);return h.useEffect(()=>{if(!e.enabled)return;const S=()=>M.current();return B.forEach(D=>{document.addEventListener(D,S,!0)}),x.current(),()=>{B.forEach(D=>{document.removeEventListener(D,S,!0)}),c.current&&(clearTimeout(c.current),c.current=null),d.current&&(clearInterval(d.current),d.current=null)}},[e.enabled]),{showWarning:n,countdown:i,hideWarning:k,renewSession:$,logoutNow:F}};function tt(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 Xn(...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 ut(...e){return T.useCallback(Xn(...e),e)}function Ed(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 _d(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,Ad(n,...t)]}function Ad(...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 Dt=globalThis?.document?T.useLayoutEffect:()=>{},Nd=T[" useId ".trim().toString()]||(()=>{}),Ld=0;function ls(e){const[t,r]=T.useState(Nd());return Dt(()=>{r(s=>s??String(Ld++))},[e]),e||(t?`radix-${t}`:"")}var Td=T[" useInsertionEffect ".trim().toString()]||Dt;function Od({prop:e,defaultProp:t,onChange:r=()=>{},caller:s}){const[n,a,i]=Fd({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=Md(d)?d(e):d;f!==e&&i.current?.(f)}else a(d)},[l,e,a,i]);return[u,c]}function Fd({defaultProp:e,onChange:t}){const[r,s]=T.useState(e),n=T.useRef(r),a=T.useRef(t);return Td(()=>{a.current=t},[t]),T.useEffect(()=>{n.current!==r&&(a.current?.(r),n.current=r)},[r,n]),[r,s,a]}function Md(e){return typeof e=="function"}function Yn(e){const t=Id(e),r=T.forwardRef((s,n)=>{const{children:a,...i}=s,l=T.Children.toArray(a),u=l.find(Dd);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 Id(e){const t=T.forwardRef((r,s)=>{const{children:n,...a}=r;if(T.isValidElement(n)){const i=$d(n),l=Bd(a,n.props);return n.type!==T.Fragment&&(l.ref=s?Xn(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 Ud=Symbol("radix.slottable");function Dd(e){return T.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ud}function Bd(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 $d(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 qd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ze=qd.reduce((e,t)=>{const r=Yn(`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 Vd(e,t){e&&Za.flushSync(()=>e.dispatchEvent(t))}function Bt(e){const t=T.useRef(e);return T.useEffect(()=>{t.current=e}),T.useMemo(()=>(...r)=>t.current?.(...r),[])}function jd(e,t=globalThis?.document){const r=Bt(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 Hd="DismissableLayer",cs="dismissableLayer.update",zd="dismissableLayer.pointerDownOutside",Wd="dismissableLayer.focusOutside",Qn,Rn=T.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ea=T.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:n,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...u}=e,c=T.useContext(Rn),[d,f]=T.useState(null),m=d?.ownerDocument??globalThis?.document,[,g]=T.useState({}),p=ut(t,_=>f(_)),w=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),x=w.indexOf(b),P=d?w.indexOf(d):-1,L=c.layersWithOutsidePointerEventsDisabled.size>0,M=P>=x,B=Gd(_=>{const k=_.target,O=[...c.branches].some(V=>V.contains(k));!M||O||(n?.(_),i?.(_),_.defaultPrevented||l?.())},m),E=Jd(_=>{const k=_.target;[...c.branches].some(V=>V.contains(k))||(a?.(_),i?.(_),_.defaultPrevented||l?.())},m);return jd(_=>{P===c.layers.size-1&&(s?.(_),!_.defaultPrevented&&l&&(_.preventDefault(),l()))},m),T.useEffect(()=>{if(d)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Qn=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),ta(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Qn)}},[d,m,r,c]),T.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),ta())},[d,c]),T.useEffect(()=>{const _=()=>g({});return document.addEventListener(cs,_),()=>document.removeEventListener(cs,_)},[]),o.jsx(Ze.div,{...u,ref:p,style:{pointerEvents:L?M?"auto":"none":void 0,...e.style},onFocusCapture:tt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:tt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:tt(e.onPointerDownCapture,B.onPointerDownCapture)})});ea.displayName=Hd;var Kd="DismissableLayerBranch",Zd=T.forwardRef((e,t)=>{const r=T.useContext(Rn),s=T.useRef(null),n=ut(t,s);return T.useEffect(()=>{const a=s.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),o.jsx(Ze.div,{...e,ref:n})});Zd.displayName=Kd;function Gd(e,t=globalThis?.document){const r=Bt(e),s=T.useRef(!1),n=T.useRef(()=>{});return T.useEffect(()=>{const a=l=>{if(l.target&&!s.current){let u=function(){ra(zd,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 Jd(e,t=globalThis?.document){const r=Bt(e),s=T.useRef(!1);return T.useEffect(()=>{const n=a=>{a.target&&!s.current&&ra(Wd,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 ta(){const e=new CustomEvent(cs);document.dispatchEvent(e)}function ra(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?Vd(n,a):n.dispatchEvent(a)}var ds="focusScope.autoFocusOnMount",us="focusScope.autoFocusOnUnmount",sa={bubbles:!1,cancelable:!0},Xd="FocusScope",oa=T.forwardRef((e,t)=>{const{loop:r=!1,trapped:s=!1,onMountAutoFocus:n,onUnmountAutoFocus:a,...i}=e,[l,u]=T.useState(null),c=Bt(n),d=Bt(a),f=T.useRef(null),m=ut(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(L){if(g.paused||!l)return;const M=L.target;l.contains(M)?f.current=M:rt(f.current,{select:!0})},b=function(L){if(g.paused||!l)return;const M=L.relatedTarget;M!==null&&(l.contains(M)||rt(f.current,{select:!0}))},x=function(L){if(document.activeElement===document.body)for(const B of L)B.removedNodes.length>0&&rt(l)};document.addEventListener("focusin",w),document.addEventListener("focusout",b);const P=new MutationObserver(x);return l&&P.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",b),P.disconnect()}}},[s,l,g.paused]),T.useEffect(()=>{if(l){ia.add(g);const w=document.activeElement;if(!l.contains(w)){const x=new CustomEvent(ds,sa);l.addEventListener(ds,c),l.dispatchEvent(x),x.defaultPrevented||(Yd(ru(na(l)),{select:!0}),document.activeElement===w&&rt(l))}return()=>{l.removeEventListener(ds,c),setTimeout(()=>{const x=new CustomEvent(us,sa);l.addEventListener(us,d),l.dispatchEvent(x),x.defaultPrevented||rt(w??document.body,{select:!0}),l.removeEventListener(us,d),ia.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,x=document.activeElement;if(b&&x){const P=w.currentTarget,[L,M]=Qd(P);L&&M?!w.shiftKey&&x===M?(w.preventDefault(),r&&rt(L,{select:!0})):w.shiftKey&&x===L&&(w.preventDefault(),r&&rt(M,{select:!0})):x===P&&w.preventDefault()}},[r,s,g.paused]);return o.jsx(Ze.div,{tabIndex:-1,...i,ref:m,onKeyDown:p})});oa.displayName=Xd;function Yd(e,{select:t=!1}={}){const r=document.activeElement;for(const s of e)if(rt(s,{select:t}),document.activeElement!==r)return}function Qd(e){const t=na(e),r=aa(t,e),s=aa(t.reverse(),e);return[r,s]}function na(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 aa(e,t){for(const r of e)if(!Rd(r,{upTo:t}))return r}function Rd(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 eu(e){return e instanceof HTMLInputElement&&"select"in e}function rt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&eu(e)&&t&&e.select()}}var ia=tu();function tu(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=la(e,t),e.unshift(t)},remove(t){e=la(e,t),e[0]?.resume()}}}function la(e,t){const r=[...e],s=r.indexOf(t);return s!==-1&&r.splice(s,1),r}function ru(e){return e.filter(t=>t.tagName!=="A")}var su="Portal",ca=T.forwardRef((e,t)=>{const{container:r,...s}=e,[n,a]=T.useState(!1);Dt(()=>a(!0),[]);const i=r||n&&globalThis?.document?.body;return i?Es.createPortal(o.jsx(Ze.div,{...s,ref:t}),i):null});ca.displayName=su;function ou(e,t){return T.useReducer((r,s)=>t[r][s]??r,e)}var ur=e=>{const{present:t,children:r}=e,s=nu(t),n=typeof r=="function"?r({present:s.isPresent}):T.Children.only(r),a=ut(s.ref,au(n));return typeof r=="function"||s.isPresent?T.cloneElement(n,{ref:a}):null};ur.displayName="Presence";function nu(e){const[t,r]=T.useState(),s=T.useRef(null),n=T.useRef(e),a=T.useRef("none"),i=e?"mounted":"unmounted",[l,u]=ou(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return T.useEffect(()=>{const c=fr(s.current);a.current=l==="mounted"?c:"none"},[l]),Dt(()=>{const c=s.current,d=n.current;if(d!==e){const m=a.current,g=fr(c);e?u("MOUNT"):g==="none"||c?.display==="none"?u("UNMOUNT"):u(d&&m!==g?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,u]),Dt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=g=>{const w=fr(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=fr(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 fr(e){return e?.animationName||"none"}function au(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 fs=0;function iu(){T.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??da()),document.body.insertAdjacentElement("beforeend",e[1]??da()),fs++,()=>{fs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),fs--}},[])}function da(){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 He=function(){return He=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},He.apply(this,arguments)};function ua(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 lu(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 hr="right-scroll-bar-position",pr="width-before-scroll-bar",cu="with-scroll-bars-hidden",du="--removed-body-scroll-bar-size";function hs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function uu(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 fu=typeof window<"u"?T.useLayoutEffect:T.useEffect,fa=new WeakMap;function hu(e,t){var r=uu(null,function(s){return e.forEach(function(n){return hs(n,s)})});return fu(function(){var s=fa.get(r);if(s){var n=new Set(s),a=new Set(e),i=r.current;n.forEach(function(l){a.has(l)||hs(l,null)}),a.forEach(function(l){n.has(l)||hs(l,i)})}fa.set(r,e)},[e]),r}function pu(e){return e}function gu(e,t){t===void 0&&(t=pu);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 mu(e){e===void 0&&(e={});var t=gu(null);return t.options=He({async:!0,ssr:!1},e),t}var ha=function(e){var t=e.sideCar,r=ua(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,He({},r))};ha.isSideCarExport=!0;function wu(e,t){return e.useMedium(t),ha}var pa=mu(),ps=function(){},gr=T.forwardRef(function(e,t){var r=T.useRef(null),s=T.useState({onScrollCapture:ps,onWheelCapture:ps,onTouchMoveCapture:ps}),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,x=e.as,P=x===void 0?"div":x,L=e.gapMode,M=ua(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),B=m,E=hu([r,t]),_=He(He({},M),n);return T.createElement(T.Fragment,null,d&&T.createElement(B,{sideCar:pa,removeScrollBar:c,shards:f,noRelative:g,noIsolation:p,inert:w,setCallbacks:a,allowPinchZoom:!!b,lockRef:r,gapMode:L}),i?T.cloneElement(T.Children.only(l),He(He({},_),{ref:E})):T.createElement(P,He({},_,{className:u,ref:E}),l))});gr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gr.classNames={fullWidth:pr,zeroRight:hr};var yu=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function bu(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=yu();return t&&e.setAttribute("nonce",t),e}function vu(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Cu(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var xu=function(){var e=0,t=null;return{add:function(r){e==0&&(t=bu())&&(vu(t,r),Cu(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Su=function(){var e=xu();return function(t,r){T.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},ga=function(){var e=Su(),t=function(r){var s=r.styles,n=r.dynamic;return e(s,n),null};return t},Pu={left:0,top:0,right:0,gap:0},gs=function(e){return parseInt(e||"",10)||0},ku=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[gs(r),gs(s),gs(n)]},Eu=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Pu;var t=ku(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])}},_u=ga(),vt="data-scroll-locked",Au=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(
|
|
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)},Kn=({isOpen:e,onClose:t})=>{const[r,s]=p.useState("account"),[n,a]=p.useState(!1),[i,l]=p.useState(!1),[d,c]=p.useState(null),[u,f]=p.useState(!1),[g,h]=p.useState(!0),[m,w]=p.useState([]),[b,C]=p.useState(!1),[S,T]=p.useState(null),[F,U]=p.useState([]),[k,L]=p.useState(null),{appData:A}=Le(),{profileData:D,loading:Y,error:_,refetch:$,shouldSetPassword:v}=Sd(e),[x,q]=p.useState({name:"",email:"",mobile:"",roles:[],currentRole:"",lastPasswordChange:"Never",nextPasswordDue:null}),[O,I]=p.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[X,oe]=p.useState({}),[P,V]=p.useState({}),[K,H]=p.useState(""),[j,N]=p.useState(!1),[Z,Q]=p.useState(null),[te,re]=p.useState({minLength:!1,hasUpperCase:!1,hasLowerCase:!1,hasNumber:!1,hasSpecialChar:!1}),he=async()=>{C(!0),T(null);try{const z=await Ys();if(z.success&&z.response){const R=z.response.data||z.response;w(R),T(null)}else{const R=z.response?.message||"Failed to fetch sessions";T(R),console.error("Sessions API Error:",z)}}catch(z){const R=z.message||"Network error while fetching sessions";T(R),console.error("Sessions fetch error:",z)}finally{C(!1)}};p.useEffect(()=>{if(D){let z=D.last_password_changed||"Never",R=null;if(D.last_password_changed&&D?.password_policy?.password_expiry_days){const Ps=new Date(D.last_password_changed),Ze=new Date(Ps);Ze.setDate(Ze.getDate()+D.password_policy.password_expiry_days),Ze>new Date?R=Ze.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):R="Expired"}q({name:D.name||"",email:D.email||"",mobile:D.mobile||"",roles:D.roles||[],currentRole:A?.profile_info?.user_role||D.roles?.[0]?.name||"Admin",lastPasswordChange:z,nextPasswordDue:R}),f(D.auth_config?.two_factor_auth?.required||!1);const ne=D?.can_set_password;h(ne),D.profile_pic&&c(D.profile_pic);let ie=null;D.auth_config?.password_policy?ie=D.auth_config.password_policy:D.password_policy&&(ie=D.password_policy),ie&&L(ie),D.tokens&&U(D.tokens)}D&&D.tokens&&U(D.tokens),A?.sessions?.tokens&&U(A.sessions.tokens),A?.password_policy&&L(A.password_policy)},[D,A]);const ue=(z,R)=>{const ne=z.user_agent||z.browser_agent||"Unknown Browser",ie=z.ip||z.location||"Unknown Location",Ps=z.created_at,Ze=z.last_seen_at,Ha=xe=>xe.includes("Chrome")?"Chrome":xe.includes("Firefox")?"Firefox":xe.includes("Safari")?"Safari":xe.includes("Edge")?"Edge":"Unknown Browser",Of=xe=>xe.includes("Mac")?"macOS":xe.includes("Windows")?"Windows":xe.includes("Linux")?"Linux":xe.includes("iPhone")||xe.includes("iOS")?"iOS":xe.includes("Android")?"Android":"Unknown OS",za=xe=>{if(!xe)return"Unknown";const _s=xe.replace(" IST",""),ks=new Date(_s),Df=new Date().getTime()-ks.getTime(),Er=Math.floor(Df/1e3),Ar=Math.floor(Er/60),Nr=Math.floor(Ar/60),Es=Math.floor(Nr/24);return Es>0?`${Es} day${Es>1?"s":""} ago`:Nr>0?`${Nr} hour${Nr>1?"s":""} ago`:Ar>0?`${Ar} minute${Ar>1?"s":""} ago`:Er>0?`${Er} second${Er>1?"s":""} ago`:"Just now"},Uf=Ha(ne),Wa=Of(ne),If=()=>{if(z.is_current)return!0;if(!Ze)return!1;const xe=typeof Ze=="string"?Ze.replace(" IST",""):Ze,_s=new Date(xe),ks=new Date(Date.now()-3600*1e3);return _s>ks};return{...z,deviceName:`${Uf} on ${Wa}`,os:Wa,location:ie==="127.0.0.1"?"Local Device":ie,sessionStartTime:za(Ps),lastSeen:za(Ze),isActive:If()}};p.useEffect(()=>{const{newPassword:z}=O;re(k?{minLength:z.length>=(k.min_length||8),hasUpperCase:k.require_uppercase?/[A-Z]/.test(z):!0,hasLowerCase:k.require_lowercase?/[a-z]/.test(z):!0,hasNumber:k.require_numbers?/[0-9]/.test(z):!0,hasSpecialChar:k.require_special_chars?/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(z):!0}:{minLength:z.length>=8,hasUpperCase:/[A-Z]/.test(z),hasLowerCase:/[a-z]/.test(z),hasNumber:/[0-9]/.test(z),hasSpecialChar:/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(z)})},[O.newPassword,k]);const[fe,de]=p.useState(e);p.useEffect(()=>{e&&!fe&&($&&$(),he(),a(!1),l(!1),oe({}),V({}),H(""),I({currentPassword:"",newPassword:"",confirmPassword:""})),de(e)},[e,fe,$]),p.useEffect(()=>{r==="security"&&e&&he()},[r,e]);const Te=z=>{const{name:R,value:ne}=z.target;q(ie=>({...ie,[R]:ne})),oe(ie=>({...ie,[R]:""}))},gt=z=>{const{name:R,value:ne}=z.target;I(ie=>({...ie,[R]:ne})),V(ie=>({...ie,[R]:""}))},kr=()=>{const z={};return x.name.trim()||(z.name="Name is required"),z},Xe=async z=>{const R=z.target.files?.[0];if(R){const ne=new FormData;ne.append("profile_pic",R);try{const ie=await Wt(ne);ie.success?(c(ie.response?.profile_pic||URL.createObjectURL(R)),H("Profile photo updated successfully!")):H(ie.response?.message||"Failed to upload photo")}catch{H("Failed to upload photo")}}},Ss=async()=>{try{const z=!u,R={two_factor_auth:{required:z}},ne=new FormData;ne.append("auth_config",JSON.stringify(R));const ie=await Wt(ne);ie.success?(f(z),H(`Two-factor authentication ${z?"enabled":"disabled"}`),y.toast.success({title:"Two-Factor Authentication Updated",description:`Two-factor authentication ${z?"enabled":"disabled"} successfully`,duration:3e3})):(H(ie.response?.message||"Failed to update two-factor authentication"),y.toast.error({title:"Update Failed",description:ie.response?.message||"Failed to update two-factor authentication",duration:5e3}))}catch{H("Failed to update two-factor authentication"),y.toast.error({title:"Update Error",description:"An error occurred while updating two-factor authentication",duration:5e3})}},ja=async z=>{try{const R=await eo(z);R.success?(he(),H("Session logged out successfully")):H(R.response?.message||"Failed to logout session")}catch{H("Failed to logout session")}},Af=async()=>{try{const z=m.filter(ne=>!ne.is_current).map(ne=>ne.id),R=await to(z);R.success?(H("All other sessions logged out successfully"),he()):H(R.response?.message||"Failed to logout all sessions")}catch{H("Failed to logout all sessions")}},Nf=()=>{const z={};return!v&&!O.currentPassword&&(z.currentPassword="Current password is required"),O.newPassword?Object.values(te).some(ne=>!ne)&&(z.newPassword="Password must meet all requirements"):z.newPassword=v?"Password is required":"New password is required",O.newPassword!==O.confirmPassword&&(z.confirmPassword="Passwords do not match"),z},Lf=async z=>{z.preventDefault();const R=kr();if(Object.keys(R).length>0){oe(R);return}N(!0),H("");try{const ne=new FormData;ne.append("name",x.name);const ie=await Wt(ne);ie.success?(H("Name updated successfully!"),a(!1),setTimeout(()=>{H("")},3e3)):H(ie.response?.message||"Failed to update name")}catch{H("An error occurred. Please try again.")}finally{N(!1)}},Tf=async z=>{z.preventDefault();const R=Nf();if(Object.keys(R).length>0){V(R);return}N(!0),H("");try{const ne={new_password:O.newPassword};v||(ne.current_password=O.currentPassword);const ie=await Qs(ne);ie.success?(H(v?"Password set successfully!":"Password changed successfully!"),I({currentPassword:"",newPassword:"",confirmPassword:""}),l(!1),$&&$(),setTimeout(()=>{H("")},3e3)):H(ie.response?.message||"Failed to change password")}catch{H("An error occurred. Please try again.")}finally{N(!1)}},Mf=async z=>{Q(z);try{const R=await Rs(z);R.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:R.response?.message||"Failed to switch role",duration:5e3}),Q(null))}catch{y.toast.error({title:"Role Switch Error",description:"An error occurred while switching role",duration:5e3}),Q(null)}},Ff=()=>{Wn(()=>{cs({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"})]})})}),Y&&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..."})]}),j&&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..."})]})}),_&&!Y&&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:_}),o.jsx("button",{onClick:$,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}),!Y&&!_&&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:[d?o.jsx("img",{src:d,alt:"Profile",className:"profile-avatar-img"}):x.name?o.jsx("span",{className:"profile-initials",children:x.name.split(" ").map(z=>z[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:Xe,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:x.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:x.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),H("")},children:"Account"}),o.jsx("button",{className:`profile-tab ${r==="security"?"active":""}`,onClick:()=>{s("security"),l(!1),H("")},children:"Security"})]}),K&&o.jsx("div",{className:`profile-alert ${K.includes("successfully")?"success":"error"}`,children:o.jsx("span",{children:K})}),X.general&&o.jsx("div",{className:"profile-alert error",children:o.jsx("span",{children:X.general})}),o.jsx("div",{className:"profile-tab-content",children:r==="account"?o.jsxs("div",{className:"account-section",children:[!x.name&&!x.email&&!x.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:Lf,className:"profile-inline-form",children:[o.jsx("input",{type:"text",name:"name",className:"profile-form-input",value:x.name,onChange:Te,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),oe({}),q(z=>({...z,name:D?.name||""}))},children:"Cancel"}),o.jsx("button",{type:"submit",className:"profile-save-btn",disabled:j,children:j?"Saving...":"Save"})]}),X.name&&o.jsx("div",{className:"profile-form-error",children:X.name})]}):o.jsx("div",{className:"profile-field-value",children:x.name||o.jsx("span",{className:"empty-value",children:"Click edit to add your name"})})]}),x.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"})}),x.email]})]}),x.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"})}),x.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:x.roles&&x.roles.length>0?x.roles.map((z,R)=>o.jsxs("div",{className:`role-item ${z.name===x.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:z.name})]}),z.name===x.currentRole?o.jsx("span",{className:"role-badge",children:"Current"}):o.jsx("button",{className:"role-switch-btn",onClick:()=>Mf(z.id),disabled:Z!==null,children:Z===z.id?"Switching...":"Switch"})]},z.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:x.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:Ff,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:[g&&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",k&&!k.allow_change&&o.jsx("span",{className:"password-disabled-badge",children:"Disabled"})]}),!v&&o.jsxs("p",{className:"security-subtitle",children:["Last changed: ",x.lastPasswordChange,x.nextPasswordDue&&o.jsxs(o.Fragment,{children:[" • ",o.jsxs("span",{className:x.nextPasswordDue==="Expired"?"password-expired":"",children:["Next due: ",x.nextPasswordDue]})]})]}),v&&o.jsx("p",{className:"security-subtitle",children:"Set your password to secure your account"})]}),!i&&k?.allow_change!==!1&&o.jsx("button",{className:"profile-field-edit-btn",onClick:()=>{l(!0),I({currentPassword:"",newPassword:"",confirmPassword:""}),V({})},children:v?"Set Password":"Change Password"})]}),i&&o.jsxs("form",{onSubmit:Tf,className:"password-form",children:[!v&&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:O.currentPassword,onChange:gt,placeholder:"Enter current password",autoComplete:"new-password"}),P.currentPassword&&o.jsx("div",{className:"profile-form-error",children:P.currentPassword})]}),o.jsxs("div",{className:"profile-form-group",children:[o.jsx("label",{className:"profile-form-label",children:v?"Password":"New Password"}),o.jsx("input",{type:"password",name:"newPassword",className:"profile-form-input",value:O.newPassword,onChange:gt,placeholder:v?"Enter password":"Enter new password",autoComplete:"new-password"}),P.newPassword&&o.jsx("div",{className:"profile-form-error",children:P.newPassword})]}),o.jsx("div",{className:"password-requirements",children:k&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`password-requirement ${te.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 ",k.min_length," characters"]})]}),k.require_uppercase&&o.jsxs("div",{className:`password-requirement ${te.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"})]}),k.require_lowercase&&o.jsxs("div",{className:`password-requirement ${te.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"})]}),k.require_numbers&&o.jsxs("div",{className:`password-requirement ${te.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"})]}),k.require_special_chars&&o.jsxs("div",{className:`password-requirement ${te.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:O.confirmPassword,onChange:gt,placeholder:v?"Confirm password":"Confirm new password",autoComplete:"new-password"}),P.confirmPassword&&o.jsx("div",{className:"profile-form-error",children:P.confirmPassword})]}),o.jsxs("div",{className:"profile-form-actions",children:[o.jsx("button",{type:"button",className:"profile-cancel-btn",onClick:()=>{l(!1),V({}),I({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),o.jsx("button",{type:"submit",className:"profile-submit-btn",disabled:j,children:j?v?"Setting...":"Updating...":v?"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:[u?"Enabled":"Disabled"," ",u?"":" - Add an extra layer of security"]}),!u&&D?.auth_config?.two_factor_auth?.can_enable===!1&&D?.auth_config?.two_factor_auth?.issue&&o.jsx("p",{style:{color:"#dc2626",fontSize:"14px",marginTop:"8px"},children:D.auth_config.two_factor_auth.issue})]}),!u&&D?.auth_config?.two_factor_auth?.can_enable===!0&&o.jsx("button",{className:"toggle-btn",onClick:Ss,children:"Enable"}),u&&D?.auth_config?.two_factor_auth?.can_disable===!0&&o.jsx("button",{className:"toggle-btn enabled",onClick:Ss,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..."})]}):S?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:S}),o.jsx("button",{onClick:he,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}):m.length>0?m.map((z,R)=>{const ne=ue(z);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:ne.deviceName}),z.is_current?o.jsx("span",{className:"session-status-tag current",children:"Current"}):ne.isActive?o.jsx("button",{className:"logout-tag-btn logout-tag-btn-ghost",onClick:()=>ja(z.id),children:"Logout"}):o.jsx("button",{className:"logout-tag-btn",onClick:()=>ja(z.id),children:"Logout"})]}),o.jsxs("p",{className:"session-details",children:[ne.os," • ",ne.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: ",ne.sessionStartTime]}),o.jsx("p",{className:"session-last-active",children:ne.isActive?"Active now":`Last seen: ${ne.lastSeen}`})]})})]},z.id||R)}):o.jsx("p",{className:"no-sessions",children:"No active sessions found"})}),m.length>1&&o.jsx("button",{className:"logout-all-btn",onClick:Af,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:F&&F.length>0?F.map((z,R)=>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:[z.role," - Bearer Token"]}),o.jsx("p",{className:"token-type",children:"Type: Bearer Authentication Token"}),o.jsxs("p",{className:"token-created",children:["Created: ",new Date(z.created).toLocaleDateString()]}),z.expiry?o.jsxs("p",{className:"token-expiry",children:["Expires: ",new Date(z.expiry).toLocaleDateString()]}):o.jsx("p",{className:"token-expiry",children:"Expires: Never"})]})]})})},R)):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"})]}),_d=({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"})]}),Zn=({profileInfo:e,theme:t={},config:r={}})=>{const[s,n]=p.useState(!1),[a,i]=p.useState(!1),[l,d]=p.useState(!1),[c,u]=p.useState(null),f=p.useRef(null);J.useNavigate(),p.useEffect(()=>{const O=I=>{f.current&&!f.current.contains(I.target)&&(n(!1),i(!1))};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]);const g=()=>{n(!s),s||i(!1)},h=()=>{Wn(()=>{cs({theme:t})})},m=O=>{window.location.href=O},w=e?.current_role||e?.user_role,b=e?.other_roles||[],{showProfile:C=!0,showLeftSection:S=!0,showRightSection:T=!0,customLeftContent:F=null,customRightContent:U=null,customProfileMenu:k=null,customViewProfile:L=null,profileMenuConfig:A={},className:D="",style:Y={}}=r,{showViewProfile:_=!0,showLogout:$=!0,showRoleSwitch:v=!0,customMenuItems:x=[]}=A,q=()=>{d(!0),n(!1)};return o.jsxs("header",{className:`topbar header-container ${D}`,style:Y,children:[o.jsxs("div",{className:"topbar-content",children:[S&&o.jsx("div",{className:"topbar-left",children:F||null}),T&&o.jsxs("div",{className:"topbar-right",children:[U,C&&o.jsxs("div",{className:"dropdown profile-dropdown-container",ref:f,children:[o.jsxs("div",{className:"profile-dropdown-menu-button",onClick:g,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=${go("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((O,I)=>o.jsxs("div",{className:"dropdown-item profile-each-role",onClick:()=>m(O.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:O.label})]},I))})}),o.jsx("li",{children:o.jsx("hr",{className:"profile-dropdown-divider"})}),x.map((O,I)=>o.jsx("li",{children:O},I)),_&&o.jsx("li",{children:o.jsx(_d,{onViewProfile:q})}),$&&o.jsx("li",{children:o.jsx(Pd,{onLogout:h})})]})]})]})]}),L?L({user:e,isOpen:l,onClose:()=>d(!1)}):o.jsx(Kn,{isOpen:l,onClose:()=>d(!1),profileData:c})]})},kd={showTopbar:!0,showNavbar:!0,layoutType:"wide"},Ed={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:{}},Ad={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:{}},pr=(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]=pr(e[s],t[s]):r[s]=e[s]}),r},Gn=()=>{const{loading:e,error:t,menu:r,profileInfo:s,appLogo:n,theme:a={},layoutConfig:i={},topbarConfig:l={},navbarConfig:d={},customComponents:c={}}=Le(),u=J.useLocation(),f=pr(i,kd),g=pr(l,Ed),h=pr(d,Ad),m=()=>{const k=document.getElementById("contentSpinner");k&&k.classList.add("active")},w=()=>{const k=document.getElementById("contentSpinner");k&&k.classList.remove("active")};if(p.useEffect(()=>{m();const k=300,L=Date.now(),A=setTimeout(()=>{const D=Date.now()-L;D>=k?w():setTimeout(w,k-D)},500);return()=>{clearTimeout(A)}},[u.pathname]),p.useEffect(()=>(window.addEventListener("beforeunload",m),()=>{window.removeEventListener("beforeunload",m)}),[]),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",C=f.showNavbar&&a?.menu_config?.display_sidebar!==!1,S=f.showTopbar,T=c?.Layout,F=c?.Topbar||g.customTopbar,U=c?.Navbar||h.customNavbar;return T?o.jsx(T,{menu:r,profileInfo:s,appLogo:n,theme:a,layoutConfig:f,topbarConfig:g,navbarConfig:h,children:o.jsx(J.Outlet,{})}):o.jsx("div",{className:`layout layout-${b}`,children:o.jsxs("main",{className:"layout-wrapper",children:[C&&(U?o.jsx(U,{menuItems:r,appLogo:n,theme:a,config:h}):o.jsx(Vn,{menuItems:r,appLogo:n,theme:a,config:h})),o.jsxs("div",{className:"layout-main",style:{width:C?`calc(100vw - ${h.isCollapsed?"80px":"244px"})`:"100vw",transition:"width 0.3s ease"},children:[S&&(F?o.jsx(F,{profileInfo:s,theme:a,config:g}):o.jsx(Zn,{profileInfo:s,theme:a,config:g})),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(J.Outlet,{})]})]})]})})},Nd=(e,t,r)=>{if(!e){const l=t.default;return l?.component?p.createElement(l.component,{message:"No page type specified"}):p.createElement("div",{style:{padding:"24px",color:"#f04438"}},"No page type specified")}const s=t[e]||t.default;if(!s)return p.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 d=l.propsBuilder?l.propsBuilder({...r,pageType:e}):{message:`No component configured for page type: ${e}`};return p.createElement(l.component,d)}return p.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 p.createElement(i,n)},Vt=({customPages:e={},forceRoute:t})=>{const r=J.useLocation(),{routes:s,pageTypeRegistry:n,registryLoading:a,registryError:i,initializerEndpoint:l}=Le(),d=Lt(),[c,u]=p.useState({pageType:null,customPagePath:null,matchedRoutePath:null,loading:!0});if(p.useEffect(()=>{u(b=>({...b,loading:!0})),(()=>{const b=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 C=b;if(s&&s.length>0){for(const S of s)if(b===S.path||b.startsWith(S.path+"/")){C=S.path;break}}u({pageType:r.state.page_type,customPagePath:r.state.custom_page_path||null,matchedRoutePath:C,loading:!1});return}if(s&&s.length>0){const C=[...s].sort((S,T)=>{const F=S.path.split("/").filter(k=>k).length;return T.path.split("/").filter(k=>k).length-F});for(const S of C){let T=J.matchPath({path:S.path,exact:!0},b);if(!T&&b.startsWith(S.path+"/")){const F=S.path.endsWith("/*")?S.path:`${S.path}/*`;T=J.matchPath({path:F,exact:!1},b)}if(T){u({pageType:S.page_type,customPagePath:S.component||null,matchedRoutePath:S.path,loading:!1});return}}}u({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:g,matchedRoutePath:h}=c,m=`${f}-${g||"default"}-${h||"none"}`;return o.jsx("div",{className:"h-full",children:Nd(f,n,{matchedRoutePath:h,customPagePath:g,customPages:e,location:r,apiConfig:d})},m)},Jn=()=>{const{metadata:e,appName:t,apiConfig:r,theme:s}=Le(),n=p.useRef(new Set),a=()=>{n.current.forEach(d=>{d.parentNode&&d.parentNode.removeChild(d)}),n.current.clear()},i=(d,c,u)=>{let f=document.querySelector(d);return f||(f=c(),document.head.appendChild(f),n.current.add(f)),u(f),f},l=(d,c="image")=>new Promise((u,f)=>{const g=document.createElement("link");g.rel="preload",g.as=c,g.href=d,g.onload=()=>u(),g.onerror=()=>f(new Error(`Failed to preload ${c}: ${d}`)),n.current.add(g),document.head.appendChild(g),setTimeout(()=>{g.parentNode&&(g.parentNode.removeChild(g),n.current.delete(g))},1e4)});return p.useEffect(()=>{if(!e)return;a();const d=(c,u)=>{if(!c)return u||null;if(c.startsWith("http://")||c.startsWith("https://")||c.startsWith("//"))return c;try{return zt(c,r)}catch(f){return console.warn(`Failed to build asset URL for ${c}:`,f),u||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=d(e.favicon,"/favicon.ico");c&&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=c,l(c).catch(f=>console.warn("Failed to preload favicon:",f.message))})}if(e.favicon_png){const c=d(e.favicon_png,"/favicon-32x32.png");c&&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=c,l(c).catch(f=>console.warn("Failed to preload PNG favicon:",f.message))})}if(e.apple_touch_icon){const c=d(e.apple_touch_icon,"/apple-touch-icon.png");c&&i('link[rel="apple-touch-icon"]',()=>{const u=document.createElement("link");return u.rel="apple-touch-icon",u},u=>{u.href=c,l(c).catch(f=>console.warn("Failed to preload Apple touch icon:",f.message))})}if(e.og_image){const c=d(e.og_image,"/og-image.png");c&&(l(c).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=c}),(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 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=d(e.og_image,"/og-image.png");c&&i('meta[name="twitter:image"]',()=>{const u=document.createElement("meta");return u.name="twitter:image",u},u=>{u.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=d(e.manifest||e.webmanifest,"/manifest.json");c&&i('link[rel="manifest"]',()=>{const u=document.createElement("link");return u.rel="manifest",u},u=>{u.href=c})}return a},[e,t,s]),null},Ld=({config:e,onExpire:t,onWarning:r,onActivity:s})=>{const[n,a]=p.useState(!1),[i,l]=p.useState(0),d=p.useRef(new Date),c=p.useRef(null),u=p.useRef(null),f=p.useRef(!1),g=p.useRef(!1),h=p.useRef(!1),m=p.useRef(t),w=p.useRef(r),b=p.useRef(s),C=p.useRef(()=>{}),S=p.useRef(()=>{}),T=p.useRef(()=>{}),F=p.useRef(()=>{});p.useEffect(()=>{m.current=t,w.current=r,b.current=s},[t,r,s]),p.useEffect(()=>{h.current=n},[n]);const U=["mousemove","scroll","keyup","click","touchstart","touchend","touchmove"],k=p.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),L=p.useCallback(()=>{f.current=!0,k(),u.current&&(clearInterval(u.current),u.current=null),m.current&&m.current(),cs({preserveCurrentPath:!0})},[k]),A=p.useCallback(()=>{a(!1),u.current&&(clearInterval(u.current),u.current=null),g.current=!1},[]),D=p.useCallback(()=>{const{warn_after:I,expire_after:X}=e,oe=X-I;if(g.current)return;l(oe),g.current=!0;const P=new Date;P.setSeconds(P.getSeconds()+oe),u.current=setInterval(()=>{const V=new Date().getTime(),K=P.getTime()-V,H=Math.floor(K/1e3);H>0?l(H):(u.current&&(clearInterval(u.current),u.current=null),l(0))},1e3)},[e]),Y=p.useCallback(()=>{u.current&&(clearInterval(u.current),u.current=null),g.current=!1;const I=e.expire_after-e.warn_after;l(I)},[e]),_=p.useCallback(I=>{if(I==="logout"||I?.response==="logout"){L();return}C.current()},[L]);p.useLayoutEffect(()=>{T.current=_},[_]);const $=p.useCallback(async()=>{const I=Math.floor((new Date().getTime()-d.current.getTime())/1e3);try{const X=await oo(e.ping_url,I);X.success?T.current(X.response):C.current()}catch{C.current()}},[e.ping_url]);p.useLayoutEffect(()=>{S.current=$},[$]);const v=p.useCallback(()=>{k();const I=Math.floor((new Date().getTime()-d.current.getTime())/1e3),{warn_after:X,expire_after:oe}=e;let P;if(I>=oe){L();return}else I>=X?(g.current||D(),a(!0),w.current&&w.current(),P=oe-I):(A(),g.current&&Y(),P=X-I);const V=Math.min(P*1e3,2147483647);c.current=setTimeout(()=>{S.current()},V)},[e,k,L,D,A,Y]);p.useLayoutEffect(()=>{C.current=v},[v]);const x=p.useCallback(()=>{const I=new Date;if(I.getTime()-d.current.getTime()<1e3)return;const X=Math.floor((I.getTime()-d.current.getTime())/1e3);if(d.current=I,X>=e.expire_after){L();return}h.current&&(S.current(),A()),b.current&&b.current()},[e.expire_after,L,A]);p.useLayoutEffect(()=>{F.current=x},[x]);const q=p.useCallback(()=>{d.current=new Date,A(),S.current()},[A]),O=p.useCallback(()=>{L()},[L]);return p.useEffect(()=>{if(!e.enabled)return;const I=()=>F.current();return U.forEach(X=>{document.addEventListener(X,I,!0)}),C.current(),()=>{U.forEach(X=>{document.removeEventListener(X,I,!0)}),c.current&&(clearTimeout(c.current),c.current=null),u.current&&(clearInterval(u.current),u.current=null)}},[e.enabled]),{showWarning:n,countdown:i,hideWarning:A,renewSession:q,logoutNow:O}};function st(e,t,{checkForDefaultPrevented:r=!0}={}){return function(n){if(e?.(n),r===!1||!n.defaultPrevented)return t?.(n)}}function Xn(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Yn(...e){return t=>{let r=!1;const s=e.map(n=>{const a=Xn(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():Xn(e[n],null)}}}}function ht(...e){return M.useCallback(Yn(...e),e)}function Td(e,t){const r=M.createContext(t),s=a=>{const{children:i,...l}=a,d=M.useMemo(()=>l,Object.values(l));return o.jsx(r.Provider,{value:d,children:i})};s.displayName=e+"Provider";function n(a){const i=M.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 Md(e,t=[]){let r=[];function s(a,i){const l=M.createContext(i),d=r.length;r=[...r,i];const c=f=>{const{scope:g,children:h,...m}=f,w=g?.[e]?.[d]||l,b=M.useMemo(()=>m,Object.values(m));return o.jsx(w.Provider,{value:b,children:h})};c.displayName=a+"Provider";function u(f,g){const h=g?.[e]?.[d]||l,m=M.useContext(h);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${a}\``)}return[c,u]}const n=()=>{const a=r.map(i=>M.createContext(i));return function(l){const d=l?.[e]||a;return M.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return n.scopeName=e,[s,Fd(n,...t)]}function Fd(...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:d,scopeName:c})=>{const f=d(a)[`__scope${c}`];return{...l,...f}},{});return M.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}var jt=globalThis?.document?M.useLayoutEffect:()=>{},Od=M[" useId ".trim().toString()]||(()=>{}),Ud=0;function ds(e){const[t,r]=M.useState(Od());return jt(()=>{r(s=>s??String(Ud++))},[e]),e||(t?`radix-${t}`:"")}var Id=M[" useInsertionEffect ".trim().toString()]||jt;function Dd({prop:e,defaultProp:t,onChange:r=()=>{},caller:s}){const[n,a,i]=$d({defaultProp:t,onChange:r}),l=e!==void 0,d=l?e:n;{const u=M.useRef(e!==void 0);M.useEffect(()=>{const f=u.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.`),u.current=l},[l,s])}const c=M.useCallback(u=>{if(l){const f=Bd(u)?u(e):u;f!==e&&i.current?.(f)}else a(u)},[l,e,a,i]);return[d,c]}function $d({defaultProp:e,onChange:t}){const[r,s]=M.useState(e),n=M.useRef(r),a=M.useRef(t);return Id(()=>{a.current=t},[t]),M.useEffect(()=>{n.current!==r&&(a.current?.(r),n.current=r)},[r,n]),[r,s,a]}function Bd(e){return typeof e=="function"}function Qn(e){const t=qd(e),r=M.forwardRef((s,n)=>{const{children:a,...i}=s,l=M.Children.toArray(a),d=l.find(jd);if(d){const c=d.props.children,u=l.map(f=>f===d?M.Children.count(c)>1?M.Children.only(null):M.isValidElement(c)?c.props.children:null:f);return o.jsx(t,{...i,ref:n,children:M.isValidElement(c)?M.cloneElement(c,void 0,u):null})}return o.jsx(t,{...i,ref:n,children:a})});return r.displayName=`${e}.Slot`,r}function qd(e){const t=M.forwardRef((r,s)=>{const{children:n,...a}=r;if(M.isValidElement(n)){const i=zd(n),l=Hd(a,n.props);return n.type!==M.Fragment&&(l.ref=s?Yn(s,i):i),M.cloneElement(n,l)}return M.Children.count(n)>1?M.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Vd=Symbol("radix.slottable");function jd(e){return M.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Vd}function Hd(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 d=a(...l);return n(...l),d}:n&&(r[s]=n):s==="style"?r[s]={...n,...a}:s==="className"&&(r[s]=[n,a].filter(Boolean).join(" "))}return{...e,...r}}function zd(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 Wd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Je=Wd.reduce((e,t)=>{const r=Qn(`Primitive.${t}`),s=M.forwardRef((n,a)=>{const{asChild:i,...l}=n,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(d,{...l,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function Kd(e,t){e&&Ga.flushSync(()=>e.dispatchEvent(t))}function Ht(e){const t=M.useRef(e);return M.useEffect(()=>{t.current=e}),M.useMemo(()=>(...r)=>t.current?.(...r),[])}function Zd(e,t=globalThis?.document){const r=Ht(e);M.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 Gd="DismissableLayer",us="dismissableLayer.update",Jd="dismissableLayer.pointerDownOutside",Xd="dismissableLayer.focusOutside",Rn,ea=M.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ta=M.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:n,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...d}=e,c=M.useContext(ea),[u,f]=M.useState(null),g=u?.ownerDocument??globalThis?.document,[,h]=M.useState({}),m=ht(t,L=>f(L)),w=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),C=w.indexOf(b),S=u?w.indexOf(u):-1,T=c.layersWithOutsidePointerEventsDisabled.size>0,F=S>=C,U=Rd(L=>{const A=L.target,D=[...c.branches].some(Y=>Y.contains(A));!F||D||(n?.(L),i?.(L),L.defaultPrevented||l?.())},g),k=eu(L=>{const A=L.target;[...c.branches].some(Y=>Y.contains(A))||(a?.(L),i?.(L),L.defaultPrevented||l?.())},g);return Zd(L=>{S===c.layers.size-1&&(s?.(L),!L.defaultPrevented&&l&&(L.preventDefault(),l()))},g),M.useEffect(()=>{if(u)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Rn=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),ra(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=Rn)}},[u,g,r,c]),M.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),ra())},[u,c]),M.useEffect(()=>{const L=()=>h({});return document.addEventListener(us,L),()=>document.removeEventListener(us,L)},[]),o.jsx(Je.div,{...d,ref:m,style:{pointerEvents:T?F?"auto":"none":void 0,...e.style},onFocusCapture:st(e.onFocusCapture,k.onFocusCapture),onBlurCapture:st(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:st(e.onPointerDownCapture,U.onPointerDownCapture)})});ta.displayName=Gd;var Yd="DismissableLayerBranch",Qd=M.forwardRef((e,t)=>{const r=M.useContext(ea),s=M.useRef(null),n=ht(t,s);return M.useEffect(()=>{const a=s.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),o.jsx(Je.div,{...e,ref:n})});Qd.displayName=Yd;function Rd(e,t=globalThis?.document){const r=Ht(e),s=M.useRef(!1),n=M.useRef(()=>{});return M.useEffect(()=>{const a=l=>{if(l.target&&!s.current){let d=function(){sa(Jd,r,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",n.current),n.current=d,t.addEventListener("click",n.current,{once:!0})):d()}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 eu(e,t=globalThis?.document){const r=Ht(e),s=M.useRef(!1);return M.useEffect(()=>{const n=a=>{a.target&&!s.current&&sa(Xd,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 ra(){const e=new CustomEvent(us);document.dispatchEvent(e)}function sa(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?Kd(n,a):n.dispatchEvent(a)}var fs="focusScope.autoFocusOnMount",hs="focusScope.autoFocusOnUnmount",oa={bubbles:!1,cancelable:!0},tu="FocusScope",na=M.forwardRef((e,t)=>{const{loop:r=!1,trapped:s=!1,onMountAutoFocus:n,onUnmountAutoFocus:a,...i}=e,[l,d]=M.useState(null),c=Ht(n),u=Ht(a),f=M.useRef(null),g=ht(t,w=>d(w)),h=M.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;M.useEffect(()=>{if(s){let w=function(T){if(h.paused||!l)return;const F=T.target;l.contains(F)?f.current=F:ot(f.current,{select:!0})},b=function(T){if(h.paused||!l)return;const F=T.relatedTarget;F!==null&&(l.contains(F)||ot(f.current,{select:!0}))},C=function(T){if(document.activeElement===document.body)for(const U of T)U.removedNodes.length>0&&ot(l)};document.addEventListener("focusin",w),document.addEventListener("focusout",b);const S=new MutationObserver(C);return l&&S.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",b),S.disconnect()}}},[s,l,h.paused]),M.useEffect(()=>{if(l){la.add(h);const w=document.activeElement;if(!l.contains(w)){const C=new CustomEvent(fs,oa);l.addEventListener(fs,c),l.dispatchEvent(C),C.defaultPrevented||(ru(iu(aa(l)),{select:!0}),document.activeElement===w&&ot(l))}return()=>{l.removeEventListener(fs,c),setTimeout(()=>{const C=new CustomEvent(hs,oa);l.addEventListener(hs,u),l.dispatchEvent(C),C.defaultPrevented||ot(w??document.body,{select:!0}),l.removeEventListener(hs,u),la.remove(h)},0)}}},[l,c,u,h]);const m=M.useCallback(w=>{if(!r&&!s||h.paused)return;const b=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,C=document.activeElement;if(b&&C){const S=w.currentTarget,[T,F]=su(S);T&&F?!w.shiftKey&&C===F?(w.preventDefault(),r&&ot(T,{select:!0})):w.shiftKey&&C===T&&(w.preventDefault(),r&&ot(F,{select:!0})):C===S&&w.preventDefault()}},[r,s,h.paused]);return o.jsx(Je.div,{tabIndex:-1,...i,ref:g,onKeyDown:m})});na.displayName=tu;function ru(e,{select:t=!1}={}){const r=document.activeElement;for(const s of e)if(ot(s,{select:t}),document.activeElement!==r)return}function su(e){const t=aa(e),r=ia(t,e),s=ia(t.reverse(),e);return[r,s]}function aa(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 ia(e,t){for(const r of e)if(!ou(r,{upTo:t}))return r}function ou(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 nu(e){return e instanceof HTMLInputElement&&"select"in e}function ot(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&nu(e)&&t&&e.select()}}var la=au();function au(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=ca(e,t),e.unshift(t)},remove(t){e=ca(e,t),e[0]?.resume()}}}function ca(e,t){const r=[...e],s=r.indexOf(t);return s!==-1&&r.splice(s,1),r}function iu(e){return e.filter(t=>t.tagName!=="A")}var lu="Portal",da=M.forwardRef((e,t)=>{const{container:r,...s}=e,[n,a]=M.useState(!1);jt(()=>a(!0),[]);const i=r||n&&globalThis?.document?.body;return i?As.createPortal(o.jsx(Je.div,{...s,ref:t}),i):null});da.displayName=lu;function cu(e,t){return M.useReducer((r,s)=>t[r][s]??r,e)}var gr=e=>{const{present:t,children:r}=e,s=du(t),n=typeof r=="function"?r({present:s.isPresent}):M.Children.only(r),a=ht(s.ref,uu(n));return typeof r=="function"||s.isPresent?M.cloneElement(n,{ref:a}):null};gr.displayName="Presence";function du(e){const[t,r]=M.useState(),s=M.useRef(null),n=M.useRef(e),a=M.useRef("none"),i=e?"mounted":"unmounted",[l,d]=cu(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return M.useEffect(()=>{const c=mr(s.current);a.current=l==="mounted"?c:"none"},[l]),jt(()=>{const c=s.current,u=n.current;if(u!==e){const g=a.current,h=mr(c);e?d("MOUNT"):h==="none"||c?.display==="none"?d("UNMOUNT"):d(u&&g!==h?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,d]),jt(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,f=h=>{const w=mr(s.current).includes(CSS.escape(h.animationName));if(h.target===t&&w&&(d("ANIMATION_END"),!n.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},g=h=>{h.target===t&&(a.current=mr(s.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:M.useCallback(c=>{s.current=c?getComputedStyle(c):null,r(c)},[])}}function mr(e){return e?.animationName||"none"}function uu(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 ps=0;function fu(){M.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ua()),document.body.insertAdjacentElement("beforeend",e[1]??ua()),ps++,()=>{ps===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ps--}},[])}function ua(){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 Ke=function(){return Ke=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},Ke.apply(this,arguments)};function fa(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 hu(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 wr="right-scroll-bar-position",yr="width-before-scroll-bar",pu="with-scroll-bars-hidden",gu="--removed-body-scroll-bar-size";function gs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mu(e,t){var r=p.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 wu=typeof window<"u"?M.useLayoutEffect:M.useEffect,ha=new WeakMap;function yu(e,t){var r=mu(null,function(s){return e.forEach(function(n){return gs(n,s)})});return wu(function(){var s=ha.get(r);if(s){var n=new Set(s),a=new Set(e),i=r.current;n.forEach(function(l){a.has(l)||gs(l,null)}),a.forEach(function(l){n.has(l)||gs(l,i)})}ha.set(r,e)},[e]),r}function bu(e){return e}function vu(e,t){t===void 0&&(t=bu);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 d=function(){var u=i;i=[],u.forEach(a)},c=function(){return Promise.resolve().then(d)};c(),r={push:function(u){i.push(u),c()},filter:function(u){return i=i.filter(u),r}}}};return n}function Cu(e){e===void 0&&(e={});var t=vu(null);return t.options=Ke({async:!0,ssr:!1},e),t}var pa=function(e){var t=e.sideCar,r=fa(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 M.createElement(s,Ke({},r))};pa.isSideCarExport=!0;function xu(e,t){return e.useMedium(t),pa}var ga=Cu(),ms=function(){},br=M.forwardRef(function(e,t){var r=M.useRef(null),s=M.useState({onScrollCapture:ms,onWheelCapture:ms,onTouchMoveCapture:ms}),n=s[0],a=s[1],i=e.forwardProps,l=e.children,d=e.className,c=e.removeScrollBar,u=e.enabled,f=e.shards,g=e.sideCar,h=e.noRelative,m=e.noIsolation,w=e.inert,b=e.allowPinchZoom,C=e.as,S=C===void 0?"div":C,T=e.gapMode,F=fa(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),U=g,k=yu([r,t]),L=Ke(Ke({},F),n);return M.createElement(M.Fragment,null,u&&M.createElement(U,{sideCar:ga,removeScrollBar:c,shards:f,noRelative:h,noIsolation:m,inert:w,setCallbacks:a,allowPinchZoom:!!b,lockRef:r,gapMode:T}),i?M.cloneElement(M.Children.only(l),Ke(Ke({},L),{ref:k})):M.createElement(S,Ke({},L,{className:d,ref:k}),l))});br.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},br.classNames={fullWidth:yr,zeroRight:wr};var Su=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=Su();return t&&e.setAttribute("nonce",t),e}function _u(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function ku(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Eu=function(){var e=0,t=null;return{add:function(r){e==0&&(t=Pu())&&(_u(t,r),ku(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Au=function(){var e=Eu();return function(t,r){M.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},ma=function(){var e=Au(),t=function(r){var s=r.styles,n=r.dynamic;return e(s,n),null};return t},Nu={left:0,top:0,right:0,gap:0},ws=function(e){return parseInt(e||"",10)||0},Lu=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[ws(r),ws(s),ws(n)]},Tu=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Nu;var t=Lu(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])}},Mu=ma(),St="data-scroll-locked",Fu=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(pu,` {
|
|
197
197
|
overflow: hidden `).concat(s,`;
|
|
198
198
|
padding-right: `).concat(l,"px ").concat(s,`;
|
|
199
199
|
}
|
|
200
|
-
body[`).concat(
|
|
200
|
+
body[`).concat(St,`] {
|
|
201
201
|
overflow: hidden `).concat(s,`;
|
|
202
202
|
overscroll-behavior: contain;
|
|
203
203
|
`).concat([t&&"position: relative ".concat(s,";"),r==="margin"&&`
|
|
@@ -210,33 +210,33 @@ export default App;`,m=`mkdir -p ${l}`,g={container:{padding:"32px",maxWidth:"90
|
|
|
210
210
|
`),r==="padding"&&"padding-right: ".concat(l,"px ").concat(s,";")].filter(Boolean).join(""),`
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
.`).concat(
|
|
213
|
+
.`).concat(wr,` {
|
|
214
214
|
right: `).concat(l,"px ").concat(s,`;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
.`).concat(
|
|
217
|
+
.`).concat(yr,` {
|
|
218
218
|
margin-right: `).concat(l,"px ").concat(s,`;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
.`).concat(
|
|
221
|
+
.`).concat(wr," .").concat(wr,` {
|
|
222
222
|
right: 0 `).concat(s,`;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
.`).concat(
|
|
225
|
+
.`).concat(yr," .").concat(yr,` {
|
|
226
226
|
margin-right: 0 `).concat(s,`;
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
body[`).concat(
|
|
230
|
-
`).concat(
|
|
229
|
+
body[`).concat(St,`] {
|
|
230
|
+
`).concat(gu,": ").concat(l,`px;
|
|
231
231
|
}
|
|
232
|
-
`)},
|
|
232
|
+
`)},wa=function(){var e=parseInt(document.body.getAttribute(St)||"0",10);return isFinite(e)?e:0},Ou=function(){M.useEffect(function(){return document.body.setAttribute(St,(wa()+1).toString()),function(){var e=wa()-1;e<=0?document.body.removeAttribute(St):document.body.setAttribute(St,e.toString())}},[])},Uu=function(e){var t=e.noRelative,r=e.noImportant,s=e.gapMode,n=s===void 0?"margin":s;Ou();var a=M.useMemo(function(){return Tu(n)},[n]);return M.createElement(Mu,{styles:Fu(a,!t,n,r?"":"!important")})},ys=!1;if(typeof window<"u")try{var vr=Object.defineProperty({},"passive",{get:function(){return ys=!0,!0}});window.addEventListener("test",vr,vr),window.removeEventListener("test",vr,vr)}catch{ys=!1}var Pt=ys?{passive:!1}:!1,Iu=function(e){return e.tagName==="TEXTAREA"},ya=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!Iu(e)&&r[t]==="visible")},Du=function(e){return ya(e,"overflowY")},$u=function(e){return ya(e,"overflowX")},ba=function(e,t){var r=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var n=va(e,s);if(n){var a=Ca(e,s),i=a[1],l=a[2];if(i>l)return!0}s=s.parentNode}while(s&&s!==r.body);return!1},Bu=function(e){var t=e.scrollTop,r=e.scrollHeight,s=e.clientHeight;return[t,r,s]},qu=function(e){var t=e.scrollLeft,r=e.scrollWidth,s=e.clientWidth;return[t,r,s]},va=function(e,t){return e==="v"?Du(t):$u(t)},Ca=function(e,t){return e==="v"?Bu(t):qu(t)},Vu=function(e,t){return e==="h"&&t==="rtl"?-1:1},ju=function(e,t,r,s,n){var a=Vu(e,window.getComputedStyle(t).direction),i=a*s,l=r.target,d=t.contains(l),c=!1,u=i>0,f=0,g=0;do{if(!l)break;var h=Ca(e,l),m=h[0],w=h[1],b=h[2],C=w-b-a*m;(m||C)&&va(e,l)&&(f+=C,g+=m);var S=l.parentNode;l=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!d&&l!==document.body||d&&(t.contains(l)||t===l));return(u&&Math.abs(f)<1||!u&&Math.abs(g)<1)&&(c=!0),c},Cr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},xa=function(e){return[e.deltaX,e.deltaY]},Sa=function(e){return e&&"current"in e?e.current:e},Hu=function(e,t){return e[0]===t[0]&&e[1]===t[1]},zu=function(e){return`
|
|
233
233
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
234
234
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
235
|
-
`)},
|
|
235
|
+
`)},Wu=0,_t=[];function Ku(e){var t=M.useRef([]),r=M.useRef([0,0]),s=M.useRef(),n=M.useState(Wu++)[0],a=M.useState(ma)[0],i=M.useRef(e);M.useEffect(function(){i.current=e},[e]),M.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(n));var w=hu([e.lockRef.current],(e.shards||[]).map(Sa),!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=M.useCallback(function(w,b){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!i.current.allowPinchZoom;var C=Cr(w),S=r.current,T="deltaX"in w?w.deltaX:S[0]-C[0],F="deltaY"in w?w.deltaY:S[1]-C[1],U,k=w.target,L=Math.abs(T)>Math.abs(F)?"h":"v";if("touches"in w&&L==="h"&&k.type==="range")return!1;var A=ba(L,k);if(!A)return!0;if(A?U=L:(U=L==="v"?"h":"v",A=ba(L,k)),!A)return!1;if(!s.current&&"changedTouches"in w&&(T||F)&&(s.current=U),!U)return!0;var D=s.current||U;return ju(D,b,w,D==="h"?T:F)},[]),d=M.useCallback(function(w){var b=w;if(!(!_t.length||_t[_t.length-1]!==a)){var C="deltaY"in b?xa(b):Cr(b),S=t.current.filter(function(U){return U.name===b.type&&(U.target===b.target||b.target===U.shadowParent)&&Hu(U.delta,C)})[0];if(S&&S.should){b.cancelable&&b.preventDefault();return}if(!S){var T=(i.current.shards||[]).map(Sa).filter(Boolean).filter(function(U){return U.contains(b.target)}),F=T.length>0?l(b,T[0]):!i.current.noIsolation;F&&b.cancelable&&b.preventDefault()}}},[]),c=M.useCallback(function(w,b,C,S){var T={name:w,delta:b,target:C,should:S,shadowParent:Zu(C)};t.current.push(T),setTimeout(function(){t.current=t.current.filter(function(F){return F!==T})},1)},[]),u=M.useCallback(function(w){r.current=Cr(w),s.current=void 0},[]),f=M.useCallback(function(w){c(w.type,xa(w),w.target,l(w,e.lockRef.current))},[]),g=M.useCallback(function(w){c(w.type,Cr(w),w.target,l(w,e.lockRef.current))},[]);M.useEffect(function(){return _t.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:g}),document.addEventListener("wheel",d,Pt),document.addEventListener("touchmove",d,Pt),document.addEventListener("touchstart",u,Pt),function(){_t=_t.filter(function(w){return w!==a}),document.removeEventListener("wheel",d,Pt),document.removeEventListener("touchmove",d,Pt),document.removeEventListener("touchstart",u,Pt)}},[]);var h=e.removeScrollBar,m=e.inert;return M.createElement(M.Fragment,null,m?M.createElement(a,{styles:zu(n)}):null,h?M.createElement(Uu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Zu(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Gu=xu(ga,Ku);var Pa=M.forwardRef(function(e,t){return M.createElement(br,Ke({},e,{ref:t,sideCar:Gu}))});Pa.classNames=br.classNames;var Ju=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},kt=new WeakMap,xr=new WeakMap,Sr={},bs=0,_a=function(e){return e&&(e.host||_a(e.parentNode))},Xu=function(e,t){return t.map(function(r){if(e.contains(r))return r;var s=_a(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})},Yu=function(e,t,r,s){var n=Xu(t,Array.isArray(e)?e:[e]);Sr[r]||(Sr[r]=new WeakMap);var a=Sr[r],i=[],l=new Set,d=new Set(n),c=function(f){!f||l.has(f)||(l.add(f),c(f.parentNode))};n.forEach(c);var u=function(f){!f||d.has(f)||Array.prototype.forEach.call(f.children,function(g){if(l.has(g))u(g);else try{var h=g.getAttribute(s),m=h!==null&&h!=="false",w=(kt.get(g)||0)+1,b=(a.get(g)||0)+1;kt.set(g,w),a.set(g,b),i.push(g),w===1&&m&&xr.set(g,!0),b===1&&g.setAttribute(r,"true"),m||g.setAttribute(s,"true")}catch(C){console.error("aria-hidden: cannot operate on ",g,C)}})};return u(t),l.clear(),bs++,function(){i.forEach(function(f){var g=kt.get(f)-1,h=a.get(f)-1;kt.set(f,g),a.set(f,h),g||(xr.has(f)||f.removeAttribute(s),xr.delete(f)),h||f.removeAttribute(r)}),bs--,bs||(kt=new WeakMap,kt=new WeakMap,xr=new WeakMap,Sr={})}},Qu=function(e,t,r){r===void 0&&(r="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),n=Ju(e);return n?(s.push.apply(s,Array.from(n.querySelectorAll("[aria-live], script"))),Yu(s,n,r,"aria-hidden")):function(){return null}},Pr="Dialog",[ka]=Md(Pr),[Ru,qe]=ka(Pr),Ea=e=>{const{__scopeDialog:t,children:r,open:s,defaultOpen:n,onOpenChange:a,modal:i=!0}=e,l=M.useRef(null),d=M.useRef(null),[c,u]=Dd({prop:s,defaultProp:n??!1,onChange:a,caller:Pr});return o.jsx(Ru,{scope:t,triggerRef:l,contentRef:d,contentId:ds(),titleId:ds(),descriptionId:ds(),open:c,onOpenChange:u,onOpenToggle:M.useCallback(()=>u(f=>!f),[u]),modal:i,children:r})};Ea.displayName=Pr;var Aa="DialogTrigger",ef=M.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,n=qe(Aa,r),a=ht(t,n.triggerRef);return o.jsx(Je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":xs(n.open),...s,ref:a,onClick:st(e.onClick,n.onOpenToggle)})});ef.displayName=Aa;var vs="DialogPortal",[tf,Na]=ka(vs,{forceMount:void 0}),La=e=>{const{__scopeDialog:t,forceMount:r,children:s,container:n}=e,a=qe(vs,t);return o.jsx(tf,{scope:t,forceMount:r,children:M.Children.map(s,i=>o.jsx(gr,{present:r||a.open,children:o.jsx(da,{asChild:!0,container:n,children:i})}))})};La.displayName=vs;var _r="DialogOverlay",Ta=M.forwardRef((e,t)=>{const r=Na(_r,e.__scopeDialog),{forceMount:s=r.forceMount,...n}=e,a=qe(_r,e.__scopeDialog);return a.modal?o.jsx(gr,{present:s||a.open,children:o.jsx(sf,{...n,ref:t})}):null});Ta.displayName=_r;var rf=Qn("DialogOverlay.RemoveScroll"),sf=M.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,n=qe(_r,r);return o.jsx(Pa,{as:rf,allowPinchZoom:!0,shards:[n.contentRef],children:o.jsx(Je.div,{"data-state":xs(n.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),pt="DialogContent",Ma=M.forwardRef((e,t)=>{const r=Na(pt,e.__scopeDialog),{forceMount:s=r.forceMount,...n}=e,a=qe(pt,e.__scopeDialog);return o.jsx(gr,{present:s||a.open,children:a.modal?o.jsx(of,{...n,ref:t}):o.jsx(nf,{...n,ref:t})})});Ma.displayName=pt;var of=M.forwardRef((e,t)=>{const r=qe(pt,e.__scopeDialog),s=M.useRef(null),n=ht(t,r.contentRef,s);return M.useEffect(()=>{const a=s.current;if(a)return Qu(a)},[]),o.jsx(Fa,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:st(e.onCloseAutoFocus,a=>{a.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:st(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:st(e.onFocusOutside,a=>a.preventDefault())})}),nf=M.forwardRef((e,t)=>{const r=qe(pt,e.__scopeDialog),s=M.useRef(!1),n=M.useRef(!1);return o.jsx(Fa,{...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()}})}),Fa=M.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:a,...i}=e,l=qe(pt,r),d=M.useRef(null),c=ht(t,d);return fu(),o.jsxs(o.Fragment,{children:[o.jsx(na,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:n,onUnmountAutoFocus:a,children:o.jsx(ta,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":xs(l.open),...i,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(cf,{titleId:l.titleId}),o.jsx(uf,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Cs="DialogTitle",Oa=M.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,n=qe(Cs,r);return o.jsx(Je.h2,{id:n.titleId,...s,ref:t})});Oa.displayName=Cs;var Ua="DialogDescription",af=M.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,n=qe(Ua,r);return o.jsx(Je.p,{id:n.descriptionId,...s,ref:t})});af.displayName=Ua;var Ia="DialogClose",lf=M.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,n=qe(Ia,r);return o.jsx(Je.button,{type:"button",...s,ref:t,onClick:st(e.onClick,()=>n.onOpenChange(!1))})});lf.displayName=Ia;function xs(e){return e?"open":"closed"}var Da="DialogTitleWarning",[vh,$a]=Td(Da,{contentName:pt,titleName:Cs,docsSlug:"dialog"}),cf=({titleId:e})=>{const t=$a(Da),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
236
236
|
|
|
237
237
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
238
238
|
|
|
239
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return
|
|
239
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return M.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},df="DialogDescriptionWarning",uf=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${$a(df).contentName}}.`;return M.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},ff=Ea,hf=La,pf=Ta,gf=Ma,mf=Oa;const wf=({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(ff,{open:e,onOpenChange:()=>{},children:[o.jsxs(hf,{children:[o.jsx(pf,{className:"session-security-overlay"}),o.jsxs(gf,{className:"session-security-modal","aria-describedby":"session-security-description",onEscapeKeyDown:a=>a.preventDefault(),onPointerDownOutside:a=>a.preventDefault(),children:[o.jsx(mf,{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
240
|
.session-security-overlay {
|
|
241
241
|
position: fixed;
|
|
242
242
|
inset: 0;
|
|
@@ -360,10 +360,10 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
360
360
|
transform: translate(-50%, -50%) scale(1);
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
-
`})]})},
|
|
363
|
+
`})]})},yf=({config:e,children:t})=>{const{showWarning:r,countdown:s,renewSession:n,logoutNow:a}=Ld({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(wf,{open:r,countdown:s,onContinue:n,onLogout:a})]})},Ba=()=>{const e=J.useNavigate(),[t,r]=p.useState(null);return p.useEffect(()=>{(async()=>{try{const n=await so();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:`
|
|
364
364
|
@keyframes spin {
|
|
365
365
|
0% { transform: rotate(0deg); }
|
|
366
366
|
100% { transform: rotate(360deg); }
|
|
367
367
|
}
|
|
368
|
-
`})]})},pf=()=>{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."})]})})},$a=({customPages:e})=>{const t=J.useParams(),s=`${J.useLocation().pathname}-${Object.values(t).join("-")}`;return o.jsx(Ut,{customPages:e},s)},qa=({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];let f=!1;if(c.page_type==="custom"){const m=c.extra_params||{};f=m.standalone!==void 0?m.standalone===!0:d&&d.standalone===!0}else f=d&&d.standalone===!0;f?l.push(c):u.push(c)}),o.jsxs(J.Routes,{children:[o.jsx(J.Route,{path:"app/login/*",element:o.jsx(ar,{basePath:"/app/login"})}),o.jsx(J.Route,{path:"app/logout",element:o.jsx(Ba,{})}),o.jsx(J.Route,{path:"app/configuration-error",element:o.jsx(pf,{})}),l.map(c=>{const d=c.path.startsWith("/")?c.path.slice(1):c.path;return o.jsxs(h.Fragment,{children:[o.jsx(J.Route,{path:`${d}/*`,element:o.jsx(Ut,{customPages:e,forceRoute:c})}),o.jsx(J.Route,{path:d,element:o.jsx(Ut,{customPages:e,forceRoute:c})})]},c.path)}),o.jsxs(J.Route,{path:"/",element:o.jsx(Zn,{}),children:[o.jsx(J.Route,{index:!0,element:i?o.jsx(J.Navigate,{to:i}):o.jsx("div",{children:"No menu items available"})}),o.jsx(J.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(J.Route,{path:`${d}/*`,element:o.jsx($a,{customPages:e})}),o.jsx(J.Route,{path:d,element:o.jsx($a,{customPages:e})})]},c.path)})]}),o.jsx(J.Route,{path:"*",element:o.jsx(Ut,{customPages:e,forceRoute:{path:"*",page_type:"404"}})}),o.jsx(J.Route,{path:"/404",element:o.jsx(Ut,{customPages:e,forceRoute:{path:"/404",page_type:"404"}})})]})},gf=({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(Gn,{}),s&&a?o.jsx(hf,{config:a,children:o.jsx(qa,{customPages:e})}):o.jsx(qa,{customPages:e})]})},mf=({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(J.BrowserRouter,{children:o.jsx(Bn,{config:e,layoutConfig:r,topbarConfig:s,navbarConfig:n,customComponents:a,authConfig:i,children:o.jsx(gf,{customPages:t})})})),wf=({customPages:e={},config:t={},layoutConfig:r={},topbarConfig:s={},navbarConfig:n={},customComponents:a={},authConfig:i={},appInitializerEndpoint:l})=>o.jsxs(o.Fragment,{children:[o.jsx(mf,{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 yf{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 yf;const bf=Object.freeze({__proto__:null,default:{crud:{component:Ar,includeBasePath:!0,propsBuilder:({matchedRoutePath:e})=>({})},training:{component:go,includeBasePath:!0,propsBuilder:({matchedRoutePath:e})=>({})},login:{component:ar,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(Lr,{componentName:t})}},404:{component:At,standalone:!0,includeBasePath:!1,propsBuilder:()=>({})},default:{component:At,includeBasePath:!1,standalone:!0,propsBuilder:({pageType:e})=>({message:`Unknown page type: ${e}`})}}});q.AppProvider=Bn,q.AuthConfigProvider=Sn,q.AuthProvider=An,q.CachedLogo=As,q.CrudPage=Ar,q.CustomPageFallback=wo,q.CustomPageLoader=Lr,q.DocumentHead=Gn,q.Layout=Zn,q.LoginContext=Qr,q.LoginPage=ar,q.LogoutPage=Ba,q.Navbar=qn,q.NotFoundPage=At,q.OTPLoginForm=pd,q.PasswordLoginForm=hd,q.PasswordResetRequired=Yr,q.RoleSelection=or,q.SSOButtons=fd,q.SmartLink=lr,q.Topbar=Kn,q.UserProfileDrawer=Wn,q.ZangoApp=wf,q.authApi=Wr,q.authService=H,q.buildApiUrl=xe,q.callApi=Se,q.callDeleteApi=Os,q.callGetApi=Ns,q.callPatchApi=Fs,q.callPostApi=Ls,q.callPutApi=Ts,q.changePassword=Bs,q.changeRole=Ys,q.configApi=wn,q.deleteCookie=je,q.fetchAppInitData=Zs,q.fetchUserProfile=Gs,q.fetchUserSessions=Js,q.generateCSSVariables=Ht,q.generatePalette=ot,q.generateQueryString=ti,q.getApiConfig=Li,q.getApiTimeout=Ra,q.getApiUrl=$t,q.getAppInitData=Ms,q.getColor=ho,q.getContrastColor=Ai,q.getCookie=as,q.getEndpoint=Qa,q.getUserProfile=Is,q.getUserSessions=Vs,q.isAuthenticatedViaCookie=jn,q.isLightColor=fo,q.logoCache=st,q.logout=zs,q.logoutAllSessions=Hs,q.logoutSession=js,q.mfaApi=Zr,q.otpApi=Kr,q.passwordApi=bt,q.performAppLogout=eo,q.performDirectLogout=to,q.performLogout=Ws,q.pingSession=ro,q.pingSessionSecurity=Ks,q.removeAllSessions=Rs,q.removeSession=Qs,q.roleApi=yn,q.saveUserProfile=qt,q.setCookie=Vn,q.setTwoFactor=si,q.switchRole=qs,q.toggleTwoFactor=$s,q.updatePassword=Xs,q.updateSvgColors=cr,q.updateUserProfile=Us,q.uploadPhoto=ri,q.uploadProfilePhoto=Ds,q.useApiConfig=_t,q.useAppContext=Ne,q.useAuth=ts,q.useAuthConfig=Ae,q.useAuthContext=Re,q.useLoginContext=Rr,q.useRouteConfig=Ni,q.useSmartNavigation=$n}));
|
|
368
|
+
`})]})},bf=()=>{const{menu:e,profileInfo:t,initializerEndpoint:r}=Le();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."})]})})},qa=({customPages:e})=>{const t=J.useParams(),s=`${J.useLocation().pathname}-${Object.values(t).join("-")}`;return o.jsx(Vt,{customPages:e},s)},vf=({firstMenuUri:e})=>{const t=J.useLocation(),r=Oe(t.search);return r&&xt(r)?o.jsx(J.Navigate,{to:r,replace:!0}):e?o.jsx(J.Navigate,{to:e,replace:!0}):o.jsx("div",{className:"zango-loading",children:"No menu items available"})},Va=({customPages:e})=>{const{routes:t,loading:r,menu:s,pageTypeRegistry:n,registryError:a}=Le(),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=[],d=[];return n&&t.forEach(c=>{const u=n[c.page_type];let f=!1;if(c.page_type==="custom"){const g=c.extra_params||{};f=g.standalone!==void 0?g.standalone===!0:u&&u.standalone===!0}else f=u&&u.standalone===!0;f?l.push(c):d.push(c)}),o.jsxs(J.Routes,{children:[o.jsx(J.Route,{path:"app/login/*",element:o.jsx(dr,{basePath:"/app/login"})}),o.jsx(J.Route,{path:"app/logout",element:o.jsx(Ba,{})}),o.jsx(J.Route,{path:"app/configuration-error",element:o.jsx(bf,{})}),l.map(c=>{const u=c.path.startsWith("/")?c.path.slice(1):c.path;return o.jsxs(p.Fragment,{children:[o.jsx(J.Route,{path:`${u}/*`,element:o.jsx(Vt,{customPages:e,forceRoute:c})}),o.jsx(J.Route,{path:u,element:o.jsx(Vt,{customPages:e,forceRoute:c})})]},c.path)}),o.jsxs(J.Route,{path:"/",element:o.jsx(Gn,{}),children:[o.jsx(J.Route,{index:!0,element:i?o.jsx(J.Navigate,{to:i}):o.jsx("div",{children:"No menu items available"})}),o.jsx(J.Route,{path:"app",element:o.jsx(vf,{firstMenuUri:i})}),d.map(c=>{const u=c.path.startsWith("/")?c.path.slice(1):c.path;return o.jsxs(p.Fragment,{children:[o.jsx(J.Route,{path:`${u}/*`,element:o.jsx(qa,{customPages:e})}),o.jsx(J.Route,{path:u,element:o.jsx(qa,{customPages:e})})]},c.path)})]}),o.jsx(J.Route,{path:"*",element:o.jsx(Vt,{customPages:e,forceRoute:{path:"*",page_type:"404"}})}),o.jsx(J.Route,{path:"/404",element:o.jsx(Vt,{customPages:e,forceRoute:{path:"/404",page_type:"404"}})})]})},Cf=({customPages:e})=>{const{appData:t,sessionSecurity:r}=Le(),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(Jn,{}),s&&a?o.jsx(yf,{config:a,children:o.jsx(Va,{customPages:e})}):o.jsx(Va,{customPages:e})]})},xf=({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(J.BrowserRouter,{children:o.jsx(Bn,{config:e,layoutConfig:r,topbarConfig:s,navbarConfig:n,customComponents:a,authConfig:i,children:o.jsx(Cf,{customPages:t})})})),Sf=({customPages:e={},config:t={},layoutConfig:r={},topbarConfig:s={},navbarConfig:n={},customComponents:a={},authConfig:i={},appInitializerEndpoint:l})=>o.jsxs(o.Fragment,{children:[o.jsx(xf,{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 Pf{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,d=typeof i=="string"?i:i.toString();if(d.startsWith("http")&&!d.startsWith(window.location.origin))return await t(i,l);const u=Date.now().toString(),f=new Headers(l.headers||{});f.set("X-Client-Timestamp",u),f.set("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),f.set("X-Client-Platform",navigator.platform);const g={...l,headers:f},h=await t(i,g),m=window.location.origin+"/login/";return h.url&&h.url===m&&r.handleRedirect("/app/login/"),h}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,u=window.location.origin+"/login/";c&&c===u&&r.handleRedirect("/app/login/")}),n.apply(this,a)}}}new Pf;const{Content:_f}=y.Layout,kf=(e,t)=>r=>{const[s,n]=p.useState(null),[a,i]=p.useState(!1),[l,d]=p.useState(!1);let c=null;try{c=Ae()?.authConfig}catch{}p.useEffect(()=>{(async()=>{const h=new URLSearchParams(window.location.search),m=h.get("token"),w=h.get("request_id");if(m&&w){d(!0);try{const b=await W.getSAMLAuthMeta(m,w);if(b?.code==="user_not_found"){y.toast.error(b.message||"User does not exist");const T=window.location.pathname;window.history.replaceState({},"",T),d(!1);return}if(b?.status===401&&b?.data?.next_step&&b.data.next_step.is_pending){let F=h.get("email")||h.get("user_email")||null,U=h.get("name")||h.get("user_name")||F;!F&&b?.data?.user&&(F=b.data.user.email||b.data.user.username,U=b.data.user.name||F);const L={...b,loginUser:{email:F,username:U||F||"SAML User",display:U||F||"SAML User"}};n(L),i(!0),d(!1);return}if(b?.roles&&b.roles.length>1){const T={status:401,data:{next_step:{id:"role_selection",is_pending:!0,metadata:{roles:b.roles}}},loginUser:{email:h.get("email")||"SAML User",username:h.get("name")||"SAML User",display:h.get("name")||"SAML User"}};n(T),i(!0),d(!1);return}const C=Oe(window.location.search),S=ge(C,b?.redirect_url,"/app");window.location.href=S}catch(b){console.error("[withMultiStepAuth] SAML callback error:",b),y.toast.error(b.message||"Failed to process SSO authentication");const C=window.location.pathname;window.history.replaceState({},"",C),d(!1)}}})()},[]);const u=g=>{let h=null,m=!1,w=null;if(g?.status===401&&g?.data)h=g.data?.next_step,w=g.status,m=g?.meta?.is_authenticated||!1;else if(g?.response?.status===401&&g?.response?.data)h=g.response.data?.next_step,w=g.response.status,m=g.response?.meta?.is_authenticated||!1;else if(g?.next_step)h=g.next_step,m=g?.meta?.is_authenticated||!1,w=g?.status;else{const b=g?.response?.data||g?.data||g;h=b?.next_step,m=b?.meta?.is_authenticated||g?.meta?.is_authenticated||!1,w=g?.status||g?.response?.status}if(h&&h.is_pending){n(g),i(!0);return}if(w===200&&m){const b=Oe(window.location.search),C=g?.redirect_url||g?.response?.data?.redirect_url||g?.data?.redirect_url,S=ge(b,C,"/app");window.location.href=S;return}console.warn("[withMultiStepAuth] Unhandled auth result:",g)},f=g=>{try{const h=Oe(window.location.search),m=g?.redirect_url||g?.response?.data?.redirect_url||g?.data?.redirect_url,w=ge(h,m,"/app");window.location.href=w}catch{window.location.href="/app"}};if(l){const g=$e(c);return o.jsx(y.Layout,{className:"min-h-screen",style:g,children:o.jsx(_f,{className:"flex justify-center items-center min-h-screen",children:o.jsx(y.Card,{className:"w-full max-w-md shadow-lg rounded-lg",bordered:!1,children: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:"Processing SSO authentication..."})]})})})})}return a&&s?o.jsx(Bt,{initialAuthState:s,onAuthComplete:f,skipLoginStep:!0,logo:t?.logo,roleSelectionTitle:t?.roleSelectionTitle,roleSelectionSubtitle:t?.roleSelectionSubtitle,twoFactorTitle:t?.twoFactorTitle,twoFactorSubtitle:t?.twoFactorSubtitle,passwordResetTitle:t?.passwordResetTitle,passwordResetSubtitle:t?.passwordResetSubtitle,...r}):o.jsx(cr.Provider,{value:{onLogin:u},children:o.jsx(e,{...r})})},Ef=Object.freeze({__proto__:null,default:{crud:{component:Mr,includeBasePath:!0,propsBuilder:({matchedRoutePath:e})=>({})},training:{component:wo,includeBasePath:!0,propsBuilder:({matchedRoutePath:e})=>({})},login:{component:dr,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?p.createElement(s):p.createElement(Or,{componentName:t})}},404:{component:Tt,standalone:!0,includeBasePath:!1,propsBuilder:()=>({})},default:{component:Tt,includeBasePath:!1,standalone:!0,propsBuilder:({pageType:e})=>({message:`Unknown page type: ${e}`})}}});B.AppProvider=Bn,B.AuthConfigProvider=Pn,B.AuthProvider=An,B.CachedLogo=Ls,B.CrudPage=Mr,B.CustomPageFallback=bo,B.CustomPageLoader=Or,B.DocumentHead=Jn,B.Layout=Gn,B.LoginContext=cr,B.LoginPage=dr,B.LogoutPage=Ba,B.Navbar=Vn,B.NotFoundPage=Tt,B.OTPLoginForm=bd,B.PasswordLoginForm=yd,B.PasswordResetRequired=es,B.RoleSelection=rs,B.SSOButtons=wd,B.SmartLink=fr,B.Topbar=Zn,B.UserProfileDrawer=Kn,B.ZangoApp=Sf,B.authApi=Jr,B.authService=W,B.buildApiUrl=Se,B.callApi=Pe,B.callDeleteApi=Os,B.callGetApi=Ts,B.callPatchApi=Us,B.callPostApi=Ms,B.callPutApi=Fs,B.changePassword=qs,B.changeRole=Rs,B.configApi=bn,B.deleteCookie=We,B.fetchAppInitData=Js,B.fetchUserProfile=Xs,B.fetchUserSessions=Ys,B.generateCSSVariables=Gt,B.generatePalette=at,B.generateQueryString=ri,B.getApiConfig=Ti,B.getApiTimeout=ei,B.getApiUrl=zt,B.getAppInitData=Is,B.getColor=go,B.getContrastColor=Ni,B.getCookie=ls,B.getEndpoint=Ra,B.getNextParam=Oe,B.getUserProfile=Ds,B.getUserSessions=Hs,B.getValidRedirectUrl=ge,B.isAuthenticatedViaCookie=Hn,B.isLightColor=po,B.logoCache=nt,B.logout=Ks,B.logoutAllSessions=Ws,B.logoutSession=zs,B.mfaApi=Yr,B.otpApi=Xr,B.passwordApi=Ct,B.performAppLogout=ro,B.performDirectLogout=so,B.performLogout=Zs,B.pingSession=oo,B.pingSessionSecurity=Gs,B.removeAllSessions=to,B.removeSession=eo,B.roleApi=Nc,B.saveUserProfile=Wt,B.setCookie=jn,B.setTwoFactor=oi,B.switchRole=js,B.toggleTwoFactor=Vs,B.updatePassword=Qs,B.updateSvgColors=hr,B.updateUserProfile=$s,B.uploadPhoto=si,B.uploadProfilePhoto=Bs,B.useApiConfig=Lt,B.useAppContext=Le,B.useAuth=ss,B.useAuthConfig=Ae,B.useAuthContext=tt,B.useLoginContext=ts,B.useRouteConfig=Li,B.useSmartNavigation=qn,B.validateRedirectUrl=xt,B.withMultiStepAuth=kf}));
|
|
369
369
|
//# sourceMappingURL=zango-crm-framework.umd.cjs.map
|