your-ai-workflow-firebase-os 1.2.18 → 1.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-DYteiM-1.cjs`),t=require(`./theme.config-0Lvwt5Bo.cjs`),n=require(`./ContactPopup-B666UTn5.cjs`),r=require(`./contactForm.config-CXyq-EbM.cjs`),i=require(`./supportForm.config-haLod4rv.cjs`);let a=require(`react`);a=e.i(a,1);let o=require(`firebase/firestore`),s=require(`firebase/auth`),c=require(`firebase/storage`),l=require(`react/jsx-runtime`),u=require(`react-router-dom`),d=require(`react-dom`);var f=(0,a.createContext)({user:null,userRole:null,loading:!0,signOut:async()=>{},registerUser:async()=>{},refreshUser:async()=>{},userInactive:!1,roleResolved:!1,activeOrg:null,activeWorkspace:null,checkOrg:async()=>{},workspaceAccess:{},userWorkspaces:[],switchWorkspace:async()=>{},createWorkspace:async()=>{},createOrg:async()=>{}});function p({children:e}){let t=n.St(),[r,i]=(0,a.useState)(null),[c,u]=(0,a.useState)(null),[d,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!0),[g,_]=(0,a.useState)(!1),v=a.default.useRef(null),y=a.default.useRef(null);return(0,a.useEffect)(()=>{let e;if(!n.Ct){h(!1),_(!0);return}let r=(0,s.onAuthStateChanged)(n.Ct,async r=>{if(r?.uid===y.current&&g){i(r);return}if(y.current=r?.uid||null,r){let a=localStorage.getItem(`fbos_role_${r.uid}`);a&&(u(a),_(!0),h(!1)),console.log(`[AuthContext] 1. onAuthStateChanged fired for user:`,r.uid),i(r);try{let i=(0,o.doc)(n.wt,`user_profiles`,r.uid),a=(await(0,o.getDoc)(i)).data()||{};(0,o.setDoc)(i,{uid:r.uid,email:r.email,displayName:r.displayName||a.displayName||``,lastLoginAt:new Date().toISOString(),createdAt:a.createdAt||new Date().toISOString()},{merge:!0}).catch(e=>console.error(`Failed to sync profile:`,e)),e&&e(),e=(0,o.onSnapshot)(i,e=>{if(e.exists()){let n=e.data(),a=n.role||`user`,s=``;try{s={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_ADMIN_EMAILS:void 0,VITE_FIREBASE_API_KEY:void 0,VITE_FIREBASE_APP_ID:void 0,VITE_FIREBASE_AUTH_DOMAIN:void 0,VITE_FIREBASE_MESSAGING_SENDER_ID:void 0,VITE_FIREBASE_PROJECT_ID:void 0,VITE_FIREBASE_STORAGE_BUCKET:void 0}?.VITE_ADMIN_EMAILS||``}catch{}let c=t.adminEmails||(s?s.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]);c.length>0&&!n.role&&c.map(e=>e.toLowerCase()).some(e=>r.email?.toLowerCase()===e)&&(a=`admin`,(0,o.updateDoc)(i,{role:`admin`}).catch(e=>console.error(`Error auto-setting admin role:`,e))),v.current===null&&(v.current=a),u(a),localStorage.setItem(`fbos_role_${r.uid}`,a),p(n.inactive===!0)}_(!0),h(!1)},e=>{console.warn(`[AuthContext] user_profiles snapshot error (safe to ignore during auth transition):`,e),_(!0),h(!1)})}catch(e){console.error(`[AuthContext] ERROR in auth resolution:`,e),_(!0),h(!1)}}else console.log(`[AuthContext] No user currently signed in.`),i(null),u(null),p(!1),_(!0),h(!1),v.current=null,e&&e()});return()=>{r(),e&&e()}},[]),(0,l.jsx)(f.Provider,{value:{user:r,userRole:c,loading:m,signOut:async()=>{await(0,s.signOut)(n.Ct),i(null)},registerUser:async(e,t,r,i)=>{let{createUserWithEmailAndPassword:a}=await import(`firebase/auth`),{user:c}=await a(n.Ct,e,t),l=`${r} ${i}`.trim();await(0,s.updateProfile)(c,{displayName:l});try{await c.getIdToken(!0),await(0,o.setDoc)((0,o.doc)(n.wt,`user_profiles`,c.uid),{uid:c.uid,email:c.email,displayName:l,createdAt:new Date().toISOString()},{merge:!0})}catch(e){console.warn(`Could not write public profile on registration.`,e)}await(0,s.sendEmailVerification)(c)},refreshUser:async()=>{n.Ct.currentUser&&(await n.Ct.currentUser.reload(),i(Object.assign(Object.create(Object.getPrototypeOf(n.Ct.currentUser)),n.Ct.currentUser)))},userInactive:d,roleResolved:g},children:e})}var m=()=>(0,a.useContext)(f);function h(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)([]),s=(0,a.useRef)(null),c=(0,u.useNavigate)();(0,a.useEffect)(()=>{function e(e){s.current&&!s.current.contains(e.target)&&t(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let d=(0,a.useRef)({users:[],submissions:[],requests:[]}),f=(e,t)=>{d.current[e]=t;let n=[...d.current.users,...d.current.submissions,...d.current.requests];n.sort((e,t)=>{let n=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return((t.time?.toDate?t.time.toDate().getTime():new Date(t.time).getTime())||0)-(n||0)}),i(n.slice(0,8))};(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.wt,`user_profiles`),(0,o.orderBy)(`createdAt`,`desc`),(0,o.limit)(5)),e=>{f(`users`,e.docs.map(e=>{let t=e.data();return{id:`u_${e.id}`,type:`user`,title:`New user registered`,subtitle:t.email||`Unknown`,time:t.createdAt}}))}),t=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.wt,`user_submissions`),(0,o.orderBy)(`submittedAt`,`desc`),(0,o.limit)(5)),e=>{f(`submissions`,e.docs.map(e=>{let t=e.data();return{id:`s_${e.id}`,type:`submission`,title:`New form submission`,subtitle:t.name||t.email||`Anonymous`,time:t.submittedAt}}))}),r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.wt,`user_requests`),(0,o.orderBy)(`submittedAt`,`desc`),(0,o.limit)(5)),e=>{f(`requests`,e.docs.map(e=>{let t=e.data();return{id:`r_${e.id}`,type:`request`,title:`New support request`,subtitle:t.name||t.submitterName||t.contactEmail||t.email||`Anonymous`,time:t.submittedAt}}))});return()=>{e(),t(),r()}},[]);let[p,m]=(0,a.useState)(()=>typeof window<`u`?parseInt(localStorage.getItem(`admin_notifications_last_read`)||`0`,10):0),h=()=>{let n=!e;if(t(n),n){let e=Date.now();m(e),typeof window<`u`&&localStorage.setItem(`admin_notifications_last_read`,e.toString())}},g=r.some(e=>{if(!e.time)return!0;let t=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return t>p||isNaN(t)}),_=e=>{t(!1),c(e===`user`?`/users`:e===`submission`?`/submissions`:`/requests`)},v=e=>{if(!e)return``;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)};return(0,l.jsxs)(`div`,{className:`relative z-50 flex-shrink-0 mr-1 md:mr-2`,ref:s,children:[(0,l.jsxs)(`button`,{onClick:h,className:`p-2 rounded-xl glass-panel transition-all border border-transparent relative text-notification-icon hover:bg-foreground/5 hover:border-[var(--panel-border)]`,"aria-label":`Admin Notifications`,children:[(0,l.jsx)(n.pt,{className:`w-4 h-4 md:w-5 md:h-5`}),g&&(0,l.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-red-500 rounded-full animate-pulse`})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`absolute top-full mt-2 right-[-60px] md:right-0 w-[320px] md:w-[400px] glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col origin-top-right overflow-hidden bg-[var(--panel-bg)]`,children:[(0,l.jsxs)(`div`,{className:`px-4 border-b border-[var(--panel-border)]/50 pb-3 pt-4 flex items-center justify-between`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] text-foreground tracking-wide`,children:`Notifications`}),(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md`,children:`Admin`})]}),(0,l.jsx)(`div`,{className:`max-h-[350px] overflow-y-auto w-full p-2 flex flex-col gap-1`,children:r.length===0?(0,l.jsx)(`div`,{className:`p-6 text-center text-foreground/40 text-[13px] font-medium`,children:`No recent activity.`}):r.map(e=>(0,l.jsxs)(`button`,{onClick:()=>_(e.type),className:`w-full flex items-start gap-3 p-3 rounded-xl hover:bg-foreground/5 transition-all text-left group border border-transparent hover:border-[var(--panel-border)]`,children:[(0,l.jsx)(`div`,{className:`mt-0.5 w-8 h-8 rounded-full flex items-center justify-center shrink-0 bg-foreground/5 text-notification-icon`,children:e.type===`user`?(0,l.jsx)(n.d,{className:`w-4 h-4`}):e.type===`submission`?(0,l.jsx)(n.k,{className:`w-4 h-4`}):(0,l.jsx)(n.et,{className:`w-4 h-4`})}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-2`,children:[(0,l.jsx)(`span`,{className:`text-[13px] font-semibold text-foreground group-hover:text-accent transition-colors truncate`,children:e.title}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/60 truncate`,children:e.subtitle}),(0,l.jsx)(`span`,{className:`text-[10px] font-mono tracking-wide text-foreground/40 mt-1`,children:v(e.time)})]})]},e.id))})]})})]})}var g=[{id:`contact`,hidden:!1},{id:`templates`,hidden:!1},{id:`setup`,hidden:!1}],_=e=>(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden}),v=[{id:`pages`,hidden:!1},{id:`forms`,hidden:!1},{id:`drive`,hidden:!1},{id:`users`,hidden:!1},{id:`theme`,hidden:!1},{id:`submissions`,hidden:!1},{id:`requests`,hidden:!1},{id:`settings`,hidden:!1},{id:`profile`,hidden:!1},{id:`support`,hidden:!0}],y={route:`/support`,template:`popup_form`,form:`support`,tabName:`Support`,iconName:``},b={templates:{label:`Templates`,path:`/templates`},setup:{label:`Setup`,path:`/setup`},contact:{label:`Contact`,path:`/contact`}};function x({customMenu:e,standalone:t}){let{user:r,userRole:i,signOut:s}=m(),c=(0,u.useNavigate)(),[d,f]=(0,a.useState)(!1),[p,v]=(0,a.useState)(null),[x,S]=(0,a.useState)(!1),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)(!1),D=r?.displayName||r?.email?.split(`@`)[0]||`User`,O=D.charAt(0).toUpperCase()+D.slice(1),{theme:k,toggleTheme:A,activeConfig:j}=n.bt(),ee=async()=>{await s(),c(`/`),f(!1)},[M,N]=(0,a.useState)({...b}),[P,F]=(0,a.useState)(g);(0,a.useEffect)(()=>{if(!n.wt)return;let e=(0,o.onSnapshot)((0,o.collection)(n.wt,`sys_pages`),e=>{let t={...b};e.forEach(e=>{let n=e.data();if(n.enabled===!1)return;let r=n.pageName||n.title||b[e.id]?.label||e.id,i=n.route||(e.id===`home`?`/`:`/`+e.id);t[e.id]={label:r,path:i}}),N(t)},e=>{console.warn(`sys_pages snapshot error (safe to ignore during auth transition):`,e)}),t=(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_configs`,`page_order`),e=>{F(e.exists()&&Array.isArray(e.data().order)?_(e.data().order):g)},e=>{console.warn(`page_order snapshot error (safe to ignore during auth transition):`,e)}),r=(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_tabs`,`support`),e=>{e.exists()&&e.data().pageName&&L(e.data().pageName)},e=>{console.warn(`support snapshot error (safe to ignore during auth transition):`,e)});return()=>{e(),t(),r()}},[]);let[I,L]=(0,a.useState)(y.tabName),R=(()=>{let e=new Set(P.filter(e=>e.hidden).map(e=>e.id)),t=new Set,n=[];return P.forEach(e=>{if(e.hidden||e.id===`home`)return;let r=M[e.id];r&&(n.push({label:r.label,path:r.path}),t.add(e.id))}),Object.entries(M).forEach(([r,i])=>{!t.has(r)&&!e.has(r)&&r!==`home`&&i.path!==`/`&&i.path!==`/support`&&n.push({label:i.label,path:i.path})}),n})(),z=e||R,B=(0,a.useRef)(null),V=(0,a.useRef)(null),[te,ne]=(0,a.useState)(z.length);(0,a.useEffect)(()=>{if(t||r)return;let e=()=>{let e=B.current,t=V.current;if(!e||!t)return;let n=e.clientWidth,r=t.querySelectorAll(`[data-measure-nav]`);if(r.length===0){ne(z.length);return}let i=0,a=!0;for(let e=0;e<r.length;e++)if(i+=r[e].offsetWidth+(e>0?28:0),i>n){a=!1;break}if(a){ne(z.length);return}let o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e].offsetWidth,i=o+t+(e>0?28:0);if(i+50>n)break;o=i,s++}ne(Math.max(s,1))},n=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(n);let i=new ResizeObserver(()=>requestAnimationFrame(e));return B.current&&i.observe(B.current),()=>{cancelAnimationFrame(n),i.disconnect()}},[z.map(e=>e.label).join(`|`),t,r,z.length]);let re=z.slice(0,te),H=z.slice(te);return(0,l.jsxs)(`nav`,{className:`flex items-center justify-between w-full max-w-7xl mx-auto z-40 p-4 md:p-10 relative`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 md:gap-4 z-50`,children:(0,l.jsxs)(u.Link,{to:`/`,className:`flex items-center gap-2 md:gap-3 group cursor-pointer z-50`,children:[(0,l.jsx)(`div`,{className:`w-9 h-9 md:w-10 md:h-10 rounded-xl glass-panel flex items-center justify-center glow-hover shadow-lg transition-transform duration-500 group-hover:rotate-[360deg] group-active:scale-95 overflow-hidden`,children:j?.logoUrl?(0,l.jsx)(`img`,{src:j.logoUrl,alt:`Logo`,className:`w-full h-full object-cover`}):(0,l.jsx)(n.Y,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,l.jsx)(`span`,{className:`hidden lg:block font-bold text-[22px] tracking-tight text-gradient transition-colors duration-300 drop-shadow-sm`,children:j?.appName||``})]})}),(0,l.jsx)(n.a,{children:x&&(0,l.jsx)(n.t,{formId:`contact`,onClose:()=>S(!1)})}),(0,l.jsx)(n.a,{children:C&&(0,l.jsx)(n.t,{formId:`support`,onClose:()=>w(!1)})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 md:gap-4 z-50 relative ml-auto flex-1 justify-end`,children:[!t&&!r&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{ref:V,"aria-hidden":`true`,className:`flex items-center gap-7 whitespace-nowrap px-1`,style:{position:`fixed`,top:-9999,left:0,visibility:`hidden`,height:0,pointerEvents:`none`},children:z.map((e,t)=>(0,l.jsxs)(`span`,{"data-measure-nav":!0,className:`text-[13px] md:text-[14px] font-bold tracking-wide flex items-center gap-1.5 shrink-0`,children:[e.label,e.submenu&&(0,l.jsx)(n.ot,{className:`w-3 h-3`})]},e.path||t))}),(0,l.jsxs)(`div`,{className:`hidden sm:flex items-center gap-7 mr-6 w-full max-w-full justify-end relative`,ref:B,children:[re.map((e,t)=>(0,l.jsxs)(`div`,{className:`relative shrink-0`,onMouseEnter:()=>v(e.label),onMouseLeave:()=>v(null),children:[e.path?(0,l.jsxs)(u.Link,{to:e.path,className:`text-[13px] md:text-[14px] font-bold tracking-wide text-foreground/50 hover:text-accent transition-all cursor-pointer flex items-center gap-1.5`,children:[e.label,e.submenu&&(0,l.jsx)(n.ot,{className:`w-3 h-3`})]}):(0,l.jsxs)(`button`,{onClick:e.action,className:`text-[13px] md:text-[14px] font-bold tracking-wide text-foreground/50 hover:text-accent transition-all flex items-center gap-1.5`,children:[e.label,e.submenu&&(0,l.jsx)(n.ot,{className:`w-3 h-3`})]}),e.submenu&&p===e.label&&(0,l.jsx)(`div`,{className:`absolute top-[100%] left-0 pt-2 z-50`,children:(0,l.jsx)(n.i.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:`min-w-[180px] max-h-[300px] overflow-y-auto styled-scrollbars bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-xl flex flex-col py-2`,children:e.submenu.map((e,t)=>e.path?(0,l.jsx)(u.Link,{to:e.path,className:`px-5 py-3 text-[13px] font-medium text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t):(0,l.jsx)(`button`,{onClick:e.action,className:`px-5 py-3 text-left w-full text-[13px] font-medium text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t))})})]},`${e.path||`no-path`}-${t}`)),H.length>0&&(0,l.jsxs)(`div`,{className:`relative flex items-center shrink-0`,onMouseEnter:()=>f(`overflow`),children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`overflow`?!1:`overflow`),className:`p-1 rounded-lg transition-colors flex items-center ${d===`overflow`?`bg-foreground/5 text-accent`:`text-foreground/50 hover:bg-foreground/5 hover:text-accent`}`,children:(0,l.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-5 h-5`,children:[(0,l.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,l.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`}),(0,l.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`})]})}),(0,l.jsx)(n.a,{children:d===`overflow`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsx)(n.i.div,{initial:{opacity:0,y:5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:5,scale:.98},className:`absolute top-[100%] pt-1 right-0 min-w-[200px] max-h-[350px] overflow-y-auto styled-scrollbars bg-background border border-[var(--panel-border)] rounded-2xl shadow-xl flex flex-col py-2 z-50 origin-top-right`,children:H.map((e,t)=>e.path?(0,l.jsx)(u.Link,{to:e.path,onClick:()=>f(!1),className:`px-5 py-3 text-[13px] font-bold tracking-wide text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t):(0,l.jsx)(`button`,{onClick:()=>{e.action&&e.action(),f(!1)},className:`px-5 py-3 text-left w-full text-[13px] font-bold tracking-wide text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t))})]})})]})]}),j?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:A,className:`p-2 mr-2 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40 shrink-0`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4 md:w-5 md:h-5`}):(0,l.jsx)(n.E,{className:`w-4 h-4 md:w-5 md:h-5`})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(u.Link,{to:`/login`,className:`hidden sm:flex text-[14px] font-bold tracking-wide text-foreground/80 hover:text-accent transition-colors px-3 py-1.5 shrink-0`,children:`Sign In`}),(0,l.jsx)(u.Link,{to:`/register`,className:`hidden sm:flex text-[13px] md:text-[14px] font-bold tracking-wide px-4 py-1.5 md:px-5 md:py-2 rounded-xl btn-primary transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5 active:scale-95 items-center justify-center ml-2`,children:`Get Started`}),(0,l.jsxs)(`div`,{className:`relative sm:hidden ml-1`,children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`guest`?!1:`guest`),className:`p-2 rounded-xl glass-panel glow-hover border transition-all ${d===`guest`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,l.jsx)(n.O,{className:`w-5 h-5 text-accent/80`})}),(0,l.jsx)(n.a,{children:d===`guest`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.95},className:`absolute top-full right-0 mt-3 w-[220px] p-2 glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col gap-1 origin-top-right`,children:[(0,l.jsxs)(u.Link,{to:`/templates`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.P,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Templates`})]}),(0,l.jsxs)(u.Link,{to:`/setup`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.y,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Setup`})]}),(0,l.jsxs)(u.Link,{to:`/contact`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full text-left`,children:[(0,l.jsx)(n.k,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Contact`})]}),(0,l.jsxs)(`div`,{className:`pt-2 mt-1 border-t border-[var(--panel-border)]/50 flex flex-col gap-1`,children:[(0,l.jsxs)(u.Link,{to:`/login`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full`,children:[(0,l.jsx)(n.A,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign In`})]}),(0,l.jsx)(u.Link,{to:`/register`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl btn-primary w-full shadow-lg hover:-translate-y-0.5 transition-transform text-white`,children:(0,l.jsx)(`span`,{className:`text-[14px] font-bold mx-auto`,children:`Get Started`})})]})]})]})})]})]})]}),!t&&r&&(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2 mr-1`,children:[i===`admin`&&(0,l.jsx)(h,{}),j?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:A,className:`p-2 ml-1 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4 md:w-5 md:h-5`}):(0,l.jsx)(n.E,{className:`w-4 h-4 md:w-5 md:h-5`})})]}),(0,l.jsxs)(`div`,{className:`relative z-50 flex items-center gap-3`,children:[(0,l.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,l.jsxs)(`button`,{onClick:()=>f(d===`user`?!1:`user`),className:`flex items-center gap-2 group p-1 sm:pr-2.5 rounded-full glass-panel hover:bg-foreground/5 transition-all duration-300 border ${d===`user`?`border-accent/40 bg-foreground/5`:`border-transparent hover:border-[var(--panel-border)]`}`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-9 md:h-9 rounded-full bg-accent/10 flex items-center justify-center overflow-hidden border border-[var(--panel-border)] group-hover:border-accent/30 transition-colors shrink-0 text-accent`,children:r.photoURL&&!T?(0,l.jsx)(`img`,{src:r.photoURL,alt:`Profile`,className:`w-full h-full object-cover`,onError:()=>E(!0)}):(0,l.jsx)(n.d,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,l.jsxs)(`div`,{className:`hidden sm:flex flex-col text-left mr-1 justify-center min-w-[70px] max-w-[160px]`,children:[(0,l.jsx)(`span`,{className:`text-[12px] font-extrabold leading-tight text-foreground truncate w-full`,children:O}),(0,l.jsx)(`span`,{className:`text-[10px] font-mono tracking-wider leading-tight text-accent truncate w-full mt-0.5 uppercase font-bold`,children:i===`admin`?`Admin`:`Free User`})]})]}),(0,l.jsx)(n.a,{children:d===`user`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`absolute top-full mt-2 right-0 w-[280px] md:w-[320px] glass-panel border border-[var(--panel-border)] rounded-2xl p-2 shadow-2xl z-50 flex flex-col origin-top-right`,children:[(0,l.jsxs)(`div`,{className:`p-3 border-b border-[var(--panel-border)]/50 mb-1 flex flex-col gap-1.5`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[15px] text-foreground truncate`,children:O}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate font-mono`,children:r.email})]}),(0,l.jsxs)(`div`,{className:`py-1`,children:[(0,l.jsxs)(u.Link,{to:`/profile`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.d,{className:`w-3 h-3 text-accent`})}),`Profile Settings`]}),(0,l.jsxs)(u.Link,{to:`/drive`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.V,{className:`w-3 h-3 text-accent`})}),`Drive`]}),i===`admin`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(u.Link,{to:`/users`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.u,{className:`w-3 h-3 text-accent`})}),`Users`]}),(0,l.jsxs)(u.Link,{to:`/submissions`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.k,{className:`w-3 h-3 text-accent`})}),`Submissions`]}),(0,l.jsxs)(u.Link,{to:`/requests`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.et,{className:`w-3 h-3 text-accent`})}),`Requests`]}),(0,l.jsxs)(u.Link,{to:`/settings`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.y,{className:`w-3 h-3 text-accent`})}),`Settings`]}),(0,l.jsxs)(u.Link,{to:`/pages`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.L,{className:`w-3 h-3 text-accent`})}),`Pages`]})]}),i!==`admin`&&(0,l.jsxs)(u.Link,{to:`/support`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3 text-left`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.et,{className:`w-3 h-3 text-accent`})}),I]})]}),(0,l.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,l.jsxs)(`button`,{onClick:ee,className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-bold tracking-wide hover:bg-red-500/10 hover:text-red-500 text-foreground/70 transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-red-500/5 flex items-center justify-center shrink-0 text-red-500`,children:(0,l.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3`,children:[(0,l.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,l.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,l.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]})}),`Sign Out`]})})]})]})})]}),(0,l.jsxs)(`div`,{className:`relative sm:hidden`,children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`nav`?!1:`nav`),className:`p-2 rounded-xl glass-panel glow-hover border transition-all ${d===`nav`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,l.jsx)(n.O,{className:`w-5 h-5 text-accent/80`})}),(0,l.jsx)(n.a,{children:d===`nav`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.95},className:`absolute top-full right-0 mt-3 w-[220px] p-2 glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col gap-1 origin-top-right`,children:[(0,l.jsxs)(u.Link,{to:`/profile`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.d,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Profile Settings`})]}),(0,l.jsxs)(u.Link,{to:`/drive`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.V,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Drive`})]}),(0,l.jsxs)(u.Link,{to:`/dashboard`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.I,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Dashboard`})]}),i===`admin`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(u.Link,{to:`/users`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.u,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Users`})]}),(0,l.jsxs)(u.Link,{to:`/submissions`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.k,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Submissions`})]}),(0,l.jsxs)(u.Link,{to:`/requests`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.et,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Requests`})]}),(0,l.jsxs)(u.Link,{to:`/settings`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.y,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Settings`})]})]}),i!==`admin`&&(0,l.jsxs)(u.Link,{to:`/support`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full text-left`,children:[(0,l.jsx)(n.et,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Support`})]}),(0,l.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,l.jsx)(`button`,{onClick:ee,className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-red-500/10 text-red-500/80 hover:text-red-500 transition-all w-full`,children:(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign Out`})})})]})]})})]})]})]}),t&&(0,l.jsx)(l.Fragment,{children:j?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:A,className:`p-2 ml-1 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4`}):(0,l.jsx)(n.E,{className:`w-4 h-4`})})})]})]})}var S={hero:{title:`Firebase OS.`,showSubtitle:!0,subtitle:`The Open-Source Firebase Starter`,text:`A production-ready Firebase backend template with Auth, Firestore prefix rules, and a clean dashboard — ready for vibe-coded apps.`,buttons:{primary:{text:`Start Building Free`,action:`register`},secondary:{text:`Sign In`,action:`sign_in`}}}};function C(){let[e,t]=(0,a.useState)(null),r=n.St()?.defaultConfigs?.home||S,[i,s]=(0,a.useState)(()=>{try{let e=localStorage.getItem(`fbos_home_config`);if(e)return JSON.parse(e)}catch{}return r}),[c,d]=(0,a.useState)(!0);if((0,a.useEffect)(()=>(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_pages`,`home`),e=>{if(e.exists()){let t=e.data();s(t),localStorage.setItem(`fbos_home_config`,JSON.stringify(t))}else s(r),localStorage.removeItem(`fbos_home_config`)}),[]),!c)return null;let f=i||S,p=f?.hero?.showSubtitle??!0;f?.hero?.subtitleEmoji;let m=f?.hero?.title||f?.heroTitle||`The Open-Source Firebase Starter`,h=f?.hero?.subtitle||f?.heroSubtitle||`The Open-Source Firebase Starter`,g=f?.hero?.text||f?.heroText||`A production-ready Firebase backend template with Auth, Firestore prefix rules, and a clean dashboard — ready for vibe-coded apps.`;f?.hero?.buttons?.primary?.text||f?.primaryBtnText,f?.hero?.buttons?.primary?.action||f?.primaryBtnAction;let _=f?.hero?.buttons?.primary||{},v=f?.hero?.buttons?.secondary||{},y=(e,n,r,i)=>{let a=e.text||n,o=e.action||r,s=i.replace(/rounded-\[.*?\]|rounded-\w+/g,``).replace(/border /g,``).replace(/border-\[.*?\]/g,``),c={borderRadius:`var(--btn-radius, 0.75rem)`};if(o===`form`){let n=e.form||`contact`;return(0,l.jsx)(`button`,{onClick:()=>t(n),className:s,style:c,children:a})}if(o===`redirect`){let t=e.url||`/`;return t.startsWith(`http`)?(0,l.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:s,style:c,children:a}):(0,l.jsx)(u.Link,{to:t,className:s,style:c,children:a})}return(0,l.jsx)(u.Link,{to:{sign_in:`/login`,register:`/register`}[o]||`/register`,className:s,style:c,children:a})};return(0,l.jsxs)(`main`,{className:`flex-1 flex flex-col items-center justify-center w-full max-w-5xl mx-auto mt-4 md:mt-12 mb-16 md:mb-24 z-10 relative`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},className:`text-center mb-8 md:mb-12`,children:[p&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{delay:.2},className:`inline-flex items-center gap-2 md:gap-3 px-5 md:px-6 py-2 md:py-2.5 mb-8 md:mb-10 text-[13px] md:text-[15px] font-semibold tracking-wide uppercase rounded-full glass-panel text-foreground glow-hover cursor-pointer`,children:[h===S.hero.subtitle&&(0,l.jsx)(n.s,{className:`w-4 h-4 text-accent`}),` `,h]}),(0,l.jsx)(n.i.h1,{className:`text-5xl sm:text-6xl md:text-7xl lg:text-[5.5rem] font-extrabold tracking-tight mb-6 md:mb-8 text-gradient animate-float leading-[1.1] md:leading-[1.15] px-2`,children:m}),(0,l.jsx)(`p`,{className:`text-[15px] sm:text-lg md:text-xl lg:text-[22px] text-foreground/60 max-w-3xl mx-auto font-medium leading-[1.6] md:leading-[1.7] mb-10 md:mb-14 px-6 md:px-4`,children:g}),(0,l.jsxs)(n.i.div,{className:`flex flex-col sm:flex-row items-center justify-center gap-4 sm:gap-6 w-full max-w-2xl mx-auto px-6`,initial:{opacity:0},animate:{opacity:1},transition:{delay:.5},children:[y(_,`Start Building Free`,`register`,`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`),y(v,`Sign In`,`sign_in`,`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-secondary text-[15px] transition-all duration-300 flex items-center justify-center hover:-translate-y-1`)]})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsx)(n.t,{onClose:()=>t(null),formId:e})})]})}function w(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),o=(0,u.useNavigate)(),{registerUser:c}=m();return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 md:mt-8 mb-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Create an account`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Join Firebase OS and start building today.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 mb-6 text-[14px] font-medium text-red-400 bg-red-500/10 rounded-xl border border-red-500/20`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let n=new FormData(e.currentTarget),r=n.get(`email`),a=n.get(`password`),s=n.get(`firstName`),d=n.get(`lastName`);if(a.length<6){i(`Password must be at least 6 characters.`),t(!1);return}try{await c(r,a,s,d),o(`/verify`)}catch(e){e?.code===`auth/email-already-in-use`?i((0,l.jsxs)(`span`,{children:[`An account with this email already exists.`,` `,(0,l.jsx)(u.Link,{to:`/login?email=${encodeURIComponent(r)}`,className:`font-bold underline hover:text-accent transition-colors`,children:`Sign in?`})]})):e?.code===`auth/weak-password`?i(`Password must be at least 6 characters.`):i(e?.message||`An error occurred during registration.`)}finally{t(!1)}},children:[(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,l.jsx)(n.r,{name:`firstName`,label:`First Name`,type:`text`,placeholder:`John`,required:!0}),(0,l.jsx)(n.r,{name:`lastName`,label:`Last Name`,type:`text`,placeholder:`Doe`,required:!0})]}),(0,l.jsx)(n.r,{name:`email`,label:`Email`,type:`email`,placeholder:`name@example.com`,required:!0}),(0,l.jsx)(n.r,{name:`password`,label:`Password`,type:`password`,placeholder:`••••••••`,required:!0}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsxs)(n.n,{type:`submit`,className:`w-full py-3 text-[15px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,isLoading:e,children:[`Create Account `,(0,l.jsx)(n.mt,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,l.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,l.jsxs)(n.n,{variant:`secondary`,onClick:async()=>{t(!0);try{await(0,s.signInWithPopup)(n.Ct,new s.GoogleAuthProvider)}catch(e){e instanceof Error&&i(e.message)}finally{t(!1)}},className:`w-full py-3 text-[15px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,disabled:e,children:[(0,l.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`})]}),`Sign up with Google`]}),(0,l.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`Already have an account? `,(0,l.jsx)(u.Link,{to:`/login`,className:`text-accent hover:underline font-bold ml-1`,children:`Sign in`})]})]})]})})}function T(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),[o]=(0,u.useSearchParams)(),c=(0,u.useNavigate)(),[d]=(0,a.useState)(o.get(`email`)||``);return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 md:mt-8 mb-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Welcome back`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Sign in to Firebase OS.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 mb-6 text-[14px] font-medium text-red-400 bg-red-500/10 rounded-xl border border-red-500/20`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let r=new FormData(e.currentTarget),a=r.get(`email`),d=r.get(`password`);try{await(0,s.signInWithEmailAndPassword)(n.Ct,a,d),c(o.get(`from`)||`/dashboard`,{replace:!0})}catch(e){e?.code===`auth/invalid-credential`||e?.code===`auth/user-not-found`||e?.code===`auth/wrong-password`?i((0,l.jsxs)(`span`,{children:[`Email or Password are incorrect.`,` `,(0,l.jsx)(u.Link,{to:`/reset-password`,className:`font-bold underline hover:text-red-400 transition-colors`,children:`Reset password?`})]})):i(e?.message||`Invalid credentials.`),t(!1)}},children:[(0,l.jsx)(n.r,{name:`email`,label:`Email`,type:`email`,defaultValue:d,placeholder:`name@example.com`,required:!0}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex justify-between items-center pr-1`,children:[(0,l.jsx)(`label`,{className:`text-[14px] md:text-[15px] tracking-wide font-medium text-foreground/80 select-none pb-1`,children:`Password`}),(0,l.jsx)(u.Link,{to:`/reset-password`,className:`text-[13px] md:text-[14px] text-accent hover:underline font-bold tracking-wide`,children:`Forgot Password?`})]}),(0,l.jsx)(n.r,{name:`password`,type:`password`,placeholder:`••••••••`,required:!0})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsxs)(n.n,{type:`submit`,className:`w-full py-3 text-base font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,isLoading:e,children:[`Sign In `,(0,l.jsx)(n.mt,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,l.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,l.jsxs)(n.n,{variant:`secondary`,onClick:async()=>{t(!0);try{await(0,s.signInWithPopup)(n.Ct,new s.GoogleAuthProvider),c(o.get(`from`)||`/dashboard`,{replace:!0})}catch(e){e instanceof Error&&i(e.message)}finally{t(!1)}},className:`w-full py-3 text-base font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,disabled:e,children:[(0,l.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`})]}),`Sign in with Google`]}),(0,l.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`New here? `,(0,l.jsx)(u.Link,{to:`/register`,className:`text-accent hover:underline font-bold ml-1`,children:`Create account`})]})]})]})})}function E(){let{user:e,refreshUser:t}=m(),r=(0,u.useNavigate)(),[i,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(!1),[f,p]=(0,a.useState)(``);return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 md:p-8 lg:p-10 rounded-3xl glass-panel relative glow-hover text-center shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`w-14 h-14 md:w-16 md:h-16 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mx-auto mb-5 md:mb-6 animate-float shadow-xl`,children:(0,l.jsx)(n.k,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,l.jsx)(`h1`,{className:`text-2xl md:text-3xl font-extrabold mb-3 text-foreground tracking-tight`,children:`Verify your email`}),(0,l.jsxs)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/60 mb-6 md:mb-8 leading-[1.6] tracking-wide`,children:[`We've sent a verification link to `,(0,l.jsx)(`span`,{className:`font-semibold text-foreground`,children:e?.email}),`. Please check your inbox (and spam folder) to verify your account and access your dashboard.`]}),f&&(0,l.jsx)(`div`,{className:`p-3 md:p-4 mb-5 md:mb-6 text-[13px] md:text-[14px] font-medium rounded-xl border ${f.includes(`Failed`)||f.includes(`not verified`)||f.includes(`wrong`)?`text-red-400 bg-red-500/10 border-red-500/20`:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`}`,children:f}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[(0,l.jsx)(n.n,{variant:`primary`,onClick:async()=>{o(!0),p(``);try{if(n.Ct.currentUser){if(await n.Ct.currentUser.reload(),!n.Ct.currentUser.emailVerified){p(`Email is not verified yet. Please check your inbox.`),o(!1);return}await n.Ct.currentUser.getIdToken(!0),await t(),r(`/dashboard`)}}catch{p(`Something went wrong. Please try again.`),o(!1)}},isLoading:i,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,children:`I've verified my email`}),(0,l.jsx)(n.n,{variant:`ghost`,onClick:async()=>{if(e){d(!0),p(``);try{await(0,s.sendEmailVerification)(e),p(`Verification email sent! Please check your inbox.`)}catch(e){e?.code===`auth/too-many-requests`?p(`Failed to resend: Please wait a minute before trying again.`):p(e?.message||`Failed to resend. Please try again later.`)}finally{d(!1)}}},isLoading:c,className:`w-full py-2.5 md:py-3 text-[13px] md:text-[14px] font-semibold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,children:`Resend verification link`})]})]})})}var D={pages:{path:`/pages`,label:`Pages`,icon:n.L,roles:[`admin`]},forms:{path:`/forms`,label:`Forms`,icon:n.S,roles:[`admin`]},drive:{path:`/drive`,label:`Drive`,icon:n.V,roles:[`admin`,`user`,`editor`,`guest`]},users:{path:`/users`,label:`Users`,icon:n.u,roles:[`admin`]},theme:{path:`/theme`,label:`Theme`,icon:n.T,roles:[`admin`]},submissions:{path:`/submissions`,label:`Submissions`,icon:n.k,roles:[`admin`]},requests:{path:`/requests`,label:`Requests`,icon:n.et,roles:[`admin`]},settings:{path:`/settings`,label:`Settings`,icon:n.y,roles:[`admin`]},profile:{path:`/profile`,label:`Profile`,icon:n.d,roles:[`admin`,`user`,`editor`,`guest`]},support:{path:`/support`,label:`Support`,icon:n.et,roles:[`user`,`editor`,`guest`]}};function O({customTabs:e=[]}){let{pathname:t}=(0,u.useLocation)(),{userRole:r}=m(),[i,s]=(0,a.useState)(!1),c=(0,a.useRef)(null),[d,f]=(0,a.useState)({}),[p,h]=(0,a.useState)(v);(0,a.useEffect)(()=>{try{let e=localStorage.getItem(`fbos_nav_tabs`);e&&f(JSON.parse(e));let t=localStorage.getItem(`fbos_nav_order`);t&&h(JSON.parse(t))}catch{}let e=(0,o.onSnapshot)((0,o.collection)(n.wt,`sys_tabs`),e=>{let t={};e.forEach(e=>{t[e.id]=e.data()}),f(t),localStorage.setItem(`fbos_nav_tabs`,JSON.stringify(t))},e=>{console.warn(`sys_tabs snapshot error:`,e)}),t=(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_configs`,`tab_order`),e=>{let t=e.exists()&&Array.isArray(e.data().order)?_(e.data().order):v;h(t),localStorage.setItem(`fbos_nav_order`,JSON.stringify(t))},e=>{console.warn(`tab_order snapshot error:`,e)});return()=>{e(),t()}},[]),(0,a.useEffect)(()=>{function e(e){c.current&&!c.current.contains(e.target)&&s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let g=[...(()=>{let e={};Object.entries(D).forEach(([t,n])=>{e[t]={id:t,...n,exact:!0}}),Object.entries(d).forEach(([t,r])=>{let i=e[t],a=i?.icon??n.L;if(r?.iconName){let e=r.iconName.trim(),t=e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);n.o[t]?a=n.o[t]:n.o[e]&&(a=n.o[e])}let o=i?.roles??[`admin`];r?.pageType===`admin`?o=[`admin`]:r?.pageType===`shared`?o=[`admin`,`editor`,`user`]:r?.pageType===`private`?o=[`admin`,`user`]:r?.pageType===`public`&&(o=[`admin`,`user`,`editor`,`guest`]),e[t]={id:t,path:r?.route?r.route.startsWith(`/`)?r.route:`/`+r.route:i?.path??`/`+t,label:r?.tabName||r?.pageTitle||r?.pageName||i?.label||t,icon:a,roles:o,exact:!0}});let t=[],r=new Set;p.forEach(n=>{n.hidden||e[n.id]&&(t.push(e[n.id]),r.add(n.id))});let i=[];return Object.keys(d).forEach(t=>{!r.has(t)&&!p.some(e=>e.id===t)&&e[t]&&i.push(e[t])}),i.length>0&&t.push(...i),t})(),...e.map(e=>({...e,id:e.path}))].filter(e=>e.id===`support`&&r===`admin`?!1:Array.isArray(e.roles)?e.roles.includes(r||`guest`):!1),y=(0,a.useRef)(null),b=(0,a.useRef)(null),[x,S]=(0,a.useState)(g.length);(0,a.useEffect)(()=>{let e=()=>{let e=y.current,t=b.current;if(!e||!t)return;let n=e.clientWidth,r=t.querySelectorAll(`[data-measure-tab]`);if(r.length===0){S(g.length);return}let i=0,a=!0;for(let e=0;e<r.length;e++)if(i+=r[e].offsetWidth+(e>0?40:0),i>n){a=!1;break}if(a){S(g.length);return}let o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e].offsetWidth,i=o+t+(e>0?40:0);if(i+52>n)break;o=i,s++}S(Math.max(s,1))},t=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(t);let n=new ResizeObserver(()=>requestAnimationFrame(e));return y.current&&n.observe(y.current),()=>{cancelAnimationFrame(t),n.disconnect()}},[g.map(e=>e.id+e.label).join(`|`),g.length]);let C=g.slice(0,x),w=g.slice(x),T=e=>e.exact?t===e.path:t.startsWith(e.path),E=w.some(e=>T(e));return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{ref:b,"aria-hidden":`true`,className:`flex items-center gap-6 md:gap-10 whitespace-nowrap px-1`,style:{position:`fixed`,top:-9999,left:0,visibility:`hidden`,pointerEvents:`none`},children:g.map(e=>{let t=e.icon;return(0,l.jsxs)(`span`,{"data-measure-tab":!0,className:`flex items-center gap-2 text-[14.5px] font-semibold shrink-0 pb-3`,children:[(0,l.jsx)(t,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)})}),(0,l.jsxs)(`div`,{ref:y,className:`w-full flex items-center gap-6 md:gap-10 mb-8 border-b border-[var(--panel-border)] px-1 whitespace-nowrap relative`,children:[C.map(e=>{let t=T(e),n=e.icon;return(0,l.jsxs)(u.Link,{to:e.path||`/`,className:`flex items-center gap-2 text-[14.5px] font-semibold transition-all duration-300 pb-3 -mb-[1px] border-b-2 shrink-0 ${t?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,children:[(0,l.jsx)(n,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)}),w.length>0&&(0,l.jsxs)(`div`,{className:`relative shrink-0 ml-auto`,ref:c,children:[(0,l.jsx)(`button`,{onClick:()=>s(!i),className:`flex items-center justify-center transition-all duration-300 pb-3 -mb-[1px] border-b-2 cursor-pointer ${E?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,title:`More items`,children:(0,l.jsx)(n.q,{className:`w-5 h-5`})}),(0,l.jsx)(n.a,{children:i&&(0,l.jsx)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:`absolute top-[100%] right-0 mt-2 min-w-[200px] bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-xl z-50 flex flex-col py-2 overflow-hidden`,children:w.map(e=>{let t=T(e),n=e.icon;return(0,l.jsxs)(u.Link,{to:e.path||`/`,onClick:()=>s(!1),className:`flex items-center gap-3 px-5 py-3 text-[14px] font-medium transition-colors ${t?`text-accent bg-accent/5`:`text-foreground/70 hover:text-foreground hover:bg-foreground/5`}`,children:[(0,l.jsx)(n,{className:`w-4 h-4`}),e.label]},e.path||e.id)})})})]})]})]})}function k(){let{user:e,refreshUser:t}=m(),[r,i]=(0,a.useState)(e?.displayName||``),[u,d]=(0,a.useState)(e?.email||``),[f,p]=(0,a.useState)(e?.photoURL||``),[h,g]=(0,a.useState)(!1),[_,v]=(0,a.useState)(null),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(``),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)(!1),[D,k]=(0,a.useState)(!0);a.default.useEffect(()=>{i(e?.displayName||``),d(e?.email||``),p(e?.photoURL||``)},[e?.uid,e?.displayName,e?.email,e?.photoURL]);let A=async t=>{if(e)try{let r=[`mem_files`,`admin_files`];(await(0,o.getDocs)((0,o.collection)(n.wt,`sys_tabs`))).forEach(e=>{let t=e.data(),n=(t.tabName||e.id).toLowerCase().replace(/[^a-z0-9]+/g,`_`);t.pageType===`shared`&&r.push(`mem_${n}_records`),t.pageType===`admin`&&r.push(`admin_${n}_records`)});for(let i of r)try{let r=await(0,o.getDocs)((0,o.query)((0,o.collection)(n.wt,i),(0,o.where)(`uid`,`==`,e.uid)));if(r.empty)continue;let a=(0,o.writeBatch)(n.wt);r.docs.forEach(e=>a.update(e.ref,{creatorAvatar:t})),await a.commit()}catch{}}catch(e){console.error(`Error propagating avatar to records:`,e)}};return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Profile Settings`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/profile`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(O,{})}),(0,l.jsx)(n.a,{children:_&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.98,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:-10},className:`p-4 mb-6 rounded-2xl border flex flex-col sm:flex-row sm:items-center gap-3 ${_.type===`error`?`bg-red-500/10 border-red-500/20 text-red-400`:`bg-accent/10 border-accent/20 text-accent`}`,children:[_.type===`success`?(0,l.jsx)(n.tt,{className:`w-5 h-5 shrink-0`}):(0,l.jsx)(n.nt,{className:`w-5 h-5 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px] font-semibold tracking-wide leading-relaxed`,children:_.text})]})}),(0,l.jsx)(`form`,{onSubmit:async i=>{if(i.preventDefault(),e){g(!0),v(null);try{r!==e.displayName&&await(0,s.updateProfile)(e,{displayName:r});let i=!1;if(u!==e.email){let t=await(0,s.fetchSignInMethodsForEmail)(n.Ct,u);if(t&&t.length>0)throw Error(`An account with this email already exists.`);await(0,s.verifyBeforeUpdateEmail)(e,u),i=!0}if(y){if(y!==x)throw Error(`Passwords do not match.`);if(y.length<6)throw Error(`Password must be at least 6 characters.`);await(0,s.updatePassword)(e,y),b(``),S(``)}await t(),v(i?{text:`Profile updated. A verification link has been sent to your new email address.`,type:`success`}:{text:`Profile successfully updated.`,type:`success`})}catch(e){console.error(e),e.code===`auth/requires-recent-login`?v({text:`For security, please sign out and sign back in before changing your email or password.`,type:`error`}):v({text:e.message||`Failed to update profile.`,type:`error`})}finally{g(!1)}}},className:`w-full flex flex-col`,children:(0,l.jsxs)(`div`,{className:`glass-panel w-full p-8 md:p-12 rounded-3xl border border-[var(--panel-border)] shadow-2xl space-y-8 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-6 pb-6 border-b border-[var(--panel-border)]/50`,children:[(0,l.jsxs)(`div`,{className:`w-24 h-24 md:w-28 md:h-28 rounded-full glass-panel border-4 border-[var(--panel-border)] shadow-xl bg-accent/10 flex items-center justify-center relative overflow-hidden shrink-0 group transition-transform duration-300 hover:scale-[1.02]`,children:[(T||f&&D&&!C)&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-10`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),f&&!C?(0,l.jsx)(`img`,{src:f,alt:`Avatar`,className:`w-full h-full object-cover transition-opacity duration-300 ${D?`opacity-0`:`opacity-100`}`,onLoad:()=>k(!1),onError:()=>{w(!0),k(!1)}}):(0,l.jsx)(n.d,{className:`w-10 h-10 md:w-12 md:h-12 text-accent`}),!T&&(0,l.jsxs)(`div`,{className:`absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2 z-10 backdrop-blur-sm`,children:[(0,l.jsxs)(`label`,{className:`flex flex-col items-center justify-center cursor-pointer p-2 rounded-full hover:bg-white/20 transition-colors text-white`,title:`Upload Photo`,children:[(0,l.jsx)(n.lt,{className:`w-5 h-5`}),(0,l.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:async r=>{let i=r.target.files?.[0];if(!(!i||!e)){if(i.size>2*1024*1024){v({text:`File too large. Please select an image under 2MB.`,type:`error`});return}E(!0),w(!1),k(!0);try{let r=(0,c.ref)(n.Et,`user_avatars/${e.uid}/file.png`);await(0,c.uploadBytes)(r,i,{customMetadata:{ownerId:e.uid}});let a=await(0,c.getDownloadURL)(r);await(0,s.updateProfile)(e,{photoURL:a}),await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,e.uid),{avatar:a}),p(a),await t(),A(a),v({text:`Avatar successfully updated!`,type:`success`})}catch(e){console.error(e),v({text:`Failed to upload photo.`,type:`error`})}finally{E(!1)}}},className:`hidden`})]}),f&&(0,l.jsx)(`button`,{type:`button`,onClick:async()=>{if(e){E(!0),w(!1),k(!1);try{await(0,c.deleteObject)((0,c.ref)(n.Et,`user_avatars/${e.uid}/file.png`)).catch(e=>console.error(e)),await(0,s.updateProfile)(e,{photoURL:``}),await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,e.uid),{avatar:``}),p(``),await t(),A(``),v({text:`Avatar removed.`,type:`success`})}catch(e){console.error(e),v({text:`Failed to delete photo.`,type:`error`})}finally{E(!1)}}},className:`p-2 rounded-full hover:bg-red-500/80 text-white transition-colors`,title:`Delete Photo`,children:(0,l.jsx)(n.h,{className:`w-5 h-5`})})]})]}),(0,l.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,l.jsx)(`h3`,{className:`font-extrabold text-2xl text-foreground mb-1`,children:r||`Firebase OS User`}),(0,l.jsx)(`div`,{className:`text-[12px] font-mono uppercase tracking-widest text-accent bg-accent/10 px-2.5 py-1 rounded-md border border-accent/20 inline-block`,children:e?.emailVerified?`Verified Account`:`Unverified`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/40 mt-2 font-medium`,children:e?.email})]})]}),(0,l.jsxs)(`div`,{className:`space-y-6`,children:[(0,l.jsx)(`h3`,{className:`text-[16px] font-extrabold text-foreground flex items-center gap-2`,children:`Account Details`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,l.jsx)(n.r,{name:`name`,value:r,onChange:e=>i(e.target.value),label:`Display Name`,placeholder:`John Doe`}),(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(n.r,{name:`email`,type:`email`,value:u,onChange:e=>d(e.target.value),label:`Email Address`,placeholder:`name@example.com`,required:!0}),(0,l.jsx)(`p`,{className:`text-[11px] text-foreground/40 mt-1.5 px-2 font-medium`,children:`Changing email sends a verification link to the new address.`})]})]})]}),(0,l.jsxs)(`div`,{className:`pt-6 border-t border-[var(--panel-border)]/50`,children:[(0,l.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground mb-4 flex items-center gap-2`,children:`Change Password`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,l.jsx)(n.r,{name:`password`,type:`password`,label:`New Password`,value:y,onChange:e=>b(e.target.value),placeholder:`Minimum 6 characters`}),(0,l.jsx)(n.r,{name:`confirmPassword`,type:`password`,label:`Confirm Password`,value:x,onChange:e=>S(e.target.value),placeholder:`Repeat password`})]})]}),(0,l.jsx)(`div`,{className:`pt-8 border-t border-[var(--panel-border)]/50 flex justify-start w-full`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:h,className:`px-12 py-3 md:py-2.5 text-[14px] md:text-[15px] font-bold tracking-wide rounded-xl hover:-translate-y-0.5`,children:`Save Changes`})})]})})]})]})}function A(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),[o,c]=(0,a.useState)(0),[d,f]=(0,a.useState)(0);return(0,a.useEffect)(()=>{let e;return o>0&&(e=setInterval(()=>c(e=>e-1),1e3)),()=>clearInterval(e)},[o]),(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16 mt-6 md:mt-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 md:p-8 lg:p-10 rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] text-center`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-40 blur-[15px] rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`w-14 h-14 md:w-16 md:h-16 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mx-auto mb-5 md:mb-6 animate-float shadow-xl`,children:(0,l.jsx)(n.R,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl md:text-3xl font-extrabold mb-2 md:mb-3 text-foreground tracking-tight`,children:`Reset Password`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Enter your email to receive a recovery link.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 md:p-4 mb-5 md:mb-6 text-[13px] md:text-[14px] font-medium text-emerald-400 bg-emerald-500/10 rounded-xl border border-emerald-500/20 max-w-[360px] mx-auto`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4 text-left max-w-[360px] mx-auto`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let r=new FormData(e.currentTarget).get(`email`);try{await(0,s.sendPasswordResetEmail)(n.Ct,r)}catch(e){console.error(e)}finally{i(`If an account exists, a password reset link has been sent. Please check your inbox (and spam folder).`);let e=d+1;f(e),c(e===1?60:120),t(!1)}},children:[(0,l.jsx)(n.r,{name:`email`,label:`Work Email`,type:`email`,placeholder:`name@company.com`,required:!0}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl md:rounded-xl transition-all ${o>0?`bg-foreground/5 text-foreground/40 border border-[var(--panel-border)] shadow-none cursor-not-allowed hover:translate-y-0`:`hover:-translate-y-0.5`}`,isLoading:e,disabled:o>0,children:o>0?`Resend link in ${(e=>`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`)(o)}`:d>0?`Resend reset password link`:`Send Reset Link`})})]}),(0,l.jsx)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:(0,l.jsxs)(u.Link,{to:`/login`,className:`inline-flex items-center text-[13px] md:text-[14px] text-foreground/70 font-medium hover:text-accent transition-colors tracking-wide`,children:[(0,l.jsx)(n.ht,{className:`w-4 h-4 mr-2`}),`Back to Sign In`]})})]})})}function j(){let{user:e,userRole:t}=m(),[r,i]=(0,a.useState)(!0),s=(0,u.useNavigate)(),{id:d}=(0,u.useParams)(),[f,p]=(0,a.useState)([]),[h,g]=(0,a.useState)(null),[_,v]=(0,a.useState)(!1),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(!1),C=d?f.find(e=>e.id===d)||null:f.length>0?f[0]:null,w=e=>{s(e?`/users/${e.id}`:`/users`)};(0,a.useEffect)(()=>{i(!0);let e=(0,o.onSnapshot)((0,o.collection)(n.wt,`user_profiles`),e=>{let t=[];e.forEach(e=>{t.push({id:e.id,...e.data()})}),p(t),i(!1),!d&&t.length>0&&s(`/users/${t[0].id}`,{replace:!0})},e=>{console.error(`Error fetching users:`,e),i(!1)});return()=>e()},[d,s]);let T=f.find(t=>t.id===e?.uid),E=e=>e.id===T?.id?!1:e.role!==`admin`||!T?.createdAt?!0:e.createdAt?new Date(T.createdAt).getTime()<=new Date(e.createdAt).getTime():!1,D=async(e,r)=>{if(!(t!==`admin`||!E(e)))try{await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,e.id),{role:r?`admin`:null}),g({text:`User role updated successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},k=async(e,r)=>{if(!(t!==`admin`||!E(e)))try{await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,e.id),{inactive:r}),g({text:`User ${r?`deactivated`:`activated`} successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},A=async()=>{if(v(!1),!(!C||!E(C)||y===C.displayName))try{await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,C.id),{displayName:y}),g({text:`Name updated successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},j=async e=>{let t=e.target.files?.[0];if(!(!t||!C||!E(C))){if(t.size>2*1024*1024){g({text:`File too large.`,type:`error`});return}S(!0);try{let e=(0,c.ref)(n.Et,`user_avatars/${C.id}/file.png`);await(0,c.uploadBytes)(e,t);let r=await(0,c.getDownloadURL)(e);await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,C.id),{avatar:r}),g({text:`Avatar successfully updated.`,type:`success`}),setTimeout(()=>g(null),3e3)}catch{g({text:`Failed to upload photo.`,type:`error`})}S(!1)}},[ee,M]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e;return r&&f.length===0?e=setTimeout(()=>M(!0),150):M(!1),()=>clearTimeout(e)},[r,f.length]),r&&f.length===0?ee?(0,l.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-background/60 backdrop-blur-xl transition-all duration-300`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 animate-spin text-accent`})}):null:(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Users`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/users`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,l.jsx)(n.a,{children:h&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:`p-4 text-[14px] font-medium border ${h.type===`error`?`text-red-500 bg-red-500/10 border-red-500/20 shadow-[0_0_15px_rgba(239,68,68,0.1)]`:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20 shadow-[0_0_15px_rgba(52,211,153,0.1)]`} rounded-xl flex items-center gap-2`,children:[h.type===`success`&&(0,l.jsx)(n.tt,{className:`w-4 h-4 shrink-0`}),h.text]})}),(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(O,{})}),(0,l.jsx)(`div`,{className:`glass-panel rounded-3xl border border-[var(--panel-border)] shadow-sm`,children:f.length===0?(0,l.jsx)(`div`,{className:`p-8 text-center text-foreground/50 text-[14px]`,children:`No members found.`}):(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`md:col-span-1 border-r md:border-r-[var(--panel-border)] border-b md:border-b-0 border-[var(--panel-border)] flex flex-col hide-scrollbar bg-black/5 dark:bg-white/5 rounded-t-3xl md:rounded-tr-none md:rounded-l-3xl`,children:[(0,l.jsx)(`div`,{className:`p-4 border-b border-[var(--panel-border)] font-bold text-[13px] text-foreground/70 uppercase tracking-wider`,children:`System Users`}),(0,l.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-2`,children:f.map(e=>(0,l.jsxs)(`div`,{onClick:()=>w(e),className:`p-4 py-5 rounded-2xl border transition-all flex items-center gap-4 cursor-pointer ${C?.id===e.id?`bg-accent/10 border-accent/40 shadow-sm`:`glass-panel border-transparent hover:border-[var(--panel-border)]`} ${e.inactive?`opacity-50 grayscale`:``}`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full overflow-hidden bg-accent/20 shrink-0 flex items-center justify-center border border-[var(--panel-border)]`,children:e.avatar||e.photoURL?(0,l.jsx)(`img`,{src:e.avatar||e.photoURL,alt:``,className:`w-full h-full object-cover`}):(0,l.jsx)(n.d,{className:`w-5 h-5 text-accent`})}),(0,l.jsxs)(`div`,{className:`flex flex-col truncate`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] truncate`,children:e.displayName||`No Name`}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 truncate font-mono mt-0.5`,children:e.email})]})]},e.id))})]}),(0,l.jsx)(`div`,{className:`md:col-span-2 flex flex-col p-6 md:p-10 relative`,children:C?(0,l.jsxs)(`div`,{className:`animate-in fade-in duration-300 w-full max-w-lg`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-6 md:gap-8 mb-10`,children:[(0,l.jsxs)(`div`,{className:`w-24 h-24 rounded-full glass-panel border-4 border-[var(--panel-border)] shadow-xl bg-accent/10 flex items-center justify-center relative overflow-hidden shrink-0 group`,children:[x?(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`}):C.avatar||C.photoURL?(0,l.jsx)(`img`,{src:C.avatar||C.photoURL,alt:`Avatar`,className:`w-full h-full object-cover`}):(0,l.jsx)(n.d,{className:`w-10 h-10 text-accent`}),!x&&E(C)&&(0,l.jsx)(`div`,{className:`absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center z-10 backdrop-blur-md`,children:(0,l.jsxs)(`label`,{className:`flex flex-col items-center justify-center cursor-pointer p-2 hover:bg-white/20 transition-colors text-white rounded-full`,title:`Upload Photo`,children:[(0,l.jsx)(n.lt,{className:`w-5 h-5`}),(0,l.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:j,className:`hidden`})]})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 w-full relative`,children:[_?(0,l.jsx)(`input`,{autoFocus:!0,value:y,onChange:e=>b(e.target.value),onBlur:A,onKeyDown:e=>e.key===`Enter`&&A(),className:`text-2xl md:text-3xl font-extrabold mb-1 bg-transparent border-b-2 border-accent outline-none text-foreground w-full py-1`}):(0,l.jsx)(`h3`,{onDoubleClick:()=>{E(C)&&(b(C.displayName||``),v(!0))},className:`text-2xl md:text-3xl font-extrabold mb-1 select-none ${E(C)?`cursor-pointer hover:text-accent transition-colors`:``}`,title:E(C)?`Double-click to edit`:``,children:C.displayName||`No Name`}),(0,l.jsx)(`p`,{className:`text-[14px] font-mono text-foreground/50`,children:C.email}),!E(C)&&C.id!==T?.id&&(0,l.jsx)(`div`,{className:`mt-3 inline-block self-start px-3 py-1.5 rounded-lg bg-foreground/5 border border-[var(--panel-border)] text-[11px] font-bold text-foreground/50 tracking-wide uppercase`,children:`Privileged Admin Account`})]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,l.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-between`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] text-foreground`,children:`Admin Access`}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/50`,children:`Toggle system privileges`})]}),(0,l.jsx)(`button`,{type:`button`,disabled:!E(C),onClick:()=>D(C,C.role!==`admin`),className:`relative inline-flex h-7 w-12 items-center rounded-full transition-colors focus:outline-none shadow-inner ${C.role===`admin`?`bg-accent`:`bg-foreground/20`} ${E(C)?`cursor-pointer`:`opacity-50 cursor-not-allowed`}`,children:(0,l.jsx)(`span`,{className:`inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-md ${C.role===`admin`?`translate-x-6`:`translate-x-1`}`})})]}),(0,l.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border flex items-center justify-between ${C.inactive?`border-amber-500/30 bg-amber-500/5`:`border-red-500/20 bg-red-500/5`}`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] ${C.inactive?`text-amber-500`:`text-red-500`}`,children:C.inactive?`Reactivate User`:`Deactivate User`}),(0,l.jsx)(`span`,{className:`text-[12px] ${C.inactive?`text-amber-500/70`:`text-red-500/70`}`,children:`Block access to this app`})]}),(0,l.jsx)(`button`,{type:`button`,disabled:!E(C),onClick:()=>k(C,!C.inactive),className:`relative inline-flex h-7 w-12 items-center rounded-full transition-colors focus:outline-none shadow-inner ${C.inactive?`bg-amber-500`:`bg-red-500/20`} ${E(C)?`cursor-pointer`:`opacity-50 cursor-not-allowed`}`,children:(0,l.jsx)(`span`,{className:`inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-md ${C.inactive?`translate-x-6`:`translate-x-1`}`})})]})]})]}):(0,l.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center opacity-30 pointer-events-none`,children:[(0,l.jsx)(n.u,{className:`w-12 h-12 mb-4`}),(0,l.jsx)(`p`,{className:`font-bold tracking-widest uppercase text-[12px]`,children:`Select a User`})]})})]})})]})]})}function ee({isOpen:e,title:t,message:r,confirmText:i=`Delete`,cancelText:a=`Cancel`,onConfirm:o,onCancel:s,isProcessing:c=!1,disableConfirm:u=!1}){return(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!c&&s(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[400px] p-6 rounded-3xl glass-panel border border-[var(--panel-border)] shadow-2xl relative z-10 text-center`,children:(0,l.jsxs)(`div`,{className:`w-full flex flex-col items-center`,children:[(0,l.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:t}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 leading-relaxed mb-6`,children:r}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:s,disabled:c,className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:a}),(0,l.jsx)(n.n,{onClick:o,disabled:c||u,className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl bg-red-500 hover:bg-red-600 border-none text-white shadow-xl hover:shadow-red-500/20 glow-hover`,children:c?(0,l.jsx)(n.M,{className:`w-5 h-5 animate-spin mx-auto`}):i})]})]})})]})})}var M=[`pages`,`forms`,`drive`,`users`,`theme`,`submissions`,`requests`,`settings`,`profile`,`support`],N={pages:`Pages`,forms:`Forms`,drive:`Drive`,users:`Users`,theme:`Theme`,submissions:`Submissions`,requests:`Requests`,settings:`Settings`,profile:`Profile`,support:`Request Support`},P=new Set([`home`]),F=new Set([`settings`]);function I(){let[e,t]=(0,a.useState)(`menu`),[r,i]=(0,a.useState)({}),[s,c]=(0,a.useState)({}),[u,d]=(0,a.useState)(g),[f,p]=(0,a.useState)(v),[m,h]=(0,a.useState)(!1),[y,b]=(0,a.useState)(null),[x,S]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.collection)(n.wt,`sys_pages`),e=>{let t={};e.forEach(e=>{let n=e.data();t[e.id]={id:e.id,title:n.pageName||n.title||e.id,path:n.route||(e.id===`home`?`/`:`/`+e.id),type:`public`,isSystem:[`home`,`templates`,`contact`,`setup`].includes(e.id)}}),t.setup||={id:`setup`,title:`Setup`,path:`/setup`,type:`public`,isSystem:!0},t.templates||={id:`templates`,title:`Templates`,path:`/templates`,type:`public`,isSystem:!0},t.contact||={id:`contact`,title:`Contact`,path:`/contact`,type:`public`,isSystem:!0},i(t)}),t=(0,o.onSnapshot)((0,o.collection)(n.wt,`sys_tabs`),e=>{let t={};e.forEach(e=>{let n=e.data();t[e.id]={id:e.id,title:n.pageName||n.tabName||n.title||N[e.id]||e.id,path:n.route||`/`+e.id,type:n.pageType||`admin`,isSystem:M.includes(e.id)}}),M.forEach(e=>{t[e]||(t[e]={id:e,title:N[e]||e,path:`/`+e,type:`admin`,isSystem:!0})}),c(t)}),r=(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_configs`,`page_order`),e=>{d(e.exists()?_(e.data().order||[]):g)}),a=(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_configs`,`tab_order`),e=>{p(e.exists()?_(e.data().order||[]):v)});return()=>{e(),t(),r(),a()}},[]);let C=async(e,t)=>{if((t?F:P).has(e))return;let i=t?f:u,a=t?`tab_order`:`page_order`,c=i.filter(e=>(t?s:r)[e.id]||(t?M.includes(e.id):[`home`,`contact`].includes(e.id))),l=c.some(t=>t.id===e)?c.map(t=>t.id===e?{...t,hidden:!t.hidden}:t):[...c,{id:e,hidden:!0}];await(0,o.setDoc)((0,o.doc)(n.wt,`sys_configs`,a),{order:l})},w=(e,t)=>{e.isSystem||b({info:e,isTab:t})},T=async()=>{if(!y)return;S(!0);let e=y.isTab?`sys_tabs`:`sys_pages`,t=y.isTab?`tab_order`:`page_order`,r=y.isTab?f:u;try{await(0,o.deleteDoc)((0,o.doc)(n.wt,e,y.info.id));let i=r.filter(e=>e.id!==y.info.id);await(0,o.setDoc)((0,o.doc)(n.wt,`sys_configs`,t),{order:i})}catch(e){console.error(`Delete failed`,e)}S(!1),b(null)},E=async(e,t,i)=>{let a=e?f:u,c=e?s:r,l=e?`tab_order`:`page_order`,d=a.filter(t=>c[t.id]||(e?M.includes(t.id):[`home`,`contact`].includes(t.id)));Object.keys(c).forEach(e=>{d.some(t=>t.id===e)||d.push({id:e,hidden:!1})});let p=d.findIndex(e=>e.id===t);if(p===-1)return;let m=+(!e&&d[0]?.id===`home`),h=i===`up`?Math.max(m,p-1):Math.min(d.length-1,p+1);if(p===h)return;let g=[...d],[_]=g.splice(p,1);g.splice(h,0,_),await(0,o.setDoc)((0,o.doc)(n.wt,`sys_configs`,l),{order:g})},D=async()=>{if(!m){h(!0);try{let e=new Set(g.map(e=>e.id)),t=new Set(v.map(e=>e.id)),r=u.filter(t=>!e.has(t.id)),i=f.filter(e=>!t.has(e.id)),a=[...r.map(e=>({...e,hidden:!1})),...g],s=[...i.map(e=>({...e,hidden:!1})),...v],c=(0,o.writeBatch)(n.wt);c.set((0,o.doc)(n.wt,`sys_configs`,`page_order`),{order:a}),c.set((0,o.doc)(n.wt,`sys_configs`,`tab_order`),{order:s}),await c.commit()}finally{setTimeout(()=>h(!1),600)}}},k=e=>{let t=e?f:u,n=e?s:r,i=t.filter(t=>n[t.id]||(e?M.includes(t.id):[`home`,`contact`].includes(t.id))),a=new Set(i.map(e=>e.id)),o=Object.keys(n).filter(e=>!a.has(e)).map(e=>({id:e,hidden:!1})),c=[...i,...o];return e||(c=c.filter(e=>e.id!==`home`)),c};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Settings`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/settings`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(O,{})}),(0,l.jsxs)(`div`,{className:`glass-panel rounded-3xl border border-[var(--panel-border)] shadow-sm grid grid-cols-1 md:grid-cols-3 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`md:col-span-1 border-r md:border-r-[var(--panel-border)] border-b md:border-b-0 border-[var(--panel-border)] flex flex-col bg-black/5 dark:bg-white/5 rounded-t-3xl md:rounded-tr-none md:rounded-l-3xl`,children:[(0,l.jsx)(`div`,{className:`p-6 pb-4 font-bold text-[13px] text-foreground/40 uppercase tracking-widest`,children:`Configuration`}),(0,l.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4 space-y-1`,children:[(0,l.jsxs)(`button`,{onClick:()=>t(`menu`),className:`w-full p-3 rounded-xl transition-all flex items-center gap-3 cursor-pointer ${e===`menu`?`bg-accent/10 text-accent font-bold`:`bg-transparent text-foreground/70 hover:bg-foreground/5 hover:text-foreground font-medium`}`,children:[(0,l.jsx)(n.O,{className:`w-4 h-4 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px]`,children:`Menu Settings`})]}),(0,l.jsxs)(`button`,{onClick:()=>t(`tabs`),className:`w-full p-3 rounded-xl transition-all flex items-center gap-3 cursor-pointer ${e===`tabs`?`bg-accent/10 text-accent font-bold`:`bg-transparent text-foreground/70 hover:bg-foreground/5 hover:text-foreground font-medium`}`,children:[(0,l.jsx)(n.ft,{className:`w-4 h-4 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px]`,children:`Tabs Settings`})]})]})]}),(0,l.jsx)(`div`,{className:`md:col-span-2 flex flex-col p-6 md:p-10`,children:(0,l.jsxs)(`div`,{className:`animate-in fade-in duration-300 w-full`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-8`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`h3`,{className:`text-2xl md:text-3xl font-extrabold text-foreground tracking-tighter mb-2`,children:e===`menu`?`Menu Settings`:`Dashboard Tabs`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 max-w-xl`,children:e===`menu`?`Reorder or hide public menu items. Changes take effect instantly for all visitors.`:`Manage visibility and order of all internal dashboard tabs.`})]}),(0,l.jsx)(`button`,{onClick:D,disabled:m,title:`Reset order and visibility to defaults`,className:`p-3 h-fit bg-foreground/5 hover:bg-foreground/10 text-foreground/70 active:scale-95 disabled:opacity-50 disabled:pointer-events-none rounded-xl transition-all font-bold text-[13px] flex items-center justify-center border border-transparent hover:border-[var(--panel-border)] shadow-sm shrink-0`,children:m?(0,l.jsx)(n.M,{className:`w-5 h-5 text-foreground/50 animate-spin`}):(0,l.jsx)(n.x,{className:`w-5 h-5 text-foreground/50`})})]}),(e=>{let t=e?s:r,i=e?F:P,a=k(e);return(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:a.map((r,o)=>{let s=t[r.id],c=s?.title||N[r.id]||r.id,u=s?.path||`/`+r.id,d=s?.isSystem??M.includes(r.id),f=i.has(r.id),p=o===0,m=o===a.length-1;return(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-4 glass-panel border border-[var(--panel-border)] rounded-2xl transition-all duration-200 ${r.hidden?`opacity-40`:`opacity-100`}`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col items-center w-6`,children:[(0,l.jsx)(`button`,{disabled:p,onClick:()=>E(e,r.id,`up`),className:`text-foreground/40 hover:text-accent disabled:opacity-20`,children:(0,l.jsx)(n.rt,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{disabled:m,onClick:()=>E(e,r.id,`down`),className:`text-foreground/40 hover:text-accent disabled:opacity-20 -mt-1`,children:(0,l.jsx)(n.ot,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-foreground text-[14px]`,children:c}),(0,l.jsx)(`span`,{className:`text-[12px] font-mono text-foreground/50`,children:u})]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[!f&&(0,l.jsx)(`button`,{onClick:()=>C(r.id,e),title:r.hidden?`Show this page`:`Hide this page`,className:`p-2 rounded-xl transition-colors ${r.hidden?`hover:bg-foreground/5 text-foreground/40`:`hover:bg-accent/10 text-accent`}`,children:r.hidden?(0,l.jsx)(n.K,{className:`w-4 h-4`}):(0,l.jsx)(n.G,{className:`w-4 h-4`})}),s&&!d&&(0,l.jsx)(`button`,{onClick:()=>w(s,e),className:`p-2 rounded-xl hover:bg-red-500/10 text-foreground/40 hover:text-red-500 transition-colors`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]})]},r.id)})})})(e===`tabs`)]})})]})]})]}),(0,l.jsx)(ee,{isOpen:!!y,onCancel:()=>b(null),onConfirm:T,title:`Delete Item`,message:`Are you sure you want to delete "${y?.info?.title??``}"? This cannot be undone.`,confirmText:`Delete`,isProcessing:x})]})}function L(){let[e,t]=(0,a.useState)([]),[r,i]=(0,a.useState)(!0),[s,c]=(0,a.useState)(null),[u,d]=(0,a.useState)(!1),[f,p]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.wt,`user_submissions`),(0,o.orderBy)(`submittedAt`,`desc`)),async e=>{let r=[];for(let t of e.docs){let e=t.data(),i=``;if(e.uid&&e.uid!==`guest`)try{let t=await(0,o.getDoc)((0,o.doc)(n.wt,`user_profiles`,e.uid));if(t.exists()){let n=t.data();n.avatar&&(i=n.avatar),n.name&&!e.name&&(e.name=n.name),n.email&&!e.email&&(e.email=n.email)}}catch(e){console.error(`Failed to fetch avatar`,e)}r.push({...e,id:t.id,avatarUrl:i})}t(r),i(!1)},e=>{console.error(`Error fetching submissions:`,e),i(!1)});return()=>e()},[]);let m=e=>{if(!e)return`Just now`;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)},h=e=>{c(t=>t===e?null:e)},g=async(e,t=!1)=>{p(e);try{await(0,o.updateDoc)((0,o.doc)(n.wt,`user_submissions`,e),{isArchived:!t}),!t&&s===e&&c(null)}catch(e){console.error(`Failed to archive/unarchive`,e)}p(null)},_=e.filter(e=>!e.isArchived),v=e.filter(e=>e.isArchived);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Form Submissions`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/submissions`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(O,{})}),(0,l.jsxs)(`div`,{className:`w-full flex-1 flex flex-col glass-panel rounded-3xl p-6 md:p-10 relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/5 blur-[100px] rounded-full pointer-events-none`}),(0,l.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col`,children:r?(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[500px]`,children:(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-10 md:h-10 border-4 border-accent/20 border-t-accent rounded-full animate-spin`})}):e.length===0?(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-8`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent mx-auto mb-6 shadow-inner`,children:(0,l.jsx)(n.D,{className:`w-6 h-6 outline-none`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No Submissions`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 font-medium max-w-md`,children:`Try submitting a form on the public layout to see it appear here.`})]}):(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 pb-8`,children:[_.length===0&&(0,l.jsx)(`div`,{className:`bg-foreground/[0.02] border border-dashed border-[var(--panel-border)] rounded-2xl flex flex-col items-center justify-center p-8 text-center mb-4`,children:(0,l.jsx)(`p`,{className:`text-[14px] font-bold text-foreground/50`,children:`All submissions have been archived.`})}),(0,l.jsx)(n.a,{children:_.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&h(e.id)},onClick:()=>h(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0`,children:(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm`,children:(0,l.jsx)(n.k,{className:`w-4 h-4`})})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 justify-center`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||e.full_name||`Anonymous Submission`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsx)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:e.email||e.contactEmail||`No email provided`})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-4 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:m(e.submittedAt)}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),g(e.id,!1)},disabled:f===e.id,className:`p-1.5 rounded-lg text-foreground/30 hover:text-orange-500 hover:bg-orange-500/10 transition-colors`,title:`Archive Submission`,children:f===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n.gt,{className:`w-4 h-4`})}),(0,l.jsx)(`div`,{className:`p-1.5 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.ot,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:m(e.submittedAt)}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e))]})})})]},e.id)})}),v.length>0&&(0,l.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`flex justify-center`,children:(0,l.jsxs)(`button`,{onClick:()=>d(!u),className:`flex items-center gap-2 text-[11px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors py-2 uppercase tracking-widest outline-none`,children:[u?`Hide`:`View`,` `,v.length,` Archived Submission`,v.length===1?``:`s`,(0,l.jsx)(n.ot,{className:`w-3.5 h-3.5 transition-transform duration-300 ${u?`rotate-180`:``}`})]})}),(0,l.jsx)(n.a,{children:u&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4`,children:(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:v.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden opacity-50 grayscale hover:opacity-100 hover:grayscale-0 hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&h(e.id)},onClick:()=>h(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0 grayscale`,children:(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm`,children:(0,l.jsx)(n.k,{className:`w-4 h-4`})})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 justify-center`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||e.full_name||`Anonymous Submission`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsx)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:e.email||e.contactEmail||`No email provided`})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-6 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:m(e.submittedAt)}),(0,l.jsx)(`div`,{className:`p-2 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.ot,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:m(e.submittedAt)}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`isArchived`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e)),(0,l.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,l.jsxs)(`button`,{onClick:()=>g(e.id,e.isArchived),disabled:f===e.id,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-[13px] font-bold text-foreground/70 hover:text-emerald-500 bg-foreground/5 hover:bg-emerald-500/10 transition-colors border border-transparent shadow-sm`,children:[f===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n._t,{className:`w-4 h-4`}),`Unarchive Submission`]})})]})})})]},e.id)})})})})]})]})})]})]})]})}function R(){let[e,t]=(0,a.useState)([]),[r,i]=(0,a.useState)(!0),[s,c]=(0,a.useState)(null),[d,f]=(0,a.useState)(!1),[p,m]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.wt,`user_requests`),(0,o.orderBy)(`submittedAt`,`desc`)),async e=>{let r=[];for(let t of e.docs){let e=t.data(),i=``;if(e.uid&&e.uid!==`guest`)try{let t=await(0,o.getDoc)((0,o.doc)(n.wt,`user_profiles`,e.uid));if(t.exists()){let n=t.data();(n.avatar||n.photoURL)&&(i=n.avatar||n.photoURL),n.displayName&&!e.name&&(e.name=n.displayName),n.email&&!e.email&&(e.email=n.email),n.email&&!e.contactEmail&&(e.contactEmail=n.email)}}catch(e){console.error(`Failed to fetch avatar`,e)}r.push({...e,id:t.id,avatarUrl:i})}t(r),i(!1)},e=>{console.error(`Error fetching requests:`,e),i(!1)});return()=>e()},[]);let h=e=>{if(!e)return`Just now`;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)},g=e=>{c(t=>t===e?null:e)},_=async(e,t=!1)=>{m(e);try{await(0,o.updateDoc)((0,o.doc)(n.wt,`user_requests`,e),{isArchived:!t}),!t&&s===e&&c(null)}catch(e){console.error(`Failed to archive/unarchive`,e)}m(null)},v=e.filter(e=>!e.isArchived),y=e.filter(e=>e.isArchived);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`User Requests`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/requests`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(O,{})}),(0,l.jsxs)(`div`,{className:`w-full flex-1 flex flex-col glass-panel rounded-3xl p-6 md:p-10 relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/5 blur-[100px] rounded-full pointer-events-none`}),(0,l.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col`,children:r?(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[500px]`,children:(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-10 md:h-10 border-4 border-accent/20 border-t-accent rounded-full animate-spin`})}):e.length===0?(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-8`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent mx-auto mb-6 shadow-inner`,children:(0,l.jsx)(n.et,{className:`w-6 h-6 outline-none`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No User Requests`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 font-medium max-w-md`,children:`User support tickets will appear here once submitted.`})]}):(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 pb-8`,children:[v.length===0&&(0,l.jsx)(`div`,{className:`bg-foreground/[0.02] border border-dashed border-[var(--panel-border)] rounded-2xl flex flex-col items-center justify-center p-8 text-center mb-4`,children:(0,l.jsx)(`p`,{className:`text-[14px] font-bold text-foreground/50`,children:`All requests have been archived.`})}),(0,l.jsx)(n.a,{children:v.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&g(e.id)},onClick:()=>g(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0`,children:e.avatarUrl||e.submitterAvatar?(0,l.jsx)(`img`,{src:e.avatarUrl||e.submitterAvatar,alt:e.submitterName||e.name,className:`w-10 h-10 rounded-full object-cover border border-[var(--panel-border)] shadow-sm`}):(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm uppercase`,children:(e.submitterName||e.name||e.contactEmail||e.email||`U`)[0]})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[e.uid===`guest`?(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||`Anonymous User`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}):(0,l.jsxs)(u.Link,{to:`/users/${e.uid}`,onClick:e=>e.stopPropagation(),className:`w-fit font-bold text-[14px] md:text-[15px] text-foreground truncate hover:text-accent flex items-center gap-2`,children:[e.submitterName||e.name||`Anonymous User`,e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsxs)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:[(0,l.jsx)(n.k,{className:`w-3.5 h-3.5`}),` `,e.contactEmail||e.email||`No email provided`]})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-4 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:h(e.submittedAt)}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),_(e.id,!1)},disabled:p===e.id,className:`p-1.5 rounded-lg text-foreground/30 hover:text-orange-500 hover:bg-orange-500/10 transition-colors`,title:`Archive Request`,children:p===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n.gt,{className:`w-4 h-4`})}),(0,l.jsx)(`div`,{className:`p-1.5 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.ot,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:h(e.submittedAt)}),e.topic&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-[13px] text-foreground/70 bg-foreground/5 px-4 py-2.5 rounded-xl w-fit border border-[var(--panel-border)]`,children:[(0,l.jsx)(n.nt,{className:`w-4 h-4 text-accent`}),(0,l.jsx)(`span`,{className:`font-medium text-accent`,children:`Topic:`}),(0,l.jsx)(`span`,{className:`font-bold`,children:e.topic})]}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`topic`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e))]})})})]},e.id)})}),y.length>0&&(0,l.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`flex justify-center`,children:(0,l.jsxs)(`button`,{onClick:()=>f(!d),className:`flex items-center gap-2 text-[11px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors py-2 uppercase tracking-widest outline-none`,children:[d?`Hide`:`View`,` `,y.length,` Archived Request`,y.length===1?``:`s`,(0,l.jsx)(n.ot,{className:`w-3.5 h-3.5 transition-transform duration-300 ${d?`rotate-180`:``}`})]})}),(0,l.jsx)(n.a,{children:d&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4`,children:(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden opacity-50 grayscale hover:opacity-100 hover:grayscale-0 hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&g(e.id)},onClick:()=>g(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0 grayscale`,children:e.avatarUrl||e.submitterAvatar?(0,l.jsx)(`img`,{src:e.avatarUrl||e.submitterAvatar,alt:e.submitterName||e.name,className:`w-10 h-10 rounded-full object-cover border border-[var(--panel-border)] shadow-sm`}):(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm uppercase`,children:(e.submitterName||e.name||e.contactEmail||e.email||`U`)[0]})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[e.uid===`guest`?(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||`Anonymous User`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}):(0,l.jsxs)(`div`,{className:`w-fit font-bold text-[14px] md:text-[15px] text-foreground truncate flex items-center gap-2`,children:[e.submitterName||e.name||`Anonymous User`,e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsxs)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:[(0,l.jsx)(n.k,{className:`w-3.5 h-3.5`}),` `,e.contactEmail||e.email||`No email provided`]})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-6 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:h(e.submittedAt)}),(0,l.jsx)(`div`,{className:`p-2 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.ot,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:h(e.submittedAt)}),e.topic&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-[13px] text-foreground/70 bg-foreground/5 px-4 py-2.5 rounded-xl w-fit border border-[var(--panel-border)]`,children:[(0,l.jsx)(n.nt,{className:`w-4 h-4 text-accent`}),(0,l.jsx)(`span`,{className:`font-medium text-accent`,children:`Topic:`}),(0,l.jsx)(`span`,{className:`font-bold`,children:e.topic})]}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`topic`,`isArchived`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e)),(0,l.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,l.jsxs)(`button`,{onClick:()=>_(e.id,e.isArchived),disabled:p===e.id,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-[13px] font-bold text-foreground/70 hover:text-emerald-500 bg-foreground/5 hover:bg-emerald-500/10 transition-colors border border-transparent shadow-sm`,children:[p===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n._t,{className:`w-4 h-4`}),`Unarchive Request`]})})]})})})]},e.id)})})})})]})]})})]})]})]})}function z(){let{user:e,userRole:t}=m(),[r,i]=(0,a.useState)([]),[s,f]=(0,a.useState)(!1),p=(0,u.useNavigate)(),{"*":h}=(0,u.useParams)(),g=h?h.split(`/`).filter(Boolean):[],_=g[0]||`private`,v=null,y=null;_===`users`?(v=g[1]||null,y=g[2]||null):y=g[1]||null;let b={public:`pub_`,shared:`mem_`,private:`user_`,admin:`admin_`,users:`users_`},x={pub_:`public`,mem_:`shared`,user_:`private`,admin_:`admin`,users_:`users`},S=b[_]||`user_`,C=e=>{p(`/drive/${x[e]}`)},[w,T]=(0,a.useState)([]);(0,a.useEffect)(()=>{S===`users_`&&t===`admin`&&w.length===0&&(0,o.getDocs)((0,o.collection)(n.wt,`user_profiles`)).then(e=>{T(e.docs.map(e=>({id:e.id,...e.data()})))})},[S,t,w.length]);let[E,D]=(0,a.useState)(!1),[k,A]=(0,a.useState)(null),[j,M]=(0,a.useState)(``),[N,P]=(0,a.useState)(`user_`),[F,I]=(0,a.useState)(!1),[L,R]=(0,a.useState)(!1),[z,B]=(0,a.useState)(!1),V=(0,a.useRef)(null),te=e=>{e.preventDefault(),e.stopPropagation(),B(!0)},ne=e=>{e.preventDefault(),e.stopPropagation(),B(!1)},re=e=>{if(e.preventDefault(),e.stopPropagation(),B(!1),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];A(t),M(t.name),P(S),I(!0)}},H=y&&r.find(e=>e._id===y)||null,U=e=>{le(!0),p(e?S===`users_`&&v?`/drive/users/${v}/${e._id}`:`/drive/${x[S]}/${e._id}`:S===`users_`&&v?`/drive/users/${v}`:`/drive/${x[S]}`)},[W,G]=(0,a.useState)(null),[ie,K]=(0,a.useState)(!1),[q,J]=(0,a.useState)(null),[Y,ae]=(0,a.useState)(!1),[oe,se]=(0,a.useState)(null),[ce,le]=(0,a.useState)(!0),[ue,de]=(0,a.useState)({}),[fe,X]=(0,a.useState)(!1);(0,a.useEffect)(()=>(H||q||W||F||fe?document.body.style.overflow=`hidden`:document.body.style.overflow=``,()=>{document.body.style.overflow=``}),[H,q,W,F,fe]),(0,a.useEffect)(()=>{if(!s&&y&&!r.some(e=>e._id===y)){X(!0);let e=setTimeout(()=>{X(!1),p(S===`users_`&&v?`/drive/users/${v}`:`/drive/${x[S]}`)},2500);return()=>clearTimeout(e)}else X(!1)},[s,y,r,S,p,v]),(0,a.useEffect)(()=>{if(!e)return;f(!0);let r=(t===`admin`?[`pub_`,`mem_`,`user_`,`admin_`]:[`pub_`,`mem_`,`user_`]).map(r=>{let a;return a=r===`user_`&&t!==`admin`?(0,o.query)((0,o.collection)(n.wt,`${r}files`),(0,o.where)(`uid`,`==`,e.uid)):(0,o.query)((0,o.collection)(n.wt,`${r}files`),(0,o.orderBy)(`createdAt`,`desc`)),(0,o.onSnapshot)(a,e=>{let t=(e.docs||[]).map(e=>({_id:e.id,accessPrefix:r,...e.data()}));i(e=>[...e.filter(e=>e.accessPrefix!==r),...t].sort((e,t)=>{let n=e.createdAt?.toMillis?e.createdAt.toMillis():0;return(t.createdAt?.toMillis?t.createdAt.toMillis():0)-n})),f(!1)},e=>{console.warn(`Error listening to ${r}files:`,e)})});return()=>r.forEach(e=>e())},[e?.uid,t]);let pe=e=>{if(e.target.files&&e.target.files[0]){let t=e.target.files[0];A(t),M(t.name)}},me=e=>{if(e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];A(t),M(t.name)}},Z=async r=>{if(r.preventDefault(),!(!k||!j)){D(!0);try{let r=(0,c.ref)(n.Et,`${N}files/${`${Date.now()}_${k.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`);await(0,c.uploadBytes)(r,k,{customMetadata:{ownerId:e.uid}});let i=await(0,c.getDownloadURL)(r);await(0,o.addDoc)((0,o.collection)(n.wt,`${N}files`),{fileName:j,fileType:k.type||`unknown`,fileSize:k.size,downloadURL:i,uid:e.uid,uploaderEmail:e.email||`user`,uploaderRole:t||`user`,createdAt:(0,o.serverTimestamp)()}),I(!1),A(null),M(``),C(N)}catch(e){console.error(e),alert(`Upload failed: ${e.message}`)}D(!1)}},he=async()=>{if(q){ae(!0);try{try{await(0,c.deleteObject)((0,c.ref)(n.Et,q.url))}catch(e){console.warn(`Storage item missing:`,e)}await(0,o.deleteDoc)((0,o.doc)(n.wt,`${q.prefix}files`,q.id)),i(e=>e.filter(e=>e._id!==q.id)),J(null)}catch(e){alert(e.message)}ae(!1)}},ge=async()=>{if(!W||!W.name.trim()){G(null);return}let e=r.find(e=>e._id===W.id);if(e&&e.fileName===W.name.trim()){G(null);return}K(!0);try{await(0,o.updateDoc)((0,o.doc)(n.wt,`${W.prefix}files`,W.id),{fileName:W.name.trim()}),i(e=>e.map(e=>e._id===W.id?{...e,fileName:W.name.trim()}:e)),G(null)}catch(e){console.error(`Rename failed:`,e)}K(!1)},_e=(e,t)=>{navigator.clipboard.writeText(e),se(t),setTimeout(()=>se(null),2e3)},ve=e=>{if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},Q=n=>e?n.accessPrefix===`mem_`?n.uid===e.uid?!0:t===`admin`?n.uploaderRole!==`admin`:!1:n.accessPrefix===`admin_`?n.uid===e.uid:n.accessPrefix===`pub_`?t===`admin`:n.uid===e.uid||t===`admin`:!1,ye=(e,t,r=!1)=>{let i=r?`w-16 h-16`:`w-10 h-10`,a=r?`w-8 h-8`:`w-5 h-5`;return e.startsWith(`image/`)?r?(0,l.jsx)(`img`,{src:t,alt:`preview`,className:`w-full h-full object-contain rounded-lg`}):(0,l.jsx)(`div`,{className:`${i} bg-cover bg-center rounded-lg`,style:{backgroundImage:`url(${t})`}}):e.includes(`video`)||e.includes(`audio`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-purple-500/10 text-purple-500 rounded-lg`,children:(0,l.jsx)(n.l,{className:a})}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-blue-500/10 text-blue-500 rounded-lg`,children:(0,l.jsx)(n.W,{className:a})}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-yellow-500/10 text-yellow-500 rounded-lg`,children:(0,l.jsx)(n.gt,{className:a})}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-emerald-500/10 text-emerald-500 rounded-lg`,children:(0,l.jsx)(n.Z,{className:a})}):(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-foreground/5 text-foreground/40 rounded-lg`,children:(0,l.jsx)(n.U,{className:a})})},be=[{id:`user_`,label:`Private`,icon:n.j,description:`This is a private folder availbale to all users in your app. Each user can see their own files. Admins can see all everyone's files here.`},{id:`mem_`,label:`Shared`,icon:n.u,description:`This is a shared folder that all signed-in users can see. Every user can upload files here and view other member's files. However, editing and deletion are strictly restricted to the original creator of the file.`},{id:`pub_`,label:`Public`,icon:n.H,description:`This admin-only folder is for assets like logos, banners, or favicons. Files here are view-only for everyone; only admins can upload or delete them.`},{id:`admin_`,label:`Admin Shared`,icon:n.v,description:`This is a shared folder for app administrators. Admins can view everything here, but they can only edit or delete files that they themselves uploaded.`},{id:`users_`,label:`User Uploads`,icon:n.Y,description:`View all underlying private user uploads securely. Select a user to explore their files.`}].filter(e=>t===`admin`?!0:e.id===`user_`||e.id===`mem_`),xe=[];xe=S===`users_`?r.filter(e=>e.accessPrefix===`user_`&&e.uid===v):S===`user_`?r.filter(t=>t.accessPrefix===`user_`&&t.uid===e?.uid):r.filter(e=>e.accessPrefix===S);let Se=be.find(e=>e.id===S);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 flex flex-col pt-12 min-h-screen relative overflow-visible`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Drive`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/drive`]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,onDragOver:te,onDragLeave:ne,onDrop:re,children:[(0,l.jsx)(O,{}),(0,l.jsxs)(`div`,{className:`flex flex-row glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl min-h-[600px] bg-background`,children:[(0,l.jsxs)(`div`,{className:`w-[280px] border-r border-[var(--panel-border)] bg-foreground/[0.01] p-4 flex flex-col shrink-0 overflow-y-auto hide-scrollbar`,children:[(0,l.jsx)(`div`,{className:`text-[11px] font-extrabold text-foreground/40 uppercase tracking-widest pl-4 mb-4 mt-2`,children:`Locations`}),(0,l.jsx)(`div`,{className:`flex flex-col gap-2`,children:be.map(e=>(0,l.jsxs)(`button`,{onClick:()=>C(e.id),className:`w-full flex items-center gap-3 px-4 py-3.5 rounded-2xl transition-all font-bold text-[14px] text-left ${S===e.id?`bg-accent/15 text-accent shadow-sm border border-accent/20`:`text-foreground/70 hover:bg-foreground/5 hover:text-foreground border border-transparent`}`,children:[(0,l.jsx)(e.icon,{className:`w-5 h-5 ${S===e.id?`text-accent`:`text-foreground/40`}`}),e.label]},e.id))})]}),(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col relative w-full h-full min-w-0`,children:[(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex items-start justify-between gap-6 shrink-0 border-b border-[var(--panel-border)]/50 bg-background/50`,children:[(0,l.jsxs)(`div`,{className:`flex-1 max-w-xl`,children:[(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground tracking-tight flex items-center gap-3`,children:Se?.label}),(0,l.jsx)(`p`,{className:`text-[13px] mt-3 text-foreground/60 leading-relaxed font-medium`,children:Se?.description})]}),S!==`users_`&&(0,l.jsxs)(n.n,{onClick:()=>{P(S),I(!0)},className:`flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-bold shadow-md hover:shadow-lg transition-all glow-hover border-transparent !border-0 outline-none ring-0`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Add File Here`]})]}),(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[300px]`,children:[s&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm rounded-b-[2rem]`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),S===`users_`&&!v?(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 pb-20`,children:[w.map(e=>(0,l.jsxs)(`div`,{onClick:()=>p(`/drive/users/${e.id}`),className:`flex items-center gap-4 bg-background border border-[var(--panel-border)] p-5 rounded-2xl cursor-pointer hover:border-accent/50 hover:shadow-md transition-all group`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-foreground/5 flex items-center justify-center shrink-0 border border-[var(--panel-border)]`,children:e.photoURL?(0,l.jsx)(`img`,{src:e.photoURL,alt:`avatar`,className:`w-full h-full rounded-full object-cover`}):(0,l.jsx)(n.d,{className:`w-5 h-5 text-foreground/40`})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,l.jsxs)(`span`,{className:`font-bold text-foreground truncate group-hover:text-accent transition-colors text-[14px]`,children:[e.firstName,` `,e.lastName]}),(0,l.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/50 truncate mt-0.5`,children:e.email})]})]},e.id)),w.length===0&&(0,l.jsxs)(`div`,{className:`col-span-full py-12 flex flex-col items-center justify-center text-center`,children:[(0,l.jsx)(n.d,{className:`w-12 h-12 text-foreground/10 mb-4`}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold text-foreground/50`,children:`No users found`})]})]}):xe.length>0?(0,l.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 pb-20`,children:xe.map(e=>(0,l.jsxs)(`div`,{className:`flex flex-col bg-background border border-[var(--panel-border)] rounded-2xl hover:border-accent/40 transition-all group overflow-hidden shadow-sm hover:shadow-md h-[190px] relative`,children:[(0,l.jsxs)(`div`,{className:`absolute top-2 right-2 flex flex-col gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10 bg-background/90 backdrop-blur-md rounded-lg p-1 border border-[var(--panel-border)] shadow-xl`,children:[(0,l.jsx)(`a`,{href:e.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-blue-500 transition-colors`,title:`Download`,children:(0,l.jsx)(n.J,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),_e(e.accessPrefix===`pub_`?e.downloadURL:`${window.location.origin}/drive/${x[e.accessPrefix]}/${e._id}`,e._id)},className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-emerald-500 transition-colors`,title:`Copy Link`,children:oe===e._id?(0,l.jsx)(n.st,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),Q(e)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),G({id:e._id,name:e.fileName,prefix:e.accessPrefix})},className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-purple-500 transition-colors`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),J({id:e._id,url:e.downloadURL,name:e.fileName,prefix:e.accessPrefix})},className:`p-1.5 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`h-[120px] w-full border-b border-[var(--panel-border)]/50 bg-foreground/[0.02] flex items-center justify-center overflow-hidden relative cursor-pointer rounded-t-[calc(1rem-1px)]`,onClick:()=>U(e),children:e.fileType.startsWith(`image/`)?(0,l.jsxs)(l.Fragment,{children:[ue[e._id]!==!1&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-0`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})}),(0,l.jsx)(`img`,{src:e.downloadURL,alt:``,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-300 group-hover:scale-105 ${ue[e._id]===!1?`opacity-100`:`opacity-0`}`,onLoad:()=>de(t=>({...t,[e._id]:!1})),onError:()=>de(t=>({...t,[e._id]:!1}))})]}):ye(e.fileType,e.downloadURL,!0)}),(0,l.jsxs)(`div`,{className:`p-3 flex flex-col justify-center flex-1 min-w-0`,onClick:()=>!W&&U(e),children:[W?.id===e._id?(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:W.name,onChange:e=>G({...W,name:e.target.value}),onBlur:()=>ge(),onKeyDown:e=>{e.key===`Enter`&&ge(),e.key===`Escape`&&G(null)},onClick:e=>e.stopPropagation(),className:`text-[12.5px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full`}):(0,l.jsx)(`span`,{className:`text-[12.5px] font-bold text-foreground truncate select-none group-hover:text-accent transition-colors`,title:e.fileName,children:e.fileName}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/40 font-bold uppercase tracking-wider mt-1 select-none`,children:ve(e.fileSize)})]})]},e._id))}):!s&&(0,l.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{if(e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];A(t),M(t.name),P(S),I(!0)}},onClick:()=>{P(S),I(!0)},className:`absolute inset-0 m-6 flex flex-col items-center justify-center text-foreground/40 transition-colors cursor-pointer group`,children:[(0,l.jsx)(`p`,{className:`text-[20px] font-bold text-foreground/50 group-hover:text-foreground/70 transition-colors`,children:`Folder is empty`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium mt-1 text-foreground/40 group-hover:text-foreground/60 transition-colors`,children:`Click here or drag and drop a file to upload`})]})]})]})]})]}),(0,l.jsx)(n.a,{children:F&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!E&&I(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[480px] border-[var(--panel-border)] border rounded-3xl relative z-10 glass-panel shadow-2xl flex flex-col bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-[var(--panel-border)]/50 relative z-20`,children:[(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsxs)(`button`,{onClick:()=>R(!L),className:`flex items-center gap-2 group outline-none`,children:[(0,l.jsx)(`span`,{className:`text-[16px] font-extrabold text-foreground tracking-tight`,children:`Upload to`}),(0,l.jsx)(`span`,{className:`bg-accent/10 group-hover:bg-accent/20 text-accent px-2 py-1 rounded-md text-[13px] font-bold transition-colors flex items-center gap-1 shadow-sm`,children:be.find(e=>e.id===N)?.label})]}),(0,l.jsx)(n.a,{children:L&&(0,l.jsxs)(a.default.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-[90]`,onClick:()=>R(!1)}),(0,l.jsx)(n.i.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:`absolute top-full left-0 mt-3 w-48 bg-background border border-[var(--panel-border)] rounded-xl shadow-2xl py-1 overflow-hidden z-[100]`,children:be.map(e=>(0,l.jsxs)(`button`,{type:`button`,onClick:()=>{P(e.id),R(!1)},className:`w-full text-left px-4 py-3 hover:bg-foreground/5 text-[13px] font-bold text-foreground flex items-center gap-3 transition-colors outline-none`,children:[(0,l.jsx)(e.icon,{className:`w-4 h-4 text-foreground/50`}),e.label]},e.id))})]})})]}),(0,l.jsx)(`button`,{onClick:()=>!E&&I(!1),className:`text-foreground/40 hover:text-foreground transition-colors`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})})]}),k?(0,l.jsxs)(`form`,{onSubmit:Z,className:`p-6 flex flex-col gap-6 relative z-10 rounded-b-[2rem]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 bg-foreground/[0.03] p-4 rounded-2xl border border-[var(--panel-border)] shadow-sm`,children:[ye(k.type,URL.createObjectURL(k)),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-[13px] font-bold text-foreground truncate`,children:k.name}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold uppercase tracking-wider mt-1`,children:ve(k.size)})]}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>!E&&A(null),className:`w-8 h-8 flex items-center justify-center text-foreground/40 hover:text-red-500 rounded-xl hover:bg-red-500/10 transition-colors shrink-0`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,l.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest pl-1`,children:`Edit File Name`}),(0,l.jsx)(`input`,{type:`text`,required:!0,value:j,onChange:e=>M(e.target.value),disabled:E,className:`w-full bg-foreground/[0.02] border border-[var(--panel-border)] rounded-xl px-4 py-3.5 text-[14px] font-bold text-foreground outline-none focus:border-accent transition-colors shadow-sm`})]}),(0,l.jsx)(`div`,{className:`flex justify-end pt-4 mt-2 border-t border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:E,className:`w-full py-4 rounded-xl text-[14px] font-bold shadow-lg`,children:E?`Uploading to Drive...`:`Save to ${be.find(e=>e.id===N)?.label}`})})]}):(0,l.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:me,className:`p-12 flex flex-col items-center justify-center rounded-b-[2rem]`,children:[(0,l.jsx)(`div`,{className:`w-20 h-20 rounded-full bg-foreground/5 flex items-center justify-center mb-5 border-2 border-dashed border-[var(--panel-border)]`,children:(0,l.jsx)(n.Q,{className:`w-8 h-8 text-foreground/40`})}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold text-foreground mb-1`,children:`Drag and drop file here`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium mb-8`,children:`or click to browse local files`}),(0,l.jsx)(`input`,{type:`file`,ref:V,onChange:pe,className:`hidden`}),(0,l.jsx)(n.n,{onClick:()=>V.current?.click(),className:`px-8 py-3 rounded-full font-bold shadow-md btn-primary transition-colors`,children:`Browse Files`})]})]})]})}),typeof window<`u`&&(0,d.createPortal)((0,l.jsx)(n.a,{children:H&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,l.jsx)(n.i.div,{onClick:()=>U(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(`button`,{onClick:()=>U(null),className:`absolute top-6 right-6 z-[160] w-12 h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0 shadow-sm z-20`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:H.fileName}),(0,l.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[H.fileType,` • `,ve(H.fileSize),H.accessPrefix===`mem_`&&(H.uploaderEmail||H.uid)&&` • From: ${H.uploaderEmail||H.uid}`]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:()=>_e(H.accessPrefix===`pub_`?H.downloadURL:`${window.location.origin}/drive/${x[H.accessPrefix]}/${H._id}`,H._id),className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500`,title:`Copy Link`,children:oe===H._id?(0,l.jsx)(n.st,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),Q(H)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:()=>{U(null),G({id:H._id,name:H.fileName,prefix:H.accessPrefix})},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-purple-500 transition-colors rounded-xl shadow-sm`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{U(null),J({id:H._id,url:H.downloadURL,name:H.fileName,prefix:H.accessPrefix})},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]}),(0,l.jsx)(`a`,{href:H.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-1`,title:`Download`,children:(0,l.jsx)(n.J,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>U(null),children:(0,l.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[ce&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none fade-in`,children:(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-background/80 backdrop-blur-md shadow-xl flex items-center justify-center border border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})})}),H.fileType.startsWith(`image/`)?(0,l.jsx)(`img`,{onLoad:()=>le(!1),src:H.downloadURL,alt:H.fileName,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full object-contain drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] rounded-lg pointer-events-auto transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):H.fileType.startsWith(`video/`)?(0,l.jsx)(`video`,{onLoadedData:()=>le(!1),src:H.downloadURL,controls:!0,autoPlay:!0,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full outline-none bg-black/40 rounded-lg pointer-events-auto drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):H.fileType===`application/pdf`?(0,l.jsx)(`iframe`,{onLoad:()=>le(!1),src:H.downloadURL,className:`w-full h-full border-none bg-white rounded-lg relative z-10 transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,title:`PDF Preview`}):(0,l.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center text-foreground/40 text-center relative z-10`,onClick:e=>{e.stopPropagation(),le(!1)},children:[(0,l.jsx)(n.U,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,l.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,l.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This file format cannot be previewed. Please download it instead.`})]})]})})]})]})}),document.body),(0,l.jsx)(n.a,{children:fe&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/90 backdrop-blur-xl`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:`relative z-10 w-full max-w-sm flex flex-col items-center pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-red-500/20 bg-background/80 p-8 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-6`,children:(0,l.jsx)(n.c,{className:`w-8 h-8 text-red-500`})}),(0,l.jsx)(`h3`,{className:`text-xl font-bold text-foreground mb-2`,children:`Access Denied`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 font-medium leading-relaxed`,children:`You don't have access to this file, or it may have been deleted.`}),(0,l.jsx)(`div`,{className:`w-5 h-5 border-2 border-accent/20 border-t-accent rounded-full animate-spin mt-6`})]})]})}),(0,l.jsx)(ee,{isOpen:!!q,title:`Confirm Deletion`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you entirely sure you wish to delete `,(0,l.jsx)(`strong`,{className:`text-foreground truncate block my-0.5`,children:q?.name}),` This action is permanent.`]}),onConfirm:he,onCancel:()=>J(null),isProcessing:Y,confirmText:`Yes, Delete`}),(0,l.jsx)(n.a,{children:z&&(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`fixed inset-0 z-[1000] bg-background/60 backdrop-blur-md pointer-events-none flex items-center justify-center p-6`,children:(0,l.jsxs)(n.i.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:`w-full max-w-lg aspect-video bg-background/80 border-2 border-dashed border-accent p-12 rounded-[40px] shadow-2xl flex flex-col items-center justify-center gap-6 relative`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-accent/5 rounded-[38px] animate-pulse`}),(0,l.jsx)(`div`,{className:`w-20 h-20 rounded-full bg-accent/10 flex items-center justify-center text-accent shadow-[0_0_40px_rgba(var(--accent-rgb),0.2)]`,children:(0,l.jsx)(n.Q,{className:`w-10 h-10 animate-bounce`})}),(0,l.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-2 relative z-10`,children:[(0,l.jsx)(`span`,{className:`text-[24px] font-extrabold text-foreground tracking-tight`,children:`Drop files to upload`}),(0,l.jsx)(`span`,{className:`text-[14px] font-medium text-foreground/50`,children:`Your files will be staged for review`})]})]})})})]})}function B(){let e=[{id:`form`,title:`Inline Form`,description:`A static, embedded contact form designed directly into the page layout.`,icon:n.P,path:`/templates/inline_form`},{id:`popup`,title:`Modal Popup Form`,description:`A centralized popup contact form that visually blurs the background context.`,icon:n.vt,path:`/templates/popup_form`},{id:`confirmation`,title:`Action Confirmation`,description:`A classic confirmation dialog styled for decisive user actions.`,icon:n.ct,path:`/templates/confirmation`},{id:`board`,title:`Board View`,description:`A modern, drag-and-drop styled Kanban board aesthetic for task management.`,icon:n.z,path:`/templates/board`},{id:`table`,title:`Data Table`,description:`A clean, column-based data table optimized for large datasets and bulk actions.`,icon:n.g,path:`/templates/table`},{id:`calendar`,title:`Calendar View`,description:`A structured monthly calendar grid for scheduling and date-based resource planning.`,icon:n.ut,path:`/templates/calendar`}];return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-10 text-center`,children:[(0,l.jsx)(`h1`,{className:`w-fit mx-auto inline-block text-4xl md:text-5xl lg:text-[4.8rem] leading-[1.1] font-extrabold tracking-tight mb-4 text-gradient animate-float`,children:`Premium Templates`}),(0,l.jsx)(`p`,{className:`text-foreground/60 text-lg font-medium max-w-2xl mx-auto`,children:`Explore our collection of fully functional, beautifully designed boilerplate components.`})]}),(0,l.jsxs)(`div`,{className:`w-full max-w-4xl mx-auto flex flex-col gap-4 relative`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[80%] h-[80%] bg-accent/5 blur-[120px] rounded-full pointer-events-none -z-10`}),e.map((e,t)=>{let r=e.icon;return(0,l.jsx)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},children:(0,l.jsxs)(u.Link,{to:e.path,className:`flex items-center gap-6 w-full p-4 md:px-6 glass-panel border border-[var(--panel-border)] rounded-2xl hover:border-accent/40 transition-all duration-300 group hover:bg-foreground/[0.02]`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-accent/10 flex items-center justify-center text-accent shrink-0 border border-accent/20 group-hover:scale-105 transition-transform`,children:(0,l.jsx)(r,{className:`w-5 h-5`})}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,l.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground truncate`,children:e.title}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 truncate font-medium`,children:e.description})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-2 text-[13px] font-bold px-5 py-2.5 rounded-xl btn-primary shrink-0 transition-transform shadow-lg group-hover:-translate-y-0.5`,children:[`View `,(0,l.jsx)(`span`,{className:`font-black leading-none ml-0.5`,children:`→`})]})]})},e.id)})]})]})}function V(){let[e,t]=(0,a.useState)({favoriteService:``,satisfactionRating:``,detailedThoughts:``}),[r,i]=(0,a.useState)(`idle`);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12`,children:[(0,l.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mb-6`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,l.jsx)(n.ht,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,l.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mt-6`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-auto`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`relative z-10 w-full`,children:r===`success`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-green-500/10 border border-green-500/20 flex items-center justify-center text-green-500 mb-4`,children:(0,l.jsx)(n.tt,{className:`w-8 h-8`})}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed`,children:`Your test data was sent successfully. Log in as an admin and check the Submissions tab!`})]}):r===`loading`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Inline Form Template`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide leading-relaxed`,children:`Try interacting with this simulated inline template block.`})]}),(0,l.jsxs)(`form`,{onSubmit:async r=>{r.preventDefault(),i(`loading`);try{let r=n.Ct.currentUser?.uid||`guest`;await(0,o.addDoc)((0,o.collection)(n.wt,`user_submissions`),{uid:r,...e,type:`template_simulation`,submittedAt:(0,o.serverTimestamp)()}),i(`success`),setTimeout(()=>{i(`idle`),t({favoriteService:``,satisfactionRating:``,detailedThoughts:``})},3e3)}catch{i(`error`)}},className:`space-y-4 w-full`,children:[(0,l.jsx)(n.r,{label:`Favorite Service`,placeholder:`e.g. Design Consulting`,value:e.favoriteService,onChange:n=>t({...e,favoriteService:n.target.value})}),(0,l.jsx)(n.r,{label:`Satisfaction Rating`,type:`number`,placeholder:`1 to 10`,value:e.satisfactionRating,onChange:n=>t({...e,satisfactionRating:n.target.value})}),(0,l.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Detailed Thoughts`}),(0,l.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:e.detailedThoughts,onChange:n=>t({...e,detailedThoughts:n.target.value}),className:`flex w-full rounded-xl text-[15px] text-foreground px-4 py-3 transition-all duration-300 placeholder:text-foreground/40 focus:outline-none focus:border-accent glow-focus disabled:cursor-not-allowed disabled:opacity-50 glass-panel min-h-[100px] resize-none`})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`,isLoading:!1,children:`Trigger Simulation`})})]})]})})]})})]})}function te(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)({concept:``,featureRequest:``,notes:``}),[s,c]=(0,a.useState)(`idle`);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Popup Form`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/popup_form`]})]}),(0,l.jsx)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`px-5 py-2 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2 text-foreground/70`,children:[(0,l.jsx)(n.ht,{className:`w-4 h-4`}),` Go Back`]})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden shadow-2xl relative flex flex-col w-full min-h-[150px] p-6 lg:p-10`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-accent/5 blur-[120px] rounded-full pointer-events-none -z-10`}),(0,l.jsx)(`div`,{className:`flex h-full w-full justify-end items-start relative z-10`,children:(0,l.jsxs)(n.n,{onClick:()=>t(!0),className:`px-6 py-2.5 text-[14px] font-bold rounded-xl shadow-lg flex items-center justify-center gap-2 btn-primary transition-all hover:-translate-y-1`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Open Form`]})})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl cursor-pointer`,onClick:()=>t(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-4 max-h-[95vh] overflow-y-auto no-scrollbar`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`relative z-10 w-full`,children:[(0,l.jsx)(`button`,{onClick:()=>t(!1),className:`absolute -top-2 -right-2 w-8 h-8 flex items-center justify-center rounded-full hover:bg-foreground/5 text-foreground/60 hover:text-foreground transition-colors z-20`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),s===`success`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-green-500/10 border border-green-500/20 flex items-center justify-center text-green-500 mb-4`,children:(0,l.jsx)(n.tt,{className:`w-8 h-8`})}),(0,l.jsx)(`h4`,{className:`text-xl font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed max-w-[280px]`,children:`Your test data was sent successfully. Log in as an admin and check the Submissions tab!`})]}):s===`loading`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Popup Template`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide leading-relaxed`,children:`Fill out the simulated fields below to test the interaction.`})]}),(0,l.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),c(`loading`);try{let e=n.Ct.currentUser?.uid||`guest`;await(0,o.addDoc)((0,o.collection)(n.wt,`user_submissions`),{uid:e,...r,type:`template_simulation`,submittedAt:(0,o.serverTimestamp)()}),c(`success`),setTimeout(()=>{c(`idle`),i({concept:``,featureRequest:``,notes:``}),t(!1)},3e3)}catch{c(`error`)}},className:`space-y-4 w-full`,children:[(0,l.jsx)(n.r,{label:`Concept Name`,placeholder:`e.g. Project Apollo`,value:r.concept,onChange:e=>i({...r,concept:e.target.value})}),(0,l.jsx)(n.r,{label:`Feature Request`,placeholder:`e.g. Real-time sync`,value:r.featureRequest,onChange:e=>i({...r,featureRequest:e.target.value})}),(0,l.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Simulated Notes`}),(0,l.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:r.notes,onChange:e=>i({...r,notes:e.target.value}),className:`flex w-full rounded-xl text-[15px] text-foreground px-4 py-3 transition-all duration-300 placeholder:text-foreground/40 focus:outline-none focus:border-accent glow-focus disabled:cursor-not-allowed disabled:opacity-50 glass-panel min-h-[100px] resize-none`})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`,isLoading:!1,children:`Trigger Simulation`})})]})]})]})]})]})})]})}function ne(){let[e,t]=(0,a.useState)(void 0);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 items-center`,children:[(0,l.jsx)(`div`,{className:`w-full max-w-5xl mb-8`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,l.jsx)(n.ht,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,l.jsxs)(`div`,{className:`w-full max-w-5xl mx-auto mt-2 glass-panel rounded-3xl border border-[var(--panel-border)] p-6 md:p-10 relative overflow-hidden shadow-2xl`,children:[(0,l.jsx)(`div`,{className:`flex items-center justify-between mb-8 pb-6 border-b border-[var(--panel-border)]/50`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h3`,{className:`text-2xl font-extrabold text-foreground tracking-tight`,children:`System Files`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 mt-1`,children:`Review and manage core application assets.`})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,l.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/50 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 w-full sm:w-auto`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-red-500/10 flex items-center justify-center text-red-500 shrink-0`,children:(0,l.jsx)(n.p,{className:`w-5 h-5`})}),(0,l.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,l.jsx)(`h4`,{className:`font-bold text-[14px] sm:text-[15px] text-foreground truncate`,children:`Critical Configuration File`}),(0,l.jsx)(`p`,{className:`text-[12px] sm:text-[13px] text-foreground/50 font-medium mt-0.5 truncate`,children:`Size: 4.2 MB • Modified 2 hours ago`})]})]}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(null),className:`w-full sm:w-auto shrink-0 flex items-center justify-center px-6 py-3 sm:py-2.5 text-[13px] font-bold rounded-xl text-red-500 hover:bg-red-500/10 hover:border-red-500/20 bg-red-500/5 sm:bg-transparent`,children:`Delete File`})]}),(0,l.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 opacity-50 pointer-events-none mt-2`,children:[1,2].map(e=>(0,l.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/20 flex items-center gap-4`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-foreground/5 shrink-0`}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 flex-1`,children:[(0,l.jsx)(`div`,{className:`w-32 h-3 rounded-full bg-foreground/10`}),(0,l.jsx)(`div`,{className:`w-20 h-2 rounded-full bg-foreground/5`})]})]},e))})]})]}),(0,l.jsx)(n.a,{children:e!==void 0&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[400px] p-6 rounded-3xl glass-panel border border-[var(--panel-border)] shadow-2xl relative z-10 text-center`,children:(0,l.jsx)(n.a,{mode:`wait`,children:e===null?(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center`,children:[(0,l.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Confirm Deletion`}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 leading-relaxed mb-6`,children:`Are you entirely sure you wish to delete this configuration? This action is permanent.`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(!1),className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:`Cancel`}),(0,l.jsx)(n.n,{onClick:()=>t(!0),className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl bg-red-500 hover:bg-red-600 border-none text-white shadow-xl hover:shadow-red-500/20 glow-hover`,children:`Yes, Delete`})]})]},`confirm`):e===!0?(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,l.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-green-500 tracking-tight flex items-center gap-2`,children:[(0,l.jsx)(n.st,{className:`w-5 h-5`}),` Verified`]}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Action successfully executed.`}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`success`):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,l.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-foreground/80 tracking-tight flex items-center gap-2`,children:[(0,l.jsx)(n.c,{className:`w-5 h-5`}),` Aborted`]}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Cancellation securely caught.`}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`error`)})})]})})]})}var re=(e,t=[])=>{let n=(e.pageName||e.pageId||`custom_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=`${n.charAt(0).toUpperCase()}${n.slice(1)}Content`;return`I need your help building the inner content for a newly created Public Page. This page is powered by the \`PublicPageTemplate\` (located at \`src/templates/PublicPageTemplate.tsx\`).
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-DYteiM-1.cjs`),t=require(`./theme.config-0Lvwt5Bo.cjs`),n=require(`./ContactPopup-B666UTn5.cjs`),r=require(`./contactForm.config-CXyq-EbM.cjs`),i=require(`./supportForm.config-haLod4rv.cjs`);let a=require(`react`);a=e.i(a,1);let o=require(`firebase/firestore`),s=require(`firebase/auth`),c=require(`firebase/storage`),l=require(`react/jsx-runtime`),u=require(`react-router-dom`),d=require(`react-dom`);var f=(0,a.createContext)({user:null,userRole:null,loading:!0,signOut:async()=>{},registerUser:async()=>{},refreshUser:async()=>{},userInactive:!1,roleResolved:!1,activeOrg:null,activeWorkspace:null,checkOrg:async()=>{},workspaceAccess:{},userWorkspaces:[],switchWorkspace:async()=>{},createWorkspace:async()=>{},createOrg:async()=>{}});function p({children:e}){let t=n.St(),[r,i]=(0,a.useState)(null),[c,u]=(0,a.useState)(null),[d,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!0),[g,_]=(0,a.useState)(!1),v=a.default.useRef(null),y=a.default.useRef(null);return(0,a.useEffect)(()=>{let e;if(!n.Ct){h(!1),_(!0);return}let r=(0,s.onAuthStateChanged)(n.Ct,async r=>{if(r?.uid===y.current&&g){i(r);return}if(y.current=r?.uid||null,r){let a=localStorage.getItem(`fbos_role_${r.uid}`);a&&(u(a),_(!0),h(!1)),console.log(`[AuthContext] 1. onAuthStateChanged fired for user:`,r.uid),i(r);try{let i=(0,o.doc)(n.wt,`user_profiles`,r.uid),a=(await(0,o.getDoc)(i)).data()||{};(0,o.setDoc)(i,{uid:r.uid,email:r.email,displayName:r.displayName||a.displayName||``,lastLoginAt:new Date().toISOString(),createdAt:a.createdAt||new Date().toISOString()},{merge:!0}).catch(e=>console.error(`Failed to sync profile:`,e)),e&&e(),e=(0,o.onSnapshot)(i,e=>{if(e.exists()){let n=e.data(),a=n.role||`user`,s=``;try{s={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_ADMIN_EMAILS:void 0,VITE_FIREBASE_API_KEY:void 0,VITE_FIREBASE_APP_ID:void 0,VITE_FIREBASE_AUTH_DOMAIN:void 0,VITE_FIREBASE_MESSAGING_SENDER_ID:void 0,VITE_FIREBASE_PROJECT_ID:void 0,VITE_FIREBASE_STORAGE_BUCKET:void 0}?.VITE_ADMIN_EMAILS||``}catch{}let c=t.adminEmails||(s?s.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]);c.length>0&&!n.role&&c.map(e=>e.toLowerCase()).some(e=>r.email?.toLowerCase()===e)&&(a=`admin`,(0,o.updateDoc)(i,{role:`admin`}).catch(e=>console.error(`Error auto-setting admin role:`,e))),v.current===null&&(v.current=a),u(a),localStorage.setItem(`fbos_role_${r.uid}`,a),p(n.inactive===!0)}_(!0),h(!1)},e=>{console.warn(`[AuthContext] user_profiles snapshot error (safe to ignore during auth transition):`,e),_(!0),h(!1)})}catch(e){console.error(`[AuthContext] ERROR in auth resolution:`,e),_(!0),h(!1)}}else console.log(`[AuthContext] No user currently signed in.`),i(null),u(null),p(!1),_(!0),h(!1),v.current=null,e&&e()});return()=>{r(),e&&e()}},[]),(0,l.jsx)(f.Provider,{value:{user:r,userRole:c,loading:m,signOut:async()=>{await(0,s.signOut)(n.Ct),i(null)},registerUser:async(e,t,r,i)=>{let{createUserWithEmailAndPassword:a}=await import(`firebase/auth`),{user:c}=await a(n.Ct,e,t),l=`${r} ${i}`.trim();await(0,s.updateProfile)(c,{displayName:l});try{await c.getIdToken(!0),await(0,o.setDoc)((0,o.doc)(n.wt,`user_profiles`,c.uid),{uid:c.uid,email:c.email,displayName:l,createdAt:new Date().toISOString()},{merge:!0})}catch(e){console.warn(`Could not write public profile on registration.`,e)}await(0,s.sendEmailVerification)(c)},refreshUser:async()=>{n.Ct.currentUser&&(await n.Ct.currentUser.reload(),i(Object.assign(Object.create(Object.getPrototypeOf(n.Ct.currentUser)),n.Ct.currentUser)))},userInactive:d,roleResolved:g},children:e})}var m=()=>(0,a.useContext)(f);function h(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)([]),s=(0,a.useRef)(null),c=(0,u.useNavigate)();(0,a.useEffect)(()=>{function e(e){s.current&&!s.current.contains(e.target)&&t(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let d=(0,a.useRef)({users:[],submissions:[],requests:[]}),f=(e,t)=>{d.current[e]=t;let n=[...d.current.users,...d.current.submissions,...d.current.requests];n.sort((e,t)=>{let n=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return((t.time?.toDate?t.time.toDate().getTime():new Date(t.time).getTime())||0)-(n||0)}),i(n.slice(0,8))};(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.wt,`user_profiles`),(0,o.orderBy)(`createdAt`,`desc`),(0,o.limit)(5)),e=>{f(`users`,e.docs.map(e=>{let t=e.data();return{id:`u_${e.id}`,type:`user`,title:`New user registered`,subtitle:t.email||`Unknown`,time:t.createdAt}}))}),t=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.wt,`user_submissions`),(0,o.orderBy)(`submittedAt`,`desc`),(0,o.limit)(5)),e=>{f(`submissions`,e.docs.map(e=>{let t=e.data();return{id:`s_${e.id}`,type:`submission`,title:`New form submission`,subtitle:t.name||t.email||`Anonymous`,time:t.submittedAt}}))}),r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.wt,`user_requests`),(0,o.orderBy)(`submittedAt`,`desc`),(0,o.limit)(5)),e=>{f(`requests`,e.docs.map(e=>{let t=e.data();return{id:`r_${e.id}`,type:`request`,title:`New support request`,subtitle:t.name||t.submitterName||t.contactEmail||t.email||`Anonymous`,time:t.submittedAt}}))});return()=>{e(),t(),r()}},[]);let[p,m]=(0,a.useState)(()=>typeof window<`u`?parseInt(localStorage.getItem(`admin_notifications_last_read`)||`0`,10):0),h=()=>{let n=!e;if(t(n),n){let e=Date.now();m(e),typeof window<`u`&&localStorage.setItem(`admin_notifications_last_read`,e.toString())}},g=r.some(e=>{if(!e.time)return!0;let t=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return t>p||isNaN(t)}),_=e=>{t(!1),c(e===`user`?`/users`:e===`submission`?`/submissions`:`/requests`)},v=e=>{if(!e)return``;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)};return(0,l.jsxs)(`div`,{className:`relative z-50 flex-shrink-0 mr-1 md:mr-2`,ref:s,children:[(0,l.jsxs)(`button`,{onClick:h,className:`p-2 rounded-xl glass-panel transition-all border border-transparent relative text-notification-icon hover:bg-foreground/5 hover:border-[var(--panel-border)]`,"aria-label":`Admin Notifications`,children:[(0,l.jsx)(n.pt,{className:`w-4 h-4 md:w-5 md:h-5`}),g&&(0,l.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-red-500 rounded-full animate-pulse`})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`absolute top-full mt-2 right-[-60px] md:right-0 w-[320px] md:w-[400px] glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col origin-top-right overflow-hidden bg-[var(--panel-bg)]`,children:[(0,l.jsxs)(`div`,{className:`px-4 border-b border-[var(--panel-border)]/50 pb-3 pt-4 flex items-center justify-between`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] text-foreground tracking-wide`,children:`Notifications`}),(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md`,children:`Admin`})]}),(0,l.jsx)(`div`,{className:`max-h-[350px] overflow-y-auto w-full p-2 flex flex-col gap-1`,children:r.length===0?(0,l.jsx)(`div`,{className:`p-6 text-center text-foreground/40 text-[13px] font-medium`,children:`No recent activity.`}):r.map(e=>(0,l.jsxs)(`button`,{onClick:()=>_(e.type),className:`w-full flex items-start gap-3 p-3 rounded-xl hover:bg-foreground/5 transition-all text-left group border border-transparent hover:border-[var(--panel-border)]`,children:[(0,l.jsx)(`div`,{className:`mt-0.5 w-8 h-8 rounded-full flex items-center justify-center shrink-0 bg-foreground/5 text-notification-icon`,children:e.type===`user`?(0,l.jsx)(n.d,{className:`w-4 h-4`}):e.type===`submission`?(0,l.jsx)(n.k,{className:`w-4 h-4`}):(0,l.jsx)(n.et,{className:`w-4 h-4`})}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-2`,children:[(0,l.jsx)(`span`,{className:`text-[13px] font-semibold text-foreground group-hover:text-accent transition-colors truncate`,children:e.title}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/60 truncate`,children:e.subtitle}),(0,l.jsx)(`span`,{className:`text-[10px] font-mono tracking-wide text-foreground/40 mt-1`,children:v(e.time)})]})]},e.id))})]})})]})}var g=[{id:`contact`,hidden:!1},{id:`templates`,hidden:!1},{id:`setup`,hidden:!1}],_=e=>(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden}),v=[{id:`pages`,hidden:!1},{id:`forms`,hidden:!1},{id:`drive`,hidden:!1},{id:`users`,hidden:!1},{id:`theme`,hidden:!1},{id:`submissions`,hidden:!1},{id:`requests`,hidden:!1},{id:`settings`,hidden:!1},{id:`profile`,hidden:!1},{id:`support`,hidden:!0}],y={route:`/support`,template:`popup_form`,form:`support`,tabName:`Support`,iconName:``},b={templates:{label:`Templates`,path:`/templates`},setup:{label:`Setup`,path:`/setup`},contact:{label:`Contact`,path:`/contact`}};function x({customMenu:e,standalone:t}){let{user:r,userRole:i,signOut:s}=m(),c=(0,u.useNavigate)(),[d,f]=(0,a.useState)(!1),[p,v]=(0,a.useState)(null),[x,S]=(0,a.useState)(!1),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)(!1),D=r?.displayName||r?.email?.split(`@`)[0]||`User`,O=D.charAt(0).toUpperCase()+D.slice(1),{theme:k,toggleTheme:A,activeConfig:j}=n.bt(),ee=async()=>{await s(),c(`/`),f(!1)},[M,N]=(0,a.useState)({...b}),[P,F]=(0,a.useState)(g);(0,a.useEffect)(()=>{if(!n.wt)return;let e=(0,o.onSnapshot)((0,o.collection)(n.wt,`sys_pages`),e=>{let t={...b};e.forEach(e=>{let n=e.data();if(n.enabled===!1)return;let r=n.pageName||n.title||b[e.id]?.label||e.id,i=n.route||(e.id===`home`?`/`:`/`+e.id);t[e.id]={label:r,path:i}}),N(t)},e=>{console.warn(`sys_pages snapshot error (safe to ignore during auth transition):`,e)}),t=(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_configs`,`page_order`),e=>{F(e.exists()&&Array.isArray(e.data().order)?_(e.data().order):g)},e=>{console.warn(`page_order snapshot error (safe to ignore during auth transition):`,e)}),r=(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_tabs`,`support`),e=>{e.exists()&&e.data().pageName&&L(e.data().pageName)},e=>{console.warn(`support snapshot error (safe to ignore during auth transition):`,e)});return()=>{e(),t(),r()}},[]);let[I,L]=(0,a.useState)(y.tabName),R=(()=>{let e=new Set(P.filter(e=>e.hidden).map(e=>e.id)),t=new Set,n=[];return P.forEach(e=>{if(e.hidden||e.id===`home`)return;let r=M[e.id];r&&(n.push({label:r.label,path:r.path}),t.add(e.id))}),Object.entries(M).forEach(([r,i])=>{!t.has(r)&&!e.has(r)&&r!==`home`&&i.path!==`/`&&i.path!==`/support`&&n.push({label:i.label,path:i.path})}),n})(),z=e||R,B=(0,a.useRef)(null),V=(0,a.useRef)(null),[te,ne]=(0,a.useState)(z.length);(0,a.useEffect)(()=>{if(t||r)return;let e=()=>{let e=B.current,t=V.current;if(!e||!t)return;let n=e.clientWidth,r=t.querySelectorAll(`[data-measure-nav]`);if(r.length===0){ne(z.length);return}let i=0,a=!0;for(let e=0;e<r.length;e++)if(i+=r[e].offsetWidth+(e>0?28:0),i>n){a=!1;break}if(a){ne(z.length);return}let o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e].offsetWidth,i=o+t+(e>0?28:0);if(i+50>n)break;o=i,s++}ne(Math.max(s,1))},n=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(n);let i=new ResizeObserver(()=>requestAnimationFrame(e));return B.current&&i.observe(B.current),()=>{cancelAnimationFrame(n),i.disconnect()}},[z.map(e=>e.label).join(`|`),t,r,z.length]);let re=z.slice(0,te),H=z.slice(te);return(0,l.jsxs)(`nav`,{className:`flex items-center justify-between w-full max-w-7xl mx-auto z-40 p-4 md:p-10 relative`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 md:gap-4 z-50`,children:(0,l.jsxs)(u.Link,{to:`/`,className:`flex items-center gap-2 md:gap-3 group cursor-pointer z-50`,children:[(0,l.jsx)(`div`,{className:`w-9 h-9 md:w-10 md:h-10 rounded-xl glass-panel flex items-center justify-center glow-hover shadow-lg transition-transform duration-500 group-hover:rotate-[360deg] group-active:scale-95 overflow-hidden`,children:j?.logoUrl?(0,l.jsx)(`img`,{src:j.logoUrl,alt:`Logo`,className:`w-full h-full object-cover`}):(0,l.jsx)(n.Y,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,l.jsx)(`span`,{className:`hidden lg:block font-bold text-[22px] tracking-tight text-gradient transition-colors duration-300 drop-shadow-sm`,children:j?.appName||``})]})}),(0,l.jsx)(n.a,{children:x&&(0,l.jsx)(n.t,{formId:`contact`,onClose:()=>S(!1)})}),(0,l.jsx)(n.a,{children:C&&(0,l.jsx)(n.t,{formId:`support`,onClose:()=>w(!1)})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 md:gap-4 z-50 relative ml-auto flex-1 justify-end`,children:[!t&&!r&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{ref:V,"aria-hidden":`true`,className:`flex items-center gap-7 whitespace-nowrap px-1`,style:{position:`fixed`,top:-9999,left:0,visibility:`hidden`,height:0,pointerEvents:`none`},children:z.map((e,t)=>(0,l.jsxs)(`span`,{"data-measure-nav":!0,className:`text-[13px] md:text-[14px] font-bold tracking-wide flex items-center gap-1.5 shrink-0`,children:[e.label,e.submenu&&(0,l.jsx)(n.ot,{className:`w-3 h-3`})]},e.path||t))}),(0,l.jsxs)(`div`,{className:`hidden sm:flex items-center gap-7 mr-6 w-full max-w-full justify-end relative`,ref:B,children:[re.map((e,t)=>(0,l.jsxs)(`div`,{className:`relative shrink-0`,onMouseEnter:()=>v(e.label),onMouseLeave:()=>v(null),children:[e.path?(0,l.jsxs)(u.Link,{to:e.path,className:`text-[13px] md:text-[14px] font-bold tracking-wide text-foreground/50 hover:text-accent transition-all cursor-pointer flex items-center gap-1.5`,children:[e.label,e.submenu&&(0,l.jsx)(n.ot,{className:`w-3 h-3`})]}):(0,l.jsxs)(`button`,{onClick:e.action,className:`text-[13px] md:text-[14px] font-bold tracking-wide text-foreground/50 hover:text-accent transition-all flex items-center gap-1.5`,children:[e.label,e.submenu&&(0,l.jsx)(n.ot,{className:`w-3 h-3`})]}),e.submenu&&p===e.label&&(0,l.jsx)(`div`,{className:`absolute top-[100%] left-0 pt-2 z-50`,children:(0,l.jsx)(n.i.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:`min-w-[180px] max-h-[300px] overflow-y-auto styled-scrollbars bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-xl flex flex-col py-2`,children:e.submenu.map((e,t)=>e.path?(0,l.jsx)(u.Link,{to:e.path,className:`px-5 py-3 text-[13px] font-medium text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t):(0,l.jsx)(`button`,{onClick:e.action,className:`px-5 py-3 text-left w-full text-[13px] font-medium text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t))})})]},`${e.path||`no-path`}-${t}`)),H.length>0&&(0,l.jsxs)(`div`,{className:`relative flex items-center shrink-0`,onMouseEnter:()=>f(`overflow`),children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`overflow`?!1:`overflow`),className:`p-1 rounded-lg transition-colors flex items-center ${d===`overflow`?`bg-foreground/5 text-accent`:`text-foreground/50 hover:bg-foreground/5 hover:text-accent`}`,children:(0,l.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-5 h-5`,children:[(0,l.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,l.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`}),(0,l.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`})]})}),(0,l.jsx)(n.a,{children:d===`overflow`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsx)(n.i.div,{initial:{opacity:0,y:5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:5,scale:.98},className:`absolute top-[100%] pt-1 right-0 min-w-[200px] max-h-[350px] overflow-y-auto styled-scrollbars bg-background border border-[var(--panel-border)] rounded-2xl shadow-xl flex flex-col py-2 z-50 origin-top-right`,children:H.map((e,t)=>e.path?(0,l.jsx)(u.Link,{to:e.path,onClick:()=>f(!1),className:`px-5 py-3 text-[13px] font-bold tracking-wide text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t):(0,l.jsx)(`button`,{onClick:()=>{e.action&&e.action(),f(!1)},className:`px-5 py-3 text-left w-full text-[13px] font-bold tracking-wide text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t))})]})})]})]}),j?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:A,className:`p-2 mr-2 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40 shrink-0`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4 md:w-5 md:h-5`}):(0,l.jsx)(n.E,{className:`w-4 h-4 md:w-5 md:h-5`})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(u.Link,{to:`/login`,className:`hidden sm:flex text-[14px] font-bold tracking-wide text-foreground/80 hover:text-accent transition-colors px-3 py-1.5 shrink-0`,children:`Sign In`}),(0,l.jsx)(u.Link,{to:`/register`,className:`hidden sm:flex text-[13px] md:text-[14px] font-bold tracking-wide px-4 py-1.5 md:px-5 md:py-2 rounded-xl btn-primary transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5 active:scale-95 items-center justify-center ml-2`,children:`Get Started`}),(0,l.jsxs)(`div`,{className:`relative sm:hidden ml-1`,children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`guest`?!1:`guest`),className:`p-2 rounded-xl glass-panel glow-hover border transition-all ${d===`guest`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,l.jsx)(n.O,{className:`w-5 h-5 text-accent/80`})}),(0,l.jsx)(n.a,{children:d===`guest`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.95},className:`absolute top-full right-0 mt-3 w-[220px] p-2 glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col gap-1 origin-top-right`,children:[(0,l.jsxs)(u.Link,{to:`/templates`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.P,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Templates`})]}),(0,l.jsxs)(u.Link,{to:`/setup`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.y,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Setup`})]}),(0,l.jsxs)(u.Link,{to:`/contact`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full text-left`,children:[(0,l.jsx)(n.k,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Contact`})]}),(0,l.jsxs)(`div`,{className:`pt-2 mt-1 border-t border-[var(--panel-border)]/50 flex flex-col gap-1`,children:[(0,l.jsxs)(u.Link,{to:`/login`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full`,children:[(0,l.jsx)(n.A,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign In`})]}),(0,l.jsx)(u.Link,{to:`/register`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl btn-primary w-full shadow-lg hover:-translate-y-0.5 transition-transform text-white`,children:(0,l.jsx)(`span`,{className:`text-[14px] font-bold mx-auto`,children:`Get Started`})})]})]})]})})]})]})]}),!t&&r&&(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2 mr-1`,children:[i===`admin`&&(0,l.jsx)(h,{}),j?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:A,className:`p-2 ml-1 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4 md:w-5 md:h-5`}):(0,l.jsx)(n.E,{className:`w-4 h-4 md:w-5 md:h-5`})})]}),(0,l.jsxs)(`div`,{className:`relative z-50 flex items-center gap-3`,children:[(0,l.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,l.jsxs)(`button`,{onClick:()=>f(d===`user`?!1:`user`),className:`flex items-center gap-2 group p-1 sm:pr-2.5 rounded-full glass-panel hover:bg-foreground/5 transition-all duration-300 border ${d===`user`?`border-accent/40 bg-foreground/5`:`border-transparent hover:border-[var(--panel-border)]`}`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-9 md:h-9 rounded-full bg-accent/10 flex items-center justify-center overflow-hidden border border-[var(--panel-border)] group-hover:border-accent/30 transition-colors shrink-0 text-accent`,children:r.photoURL&&!T?(0,l.jsx)(`img`,{src:r.photoURL,alt:`Profile`,className:`w-full h-full object-cover`,onError:()=>E(!0)}):(0,l.jsx)(n.d,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,l.jsxs)(`div`,{className:`hidden sm:flex flex-col text-left mr-1 justify-center min-w-[70px] max-w-[160px]`,children:[(0,l.jsx)(`span`,{className:`text-[12px] font-extrabold leading-tight text-foreground truncate w-full`,children:O}),(0,l.jsx)(`span`,{className:`text-[10px] font-mono tracking-wider leading-tight text-accent truncate w-full mt-0.5 uppercase font-bold`,children:i===`admin`?`Admin`:`Free User`})]})]}),(0,l.jsx)(n.a,{children:d===`user`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`absolute top-full mt-2 right-0 w-[280px] md:w-[320px] glass-panel border border-[var(--panel-border)] rounded-2xl p-2 shadow-2xl z-50 flex flex-col origin-top-right`,children:[(0,l.jsxs)(`div`,{className:`p-3 border-b border-[var(--panel-border)]/50 mb-1 flex flex-col gap-1.5`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[15px] text-foreground truncate`,children:O}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate font-mono`,children:r.email})]}),(0,l.jsxs)(`div`,{className:`py-1`,children:[(0,l.jsxs)(u.Link,{to:`/profile`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.d,{className:`w-3 h-3 text-accent`})}),`Profile Settings`]}),(0,l.jsxs)(u.Link,{to:`/drive`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.V,{className:`w-3 h-3 text-accent`})}),`Drive`]}),i===`admin`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(u.Link,{to:`/users`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.u,{className:`w-3 h-3 text-accent`})}),`Users`]}),(0,l.jsxs)(u.Link,{to:`/submissions`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.k,{className:`w-3 h-3 text-accent`})}),`Submissions`]}),(0,l.jsxs)(u.Link,{to:`/requests`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.et,{className:`w-3 h-3 text-accent`})}),`Requests`]}),(0,l.jsxs)(u.Link,{to:`/settings`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.y,{className:`w-3 h-3 text-accent`})}),`Settings`]}),(0,l.jsxs)(u.Link,{to:`/pages`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.L,{className:`w-3 h-3 text-accent`})}),`Pages`]})]}),i!==`admin`&&(0,l.jsxs)(u.Link,{to:`/support`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3 text-left`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.et,{className:`w-3 h-3 text-accent`})}),I]})]}),(0,l.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,l.jsxs)(`button`,{onClick:ee,className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-bold tracking-wide hover:bg-red-500/10 hover:text-red-500 text-foreground/70 transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-red-500/5 flex items-center justify-center shrink-0 text-red-500`,children:(0,l.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3`,children:[(0,l.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,l.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,l.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]})}),`Sign Out`]})})]})]})})]}),(0,l.jsxs)(`div`,{className:`relative sm:hidden`,children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`nav`?!1:`nav`),className:`p-2 rounded-xl glass-panel glow-hover border transition-all ${d===`nav`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,l.jsx)(n.O,{className:`w-5 h-5 text-accent/80`})}),(0,l.jsx)(n.a,{children:d===`nav`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.95},className:`absolute top-full right-0 mt-3 w-[220px] p-2 glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col gap-1 origin-top-right`,children:[(0,l.jsxs)(u.Link,{to:`/profile`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.d,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Profile Settings`})]}),(0,l.jsxs)(u.Link,{to:`/drive`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.V,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Drive`})]}),(0,l.jsxs)(u.Link,{to:`/dashboard`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.I,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Dashboard`})]}),i===`admin`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(u.Link,{to:`/users`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.u,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Users`})]}),(0,l.jsxs)(u.Link,{to:`/submissions`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.k,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Submissions`})]}),(0,l.jsxs)(u.Link,{to:`/requests`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.et,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Requests`})]}),(0,l.jsxs)(u.Link,{to:`/settings`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.y,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Settings`})]})]}),i!==`admin`&&(0,l.jsxs)(u.Link,{to:`/support`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full text-left`,children:[(0,l.jsx)(n.et,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Support`})]}),(0,l.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,l.jsx)(`button`,{onClick:ee,className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-red-500/10 text-red-500/80 hover:text-red-500 transition-all w-full`,children:(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign Out`})})})]})]})})]})]})]}),t&&(0,l.jsx)(l.Fragment,{children:j?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:A,className:`p-2 ml-1 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4`}):(0,l.jsx)(n.E,{className:`w-4 h-4`})})})]})]})}var S={hero:{title:`Firebase OS.`,showSubtitle:!0,subtitle:`The Open-Source Firebase Starter`,text:`A production-ready Firebase backend template with Auth, Firestore prefix rules, and a clean dashboard — ready for vibe-coded apps.`,buttons:{primary:{text:`Start Building Free`,action:`register`},secondary:{text:`Sign In`,action:`sign_in`}}}};function C(){let[e,t]=(0,a.useState)(null),r=n.St()?.defaultConfigs?.home||S,[i,s]=(0,a.useState)(()=>{try{let e=localStorage.getItem(`fbos_home_config`);if(e)return JSON.parse(e)}catch{}return r}),[c,d]=(0,a.useState)(!0);if((0,a.useEffect)(()=>(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_pages`,`home`),e=>{if(e.exists()){let t=e.data();s(t),localStorage.setItem(`fbos_home_config`,JSON.stringify(t))}else s(r),localStorage.removeItem(`fbos_home_config`)}),[]),!c)return null;let f=i||S,p=f?.hero?.showSubtitle??!0;f?.hero?.subtitleEmoji;let m=f?.hero?.title||f?.heroTitle||`The Open-Source Firebase Starter`,h=f?.hero?.subtitle||f?.heroSubtitle||`The Open-Source Firebase Starter`,g=f?.hero?.text||f?.heroText||`A production-ready Firebase backend template with Auth, Firestore prefix rules, and a clean dashboard — ready for vibe-coded apps.`;f?.hero?.buttons?.primary?.text||f?.primaryBtnText,f?.hero?.buttons?.primary?.action||f?.primaryBtnAction;let _=f?.hero?.buttons?.primary||{},v=f?.hero?.buttons?.secondary||{},y=(e,n,r,i)=>{let a=e.text||n,o=e.action||r,s=i.replace(/rounded-\[.*?\]|rounded-\w+/g,``).replace(/border /g,``).replace(/border-\[.*?\]/g,``),c={borderRadius:`var(--btn-radius, 0.75rem)`};if(o===`form`){let n=e.form||`contact`;return(0,l.jsx)(`button`,{onClick:()=>t(n),className:s,style:c,children:a})}if(o===`redirect`){let t=e.url||`/`;return t.startsWith(`http`)?(0,l.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:s,style:c,children:a}):(0,l.jsx)(u.Link,{to:t,className:s,style:c,children:a})}return(0,l.jsx)(u.Link,{to:{sign_in:`/login`,register:`/register`}[o]||`/register`,className:s,style:c,children:a})};return(0,l.jsxs)(`main`,{className:`flex-1 flex flex-col items-center justify-center w-full max-w-5xl mx-auto mt-4 md:mt-12 mb-16 md:mb-24 z-10 relative`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},className:`text-center mb-8 md:mb-12`,children:[p&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{delay:.2},className:`inline-flex items-center gap-2 md:gap-3 px-5 md:px-6 py-2 md:py-2.5 mb-8 md:mb-10 text-[13px] md:text-[15px] font-semibold tracking-wide uppercase rounded-full glass-panel text-foreground glow-hover cursor-pointer`,children:[h===S.hero.subtitle&&(0,l.jsx)(n.s,{className:`w-4 h-4 text-accent`}),` `,h]}),(0,l.jsx)(n.i.h1,{className:`text-5xl sm:text-6xl md:text-7xl lg:text-[5.5rem] font-extrabold tracking-tight mb-6 md:mb-8 text-gradient animate-float leading-[1.1] md:leading-[1.15] px-2`,children:m}),(0,l.jsx)(`p`,{className:`text-[15px] sm:text-lg md:text-xl lg:text-[22px] text-foreground/60 max-w-3xl mx-auto font-medium leading-[1.6] md:leading-[1.7] mb-10 md:mb-14 px-6 md:px-4`,children:g}),(0,l.jsxs)(n.i.div,{className:`flex flex-col sm:flex-row items-center justify-center gap-4 sm:gap-6 w-full max-w-2xl mx-auto px-6`,initial:{opacity:0},animate:{opacity:1},transition:{delay:.5},children:[y(_,`Start Building Free`,`register`,`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`),y(v,`Sign In`,`sign_in`,`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-secondary text-[15px] transition-all duration-300 flex items-center justify-center hover:-translate-y-1`)]})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsx)(n.t,{onClose:()=>t(null),formId:e})})]})}function w(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),o=(0,u.useNavigate)(),{registerUser:c}=m();return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 md:mt-8 mb-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Create an account`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Join Firebase OS and start building today.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 mb-6 text-[14px] font-medium text-red-400 bg-red-500/10 rounded-xl border border-red-500/20`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let n=new FormData(e.currentTarget),r=n.get(`email`),a=n.get(`password`),s=n.get(`firstName`),d=n.get(`lastName`);if(a.length<6){i(`Password must be at least 6 characters.`),t(!1);return}try{await c(r,a,s,d),o(`/verify`)}catch(e){e?.code===`auth/email-already-in-use`?i((0,l.jsxs)(`span`,{children:[`An account with this email already exists.`,` `,(0,l.jsx)(u.Link,{to:`/login?email=${encodeURIComponent(r)}`,className:`font-bold underline hover:text-accent transition-colors`,children:`Sign in?`})]})):e?.code===`auth/weak-password`?i(`Password must be at least 6 characters.`):i(e?.message||`An error occurred during registration.`)}finally{t(!1)}},children:[(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,l.jsx)(n.r,{name:`firstName`,label:`First Name`,type:`text`,placeholder:`John`,required:!0}),(0,l.jsx)(n.r,{name:`lastName`,label:`Last Name`,type:`text`,placeholder:`Doe`,required:!0})]}),(0,l.jsx)(n.r,{name:`email`,label:`Email`,type:`email`,placeholder:`name@example.com`,required:!0}),(0,l.jsx)(n.r,{name:`password`,label:`Password`,type:`password`,placeholder:`••••••••`,required:!0}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsxs)(n.n,{type:`submit`,className:`w-full py-3 text-[15px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,isLoading:e,children:[`Create Account `,(0,l.jsx)(n.mt,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,l.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,l.jsxs)(n.n,{variant:`secondary`,onClick:async()=>{t(!0);try{await(0,s.signInWithPopup)(n.Ct,new s.GoogleAuthProvider)}catch(e){e instanceof Error&&i(e.message)}finally{t(!1)}},className:`w-full py-3 text-[15px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,disabled:e,children:[(0,l.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`})]}),`Sign up with Google`]}),(0,l.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`Already have an account? `,(0,l.jsx)(u.Link,{to:`/login`,className:`text-accent hover:underline font-bold ml-1`,children:`Sign in`})]})]})]})})}function T(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),[o]=(0,u.useSearchParams)(),c=(0,u.useNavigate)(),[d]=(0,a.useState)(o.get(`email`)||``);return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 md:mt-8 mb-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Welcome back`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Sign in to Firebase OS.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 mb-6 text-[14px] font-medium text-red-400 bg-red-500/10 rounded-xl border border-red-500/20`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let r=new FormData(e.currentTarget),a=r.get(`email`),d=r.get(`password`);try{await(0,s.signInWithEmailAndPassword)(n.Ct,a,d),c(o.get(`from`)||`/dashboard`,{replace:!0})}catch(e){e?.code===`auth/invalid-credential`||e?.code===`auth/user-not-found`||e?.code===`auth/wrong-password`?i((0,l.jsxs)(`span`,{children:[`Email or Password are incorrect.`,` `,(0,l.jsx)(u.Link,{to:`/reset-password`,className:`font-bold underline hover:text-red-400 transition-colors`,children:`Reset password?`})]})):i(e?.message||`Invalid credentials.`),t(!1)}},children:[(0,l.jsx)(n.r,{name:`email`,label:`Email`,type:`email`,defaultValue:d,placeholder:`name@example.com`,required:!0}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex justify-between items-center pr-1`,children:[(0,l.jsx)(`label`,{className:`text-[14px] md:text-[15px] tracking-wide font-medium text-foreground/80 select-none pb-1`,children:`Password`}),(0,l.jsx)(u.Link,{to:`/reset-password`,className:`text-[13px] md:text-[14px] text-accent hover:underline font-bold tracking-wide`,children:`Forgot Password?`})]}),(0,l.jsx)(n.r,{name:`password`,type:`password`,placeholder:`••••••••`,required:!0})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsxs)(n.n,{type:`submit`,className:`w-full py-3 text-base font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,isLoading:e,children:[`Sign In `,(0,l.jsx)(n.mt,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,l.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,l.jsxs)(n.n,{variant:`secondary`,onClick:async()=>{t(!0);try{await(0,s.signInWithPopup)(n.Ct,new s.GoogleAuthProvider),c(o.get(`from`)||`/dashboard`,{replace:!0})}catch(e){e instanceof Error&&i(e.message)}finally{t(!1)}},className:`w-full py-3 text-base font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,disabled:e,children:[(0,l.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`}),(0,l.jsx)(`path`,{fill:`currentColor`,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`})]}),`Sign in with Google`]}),(0,l.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`New here? `,(0,l.jsx)(u.Link,{to:`/register`,className:`text-accent hover:underline font-bold ml-1`,children:`Create account`})]})]})]})})}function E(){let{user:e,refreshUser:t}=m(),r=(0,u.useNavigate)(),[i,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(!1),[f,p]=(0,a.useState)(``);return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 md:p-8 lg:p-10 rounded-3xl glass-panel relative glow-hover text-center shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`w-14 h-14 md:w-16 md:h-16 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mx-auto mb-5 md:mb-6 animate-float shadow-xl`,children:(0,l.jsx)(n.k,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,l.jsx)(`h1`,{className:`text-2xl md:text-3xl font-extrabold mb-3 text-foreground tracking-tight`,children:`Verify your email`}),(0,l.jsxs)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/60 mb-6 md:mb-8 leading-[1.6] tracking-wide`,children:[`We've sent a verification link to `,(0,l.jsx)(`span`,{className:`font-semibold text-foreground`,children:e?.email}),`. Please check your inbox (and spam folder) to verify your account and access your dashboard.`]}),f&&(0,l.jsx)(`div`,{className:`p-3 md:p-4 mb-5 md:mb-6 text-[13px] md:text-[14px] font-medium rounded-xl border ${f.includes(`Failed`)||f.includes(`not verified`)||f.includes(`wrong`)?`text-red-400 bg-red-500/10 border-red-500/20`:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`}`,children:f}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[(0,l.jsx)(n.n,{variant:`primary`,onClick:async()=>{o(!0),p(``);try{if(n.Ct.currentUser){if(await n.Ct.currentUser.reload(),!n.Ct.currentUser.emailVerified){p(`Email is not verified yet. Please check your inbox.`),o(!1);return}await n.Ct.currentUser.getIdToken(!0),await t(),r(`/dashboard`)}}catch{p(`Something went wrong. Please try again.`),o(!1)}},isLoading:i,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,children:`I've verified my email`}),(0,l.jsx)(n.n,{variant:`ghost`,onClick:async()=>{if(e){d(!0),p(``);try{await(0,s.sendEmailVerification)(e),p(`Verification email sent! Please check your inbox.`)}catch(e){e?.code===`auth/too-many-requests`?p(`Failed to resend: Please wait a minute before trying again.`):p(e?.message||`Failed to resend. Please try again later.`)}finally{d(!1)}}},isLoading:c,className:`w-full py-2.5 md:py-3 text-[13px] md:text-[14px] font-semibold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,children:`Resend verification link`})]})]})})}var D={pages:{path:`/pages`,label:`Pages`,icon:n.L,roles:[`admin`]},forms:{path:`/forms`,label:`Forms`,icon:n.S,roles:[`admin`]},drive:{path:`/drive`,label:`Drive`,icon:n.V,roles:[`admin`,`user`,`editor`,`guest`]},users:{path:`/users`,label:`Users`,icon:n.u,roles:[`admin`]},theme:{path:`/theme`,label:`Theme`,icon:n.T,roles:[`admin`]},submissions:{path:`/submissions`,label:`Submissions`,icon:n.k,roles:[`admin`]},requests:{path:`/requests`,label:`Requests`,icon:n.et,roles:[`admin`]},settings:{path:`/settings`,label:`Settings`,icon:n.y,roles:[`admin`]},profile:{path:`/profile`,label:`Profile`,icon:n.d,roles:[`admin`,`user`,`editor`,`guest`]},support:{path:`/support`,label:`Support`,icon:n.et,roles:[`user`,`editor`,`guest`]}};function O({customTabs:e=[]}){let{pathname:t}=(0,u.useLocation)(),{userRole:r}=m(),[i,s]=(0,a.useState)(!1),c=(0,a.useRef)(null),[d,f]=(0,a.useState)({}),[p,h]=(0,a.useState)(v);(0,a.useEffect)(()=>{try{let e=localStorage.getItem(`fbos_nav_tabs`);e&&f(JSON.parse(e));let t=localStorage.getItem(`fbos_nav_order`);t&&h(JSON.parse(t))}catch{}let e=(0,o.onSnapshot)((0,o.collection)(n.wt,`sys_tabs`),e=>{let t={};e.forEach(e=>{t[e.id]=e.data()}),f(t),localStorage.setItem(`fbos_nav_tabs`,JSON.stringify(t))},e=>{console.warn(`sys_tabs snapshot error:`,e)}),t=(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_configs`,`tab_order`),e=>{let t=e.exists()&&Array.isArray(e.data().order)?_(e.data().order):v;h(t),localStorage.setItem(`fbos_nav_order`,JSON.stringify(t))},e=>{console.warn(`tab_order snapshot error:`,e)});return()=>{e(),t()}},[]),(0,a.useEffect)(()=>{function e(e){c.current&&!c.current.contains(e.target)&&s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let g=[...(()=>{let e={};Object.entries(D).forEach(([t,n])=>{e[t]={id:t,...n,exact:!0}}),Object.entries(d).forEach(([t,r])=>{let i=e[t],a=i?.icon??n.L;if(r?.iconName){let e=r.iconName.trim(),t=e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);n.o[t]?a=n.o[t]:n.o[e]&&(a=n.o[e])}let o=i?.roles??[`admin`];r?.pageType===`admin`?o=[`admin`]:r?.pageType===`shared`?o=[`admin`,`editor`,`user`]:r?.pageType===`private`?o=[`admin`,`user`]:r?.pageType===`public`&&(o=[`admin`,`user`,`editor`,`guest`]),e[t]={id:t,path:r?.route?r.route.startsWith(`/`)?r.route:`/`+r.route:i?.path??`/`+t,label:r?.tabName||r?.pageTitle||r?.pageName||i?.label||t,icon:a,roles:o,exact:!0}});let t=[],r=new Set;p.forEach(n=>{n.hidden||e[n.id]&&(t.push(e[n.id]),r.add(n.id))});let i=[],a=[];return Object.keys(e).forEach(t=>{if(r.has(t))return;let n=p.find(e=>e.id===t);n?.hidden||(t in d&&!n?i.push(e[t]):a.push(e[t]))}),i.length>0&&t.unshift(...i),a.length>0&&t.push(...a),t})(),...e.map(e=>({...e,id:e.path}))].filter(e=>e.id===`support`&&r===`admin`?!1:Array.isArray(e.roles)?e.roles.includes(r||`guest`):!1),y=(0,a.useRef)(null),b=(0,a.useRef)(null),[x,S]=(0,a.useState)(g.length);(0,a.useEffect)(()=>{let e=()=>{let e=y.current,t=b.current;if(!e||!t)return;let n=e.clientWidth;if(n===0)return;let r=t.querySelectorAll(`[data-measure-tab]`);if(r.length===0){S(g.length);return}let i=0,a=!0;for(let e=0;e<r.length;e++)if(i+=r[e].offsetWidth+(e>0?40:0),i>n){a=!1;break}if(a){S(g.length);return}let o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e].offsetWidth,i=o+t+(e>0?40:0);if(i+52>n)break;o=i,s++}S(Math.max(s,1))},t=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(t);let n=new ResizeObserver(()=>requestAnimationFrame(e));return y.current&&n.observe(y.current),()=>{cancelAnimationFrame(t),n.disconnect()}},[g.map(e=>e.id+e.label).join(`|`),g.length]);let C=g.slice(0,x),w=g.slice(x),T=e=>e.exact?t===e.path:t.startsWith(e.path),E=w.some(e=>T(e));return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{ref:b,"aria-hidden":`true`,className:`flex items-center gap-6 md:gap-10 whitespace-nowrap px-1`,style:{position:`fixed`,top:-9999,left:0,visibility:`hidden`,pointerEvents:`none`},children:g.map(e=>{let t=e.icon;return(0,l.jsxs)(`span`,{"data-measure-tab":!0,className:`flex items-center gap-2 text-[14.5px] font-semibold shrink-0 pb-3`,children:[(0,l.jsx)(t,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)})}),(0,l.jsxs)(`div`,{ref:y,className:`w-full flex items-center gap-6 md:gap-10 mb-8 border-b border-[var(--panel-border)] px-1 whitespace-nowrap relative`,children:[C.map(e=>{let t=T(e),n=e.icon;return(0,l.jsxs)(u.Link,{to:e.path||`/`,className:`flex items-center gap-2 text-[14.5px] font-semibold transition-all duration-300 pb-3 -mb-[1px] border-b-2 shrink-0 ${t?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,children:[(0,l.jsx)(n,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)}),w.length>0&&(0,l.jsxs)(`div`,{className:`relative shrink-0 ml-auto`,ref:c,children:[(0,l.jsx)(`button`,{onClick:()=>s(!i),className:`flex items-center justify-center transition-all duration-300 pb-3 -mb-[1px] border-b-2 cursor-pointer ${E?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,title:`More items`,children:(0,l.jsx)(n.q,{className:`w-5 h-5`})}),(0,l.jsx)(n.a,{children:i&&(0,l.jsx)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:`absolute top-[100%] right-0 mt-2 min-w-[200px] bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-xl z-50 flex flex-col py-2 overflow-hidden`,children:w.map(e=>{let t=T(e),n=e.icon;return(0,l.jsxs)(u.Link,{to:e.path||`/`,onClick:()=>s(!1),className:`flex items-center gap-3 px-5 py-3 text-[14px] font-medium transition-colors ${t?`text-accent bg-accent/5`:`text-foreground/70 hover:text-foreground hover:bg-foreground/5`}`,children:[(0,l.jsx)(n,{className:`w-4 h-4`}),e.label]},e.path||e.id)})})})]})]})]})}function k(){let{user:e,refreshUser:t}=m(),[r,i]=(0,a.useState)(e?.displayName||``),[u,d]=(0,a.useState)(e?.email||``),[f,p]=(0,a.useState)(e?.photoURL||``),[h,g]=(0,a.useState)(!1),[_,v]=(0,a.useState)(null),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(``),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)(!1),[D,k]=(0,a.useState)(!0);a.default.useEffect(()=>{i(e?.displayName||``),d(e?.email||``),p(e?.photoURL||``)},[e?.uid,e?.displayName,e?.email,e?.photoURL]);let A=async t=>{if(e)try{let r=[`mem_files`,`admin_files`];(await(0,o.getDocs)((0,o.collection)(n.wt,`sys_tabs`))).forEach(e=>{let t=e.data(),n=(t.tabName||e.id).toLowerCase().replace(/[^a-z0-9]+/g,`_`);t.pageType===`shared`&&r.push(`mem_${n}_records`),t.pageType===`admin`&&r.push(`admin_${n}_records`)});for(let i of r)try{let r=await(0,o.getDocs)((0,o.query)((0,o.collection)(n.wt,i),(0,o.where)(`uid`,`==`,e.uid)));if(r.empty)continue;let a=(0,o.writeBatch)(n.wt);r.docs.forEach(e=>a.update(e.ref,{creatorAvatar:t})),await a.commit()}catch{}}catch(e){console.error(`Error propagating avatar to records:`,e)}};return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Profile Settings`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/profile`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(O,{})}),(0,l.jsx)(n.a,{children:_&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.98,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:-10},className:`p-4 mb-6 rounded-2xl border flex flex-col sm:flex-row sm:items-center gap-3 ${_.type===`error`?`bg-red-500/10 border-red-500/20 text-red-400`:`bg-accent/10 border-accent/20 text-accent`}`,children:[_.type===`success`?(0,l.jsx)(n.tt,{className:`w-5 h-5 shrink-0`}):(0,l.jsx)(n.nt,{className:`w-5 h-5 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px] font-semibold tracking-wide leading-relaxed`,children:_.text})]})}),(0,l.jsx)(`form`,{onSubmit:async i=>{if(i.preventDefault(),e){g(!0),v(null);try{r!==e.displayName&&await(0,s.updateProfile)(e,{displayName:r});let i=!1;if(u!==e.email){let t=await(0,s.fetchSignInMethodsForEmail)(n.Ct,u);if(t&&t.length>0)throw Error(`An account with this email already exists.`);await(0,s.verifyBeforeUpdateEmail)(e,u),i=!0}if(y){if(y!==x)throw Error(`Passwords do not match.`);if(y.length<6)throw Error(`Password must be at least 6 characters.`);await(0,s.updatePassword)(e,y),b(``),S(``)}await t(),v(i?{text:`Profile updated. A verification link has been sent to your new email address.`,type:`success`}:{text:`Profile successfully updated.`,type:`success`})}catch(e){console.error(e),e.code===`auth/requires-recent-login`?v({text:`For security, please sign out and sign back in before changing your email or password.`,type:`error`}):v({text:e.message||`Failed to update profile.`,type:`error`})}finally{g(!1)}}},className:`w-full flex flex-col`,children:(0,l.jsxs)(`div`,{className:`glass-panel w-full p-8 md:p-12 rounded-3xl border border-[var(--panel-border)] shadow-2xl space-y-8 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-6 pb-6 border-b border-[var(--panel-border)]/50`,children:[(0,l.jsxs)(`div`,{className:`w-24 h-24 md:w-28 md:h-28 rounded-full glass-panel border-4 border-[var(--panel-border)] shadow-xl bg-accent/10 flex items-center justify-center relative overflow-hidden shrink-0 group transition-transform duration-300 hover:scale-[1.02]`,children:[(T||f&&D&&!C)&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-10`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),f&&!C?(0,l.jsx)(`img`,{src:f,alt:`Avatar`,className:`w-full h-full object-cover transition-opacity duration-300 ${D?`opacity-0`:`opacity-100`}`,onLoad:()=>k(!1),onError:()=>{w(!0),k(!1)}}):(0,l.jsx)(n.d,{className:`w-10 h-10 md:w-12 md:h-12 text-accent`}),!T&&(0,l.jsxs)(`div`,{className:`absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2 z-10 backdrop-blur-sm`,children:[(0,l.jsxs)(`label`,{className:`flex flex-col items-center justify-center cursor-pointer p-2 rounded-full hover:bg-white/20 transition-colors text-white`,title:`Upload Photo`,children:[(0,l.jsx)(n.lt,{className:`w-5 h-5`}),(0,l.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:async r=>{let i=r.target.files?.[0];if(!(!i||!e)){if(i.size>2*1024*1024){v({text:`File too large. Please select an image under 2MB.`,type:`error`});return}E(!0),w(!1),k(!0);try{let r=(0,c.ref)(n.Et,`user_avatars/${e.uid}/file.png`);await(0,c.uploadBytes)(r,i,{customMetadata:{ownerId:e.uid}});let a=await(0,c.getDownloadURL)(r);await(0,s.updateProfile)(e,{photoURL:a}),await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,e.uid),{avatar:a}),p(a),await t(),A(a),v({text:`Avatar successfully updated!`,type:`success`})}catch(e){console.error(e),v({text:`Failed to upload photo.`,type:`error`})}finally{E(!1)}}},className:`hidden`})]}),f&&(0,l.jsx)(`button`,{type:`button`,onClick:async()=>{if(e){E(!0),w(!1),k(!1);try{await(0,c.deleteObject)((0,c.ref)(n.Et,`user_avatars/${e.uid}/file.png`)).catch(e=>console.error(e)),await(0,s.updateProfile)(e,{photoURL:``}),await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,e.uid),{avatar:``}),p(``),await t(),A(``),v({text:`Avatar removed.`,type:`success`})}catch(e){console.error(e),v({text:`Failed to delete photo.`,type:`error`})}finally{E(!1)}}},className:`p-2 rounded-full hover:bg-red-500/80 text-white transition-colors`,title:`Delete Photo`,children:(0,l.jsx)(n.h,{className:`w-5 h-5`})})]})]}),(0,l.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,l.jsx)(`h3`,{className:`font-extrabold text-2xl text-foreground mb-1`,children:r||`Firebase OS User`}),(0,l.jsx)(`div`,{className:`text-[12px] font-mono uppercase tracking-widest text-accent bg-accent/10 px-2.5 py-1 rounded-md border border-accent/20 inline-block`,children:e?.emailVerified?`Verified Account`:`Unverified`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/40 mt-2 font-medium`,children:e?.email})]})]}),(0,l.jsxs)(`div`,{className:`space-y-6`,children:[(0,l.jsx)(`h3`,{className:`text-[16px] font-extrabold text-foreground flex items-center gap-2`,children:`Account Details`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,l.jsx)(n.r,{name:`name`,value:r,onChange:e=>i(e.target.value),label:`Display Name`,placeholder:`John Doe`}),(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(n.r,{name:`email`,type:`email`,value:u,onChange:e=>d(e.target.value),label:`Email Address`,placeholder:`name@example.com`,required:!0}),(0,l.jsx)(`p`,{className:`text-[11px] text-foreground/40 mt-1.5 px-2 font-medium`,children:`Changing email sends a verification link to the new address.`})]})]})]}),(0,l.jsxs)(`div`,{className:`pt-6 border-t border-[var(--panel-border)]/50`,children:[(0,l.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground mb-4 flex items-center gap-2`,children:`Change Password`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,l.jsx)(n.r,{name:`password`,type:`password`,label:`New Password`,value:y,onChange:e=>b(e.target.value),placeholder:`Minimum 6 characters`}),(0,l.jsx)(n.r,{name:`confirmPassword`,type:`password`,label:`Confirm Password`,value:x,onChange:e=>S(e.target.value),placeholder:`Repeat password`})]})]}),(0,l.jsx)(`div`,{className:`pt-8 border-t border-[var(--panel-border)]/50 flex justify-start w-full`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:h,className:`px-12 py-3 md:py-2.5 text-[14px] md:text-[15px] font-bold tracking-wide rounded-xl hover:-translate-y-0.5`,children:`Save Changes`})})]})})]})]})}function A(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),[o,c]=(0,a.useState)(0),[d,f]=(0,a.useState)(0);return(0,a.useEffect)(()=>{let e;return o>0&&(e=setInterval(()=>c(e=>e-1),1e3)),()=>clearInterval(e)},[o]),(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16 mt-6 md:mt-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 md:p-8 lg:p-10 rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] text-center`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-40 blur-[15px] rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`w-14 h-14 md:w-16 md:h-16 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mx-auto mb-5 md:mb-6 animate-float shadow-xl`,children:(0,l.jsx)(n.R,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl md:text-3xl font-extrabold mb-2 md:mb-3 text-foreground tracking-tight`,children:`Reset Password`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Enter your email to receive a recovery link.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 md:p-4 mb-5 md:mb-6 text-[13px] md:text-[14px] font-medium text-emerald-400 bg-emerald-500/10 rounded-xl border border-emerald-500/20 max-w-[360px] mx-auto`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4 text-left max-w-[360px] mx-auto`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let r=new FormData(e.currentTarget).get(`email`);try{await(0,s.sendPasswordResetEmail)(n.Ct,r)}catch(e){console.error(e)}finally{i(`If an account exists, a password reset link has been sent. Please check your inbox (and spam folder).`);let e=d+1;f(e),c(e===1?60:120),t(!1)}},children:[(0,l.jsx)(n.r,{name:`email`,label:`Work Email`,type:`email`,placeholder:`name@company.com`,required:!0}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl md:rounded-xl transition-all ${o>0?`bg-foreground/5 text-foreground/40 border border-[var(--panel-border)] shadow-none cursor-not-allowed hover:translate-y-0`:`hover:-translate-y-0.5`}`,isLoading:e,disabled:o>0,children:o>0?`Resend link in ${(e=>`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`)(o)}`:d>0?`Resend reset password link`:`Send Reset Link`})})]}),(0,l.jsx)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:(0,l.jsxs)(u.Link,{to:`/login`,className:`inline-flex items-center text-[13px] md:text-[14px] text-foreground/70 font-medium hover:text-accent transition-colors tracking-wide`,children:[(0,l.jsx)(n.ht,{className:`w-4 h-4 mr-2`}),`Back to Sign In`]})})]})})}function j(){let{user:e,userRole:t}=m(),[r,i]=(0,a.useState)(!0),s=(0,u.useNavigate)(),{id:d}=(0,u.useParams)(),[f,p]=(0,a.useState)([]),[h,g]=(0,a.useState)(null),[_,v]=(0,a.useState)(!1),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(!1),C=d?f.find(e=>e.id===d)||null:f.length>0?f[0]:null,w=e=>{s(e?`/users/${e.id}`:`/users`)};(0,a.useEffect)(()=>{i(!0);let e=(0,o.onSnapshot)((0,o.collection)(n.wt,`user_profiles`),e=>{let t=[];e.forEach(e=>{t.push({id:e.id,...e.data()})}),p(t),i(!1),!d&&t.length>0&&s(`/users/${t[0].id}`,{replace:!0})},e=>{console.error(`Error fetching users:`,e),i(!1)});return()=>e()},[d,s]);let T=f.find(t=>t.id===e?.uid),E=e=>e.id===T?.id?!1:e.role!==`admin`||!T?.createdAt?!0:e.createdAt?new Date(T.createdAt).getTime()<=new Date(e.createdAt).getTime():!1,D=async(e,r)=>{if(!(t!==`admin`||!E(e)))try{await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,e.id),{role:r?`admin`:null}),g({text:`User role updated successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},k=async(e,r)=>{if(!(t!==`admin`||!E(e)))try{await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,e.id),{inactive:r}),g({text:`User ${r?`deactivated`:`activated`} successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},A=async()=>{if(v(!1),!(!C||!E(C)||y===C.displayName))try{await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,C.id),{displayName:y}),g({text:`Name updated successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},j=async e=>{let t=e.target.files?.[0];if(!(!t||!C||!E(C))){if(t.size>2*1024*1024){g({text:`File too large.`,type:`error`});return}S(!0);try{let e=(0,c.ref)(n.Et,`user_avatars/${C.id}/file.png`);await(0,c.uploadBytes)(e,t);let r=await(0,c.getDownloadURL)(e);await(0,o.updateDoc)((0,o.doc)(n.wt,`user_profiles`,C.id),{avatar:r}),g({text:`Avatar successfully updated.`,type:`success`}),setTimeout(()=>g(null),3e3)}catch{g({text:`Failed to upload photo.`,type:`error`})}S(!1)}},[ee,M]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e;return r&&f.length===0?e=setTimeout(()=>M(!0),150):M(!1),()=>clearTimeout(e)},[r,f.length]),r&&f.length===0?ee?(0,l.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-background/60 backdrop-blur-xl transition-all duration-300`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 animate-spin text-accent`})}):null:(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Users`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/users`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,l.jsx)(n.a,{children:h&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:`p-4 text-[14px] font-medium border ${h.type===`error`?`text-red-500 bg-red-500/10 border-red-500/20 shadow-[0_0_15px_rgba(239,68,68,0.1)]`:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20 shadow-[0_0_15px_rgba(52,211,153,0.1)]`} rounded-xl flex items-center gap-2`,children:[h.type===`success`&&(0,l.jsx)(n.tt,{className:`w-4 h-4 shrink-0`}),h.text]})}),(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(O,{})}),(0,l.jsx)(`div`,{className:`glass-panel rounded-3xl border border-[var(--panel-border)] shadow-sm`,children:f.length===0?(0,l.jsx)(`div`,{className:`p-8 text-center text-foreground/50 text-[14px]`,children:`No members found.`}):(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`md:col-span-1 border-r md:border-r-[var(--panel-border)] border-b md:border-b-0 border-[var(--panel-border)] flex flex-col hide-scrollbar bg-black/5 dark:bg-white/5 rounded-t-3xl md:rounded-tr-none md:rounded-l-3xl`,children:[(0,l.jsx)(`div`,{className:`p-4 border-b border-[var(--panel-border)] font-bold text-[13px] text-foreground/70 uppercase tracking-wider`,children:`System Users`}),(0,l.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-2`,children:f.map(e=>(0,l.jsxs)(`div`,{onClick:()=>w(e),className:`p-4 py-5 rounded-2xl border transition-all flex items-center gap-4 cursor-pointer ${C?.id===e.id?`bg-accent/10 border-accent/40 shadow-sm`:`glass-panel border-transparent hover:border-[var(--panel-border)]`} ${e.inactive?`opacity-50 grayscale`:``}`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full overflow-hidden bg-accent/20 shrink-0 flex items-center justify-center border border-[var(--panel-border)]`,children:e.avatar||e.photoURL?(0,l.jsx)(`img`,{src:e.avatar||e.photoURL,alt:``,className:`w-full h-full object-cover`}):(0,l.jsx)(n.d,{className:`w-5 h-5 text-accent`})}),(0,l.jsxs)(`div`,{className:`flex flex-col truncate`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] truncate`,children:e.displayName||`No Name`}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 truncate font-mono mt-0.5`,children:e.email})]})]},e.id))})]}),(0,l.jsx)(`div`,{className:`md:col-span-2 flex flex-col p-6 md:p-10 relative`,children:C?(0,l.jsxs)(`div`,{className:`animate-in fade-in duration-300 w-full max-w-lg`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-6 md:gap-8 mb-10`,children:[(0,l.jsxs)(`div`,{className:`w-24 h-24 rounded-full glass-panel border-4 border-[var(--panel-border)] shadow-xl bg-accent/10 flex items-center justify-center relative overflow-hidden shrink-0 group`,children:[x?(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`}):C.avatar||C.photoURL?(0,l.jsx)(`img`,{src:C.avatar||C.photoURL,alt:`Avatar`,className:`w-full h-full object-cover`}):(0,l.jsx)(n.d,{className:`w-10 h-10 text-accent`}),!x&&E(C)&&(0,l.jsx)(`div`,{className:`absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center z-10 backdrop-blur-md`,children:(0,l.jsxs)(`label`,{className:`flex flex-col items-center justify-center cursor-pointer p-2 hover:bg-white/20 transition-colors text-white rounded-full`,title:`Upload Photo`,children:[(0,l.jsx)(n.lt,{className:`w-5 h-5`}),(0,l.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:j,className:`hidden`})]})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 w-full relative`,children:[_?(0,l.jsx)(`input`,{autoFocus:!0,value:y,onChange:e=>b(e.target.value),onBlur:A,onKeyDown:e=>e.key===`Enter`&&A(),className:`text-2xl md:text-3xl font-extrabold mb-1 bg-transparent border-b-2 border-accent outline-none text-foreground w-full py-1`}):(0,l.jsx)(`h3`,{onDoubleClick:()=>{E(C)&&(b(C.displayName||``),v(!0))},className:`text-2xl md:text-3xl font-extrabold mb-1 select-none ${E(C)?`cursor-pointer hover:text-accent transition-colors`:``}`,title:E(C)?`Double-click to edit`:``,children:C.displayName||`No Name`}),(0,l.jsx)(`p`,{className:`text-[14px] font-mono text-foreground/50`,children:C.email}),!E(C)&&C.id!==T?.id&&(0,l.jsx)(`div`,{className:`mt-3 inline-block self-start px-3 py-1.5 rounded-lg bg-foreground/5 border border-[var(--panel-border)] text-[11px] font-bold text-foreground/50 tracking-wide uppercase`,children:`Privileged Admin Account`})]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,l.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-between`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] text-foreground`,children:`Admin Access`}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/50`,children:`Toggle system privileges`})]}),(0,l.jsx)(`button`,{type:`button`,disabled:!E(C),onClick:()=>D(C,C.role!==`admin`),className:`relative inline-flex h-7 w-12 items-center rounded-full transition-colors focus:outline-none shadow-inner ${C.role===`admin`?`bg-accent`:`bg-foreground/20`} ${E(C)?`cursor-pointer`:`opacity-50 cursor-not-allowed`}`,children:(0,l.jsx)(`span`,{className:`inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-md ${C.role===`admin`?`translate-x-6`:`translate-x-1`}`})})]}),(0,l.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border flex items-center justify-between ${C.inactive?`border-amber-500/30 bg-amber-500/5`:`border-red-500/20 bg-red-500/5`}`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] ${C.inactive?`text-amber-500`:`text-red-500`}`,children:C.inactive?`Reactivate User`:`Deactivate User`}),(0,l.jsx)(`span`,{className:`text-[12px] ${C.inactive?`text-amber-500/70`:`text-red-500/70`}`,children:`Block access to this app`})]}),(0,l.jsx)(`button`,{type:`button`,disabled:!E(C),onClick:()=>k(C,!C.inactive),className:`relative inline-flex h-7 w-12 items-center rounded-full transition-colors focus:outline-none shadow-inner ${C.inactive?`bg-amber-500`:`bg-red-500/20`} ${E(C)?`cursor-pointer`:`opacity-50 cursor-not-allowed`}`,children:(0,l.jsx)(`span`,{className:`inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-md ${C.inactive?`translate-x-6`:`translate-x-1`}`})})]})]})]}):(0,l.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center opacity-30 pointer-events-none`,children:[(0,l.jsx)(n.u,{className:`w-12 h-12 mb-4`}),(0,l.jsx)(`p`,{className:`font-bold tracking-widest uppercase text-[12px]`,children:`Select a User`})]})})]})})]})]})}function ee({isOpen:e,title:t,message:r,confirmText:i=`Delete`,cancelText:a=`Cancel`,onConfirm:o,onCancel:s,isProcessing:c=!1,disableConfirm:u=!1}){return(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!c&&s(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[400px] p-6 rounded-3xl glass-panel border border-[var(--panel-border)] shadow-2xl relative z-10 text-center`,children:(0,l.jsxs)(`div`,{className:`w-full flex flex-col items-center`,children:[(0,l.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:t}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 leading-relaxed mb-6`,children:r}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:s,disabled:c,className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:a}),(0,l.jsx)(n.n,{onClick:o,disabled:c||u,className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl bg-red-500 hover:bg-red-600 border-none text-white shadow-xl hover:shadow-red-500/20 glow-hover`,children:c?(0,l.jsx)(n.M,{className:`w-5 h-5 animate-spin mx-auto`}):i})]})]})})]})})}var M=[`pages`,`forms`,`drive`,`users`,`theme`,`submissions`,`requests`,`settings`,`profile`,`support`],N={pages:`Pages`,forms:`Forms`,drive:`Drive`,users:`Users`,theme:`Theme`,submissions:`Submissions`,requests:`Requests`,settings:`Settings`,profile:`Profile`,support:`Request Support`},P=new Set([`home`]),F=new Set([`settings`]);function I(){let[e,t]=(0,a.useState)(`menu`),[r,i]=(0,a.useState)({}),[s,c]=(0,a.useState)({}),[u,d]=(0,a.useState)(g),[f,p]=(0,a.useState)(v),[m,h]=(0,a.useState)(!1),[y,b]=(0,a.useState)(null),[x,S]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.collection)(n.wt,`sys_pages`),e=>{let t={};e.forEach(e=>{let n=e.data();t[e.id]={id:e.id,title:n.pageName||n.title||e.id,path:n.route||(e.id===`home`?`/`:`/`+e.id),type:`public`,isSystem:[`home`,`templates`,`contact`,`setup`].includes(e.id)}}),t.setup||={id:`setup`,title:`Setup`,path:`/setup`,type:`public`,isSystem:!0},t.templates||={id:`templates`,title:`Templates`,path:`/templates`,type:`public`,isSystem:!0},t.contact||={id:`contact`,title:`Contact`,path:`/contact`,type:`public`,isSystem:!0},i(t)}),t=(0,o.onSnapshot)((0,o.collection)(n.wt,`sys_tabs`),e=>{let t={};e.forEach(e=>{let n=e.data();t[e.id]={id:e.id,title:n.pageName||n.tabName||n.title||N[e.id]||e.id,path:n.route||`/`+e.id,type:n.pageType||`admin`,isSystem:M.includes(e.id)}}),M.forEach(e=>{t[e]||(t[e]={id:e,title:N[e]||e,path:`/`+e,type:`admin`,isSystem:!0})}),c(t)}),r=(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_configs`,`page_order`),e=>{d(e.exists()?_(e.data().order||[]):g)}),a=(0,o.onSnapshot)((0,o.doc)(n.wt,`sys_configs`,`tab_order`),e=>{p(e.exists()?_(e.data().order||[]):v)});return()=>{e(),t(),r(),a()}},[]);let C=async(e,t)=>{if((t?F:P).has(e))return;let i=t?f:u,a=t?`tab_order`:`page_order`,c=i.filter(e=>(t?s:r)[e.id]||(t?M.includes(e.id):[`home`,`contact`].includes(e.id))),l=c.some(t=>t.id===e)?c.map(t=>t.id===e?{...t,hidden:!t.hidden}:t):[...c,{id:e,hidden:!0}];await(0,o.setDoc)((0,o.doc)(n.wt,`sys_configs`,a),{order:l})},w=(e,t)=>{e.isSystem||b({info:e,isTab:t})},T=async()=>{if(!y)return;S(!0);let e=y.isTab?`sys_tabs`:`sys_pages`,t=y.isTab?`tab_order`:`page_order`,r=y.isTab?f:u;try{await(0,o.deleteDoc)((0,o.doc)(n.wt,e,y.info.id));let i=r.filter(e=>e.id!==y.info.id);await(0,o.setDoc)((0,o.doc)(n.wt,`sys_configs`,t),{order:i})}catch(e){console.error(`Delete failed`,e)}S(!1),b(null)},E=async(e,t,i)=>{let a=e?f:u,c=e?s:r,l=e?`tab_order`:`page_order`,d=a.filter(t=>c[t.id]||(e?M.includes(t.id):[`home`,`contact`].includes(t.id)));Object.keys(c).forEach(e=>{d.some(t=>t.id===e)||d.push({id:e,hidden:!1})});let p=d.findIndex(e=>e.id===t);if(p===-1)return;let m=+(!e&&d[0]?.id===`home`),h=i===`up`?Math.max(m,p-1):Math.min(d.length-1,p+1);if(p===h)return;let g=[...d],[_]=g.splice(p,1);g.splice(h,0,_),await(0,o.setDoc)((0,o.doc)(n.wt,`sys_configs`,l),{order:g})},D=async()=>{if(!m){h(!0);try{let e=new Set(g.map(e=>e.id)),t=new Set(v.map(e=>e.id)),r=u.filter(t=>!e.has(t.id)),i=f.filter(e=>!t.has(e.id)),a=[...r.map(e=>({...e,hidden:!1})),...g],s=[...i.map(e=>({...e,hidden:!1})),...v],c=(0,o.writeBatch)(n.wt);c.set((0,o.doc)(n.wt,`sys_configs`,`page_order`),{order:a}),c.set((0,o.doc)(n.wt,`sys_configs`,`tab_order`),{order:s}),await c.commit()}finally{setTimeout(()=>h(!1),600)}}},k=e=>{let t=e?f:u,n=e?s:r,i=t.filter(t=>n[t.id]||(e?M.includes(t.id):[`home`,`contact`].includes(t.id))),a=new Set(i.map(e=>e.id)),o=Object.keys(n).filter(e=>!a.has(e)).map(e=>({id:e,hidden:!1})),c=[...i,...o];return e||(c=c.filter(e=>e.id!==`home`)),c};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Settings`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/settings`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(O,{})}),(0,l.jsxs)(`div`,{className:`glass-panel rounded-3xl border border-[var(--panel-border)] shadow-sm grid grid-cols-1 md:grid-cols-3 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`md:col-span-1 border-r md:border-r-[var(--panel-border)] border-b md:border-b-0 border-[var(--panel-border)] flex flex-col bg-black/5 dark:bg-white/5 rounded-t-3xl md:rounded-tr-none md:rounded-l-3xl`,children:[(0,l.jsx)(`div`,{className:`p-6 pb-4 font-bold text-[13px] text-foreground/40 uppercase tracking-widest`,children:`Configuration`}),(0,l.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4 space-y-1`,children:[(0,l.jsxs)(`button`,{onClick:()=>t(`menu`),className:`w-full p-3 rounded-xl transition-all flex items-center gap-3 cursor-pointer ${e===`menu`?`bg-accent/10 text-accent font-bold`:`bg-transparent text-foreground/70 hover:bg-foreground/5 hover:text-foreground font-medium`}`,children:[(0,l.jsx)(n.O,{className:`w-4 h-4 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px]`,children:`Menu Settings`})]}),(0,l.jsxs)(`button`,{onClick:()=>t(`tabs`),className:`w-full p-3 rounded-xl transition-all flex items-center gap-3 cursor-pointer ${e===`tabs`?`bg-accent/10 text-accent font-bold`:`bg-transparent text-foreground/70 hover:bg-foreground/5 hover:text-foreground font-medium`}`,children:[(0,l.jsx)(n.ft,{className:`w-4 h-4 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px]`,children:`Tabs Settings`})]})]})]}),(0,l.jsx)(`div`,{className:`md:col-span-2 flex flex-col p-6 md:p-10`,children:(0,l.jsxs)(`div`,{className:`animate-in fade-in duration-300 w-full`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-8`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`h3`,{className:`text-2xl md:text-3xl font-extrabold text-foreground tracking-tighter mb-2`,children:e===`menu`?`Menu Settings`:`Dashboard Tabs`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 max-w-xl`,children:e===`menu`?`Reorder or hide public menu items. Changes take effect instantly for all visitors.`:`Manage visibility and order of all internal dashboard tabs.`})]}),(0,l.jsx)(`button`,{onClick:D,disabled:m,title:`Reset order and visibility to defaults`,className:`p-3 h-fit bg-foreground/5 hover:bg-foreground/10 text-foreground/70 active:scale-95 disabled:opacity-50 disabled:pointer-events-none rounded-xl transition-all font-bold text-[13px] flex items-center justify-center border border-transparent hover:border-[var(--panel-border)] shadow-sm shrink-0`,children:m?(0,l.jsx)(n.M,{className:`w-5 h-5 text-foreground/50 animate-spin`}):(0,l.jsx)(n.x,{className:`w-5 h-5 text-foreground/50`})})]}),(e=>{let t=e?s:r,i=e?F:P,a=k(e);return(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:a.map((r,o)=>{let s=t[r.id],c=s?.title||N[r.id]||r.id,u=s?.path||`/`+r.id,d=s?.isSystem??M.includes(r.id),f=i.has(r.id),p=o===0,m=o===a.length-1;return(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-4 glass-panel border border-[var(--panel-border)] rounded-2xl transition-all duration-200 ${r.hidden?`opacity-40`:`opacity-100`}`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col items-center w-6`,children:[(0,l.jsx)(`button`,{disabled:p,onClick:()=>E(e,r.id,`up`),className:`text-foreground/40 hover:text-accent disabled:opacity-20`,children:(0,l.jsx)(n.rt,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{disabled:m,onClick:()=>E(e,r.id,`down`),className:`text-foreground/40 hover:text-accent disabled:opacity-20 -mt-1`,children:(0,l.jsx)(n.ot,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-foreground text-[14px]`,children:c}),(0,l.jsx)(`span`,{className:`text-[12px] font-mono text-foreground/50`,children:u})]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[!f&&(0,l.jsx)(`button`,{onClick:()=>C(r.id,e),title:r.hidden?`Show this page`:`Hide this page`,className:`p-2 rounded-xl transition-colors ${r.hidden?`hover:bg-foreground/5 text-foreground/40`:`hover:bg-accent/10 text-accent`}`,children:r.hidden?(0,l.jsx)(n.K,{className:`w-4 h-4`}):(0,l.jsx)(n.G,{className:`w-4 h-4`})}),s&&!d&&(0,l.jsx)(`button`,{onClick:()=>w(s,e),className:`p-2 rounded-xl hover:bg-red-500/10 text-foreground/40 hover:text-red-500 transition-colors`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]})]},r.id)})})})(e===`tabs`)]})})]})]})]}),(0,l.jsx)(ee,{isOpen:!!y,onCancel:()=>b(null),onConfirm:T,title:`Delete Item`,message:`Are you sure you want to delete "${y?.info?.title??``}"? This cannot be undone.`,confirmText:`Delete`,isProcessing:x})]})}function L(){let[e,t]=(0,a.useState)([]),[r,i]=(0,a.useState)(!0),[s,c]=(0,a.useState)(null),[u,d]=(0,a.useState)(!1),[f,p]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.wt,`user_submissions`),(0,o.orderBy)(`submittedAt`,`desc`)),async e=>{let r=[];for(let t of e.docs){let e=t.data(),i=``;if(e.uid&&e.uid!==`guest`)try{let t=await(0,o.getDoc)((0,o.doc)(n.wt,`user_profiles`,e.uid));if(t.exists()){let n=t.data();n.avatar&&(i=n.avatar),n.name&&!e.name&&(e.name=n.name),n.email&&!e.email&&(e.email=n.email)}}catch(e){console.error(`Failed to fetch avatar`,e)}r.push({...e,id:t.id,avatarUrl:i})}t(r),i(!1)},e=>{console.error(`Error fetching submissions:`,e),i(!1)});return()=>e()},[]);let m=e=>{if(!e)return`Just now`;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)},h=e=>{c(t=>t===e?null:e)},g=async(e,t=!1)=>{p(e);try{await(0,o.updateDoc)((0,o.doc)(n.wt,`user_submissions`,e),{isArchived:!t}),!t&&s===e&&c(null)}catch(e){console.error(`Failed to archive/unarchive`,e)}p(null)},_=e.filter(e=>!e.isArchived),v=e.filter(e=>e.isArchived);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Form Submissions`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/submissions`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(O,{})}),(0,l.jsxs)(`div`,{className:`w-full flex-1 flex flex-col glass-panel rounded-3xl p-6 md:p-10 relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/5 blur-[100px] rounded-full pointer-events-none`}),(0,l.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col`,children:r?(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[500px]`,children:(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-10 md:h-10 border-4 border-accent/20 border-t-accent rounded-full animate-spin`})}):e.length===0?(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-8`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent mx-auto mb-6 shadow-inner`,children:(0,l.jsx)(n.D,{className:`w-6 h-6 outline-none`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No Submissions`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 font-medium max-w-md`,children:`Try submitting a form on the public layout to see it appear here.`})]}):(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 pb-8`,children:[_.length===0&&(0,l.jsx)(`div`,{className:`bg-foreground/[0.02] border border-dashed border-[var(--panel-border)] rounded-2xl flex flex-col items-center justify-center p-8 text-center mb-4`,children:(0,l.jsx)(`p`,{className:`text-[14px] font-bold text-foreground/50`,children:`All submissions have been archived.`})}),(0,l.jsx)(n.a,{children:_.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&h(e.id)},onClick:()=>h(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0`,children:(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm`,children:(0,l.jsx)(n.k,{className:`w-4 h-4`})})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 justify-center`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||e.full_name||`Anonymous Submission`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsx)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:e.email||e.contactEmail||`No email provided`})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-4 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:m(e.submittedAt)}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),g(e.id,!1)},disabled:f===e.id,className:`p-1.5 rounded-lg text-foreground/30 hover:text-orange-500 hover:bg-orange-500/10 transition-colors`,title:`Archive Submission`,children:f===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n.gt,{className:`w-4 h-4`})}),(0,l.jsx)(`div`,{className:`p-1.5 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.ot,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:m(e.submittedAt)}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e))]})})})]},e.id)})}),v.length>0&&(0,l.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`flex justify-center`,children:(0,l.jsxs)(`button`,{onClick:()=>d(!u),className:`flex items-center gap-2 text-[11px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors py-2 uppercase tracking-widest outline-none`,children:[u?`Hide`:`View`,` `,v.length,` Archived Submission`,v.length===1?``:`s`,(0,l.jsx)(n.ot,{className:`w-3.5 h-3.5 transition-transform duration-300 ${u?`rotate-180`:``}`})]})}),(0,l.jsx)(n.a,{children:u&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4`,children:(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:v.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden opacity-50 grayscale hover:opacity-100 hover:grayscale-0 hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&h(e.id)},onClick:()=>h(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0 grayscale`,children:(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm`,children:(0,l.jsx)(n.k,{className:`w-4 h-4`})})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 justify-center`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||e.full_name||`Anonymous Submission`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsx)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:e.email||e.contactEmail||`No email provided`})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-6 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:m(e.submittedAt)}),(0,l.jsx)(`div`,{className:`p-2 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.ot,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:m(e.submittedAt)}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`isArchived`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e)),(0,l.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,l.jsxs)(`button`,{onClick:()=>g(e.id,e.isArchived),disabled:f===e.id,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-[13px] font-bold text-foreground/70 hover:text-emerald-500 bg-foreground/5 hover:bg-emerald-500/10 transition-colors border border-transparent shadow-sm`,children:[f===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n._t,{className:`w-4 h-4`}),`Unarchive Submission`]})})]})})})]},e.id)})})})})]})]})})]})]})]})}function R(){let[e,t]=(0,a.useState)([]),[r,i]=(0,a.useState)(!0),[s,c]=(0,a.useState)(null),[d,f]=(0,a.useState)(!1),[p,m]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.wt,`user_requests`),(0,o.orderBy)(`submittedAt`,`desc`)),async e=>{let r=[];for(let t of e.docs){let e=t.data(),i=``;if(e.uid&&e.uid!==`guest`)try{let t=await(0,o.getDoc)((0,o.doc)(n.wt,`user_profiles`,e.uid));if(t.exists()){let n=t.data();(n.avatar||n.photoURL)&&(i=n.avatar||n.photoURL),n.displayName&&!e.name&&(e.name=n.displayName),n.email&&!e.email&&(e.email=n.email),n.email&&!e.contactEmail&&(e.contactEmail=n.email)}}catch(e){console.error(`Failed to fetch avatar`,e)}r.push({...e,id:t.id,avatarUrl:i})}t(r),i(!1)},e=>{console.error(`Error fetching requests:`,e),i(!1)});return()=>e()},[]);let h=e=>{if(!e)return`Just now`;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)},g=e=>{c(t=>t===e?null:e)},_=async(e,t=!1)=>{m(e);try{await(0,o.updateDoc)((0,o.doc)(n.wt,`user_requests`,e),{isArchived:!t}),!t&&s===e&&c(null)}catch(e){console.error(`Failed to archive/unarchive`,e)}m(null)},v=e.filter(e=>!e.isArchived),y=e.filter(e=>e.isArchived);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`User Requests`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/requests`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(O,{})}),(0,l.jsxs)(`div`,{className:`w-full flex-1 flex flex-col glass-panel rounded-3xl p-6 md:p-10 relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/5 blur-[100px] rounded-full pointer-events-none`}),(0,l.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col`,children:r?(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[500px]`,children:(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-10 md:h-10 border-4 border-accent/20 border-t-accent rounded-full animate-spin`})}):e.length===0?(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-8`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent mx-auto mb-6 shadow-inner`,children:(0,l.jsx)(n.et,{className:`w-6 h-6 outline-none`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No User Requests`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 font-medium max-w-md`,children:`User support tickets will appear here once submitted.`})]}):(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 pb-8`,children:[v.length===0&&(0,l.jsx)(`div`,{className:`bg-foreground/[0.02] border border-dashed border-[var(--panel-border)] rounded-2xl flex flex-col items-center justify-center p-8 text-center mb-4`,children:(0,l.jsx)(`p`,{className:`text-[14px] font-bold text-foreground/50`,children:`All requests have been archived.`})}),(0,l.jsx)(n.a,{children:v.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&g(e.id)},onClick:()=>g(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0`,children:e.avatarUrl||e.submitterAvatar?(0,l.jsx)(`img`,{src:e.avatarUrl||e.submitterAvatar,alt:e.submitterName||e.name,className:`w-10 h-10 rounded-full object-cover border border-[var(--panel-border)] shadow-sm`}):(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm uppercase`,children:(e.submitterName||e.name||e.contactEmail||e.email||`U`)[0]})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[e.uid===`guest`?(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||`Anonymous User`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}):(0,l.jsxs)(u.Link,{to:`/users/${e.uid}`,onClick:e=>e.stopPropagation(),className:`w-fit font-bold text-[14px] md:text-[15px] text-foreground truncate hover:text-accent flex items-center gap-2`,children:[e.submitterName||e.name||`Anonymous User`,e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsxs)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:[(0,l.jsx)(n.k,{className:`w-3.5 h-3.5`}),` `,e.contactEmail||e.email||`No email provided`]})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-4 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:h(e.submittedAt)}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),_(e.id,!1)},disabled:p===e.id,className:`p-1.5 rounded-lg text-foreground/30 hover:text-orange-500 hover:bg-orange-500/10 transition-colors`,title:`Archive Request`,children:p===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n.gt,{className:`w-4 h-4`})}),(0,l.jsx)(`div`,{className:`p-1.5 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.ot,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:h(e.submittedAt)}),e.topic&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-[13px] text-foreground/70 bg-foreground/5 px-4 py-2.5 rounded-xl w-fit border border-[var(--panel-border)]`,children:[(0,l.jsx)(n.nt,{className:`w-4 h-4 text-accent`}),(0,l.jsx)(`span`,{className:`font-medium text-accent`,children:`Topic:`}),(0,l.jsx)(`span`,{className:`font-bold`,children:e.topic})]}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`topic`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e))]})})})]},e.id)})}),y.length>0&&(0,l.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`flex justify-center`,children:(0,l.jsxs)(`button`,{onClick:()=>f(!d),className:`flex items-center gap-2 text-[11px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors py-2 uppercase tracking-widest outline-none`,children:[d?`Hide`:`View`,` `,y.length,` Archived Request`,y.length===1?``:`s`,(0,l.jsx)(n.ot,{className:`w-3.5 h-3.5 transition-transform duration-300 ${d?`rotate-180`:``}`})]})}),(0,l.jsx)(n.a,{children:d&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4`,children:(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden opacity-50 grayscale hover:opacity-100 hover:grayscale-0 hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&g(e.id)},onClick:()=>g(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0 grayscale`,children:e.avatarUrl||e.submitterAvatar?(0,l.jsx)(`img`,{src:e.avatarUrl||e.submitterAvatar,alt:e.submitterName||e.name,className:`w-10 h-10 rounded-full object-cover border border-[var(--panel-border)] shadow-sm`}):(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm uppercase`,children:(e.submitterName||e.name||e.contactEmail||e.email||`U`)[0]})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[e.uid===`guest`?(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||`Anonymous User`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}):(0,l.jsxs)(`div`,{className:`w-fit font-bold text-[14px] md:text-[15px] text-foreground truncate flex items-center gap-2`,children:[e.submitterName||e.name||`Anonymous User`,e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsxs)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:[(0,l.jsx)(n.k,{className:`w-3.5 h-3.5`}),` `,e.contactEmail||e.email||`No email provided`]})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-6 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:h(e.submittedAt)}),(0,l.jsx)(`div`,{className:`p-2 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.ot,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:h(e.submittedAt)}),e.topic&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-[13px] text-foreground/70 bg-foreground/5 px-4 py-2.5 rounded-xl w-fit border border-[var(--panel-border)]`,children:[(0,l.jsx)(n.nt,{className:`w-4 h-4 text-accent`}),(0,l.jsx)(`span`,{className:`font-medium text-accent`,children:`Topic:`}),(0,l.jsx)(`span`,{className:`font-bold`,children:e.topic})]}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`topic`,`isArchived`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e)),(0,l.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,l.jsxs)(`button`,{onClick:()=>_(e.id,e.isArchived),disabled:p===e.id,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-[13px] font-bold text-foreground/70 hover:text-emerald-500 bg-foreground/5 hover:bg-emerald-500/10 transition-colors border border-transparent shadow-sm`,children:[p===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n._t,{className:`w-4 h-4`}),`Unarchive Request`]})})]})})})]},e.id)})})})})]})]})})]})]})]})}function z(){let{user:e,userRole:t}=m(),[r,i]=(0,a.useState)([]),[s,f]=(0,a.useState)(!1),p=(0,u.useNavigate)(),{"*":h}=(0,u.useParams)(),g=h?h.split(`/`).filter(Boolean):[],_=g[0]||`private`,v=null,y=null;_===`users`?(v=g[1]||null,y=g[2]||null):y=g[1]||null;let b={public:`pub_`,shared:`mem_`,private:`user_`,admin:`admin_`,users:`users_`},x={pub_:`public`,mem_:`shared`,user_:`private`,admin_:`admin`,users_:`users`},S=b[_]||`user_`,C=e=>{p(`/drive/${x[e]}`)},[w,T]=(0,a.useState)([]);(0,a.useEffect)(()=>{S===`users_`&&t===`admin`&&w.length===0&&(0,o.getDocs)((0,o.collection)(n.wt,`user_profiles`)).then(e=>{T(e.docs.map(e=>({id:e.id,...e.data()})))})},[S,t,w.length]);let[E,D]=(0,a.useState)(!1),[k,A]=(0,a.useState)(null),[j,M]=(0,a.useState)(``),[N,P]=(0,a.useState)(`user_`),[F,I]=(0,a.useState)(!1),[L,R]=(0,a.useState)(!1),[z,B]=(0,a.useState)(!1),V=(0,a.useRef)(null),te=e=>{e.preventDefault(),e.stopPropagation(),B(!0)},ne=e=>{e.preventDefault(),e.stopPropagation(),B(!1)},re=e=>{if(e.preventDefault(),e.stopPropagation(),B(!1),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];A(t),M(t.name),P(S),I(!0)}},H=y&&r.find(e=>e._id===y)||null,U=e=>{le(!0),p(e?S===`users_`&&v?`/drive/users/${v}/${e._id}`:`/drive/${x[S]}/${e._id}`:S===`users_`&&v?`/drive/users/${v}`:`/drive/${x[S]}`)},[W,G]=(0,a.useState)(null),[ie,K]=(0,a.useState)(!1),[q,J]=(0,a.useState)(null),[Y,ae]=(0,a.useState)(!1),[oe,se]=(0,a.useState)(null),[ce,le]=(0,a.useState)(!0),[ue,de]=(0,a.useState)({}),[fe,X]=(0,a.useState)(!1);(0,a.useEffect)(()=>(H||q||W||F||fe?document.body.style.overflow=`hidden`:document.body.style.overflow=``,()=>{document.body.style.overflow=``}),[H,q,W,F,fe]),(0,a.useEffect)(()=>{if(!s&&y&&!r.some(e=>e._id===y)){X(!0);let e=setTimeout(()=>{X(!1),p(S===`users_`&&v?`/drive/users/${v}`:`/drive/${x[S]}`)},2500);return()=>clearTimeout(e)}else X(!1)},[s,y,r,S,p,v]),(0,a.useEffect)(()=>{if(!e)return;f(!0);let r=(t===`admin`?[`pub_`,`mem_`,`user_`,`admin_`]:[`pub_`,`mem_`,`user_`]).map(r=>{let a;return a=r===`user_`&&t!==`admin`?(0,o.query)((0,o.collection)(n.wt,`${r}files`),(0,o.where)(`uid`,`==`,e.uid)):(0,o.query)((0,o.collection)(n.wt,`${r}files`),(0,o.orderBy)(`createdAt`,`desc`)),(0,o.onSnapshot)(a,e=>{let t=(e.docs||[]).map(e=>({_id:e.id,accessPrefix:r,...e.data()}));i(e=>[...e.filter(e=>e.accessPrefix!==r),...t].sort((e,t)=>{let n=e.createdAt?.toMillis?e.createdAt.toMillis():0;return(t.createdAt?.toMillis?t.createdAt.toMillis():0)-n})),f(!1)},e=>{console.warn(`Error listening to ${r}files:`,e)})});return()=>r.forEach(e=>e())},[e?.uid,t]);let pe=e=>{if(e.target.files&&e.target.files[0]){let t=e.target.files[0];A(t),M(t.name)}},me=e=>{if(e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];A(t),M(t.name)}},Z=async r=>{if(r.preventDefault(),!(!k||!j)){D(!0);try{let r=(0,c.ref)(n.Et,`${N}files/${`${Date.now()}_${k.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`);await(0,c.uploadBytes)(r,k,{customMetadata:{ownerId:e.uid}});let i=await(0,c.getDownloadURL)(r);await(0,o.addDoc)((0,o.collection)(n.wt,`${N}files`),{fileName:j,fileType:k.type||`unknown`,fileSize:k.size,downloadURL:i,uid:e.uid,uploaderEmail:e.email||`user`,uploaderRole:t||`user`,createdAt:(0,o.serverTimestamp)()}),I(!1),A(null),M(``),C(N)}catch(e){console.error(e),alert(`Upload failed: ${e.message}`)}D(!1)}},he=async()=>{if(q){ae(!0);try{try{await(0,c.deleteObject)((0,c.ref)(n.Et,q.url))}catch(e){console.warn(`Storage item missing:`,e)}await(0,o.deleteDoc)((0,o.doc)(n.wt,`${q.prefix}files`,q.id)),i(e=>e.filter(e=>e._id!==q.id)),J(null)}catch(e){alert(e.message)}ae(!1)}},ge=async()=>{if(!W||!W.name.trim()){G(null);return}let e=r.find(e=>e._id===W.id);if(e&&e.fileName===W.name.trim()){G(null);return}K(!0);try{await(0,o.updateDoc)((0,o.doc)(n.wt,`${W.prefix}files`,W.id),{fileName:W.name.trim()}),i(e=>e.map(e=>e._id===W.id?{...e,fileName:W.name.trim()}:e)),G(null)}catch(e){console.error(`Rename failed:`,e)}K(!1)},_e=(e,t)=>{navigator.clipboard.writeText(e),se(t),setTimeout(()=>se(null),2e3)},ve=e=>{if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},Q=n=>e?n.accessPrefix===`mem_`?n.uid===e.uid?!0:t===`admin`?n.uploaderRole!==`admin`:!1:n.accessPrefix===`admin_`?n.uid===e.uid:n.accessPrefix===`pub_`?t===`admin`:n.uid===e.uid||t===`admin`:!1,ye=(e,t,r=!1)=>{let i=r?`w-16 h-16`:`w-10 h-10`,a=r?`w-8 h-8`:`w-5 h-5`;return e.startsWith(`image/`)?r?(0,l.jsx)(`img`,{src:t,alt:`preview`,className:`w-full h-full object-contain rounded-lg`}):(0,l.jsx)(`div`,{className:`${i} bg-cover bg-center rounded-lg`,style:{backgroundImage:`url(${t})`}}):e.includes(`video`)||e.includes(`audio`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-purple-500/10 text-purple-500 rounded-lg`,children:(0,l.jsx)(n.l,{className:a})}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-blue-500/10 text-blue-500 rounded-lg`,children:(0,l.jsx)(n.W,{className:a})}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-yellow-500/10 text-yellow-500 rounded-lg`,children:(0,l.jsx)(n.gt,{className:a})}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-emerald-500/10 text-emerald-500 rounded-lg`,children:(0,l.jsx)(n.Z,{className:a})}):(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-foreground/5 text-foreground/40 rounded-lg`,children:(0,l.jsx)(n.U,{className:a})})},be=[{id:`user_`,label:`Private`,icon:n.j,description:`This is a private folder availbale to all users in your app. Each user can see their own files. Admins can see all everyone's files here.`},{id:`mem_`,label:`Shared`,icon:n.u,description:`This is a shared folder that all signed-in users can see. Every user can upload files here and view other member's files. However, editing and deletion are strictly restricted to the original creator of the file.`},{id:`pub_`,label:`Public`,icon:n.H,description:`This admin-only folder is for assets like logos, banners, or favicons. Files here are view-only for everyone; only admins can upload or delete them.`},{id:`admin_`,label:`Admin Shared`,icon:n.v,description:`This is a shared folder for app administrators. Admins can view everything here, but they can only edit or delete files that they themselves uploaded.`},{id:`users_`,label:`User Uploads`,icon:n.Y,description:`View all underlying private user uploads securely. Select a user to explore their files.`}].filter(e=>t===`admin`?!0:e.id===`user_`||e.id===`mem_`),xe=[];xe=S===`users_`?r.filter(e=>e.accessPrefix===`user_`&&e.uid===v):S===`user_`?r.filter(t=>t.accessPrefix===`user_`&&t.uid===e?.uid):r.filter(e=>e.accessPrefix===S);let Se=be.find(e=>e.id===S);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 flex flex-col pt-12 min-h-screen relative overflow-visible`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Drive`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/drive`]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,onDragOver:te,onDragLeave:ne,onDrop:re,children:[(0,l.jsx)(O,{}),(0,l.jsxs)(`div`,{className:`flex flex-row glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl min-h-[600px] bg-background`,children:[(0,l.jsxs)(`div`,{className:`w-[280px] border-r border-[var(--panel-border)] bg-foreground/[0.01] p-4 flex flex-col shrink-0 overflow-y-auto hide-scrollbar`,children:[(0,l.jsx)(`div`,{className:`text-[11px] font-extrabold text-foreground/40 uppercase tracking-widest pl-4 mb-4 mt-2`,children:`Locations`}),(0,l.jsx)(`div`,{className:`flex flex-col gap-2`,children:be.map(e=>(0,l.jsxs)(`button`,{onClick:()=>C(e.id),className:`w-full flex items-center gap-3 px-4 py-3.5 rounded-2xl transition-all font-bold text-[14px] text-left ${S===e.id?`bg-accent/15 text-accent shadow-sm border border-accent/20`:`text-foreground/70 hover:bg-foreground/5 hover:text-foreground border border-transparent`}`,children:[(0,l.jsx)(e.icon,{className:`w-5 h-5 ${S===e.id?`text-accent`:`text-foreground/40`}`}),e.label]},e.id))})]}),(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col relative w-full h-full min-w-0`,children:[(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex items-start justify-between gap-6 shrink-0 border-b border-[var(--panel-border)]/50 bg-background/50`,children:[(0,l.jsxs)(`div`,{className:`flex-1 max-w-xl`,children:[(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground tracking-tight flex items-center gap-3`,children:Se?.label}),(0,l.jsx)(`p`,{className:`text-[13px] mt-3 text-foreground/60 leading-relaxed font-medium`,children:Se?.description})]}),S!==`users_`&&(0,l.jsxs)(n.n,{onClick:()=>{P(S),I(!0)},className:`flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-bold shadow-md hover:shadow-lg transition-all glow-hover border-transparent !border-0 outline-none ring-0`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Add File Here`]})]}),(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[300px]`,children:[s&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm rounded-b-[2rem]`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),S===`users_`&&!v?(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 pb-20`,children:[w.map(e=>(0,l.jsxs)(`div`,{onClick:()=>p(`/drive/users/${e.id}`),className:`flex items-center gap-4 bg-background border border-[var(--panel-border)] p-5 rounded-2xl cursor-pointer hover:border-accent/50 hover:shadow-md transition-all group`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-foreground/5 flex items-center justify-center shrink-0 border border-[var(--panel-border)]`,children:e.photoURL?(0,l.jsx)(`img`,{src:e.photoURL,alt:`avatar`,className:`w-full h-full rounded-full object-cover`}):(0,l.jsx)(n.d,{className:`w-5 h-5 text-foreground/40`})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,l.jsxs)(`span`,{className:`font-bold text-foreground truncate group-hover:text-accent transition-colors text-[14px]`,children:[e.firstName,` `,e.lastName]}),(0,l.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/50 truncate mt-0.5`,children:e.email})]})]},e.id)),w.length===0&&(0,l.jsxs)(`div`,{className:`col-span-full py-12 flex flex-col items-center justify-center text-center`,children:[(0,l.jsx)(n.d,{className:`w-12 h-12 text-foreground/10 mb-4`}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold text-foreground/50`,children:`No users found`})]})]}):xe.length>0?(0,l.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 pb-20`,children:xe.map(e=>(0,l.jsxs)(`div`,{className:`flex flex-col bg-background border border-[var(--panel-border)] rounded-2xl hover:border-accent/40 transition-all group overflow-hidden shadow-sm hover:shadow-md h-[190px] relative`,children:[(0,l.jsxs)(`div`,{className:`absolute top-2 right-2 flex flex-col gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10 bg-background/90 backdrop-blur-md rounded-lg p-1 border border-[var(--panel-border)] shadow-xl`,children:[(0,l.jsx)(`a`,{href:e.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-blue-500 transition-colors`,title:`Download`,children:(0,l.jsx)(n.J,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),_e(e.accessPrefix===`pub_`?e.downloadURL:`${window.location.origin}/drive/${x[e.accessPrefix]}/${e._id}`,e._id)},className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-emerald-500 transition-colors`,title:`Copy Link`,children:oe===e._id?(0,l.jsx)(n.st,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),Q(e)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),G({id:e._id,name:e.fileName,prefix:e.accessPrefix})},className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-purple-500 transition-colors`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),J({id:e._id,url:e.downloadURL,name:e.fileName,prefix:e.accessPrefix})},className:`p-1.5 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`h-[120px] w-full border-b border-[var(--panel-border)]/50 bg-foreground/[0.02] flex items-center justify-center overflow-hidden relative cursor-pointer rounded-t-[calc(1rem-1px)]`,onClick:()=>U(e),children:e.fileType.startsWith(`image/`)?(0,l.jsxs)(l.Fragment,{children:[ue[e._id]!==!1&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-0`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})}),(0,l.jsx)(`img`,{src:e.downloadURL,alt:``,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-300 group-hover:scale-105 ${ue[e._id]===!1?`opacity-100`:`opacity-0`}`,onLoad:()=>de(t=>({...t,[e._id]:!1})),onError:()=>de(t=>({...t,[e._id]:!1}))})]}):ye(e.fileType,e.downloadURL,!0)}),(0,l.jsxs)(`div`,{className:`p-3 flex flex-col justify-center flex-1 min-w-0`,onClick:()=>!W&&U(e),children:[W?.id===e._id?(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:W.name,onChange:e=>G({...W,name:e.target.value}),onBlur:()=>ge(),onKeyDown:e=>{e.key===`Enter`&&ge(),e.key===`Escape`&&G(null)},onClick:e=>e.stopPropagation(),className:`text-[12.5px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full`}):(0,l.jsx)(`span`,{className:`text-[12.5px] font-bold text-foreground truncate select-none group-hover:text-accent transition-colors`,title:e.fileName,children:e.fileName}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/40 font-bold uppercase tracking-wider mt-1 select-none`,children:ve(e.fileSize)})]})]},e._id))}):!s&&(0,l.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{if(e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];A(t),M(t.name),P(S),I(!0)}},onClick:()=>{P(S),I(!0)},className:`absolute inset-0 m-6 flex flex-col items-center justify-center text-foreground/40 transition-colors cursor-pointer group`,children:[(0,l.jsx)(`p`,{className:`text-[20px] font-bold text-foreground/50 group-hover:text-foreground/70 transition-colors`,children:`Folder is empty`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium mt-1 text-foreground/40 group-hover:text-foreground/60 transition-colors`,children:`Click here or drag and drop a file to upload`})]})]})]})]})]}),(0,l.jsx)(n.a,{children:F&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!E&&I(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[480px] border-[var(--panel-border)] border rounded-3xl relative z-10 glass-panel shadow-2xl flex flex-col bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-[var(--panel-border)]/50 relative z-20`,children:[(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsxs)(`button`,{onClick:()=>R(!L),className:`flex items-center gap-2 group outline-none`,children:[(0,l.jsx)(`span`,{className:`text-[16px] font-extrabold text-foreground tracking-tight`,children:`Upload to`}),(0,l.jsx)(`span`,{className:`bg-accent/10 group-hover:bg-accent/20 text-accent px-2 py-1 rounded-md text-[13px] font-bold transition-colors flex items-center gap-1 shadow-sm`,children:be.find(e=>e.id===N)?.label})]}),(0,l.jsx)(n.a,{children:L&&(0,l.jsxs)(a.default.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-[90]`,onClick:()=>R(!1)}),(0,l.jsx)(n.i.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:`absolute top-full left-0 mt-3 w-48 bg-background border border-[var(--panel-border)] rounded-xl shadow-2xl py-1 overflow-hidden z-[100]`,children:be.map(e=>(0,l.jsxs)(`button`,{type:`button`,onClick:()=>{P(e.id),R(!1)},className:`w-full text-left px-4 py-3 hover:bg-foreground/5 text-[13px] font-bold text-foreground flex items-center gap-3 transition-colors outline-none`,children:[(0,l.jsx)(e.icon,{className:`w-4 h-4 text-foreground/50`}),e.label]},e.id))})]})})]}),(0,l.jsx)(`button`,{onClick:()=>!E&&I(!1),className:`text-foreground/40 hover:text-foreground transition-colors`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})})]}),k?(0,l.jsxs)(`form`,{onSubmit:Z,className:`p-6 flex flex-col gap-6 relative z-10 rounded-b-[2rem]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 bg-foreground/[0.03] p-4 rounded-2xl border border-[var(--panel-border)] shadow-sm`,children:[ye(k.type,URL.createObjectURL(k)),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-[13px] font-bold text-foreground truncate`,children:k.name}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold uppercase tracking-wider mt-1`,children:ve(k.size)})]}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>!E&&A(null),className:`w-8 h-8 flex items-center justify-center text-foreground/40 hover:text-red-500 rounded-xl hover:bg-red-500/10 transition-colors shrink-0`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,l.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest pl-1`,children:`Edit File Name`}),(0,l.jsx)(`input`,{type:`text`,required:!0,value:j,onChange:e=>M(e.target.value),disabled:E,className:`w-full bg-foreground/[0.02] border border-[var(--panel-border)] rounded-xl px-4 py-3.5 text-[14px] font-bold text-foreground outline-none focus:border-accent transition-colors shadow-sm`})]}),(0,l.jsx)(`div`,{className:`flex justify-end pt-4 mt-2 border-t border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:E,className:`w-full py-4 rounded-xl text-[14px] font-bold shadow-lg`,children:E?`Uploading to Drive...`:`Save to ${be.find(e=>e.id===N)?.label}`})})]}):(0,l.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:me,className:`p-12 flex flex-col items-center justify-center rounded-b-[2rem]`,children:[(0,l.jsx)(`div`,{className:`w-20 h-20 rounded-full bg-foreground/5 flex items-center justify-center mb-5 border-2 border-dashed border-[var(--panel-border)]`,children:(0,l.jsx)(n.Q,{className:`w-8 h-8 text-foreground/40`})}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold text-foreground mb-1`,children:`Drag and drop file here`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium mb-8`,children:`or click to browse local files`}),(0,l.jsx)(`input`,{type:`file`,ref:V,onChange:pe,className:`hidden`}),(0,l.jsx)(n.n,{onClick:()=>V.current?.click(),className:`px-8 py-3 rounded-full font-bold shadow-md btn-primary transition-colors`,children:`Browse Files`})]})]})]})}),typeof window<`u`&&(0,d.createPortal)((0,l.jsx)(n.a,{children:H&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,l.jsx)(n.i.div,{onClick:()=>U(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(`button`,{onClick:()=>U(null),className:`absolute top-6 right-6 z-[160] w-12 h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0 shadow-sm z-20`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:H.fileName}),(0,l.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[H.fileType,` • `,ve(H.fileSize),H.accessPrefix===`mem_`&&(H.uploaderEmail||H.uid)&&` • From: ${H.uploaderEmail||H.uid}`]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:()=>_e(H.accessPrefix===`pub_`?H.downloadURL:`${window.location.origin}/drive/${x[H.accessPrefix]}/${H._id}`,H._id),className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500`,title:`Copy Link`,children:oe===H._id?(0,l.jsx)(n.st,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),Q(H)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:()=>{U(null),G({id:H._id,name:H.fileName,prefix:H.accessPrefix})},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-purple-500 transition-colors rounded-xl shadow-sm`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{U(null),J({id:H._id,url:H.downloadURL,name:H.fileName,prefix:H.accessPrefix})},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]}),(0,l.jsx)(`a`,{href:H.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-1`,title:`Download`,children:(0,l.jsx)(n.J,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>U(null),children:(0,l.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[ce&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none fade-in`,children:(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-background/80 backdrop-blur-md shadow-xl flex items-center justify-center border border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})})}),H.fileType.startsWith(`image/`)?(0,l.jsx)(`img`,{onLoad:()=>le(!1),src:H.downloadURL,alt:H.fileName,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full object-contain drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] rounded-lg pointer-events-auto transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):H.fileType.startsWith(`video/`)?(0,l.jsx)(`video`,{onLoadedData:()=>le(!1),src:H.downloadURL,controls:!0,autoPlay:!0,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full outline-none bg-black/40 rounded-lg pointer-events-auto drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):H.fileType===`application/pdf`?(0,l.jsx)(`iframe`,{onLoad:()=>le(!1),src:H.downloadURL,className:`w-full h-full border-none bg-white rounded-lg relative z-10 transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,title:`PDF Preview`}):(0,l.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center text-foreground/40 text-center relative z-10`,onClick:e=>{e.stopPropagation(),le(!1)},children:[(0,l.jsx)(n.U,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,l.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,l.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This file format cannot be previewed. Please download it instead.`})]})]})})]})]})}),document.body),(0,l.jsx)(n.a,{children:fe&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/90 backdrop-blur-xl`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:`relative z-10 w-full max-w-sm flex flex-col items-center pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-red-500/20 bg-background/80 p-8 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-6`,children:(0,l.jsx)(n.c,{className:`w-8 h-8 text-red-500`})}),(0,l.jsx)(`h3`,{className:`text-xl font-bold text-foreground mb-2`,children:`Access Denied`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 font-medium leading-relaxed`,children:`You don't have access to this file, or it may have been deleted.`}),(0,l.jsx)(`div`,{className:`w-5 h-5 border-2 border-accent/20 border-t-accent rounded-full animate-spin mt-6`})]})]})}),(0,l.jsx)(ee,{isOpen:!!q,title:`Confirm Deletion`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you entirely sure you wish to delete `,(0,l.jsx)(`strong`,{className:`text-foreground truncate block my-0.5`,children:q?.name}),` This action is permanent.`]}),onConfirm:he,onCancel:()=>J(null),isProcessing:Y,confirmText:`Yes, Delete`}),(0,l.jsx)(n.a,{children:z&&(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`fixed inset-0 z-[1000] bg-background/60 backdrop-blur-md pointer-events-none flex items-center justify-center p-6`,children:(0,l.jsxs)(n.i.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:`w-full max-w-lg aspect-video bg-background/80 border-2 border-dashed border-accent p-12 rounded-[40px] shadow-2xl flex flex-col items-center justify-center gap-6 relative`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-accent/5 rounded-[38px] animate-pulse`}),(0,l.jsx)(`div`,{className:`w-20 h-20 rounded-full bg-accent/10 flex items-center justify-center text-accent shadow-[0_0_40px_rgba(var(--accent-rgb),0.2)]`,children:(0,l.jsx)(n.Q,{className:`w-10 h-10 animate-bounce`})}),(0,l.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-2 relative z-10`,children:[(0,l.jsx)(`span`,{className:`text-[24px] font-extrabold text-foreground tracking-tight`,children:`Drop files to upload`}),(0,l.jsx)(`span`,{className:`text-[14px] font-medium text-foreground/50`,children:`Your files will be staged for review`})]})]})})})]})}function B(){let e=[{id:`form`,title:`Inline Form`,description:`A static, embedded contact form designed directly into the page layout.`,icon:n.P,path:`/templates/inline_form`},{id:`popup`,title:`Modal Popup Form`,description:`A centralized popup contact form that visually blurs the background context.`,icon:n.vt,path:`/templates/popup_form`},{id:`confirmation`,title:`Action Confirmation`,description:`A classic confirmation dialog styled for decisive user actions.`,icon:n.ct,path:`/templates/confirmation`},{id:`board`,title:`Board View`,description:`A modern, drag-and-drop styled Kanban board aesthetic for task management.`,icon:n.z,path:`/templates/board`},{id:`table`,title:`Data Table`,description:`A clean, column-based data table optimized for large datasets and bulk actions.`,icon:n.g,path:`/templates/table`},{id:`calendar`,title:`Calendar View`,description:`A structured monthly calendar grid for scheduling and date-based resource planning.`,icon:n.ut,path:`/templates/calendar`}];return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-10 text-center`,children:[(0,l.jsx)(`h1`,{className:`w-fit mx-auto inline-block text-4xl md:text-5xl lg:text-[4.8rem] leading-[1.1] font-extrabold tracking-tight mb-4 text-gradient animate-float`,children:`Premium Templates`}),(0,l.jsx)(`p`,{className:`text-foreground/60 text-lg font-medium max-w-2xl mx-auto`,children:`Explore our collection of fully functional, beautifully designed boilerplate components.`})]}),(0,l.jsxs)(`div`,{className:`w-full max-w-4xl mx-auto flex flex-col gap-4 relative`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[80%] h-[80%] bg-accent/5 blur-[120px] rounded-full pointer-events-none -z-10`}),e.map((e,t)=>{let r=e.icon;return(0,l.jsx)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},children:(0,l.jsxs)(u.Link,{to:e.path,className:`flex items-center gap-6 w-full p-4 md:px-6 glass-panel border border-[var(--panel-border)] rounded-2xl hover:border-accent/40 transition-all duration-300 group hover:bg-foreground/[0.02]`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-accent/10 flex items-center justify-center text-accent shrink-0 border border-accent/20 group-hover:scale-105 transition-transform`,children:(0,l.jsx)(r,{className:`w-5 h-5`})}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,l.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground truncate`,children:e.title}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 truncate font-medium`,children:e.description})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-2 text-[13px] font-bold px-5 py-2.5 rounded-xl btn-primary shrink-0 transition-transform shadow-lg group-hover:-translate-y-0.5`,children:[`View `,(0,l.jsx)(`span`,{className:`font-black leading-none ml-0.5`,children:`→`})]})]})},e.id)})]})]})}function V(){let[e,t]=(0,a.useState)({favoriteService:``,satisfactionRating:``,detailedThoughts:``}),[r,i]=(0,a.useState)(`idle`);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12`,children:[(0,l.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mb-6`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,l.jsx)(n.ht,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,l.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mt-6`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-auto`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`relative z-10 w-full`,children:r===`success`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-green-500/10 border border-green-500/20 flex items-center justify-center text-green-500 mb-4`,children:(0,l.jsx)(n.tt,{className:`w-8 h-8`})}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed`,children:`Your test data was sent successfully. Log in as an admin and check the Submissions tab!`})]}):r===`loading`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Inline Form Template`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide leading-relaxed`,children:`Try interacting with this simulated inline template block.`})]}),(0,l.jsxs)(`form`,{onSubmit:async r=>{r.preventDefault(),i(`loading`);try{let r=n.Ct.currentUser?.uid||`guest`;await(0,o.addDoc)((0,o.collection)(n.wt,`user_submissions`),{uid:r,...e,type:`template_simulation`,submittedAt:(0,o.serverTimestamp)()}),i(`success`),setTimeout(()=>{i(`idle`),t({favoriteService:``,satisfactionRating:``,detailedThoughts:``})},3e3)}catch{i(`error`)}},className:`space-y-4 w-full`,children:[(0,l.jsx)(n.r,{label:`Favorite Service`,placeholder:`e.g. Design Consulting`,value:e.favoriteService,onChange:n=>t({...e,favoriteService:n.target.value})}),(0,l.jsx)(n.r,{label:`Satisfaction Rating`,type:`number`,placeholder:`1 to 10`,value:e.satisfactionRating,onChange:n=>t({...e,satisfactionRating:n.target.value})}),(0,l.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Detailed Thoughts`}),(0,l.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:e.detailedThoughts,onChange:n=>t({...e,detailedThoughts:n.target.value}),className:`flex w-full rounded-xl text-[15px] text-foreground px-4 py-3 transition-all duration-300 placeholder:text-foreground/40 focus:outline-none focus:border-accent glow-focus disabled:cursor-not-allowed disabled:opacity-50 glass-panel min-h-[100px] resize-none`})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`,isLoading:!1,children:`Trigger Simulation`})})]})]})})]})})]})}function te(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)({concept:``,featureRequest:``,notes:``}),[s,c]=(0,a.useState)(`idle`);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Popup Form`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/popup_form`]})]}),(0,l.jsx)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`px-5 py-2 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2 text-foreground/70`,children:[(0,l.jsx)(n.ht,{className:`w-4 h-4`}),` Go Back`]})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden shadow-2xl relative flex flex-col w-full min-h-[150px] p-6 lg:p-10`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-accent/5 blur-[120px] rounded-full pointer-events-none -z-10`}),(0,l.jsx)(`div`,{className:`flex h-full w-full justify-end items-start relative z-10`,children:(0,l.jsxs)(n.n,{onClick:()=>t(!0),className:`px-6 py-2.5 text-[14px] font-bold rounded-xl shadow-lg flex items-center justify-center gap-2 btn-primary transition-all hover:-translate-y-1`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Open Form`]})})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl cursor-pointer`,onClick:()=>t(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-4 max-h-[95vh] overflow-y-auto no-scrollbar`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`relative z-10 w-full`,children:[(0,l.jsx)(`button`,{onClick:()=>t(!1),className:`absolute -top-2 -right-2 w-8 h-8 flex items-center justify-center rounded-full hover:bg-foreground/5 text-foreground/60 hover:text-foreground transition-colors z-20`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),s===`success`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-green-500/10 border border-green-500/20 flex items-center justify-center text-green-500 mb-4`,children:(0,l.jsx)(n.tt,{className:`w-8 h-8`})}),(0,l.jsx)(`h4`,{className:`text-xl font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed max-w-[280px]`,children:`Your test data was sent successfully. Log in as an admin and check the Submissions tab!`})]}):s===`loading`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Popup Template`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide leading-relaxed`,children:`Fill out the simulated fields below to test the interaction.`})]}),(0,l.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),c(`loading`);try{let e=n.Ct.currentUser?.uid||`guest`;await(0,o.addDoc)((0,o.collection)(n.wt,`user_submissions`),{uid:e,...r,type:`template_simulation`,submittedAt:(0,o.serverTimestamp)()}),c(`success`),setTimeout(()=>{c(`idle`),i({concept:``,featureRequest:``,notes:``}),t(!1)},3e3)}catch{c(`error`)}},className:`space-y-4 w-full`,children:[(0,l.jsx)(n.r,{label:`Concept Name`,placeholder:`e.g. Project Apollo`,value:r.concept,onChange:e=>i({...r,concept:e.target.value})}),(0,l.jsx)(n.r,{label:`Feature Request`,placeholder:`e.g. Real-time sync`,value:r.featureRequest,onChange:e=>i({...r,featureRequest:e.target.value})}),(0,l.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Simulated Notes`}),(0,l.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:r.notes,onChange:e=>i({...r,notes:e.target.value}),className:`flex w-full rounded-xl text-[15px] text-foreground px-4 py-3 transition-all duration-300 placeholder:text-foreground/40 focus:outline-none focus:border-accent glow-focus disabled:cursor-not-allowed disabled:opacity-50 glass-panel min-h-[100px] resize-none`})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`,isLoading:!1,children:`Trigger Simulation`})})]})]})]})]})]})})]})}function ne(){let[e,t]=(0,a.useState)(void 0);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 items-center`,children:[(0,l.jsx)(`div`,{className:`w-full max-w-5xl mb-8`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,l.jsx)(n.ht,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,l.jsxs)(`div`,{className:`w-full max-w-5xl mx-auto mt-2 glass-panel rounded-3xl border border-[var(--panel-border)] p-6 md:p-10 relative overflow-hidden shadow-2xl`,children:[(0,l.jsx)(`div`,{className:`flex items-center justify-between mb-8 pb-6 border-b border-[var(--panel-border)]/50`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h3`,{className:`text-2xl font-extrabold text-foreground tracking-tight`,children:`System Files`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 mt-1`,children:`Review and manage core application assets.`})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,l.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/50 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 w-full sm:w-auto`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-red-500/10 flex items-center justify-center text-red-500 shrink-0`,children:(0,l.jsx)(n.p,{className:`w-5 h-5`})}),(0,l.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,l.jsx)(`h4`,{className:`font-bold text-[14px] sm:text-[15px] text-foreground truncate`,children:`Critical Configuration File`}),(0,l.jsx)(`p`,{className:`text-[12px] sm:text-[13px] text-foreground/50 font-medium mt-0.5 truncate`,children:`Size: 4.2 MB • Modified 2 hours ago`})]})]}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(null),className:`w-full sm:w-auto shrink-0 flex items-center justify-center px-6 py-3 sm:py-2.5 text-[13px] font-bold rounded-xl text-red-500 hover:bg-red-500/10 hover:border-red-500/20 bg-red-500/5 sm:bg-transparent`,children:`Delete File`})]}),(0,l.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 opacity-50 pointer-events-none mt-2`,children:[1,2].map(e=>(0,l.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/20 flex items-center gap-4`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-foreground/5 shrink-0`}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 flex-1`,children:[(0,l.jsx)(`div`,{className:`w-32 h-3 rounded-full bg-foreground/10`}),(0,l.jsx)(`div`,{className:`w-20 h-2 rounded-full bg-foreground/5`})]})]},e))})]})]}),(0,l.jsx)(n.a,{children:e!==void 0&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[400px] p-6 rounded-3xl glass-panel border border-[var(--panel-border)] shadow-2xl relative z-10 text-center`,children:(0,l.jsx)(n.a,{mode:`wait`,children:e===null?(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center`,children:[(0,l.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Confirm Deletion`}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 leading-relaxed mb-6`,children:`Are you entirely sure you wish to delete this configuration? This action is permanent.`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(!1),className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:`Cancel`}),(0,l.jsx)(n.n,{onClick:()=>t(!0),className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl bg-red-500 hover:bg-red-600 border-none text-white shadow-xl hover:shadow-red-500/20 glow-hover`,children:`Yes, Delete`})]})]},`confirm`):e===!0?(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,l.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-green-500 tracking-tight flex items-center gap-2`,children:[(0,l.jsx)(n.st,{className:`w-5 h-5`}),` Verified`]}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Action successfully executed.`}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`success`):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,l.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-foreground/80 tracking-tight flex items-center gap-2`,children:[(0,l.jsx)(n.c,{className:`w-5 h-5`}),` Aborted`]}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Cancellation securely caught.`}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`error`)})})]})})]})}var re=(e,t=[])=>{let n=(e.pageName||e.pageId||`custom_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=`${n.charAt(0).toUpperCase()}${n.slice(1)}Content`;return`I need your help building the inner content for a newly created Public Page. This page is powered by the \`PublicPageTemplate\` (located at \`src/templates/PublicPageTemplate.tsx\`).
2
2
 
3
3
  The page "infrastructure" (routing, header, public accessibility) is already set up and working. Your goal is to design the "Landing Content" that lives inside this page.
4
4
 
@@ -1701,10 +1701,12 @@ function Ut({ customTabs: e = [] }) {
1701
1701
  c.forEach((r) => {
1702
1702
  r.hidden || e[r.id] && (t.push(e[r.id]), n.add(r.id));
1703
1703
  });
1704
- let r = [];
1705
- return Object.keys(o).forEach((t) => {
1706
- !n.has(t) && !c.some((e) => e.id === t) && e[t] && r.push(e[t]);
1707
- }), r.length > 0 && t.push(...r), t;
1704
+ let r = [], i = [];
1705
+ return Object.keys(e).forEach((t) => {
1706
+ if (n.has(t)) return;
1707
+ let a = c.find((e) => e.id === t);
1708
+ a?.hidden || (t in o && !a ? r.push(e[t]) : i.push(e[t]));
1709
+ }), r.length > 0 && t.unshift(...r), i.length > 0 && t.push(...i), t;
1708
1710
  })(), ...e.map((e) => ({
1709
1711
  ...e,
1710
1712
  id: e.path
@@ -1713,7 +1715,9 @@ function Ut({ customTabs: e = [] }) {
1713
1715
  let e = () => {
1714
1716
  let e = d.current, t = f.current;
1715
1717
  if (!e || !t) return;
1716
- let n = e.clientWidth, r = t.querySelectorAll("[data-measure-tab]");
1718
+ let n = e.clientWidth;
1719
+ if (n === 0) return;
1720
+ let r = t.querySelectorAll("[data-measure-tab]");
1717
1721
  if (r.length === 0) {
1718
1722
  h(u.length);
1719
1723
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "your-ai-workflow-firebase-os",
3
- "version": "1.2.18",
3
+ "version": "1.2.20",
4
4
  "description": "A complete Firebase-powered admin OS — one React component.",
5
5
  "type": "module",
6
6
  "main": "dist/your-ai-workflow-firebase-os.cjs.js",
@@ -134,16 +134,31 @@ export function DashboardNav({ customTabs = [] }: { customTabs?: Omit<TabItem, '
134
134
  }
135
135
  });
136
136
 
137
- // 4. Insert custom/new tabs at the beginning (before 'pages') admin/shared tabs show first
138
- const newTabs: TabItem[] = [];
139
- Object.keys(tabOverrides).forEach(id => {
140
- if (!placed.has(id) && !tabOrder.some(o => o.id === id) && tabMap[id]) {
141
- newTabs.push(tabMap[id]);
137
+ // 4. Ensure ALL tabMap entries appear if they weren't placed by step 3.
138
+ // - New custom tabs (in tabOverrides, not in tabOrder) → go to the FRONT
139
+ // - Missing system tabs (in systemTabDefaults, fell out of tabOrder) go to the END
140
+ const newCustomTabs: TabItem[] = [];
141
+ const missedSystemTabs: TabItem[] = [];
142
+
143
+ Object.keys(tabMap).forEach(id => {
144
+ if (placed.has(id)) return; // Already visible from step 3
145
+
146
+ // Respect explicit hidden flags in tabOrder
147
+ const orderEntry = tabOrder.find(o => o.id === id);
148
+ if (orderEntry?.hidden) return;
149
+
150
+ // A "new custom tab" is one that's in tabOverrides but has no entry in tabOrder at all
151
+ const isNewCustom = (id in tabOverrides) && !orderEntry;
152
+ if (isNewCustom) {
153
+ newCustomTabs.push(tabMap[id]);
154
+ } else {
155
+ missedSystemTabs.push(tabMap[id]);
142
156
  }
143
157
  });
144
- if (newTabs.length > 0) {
145
- ordered.push(...newTabs);
146
- }
158
+
159
+ // New custom tabs show first; missed system tabs append at the end
160
+ if (newCustomTabs.length > 0) ordered.unshift(...newCustomTabs);
161
+ if (missedSystemTabs.length > 0) ordered.push(...missedSystemTabs);
147
162
 
148
163
  return ordered;
149
164
  };
@@ -173,6 +188,8 @@ export function DashboardNav({ customTabs = [] }: { customTabs?: Omit<TabItem, '
173
188
  if (!nav || !measureRow) return;
174
189
 
175
190
  const containerWidth = nav.clientWidth;
191
+ if (containerWidth === 0) return; // Prevent setting maxVisible to 1 during initial layout
192
+
176
193
  const moreButtonWidth = 52;
177
194
  const gap = 40; // gap-10 = 2.5rem ≈ 40px
178
195
  const tabEls = measureRow.querySelectorAll<HTMLElement>('[data-measure-tab]');