your-ai-workflow-firebase-os 1.2.48 → 1.2.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{ContactPopup-Dl2ToG1c.cjs → ContactPopup-BEjdVo2u.cjs} +1 -1
- package/dist/{ContactPopup-DoDjA5wi.js → ContactPopup-DaLnjoL7.js} +3 -3
- package/dist/{PhoneInputField-Dsbycpqe.js → PhoneInputField-jzt5B2SR.js} +1 -1
- package/dist/renderer.cjs.js +1 -1
- package/dist/renderer.es.js +1 -1
- package/dist/your-ai-workflow-firebase-os.cjs.js +17 -16
- package/dist/your-ai-workflow-firebase-os.css +1 -1
- package/dist/your-ai-workflow-firebase-os.es.js +3965 -3766
- package/package.json +1 -1
- package/src/index.css +19 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-DYteiM-1.cjs`),t=require(`./ContactPopup-Dl2ToG1c.cjs`),n=require(`./PhoneInputField-CQ7ylxOC.cjs`);let r=require(`react`);r=e.i(r,1);let i=require(`firebase/firestore`),a=require(`firebase/auth`),o=require(`firebase/storage`),s=require(`react/jsx-runtime`),c=require(`react-router-dom`),l=require(`react-dom`);var u=Object.assign({"./contactForm.config.ts":t.Jt,"./supportForm.config.ts":t.Kt}),d={};for(let e in u){let t=u[e];if(!t)continue;let n=null;for(let e in t)if(e.endsWith(`FormConfig`)||e.endsWith(`Config`)){n=t[e];break}if(!n&&t?.default&&(n=t.default),!n)continue;let r=e.replace(`./`,``).replace(`.config.ts`,``).replace(/Form$/,``).toLowerCase(),i={...n,systemName:n.systemName||r};d[r]=i,i.systemName&&(d[i.systemName]=i,d[i.systemName.toLowerCase()]=i)}if(typeof window<`u`){let e=window.__FBOS_FORMS__||{};window.__FBOS_FORMS__={...d,...e}}var f=Object.assign({}),p=Object.assign({}),m={};for(let e in f){let t=f[e];if(!t)continue;let n=null;for(let e in t)if(e.endsWith(`TabConfig`)||e.endsWith(`Config`)){n=t[e];break}if(!n&&t?.default&&(n=t.default),!n)continue;let r=e.replace(`./`,``).replace(`.config.ts`,``).replace(/Tab$/,``).toLowerCase(),i={config:{...n,pageId:n.pageId||r,tabName:n.tabName||n.title||r},isPublic:!1};m[r]=i,i.config.pageId&&(m[i.config.pageId]=i,m[i.config.pageId.toLowerCase()]=i)}for(let e in p){let t=p[e];if(!t)continue;let n=null;for(let e in t)if(e.endsWith(`PageConfig`)||e.endsWith(`Config`)){n=t[e];break}if(!n&&t?.default&&(n=t.default),!n)continue;let r=e.replace(`./`,``).replace(`.config.ts`,``).replace(/Page$/,``).toLowerCase(),i={config:{...n,pageId:n.pageId||r,pageName:n.pageName||n.title||r},isPublic:!0};m[r]=i,i.config.pageId&&(m[i.config.pageId]=i,m[i.config.pageId.toLowerCase()]=i)}if(typeof window<`u`){let e=window.__FBOS_PAGES__||{};window.__FBOS_PAGES__={...m,...e}}var h=()=>{document.querySelectorAll(`.fbos-content-slot style`).forEach(e=>{e.disabled&&e.media===`not all`||(e.disabled=!0,e.media=`not all`,typeof console<`u`&&console.warn(`FirebaseOS: a <style> tag inside a content file is global CSS and was disabled — style with theme classes (bg-background, text-foreground, glass-panel, btn-primary) instead.`))})},g=()=>{(0,r.useEffect)(()=>{if(typeof document>`u`||typeof MutationObserver>`u`)return;h();let e=new MutationObserver(h);return e.observe(document.body,{childList:!0,subtree:!0}),()=>e.disconnect()},[])},_=[`free`,`internal`,`admin`],v=[`user`,`internal`,`admin`],y={free:`Free`,internal:`Internal`,admin:`Admin`},b={free:`Pages for anyone, plus their own pages. Your team’s pages stay hidden.`,internal:`Everything a signed-in user sees, plus every page for your team.`,admin:`Full access, including Users, Pages, Forms, Inbox, Theme and Assets.`};function x(e){return e===`admin`?`admin`:e===`internal`?`internal`:`free`}function S(e){return e===`free`?`user`:e}var C=e=>x(e)===`admin`,w=e=>x(e)!==`free`;function T(e){return e===`admin`?`admin`:e===`public`?`public`:e===`internal`||e===`shared`?`internal`:`user`}function E(e){let t=T(e);return t===`public`?`user`:t}function D(e,t){switch(T(t)){case`public`:return!0;case`admin`:return C(e);case`internal`:return w(e);case`user`:return!0}}function O(e,t=!0){if(!t)return`guest`;let n=x(e);return n===`free`?`user`:n}function k(e){switch(T(e)){case`public`:return[`admin`,`internal`,`user`,`guest`];case`admin`:return[`admin`];case`internal`:return[`admin`,`internal`];case`user`:return[`admin`,`internal`,`user`]}}var A=(0,r.createContext)({user:null,userRole:null,accessLevel:`free`,isInternal:!1,isAdmin:!1,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 j({children:e}){let[n,o]=(0,r.useState)(null),[c,l]=(0,r.useState)(null),[u,d]=(0,r.useState)(!1),[f,p]=(0,r.useState)(!0),[m,h]=(0,r.useState)(!1),g=r.default.useRef(null),_=r.default.useRef(null),v=r.default.useRef(new Set),y=e=>(0,i.updateDoc)((0,i.doc)(t.Vt,`user_profiles`,e),{role:`admin`}),b=async e=>{if(!v.current.has(e)){v.current.add(e);try{await y(e)}catch(n){if(n?.code!==`permission-denied`){console.error(`Error claiming the admin role:`,n);return}try{if(!t.Bt.currentUser)return;await t.Bt.currentUser.getIdToken(!0),await y(e)}catch(e){e?.code!==`permission-denied`&&console.error(`Error claiming the admin role:`,e)}}}};return(0,r.useEffect)(()=>{let e;if(!t.Bt){p(!1),h(!0);return}(0,a.getRedirectResult)(t.Bt).catch(()=>{});let n=(0,a.onAuthStateChanged)(t.Bt,async n=>{if(n?.uid===_.current&&m){o(n);return}if(_.current=n?.uid||null,n){let r=localStorage.getItem(`fbos_role_${n.uid}`);r&&(l(r),h(!0),p(!1)),console.log(`[AuthContext] 1. onAuthStateChanged fired for user:`,n.uid),o(n);try{let r=(0,i.doc)(t.Vt,`user_profiles`,n.uid),a=(await(0,i.getDoc)(r)).data()||{};(0,i.setDoc)(r,{uid:n.uid,email:n.email,displayName:n.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,i.onSnapshot)(r,e=>{if(e.exists()){let r=e.data(),i=r.role||`user`;!r.role&&t.Bt.currentUser?.emailVerified&&b(n.uid),g.current===null&&(g.current=i),l(i),localStorage.setItem(`fbos_role_${n.uid}`,i),d(r.inactive===!0)}h(!0),p(!1)},e=>{console.warn(`[AuthContext] user_profiles snapshot error (safe to ignore during auth transition):`,e),h(!0),p(!1)})}catch(e){console.error(`[AuthContext] ERROR in auth resolution:`,e),h(!0),p(!1)}}else console.log(`[AuthContext] No user currently signed in.`),o(null),l(null),d(!1),h(!0),p(!1),g.current=null,e&&e()});return()=>{n(),e&&e()}},[]),(0,r.useEffect)(()=>{if(!n?.emailVerified||c===`admin`)return;let e=!1;return(0,i.getDoc)((0,i.doc)(t.Vt,`user_profiles`,n.uid)).then(t=>{!e&&t.exists()&&!t.data().role&&b(n.uid)}).catch(()=>{}),()=>{e=!0}},[n?.uid,n?.emailVerified,c]),(0,s.jsx)(A.Provider,{value:{user:n,userRole:c,accessLevel:x(c),isInternal:w(c),isAdmin:C(c),loading:f,signOut:async()=>{await(0,a.signOut)(t.Bt),o(null)},registerUser:async(e,n,r,o)=>{let{createUserWithEmailAndPassword:s}=await import(`firebase/auth`),{user:c}=await s(t.Bt,e,n),l=`${r} ${o}`.trim();await(0,a.updateProfile)(c,{displayName:l});try{await c.getIdToken(!0),await(0,i.setDoc)((0,i.doc)(t.Vt,`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,a.sendEmailVerification)(c)},refreshUser:async()=>{t.Bt.currentUser&&(await t.Bt.currentUser.reload(),o(Object.assign(Object.create(t.Bt.currentUser),{photoURL:t.Bt.currentUser.photoURL,displayName:t.Bt.currentUser.displayName,email:t.Bt.currentUser.email,emailVerified:t.Bt.currentUser.emailVerified})))},userInactive:u,roleResolved:m},children:e})}var ee=()=>(0,r.useContext)(A);function M(){return(typeof window<`u`?window.__FBOS_PAGES__:null)||{}}function N(e=M()){let t=new Set,n=[];for(let[r,i]of Object.entries(e))!i||t.has(i)||(t.add(i),n.push([r,i]));return n}function P(){let[e,n]=(0,r.useState)(!1),[a,o]=(0,r.useState)([]),l=(0,r.useRef)(null),u=(0,r.useRef)(null),[d,f]=(0,r.useState)(null),p=(0,c.useNavigate)();(0,r.useEffect)(()=>{function e(e){l.current&&!l.current.contains(e.target)&&n(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let m=(0,r.useRef)({users:[],submissions:[],requests:[]}),h=(e,t)=>{m.current[e]=t;let n=[...m.current.users,...m.current.submissions,...m.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)}),o(n.slice(0,8))},g=(e,t)=>{console.warn(`AdminNotifications: ${e} are not readable by this account.`,t),h(e,[])};(0,r.useEffect)(()=>{let e=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Vt,`user_profiles`),(0,i.orderBy)(`createdAt`,`desc`),(0,i.limit)(5)),e=>{h(`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}}))},e=>g(`users`,e)),n=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Vt,`user_submissions`),(0,i.orderBy)(`submittedAt`,`desc`),(0,i.limit)(5)),e=>{h(`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}}))},e=>g(`submissions`,e)),r=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Vt,`user_requests`),(0,i.orderBy)(`submittedAt`,`desc`),(0,i.limit)(5)),e=>{h(`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}}))},e=>g(`requests`,e));return()=>{e(),n(),r()}},[]);let[_,v]=(0,r.useState)(()=>typeof window<`u`?parseInt(localStorage.getItem(`admin_notifications_last_read`)||`0`,10):0),y=()=>{let t=!e;if(n(t),t){let e=u.current?.getBoundingClientRect();f(typeof window<`u`&&window.innerWidth<640&&e?e.bottom+8:null);let t=Date.now();v(t),typeof window<`u`&&localStorage.setItem(`admin_notifications_last_read`,t.toString())}},b=a.some(e=>{if(!e.time)return!0;let t=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return t>_||isNaN(t)}),x=e=>{n(!1),p(e===`user`?`/users`:e===`submission`?`/submissions`:`/requests`)},S=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,s.jsxs)(`div`,{className:`relative z-50 flex-shrink-0`,ref:l,children:[(0,s.jsxs)(`button`,{ref:u,onClick:y,className:`w-9 h-9 rounded-xl border border-[var(--panel-border)] transition-all relative text-foreground/60 hover:bg-foreground/5 hover:text-foreground flex items-center justify-center shadow-sm cursor-pointer`,"aria-label":`Admin Notifications`,children:[(0,s.jsx)(t.Dt,{className:`w-4 h-4`}),b&&(0,s.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-red-500 rounded-full animate-pulse`})]}),(0,s.jsx)(t.f,{children:e&&(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`${d===null?`absolute top-full mt-2 right-0`:`fixed right-4`} w-[min(320px,calc(100vw-2rem))] md:w-[400px] glass-popover border border-[var(--panel-border)] rounded-2xl z-50 flex flex-col origin-top-right overflow-hidden`,style:d===null?void 0:{top:d},children:[(0,s.jsxs)(`div`,{className:`px-4 border-b border-[var(--panel-border)]/50 pb-3 pt-4 flex items-center justify-between`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[14px] text-foreground tracking-wide`,children:`Notifications`}),(0,s.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,s.jsx)(`div`,{className:`max-h-[350px] overflow-y-auto w-full p-2 flex flex-col gap-1`,children:a.length===0?(0,s.jsx)(`div`,{className:`p-6 text-center text-foreground/40 text-[13px] font-medium`,children:`No recent activity.`}):a.map(e=>(0,s.jsxs)(`button`,{onClick:()=>x(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,s.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,s.jsx)(t.b,{className:`w-4 h-4`}):e.type===`submission`?(0,s.jsx)(t.V,{className:`w-4 h-4`}):(0,s.jsx)(t.ht,{className:`w-4 h-4`})}),(0,s.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-2`,children:[(0,s.jsx)(`span`,{className:`text-[13px] font-semibold text-foreground group-hover:text-accent transition-colors truncate`,children:e.title}),(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/60 truncate`,children:e.subtitle}),(0,s.jsx)(`span`,{className:`text-[10px] font-mono tracking-wide text-foreground/40 mt-1`,children:S(e.time)})]})]},e.id))})]})})]})}var F=[{id:`guide`,hidden:!1},{id:`contact`,hidden:!1},{id:`templates`,hidden:!1},{id:`setup`,hidden:!1}],I={drive:`assets`,submissions:`inbox`,requests:`inbox`},L=e=>{let t=(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden}).map(e=>({...e,id:I[e.id]||e.id}));return t.filter((e,n)=>t.findIndex(t=>t.id===e.id)===n)},R=[{id:`pages`,hidden:!1},{id:`forms`,hidden:!1},{id:`inbox`,hidden:!1},{id:`users`,hidden:!1},{id:`theme`,hidden:!1},{id:`assets`,hidden:!1}],z={route:`/support`,template:`popup_form`,form:`support`,tabName:`Support`,iconName:``},B={guide:{label:`Guide`,path:`/guide`},templates:{label:`Templates`,path:`/templates`},setup:{label:`Setup`,path:`/setup`},contact:{label:`Contact`,path:`/contact`}};function V({customMenu:e,standalone:n}){let{user:a,userRole:o,signOut:l}=ee(),u=C(o),d=x(o),f=d===`free`?`Free User`:y[d],p=(0,c.useNavigate)(),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(null),[v,b]=(0,r.useState)(!1),[S,w]=(0,r.useState)(!1),[T,E]=(0,r.useState)(!1),D=a?.displayName||a?.email?.split(`@`)[0]||`User`,O=D.charAt(0).toUpperCase()+D.slice(1),{theme:k,toggleTheme:A,activeConfig:j}=t.Lt(),M=async()=>{await l(),p(`/`),h(!1)},[I,R]=(0,r.useState)({...B}),[V,te]=(0,r.useState)(F);(0,r.useEffect)(()=>{if(!t.Vt)return;let e=(0,i.onSnapshot)((0,i.collection)(t.Vt,`sys_pages`),e=>{let t={...B};for(let[e,n]of N()){if(!n.isPublic)continue;let r=n.config||{};if(r.enabled===!1)continue;let i=r.route?r.route.startsWith(`/`)?r.route:`/`+r.route:`/`+e;t[e]={label:r.pageName||r.pageTitle||r.title||e,path:i}}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}}),R(t)},e=>{console.warn(`sys_pages snapshot error (safe to ignore during auth transition):`,e)}),n=(0,i.onSnapshot)((0,i.doc)(t.Vt,`sys_configs`,`page_order`),e=>{te(e.exists()&&Array.isArray(e.data().order)?L(e.data().order):F)},e=>{console.warn(`page_order snapshot error (safe to ignore during auth transition):`,e)}),r=(0,i.onSnapshot)((0,i.doc)(t.Vt,`sys_tabs`,`support`),e=>{e.exists()&&e.data().pageName&&U(e.data().pageName)},e=>{console.warn(`support snapshot error (safe to ignore during auth transition):`,e)});return()=>{e(),n(),r()}},[]);let[H,U]=(0,r.useState)(z.tabName),W=(()=>{let e=new Set(V.filter(e=>e.hidden).map(e=>e.id)),t=new Set,n=[];return V.forEach(e=>{if(e.hidden||e.id===`home`)return;let r=I[e.id];r&&(n.push({label:r.label,path:r.path}),t.add(e.id))}),Object.entries(I).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})(),G=e||W,K=(0,r.useRef)(null),q=(0,r.useRef)(null),[J,Y]=(0,r.useState)(G.length);(0,r.useEffect)(()=>{if(n||a)return;let e=()=>{let e=K.current,t=q.current;if(!e||!t)return;let n=e.clientWidth,r=t.querySelectorAll(`[data-measure-nav]`);if(r.length===0){Y(G.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){Y(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?28:0);if(i+50>n)break;o=i,s++}Y(Math.max(s,1))},t=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(t);let r=new ResizeObserver(()=>requestAnimationFrame(e));return K.current&&r.observe(K.current),()=>{cancelAnimationFrame(t),r.disconnect()}},[G.map(e=>e.label).join(`|`),n,a,G.length]);let ne=G.slice(0,J),re=G.slice(J);return(0,s.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,s.jsx)(`div`,{className:`flex items-center min-w-0 z-50`,children:(0,s.jsxs)(c.Link,{to:`/`,className:`flex items-center gap-2.5 md:gap-3 group cursor-pointer z-50 min-w-0`,children:[(0,s.jsx)(`div`,{className:`w-9 h-9 rounded-lg glass-panel flex items-center justify-center glow-hover shadow-lg transition-transform duration-500 group-hover:rotate-180 group-active:scale-95 overflow-hidden shrink-0`,children:j?.logoUrl?(0,s.jsx)(`img`,{src:j.logoUrl,alt:`Logo`,className:`w-full h-full object-contain`}):(0,s.jsx)(t.ut,{className:`w-4 h-4 text-accent`})}),(0,s.jsx)(`span`,{className:`font-bold text-[18px] md:text-[20px] tracking-tight text-gradient transition-all duration-300 drop-shadow-sm truncate`,children:j?.appName||``})]})}),(0,s.jsx)(t.f,{children:v&&(0,s.jsx)(t.t,{formId:`contact`,onClose:()=>b(!1)})}),(0,s.jsx)(t.f,{children:S&&(0,s.jsx)(t.t,{formId:`support`,onClose:()=>w(!1)})}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2.5 md:gap-4 z-50 relative ml-auto flex-1 justify-end`,children:[!n&&!a&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{ref:q,"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:G.map((e,n)=>(0,s.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,s.jsx)(t.St,{className:`w-3 h-3`})]},e.path||n))}),(0,s.jsxs)(`div`,{className:`hidden sm:flex items-center gap-7 mr-6 w-full max-w-full justify-end relative`,ref:K,children:[ne.map((e,n)=>(0,s.jsxs)(`div`,{className:`relative shrink-0`,onMouseEnter:()=>_(e.label),onMouseLeave:()=>_(null),children:[e.path?(0,s.jsxs)(c.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,s.jsx)(t.St,{className:`w-3 h-3`})]}):(0,s.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,s.jsx)(t.St,{className:`w-3 h-3`})]}),e.submenu&&g===e.label&&(0,s.jsx)(`div`,{className:`absolute top-[100%] left-0 pt-2 z-50`,children:(0,s.jsx)(t.d.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,s.jsx)(c.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,s.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`}-${n}`)),re.length>0&&(0,s.jsxs)(`div`,{className:`relative flex items-center shrink-0`,onMouseEnter:()=>h(`overflow`),children:[(0,s.jsx)(`button`,{onClick:()=>h(m===`overflow`?!1:`overflow`),className:`p-1 rounded-lg transition-colors flex items-center ${m===`overflow`?`bg-foreground/5 text-accent`:`text-foreground/50 hover:bg-foreground/5 hover:text-accent`}`,children:(0,s.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,s.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,s.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`}),(0,s.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`})]})}),(0,s.jsx)(t.f,{children:m===`overflow`&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>h(!1)}),(0,s.jsx)(t.d.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 glass-popover border border-[var(--panel-border)] rounded-2xl flex flex-col py-2 z-50 origin-top-right`,children:re.map((e,t)=>e.path?(0,s.jsx)(c.Link,{to:e.path,onClick:()=>h(!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,s.jsx)(`button`,{onClick:()=>{e.action&&e.action(),h(!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,s.jsx)(`button`,{onClick:A,className:`w-9 h-9 rounded-xl border border-[var(--panel-border)] hover:bg-foreground/5 transition-all text-foreground/60 hover:text-foreground flex items-center justify-center shadow-sm shrink-0 cursor-pointer`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,s.jsx)(t.D,{className:`w-4 h-4`}):(0,s.jsx)(t.z,{className:`w-4 h-4`})}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2.5 shrink-0`,children:[(0,s.jsx)(c.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,s.jsx)(c.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,s.jsxs)(`div`,{className:`relative sm:hidden`,children:[(0,s.jsx)(`button`,{onClick:()=>h(m===`guest`?!1:`guest`),className:`p-2 rounded-xl glass-panel glow-hover border transition-all ${m===`guest`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,s.jsx)(t.B,{className:`w-5 h-5 text-accent/80`})}),(0,s.jsx)(t.f,{children:m===`guest`&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>h(!1)}),(0,s.jsxs)(t.d.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-popover border border-[var(--panel-border)] rounded-2xl z-50 flex flex-col gap-1 origin-top-right`,children:[(0,s.jsxs)(c.Link,{to:`/guide`,onClick:()=>h(!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,s.jsx)(t.gt,{className:`w-4 h-4 text-accent/70`}),` `,(0,s.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Guide`})]}),(0,s.jsxs)(c.Link,{to:`/templates`,onClick:()=>h(!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,s.jsx)(t.q,{className:`w-4 h-4 text-accent/70`}),` `,(0,s.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Templates`})]}),(0,s.jsxs)(c.Link,{to:`/setup`,onClick:()=>h(!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,s.jsx)(t.A,{className:`w-4 h-4 text-accent/70`}),` `,(0,s.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Setup`})]}),(0,s.jsxs)(c.Link,{to:`/contact`,onClick:()=>h(!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,s.jsx)(t.V,{className:`w-4 h-4 text-accent/70`}),` `,(0,s.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Contact`})]}),(0,s.jsxs)(`div`,{className:`pt-2 mt-1 border-t border-[var(--panel-border)]/50 flex flex-col gap-1`,children:[(0,s.jsxs)(c.Link,{to:`/login`,onClick:()=>h(!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,s.jsx)(t.H,{className:`w-4 h-4 text-accent/70`}),` `,(0,s.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign In`})]}),(0,s.jsx)(c.Link,{to:`/register`,onClick:()=>h(!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,s.jsx)(`span`,{className:`text-[14px] font-bold mx-auto`,children:`Get Started`})})]})]})]})})]})]})]}),!n&&a&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[o===`admin`&&(0,s.jsx)(P,{}),j?.showThemeToggle&&(0,s.jsx)(`button`,{onClick:A,className:`w-9 h-9 rounded-xl border border-[var(--panel-border)] hover:bg-foreground/5 transition-all text-foreground/60 hover:text-foreground flex items-center justify-center shadow-sm shrink-0 cursor-pointer`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,s.jsx)(t.D,{className:`w-4 h-4`}):(0,s.jsx)(t.z,{className:`w-4 h-4`})}),(0,s.jsxs)(`div`,{className:`relative z-50 flex-shrink-0`,children:[(0,s.jsxs)(`button`,{onClick:()=>h(m===`user`?!1:`user`),className:`flex items-center gap-2 group p-0.5 sm:p-1 sm:pr-2.5 rounded-full hover:bg-foreground/5 transition-all duration-300 border ${m===`user`?`border-accent/40 bg-foreground/5`:`border-transparent`}`,children:[(0,s.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:a.photoURL&&!T?(0,s.jsx)(`img`,{src:a.photoURL,alt:`Profile`,className:`w-full h-full object-cover`,onError:()=>E(!0)}):(0,s.jsx)(t.b,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,s.jsxs)(`div`,{className:`hidden sm:flex flex-col text-left mr-1 justify-center min-w-[70px] max-w-[160px]`,children:[(0,s.jsx)(`span`,{className:`text-[12px] font-extrabold leading-tight text-foreground truncate w-full`,children:O}),(0,s.jsx)(`span`,{className:`text-[10px] font-mono tracking-wider leading-tight text-accent truncate w-full mt-0.5 uppercase font-bold`,children:f})]})]}),(0,s.jsx)(t.f,{children:m===`user`&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>h(!1)}),(0,s.jsxs)(t.d.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-popover border border-[var(--panel-border)] rounded-2xl p-2 z-50 flex flex-col origin-top-right`,children:[(0,s.jsxs)(`div`,{className:`p-3 border-b border-[var(--panel-border)]/50 mb-1 flex flex-col gap-1.5`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[15px] text-foreground truncate`,children:O}),(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate font-mono`,children:a.email})]}),(0,s.jsxs)(`div`,{className:`py-1`,children:[(0,s.jsxs)(c.Link,{to:`/profile`,onClick:()=>h(!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,s.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,s.jsx)(t.b,{className:`w-3 h-3 text-accent`})}),`Profile Settings`]}),(0,s.jsxs)(c.Link,{to:`/dashboard`,onClick:()=>h(!1),className:`sm:hidden 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,s.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,s.jsx)(t.Y,{className:`w-3 h-3 text-accent`})}),`Dashboard`]}),u&&(0,s.jsxs)(c.Link,{to:`/assets`,onClick:()=>h(!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,s.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,s.jsx)(t.tt,{className:`w-3 h-3 text-accent`})}),`Assets`]}),o===`admin`&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(c.Link,{to:`/users`,onClick:()=>h(!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,s.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,s.jsx)(t.y,{className:`w-3 h-3 text-accent`})}),`Users`]}),(0,s.jsxs)(c.Link,{to:`/inbox`,onClick:()=>h(!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,s.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,s.jsx)(t.$,{className:`w-3 h-3 text-accent`})}),`Inbox`]}),(0,s.jsxs)(c.Link,{to:`/pages`,onClick:()=>h(!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,s.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,s.jsx)(t.X,{className:`w-3 h-3 text-accent`})}),`Pages`]})]}),o!==`admin`&&(0,s.jsxs)(c.Link,{to:`/support`,onClick:()=>h(!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,s.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,s.jsx)(t.ht,{className:`w-3 h-3 text-accent`})}),H]})]}),(0,s.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,s.jsxs)(`button`,{onClick:M,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,s.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,s.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,s.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,s.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,s.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]})}),`Sign Out`]})})]})]})})]})]}),n&&(0,s.jsx)(s.Fragment,{children:j?.showThemeToggle&&(0,s.jsx)(`button`,{onClick:A,className:`w-9 h-9 rounded-xl border border-[var(--panel-border)] hover:bg-foreground/5 transition-all text-foreground/60 hover:text-foreground flex items-center justify-center shadow-sm shrink-0 cursor-pointer`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,s.jsx)(t.D,{className:`w-4 h-4`}):(0,s.jsx)(t.z,{className:`w-4 h-4`})})})]})]})}function te(){let[e,n]=(0,r.useState)(null);return(0,s.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,s.jsxs)(t.d.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},className:`text-center mb-8 md:mb-12`,children:[(0,s.jsxs)(t.d.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:[(0,s.jsx)(t.h,{className:`w-4 h-4 text-accent`}),` The Open-Source Firebase Starter`]}),(0,s.jsx)(t.d.h1,{className:`text-4xl sm:text-5xl md:text-6xl lg:text-[4.5rem] font-extrabold tracking-tight mb-6 md:mb-8 text-gradient animate-float leading-[1.1] md:leading-[1.15] px-2`,children:`Your AI Firebase`}),(0,s.jsx)(`p`,{className:`text-[14px] sm:text-[15px] md:text-lg lg:text-xl 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:`A production-ready Firebase backend template with Auth, Firestore prefix rules, and a clean dashboard — ready for vibe-coded apps.`}),(0,s.jsxs)(t.d.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:[(0,s.jsx)(c.Link,{to:`/register`,style:{borderRadius:`var(--btn-radius, 0.75rem)`},className:`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 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`,children:`Start Building Free`}),(0,s.jsx)(c.Link,{to:`/login`,style:{borderRadius:`var(--btn-radius, 0.75rem)`},className:`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 font-semibold tracking-wide btn-secondary text-[15px] transition-all duration-300 flex items-center justify-center hover:-translate-y-1`,children:`Sign In`})]})]}),(0,s.jsx)(t.f,{children:e&&(0,s.jsx)(t.t,{onClose:()=>n(null),formId:e})})]})}var H=[{id:`length`,label:`At least 8 characters`,ok:e=>e.length>=8},{id:`case`,label:`An uppercase and a lowercase letter`,ok:e=>/[a-z]/.test(e)&&/[A-Z]/.test(e)},{id:`number`,label:`A number`,ok:e=>/[0-9]/.test(e)}],U=new Set(`password1.password12.password123.password1234.passw0rd1.p@ssword1.p@ssw0rd1.test1234.test12345.testing123.test123456.qwerty123.qwerty1234.abcd1234.abc12345.welcome1.welcome123.admin123.admin1234.letmein123.iloveyou1.monkey123.football1.changeme1.secret123.summer2024.summer2025`.split(`.`)),W=e=>e.toLowerCase().replace(/[\s._-]/g,``),G=e=>U.has(W(e||``)),K=e=>H.map(t=>({rule:t,met:t.ok(e||``)}));function q(e){let t=e||``;if(!t)return`Choose a password.`;let n=H.find(e=>!e.ok(t));return n?`Your password needs ${n.label.toLowerCase()}.`:G(t)?`That password is one of the first anyone would guess. Please pick another.`:``}function J(e,t){return t?e===t?``:`Both passwords must be the same.`:`Type your password a second time.`}function Y({value:e,className:n=``}){return(0,s.jsx)(`ul`,{className:`flex flex-col gap-1 ml-1 ${n}`,"aria-label":`Password requirements`,children:K(e).map(({rule:e,met:n})=>(0,s.jsxs)(`li`,{className:`flex items-center gap-2 text-[12.5px] font-medium transition-colors ${n?`text-emerald-500`:`text-foreground/45`}`,children:[n?(0,s.jsx)(t.Ct,{className:`w-3.5 h-3.5 shrink-0`}):(0,s.jsx)(`span`,{className:`w-3.5 flex justify-center shrink-0`,children:(0,s.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-foreground/25`})}),e.label]},e.id))})}function ne(){let[e,n]=(0,r.useState)(!1),[i,o]=(0,r.useState)(null),[l,u]=(0,r.useState)(``),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(``),_=(0,c.useNavigate)(),{registerUser:v}=ee();return(0,s.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,s.jsxs)(t.d.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,s.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,s.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,s.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Create an account`}),(0,s.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Join Your AI Firebase and start building today.`})]}),i&&(0,s.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:i}),(0,s.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),n(!0),o(null);let t=new FormData(e.currentTarget),r=t.get(`email`),i=t.get(`firstName`),a=t.get(`lastName`),u=q(l),f=u?``:J(l,d);if(m(u),g(f),u||f){o(u||f),n(!1);return}try{await v(r,l,i,a),_(`/verify`)}catch(e){e?.code===`auth/email-already-in-use`?o((0,s.jsxs)(`span`,{children:[`An account with this email already exists.`,` `,(0,s.jsx)(c.Link,{to:`/login?email=${encodeURIComponent(r)}`,className:`font-bold underline hover:text-accent transition-colors`,children:`Sign in?`})]})):e?.code===`auth/weak-password`?o(q(l)||`Please choose a stronger password.`):o(e?.message||`An error occurred during registration.`)}finally{n(!1)}},children:[(0,s.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,s.jsx)(t.s,{name:`firstName`,label:`First Name`,type:`text`,placeholder:`John`,required:!0}),(0,s.jsx)(t.s,{name:`lastName`,label:`Last Name`,type:`text`,placeholder:`Doe`,required:!0})]}),(0,s.jsx)(t.s,{name:`email`,label:`Email`,type:`email`,placeholder:`name@example.com`,required:!0}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,s.jsx)(t.s,{name:`password`,label:`Password`,type:`password`,placeholder:`••••••••`,autoComplete:`new-password`,value:l,onChange:e=>{u(e.target.value),p&&m(``),h&&e.target.value===d&&g(``)},onBlur:()=>m(l?q(l):``),error:p,required:!0}),(0,s.jsx)(Y,{value:l})]}),(0,s.jsx)(t.s,{name:`confirmPassword`,label:`Confirm password`,type:`password`,placeholder:`••••••••`,autoComplete:`new-password`,value:d,onChange:e=>{f(e.target.value),h&&g(``)},onBlur:()=>g(d?J(l,d):``),error:h,required:!0}),(0,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsxs)(t.o,{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,s.jsx)(t.At,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,s.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,s.jsxs)(t.o,{variant:`secondary`,onClick:async()=>{n(!0),o(null);try{if(!t.Bt)throw Error(`Firebase is not initialized. Check your configuration.`);let e=new a.GoogleAuthProvider;try{await(0,a.signInWithPopup)(t.Bt,e)}catch(n){if(n?.code===`auth/popup-blocked`||n?.code===`auth/popup-closed-by-user`||n?.code===`auth/cancelled-popup-request`){let{signInWithRedirect:n}=await import(`firebase/auth`);await n(t.Bt,e);return}throw n}}catch(e){let t=e?.code||``;t===`auth/unauthorized-domain`||(e?.message||``).includes(`requested action is invalid`)?o(`Google Sign-In failed: your app domain is not authorized. Go to Firebase Console → Authentication → Settings → Authorized domains and add your domain (e.g. localhost or your-app.com).`):o(t===`auth/network-request-failed`?`Network error — please check your internet connection and Firebase configuration.`:e?.message||`Google sign-up failed.`)}finally{n(!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,s.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,s.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,s.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,s.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,s.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,s.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`Already have an account? `,(0,s.jsx)(c.Link,{to:`/login`,className:`text-accent hover:underline font-bold ml-1`,children:`Sign in`})]})]})]})})}function re(){let[e,n]=(0,r.useState)(!1),[i,o]=(0,r.useState)(null),[l]=(0,c.useSearchParams)(),u=(0,c.useNavigate)(),[d]=(0,r.useState)(l.get(`email`)||``);return(0,s.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,s.jsxs)(t.d.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,s.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,s.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,s.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Welcome back`}),(0,s.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Sign in to Your AI Firebase.`})]}),i&&(0,s.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:i}),(0,s.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),n(!0),o(null);let r=new FormData(e.currentTarget),i=r.get(`email`),d=r.get(`password`);try{if(!t.Bt)throw Error(`Firebase is not initialized. Check your configuration.`);await(0,a.signInWithEmailAndPassword)(t.Bt,i,d),u(l.get(`from`)||`/dashboard`,{replace:!0})}catch(e){e?.code===`auth/invalid-credential`||e?.code===`auth/user-not-found`||e?.code===`auth/wrong-password`?o((0,s.jsxs)(`span`,{children:[`Email or Password are incorrect.`,` `,(0,s.jsx)(c.Link,{to:`/reset-password`,className:`font-bold underline hover:text-red-400 transition-colors`,children:`Reset password?`})]})):e?.code===`auth/network-request-failed`?o(`Network error — please check your internet connection and Firebase configuration.`):o(e?.message||`Invalid credentials.`),n(!1)}},children:[(0,s.jsx)(t.s,{name:`email`,label:`Email`,type:`email`,defaultValue:d,placeholder:`name@example.com`,required:!0}),(0,s.jsxs)(`div`,{className:`space-y-2`,children:[(0,s.jsxs)(`div`,{className:`flex justify-between items-center pr-1`,children:[(0,s.jsx)(`label`,{className:`text-[14px] md:text-[15px] tracking-wide font-medium text-foreground/80 select-none pb-1`,children:`Password`}),(0,s.jsx)(c.Link,{to:`/reset-password`,className:`text-[13px] md:text-[14px] text-accent hover:underline font-bold tracking-wide`,children:`Forgot Password?`})]}),(0,s.jsx)(t.s,{name:`password`,type:`password`,placeholder:`••••••••`,required:!0})]}),(0,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsxs)(t.o,{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,s.jsx)(t.At,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,s.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,s.jsxs)(t.o,{variant:`secondary`,onClick:async()=>{n(!0),o(null);try{if(!t.Bt)throw Error(`Firebase is not initialized. Check your configuration.`);let e=new a.GoogleAuthProvider;try{await(0,a.signInWithPopup)(t.Bt,e)}catch(n){if(n?.code===`auth/popup-blocked`||n?.code===`auth/popup-closed-by-user`||n?.code===`auth/cancelled-popup-request`){let{signInWithRedirect:n}=await import(`firebase/auth`);await n(t.Bt,e);return}throw n}u(l.get(`from`)||`/dashboard`,{replace:!0})}catch(e){let t=e?.code||``;t===`auth/unauthorized-domain`||(e?.message||``).includes(`requested action is invalid`)?o(`Google Sign-In failed: your app domain is not authorized. Go to Firebase Console → Authentication → Settings → Authorized domains and add your domain (e.g. localhost or your-app.com).`):o(t===`auth/network-request-failed`?`Network error — please check your internet connection and Firebase configuration.`:e?.message||`Google sign-in failed.`)}finally{n(!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,s.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,s.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,s.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,s.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,s.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,s.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`New here? `,(0,s.jsx)(c.Link,{to:`/register`,className:`text-accent hover:underline font-bold ml-1`,children:`Create account`})]})]})]})})}function ie(){let{user:e,refreshUser:n}=ee(),i=(0,c.useNavigate)(),[o,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(!1),[f,p]=(0,r.useState)(``);return(0,s.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16`,children:(0,s.jsxs)(t.d.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,s.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,s.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,s.jsx)(t.V,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,s.jsx)(`h1`,{className:`text-2xl md:text-3xl font-extrabold mb-3 text-foreground tracking-tight`,children:`Verify your email`}),(0,s.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,s.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.`]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[f&&(0,s.jsx)(`div`,{role:`status`,className:`w-full px-4 py-2.5 md:py-3 text-[13px] md:text-[14px] font-semibold leading-snug 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,s.jsx)(t.o,{variant:`primary`,onClick:async()=>{l(!0),p(``);try{if(t.Bt.currentUser){if(await t.Bt.currentUser.reload(),!t.Bt.currentUser.emailVerified){p(`Email is not verified yet. Please check your inbox.`),l(!1);return}await t.Bt.currentUser.getIdToken(!0),await n(),i(`/dashboard`)}}catch{p(`Something went wrong. Please try again.`),l(!1)}},isLoading:o,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,s.jsx)(t.o,{variant:`ghost`,onClick:async()=>{if(e){d(!0),p(``);try{await(0,a.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:u,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`})]})]})})}function ae(...e){return t.c(t.l(e))}var oe=.72,se=({className:e,children:t,...n})=>{let i=(0,r.useRef)(null);return(0,r.useLayoutEffect)(()=>{let e=i.current,t=e?.parentElement;if(!e||!t)return;let n=()=>{e.style.fontSize=``,e.removeAttribute(`data-fold`);let n=t.clientWidth,r=e.scrollWidth;if(!n||r<=n)return;let i=parseFloat(window.getComputedStyle(e).fontSize)||24,a=n/r;e.style.fontSize=`${(i*Math.max(a,oe)).toFixed(2)}px`,a<oe&&e.setAttribute(`data-fold`,``)};if(n(),document.fonts?.ready.then(n).catch(()=>{}),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()},[t]),(0,s.jsx)(`h1`,{ref:i,className:ae(`page-title w-fit inline-block font-extrabold tracking-tight mb-3 mt-1 text-gradient`,e),...n,children:t})};se.displayName=`PageTitle`;var X=k(`admin`),ce={pages:{path:`/pages`,label:`Pages`,icon:t.X,roles:X},forms:{path:`/forms`,label:`Forms`,icon:t.P,roles:X},inbox:{path:`/inbox`,label:`Inbox`,icon:t.$,roles:X},users:{path:`/users`,label:`Users`,icon:t.y,roles:X},theme:{path:`/theme`,label:`Theme`,icon:t.R,roles:X},assets:{path:`/assets`,label:`Assets`,icon:t.tt,roles:X}};function le({customTabs:e=[]}){let{pathname:n}=(0,c.useLocation)(),{user:a,userRole:o}=ee(),[l,u]=(0,r.useState)(!1),d=(0,r.useRef)(null),[f,p]=(0,r.useState)({}),[m,h]=(0,r.useState)(R);(0,r.useEffect)(()=>{try{let e=localStorage.getItem(`fbos_nav_tabs`);e&&p(JSON.parse(e));let t=localStorage.getItem(`fbos_nav_order`);t&&h(JSON.parse(t))}catch{}let e=(0,i.onSnapshot)((0,i.collection)(t.Vt,`sys_tabs`),e=>{let t={};e.forEach(e=>{t[e.id]=e.data()}),p(t),localStorage.setItem(`fbos_nav_tabs`,JSON.stringify(t))},e=>{console.warn(`sys_tabs snapshot error:`,e)}),n=(0,i.onSnapshot)((0,i.doc)(t.Vt,`sys_configs`,`tab_order`),e=>{let t=e.exists()&&Array.isArray(e.data().order)?L(e.data().order):R;h(t),localStorage.setItem(`fbos_nav_order`,JSON.stringify(t))},e=>{console.warn(`tab_order snapshot error:`,e)});return()=>{e(),n()}},[]),(0,r.useEffect)(()=>{function e(e){d.current&&!d.current.contains(e.target)&&u(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let g=[...(()=>{let e={};Object.entries(ce).forEach(([t,n])=>{e[t]={id:t,...n,exact:!0}});let n={...f};for(let[e,t]of N())t.isPublic||(n[e]={...t.config,...f[e]});Object.entries(n).forEach(([n,r])=>{let i=e[n],a=i?.icon??t.X;if(r?.iconName){let e=r.iconName.trim(),n=e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);t.p[n]?a=t.p[n]:t.p[e]&&(a=t.p[e])}let o=i?.roles??X;r?.pageType&&(o=k(E(r.pageType))),e[n]={id:n,path:r?.route?r.route.startsWith(`/`)?r.route:`/`+r.route:i?.path??`/`+n,label:r?.tabName||r?.pageTitle||r?.pageName||i?.label||n,icon:a,roles:o,exact:!0}});let r=[],i=new Set;m.forEach(t=>{t.hidden||i.has(t.id)||e[t.id]&&(r.push(e[t.id]),i.add(t.id))});let a=[],o=[];return Object.keys(e).forEach(t=>{if(i.has(t))return;let r=m.find(e=>e.id===t);r?.hidden||(t in n&&!r?a.push(e[t]):o.push(e[t]))}),a.length>0&&r.unshift(...a),o.length>0&&r.push(...o),r})(),...e.map(e=>({...e,id:e.path}))].filter(e=>{let t=O(o,!!a);return Array.isArray(e.roles)?e.roles.includes(t):!1}),_=(0,r.useRef)(null),v=(0,r.useRef)(null),[y,b]=(0,r.useState)(g.length);(0,r.useEffect)(()=>{let e=()=>{let e=_.current,t=v.current;if(!e||!t)return;let n=e.clientWidth;if(n===0)return;let r=parseFloat(getComputedStyle(e).columnGap)||40,i=t.querySelectorAll(`[data-measure-tab]`);if(i.length===0){b(g.length);return}let a=0,o=!0;for(let e=0;e<i.length;e++)if(a+=i[e].offsetWidth+(e>0?r:0),a>n){o=!1;break}if(o){b(g.length);return}let s=0,c=0;for(let e=0;e<i.length;e++){let t=i[e].offsetWidth,a=s+t+(e>0?r:0);if(a+52>n)break;s=a,c++}b(Math.max(c,1))},t=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(t);let n=new ResizeObserver(()=>requestAnimationFrame(e));return _.current&&n.observe(_.current),()=>{cancelAnimationFrame(t),n.disconnect()}},[g.map(e=>e.id+e.label).join(`|`),g.length]);let x=g.slice(0,y),S=g.slice(y),C=e=>e.exact?n===e.path:n.startsWith(e.path),w=S.some(e=>C(e));return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{ref:v,"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,s.jsxs)(`span`,{"data-measure-tab":!0,className:`flex items-center gap-2 text-[14.5px] font-semibold shrink-0 pb-3`,children:[(0,s.jsx)(t,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)})}),(0,s.jsxs)(`div`,{ref:_,className:`w-full flex items-center gap-6 md:gap-10 mb-5 border-b border-[var(--panel-border)] px-1 whitespace-nowrap relative`,children:[x.map(e=>{let t=C(e),n=e.icon;return(0,s.jsxs)(c.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,s.jsx)(n,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)}),S.length>0&&(0,s.jsxs)(`div`,{className:`relative shrink-0 ml-auto`,ref:d,children:[(0,s.jsx)(`button`,{onClick:()=>u(!l),className:`flex items-center justify-center transition-all duration-300 pb-3 -mb-[1px] border-b-2 cursor-pointer ${w?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,title:`More items`,children:(0,s.jsx)(t.ct,{className:`w-5 h-5`})}),(0,s.jsx)(t.f,{children:l&&(0,s.jsx)(t.d.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] glass-popover border border-[var(--panel-border)] rounded-2xl z-50 flex flex-col py-2 overflow-hidden`,children:S.map(e=>{let t=C(e),n=e.icon;return(0,s.jsxs)(c.Link,{to:e.path||`/`,onClick:()=>u(!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,s.jsx)(n,{className:`w-4 h-4`}),e.label]},e.path||e.id)})})})]})]})]})}function Z(){let{user:e,refreshUser:n,isInternal:c}=ee(),[l,u]=(0,r.useState)(e?.displayName||``),[d,f]=(0,r.useState)(e?.email||``),[p,m]=(0,r.useState)(e?.photoURL||``),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(null),[y,b]=(0,r.useState)(``),[x,S]=(0,r.useState)(``),[C,w]=(0,r.useState)(!1),[E,D]=(0,r.useState)(!1),[O,k]=(0,r.useState)(!0);r.default.useEffect(()=>{u(e?.displayName||``),f(e?.email||``),m(e?.photoURL||``)},[e?.uid,e?.displayName,e?.email,e?.photoURL]);let A=async n=>{if(e)try{if(!c)return;let r=[`mem_files`,`admin_files`];(await(0,i.getDocs)((0,i.collection)(t.Vt,`sys_tabs`))).forEach(e=>{let t=e.data(),n=(t.tabName||e.id).toLowerCase().replace(/[^a-z0-9]+/g,`_`),i=T(t.pageType);i===`internal`&&r.push(`mem_${n}_records`),i===`admin`&&r.push(`admin_${n}_records`)});for(let a of r)try{let r=await(0,i.getDocs)((0,i.query)((0,i.collection)(t.Vt,a),(0,i.where)(`uid`,`==`,e.uid)));if(r.empty)continue;let o=(0,i.writeBatch)(t.Vt);r.docs.forEach(e=>o.update(e.ref,{creatorAvatar:n})),await o.commit()}catch{}}catch(e){console.error(`Error propagating avatar to records:`,e)}};return(0,s.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,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,s.jsx)(se,{children:`Profile Settings`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/profile`]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,s.jsx)(`div`,{className:`flex justify-start`,children:(0,s.jsx)(le,{})}),(0,s.jsx)(t.f,{children:_&&(0,s.jsxs)(t.d.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,s.jsx)(t._t,{className:`w-5 h-5 shrink-0`}):(0,s.jsx)(t.vt,{className:`w-5 h-5 shrink-0`}),(0,s.jsx)(`span`,{className:`text-[14px] font-semibold tracking-wide leading-relaxed`,children:_.text})]})}),(0,s.jsx)(`form`,{onSubmit:async r=>{if(r.preventDefault(),e){g(!0),v(null);try{l!==e.displayName&&await(0,a.updateProfile)(e,{displayName:l});let r=!1;if(d!==e.email){let n=await(0,a.fetchSignInMethodsForEmail)(t.Bt,d);if(n&&n.length>0)throw Error(`An account with this email already exists.`);await(0,a.verifyBeforeUpdateEmail)(e,d),r=!0}if(y){let t=q(y)||J(y,x);if(t)throw Error(t);await(0,a.updatePassword)(e,y),b(``),S(``)}await n(),v(r?{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,s.jsxs)(`div`,{className:`glass-panel w-full p-5 sm:p-8 md:p-12 rounded-3xl border border-[var(--panel-border)] shadow-2xl space-y-8 md:min-h-[500px]`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-4 sm:gap-5 pb-6 border-b border-[var(--panel-border)]/50`,children:[(0,s.jsxs)(`div`,{className:`relative shrink-0 group/avatar`,children:[(0,s.jsxs)(`div`,{className:`w-16 h-16 sm:w-20 sm:h-20 rounded-full glass-panel border-2 border-[var(--panel-border)] shadow-lg bg-accent/10 flex items-center justify-center relative overflow-hidden`,children:[(E||p&&O&&!C)&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-10`,children:(0,s.jsx)(t.W,{className:`w-6 h-6 text-accent animate-spin`})}),p&&!C?(0,s.jsx)(`img`,{src:p,alt:`Avatar`,className:`w-full h-full object-cover transition-opacity duration-300 ${O?`opacity-0`:`opacity-100`}`,onLoad:()=>k(!1),onError:()=>{w(!0),k(!1)}}):(0,s.jsx)(t.b,{className:`w-7 h-7 sm:w-8 sm:h-8 text-accent`})]}),!E&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`label`,{title:p?`Change photo`:`Upload photo`,className:`absolute inset-0 rounded-full bg-background/60 backdrop-blur-[2px] opacity-0 group-hover/avatar:opacity-100 focus-within:opacity-100 flex items-center justify-center cursor-pointer transition-opacity z-20`,children:[(0,s.jsx)(t.Tt,{className:`w-4 h-4 text-foreground`}),(0,s.jsx)(`input`,{type:`file`,accept:`image/*`,"aria-label":`Upload photo`,onChange:async r=>{let s=r.target.files?.[0];if(!(!s||!e)){if(s.size>2*1024*1024){v({text:`File too large. Please select an image under 2MB.`,type:`error`});return}D(!0),w(!1),k(!0);try{let r=(0,o.ref)(t.Ut,`user_avatars/${e.uid}/file.png`);await(0,o.uploadBytes)(r,s,{customMetadata:{ownerId:e.uid}});let c=await(0,o.getDownloadURL)(r);m(c);let l=(0,i.doc)(t.Vt,`user_profiles`,e.uid);await Promise.all([(0,a.updateProfile)(e,{photoURL:c}),(0,i.updateDoc)(l,{avatar:c}),A(c)]),await n(),v({text:`Avatar successfully updated!`,type:`success`})}catch(e){console.error(e),v({text:`Failed to upload photo.`,type:`error`})}finally{D(!1)}}},className:`hidden`})]}),p&&(0,s.jsx)(`button`,{type:`button`,onClick:async()=>{if(e){D(!0),w(!1),k(!1);try{let r=(0,o.ref)(t.Ut,`user_avatars/${e.uid}/file.png`);m(``),D(!1);let s=(0,i.doc)(t.Vt,`user_profiles`,e.uid);await Promise.all([(0,o.deleteObject)(r).catch(e=>console.error(e)),(0,a.updateProfile)(e,{photoURL:``}),(0,i.updateDoc)(s,{avatar:``}),A(``)]),await n(),v({text:`Avatar removed.`,type:`success`})}catch(e){console.error(e),v({text:`Failed to delete photo.`,type:`error`}),D(!1)}}},title:`Remove photo`,"aria-label":`Remove photo`,className:`hidden group-hover/avatar:flex absolute -top-1 -right-1 w-6 h-6 rounded-full bg-background border border-[var(--panel-border)] text-foreground/50 hover:text-red-500 hover:border-red-500/40 items-center justify-center shadow-sm cursor-pointer z-30`,children:(0,s.jsx)(t.T,{className:`w-3 h-3`})})]})]}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h3`,{className:`font-extrabold text-lg sm:text-xl text-foreground mb-1 truncate`,children:l||`User`}),(0,s.jsx)(`div`,{className:`text-[11px] sm: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,s.jsx)(`p`,{className:`text-[13px] text-foreground/40 mt-2 font-medium break-words`,children:e?.email})]})]}),(0,s.jsxs)(`div`,{className:`space-y-6`,children:[(0,s.jsx)(`h3`,{className:`text-[16px] font-extrabold text-foreground flex items-center gap-2`,children:`Account Details`}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,s.jsx)(t.s,{name:`name`,value:l,onChange:e=>u(e.target.value),label:`Display Name`,placeholder:`John Doe`}),(0,s.jsxs)(`div`,{className:`flex flex-col`,children:[(0,s.jsx)(t.s,{name:`email`,type:`email`,value:d,onChange:e=>f(e.target.value),label:`Email Address`,placeholder:`name@example.com`,required:!0}),(0,s.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,s.jsxs)(`div`,{className:`pt-6 border-t border-[var(--panel-border)]/50`,children:[(0,s.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground mb-4 flex items-center gap-2`,children:`Change Password`}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,s.jsx)(t.s,{name:`password`,type:`password`,label:`New Password`,autoComplete:`new-password`,value:y,onChange:e=>b(e.target.value),placeholder:`At least 8 characters`}),(0,s.jsx)(t.s,{name:`confirmPassword`,type:`password`,label:`Confirm Password`,autoComplete:`new-password`,value:x,onChange:e=>S(e.target.value),placeholder:`Repeat password`,error:x&&y!==x?`Both passwords must be the same.`:void 0})]}),y&&(0,s.jsx)(Y,{value:y,className:`mt-3`})]}),(0,s.jsx)(`div`,{className:`pt-6 md:pt-8 border-t border-[var(--panel-border)]/50 flex justify-start w-full`,children:(0,s.jsx)(t.o,{type:`submit`,isLoading:h,className:`w-full sm:w-auto sm: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 ue(){let[e,n]=(0,r.useState)(!1),[i,o]=(0,r.useState)(null),[l,u]=(0,r.useState)(0),[d,f]=(0,r.useState)(0);return(0,r.useEffect)(()=>{let e;return l>0&&(e=setInterval(()=>u(e=>e-1),1e3)),()=>clearInterval(e)},[l]),(0,s.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,s.jsxs)(t.d.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,s.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,s.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,s.jsx)(t.Z,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,s.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,s.jsx)(`h3`,{className:`text-2xl md:text-3xl font-extrabold mb-2 md:mb-3 text-foreground tracking-tight`,children:`Reset Password`}),(0,s.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Enter your email to receive a recovery link.`})]}),i&&(0,s.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:i}),(0,s.jsxs)(`form`,{className:`space-y-4 text-left max-w-[360px] mx-auto`,onSubmit:async e=>{e.preventDefault(),n(!0),o(null);let r=new FormData(e.currentTarget).get(`email`);try{await(0,a.sendPasswordResetEmail)(t.Bt,r)}catch(e){console.error(e)}finally{o(`If an account exists, a password reset link has been sent. Please check your inbox (and spam folder).`);let e=d+1;f(e),u(e===1?60:120),n(!1)}},children:[(0,s.jsx)(t.s,{name:`email`,label:`Work Email`,type:`email`,placeholder:`name@company.com`,required:!0}),(0,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsx)(t.o,{type:`submit`,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl md:rounded-xl transition-all ${l>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:l>0,children:l>0?`Resend link in ${(e=>`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`)(l)}`:d>0?`Resend reset password link`:`Send Reset Link`})})]}),(0,s.jsx)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:(0,s.jsxs)(c.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,s.jsx)(t.jt,{className:`w-4 h-4 mr-2`}),`Back to Sign In`]})})]})})}var de={free:``,internal:`text-blue-500 border-blue-500/30 bg-blue-500/10`,admin:`text-red-500 border-red-500/30 bg-red-500/10`},fe=({level:e})=>e===`free`?null:(0,s.jsx)(`span`,{className:`shrink-0 text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded border ${de[e]}`,children:y[e]});function pe(){let{user:e,userRole:n}=ee(),[a,l]=(0,r.useState)(!0),u=(0,c.useNavigate)(),{id:d}=(0,c.useParams)(),[f,p]=(0,r.useState)([]),[m,h]=(0,r.useState)(null),[g,v]=(0,r.useState)(!1),[C,w]=(0,r.useState)(``),[T,E]=(0,r.useState)(!1),D=d?f.find(e=>e.id===d)||null:f.length>0?f[0]:null,O=e=>{u(e?`/users/${e.id}`:`/users`)};(0,r.useEffect)(()=>{l(!0);let e=(0,i.onSnapshot)((0,i.collection)(t.Vt,`user_profiles`),e=>{let t=[];e.forEach(e=>{t.push({id:e.id,...e.data()})}),p(t),l(!1),!d&&t.length>0&&window.innerWidth>=768&&u(`/users/${t[0].id}`,{replace:!0})},e=>{console.error(`Error fetching users:`,e),l(!1)});return()=>e()},[d,u]);let k=f.find(t=>t.id===e?.uid),A=e=>e.id===k?.id?!1:e.role!==`admin`||!k?.createdAt?!0:e.createdAt?new Date(k.createdAt).getTime()<=new Date(e.createdAt).getTime():!1,j=async(e,r)=>{if(!(n!==`admin`||!A(e))&&x(e.role)!==r)try{await(0,i.updateDoc)((0,i.doc)(t.Vt,`user_profiles`,e.id),{role:S(r)}),h({text:`Access level set to ${y[r]}`,type:`success`}),setTimeout(()=>h(null),3e3)}catch(e){h({text:e.message,type:`error`}),setTimeout(()=>h(null),3e3)}},M=async(e,r)=>{if(!(n!==`admin`||!A(e)))try{await(0,i.updateDoc)((0,i.doc)(t.Vt,`user_profiles`,e.id),{inactive:r}),h({text:`User ${r?`deactivated`:`activated`} successfully`,type:`success`}),setTimeout(()=>h(null),3e3)}catch(e){h({text:e.message,type:`error`}),setTimeout(()=>h(null),3e3)}},N=async()=>{if(v(!1),!(!D||!A(D)||C===D.displayName))try{await(0,i.updateDoc)((0,i.doc)(t.Vt,`user_profiles`,D.id),{displayName:C}),h({text:`Name updated successfully`,type:`success`}),setTimeout(()=>h(null),3e3)}catch(e){h({text:e.message,type:`error`}),setTimeout(()=>h(null),3e3)}},P=async e=>{let n=e.target.files?.[0];if(!(!n||!D||!A(D))){if(n.size>2*1024*1024){h({text:`File too large. Please select an image under 2MB.`,type:`error`});return}E(!0);try{let e=(0,o.ref)(t.Ut,`user_avatars/${D.id}/file.png`);await(0,o.uploadBytes)(e,n);let r=await(0,o.getDownloadURL)(e);p(e=>e.map(e=>e.id===D.id?{...e,avatar:r}:e)),await(0,i.updateDoc)((0,i.doc)(t.Vt,`user_profiles`,D.id),{avatar:r}),h({text:`Avatar successfully updated.`,type:`success`}),setTimeout(()=>h(null),3e3)}catch{h({text:`Failed to upload photo.`,type:`error`})}E(!1)}},[F,I]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let e;return a&&f.length===0?e=setTimeout(()=>I(!0),150):I(!1),()=>clearTimeout(e)},[a,f.length]),a&&f.length===0?F?(0,s.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,s.jsx)(t.W,{className:`w-8 h-8 animate-spin text-accent`})}):null:(0,s.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,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,s.jsx)(se,{children:`Users`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/users`]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,s.jsx)(t.f,{children:m&&(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:`p-4 text-[14px] font-medium border ${m.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:[m.type===`success`&&(0,s.jsx)(t._t,{className:`w-4 h-4 shrink-0`}),m.text]})}),(0,s.jsx)(`div`,{className:`flex justify-start`,children:(0,s.jsx)(le,{})}),(0,s.jsx)(`div`,{className:`glass-panel rounded-3xl border border-[var(--panel-border)] shadow-sm`,children:f.length===0?(0,s.jsx)(`div`,{className:`p-8 text-center text-foreground/50 text-[14px]`,children:`No members found.`}):(0,s.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 md:min-h-[500px]`,children:[(0,s.jsxs)(`div`,{className:`${d?`hidden md:flex`:`flex`} md:col-span-1 border-r md:border-r-[var(--panel-border)] border-b md:border-b-0 border-[var(--panel-border)] flex-col hide-scrollbar bg-foreground/[0.03] rounded-t-3xl md:rounded-tr-none md:rounded-l-3xl`,children:[(0,s.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,s.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-2 md:max-h-[520px]`,children:f.map(e=>(0,s.jsxs)(`div`,{onClick:()=>O(e),className:`p-4 py-5 rounded-2xl border transition-all flex items-center gap-4 cursor-pointer ${D?.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,s.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,s.jsx)(`img`,{src:e.avatar||e.photoURL,alt:``,className:`w-full h-full object-cover`}):(0,s.jsx)(t.b,{className:`w-5 h-5 text-accent`})}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[14px] truncate`,children:e.displayName||`No Name`}),(0,s.jsx)(fe,{level:x(e.role)})]}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/50 truncate font-mono mt-0.5`,children:e.email})]}),(0,s.jsx)(t.bt,{className:`md:hidden w-4 h-4 text-foreground/25 shrink-0`})]},e.id))})]}),(0,s.jsx)(`div`,{className:`${d?`flex`:`hidden md:flex`} md:col-span-2 flex-col p-5 sm:p-6 md:p-10 relative`,children:D?(0,s.jsxs)(`div`,{className:`animate-in fade-in duration-300 w-full max-w-lg`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:()=>O(null),"aria-label":`Back to all users`,className:`md:hidden mb-4 -ml-2 w-9 h-9 flex items-center justify-center rounded-xl text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-colors cursor-pointer`,children:(0,s.jsx)(t.jt,{className:`w-5 h-5`})}),(0,s.jsxs)(`div`,{className:`flex flex-row items-center gap-4 sm:gap-6 md:gap-8 mb-8 sm:mb-10`,children:[(0,s.jsxs)(`div`,{className:`relative shrink-0 group/avatar`,children:[(0,s.jsx)(`div`,{className:`w-14 h-14 sm:w-24 sm:h-24 rounded-full glass-panel border-2 sm:border-4 border-[var(--panel-border)] shadow-lg sm:shadow-xl bg-accent/10 flex items-center justify-center overflow-hidden`,children:T?(0,s.jsx)(t.W,{className:`w-5 h-5 sm:w-8 sm:h-8 text-accent animate-spin`}):D.avatar||D.photoURL?(0,s.jsx)(`img`,{src:D.avatar||D.photoURL,alt:`Avatar`,className:`w-full h-full object-cover`}):(0,s.jsx)(t.b,{className:`w-6 h-6 sm:w-10 sm:h-10 text-accent`})}),!T&&A(D)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`label`,{title:`Change photo`,className:`hidden sm:flex absolute -bottom-0.5 -right-0.5 w-9 h-9 rounded-full btn-primary text-white items-center justify-center cursor-pointer shadow-lg border-2 border-[var(--bg-color)] hover:scale-105 active:scale-95 transition-transform z-10`,children:[(0,s.jsx)(t.Tt,{className:`w-4 h-4`}),(0,s.jsx)(`input`,{type:`file`,accept:`image/*`,"aria-label":`Change photo`,onChange:P,className:`hidden`})]}),(0,s.jsxs)(`label`,{title:`Change photo`,className:`flex sm:hidden absolute inset-0 rounded-full bg-background/60 backdrop-blur-[2px] opacity-0 group-hover/avatar:opacity-100 focus-within:opacity-100 items-center justify-center cursor-pointer transition-opacity z-10`,children:[(0,s.jsx)(t.Tt,{className:`w-4 h-4 text-foreground`}),(0,s.jsx)(`input`,{type:`file`,accept:`image/*`,"aria-label":`Change photo`,onChange:P,className:`hidden`})]})]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col flex-1 w-full min-w-0 relative`,children:[g?(0,s.jsx)(`input`,{autoFocus:!0,value:C,onChange:e=>w(e.target.value),onBlur:N,onKeyDown:e=>e.key===`Enter`&&N(),className:`text-xl sm: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,s.jsx)(`h3`,{onDoubleClick:()=>{A(D)&&(w(D.displayName||``),v(!0))},className:`text-xl sm:text-2xl md:text-3xl font-extrabold mb-1 select-none break-words ${A(D)?`cursor-pointer hover:text-accent transition-colors`:``}`,title:A(D)?`Double-click to edit`:``,children:D.displayName||`No Name`}),(0,s.jsx)(`p`,{className:`text-[13px] sm:text-[14px] font-mono text-foreground/50 break-all`,children:D.email}),!A(D)&&D.id!==k?.id&&(0,s.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-[12px] font-medium text-foreground/45`,children:[(0,s.jsx)(t.U,{className:`w-3 h-3 shrink-0`}),`Admin since before you, so only they can change this account.`]})]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,s.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border border-[var(--panel-border)] flex flex-col gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[14px] text-foreground`,children:`Access level`}),(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/50`,children:`What this person can open`})]}),(0,s.jsx)(`div`,{role:`radiogroup`,"aria-label":`Access level`,className:`flex items-center gap-1.5 flex-wrap ${A(D)?``:`opacity-50`}`,children:_.map(e=>{let t=x(D.role)===e;return(0,s.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t,disabled:!A(D),onClick:()=>j(D,e),className:`h-8 px-3.5 rounded-full text-[12.5px] font-semibold border transition-all ${t?`bg-accent/10 border-accent/40 text-accent`:`border-[var(--panel-border)] text-foreground/55 hover:text-foreground hover:border-accent/30`} ${A(D)?`cursor-pointer`:`cursor-not-allowed`}`,children:y[e]},e)})})]}),(0,s.jsx)(`p`,{className:`text-[12px] text-foreground/50 leading-relaxed`,children:b[x(D.role)]})]}),(0,s.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border flex items-center justify-between gap-3 ${D.inactive?`border-amber-500/30 bg-amber-500/5`:`border-red-500/20 bg-red-500/5`}`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[14px] ${D.inactive?`text-amber-500`:`text-red-500`}`,children:D.inactive?`Reactivate User`:`Deactivate User`}),(0,s.jsx)(`span`,{className:`text-[12px] ${D.inactive?`text-amber-500/70`:`text-red-500/70`}`,children:`Block access to this app`})]}),(0,s.jsx)(`button`,{type:`button`,disabled:!A(D),onClick:()=>M(D,!D.inactive),className:`relative inline-flex h-7 w-12 shrink-0 items-center rounded-full transition-colors focus:outline-none shadow-inner ${D.inactive?`bg-amber-500`:`bg-red-500/20`} ${A(D)?`cursor-pointer`:`opacity-50 cursor-not-allowed`}`,children:(0,s.jsx)(`span`,{className:`inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-md ${D.inactive?`translate-x-6`:`translate-x-1`}`})})]})]})]}):(0,s.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center opacity-30 pointer-events-none`,children:[(0,s.jsx)(t.y,{className:`w-12 h-12 mb-4`}),(0,s.jsx)(`p`,{className:`font-bold tracking-widest uppercase text-[12px]`,children:`Select a User`})]})})]})})]})]})}function me({isOpen:e,title:n,message:r,confirmText:i=`Delete`,cancelText:a=`Cancel`,onConfirm:o,onCancel:c,isProcessing:l=!1,disableConfirm:u=!1}){return(0,s.jsx)(t.f,{children:e&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[(0,s.jsx)(t.d.div,{onClick:()=>!l&&c(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,s.jsx)(t.d.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-popover border border-[var(--panel-border)] shadow-2xl relative z-10 text-center`,children:(0,s.jsxs)(`div`,{className:`w-full flex flex-col items-center`,children:[(0,s.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:n}),(0,s.jsx)(`p`,{className:`w-full text-[14px] font-medium text-foreground/60 leading-relaxed mb-6 break-words`,children:r}),(0,s.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,s.jsx)(t.o,{variant:`secondary`,onClick:c,disabled:l,className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:a}),(0,s.jsx)(t.o,{onClick:o,disabled:l||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:l?(0,s.jsx)(t.W,{className:`w-5 h-5 animate-spin mx-auto`}):i})]})]})})]})})}var he=`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] transition-colors hover:border-accent/40`,ge=`inline-flex items-center justify-center gap-1.5 h-8 px-2.5 sm:h-9 sm:px-3 rounded-[var(--btn-radius,0.75rem)] text-[12.5px] font-semibold border border-[var(--panel-border)] bg-transparent text-foreground/60 hover:text-foreground hover:border-accent/40 hover:bg-foreground/[0.04] active:scale-[0.98] transition-all cursor-pointer disabled:opacity-40 disabled:pointer-events-none`,_e=`w-full h-11 px-4 rounded-[var(--input-radius,0.75rem)] border border-[var(--panel-border)] bg-[var(--panel-bg)] text-[14px] text-foreground outline-none transition-all duration-300 placeholder:text-foreground/35 hover:border-accent/40 focus:border-accent disabled:opacity-50 disabled:cursor-not-allowed console-field`,ve=`w-full h-11 flex items-center px-4 rounded-[var(--input-radius,0.75rem)] border border-[var(--panel-border)] bg-[var(--panel-bg)] transition-all duration-300 hover:border-accent/40 focus-within:border-accent console-field`,ye=`flex-1 min-w-0 h-full bg-transparent border-none outline-none shadow-none text-[14px] text-foreground placeholder:text-foreground/35 disabled:cursor-not-allowed`,be=`text-[13px] font-medium text-foreground/50 select-none`;function xe({state:e=`saved`,label:n}){return(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11.5px] font-semibold text-foreground/50 whitespace-nowrap shrink-0`,children:[e===`saving`?(0,s.jsx)(t.W,{className:`w-3 h-3 animate-spin text-foreground/40 shrink-0`}):(0,s.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${e===`saved`?`bg-emerald-500`:e===`error`?`bg-red-500`:`bg-foreground/25`}`}),n]})}function Q({icon:e,children:n,onClick:r,disabled:i,busy:a,tone:o=`default`,className:c=``,title:l}){return(0,s.jsxs)(`button`,{type:`button`,title:l,onClick:r,disabled:i||a,className:`${ge} ${o===`danger`?`hover:text-red-500 hover:border-red-500/40 hover:bg-red-500/[0.06]`:``} ${c}`,children:[a?(0,s.jsx)(t.W,{className:`w-3.5 h-3.5 animate-spin shrink-0`}):e?(0,s.jsx)(e,{className:`w-3.5 h-3.5 shrink-0`}):null,n]})}function Se({icon:e,title:n,description:i,actions:a,children:o,defaultOpen:c=!0,collapsible:l=!0}){let[u,d]=(0,r.useState)(c),f=l?u:!0;return(0,s.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)]/60 bg-foreground/[0.015] overflow-hidden transition-all`,children:[(0,s.jsxs)(`div`,{className:`w-full px-4 sm:px-5 py-4 grid grid-cols-[auto_minmax(0,1fr)_auto_auto] items-center gap-x-3 sm:gap-x-3.5 gap-y-0.5 text-left`,children:[e&&(0,s.jsx)(`div`,{className:`row-start-1 col-start-1 row-span-2 self-center w-10 h-10 rounded-2xl flex items-center justify-center shrink-0 border border-[var(--panel-border)]/50 bg-accent/10 text-accent`,children:(0,s.jsx)(e,{className:`w-5 h-5`})}),(0,s.jsx)(`span`,{className:`row-start-1 col-start-2 sm:col-span-1 col-span-2 min-w-0 text-[15px] font-bold text-foreground tracking-tight leading-tight truncate self-end`,children:n}),a&&(0,s.jsx)(`div`,{className:`row-start-3 col-start-1 col-span-4 justify-self-end mt-2 sm:mt-0 sm:row-start-1 sm:row-span-2 sm:col-start-3 sm:col-span-1 self-center flex items-center gap-2 shrink-0`,children:a}),l&&(0,s.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),"aria-expanded":f,"aria-label":f?`Collapse ${n}`:`Expand ${n}`,className:`row-start-1 col-start-4 row-span-2 self-center w-8 h-8 rounded-xl border border-[var(--panel-border)]/60 hover:border-accent/40 flex items-center justify-center text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-all cursor-pointer justify-self-end`,children:(0,s.jsx)(t.St,{className:`w-4 h-4 transition-transform duration-200 ${f?`rotate-180`:``}`})}),i&&(0,s.jsx)(`span`,{className:`row-start-2 col-start-2 sm:col-span-1 col-span-2 min-w-0 text-[12px] text-foreground/50 font-normal leading-snug truncate self-start`,children:i})]}),(0,s.jsx)(t.f,{initial:!1,children:f&&(0,s.jsx)(t.d.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,s.jsx)(`div`,{className:`border-t border-[var(--panel-border)]/40 p-4 sm:p-5 flex flex-col gap-5 bg-background/30`,children:o})})})]})}function Ce({label:e,hint:t,action:n,children:r,error:i}){return(0,s.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-1.5 ml-1`,children:[(0,s.jsx)(`label`,{className:be,children:e}),n]}),r,t&&!i&&(0,s.jsx)(`span`,{className:`text-[11.5px] text-foreground/40 font-medium leading-snug mt-1.5 px-1`,children:t}),i&&(0,s.jsx)(`span`,{className:`text-[11.5px] font-semibold text-red-500 leading-snug mt-1.5 px-1`,children:i})]})}function we({label:e,hint:t,value:n,onChange:r,onBlur:i,placeholder:a,prefix:o,error:c,disabled:l,action:u}){return(0,s.jsx)(Ce,{label:e,hint:t,error:c,action:u,children:o?(0,s.jsxs)(`div`,{className:`${ve} ${c?`is-invalid border-red-500/60`:``} ${l?`opacity-50`:``}`,children:[(0,s.jsx)(`span`,{className:`mr-0.5 text-[14px] font-semibold text-foreground/40 select-none shrink-0`,children:o}),(0,s.jsx)(`input`,{type:`text`,value:n??``,disabled:l,placeholder:a,onChange:e=>r(e.target.value),onBlur:i,"aria-label":e,className:`${ye} no-glow`})]}):(0,s.jsx)(`input`,{type:`text`,value:n??``,disabled:l,placeholder:a,onChange:e=>r(e.target.value),onBlur:i,"aria-label":e,className:`${_e} ${c?`is-invalid border-red-500/60`:``}`})})}function Te({label:e,hint:t,value:n,onChange:r,onBlur:i,placeholder:a,rows:o=3}){return(0,s.jsx)(Ce,{label:e,hint:t,children:(0,s.jsx)(`textarea`,{rows:o,value:n??``,placeholder:a,onChange:e=>r(e.target.value),onBlur:i,"aria-label":e,className:`${_e} h-auto py-3 leading-relaxed resize-y`})})}function Ee({label:e,hint:n,value:r,onChange:i,options:a,placeholder:o=`None`,allowEmpty:c=!0,disabled:l}){let u=[...c?[{value:``,label:o}]:[],...a.filter(e=>e.value!==``)];return(0,s.jsx)(Ce,{label:e,hint:n,children:(0,s.jsx)(t.a,{ariaLabel:e,value:r??``,options:u,onChange:i,disabled:l,className:`console-select`,dense:!0,portal:!0,direction:`auto`})})}function De({label:e,hint:t,enabled:n,onChange:r,disabled:i}){return(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-4 w-full`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0 ml-1`,children:[(0,s.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/80`,children:e}),t&&(0,s.jsx)(`span`,{className:`text-[11.5px] text-foreground/40 font-medium leading-snug`,children:t})]}),(0,s.jsx)(Oe,{enabled:n,onChange:r,disabled:i,label:e})]})}function Oe({enabled:e,onChange:t,disabled:n,label:r}){return(0,s.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,onClick:n=>{n.stopPropagation(),t(!e)},className:`relative w-10 h-6 rounded-full transition-colors shrink-0 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed ${e?`bg-accent`:`bg-foreground/15`}`,children:(0,s.jsx)(`span`,{className:`absolute top-1 left-1 w-4 h-4 rounded-full bg-[var(--button-fg,#fff)] shadow transition-transform ${e?`translate-x-4`:`translate-x-0`}`})})}function ke({saving:e,savedAt:t}){return e?(0,s.jsx)(xe,{state:`saving`,label:`Saving`}):t?(0,s.jsx)(xe,{state:`saved`,label:`Saved`}):null}var Ae=e=>e.trim().split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``),je=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1-$2`).toLowerCase(),Me=e=>{let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)},Ne=(()=>{let e=t.m,n=e?Object.keys(e):[];return n.length===0&&(n=Object.keys(t.p).filter(e=>/^[A-Z]/.test(e)&&!/Icon$/.test(e)&&!/^Lucide/.test(e)&&e!==`IconNode`)),Array.from(new Set(n.map(je))).sort()})(),Pe=`layers.house.layout-dashboard.list.table.kanban.calendar.clock.file-text.files.folder.hard-drive.upload.download.paperclip.book-open.notebook-pen.users.user.user-plus.contact.building-2.briefcase.handshake.mail.message-square.message-circle.send.inbox.bell.megaphone.phone.shopping-cart.package.truck.receipt.credit-card.banknote.wallet.tag.percent.chart-bar.chart-line.chart-pie.trending-up.target.gauge.activity.settings.sliders-horizontal.wrench.shield.lock.key.eye.search.star.heart.bookmark.flag.pin.map-pin.globe.circle-check.circle-alert.info.circle-help.life-buoy.sparkles.zap.rocket.camera.image.video.music.mic.palette.pen-tool.scissors.stethoscope.graduation-cap.utensils.plane.car.dumbbell.leaf.sun.moon`.split(`.`),Fe={money:[`banknote`,`wallet`,`credit-card`,`coins`,`dollar-sign`,`receipt`],cash:[`banknote`,`coins`,`wallet`],payment:[`credit-card`,`banknote`,`receipt`],invoice:[`receipt`,`file-text`],price:[`tag`,`dollar-sign`,`receipt`],people:[`users`,`user`,`contact`],customer:[`users`,`contact`,`user-round`],client:[`users`,`contact`,`briefcase`],team:[`users`,`users-round`],staff:[`users`,`id-card`],chat:[`message-circle`,`message-square`,`messages-square`],message:[`message-circle`,`mail`,`send`],email:[`mail`,`send`,`inbox`],task:[`list-checks`,`square-check`,`clipboard-check`],todo:[`list-checks`,`square-check`],project:[`kanban`,`folder-kanban`,`briefcase`],board:[`kanban`,`layout-dashboard`],photo:[`image`,`camera`,`images`],picture:[`image`,`images`],document:[`file-text`,`files`,`file`],doc:[`file-text`,`file`],shop:[`shopping-cart`,`store`,`shopping-bag`],store:[`store`,`shopping-bag`,`shopping-cart`],order:[`shopping-cart`,`package`,`receipt`],delivery:[`truck`,`package`],home:[`house`,`home`],booking:[`calendar-check`,`calendar`,`clock`],appointment:[`calendar-clock`,`calendar`,`clock`],schedule:[`calendar-days`,`calendar`,`clock`],event:[`calendar`,`party-popper`,`ticket`],report:[`chart-bar`,`chart-line`,`file-chart-column`],stats:[`chart-bar`,`chart-line`,`chart-pie`],analytics:[`chart-line`,`chart-bar`,`activity`],help:[`circle-help`,`life-buoy`,`info`],support:[`life-buoy`,`headset`,`circle-help`],idea:[`lightbulb`,`sparkles`],health:[`heart-pulse`,`stethoscope`,`activity`],food:[`utensils`,`chef-hat`,`pizza`],travel:[`plane`,`map`,`luggage`],location:[`map-pin`,`map`,`globe`],address:[`map-pin`,`house`],security:[`shield`,`lock`,`key`],password:[`key`,`lock`],settings:[`settings`,`sliders-horizontal`,`wrench`],file:[`file`,`file-text`,`files`,`folder`],upload:[`upload`,`cloud-upload`],video:[`video`,`film`,`clapperboard`],school:[`graduation-cap`,`book-open`,`school`],course:[`graduation-cap`,`book-open`],gym:[`dumbbell`,`activity`],garden:[`leaf`,`flower`,`sprout`],car:[`car`,`car-front`],pet:[`paw-print`,`dog`,`cat`],note:[`notebook-pen`,`sticky-note`,`pencil`],write:[`pencil`,`pen-tool`,`notebook-pen`],time:[`clock`,`timer`,`hourglass`],star:[`star`,`sparkles`],favourite:[`star`,`heart`,`bookmark`],favorite:[`star`,`heart`,`bookmark`]},Ie=(e,t)=>{if(Math.abs(e.length-t.length)>2)return 3;let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=n[0];n[0]=r;for(let a=1;a<=t.length;a++){let o=n[a];n[a]=Math.min(n[a]+1,n[a-1]+1,i+(e[r-1]===t[a-1]?0:1)),i=o}}return n[t.length]},Le=(e,t)=>{let n=0;for(let r of t)r===e[n]&&n++;return n===e.length};function Re(e,t=96,n=Ne){let r=e.trim().toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``);if(!r)return[];let i=r.split(`-`).filter(Boolean),a=new Set(n),o=new Map,s=(e,t)=>{a.has(e)&&o.set(e,Math.max(o.get(e)||0,t))};for(let e of n){let t=e.split(`-`);if(e===r){s(e,100);continue}if(e.startsWith(r)){s(e,90);continue}if(t.some(e=>e===r)){s(e,85);continue}if(t.some(e=>e.startsWith(r))){s(e,75);continue}if(e.includes(r)){s(e,65);continue}if(i.length>1&&i.every(e=>t.some(t=>t.startsWith(e)))){s(e,60);continue}}for(let e of i){for(let t of Fe[e]||[])s(t,70);if(e.endsWith(`s`))for(let t of Fe[e.slice(0,-1)]||[])s(t,70)}if(o.size===0&&r.length>=3)for(let e of n)e.split(`-`).some(e=>Ie(r,e)<=(r.length>5?2:1))?s(e,40):r.length>=4&&Le(r,e.replace(/-/g,``))&&s(e,20);let c=e=>{let t=Pe.indexOf(e);return t===-1?Pe.length:t};return Array.from(o.entries()).sort((e,t)=>t[1]-e[1]||c(e[0])-c(t[0])||e[0].length-t[0].length||e[0].localeCompare(t[0])).slice(0,t).map(([e])=>e)}function ze(e){if(!e)return t.X;let n=e.trim(),r=t.p;return r[Ae(n)]||r[n]||t.X}function Be({name:e,className:t}){return(0,r.createElement)(ze(e),{className:t})}function Ve({label:e=`Icon`,hint:n=`Shown next to the name in the menu.`,value:i,onChange:a}){let[o,c]=(0,r.useState)(``),l=(i||``).trim(),u=(0,r.useMemo)(()=>Re(o),[o]),d=o.trim().length>0;return(0,s.jsx)(Ce,{label:e,hint:n,children:(0,s.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,s.jsxs)(`div`,{className:ve,children:[l&&!d?(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-2 mr-2.5 shrink-0 min-w-0 text-accent`,children:[(0,s.jsx)(`span`,{className:`w-7 h-7 -ml-1 rounded-lg bg-accent/[0.08] border border-accent/25 flex items-center justify-center shrink-0`,children:(0,s.jsx)(Be,{name:l,className:`w-4 h-4`})}),(0,s.jsx)(`span`,{className:`text-[13px] font-semibold truncate`,children:Me(je(l))}),(0,s.jsx)(t.Ct,{className:`w-3.5 h-3.5 shrink-0`})]}):(0,s.jsx)(t.M,{className:`w-4 h-4 mr-2.5 text-foreground/30 shrink-0`}),(0,s.jsx)(`input`,{type:`text`,value:o,onChange:e=>c(e.target.value),placeholder:l?`Type a word to change it`:`Type a word, e.g. calendar`,"aria-label":`Search icons`,className:`${ye} no-glow`})]}),d&&(0,s.jsx)(`div`,{className:`rounded-[var(--input-radius,0.75rem)] border border-[var(--panel-border)] bg-[var(--panel-bg)] p-2 max-h-56 overflow-y-auto`,children:u.length>0?(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>{let t=je(l).toLowerCase()===e;return(0,s.jsx)(`button`,{type:`button`,title:Me(e),"aria-label":Me(e),"aria-pressed":t,onClick:()=>{a(e),c(``)},className:`w-9 h-9 rounded-lg flex items-center justify-center transition-all cursor-pointer ${t?`bg-accent text-[var(--button-fg,#fff)] ring-2 ring-accent/40`:`text-foreground/60 hover:text-foreground hover:bg-foreground/[0.06]`}`,children:(0,s.jsx)(Be,{name:e,className:`w-4 h-4`})},e)})}):(0,s.jsx)(`span`,{className:`block px-2 py-2 text-[12px] font-medium text-foreground/45`,children:`Nothing close to that. Try a simpler word, like calendar or people.`})})]})})}function He({title:e=`Ask your assistant`,description:n,prompt:i,compact:a=!1,locked:o=!1}){let[c,l]=(0,r.useState)(!1),u=i.includes(`
|
|
2
|
-
`);return o?null:(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 min-w-0 max-w-full rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] ${a?`px-4 py-3.5`:`px-5 py-4`}`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,s.jsx)(`span`,{className:`text-[12px] font-extrabold tracking-tight text-gradient`,children:e}),(0,s.jsxs)(`button`,{type:`button`,onClick:()=>{navigator.clipboard?.writeText(i),l(!0),setTimeout(()=>l(!1),2e3)},className:`inline-flex items-center justify-center gap-1.5 h-8 px-3 rounded-[var(--btn-radius,0.75rem)] text-[12px] font-semibold shrink-0 border ${c?`copy-btn-done border-emerald-500/30 bg-emerald-500/10 text-emerald-500 cursor-pointer`:`copy-btn cursor-pointer`}`,children:[c?(0,s.jsx)(t.Ct,{className:`copy-icon w-3.5 h-3.5`}):(0,s.jsx)(t.dt,{className:`copy-icon w-3.5 h-3.5`}),c?`Copied`:`Copy`]})]}),n&&(0,s.jsx)(`p`,{className:`text-[12.5px] text-foreground/50 font-medium leading-relaxed break-words`,children:n}),(0,s.jsx)(`p`,{className:`text-[13.5px] text-foreground/80 font-medium leading-relaxed whitespace-pre-line break-words [overflow-wrap:anywhere]`,children:u?i:`“${i}”`})]})}function Ue({label:e,hint:n,value:i,onChange:a,accept:o=`image/*`,action:c,clearable:l=!0,tips:u}){let{user:d}=ee(),f=(0,r.useRef)(null),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(``),_=async e=>{if(!(!e||p)){m(!0),g(``);try{a(await t.i(e,d))}catch(e){g(t.r(e))}m(!1),f.current&&(f.current.value=``)}};return(0,s.jsxs)(Ce,{label:e,hint:n,error:h,action:c,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,s.jsx)(`div`,{className:`w-10 h-10 rounded-lg shrink-0 overflow-hidden flex items-center justify-center bg-foreground/5 border border-[var(--panel-border)]/60`,children:p?(0,s.jsx)(t.W,{className:`w-4 h-4 animate-spin text-accent`}):i?(0,s.jsx)(`img`,{src:i,alt:e,className:`w-full h-full object-contain`}):(0,s.jsx)(t.et,{className:`w-4 h-4 text-foreground/30`})}),(0,s.jsx)(`input`,{type:`text`,"aria-label":e,value:i??``,placeholder:`Upload one, or paste a link`,onChange:e=>a(e.target.value),className:_e}),l&&!!i&&!p&&(0,s.jsx)(`button`,{type:`button`,onClick:()=>{g(``),a(``)},"aria-label":`Remove ${e}`,title:`Remove ${e}`,className:`w-9 h-9 rounded-lg shrink-0 flex items-center justify-center text-foreground/40 hover:text-red-500 hover:bg-red-500/10 transition-colors cursor-pointer`,children:(0,s.jsx)(t.g,{className:`w-4 h-4`})}),(0,s.jsxs)(`label`,{className:`${ge} shrink-0 ${p?`opacity-40 pointer-events-none`:``}`,title:i?`Replace ${e}`:`Upload ${e}`,children:[p?(0,s.jsx)(t.W,{className:`w-3.5 h-3.5 animate-spin shrink-0`}):(0,s.jsx)(t.pt,{className:`w-3.5 h-3.5 shrink-0`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:p?`Uploading`:i?`Replace`:`Upload`}),(0,s.jsx)(`input`,{ref:f,type:`file`,accept:o,"aria-label":`Upload ${e}`,disabled:p,onChange:e=>_(e.target.files?.[0]),className:`hidden`})]})]}),!!u?.length&&(0,s.jsx)(`ul`,{className:`flex flex-col gap-1 mt-2 px-1`,children:u.map(e=>(0,s.jsxs)(`li`,{className:`text-[11.5px] text-foreground/40 font-medium leading-snug flex gap-1.5`,children:[(0,s.jsx)(`span`,{"aria-hidden":!0,className:`text-accent/60`,children:`•`}),e]},e))})]})}var We=[`A wide picture sits best across a page — about 1600 by 900.`,`JPG or PNG, and under 1 MB if you can: a heavy picture makes the page slow to open.`,`Your own photo beats a stock one. People can tell.`,`No writing baked into the picture — your assistant sets the words, so they stay readable on a phone.`],Ge=e=>typeof e==`string`&&/^https?:\/\/\S+$/.test(e.trim()),Ke={anyone:{collectionName:`user_submissions`,chip:`Anyone`,filterLabel:`From anyone`},signedIn:{collectionName:`user_requests`,chip:`Signed-in user`,filterLabel:`From signed-in users`}},qe=`Create a form called Ask a question for website visitors. Ask for full name (required), email (required) and their question as long text (required). Put it on my /contact page built into the page, send the answers to my Inbox, and show a thank-you message after sending.`,Je=[`id`,`source`,`uid`,`submittedAt`,`avatarUrl`,`isArchived`,`name`,`full_name`,`email`,`contactEmail`,`topic`],Ye=e=>{let t=e.submittedAt;if(!t)return 0;if(typeof t.toMillis==`function`)return t.toMillis();if(typeof t.toDate==`function`)return t.toDate().getTime();let n=new Date(t).getTime();return Number.isNaN(n)?0:n},Xe=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)},Ze=e=>e.submitterName||e.name||e.full_name||`Anonymous`,Qe=e=>e.contactEmail||e.email||`No email provided`;function $e(e){let[n,a]=(0,r.useState)([]),[o,s]=(0,r.useState)(!0);return(0,r.useEffect)(()=>{let n=!1,r=Ke[e].collectionName,o=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Vt,r),(0,i.orderBy)(`submittedAt`,`desc`)),async r=>{let o=[];for(let n of r.docs){let r={...n.data()},a=``;if(r.uid&&r.uid!==`guest`)try{let e=await(0,i.getDoc)((0,i.doc)(t.Vt,`user_profiles`,r.uid));if(e.exists()){let t=e.data();(t.avatar||t.photoURL)&&(a=t.avatar||t.photoURL),r.name||=t.name||t.displayName,r.email||=t.email,r.contactEmail||=t.email}}catch(e){console.error(`Failed to fetch profile`,e)}o.push({...r,id:n.id,source:e,avatarUrl:a})}n||(a(o),s(!1))},e=>{console.error(`Error loading ${r}:`,e),n||s(!1)});return()=>{n=!0,o()}},[e]),{items:n,loading:o}}function et({source:e}){return(0,s.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:Ke[e].chip})}function tt({item:e,isExpanded:n,onToggle:r,onArchive:i,onDelete:a,busy:o,dimmed:l}){let u=Ze(e),d=e.avatarUrl||e.submitterAvatar,f=!!e.uid&&e.uid!==`guest`,p=Object.entries(e).filter(([e])=>!Je.includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`),m=e.topic?[[`topic`,e.topic],...p]:p,h=p.map(([,e])=>typeof e==`string`&&!Ge(e)?e.trim():``).find(Boolean)||e.topic||``;return(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden hover:border-accent/40 transition-all duration-300 ${l?`opacity-60 hover:opacity-100`:``}`,children:[(0,s.jsxs)(`div`,{className:`w-full flex items-center gap-3 p-3.5 md:p-4 md:px-6`,children:[(0,s.jsxs)(`button`,{type:`button`,onClick:r,"aria-expanded":n,className:`flex items-center gap-3 md:gap-4 flex-1 min-w-0 text-left cursor-pointer`,children:[(0,s.jsx)(`div`,{className:`relative shrink-0`,children:d?(0,s.jsx)(`img`,{src:d,alt:``,className:`w-9 h-9 md:w-10 md:h-10 rounded-full object-cover border border-[var(--panel-border)] shadow-sm`}):(0,s.jsx)(`div`,{className:`w-9 h-9 md:w-10 md:h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm uppercase`,children:(u||`A`)[0]})}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:u}),(0,s.jsxs)(`span`,{className:`hidden md:inline-flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(et,{source:e.source}),e.formId&&(0,s.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-foreground/40 bg-foreground/5 px-2 py-0.5 rounded-md border border-[var(--panel-border)] shrink-0`,children:String(e.formId).replace(/_/g,` `)})]}),(0,s.jsx)(`span`,{className:`md:hidden ml-auto pl-2 text-[11px] font-medium text-foreground/40 shrink-0`,children:Xe(e.submittedAt)})]}),(0,s.jsxs)(`span`,{className:`text-[12px] md:text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:[(0,s.jsx)(t.V,{className:`w-3.5 h-3.5 shrink-0`}),` `,Qe(e)]}),!n&&h&&(0,s.jsx)(`span`,{className:`hidden md:block text-[13px] text-foreground/40 truncate mt-1`,children:h})]})]}),(0,s.jsx)(t.St,{className:`md:hidden w-4 h-4 text-foreground/30 shrink-0 transition-transform duration-300 ${n?`rotate-180`:``}`}),(0,s.jsxs)(`div`,{className:`hidden md:flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:Xe(e.submittedAt)}),(0,s.jsx)(Q,{icon:e.isArchived?t.kt:t.Nt,onClick:i,busy:o,children:e.isArchived?`Restore`:`Archive`}),(0,s.jsx)(Q,{icon:t.T,tone:`danger`,onClick:a,children:`Delete`}),(0,s.jsx)(`button`,{type:`button`,onClick:r,"aria-label":n?`Hide details from ${u}`:`Show details from ${u}`,className:`p-1.5 text-foreground/40 transition-transform duration-300 cursor-pointer ${n?`rotate-180`:``}`,children:(0,s.jsx)(t.St,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(t.f,{children:n&&(0,s.jsx)(t.d.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,s.jsxs)(`div`,{className:`px-3.5 md:px-6 py-4 md:py-5 border-t border-[var(--panel-border)]/40`,children:[(0,s.jsxs)(`div`,{className:`md:hidden flex flex-wrap items-center gap-2 mb-3`,children:[(0,s.jsx)(et,{source:e.source}),e.formId&&(0,s.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-foreground/40 bg-foreground/5 px-2 py-0.5 rounded-md border border-[var(--panel-border)] shrink-0`,children:String(e.formId).replace(/_/g,` `)})]}),m.length>0?(0,s.jsx)(`div`,{className:`rounded-xl border border-[var(--panel-border)]/60 bg-foreground/[0.02] divide-y divide-[var(--panel-border)]/40 overflow-hidden`,children:m.map(([e,n])=>(0,s.jsxs)(`div`,{className:`px-3.5 md:px-5 py-3 md:py-3.5`,children:[(0,s.jsx)(`span`,{className:`block text-[11px] font-bold uppercase tracking-widest text-foreground/40 mb-1`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}),Ge(n)?(0,s.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-2 text-[14px] md:text-[15px] font-semibold text-accent hover:underline break-all [overflow-wrap:anywhere]`,children:[(0,s.jsx)(t.L,{className:`w-4 h-4 shrink-0`}),t.n(n)]}):(0,s.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/85 leading-relaxed whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:typeof n==`boolean`?n?`Yes`:`No`:e.toLowerCase()===`budget`&&n?`$${n}`:String(n??``)||`No data provided`})]},e))}):(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/40 font-medium`,children:`This form only asked for a name and email.`}),f&&(0,s.jsx)(c.Link,{to:`/users/${e.uid}`,className:`inline-flex mt-3 text-[12.5px] font-bold text-accent hover:underline`,children:`Open this person’s profile`}),(0,s.jsxs)(`div`,{className:`md:hidden flex items-center justify-end gap-2 mt-4`,children:[(0,s.jsx)(Q,{icon:e.isArchived?t.kt:t.Nt,onClick:i,busy:o,children:e.isArchived?`Restore`:`Archive`}),(0,s.jsx)(Q,{icon:t.T,tone:`danger`,onClick:a,children:`Delete`})]})]})})})]})}function nt(){let e=$e(`anyone`),n=$e(`signedIn`),[a,o]=(0,r.useState)(`all`),[c,l]=(0,r.useState)(null),[u,d]=(0,r.useState)(!1),[f,p]=(0,r.useState)(null),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(!1),v=e.loading||n.loading,y=(0,r.useMemo)(()=>[...e.items,...n.items].sort((e,t)=>Ye(t)-Ye(e)),[e.items,n.items]),b=a===`all`?y:y.filter(e=>e.source===a),x=b.filter(e=>!e.isArchived),S=b.filter(e=>e.isArchived),C=e=>`${e.source}:${e.id}`,w=e=>l(t=>t===C(e)?null:C(e)),T=async e=>{p(C(e));try{await(0,i.updateDoc)((0,i.doc)(t.Vt,Ke[e.source].collectionName,e.id),{isArchived:!e.isArchived}),!e.isArchived&&c===C(e)&&l(null)}catch(e){console.error(`Failed to archive`,e)}p(null)},E=async()=>{if(m){_(!0);try{await(0,i.deleteDoc)((0,i.doc)(t.Vt,Ke[m.source].collectionName,m.id)),c===C(m)&&l(null),h(null)}catch(e){console.error(`Failed to delete`,e)}_(!1)}},D=[{key:`all`,label:`Everything`,short:`All`},{key:`anyone`,label:Ke.anyone.filterLabel,short:`Anyone`},{key:`signedIn`,label:Ke.signedIn.filterLabel,short:`Signed in`}];return(0,s.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,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,s.jsx)(se,{children:`Inbox`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/inbox`]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,s.jsx)(`div`,{className:`flex justify-start`,children:(0,s.jsx)(le,{})}),(0,s.jsxs)(`div`,{className:`w-full flex-1 flex flex-col glass-panel rounded-2xl md:rounded-3xl p-3 sm:p-6 md:p-10 relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,s.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,s.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col`,children:v?(0,s.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[500px]`,children:(0,s.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`})}):y.length===0?(0,s.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-8 gap-6`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent shadow-inner`,children:(0,s.jsx)(t.$,{className:`w-6 h-6`})}),(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`Nothing here yet`}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/50 font-medium max-w-md`,children:`Everything people send you through a form on your site lands here.`})]}),(0,s.jsx)(`div`,{className:`w-full max-w-xl text-left`,children:(0,s.jsx)(He,{prompt:qe})})]}):(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 pb-8`,children:[(0,s.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 mb-2`,children:D.map(e=>(0,s.jsxs)(`button`,{type:`button`,onClick:()=>o(e.key),"aria-pressed":a===e.key,"aria-label":e.label,className:`h-8 md:h-9 px-3 md:px-4 rounded-full text-[12px] md:text-[12.5px] font-bold border transition-all cursor-pointer ${a===e.key?`bg-accent/10 border-accent/40 text-accent`:`border-[var(--panel-border)]/70 bg-background/60 text-foreground/60 hover:text-foreground hover:border-accent/30`}`,children:[(0,s.jsx)(`span`,{className:`sm:hidden`,children:e.short}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:e.label})]},e.key))}),x.length===0&&(0,s.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,s.jsx)(`p`,{className:`text-[14px] font-bold text-foreground/50`,children:S.length>0?`Everything here is archived.`:`Nothing matches this filter.`})}),(0,s.jsx)(t.f,{children:x.map(e=>(0,s.jsx)(tt,{item:e,isExpanded:c===C(e),onToggle:()=>w(e),onArchive:()=>T(e),onDelete:()=>h(e),busy:f===C(e)},C(e)))}),S.length>0&&(0,s.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-[var(--panel-border)]/30`,children:[(0,s.jsx)(`div`,{className:`flex justify-center`,children:(0,s.jsxs)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:`flex items-center gap-2 text-[11px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors py-2 uppercase tracking-widest cursor-pointer`,children:[u?`Hide`:`View`,` `,S.length,` archived`,(0,s.jsx)(t.St,{className:`w-3.5 h-3.5 transition-transform duration-300 ${u?`rotate-180`:``}`})]})}),(0,s.jsx)(t.f,{children:u&&(0,s.jsx)(t.d.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4`,children:(0,s.jsx)(`div`,{className:`flex flex-col gap-3`,children:S.map(e=>(0,s.jsx)(tt,{item:e,isExpanded:c===C(e),onToggle:()=>w(e),onArchive:()=>T(e),onDelete:()=>h(e),busy:f===C(e),dimmed:!0},C(e)))})})})]})]})})]})]}),(0,s.jsx)(me,{isOpen:!!m,title:`Delete this message?`,message:`This removes it for good. There is no undo — archive it instead if you only want it out of the way.`,onConfirm:E,onCancel:()=>h(null),isProcessing:g,confirmText:`Yes, delete`})]})}var rt=e=>{if(!e)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]};function it({title:e=`Drive`,subtitle:n=`/templates/drive`,backUrl:a=`/templates`,filesCollection:u=`pub_files`,config:d,customContent:f,footer:p}){let{user:m,userRole:h}=ee(),g=!!d,_=h===`admin`,v=u,y=u.startsWith(`user_`),[b,x]=(0,r.useState)([]),[S,C]=(0,r.useState)(!0),[w,T]=(0,r.useState)(null),[E,D]=(0,r.useState)(!0),[O,k]=(0,r.useState)(null),[A,j]=(0,r.useState)(!1),[M,N]=(0,r.useState)(null),[P,F]=(0,r.useState)(null),[I,L]=(0,r.useState)({}),[R,z]=(0,r.useState)(!1),[B,V]=(0,r.useState)(null),[te,H]=(0,r.useState)(``),[U,W]=(0,r.useState)(!1),[G,K]=(0,r.useState)(``),[q,J]=(0,r.useState)(!1),Y=(0,r.useRef)(null);(0,r.useEffect)(()=>{D(!0)},[w?._id]),(0,r.useEffect)(()=>{if(!(y&&!m))return C(!0),(0,i.onSnapshot)(y?(0,i.query)((0,i.collection)(t.Vt,u),(0,i.where)(`uid`,`==`,m.uid)):(0,i.query)((0,i.collection)(t.Vt,u),(0,i.orderBy)(`createdAt`,`desc`)),e=>{let t=e.docs.map(e=>({_id:e.id,...e.data()}));t.sort((e,t)=>(t.createdAt?.toMillis?.()||0)-(e.createdAt?.toMillis?.()||0)),x(t),C(!1)},e=>{console.warn(`Error listening to ${u}:`,e),C(!1)})},[u,y,m?.uid]);let ne=e=>!!m&&(e.uid===m.uid||_),re=e=>{V(e),H(e.name),K(``),z(!0)},ie=()=>{V(null),K(``),z(!0)},ae=async e=>{if(e.preventDefault(),!(!B||!te.trim()||!m)){W(!0),K(``);try{let e=`${v}/${`${Date.now()}_${B.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`,n=(0,o.ref)(t.Ut,e);await(0,o.uploadBytes)(n,B,{customMetadata:{ownerId:m.uid}});let r=await(0,o.getDownloadURL)(n);await(0,i.addDoc)((0,i.collection)(t.Vt,u),{fileName:te.trim(),fileType:B.type||`unknown`,fileSize:B.size,downloadURL:r,storagePath:e,uid:m.uid,uploaderEmail:m.email||``,createdAt:(0,i.serverTimestamp)()}),z(!1),V(null),H(``)}catch(e){K(e?.code===`storage/unauthorized`?`You do not have permission to upload here.`:e?.message||`Upload failed. Please try again.`)}W(!1)}},oe=async()=>{if(O){j(!0);try{await Promise.all([(0,o.deleteObject)((0,o.ref)(t.Ut,O.storagePath||O.downloadURL)).catch(e=>console.warn(`Storage object missing:`,e)),(0,i.deleteDoc)((0,i.doc)(t.Vt,u,O._id))]),k(null)}catch(e){console.error(`Delete failed:`,e)}j(!1)}},X=async()=>{if(!M||!M.name.trim()){N(null);return}try{await(0,i.updateDoc)((0,i.doc)(t.Vt,u,M.id),{fileName:M.name.trim()})}catch(e){console.error(`Rename failed:`,e)}N(null)},ce=(e,t)=>{navigator.clipboard.writeText(e),F(t),setTimeout(()=>F(null),2e3)},Z=(e,n=!1)=>{let r=n?`w-16 h-16`:`w-10 h-10`,i=n?`w-8 h-8`:`w-5 h-5`;return e.includes(`video`)||e.includes(`audio`)?(0,s.jsx)(`div`,{className:`${r} flex items-center justify-center bg-purple-500/10 text-purple-500 rounded-lg`,children:(0,s.jsx)(t.v,{className:i})}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,s.jsx)(`div`,{className:`${r} flex items-center justify-center bg-blue-500/10 text-blue-500 rounded-lg`,children:(0,s.jsx)(t.it,{className:i})}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,s.jsx)(`div`,{className:`${r} flex items-center justify-center bg-yellow-500/10 text-yellow-500 rounded-lg`,children:(0,s.jsx)(t.Pt,{className:i})}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,s.jsx)(`div`,{className:`${r} flex items-center justify-center bg-emerald-500/10 text-emerald-500 rounded-lg`,children:(0,s.jsx)(t.ft,{className:i})}):(0,s.jsx)(`div`,{className:`${r} flex items-center justify-center bg-foreground/5 text-foreground/40 rounded-lg`,children:(0,s.jsx)(t.rt,{className:i})})};return(0,s.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`,onDragOver:e=>{e.preventDefault(),J(!0)},onDragLeave:e=>{e.preventDefault(),J(!1)},onDrop:e=>{e.preventDefault(),J(!1),e.dataTransfer.files?.[0]&&re(e.dataTransfer.files[0])},children:[(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6`,children:[!g&&(0,s.jsxs)(c.Link,{to:a,className:`inline-flex items-center gap-2 text-[13px] font-bold text-foreground/50 hover:text-accent transition-colors mb-4`,children:[(0,s.jsx)(t.jt,{className:`w-4 h-4`}),` Back to templates`]}),(0,s.jsx)(se,{children:e}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),n]})]}),g&&(0,s.jsx)(`div`,{className:`mb-6`,children:(0,s.jsx)(le,{})}),(0,s.jsxs)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-2xl md:rounded-3xl overflow-hidden flex-1 shadow-2xl min-h-[420px] md:min-h-[520px] bg-background flex flex-col`,children:[(0,s.jsxs)(`div`,{className:`p-4 md:p-8 flex items-center justify-between gap-3 md:gap-6 border-b border-[var(--panel-border)]/50 bg-background/50`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-lg md:text-2xl font-extrabold text-foreground tracking-tight`,children:`Files`}),(0,s.jsx)(`p`,{className:`hidden sm:block text-[12px] md:text-[13px] mt-1 md:mt-2 text-foreground/60 font-medium`,children:y?`Only you can see the files you upload here.`:`Everyone who can open this page can see these files.`})]}),m&&!f&&(0,s.jsxs)(t.o,{onClick:ie,title:`Add file`,className:`flex items-center justify-center gap-2 w-9 h-9 p-0 sm:w-auto sm:h-auto sm:px-5 sm:py-2.5 rounded-xl text-[13px] font-bold shadow-md shrink-0`,children:[(0,s.jsx)(t.F,{className:`w-4 h-4`}),` `,(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:`Add file`})]})]}),f?(0,s.jsx)(`div`,{className:`fbos-content-slot p-4 md:p-8 flex-1`,children:(0,s.jsx)(f,{files:b,loading:S,user:m,uploadFile:re,deleteFile:k,openUploadModal:ie,config:d})}):(0,s.jsxs)(`div`,{className:`p-3.5 sm:p-6 md:p-8 flex-1 relative`,children:[S&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,s.jsx)(t.W,{className:`w-8 h-8 text-accent animate-spin`})}),b.length>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`sm:hidden flex flex-col divide-y divide-[var(--panel-border)]/40 border border-[var(--panel-border)] rounded-2xl overflow-hidden bg-background`,children:b.map(e=>(0,s.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:()=>T(e),"aria-label":`Preview ${e.fileName}`,className:`w-10 h-10 shrink-0 rounded-lg overflow-hidden border border-[var(--panel-border)]/50 bg-foreground/[0.02] flex items-center justify-center`,children:e.fileType.startsWith(`image/`)?(0,s.jsx)(`img`,{src:e.downloadURL,alt:``,className:`w-full h-full object-cover`}):Z(e.fileType)}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,onClick:()=>!M&&T(e),children:[M?.id===e._id?(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,value:M.name,onChange:e=>N({...M,name:e.target.value}),onBlur:X,onKeyDown:e=>{e.key===`Enter`&&X(),e.key===`Escape`&&N(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[13px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full`}):(0,s.jsx)(`span`,{className:`block text-[13px] font-bold text-foreground truncate`,children:e.fileName}),(0,s.jsx)(`span`,{className:`block text-[10.5px] text-foreground/40 font-bold uppercase tracking-wider mt-0.5`,children:rt(e.fileSize)})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:()=>ce(e.downloadURL,e._id),className:`p-2 rounded-lg text-foreground/50 hover:bg-foreground/5 hover:text-emerald-500 transition-colors`,title:`Copy link`,children:P===e._id?(0,s.jsx)(t.Ct,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.K,{className:`w-4 h-4`})}),ne(e)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{type:`button`,onClick:()=>N({id:e._id,name:e.fileName}),className:`p-2 rounded-lg text-foreground/50 hover:bg-foreground/5 hover:text-purple-500 transition-colors`,title:`Rename`,children:(0,s.jsx)(t.I,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>k(e),className:`p-2 rounded-lg text-foreground/50 hover:bg-red-500/10 hover:text-red-500 transition-colors`,title:`Delete`,children:(0,s.jsx)(t.T,{className:`w-4 h-4`})})]})]})]},e._id))}),(0,s.jsx)(`div`,{className:`hidden sm:grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:b.map(e=>(0,s.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 h-[190px] relative`,children:[(0,s.jsxs)(`div`,{className:`absolute top-2 right-2 flex flex-col gap-1 opacity-100 md:opacity-0 md: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,s.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,s.jsx)(t.lt,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ce(e.downloadURL,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:P===e._id?(0,s.jsx)(t.Ct,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.K,{className:`w-4 h-4`})}),ne(e)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),N({id:e._id,name:e.fileName})},className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-purple-500 transition-colors`,title:`Rename`,children:(0,s.jsx)(t.I,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),k(e)},className:`p-1.5 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,title:`Delete`,children:(0,s.jsx)(t.T,{className:`w-4 h-4`})})]})]}),(0,s.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`,onClick:()=>T(e),children:e.fileType.startsWith(`image/`)?(0,s.jsxs)(s.Fragment,{children:[I[e._id]!==!1&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 z-0`,children:(0,s.jsx)(t.W,{className:`w-5 h-5 text-accent animate-spin`})}),(0,s.jsx)(`img`,{src:e.downloadURL,alt:``,className:`absolute inset-0 w-full h-full object-contain p-2 transition-opacity duration-300 ${I[e._id]===!1?`opacity-100`:`opacity-0`}`,onLoad:()=>L(t=>({...t,[e._id]:!1})),onError:()=>L(t=>({...t,[e._id]:!1}))})]}):Z(e.fileType,!0)}),(0,s.jsxs)(`div`,{className:`p-3 flex flex-col justify-center flex-1 min-w-0`,onClick:()=>!M&&T(e),children:[M?.id===e._id?(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,value:M.name,onChange:e=>N({...M,name:e.target.value}),onBlur:X,onKeyDown:e=>{e.key===`Enter`&&X(),e.key===`Escape`&&N(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[12.5px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full`}):(0,s.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,s.jsx)(`span`,{className:`text-[11px] text-foreground/40 font-bold uppercase tracking-wider mt-1 select-none`,children:rt(e.fileSize)})]})]},e._id))})]}):!S&&(0,s.jsxs)(`div`,{onClick:()=>m&&z(!0),className:`min-h-[320px] flex flex-col items-center justify-center text-center cursor-pointer group`,children:[(0,s.jsx)(t.pt,{className:`w-12 h-12 text-foreground/15 mb-4`}),(0,s.jsx)(`p`,{className:`text-[20px] font-bold text-foreground/50 group-hover:text-foreground/70 transition-colors`,children:`No files yet`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium mt-1 text-foreground/40`,children:m?`Click here or drag a file in to upload`:`Sign in to upload a file`})]})]})]}),p,(0,s.jsx)(t.f,{children:R&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.d.div,{onClick:()=>!U&&z(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,s.jsxs)(t.d.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,s.jsxs)(`div`,{className:`flex items-center justify-between p-4 md:p-6 border-b border-[var(--panel-border)]/50`,children:[(0,s.jsx)(`span`,{className:`text-[16px] font-extrabold text-foreground tracking-tight`,children:`Upload a file`}),(0,s.jsx)(`button`,{onClick:()=>!U&&z(!1),className:`text-foreground/40 hover:text-foreground transition-colors`,children:(0,s.jsx)(t.g,{className:`w-5 h-5`})})]}),B?(0,s.jsxs)(`form`,{onSubmit:ae,className:`p-4 md:p-6 flex flex-col gap-5 md:gap-6`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-4 bg-foreground/[0.03] p-4 rounded-2xl border border-[var(--panel-border)]`,children:[Z(B.type),(0,s.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-4`,children:[(0,s.jsx)(`span`,{className:`text-[13px] font-bold text-foreground truncate`,children:B.name}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold uppercase tracking-wider mt-1`,children:rt(B.size)})]}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>!U&&V(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,s.jsx)(t.T,{className:`w-4 h-4`})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,s.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest pl-1`,children:`File name`}),(0,s.jsx)(`input`,{type:`text`,required:!0,value:te,onChange:e=>H(e.target.value),disabled:U,className:`no-glow 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`})]}),G&&(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded-xl p-3`,children:G}),(0,s.jsx)(t.o,{type:`submit`,isLoading:U,className:`w-full py-4 rounded-xl text-[14px] font-bold shadow-lg`,children:U?`Uploading…`:`Upload`})]}):(0,s.jsx)(`div`,{className:`p-4 md:p-6`,children:(0,s.jsxs)(`label`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),e.dataTransfer.files?.[0]&&re(e.dataTransfer.files[0])},className:`group flex flex-col items-center justify-center gap-1.5 px-6 py-12 rounded-2xl border-2 border-dashed border-[var(--panel-border)] bg-foreground/[0.015] hover:border-accent/50 hover:bg-accent/[0.03] cursor-pointer text-center transition-all`,children:[(0,s.jsx)(`span`,{className:`w-14 h-14 rounded-full bg-accent/10 text-accent flex items-center justify-center mb-2 group-hover:scale-105 transition-transform`,children:(0,s.jsx)(t.pt,{className:`w-6 h-6`})}),(0,s.jsxs)(`p`,{className:`text-[15px] font-bold text-foreground`,children:[(0,s.jsx)(`span`,{className:`text-accent`,children:`Click to upload`}),` or drag a file in`]}),(0,s.jsx)(`p`,{className:`text-[12.5px] text-foreground/45 font-medium`,children:`Pictures, documents, anything`}),(0,s.jsx)(`input`,{type:`file`,ref:Y,"aria-label":`Upload a file`,onChange:e=>e.target.files?.[0]&&re(e.target.files[0]),className:`hidden`})]})})]})]})}),typeof window<`u`&&(0,l.createPortal)((0,s.jsx)(t.f,{children:w&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,s.jsx)(t.d.div,{onClick:()=>T(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,s.jsx)(`button`,{onClick:()=>T(null),className:`absolute top-3 right-3 md:top-6 md:right-6 z-[160] w-10 h-10 md:w-12 md:h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all`,children:(0,s.jsx)(t.g,{className:`w-5 h-5`})}),(0,s.jsxs)(t.d.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between p-3.5 md:p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-3 md:pr-4`,children:[(0,s.jsx)(`span`,{className:`text-[15px] md:text-xl font-extrabold text-foreground truncate`,children:w.fileName}),(0,s.jsxs)(`span`,{className:`text-[10.5px] md:text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-0.5 md:mt-1 truncate`,children:[w.fileType,` • `,rt(w.fileSize)]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 md:gap-2 shrink-0`,children:[(0,s.jsx)(`button`,{onClick:()=>ce(w.downloadURL,w._id),className:`p-2 md:p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-emerald-500 transition-colors rounded-xl`,title:`Copy link`,children:P===w._id?(0,s.jsx)(t.Ct,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.K,{className:`w-4 h-4`})}),ne(w)&&(0,s.jsx)(`button`,{onClick:()=>{let e=w;T(null),k(e)},className:`p-2 md:p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl`,title:`Delete`,children:(0,s.jsx)(t.T,{className:`w-4 h-4`})}),(0,s.jsx)(`a`,{href:w.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2 md:p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-0.5 md:ml-1`,title:`Download`,children:(0,s.jsx)(t.lt,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-0 h-[70vh]`,children:(0,s.jsxs)(`div`,{className:`absolute inset-4 md:inset-8 flex items-center justify-center`,children:[E&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center z-50 pointer-events-none`,children:(0,s.jsx)(t.W,{className:`w-6 h-6 text-accent animate-spin`})}),w.fileType.startsWith(`image/`)?(0,s.jsx)(`img`,{onLoad:()=>D(!1),src:w.downloadURL,alt:w.fileName,className:`block max-w-full max-h-full w-auto h-auto object-contain rounded-lg transition-opacity duration-500 ${E?`opacity-0`:`opacity-100`}`}):w.fileType.startsWith(`video/`)?(0,s.jsx)(`video`,{onLoadedData:()=>D(!1),src:w.downloadURL,controls:!0,className:`max-w-full max-h-full rounded-lg transition-opacity duration-500 ${E?`opacity-0`:`opacity-100`}`}):w.fileType===`application/pdf`?(0,s.jsx)(`iframe`,{onLoad:()=>D(!1),src:w.downloadURL,className:`w-full h-full border-none bg-white rounded-lg transition-opacity duration-500 ${E?`opacity-0`:`opacity-100`}`,title:`PDF preview`}):(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-foreground/40 text-center`,onClick:()=>D(!1),children:[(0,s.jsx)(t.rt,{className:`w-24 h-24 mb-6 opacity-40`}),(0,s.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview unavailable`}),(0,s.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This format cannot be previewed. Download it instead.`})]})]})})]})]})}),document.body),(0,s.jsx)(me,{isOpen:!!O,title:`Delete file`,message:(0,s.jsxs)(s.Fragment,{children:[`Delete `,(0,s.jsx)(`strong`,{className:`text-foreground block my-1 break-words max-w-full text-center`,children:O?.fileName}),` This cannot be undone.`]}),onConfirm:oe,onCancel:()=>k(null),isProcessing:A,confirmText:`Yes, delete`}),(0,s.jsx)(t.f,{children:q&&(0,s.jsx)(t.d.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,s.jsxs)(`div`,{className:`w-full max-w-lg aspect-video bg-background/80 border-2 border-dashed border-accent rounded-[40px] shadow-2xl flex flex-col items-center justify-center gap-6`,children:[(0,s.jsx)(`div`,{className:`w-20 h-20 rounded-full bg-accent/10 flex items-center justify-center text-accent`,children:(0,s.jsx)(t.pt,{className:`w-10 h-10 animate-bounce`})}),(0,s.jsx)(`span`,{className:`text-[24px] font-extrabold text-foreground tracking-tight`,children:`Drop to upload`})]})})})]})}var at=[`mem_files`,`user_files`,`admin_files`],ot=e=>!e.sourceTab;function st(){let[e,n]=(0,r.useState)(null),[a,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=!1;return Promise.all(at.map(async e=>{try{return(await(0,i.getDocs)((0,i.collection)(t.Vt,e))).docs.map(t=>({collectionName:e,id:t.id,...t.data()}))}catch{return[]}})).then(t=>{e||n(t.flat())}),()=>{e=!0}},[]);let h=async()=>{if(!e)return;u(!0),f(``);let r=0;for(let n of e)try{let e=n.storagePath||n.downloadURL;e&&ot(n)&&await(0,o.deleteObject)((0,o.ref)(t.Ut,e)).catch(()=>{}),await(0,i.deleteDoc)((0,i.doc)(t.Vt,n.collectionName,n.id)),m(e=>e+1)}catch(e){r+=1,console.error(`Could not delete ${n.collectionName}/${n.id}:`,e)}r>0?(f(`${r} file${r===1?``:`s`} could not be deleted. Reload and try again.`),n((await Promise.all(at.map(async e=>{try{return(await(0,i.getDocs)((0,i.collection)(t.Vt,e))).docs.map(t=>({collectionName:e,id:t.id,...t.data()}))}catch{return[]}}))).flat())):n([]),u(!1),c(!1)};if(!e||e.length===0)return null;let g=e.filter(ot).length,_=at.map(t=>({name:t,n:e.filter(e=>e.collectionName===t).length})).filter(e=>e.n>0);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`mt-6 glass-panel border border-amber-500/25 bg-amber-500/[0.03] rounded-2xl md:rounded-3xl p-4 md:p-8`,children:[(0,s.jsxs)(`h3`,{className:`text-[17px] font-extrabold text-foreground tracking-tight mb-2`,children:[e.length,` leftover record`,e.length===1?``:`s`,` from the old Drive`]}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed mb-3 max-w-2xl`,children:`Drive used to have Internal, User and Admin folders. They are gone — this page is the only built-in folder now, and each page you have built keeps its own files. Nothing reads these records any more.`}),(0,s.jsxs)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed mb-3 max-w-2xl`,children:[g>0?`${g} ${g===1?`was`:`were`} uploaded through the old Drive screen, so ${g===1?`its file is`:`their files are`} deleted too. `:``,e.length-g>0?`${e.length-g} belong to files a page still shows, so only the leftover record goes — the ${e.length-g===1?`file stays`:`files stay`} where ${e.length-g===1?`it is`:`they are`}.`:``]}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium mb-5`,children:_.map(e=>`${e.n} in ${e.name}`).join(` · `)}),d&&(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded-xl p-3 mb-4`,children:d}),(0,s.jsxs)(`button`,{onClick:()=>c(!0),disabled:l,className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-bold bg-red-500/10 hover:bg-red-500/20 text-red-500 border border-red-500/20 transition-colors disabled:opacity-50`,children:[l?(0,s.jsx)(t.W,{className:`w-4 h-4 animate-spin`}):(0,s.jsx)(t.T,{className:`w-4 h-4`}),l?`Deleting ${p} of ${e.length}…`:`Clean up all ${e.length} permanently`]})]}),(0,s.jsx)(me,{isOpen:a,title:`Delete the old Drive files`,message:(0,s.jsxs)(s.Fragment,{children:[`This permanently deletes `,(0,s.jsxs)(`strong`,{className:`text-foreground`,children:[e.length,` leftover record`,e.length===1?``:`s`]}),` `,`from `,_.map(e=>e.name).join(`, `),g>0&&(0,s.jsxs)(s.Fragment,{children:[`, along with the `,(0,s.jsxs)(`strong`,{className:`text-foreground`,children:[g,` file`,g===1?``:`s`]}),` uploaded through the old Drive screen`]}),`. It cannot be undone, and it covers every user's uploads, not only your own. Files that a page still shows are left alone.`]}),onConfirm:h,onCancel:()=>c(!1),isProcessing:l,confirmText:`Yes, delete them`})]})}function ct(){let{isAdmin:e}=ee();return(0,s.jsx)(it,{title:`Assets`,subtitle:`/assets`,filesCollection:`pub_files`,config:{isAdmin:!0,pageId:`assets`},footer:e?(0,s.jsx)(st,{}):null})}function lt(){let e=[{id:`form`,title:`Inline Form`,description:`A contact form built straight into the page, so people can write to you without leaving it.`,icon:t.q,path:`/templates/inline_form`,setup:`On your Pages screen, add a page for Anyone, give it an address and a name, and pick your form in its Form setting.`,prompt:`Show my form built into the page, not as a pop-up, with a short friendly line above it. After sending, show a thank-you message.`},{id:`popup`,title:`Modal Popup Form`,description:`A button that opens the form in a popup over the page, with the background softly blurred.`,icon:t.Ft,path:`/templates/popup_form`,setup:`On your Pages screen, add a page for Anyone, give it an address and a name, and pick your form in its Form setting.`,prompt:`Put a button that says Start an enquiry which opens my form as a pop-up over the page. After sending, show a thank-you message.`},{id:`confirmation`,title:`Action Confirmation`,description:`A short "are you sure?" step that appears before anything is deleted or sent.`,icon:t.wt,path:`/templates/confirmation`,setup:`Nothing to add — this one is asked for on any page you already have.`,prompt:`On every page of mine where something can be deleted, ask me to confirm first with a pop-up that says Delete this? and two buttons, Cancel and Delete, using the confirmation template as the reference.`},{id:`board`,title:`Board View`,description:`Cards in columns that you drag from one stage to the next, for work in progress.`,icon:t.Q,path:`/templates/board`,setup:`On your Pages screen, add a page for Your team and pick Board as its starting layout.`,prompt:`A board with the columns To do, In progress and Done. Each card has a client name, a contact email and a short note, and I can drag cards between columns.`},{id:`table`,title:`Data Table`,description:`Rows and columns for longer lists, with sorting and actions on many rows at once.`,icon:t.E,path:`/templates/table`,setup:`On your Pages screen, add a page for Your team and pick Table as its starting layout.`,prompt:`A table with the columns name, email, phone and status (Lead, Active, Past). Everyone on the team sees the same rows and can add, edit and delete them.`},{id:`calendar`,title:`Calendar View`,description:`A month at a time, for anything that belongs on a date — bookings, shifts, deadlines.`,icon:t.Et,path:`/templates/calendar`,setup:`On your Pages screen, add a page for Your team and pick Calendar as its starting layout.`,prompt:`A month calendar of appointments. Each appointment has a client name, a start time, a length in minutes and a note. Everyone on the team sees the same calendar.`},{id:`drive`,title:`Drive View`,description:`A file library with upload, preview, rename and delete. The demo writes to the Assets folder, so uploading from here is something only admins can do.`,icon:t.tt,path:`/templates/drive`,setup:`On your Pages screen, add a page for Admins only and pick Files as its starting layout.`,prompt:`A file library where admins can upload, preview, rename and delete files.`}];return(0,s.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,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-10 text-center`,children:[(0,s.jsx)(`h1`,{className:`w-fit mx-auto inline-block text-[26px] sm:text-3xl md:text-4xl lg:text-5xl leading-[1.1] font-extrabold tracking-tight mb-4 text-gradient animate-float`,children:`What your assistant can build`}),(0,s.jsx)(`p`,{className:`text-foreground/60 text-lg font-medium max-w-2xl mx-auto`,children:`Every layout below already works. Look at one, add the page on your Pages screen the way the card says, and use the words underneath as what you would like to see on it.`}),(0,s.jsxs)(`p`,{className:`text-foreground/50 text-[13.5px] font-medium max-w-2xl mx-auto mt-3`,children:[`New here?`,` `,(0,s.jsx)(c.Link,{to:`/guide`,className:`text-accent font-bold hover:underline`,children:`Start with the guide`}),`.`]})]}),(0,s.jsxs)(`div`,{className:`w-full max-w-4xl mx-auto flex flex-col gap-4 relative`,children:[(0,s.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,n)=>{let r=e.icon;return(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:n*.05},className:`flex flex-col gap-3 w-full p-4 md:p-6 glass-panel border border-[var(--panel-border)] rounded-2xl hover:border-accent/40 transition-all duration-300 group`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-4 md:gap-6`,children:[(0,s.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,s.jsx)(r,{className:`w-5 h-5`})}),(0,s.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,s.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground`,children:e.title}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium leading-snug`,children:e.description})]}),(0,s.jsxs)(c.Link,{to:e.path,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 hover:-translate-y-0.5`,children:[`View `,(0,s.jsx)(`span`,{className:`font-black leading-none ml-0.5`,children:`→`})]})]}),(0,s.jsx)(He,{title:e.id===`confirmation`?`Ask your assistant for this`:`Use this as what you would like to see on the page`,description:e.setup,prompt:e.prompt,compact:!0}),(0,s.jsxs)(c.Link,{to:e.path,className:`md:hidden inline-flex items-center justify-center gap-2 text-[13px] font-bold px-5 py-2.5 rounded-xl btn-primary transition-transform shadow-lg`,children:[`View `,(0,s.jsx)(`span`,{className:`font-black leading-none ml-0.5`,children:`→`})]})]},e.id)})]})]})}var ut=`Xl271wWblkY`,dt=[{term:`Who it is for`,body:`One of the four audiences below. It decides who can open the page and which menu it appears in. Ask the chat only for pages anyone can visit — dashboard pages are added on the Pages screen, see the three steps below.`,example:`Create a page anyone can visit.`},{term:`The web address`,body:`Starts with a slash. It is the address people type or click, and it never changes unless you change it on the Pages screen.`,example:`Web address: /pricing.`},{term:`The name in the menu`,body:`The word people click to get there.`,example:`Name in the site menu: Pricing.`},{term:`The heading`,body:`The title at the top of the page.`,example:`Heading: Our prices.`},{term:`What is on it`,body:`The sections from top to bottom, with the exact words for every heading and button, and what each button does.`,example:`Three plans side by side, each with a price and a button that says Choose this plan.`},{term:`Where to start`,body:`For a page in the dashboard you pick this on the Pages screen when you add it — board, table, calendar, files, or from scratch. In the chat, only say whether people can upload files.`,example:`No file uploads.`},{term:`The questions`,body:`For a form: every question, its kind, and whether it is required. Kinds: short text, long text, email, phone, number, money, date, yes-no, or choose one with the choices listed.`,example:`Budget (money in dollars, optional).`},{term:`After sending`,body:`Stay and show a message, go to the home page, or go to another page by its web address.`,example:`After sending, stay on the page and show Thanks, we will reply today.`},{term:`What to leave alone`,body:`End with "Build only this" and name anything that must not change. Without it the assistant adds pages, sample data and sections you did not ask for.`,example:`Build only this — no other pages, forms or sample data.`}],ft=[{name:`Anyone`,how:`Say: a page anyone can visit`,who:`Everybody, signed in or not. This is your public website, and the page shows in the site menu.`},{name:`Signed-in users`,how:`Pick it when you add the page`,who:`Anyone who registers. Each person sees only their own information, never anyone else’s.`},{name:`Your team`,how:`Pick it when you add the page`,who:`Only people you marked as team members on the Users screen, plus admins. Everyone on it sees the same information.`},{name:`Admins only`,how:`Pick it when you add the page`,who:`You, and anyone you marked as an admin.`}],pt=[{title:`Add the page on the Pages screen`,body:`Press Add a page and pick who it is for — Your team, Signed-in users or Admins only. Give it a name, a web address and a starting layout: board, table, calendar, files, or from scratch.`},{title:`If it needs a form, add it right there`,body:`In the page’s Form box pick A new form made for this page, say what it should ask, and name the button that opens it. Who can fill it in follows who the page is for.`},{title:`Say what you want on it, then copy the sentence`,body:`On the page’s row, write what you would like to see on the page in your own words — the examples below show what that can sound like. The finished sentence appears under it; copy it and paste it into the chat. That is the whole hand-over.`},{title:`Change it later with Edit with AI`,body:`Once a page is built, press Edit with AI on its row. The row swaps to three boxes — what to add, what to change, what to take off — and hands you a different sentence: one that edits the page you already have. Nothing you did not mention is touched.`}],mt=[{screen:`Pages`,path:`/pages`,body:`Add a page for your team, signed-in users or admins, and give it a form if it needs one. Rename a page, change its web address or icon, reorder it, hide it or delete it — and press Edit with AI on any row to copy the sentence that changes a page you already have.`},{screen:`Forms`,path:`/forms`,body:`See every form. Add a question or change a form’s title and button text after it is built — forms are created with their pages.`},{screen:`Theme`,path:`/theme`,body:`Colours, typeface, corner rounding, the logo, and whether the site opens light or dark.`},{screen:`Users`,path:`/users`,body:`Mark a person as a team member or an admin.`},{screen:`Inbox`,path:`/inbox`,body:`Read every answer people sent through your forms.`}],ht=[{title:`One page or one form per message`,body:`Describe it completely, then send. Ask for the next one when the first is live.`},{title:`Give every detail up front`,body:`If a part of the recipe is missing, the assistant stops to ask for it. Answer with just that part.`},{title:`Use the exact words you want to see`,body:`Headings, button labels, choices in a list. The assistant copies them; it does not improve them.`},{title:`When something is wrong, describe your screen`,body:`The web address, what you clicked, what happened, what you expected. Not what you think the cause is.`},{title:`Never accept homework`,body:`The assistant makes every change itself. If a reply ends with something for you to edit, paste or run, answer: "Do that for me."`}],gt=[{id:`website`,title:`Pages anyone can visit`,description:`Your public website. They appear in the site menu.`,prompts:[{title:`A pricing page with a quote form`,prompt:`Create a page anyone can visit.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-DYteiM-1.cjs`),t=require(`./ContactPopup-BEjdVo2u.cjs`),n=require(`./PhoneInputField-CQ7ylxOC.cjs`);let r=require(`react`);r=e.i(r,1);let i=require(`firebase/firestore`),a=require(`firebase/auth`),o=require(`firebase/storage`),s=require(`react/jsx-runtime`),c=require(`react-router-dom`),l=require(`react-dom`);var u=Object.assign({"./contactForm.config.ts":t.Yt,"./supportForm.config.ts":t.qt}),d={};for(let e in u){let t=u[e];if(!t)continue;let n=null;for(let e in t)if(e.endsWith(`FormConfig`)||e.endsWith(`Config`)){n=t[e];break}if(!n&&t?.default&&(n=t.default),!n)continue;let r=e.replace(`./`,``).replace(`.config.ts`,``).replace(/Form$/,``).toLowerCase(),i={...n,systemName:n.systemName||r};d[r]=i,i.systemName&&(d[i.systemName]=i,d[i.systemName.toLowerCase()]=i)}if(typeof window<`u`){let e=window.__FBOS_FORMS__||{};window.__FBOS_FORMS__={...d,...e}}var f=Object.assign({}),p=Object.assign({}),m={};for(let e in f){let t=f[e];if(!t)continue;let n=null;for(let e in t)if(e.endsWith(`TabConfig`)||e.endsWith(`Config`)){n=t[e];break}if(!n&&t?.default&&(n=t.default),!n)continue;let r=e.replace(`./`,``).replace(`.config.ts`,``).replace(/Tab$/,``).toLowerCase(),i={config:{...n,pageId:n.pageId||r,tabName:n.tabName||n.title||r},isPublic:!1};m[r]=i,i.config.pageId&&(m[i.config.pageId]=i,m[i.config.pageId.toLowerCase()]=i)}for(let e in p){let t=p[e];if(!t)continue;let n=null;for(let e in t)if(e.endsWith(`PageConfig`)||e.endsWith(`Config`)){n=t[e];break}if(!n&&t?.default&&(n=t.default),!n)continue;let r=e.replace(`./`,``).replace(`.config.ts`,``).replace(/Page$/,``).toLowerCase(),i={config:{...n,pageId:n.pageId||r,pageName:n.pageName||n.title||r},isPublic:!0};m[r]=i,i.config.pageId&&(m[i.config.pageId]=i,m[i.config.pageId.toLowerCase()]=i)}if(typeof window<`u`){let e=window.__FBOS_PAGES__||{};window.__FBOS_PAGES__={...m,...e}}var h=()=>{document.querySelectorAll(`.fbos-content-slot style`).forEach(e=>{e.disabled&&e.media===`not all`||(e.disabled=!0,e.media=`not all`,typeof console<`u`&&console.warn(`FirebaseOS: a <style> tag inside a content file is global CSS and was disabled — style with theme classes (bg-background, text-foreground, glass-panel, btn-primary) instead.`))})},g=()=>{(0,r.useEffect)(()=>{if(typeof document>`u`||typeof MutationObserver>`u`)return;h();let e=new MutationObserver(h);return e.observe(document.body,{childList:!0,subtree:!0}),()=>e.disconnect()},[])},_=[`free`,`internal`,`admin`],v=[`user`,`internal`,`admin`],y={free:`Free`,internal:`Internal`,admin:`Admin`},b={free:`Pages for anyone, plus their own pages. Your team’s pages stay hidden.`,internal:`Everything a signed-in user sees, plus every page for your team.`,admin:`Full access, including Users, Pages, Forms, Inbox, Theme and Assets.`};function x(e){return e===`admin`?`admin`:e===`internal`?`internal`:`free`}function S(e){return e===`free`?`user`:e}var C=e=>x(e)===`admin`,w=e=>x(e)!==`free`;function T(e){return e===`admin`?`admin`:e===`public`?`public`:e===`internal`||e===`shared`?`internal`:`user`}function E(e){let t=T(e);return t===`public`?`user`:t}function D(e,t){switch(T(t)){case`public`:return!0;case`admin`:return C(e);case`internal`:return w(e);case`user`:return!0}}function O(e,t=!0){if(!t)return`guest`;let n=x(e);return n===`free`?`user`:n}function k(e){switch(T(e)){case`public`:return[`admin`,`internal`,`user`,`guest`];case`admin`:return[`admin`];case`internal`:return[`admin`,`internal`];case`user`:return[`admin`,`internal`,`user`]}}var A=(0,r.createContext)({user:null,userRole:null,accessLevel:`free`,isInternal:!1,isAdmin:!1,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 j({children:e}){let[n,o]=(0,r.useState)(null),[c,l]=(0,r.useState)(null),[u,d]=(0,r.useState)(!1),[f,p]=(0,r.useState)(!0),[m,h]=(0,r.useState)(!1),g=r.default.useRef(null),_=r.default.useRef(null),v=r.default.useRef(new Set),y=e=>(0,i.updateDoc)((0,i.doc)(t.Ht,`user_profiles`,e),{role:`admin`}),b=async e=>{if(!v.current.has(e)){v.current.add(e);try{await y(e)}catch(n){if(n?.code!==`permission-denied`){console.error(`Error claiming the admin role:`,n);return}try{if(!t.Vt.currentUser)return;await t.Vt.currentUser.getIdToken(!0),await y(e)}catch(e){e?.code!==`permission-denied`&&console.error(`Error claiming the admin role:`,e)}}}};return(0,r.useEffect)(()=>{let e;if(!t.Vt){p(!1),h(!0);return}(0,a.getRedirectResult)(t.Vt).catch(()=>{});let n=(0,a.onAuthStateChanged)(t.Vt,async n=>{if(n?.uid===_.current&&m){o(n);return}if(_.current=n?.uid||null,n){let r=localStorage.getItem(`fbos_role_${n.uid}`);r&&(l(r),h(!0),p(!1)),console.log(`[AuthContext] 1. onAuthStateChanged fired for user:`,n.uid),o(n);try{let r=(0,i.doc)(t.Ht,`user_profiles`,n.uid),a=(await(0,i.getDoc)(r)).data()||{};(0,i.setDoc)(r,{uid:n.uid,email:n.email,displayName:n.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,i.onSnapshot)(r,e=>{if(e.exists()){let r=e.data(),i=r.role||`user`;!r.role&&t.Vt.currentUser?.emailVerified&&b(n.uid),g.current===null&&(g.current=i),l(i),localStorage.setItem(`fbos_role_${n.uid}`,i),d(r.inactive===!0)}h(!0),p(!1)},e=>{console.warn(`[AuthContext] user_profiles snapshot error (safe to ignore during auth transition):`,e),h(!0),p(!1)})}catch(e){console.error(`[AuthContext] ERROR in auth resolution:`,e),h(!0),p(!1)}}else console.log(`[AuthContext] No user currently signed in.`),o(null),l(null),d(!1),h(!0),p(!1),g.current=null,e&&e()});return()=>{n(),e&&e()}},[]),(0,r.useEffect)(()=>{if(!n?.emailVerified||c===`admin`)return;let e=!1;return(0,i.getDoc)((0,i.doc)(t.Ht,`user_profiles`,n.uid)).then(t=>{!e&&t.exists()&&!t.data().role&&b(n.uid)}).catch(()=>{}),()=>{e=!0}},[n?.uid,n?.emailVerified,c]),(0,s.jsx)(A.Provider,{value:{user:n,userRole:c,accessLevel:x(c),isInternal:w(c),isAdmin:C(c),loading:f,signOut:async()=>{await(0,a.signOut)(t.Vt),o(null)},registerUser:async(e,n,r,o)=>{let{createUserWithEmailAndPassword:s}=await import(`firebase/auth`),{user:c}=await s(t.Vt,e,n),l=`${r} ${o}`.trim();await(0,a.updateProfile)(c,{displayName:l});try{await c.getIdToken(!0),await(0,i.setDoc)((0,i.doc)(t.Ht,`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,a.sendEmailVerification)(c)},refreshUser:async()=>{t.Vt.currentUser&&(await t.Vt.currentUser.reload(),o(Object.assign(Object.create(t.Vt.currentUser),{photoURL:t.Vt.currentUser.photoURL,displayName:t.Vt.currentUser.displayName,email:t.Vt.currentUser.email,emailVerified:t.Vt.currentUser.emailVerified})))},userInactive:u,roleResolved:m},children:e})}var ee=()=>(0,r.useContext)(A);function M(){return(typeof window<`u`?window.__FBOS_PAGES__:null)||{}}function N(e=M()){let t=new Set,n=[];for(let[r,i]of Object.entries(e))!i||t.has(i)||(t.add(i),n.push([r,i]));return n}function P(){let[e,n]=(0,r.useState)(!1),[a,o]=(0,r.useState)([]),l=(0,r.useRef)(null),u=(0,r.useRef)(null),[d,f]=(0,r.useState)(null),p=(0,c.useNavigate)();(0,r.useEffect)(()=>{function e(e){l.current&&!l.current.contains(e.target)&&n(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let m=(0,r.useRef)({users:[],submissions:[],requests:[]}),h=(e,t)=>{m.current[e]=t;let n=[...m.current.users,...m.current.submissions,...m.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)}),o(n.slice(0,8))},g=(e,t)=>{console.warn(`AdminNotifications: ${e} are not readable by this account.`,t),h(e,[])};(0,r.useEffect)(()=>{let e=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Ht,`user_profiles`),(0,i.orderBy)(`createdAt`,`desc`),(0,i.limit)(5)),e=>{h(`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}}))},e=>g(`users`,e)),n=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Ht,`user_submissions`),(0,i.orderBy)(`submittedAt`,`desc`),(0,i.limit)(5)),e=>{h(`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}}))},e=>g(`submissions`,e)),r=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Ht,`user_requests`),(0,i.orderBy)(`submittedAt`,`desc`),(0,i.limit)(5)),e=>{h(`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}}))},e=>g(`requests`,e));return()=>{e(),n(),r()}},[]);let[_,v]=(0,r.useState)(()=>typeof window<`u`?parseInt(localStorage.getItem(`admin_notifications_last_read`)||`0`,10):0),y=()=>{let t=!e;if(n(t),t){let e=u.current?.getBoundingClientRect();f(typeof window<`u`&&window.innerWidth<640&&e?e.bottom+8:null);let t=Date.now();v(t),typeof window<`u`&&localStorage.setItem(`admin_notifications_last_read`,t.toString())}},b=a.some(e=>{if(!e.time)return!0;let t=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return t>_||isNaN(t)}),x=e=>{n(!1),p(e===`user`?`/users`:e===`submission`?`/submissions`:`/requests`)},S=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,s.jsxs)(`div`,{className:`relative z-50 flex-shrink-0`,ref:l,children:[(0,s.jsxs)(`button`,{ref:u,onClick:y,className:`w-9 h-9 rounded-xl border border-[var(--panel-border)] transition-all relative text-foreground/60 hover:bg-foreground/5 hover:text-foreground flex items-center justify-center shadow-sm cursor-pointer`,"aria-label":`Admin Notifications`,children:[(0,s.jsx)(t.Ot,{className:`w-4 h-4`}),b&&(0,s.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-red-500 rounded-full animate-pulse`})]}),(0,s.jsx)(t.p,{children:e&&(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`${d===null?`absolute top-full mt-2 right-0`:`fixed right-4`} w-[min(320px,calc(100vw-2rem))] md:w-[400px] glass-popover border border-[var(--panel-border)] rounded-2xl z-50 flex flex-col origin-top-right overflow-hidden`,style:d===null?void 0:{top:d},children:[(0,s.jsxs)(`div`,{className:`px-4 border-b border-[var(--panel-border)]/50 pb-3 pt-4 flex items-center justify-between`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[14px] text-foreground tracking-wide`,children:`Notifications`}),(0,s.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,s.jsx)(`div`,{className:`max-h-[350px] overflow-y-auto w-full p-2 flex flex-col gap-1`,children:a.length===0?(0,s.jsx)(`div`,{className:`p-6 text-center text-foreground/40 text-[13px] font-medium`,children:`No recent activity.`}):a.map(e=>(0,s.jsxs)(`button`,{onClick:()=>x(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,s.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,s.jsx)(t.x,{className:`w-4 h-4`}):e.type===`submission`?(0,s.jsx)(t.H,{className:`w-4 h-4`}):(0,s.jsx)(t.gt,{className:`w-4 h-4`})}),(0,s.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-2`,children:[(0,s.jsx)(`span`,{className:`text-[13px] font-semibold text-foreground group-hover:text-accent transition-colors truncate`,children:e.title}),(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/60 truncate`,children:e.subtitle}),(0,s.jsx)(`span`,{className:`text-[10px] font-mono tracking-wide text-foreground/40 mt-1`,children:S(e.time)})]})]},e.id))})]})})]})}var F=[{id:`guide`,hidden:!1},{id:`contact`,hidden:!1},{id:`templates`,hidden:!1},{id:`setup`,hidden:!1}],I={drive:`assets`,submissions:`inbox`,requests:`inbox`},L=e=>{let t=(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden}).map(e=>({...e,id:I[e.id]||e.id}));return t.filter((e,n)=>t.findIndex(t=>t.id===e.id)===n)},R=[{id:`pages`,hidden:!1},{id:`forms`,hidden:!1},{id:`inbox`,hidden:!1},{id:`users`,hidden:!1},{id:`theme`,hidden:!1},{id:`assets`,hidden:!1}],z={route:`/support`,template:`popup_form`,form:`support`,tabName:`Support`,iconName:``},B={guide:{label:`Guide`,path:`/guide`},templates:{label:`Templates`,path:`/templates`},setup:{label:`Setup`,path:`/setup`},contact:{label:`Contact`,path:`/contact`}};function V({customMenu:e,standalone:n}){let{user:a,userRole:o,signOut:l}=ee(),u=C(o),d=x(o),f=d===`free`?`Free User`:y[d],p=(0,c.useNavigate)(),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(null),[v,b]=(0,r.useState)(!1),[S,w]=(0,r.useState)(!1),[T,E]=(0,r.useState)(!1),D=a?.displayName||a?.email?.split(`@`)[0]||`User`,O=D.charAt(0).toUpperCase()+D.slice(1),{theme:k,toggleTheme:A,activeConfig:j}=t.Rt(),M=async()=>{await l(),p(`/`),h(!1)},[I,R]=(0,r.useState)({...B}),[V,te]=(0,r.useState)(F);(0,r.useEffect)(()=>{if(!t.Ht)return;let e=(0,i.onSnapshot)((0,i.collection)(t.Ht,`sys_pages`),e=>{let t={...B};for(let[e,n]of N()){if(!n.isPublic)continue;let r=n.config||{};if(r.enabled===!1)continue;let i=r.route?r.route.startsWith(`/`)?r.route:`/`+r.route:`/`+e;t[e]={label:r.pageName||r.pageTitle||r.title||e,path:i}}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}}),R(t)},e=>{console.warn(`sys_pages snapshot error (safe to ignore during auth transition):`,e)}),n=(0,i.onSnapshot)((0,i.doc)(t.Ht,`sys_configs`,`page_order`),e=>{te(e.exists()&&Array.isArray(e.data().order)?L(e.data().order):F)},e=>{console.warn(`page_order snapshot error (safe to ignore during auth transition):`,e)}),r=(0,i.onSnapshot)((0,i.doc)(t.Ht,`sys_tabs`,`support`),e=>{e.exists()&&e.data().pageName&&U(e.data().pageName)},e=>{console.warn(`support snapshot error (safe to ignore during auth transition):`,e)});return()=>{e(),n(),r()}},[]);let[H,U]=(0,r.useState)(z.tabName),W=(()=>{let e=new Set(V.filter(e=>e.hidden).map(e=>e.id)),t=new Set,n=[];return V.forEach(e=>{if(e.hidden||e.id===`home`)return;let r=I[e.id];r&&(n.push({label:r.label,path:r.path}),t.add(e.id))}),Object.entries(I).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})(),G=e||W,K=(0,r.useRef)(null),q=(0,r.useRef)(null),[J,Y]=(0,r.useState)(G.length);(0,r.useEffect)(()=>{if(n)return;let e=()=>{let e=K.current,t=q.current;if(!e||!t)return;let n=e.clientWidth,r=t.querySelectorAll(`[data-measure-nav]`);if(r.length===0){Y(G.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){Y(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?28:0);if(i+50>n)break;o=i,s++}Y(Math.max(s,1))},t=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(t);let r=new ResizeObserver(()=>requestAnimationFrame(e));return K.current&&r.observe(K.current),()=>{cancelAnimationFrame(t),r.disconnect()}},[G.map(e=>e.label).join(`|`),n,G.length]);let ne=G.slice(0,J),re=G.slice(J);return(0,s.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,s.jsx)(`div`,{className:`flex items-center min-w-0 z-50`,children:(0,s.jsxs)(c.Link,{to:`/`,className:`flex items-center gap-2.5 md:gap-3 group cursor-pointer z-50 min-w-0`,children:[(0,s.jsx)(`div`,{className:`w-9 h-9 rounded-lg glass-panel flex items-center justify-center glow-hover shadow-lg transition-transform duration-500 group-hover:rotate-180 group-active:scale-95 overflow-hidden shrink-0`,children:j?.logoUrl?(0,s.jsx)(`img`,{src:j.logoUrl,alt:`Logo`,className:`w-full h-full object-contain`}):(0,s.jsx)(t.dt,{className:`w-4 h-4 text-accent`})}),(0,s.jsx)(`span`,{className:`font-bold text-[18px] md:text-[20px] tracking-tight text-gradient transition-all duration-300 drop-shadow-sm truncate`,children:j?.appName||``})]})}),(0,s.jsx)(t.p,{children:v&&(0,s.jsx)(t.t,{formId:`contact`,onClose:()=>b(!1)})}),(0,s.jsx)(t.p,{children:S&&(0,s.jsx)(t.t,{formId:`support`,onClose:()=>w(!1)})}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2.5 md:gap-4 z-50 relative ml-auto flex-1 justify-end`,children:[!n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{ref:q,"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:G.map((e,n)=>(0,s.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,s.jsx)(t.Ct,{className:`w-3 h-3`})]},e.path||n))}),(0,s.jsxs)(`div`,{className:`max-sm:hidden flex items-center gap-7 mr-6 w-full max-w-full justify-end relative`,ref:K,children:[ne.map((e,n)=>(0,s.jsxs)(`div`,{className:`relative shrink-0`,onMouseEnter:()=>_(e.label),onMouseLeave:()=>_(null),children:[e.path?(0,s.jsxs)(c.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,s.jsx)(t.Ct,{className:`w-3 h-3`})]}):(0,s.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,s.jsx)(t.Ct,{className:`w-3 h-3`})]}),e.submenu&&g===e.label&&(0,s.jsx)(`div`,{className:`absolute top-[100%] left-0 pt-2 z-50`,children:(0,s.jsx)(t.f.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,s.jsx)(c.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,s.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`}-${n}`)),re.length>0&&(0,s.jsxs)(`div`,{className:`relative flex items-center shrink-0`,onMouseEnter:()=>h(`overflow`),children:[(0,s.jsx)(`button`,{onClick:()=>h(m===`overflow`?!1:`overflow`),className:`p-1 rounded-lg transition-colors flex items-center ${m===`overflow`?`bg-foreground/5 text-accent`:`text-foreground/50 hover:bg-foreground/5 hover:text-accent`}`,children:(0,s.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,s.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,s.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`}),(0,s.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`})]})}),(0,s.jsx)(t.p,{children:m===`overflow`&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>h(!1)}),(0,s.jsx)(t.f.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 glass-popover border border-[var(--panel-border)] rounded-2xl flex flex-col py-2 z-50 origin-top-right`,children:re.map((e,t)=>e.path?(0,s.jsx)(c.Link,{to:e.path,onClick:()=>h(!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,s.jsx)(`button`,{onClick:()=>{e.action&&e.action(),h(!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))})]})})]})]})]}),!n&&!a&&(0,s.jsxs)(s.Fragment,{children:[j?.showThemeToggle&&(0,s.jsx)(`button`,{onClick:A,className:`w-9 h-9 rounded-xl border border-[var(--panel-border)] hover:bg-foreground/5 transition-all text-foreground/60 hover:text-foreground flex items-center justify-center shadow-sm shrink-0 cursor-pointer`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,s.jsx)(t.O,{className:`w-4 h-4`}):(0,s.jsx)(t.B,{className:`w-4 h-4`})}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2.5 shrink-0`,children:[(0,s.jsx)(c.Link,{to:`/login`,className:`max-sm:hidden 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,s.jsx)(c.Link,{to:`/register`,className:`max-sm:hidden 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,s.jsxs)(`div`,{className:`relative sm:hidden`,children:[(0,s.jsx)(`button`,{onClick:()=>h(m===`guest`?!1:`guest`),className:`p-2 rounded-xl glass-panel glow-hover border transition-all ${m===`guest`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,s.jsx)(t.V,{className:`w-5 h-5 text-accent/80`})}),(0,s.jsx)(t.p,{children:m===`guest`&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>h(!1)}),(0,s.jsxs)(t.f.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-popover border border-[var(--panel-border)] rounded-2xl z-50 flex flex-col gap-1 origin-top-right`,children:[(0,s.jsxs)(c.Link,{to:`/guide`,onClick:()=>h(!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,s.jsx)(t._t,{className:`w-4 h-4 text-accent/70`}),` `,(0,s.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Guide`})]}),(0,s.jsxs)(c.Link,{to:`/templates`,onClick:()=>h(!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,s.jsx)(t.J,{className:`w-4 h-4 text-accent/70`}),` `,(0,s.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Templates`})]}),(0,s.jsxs)(c.Link,{to:`/setup`,onClick:()=>h(!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,s.jsx)(t.j,{className:`w-4 h-4 text-accent/70`}),` `,(0,s.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Setup`})]}),(0,s.jsxs)(c.Link,{to:`/contact`,onClick:()=>h(!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,s.jsx)(t.H,{className:`w-4 h-4 text-accent/70`}),` `,(0,s.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Contact`})]}),(0,s.jsxs)(`div`,{className:`pt-2 mt-1 border-t border-[var(--panel-border)]/50 flex flex-col gap-1`,children:[(0,s.jsxs)(c.Link,{to:`/login`,onClick:()=>h(!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,s.jsx)(t.U,{className:`w-4 h-4 text-accent/70`}),` `,(0,s.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign In`})]}),(0,s.jsx)(c.Link,{to:`/register`,onClick:()=>h(!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,s.jsx)(`span`,{className:`text-[14px] font-bold mx-auto`,children:`Get Started`})})]})]})]})})]})]})]}),!n&&a&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[o===`admin`&&(0,s.jsx)(P,{}),j?.showThemeToggle&&(0,s.jsx)(`button`,{onClick:A,className:`w-9 h-9 rounded-xl border border-[var(--panel-border)] hover:bg-foreground/5 transition-all text-foreground/60 hover:text-foreground flex items-center justify-center shadow-sm shrink-0 cursor-pointer`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,s.jsx)(t.O,{className:`w-4 h-4`}):(0,s.jsx)(t.B,{className:`w-4 h-4`})}),(0,s.jsxs)(`div`,{className:`relative z-50 flex-shrink-0`,children:[(0,s.jsxs)(`button`,{onClick:()=>h(m===`user`?!1:`user`),className:`flex items-center gap-2 group p-0.5 sm:p-1 sm:pr-2.5 rounded-full hover:bg-foreground/5 transition-all duration-300 cursor-pointer`,children:[(0,s.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 transition-colors shrink-0 text-accent ${m===`user`?`border-accent/50`:`border-[var(--panel-border)] group-hover:border-accent/30`}`,children:a.photoURL&&!T?(0,s.jsx)(`img`,{src:a.photoURL,alt:`Profile`,className:`w-full h-full object-cover`,onError:()=>E(!0)}):(0,s.jsx)(t.x,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,s.jsxs)(`div`,{className:`max-sm:hidden flex flex-col text-left mr-1 justify-center min-w-[70px] max-w-[160px]`,children:[(0,s.jsx)(`span`,{className:`text-[12px] font-extrabold leading-tight text-foreground truncate w-full`,children:O}),(0,s.jsx)(`span`,{className:`text-[10px] font-mono tracking-wider leading-tight text-accent truncate w-full mt-0.5 uppercase font-bold`,children:f})]})]}),(0,s.jsx)(t.p,{children:m===`user`&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>h(!1)}),(0,s.jsxs)(t.f.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-popover border border-[var(--panel-border)] rounded-2xl p-2 z-50 flex flex-col origin-top-right`,children:[(0,s.jsxs)(`div`,{className:`p-3 border-b border-[var(--panel-border)]/50 mb-1 flex flex-col gap-1.5`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[15px] text-foreground truncate`,children:O}),(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate font-mono`,children:a.email})]}),(0,s.jsxs)(`div`,{className:`py-1`,children:[(0,s.jsxs)(c.Link,{to:`/profile`,onClick:()=>h(!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,s.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,s.jsx)(t.x,{className:`w-3 h-3 text-accent`})}),`Profile Settings`]}),(0,s.jsxs)(c.Link,{to:`/dashboard`,onClick:()=>h(!1),className:`sm:hidden 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,s.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,s.jsx)(t.X,{className:`w-3 h-3 text-accent`})}),`Dashboard`]}),G.length>0&&(0,s.jsx)(`div`,{className:`sm:hidden pt-1 mt-1 border-t border-[var(--panel-border)]/50 flex flex-col`,children:G.map((e,n)=>e.path?(0,s.jsxs)(c.Link,{to:e.path,onClick:()=>h(!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,s.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,s.jsx)(t.Z,{className:`w-3 h-3 text-accent`})}),e.label]},`${e.path}-${n}`):(0,s.jsxs)(`button`,{onClick:()=>{e.action&&e.action(),h(!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,s.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,s.jsx)(t.Z,{className:`w-3 h-3 text-accent`})}),e.label]},`${e.label}-${n}`))}),u&&(0,s.jsxs)(c.Link,{to:`/assets`,onClick:()=>h(!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,s.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,s.jsx)(t.nt,{className:`w-3 h-3 text-accent`})}),`Assets`]}),o===`admin`&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(c.Link,{to:`/users`,onClick:()=>h(!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,s.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,s.jsx)(t.b,{className:`w-3 h-3 text-accent`})}),`Users`]}),(0,s.jsxs)(c.Link,{to:`/inbox`,onClick:()=>h(!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,s.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,s.jsx)(t.et,{className:`w-3 h-3 text-accent`})}),`Inbox`]}),(0,s.jsxs)(c.Link,{to:`/pages`,onClick:()=>h(!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,s.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,s.jsx)(t.Z,{className:`w-3 h-3 text-accent`})}),`Pages`]})]}),o!==`admin`&&(0,s.jsxs)(c.Link,{to:`/support`,onClick:()=>h(!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,s.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,s.jsx)(t.gt,{className:`w-3 h-3 text-accent`})}),H]})]}),(0,s.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,s.jsxs)(`button`,{onClick:M,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,s.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,s.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,s.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,s.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,s.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]})}),`Sign Out`]})})]})]})})]})]}),n&&(0,s.jsx)(s.Fragment,{children:j?.showThemeToggle&&(0,s.jsx)(`button`,{onClick:A,className:`w-9 h-9 rounded-xl border border-[var(--panel-border)] hover:bg-foreground/5 transition-all text-foreground/60 hover:text-foreground flex items-center justify-center shadow-sm shrink-0 cursor-pointer`,"aria-label":`Toggle Theme`,children:k===`dark`?(0,s.jsx)(t.O,{className:`w-4 h-4`}):(0,s.jsx)(t.B,{className:`w-4 h-4`})})})]})]})}function te(){let[e,n]=(0,r.useState)(null);return(0,s.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,s.jsxs)(t.f.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},className:`text-center mb-8 md:mb-12`,children:[(0,s.jsxs)(t.f.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:[(0,s.jsx)(t.g,{className:`w-4 h-4 text-accent`}),` The Open-Source Firebase Starter`]}),(0,s.jsx)(t.f.h1,{className:`text-4xl sm:text-5xl md:text-6xl lg:text-[4.5rem] font-extrabold tracking-tight mb-6 md:mb-8 text-gradient animate-float leading-[1.1] md:leading-[1.15] px-2`,children:`Your AI Firebase`}),(0,s.jsx)(`p`,{className:`text-[14px] sm:text-[15px] md:text-lg lg:text-xl 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:`A production-ready Firebase backend template with Auth, Firestore prefix rules, and a clean dashboard — ready for vibe-coded apps.`}),(0,s.jsxs)(t.f.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:[(0,s.jsx)(c.Link,{to:`/register`,style:{borderRadius:`var(--btn-radius, 0.75rem)`},className:`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 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`,children:`Start Building Free`}),(0,s.jsx)(c.Link,{to:`/login`,style:{borderRadius:`var(--btn-radius, 0.75rem)`},className:`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 font-semibold tracking-wide btn-secondary text-[15px] transition-all duration-300 flex items-center justify-center hover:-translate-y-1`,children:`Sign In`})]})]}),(0,s.jsx)(t.p,{children:e&&(0,s.jsx)(t.t,{onClose:()=>n(null),formId:e})})]})}var H=[{id:`length`,label:`At least 8 characters`,ok:e=>e.length>=8},{id:`case`,label:`An uppercase and a lowercase letter`,ok:e=>/[a-z]/.test(e)&&/[A-Z]/.test(e)},{id:`number`,label:`A number`,ok:e=>/[0-9]/.test(e)}],U=new Set(`password1.password12.password123.password1234.passw0rd1.p@ssword1.p@ssw0rd1.test1234.test12345.testing123.test123456.qwerty123.qwerty1234.abcd1234.abc12345.welcome1.welcome123.admin123.admin1234.letmein123.iloveyou1.monkey123.football1.changeme1.secret123.summer2024.summer2025`.split(`.`)),W=e=>e.toLowerCase().replace(/[\s._-]/g,``),G=e=>U.has(W(e||``)),K=e=>H.map(t=>({rule:t,met:t.ok(e||``)}));function q(e){let t=e||``;if(!t)return`Choose a password.`;let n=H.find(e=>!e.ok(t));return n?`Your password needs ${n.label.toLowerCase()}.`:G(t)?`That password is one of the first anyone would guess. Please pick another.`:``}function J(e,t){return t?e===t?``:`Both passwords must be the same.`:`Type your password a second time.`}function Y({value:e,className:n=``}){return(0,s.jsx)(`ul`,{className:`flex flex-col gap-1 ml-1 ${n}`,"aria-label":`Password requirements`,children:K(e).map(({rule:e,met:n})=>(0,s.jsxs)(`li`,{className:`flex items-center gap-2 text-[12.5px] font-medium transition-colors ${n?`text-emerald-500`:`text-foreground/45`}`,children:[n?(0,s.jsx)(t.wt,{className:`w-3.5 h-3.5 shrink-0`}):(0,s.jsx)(`span`,{className:`w-3.5 flex justify-center shrink-0`,children:(0,s.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-foreground/25`})}),e.label]},e.id))})}function ne(){let[e,n]=(0,r.useState)(!1),[i,o]=(0,r.useState)(null),[l,u]=(0,r.useState)(``),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(``),_=(0,c.useNavigate)(),{registerUser:v}=ee();return(0,s.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,s.jsxs)(t.f.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,s.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,s.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,s.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Create an account`}),(0,s.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Join Your AI Firebase and start building today.`})]}),i&&(0,s.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:i}),(0,s.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),n(!0),o(null);let t=new FormData(e.currentTarget),r=t.get(`email`),i=t.get(`firstName`),a=t.get(`lastName`),u=q(l),f=u?``:J(l,d);if(m(u),g(f),u||f){o(u||f),n(!1);return}try{await v(r,l,i,a),_(`/verify`)}catch(e){e?.code===`auth/email-already-in-use`?o((0,s.jsxs)(`span`,{children:[`An account with this email already exists.`,` `,(0,s.jsx)(c.Link,{to:`/login?email=${encodeURIComponent(r)}`,className:`font-bold underline hover:text-accent transition-colors`,children:`Sign in?`})]})):e?.code===`auth/weak-password`?o(q(l)||`Please choose a stronger password.`):o(e?.message||`An error occurred during registration.`)}finally{n(!1)}},children:[(0,s.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,s.jsx)(t.c,{name:`firstName`,label:`First Name`,type:`text`,placeholder:`John`,required:!0}),(0,s.jsx)(t.c,{name:`lastName`,label:`Last Name`,type:`text`,placeholder:`Doe`,required:!0})]}),(0,s.jsx)(t.c,{name:`email`,label:`Email`,type:`email`,placeholder:`name@example.com`,required:!0}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,s.jsx)(t.c,{name:`password`,label:`Password`,type:`password`,placeholder:`••••••••`,autoComplete:`new-password`,value:l,onChange:e=>{u(e.target.value),p&&m(``),h&&e.target.value===d&&g(``)},onBlur:()=>m(l?q(l):``),error:p,required:!0}),l&&(0,s.jsx)(Y,{value:l})]}),(0,s.jsx)(t.c,{name:`confirmPassword`,label:`Confirm password`,type:`password`,placeholder:`••••••••`,autoComplete:`new-password`,value:d,onChange:e=>{f(e.target.value),h&&g(``)},onBlur:()=>g(d?J(l,d):``),error:h,required:!0}),(0,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsxs)(t.s,{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,s.jsx)(t.jt,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,s.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,s.jsxs)(t.s,{variant:`secondary`,onClick:async()=>{n(!0),o(null);try{if(!t.Vt)throw Error(`Firebase is not initialized. Check your configuration.`);let e=new a.GoogleAuthProvider;try{await(0,a.signInWithPopup)(t.Vt,e)}catch(n){if(n?.code===`auth/popup-blocked`||n?.code===`auth/popup-closed-by-user`||n?.code===`auth/cancelled-popup-request`){let{signInWithRedirect:n}=await import(`firebase/auth`);await n(t.Vt,e);return}throw n}}catch(e){let t=e?.code||``;t===`auth/unauthorized-domain`||(e?.message||``).includes(`requested action is invalid`)?o(`Google Sign-In failed: your app domain is not authorized. Go to Firebase Console → Authentication → Settings → Authorized domains and add your domain (e.g. localhost or your-app.com).`):o(t===`auth/network-request-failed`?`Network error — please check your internet connection and Firebase configuration.`:e?.message||`Google sign-up failed.`)}finally{n(!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,s.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,s.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,s.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,s.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,s.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,s.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`Already have an account? `,(0,s.jsx)(c.Link,{to:`/login`,className:`text-accent hover:underline font-bold ml-1`,children:`Sign in`})]})]})]})})}function re(){let[e,n]=(0,r.useState)(!1),[i,o]=(0,r.useState)(null),[l]=(0,c.useSearchParams)(),u=(0,c.useNavigate)(),[d]=(0,r.useState)(l.get(`email`)||``);return(0,s.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,s.jsxs)(t.f.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,s.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,s.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,s.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Welcome back`}),(0,s.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Sign in to Your AI Firebase.`})]}),i&&(0,s.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:i}),(0,s.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),n(!0),o(null);let r=new FormData(e.currentTarget),i=r.get(`email`),d=r.get(`password`);try{if(!t.Vt)throw Error(`Firebase is not initialized. Check your configuration.`);await(0,a.signInWithEmailAndPassword)(t.Vt,i,d),u(l.get(`from`)||`/dashboard`,{replace:!0})}catch(e){e?.code===`auth/invalid-credential`||e?.code===`auth/user-not-found`||e?.code===`auth/wrong-password`?o((0,s.jsxs)(`span`,{children:[`Email or Password are incorrect.`,` `,(0,s.jsx)(c.Link,{to:`/reset-password`,className:`font-bold underline hover:text-red-400 transition-colors`,children:`Reset password?`})]})):e?.code===`auth/network-request-failed`?o(`Network error — please check your internet connection and Firebase configuration.`):o(e?.message||`Invalid credentials.`),n(!1)}},children:[(0,s.jsx)(t.c,{name:`email`,label:`Email`,type:`email`,defaultValue:d,placeholder:`name@example.com`,required:!0}),(0,s.jsxs)(`div`,{className:`space-y-2`,children:[(0,s.jsxs)(`div`,{className:`flex justify-between items-center pr-1`,children:[(0,s.jsx)(`label`,{className:`text-[14px] md:text-[15px] tracking-wide font-medium text-foreground/80 select-none pb-1`,children:`Password`}),(0,s.jsx)(c.Link,{to:`/reset-password`,className:`text-[13px] md:text-[14px] text-accent hover:underline font-bold tracking-wide`,children:`Forgot Password?`})]}),(0,s.jsx)(t.c,{name:`password`,type:`password`,placeholder:`••••••••`,required:!0})]}),(0,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsxs)(t.s,{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,s.jsx)(t.jt,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,s.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,s.jsxs)(t.s,{variant:`secondary`,onClick:async()=>{n(!0),o(null);try{if(!t.Vt)throw Error(`Firebase is not initialized. Check your configuration.`);let e=new a.GoogleAuthProvider;try{await(0,a.signInWithPopup)(t.Vt,e)}catch(n){if(n?.code===`auth/popup-blocked`||n?.code===`auth/popup-closed-by-user`||n?.code===`auth/cancelled-popup-request`){let{signInWithRedirect:n}=await import(`firebase/auth`);await n(t.Vt,e);return}throw n}u(l.get(`from`)||`/dashboard`,{replace:!0})}catch(e){let t=e?.code||``;t===`auth/unauthorized-domain`||(e?.message||``).includes(`requested action is invalid`)?o(`Google Sign-In failed: your app domain is not authorized. Go to Firebase Console → Authentication → Settings → Authorized domains and add your domain (e.g. localhost or your-app.com).`):o(t===`auth/network-request-failed`?`Network error — please check your internet connection and Firebase configuration.`:e?.message||`Google sign-in failed.`)}finally{n(!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,s.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,s.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,s.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,s.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,s.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,s.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`New here? `,(0,s.jsx)(c.Link,{to:`/register`,className:`text-accent hover:underline font-bold ml-1`,children:`Create account`})]})]})]})})}function ie(){let{user:e,refreshUser:n}=ee(),i=(0,c.useNavigate)(),[o,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(!1),[f,p]=(0,r.useState)(``);return(0,s.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16`,children:(0,s.jsxs)(t.f.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,s.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,s.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,s.jsx)(t.H,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,s.jsx)(`h1`,{className:`text-2xl md:text-3xl font-extrabold mb-3 text-foreground tracking-tight`,children:`Verify your email`}),(0,s.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,s.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.`]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[f&&(0,s.jsx)(`div`,{role:`status`,className:`w-full px-4 py-2.5 md:py-3 text-[13px] md:text-[14px] font-semibold leading-snug 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,s.jsx)(t.s,{variant:`primary`,onClick:async()=>{l(!0),p(``);try{if(t.Vt.currentUser){if(await t.Vt.currentUser.reload(),!t.Vt.currentUser.emailVerified){p(`Email is not verified yet. Please check your inbox.`),l(!1);return}await t.Vt.currentUser.getIdToken(!0),await n(),i(`/dashboard`)}}catch{p(`Something went wrong. Please try again.`),l(!1)}},isLoading:o,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,s.jsx)(t.s,{variant:`ghost`,onClick:async()=>{if(e){d(!0),p(``);try{await(0,a.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:u,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`})]})]})})}function ae(...e){return t.l(t.u(e))}var oe=.72,se=({className:e,children:t,...n})=>{let i=(0,r.useRef)(null);return(0,r.useLayoutEffect)(()=>{let e=i.current,t=e?.parentElement;if(!e||!t)return;let n=()=>{e.style.fontSize=``,e.removeAttribute(`data-fold`);let n=t.clientWidth,r=e.scrollWidth;if(!n||r<=n)return;let i=parseFloat(window.getComputedStyle(e).fontSize)||24,a=n/r;e.style.fontSize=`${(i*Math.max(a,oe)).toFixed(2)}px`,a<oe&&e.setAttribute(`data-fold`,``)};if(n(),document.fonts?.ready.then(n).catch(()=>{}),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()},[t]),(0,s.jsx)(`h1`,{ref:i,className:ae(`page-title w-fit inline-block tracking-tight mb-3 mt-1 text-gradient`,e),...n,children:t})};se.displayName=`PageTitle`;var X=k(`admin`),ce={pages:{path:`/pages`,label:`Pages`,icon:t.Z,roles:X},forms:{path:`/forms`,label:`Forms`,icon:t.F,roles:X},inbox:{path:`/inbox`,label:`Inbox`,icon:t.et,roles:X},users:{path:`/users`,label:`Users`,icon:t.b,roles:X},theme:{path:`/theme`,label:`Theme`,icon:t.z,roles:X},assets:{path:`/assets`,label:`Assets`,icon:t.nt,roles:X}};function le({customTabs:e=[]}){let{pathname:n}=(0,c.useLocation)(),{user:a,userRole:o}=ee(),[l,u]=(0,r.useState)(!1),d=(0,r.useRef)(null),[f,p]=(0,r.useState)({}),[m,h]=(0,r.useState)(R);(0,r.useEffect)(()=>{try{let e=localStorage.getItem(`fbos_nav_tabs`);e&&p(JSON.parse(e));let t=localStorage.getItem(`fbos_nav_order`);t&&h(JSON.parse(t))}catch{}let e=(0,i.onSnapshot)((0,i.collection)(t.Ht,`sys_tabs`),e=>{let t={};e.forEach(e=>{t[e.id]=e.data()}),p(t),localStorage.setItem(`fbos_nav_tabs`,JSON.stringify(t))},e=>{console.warn(`sys_tabs snapshot error:`,e)}),n=(0,i.onSnapshot)((0,i.doc)(t.Ht,`sys_configs`,`tab_order`),e=>{let t=e.exists()&&Array.isArray(e.data().order)?L(e.data().order):R;h(t),localStorage.setItem(`fbos_nav_order`,JSON.stringify(t))},e=>{console.warn(`tab_order snapshot error:`,e)});return()=>{e(),n()}},[]),(0,r.useEffect)(()=>{function e(e){d.current&&!d.current.contains(e.target)&&u(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let g=[...(()=>{let e={};Object.entries(ce).forEach(([t,n])=>{e[t]={id:t,...n,exact:!0}});let n={...f};for(let[e,t]of N())t.isPublic||(n[e]={...t.config,...f[e]});Object.entries(n).forEach(([n,r])=>{let i=e[n],a=i?.icon??t.Z;if(r?.iconName){let e=r.iconName.trim(),n=e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);t.m[n]?a=t.m[n]:t.m[e]&&(a=t.m[e])}let o=i?.roles??X;r?.pageType&&(o=k(E(r.pageType))),e[n]={id:n,path:r?.route?r.route.startsWith(`/`)?r.route:`/`+r.route:i?.path??`/`+n,label:r?.tabName||r?.pageTitle||r?.pageName||i?.label||n,icon:a,roles:o,exact:!0}});let r=[],i=new Set;m.forEach(t=>{t.hidden||i.has(t.id)||e[t.id]&&(r.push(e[t.id]),i.add(t.id))});let a=[],o=[];return Object.keys(e).forEach(t=>{if(i.has(t))return;let r=m.find(e=>e.id===t);r?.hidden||(t in n&&!r?a.push(e[t]):o.push(e[t]))}),a.length>0&&r.unshift(...a),o.length>0&&r.push(...o),r})(),...e.map(e=>({...e,id:e.path}))].filter(e=>{let t=O(o,!!a);return Array.isArray(e.roles)?e.roles.includes(t):!1}),_=(0,r.useRef)(null),v=(0,r.useRef)(null),[y,b]=(0,r.useState)(g.length);(0,r.useEffect)(()=>{let e=()=>{let e=_.current,t=v.current;if(!e||!t)return;let n=e.clientWidth;if(n===0)return;let r=parseFloat(getComputedStyle(e).columnGap)||40,i=t.querySelectorAll(`[data-measure-tab]`);if(i.length===0){b(g.length);return}let a=0,o=!0;for(let e=0;e<i.length;e++)if(a+=i[e].offsetWidth+(e>0?r:0),a>n){o=!1;break}if(o){b(g.length);return}let s=0,c=0;for(let e=0;e<i.length;e++){let t=i[e].offsetWidth,a=s+t+(e>0?r:0);if(a+52>n)break;s=a,c++}b(Math.max(c,1))},t=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(t);let n=new ResizeObserver(()=>requestAnimationFrame(e));return _.current&&n.observe(_.current),()=>{cancelAnimationFrame(t),n.disconnect()}},[g.map(e=>e.id+e.label).join(`|`),g.length]);let x=g.slice(0,y),S=g.slice(y),C=e=>e.exact?n===e.path:n.startsWith(e.path),w=S.some(e=>C(e));return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{ref:v,"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,s.jsxs)(`span`,{"data-measure-tab":!0,className:`flex items-center gap-2 text-[14.5px] font-semibold shrink-0 pb-3`,children:[(0,s.jsx)(t,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)})}),(0,s.jsxs)(`div`,{ref:_,className:`w-full flex items-center gap-6 md:gap-10 mb-5 border-b border-[var(--panel-border)] px-1 whitespace-nowrap relative`,children:[x.map(e=>{let t=C(e),n=e.icon;return(0,s.jsxs)(c.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,s.jsx)(n,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)}),S.length>0&&(0,s.jsxs)(`div`,{className:`relative shrink-0 ml-auto`,ref:d,children:[(0,s.jsx)(`button`,{onClick:()=>u(!l),className:`flex items-center justify-center transition-all duration-300 pb-3 -mb-[1px] border-b-2 cursor-pointer ${w?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,title:`More items`,children:(0,s.jsx)(t.lt,{className:`w-5 h-5`})}),(0,s.jsx)(t.p,{children:l&&(0,s.jsx)(t.f.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] glass-popover border border-[var(--panel-border)] rounded-2xl z-50 flex flex-col py-2 overflow-hidden`,children:S.map(e=>{let t=C(e),n=e.icon;return(0,s.jsxs)(c.Link,{to:e.path||`/`,onClick:()=>u(!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,s.jsx)(n,{className:`w-4 h-4`}),e.label]},e.path||e.id)})})})]})]})]})}function Z(){let{user:e,refreshUser:n,isInternal:c}=ee(),[l,u]=(0,r.useState)(e?.displayName||``),[d,f]=(0,r.useState)(e?.email||``),[p,m]=(0,r.useState)(e?.photoURL||``),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(null),[y,b]=(0,r.useState)(``),[x,S]=(0,r.useState)(!1),[C,w]=(0,r.useState)(!1),[E,D]=(0,r.useState)(!0);r.default.useEffect(()=>{u(e?.displayName||``),f(e?.email||``),m(e?.photoURL||``)},[e?.uid,e?.displayName,e?.email,e?.photoURL]);let O=async n=>{if(e)try{if(!c)return;let r=[`mem_files`,`admin_files`];(await(0,i.getDocs)((0,i.collection)(t.Ht,`sys_tabs`))).forEach(e=>{let t=e.data(),n=(t.tabName||e.id).toLowerCase().replace(/[^a-z0-9]+/g,`_`),i=T(t.pageType);i===`internal`&&r.push(`mem_${n}_records`),i===`admin`&&r.push(`admin_${n}_records`)});for(let a of r)try{let r=await(0,i.getDocs)((0,i.query)((0,i.collection)(t.Ht,a),(0,i.where)(`uid`,`==`,e.uid)));if(r.empty)continue;let o=(0,i.writeBatch)(t.Ht);r.docs.forEach(e=>o.update(e.ref,{creatorAvatar:n})),await o.commit()}catch{}}catch(e){console.error(`Error propagating avatar to records:`,e)}};return(0,s.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,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,s.jsx)(se,{children:`Profile Settings`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/profile`]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,s.jsx)(`div`,{className:`flex justify-start`,children:(0,s.jsx)(le,{})}),(0,s.jsx)(t.p,{children:_&&(0,s.jsxs)(t.f.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,s.jsx)(t.vt,{className:`w-5 h-5 shrink-0`}):(0,s.jsx)(t.yt,{className:`w-5 h-5 shrink-0`}),(0,s.jsx)(`span`,{className:`text-[14px] font-semibold tracking-wide leading-relaxed`,children:_.text})]})}),(0,s.jsx)(`form`,{onSubmit:async r=>{if(r.preventDefault(),e){g(!0),v(null);try{l!==e.displayName&&await(0,a.updateProfile)(e,{displayName:l});let r=!1;if(d!==e.email){let n=await(0,a.fetchSignInMethodsForEmail)(t.Vt,d);if(n&&n.length>0)throw Error(`An account with this email already exists.`);await(0,a.verifyBeforeUpdateEmail)(e,d),r=!0}if(y){let t=q(y);if(t)throw Error(t);await(0,a.updatePassword)(e,y),b(``)}await n(),v(r?{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,s.jsxs)(`div`,{className:`glass-panel w-full p-5 sm:p-8 md:p-12 rounded-3xl border border-[var(--panel-border)] shadow-2xl space-y-8 md:min-h-[500px]`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-4 sm:gap-5 pb-6 border-b border-[var(--panel-border)]/50`,children:[(0,s.jsxs)(`div`,{className:`relative shrink-0 group/avatar`,children:[(0,s.jsxs)(`div`,{className:`w-16 h-16 sm:w-20 sm:h-20 rounded-full glass-panel border-2 border-[var(--panel-border)] shadow-lg bg-accent/10 flex items-center justify-center relative overflow-hidden`,children:[(C||p&&E&&!x)&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-10`,children:(0,s.jsx)(t.G,{className:`w-6 h-6 text-accent animate-spin`})}),p&&!x?(0,s.jsx)(`img`,{src:p,alt:`Avatar`,className:`w-full h-full object-cover transition-opacity duration-300 ${E?`opacity-0`:`opacity-100`}`,onLoad:()=>D(!1),onError:()=>{S(!0),D(!1)}}):(0,s.jsx)(t.x,{className:`w-7 h-7 sm:w-8 sm:h-8 text-accent`})]}),!C&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`label`,{title:p?`Change photo`:`Upload photo`,className:`absolute inset-0 rounded-full bg-background/60 backdrop-blur-[2px] opacity-0 group-hover/avatar:opacity-100 focus-within:opacity-100 flex items-center justify-center cursor-pointer transition-opacity z-20`,children:[(0,s.jsx)(t.Et,{className:`w-4 h-4 text-foreground`}),(0,s.jsx)(`input`,{type:`file`,accept:`image/*`,"aria-label":`Upload photo`,onChange:async r=>{let s=r.target.files?.[0];if(!(!s||!e)){if(s.size>2*1024*1024){v({text:`File too large. Please select an image under 2MB.`,type:`error`});return}w(!0),S(!1),D(!0);try{let r=(0,o.ref)(t.Wt,`user_avatars/${e.uid}/file.png`);await(0,o.uploadBytes)(r,s,{customMetadata:{ownerId:e.uid}});let c=await(0,o.getDownloadURL)(r);m(c);let l=(0,i.doc)(t.Ht,`user_profiles`,e.uid);await Promise.all([(0,a.updateProfile)(e,{photoURL:c}),(0,i.updateDoc)(l,{avatar:c}),O(c)]),await n(),v({text:`Avatar successfully updated!`,type:`success`})}catch(e){console.error(e),v({text:`Failed to upload photo.`,type:`error`})}finally{w(!1)}}},className:`hidden`})]}),p&&(0,s.jsx)(`button`,{type:`button`,onClick:async()=>{if(e){w(!0),S(!1),D(!1);try{let r=(0,o.ref)(t.Wt,`user_avatars/${e.uid}/file.png`);m(``),w(!1);let s=(0,i.doc)(t.Ht,`user_profiles`,e.uid);await Promise.all([(0,o.deleteObject)(r).catch(e=>console.error(e)),(0,a.updateProfile)(e,{photoURL:``}),(0,i.updateDoc)(s,{avatar:``}),O(``)]),await n(),v({text:`Avatar removed.`,type:`success`})}catch(e){console.error(e),v({text:`Failed to delete photo.`,type:`error`}),w(!1)}}},title:`Remove photo`,"aria-label":`Remove photo`,className:`hidden group-hover/avatar:flex absolute -top-1 -right-1 w-6 h-6 rounded-full bg-background border border-[var(--panel-border)] text-foreground/50 hover:text-red-500 hover:border-red-500/40 items-center justify-center shadow-sm cursor-pointer z-30`,children:(0,s.jsx)(t.E,{className:`w-3 h-3`})})]})]}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h3`,{className:`font-extrabold text-lg sm:text-xl text-foreground mb-1 truncate`,children:l||`User`}),(0,s.jsx)(`div`,{className:`max-sm:hidden inline-block text-[12px] font-mono uppercase tracking-widest text-accent bg-accent/10 px-2.5 py-1 rounded-md border border-accent/20`,children:e?.emailVerified?`Verified Account`:`Unverified`}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/40 mt-1 sm:mt-2 font-medium break-words`,children:e?.email})]})]}),(0,s.jsxs)(`div`,{className:`space-y-6`,children:[(0,s.jsx)(`h3`,{className:`text-[16px] font-extrabold text-foreground flex items-center gap-2`,children:`Account Details`}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,s.jsx)(t.c,{name:`name`,value:l,onChange:e=>u(e.target.value),label:`Display Name`,placeholder:`John Doe`}),(0,s.jsxs)(`div`,{className:`flex flex-col`,children:[(0,s.jsx)(t.c,{name:`email`,type:`email`,value:d,onChange:e=>f(e.target.value),label:`Email Address`,placeholder:`name@example.com`,required:!0}),(0,s.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,s.jsxs)(`div`,{className:`pt-6 border-t border-[var(--panel-border)]/50`,children:[(0,s.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground mb-4 flex items-center gap-2`,children:`Change Password`}),(0,s.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:(0,s.jsx)(t.c,{name:`password`,type:`password`,label:`New Password`,autoComplete:`new-password`,value:y,onChange:e=>b(e.target.value),placeholder:`At least 8 characters`})}),y&&(0,s.jsx)(Y,{value:y,className:`mt-3`})]}),(0,s.jsx)(`div`,{className:`pt-6 md:pt-8 border-t border-[var(--panel-border)]/50 flex justify-start w-full`,children:(0,s.jsx)(t.s,{type:`submit`,isLoading:h,className:`w-full sm:w-auto sm: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 ue(){let[e,n]=(0,r.useState)(!1),[i,o]=(0,r.useState)(null),[l,u]=(0,r.useState)(0),[d,f]=(0,r.useState)(0);return(0,r.useEffect)(()=>{let e;return l>0&&(e=setInterval(()=>u(e=>e-1),1e3)),()=>clearInterval(e)},[l]),(0,s.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,s.jsxs)(t.f.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,s.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,s.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,s.jsx)(t.Q,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,s.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,s.jsx)(`h3`,{className:`text-2xl md:text-3xl font-extrabold mb-2 md:mb-3 text-foreground tracking-tight`,children:`Reset Password`}),(0,s.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Enter your email to receive a recovery link.`})]}),i&&(0,s.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:i}),(0,s.jsxs)(`form`,{className:`space-y-4 text-left max-w-[360px] mx-auto`,onSubmit:async e=>{e.preventDefault(),n(!0),o(null);let r=new FormData(e.currentTarget).get(`email`);try{await(0,a.sendPasswordResetEmail)(t.Vt,r)}catch(e){console.error(e)}finally{o(`If an account exists, a password reset link has been sent. Please check your inbox (and spam folder).`);let e=d+1;f(e),u(e===1?60:120),n(!1)}},children:[(0,s.jsx)(t.c,{name:`email`,label:`Work Email`,type:`email`,placeholder:`name@company.com`,required:!0}),(0,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsx)(t.s,{type:`submit`,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl md:rounded-xl transition-all ${l>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:l>0,children:l>0?`Resend link in ${(e=>`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`)(l)}`:d>0?`Resend reset password link`:`Send Reset Link`})})]}),(0,s.jsx)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:(0,s.jsxs)(c.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,s.jsx)(t.Mt,{className:`w-4 h-4 mr-2`}),`Back to Sign In`]})})]})})}var de={free:``,internal:`text-blue-500 border-blue-500/30 bg-blue-500/10`,admin:`text-red-500 border-red-500/30 bg-red-500/10`},fe=({level:e})=>e===`free`?null:(0,s.jsx)(`span`,{className:`shrink-0 text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded border ${de[e]}`,children:y[e]}),pe=`(max-width: 767px)`,me=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(pe).matches;function he(){let[e,t]=(0,r.useState)(me);return(0,r.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(pe),n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function ge(){let{user:e,userRole:n}=ee(),[a,l]=(0,r.useState)(!0),u=(0,c.useNavigate)(),{id:d}=(0,c.useParams)(),f=he(),[p,m]=(0,r.useState)([]),[h,g]=(0,r.useState)(null),[v,C]=(0,r.useState)(!1),[w,T]=(0,r.useState)(``),[E,D]=(0,r.useState)(!1),O=d?p.find(e=>e.id===d)||null:p.length>0?p[0]:null,k=e=>{u(e?`/users/${e.id}`:`/users`)};(0,r.useEffect)(()=>{l(!0);let e=(0,i.onSnapshot)((0,i.collection)(t.Ht,`user_profiles`),e=>{let t=[];e.forEach(e=>{t.push({id:e.id,...e.data()})}),m(t),l(!1),!d&&t.length>0&&!me()&&u(`/users/${t[0].id}`,{replace:!0})},e=>{console.error(`Error fetching users:`,e),l(!1)});return()=>e()},[d,u]);let A=p.find(t=>t.id===e?.uid),j=e=>e.id===A?.id?!1:e.role!==`admin`||!A?.createdAt?!0:e.createdAt?new Date(A.createdAt).getTime()<=new Date(e.createdAt).getTime():!1,M=async(e,r)=>{if(!(n!==`admin`||!j(e))&&x(e.role)!==r)try{await(0,i.updateDoc)((0,i.doc)(t.Ht,`user_profiles`,e.id),{role:S(r)}),g({text:`Access level set to ${y[r]}`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},N=async(e,r)=>{if(!(n!==`admin`||!j(e)))try{await(0,i.updateDoc)((0,i.doc)(t.Ht,`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)}},P=async()=>{if(C(!1),!(!O||!j(O)||w===O.displayName))try{await(0,i.updateDoc)((0,i.doc)(t.Ht,`user_profiles`,O.id),{displayName:w}),g({text:`Name updated successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},F=async e=>{let n=e.target.files?.[0];if(!(!n||!O||!j(O))){if(n.size>2*1024*1024){g({text:`File too large. Please select an image under 2MB.`,type:`error`});return}D(!0);try{let e=(0,o.ref)(t.Wt,`user_avatars/${O.id}/file.png`);await(0,o.uploadBytes)(e,n);let r=await(0,o.getDownloadURL)(e);m(e=>e.map(e=>e.id===O.id?{...e,avatar:r}:e)),await(0,i.updateDoc)((0,i.doc)(t.Ht,`user_profiles`,O.id),{avatar:r}),g({text:`Avatar successfully updated.`,type:`success`}),setTimeout(()=>g(null),3e3)}catch{g({text:`Failed to upload photo.`,type:`error`})}D(!1)}},[I,L]=(0,r.useState)(!1);if((0,r.useEffect)(()=>{let e;return a&&p.length===0?e=setTimeout(()=>L(!0),150):L(!1),()=>clearTimeout(e)},[a,p.length]),a&&p.length===0)return I?(0,s.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,s.jsx)(t.G,{className:`w-8 h-8 animate-spin text-accent`})}):null;let R=f&&!!d,z=!R,B=!f||!!d;return(0,s.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto z-10 flex flex-col min-h-screen ${R?`p-0`:`p-4 md:p-8 pt-12`}`,children:[!R&&(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,s.jsx)(se,{children:`Users`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/users`]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col animate-in fade-in duration-500 ${R?`flex-1`:`gap-6 pb-20`}`,children:[(0,s.jsx)(t.p,{children:h&&(0,s.jsxs)(t.f.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)]`} ${R?`mx-4 mt-4 rounded-xl`:`rounded-xl`} flex items-center gap-2`,children:[h.type===`success`&&(0,s.jsx)(t.vt,{className:`w-4 h-4 shrink-0`}),h.text]})}),!R&&(0,s.jsx)(`div`,{className:`flex justify-start`,children:(0,s.jsx)(le,{})}),(0,s.jsx)(`div`,{className:`glass-panel border border-[var(--panel-border)] bg-[var(--panel-bg)] overflow-hidden ${R?`flex-1 flex flex-col border-0 shadow-none`:`rounded-3xl shadow-2xl`}`,children:p.length===0?(0,s.jsx)(`div`,{className:`p-8 text-center text-foreground/50 text-[14px]`,children:`No members found.`}):(0,s.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 md:min-h-[500px] ${R?`flex-1`:``}`,children:[z&&(0,s.jsxs)(`div`,{className:`flex md:col-span-1 border-r md:border-r-[var(--panel-border)] border-b md:border-b-0 border-[var(--panel-border)] flex-col hide-scrollbar bg-foreground/[0.03] rounded-t-3xl md:rounded-tr-none md:rounded-l-3xl`,children:[(0,s.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,s.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-2 md:max-h-[520px]`,children:p.map(e=>(0,s.jsxs)(`div`,{onClick:()=>k(e),className:`p-4 py-5 rounded-2xl border transition-all flex items-center gap-4 cursor-pointer ${O?.id===e.id?`bg-foreground/[0.06] border-accent/40 shadow-sm`:`glass-panel border-transparent hover:border-[var(--panel-border)]`} ${e.inactive?`opacity-50 grayscale`:``}`,children:[(0,s.jsx)(`div`,{className:`w-12 h-12 rounded-full overflow-hidden bg-accent/10 shrink-0 flex items-center justify-center border border-accent/20`,children:e.avatar||e.photoURL?(0,s.jsx)(`img`,{src:e.avatar||e.photoURL,alt:``,className:`w-full h-full object-cover`}):(0,s.jsx)(t.x,{className:`w-5 h-5 text-accent`})}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[14px] truncate`,children:e.displayName||`No Name`}),(0,s.jsx)(fe,{level:x(e.role)})]}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/50 truncate font-mono mt-0.5`,children:e.email})]}),f&&(0,s.jsx)(t.xt,{className:`w-4 h-4 text-foreground/25 shrink-0`})]},e.id))})]}),B&&(0,s.jsx)(`div`,{className:`flex md:col-span-2 flex-col relative ${R?`px-4 pt-4 pb-10`:`p-5 sm:p-6 md:p-10`}`,children:O?(0,s.jsxs)(`div`,{className:`animate-in fade-in duration-300 w-full max-w-lg`,children:[(0,s.jsxs)(`div`,{className:`flex flex-row items-center gap-3 sm:gap-6 md:gap-8 mb-8 sm:mb-10`,children:[R&&(0,s.jsx)(`button`,{type:`button`,onClick:()=>k(null),"aria-label":`Back to all users`,className:`shrink-0 -ml-1.5 w-7 h-7 flex items-center justify-center rounded-lg text-foreground/40 hover:text-foreground active:bg-foreground/5 transition-colors cursor-pointer`,children:(0,s.jsx)(t.Mt,{className:`w-5 h-5`})}),(0,s.jsxs)(`div`,{className:`relative shrink-0 group/avatar`,children:[(0,s.jsx)(`div`,{className:`w-14 h-14 sm:w-24 sm:h-24 rounded-full glass-panel border-2 sm:border-4 border-[var(--panel-border)] shadow-lg sm:shadow-xl bg-accent/10 flex items-center justify-center overflow-hidden`,children:E?(0,s.jsx)(t.G,{className:`w-5 h-5 sm:w-8 sm:h-8 text-accent animate-spin`}):O.avatar||O.photoURL?(0,s.jsx)(`img`,{src:O.avatar||O.photoURL,alt:`Avatar`,className:`w-full h-full object-cover`}):(0,s.jsx)(t.x,{className:`w-6 h-6 sm:w-10 sm:h-10 text-accent`})}),!E&&j(O)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`label`,{title:`Change photo`,className:`max-sm:hidden flex absolute -bottom-0.5 -right-0.5 w-9 h-9 rounded-full btn-primary text-white items-center justify-center cursor-pointer shadow-lg border-2 border-[var(--bg-color)] hover:scale-105 active:scale-95 transition-transform z-10`,children:[(0,s.jsx)(t.Et,{className:`w-4 h-4`}),(0,s.jsx)(`input`,{type:`file`,accept:`image/*`,"aria-label":`Change photo`,onChange:F,className:`hidden`})]}),(0,s.jsxs)(`label`,{title:`Change photo`,className:`flex sm:hidden absolute inset-0 rounded-full bg-background/60 backdrop-blur-[2px] opacity-0 group-hover/avatar:opacity-100 focus-within:opacity-100 items-center justify-center cursor-pointer transition-opacity z-10`,children:[(0,s.jsx)(t.Et,{className:`w-4 h-4 text-foreground`}),(0,s.jsx)(`input`,{type:`file`,accept:`image/*`,"aria-label":`Change photo`,onChange:F,className:`hidden`})]})]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col flex-1 w-full min-w-0 relative`,children:[v?(0,s.jsx)(`input`,{autoFocus:!0,value:w,onChange:e=>T(e.target.value),onBlur:P,onKeyDown:e=>e.key===`Enter`&&P(),className:`text-xl sm: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,s.jsx)(`h3`,{onDoubleClick:()=>{j(O)&&(T(O.displayName||``),C(!0))},className:`text-xl sm:text-2xl md:text-3xl font-extrabold mb-1 select-none break-words ${j(O)?`cursor-pointer hover:text-accent transition-colors`:``}`,title:j(O)?`Double-click to edit`:``,children:O.displayName||`No Name`}),(0,s.jsx)(`p`,{className:`text-[13px] sm:text-[14px] font-mono text-foreground/50 break-all`,children:O.email}),!j(O)&&O.id!==A?.id&&(0,s.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-[12px] font-medium text-foreground/45`,children:[(0,s.jsx)(t.W,{className:`w-3 h-3 shrink-0`}),`Admin since before you, so only they can change this account.`]})]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,s.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border border-[var(--panel-border)] flex flex-col gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[14px] text-foreground`,children:`Access level`}),(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/50`,children:`What this person can open`})]}),(0,s.jsx)(`div`,{role:`radiogroup`,"aria-label":`Access level`,className:`flex items-center gap-1.5 flex-wrap ${j(O)?``:`opacity-50`}`,children:_.map(e=>{let t=x(O.role)===e;return(0,s.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t,disabled:!j(O),onClick:()=>M(O,e),className:`h-8 px-3.5 rounded-full text-[12.5px] font-semibold border transition-all ${t?`bg-accent/10 border-accent/40 text-accent`:`border-[var(--panel-border)] text-foreground/55 hover:text-foreground hover:border-accent/30`} ${j(O)?`cursor-pointer`:`cursor-not-allowed`}`,children:y[e]},e)})})]}),!f&&(0,s.jsx)(`p`,{className:`text-[12px] text-foreground/50 leading-relaxed`,children:b[x(O.role)]})]}),(0,s.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border flex items-center justify-between gap-3 ${O.inactive?`border-amber-500/30 bg-amber-500/5`:`border-red-500/20 bg-red-500/5`}`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[14px] ${O.inactive?`text-amber-500`:`text-red-500`}`,children:O.inactive?`Reactivate User`:`Deactivate User`}),(0,s.jsx)(`span`,{className:`text-[12px] ${O.inactive?`text-amber-500/70`:`text-red-500/70`}`,children:`Block access to this app`})]}),(0,s.jsx)(`button`,{type:`button`,disabled:!j(O),onClick:()=>N(O,!O.inactive),className:`relative inline-flex h-7 w-12 shrink-0 items-center rounded-full transition-colors focus:outline-none shadow-inner ${O.inactive?`bg-amber-500`:`bg-red-500/20`} ${j(O)?`cursor-pointer`:`opacity-50 cursor-not-allowed`}`,children:(0,s.jsx)(`span`,{className:`inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-md ${O.inactive?`translate-x-6`:`translate-x-1`}`})})]})]})]}):(0,s.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center opacity-30 pointer-events-none`,children:[(0,s.jsx)(t.b,{className:`w-12 h-12 mb-4`}),(0,s.jsx)(`p`,{className:`font-bold tracking-widest uppercase text-[12px]`,children:`Select a User`})]})})]})})]})]})}function _e({isOpen:e,title:n,message:r,confirmText:i=`Delete`,cancelText:a=`Cancel`,onConfirm:o,onCancel:c,isProcessing:l=!1,disableConfirm:u=!1}){return(0,s.jsx)(t.p,{children:e&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{onClick:()=>!l&&c(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,s.jsx)(t.f.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-popover border border-[var(--panel-border)] shadow-2xl relative z-10 text-center`,children:(0,s.jsxs)(`div`,{className:`w-full flex flex-col items-center`,children:[(0,s.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:n}),(0,s.jsx)(`p`,{className:`w-full text-[14px] font-medium text-foreground/60 leading-relaxed mb-6 break-words`,children:r}),(0,s.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,s.jsx)(t.s,{variant:`secondary`,onClick:c,disabled:l,className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:a}),(0,s.jsx)(t.s,{onClick:o,disabled:l||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:l?(0,s.jsx)(t.G,{className:`w-5 h-5 animate-spin mx-auto`}):i})]})]})})]})})}var ve=`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] transition-colors hover:border-accent/40`,ye=`inline-flex items-center justify-center gap-1.5 h-8 px-2.5 sm:h-9 sm:px-3 rounded-[var(--btn-radius,0.75rem)] text-[12.5px] font-semibold border border-[var(--panel-border)] bg-transparent text-foreground/60 hover:text-foreground hover:border-accent/40 hover:bg-foreground/[0.04] active:scale-[0.98] transition-all cursor-pointer disabled:opacity-40 disabled:pointer-events-none`,be=`w-full h-11 px-4 rounded-[var(--input-radius,0.75rem)] border border-[var(--panel-border)] bg-[var(--panel-bg)] text-[14px] text-foreground outline-none transition-all duration-300 placeholder:text-foreground/35 hover:border-accent/40 focus:border-accent disabled:opacity-50 disabled:cursor-not-allowed console-field`,xe=`w-full h-11 flex items-center px-4 rounded-[var(--input-radius,0.75rem)] border border-[var(--panel-border)] bg-[var(--panel-bg)] transition-all duration-300 hover:border-accent/40 focus-within:border-accent console-field`,Se=`flex-1 min-w-0 h-full bg-transparent border-none outline-none shadow-none text-[14px] text-foreground placeholder:text-foreground/35 disabled:cursor-not-allowed`,Ce=`text-[12.5px] sm:text-[13px] font-medium text-foreground/50 select-none`;function we({state:e=`saved`,label:n}){return(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11.5px] font-semibold text-foreground/50 whitespace-nowrap shrink-0`,children:[e===`saving`?(0,s.jsx)(t.G,{className:`w-3 h-3 animate-spin text-foreground/40 shrink-0`}):(0,s.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${e===`saved`?`bg-emerald-500`:e===`error`?`bg-red-500`:`bg-foreground/25`}`}),n]})}function Q({icon:e,children:n,onClick:r,disabled:i,busy:a,tone:o=`default`,className:c=``,title:l,compact:u}){return(0,s.jsxs)(`button`,{type:`button`,title:l,onClick:r,disabled:i||a,className:`${ye} ${o===`danger`?`hover:text-red-500 hover:border-red-500/40 hover:bg-red-500/[0.06]`:``} ${u?`max-sm:w-8 max-sm:px-0 max-sm:gap-0 max-sm:border-transparent max-sm:hover:border-transparent max-sm:hover:bg-foreground/[0.06]`:``} ${c}`,children:[a?(0,s.jsx)(t.G,{className:`w-3.5 h-3.5 animate-spin shrink-0`}):e?(0,s.jsx)(e,{className:`w-3.5 h-3.5 shrink-0`}):null,u?(0,s.jsx)(`span`,{className:`max-sm:hidden inline-flex items-center gap-1.5`,children:n}):n]})}function Te({icon:e,title:n,description:i,actions:a,children:o,defaultOpen:c=!0,collapsible:l=!0}){let[u,d]=(0,r.useState)(c),f=l?u:!0;return(0,s.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)]/60 bg-foreground/[0.015] overflow-hidden transition-all`,children:[(0,s.jsxs)(`div`,{className:`w-full px-4 sm:px-5 py-4 grid grid-cols-[auto_minmax(0,1fr)_auto_auto] items-center gap-x-3 sm:gap-x-3.5 gap-y-0.5 text-left`,children:[e&&(0,s.jsx)(`div`,{className:`row-start-1 col-start-1 row-span-2 self-center w-10 h-10 rounded-2xl flex items-center justify-center shrink-0 border border-[var(--panel-border)]/50 bg-accent/10 text-accent`,children:(0,s.jsx)(e,{className:`w-5 h-5`})}),(0,s.jsx)(`span`,{className:`row-start-1 col-start-2 min-w-0 text-[15px] font-bold text-foreground tracking-tight leading-tight truncate self-end`,children:n}),a&&(0,s.jsx)(`div`,{className:`row-start-1 row-span-2 col-start-3 self-center justify-self-end flex items-center gap-1 sm:gap-2 shrink-0`,children:a}),l&&(0,s.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),"aria-expanded":f,"aria-label":f?`Collapse ${n}`:`Expand ${n}`,className:`row-start-1 col-start-4 row-span-2 self-center w-8 h-8 rounded-xl border border-[var(--panel-border)]/60 hover:border-accent/40 flex items-center justify-center text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-all cursor-pointer justify-self-end`,children:(0,s.jsx)(t.Ct,{className:`w-4 h-4 transition-transform duration-200 ${f?`rotate-180`:``}`})}),i&&(0,s.jsx)(`span`,{className:`row-start-2 col-start-2 min-w-0 text-[12px] text-foreground/50 font-normal leading-snug truncate self-start`,children:i})]}),(0,s.jsx)(t.p,{initial:!1,children:f&&(0,s.jsx)(t.f.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,s.jsx)(`div`,{className:`border-t border-[var(--panel-border)]/40 p-4 sm:p-5 flex flex-col gap-5 bg-background/30`,children:o})})})]})}function Ee({label:e,hint:t,action:n,children:r,error:i}){return(0,s.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-1 sm:mb-1.5 ml-1`,children:[(0,s.jsx)(`label`,{className:Ce,children:e}),n]}),r,t&&!i&&(0,s.jsx)(`span`,{className:`text-[11px] sm:text-[11.5px] text-foreground/40 font-medium leading-snug mt-1 sm:mt-1.5 px-1`,children:t}),i&&(0,s.jsx)(`span`,{className:`text-[11.5px] font-semibold text-red-500 leading-snug mt-1 sm:mt-1.5 px-1`,children:i})]})}function De({label:e,hint:t,value:n,onChange:r,onBlur:i,placeholder:a,prefix:o,error:c,disabled:l,action:u}){return(0,s.jsx)(Ee,{label:e,hint:t,error:c,action:u,children:o?(0,s.jsxs)(`div`,{className:`${xe} ${c?`is-invalid border-red-500/60`:``} ${l?`opacity-50`:``}`,children:[(0,s.jsx)(`span`,{className:`mr-0.5 text-[14px] font-semibold text-foreground/40 select-none shrink-0`,children:o}),(0,s.jsx)(`input`,{type:`text`,value:n??``,disabled:l,placeholder:a,onChange:e=>r(e.target.value),onBlur:i,"aria-label":e,className:`${Se} no-glow`})]}):(0,s.jsx)(`input`,{type:`text`,value:n??``,disabled:l,placeholder:a,onChange:e=>r(e.target.value),onBlur:i,"aria-label":e,className:`${be} ${c?`is-invalid border-red-500/60`:``}`})})}function Oe({value:e,className:t=``,...n}){let i=(0,r.useRef)(null),a=r.default.useCallback(()=>{let e=i.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+(e.offsetHeight-e.clientHeight)}px`)},[]);return(0,r.useLayoutEffect)(a,[a,e]),(0,r.useEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(a);return e.parentElement&&t.observe(e.parentElement),()=>t.disconnect()},[a]),(0,s.jsx)(`textarea`,{ref:i,rows:1,value:e??``,onInput:a,className:`${t} resize-none overflow-hidden`,...n})}function ke({label:e,hint:t,value:n,onChange:r,onBlur:i,placeholder:a}){return(0,s.jsx)(Ee,{label:e,hint:t,children:(0,s.jsx)(Oe,{value:n??``,placeholder:a,onChange:e=>r(e.target.value),onBlur:i,"aria-label":e,className:`${be.replace(`h-11 `,``)} min-h-11 py-2.5 leading-5`})})}function Ae({label:e,hint:n,value:r,onChange:i,options:a,placeholder:o=`None`,allowEmpty:c=!0,disabled:l}){let u=[...c?[{value:``,label:o}]:[],...a.filter(e=>e.value!==``)];return(0,s.jsx)(Ee,{label:e,hint:n,children:(0,s.jsx)(t.o,{ariaLabel:e,value:r??``,options:u,onChange:i,disabled:l,className:`console-select`,dense:!0,portal:!0,direction:`auto`})})}function je({label:e,hint:t,enabled:n,onChange:r,disabled:i}){return(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-4 w-full`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0 ml-1`,children:[(0,s.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/80`,children:e}),t&&(0,s.jsx)(`span`,{className:`text-[11px] sm:text-[11.5px] text-foreground/40 font-medium leading-snug`,children:t})]}),(0,s.jsx)(Me,{enabled:n,onChange:r,disabled:i,label:e})]})}function Me({enabled:e,onChange:t,disabled:n,label:r}){return(0,s.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,onClick:n=>{n.stopPropagation(),t(!e)},className:`relative w-10 h-6 rounded-full transition-colors shrink-0 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed ${e?`bg-accent`:`bg-foreground/15`}`,children:(0,s.jsx)(`span`,{className:`absolute top-1 left-1 w-4 h-4 rounded-full bg-[var(--button-fg,#fff)] shadow transition-transform ${e?`translate-x-4`:`translate-x-0`}`})})}function Ne({saving:e,savedAt:t}){return e?(0,s.jsx)(we,{state:`saving`,label:`Saving`}):t?(0,s.jsx)(we,{state:`saved`,label:`Saved`}):null}var Pe=e=>e.trim().split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``),Fe=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1-$2`).toLowerCase(),Ie=e=>{let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)},Le=(()=>{let e=t.h,n=e?Object.keys(e):[];return n.length===0&&(n=Object.keys(t.m).filter(e=>/^[A-Z]/.test(e)&&!/Icon$/.test(e)&&!/^Lucide/.test(e)&&e!==`IconNode`)),Array.from(new Set(n.map(Fe))).sort()})(),Re=`layers.house.layout-dashboard.list.table.kanban.calendar.clock.file-text.files.folder.hard-drive.upload.download.paperclip.book-open.notebook-pen.users.user.user-plus.contact.building-2.briefcase.handshake.mail.message-square.message-circle.send.inbox.bell.megaphone.phone.shopping-cart.package.truck.receipt.credit-card.banknote.wallet.tag.percent.chart-bar.chart-line.chart-pie.trending-up.target.gauge.activity.settings.sliders-horizontal.wrench.shield.lock.key.eye.search.star.heart.bookmark.flag.pin.map-pin.globe.circle-check.circle-alert.info.circle-help.life-buoy.sparkles.zap.rocket.camera.image.video.music.mic.palette.pen-tool.scissors.stethoscope.graduation-cap.utensils.plane.car.dumbbell.leaf.sun.moon`.split(`.`),ze={money:[`banknote`,`wallet`,`credit-card`,`coins`,`dollar-sign`,`receipt`],cash:[`banknote`,`coins`,`wallet`],payment:[`credit-card`,`banknote`,`receipt`],invoice:[`receipt`,`file-text`],price:[`tag`,`dollar-sign`,`receipt`],people:[`users`,`user`,`contact`],customer:[`users`,`contact`,`user-round`],client:[`users`,`contact`,`briefcase`],team:[`users`,`users-round`],staff:[`users`,`id-card`],chat:[`message-circle`,`message-square`,`messages-square`],message:[`message-circle`,`mail`,`send`],email:[`mail`,`send`,`inbox`],task:[`list-checks`,`square-check`,`clipboard-check`],todo:[`list-checks`,`square-check`],project:[`kanban`,`folder-kanban`,`briefcase`],board:[`kanban`,`layout-dashboard`],photo:[`image`,`camera`,`images`],picture:[`image`,`images`],document:[`file-text`,`files`,`file`],doc:[`file-text`,`file`],shop:[`shopping-cart`,`store`,`shopping-bag`],store:[`store`,`shopping-bag`,`shopping-cart`],order:[`shopping-cart`,`package`,`receipt`],delivery:[`truck`,`package`],home:[`house`,`home`],booking:[`calendar-check`,`calendar`,`clock`],appointment:[`calendar-clock`,`calendar`,`clock`],schedule:[`calendar-days`,`calendar`,`clock`],event:[`calendar`,`party-popper`,`ticket`],report:[`chart-bar`,`chart-line`,`file-chart-column`],stats:[`chart-bar`,`chart-line`,`chart-pie`],analytics:[`chart-line`,`chart-bar`,`activity`],help:[`circle-help`,`life-buoy`,`info`],support:[`life-buoy`,`headset`,`circle-help`],idea:[`lightbulb`,`sparkles`],health:[`heart-pulse`,`stethoscope`,`activity`],food:[`utensils`,`chef-hat`,`pizza`],travel:[`plane`,`map`,`luggage`],location:[`map-pin`,`map`,`globe`],address:[`map-pin`,`house`],security:[`shield`,`lock`,`key`],password:[`key`,`lock`],settings:[`settings`,`sliders-horizontal`,`wrench`],file:[`file`,`file-text`,`files`,`folder`],upload:[`upload`,`cloud-upload`],video:[`video`,`film`,`clapperboard`],school:[`graduation-cap`,`book-open`,`school`],course:[`graduation-cap`,`book-open`],gym:[`dumbbell`,`activity`],garden:[`leaf`,`flower`,`sprout`],car:[`car`,`car-front`],pet:[`paw-print`,`dog`,`cat`],note:[`notebook-pen`,`sticky-note`,`pencil`],write:[`pencil`,`pen-tool`,`notebook-pen`],time:[`clock`,`timer`,`hourglass`],star:[`star`,`sparkles`],favourite:[`star`,`heart`,`bookmark`],favorite:[`star`,`heart`,`bookmark`]},Be=(e,t)=>{if(Math.abs(e.length-t.length)>2)return 3;let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=n[0];n[0]=r;for(let a=1;a<=t.length;a++){let o=n[a];n[a]=Math.min(n[a]+1,n[a-1]+1,i+(e[r-1]===t[a-1]?0:1)),i=o}}return n[t.length]},Ve=(e,t)=>{let n=0;for(let r of t)r===e[n]&&n++;return n===e.length};function He(e,t=96,n=Le){let r=e.trim().toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``);if(!r)return[];let i=r.split(`-`).filter(Boolean),a=new Set(n),o=new Map,s=(e,t)=>{a.has(e)&&o.set(e,Math.max(o.get(e)||0,t))};for(let e of n){let t=e.split(`-`);if(e===r){s(e,100);continue}if(e.startsWith(r)){s(e,90);continue}if(t.some(e=>e===r)){s(e,85);continue}if(t.some(e=>e.startsWith(r))){s(e,75);continue}if(e.includes(r)){s(e,65);continue}if(i.length>1&&i.every(e=>t.some(t=>t.startsWith(e)))){s(e,60);continue}}for(let e of i){for(let t of ze[e]||[])s(t,70);if(e.endsWith(`s`))for(let t of ze[e.slice(0,-1)]||[])s(t,70)}if(o.size===0&&r.length>=3)for(let e of n)e.split(`-`).some(e=>Be(r,e)<=(r.length>5?2:1))?s(e,40):r.length>=4&&Ve(r,e.replace(/-/g,``))&&s(e,20);let c=e=>{let t=Re.indexOf(e);return t===-1?Re.length:t};return Array.from(o.entries()).sort((e,t)=>t[1]-e[1]||c(e[0])-c(t[0])||e[0].length-t[0].length||e[0].localeCompare(t[0])).slice(0,t).map(([e])=>e)}function Ue(e){if(!e)return t.Z;let n=e.trim(),r=t.m;return r[Pe(n)]||r[n]||t.Z}function We({name:e,className:t}){return(0,r.createElement)(Ue(e),{className:t})}function Ge({label:e=`Icon`,hint:n=`Shown next to the name in the menu.`,value:i,onChange:a}){let[o,c]=(0,r.useState)(``),l=(i||``).trim(),u=(0,r.useMemo)(()=>He(o),[o]),d=o.trim().length>0;return(0,s.jsx)(Ee,{label:e,hint:n,children:(0,s.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,s.jsxs)(`div`,{className:xe,children:[l&&!d?(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-2 mr-2.5 shrink-0 min-w-0 text-accent`,children:[(0,s.jsx)(`span`,{className:`w-7 h-7 -ml-1 rounded-lg bg-accent/[0.08] border border-accent/25 flex items-center justify-center shrink-0`,children:(0,s.jsx)(We,{name:l,className:`w-4 h-4`})}),(0,s.jsx)(`span`,{className:`text-[13px] font-semibold truncate`,children:Ie(Fe(l))}),(0,s.jsx)(t.wt,{className:`w-3.5 h-3.5 shrink-0`})]}):(0,s.jsx)(t.N,{className:`w-4 h-4 mr-2.5 text-foreground/30 shrink-0`}),(0,s.jsx)(`input`,{type:`text`,value:o,onChange:e=>c(e.target.value),placeholder:l?`Type a word to change it`:`Type a word, e.g. calendar`,"aria-label":`Search icons`,className:`${Se} no-glow`})]}),d&&(0,s.jsx)(`div`,{className:`rounded-[var(--input-radius,0.75rem)] border border-[var(--panel-border)] bg-[var(--panel-bg)] p-2 max-h-56 overflow-y-auto`,children:u.length>0?(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>{let t=Fe(l).toLowerCase()===e;return(0,s.jsx)(`button`,{type:`button`,title:Ie(e),"aria-label":Ie(e),"aria-pressed":t,onClick:()=>{a(e),c(``)},className:`w-9 h-9 rounded-lg flex items-center justify-center transition-all cursor-pointer ${t?`bg-accent text-[var(--button-fg,#fff)] ring-2 ring-accent/40`:`text-foreground/60 hover:text-foreground hover:bg-foreground/[0.06]`}`,children:(0,s.jsx)(We,{name:e,className:`w-4 h-4`})},e)})}):(0,s.jsx)(`span`,{className:`block px-2 py-2 text-[12px] font-medium text-foreground/45`,children:`Nothing close to that. Try a simpler word, like calendar or people.`})})]})})}var Ke=/(https?:\/\/[^\s]+|src\/[A-Za-z0-9_./-]+)/g,qe=e=>e.split(Ke).map((e,t)=>({text:e,mark:t%2==1})).filter(e=>e.text),Je=e=>{let t=e.indexOf(`exactly: `);if(t===-1)return qe(e);let n=e.slice(0,t+9),r=e.slice(t+9),i=r.indexOf(` — `);return[...qe(n),{text:i===-1?r:r.slice(0,i),mark:!0},...qe(i===-1?``:r.slice(i))]},Ye=`text-accent font-semibold bg-accent/[0.08] rounded-[4px] px-1 -mx-[1px] [overflow-wrap:anywhere]`;function Xe({text:e}){return(0,s.jsx)(s.Fragment,{children:Je(e).map((e,t)=>e.mark?(0,s.jsx)(`span`,{className:Ye,children:e.text},t):(0,s.jsx)(r.default.Fragment,{children:e.text},t))})}function Ze({title:e=`Ask your assistant`,description:n,prompt:i,compact:a=!1,locked:o=!1}){let[c,l]=(0,r.useState)(!1),u=i.includes(`
|
|
2
|
+
`);return o?null:(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 min-w-0 max-w-full rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] ${a?`px-4 py-3.5`:`px-5 py-4`}`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,s.jsx)(`span`,{className:`text-[12px] font-extrabold tracking-tight text-gradient`,children:e}),(0,s.jsxs)(`button`,{type:`button`,onClick:()=>{navigator.clipboard?.writeText(i),l(!0),setTimeout(()=>l(!1),2e3)},className:`inline-flex items-center justify-center gap-1.5 h-8 px-3 rounded-[var(--btn-radius,0.75rem)] text-[12px] font-semibold shrink-0 border ${c?`copy-btn-done border-emerald-500/30 bg-emerald-500/10 text-emerald-500 cursor-pointer`:`copy-btn cursor-pointer`}`,children:[c?(0,s.jsx)(t.wt,{className:`copy-icon w-3.5 h-3.5`}):(0,s.jsx)(t.ft,{className:`copy-icon w-3.5 h-3.5`}),c?`Copied`:`Copy`]})]}),n&&(0,s.jsx)(`p`,{className:`text-[12.5px] text-foreground/50 font-medium leading-relaxed break-words`,children:n}),(0,s.jsx)(`div`,{className:`text-[13.5px] font-medium leading-relaxed break-words [overflow-wrap:anywhere]`,children:u?i.split(`
|
|
3
|
+
`).map((e,t)=>(0,s.jsx)(`p`,{className:t===0?`text-foreground font-semibold`:`text-foreground/65 mt-1.5`,children:(0,s.jsx)(Xe,{text:e})},t)):(0,s.jsxs)(`p`,{className:`text-foreground/80`,children:[`“`,(0,s.jsx)(Xe,{text:i}),`”`]})})]})}var Qe=`w-11 h-11 shrink-0 rounded-[var(--input-radius,0.75rem)] overflow-hidden border border-[var(--panel-border)]`;function $e({label:e,hint:n,value:i,onChange:a,accept:o=`image/*`,action:c,clearable:l=!0,tips:u}){let{user:d}=ee(),[f,p]=(0,r.useState)(!1),[m,h]=(0,r.useState)(``),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(!1),b=(0,s.jsx)(`input`,{type:`file`,accept:o,"aria-label":i?`Replace ${e}`:`Upload ${e}`,disabled:f,onChange:async e=>{let n=e.target.files?.[0];if(e.target.value=``,!(!n||f)){p(!0),h(``);try{a(await t.a(n,d))}catch(e){h(t.i(e))}p(!1),y(!1)}},className:`sr-only`});return(0,s.jsxs)(Ee,{label:e,hint:n,error:m,action:c,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`input`,{type:`text`,"aria-label":e,value:i??``,placeholder:`Upload one, or paste a link`,onChange:e=>a(e.target.value),className:be}),i&&!f?(0,s.jsxs)(`div`,{className:`${Qe} relative group/pic`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:()=>y(e=>!e),"aria-label":`Change ${e}`,"aria-expanded":v,className:`block w-full h-full cursor-pointer`,children:(0,s.jsx)(`img`,{src:i,alt:e,className:`w-full h-full object-cover`})}),(0,s.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center gap-1 bg-background/85 transition-opacity duration-200 ${v?`opacity-100`:`opacity-0 pointer-events-none group-hover/pic:opacity-100 group-hover/pic:pointer-events-auto focus-within:opacity-100 focus-within:pointer-events-auto`}`,children:[(0,s.jsxs)(`label`,{title:`Replace ${e}`,className:`w-6 h-6 rounded-md flex items-center justify-center text-foreground/60 hover:text-accent hover:bg-foreground/10 transition-colors cursor-pointer`,children:[(0,s.jsx)(t.mt,{className:`w-3.5 h-3.5`}),b]}),l&&(0,s.jsx)(`button`,{type:`button`,onClick:()=>{h(``),y(!1),a(``)},"aria-label":`Remove ${e}`,title:`Remove ${e}`,className:`w-6 h-6 rounded-md flex items-center justify-center text-foreground/60 hover:text-red-500 hover:bg-red-500/10 transition-colors cursor-pointer`,children:(0,s.jsx)(t._,{className:`w-3.5 h-3.5`})})]})]}):(0,s.jsxs)(`label`,{title:`Upload ${e}`,className:`${Qe} flex items-center justify-center bg-[var(--panel-bg)] text-foreground/40 hover:text-accent hover:border-accent/40 focus-within:border-accent transition-colors ${f?`pointer-events-none`:`cursor-pointer`}`,children:[f?(0,s.jsx)(t.G,{className:`w-4 h-4 animate-spin text-accent`}):(0,s.jsx)(t.mt,{className:`w-4 h-4`}),b]})]}),!!u?.length&&(0,s.jsxs)(`div`,{className:`mt-2 px-1`,children:[(0,s.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),"aria-expanded":g,className:`inline-flex items-center gap-1 text-[11.5px] font-semibold text-foreground/40 hover:text-foreground/70 transition-colors cursor-pointer`,children:[(0,s.jsx)(t.xt,{className:`w-3 h-3 shrink-0 transition-transform duration-200 ${g?`rotate-90`:``}`}),`Which picture should I upload?`]}),g&&(0,s.jsx)(`ul`,{className:`flex flex-col gap-1 mt-1.5 ml-4`,children:u.map(e=>(0,s.jsxs)(`li`,{className:`text-[11.5px] text-foreground/40 font-medium leading-snug flex gap-1.5`,children:[(0,s.jsx)(`span`,{"aria-hidden":!0,className:`text-accent/60`,children:`•`}),e]},e))})]})]})}var et=[`A wide picture sits best across a page — about 1600 by 900.`,`JPG or PNG, and under 1 MB if you can: a heavy picture makes the page slow to open.`,`Your own photo beats a stock one. People can tell.`,`No writing baked into the picture — your assistant sets the words, so they stay readable on a phone.`],tt=[`A wide picture, not a square one — it sits in a short bar about 40px tall.`,`PNG with a see-through background looks right on both the light and the dark theme.`],nt=[`A square picture — 64 by 64 is plenty.`,`One shape or one letter. A whole logo turns to mush at this size.`],rt=e=>typeof e==`string`&&/^https?:\/\/\S+$/.test(e.trim())&&RegExp(`(/|%2F)pub_form_uploads(/|%2F)`,`i`).test(e),it={anyone:{collectionName:`user_submissions`,chip:`Anyone`,filterLabel:`From anyone`},signedIn:{collectionName:`user_requests`,chip:`Signed-in user`,filterLabel:`From signed-in users`}},at=`Create a form called Ask a question for website visitors. Ask for full name (required), email (required) and their question as long text (required). Put it on my /contact page built into the page, send the answers to my Inbox, and show a thank-you message after sending.`,ot=[`id`,`source`,`uid`,`submittedAt`,`avatarUrl`,`isArchived`,`name`,`full_name`,`email`,`contactEmail`,`topic`],st=e=>{let t=e.submittedAt;if(!t)return 0;if(typeof t.toMillis==`function`)return t.toMillis();if(typeof t.toDate==`function`)return t.toDate().getTime();let n=new Date(t).getTime();return Number.isNaN(n)?0:n},ct=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)},lt=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()},ut=e=>{let t=st(e);if(!t)return`Older`;let n=Math.round((lt(Date.now())-lt(t))/864e5);return n<=0?`Today`:n===1?`Yesterday`:n<7?`This week`:n<30?`This month`:`Older`},dt=e=>e.reduce((e,t)=>{let n=ut(t),r=e[e.length-1];return r&&r.label===n?r.items.push(t):e.push({label:n,items:[t]}),e},[]);function ft({label:e}){return(0,s.jsxs)(`div`,{className:`md:hidden flex items-center gap-3 pt-1 first:pt-0 select-none`,children:[(0,s.jsx)(`span`,{className:`text-[10.5px] font-bold uppercase tracking-[0.18em] text-foreground/35 shrink-0`,children:e}),(0,s.jsx)(`span`,{className:`h-px flex-1 bg-[var(--panel-border)]/60`})]})}var pt=e=>e.submitterName||e.name||e.full_name||`Anonymous`,mt=e=>e.contactEmail||e.email||`No email provided`;function ht(e){let[n,a]=(0,r.useState)([]),[o,s]=(0,r.useState)(!0);return(0,r.useEffect)(()=>{let n=!1,r=it[e].collectionName,o=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Ht,r),(0,i.orderBy)(`submittedAt`,`desc`)),async r=>{let o=[];for(let n of r.docs){let r={...n.data()},a=``;if(r.uid&&r.uid!==`guest`)try{let e=await(0,i.getDoc)((0,i.doc)(t.Ht,`user_profiles`,r.uid));if(e.exists()){let t=e.data();(t.avatar||t.photoURL)&&(a=t.avatar||t.photoURL),r.name||=t.name||t.displayName,r.email||=t.email,r.contactEmail||=t.email}}catch(e){console.error(`Failed to fetch profile`,e)}o.push({...r,id:n.id,source:e,avatarUrl:a})}n||(a(o),s(!1))},e=>{console.error(`Error loading ${r}:`,e),n||s(!1)});return()=>{n=!0,o()}},[e]),{items:n,loading:o}}function gt({source:e}){return(0,s.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:it[e].chip})}function _t({item:e,isExpanded:n,onToggle:r,onArchive:i,onDelete:a,busy:o,dimmed:l}){let u=pt(e),d=e.avatarUrl||e.submitterAvatar,f=!!e.uid&&e.uid!==`guest`,p=Object.entries(e).filter(([e])=>!ot.includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`),m=e.topic?[[`topic`,e.topic],...p]:p,h=p.map(([,e])=>typeof e==`string`&&!rt(e)?e.trim():``).find(Boolean)||e.topic||``;return(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden hover:border-accent/40 transition-all duration-300 ${l?`opacity-60 hover:opacity-100`:``}`,children:[(0,s.jsxs)(`div`,{className:`w-full flex items-center gap-3 p-3.5 md:p-4 md:px-6`,children:[(0,s.jsxs)(`button`,{type:`button`,onClick:r,"aria-expanded":n,className:`flex items-center gap-3 md:gap-4 flex-1 min-w-0 text-left cursor-pointer`,children:[(0,s.jsx)(`div`,{className:`relative shrink-0`,children:d?(0,s.jsx)(`img`,{src:d,alt:``,className:`w-9 h-9 md:w-10 md:h-10 rounded-full object-cover border border-[var(--panel-border)] shadow-sm`}):(0,s.jsx)(`div`,{className:`w-9 h-9 md:w-10 md:h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm uppercase`,children:(u||`A`)[0]})}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,s.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:u}),(0,s.jsxs)(`span`,{className:`max-md:hidden inline-flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(gt,{source:e.source}),e.formId&&(0,s.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-foreground/40 bg-foreground/5 px-2 py-0.5 rounded-md border border-[var(--panel-border)] shrink-0`,children:String(e.formId).replace(/_/g,` `)})]})]}),(0,s.jsxs)(`span`,{className:`text-[12px] md:text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:[(0,s.jsx)(t.H,{className:`w-3.5 h-3.5 shrink-0`}),` `,mt(e)]}),!n&&h&&(0,s.jsx)(`span`,{className:`max-md:hidden block text-[13px] text-foreground/40 truncate mt-1`,children:h})]})]}),(0,s.jsx)(`button`,{type:`button`,onClick:r,tabIndex:-1,"aria-hidden":`true`,className:`md:hidden w-8 h-8 -mr-1 flex items-center justify-center rounded-lg text-foreground/30 hover:text-accent hover:bg-foreground/5 transition-colors shrink-0 cursor-pointer`,children:(0,s.jsx)(t.Ct,{className:`w-4 h-4 transition-transform duration-300 ${n?`rotate-180`:``}`})}),(0,s.jsxs)(`div`,{className:`max-md:hidden flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:ct(e.submittedAt)}),(0,s.jsx)(Q,{icon:e.isArchived?t.At:t.Pt,onClick:i,busy:o,children:e.isArchived?`Restore`:`Archive`}),(0,s.jsx)(Q,{icon:t.E,tone:`danger`,onClick:a,children:`Delete`}),(0,s.jsx)(`button`,{type:`button`,onClick:r,"aria-label":n?`Hide details from ${u}`:`Show details from ${u}`,className:`p-1.5 text-foreground/40 transition-transform duration-300 cursor-pointer ${n?`rotate-180`:``}`,children:(0,s.jsx)(t.Ct,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(t.p,{children:n&&(0,s.jsx)(t.f.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,s.jsxs)(`div`,{className:`px-3.5 md:px-6 py-4 md:py-5 border-t border-[var(--panel-border)]/40`,children:[(0,s.jsxs)(`div`,{className:`md:hidden flex flex-wrap items-center gap-2 mb-3`,children:[(0,s.jsx)(gt,{source:e.source}),e.formId&&(0,s.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-foreground/40 bg-foreground/5 px-2 py-0.5 rounded-md border border-[var(--panel-border)] shrink-0`,children:String(e.formId).replace(/_/g,` `)}),(0,s.jsx)(`span`,{className:`md:hidden text-[11px] font-medium text-foreground/40 shrink-0`,children:ct(e.submittedAt)})]}),m.length>0?(0,s.jsx)(`div`,{className:`rounded-xl border border-[var(--panel-border)]/60 bg-foreground/[0.02] divide-y divide-[var(--panel-border)]/40 overflow-hidden`,children:m.map(([e,n])=>(0,s.jsxs)(`div`,{className:`px-3.5 md:px-5 py-3 md:py-3.5`,children:[(0,s.jsx)(`span`,{className:`block text-[11px] font-bold uppercase tracking-widest text-foreground/40 mb-1`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}),rt(n)?(0,s.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-2 text-[14px] md:text-[15px] font-semibold text-accent hover:underline break-all [overflow-wrap:anywhere]`,children:[(0,s.jsx)(t.R,{className:`w-4 h-4 shrink-0`}),t.r(n)]}):(0,s.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/85 leading-relaxed whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:typeof n==`boolean`?n?`Yes`:`No`:e.toLowerCase()===`budget`&&n?`$${n}`:String(n??``)||`No data provided`})]},e))}):(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/40 font-medium`,children:`This form only asked for a name and email.`}),f&&(0,s.jsx)(c.Link,{to:`/users/${e.uid}`,className:`inline-flex mt-3 text-[12.5px] font-bold text-accent hover:underline`,children:`Open this person’s profile`}),(0,s.jsxs)(`div`,{className:`md:hidden flex items-center justify-end gap-2 mt-4`,children:[(0,s.jsx)(Q,{icon:e.isArchived?t.At:t.Pt,onClick:i,busy:o,children:e.isArchived?`Restore`:`Archive`}),(0,s.jsx)(Q,{icon:t.E,tone:`danger`,onClick:a,children:`Delete`})]})]})})})]})}function vt(){let e=ht(`anyone`),n=ht(`signedIn`),[a,o]=(0,r.useState)(`all`),[c,l]=(0,r.useState)(null),[u,d]=(0,r.useState)(!1),[f,p]=(0,r.useState)(null),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(!1),v=e.loading||n.loading,y=(0,r.useMemo)(()=>[...e.items,...n.items].sort((e,t)=>st(t)-st(e)),[e.items,n.items]),b=a===`all`?y:y.filter(e=>e.source===a),x=b.filter(e=>!e.isArchived),S=b.filter(e=>e.isArchived),C=e=>`${e.source}:${e.id}`,w=e=>l(t=>t===C(e)?null:C(e)),T=async e=>{p(C(e));try{await(0,i.updateDoc)((0,i.doc)(t.Ht,it[e.source].collectionName,e.id),{isArchived:!e.isArchived}),!e.isArchived&&c===C(e)&&l(null)}catch(e){console.error(`Failed to archive`,e)}p(null)},E=async()=>{if(m){_(!0);try{await(0,i.deleteDoc)((0,i.doc)(t.Ht,it[m.source].collectionName,m.id)),c===C(m)&&l(null),h(null)}catch(e){console.error(`Failed to delete`,e)}_(!1)}},D=[{key:`all`,label:`Everything`,short:`All`},{key:`anyone`,label:it.anyone.filterLabel,short:`Anyone`},{key:`signedIn`,label:it.signedIn.filterLabel,short:`Signed in`}];return(0,s.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,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,s.jsx)(se,{children:`Inbox`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/inbox`]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,s.jsx)(`div`,{className:`flex justify-start`,children:(0,s.jsx)(le,{})}),(0,s.jsxs)(`div`,{className:`w-full flex-1 flex flex-col glass-panel rounded-2xl md:rounded-3xl p-3 sm:p-6 md:p-10 relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,s.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,s.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col`,children:v?(0,s.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[500px]`,children:(0,s.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`})}):y.length===0?(0,s.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-8 gap-6`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent shadow-inner`,children:(0,s.jsx)(t.et,{className:`w-6 h-6`})}),(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`Nothing here yet`}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/50 font-medium max-w-md`,children:`Everything people send you through a form on your site lands here.`})]}),(0,s.jsx)(`div`,{className:`w-full max-w-xl text-left`,children:(0,s.jsx)(Ze,{prompt:at})})]}):(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 pb-8`,children:[(0,s.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 mb-2`,children:D.map(e=>(0,s.jsxs)(`button`,{type:`button`,onClick:()=>o(e.key),"aria-pressed":a===e.key,"aria-label":e.label,className:`h-8 md:h-9 px-3 md:px-4 rounded-full text-[12px] md:text-[12.5px] font-bold border transition-all cursor-pointer ${a===e.key?`bg-accent/10 border-accent/40 text-accent`:`border-[var(--panel-border)]/70 bg-background/60 text-foreground/60 hover:text-foreground hover:border-accent/30`}`,children:[(0,s.jsx)(`span`,{className:`sm:hidden`,children:e.short}),(0,s.jsx)(`span`,{className:`max-sm:hidden`,children:e.label})]},e.key))}),x.length===0&&(0,s.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,s.jsx)(`p`,{className:`text-[14px] font-bold text-foreground/50`,children:S.length>0?`Everything here is archived.`:`Nothing matches this filter.`})}),(0,s.jsx)(t.p,{children:dt(x).map(e=>(0,s.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,s.jsx)(ft,{label:e.label}),e.items.map(e=>(0,s.jsx)(_t,{item:e,isExpanded:c===C(e),onToggle:()=>w(e),onArchive:()=>T(e),onDelete:()=>h(e),busy:f===C(e)},C(e)))]},e.label))}),S.length>0&&(0,s.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-[var(--panel-border)]/30`,children:[(0,s.jsx)(`div`,{className:`flex justify-center`,children:(0,s.jsxs)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:`flex items-center gap-2 text-[11px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors py-2 uppercase tracking-widest cursor-pointer`,children:[u?`Hide`:`View`,` `,S.length,` archived`,(0,s.jsx)(t.Ct,{className:`w-3.5 h-3.5 transition-transform duration-300 ${u?`rotate-180`:``}`})]})}),(0,s.jsx)(t.p,{children:u&&(0,s.jsx)(t.f.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4`,children:(0,s.jsx)(`div`,{className:`flex flex-col gap-3`,children:dt(S).map(e=>(0,s.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,s.jsx)(ft,{label:e.label}),e.items.map(e=>(0,s.jsx)(_t,{item:e,isExpanded:c===C(e),onToggle:()=>w(e),onArchive:()=>T(e),onDelete:()=>h(e),busy:f===C(e),dimmed:!0},C(e)))]},e.label))})})})]})]})})]})]}),(0,s.jsx)(_e,{isOpen:!!m,title:`Delete this message?`,message:`This removes it for good. There is no undo — archive it instead if you only want it out of the way.`,onConfirm:E,onCancel:()=>h(null),isProcessing:g,confirmText:`Yes, delete`})]})}var yt=e=>{if(!e)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]};function bt({title:e=`Drive`,subtitle:n=`/templates/drive`,backUrl:a=`/templates`,filesCollection:u=`pub_files`,config:d,customContent:f,footer:p}){let{user:m,userRole:h}=ee(),g=!!d,_=h===`admin`,v=u,y=u.startsWith(`user_`),[b,x]=(0,r.useState)([]),[S,C]=(0,r.useState)(!0),[w,T]=(0,r.useState)(null),[E,D]=(0,r.useState)(!0),[O,k]=(0,r.useState)(null),[A,j]=(0,r.useState)(!1),[M,N]=(0,r.useState)(null),[P,F]=(0,r.useState)(null),[I,L]=(0,r.useState)({}),[R,z]=(0,r.useState)(!1),[B,V]=(0,r.useState)(null),[te,H]=(0,r.useState)(``),[U,W]=(0,r.useState)(!1),[G,K]=(0,r.useState)(``),[q,J]=(0,r.useState)(!1),Y=(0,r.useRef)(null);(0,r.useEffect)(()=>{D(!0)},[w?._id]),(0,r.useEffect)(()=>{if(!(y&&!m))return C(!0),(0,i.onSnapshot)(y?(0,i.query)((0,i.collection)(t.Ht,u),(0,i.where)(`uid`,`==`,m.uid)):(0,i.query)((0,i.collection)(t.Ht,u),(0,i.orderBy)(`createdAt`,`desc`)),e=>{let t=e.docs.map(e=>({_id:e.id,...e.data()}));t.sort((e,t)=>(t.createdAt?.toMillis?.()||0)-(e.createdAt?.toMillis?.()||0)),x(t),C(!1)},e=>{console.warn(`Error listening to ${u}:`,e),C(!1)})},[u,y,m?.uid]);let ne=e=>!!m&&(e.uid===m.uid||_),re=e=>{V(e),H(e.name),K(``),z(!0)},ie=()=>{V(null),K(``),z(!0)},ae=async e=>{if(e.preventDefault(),!(!B||!te.trim()||!m)){W(!0),K(``);try{let e=`${v}/${`${Date.now()}_${B.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`,n=(0,o.ref)(t.Wt,e);await(0,o.uploadBytes)(n,B,{customMetadata:{ownerId:m.uid}});let r=await(0,o.getDownloadURL)(n);await(0,i.addDoc)((0,i.collection)(t.Ht,u),{fileName:te.trim(),fileType:B.type||`unknown`,fileSize:B.size,downloadURL:r,storagePath:e,uid:m.uid,uploaderEmail:m.email||``,createdAt:(0,i.serverTimestamp)()}),z(!1),V(null),H(``)}catch(e){K(e?.code===`storage/unauthorized`?`You do not have permission to upload here.`:e?.message||`Upload failed. Please try again.`)}W(!1)}},oe=async()=>{if(O){j(!0);try{await Promise.all([(0,o.deleteObject)((0,o.ref)(t.Wt,O.storagePath||O.downloadURL)).catch(e=>console.warn(`Storage object missing:`,e)),(0,i.deleteDoc)((0,i.doc)(t.Ht,u,O._id))]),k(null)}catch(e){console.error(`Delete failed:`,e)}j(!1)}},X=async()=>{if(!M||!M.name.trim()){N(null);return}try{await(0,i.updateDoc)((0,i.doc)(t.Ht,u,M.id),{fileName:M.name.trim()})}catch(e){console.error(`Rename failed:`,e)}N(null)},ce=(e,t)=>{navigator.clipboard.writeText(e),F(t),setTimeout(()=>F(null),2e3)},Z=(e,n=!1)=>{let r=n?`w-16 h-16`:`w-10 h-10`,i=n?`w-8 h-8`:`w-5 h-5`;return e.includes(`video`)||e.includes(`audio`)?(0,s.jsx)(`div`,{className:`${r} flex items-center justify-center bg-purple-500/10 text-purple-500 rounded-lg`,children:(0,s.jsx)(t.y,{className:i})}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,s.jsx)(`div`,{className:`${r} flex items-center justify-center bg-blue-500/10 text-blue-500 rounded-lg`,children:(0,s.jsx)(t.at,{className:i})}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,s.jsx)(`div`,{className:`${r} flex items-center justify-center bg-yellow-500/10 text-yellow-500 rounded-lg`,children:(0,s.jsx)(t.Ft,{className:i})}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,s.jsx)(`div`,{className:`${r} flex items-center justify-center bg-emerald-500/10 text-emerald-500 rounded-lg`,children:(0,s.jsx)(t.pt,{className:i})}):(0,s.jsx)(`div`,{className:`${r} flex items-center justify-center bg-foreground/5 text-foreground/40 rounded-lg`,children:(0,s.jsx)(t.it,{className:i})})};return(0,s.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`,onDragOver:e=>{e.preventDefault(),J(!0)},onDragLeave:e=>{e.preventDefault(),J(!1)},onDrop:e=>{e.preventDefault(),J(!1),e.dataTransfer.files?.[0]&&re(e.dataTransfer.files[0])},children:[(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6`,children:[!g&&(0,s.jsxs)(c.Link,{to:a,className:`inline-flex items-center gap-2 text-[13px] font-bold text-foreground/50 hover:text-accent transition-colors mb-4`,children:[(0,s.jsx)(t.Mt,{className:`w-4 h-4`}),` Back to templates`]}),(0,s.jsx)(se,{children:e}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),n]})]}),g&&(0,s.jsx)(`div`,{className:`mb-6`,children:(0,s.jsx)(le,{})}),(0,s.jsxs)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-2xl md:rounded-3xl overflow-hidden flex-1 shadow-2xl min-h-[420px] md:min-h-[520px] bg-background flex flex-col`,children:[(0,s.jsxs)(`div`,{className:`p-4 md:p-8 flex items-center justify-between gap-3 md:gap-6 border-b border-[var(--panel-border)]/50 bg-background/50`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-lg md:text-2xl font-extrabold text-foreground tracking-tight`,children:`Files`}),(0,s.jsx)(`p`,{className:`max-sm:hidden block text-[12px] md:text-[13px] mt-1 md:mt-2 text-foreground/60 font-medium`,children:y?`Only you can see the files you upload here.`:`Everyone who can open this page can see these files.`})]}),m&&!f&&(0,s.jsxs)(t.s,{onClick:ie,title:`Add file`,className:`flex items-center justify-center gap-2 w-9 h-9 p-0 sm:w-auto sm:h-auto sm:px-5 sm:py-2.5 rounded-xl text-[13px] font-bold shadow-md shrink-0`,children:[(0,s.jsx)(t.I,{className:`w-4 h-4`}),` `,(0,s.jsx)(`span`,{className:`max-sm:hidden`,children:`Add file`})]})]}),f?(0,s.jsx)(`div`,{className:`fbos-content-slot p-4 md:p-8 flex-1`,children:(0,s.jsx)(f,{files:b,loading:S,user:m,uploadFile:re,deleteFile:k,openUploadModal:ie,config:d})}):(0,s.jsxs)(`div`,{className:`p-3.5 sm:p-6 md:p-8 flex-1 relative`,children:[S&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,s.jsx)(t.G,{className:`w-8 h-8 text-accent animate-spin`})}),b.length>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`sm:hidden flex flex-col divide-y divide-[var(--panel-border)]/40 border border-[var(--panel-border)] rounded-2xl overflow-hidden bg-background`,children:b.map(e=>(0,s.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:()=>T(e),"aria-label":`Preview ${e.fileName}`,className:`w-10 h-10 shrink-0 rounded-lg overflow-hidden border border-[var(--panel-border)]/50 bg-foreground/[0.02] flex items-center justify-center`,children:e.fileType.startsWith(`image/`)?(0,s.jsx)(`img`,{src:e.downloadURL,alt:``,className:`w-full h-full object-cover`}):Z(e.fileType)}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,onClick:()=>!M&&T(e),children:[M?.id===e._id?(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,value:M.name,onChange:e=>N({...M,name:e.target.value}),onBlur:X,onKeyDown:e=>{e.key===`Enter`&&X(),e.key===`Escape`&&N(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[13px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full`}):(0,s.jsx)(`span`,{className:`block text-[13px] font-bold text-foreground truncate`,children:e.fileName}),(0,s.jsx)(`span`,{className:`block text-[10.5px] text-foreground/40 font-bold uppercase tracking-wider mt-0.5`,children:yt(e.fileSize)})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:()=>ce(e.downloadURL,e._id),className:`p-2 rounded-lg text-foreground/50 hover:bg-foreground/5 hover:text-emerald-500 transition-colors`,title:`Copy link`,children:P===e._id?(0,s.jsx)(t.wt,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.q,{className:`w-4 h-4`})}),ne(e)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{type:`button`,onClick:()=>N({id:e._id,name:e.fileName}),className:`p-2 rounded-lg text-foreground/50 hover:bg-foreground/5 hover:text-purple-500 transition-colors`,title:`Rename`,children:(0,s.jsx)(t.L,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>k(e),className:`p-2 rounded-lg text-foreground/50 hover:bg-red-500/10 hover:text-red-500 transition-colors`,title:`Delete`,children:(0,s.jsx)(t.E,{className:`w-4 h-4`})})]})]})]},e._id))}),(0,s.jsx)(`div`,{className:`max-sm:hidden grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:b.map(e=>(0,s.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 h-[190px] relative`,children:[(0,s.jsxs)(`div`,{className:`absolute top-2 right-2 flex flex-col gap-1 opacity-100 md:opacity-0 md: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,s.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,s.jsx)(t.ut,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ce(e.downloadURL,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:P===e._id?(0,s.jsx)(t.wt,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.q,{className:`w-4 h-4`})}),ne(e)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),N({id:e._id,name:e.fileName})},className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-purple-500 transition-colors`,title:`Rename`,children:(0,s.jsx)(t.L,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),k(e)},className:`p-1.5 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,title:`Delete`,children:(0,s.jsx)(t.E,{className:`w-4 h-4`})})]})]}),(0,s.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`,onClick:()=>T(e),children:e.fileType.startsWith(`image/`)?(0,s.jsxs)(s.Fragment,{children:[I[e._id]!==!1&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 z-0`,children:(0,s.jsx)(t.G,{className:`w-5 h-5 text-accent animate-spin`})}),(0,s.jsx)(`img`,{src:e.downloadURL,alt:``,className:`absolute inset-0 w-full h-full object-contain p-2 transition-opacity duration-300 ${I[e._id]===!1?`opacity-100`:`opacity-0`}`,onLoad:()=>L(t=>({...t,[e._id]:!1})),onError:()=>L(t=>({...t,[e._id]:!1}))})]}):Z(e.fileType,!0)}),(0,s.jsxs)(`div`,{className:`p-3 flex flex-col justify-center flex-1 min-w-0`,onClick:()=>!M&&T(e),children:[M?.id===e._id?(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,value:M.name,onChange:e=>N({...M,name:e.target.value}),onBlur:X,onKeyDown:e=>{e.key===`Enter`&&X(),e.key===`Escape`&&N(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[12.5px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full`}):(0,s.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,s.jsx)(`span`,{className:`text-[11px] text-foreground/40 font-bold uppercase tracking-wider mt-1 select-none`,children:yt(e.fileSize)})]})]},e._id))})]}):!S&&(0,s.jsxs)(`div`,{onClick:()=>m&&z(!0),className:`min-h-[320px] flex flex-col items-center justify-center text-center cursor-pointer group`,children:[(0,s.jsx)(t.mt,{className:`w-12 h-12 text-foreground/15 mb-4`}),(0,s.jsx)(`p`,{className:`text-[20px] font-bold text-foreground/50 group-hover:text-foreground/70 transition-colors`,children:`No files yet`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium mt-1 text-foreground/40`,children:m?`Click here or drag a file in to upload`:`Sign in to upload a file`})]})]})]}),p,(0,s.jsx)(t.p,{children:R&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{onClick:()=>!U&&z(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,s.jsxs)(t.f.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,s.jsxs)(`div`,{className:`flex items-center justify-between p-4 md:p-6 border-b border-[var(--panel-border)]/50`,children:[(0,s.jsx)(`span`,{className:`text-[16px] font-extrabold text-foreground tracking-tight`,children:`Upload a file`}),(0,s.jsx)(`button`,{onClick:()=>!U&&z(!1),className:`text-foreground/40 hover:text-foreground transition-colors`,children:(0,s.jsx)(t._,{className:`w-5 h-5`})})]}),B?(0,s.jsxs)(`form`,{onSubmit:ae,className:`p-4 md:p-6 flex flex-col gap-5 md:gap-6`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-4 bg-foreground/[0.03] p-4 rounded-2xl border border-[var(--panel-border)]`,children:[Z(B.type),(0,s.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-4`,children:[(0,s.jsx)(`span`,{className:`text-[13px] font-bold text-foreground truncate`,children:B.name}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold uppercase tracking-wider mt-1`,children:yt(B.size)})]}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>!U&&V(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,s.jsx)(t.E,{className:`w-4 h-4`})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,s.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest pl-1`,children:`File name`}),(0,s.jsx)(`input`,{type:`text`,required:!0,value:te,onChange:e=>H(e.target.value),disabled:U,className:`no-glow 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`})]}),G&&(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded-xl p-3`,children:G}),(0,s.jsx)(t.s,{type:`submit`,isLoading:U,className:`w-full py-4 rounded-xl text-[14px] font-bold shadow-lg`,children:U?`Uploading…`:`Upload`})]}):(0,s.jsx)(`div`,{className:`p-4 md:p-6`,children:(0,s.jsxs)(`label`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),e.dataTransfer.files?.[0]&&re(e.dataTransfer.files[0])},className:`group flex flex-col items-center justify-center gap-1.5 px-6 py-12 rounded-2xl border-2 border-dashed border-[var(--panel-border)] bg-foreground/[0.015] hover:border-accent/50 hover:bg-accent/[0.03] cursor-pointer text-center transition-all`,children:[(0,s.jsx)(`span`,{className:`w-14 h-14 rounded-full bg-accent/10 text-accent flex items-center justify-center mb-2 group-hover:scale-105 transition-transform`,children:(0,s.jsx)(t.mt,{className:`w-6 h-6`})}),(0,s.jsxs)(`p`,{className:`text-[15px] font-bold text-foreground`,children:[(0,s.jsx)(`span`,{className:`text-accent`,children:`Click to upload`}),` or drag a file in`]}),(0,s.jsx)(`p`,{className:`text-[12.5px] text-foreground/45 font-medium`,children:`Pictures, documents, anything`}),(0,s.jsx)(`input`,{type:`file`,ref:Y,"aria-label":`Upload a file`,onChange:e=>e.target.files?.[0]&&re(e.target.files[0]),className:`hidden`})]})})]})]})}),typeof window<`u`&&(0,l.createPortal)((0,s.jsx)(t.p,{children:w&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,s.jsx)(t.f.div,{onClick:()=>T(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,s.jsx)(`button`,{onClick:()=>T(null),className:`absolute top-3 right-3 md:top-6 md:right-6 z-[160] w-10 h-10 md:w-12 md:h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all`,children:(0,s.jsx)(t._,{className:`w-5 h-5`})}),(0,s.jsxs)(t.f.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between p-3.5 md:p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-3 md:pr-4`,children:[(0,s.jsx)(`span`,{className:`text-[15px] md:text-xl font-extrabold text-foreground truncate`,children:w.fileName}),(0,s.jsxs)(`span`,{className:`text-[10.5px] md:text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-0.5 md:mt-1 truncate`,children:[w.fileType,` • `,yt(w.fileSize)]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 md:gap-2 shrink-0`,children:[(0,s.jsx)(`button`,{onClick:()=>ce(w.downloadURL,w._id),className:`p-2 md:p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-emerald-500 transition-colors rounded-xl`,title:`Copy link`,children:P===w._id?(0,s.jsx)(t.wt,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.q,{className:`w-4 h-4`})}),ne(w)&&(0,s.jsx)(`button`,{onClick:()=>{let e=w;T(null),k(e)},className:`p-2 md:p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl`,title:`Delete`,children:(0,s.jsx)(t.E,{className:`w-4 h-4`})}),(0,s.jsx)(`a`,{href:w.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2 md:p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-0.5 md:ml-1`,title:`Download`,children:(0,s.jsx)(t.ut,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-0 h-[70vh]`,children:(0,s.jsxs)(`div`,{className:`absolute inset-4 md:inset-8 flex items-center justify-center`,children:[E&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center z-50 pointer-events-none`,children:(0,s.jsx)(t.G,{className:`w-6 h-6 text-accent animate-spin`})}),w.fileType.startsWith(`image/`)?(0,s.jsx)(`img`,{onLoad:()=>D(!1),src:w.downloadURL,alt:w.fileName,className:`block max-w-full max-h-full w-auto h-auto object-contain rounded-lg transition-opacity duration-500 ${E?`opacity-0`:`opacity-100`}`}):w.fileType.startsWith(`video/`)?(0,s.jsx)(`video`,{onLoadedData:()=>D(!1),src:w.downloadURL,controls:!0,className:`max-w-full max-h-full rounded-lg transition-opacity duration-500 ${E?`opacity-0`:`opacity-100`}`}):w.fileType===`application/pdf`?(0,s.jsx)(`iframe`,{onLoad:()=>D(!1),src:w.downloadURL,className:`w-full h-full border-none bg-white rounded-lg transition-opacity duration-500 ${E?`opacity-0`:`opacity-100`}`,title:`PDF preview`}):(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-foreground/40 text-center`,onClick:()=>D(!1),children:[(0,s.jsx)(t.it,{className:`w-24 h-24 mb-6 opacity-40`}),(0,s.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview unavailable`}),(0,s.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This format cannot be previewed. Download it instead.`})]})]})})]})]})}),document.body),(0,s.jsx)(_e,{isOpen:!!O,title:`Delete file`,message:(0,s.jsxs)(s.Fragment,{children:[`Delete `,(0,s.jsx)(`strong`,{className:`text-foreground block my-1 break-words max-w-full text-center`,children:O?.fileName}),` This cannot be undone.`]}),onConfirm:oe,onCancel:()=>k(null),isProcessing:A,confirmText:`Yes, delete`}),(0,s.jsx)(t.p,{children:q&&(0,s.jsx)(t.f.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,s.jsxs)(`div`,{className:`w-full max-w-lg aspect-video bg-background/80 border-2 border-dashed border-accent rounded-[40px] shadow-2xl flex flex-col items-center justify-center gap-6`,children:[(0,s.jsx)(`div`,{className:`w-20 h-20 rounded-full bg-accent/10 flex items-center justify-center text-accent`,children:(0,s.jsx)(t.mt,{className:`w-10 h-10 animate-bounce`})}),(0,s.jsx)(`span`,{className:`text-[24px] font-extrabold text-foreground tracking-tight`,children:`Drop to upload`})]})})})]})}var xt=[`mem_files`,`user_files`,`admin_files`],St=e=>!e.sourceTab;function Ct(){let[e,n]=(0,r.useState)(null),[a,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=!1;return Promise.all(xt.map(async e=>{try{return(await(0,i.getDocs)((0,i.collection)(t.Ht,e))).docs.map(t=>({collectionName:e,id:t.id,...t.data()}))}catch{return[]}})).then(t=>{e||n(t.flat())}),()=>{e=!0}},[]);let h=async()=>{if(!e)return;u(!0),f(``);let r=0;for(let n of e)try{let e=n.storagePath||n.downloadURL;e&&St(n)&&await(0,o.deleteObject)((0,o.ref)(t.Wt,e)).catch(()=>{}),await(0,i.deleteDoc)((0,i.doc)(t.Ht,n.collectionName,n.id)),m(e=>e+1)}catch(e){r+=1,console.error(`Could not delete ${n.collectionName}/${n.id}:`,e)}r>0?(f(`${r} file${r===1?``:`s`} could not be deleted. Reload and try again.`),n((await Promise.all(xt.map(async e=>{try{return(await(0,i.getDocs)((0,i.collection)(t.Ht,e))).docs.map(t=>({collectionName:e,id:t.id,...t.data()}))}catch{return[]}}))).flat())):n([]),u(!1),c(!1)};if(!e||e.length===0)return null;let g=e.filter(St).length,_=xt.map(t=>({name:t,n:e.filter(e=>e.collectionName===t).length})).filter(e=>e.n>0);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`mt-6 glass-panel border border-amber-500/25 bg-amber-500/[0.03] rounded-2xl md:rounded-3xl p-4 md:p-8`,children:[(0,s.jsxs)(`h3`,{className:`text-[17px] font-extrabold text-foreground tracking-tight mb-2`,children:[e.length,` leftover record`,e.length===1?``:`s`,` from the old Drive`]}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed mb-3 max-w-2xl`,children:`Drive used to have Internal, User and Admin folders. They are gone — this page is the only built-in folder now, and each page you have built keeps its own files. Nothing reads these records any more.`}),(0,s.jsxs)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed mb-3 max-w-2xl`,children:[g>0?`${g} ${g===1?`was`:`were`} uploaded through the old Drive screen, so ${g===1?`its file is`:`their files are`} deleted too. `:``,e.length-g>0?`${e.length-g} belong to files a page still shows, so only the leftover record goes — the ${e.length-g===1?`file stays`:`files stay`} where ${e.length-g===1?`it is`:`they are`}.`:``]}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium mb-5`,children:_.map(e=>`${e.n} in ${e.name}`).join(` · `)}),d&&(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded-xl p-3 mb-4`,children:d}),(0,s.jsxs)(`button`,{onClick:()=>c(!0),disabled:l,className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-bold bg-red-500/10 hover:bg-red-500/20 text-red-500 border border-red-500/20 transition-colors disabled:opacity-50`,children:[l?(0,s.jsx)(t.G,{className:`w-4 h-4 animate-spin`}):(0,s.jsx)(t.E,{className:`w-4 h-4`}),l?`Deleting ${p} of ${e.length}…`:`Clean up all ${e.length} permanently`]})]}),(0,s.jsx)(_e,{isOpen:a,title:`Delete the old Drive files`,message:(0,s.jsxs)(s.Fragment,{children:[`This permanently deletes `,(0,s.jsxs)(`strong`,{className:`text-foreground`,children:[e.length,` leftover record`,e.length===1?``:`s`]}),` `,`from `,_.map(e=>e.name).join(`, `),g>0&&(0,s.jsxs)(s.Fragment,{children:[`, along with the `,(0,s.jsxs)(`strong`,{className:`text-foreground`,children:[g,` file`,g===1?``:`s`]}),` uploaded through the old Drive screen`]}),`. It cannot be undone, and it covers every user's uploads, not only your own. Files that a page still shows are left alone.`]}),onConfirm:h,onCancel:()=>c(!1),isProcessing:l,confirmText:`Yes, delete them`})]})}function wt(){let{isAdmin:e}=ee();return(0,s.jsx)(bt,{title:`Assets`,subtitle:`/assets`,filesCollection:`pub_files`,config:{isAdmin:!0,pageId:`assets`},footer:e?(0,s.jsx)(Ct,{}):null})}function Tt(){let e=[{id:`form`,title:`Inline Form`,description:`A contact form built straight into the page, so people can write to you without leaving it.`,icon:t.J,path:`/templates/inline_form`,setup:`On your Pages screen, add a page for Anyone, give it an address and a name, and pick your form in its Form setting.`,prompt:`Show my form built into the page, not as a pop-up, with a short friendly line above it. After sending, show a thank-you message.`},{id:`popup`,title:`Modal Popup Form`,description:`A button that opens the form in a popup over the page, with the background softly blurred.`,icon:t.It,path:`/templates/popup_form`,setup:`On your Pages screen, add a page for Anyone, give it an address and a name, and pick your form in its Form setting.`,prompt:`Put a button that says Start an enquiry which opens my form as a pop-up over the page. After sending, show a thank-you message.`},{id:`confirmation`,title:`Action Confirmation`,description:`A short "are you sure?" step that appears before anything is deleted or sent.`,icon:t.Tt,path:`/templates/confirmation`,setup:`Nothing to add — this one is asked for on any page you already have.`,prompt:`On every page of mine where something can be deleted, ask me to confirm first with a pop-up that says Delete this? and two buttons, Cancel and Delete, using the confirmation template as the reference.`},{id:`board`,title:`Board View`,description:`Cards in columns that you drag from one stage to the next, for work in progress.`,icon:t.$,path:`/templates/board`,setup:`On your Pages screen, add a page for Your team and pick Board as its starting layout.`,prompt:`A board with the columns To do, In progress and Done. Each card has a client name, a contact email and a short note, and I can drag cards between columns.`},{id:`table`,title:`Data Table`,description:`Rows and columns for longer lists, with sorting and actions on many rows at once.`,icon:t.D,path:`/templates/table`,setup:`On your Pages screen, add a page for Your team and pick Table as its starting layout.`,prompt:`A table with the columns name, email, phone and status (Lead, Active, Past). Everyone on the team sees the same rows and can add, edit and delete them.`},{id:`calendar`,title:`Calendar View`,description:`A month at a time, for anything that belongs on a date — bookings, shifts, deadlines.`,icon:t.Dt,path:`/templates/calendar`,setup:`On your Pages screen, add a page for Your team and pick Calendar as its starting layout.`,prompt:`A month calendar of appointments. Each appointment has a client name, a start time, a length in minutes and a note. Everyone on the team sees the same calendar.`},{id:`drive`,title:`Drive View`,description:`A file library with upload, preview, rename and delete. The demo writes to the Assets folder, so uploading from here is something only admins can do.`,icon:t.nt,path:`/templates/drive`,setup:`On your Pages screen, add a page for Admins only and pick Files as its starting layout.`,prompt:`A file library where admins can upload, preview, rename and delete files.`}];return(0,s.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,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-10 text-center`,children:[(0,s.jsx)(`h1`,{className:`w-fit mx-auto inline-block text-[26px] sm:text-3xl md:text-4xl lg:text-5xl leading-[1.1] font-extrabold tracking-tight mb-4 text-gradient animate-float`,children:`What your assistant can build`}),(0,s.jsx)(`p`,{className:`text-foreground/60 text-lg font-medium max-w-2xl mx-auto`,children:`Every layout below already works. Look at one, add the page on your Pages screen the way the card says, and use the words underneath as what you would like to see on it.`}),(0,s.jsxs)(`p`,{className:`text-foreground/50 text-[13.5px] font-medium max-w-2xl mx-auto mt-3`,children:[`New here?`,` `,(0,s.jsx)(c.Link,{to:`/guide`,className:`text-accent font-bold hover:underline`,children:`Start with the guide`}),`.`]})]}),(0,s.jsxs)(`div`,{className:`w-full max-w-4xl mx-auto flex flex-col gap-4 relative`,children:[(0,s.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,n)=>{let r=e.icon;return(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:n*.05},className:`flex flex-col gap-3 w-full p-4 md:p-6 glass-panel border border-[var(--panel-border)] rounded-2xl hover:border-accent/40 transition-all duration-300 group`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-4 md:gap-6`,children:[(0,s.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,s.jsx)(r,{className:`w-5 h-5`})}),(0,s.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,s.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground`,children:e.title}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium leading-snug`,children:e.description})]}),(0,s.jsxs)(c.Link,{to:e.path,className:`max-md:hidden flex items-center gap-2 text-[13px] font-bold px-5 py-2.5 rounded-xl btn-primary shrink-0 transition-transform shadow-lg hover:-translate-y-0.5`,children:[`View `,(0,s.jsx)(`span`,{className:`font-black leading-none ml-0.5`,children:`→`})]})]}),(0,s.jsx)(Ze,{title:e.id===`confirmation`?`Ask your assistant for this`:`Use this as what you would like to see on the page`,description:e.setup,prompt:e.prompt,compact:!0}),(0,s.jsxs)(c.Link,{to:e.path,className:`md:hidden inline-flex items-center justify-center gap-2 text-[13px] font-bold px-5 py-2.5 rounded-xl btn-primary transition-transform shadow-lg`,children:[`View `,(0,s.jsx)(`span`,{className:`font-black leading-none ml-0.5`,children:`→`})]})]},e.id)})]})]})}var Et=`Xl271wWblkY`,Dt=[{term:`Who it is for`,body:`One of the four audiences below. It decides who can open the page and which menu it appears in. Ask the chat only for pages anyone can visit — dashboard pages are added on the Pages screen, see the three steps below.`,example:`Create a page anyone can visit.`},{term:`The web address`,body:`Starts with a slash. It is the address people type or click, and it never changes unless you change it on the Pages screen.`,example:`Web address: /pricing.`},{term:`The name in the menu`,body:`The word people click to get there.`,example:`Name in the site menu: Pricing.`},{term:`The heading`,body:`The title at the top of the page.`,example:`Heading: Our prices.`},{term:`What is on it`,body:`The sections from top to bottom, with the exact words for every heading and button, and what each button does.`,example:`Three plans side by side, each with a price and a button that says Choose this plan.`},{term:`Where to start`,body:`For a page in the dashboard you pick this on the Pages screen when you add it — board, table, calendar, files, or from scratch. In the chat, only say whether people can upload files.`,example:`No file uploads.`},{term:`The questions`,body:`For a form: every question, its kind, and whether it is required. Kinds: short text, long text, email, phone, number, money, date, yes-no, or choose one with the choices listed.`,example:`Budget (money in dollars, optional).`},{term:`After sending`,body:`Stay and show a message, go to the home page, or go to another page by its web address.`,example:`After sending, stay on the page and show Thanks, we will reply today.`},{term:`What to leave alone`,body:`End with "Build only this" and name anything that must not change. Without it the assistant adds pages, sample data and sections you did not ask for.`,example:`Build only this — no other pages, forms or sample data.`}],Ot=[{name:`Anyone`,how:`Say: a page anyone can visit`,who:`Everybody, signed in or not. This is your public website, and the page shows in the site menu.`},{name:`Signed-in users`,how:`Pick it when you add the page`,who:`Anyone who registers. Each person sees only their own information, never anyone else’s.`},{name:`Your team`,how:`Pick it when you add the page`,who:`Only people you marked as team members on the Users screen, plus admins. Everyone on it sees the same information.`},{name:`Admins only`,how:`Pick it when you add the page`,who:`You, and anyone you marked as an admin.`}],kt=[{title:`Add the page on the Pages screen`,body:`Press Add a page and pick who it is for — Your team, Signed-in users or Admins only. Give it a name, a web address and a starting layout: board, table, calendar, files, or from scratch.`},{title:`If it needs a form, add it right there`,body:`In the page’s Form box pick A new form made for this page, say what it should ask, and name the button that opens it. Who can fill it in follows who the page is for.`},{title:`Say what you want on it, then copy the sentence`,body:`On the page’s row, write what you would like to see on the page in your own words — the examples below show what that can sound like. The finished sentence appears under it; copy it and paste it into the chat. That is the whole hand-over.`},{title:`Change it later with Edit with AI`,body:`Once a page is built, press Edit with AI on its row. The row swaps to three boxes — what to add, what to change, what to take off — and hands you a different sentence: one that edits the page you already have. Nothing you did not mention is touched.`}],At=[{screen:`Pages`,path:`/pages`,body:`Add a page for your team, signed-in users or admins, and give it a form if it needs one. Rename a page, change its web address or icon, reorder it, hide it or delete it — and press Edit with AI on any row to copy the sentence that changes a page you already have.`},{screen:`Forms`,path:`/forms`,body:`See every form. Add a question or change a form’s title and button text after it is built — forms are created with their pages.`},{screen:`Theme`,path:`/theme`,body:`Colours, typeface, corner rounding, the logo, and whether the site opens light or dark.`},{screen:`Users`,path:`/users`,body:`Mark a person as a team member or an admin.`},{screen:`Inbox`,path:`/inbox`,body:`Read every answer people sent through your forms.`}],jt=[{title:`One page or one form per message`,body:`Describe it completely, then send. Ask for the next one when the first is live.`},{title:`Give every detail up front`,body:`If a part of the recipe is missing, the assistant stops to ask for it. Answer with just that part.`},{title:`Use the exact words you want to see`,body:`Headings, button labels, choices in a list. The assistant copies them; it does not improve them.`},{title:`When something is wrong, describe your screen`,body:`The web address, what you clicked, what happened, what you expected. Not what you think the cause is.`},{title:`Never accept homework`,body:`The assistant makes every change itself. If a reply ends with something for you to edit, paste or run, answer: "Do that for me."`}],Mt=[{id:`website`,title:`Pages anyone can visit`,description:`Your public website. They appear in the site menu.`,prompts:[{title:`A pricing page with a quote form`,prompt:`Create a page anyone can visit.
|
|
3
4
|
Web address: /pricing. Name in the site menu: Pricing. Heading at the top: Our prices.
|
|
4
5
|
On the page: three plans side by side — Starter, Growth and Pro — each with a one-line description, a monthly price in dollars and a button that says Choose this plan.
|
|
5
6
|
Every button opens the same pop-up form, called Request a quote, for website visitors. Questions, in this order: full name (short text, required), email (required), which plan (choose one: Starter, Growth, Pro — required), budget (money in dollars, optional), message (long text, optional).
|
|
@@ -26,27 +27,27 @@ Build only this.`},{title:`Change some words on the home page`,prompt:`On my hom
|
|
|
26
27
|
Leave everything else on the page exactly as it is — the buttons, the sections, the colours and the logo.`},{title:`Get colours to paste into the Theme screen`,prompt:`I run a small design studio. Suggest one colour scheme for my site — a brand colour, a page background and a text colour, for light mode and for dark mode — and give me each one as a colour code I can paste into the boxes on my Theme screen. Pick a typeface from Inter, Outfit, Roboto, Space Grotesk or Plus Jakarta Sans to go with it.
|
|
27
28
|
Do not change anything yourself — I will paste the codes in.`}]},{id:`fixing`,title:`Fixing and removing`,description:`When something is wrong, or something has to go.`,prompts:[{title:`Something on a page does not work`,prompt:`On my page at /orders, the Add order button does nothing when I click it. I expected a box to appear where I can type a new order. Nothing else on the page has changed.
|
|
28
29
|
Fix it, and tell me in one sentence what I should see now.`},{title:`The assistant says a page exists, but I cannot open it`,prompt:`You said you created a page at /leads, but when I open that address I see a page that says it cannot be found. Check the page you made, fix whatever stops it from showing, and tell me the exact address to open when it works.`},{title:`Delete a page you asked for`,prompt:`Delete the page at /pricing, including its entry in the site menu and any button or link on other pages that leads to it. Keep the Request a quote form only if another page still uses it; otherwise delete that too.
|
|
29
|
-
Do not change anything else.`},{title:`Remove the pages that came with the app`,prompt:`Remove the Guide, Templates and Contact pages from my site, including their entries in the site menu.`}]}],_t=`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px] mb-3`,vt=`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)]`;function yt({children:e}){return(0,s.jsxs)(`div`,{className:_t,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e]})}function bt(){return(0,s.jsxs)(`main`,{className:`flex-1 w-full max-w-4xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12`,children:[(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-10 text-center`,children:[(0,s.jsx)(`h1`,{className:`w-fit mx-auto inline-block text-[26px] sm:text-3xl md:text-4xl lg:text-5xl leading-[1.1] font-extrabold tracking-tight mb-4 text-gradient`,children:`Guide`}),(0,s.jsx)(`p`,{className:`text-foreground/60 text-base sm:text-lg font-medium max-w-2xl mx-auto`,children:`Your website is built by describing it, and your dashboard pages are added on the Pages screen and filled by describing them. This page shows what a complete description contains, and gives you finished ones to paste.`})]}),(0,s.jsxs)(t.d.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`mb-12`,children:[(0,s.jsx)(`div`,{className:`relative w-full rounded-2xl overflow-hidden border border-[var(--panel-border)] glass-panel`,children:(0,s.jsx)(`div`,{className:`relative w-full aspect-video`,children:(0,s.jsx)(`iframe`,{className:`absolute inset-0 w-full h-full`,src:`https://www.youtube-nocookie.com/embed/${ut}?start=1`,title:`Watch the guide`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share`,allowFullScreen:!0,loading:`lazy`,referrerPolicy:`strict-origin-when-cross-origin`})})}),(0,s.jsx)(`p`,{className:`mt-3 text-center text-[12.5px] text-foreground/45 font-medium`,children:`Six minutes, from an empty project to a finished site.`})]}),(0,s.jsxs)(t.d.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.05},className:`mb-12`,children:[(0,s.jsx)(yt,{children:`A page anyone can visit: what a complete request contains`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-2`,children:`Nine things, in this order`}),(0,s.jsx)(`p`,{className:`text-[13.5px] text-foreground/55 font-medium leading-relaxed mb-5 max-w-2xl`,children:`Before the assistant builds anything it needs every one of these. Say them all in one message and it builds the whole thing in one go. Leave one out and it stops to ask.`}),(0,s.jsx)(`div`,{className:`${vt} divide-y divide-[var(--panel-border)]`,children:dt.map((e,t)=>(0,s.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[11rem_1fr] sm:gap-6 px-5 py-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-baseline gap-2.5 sm:block`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/35 tabular-nums sm:block sm:mb-0.5`,children:String(t+1).padStart(2,`0`)}),(0,s.jsx)(`h3`,{className:`text-[13.5px] font-bold text-foreground tracking-tight`,children:e.term})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:e.body}),(0,s.jsx)(`p`,{className:`text-[13px] text-accent font-semibold leading-relaxed`,children:e.example})]})]},e.term))})]}),(0,s.jsxs)(t.d.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:`mb-12`,children:[(0,s.jsx)(yt,{children:`Who it is for`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-2`,children:`The four audiences`}),(0,s.jsx)(`p`,{className:`text-[13.5px] text-foreground/55 font-medium leading-relaxed mb-5 max-w-2xl`,children:`Every page is for exactly one of these. These are the words on your Pages screen. A page anyone can visit is asked for in the chat; the other three are added on the Pages screen.`}),(0,s.jsx)(`div`,{className:`${vt} divide-y divide-[var(--panel-border)]`,children:ft.map(e=>(0,s.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[11rem_1fr] sm:gap-6 px-5 py-4`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,s.jsx)(`h3`,{className:`text-[13.5px] font-bold text-foreground tracking-tight`,children:e.name}),(0,s.jsx)(`p`,{className:`text-[12px] text-accent font-semibold`,children:e.how})]}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:e.who})]},e.name))}),(0,s.jsx)(`p`,{className:`mt-3 text-[12.5px] text-foreground/50 font-medium leading-relaxed max-w-2xl`,children:`Registering only makes someone a signed-in user, not a team member. Never put your team’s information on a page for signed-in users: any stranger who registers could open it.`})]}),(0,s.jsxs)(t.d.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.12},className:`mb-12`,children:[(0,s.jsx)(yt,{children:`A page for your team, signed-in users or admins`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-2`,children:`Three steps, and the assistant only fills it in`}),(0,s.jsx)(`p`,{className:`text-[13.5px] text-foreground/55 font-medium leading-relaxed mb-5 max-w-2xl`,children:`Never ask the chat to create a dashboard page. Asked to, it rewrites files it must not touch, opens the page to strangers and invents forms. You add the page; the assistant only writes what is on it.`}),(0,s.jsx)(`div`,{className:`${vt} divide-y divide-[var(--panel-border)]`,children:pt.map((e,t)=>(0,s.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[11rem_1fr] sm:gap-6 px-5 py-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-baseline gap-2.5 sm:block`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/35 tabular-nums sm:block sm:mb-0.5`,children:String(t+1).padStart(2,`0`)}),(0,s.jsx)(`h3`,{className:`text-[13.5px] font-bold text-foreground tracking-tight`,children:e.title})]}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:e.body})]},e.title))})]}),(0,s.jsxs)(t.d.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.15},className:`mb-12`,children:[(0,s.jsx)(yt,{children:`No assistant needed`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-2`,children:`Things you change yourself`}),(0,s.jsx)(`p`,{className:`text-[13.5px] text-foreground/55 font-medium leading-relaxed mb-5 max-w-2xl`,children:`These are switches and boxes in your admin screens. Asking the assistant for them only gets you sent here.`}),(0,s.jsx)(`div`,{className:`${vt} divide-y divide-[var(--panel-border)]`,children:mt.map(e=>(0,s.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[11rem_1fr] sm:gap-6 px-5 py-4`,children:[(0,s.jsx)(c.Link,{to:e.path,className:`text-[13.5px] font-bold text-foreground tracking-tight hover:text-accent transition-colors w-fit`,children:e.screen}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:e.body})]},e.screen))}),(0,s.jsx)(`p`,{className:`mt-3 text-[12.5px] text-foreground/50 font-medium leading-relaxed max-w-2xl`,children:`The Guide, Templates, Contact and Setup pages come with the app and are visible on purpose. Hide any of them on the Pages screen with the switch next to its name.`})]}),(0,s.jsxs)(t.d.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2},className:`mb-12`,children:[(0,s.jsx)(yt,{children:`Working with the assistant`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-5`,children:`Five habits`}),(0,s.jsx)(`div`,{className:`${vt} divide-y divide-[var(--panel-border)]`,children:ht.map(e=>(0,s.jsxs)(`div`,{className:`flex flex-col gap-1 px-5 py-4`,children:[(0,s.jsx)(`h3`,{className:`text-[13.5px] font-bold text-foreground tracking-tight`,children:e.title}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:e.body})]},e.title))})]}),(0,s.jsxs)(t.d.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.25},className:`flex flex-col gap-4 mb-12`,children:[(0,s.jsxs)(`div`,{className:`mb-1`,children:[(0,s.jsx)(yt,{children:`Ready to paste`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-2`,children:`Finished requests`}),(0,s.jsxs)(`p`,{className:`text-[13.5px] text-foreground/55 font-medium leading-relaxed max-w-2xl`,children:[`Each one answers every question the assistant would otherwise ask. Copy it, change the words to yours, and paste it as one message. Want to see the layouts first?`,` `,(0,s.jsx)(c.Link,{to:`/templates`,className:`text-accent font-bold hover:underline`,children:`Look through the templates`}),`.`]})]}),gt.map(e=>(0,s.jsx)(Se,{title:e.title,description:e.description,children:e.prompts.map(e=>(0,s.jsx)(He,{title:e.title,prompt:e.prompt,compact:!0},e.title))},e.id))]})]})}function xt(){let[e,n]=(0,r.useState)({favoriteService:``,satisfactionRating:``,detailedThoughts:``}),[a,o]=(0,r.useState)(`idle`);return(0,s.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,s.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mb-6`,children:(0,s.jsxs)(c.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,s.jsx)(t.jt,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,s.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mt-6`,children:(0,s.jsxs)(t.d.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-form relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-auto`,children:[(0,s.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,s.jsx)(`div`,{className:`relative z-10 w-full`,children:a===`success`?(0,s.jsxs)(t.d.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,s.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,s.jsx)(t._t,{className:`w-8 h-8`})}),(0,s.jsx)(`h4`,{className:`text-lg font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed`,children:`Your test data was sent successfully. Log in as an admin and open your Inbox to see it.`})]}):a===`loading`?(0,s.jsxs)(t.d.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,s.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,s.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,s.jsxs)(t.d.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,s.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,s.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Inline Form Template`}),(0,s.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,s.jsxs)(`form`,{onSubmit:async r=>{r.preventDefault(),o(`loading`);try{let r=t.Bt.currentUser?.uid||`guest`;await(0,i.addDoc)((0,i.collection)(t.Vt,`user_submissions`),{uid:r,...e,type:`template_simulation`,submittedAt:(0,i.serverTimestamp)()}),o(`success`),setTimeout(()=>{o(`idle`),n({favoriteService:``,satisfactionRating:``,detailedThoughts:``})},3e3)}catch{o(`error`)}},className:`space-y-4 w-full`,children:[(0,s.jsx)(t.s,{label:`Favorite Service`,placeholder:`e.g. Design Consulting`,value:e.favoriteService,onChange:t=>n({...e,favoriteService:t.target.value})}),(0,s.jsx)(t.s,{label:`Satisfaction Rating`,type:`number`,placeholder:`1 to 10`,value:e.satisfactionRating,onChange:t=>n({...e,satisfactionRating:t.target.value})}),(0,s.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,s.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Detailed Thoughts`}),(0,s.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:e.detailedThoughts,onChange:t=>n({...e,detailedThoughts:t.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,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsx)(t.o,{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 St(){let[e,n]=(0,r.useState)(!1),[a,o]=(0,r.useState)({concept:``,featureRequest:``,notes:``}),[l,u]=(0,r.useState)(`idle`);return(0,s.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,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,s.jsx)(se,{children:`Popup Form`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/popup_form`]})]}),(0,s.jsx)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:(0,s.jsxs)(c.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,s.jsx)(t.jt,{className:`w-4 h-4`}),` Go Back`]})}),(0,s.jsxs)(t.d.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,s.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,s.jsx)(`div`,{className:`flex h-full w-full justify-end items-start relative z-10`,children:(0,s.jsxs)(t.o,{onClick:()=>n(!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,s.jsx)(t.F,{className:`w-4 h-4`}),` Open Form`]})})]}),(0,s.jsx)(t.f,{children:e&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl cursor-pointer`,onClick:()=>n(!1)}),(0,s.jsxs)(t.d.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-popover relative shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-4 max-h-[95vh] overflow-y-auto no-scrollbar`,children:[(0,s.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,s.jsxs)(`div`,{className:`relative z-10 w-full`,children:[(0,s.jsx)(`button`,{onClick:()=>n(!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,s.jsx)(t.g,{className:`w-5 h-5`})}),l===`success`?(0,s.jsxs)(t.d.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,s.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,s.jsx)(t._t,{className:`w-8 h-8`})}),(0,s.jsx)(`h4`,{className:`text-xl font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,s.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 open your Inbox to see it.`})]}):l===`loading`?(0,s.jsxs)(t.d.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,s.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,s.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,s.jsxs)(t.d.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,s.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,s.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Popup Template`}),(0,s.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,s.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),u(`loading`);try{let e=t.Bt.currentUser?.uid||`guest`;await(0,i.addDoc)((0,i.collection)(t.Vt,`user_submissions`),{uid:e,...a,type:`template_simulation`,submittedAt:(0,i.serverTimestamp)()}),u(`success`),setTimeout(()=>{u(`idle`),o({concept:``,featureRequest:``,notes:``}),n(!1)},3e3)}catch{u(`error`)}},className:`space-y-4 w-full`,children:[(0,s.jsx)(t.s,{label:`Concept Name`,placeholder:`e.g. Project Apollo`,value:a.concept,onChange:e=>o({...a,concept:e.target.value})}),(0,s.jsx)(t.s,{label:`Feature Request`,placeholder:`e.g. Real-time sync`,value:a.featureRequest,onChange:e=>o({...a,featureRequest:e.target.value})}),(0,s.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,s.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Simulated Notes`}),(0,s.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:a.notes,onChange:e=>o({...a,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,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsx)(t.o,{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 Ct(){let[e,n]=(0,r.useState)(void 0);return(0,s.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,s.jsx)(`div`,{className:`w-full max-w-5xl mb-8`,children:(0,s.jsxs)(c.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,s.jsx)(t.jt,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,s.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,s.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-8 pb-6 border-b border-[var(--panel-border)]/50`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h3`,{className:`text-2xl font-extrabold text-foreground tracking-tight`,children:`System Files`}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/50 mt-1`,children:`Review and manage core application assets.`})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,s.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/50 flex items-center justify-between gap-3 sm:gap-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-4 min-w-0 flex-1`,children:[(0,s.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,s.jsx)(t.C,{className:`w-5 h-5`})}),(0,s.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,s.jsx)(`h4`,{className:`font-bold text-[14px] sm:text-[15px] text-foreground truncate`,children:`Critical Configuration File`}),(0,s.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,s.jsx)(t.o,{variant:`secondary`,onClick:()=>n(null),className:`shrink-0 flex items-center justify-center px-4 sm:px-6 py-2.5 text-[13px] font-bold rounded-xl text-red-500 hover:bg-red-500/10 hover:border-red-500/20 bg-transparent`,children:`Delete File`})]}),(0,s.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,s.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/20 flex items-center gap-4`,children:[(0,s.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-foreground/5 shrink-0`}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 flex-1`,children:[(0,s.jsx)(`div`,{className:`w-32 h-3 rounded-full bg-foreground/10`}),(0,s.jsx)(`div`,{className:`w-20 h-2 rounded-full bg-foreground/5`})]})]},e))})]})]}),(0,s.jsx)(t.f,{children:e!==void 0&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl`}),(0,s.jsx)(t.d.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,s.jsx)(t.f,{mode:`wait`,children:e===null?(0,s.jsxs)(t.d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center`,children:[(0,s.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Confirm Deletion`}),(0,s.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,s.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,s.jsx)(t.o,{variant:`secondary`,onClick:()=>n(!1),className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:`Cancel`}),(0,s.jsx)(t.o,{onClick:()=>n(!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,s.jsxs)(t.d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,s.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-green-500 tracking-tight flex items-center gap-2`,children:[(0,s.jsx)(t.Ct,{className:`w-5 h-5`}),` Verified`]}),(0,s.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Action successfully executed.`}),(0,s.jsx)(t.o,{variant:`secondary`,onClick:()=>n(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`success`):(0,s.jsxs)(t.d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,s.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-foreground/80 tracking-tight flex items-center gap-2`,children:[(0,s.jsx)(t.g,{className:`w-5 h-5`}),` Aborted`]}),(0,s.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Cancellation securely caught.`}),(0,s.jsx)(t.o,{variant:`secondary`,onClick:()=>n(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`error`)})})]})})]})}var wt=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}];function Tt({title:e=`Board View`,subtitle:n=`/templates/board`,backUrl:a=`/templates`,tasksCollection:o=`pub_tasks`,categoriesCollection:l=`pub_categories`,config:u,customContent:d}){let{user:f}=ee(),p=!!u,m=u?.isInternal||u?.isShared;u?.isPrivate&&u?.isAdmin;let h=u?.isAdmin||m,g=p?h:!0,_=!!d,v=u?.showButton!==!1&&!_,y=u?.buttonText||`+`,b=u?.buttonStyle||`primary`,x=u?.keyName||`key`,S=u?.valueName||`value`,[C,w]=(0,r.useState)([]),[T,E]=(0,r.useState)([]),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),[j,M]=(0,r.useState)({name:``}),[N,P]=(0,r.useState)([]),[F,I]=(0,r.useState)(null),[L,R]=(0,r.useState)(null),[z,B]=(0,r.useState)(null),[V,te]=(0,r.useState)(null),[H,U]=(0,r.useState)(!1),[W,G]=(0,r.useState)(null),[K,q]=(0,r.useState)(``),[J,Y]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=o.startsWith(`user_`),n=l.startsWith(`user_`);if(e&&!f)return;try{let e=localStorage.getItem(`fbos_board_tasks_${o}`);e&&w(JSON.parse(e));let t=localStorage.getItem(`fbos_board_cats_${l}`);t&&E(JSON.parse(t))}catch{}let r=(0,i.onSnapshot)(e&&f?(0,i.query)((0,i.collection)(t.Vt,o),(0,i.where)(`uid`,`==`,f.uid)):(0,i.collection)(t.Vt,o),e=>{let t=[];e.forEach(e=>{let n=e.data();t.push({id:e.id,categoryId:n.categoryId,name:n.name||n.text||`Unnamed Item`,fields:n.fields||(n.value?[{key:`Label`,value:n.value}]:[]),order:n.order||0})});let n=t.sort((e,t)=>(e.order||0)-(t.order||0));w(n),localStorage.setItem(`fbos_board_tasks_${o}`,JSON.stringify(n))}),a=(0,i.onSnapshot)(n&&f?(0,i.query)((0,i.collection)(t.Vt,l),(0,i.where)(`uid`,`==`,f.uid)):(0,i.collection)(t.Vt,l),e=>{let n=[];if(e.forEach(e=>{n.push({id:e.id,...e.data()})}),n.length===0){let e=[{id:`todo`,title:`To Do`,createdAt:Date.now()-2e3},{id:`in_progress`,title:`In Progress`,createdAt:Date.now()-1e3},{id:`review`,title:`Review`,createdAt:Date.now()}],n=f?{uid:f.uid}:{};e.forEach(e=>(0,i.setDoc)((0,i.doc)(t.Vt,l,e.id),{...n,title:e.title,createdAt:e.createdAt}))}else E(n),localStorage.setItem(`fbos_board_cats_${l}`,JSON.stringify(n))});return()=>{r(),a()}},[o,l,f]);let ne=(e,t)=>{t?(A(t.id),M({id:t.id,name:t.name}),P(t.fields?.length?[...t.fields,{key:``,value:``}]:[{key:``,value:``}])):(O(e),M({name:``}),P([{key:``,value:``}]))},re=(e,t,n)=>{let r=[...N];r[e]={key:t,value:n},e===N.length-1&&(t.trim()!==``||n.trim()!==``)&&r.push({key:``,value:``}),P(r)},ie=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`taskId`,t),I(t)},ae=(e,t)=>{e.preventDefault(),e.stopPropagation(),t!==F&&R(t)},oe=(e,t)=>{e.preventDefault(),e.stopPropagation(),B(t)},X=e=>{e.preventDefault(),R(null),B(null)},ce=async(e,n,r)=>{e.preventDefault(),e.stopPropagation(),R(null),B(null);let a=e.dataTransfer.getData(`taskId`);if(!a||a===r){I(null);return}let s=C.find(e=>e.id===a);if(!s)return;let c=C.filter(e=>e.categoryId===n).sort((e,t)=>(e.order||0)-(t.order||0));if(s.categoryId===n?(c=c.filter(e=>e.id!==a),c.push(s)):c.push({...s,categoryId:n}),r){let e=c.findIndex(e=>e.id===r),t=c.findIndex(e=>e.id===a),[n]=c.splice(t,1);c.splice(e,0,n)}c.forEach((e,r)=>{let a={categoryId:n,order:r};f&&(a.uid=f.uid),(0,i.setDoc)((0,i.doc)(t.Vt,o,e.id),a,{merge:!0})}),I(null)},Z=async e=>{let n=j.id||`item_${Date.now()}`,r=j.name.trim(),a=r||`Untitled Item`,s=N.filter(e=>e.key.trim()!==``||e.value.trim()!==``),c=!0,l=j.id?C.find(e=>e.id===j.id):null;if(l){let e=JSON.stringify(l.fields||[]),t=JSON.stringify(s);l.name===a&&e===t&&(c=!1)}else !r&&s.length===0&&(c=!1);if(!c){O(null),A(null);return}te(j.id||`new`);let u={categoryId:e,name:a,fields:s};f&&!j.id&&(u.uid=f.uid),await(0,i.setDoc)((0,i.doc)(t.Vt,o,n),u,{merge:!0}),setTimeout(()=>{O(null),A(null),te(null)},400)},ue=(e,t)=>{Y({type:`item`,id:e,title:t})},de=async()=>{let e=`cat_${Date.now()}`,n={title:``,createdAt:Date.now()};f&&(n.uid=f.uid),await(0,i.setDoc)((0,i.doc)(t.Vt,l,e),n),G(e),q(``),setTimeout(()=>{let e=document.getElementById(`board-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},150)},fe=async(e,n)=>{E(t=>t.map(t=>t.id===e?{...t,color:n}:t)),await(0,i.setDoc)((0,i.doc)(t.Vt,l,e),{color:n},{merge:!0})},pe=async e=>{K.trim()?await(0,i.setDoc)((0,i.doc)(t.Vt,l,e),{title:K},{merge:!0}):await(0,i.deleteDoc)((0,i.doc)(t.Vt,l,e)),G(null)},he=(e,t)=>{Y({type:`category`,id:e,title:t})},ge=async()=>{if(J){U(!0);try{if(J.type===`item`)await(0,i.deleteDoc)((0,i.doc)(t.Vt,o,J.id)),A(null);else{let e=C.filter(e=>e.categoryId===J.id);for(let n of e)await(0,i.deleteDoc)((0,i.doc)(t.Vt,o,n.id));await(0,i.deleteDoc)((0,i.doc)(t.Vt,l,J.id))}}catch{}U(!1),Y(null)}},_e=[...T].sort((e,t)=>(e.createdAt||0)-(t.createdAt||0));return(0,s.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 overflow-x-hidden`,children:[(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,s.jsx)(se,{children:e}),n&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),n]})]}),p&&(0,s.jsx)(`div`,{className:`mb-6`,children:(0,s.jsx)(le,{})}),(0,s.jsxs)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 gap-3 sm:gap-4 relative z-20 shrink-0`,children:[!p&&a&&(0,s.jsxs)(c.Link,{to:a,className:`px-5 py-2 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold text-foreground/70 hover:bg-foreground/5 transition-all flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(t.jt,{className:`w-4 h-4`}),` Go Back`]}),p&&(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:u?.tabTitle||u?.tabName||e}),(0,s.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[C.length,` `,C.length===1?`item`:`items`,` · `,_e.length,` `,_e.length===1?`category`:`categories`]})]}),(0,s.jsx)(`div`,{className:`flex flex-row gap-2 shrink-0`,children:v&&(0,s.jsx)(t.o,{variant:b===`secondary`?`secondary`:void 0,onClick:de,className:`px-3 py-2.5 text-[14px] font-bold rounded-xl shadow-lg hover:-translate-y-0.5 transition-all shrink-0`,children:y===`+`?(0,s.jsx)(t.F,{className:`w-4 h-4`}):y})})]}),(0,s.jsx)(`div`,{className:`flex-1 w-full relative z-40 min-h-0`,children:d?(0,s.jsx)(`div`,{className:`fbos-content-slot w-full h-full overflow-y-auto`,children:(0,s.jsx)(d,{config:u,actions:{tasks:C,categories:T,collection:o,catCollection:l,user:f,saveTask:async(e,n)=>{let r=e||`item_${Date.now()}`;w(e=>e.find(e=>e.id===r)?e.map(e=>e.id===r?{...e,...n}:e):[...e,{id:r,...n}]),await(0,i.setDoc)((0,i.doc)(t.Vt,o,r),n,{merge:!0})},deleteTask:async e=>{w(t=>t.filter(t=>t.id!==e)),await(0,i.deleteDoc)((0,i.doc)(t.Vt,o,e))},saveCategory:async(e,n)=>{E(t=>t.find(t=>t.id===e)?t.map(t=>t.id===e?{...t,...n}:t):[...t,{id:e,...n}]),await(0,i.setDoc)((0,i.doc)(t.Vt,l,e),n,{merge:!0})},deleteCategory:async e=>{E(t=>t.filter(t=>t.id!==e)),await(0,i.deleteDoc)((0,i.doc)(t.Vt,l,e))},openInlineEditor:(e,t)=>ne(e,t)}})}):(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl shadow-2xl relative z-10 flex flex-col h-full p-4 md:p-6`,children:[(0,s.jsx)(`div`,{className:`absolute top-0 right-0 w-[400px] h-[400px] bg-accent/5 blur-[100px] rounded-full pointer-events-none -z-10`}),(0,s.jsxs)(`div`,{id:`board-container`,className:`w-full h-full flex flex-row gap-4 md:gap-6 overflow-x-auto pb-4 snap-x snap-mandatory styled-scrollbars items-start`,children:[_e.map((e,n)=>{let r=C.filter(t=>t.categoryId===e.id);r.sort((e,t)=>(e.order||0)-(t.order||0));let i=wt.find(t=>t.text===e.color)||wt.find(e=>e.text===`text-accent`);return i.text,i.bgLight,i.bgHover,(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:n*.1},className:`w-[calc(100vw-80px)] sm:w-[300px] md:w-[320px] shrink-0 flex flex-col max-h-full rounded-3xl p-4 snap-center relative border transition-colors ${wt.find(t=>t.text===e.color)?.bgCard||`bg-foreground/[0.02]`} ${wt.find(t=>t.text===e.color)?.borderCard||`border-[var(--panel-border)]/50`}`,children:[(0,s.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-2 relative z-[200]`,children:(0,s.jsxs)(`h3`,{className:`font-bold text-[14px] flex items-center w-full text-foreground/80 group relative z-[200]`,children:[W===e.id?(0,s.jsxs)(`div`,{className:`relative flex-1 w-full flex items-center pr-8 z-[200]`,children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),pe(e.id)}}),(0,s.jsx)(`input`,{value:K,onChange:e=>q(e.target.value),onBlur:t=>{t.relatedTarget?.closest(`.category-color-picker`)||pe(e.id)},onKeyDown:t=>t.key===`Enter`&&pe(e.id),className:`bg-transparent border-none outline-none font-bold text-[14px] w-full p-0 ${e.color||`text-foreground/80`}`,placeholder:`Category name`,autoFocus:!0}),(0,s.jsxs)(`div`,{className:`absolute top-8 left-0 flex gap-1.5 bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-[100] category-color-picker items-center`,tabIndex:-1,children:[(0,s.jsx)(`button`,{onClick:async t=>{t.preventDefault(),t.stopPropagation(),await fe(e.id,``),G(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Reset Category Color`,children:(0,s.jsx)(t.g,{className:`w-3 h-3`})}),(0,s.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),wt.map(t=>(0,s.jsx)(`button`,{onMouseDown:async n=>{n.preventDefault(),await fe(e.id,t.text)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50 shrink-0`},t.name))]})]}):(0,s.jsxs)(`div`,{className:`flex items-center gap-2 w-full cursor-pointer hover:text-foreground transition-colors pr-8`,onClick:()=>{G(e.id),q(e.title)},children:[(0,s.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${wt.find(t=>t.text===e.color)?.bgCircle||`bg-foreground/20`} transition-colors shrink-0`}),(0,s.jsx)(`span`,{className:`truncate flex-1 max-w-[200px] ${e.color||``}`,children:e.title||`Untitled Category`}),(0,s.jsx)(`span`,{className:`text-[11px] bg-foreground/10 text-foreground/60 px-1.5 py-0.5 rounded-md font-medium shrink-0`,children:r.length})]}),T.length>1&&(0,s.jsx)(`button`,{onClick:()=>he(e.id,e.title),className:`absolute right-0 opacity-100 md:opacity-0 md:group-hover:opacity-100 text-foreground/30 hover:text-red-500 transition-all shrink-0`,children:(0,s.jsx)(t.w,{className:`w-3.5 h-3.5`})})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2.5 flex-1 overflow-y-auto styled-scrollbars pr-1 relative min-h-[150px] rounded-xl transition-all ${z===e.id&&!L?`bg-foreground/5 scale-[1.01] border-dashed border border-accent/20`:``}`,onDragOver:t=>oe(t,e.id),onDragLeave:X,onDrop:t=>ce(t,e.id),children:[(0,s.jsx)(t.f,{children:r.map(n=>k===n.id?(0,s.jsxs)(t.d.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-md border border-accent/40 transition-all flex flex-col gap-2 relative z-[100]`,children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Z(e.id)}}),(0,s.jsx)(`textarea`,{placeholder:`Write an item name...`,className:`no-glow bg-transparent border-none outline-none text-[13px] text-foreground/90 font-medium leading-snug resize-none w-full min-h-[40px] relative z-10`,value:j.name,onChange:e=>M({...j,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Z(e.id))}}),(0,s.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:N.map((t,n)=>(0,s.jsxs)(`div`,{className:`flex items-start bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 w-full`,children:[(0,s.jsx)(`input`,{placeholder:x,value:t.key,onChange:e=>re(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&Z(e.id),className:`no-glow bg-transparent outline-none text-[11px] text-foreground/50 font-bold placeholder:text-foreground/30 relative top-[1px] shrink-0`,style:{width:`${Math.max(3,t.key.length||x.length)}ch`}}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,s.jsx)(`textarea`,{rows:1,placeholder:S,value:t.value,onChange:e=>re(n,t.key,e.target.value),onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=t.scrollHeight+`px`},onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Z(e.id))},className:`no-glow bg-transparent outline-none text-[12px] text-foreground/90 font-medium flex-1 min-w-[40px] placeholder:opacity-40 resize-none overflow-hidden leading-tight relative top-[1px]`})]},n))}),V===n.id&&(0,s.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,s.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]},n.id):(0,s.jsxs)(t.d.div,{draggable:!0,onDragStart:e=>ie(e,n.id),onDragOver:e=>ae(e,n.id),onDragLeave:X,onDrop:t=>ce(t,e.id,n.id),initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-sm hover:shadow-md cursor-grab active:cursor-grabbing hover:border-accent/40 transition-all group flex flex-col gap-2 relative z-10 border ${L===n.id?`border-accent border-t-2 translate-y-1`:`border-[var(--panel-border)]`} ${F===n.id?`opacity-30 scale-95 border-dashed border-2`:``}`,children:[(0,s.jsxs)(`div`,{className:`absolute top-2 right-2 flex items-center gap-1.5 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity bg-background/90 backdrop-blur-md border border-[var(--panel-border)] rounded-lg p-1 z-20 shadow-md`,children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ne(e.id,n)},className:`p-1 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-accent transition-colors`,children:(0,s.jsx)(t.I,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ue(n.id,n.name)},className:`p-1 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,children:(0,s.jsx)(t.w,{className:`w-3.5 h-3.5`})})]}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/90 font-medium leading-snug break-words pr-12`,children:n.name}),n.fields&&n.fields.length>0&&(0,s.jsx)(`div`,{className:`flex flex-row flex-wrap gap-2 mt-2`,children:n.fields.map((e,t)=>(0,s.jsxs)(`div`,{className:`inline-flex bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 max-w-full`,children:[(0,s.jsxs)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative -top-[1px] shrink-0 break-all`,children:[e.key,`:`]}),(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/90 font-medium break-words leading-tight min-w-0`,children:e.value})]},t))}),(0,s.jsxs)(`div`,{className:`flex items-end justify-between mt-3 pt-3 border-t border-[var(--panel-border)]/50 w-full gap-2`,children:[g&&p&&f?(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`,children:[f.photoURL?(0,s.jsx)(`img`,{src:f.photoURL,className:`w-4 h-4 rounded-full shrink-0 object-cover`}):(0,s.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[9px] font-bold shrink-0`,children:(f.displayName||f.email||`U`)[0].toUpperCase()}),(0,s.jsx)(`span`,{className:`text-[10px] font-bold text-foreground/60 truncate max-w-[80px]`,children:f.displayName||f.email?.split(`@`)[0]||`User`})]}):(0,s.jsx)(`div`,{className:`flex items-center gap-2 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`}),(0,s.jsx)(`span`,{className:`text-[10px] text-foreground/40 font-bold text-right pt-0.5 shrink-0 max-w-[50%] truncate flex-1`,children:n.id.startsWith(`item_`)?new Date(parseInt(n.id.split(`_`)[1])).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`Recently Added`})]})]},n.id))}),D===e.id?(0,s.jsxs)(t.d.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-md border border-accent/40 transition-all flex flex-col gap-2 relative z-[100] mt-1`,children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Z(e.id)}}),(0,s.jsx)(`textarea`,{placeholder:`Write an item name...`,className:`no-glow bg-transparent border-none outline-none text-[13px] text-foreground/90 font-medium leading-snug resize-none w-full min-h-[40px] relative z-10`,value:j.name,onChange:e=>M({...j,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Z(e.id))},autoFocus:!0}),(0,s.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:N.map((t,n)=>(0,s.jsxs)(`div`,{className:`flex items-start bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 w-full`,children:[(0,s.jsx)(`input`,{placeholder:x,style:{width:`${Math.max(3,t.key.length||x.length)}ch`},value:t.key,onChange:e=>re(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&Z(e.id),className:`no-glow bg-transparent outline-none text-[11px] text-foreground/50 font-bold placeholder:text-foreground/30 relative top-[1px]`}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,s.jsx)(`textarea`,{rows:1,placeholder:S,value:t.value,onChange:e=>re(n,t.key,e.target.value),onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=t.scrollHeight+`px`},onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Z(e.id))},className:`no-glow bg-transparent outline-none text-[12px] text-foreground/90 font-medium flex-1 min-w-[40px] placeholder:opacity-40 resize-none overflow-hidden leading-tight relative top-[1px]`})]},n))}),V===`new`&&(0,s.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,s.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]}):(0,s.jsxs)(`button`,{onClick:()=>ne(e.id),className:`flex items-center gap-2 justify-center w-full py-2.5 mt-1 rounded-xl border border-transparent text-[12px] font-bold text-foreground/40 hover:text-foreground hover:bg-foreground/[0.03] transition-all shrink-0`,children:[(0,s.jsx)(t.F,{className:`w-4 h-4`}),` Add Item`]})]})]},e.id)}),(0,s.jsx)(`div`,{className:`w-[10px] shrink-0 pointer-events-none`})]})]})}),(0,s.jsx)(`style`,{children:`.styled-scrollbars::-webkit-scrollbar { width: 6px; height: 6px; } .styled-scrollbars::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent-color) 20%, transparent); border-radius: 4px; } .styled-scrollbars::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--accent-color) 40%, transparent); }`}),(0,s.jsx)(me,{isOpen:!!J,title:`Confirm Deletion`,message:(0,s.jsxs)(s.Fragment,{children:[`Are you sure you want to delete `,(0,s.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:J?.title}),` This action is permanent.`]}),onConfirm:ge,onCancel:()=>Y(null),isProcessing:H,confirmText:`Yes, Delete`})]})}function Et(e){return Array.isArray?Array.isArray(e):It(e)===`[object Array]`}function Dt(e){if(typeof e==`string`)return e;if(typeof e==`bigint`)return e.toString();let t=e+``;return t==`0`&&1/e==-1/0?`-0`:t}function Ot(e){return e==null?``:Dt(e)}function kt(e){return typeof e==`string`}function At(e){return typeof e==`number`}function jt(e){return e===!0||e===!1||Nt(e)&&It(e)==`[object Boolean]`}function Mt(e){return typeof e==`object`}function Nt(e){return Mt(e)&&e!==null}function Pt(e){return e!=null}function Ft(e){return!e.trim().length}function It(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var Lt=`Incorrect 'index' type`,Rt=e=>`Invalid value for key ${e}`,zt=e=>`Pattern length exceeds max of ${e}.`,Bt=e=>`Missing ${e} property in key`,Vt=e=>`Property 'weight' in key '${e}' must be a positive integer`,Ht=Object.prototype.hasOwnProperty,Ut=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=Wt(e);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function Wt(e){let t=null,n=null,r=null,i=1,a=null;if(kt(e)||Et(e))r=e,t=Gt(e),n=Kt(e);else{if(!Ht.call(e,`name`))throw Error(Bt(`name`));let o=e.name;if(r=o,Ht.call(e,`weight`)&&(i=e.weight,i<=0))throw Error(Vt(o));t=Gt(o),n=Kt(o),a=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:a}}function Gt(e){return Et(e)?e:e.split(`.`)}function Kt(e){return Et(e)?e.join(`.`):e}function qt(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(Pt(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!Pt(s))return;if(a===t.length-1&&(kt(s)||At(s)||jt(s)||typeof s==`bigint`))n.push(o===void 0?Ot(s):{v:Ot(s),i:o});else if(Et(s)){r=!0;for(let e=0,n=s.length;e<n;e+=1)i(s[e],t,a+1,e)}else t.length&&i(s,t,a+1,o)}};return i(e,kt(t)?t.split(`.`):t,0),r?n:n[0]}var Jt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Yt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},Xt={location:0,threshold:.6,distance:100},Zt={useExtendedSearch:!1,useTokenSearch:!1,getFn:qt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},$=Object.freeze({...Yt,...Jt,...Xt,...Zt}),Qt=/[^ ]+/g;function $t(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=t.match(Qt).length;if(n.has(i))return n.get(i);let a=1/i**(.5*e),o=parseFloat(Math.round(a*r)/r);return n.set(i,o),o},clear(){n.clear()}}}var en=class{constructor({getFn:e=$.getFn,fieldNormWeight:t=$.fieldNormWeight}={}){this.norm=$t(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,kt(this.docs[0])?this.docs.forEach((e,t)=>{this._addString(e,t)}):this.docs.forEach((e,t)=>{this._addObject(e,t)}),this.norm.clear())}add(e){let t=this.size();kt(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,n=this.size();t<n;t+=1)--this.records[t].i}removeAll(e){for(let t=e.length-1;t>=0;--t)this.records.splice(e[t],1);for(let e=0,t=this.records.length;e<t;e+=1)this.records[e].i=e}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!Pt(e)||Ft(e))return;let n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}_addObject(e,t){let n={i:t,$:{}};this.keys.forEach((t,r)=>{let i=t.getFn?t.getFn(e):this.getFn(e,t.path);if(Pt(i)){if(Et(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(Pt(n)){if(kt(n)){if(!Ft(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(Pt(n.v)){let t=kt(n.v)?n.v:Ot(n.v);if(!Ft(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[r]=e}else if(kt(i)&&!Ft(i)){let e={v:i,n:this.norm.get(i)};n.$[r]=e}}}),this.records.push(n)}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function tn(e,t,{getFn:n=$.getFn,fieldNormWeight:r=$.fieldNormWeight}={}){let i=new en({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(Wt)),i.setSources(t),i.create(),i}function nn(e,{getFn:t=$.getFn,fieldNormWeight:n=$.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new en({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function rn(e=[],t=$.minMatchCharLength){let n=[],r=-1,i=-1,a=0;for(let o=e.length;a<o;a+=1){let o=e[a];o&&r===-1?r=a:!o&&r!==-1&&(i=a-1,i-r+1>=t&&n.push([r,i]),r=-1)}return e[a-1]&&a-r>=t&&n.push([r,a-1]),n}var an=32;function on(e,t,n,{location:r=$.location,distance:i=$.distance,threshold:a=$.threshold,findAllMatches:o=$.findAllMatches,minMatchCharLength:s=$.minMatchCharLength,includeMatches:c=$.includeMatches,ignoreLocation:l=$.ignoreLocation}={}){if(t.length>an)throw Error(zt(an));let u=t.length,d=e.length,f=Math.max(0,Math.min(r,d)),p=a,m=f,h=(e,t)=>{let n=e/u;if(l)return n;let r=Math.abs(f-t);return i?n+r/i:r?1:n},g=s>1||c,_=g?Array(d):[],v;for(;(v=e.indexOf(t,m))>-1;){let e=h(0,v);if(p=Math.min(e,p),m=v+u,g){let e=0;for(;e<u;)_[v+e]=1,e+=1}}m=-1;let y=[],b=1,x=u+d,S=1<<u-1;for(let t=0;t<u;t+=1){let r=0,i=x;for(;r<i;)h(t,f+i)<=p?r=i:x=i,i=Math.floor((x-r)/2+r);x=i;let a=Math.max(1,f-i+1),s=o?d:Math.min(f+i,d)+u,c=Array(s+2);c[s+1]=(1<<t)-1;for(let r=s;r>=a;--r){let i=r-1,o=n[e[i]];if(g&&(_[i]=+!!o),c[r]=(c[r+1]<<1|1)&o,t&&(c[r]|=(y[r+1]|y[r])<<1|1|y[r+1]),c[r]&S&&(b=h(t,i),b<=p)){if(p=b,m=i,m<=f)break;a=Math.max(1,2*f-m)}}if(h(t+1,f)>p)break;y=c}let C={isMatch:m>=0,score:Math.max(.001,b)};if(g){let e=rn(_,s);e.length?c&&(C.indices=e):C.isMatch=!1}return C}function sn(e){let t={};for(let n=0,r=e.length;n<r;n+=1){let i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}function cn(e){if(e.length<=1)return e;e.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let t=[e[0]];for(let n=1,r=e.length;n<r;n+=1){let r=t[t.length-1],i=e[n];i[0]<=r[1]+1?r[1]=Math.max(r[1],i[1]):t.push(i)}return t}var ln={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},un=RegExp(`[`+Object.keys(ln).join(``)+`]`,`g`),dn=String.prototype.normalize?e=>e.normalize(`NFD`).replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,``).replace(un,e=>ln[e]):e=>e,fn=class{constructor(e,{location:t=$.location,threshold:n=$.threshold,distance:r=$.distance,includeMatches:i=$.includeMatches,findAllMatches:a=$.findAllMatches,minMatchCharLength:o=$.minMatchCharLength,isCaseSensitive:s=$.isCaseSensitive,ignoreDiacritics:c=$.ignoreDiacritics,ignoreLocation:l=$.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l},e=s?e:e.toLowerCase(),e=c?dn(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:sn(e),startIndex:t})},d=this.pattern.length;if(d>an){let e=0,t=d%an,n=d-t;for(;e<n;)u(this.pattern.substr(e,an),e),e+=an;if(t){let e=d-an;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){let{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?dn(e):e,this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}let{location:i,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:t,alphabet:n,startIndex:p})=>{let{isMatch:m,score:h,indices:g}=on(e,t,n,{location:i+p,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});m&&(f=!0),d+=h,m&&g&&u.push(...g)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(p.indices=cn(u)),p}},pn=class{constructor(e){this.pattern=e}static isMultiMatch(e){return mn(e,this.multiRegex)}static isSingleMatch(e){return mn(e,this.singleRegex)}search(e){return{isMatch:!1,score:1}}};function mn(e,t){let n=e.match(t);return n?n[1]:null}var hn=class extends pn{constructor(e){super(e)}static get type(){return`exact`}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){let t=e===this.pattern;return{isMatch:t,score:+!t,indices:[0,this.pattern.length-1]}}},gn=class extends pn{constructor(e){super(e)}static get type(){return`inverse-exact`}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){let t=e.indexOf(this.pattern)===-1;return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},_n=class extends pn{constructor(e){super(e)}static get type(){return`prefix-exact`}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){let t=e.startsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,this.pattern.length-1]}}},vn=class extends pn{constructor(e){super(e)}static get type(){return`inverse-prefix-exact`}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){let t=!e.startsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},yn=class extends pn{constructor(e){super(e)}static get type(){return`suffix-exact`}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){let t=e.endsWith(this.pattern);return{isMatch:t,score:+!t,indices:[e.length-this.pattern.length,e.length-1]}}},bn=class extends pn{constructor(e){super(e)}static get type(){return`inverse-suffix-exact`}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){let t=!e.endsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},xn=class extends pn{constructor(e,{location:t=$.location,threshold:n=$.threshold,distance:r=$.distance,includeMatches:i=$.includeMatches,findAllMatches:a=$.findAllMatches,minMatchCharLength:o=$.minMatchCharLength,isCaseSensitive:s=$.isCaseSensitive,ignoreDiacritics:c=$.ignoreDiacritics,ignoreLocation:l=$.ignoreLocation}={}){super(e),this._bitapSearch=new fn(e,{location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l})}static get type(){return`fuzzy`}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}},Sn=class extends pn{constructor(e){super(e)}static get type(){return`include`}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t=0,n,r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,t))>-1;)t=n+i,r.push([n,t-1]);let a=!!r.length;return{isMatch:a,score:+!a,indices:r}}},Cn=[hn,Sn,_n,vn,bn,yn,gn,xn],wn=Cn.length,Tn=`\0`,En=`|`;function Dn(e){let t=[],n=e.length,r=0;for(;r<n;){for(;r<n&&e[r]===` `;)r++;if(r>=n)break;let i=r;for(;i<n&&e[i]!==` `&&e[i]!==`"`;)i++;if(i<n&&e[i]===`"`){for(i++;i<n;){if(e[i]===`"`){let t=i+1;if(t>=n||e[t]===` `){i++;break}if(e[t]===`$`&&(t+1>=n||e[t+1]===` `)){i+=2;break}}i++}t.push(e.substring(r,i)),r=i}else{for(;i<n&&e[i]!==` `;)i++;t.push(e.substring(r,i)),r=i}}return t}function On(e,t={}){return e.replace(/\\\|/g,Tn).split(En).map(e=>{let n=Dn(e.replace(/\u0000/g,`|`).trim()).filter(e=>e&&!!e.trim()),r=[];for(let e=0,i=n.length;e<i;e+=1){let i=n[e],a=!1,o=-1;for(;!a&&++o<wn;){let e=Cn[o],n=e.isMultiMatch(i);n&&(r.push(new e(n,t)),a=!0)}if(!a)for(o=-1;++o<wn;){let e=Cn[o],n=e.isSingleMatch(i);if(n){r.push(new e(n,t));break}}}return r})}var kn=new Set([xn.type,Sn.type]),An=class{constructor(e,{isCaseSensitive:t=$.isCaseSensitive,ignoreDiacritics:n=$.ignoreDiacritics,includeMatches:r=$.includeMatches,minMatchCharLength:i=$.minMatchCharLength,ignoreLocation:a=$.ignoreLocation,findAllMatches:o=$.findAllMatches,location:s=$.location,threshold:c=$.threshold,distance:l=$.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:o,ignoreLocation:a,location:s,threshold:c,distance:l},e=t?e:e.toLowerCase(),e=n?dn(e):e,this.pattern=e,this.query=On(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){let t=this.query;if(!t)return{isMatch:!1,score:1};let{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?dn(e):e;let a=0,o=[],s=0,c=!1;for(let r=0,i=t.length;r<i;r+=1){let i=t[r];o.length=0,a=0,c=!1;for(let t=0,r=i.length;t<r;t+=1){let r=i[t],{isMatch:l,indices:u,score:d}=r.search(e);if(l){a+=1,s+=d;let e=r.constructor.type;e.startsWith(`inverse`)&&(c=!0),n&&(kn.has(e)?o.push(...u):o.push(u))}else{s=0,a=0,o.length=0,c=!1;break}}if(a){let e={isMatch:!0,score:s/a};return c&&(e.hasInverse=!0),n&&(e.indices=cn(o)),e}}return{isMatch:!1,score:1}}},jn=[];function Mn(...e){jn.push(...e)}function Nn(e,t){for(let n=0,r=jn.length;n<r;n+=1){let r=jn[n];if(r.condition(e,t))return new r(e,t)}return new fn(e,t)}var Pn={AND:`$and`,OR:`$or`},Fn={PATH:`$path`,PATTERN:`$val`},In=e=>!!(e[Pn.AND]||e[Pn.OR]),Ln=e=>!!e[Fn.PATH],Rn=e=>!Et(e)&&Mt(e)&&!In(e),zn=e=>({[Pn.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Bn(e,t,{auto:n=!0}={}){let r=e=>{if(kt(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=Nn(e,t)),r}let i=Object.keys(e),a=Ln(e);if(!a&&i.length>1&&!In(e))return r(zn(e));if(Rn(e)){let r=a?e[Fn.PATH]:i[0],o=a?e[Fn.PATTERN]:e[r];if(!kt(o))throw Error(Rt(r));let s={keyId:Kt(r),pattern:o};return n&&(s.searcher=Nn(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];Et(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return In(e)||(e=zn(e)),r(e)}function Vn(e,{ignoreFieldNorm:t=$.ignoreFieldNorm}){let n=1;return e.forEach(({key:e,norm:r,score:i})=>{let a=e?e.weight:null;n*=(i===0&&a?2**-52:i)**+((a||1)*(t?1:r))}),n}function Hn(e,{ignoreFieldNorm:t=$.ignoreFieldNorm}){e.forEach(e=>{e.score=Vn(e.matches,{ignoreFieldNorm:t})})}var Un=class{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){let t=this.heap;for(;e>0;){let n=e-1>>1;if(t[e].score<=t[n].score)break;let r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){let t=this.heap,n=t.length,r=e;do{e=r;let i=2*e+1,a=2*e+2;if(i<n&&t[i].score>t[r].score&&(r=i),a<n&&t[a].score>t[r].score&&(r=a),r!==e){let n=t[e];t[e]=t[r],t[r]=n}}while(r!==e)}};function Wn(e,t){let n=e.matches;t.matches=[],Pt(n)&&n.forEach(e=>{if(!Pt(e.indices)||!e.indices.length)return;let{indices:n,value:r}=e,i={indices:n,value:r};e.key&&(i.key=e.key.src),e.idx>-1&&(i.refIndex=e.idx),t.matches.push(i)})}function Gn(e,t){t.score=e.score}function Kn(e,t,{includeMatches:n=$.includeMatches,includeScore:r=$.includeScore}={}){let i=[];return n&&i.push(Wn),r&&i.push(Gn),e.map(e=>{let{idx:n}=e,r={item:t[n],refIndex:n};return i.length&&i.forEach(t=>{t(e,r)}),r})}var qn=/\b\w+\b/g;function Jn({isCaseSensitive:e=!1,ignoreDiacritics:t=!1}={}){return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=dn(n)),n.match(qn)||[]}}}function Yn(e,t,n){let r=new Map,i=new Map,a=0;function o(e,t,o,s){let c=n.tokenize(e);if(!c.length)return;a++;let l=new Map;for(let e of c)l.set(e,(l.get(e)||0)+1);for(let[e,n]of l){let a={docIdx:t,keyIdx:o,subIdx:s,tf:n},c=r.get(e);c||(c=[],r.set(e,c)),c.push(a),i.set(e,(i.get(e)||0)+1)}}for(let n of e){let{i:e,v:r,$:i}=n;if(r!==void 0){o(r,e,-1,-1);continue}if(i)for(let n=0;n<t;n++){let t=i[n];if(t)if(Array.isArray(t))for(let r of t)o(r.v,e,n,r.i??-1);else o(t.v,e,n,-1)}}return{terms:r,fieldCount:a,df:i}}function Xn(e,t,n,r){let{i,v:a,$:o}=t;function s(t,n,a){let o=r.tokenize(t);if(!o.length)return;e.fieldCount++;let s=new Map;for(let e of o)s.set(e,(s.get(e)||0)+1);for(let[t,r]of s){let o={docIdx:i,keyIdx:n,subIdx:a,tf:r},s=e.terms.get(t);s||(s=[],e.terms.set(t,s)),s.push(o),e.df.set(t,(e.df.get(t)||0)+1)}}if(a!==void 0){s(a,-1,-1);return}if(o)for(let e=0;e<n;e++){let t=o[e];if(t)if(Array.isArray(t))for(let n of t)s(n.v,e,n.i??-1);else s(t.v,e,-1)}}function Zn(e,t){for(let[n,r]of e.terms){let i=r.filter(e=>e.docIdx!==t),a=r.length-i.length;a>0&&(e.fieldCount-=a,e.df.set(n,(e.df.get(n)||0)-a),i.length===0?(e.terms.delete(n),e.df.delete(n)):e.terms.set(n,i))}}var Qn=class{constructor(e,t,n){this.options={...$,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Ut(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;let t=Nn(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof en))throw Error(Lt);if(this._myIndex=t||tn(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=Jn({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});this._invertedIndex=Yn(this._myIndex.records,this._myIndex.keys.length,e)}}add(e){if(Pt(e)&&(this._docs.push(e),this._myIndex.add(e),this._invertedIndex)){let e=this._myIndex.records[this._myIndex.records.length-1],t=Jn({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});Xn(this._invertedIndex,e,this._myIndex.keys.length,t)}}remove(e=()=>!1){let t=[],n=[];for(let r=0,i=this._docs.length;r<i;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){if(this._invertedIndex)for(let e of n)Zn(this._invertedIndex,e);for(let e=n.length-1;e>=0;--e)this._docs.splice(n[e],1);this._myIndex.removeAll(n)}return t}removeAt(e){this._invertedIndex&&Zn(this._invertedIndex,e);let t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),t}getIndex(){return this._myIndex}search(e,t){let{limit:n=-1}=t||{},{includeMatches:r,includeScore:i,shouldSort:a,sortFn:o,ignoreFieldNorm:s}=this.options;if(kt(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return At(n)&&n>-1&&(e=e.slice(0,n)),e}let c=At(n)&&n>0&&kt(e),l;if(c){let t=new Un(n);kt(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=kt(e)?kt(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),Hn(l,{ignoreFieldNorm:s}),a&&l.sort(o),At(n)&&n>-1&&(l=l.slice(0,n));return Kn(l,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),{records:i}=this._myIndex,a=t?null:[];return i.forEach(({v:e,i,n:o})=>{if(!Pt(e))return;let{isMatch:s,score:c,indices:l}=r.searchIn(e);if(s){let r={item:e,idx:i,matches:[{score:c,value:e,norm:o,indices:l}]};t?(r.score=Vn(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):a.push(r)}}),a}_searchLogical(e){let t=Bn(e,this.options),n=(e,t,r)=>{if(!(`children`in e)){let{keyId:n,searcher:i}=e,a;return n===null?(a=[],this._myIndex.keys.forEach((e,n)=>{a.push(...this._findMatches({key:e,value:t[n],searcher:i}))})):a=this._findMatches({key:this._keyStore.get(n),value:this._myIndex.getValueForItemAtKeyId(t,n),searcher:i}),a&&a.length?[{idx:r,item:t,matches:a}]:[]}let{children:i,operator:a}=e,o=[];for(let e=0,s=i.length;e<s;e+=1){let s=i[e],c=n(s,t,r);if(c.length)o.push(...c);else if(a===Pn.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(Pt(e)){let o=n(t,e,r);o.length&&(i.has(r)||(i.set(r,{idx:r,item:e,matches:[]}),a.push(i.get(r))),o.forEach(({matches:e})=>{i.get(r).matches.push(...e)}))}}),a}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),{keys:i,records:a}=this._myIndex,o=t?null:[];return a.forEach(({$:e,i:a})=>{if(!Pt(e))return;let s=[],c=!1,l=!1;if(i.forEach((t,n)=>{let i=this._findMatches({key:t,value:e[n],searcher:r});i.length?(s.push(...i),i[0].hasInverse&&(l=!0)):c=!0}),!(l&&c)&&s.length){let r={idx:a,item:e,matches:s};t?(r.score=Vn(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}),o}_findMatches({key:e,value:t,searcher:n}){if(!Pt(t))return[];let r=[];if(Et(t))t.forEach(({v:t,i,n:a})=>{if(!Pt(t))return;let{isMatch:o,score:s,indices:c,hasInverse:l}=n.searchIn(t);o&&r.push({score:s,key:e,value:t,idx:i,norm:a,indices:c,hasInverse:l})});else{let{v:i,n:a}=t,{isMatch:o,score:s,indices:c,hasInverse:l}=n.searchIn(i);o&&r.push({score:s,key:e,value:i,norm:a,indices:c,hasInverse:l})}return r}},$n=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=Jn({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics});let n=this.analyzer.tokenize(e),{df:r,fieldCount:i}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let e of n){this.termSearchers.push(new fn(e,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));let n=r.get(e)||0,a=Math.log(1+(i-n+.5)/(n+.5));this.idfWeights.push(a)}}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};let t=[],n=0,r=0,i=0;for(let a=0;a<this.termSearchers.length;a++){let o=this.termSearchers[a].searchIn(e),s=this.idfWeights[a];r+=s,o.isMatch&&(i++,n+=s*(1-o.score),o.indices&&t.push(...o.indices))}if(i===0)return{isMatch:!1,score:1};let a=r>0?1-n/r:0,o={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&t.length&&(o.indices=cn(t)),o}};Qn.version=`7.3.0`,Qn.createIndex=tn,Qn.parseIndex=nn,Qn.config=$,Qn.match=function(e,t,n){return Nn(e,{...$,...n}).searchIn(t)},Qn.parseQuery=Bn,Mn(An),Mn($n),Qn.use=function(...e){e.forEach(e=>Mn(e))};var er=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}];function tr({title:e=`Table View`,subtitle:n=`/templates/table`,backUrl:a=`/templates`,tableCollection:o=`pub_table_data`,config:l,customContent:u}){let{user:d}=ee(),f=!!l,p=l?.isInternal||l?.isShared;l?.isPrivate&&l?.isAdmin;let m=l?.isAdmin||p,h=f?m:!0,g=!!u,_=l?.showButton!==!1&&!g,v=l?.buttonText||`+`,y=l?.buttonStyle||`secondary`,b=l?.showExportButton!==!1,[x,S]=(0,r.useState)([]),[C,w]=(0,r.useState)(`demo`),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(!1),[k,A]=(0,r.useState)(``),[j,M]=(0,r.useState)(!1),[N,P]=(0,r.useState)(null),[F,I]=(0,r.useState)(null),[L,R]=(0,r.useState)(``),[z,B]=(0,r.useState)(``),[V,te]=(0,r.useState)(null),[H,U]=(0,r.useState)(null),[W,G]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=o.startsWith(`user_`);if(e&&!d)return;try{let e=localStorage.getItem(`fbos_tables_${o}`);e&&S(JSON.parse(e))}catch{}let n=(0,i.onSnapshot)(e&&d?(0,i.query)((0,i.collection)(t.Vt,o),(0,i.where)(`uid`,`==`,d.uid)):(0,i.collection)(t.Vt,o),e=>{let n=[];if(e.forEach(e=>{n.push({id:e.id,...e.data()})}),n.length===0){let e={name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`,`Column 4`],...d?{uid:d.uid}:{},rows:[{id:`1`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``},{id:`2`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``}]};(0,i.setDoc)((0,i.doc)(t.Vt,o,`demo`),e)}else{let e=n.sort((e,t)=>(e.name||``).localeCompare(t.name||``));S(e),localStorage.setItem(`fbos_tables_${o}`,JSON.stringify(e))}});return()=>n()},[o,d]);let K=x.find(e=>e.id===C)||x[0]||{columns:[],rows:[]},q=async e=>{K.id&&(d&&o.startsWith(`user_`)&&(e.uid=d.uid),await(0,i.setDoc)((0,i.doc)(t.Vt,o,K.id),e,{merge:!0}))},J=()=>{if(!K.rows||K.rows.length===0)return;let e=K.columns.join(`,`),t=K.rows.map(e=>K.columns.map(t=>`"${e[t]||``}"`).join(`,`)).join(`
|
|
30
|
-
`),n=new Blob([`${e}\n${t}`],{type:`text/csv`}),r=window.URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`export_${K.name||`table`}.csv`,i.click(),window.URL.revokeObjectURL(r)},Y=(e,t,n)=>{q({...K,rows:K.rows.map(r=>r.id===e?{...r,[t]:n}:r)})},ne=()=>{let e={id:Date.now().toString()};K.columns.forEach(t=>e[t]=``),q({...K,rows:[...K.rows||[],e]})},re=e=>{q({...K,rows:K.rows.filter(t=>t.id!==e)})},ie=()=>{let e=`Column ${(K.columns?.length||0)+1}`;K.columns?.includes(e)||(q({...K,columns:[...K.columns||[],e]}),setTimeout(()=>{let e=document.getElementById(`table-scroll-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},100))},ae=e=>{let t=(K.columns||[]).filter(t=>t!==e),n=(K.rows||[]).map(t=>{let n={...t};return delete n[e],n}),r={...K.colColors||{}};delete r[e],q({...K,columns:t,rows:n,colColors:r})},oe=async e=>{e.trim()&&K.id&&e!==K.name&&await(0,i.setDoc)((0,i.doc)(t.Vt,o,K.id),{name:e},{merge:!0})},X=async()=>{M(!0),E(!1);let e=`tbl_${Date.now()}`;await(0,i.setDoc)((0,i.doc)(t.Vt,o,e),{name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`],...d?{uid:d.uid}:{},rows:[]}),setTimeout(()=>{w(e),M(!1)},600)},ce=e=>{let t=z.trim();if(t&&t!==e&&!K.columns?.includes(t)){let n=K.columns.map(n=>n===e?t:n),r=(K.rows||[]).map(n=>{let r={...n};return r[t]=r[e]||``,delete r[e],r}),i={...K.colColors||{}};i[e]&&(i[t]=i[e],delete i[e]),q({...K,columns:n,rows:r,colColors:i})}I(null)},Z=K.rows||[];return L.trim()!==``&&(Z=new Qn(Z.map(e=>({...e,_creatorMatch:`Guest`})),{keys:(K.columns||[]).concat([`_creatorMatch`]),threshold:.4,ignoreLocation:!0}).search(L).map(e=>{let{_creatorMatch:t,...n}=e.item;return n})),(0,s.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,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,s.jsx)(se,{children:e}),n&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),n]})]}),f&&(0,s.jsx)(`div`,{className:`mb-6`,children:(0,s.jsx)(le,{})}),(0,s.jsxs)(`div`,{className:`flex justify-between items-center gap-3 mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:[!f&&a&&(0,s.jsxs)(c.Link,{to:a,className:`px-4 md:px-5 py-2.5 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(t.jt,{className:`w-4 h-4`}),` `,(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:`Go Back`})]}),f&&(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:l?.tabTitle||l?.tabName||e}),(0,s.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[x.length,` `,x.length===1?`table`:`tables`]})]}),(0,s.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[b&&(0,s.jsx)(t.o,{variant:`secondary`,onClick:J,className:`px-3 py-2.5 font-bold rounded-xl shadow-sm border border-[var(--panel-border)] flex items-center gap-2`,children:(0,s.jsx)(t.lt,{className:`w-4 h-4`})}),_&&(0,s.jsx)(t.o,{variant:y===`primary`?void 0:`secondary`,onClick:ne,className:`px-3 py-2.5 font-bold rounded-xl border border-[var(--panel-border)] shadow-sm flex items-center gap-2 whitespace-nowrap`,children:v===`+`?(0,s.jsx)(t.F,{className:`w-4 h-4`}):v})]})]}),(0,s.jsxs)(t.d.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 z-10 block`,children:[(0,s.jsx)(`div`,{className:`absolute top-0 right-0 w-[400px] h-[400px] bg-accent/5 blur-[100px] rounded-full pointer-events-none -z-10`}),(0,s.jsxs)(`div`,{className:`p-4 md:px-6 border-b border-[var(--panel-border)]/50 flex items-center justify-between bg-foreground/[0.01] gap-3 sm:gap-4`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 relative`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,s.jsxs)(`div`,{className:`relative flex items-center`,children:[D?(0,s.jsx)(`div`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:e=>{O(!1),oe(e.currentTarget.textContent||``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},className:`bg-transparent border-b-2 border-accent outline-none text-[16px] font-bold text-foreground inline-block min-w-[20px] whitespace-nowrap px-1 py-0.5`,children:K.name||`Unnamed Table`}):(0,s.jsx)(`h3`,{className:`font-bold text-[16px] text-foreground/90 cursor-pointer hover:text-accent transition-colors truncate max-w-[38vw] sm:max-w-[200px]`,onClick:()=>O(!0),title:`Click to rename table`,children:K.name||`Unnamed Table`}),(0,s.jsx)(t.f,{children:T&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>E(!1)}),(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:`absolute top-[120%] left-0 w-[220px] bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 py-2 flex flex-col`,children:[(0,s.jsx)(`div`,{className:`px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-foreground/40 border-b border-[var(--panel-border)] mb-1`,children:`Your Tables`}),(0,s.jsx)(`div`,{className:`max-h-[250px] overflow-y-auto styled-scrollbars z-50 relative`,children:x.map(e=>(0,s.jsx)(`button`,{onClick:()=>{w(e.id),E(!1)},className:`w-full px-4 py-2 text-[13px] font-bold text-left hover:bg-foreground/[0.03] transition-colors truncate ${C===e.id?`text-accent bg-accent/5`:`text-foreground/70`}`,children:e.name||`Unnamed Table`},e.id))}),(0,s.jsx)(`div`,{className:`w-full h-[1px] bg-[var(--panel-border)]/50 my-1`}),(0,s.jsxs)(`button`,{onClick:X,className:`w-full px-4 py-2.5 text-[13px] font-bold text-left text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors flex items-center gap-2`,children:[(0,s.jsx)(t.F,{className:`w-4 h-4`}),` Create New Table`]})]})]})})]}),(0,s.jsx)(`button`,{onClick:()=>E(!T),className:`p-1 px-1.5 rounded-lg hover:bg-foreground/5 transition-colors text-foreground/40 hover:text-foreground shrink-0 border border-transparent hover:border-[var(--panel-border)]`,children:(0,s.jsx)(t.St,{className:`w-4 h-4 transition-transform ${T?`rotate-180 text-accent`:``}`})})]}),(0,s.jsxs)(`span`,{className:`opacity-40 text-[11px] font-bold mt-1 uppercase tracking-wider`,children:[(K.rows||[]).length,` Records`]})]}),(0,s.jsxs)(`div`,{className:`relative flex-1 min-w-[130px] max-w-[300px]`,children:[(0,s.jsx)(t.M,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-foreground/40`}),(0,s.jsx)(`input`,{type:`text`,placeholder:`Search active records...`,value:L,onChange:e=>R(e.target.value),className:`w-full bg-background border border-[var(--panel-border)] rounded-xl py-2.5 px-9 text-[13px] font-medium text-foreground focus:outline-none focus:border-accent transition-colors shadow-inner`})]})]}),(0,s.jsx)(`div`,{id:`table-scroll-container`,className:`overflow-x-auto w-full block min-h-[300px] relative styled-scrollbars`,children:u?(0,s.jsx)(`div`,{className:`fbos-content-slot p-4 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:(0,s.jsx)(u,{config:l,actions:{tables:x,activeTable:K,collection:o,user:d,saveTable:async(e,n)=>{S(t=>t.find(t=>t.id===e)?t.map(t=>t.id===e?{...t,...n}:t):[...t,{id:e,...n}]),await(0,i.setDoc)((0,i.doc)(t.Vt,o,e),n,{merge:!0})},deleteTable:async e=>{S(t=>t.filter(t=>t.id!==e)),await(0,i.deleteDoc)((0,i.doc)(t.Vt,o,e))},updateCell:(e,t,n)=>Y(e,t,n),addRow:()=>ne(),addColumn:()=>ie()}})}):(0,s.jsx)(t.f,{mode:`wait`,children:j?(0,s.jsxs)(t.d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 flex flex-col items-center justify-center bg-background/40 backdrop-blur-[2px] z-50`,children:[(0,s.jsx)(`div`,{className:`w-8 h-8 rounded-full border-2 border-accent border-r-transparent animate-spin mb-4`}),(0,s.jsx)(`p`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest`,children:`Generating Table`})]},`loader`):(0,s.jsxs)(t.d.table,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full text-left border-collapse table-auto relative min-w-[800px]`,children:[(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)] transition-colors ${K.headerColor?er.find(e=>e.text===K.headerColor)?.bgAlt:`bg-foreground/[0.02]`}`,children:[(0,s.jsx)(`th`,{className:`py-4 px-6 text-[12px] font-bold uppercase tracking-wider whitespace-nowrap text-foreground/50 w-32 border-r border-[var(--panel-border)]/20 ${h?``:`hidden`}`,children:`Creator`}),(K.columns||[]).map((e,n)=>{let r=(K.colColors||{})[e],i=(K.colorTimestamps||{})[`col_${e}`]||0;K.headerColor;let a=(K.colorTimestamps||{}).header||0,o=`bg-transparent`,c=`text-foreground/50`;if(r&&r!==`none`&&i>=a){let e=er.find(e=>e.text===r);e&&(o=e.bgCard,c=e.text)}return(0,s.jsx)(`th`,{className:`py-3 px-6 text-[12px] font-bold uppercase tracking-wider relative group h-[53px] min-w-[120px] ${c} ${o} border-r border-[var(--panel-border)]/20 last:border-r-0 select-none align-middle`,children:(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2 w-full h-full`,children:[F===e?(0,s.jsx)(`div`,{className:`flex-1 min-w-[50px]`,children:(0,s.jsx)(`span`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>{I(null),B(t.currentTarget.textContent||``),(t.currentTarget.textContent||``).trim()!==``&&ce(e)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},className:`bg-transparent outline-none border-b border-accent/40 font-bold text-[12px] uppercase tracking-wider p-0 m-0 ${c} block w-full whitespace-nowrap overflow-hidden cursor-text`,ref:e=>{e&&requestAnimationFrame(()=>{e.focus()})},children:z})}):(0,s.jsx)(`div`,{className:`flex items-center gap-2 flex-1 overflow-hidden`,onClick:()=>{I(e),B(e)},children:(0,s.jsx)(`span`,{className:`truncate cursor-text`,children:e})}),(0,s.jsxs)(`div`,{className:`relative shrink-0 flex items-center h-full gap-0.5`,children:[(0,s.jsx)(`button`,{onClick:()=>U(H===e?null:e),className:`p-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity hover:bg-foreground/10 ${r&&r!==`none`?`!opacity-100`:``} text-current`,children:(0,s.jsx)(t.R,{className:`w-4 h-4`})}),(K.columns||[]).length>1&&(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ae(e)},className:`p-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500/10 text-foreground/30 hover:text-red-500`,title:`Delete column`,children:(0,s.jsx)(t.w,{className:`w-3.5 h-3.5`})}),H===e&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>U(null)}),(0,s.jsxs)(`div`,{className:`absolute top-8 right-0 flex gap-1.5 bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,s.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...K.colColors||{},[e]:`none`},r={...K.colorTimestamps||{},[`col_${e}`]:Date.now()};q({...K,colColors:n,colorTimestamps:r}),U(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Color`,children:(0,s.jsx)(t.g,{className:`w-3 h-3`})}),(0,s.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),er.map(t=>(0,s.jsx)(`button`,{onClick:n=>{n.preventDefault(),n.stopPropagation();let r={...K.colColors||{},[e]:t.text},i={...K.colorTimestamps||{},[`col_${e}`]:Date.now()};q({...K,colColors:r,colorTimestamps:i}),U(null)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50 shrink-0`},t.name))]})]})]})]})},`col_${n}_${e}`)}),(0,s.jsx)(`th`,{className:`py-4 px-4 w-14 border-l border-[var(--panel-border)]/30 relative`,children:(0,s.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5 relative z-20`,children:[(0,s.jsx)(`button`,{onClick:()=>G(!W),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${K.headerColor?er.find(e=>e.text===K.headerColor)?.text:`text-foreground/30`}`,children:(0,s.jsx)(t.R,{className:`w-4 h-4`})}),W&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>G(!1)}),(0,s.jsxs)(`div`,{className:`absolute top-6 right-8 flex gap-1.5 bg-background/90 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,s.jsx)(`button`,{onClick:()=>{q({...K,headerColor:``}),G(!1)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Header Color`,children:(0,s.jsx)(t.g,{className:`w-3 h-3`})}),(0,s.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),er.map(e=>(0,s.jsx)(`button`,{onClick:()=>{let t={...K.colorTimestamps||{},header:Date.now()};q({...K,headerColor:e.text,colorTimestamps:t}),G(!1)},className:`w-4 h-4 rounded-full ${e.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},e.name))]})]}),(0,s.jsx)(`button`,{onClick:ie,className:`p-1.5 rounded-lg text-foreground/40 hover:text-accent hover:bg-accent/10 transition-colors flex items-center justify-center`,children:(0,s.jsx)(t.F,{className:`w-4 h-4`})})]})})]})}),(0,s.jsxs)(`tbody`,{children:[Z.map((e,n)=>{let r=n%2==1,i=(K.rowColors||{})[e.id],a=i?r?er.find(e=>e.text===i)?.bgAlt:er.find(e=>e.text===i)?.bgCard:r?`bg-foreground/[0.02]`:`bg-transparent`;return(0,s.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)]/30 hover:bg-foreground/[0.04] transition-colors group`,children:[(0,s.jsx)(`td`,{className:`py-4 px-6 whitespace-nowrap h-[53px] border-r border-[var(--panel-border)]/20 ${a} ${h?``:`hidden`}`,children:(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:f&&d?(0,s.jsxs)(s.Fragment,{children:[d.photoURL?(0,s.jsx)(`img`,{src:d.photoURL,className:`w-5 h-5 rounded-full shrink-0 object-cover`}):(0,s.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[10px] font-bold shrink-0`,children:(d.displayName||d.email||`U`)[0].toUpperCase()}),(0,s.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:d.displayName||d.email?.split(`@`)[0]||`User`})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[10px] font-bold shrink-0 shadow-inner group-hover:scale-110 transition-transform`,children:`G`}),(0,s.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:`Guest`})]})})}),(K.columns||[]).map(t=>{let i=N?.id===e.id&&N?.field===t,a=(K.colColors||{})[t],o=(K.colorTimestamps||{})[`col_${t}`]||0,c=(K.rowColors||{})[e.id],l=(K.colorTimestamps||{})[`row_${e.id}`]||0,u=``;u=l>o?c===`none`?``:c:o>l?a===`none`?``:a:c===`none`?``:c||a||``,u===`none`&&(u=``);let d=u?er.find(e=>e.text===u):null,f=d?r?d.bgAlt:d.bgCard:r?`bg-foreground/[0.02]`:`bg-transparent`,p=d?d.text:`text-foreground/80`;return(0,s.jsxs)(`td`,{className:`py-4 px-6 whitespace-pre-wrap min-w-[120px] text-[14px] font-medium relative ${f} align-top border-r border-[var(--panel-border)]/10 last:border-r-0`,onClick:()=>!i&&P({id:e.id,field:t}),children:[i?(0,s.jsx)(`textarea`,{autoFocus:!0,value:e[t]||``,onChange:n=>Y(e.id,t,n.target.value),onBlur:()=>P(null),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&P(null)},className:`absolute inset-0 bg-transparent !border-0 !outline-none focus:!outline-none focus:!ring-0 !ring-0 !shadow-none focus:!shadow-none p-4 px-6 text-[14px] font-medium w-full h-full caret-accent ${p} z-20 resize-none styled-scrollbars`}):null,(0,s.jsx)(`span`,{className:`block w-full min-h-[20px] break-words transition-all ${i?`opacity-0`:`opacity-100`} ${p} ${t===`Status`&&e[t]===`Active`&&!u?`text-green-500`:``}`,children:e[t]||(0,s.jsx)(`span`,{className:`opacity-30 italic font-normal`,children:`empty`})})]},`cell_${e.id||n}_${t}`)}),(0,s.jsx)(`td`,{className:`py-4 px-4 whitespace-nowrap text-right h-[53px] ${a} relative z-10`,children:(0,s.jsxs)(`div`,{className:`flex items-center justify-end gap-1 opacity-100 md:opacity-20 md:group-hover:opacity-100 transition-opacity relative`,children:[(0,s.jsx)(`button`,{onClick:()=>te(V===e.id?null:e.id),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${i?er.find(e=>e.text===i)?.text:`text-foreground/40`}`,children:(0,s.jsx)(t.R,{className:`w-4 h-4`})}),V===e.id&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>te(null)}),(0,s.jsxs)(`div`,{className:`absolute top-6 right-8 flex gap-1.5 bg-background/90 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,s.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...K.rowColors||{},[e.id]:`none`},r={...K.colorTimestamps||{},[`row_${e.id}`]:Date.now()};q({...K,rowColors:n,colorTimestamps:r}),te(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Row Color`,children:(0,s.jsx)(t.g,{className:`w-3 h-3`})}),(0,s.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),er.map(t=>(0,s.jsx)(`button`,{onClick:()=>{let n={...K.colorTimestamps||{},[`row_${e.id}`]:Date.now()};q({...K,rowColors:{...K.rowColors||{},[e.id]:t.text},colorTimestamps:n}),te(null)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},t.name))]})]}),(0,s.jsx)(`button`,{onClick:()=>re(e.id),className:`p-2 ml-auto rounded-lg text-foreground/20 hover:text-red-500 hover:bg-red-500/10 transition-colors flex items-center justify-center`,children:(0,s.jsx)(t.w,{className:`w-4 h-4`})})]})})]},e.id||`row_${n}`)}),Z.length===0&&(0,s.jsx)(`tr`,{children:(0,s.jsxs)(`td`,{colSpan:(K.columns||[]).length+2,className:`py-12 text-center text-foreground/40 text-[14px] font-medium border border-[var(--panel-border)] m-4 rounded-xl border-dashed`,children:[`No records found in `,K.name||`this table`,`.`]})}),(0,s.jsx)(`tr`,{children:(0,s.jsx)(`td`,{colSpan:(K.columns||[]).length+2,className:`py-2 px-4 border-none bg-foreground/[0.01]`,children:(0,s.jsx)(`div`,{className:`flex items-center gap-4`,children:(0,s.jsx)(`button`,{onClick:ne,className:`p-1.5 rounded-lg text-foreground/40 hover:text-accent hover:bg-accent/10 transition-colors flex items-center justify-center ml-2 border border-transparent hover:border-accent/20`,children:(0,s.jsx)(t.F,{className:`w-4 h-4`})})})})})]})]},`table`)})})]})]})}var nr=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}],rr={dateStr:``,title:``,description:``,time:`12:00`,duration:`60`,color:``,guestEmail:``,customFields:{}};function ir({title:e=`Calendar View`,subtitle:n=`/templates/calendar`,backUrl:o=`/templates`,eventsCollection:l=`pub_events`,defaultTimeFormat:u=`12h`,config:d,customContent:f}){let p=!!(d?.isPrivate||d?.isAdmin||d?.isInternal||d?.isShared);d?.isAdmin,d?.isInternal||d?.isShared,d?.isPrivate;let m=d?.showButton!==!1,h=d?.buttonText||`+`,g=d?.buttonStyle||`primary`,_=d?.showViewsButton!==!1,v=d?.viewsButtonStyle||`secondary`,y=d?.defaultView||`calendar`,b=d?.customFields||[],x=l.startsWith(`user_`)?`user`:l.startsWith(`mem_`)?`internal`:l.startsWith(`admin_`)?`admin_only`:`public`,[S,C]=(0,r.useState)(()=>{try{let e=localStorage.getItem(`cal_view_${l}`);if(e===`list`||e===`month`)return e}catch{}return y===`board`?`list`:`month`}),[w,T]=(0,r.useState)([]),[E,D]=(0,r.useState)(!1),[O,k]=(0,r.useState)(null),[A,j]=(0,r.useState)(!1),[ee,M]=(0,r.useState)(!1),[N,P]=(0,r.useState)(null),[F,I]=(0,r.useState)(rr),[L,R]=(0,r.useState)(new Date),[z,B]=(0,r.useState)(null),[V,te]=(0,r.useState)(null),[H,U]=(0,r.useState)(!1),W=`cal_24h_${l}`,[G,K]=(0,r.useState)(()=>{try{let e=localStorage.getItem(W);if(e!==null)return e===`true`}catch{}return u===`24h`}),q=()=>{let e=!G;K(e);try{localStorage.setItem(W,String(e))}catch{}};(0,r.useEffect)(()=>{try{localStorage.setItem(`cal_view_${l}`,S)}catch{}},[S,l,x]);let J=()=>{let e=S===`month`?`list`:`month`;C(e);try{localStorage.setItem(`cal_view_${l}`,e)}catch{}},Y=()=>{try{return sessionStorage.getItem(`cal_guest_email`)||``}catch{return``}},ne=e=>{try{sessionStorage.setItem(`cal_guest_email`,e)}catch{}};(0,r.useEffect)(()=>(0,a.onAuthStateChanged)(t.Bt,async e=>{if(B(e),e&&x===`admin_only`)try{let n=await(0,i.getDoc)((0,i.doc)(t.Vt,`user_profiles`,e.uid));n.exists()&&te(n.data())}catch{}U(!0)}),[x]),(0,r.useEffect)(()=>{if(!H)return;if(x!==`public`&&!z){T([]);return}try{let e=localStorage.getItem(`fbos_cal_${l}`);e&&T(JSON.parse(e))}catch{}let e=(0,i.onSnapshot)(x===`user`&&z?(0,i.query)((0,i.collection)(t.Vt,l),(0,i.where)(`uid`,`==`,z.uid)):(0,i.collection)(t.Vt,l),e=>{let t=[];e.forEach(e=>t.push({id:e.id,...e.data()})),T(t),localStorage.setItem(`fbos_cal_${l}`,JSON.stringify(t))},e=>console.error(`Calendar events:`,e));return()=>e()},[l,x,z?.uid,H]);let re=e=>!!z&&z.uid===e.uid,ie=e=>x===`public`?!1:x===`user`?!!z:re(e),ae=e=>{if(!e)return``;if(G)return e;let[t,n]=e.split(`:`),r=parseInt(t,10),i=r>=12?`PM`:`AM`;return r=r%12||12,`${r}:${n} ${i}`},oe=e=>{if(!e)return`60m`;let t=parseInt(e,10);return isNaN(t)?e:t>=60?t%60==0?`${t/60}h`:`${Math.floor(t/60)}h ${t%60}m`:`${t}m`},X=e=>{let[t,n]=(e||`12:00`).split(`:`),r=parseInt(t,10)||0,i=parseInt(n,10)||0,a=r>=12?`PM`:`AM`;return r=r%12||12,{h:r,m:i,ampm:a}},ce=(e,t,n)=>{let r=e%12;return n===`PM`&&(r+=12),`${r.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},Z=e=>{let t=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-t).toISOString().split(`T`)[0]},ue=()=>Z(new Date),de=new Date(L.getFullYear(),L.getMonth(),1),fe=new Date(L.getFullYear(),L.getMonth()+1,0),pe=de.getDay(),he=fe.getDate(),ge=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],_e=Array.from({length:42},(e,t)=>{let n=t-pe+1,r=new Date(L.getFullYear(),L.getMonth(),n);return{day:r.getDate(),dateStr:Z(r),isCurrentMonth:n>0&&n<=he}}),ve=()=>R(S===`month`?new Date(L.getFullYear(),L.getMonth()-1,1):new Date(L.getFullYear(),L.getMonth(),L.getDate()-1)),ye=()=>R(S===`month`?new Date(L.getFullYear(),L.getMonth()+1,1):new Date(L.getFullYear(),L.getMonth(),L.getDate()+1)),be=e=>{if(x!==`public`&&!z)return;let t=new Date;t.setDate(t.getDate()+1);let n=new Date().getHours().toString().padStart(2,`0`);I({...rr,dateStr:e||Z(t),time:`${n}:00`,guestEmail:x===`public`?Y():``,customFields:{}}),D(!0)},xe=e=>{let t=e.time;if(t){let[e,n]=t.split(`:`);e&&n&&(t=`${e.padStart(2,`0`)}:${n}`)}I({id:e.id,uid:e.uid,dateStr:e.dateStr,title:e.title,description:e.description||``,time:t||`12:00`,duration:e.duration||`60`,color:e.color||``,guestEmail:e.creatorEmail||``,customFields:e.customFields||{}}),D(!0)},Q=async e=>{if(e.preventDefault(),F.title.trim()){j(!0);try{let e={dateStr:F.dateStr,title:F.title.trim(),description:F.description.trim(),time:F.time,duration:F.duration||`60`};if(F.color&&(e.color=F.color),b.length>0&&(e.customFields=F.customFields),!F.id)if(x===`public`){let t=F.guestEmail.trim();e.creatorEmail=t,ne(t)}else x===`user`||x===`internal`?(e.uid=z?.uid,e.creatorEmail=z?.email||``,e.creatorName=z?.displayName||``,e.creatorAvatar=z?.photoURL||``):x===`admin_only`&&(e.uid=z?.uid,e.creatorEmail=V?.email||z?.email||``,e.creatorName=V?.displayName||V?.name||``,e.creatorAvatar=V?.avatar||V?.avatarUrl||z?.photoURL||``);F.id?(await(0,i.setDoc)((0,i.doc)(t.Vt,l,F.id),e,{merge:!0}),O?.id===F.id&&k({...O,...e})):await(0,i.setDoc)((0,i.doc)(t.Vt,l,`ev_${Date.now()}`),e,{merge:!0}),D(!1)}catch(e){console.error(e)}j(!1)}},Se=async()=>{if(N){M(!0);try{await(0,i.deleteDoc)((0,i.doc)(t.Vt,l,N.id)),O?.id===N.id&&k(null),P(null),D(!1)}catch{}M(!1)}},Ce=e=>{if(x===`user`||!e.creatorEmail&&!e.creatorName)return null;let t=(e.creatorName||e.creatorEmail||`?`).charAt(0).toUpperCase(),n=nr.find(t=>t.text===e.color);return(0,s.jsxs)(`div`,{className:`flex items-center gap-3 mt-4 p-3 rounded-xl bg-foreground/[0.03] border border-[var(--panel-border)]/50`,children:[e.creatorAvatar?(0,s.jsx)(`img`,{src:e.creatorAvatar,alt:``,className:`w-8 h-8 rounded-full object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`w-8 h-8 rounded-full ${n?.bgCircle||`bg-accent`} flex items-center justify-center text-[13px] font-extrabold text-white shrink-0`,children:t}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[e.creatorName&&(0,s.jsx)(`span`,{className:`text-[13px] font-bold text-foreground/90 truncate`,children:e.creatorName}),e.creatorEmail&&(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate`,children:e.creatorEmail})]})]})},we=e=>{if(x===`user`||x===`public`||!e.creatorName&&!e.creatorEmail)return null;let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||``,n=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[e.creatorAvatar?(0,s.jsx)(`img`,{src:e.creatorAvatar,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:n}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),e.creatorEmail&&(0,s.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,e.creatorEmail]})]})]})};if(H&&x!==`public`&&!z)return(0,s.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen p-8`,children:(0,s.jsxs)(`div`,{className:`text-center glass-panel border border-[var(--panel-border)] rounded-3xl p-12 max-w-sm w-full`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-accent/10 border border-accent/20 flex items-center justify-center mx-auto mb-4`,children:(0,s.jsx)(t.V,{className:`w-7 h-7 text-accent`})}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold mb-2`,children:`Sign in required`}),(0,s.jsx)(`p`,{className:`text-foreground/50 text-[14px] mb-6`,children:`You need to be signed in to access this calendar.`}),(0,s.jsx)(c.Link,{to:`/login`,className:`inline-flex items-center justify-center gap-2 px-6 py-2.5 rounded-xl btn-primary font-bold text-[14px] w-full`,children:`Sign In`})]})});if(!H&&x!==`public`)return(0,s.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen`,children:(0,s.jsx)(t.W,{className:`w-8 h-8 animate-spin text-accent`})});let Te=!!f,Ee=(x===`public`||!!z)&&m&&!Te,De=()=>(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 sm:gap-4 p-4 sm:p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:d?.tabTitle||d?.tabName||e}),(0,s.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[w.length,` `,w.length===1?`event`:`events`,` · `,S===`month`?`Month`:`Board`,` View`]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(t.d.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:q,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer btn-secondary text-[12px] font-extrabold`,children:G?`24h`:`12h`}),_&&!Te&&(0,s.jsx)(t.d.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:J,title:S===`month`?`Switch to Board`:`Switch to Calendar`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${v===`primary`?`btn-primary`:`btn-secondary`}`,children:S===`month`?(0,s.jsx)(t.J,{className:`w-4 h-4`}):(0,s.jsx)(t.Et,{className:`w-4 h-4`})}),Ee&&(0,s.jsx)(t.d.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>be(),className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${h===`+`?`w-10`:`px-5`} ${g===`primary`?`btn-primary`:`btn-secondary`}`,children:h===`+`?(0,s.jsx)(t.F,{className:`w-4 h-4`}):(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:h})})]})]}),Oe=()=>(0,s.jsxs)(`div`,{className:`p-4 md:p-6 border-b border-[var(--panel-border)]/50 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 bg-foreground/[0.01]`,children:[(0,s.jsx)(`h3`,{className:`text-lg md:text-xl font-extrabold tracking-tight ml-2 min-w-0`,children:S===`month`?L.toLocaleString(`default`,{month:`long`,year:`numeric`}):L.toLocaleString(`default`,{month:`long`,day:`numeric`,year:`numeric`})}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,s.jsx)(`button`,{onClick:()=>R(new Date),className:`px-3 md:px-4 py-2 text-[13px] font-bold border border-[var(--panel-border)] rounded-xl mr-1 md:mr-2 hover:bg-foreground/5 transition-colors`,children:`Today`}),(0,s.jsx)(`button`,{onClick:ve,className:`p-2 rounded-xl text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-colors border border-transparent hover:border-[var(--panel-border)]`,children:(0,s.jsx)(t.xt,{className:`w-5 h-5`})}),(0,s.jsx)(`button`,{onClick:ye,className:`p-2 rounded-xl text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-colors border border-transparent hover:border-[var(--panel-border)]`,children:(0,s.jsx)(t.bt,{className:`w-5 h-5`})})]})]}),ke=()=>(0,s.jsxs)(s.Fragment,{children:[Oe(),f?(0,s.jsx)(`div`,{className:`fbos-content-slot p-4 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:(0,s.jsx)(f,{config:d,actions:{events:w,loading:!H,collection:l,currentUser:z,saveEvent:async e=>{let n=e.id||`ev_${Date.now()}`;T(t=>t.find(e=>e.id===n)?t.map(t=>t.id===n?{...t,...e}:t):[...t,{id:n,...e}]),await(0,i.setDoc)((0,i.doc)(t.Vt,l,n),e,{merge:!0})},deleteEvent:async e=>{T(t=>t.filter(t=>t.id!==e)),await(0,i.deleteDoc)((0,i.doc)(t.Vt,l,e))},openAddModal:e=>be(e),openEditModal:e=>xe(e),setViewingEvent:e=>k(e),currentDate:L,setCurrentDate:R,goToPrev:ve,goToNext:ye,goToToday:()=>R(new Date)}})}):S===`month`?(0,s.jsx)(`div`,{className:`overflow-x-auto w-full flex-1`,children:(0,s.jsxs)(`div`,{className:`min-w-[800px] h-full flex flex-col`,children:[(0,s.jsx)(`div`,{className:`grid grid-cols-7 border-b border-[var(--panel-border)]/50 bg-foreground/[0.02]`,children:ge.map(e=>(0,s.jsx)(`div`,{className:`py-3 text-center text-[12px] font-bold uppercase tracking-wider text-foreground/40`,children:e},e))}),(0,s.jsx)(`div`,{className:`grid grid-cols-7 auto-rows-auto bg-[var(--panel-border)] gap-[1px] relative flex-1`,children:_e.map((e,n)=>{let r=e.dateStr===ue(),i=w.filter(t=>t.dateStr===e.dateStr);return(0,s.jsxs)(`div`,{onClick:()=>e.isCurrentMonth&&Ee&&be(e.dateStr),className:`min-h-[140px] p-2 bg-[var(--panel-bg)] flex flex-col relative group
|
|
31
|
-
${e.isCurrentMonth?Ee?`hover:bg-foreground/[0.03] transition-colors cursor-cell`:``:`opacity-30 bg-background/50 pointer-events-none`}`,children:[(0,s.jsx)(`div`,{className:`flex justify-between items-start mb-2 shrink-0`,children:(0,s.jsx)(`span`,{className:`w-8 h-8 rounded-full flex items-center justify-center text-[14px] font-bold ${r?`bg-accent text-white shadow-lg shadow-accent/20`:`text-foreground/70 group-hover:text-foreground`}`,children:e.day})}),(0,s.jsx)(`div`,{className:`flex flex-col gap-1.5 flex-1 w-full relative z-10 pb-1`,children:i.map(e=>{let n=
|
|
30
|
+
Do not change anything else.`},{title:`Remove the pages that came with the app`,prompt:`Remove the Guide, Templates and Contact pages from my site, including their entries in the site menu.`}]}],Nt=`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px] mb-3`,Pt=`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)]`;function Ft({children:e}){return(0,s.jsxs)(`div`,{className:Nt,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e]})}function It(){return(0,s.jsxs)(`main`,{className:`flex-1 w-full max-w-4xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12`,children:[(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-10 text-center`,children:[(0,s.jsx)(`h1`,{className:`w-fit mx-auto inline-block text-[26px] sm:text-3xl md:text-4xl lg:text-5xl leading-[1.1] font-extrabold tracking-tight mb-4 text-gradient`,children:`Guide`}),(0,s.jsx)(`p`,{className:`text-foreground/60 text-base sm:text-lg font-medium max-w-2xl mx-auto`,children:`Your website is built by describing it, and your dashboard pages are added on the Pages screen and filled by describing them. This page shows what a complete description contains, and gives you finished ones to paste.`})]}),(0,s.jsxs)(t.f.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`mb-12`,children:[(0,s.jsx)(`div`,{className:`relative w-full rounded-2xl overflow-hidden border border-[var(--panel-border)] glass-panel`,children:(0,s.jsx)(`div`,{className:`relative w-full aspect-video`,children:(0,s.jsx)(`iframe`,{className:`absolute inset-0 w-full h-full`,src:`https://www.youtube-nocookie.com/embed/${Et}?start=1`,title:`Watch the guide`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share`,allowFullScreen:!0,loading:`lazy`,referrerPolicy:`strict-origin-when-cross-origin`})})}),(0,s.jsx)(`p`,{className:`mt-3 text-center text-[12.5px] text-foreground/45 font-medium`,children:`Six minutes, from an empty project to a finished site.`})]}),(0,s.jsxs)(t.f.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.05},className:`mb-12`,children:[(0,s.jsx)(Ft,{children:`A page anyone can visit: what a complete request contains`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-2`,children:`Nine things, in this order`}),(0,s.jsx)(`p`,{className:`text-[13.5px] text-foreground/55 font-medium leading-relaxed mb-5 max-w-2xl`,children:`Before the assistant builds anything it needs every one of these. Say them all in one message and it builds the whole thing in one go. Leave one out and it stops to ask.`}),(0,s.jsx)(`div`,{className:`${Pt} divide-y divide-[var(--panel-border)]`,children:Dt.map((e,t)=>(0,s.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[11rem_1fr] sm:gap-6 px-5 py-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-baseline gap-2.5 sm:block`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/35 tabular-nums sm:block sm:mb-0.5`,children:String(t+1).padStart(2,`0`)}),(0,s.jsx)(`h3`,{className:`text-[13.5px] font-bold text-foreground tracking-tight`,children:e.term})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:e.body}),(0,s.jsx)(`p`,{className:`text-[13px] text-accent font-semibold leading-relaxed`,children:e.example})]})]},e.term))})]}),(0,s.jsxs)(t.f.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:`mb-12`,children:[(0,s.jsx)(Ft,{children:`Who it is for`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-2`,children:`The four audiences`}),(0,s.jsx)(`p`,{className:`text-[13.5px] text-foreground/55 font-medium leading-relaxed mb-5 max-w-2xl`,children:`Every page is for exactly one of these. These are the words on your Pages screen. A page anyone can visit is asked for in the chat; the other three are added on the Pages screen.`}),(0,s.jsx)(`div`,{className:`${Pt} divide-y divide-[var(--panel-border)]`,children:Ot.map(e=>(0,s.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[11rem_1fr] sm:gap-6 px-5 py-4`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,s.jsx)(`h3`,{className:`text-[13.5px] font-bold text-foreground tracking-tight`,children:e.name}),(0,s.jsx)(`p`,{className:`text-[12px] text-accent font-semibold`,children:e.how})]}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:e.who})]},e.name))}),(0,s.jsx)(`p`,{className:`mt-3 text-[12.5px] text-foreground/50 font-medium leading-relaxed max-w-2xl`,children:`Registering only makes someone a signed-in user, not a team member. Never put your team’s information on a page for signed-in users: any stranger who registers could open it.`})]}),(0,s.jsxs)(t.f.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.12},className:`mb-12`,children:[(0,s.jsx)(Ft,{children:`A page for your team, signed-in users or admins`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-2`,children:`Three steps, and the assistant only fills it in`}),(0,s.jsx)(`p`,{className:`text-[13.5px] text-foreground/55 font-medium leading-relaxed mb-5 max-w-2xl`,children:`Never ask the chat to create a dashboard page. Asked to, it rewrites files it must not touch, opens the page to strangers and invents forms. You add the page; the assistant only writes what is on it.`}),(0,s.jsx)(`div`,{className:`${Pt} divide-y divide-[var(--panel-border)]`,children:kt.map((e,t)=>(0,s.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[11rem_1fr] sm:gap-6 px-5 py-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-baseline gap-2.5 sm:block`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/35 tabular-nums sm:block sm:mb-0.5`,children:String(t+1).padStart(2,`0`)}),(0,s.jsx)(`h3`,{className:`text-[13.5px] font-bold text-foreground tracking-tight`,children:e.title})]}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:e.body})]},e.title))})]}),(0,s.jsxs)(t.f.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.15},className:`mb-12`,children:[(0,s.jsx)(Ft,{children:`No assistant needed`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-2`,children:`Things you change yourself`}),(0,s.jsx)(`p`,{className:`text-[13.5px] text-foreground/55 font-medium leading-relaxed mb-5 max-w-2xl`,children:`These are switches and boxes in your admin screens. Asking the assistant for them only gets you sent here.`}),(0,s.jsx)(`div`,{className:`${Pt} divide-y divide-[var(--panel-border)]`,children:At.map(e=>(0,s.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[11rem_1fr] sm:gap-6 px-5 py-4`,children:[(0,s.jsx)(c.Link,{to:e.path,className:`text-[13.5px] font-bold text-foreground tracking-tight hover:text-accent transition-colors w-fit`,children:e.screen}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:e.body})]},e.screen))}),(0,s.jsx)(`p`,{className:`mt-3 text-[12.5px] text-foreground/50 font-medium leading-relaxed max-w-2xl`,children:`The Guide, Templates, Contact and Setup pages come with the app and are visible on purpose. Hide any of them on the Pages screen with the switch next to its name.`})]}),(0,s.jsxs)(t.f.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2},className:`mb-12`,children:[(0,s.jsx)(Ft,{children:`Working with the assistant`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-5`,children:`Five habits`}),(0,s.jsx)(`div`,{className:`${Pt} divide-y divide-[var(--panel-border)]`,children:jt.map(e=>(0,s.jsxs)(`div`,{className:`flex flex-col gap-1 px-5 py-4`,children:[(0,s.jsx)(`h3`,{className:`text-[13.5px] font-bold text-foreground tracking-tight`,children:e.title}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:e.body})]},e.title))})]}),(0,s.jsxs)(t.f.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.25},className:`flex flex-col gap-4 mb-12`,children:[(0,s.jsxs)(`div`,{className:`mb-1`,children:[(0,s.jsx)(Ft,{children:`Ready to paste`}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold tracking-tight text-foreground mb-2`,children:`Finished requests`}),(0,s.jsxs)(`p`,{className:`text-[13.5px] text-foreground/55 font-medium leading-relaxed max-w-2xl`,children:[`Each one answers every question the assistant would otherwise ask. Copy it, change the words to yours, and paste it as one message. Want to see the layouts first?`,` `,(0,s.jsx)(c.Link,{to:`/templates`,className:`text-accent font-bold hover:underline`,children:`Look through the templates`}),`.`]})]}),Mt.map(e=>(0,s.jsx)(Te,{title:e.title,description:e.description,children:e.prompts.map(e=>(0,s.jsx)(Ze,{title:e.title,prompt:e.prompt,compact:!0},e.title))},e.id))]})]})}function Lt(){let[e,n]=(0,r.useState)({favoriteService:``,satisfactionRating:``,detailedThoughts:``}),[a,o]=(0,r.useState)(`idle`);return(0,s.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,s.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mb-6`,children:(0,s.jsxs)(c.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,s.jsx)(t.Mt,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,s.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mt-6`,children:(0,s.jsxs)(t.f.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-form relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-auto`,children:[(0,s.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,s.jsx)(`div`,{className:`relative z-10 w-full`,children:a===`success`?(0,s.jsxs)(t.f.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,s.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,s.jsx)(t.vt,{className:`w-8 h-8`})}),(0,s.jsx)(`h4`,{className:`text-lg font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed`,children:`Your test data was sent successfully. Log in as an admin and open your Inbox to see it.`})]}):a===`loading`?(0,s.jsxs)(t.f.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,s.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,s.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,s.jsxs)(t.f.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,s.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,s.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Inline Form Template`}),(0,s.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,s.jsxs)(`form`,{onSubmit:async r=>{r.preventDefault(),o(`loading`);try{let r=t.Vt.currentUser?.uid||`guest`;await(0,i.addDoc)((0,i.collection)(t.Ht,`user_submissions`),{uid:r,...e,type:`template_simulation`,submittedAt:(0,i.serverTimestamp)()}),o(`success`),setTimeout(()=>{o(`idle`),n({favoriteService:``,satisfactionRating:``,detailedThoughts:``})},3e3)}catch{o(`error`)}},className:`space-y-4 w-full`,children:[(0,s.jsx)(t.c,{label:`Favorite Service`,placeholder:`e.g. Design Consulting`,value:e.favoriteService,onChange:t=>n({...e,favoriteService:t.target.value})}),(0,s.jsx)(t.c,{label:`Satisfaction Rating`,type:`number`,placeholder:`1 to 10`,value:e.satisfactionRating,onChange:t=>n({...e,satisfactionRating:t.target.value})}),(0,s.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,s.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Detailed Thoughts`}),(0,s.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:e.detailedThoughts,onChange:t=>n({...e,detailedThoughts:t.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,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsx)(t.s,{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 Rt(){let[e,n]=(0,r.useState)(!1),[a,o]=(0,r.useState)({concept:``,featureRequest:``,notes:``}),[l,u]=(0,r.useState)(`idle`);return(0,s.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,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,s.jsx)(se,{children:`Popup Form`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/popup_form`]})]}),(0,s.jsx)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:(0,s.jsxs)(c.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,s.jsx)(t.Mt,{className:`w-4 h-4`}),` Go Back`]})}),(0,s.jsxs)(t.f.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,s.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,s.jsx)(`div`,{className:`flex h-full w-full justify-end items-start relative z-10`,children:(0,s.jsxs)(t.s,{onClick:()=>n(!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,s.jsx)(t.I,{className:`w-4 h-4`}),` Open Form`]})})]}),(0,s.jsx)(t.p,{children:e&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl cursor-pointer`,onClick:()=>n(!1)}),(0,s.jsxs)(t.f.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-popover relative shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-4 max-h-[95vh] overflow-y-auto no-scrollbar`,children:[(0,s.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,s.jsxs)(`div`,{className:`relative z-10 w-full`,children:[(0,s.jsx)(`button`,{onClick:()=>n(!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,s.jsx)(t._,{className:`w-5 h-5`})}),l===`success`?(0,s.jsxs)(t.f.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,s.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,s.jsx)(t.vt,{className:`w-8 h-8`})}),(0,s.jsx)(`h4`,{className:`text-xl font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,s.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 open your Inbox to see it.`})]}):l===`loading`?(0,s.jsxs)(t.f.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,s.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,s.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,s.jsxs)(t.f.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,s.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,s.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Popup Template`}),(0,s.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,s.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),u(`loading`);try{let e=t.Vt.currentUser?.uid||`guest`;await(0,i.addDoc)((0,i.collection)(t.Ht,`user_submissions`),{uid:e,...a,type:`template_simulation`,submittedAt:(0,i.serverTimestamp)()}),u(`success`),setTimeout(()=>{u(`idle`),o({concept:``,featureRequest:``,notes:``}),n(!1)},3e3)}catch{u(`error`)}},className:`space-y-4 w-full`,children:[(0,s.jsx)(t.c,{label:`Concept Name`,placeholder:`e.g. Project Apollo`,value:a.concept,onChange:e=>o({...a,concept:e.target.value})}),(0,s.jsx)(t.c,{label:`Feature Request`,placeholder:`e.g. Real-time sync`,value:a.featureRequest,onChange:e=>o({...a,featureRequest:e.target.value})}),(0,s.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,s.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Simulated Notes`}),(0,s.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:a.notes,onChange:e=>o({...a,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,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsx)(t.s,{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 zt(){let[e,n]=(0,r.useState)(void 0);return(0,s.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,s.jsx)(`div`,{className:`w-full max-w-5xl mb-8`,children:(0,s.jsxs)(c.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,s.jsx)(t.Mt,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,s.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,s.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-8 pb-6 border-b border-[var(--panel-border)]/50`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h3`,{className:`text-2xl font-extrabold text-foreground tracking-tight`,children:`System Files`}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/50 mt-1`,children:`Review and manage core application assets.`})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,s.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/50 flex items-center justify-between gap-3 sm:gap-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-4 min-w-0 flex-1`,children:[(0,s.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,s.jsx)(t.w,{className:`w-5 h-5`})}),(0,s.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,s.jsx)(`h4`,{className:`font-bold text-[14px] sm:text-[15px] text-foreground truncate`,children:`Critical Configuration File`}),(0,s.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,s.jsx)(t.s,{variant:`secondary`,onClick:()=>n(null),className:`shrink-0 flex items-center justify-center px-4 sm:px-6 py-2.5 text-[13px] font-bold rounded-xl text-red-500 hover:bg-red-500/10 hover:border-red-500/20 bg-transparent`,children:`Delete File`})]}),(0,s.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,s.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/20 flex items-center gap-4`,children:[(0,s.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-foreground/5 shrink-0`}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 flex-1`,children:[(0,s.jsx)(`div`,{className:`w-32 h-3 rounded-full bg-foreground/10`}),(0,s.jsx)(`div`,{className:`w-20 h-2 rounded-full bg-foreground/5`})]})]},e))})]})]}),(0,s.jsx)(t.p,{children:e!==void 0&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl`}),(0,s.jsx)(t.f.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,s.jsx)(t.p,{mode:`wait`,children:e===null?(0,s.jsxs)(t.f.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center`,children:[(0,s.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Confirm Deletion`}),(0,s.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,s.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,s.jsx)(t.s,{variant:`secondary`,onClick:()=>n(!1),className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:`Cancel`}),(0,s.jsx)(t.s,{onClick:()=>n(!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,s.jsxs)(t.f.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,s.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-green-500 tracking-tight flex items-center gap-2`,children:[(0,s.jsx)(t.wt,{className:`w-5 h-5`}),` Verified`]}),(0,s.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Action successfully executed.`}),(0,s.jsx)(t.s,{variant:`secondary`,onClick:()=>n(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`success`):(0,s.jsxs)(t.f.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,s.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-foreground/80 tracking-tight flex items-center gap-2`,children:[(0,s.jsx)(t._,{className:`w-5 h-5`}),` Aborted`]}),(0,s.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Cancellation securely caught.`}),(0,s.jsx)(t.s,{variant:`secondary`,onClick:()=>n(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`error`)})})]})})]})}var Bt=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}];function Vt({title:e=`Board View`,subtitle:n=`/templates/board`,backUrl:a=`/templates`,tasksCollection:o=`pub_tasks`,categoriesCollection:l=`pub_categories`,config:u,customContent:d}){let{user:f}=ee(),p=!!u,m=u?.isInternal||u?.isShared;u?.isPrivate&&u?.isAdmin;let h=u?.isAdmin||m,g=p?h:!0,_=!!d,v=u?.showButton!==!1&&!_,y=u?.buttonText||`+`,b=u?.buttonStyle||`primary`,x=u?.keyName||`key`,S=u?.valueName||`value`,[C,w]=(0,r.useState)([]),[T,E]=(0,r.useState)([]),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),[j,M]=(0,r.useState)({name:``}),[N,P]=(0,r.useState)([]),[F,I]=(0,r.useState)(null),[L,R]=(0,r.useState)(null),[z,B]=(0,r.useState)(null),[V,te]=(0,r.useState)(null),[H,U]=(0,r.useState)(!1),[W,G]=(0,r.useState)(null),[K,q]=(0,r.useState)(``),[J,Y]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=o.startsWith(`user_`),n=l.startsWith(`user_`);if(e&&!f)return;try{let e=localStorage.getItem(`fbos_board_tasks_${o}`);e&&w(JSON.parse(e));let t=localStorage.getItem(`fbos_board_cats_${l}`);t&&E(JSON.parse(t))}catch{}let r=(0,i.onSnapshot)(e&&f?(0,i.query)((0,i.collection)(t.Ht,o),(0,i.where)(`uid`,`==`,f.uid)):(0,i.collection)(t.Ht,o),e=>{let t=[];e.forEach(e=>{let n=e.data();t.push({id:e.id,categoryId:n.categoryId,name:n.name||n.text||`Unnamed Item`,fields:n.fields||(n.value?[{key:`Label`,value:n.value}]:[]),order:n.order||0})});let n=t.sort((e,t)=>(e.order||0)-(t.order||0));w(n),localStorage.setItem(`fbos_board_tasks_${o}`,JSON.stringify(n))}),a=(0,i.onSnapshot)(n&&f?(0,i.query)((0,i.collection)(t.Ht,l),(0,i.where)(`uid`,`==`,f.uid)):(0,i.collection)(t.Ht,l),e=>{let n=[];if(e.forEach(e=>{n.push({id:e.id,...e.data()})}),n.length===0){let e=[{id:`todo`,title:`To Do`,createdAt:Date.now()-2e3},{id:`in_progress`,title:`In Progress`,createdAt:Date.now()-1e3},{id:`review`,title:`Review`,createdAt:Date.now()}],n=f?{uid:f.uid}:{};e.forEach(e=>(0,i.setDoc)((0,i.doc)(t.Ht,l,e.id),{...n,title:e.title,createdAt:e.createdAt}))}else E(n),localStorage.setItem(`fbos_board_cats_${l}`,JSON.stringify(n))});return()=>{r(),a()}},[o,l,f]);let ne=(e,t)=>{t?(A(t.id),M({id:t.id,name:t.name}),P(t.fields?.length?[...t.fields,{key:``,value:``}]:[{key:``,value:``}])):(O(e),M({name:``}),P([{key:``,value:``}]))},re=(e,t,n)=>{let r=[...N];r[e]={key:t,value:n},e===N.length-1&&(t.trim()!==``||n.trim()!==``)&&r.push({key:``,value:``}),P(r)},ie=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`taskId`,t),I(t)},ae=(e,t)=>{e.preventDefault(),e.stopPropagation(),t!==F&&R(t)},oe=(e,t)=>{e.preventDefault(),e.stopPropagation(),B(t)},X=e=>{e.preventDefault(),R(null),B(null)},ce=async(e,n,r)=>{e.preventDefault(),e.stopPropagation(),R(null),B(null);let a=e.dataTransfer.getData(`taskId`);if(!a||a===r){I(null);return}let s=C.find(e=>e.id===a);if(!s)return;let c=C.filter(e=>e.categoryId===n).sort((e,t)=>(e.order||0)-(t.order||0));if(s.categoryId===n?(c=c.filter(e=>e.id!==a),c.push(s)):c.push({...s,categoryId:n}),r){let e=c.findIndex(e=>e.id===r),t=c.findIndex(e=>e.id===a),[n]=c.splice(t,1);c.splice(e,0,n)}c.forEach((e,r)=>{let a={categoryId:n,order:r};f&&(a.uid=f.uid),(0,i.setDoc)((0,i.doc)(t.Ht,o,e.id),a,{merge:!0})}),I(null)},Z=async e=>{let n=j.id||`item_${Date.now()}`,r=j.name.trim(),a=r||`Untitled Item`,s=N.filter(e=>e.key.trim()!==``||e.value.trim()!==``),c=!0,l=j.id?C.find(e=>e.id===j.id):null;if(l){let e=JSON.stringify(l.fields||[]),t=JSON.stringify(s);l.name===a&&e===t&&(c=!1)}else !r&&s.length===0&&(c=!1);if(!c){O(null),A(null);return}te(j.id||`new`);let u={categoryId:e,name:a,fields:s};f&&!j.id&&(u.uid=f.uid),await(0,i.setDoc)((0,i.doc)(t.Ht,o,n),u,{merge:!0}),setTimeout(()=>{O(null),A(null),te(null)},400)},ue=(e,t)=>{Y({type:`item`,id:e,title:t})},de=async()=>{let e=`cat_${Date.now()}`,n={title:``,createdAt:Date.now()};f&&(n.uid=f.uid),await(0,i.setDoc)((0,i.doc)(t.Ht,l,e),n),G(e),q(``),setTimeout(()=>{let e=document.getElementById(`board-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},150)},fe=async(e,n)=>{E(t=>t.map(t=>t.id===e?{...t,color:n}:t)),await(0,i.setDoc)((0,i.doc)(t.Ht,l,e),{color:n},{merge:!0})},pe=async e=>{K.trim()?await(0,i.setDoc)((0,i.doc)(t.Ht,l,e),{title:K},{merge:!0}):await(0,i.deleteDoc)((0,i.doc)(t.Ht,l,e)),G(null)},me=(e,t)=>{Y({type:`category`,id:e,title:t})},he=async()=>{if(J){U(!0);try{if(J.type===`item`)await(0,i.deleteDoc)((0,i.doc)(t.Ht,o,J.id)),A(null);else{let e=C.filter(e=>e.categoryId===J.id);for(let n of e)await(0,i.deleteDoc)((0,i.doc)(t.Ht,o,n.id));await(0,i.deleteDoc)((0,i.doc)(t.Ht,l,J.id))}}catch{}U(!1),Y(null)}},ge=[...T].sort((e,t)=>(e.createdAt||0)-(t.createdAt||0));return(0,s.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 overflow-x-hidden`,children:[(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,s.jsx)(se,{children:e}),n&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),n]})]}),p&&(0,s.jsx)(`div`,{className:`mb-6`,children:(0,s.jsx)(le,{})}),(0,s.jsxs)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 gap-3 sm:gap-4 relative z-20 shrink-0`,children:[!p&&a&&(0,s.jsxs)(c.Link,{to:a,className:`px-5 py-2 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold text-foreground/70 hover:bg-foreground/5 transition-all flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(t.Mt,{className:`w-4 h-4`}),` Go Back`]}),p&&(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:u?.tabTitle||u?.tabName||e}),(0,s.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[C.length,` `,C.length===1?`item`:`items`,` · `,ge.length,` `,ge.length===1?`category`:`categories`]})]}),(0,s.jsx)(`div`,{className:`flex flex-row gap-2 shrink-0`,children:v&&(0,s.jsx)(t.s,{variant:b===`secondary`?`secondary`:void 0,onClick:de,className:`px-3 py-2.5 text-[14px] font-bold rounded-xl shadow-lg hover:-translate-y-0.5 transition-all shrink-0`,children:y===`+`?(0,s.jsx)(t.I,{className:`w-4 h-4`}):y})})]}),(0,s.jsx)(`div`,{className:`flex-1 w-full relative z-40 min-h-0`,children:d?(0,s.jsx)(`div`,{className:`fbos-content-slot w-full h-full overflow-y-auto`,children:(0,s.jsx)(d,{config:u,actions:{tasks:C,categories:T,collection:o,catCollection:l,user:f,saveTask:async(e,n)=>{let r=e||`item_${Date.now()}`;w(e=>e.find(e=>e.id===r)?e.map(e=>e.id===r?{...e,...n}:e):[...e,{id:r,...n}]),await(0,i.setDoc)((0,i.doc)(t.Ht,o,r),n,{merge:!0})},deleteTask:async e=>{w(t=>t.filter(t=>t.id!==e)),await(0,i.deleteDoc)((0,i.doc)(t.Ht,o,e))},saveCategory:async(e,n)=>{E(t=>t.find(t=>t.id===e)?t.map(t=>t.id===e?{...t,...n}:t):[...t,{id:e,...n}]),await(0,i.setDoc)((0,i.doc)(t.Ht,l,e),n,{merge:!0})},deleteCategory:async e=>{E(t=>t.filter(t=>t.id!==e)),await(0,i.deleteDoc)((0,i.doc)(t.Ht,l,e))},openInlineEditor:(e,t)=>ne(e,t)}})}):(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl shadow-2xl relative z-10 flex flex-col h-full p-4 md:p-6`,children:[(0,s.jsx)(`div`,{className:`absolute top-0 right-0 w-[400px] h-[400px] bg-accent/5 blur-[100px] rounded-full pointer-events-none -z-10`}),(0,s.jsxs)(`div`,{id:`board-container`,className:`w-full h-full flex flex-row gap-4 md:gap-6 overflow-x-auto pb-4 snap-x snap-mandatory styled-scrollbars items-start`,children:[ge.map((e,n)=>{let r=C.filter(t=>t.categoryId===e.id);r.sort((e,t)=>(e.order||0)-(t.order||0));let i=Bt.find(t=>t.text===e.color)||Bt.find(e=>e.text===`text-accent`);return i.text,i.bgLight,i.bgHover,(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:n*.1},className:`w-[calc(100vw-80px)] sm:w-[300px] md:w-[320px] shrink-0 flex flex-col max-h-full rounded-3xl p-4 snap-center relative border transition-colors ${Bt.find(t=>t.text===e.color)?.bgCard||`bg-foreground/[0.02]`} ${Bt.find(t=>t.text===e.color)?.borderCard||`border-[var(--panel-border)]/50`}`,children:[(0,s.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-2 relative z-[200]`,children:(0,s.jsxs)(`h3`,{className:`font-bold text-[14px] flex items-center w-full text-foreground/80 group relative z-[200]`,children:[W===e.id?(0,s.jsxs)(`div`,{className:`relative flex-1 w-full flex items-center pr-8 z-[200]`,children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),pe(e.id)}}),(0,s.jsx)(`input`,{value:K,onChange:e=>q(e.target.value),onBlur:t=>{t.relatedTarget?.closest(`.category-color-picker`)||pe(e.id)},onKeyDown:t=>t.key===`Enter`&&pe(e.id),className:`bg-transparent border-none outline-none font-bold text-[14px] w-full p-0 ${e.color||`text-foreground/80`}`,placeholder:`Category name`,autoFocus:!0}),(0,s.jsxs)(`div`,{className:`absolute top-8 left-0 flex gap-1.5 bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-[100] category-color-picker items-center`,tabIndex:-1,children:[(0,s.jsx)(`button`,{onClick:async t=>{t.preventDefault(),t.stopPropagation(),await fe(e.id,``),G(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Reset Category Color`,children:(0,s.jsx)(t._,{className:`w-3 h-3`})}),(0,s.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Bt.map(t=>(0,s.jsx)(`button`,{onMouseDown:async n=>{n.preventDefault(),await fe(e.id,t.text)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50 shrink-0`},t.name))]})]}):(0,s.jsxs)(`div`,{className:`flex items-center gap-2 w-full cursor-pointer hover:text-foreground transition-colors pr-8`,onClick:()=>{G(e.id),q(e.title)},children:[(0,s.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${Bt.find(t=>t.text===e.color)?.bgCircle||`bg-foreground/20`} transition-colors shrink-0`}),(0,s.jsx)(`span`,{className:`truncate flex-1 max-w-[200px] ${e.color||``}`,children:e.title||`Untitled Category`}),(0,s.jsx)(`span`,{className:`text-[11px] bg-foreground/10 text-foreground/60 px-1.5 py-0.5 rounded-md font-medium shrink-0`,children:r.length})]}),T.length>1&&(0,s.jsx)(`button`,{onClick:()=>me(e.id,e.title),className:`absolute right-0 opacity-100 md:opacity-0 md:group-hover:opacity-100 text-foreground/30 hover:text-red-500 transition-all shrink-0`,children:(0,s.jsx)(t.T,{className:`w-3.5 h-3.5`})})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2.5 flex-1 overflow-y-auto styled-scrollbars pr-1 relative min-h-[150px] rounded-xl transition-all ${z===e.id&&!L?`bg-foreground/5 scale-[1.01] border-dashed border border-accent/20`:``}`,onDragOver:t=>oe(t,e.id),onDragLeave:X,onDrop:t=>ce(t,e.id),children:[(0,s.jsx)(t.p,{children:r.map(n=>k===n.id?(0,s.jsxs)(t.f.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-md border border-accent/40 transition-all flex flex-col gap-2 relative z-[100]`,children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Z(e.id)}}),(0,s.jsx)(`textarea`,{placeholder:`Write an item name...`,className:`no-glow bg-transparent border-none outline-none text-[13px] text-foreground/90 font-medium leading-snug resize-none w-full min-h-[40px] relative z-10`,value:j.name,onChange:e=>M({...j,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Z(e.id))}}),(0,s.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:N.map((t,n)=>(0,s.jsxs)(`div`,{className:`flex items-start bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 w-full`,children:[(0,s.jsx)(`input`,{placeholder:x,value:t.key,onChange:e=>re(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&Z(e.id),className:`no-glow bg-transparent outline-none text-[11px] text-foreground/50 font-bold placeholder:text-foreground/30 relative top-[1px] shrink-0`,style:{width:`${Math.max(3,t.key.length||x.length)}ch`}}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,s.jsx)(`textarea`,{rows:1,placeholder:S,value:t.value,onChange:e=>re(n,t.key,e.target.value),onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=t.scrollHeight+`px`},onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Z(e.id))},className:`no-glow bg-transparent outline-none text-[12px] text-foreground/90 font-medium flex-1 min-w-[40px] placeholder:opacity-40 resize-none overflow-hidden leading-tight relative top-[1px]`})]},n))}),V===n.id&&(0,s.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,s.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]},n.id):(0,s.jsxs)(t.f.div,{draggable:!0,onDragStart:e=>ie(e,n.id),onDragOver:e=>ae(e,n.id),onDragLeave:X,onDrop:t=>ce(t,e.id,n.id),initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-sm hover:shadow-md cursor-grab active:cursor-grabbing hover:border-accent/40 transition-all group flex flex-col gap-2 relative z-10 border ${L===n.id?`border-accent border-t-2 translate-y-1`:`border-[var(--panel-border)]`} ${F===n.id?`opacity-30 scale-95 border-dashed border-2`:``}`,children:[(0,s.jsxs)(`div`,{className:`absolute top-2 right-2 flex items-center gap-1.5 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity bg-background/90 backdrop-blur-md border border-[var(--panel-border)] rounded-lg p-1 z-20 shadow-md`,children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ne(e.id,n)},className:`p-1 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-accent transition-colors`,children:(0,s.jsx)(t.L,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ue(n.id,n.name)},className:`p-1 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,children:(0,s.jsx)(t.T,{className:`w-3.5 h-3.5`})})]}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/90 font-medium leading-snug break-words pr-12`,children:n.name}),n.fields&&n.fields.length>0&&(0,s.jsx)(`div`,{className:`flex flex-row flex-wrap gap-2 mt-2`,children:n.fields.map((e,t)=>(0,s.jsxs)(`div`,{className:`inline-flex bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 max-w-full`,children:[(0,s.jsxs)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative -top-[1px] shrink-0 break-all`,children:[e.key,`:`]}),(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/90 font-medium break-words leading-tight min-w-0`,children:e.value})]},t))}),(0,s.jsxs)(`div`,{className:`flex items-end justify-between mt-3 pt-3 border-t border-[var(--panel-border)]/50 w-full gap-2`,children:[g&&p&&f?(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`,children:[f.photoURL?(0,s.jsx)(`img`,{src:f.photoURL,className:`w-4 h-4 rounded-full shrink-0 object-cover`}):(0,s.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[9px] font-bold shrink-0`,children:(f.displayName||f.email||`U`)[0].toUpperCase()}),(0,s.jsx)(`span`,{className:`text-[10px] font-bold text-foreground/60 truncate max-w-[80px]`,children:f.displayName||f.email?.split(`@`)[0]||`User`})]}):(0,s.jsx)(`div`,{className:`flex items-center gap-2 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`}),(0,s.jsx)(`span`,{className:`text-[10px] text-foreground/40 font-bold text-right pt-0.5 shrink-0 max-w-[50%] truncate flex-1`,children:n.id.startsWith(`item_`)?new Date(parseInt(n.id.split(`_`)[1])).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`Recently Added`})]})]},n.id))}),D===e.id?(0,s.jsxs)(t.f.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-md border border-accent/40 transition-all flex flex-col gap-2 relative z-[100] mt-1`,children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Z(e.id)}}),(0,s.jsx)(`textarea`,{placeholder:`Write an item name...`,className:`no-glow bg-transparent border-none outline-none text-[13px] text-foreground/90 font-medium leading-snug resize-none w-full min-h-[40px] relative z-10`,value:j.name,onChange:e=>M({...j,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Z(e.id))},autoFocus:!0}),(0,s.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:N.map((t,n)=>(0,s.jsxs)(`div`,{className:`flex items-start bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 w-full`,children:[(0,s.jsx)(`input`,{placeholder:x,style:{width:`${Math.max(3,t.key.length||x.length)}ch`},value:t.key,onChange:e=>re(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&Z(e.id),className:`no-glow bg-transparent outline-none text-[11px] text-foreground/50 font-bold placeholder:text-foreground/30 relative top-[1px]`}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,s.jsx)(`textarea`,{rows:1,placeholder:S,value:t.value,onChange:e=>re(n,t.key,e.target.value),onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=t.scrollHeight+`px`},onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Z(e.id))},className:`no-glow bg-transparent outline-none text-[12px] text-foreground/90 font-medium flex-1 min-w-[40px] placeholder:opacity-40 resize-none overflow-hidden leading-tight relative top-[1px]`})]},n))}),V===`new`&&(0,s.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,s.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]}):(0,s.jsxs)(`button`,{onClick:()=>ne(e.id),className:`flex items-center gap-2 justify-center w-full py-2.5 mt-1 rounded-xl border border-transparent text-[12px] font-bold text-foreground/40 hover:text-foreground hover:bg-foreground/[0.03] transition-all shrink-0`,children:[(0,s.jsx)(t.I,{className:`w-4 h-4`}),` Add Item`]})]})]},e.id)}),(0,s.jsx)(`div`,{className:`w-[10px] shrink-0 pointer-events-none`})]})]})}),(0,s.jsx)(`style`,{children:`.styled-scrollbars::-webkit-scrollbar { width: 6px; height: 6px; } .styled-scrollbars::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent-color) 20%, transparent); border-radius: 4px; } .styled-scrollbars::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--accent-color) 40%, transparent); }`}),(0,s.jsx)(_e,{isOpen:!!J,title:`Confirm Deletion`,message:(0,s.jsxs)(s.Fragment,{children:[`Are you sure you want to delete `,(0,s.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:J?.title}),` This action is permanent.`]}),onConfirm:he,onCancel:()=>Y(null),isProcessing:H,confirmText:`Yes, Delete`})]})}function Ht(e){return Array.isArray?Array.isArray(e):Qt(e)===`[object Array]`}function Ut(e){if(typeof e==`string`)return e;if(typeof e==`bigint`)return e.toString();let t=e+``;return t==`0`&&1/e==-1/0?`-0`:t}function Wt(e){return e==null?``:Ut(e)}function Gt(e){return typeof e==`string`}function Kt(e){return typeof e==`number`}function qt(e){return e===!0||e===!1||Yt(e)&&Qt(e)==`[object Boolean]`}function Jt(e){return typeof e==`object`}function Yt(e){return Jt(e)&&e!==null}function Xt(e){return e!=null}function Zt(e){return!e.trim().length}function Qt(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var $t=`Incorrect 'index' type`,en=e=>`Invalid value for key ${e}`,tn=e=>`Pattern length exceeds max of ${e}.`,nn=e=>`Missing ${e} property in key`,rn=e=>`Property 'weight' in key '${e}' must be a positive integer`,an=Object.prototype.hasOwnProperty,on=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=sn(e);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function sn(e){let t=null,n=null,r=null,i=1,a=null;if(Gt(e)||Ht(e))r=e,t=cn(e),n=ln(e);else{if(!an.call(e,`name`))throw Error(nn(`name`));let o=e.name;if(r=o,an.call(e,`weight`)&&(i=e.weight,i<=0))throw Error(rn(o));t=cn(o),n=ln(o),a=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:a}}function cn(e){return Ht(e)?e:e.split(`.`)}function ln(e){return Ht(e)?e.join(`.`):e}function un(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(Xt(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!Xt(s))return;if(a===t.length-1&&(Gt(s)||Kt(s)||qt(s)||typeof s==`bigint`))n.push(o===void 0?Wt(s):{v:Wt(s),i:o});else if(Ht(s)){r=!0;for(let e=0,n=s.length;e<n;e+=1)i(s[e],t,a+1,e)}else t.length&&i(s,t,a+1,o)}};return i(e,Gt(t)?t.split(`.`):t,0),r?n:n[0]}var dn={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},fn={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},pn={location:0,threshold:.6,distance:100},mn={useExtendedSearch:!1,useTokenSearch:!1,getFn:un,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},$=Object.freeze({...fn,...dn,...pn,...mn}),hn=/[^ ]+/g;function gn(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=t.match(hn).length;if(n.has(i))return n.get(i);let a=1/i**(.5*e),o=parseFloat(Math.round(a*r)/r);return n.set(i,o),o},clear(){n.clear()}}}var _n=class{constructor({getFn:e=$.getFn,fieldNormWeight:t=$.fieldNormWeight}={}){this.norm=gn(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Gt(this.docs[0])?this.docs.forEach((e,t)=>{this._addString(e,t)}):this.docs.forEach((e,t)=>{this._addObject(e,t)}),this.norm.clear())}add(e){let t=this.size();Gt(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,n=this.size();t<n;t+=1)--this.records[t].i}removeAll(e){for(let t=e.length-1;t>=0;--t)this.records.splice(e[t],1);for(let e=0,t=this.records.length;e<t;e+=1)this.records[e].i=e}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!Xt(e)||Zt(e))return;let n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}_addObject(e,t){let n={i:t,$:{}};this.keys.forEach((t,r)=>{let i=t.getFn?t.getFn(e):this.getFn(e,t.path);if(Xt(i)){if(Ht(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(Xt(n)){if(Gt(n)){if(!Zt(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(Xt(n.v)){let t=Gt(n.v)?n.v:Wt(n.v);if(!Zt(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[r]=e}else if(Gt(i)&&!Zt(i)){let e={v:i,n:this.norm.get(i)};n.$[r]=e}}}),this.records.push(n)}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function vn(e,t,{getFn:n=$.getFn,fieldNormWeight:r=$.fieldNormWeight}={}){let i=new _n({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(sn)),i.setSources(t),i.create(),i}function yn(e,{getFn:t=$.getFn,fieldNormWeight:n=$.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new _n({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function bn(e=[],t=$.minMatchCharLength){let n=[],r=-1,i=-1,a=0;for(let o=e.length;a<o;a+=1){let o=e[a];o&&r===-1?r=a:!o&&r!==-1&&(i=a-1,i-r+1>=t&&n.push([r,i]),r=-1)}return e[a-1]&&a-r>=t&&n.push([r,a-1]),n}var xn=32;function Sn(e,t,n,{location:r=$.location,distance:i=$.distance,threshold:a=$.threshold,findAllMatches:o=$.findAllMatches,minMatchCharLength:s=$.minMatchCharLength,includeMatches:c=$.includeMatches,ignoreLocation:l=$.ignoreLocation}={}){if(t.length>xn)throw Error(tn(xn));let u=t.length,d=e.length,f=Math.max(0,Math.min(r,d)),p=a,m=f,h=(e,t)=>{let n=e/u;if(l)return n;let r=Math.abs(f-t);return i?n+r/i:r?1:n},g=s>1||c,_=g?Array(d):[],v;for(;(v=e.indexOf(t,m))>-1;){let e=h(0,v);if(p=Math.min(e,p),m=v+u,g){let e=0;for(;e<u;)_[v+e]=1,e+=1}}m=-1;let y=[],b=1,x=u+d,S=1<<u-1;for(let t=0;t<u;t+=1){let r=0,i=x;for(;r<i;)h(t,f+i)<=p?r=i:x=i,i=Math.floor((x-r)/2+r);x=i;let a=Math.max(1,f-i+1),s=o?d:Math.min(f+i,d)+u,c=Array(s+2);c[s+1]=(1<<t)-1;for(let r=s;r>=a;--r){let i=r-1,o=n[e[i]];if(g&&(_[i]=+!!o),c[r]=(c[r+1]<<1|1)&o,t&&(c[r]|=(y[r+1]|y[r])<<1|1|y[r+1]),c[r]&S&&(b=h(t,i),b<=p)){if(p=b,m=i,m<=f)break;a=Math.max(1,2*f-m)}}if(h(t+1,f)>p)break;y=c}let C={isMatch:m>=0,score:Math.max(.001,b)};if(g){let e=bn(_,s);e.length?c&&(C.indices=e):C.isMatch=!1}return C}function Cn(e){let t={};for(let n=0,r=e.length;n<r;n+=1){let i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}function wn(e){if(e.length<=1)return e;e.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let t=[e[0]];for(let n=1,r=e.length;n<r;n+=1){let r=t[t.length-1],i=e[n];i[0]<=r[1]+1?r[1]=Math.max(r[1],i[1]):t.push(i)}return t}var Tn={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},En=RegExp(`[`+Object.keys(Tn).join(``)+`]`,`g`),Dn=String.prototype.normalize?e=>e.normalize(`NFD`).replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,``).replace(En,e=>Tn[e]):e=>e,On=class{constructor(e,{location:t=$.location,threshold:n=$.threshold,distance:r=$.distance,includeMatches:i=$.includeMatches,findAllMatches:a=$.findAllMatches,minMatchCharLength:o=$.minMatchCharLength,isCaseSensitive:s=$.isCaseSensitive,ignoreDiacritics:c=$.ignoreDiacritics,ignoreLocation:l=$.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l},e=s?e:e.toLowerCase(),e=c?Dn(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:Cn(e),startIndex:t})},d=this.pattern.length;if(d>xn){let e=0,t=d%xn,n=d-t;for(;e<n;)u(this.pattern.substr(e,xn),e),e+=xn;if(t){let e=d-xn;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){let{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?Dn(e):e,this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}let{location:i,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:t,alphabet:n,startIndex:p})=>{let{isMatch:m,score:h,indices:g}=Sn(e,t,n,{location:i+p,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});m&&(f=!0),d+=h,m&&g&&u.push(...g)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(p.indices=wn(u)),p}},kn=class{constructor(e){this.pattern=e}static isMultiMatch(e){return An(e,this.multiRegex)}static isSingleMatch(e){return An(e,this.singleRegex)}search(e){return{isMatch:!1,score:1}}};function An(e,t){let n=e.match(t);return n?n[1]:null}var jn=class extends kn{constructor(e){super(e)}static get type(){return`exact`}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){let t=e===this.pattern;return{isMatch:t,score:+!t,indices:[0,this.pattern.length-1]}}},Mn=class extends kn{constructor(e){super(e)}static get type(){return`inverse-exact`}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){let t=e.indexOf(this.pattern)===-1;return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},Nn=class extends kn{constructor(e){super(e)}static get type(){return`prefix-exact`}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){let t=e.startsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,this.pattern.length-1]}}},Pn=class extends kn{constructor(e){super(e)}static get type(){return`inverse-prefix-exact`}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){let t=!e.startsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},Fn=class extends kn{constructor(e){super(e)}static get type(){return`suffix-exact`}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){let t=e.endsWith(this.pattern);return{isMatch:t,score:+!t,indices:[e.length-this.pattern.length,e.length-1]}}},In=class extends kn{constructor(e){super(e)}static get type(){return`inverse-suffix-exact`}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){let t=!e.endsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},Ln=class extends kn{constructor(e,{location:t=$.location,threshold:n=$.threshold,distance:r=$.distance,includeMatches:i=$.includeMatches,findAllMatches:a=$.findAllMatches,minMatchCharLength:o=$.minMatchCharLength,isCaseSensitive:s=$.isCaseSensitive,ignoreDiacritics:c=$.ignoreDiacritics,ignoreLocation:l=$.ignoreLocation}={}){super(e),this._bitapSearch=new On(e,{location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l})}static get type(){return`fuzzy`}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}},Rn=class extends kn{constructor(e){super(e)}static get type(){return`include`}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t=0,n,r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,t))>-1;)t=n+i,r.push([n,t-1]);let a=!!r.length;return{isMatch:a,score:+!a,indices:r}}},zn=[jn,Rn,Nn,Pn,In,Fn,Mn,Ln],Bn=zn.length,Vn=`\0`,Hn=`|`;function Un(e){let t=[],n=e.length,r=0;for(;r<n;){for(;r<n&&e[r]===` `;)r++;if(r>=n)break;let i=r;for(;i<n&&e[i]!==` `&&e[i]!==`"`;)i++;if(i<n&&e[i]===`"`){for(i++;i<n;){if(e[i]===`"`){let t=i+1;if(t>=n||e[t]===` `){i++;break}if(e[t]===`$`&&(t+1>=n||e[t+1]===` `)){i+=2;break}}i++}t.push(e.substring(r,i)),r=i}else{for(;i<n&&e[i]!==` `;)i++;t.push(e.substring(r,i)),r=i}}return t}function Wn(e,t={}){return e.replace(/\\\|/g,Vn).split(Hn).map(e=>{let n=Un(e.replace(/\u0000/g,`|`).trim()).filter(e=>e&&!!e.trim()),r=[];for(let e=0,i=n.length;e<i;e+=1){let i=n[e],a=!1,o=-1;for(;!a&&++o<Bn;){let e=zn[o],n=e.isMultiMatch(i);n&&(r.push(new e(n,t)),a=!0)}if(!a)for(o=-1;++o<Bn;){let e=zn[o],n=e.isSingleMatch(i);if(n){r.push(new e(n,t));break}}}return r})}var Gn=new Set([Ln.type,Rn.type]),Kn=class{constructor(e,{isCaseSensitive:t=$.isCaseSensitive,ignoreDiacritics:n=$.ignoreDiacritics,includeMatches:r=$.includeMatches,minMatchCharLength:i=$.minMatchCharLength,ignoreLocation:a=$.ignoreLocation,findAllMatches:o=$.findAllMatches,location:s=$.location,threshold:c=$.threshold,distance:l=$.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:o,ignoreLocation:a,location:s,threshold:c,distance:l},e=t?e:e.toLowerCase(),e=n?Dn(e):e,this.pattern=e,this.query=Wn(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){let t=this.query;if(!t)return{isMatch:!1,score:1};let{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?Dn(e):e;let a=0,o=[],s=0,c=!1;for(let r=0,i=t.length;r<i;r+=1){let i=t[r];o.length=0,a=0,c=!1;for(let t=0,r=i.length;t<r;t+=1){let r=i[t],{isMatch:l,indices:u,score:d}=r.search(e);if(l){a+=1,s+=d;let e=r.constructor.type;e.startsWith(`inverse`)&&(c=!0),n&&(Gn.has(e)?o.push(...u):o.push(u))}else{s=0,a=0,o.length=0,c=!1;break}}if(a){let e={isMatch:!0,score:s/a};return c&&(e.hasInverse=!0),n&&(e.indices=wn(o)),e}}return{isMatch:!1,score:1}}},qn=[];function Jn(...e){qn.push(...e)}function Yn(e,t){for(let n=0,r=qn.length;n<r;n+=1){let r=qn[n];if(r.condition(e,t))return new r(e,t)}return new On(e,t)}var Xn={AND:`$and`,OR:`$or`},Zn={PATH:`$path`,PATTERN:`$val`},Qn=e=>!!(e[Xn.AND]||e[Xn.OR]),$n=e=>!!e[Zn.PATH],er=e=>!Ht(e)&&Jt(e)&&!Qn(e),tr=e=>({[Xn.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function nr(e,t,{auto:n=!0}={}){let r=e=>{if(Gt(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=Yn(e,t)),r}let i=Object.keys(e),a=$n(e);if(!a&&i.length>1&&!Qn(e))return r(tr(e));if(er(e)){let r=a?e[Zn.PATH]:i[0],o=a?e[Zn.PATTERN]:e[r];if(!Gt(o))throw Error(en(r));let s={keyId:ln(r),pattern:o};return n&&(s.searcher=Yn(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];Ht(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return Qn(e)||(e=tr(e)),r(e)}function rr(e,{ignoreFieldNorm:t=$.ignoreFieldNorm}){let n=1;return e.forEach(({key:e,norm:r,score:i})=>{let a=e?e.weight:null;n*=(i===0&&a?2**-52:i)**+((a||1)*(t?1:r))}),n}function ir(e,{ignoreFieldNorm:t=$.ignoreFieldNorm}){e.forEach(e=>{e.score=rr(e.matches,{ignoreFieldNorm:t})})}var ar=class{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){let t=this.heap;for(;e>0;){let n=e-1>>1;if(t[e].score<=t[n].score)break;let r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){let t=this.heap,n=t.length,r=e;do{e=r;let i=2*e+1,a=2*e+2;if(i<n&&t[i].score>t[r].score&&(r=i),a<n&&t[a].score>t[r].score&&(r=a),r!==e){let n=t[e];t[e]=t[r],t[r]=n}}while(r!==e)}};function or(e,t){let n=e.matches;t.matches=[],Xt(n)&&n.forEach(e=>{if(!Xt(e.indices)||!e.indices.length)return;let{indices:n,value:r}=e,i={indices:n,value:r};e.key&&(i.key=e.key.src),e.idx>-1&&(i.refIndex=e.idx),t.matches.push(i)})}function sr(e,t){t.score=e.score}function cr(e,t,{includeMatches:n=$.includeMatches,includeScore:r=$.includeScore}={}){let i=[];return n&&i.push(or),r&&i.push(sr),e.map(e=>{let{idx:n}=e,r={item:t[n],refIndex:n};return i.length&&i.forEach(t=>{t(e,r)}),r})}var lr=/\b\w+\b/g;function ur({isCaseSensitive:e=!1,ignoreDiacritics:t=!1}={}){return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=Dn(n)),n.match(lr)||[]}}}function dr(e,t,n){let r=new Map,i=new Map,a=0;function o(e,t,o,s){let c=n.tokenize(e);if(!c.length)return;a++;let l=new Map;for(let e of c)l.set(e,(l.get(e)||0)+1);for(let[e,n]of l){let a={docIdx:t,keyIdx:o,subIdx:s,tf:n},c=r.get(e);c||(c=[],r.set(e,c)),c.push(a),i.set(e,(i.get(e)||0)+1)}}for(let n of e){let{i:e,v:r,$:i}=n;if(r!==void 0){o(r,e,-1,-1);continue}if(i)for(let n=0;n<t;n++){let t=i[n];if(t)if(Array.isArray(t))for(let r of t)o(r.v,e,n,r.i??-1);else o(t.v,e,n,-1)}}return{terms:r,fieldCount:a,df:i}}function fr(e,t,n,r){let{i,v:a,$:o}=t;function s(t,n,a){let o=r.tokenize(t);if(!o.length)return;e.fieldCount++;let s=new Map;for(let e of o)s.set(e,(s.get(e)||0)+1);for(let[t,r]of s){let o={docIdx:i,keyIdx:n,subIdx:a,tf:r},s=e.terms.get(t);s||(s=[],e.terms.set(t,s)),s.push(o),e.df.set(t,(e.df.get(t)||0)+1)}}if(a!==void 0){s(a,-1,-1);return}if(o)for(let e=0;e<n;e++){let t=o[e];if(t)if(Array.isArray(t))for(let n of t)s(n.v,e,n.i??-1);else s(t.v,e,-1)}}function pr(e,t){for(let[n,r]of e.terms){let i=r.filter(e=>e.docIdx!==t),a=r.length-i.length;a>0&&(e.fieldCount-=a,e.df.set(n,(e.df.get(n)||0)-a),i.length===0?(e.terms.delete(n),e.df.delete(n)):e.terms.set(n,i))}}var mr=class{constructor(e,t,n){this.options={...$,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new on(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;let t=Yn(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof _n))throw Error($t);if(this._myIndex=t||vn(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=ur({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});this._invertedIndex=dr(this._myIndex.records,this._myIndex.keys.length,e)}}add(e){if(Xt(e)&&(this._docs.push(e),this._myIndex.add(e),this._invertedIndex)){let e=this._myIndex.records[this._myIndex.records.length-1],t=ur({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});fr(this._invertedIndex,e,this._myIndex.keys.length,t)}}remove(e=()=>!1){let t=[],n=[];for(let r=0,i=this._docs.length;r<i;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){if(this._invertedIndex)for(let e of n)pr(this._invertedIndex,e);for(let e=n.length-1;e>=0;--e)this._docs.splice(n[e],1);this._myIndex.removeAll(n)}return t}removeAt(e){this._invertedIndex&&pr(this._invertedIndex,e);let t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),t}getIndex(){return this._myIndex}search(e,t){let{limit:n=-1}=t||{},{includeMatches:r,includeScore:i,shouldSort:a,sortFn:o,ignoreFieldNorm:s}=this.options;if(Gt(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return Kt(n)&&n>-1&&(e=e.slice(0,n)),e}let c=Kt(n)&&n>0&&Gt(e),l;if(c){let t=new ar(n);Gt(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=Gt(e)?Gt(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),ir(l,{ignoreFieldNorm:s}),a&&l.sort(o),Kt(n)&&n>-1&&(l=l.slice(0,n));return cr(l,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),{records:i}=this._myIndex,a=t?null:[];return i.forEach(({v:e,i,n:o})=>{if(!Xt(e))return;let{isMatch:s,score:c,indices:l}=r.searchIn(e);if(s){let r={item:e,idx:i,matches:[{score:c,value:e,norm:o,indices:l}]};t?(r.score=rr(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):a.push(r)}}),a}_searchLogical(e){let t=nr(e,this.options),n=(e,t,r)=>{if(!(`children`in e)){let{keyId:n,searcher:i}=e,a;return n===null?(a=[],this._myIndex.keys.forEach((e,n)=>{a.push(...this._findMatches({key:e,value:t[n],searcher:i}))})):a=this._findMatches({key:this._keyStore.get(n),value:this._myIndex.getValueForItemAtKeyId(t,n),searcher:i}),a&&a.length?[{idx:r,item:t,matches:a}]:[]}let{children:i,operator:a}=e,o=[];for(let e=0,s=i.length;e<s;e+=1){let s=i[e],c=n(s,t,r);if(c.length)o.push(...c);else if(a===Xn.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(Xt(e)){let o=n(t,e,r);o.length&&(i.has(r)||(i.set(r,{idx:r,item:e,matches:[]}),a.push(i.get(r))),o.forEach(({matches:e})=>{i.get(r).matches.push(...e)}))}}),a}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),{keys:i,records:a}=this._myIndex,o=t?null:[];return a.forEach(({$:e,i:a})=>{if(!Xt(e))return;let s=[],c=!1,l=!1;if(i.forEach((t,n)=>{let i=this._findMatches({key:t,value:e[n],searcher:r});i.length?(s.push(...i),i[0].hasInverse&&(l=!0)):c=!0}),!(l&&c)&&s.length){let r={idx:a,item:e,matches:s};t?(r.score=rr(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}),o}_findMatches({key:e,value:t,searcher:n}){if(!Xt(t))return[];let r=[];if(Ht(t))t.forEach(({v:t,i,n:a})=>{if(!Xt(t))return;let{isMatch:o,score:s,indices:c,hasInverse:l}=n.searchIn(t);o&&r.push({score:s,key:e,value:t,idx:i,norm:a,indices:c,hasInverse:l})});else{let{v:i,n:a}=t,{isMatch:o,score:s,indices:c,hasInverse:l}=n.searchIn(i);o&&r.push({score:s,key:e,value:i,norm:a,indices:c,hasInverse:l})}return r}},hr=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=ur({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics});let n=this.analyzer.tokenize(e),{df:r,fieldCount:i}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let e of n){this.termSearchers.push(new On(e,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));let n=r.get(e)||0,a=Math.log(1+(i-n+.5)/(n+.5));this.idfWeights.push(a)}}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};let t=[],n=0,r=0,i=0;for(let a=0;a<this.termSearchers.length;a++){let o=this.termSearchers[a].searchIn(e),s=this.idfWeights[a];r+=s,o.isMatch&&(i++,n+=s*(1-o.score),o.indices&&t.push(...o.indices))}if(i===0)return{isMatch:!1,score:1};let a=r>0?1-n/r:0,o={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&t.length&&(o.indices=wn(t)),o}};mr.version=`7.3.0`,mr.createIndex=vn,mr.parseIndex=yn,mr.config=$,mr.match=function(e,t,n){return Yn(e,{...$,...n}).searchIn(t)},mr.parseQuery=nr,Jn(Kn),Jn(hr),mr.use=function(...e){e.forEach(e=>Jn(e))};var gr=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}];function _r({title:e=`Table View`,subtitle:n=`/templates/table`,backUrl:a=`/templates`,tableCollection:o=`pub_table_data`,config:l,customContent:u}){let{user:d}=ee(),f=!!l,p=l?.isInternal||l?.isShared;l?.isPrivate&&l?.isAdmin;let m=l?.isAdmin||p,h=f?m:!0,g=!!u,_=l?.showButton!==!1&&!g,v=l?.buttonText||`+`,y=l?.buttonStyle||`secondary`,b=l?.showExportButton!==!1,[x,S]=(0,r.useState)([]),[C,w]=(0,r.useState)(`demo`),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(!1),[k,A]=(0,r.useState)(``),[j,M]=(0,r.useState)(!1),[N,P]=(0,r.useState)(null),[F,I]=(0,r.useState)(null),[L,R]=(0,r.useState)(``),[z,B]=(0,r.useState)(``),[V,te]=(0,r.useState)(null),[H,U]=(0,r.useState)(null),[W,G]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=o.startsWith(`user_`);if(e&&!d)return;try{let e=localStorage.getItem(`fbos_tables_${o}`);e&&S(JSON.parse(e))}catch{}let n=(0,i.onSnapshot)(e&&d?(0,i.query)((0,i.collection)(t.Ht,o),(0,i.where)(`uid`,`==`,d.uid)):(0,i.collection)(t.Ht,o),e=>{let n=[];if(e.forEach(e=>{n.push({id:e.id,...e.data()})}),n.length===0){let e={name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`,`Column 4`],...d?{uid:d.uid}:{},rows:[{id:`1`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``},{id:`2`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``}]};(0,i.setDoc)((0,i.doc)(t.Ht,o,`demo`),e)}else{let e=n.sort((e,t)=>(e.name||``).localeCompare(t.name||``));S(e),localStorage.setItem(`fbos_tables_${o}`,JSON.stringify(e))}});return()=>n()},[o,d]);let K=x.find(e=>e.id===C)||x[0]||{columns:[],rows:[]},q=async e=>{K.id&&(d&&o.startsWith(`user_`)&&(e.uid=d.uid),await(0,i.setDoc)((0,i.doc)(t.Ht,o,K.id),e,{merge:!0}))},J=()=>{if(!K.rows||K.rows.length===0)return;let e=K.columns.join(`,`),t=K.rows.map(e=>K.columns.map(t=>`"${e[t]||``}"`).join(`,`)).join(`
|
|
31
|
+
`),n=new Blob([`${e}\n${t}`],{type:`text/csv`}),r=window.URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`export_${K.name||`table`}.csv`,i.click(),window.URL.revokeObjectURL(r)},Y=(e,t,n)=>{q({...K,rows:K.rows.map(r=>r.id===e?{...r,[t]:n}:r)})},ne=()=>{let e={id:Date.now().toString()};K.columns.forEach(t=>e[t]=``),q({...K,rows:[...K.rows||[],e]})},re=e=>{q({...K,rows:K.rows.filter(t=>t.id!==e)})},ie=()=>{let e=`Column ${(K.columns?.length||0)+1}`;K.columns?.includes(e)||(q({...K,columns:[...K.columns||[],e]}),setTimeout(()=>{let e=document.getElementById(`table-scroll-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},100))},ae=e=>{let t=(K.columns||[]).filter(t=>t!==e),n=(K.rows||[]).map(t=>{let n={...t};return delete n[e],n}),r={...K.colColors||{}};delete r[e],q({...K,columns:t,rows:n,colColors:r})},oe=async e=>{e.trim()&&K.id&&e!==K.name&&await(0,i.setDoc)((0,i.doc)(t.Ht,o,K.id),{name:e},{merge:!0})},X=async()=>{M(!0),E(!1);let e=`tbl_${Date.now()}`;await(0,i.setDoc)((0,i.doc)(t.Ht,o,e),{name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`],...d?{uid:d.uid}:{},rows:[]}),setTimeout(()=>{w(e),M(!1)},600)},ce=e=>{let t=z.trim();if(t&&t!==e&&!K.columns?.includes(t)){let n=K.columns.map(n=>n===e?t:n),r=(K.rows||[]).map(n=>{let r={...n};return r[t]=r[e]||``,delete r[e],r}),i={...K.colColors||{}};i[e]&&(i[t]=i[e],delete i[e]),q({...K,columns:n,rows:r,colColors:i})}I(null)},Z=K.rows||[];return L.trim()!==``&&(Z=new mr(Z.map(e=>({...e,_creatorMatch:`Guest`})),{keys:(K.columns||[]).concat([`_creatorMatch`]),threshold:.4,ignoreLocation:!0}).search(L).map(e=>{let{_creatorMatch:t,...n}=e.item;return n})),(0,s.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,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,s.jsx)(se,{children:e}),n&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),n]})]}),f&&(0,s.jsx)(`div`,{className:`mb-6`,children:(0,s.jsx)(le,{})}),(0,s.jsxs)(`div`,{className:`flex justify-between items-center gap-3 mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:[!f&&a&&(0,s.jsxs)(c.Link,{to:a,className:`px-4 md:px-5 py-2.5 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(t.Mt,{className:`w-4 h-4`}),` `,(0,s.jsx)(`span`,{className:`max-sm:hidden`,children:`Go Back`})]}),f&&(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:l?.tabTitle||l?.tabName||e}),(0,s.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[x.length,` `,x.length===1?`table`:`tables`]})]}),(0,s.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[b&&(0,s.jsx)(t.s,{variant:`secondary`,onClick:J,className:`px-3 py-2.5 font-bold rounded-xl shadow-sm border border-[var(--panel-border)] flex items-center gap-2`,children:(0,s.jsx)(t.ut,{className:`w-4 h-4`})}),_&&(0,s.jsx)(t.s,{variant:y===`primary`?void 0:`secondary`,onClick:ne,className:`px-3 py-2.5 font-bold rounded-xl border border-[var(--panel-border)] shadow-sm flex items-center gap-2 whitespace-nowrap`,children:v===`+`?(0,s.jsx)(t.I,{className:`w-4 h-4`}):v})]})]}),(0,s.jsxs)(t.f.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 z-10 block`,children:[(0,s.jsx)(`div`,{className:`absolute top-0 right-0 w-[400px] h-[400px] bg-accent/5 blur-[100px] rounded-full pointer-events-none -z-10`}),(0,s.jsxs)(`div`,{className:`p-4 md:px-6 border-b border-[var(--panel-border)]/50 flex items-center justify-between bg-foreground/[0.01] gap-3 sm:gap-4`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 relative`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,s.jsxs)(`div`,{className:`relative flex items-center`,children:[D?(0,s.jsx)(`div`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:e=>{O(!1),oe(e.currentTarget.textContent||``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},className:`bg-transparent border-b-2 border-accent outline-none text-[16px] font-bold text-foreground inline-block min-w-[20px] whitespace-nowrap px-1 py-0.5`,children:K.name||`Unnamed Table`}):(0,s.jsx)(`h3`,{className:`font-bold text-[16px] text-foreground/90 cursor-pointer hover:text-accent transition-colors truncate max-w-[38vw] sm:max-w-[200px]`,onClick:()=>O(!0),title:`Click to rename table`,children:K.name||`Unnamed Table`}),(0,s.jsx)(t.p,{children:T&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>E(!1)}),(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:`absolute top-[120%] left-0 w-[220px] bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 py-2 flex flex-col`,children:[(0,s.jsx)(`div`,{className:`px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-foreground/40 border-b border-[var(--panel-border)] mb-1`,children:`Your Tables`}),(0,s.jsx)(`div`,{className:`max-h-[250px] overflow-y-auto styled-scrollbars z-50 relative`,children:x.map(e=>(0,s.jsx)(`button`,{onClick:()=>{w(e.id),E(!1)},className:`w-full px-4 py-2 text-[13px] font-bold text-left hover:bg-foreground/[0.03] transition-colors truncate ${C===e.id?`text-accent bg-accent/5`:`text-foreground/70`}`,children:e.name||`Unnamed Table`},e.id))}),(0,s.jsx)(`div`,{className:`w-full h-[1px] bg-[var(--panel-border)]/50 my-1`}),(0,s.jsxs)(`button`,{onClick:X,className:`w-full px-4 py-2.5 text-[13px] font-bold text-left text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors flex items-center gap-2`,children:[(0,s.jsx)(t.I,{className:`w-4 h-4`}),` Create New Table`]})]})]})})]}),(0,s.jsx)(`button`,{onClick:()=>E(!T),className:`p-1 px-1.5 rounded-lg hover:bg-foreground/5 transition-colors text-foreground/40 hover:text-foreground shrink-0 border border-transparent hover:border-[var(--panel-border)]`,children:(0,s.jsx)(t.Ct,{className:`w-4 h-4 transition-transform ${T?`rotate-180 text-accent`:``}`})})]}),(0,s.jsxs)(`span`,{className:`opacity-40 text-[11px] font-bold mt-1 uppercase tracking-wider`,children:[(K.rows||[]).length,` Records`]})]}),(0,s.jsxs)(`div`,{className:`relative flex-1 min-w-[130px] max-w-[300px]`,children:[(0,s.jsx)(t.N,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-foreground/40`}),(0,s.jsx)(`input`,{type:`text`,placeholder:`Search active records...`,value:L,onChange:e=>R(e.target.value),className:`w-full bg-background border border-[var(--panel-border)] rounded-xl py-2.5 px-9 text-[13px] font-medium text-foreground focus:outline-none focus:border-accent transition-colors shadow-inner`})]})]}),(0,s.jsx)(`div`,{id:`table-scroll-container`,className:`overflow-x-auto w-full block min-h-[300px] relative styled-scrollbars`,children:u?(0,s.jsx)(`div`,{className:`fbos-content-slot p-4 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:(0,s.jsx)(u,{config:l,actions:{tables:x,activeTable:K,collection:o,user:d,saveTable:async(e,n)=>{S(t=>t.find(t=>t.id===e)?t.map(t=>t.id===e?{...t,...n}:t):[...t,{id:e,...n}]),await(0,i.setDoc)((0,i.doc)(t.Ht,o,e),n,{merge:!0})},deleteTable:async e=>{S(t=>t.filter(t=>t.id!==e)),await(0,i.deleteDoc)((0,i.doc)(t.Ht,o,e))},updateCell:(e,t,n)=>Y(e,t,n),addRow:()=>ne(),addColumn:()=>ie()}})}):(0,s.jsx)(t.p,{mode:`wait`,children:j?(0,s.jsxs)(t.f.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 flex flex-col items-center justify-center bg-background/40 backdrop-blur-[2px] z-50`,children:[(0,s.jsx)(`div`,{className:`w-8 h-8 rounded-full border-2 border-accent border-r-transparent animate-spin mb-4`}),(0,s.jsx)(`p`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest`,children:`Generating Table`})]},`loader`):(0,s.jsxs)(t.f.table,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full text-left border-collapse table-auto relative min-w-[800px]`,children:[(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)] transition-colors ${K.headerColor?gr.find(e=>e.text===K.headerColor)?.bgAlt:`bg-foreground/[0.02]`}`,children:[(0,s.jsx)(`th`,{className:`py-4 px-6 text-[12px] font-bold uppercase tracking-wider whitespace-nowrap text-foreground/50 w-32 border-r border-[var(--panel-border)]/20 ${h?``:`hidden`}`,children:`Creator`}),(K.columns||[]).map((e,n)=>{let r=(K.colColors||{})[e],i=(K.colorTimestamps||{})[`col_${e}`]||0;K.headerColor;let a=(K.colorTimestamps||{}).header||0,o=`bg-transparent`,c=`text-foreground/50`;if(r&&r!==`none`&&i>=a){let e=gr.find(e=>e.text===r);e&&(o=e.bgCard,c=e.text)}return(0,s.jsx)(`th`,{className:`py-3 px-6 text-[12px] font-bold uppercase tracking-wider relative group h-[53px] min-w-[120px] ${c} ${o} border-r border-[var(--panel-border)]/20 last:border-r-0 select-none align-middle`,children:(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2 w-full h-full`,children:[F===e?(0,s.jsx)(`div`,{className:`flex-1 min-w-[50px]`,children:(0,s.jsx)(`span`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>{I(null),B(t.currentTarget.textContent||``),(t.currentTarget.textContent||``).trim()!==``&&ce(e)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},className:`bg-transparent outline-none border-b border-accent/40 font-bold text-[12px] uppercase tracking-wider p-0 m-0 ${c} block w-full whitespace-nowrap overflow-hidden cursor-text`,ref:e=>{e&&requestAnimationFrame(()=>{e.focus()})},children:z})}):(0,s.jsx)(`div`,{className:`flex items-center gap-2 flex-1 overflow-hidden`,onClick:()=>{I(e),B(e)},children:(0,s.jsx)(`span`,{className:`truncate cursor-text`,children:e})}),(0,s.jsxs)(`div`,{className:`relative shrink-0 flex items-center h-full gap-0.5`,children:[(0,s.jsx)(`button`,{onClick:()=>U(H===e?null:e),className:`p-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity hover:bg-foreground/10 ${r&&r!==`none`?`!opacity-100`:``} text-current`,children:(0,s.jsx)(t.z,{className:`w-4 h-4`})}),(K.columns||[]).length>1&&(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ae(e)},className:`p-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500/10 text-foreground/30 hover:text-red-500`,title:`Delete column`,children:(0,s.jsx)(t.T,{className:`w-3.5 h-3.5`})}),H===e&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>U(null)}),(0,s.jsxs)(`div`,{className:`absolute top-8 right-0 flex gap-1.5 bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,s.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...K.colColors||{},[e]:`none`},r={...K.colorTimestamps||{},[`col_${e}`]:Date.now()};q({...K,colColors:n,colorTimestamps:r}),U(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Color`,children:(0,s.jsx)(t._,{className:`w-3 h-3`})}),(0,s.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),gr.map(t=>(0,s.jsx)(`button`,{onClick:n=>{n.preventDefault(),n.stopPropagation();let r={...K.colColors||{},[e]:t.text},i={...K.colorTimestamps||{},[`col_${e}`]:Date.now()};q({...K,colColors:r,colorTimestamps:i}),U(null)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50 shrink-0`},t.name))]})]})]})]})},`col_${n}_${e}`)}),(0,s.jsx)(`th`,{className:`py-4 px-4 w-14 border-l border-[var(--panel-border)]/30 relative`,children:(0,s.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5 relative z-20`,children:[(0,s.jsx)(`button`,{onClick:()=>G(!W),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${K.headerColor?gr.find(e=>e.text===K.headerColor)?.text:`text-foreground/30`}`,children:(0,s.jsx)(t.z,{className:`w-4 h-4`})}),W&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>G(!1)}),(0,s.jsxs)(`div`,{className:`absolute top-6 right-8 flex gap-1.5 bg-background/90 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,s.jsx)(`button`,{onClick:()=>{q({...K,headerColor:``}),G(!1)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Header Color`,children:(0,s.jsx)(t._,{className:`w-3 h-3`})}),(0,s.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),gr.map(e=>(0,s.jsx)(`button`,{onClick:()=>{let t={...K.colorTimestamps||{},header:Date.now()};q({...K,headerColor:e.text,colorTimestamps:t}),G(!1)},className:`w-4 h-4 rounded-full ${e.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},e.name))]})]}),(0,s.jsx)(`button`,{onClick:ie,className:`p-1.5 rounded-lg text-foreground/40 hover:text-accent hover:bg-accent/10 transition-colors flex items-center justify-center`,children:(0,s.jsx)(t.I,{className:`w-4 h-4`})})]})})]})}),(0,s.jsxs)(`tbody`,{children:[Z.map((e,n)=>{let r=n%2==1,i=(K.rowColors||{})[e.id],a=i?r?gr.find(e=>e.text===i)?.bgAlt:gr.find(e=>e.text===i)?.bgCard:r?`bg-foreground/[0.02]`:`bg-transparent`;return(0,s.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)]/30 hover:bg-foreground/[0.04] transition-colors group`,children:[(0,s.jsx)(`td`,{className:`py-4 px-6 whitespace-nowrap h-[53px] border-r border-[var(--panel-border)]/20 ${a} ${h?``:`hidden`}`,children:(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:f&&d?(0,s.jsxs)(s.Fragment,{children:[d.photoURL?(0,s.jsx)(`img`,{src:d.photoURL,className:`w-5 h-5 rounded-full shrink-0 object-cover`}):(0,s.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[10px] font-bold shrink-0`,children:(d.displayName||d.email||`U`)[0].toUpperCase()}),(0,s.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:d.displayName||d.email?.split(`@`)[0]||`User`})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[10px] font-bold shrink-0 shadow-inner group-hover:scale-110 transition-transform`,children:`G`}),(0,s.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:`Guest`})]})})}),(K.columns||[]).map(t=>{let i=N?.id===e.id&&N?.field===t,a=(K.colColors||{})[t],o=(K.colorTimestamps||{})[`col_${t}`]||0,c=(K.rowColors||{})[e.id],l=(K.colorTimestamps||{})[`row_${e.id}`]||0,u=``;u=l>o?c===`none`?``:c:o>l?a===`none`?``:a:c===`none`?``:c||a||``,u===`none`&&(u=``);let d=u?gr.find(e=>e.text===u):null,f=d?r?d.bgAlt:d.bgCard:r?`bg-foreground/[0.02]`:`bg-transparent`,p=d?d.text:`text-foreground/80`;return(0,s.jsxs)(`td`,{className:`py-4 px-6 whitespace-pre-wrap min-w-[120px] text-[14px] font-medium relative ${f} align-top border-r border-[var(--panel-border)]/10 last:border-r-0`,onClick:()=>!i&&P({id:e.id,field:t}),children:[i?(0,s.jsx)(`textarea`,{autoFocus:!0,value:e[t]||``,onChange:n=>Y(e.id,t,n.target.value),onBlur:()=>P(null),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&P(null)},className:`absolute inset-0 bg-transparent !border-0 !outline-none focus:!outline-none focus:!ring-0 !ring-0 !shadow-none focus:!shadow-none p-4 px-6 text-[14px] font-medium w-full h-full caret-accent ${p} z-20 resize-none styled-scrollbars`}):null,(0,s.jsx)(`span`,{className:`block w-full min-h-[20px] break-words transition-all ${i?`opacity-0`:`opacity-100`} ${p} ${t===`Status`&&e[t]===`Active`&&!u?`text-green-500`:``}`,children:e[t]||(0,s.jsx)(`span`,{className:`opacity-30 italic font-normal`,children:`empty`})})]},`cell_${e.id||n}_${t}`)}),(0,s.jsx)(`td`,{className:`py-4 px-4 whitespace-nowrap text-right h-[53px] ${a} relative z-10`,children:(0,s.jsxs)(`div`,{className:`flex items-center justify-end gap-1 opacity-100 md:opacity-20 md:group-hover:opacity-100 transition-opacity relative`,children:[(0,s.jsx)(`button`,{onClick:()=>te(V===e.id?null:e.id),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${i?gr.find(e=>e.text===i)?.text:`text-foreground/40`}`,children:(0,s.jsx)(t.z,{className:`w-4 h-4`})}),V===e.id&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>te(null)}),(0,s.jsxs)(`div`,{className:`absolute top-6 right-8 flex gap-1.5 bg-background/90 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,s.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...K.rowColors||{},[e.id]:`none`},r={...K.colorTimestamps||{},[`row_${e.id}`]:Date.now()};q({...K,rowColors:n,colorTimestamps:r}),te(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Row Color`,children:(0,s.jsx)(t._,{className:`w-3 h-3`})}),(0,s.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),gr.map(t=>(0,s.jsx)(`button`,{onClick:()=>{let n={...K.colorTimestamps||{},[`row_${e.id}`]:Date.now()};q({...K,rowColors:{...K.rowColors||{},[e.id]:t.text},colorTimestamps:n}),te(null)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},t.name))]})]}),(0,s.jsx)(`button`,{onClick:()=>re(e.id),className:`p-2 ml-auto rounded-lg text-foreground/20 hover:text-red-500 hover:bg-red-500/10 transition-colors flex items-center justify-center`,children:(0,s.jsx)(t.T,{className:`w-4 h-4`})})]})})]},e.id||`row_${n}`)}),Z.length===0&&(0,s.jsx)(`tr`,{children:(0,s.jsxs)(`td`,{colSpan:(K.columns||[]).length+2,className:`py-12 text-center text-foreground/40 text-[14px] font-medium border border-[var(--panel-border)] m-4 rounded-xl border-dashed`,children:[`No records found in `,K.name||`this table`,`.`]})}),(0,s.jsx)(`tr`,{children:(0,s.jsx)(`td`,{colSpan:(K.columns||[]).length+2,className:`py-2 px-4 border-none bg-foreground/[0.01]`,children:(0,s.jsx)(`div`,{className:`flex items-center gap-4`,children:(0,s.jsx)(`button`,{onClick:ne,className:`p-1.5 rounded-lg text-foreground/40 hover:text-accent hover:bg-accent/10 transition-colors flex items-center justify-center ml-2 border border-transparent hover:border-accent/20`,children:(0,s.jsx)(t.I,{className:`w-4 h-4`})})})})})]})]},`table`)})})]})]})}var vr=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}],yr={dateStr:``,title:``,description:``,time:`12:00`,duration:`60`,color:``,guestEmail:``,customFields:{}};function br({title:e=`Calendar View`,subtitle:n=`/templates/calendar`,backUrl:o=`/templates`,eventsCollection:l=`pub_events`,defaultTimeFormat:u=`12h`,config:d,customContent:f}){let p=!!(d?.isPrivate||d?.isAdmin||d?.isInternal||d?.isShared);d?.isAdmin,d?.isInternal||d?.isShared,d?.isPrivate;let m=d?.showButton!==!1,h=d?.buttonText||`+`,g=d?.buttonStyle||`primary`,_=d?.showViewsButton!==!1,v=d?.viewsButtonStyle||`secondary`,y=d?.defaultView||`calendar`,b=d?.customFields||[],x=l.startsWith(`user_`)?`user`:l.startsWith(`mem_`)?`internal`:l.startsWith(`admin_`)?`admin_only`:`public`,[S,C]=(0,r.useState)(()=>{try{let e=localStorage.getItem(`cal_view_${l}`);if(e===`list`||e===`month`)return e}catch{}return y===`board`?`list`:`month`}),[w,T]=(0,r.useState)([]),[E,D]=(0,r.useState)(!1),[O,k]=(0,r.useState)(null),[A,j]=(0,r.useState)(!1),[ee,M]=(0,r.useState)(!1),[N,P]=(0,r.useState)(null),[F,I]=(0,r.useState)(yr),[L,R]=(0,r.useState)(new Date),[z,B]=(0,r.useState)(null),[V,te]=(0,r.useState)(null),[H,U]=(0,r.useState)(!1),W=`cal_24h_${l}`,[G,K]=(0,r.useState)(()=>{try{let e=localStorage.getItem(W);if(e!==null)return e===`true`}catch{}return u===`24h`}),q=()=>{let e=!G;K(e);try{localStorage.setItem(W,String(e))}catch{}};(0,r.useEffect)(()=>{try{localStorage.setItem(`cal_view_${l}`,S)}catch{}},[S,l,x]);let J=()=>{let e=S===`month`?`list`:`month`;C(e);try{localStorage.setItem(`cal_view_${l}`,e)}catch{}},Y=()=>{try{return sessionStorage.getItem(`cal_guest_email`)||``}catch{return``}},ne=e=>{try{sessionStorage.setItem(`cal_guest_email`,e)}catch{}};(0,r.useEffect)(()=>(0,a.onAuthStateChanged)(t.Vt,async e=>{if(B(e),e&&x===`admin_only`)try{let n=await(0,i.getDoc)((0,i.doc)(t.Ht,`user_profiles`,e.uid));n.exists()&&te(n.data())}catch{}U(!0)}),[x]),(0,r.useEffect)(()=>{if(!H)return;if(x!==`public`&&!z){T([]);return}try{let e=localStorage.getItem(`fbos_cal_${l}`);e&&T(JSON.parse(e))}catch{}let e=(0,i.onSnapshot)(x===`user`&&z?(0,i.query)((0,i.collection)(t.Ht,l),(0,i.where)(`uid`,`==`,z.uid)):(0,i.collection)(t.Ht,l),e=>{let t=[];e.forEach(e=>t.push({id:e.id,...e.data()})),T(t),localStorage.setItem(`fbos_cal_${l}`,JSON.stringify(t))},e=>console.error(`Calendar events:`,e));return()=>e()},[l,x,z?.uid,H]);let re=e=>!!z&&z.uid===e.uid,ie=e=>x===`public`?!1:x===`user`?!!z:re(e),ae=e=>{if(!e)return``;if(G)return e;let[t,n]=e.split(`:`),r=parseInt(t,10),i=r>=12?`PM`:`AM`;return r=r%12||12,`${r}:${n} ${i}`},oe=e=>{if(!e)return`60m`;let t=parseInt(e,10);return isNaN(t)?e:t>=60?t%60==0?`${t/60}h`:`${Math.floor(t/60)}h ${t%60}m`:`${t}m`},X=e=>{let[t,n]=(e||`12:00`).split(`:`),r=parseInt(t,10)||0,i=parseInt(n,10)||0,a=r>=12?`PM`:`AM`;return r=r%12||12,{h:r,m:i,ampm:a}},ce=(e,t,n)=>{let r=e%12;return n===`PM`&&(r+=12),`${r.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},Z=e=>{let t=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-t).toISOString().split(`T`)[0]},ue=()=>Z(new Date),de=new Date(L.getFullYear(),L.getMonth(),1),fe=new Date(L.getFullYear(),L.getMonth()+1,0),pe=de.getDay(),me=fe.getDate(),he=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],ge=Array.from({length:42},(e,t)=>{let n=t-pe+1,r=new Date(L.getFullYear(),L.getMonth(),n);return{day:r.getDate(),dateStr:Z(r),isCurrentMonth:n>0&&n<=me}}),ve=()=>R(S===`month`?new Date(L.getFullYear(),L.getMonth()-1,1):new Date(L.getFullYear(),L.getMonth(),L.getDate()-1)),ye=()=>R(S===`month`?new Date(L.getFullYear(),L.getMonth()+1,1):new Date(L.getFullYear(),L.getMonth(),L.getDate()+1)),be=e=>{if(x!==`public`&&!z)return;let t=new Date;t.setDate(t.getDate()+1);let n=new Date().getHours().toString().padStart(2,`0`);I({...yr,dateStr:e||Z(t),time:`${n}:00`,guestEmail:x===`public`?Y():``,customFields:{}}),D(!0)},xe=e=>{let t=e.time;if(t){let[e,n]=t.split(`:`);e&&n&&(t=`${e.padStart(2,`0`)}:${n}`)}I({id:e.id,uid:e.uid,dateStr:e.dateStr,title:e.title,description:e.description||``,time:t||`12:00`,duration:e.duration||`60`,color:e.color||``,guestEmail:e.creatorEmail||``,customFields:e.customFields||{}}),D(!0)},Se=async e=>{if(e.preventDefault(),F.title.trim()){j(!0);try{let e={dateStr:F.dateStr,title:F.title.trim(),description:F.description.trim(),time:F.time,duration:F.duration||`60`};if(F.color&&(e.color=F.color),b.length>0&&(e.customFields=F.customFields),!F.id)if(x===`public`){let t=F.guestEmail.trim();e.creatorEmail=t,ne(t)}else x===`user`||x===`internal`?(e.uid=z?.uid,e.creatorEmail=z?.email||``,e.creatorName=z?.displayName||``,e.creatorAvatar=z?.photoURL||``):x===`admin_only`&&(e.uid=z?.uid,e.creatorEmail=V?.email||z?.email||``,e.creatorName=V?.displayName||V?.name||``,e.creatorAvatar=V?.avatar||V?.avatarUrl||z?.photoURL||``);F.id?(await(0,i.setDoc)((0,i.doc)(t.Ht,l,F.id),e,{merge:!0}),O?.id===F.id&&k({...O,...e})):await(0,i.setDoc)((0,i.doc)(t.Ht,l,`ev_${Date.now()}`),e,{merge:!0}),D(!1)}catch(e){console.error(e)}j(!1)}},Ce=async()=>{if(N){M(!0);try{await(0,i.deleteDoc)((0,i.doc)(t.Ht,l,N.id)),O?.id===N.id&&k(null),P(null),D(!1)}catch{}M(!1)}},we=e=>{if(x===`user`||!e.creatorEmail&&!e.creatorName)return null;let t=(e.creatorName||e.creatorEmail||`?`).charAt(0).toUpperCase(),n=vr.find(t=>t.text===e.color);return(0,s.jsxs)(`div`,{className:`flex items-center gap-3 mt-4 p-3 rounded-xl bg-foreground/[0.03] border border-[var(--panel-border)]/50`,children:[e.creatorAvatar?(0,s.jsx)(`img`,{src:e.creatorAvatar,alt:``,className:`w-8 h-8 rounded-full object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`w-8 h-8 rounded-full ${n?.bgCircle||`bg-accent`} flex items-center justify-center text-[13px] font-extrabold text-white shrink-0`,children:t}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[e.creatorName&&(0,s.jsx)(`span`,{className:`text-[13px] font-bold text-foreground/90 truncate`,children:e.creatorName}),e.creatorEmail&&(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate`,children:e.creatorEmail})]})]})},Q=e=>{if(x===`user`||x===`public`||!e.creatorName&&!e.creatorEmail)return null;let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||``,n=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[e.creatorAvatar?(0,s.jsx)(`img`,{src:e.creatorAvatar,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:n}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),e.creatorEmail&&(0,s.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,e.creatorEmail]})]})]})};if(H&&x!==`public`&&!z)return(0,s.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen p-8`,children:(0,s.jsxs)(`div`,{className:`text-center glass-panel border border-[var(--panel-border)] rounded-3xl p-12 max-w-sm w-full`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-accent/10 border border-accent/20 flex items-center justify-center mx-auto mb-4`,children:(0,s.jsx)(t.H,{className:`w-7 h-7 text-accent`})}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold mb-2`,children:`Sign in required`}),(0,s.jsx)(`p`,{className:`text-foreground/50 text-[14px] mb-6`,children:`You need to be signed in to access this calendar.`}),(0,s.jsx)(c.Link,{to:`/login`,className:`inline-flex items-center justify-center gap-2 px-6 py-2.5 rounded-xl btn-primary font-bold text-[14px] w-full`,children:`Sign In`})]})});if(!H&&x!==`public`)return(0,s.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen`,children:(0,s.jsx)(t.G,{className:`w-8 h-8 animate-spin text-accent`})});let Te=!!f,Ee=(x===`public`||!!z)&&m&&!Te,De=()=>(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 sm:gap-4 p-4 sm:p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:d?.tabTitle||d?.tabName||e}),(0,s.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[w.length,` `,w.length===1?`event`:`events`,` · `,S===`month`?`Month`:`Board`,` View`]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(t.f.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:q,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer btn-secondary text-[12px] font-extrabold`,children:G?`24h`:`12h`}),_&&!Te&&(0,s.jsx)(t.f.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:J,title:S===`month`?`Switch to Board`:`Switch to Calendar`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${v===`primary`?`btn-primary`:`btn-secondary`}`,children:S===`month`?(0,s.jsx)(t.Y,{className:`w-4 h-4`}):(0,s.jsx)(t.Dt,{className:`w-4 h-4`})}),Ee&&(0,s.jsx)(t.f.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>be(),className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${h===`+`?`w-10`:`px-5`} ${g===`primary`?`btn-primary`:`btn-secondary`}`,children:h===`+`?(0,s.jsx)(t.I,{className:`w-4 h-4`}):(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:h})})]})]}),Oe=()=>(0,s.jsxs)(`div`,{className:`p-4 md:p-6 border-b border-[var(--panel-border)]/50 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 bg-foreground/[0.01]`,children:[(0,s.jsx)(`h3`,{className:`text-lg md:text-xl font-extrabold tracking-tight ml-2 min-w-0`,children:S===`month`?L.toLocaleString(`default`,{month:`long`,year:`numeric`}):L.toLocaleString(`default`,{month:`long`,day:`numeric`,year:`numeric`})}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,s.jsx)(`button`,{onClick:()=>R(new Date),className:`px-3 md:px-4 py-2 text-[13px] font-bold border border-[var(--panel-border)] rounded-xl mr-1 md:mr-2 hover:bg-foreground/5 transition-colors`,children:`Today`}),(0,s.jsx)(`button`,{onClick:ve,className:`p-2 rounded-xl text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-colors border border-transparent hover:border-[var(--panel-border)]`,children:(0,s.jsx)(t.St,{className:`w-5 h-5`})}),(0,s.jsx)(`button`,{onClick:ye,className:`p-2 rounded-xl text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-colors border border-transparent hover:border-[var(--panel-border)]`,children:(0,s.jsx)(t.xt,{className:`w-5 h-5`})})]})]}),ke=()=>(0,s.jsxs)(s.Fragment,{children:[Oe(),f?(0,s.jsx)(`div`,{className:`fbos-content-slot p-4 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:(0,s.jsx)(f,{config:d,actions:{events:w,loading:!H,collection:l,currentUser:z,saveEvent:async e=>{let n=e.id||`ev_${Date.now()}`;T(t=>t.find(e=>e.id===n)?t.map(t=>t.id===n?{...t,...e}:t):[...t,{id:n,...e}]),await(0,i.setDoc)((0,i.doc)(t.Ht,l,n),e,{merge:!0})},deleteEvent:async e=>{T(t=>t.filter(t=>t.id!==e)),await(0,i.deleteDoc)((0,i.doc)(t.Ht,l,e))},openAddModal:e=>be(e),openEditModal:e=>xe(e),setViewingEvent:e=>k(e),currentDate:L,setCurrentDate:R,goToPrev:ve,goToNext:ye,goToToday:()=>R(new Date)}})}):S===`month`?(0,s.jsx)(`div`,{className:`overflow-x-auto w-full flex-1`,children:(0,s.jsxs)(`div`,{className:`min-w-[800px] h-full flex flex-col`,children:[(0,s.jsx)(`div`,{className:`grid grid-cols-7 border-b border-[var(--panel-border)]/50 bg-foreground/[0.02]`,children:he.map(e=>(0,s.jsx)(`div`,{className:`py-3 text-center text-[12px] font-bold uppercase tracking-wider text-foreground/40`,children:e},e))}),(0,s.jsx)(`div`,{className:`grid grid-cols-7 auto-rows-auto bg-[var(--panel-border)] gap-[1px] relative flex-1`,children:ge.map((e,n)=>{let r=e.dateStr===ue(),i=w.filter(t=>t.dateStr===e.dateStr);return(0,s.jsxs)(`div`,{onClick:()=>e.isCurrentMonth&&Ee&&be(e.dateStr),className:`min-h-[140px] p-2 bg-[var(--panel-bg)] flex flex-col relative group
|
|
32
|
+
${e.isCurrentMonth?Ee?`hover:bg-foreground/[0.03] transition-colors cursor-cell`:``:`opacity-30 bg-background/50 pointer-events-none`}`,children:[(0,s.jsx)(`div`,{className:`flex justify-between items-start mb-2 shrink-0`,children:(0,s.jsx)(`span`,{className:`w-8 h-8 rounded-full flex items-center justify-center text-[14px] font-bold ${r?`bg-accent text-white shadow-lg shadow-accent/20`:`text-foreground/70 group-hover:text-foreground`}`,children:e.day})}),(0,s.jsx)(`div`,{className:`flex flex-col gap-1.5 flex-1 w-full relative z-10 pb-1`,children:i.map(e=>{let n=vr.find(t=>t.text===e.color),r=ie(e);return(0,s.jsxs)(`div`,{className:`px-2 py-1.5 rounded-lg border transition-colors shadow-sm cursor-pointer group/ev relative ${n?n.bgCard+` `+n.borderCard:`bg-accent/20 border-accent/30 hover:bg-accent/40`}`,onClick:t=>{t.stopPropagation(),k(e)},children:[(0,s.jsx)(`p`,{className:`text-[12px] font-bold truncate leading-tight ${r?`pr-5`:``} ${n?n.text:`text-foreground`}`,children:e.title}),(0,s.jsx)(`p`,{className:`text-[10px] text-foreground/70 mt-0.5`,children:ae(e.time)}),r&&(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),xe(e)},className:`absolute top-1 right-1 opacity-0 group-hover/ev:opacity-100 p-1 text-foreground/60 hover:bg-foreground/10 hover:text-foreground transition-all rounded`,children:(0,s.jsx)(t.L,{className:`w-3 h-3`})})]},e.id)})})]},n)})}),(0,s.jsx)(`style`,{children:`
|
|
32
33
|
.styled-scrollbars::-webkit-scrollbar{width:4px}
|
|
33
34
|
.styled-scrollbars::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--accent-color) 30%,transparent);border-radius:4px}
|
|
34
35
|
input[type="time"]::-webkit-calendar-picker-indicator{display:none!important}
|
|
35
36
|
input[type="date"]{color-scheme:dark}
|
|
36
37
|
input[type="date"]::-webkit-calendar-picker-indicator{cursor:pointer;opacity:.5;transition:opacity .2s}
|
|
37
38
|
input[type="date"]::-webkit-calendar-picker-indicator:hover{opacity:1}
|
|
38
|
-
`})]})}):(0,s.jsxs)(`div`,{className:`flex flex-col p-4 md:p-8 overflow-y-auto w-full flex-1 gap-4`,children:[w.filter(e=>e.dateStr===Z(L)).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>{let n=new Date(e.dateStr+`T12:00:00`),r=
|
|
39
|
+
`})]})}):(0,s.jsxs)(`div`,{className:`flex flex-col p-4 md:p-8 overflow-y-auto w-full flex-1 gap-4`,children:[w.filter(e=>e.dateStr===Z(L)).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>{let n=new Date(e.dateStr+`T12:00:00`),r=vr.find(t=>t.text===e.color),i=ie(e);return(0,s.jsxs)(`div`,{onClick:()=>k(e),className:`p-4 rounded-2xl border flex flex-col cursor-pointer transition-colors group ${r?r.bgCard+` `+r.borderCard+` hover:brightness-110`:`bg-foreground/[0.01] border-[var(--panel-border)]/70 hover:border-accent/40 hover:bg-foreground/[0.02]`}`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,s.jsxs)(`div`,{className:`w-11 h-11 md:w-12 md:h-12 rounded-xl flex flex-col items-center justify-center border transition-colors shadow-sm ${r?r.bgCard+` `+r.borderCard:`bg-foreground/5 border-[var(--panel-border)] group-hover:bg-accent/10 group-hover:border-accent/30`}`,children:[(0,s.jsx)(`span`,{className:`text-[10px] font-bold uppercase leading-none mb-0.5 ${r?r.text:`text-foreground/40 group-hover:text-accent/60`}`,children:n.toLocaleString(`default`,{month:`short`})}),(0,s.jsx)(`span`,{className:`text-[18px] font-black leading-none ${r?r.text:`group-hover:text-accent`}`,children:n.getDate()})]}),(0,s.jsx)(`div`,{className:`h-6 w-px bg-[var(--panel-border)] max-sm:hidden block group-hover:bg-accent/30 transition-colors`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[(0,s.jsx)(`h4`,{className:`text-[15px] md:text-[16px] font-extrabold tracking-tight truncate ${r?r.text:`text-foreground group-hover:text-accent`}`,children:e.title}),(0,s.jsxs)(`div`,{className:`flex items-center gap-3 text-[12px] text-foreground/50 font-medium`,children:[(0,s.jsx)(`span`,{children:ae(e.time)}),(0,s.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,s.jsx)(t.ht,{className:`w-3 h-3`}),oe(e.duration)]})]})]}),i&&(0,s.jsxs)(`div`,{className:`ml-auto pl-2 flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity`,children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),xe(e)},className:`p-2.5 rounded-xl text-foreground/50 hover:bg-foreground/10 hover:text-foreground transition-colors`,children:(0,s.jsx)(t.L,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),P(e)},className:`p-2.5 rounded-xl text-foreground/30 hover:bg-red-500/10 hover:text-red-500 transition-colors`,children:(0,s.jsx)(t.T,{className:`w-4 h-4`})})]})]}),p&&Q(e)]},e.id)}),w.filter(e=>e.dateStr===Z(L)).length===0&&(0,s.jsx)(`div`,{className:`p-12 text-center text-foreground/40 font-medium`,children:`No events scheduled for this day.`})]})]}),Ae=()=>(0,s.jsxs)(t.p,{children:[O&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{onClick:()=>k(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,s.jsxs)(t.f.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 rounded-3xl glass-popover border shadow-2xl relative z-10 ${vr.find(e=>e.text===O.color)?.borderCard||`border-[var(--panel-border)]`}`,children:[(0,s.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1 bg-background/50 backdrop-blur-3xl p-1 rounded-2xl border border-[var(--panel-border)]/50 shadow-sm z-50`,children:[ie(O)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:()=>{k(null),xe(O)},className:`p-2 rounded-xl text-foreground/50 hover:bg-foreground/10 hover:text-foreground transition-all`,title:`Edit`,children:(0,s.jsx)(t.L,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{P(O),k(null)},className:`p-2 rounded-xl text-foreground/50 hover:bg-red-500/10 hover:text-red-500 transition-all`,title:`Delete`,children:(0,s.jsx)(t.T,{className:`w-4 h-4`})}),(0,s.jsx)(`div`,{className:`w-px h-6 bg-[var(--panel-border)]/50 mx-1`})]}),(0,s.jsx)(`button`,{onClick:()=>k(null),className:`p-2 rounded-xl text-foreground/40 hover:bg-foreground/10 hover:text-foreground transition-all`,children:(0,s.jsx)(t._,{className:`w-5 h-5`})})]}),(0,s.jsxs)(`div`,{className:`mb-6 mt-12 sm:mt-0 sm:pr-32`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,s.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${vr.find(e=>e.text===O.color)?.bgCircle||`bg-accent`}`}),(0,s.jsx)(`span`,{className:`text-[11px] font-bold tracking-[0.2em] uppercase ${vr.find(e=>e.text===O.color)?.text||`text-accent`}`,children:`Event Details`})]}),(0,s.jsx)(`h3`,{className:`text-xl sm:text-3xl font-black mb-3 tracking-tight leading-tight break-words ${vr.find(e=>e.text===O.color)?.text||`text-foreground`}`,children:O.title}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 mt-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[14px] text-foreground/70 font-medium`,children:[(0,s.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,s.jsx)(t.Dt,{className:`w-4 h-4 text-foreground/50`})}),new Date(O.dateStr+`T12:00:00`).toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[14px] text-foreground/70 font-medium`,children:[(0,s.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,s.jsx)(t.ht,{className:`w-4 h-4 text-foreground/50`})}),ae(O.time),` `,(0,s.jsxs)(`span`,{className:`text-foreground/40 text-[12px] ml-1`,children:[`(`,oe(O.duration),`)`]})]})]}),we(O)]}),(0,s.jsx)(`div`,{className:`w-full h-px bg-gradient-to-r from-[var(--panel-border)]/0 via-[var(--panel-border)] to-[var(--panel-border)]/0 mb-6`}),O.description?(0,s.jsx)(`div`,{className:`bg-foreground/[0.02] border border-[var(--panel-border)]/50 rounded-2xl py-3 px-4 mb-4 w-full overflow-hidden`,children:(0,s.jsx)(`div`,{className:`text-[14px] text-foreground/80 font-medium whitespace-pre-wrap leading-tight break-words`,children:O.description})}):(0,s.jsx)(`div`,{className:`p-4 mb-4 rounded-2xl border border-dashed border-[var(--panel-border)] bg-foreground/[0.01] text-center`,children:(0,s.jsx)(`p`,{className:`text-[12px] font-medium text-foreground/40`,children:`No description provided for this event.`})}),O.customFields&&Object.entries(O.customFields).filter(([,e])=>e).length>0&&(0,s.jsx)(`div`,{className:`flex flex-col gap-2 mb-2`,children:Object.entries(O.customFields).filter(([,e])=>e).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex items-start gap-2 text-[13px]`,children:[(0,s.jsxs)(`span`,{className:`font-bold text-foreground/50 capitalize shrink-0`,children:[e,`:`]}),(0,s.jsx)(`span`,{className:`text-foreground/80 font-medium break-words min-w-0`,children:t})]},e))})]})]},`view-modal`),E&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{onClick:()=>D(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,s.jsxs)(t.f.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 rounded-3xl glass-popover border border-[var(--panel-border)] shadow-2xl relative z-10 max-h-[90vh] overflow-y-auto styled-scrollbars`,children:[(0,s.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1`,children:[F.id&&ie({uid:F.uid})&&(0,s.jsx)(`button`,{onClick:()=>{D(!1),P({id:F.id,...F})},className:`p-2 rounded-xl text-foreground/30 hover:bg-red-500/10 hover:text-red-500 transition-all`,children:(0,s.jsx)(t.T,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>D(!1),className:`p-2 rounded-xl text-foreground/40 hover:bg-foreground/10 hover:text-foreground transition-all`,children:(0,s.jsx)(t._,{className:`w-5 h-5`})})]}),(0,s.jsxs)(`div`,{className:`mb-6 pr-12`,children:[(0,s.jsx)(`h3`,{className:`text-2xl font-extrabold mb-1 tracking-tight`,children:F.id?`Edit Event`:`Add Event`}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/50`,children:F.id?`Modify your scheduled calendar block.`:`Schedule a new calendar block.`})]}),(0,s.jsxs)(`form`,{onSubmit:Se,className:`space-y-4`,children:[x===`public`&&!F.id&&(0,s.jsx)(t.c,{label:`Your Email`,type:`email`,value:F.guestEmail,onChange:e=>I({...F,guestEmail:e.target.value}),placeholder:`you@example.com`,required:!0}),(0,s.jsx)(t.c,{label:`Event Title`,value:F.title,onChange:e=>I({...F,title:e.target.value}),placeholder:`e.g. Design Sync`,required:!0}),(0,s.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,s.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Description`}),(0,s.jsx)(`textarea`,{value:F.description,onChange:e=>I({...F,description:e.target.value}),placeholder:`e.g. Discussing the new features...`,className:`block min-h-[80px] 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 glass-panel styled-scrollbars resize-none`})]}),b.map(e=>(0,s.jsx)(t.c,{label:e,value:F.customFields[e]||``,onChange:t=>I({...F,customFields:{...F.customFields,[e]:t.target.value}}),placeholder:`Enter ${e.toLowerCase()}...`},e)),(0,s.jsx)(`style`,{children:`
|
|
39
40
|
input[type="date"]::-webkit-calendar-picker-indicator{background:transparent;bottom:0;color:transparent;cursor:pointer;height:auto;left:0;position:absolute;right:0;top:0;width:auto;z-index:10}
|
|
40
41
|
input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
|
|
41
42
|
input[type="number"]{-moz-appearance:textfield}
|
|
42
|
-
`}),(0,s.jsxs)(`div`,{className:`relative group/date flex flex-col w-full`,children:[(0,s.jsx)(t.s,{type:`date`,label:`Date`,required:!0,value:F.dateStr,onChange:e=>I({...F,dateStr:e.target.value}),className:`pr-10`}),(0,s.jsx)(`div`,{className:`absolute right-4 bottom-4 pointer-events-none group-focus-within/date:text-accent text-foreground/40 transition-colors`,children:(0,s.jsx)(t.Et,{className:`w-4 h-4`})})]}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[G?(0,s.jsx)(t.s,{type:`time`,label:`Time`,value:F.time,onChange:e=>I({...F,time:e.target.value}),required:!0}):(()=>{let{h:e,m:t,ampm:n}=X(F.time);return(0,s.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,s.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Time`}),(0,s.jsxs)(`div`,{className:`flex items-center h-12 glass-panel border border-[var(--panel-border)] rounded-xl px-3 gap-1 focus-within:border-accent transition-colors`,children:[(0,s.jsx)(`input`,{type:`number`,min:1,max:12,value:e,onChange:e=>I({...F,time:ce(Math.min(12,Math.max(1,parseInt(e.target.value)||12)),t,n)}),className:`w-8 text-center bg-transparent focus:outline-none text-foreground font-bold text-[15px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),(0,s.jsx)(`span`,{className:`text-foreground/40 font-bold text-[15px] select-none`,children:`:`}),(0,s.jsx)(`input`,{type:`number`,min:0,max:59,value:t.toString().padStart(2,`0`),onChange:t=>I({...F,time:ce(e,Math.min(59,Math.max(0,parseInt(t.target.value)||0)),n)}),className:`w-8 text-center bg-transparent focus:outline-none text-foreground font-bold text-[15px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>I({...F,time:ce(e,t,n===`AM`?`PM`:`AM`)}),className:`ml-auto px-2 py-0.5 rounded-md bg-accent/10 text-accent text-[11px] font-extrabold uppercase tracking-wider hover:bg-accent/20 transition-colors shrink-0`,children:n})]})]})})(),(0,s.jsx)(t.s,{type:`number`,min:`1`,max:`1440`,label:`Duration (min)`,value:F.duration,onChange:e=>I({...F,duration:e.target.value}),placeholder:`60`,required:!0})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,s.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest mt-1`,children:`Event Color`}),(0,s.jsx)(`div`,{className:`flex gap-2 items-center relative z-10 w-full h-[46px]`,children:nr.map(e=>(0,s.jsx)(`button`,{type:`button`,onClick:()=>I({...F,color:F.color===e.text?``:e.text}),className:`w-6 h-6 rounded-full shrink-0 ${e.bgCircle} hover:scale-110 transition-transform flex items-center justify-center border border-[var(--panel-border)]`,children:F.color===e.text&&(0,s.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full bg-background`})},e.name))})]}),(0,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsx)(t.o,{type:`submit`,isLoading:A,className:`w-full py-3`,children:F.id?`Save Changes`:`Create Event`})})]})]})]},`edit-modal`),(0,s.jsx)(me,{isOpen:!!N,title:`Confirm Deletion`,message:(0,s.jsxs)(s.Fragment,{children:[`Are you sure you want to delete `,(0,s.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:N?.title}),` This action is permanent.`]}),onConfirm:Se,onCancel:()=>{P(null)},isProcessing:ee,confirmText:`Yes, Delete`})]});return p?(0,s.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,s.jsx)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:d?.tabTitle||d?.tabName||e}),n&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),n]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[De(),ke()]})]}),Ae()]}):(0,s.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,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,s.jsx)(se,{children:e}),n&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),n]})]}),(0,s.jsxs)(`div`,{className:`flex flex-wrap justify-between items-center gap-2 mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:[o?(0,s.jsxs)(c.Link,{to:o,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`,children:[(0,s.jsx)(t.jt,{className:`w-4 h-4`}),` Go Back`]}):(0,s.jsx)(`div`,{}),(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsx)(t.o,{variant:`secondary`,onClick:q,className:`px-3 h-10 text-[12px] font-bold rounded-xl flex items-center justify-center border-[var(--panel-border)] border shrink-0 hover:bg-foreground/5 shadow-sm text-foreground/70`,children:G?`24h`:`12h`}),(0,s.jsx)(t.o,{variant:`secondary`,onClick:J,className:`w-10 h-10 p-0 text-[14px] font-bold rounded-xl flex items-center justify-center border-[var(--panel-border)] border shrink-0`,children:S===`month`?(0,s.jsx)(t.J,{className:`w-4 h-4 text-foreground/70`}):(0,s.jsx)(t.Et,{className:`w-4 h-4 text-foreground/70`})}),Ee&&(0,s.jsxs)(t.o,{onClick:()=>be(),className:`px-6 py-2.5 text-[14px] font-bold rounded-xl shadow-lg flex items-center gap-2`,children:[(0,s.jsx)(t.F,{className:`w-4 h-4`}),` Event`]})]})]}),(0,s.jsxs)(t.d.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 flex-1`,children:[(0,s.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`}),ke()]}),Ae()]})}var ar=[{name:`Purple Standard`,preview:[`#2e1065`,`#cdc1ff`],dark:{buttonText:`#ffffff`,background:`#07070f`,backgroundSecondary:`#0a0a18`,accent:`#a78bfa`,gradient:[`#6d28d9`,`#a78bfa`],text:[`#f0eeff`,`#c4b5fd`,`#a78bfa`]},light:{buttonText:`#ffffff`,background:`#fcfaff`,backgroundSecondary:`#f7f3ff`,accent:`#7c3aed`,gradient:[`#5b21b6`,`#a78bfa`],text:[`#2e1065`,`#6d28d9`,`#cdc1ff`]}},{name:`Royal Navy`,preview:[`#1e3a8a`,`#60a5fa`],dark:{buttonText:`#ffffff`,background:`#050b14`,backgroundSecondary:`#0a192f`,accent:`#60a5fa`,gradient:[`#1d4ed8`,`#60a5fa`],text:[`#dbeafe`,`#93c5fd`,`#60a5fa`]},light:{buttonText:`#ffffff`,background:`#f8fafc`,backgroundSecondary:`#f1f5f9`,accent:`#2563eb`,gradient:[`#1e3a8a`,`#60a5fa`],text:[`#1e3a8a`,`#2563eb`,`#60a5fa`]}},{name:`Emerald Green`,preview:[`#064e3b`,`#10b981`],dark:{buttonText:`#ffffff`,background:`#050806`,backgroundSecondary:`#0a2218`,accent:`#34d399`,gradient:[`#047857`,`#34d399`],text:[`#d1fae5`,`#6ee7b7`,`#34d399`]},light:{buttonText:`#ffffff`,background:`#f6fbf8`,backgroundSecondary:`#eff7f2`,accent:`#059669`,gradient:[`#064e3b`,`#10b981`],text:[`#064e3b`,`#059669`,`#10b981`]}},{name:`Gold`,preview:[`#854d0e`,`#eab308`],dark:{buttonText:`#000000`,background:`#0f0905`,backgroundSecondary:`#1c1208`,accent:`#fcd34d`,gradient:[`#ca8a04`,`#facc15`],text:[`#fefce8`,`#fef08a`,`#facc15`]},light:{buttonText:`#ffffff`,background:`#fbfaf6`,backgroundSecondary:`#f5f2eb`,accent:`#d97706`,gradient:[`#854d0e`,`#eab308`],text:[`#854d0e`,`#ca8a04`,`#eab308`]}},{name:`Silver`,preview:[`#1e293b`,`#94a3b8`],dark:{buttonText:`#ffffff`,background:`#090e17`,backgroundSecondary:`#101725`,accent:`#cbd5e1`,gradient:[`#475569`,`#94a3b8`],text:[`#e2e8f0`,`#94a3b8`,`#cbd5e1`]},light:{buttonText:`#ffffff`,background:`#f8fafc`,backgroundSecondary:`#e2e8f0`,accent:`#64748b`,gradient:[`#1e293b`,`#94a3b8`],text:[`#1e293b`,`#475569`,`#94a3b8`]}},{name:`Barbie Pink`,preview:[`#d946ef`,`#f472b6`],dark:{buttonText:`#ffffff`,background:`#0c030a`,backgroundSecondary:`#1a0515`,accent:`#ff80ff`,gradient:[`#c026d3`,`#f472b6`],text:[`#ffeeff`,`#ffb3ff`,`#ff80ff`]},light:{buttonText:`#ffffff`,background:`#fcf5fa`,backgroundSecondary:`#f5ebf2`,accent:`#d946ef`,gradient:[`#c026d3`,`#ec4899`],text:[`#a21caf`,`#c026d3`,`#ec4899`]}},{name:`Orange`,preview:[`#7c2d12`,`#f97316`],dark:{buttonText:`#ffffff`,background:`#0a0200`,backgroundSecondary:`#1c0b05`,accent:`#fb923c`,gradient:[`#c2410c`,`#fb923c`],text:[`#fff7ed`,`#fdba74`,`#fb923c`]},light:{buttonText:`#ffffff`,background:`#fdf6f2`,backgroundSecondary:`#f5ebe4`,accent:`#ea580c`,gradient:[`#7c2d12`,`#f97316`],text:[`#7c2d12`,`#ea580c`,`#f97316`]}},{name:`Red`,preview:[`#7f1d1d`,`#ef4444`],dark:{buttonText:`#ffffff`,background:`#0a0000`,backgroundSecondary:`#2e0a0a`,accent:`#ef4444`,gradient:[`#b91c1c`,`#f87171`],text:[`#fef2f2`,`#fecaca`,`#f87171`]},light:{buttonText:`#ffffff`,background:`#fdf5f5`,backgroundSecondary:`#f5ebeb`,accent:`#dc2626`,gradient:[`#7f1d1d`,`#ef4444`],text:[`#7f1d1d`,`#dc2626`,`#ef4444`]}},{name:`Black & White`,preview:[`#ffffff`,`#000000`],dark:{buttonText:`#000000`,background:`#000000`,backgroundSecondary:`#111111`,accent:`#ffffff`,gradient:[`#ffffff`,`#e5e7eb`],text:[`#ffffff`,`#f3f4f6`,`#ffffff`]},light:{buttonText:`#ffffff`,background:`#ffffff`,backgroundSecondary:`#f3f4f6`,accent:`#000000`,gradient:[`#000000`,`#1f2937`],text:[`#000000`,`#1f2937`,`#374151`]}}],or=[`Inter`,`Outfit`,`Roboto`,`Space Grotesk`,`Plus Jakarta Sans`,`System UI`],sr=[{key:`light`,label:`Light mode`,icon:t.D,description:`How the site looks for someone with light mode on.`},{key:`dark`,label:`Dark mode`,icon:t.z,description:`How the site looks for someone with dark mode on.`}],cr=_e,lr=`flex items-center gap-2 w-full h-10 px-1.5 rounded-[var(--input-radius,0.75rem)] border border-[var(--panel-border)] bg-[var(--panel-bg)] transition-all focus-within:border-accent hover:border-accent/40`,ur=`border border-[var(--panel-border)]/60`,dr=e=>JSON.parse(JSON.stringify(e)),fr=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e)||typeof t!=`object`||!t||Array.isArray(t))return JSON.stringify(e)===JSON.stringify(t)?void 0:e;let n={};for(let r of Object.keys(e)){let i=fr(e[r],t[r]);i!==void 0&&(n[r]=i)}return Object.keys(n).length?n:void 0},pr=e=>{let t=(e||``).replace(`#`,``).trim();return t.length===3?[0,1,2].map(e=>parseInt(t[e]+t[e],16)):t.length===6?[0,2,4].map(e=>parseInt(t.substring(e,e+2),16)):null},mr=(e,t,n)=>{let r=e=>Math.max(0,Math.min(255,Math.round(e)));return`#${[e,t,n].map(e=>r(e).toString(16).padStart(2,`0`)).join(``)}`},hr=e=>{let t=(e||``).trim();if(t.startsWith(`#`)){let e=pr(t);return e?mr(e[0],e[1],e[2]):null}let n=t.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);return n?mr(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3])):null},gr=(e,t)=>{let n=pr(e);return n?mr(n[0]*t,n[1]*t,n[2]*t):e},_r=e=>e?Array.isArray(e)?e.length===1?e[0]:`linear-gradient(135deg, ${e.join(`, `)})`:e:``,vr=(e,t)=>{let n=pr(hr(t)||t);if(!n)return{};let r=e=>`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${e})`;return{panelBg:e===`dark`?r(`0.05`):`rgba(255, 255, 255, 0.70)`,panelBorder:r(e===`dark`?`0.15`:`0.08`),glowColor:r(e===`dark`?`0.40`:`0.30`),selectionBg:r(e===`dark`?`0.40`:`0.30`)}};function yr({label:e,hint:t,value:n,over:r,onChange:i}){let a=hr(n)||`#7c3aed`;return(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5 p-3.5 sm:p-4 ${he}`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,s.jsx)(`label`,{className:`text-[12.5px] font-bold text-foreground truncate`,children:e}),(0,s.jsxs)(`label`,{className:`relative w-7 h-7 rounded-lg cursor-pointer overflow-hidden shrink-0 shadow-2xs transition-all hover:scale-105 active:scale-95 flex items-center justify-center focus-within:ring-2 focus-within:ring-accent ${ur}`,title:`Pick a colour for ${e}`,children:[(0,s.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-0`,style:{backgroundColor:r||`transparent`}}),(0,s.jsx)(`span`,{"aria-hidden":!0,"data-testid":`color-swatch`,className:`absolute inset-0`,style:{backgroundColor:n||`transparent`}}),(0,s.jsx)(`input`,{type:`color`,"aria-label":`${e} colour picker`,value:a,onChange:e=>i(e.target.value),className:`absolute inset-0 w-full h-full opacity-0 cursor-pointer p-0 border-0`})]})]}),t&&(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/45 font-medium leading-snug`,children:t}),(0,s.jsx)(`input`,{type:`text`,"aria-label":e,value:n??``,onChange:e=>i(e.target.value),className:cr})]})}function br({label:e,hint:n,value:r,onChange:i}){let a=Array.isArray(r)&&r.length?r:[`#7c3aed`,`#6d28d9`],o=(e,t)=>{let n=[...a];n[e]=t,i(n)};return(0,s.jsxs)(`div`,{className:`flex flex-col gap-2.5 p-3.5 sm:p-4 ${he}`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,s.jsx)(`label`,{className:`text-[12.5px] font-bold text-foreground truncate`,children:e}),(0,s.jsx)(`div`,{"data-testid":`gradient-preview`,className:`w-16 h-5 rounded-lg border border-[var(--panel-border)]/60 shrink-0 shadow-2xs overflow-hidden`,style:{background:_r(a)}})]}),n&&(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/45 font-medium leading-snug`,children:n}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 pt-1.5`,children:[a.map((n,r)=>(0,s.jsxs)(`div`,{className:lr,children:[(0,s.jsx)(`label`,{className:`relative w-6 h-6 rounded-md cursor-pointer overflow-hidden shrink-0 transition-all hover:scale-105 active:scale-95 flex items-center justify-center ${ur}`,style:{backgroundColor:n||`transparent`},title:`Pick colour ${r+1} for ${e}`,children:(0,s.jsx)(`input`,{type:`color`,"aria-label":`${e} colour ${r+1} picker`,value:hr(n)||`#7c3aed`,onChange:e=>o(r,e.target.value),className:`absolute inset-0 w-full h-full opacity-0 cursor-pointer p-0 border-0`})}),(0,s.jsx)(`input`,{type:`text`,"aria-label":`${e} colour ${r+1}`,value:n,onChange:e=>o(r,e.target.value),className:`flex-1 min-w-0 h-full bg-transparent border-0 px-0 text-[12px] font-semibold text-foreground outline-none`}),a.length>2&&(0,s.jsx)(`button`,{type:`button`,onClick:()=>i(a.filter((e,t)=>t!==r)),"aria-label":`Remove colour ${r+1} from ${e}`,className:`w-6 h-6 rounded-md flex items-center justify-center text-foreground/35 hover:text-red-500 hover:bg-red-500/10 transition-colors cursor-pointer shrink-0`,children:(0,s.jsx)(t.g,{className:`w-3.5 h-3.5`})})]},r)),a.length<6&&(0,s.jsxs)(`button`,{type:`button`,onClick:()=>i([...a,gr(a[a.length-1]||`#6d28d9`,.9)]),className:`w-full h-9 px-3 rounded-lg border border-dashed border-accent/40 hover:border-accent bg-accent/[0.03] hover:bg-accent/10 text-accent text-[11.5px] font-bold flex items-center justify-center gap-1.5 transition-all active:scale-[0.99] cursor-pointer shadow-2xs mt-0.5`,children:[(0,s.jsx)(t.F,{className:`w-3.5 h-3.5`}),`Add another colour`]})]})]})}function xr({label:e,hint:t,value:n,onChange:r}){let i=Number.isFinite(n)?n:0;return(0,s.jsx)(Ce,{label:e,hint:t,action:(0,s.jsxs)(`span`,{className:`text-[11px] font-bold text-foreground/50 tabular-nums shrink-0`,children:[Math.round(i*16),`px`]}),children:(0,s.jsx)(`input`,{type:`range`,min:0,max:3,step:.125,value:i,"aria-label":e,onChange:e=>r(parseFloat(e.target.value)),className:`w-full accent-accent cursor-pointer`})})}function Sr({title:e,onReset:n}){return(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-2 first:pt-0`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-black uppercase tracking-wider text-foreground/40`,children:e}),(0,s.jsx)(Q,{icon:t.N,onClick:n,children:`Reset`})]})}var Cr=[`accent`,`foreground`,`background`,`backgroundSecondary`,`textGradient`,`notificationIconColor`],wr=[`buttonGradient`,`buttonHoverGradient`,`buttonText`,`secondaryButton`],Tr=[`panelBg`,`panelBorder`,`glowColor`,`selectionBg`,`selectionText`],Er=`fbos_theme_ai_draft`,Dr=()=>{try{return JSON.parse(localStorage.getItem(Er)||`{}`)}catch{return{}}},Or=e=>{let t=String(e?.brief||``).trim(),n=String(e?.appName||``).trim(),r=String(e?.logoUrl||``).trim(),i=String(e?.faviconUrl||``).trim(),a=[`Design the look of my whole app. Here is what I am after: ${t||`___`}`,`Do it all in one file: src/your-ai-workflow-firebase-os/configs/theme.config.ts — the colours, the typeface and how rounded things are. Do not restyle by rewriting components, and do not put colours of your own anywhere else.`,`Set the dark colours and the light colours both, so my site reads well either way.`];return n&&a.push(`In that same file, set appName to exactly: ${n}`),r&&a.push(`In that same file, set logoUrl to exactly this link: ${r} — that is my logo for the top bar. Use my link character for character, take my colours from the picture, and never swap it for a placeholder or a picture of your own.`),i&&a.push(i===r?`Set faviconUrl to that same link — it is my browser tab icon too.`:`In that same file, set faviconUrl to exactly this link: ${i} — that is my browser tab icon. Use my link character for character.`),!r&&!i?a.push(`Leave logoUrl and faviconUrl exactly as they are. The logo and the browser tab icon are mine, and my Theme screen is the only place they change.`):r?i||a.push(`Leave faviconUrl exactly as it is — my browser tab icon is mine, and my Theme screen is the only place it changes.`):a.push(`Leave logoUrl exactly as it is — my logo is mine, and my Theme screen is the only place it changes.`),a.push(`Tell me what you picked and why, in one short paragraph.`),a.push(`If nothing changes on my site after you edit that file, say so — a look I have saved in the app wins over the file, and I can undo that with Start again on my Theme screen.`),a.join(`
|
|
43
|
-
`)},kr=e=>String(e?.brief||``).trim()?``:`Say what look you are after, and this sentence is ready to copy.`,Ar=[`appName`,`defaultTheme`,`showThemeToggle`],jr=[`fontFamily`,`cornerRounding`,`cornerRadii`];function Mr(){let{activeConfig:e,theme:n}=t.Lt(),a=t.zt(),o=(0,r.useMemo)(()=>dr(a?.themeConfig||t.Wt),[a]),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(Dr),p=(e,t)=>f(n=>{let r={...n,[e]:t};try{localStorage.setItem(Er,JSON.stringify(r))}catch{}return r}),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(null),[v,y]=(0,r.useState)(!1),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=(0,i.onSnapshot)((0,i.doc)(t.Vt,`sys_configs`,`theme`),e=>x(e.exists()));return()=>e()},[]);let w=r.default.useRef(null);(0,r.useEffect)(()=>{if(!e)return;let t=JSON.stringify(dr(e)),n=l?JSON.stringify(l):null;n!==t&&(n&&n!==w.current||(w.current=t,u(JSON.parse(t))))},[e,l]),(0,r.useEffect)(()=>{try{let e=sessionStorage.getItem(`fbos_theme_scrollY`);e&&requestAnimationFrame(()=>window.scrollTo(0,parseInt(e,10)))}catch{}let e=()=>{try{sessionStorage.setItem(`fbos_theme_scrollY`,String(window.scrollY))}catch{}};return window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[]),(0,r.useEffect)(()=>{if(!l)return;let e=JSON.stringify(l);if(e===w.current)return;let n=setTimeout(async()=>{h(!0);try{let n=fr(l,o);n?await(0,i.setDoc)((0,i.doc)(t.Vt,`sys_configs`,`theme`),n):(await(0,i.deleteDoc)((0,i.doc)(t.Vt,`sys_configs`,`theme`)),localStorage.removeItem(`theme_config_cache`)),w.current=e,_(Date.now())}catch(e){console.error(`Auto-save failed`,e)}h(!1)},300);return()=>clearTimeout(n)},[l,o]);let T=(e,t)=>u(n=>({...n,[e]:t})),E=(e,t)=>u(n=>({...n,colors:{...n.colors,[e]:{...n.colors?.[e]||{},...t}}})),D=(e,t)=>u(n=>({...n,colors:{...n.colors,[e]:{...n.colors?.[e]||{},secondaryButton:{...n.colors?.[e]?.secondaryButton||{},...t}}}})),O=(e,t)=>E(e,{accent:t,notificationIconColor:t,...vr(e,t)}),k=(e,t,n)=>C({title:e,message:t,apply:n}),A=e=>u(t=>{let n=dr(t);return e.forEach(e=>{o[e]===void 0?delete n[e]:n[e]=dr(o[e])}),n}),j=(e,t)=>u(n=>{let r=dr(n),i=o.colors?.[e]||{};return r.colors=r.colors||{},r.colors[e]=r.colors[e]||{},t.forEach(t=>{i[t]===void 0?delete r.colors[e][t]:r.colors[e][t]=dr(i[t])}),r}),ee=e=>{if(!l)return;let t=dr(l);t.colors=t.colors||{},[`dark`,`light`].forEach(n=>{let r=e[n],i=t.colors[n]||{};t.colors[n]={...i,accent:r.accent,buttonGradient:[...r.gradient],buttonHoverGradient:[...r.gradient],buttonText:r.buttonText,notificationIconColor:r.accent,textGradient:[...r.text],foreground:r.text[0],background:r.background,backgroundSecondary:r.backgroundSecondary,...vr(n,r.accent),...i.secondaryButton?{secondaryButton:{...i.secondaryButton,text:r.text[0]}}:{}}}),u(t)},M=async()=>{y(!0);try{let e=dr(o);await(0,i.deleteDoc)((0,i.doc)(t.Vt,`sys_configs`,`theme`)),localStorage.removeItem(`theme_config_cache`),localStorage.removeItem(`theme-mode`),localStorage.removeItem(`last-seen-default-theme`),localStorage.removeItem(Er),f({}),w.current=JSON.stringify(e),u(e)}catch{}setTimeout(()=>y(!1),600)},N=e=>{let t=sr.find(t=>t.key===e),r=l?.colors?.[e]||{},i=o.colors?.[e]||{},a=r.background||i.background||`#ffffff`;return(0,s.jsxs)(Se,{icon:t.icon,title:t.label,description:t.description,defaultOpen:n===e,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 p-3.5 sm:p-4 ${he}`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,s.jsx)(`span`,{className:`text-[12.5px] font-bold text-foreground`,children:`Ready-made colour sets`}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/45 font-medium leading-snug`,children:`One click repaints light and dark together.`})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-3 overflow-x-auto no-scrollbar py-2.5 px-2.5 -mx-2.5`,children:ar.map(t=>{let n=r.accent===t[e].accent&&l?.colors?.[e]?.buttonGradient?.[0]===t[e].gradient[0],i=t.name===`Black & White`;return(0,s.jsx)(`button`,{type:`button`,onClick:()=>ee(t),"aria-label":t.name,title:t.name,className:`w-9 h-9 rounded-full shrink-0 outline-none transition-all shadow-sm relative cursor-pointer ${n?`ring-2 ring-accent ring-offset-2 ring-offset-[var(--bg-color)] scale-110 z-10`:`opacity-80 hover:opacity-100 hover:ring-2 hover:ring-foreground/25 hover:ring-offset-2 hover:ring-offset-[var(--bg-color)] hover:scale-105`}`,children:(0,s.jsx)(`span`,{className:`absolute inset-0 rounded-full border border-[var(--panel-border)]/60`,style:i?{backgroundColor:`#ffffff`,border:`3px solid #000000`}:{backgroundImage:`linear-gradient(135deg, ${t.preview[0]}, ${t.preview[1]})`}})},t.name)})})]}),(0,s.jsx)(Sr,{title:`Brand and colours`,onReset:()=>k(`Reset the colours?`,`The brand colour, the text and the two backgrounds in ${t.label.toLowerCase()} go back to how they started. Nothing else changes.`,()=>j(e,Cr))}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 items-start`,children:[(0,s.jsx)(yr,{over:a,label:`Brand colour`,hint:`Links, highlights and the main buttons. Panels follow it too.`,value:r.accent||i.accent||`#7c3aed`,onChange:t=>O(e,t)}),(0,s.jsx)(yr,{over:a,label:`Text colour`,hint:`Primary typography colour used across the app.`,value:r.foreground||i.foreground||`#111827`,onChange:t=>E(e,{foreground:t})}),(0,s.jsx)(yr,{over:a,label:`Page background`,hint:`Main background canvas colour under all content.`,value:r.background||i.background||`#ffffff`,onChange:t=>E(e,{background:t})}),(0,s.jsx)(yr,{over:a,label:`Second background`,hint:`The colour the page background fades into.`,value:r.backgroundSecondary||i.backgroundSecondary||`#f9fafb`,onChange:t=>E(e,{backgroundSecondary:t})}),(0,s.jsx)(yr,{over:a,label:`Notification dot`,hint:`Colour applied to notification badging.`,value:r.notificationIconColor||r.accent||i.notificationIconColor||`#7c3aed`,onChange:t=>E(e,{notificationIconColor:t})}),(0,s.jsx)(br,{label:`Heading colours`,hint:`The colours big headings fade through.`,value:r.textGradient||i.textGradient,onChange:t=>E(e,{textGradient:t})})]}),(0,s.jsx)(Sr,{title:`Buttons`,onReset:()=>k(`Reset the buttons?`,`Every button colour in ${t.label.toLowerCase()} goes back to how it started. Nothing else changes.`,()=>j(e,wr))}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3 items-start`,children:[(0,s.jsx)(br,{label:`Button colours`,hint:`The colours your main buttons fade through.`,value:r.buttonGradient||i.buttonGradient,onChange:t=>E(e,{buttonGradient:t})}),(0,s.jsx)(br,{label:`Button colours on hover`,hint:`How a main button looks under the pointer.`,value:r.buttonHoverGradient||i.buttonHoverGradient,onChange:t=>E(e,{buttonHoverGradient:t})}),(0,s.jsx)(yr,{over:a,label:`Button text`,hint:`The writing on your main buttons.`,value:r.buttonText||i.buttonText||`#ffffff`,onChange:t=>E(e,{buttonText:t})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 mt-1`,children:[(0,s.jsx)(`span`,{className:`text-[10px] font-extrabold uppercase tracking-wider text-foreground/40`,children:`Quieter buttons`}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-3 items-start`,children:[(0,s.jsx)(yr,{over:a,label:`Quiet button fill`,value:r.secondaryButton?.bg||i.secondaryButton?.bg||`rgba(0, 0, 0, 0.03)`,onChange:t=>D(e,{bg:t})}),(0,s.jsx)(yr,{over:a,label:`Quiet button edge`,value:r.secondaryButton?.border||i.secondaryButton?.border||`rgba(0, 0, 0, 0.06)`,onChange:t=>D(e,{border:t})}),(0,s.jsx)(yr,{over:a,label:`Quiet button text`,value:r.secondaryButton?.text||i.secondaryButton?.text||`#111827`,onChange:t=>D(e,{text:t})})]})]}),(0,s.jsx)(Sr,{title:`Panels and highlights`,onReset:()=>k(`Reset the panels?`,`Panels, edges, the focus glow and text highlighting in ${t.label.toLowerCase()} go back to how they started. Nothing else changes.`,()=>j(e,Tr))}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 items-start`,children:[(0,s.jsx)(yr,{over:a,label:`Panel fill`,hint:`Background colour of cards and panels.`,value:r.panelBg||i.panelBg||`rgba(255, 255, 255, 0.70)`,onChange:t=>E(e,{panelBg:t})}),(0,s.jsx)(yr,{over:a,label:`Panel edge`,hint:`Borders of panels, inputs and dropdowns.`,value:r.panelBorder||i.panelBorder||`rgba(0, 0, 0, 0.08)`,onChange:t=>E(e,{panelBorder:t})}),(0,s.jsx)(yr,{over:a,label:`Focus glow`,hint:`The glow around the box someone is typing in.`,value:r.glowColor||i.glowColor||`rgba(124, 58, 237, 0.30)`,onChange:t=>E(e,{glowColor:t})}),(0,s.jsx)(yr,{over:a,label:`Highlight`,hint:`The colour behind text someone has selected.`,value:r.selectionBg||i.selectionBg||`rgba(124, 58, 237, 0.30)`,onChange:t=>E(e,{selectionBg:t})}),(0,s.jsx)(yr,{over:a,label:`Highlighted text`,hint:`The colour of the selected text itself.`,value:r.selectionText||i.selectionText||`#ffffff`,onChange:t=>E(e,{selectionText:t})})]})]},e)};return(0,s.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,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6`,children:[(0,s.jsx)(se,{children:`Theme`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/theme`]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-3xl p-4 sm:p-5 md:p-8 shadow-2xl relative bg-background flex flex-col min-h-[600px]`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-[17px] sm:text-xl font-extrabold text-foreground tracking-tight`,children:`Design it with your assistant`}),(0,s.jsxs)(`p`,{className:`text-[12.5px] sm:text-[13.5px] font-medium text-foreground/55 mt-1 sm:mt-1.5`,children:[(0,s.jsx)(`span`,{className:`sm:hidden`,children:`Fill these in for your assistant.`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:`Fill these in, then copy the sentence below into your assistant’s chat.`})]})]}),(0,s.jsx)(Ue,{label:`Logo`,hint:`The picture in the top bar.`,value:d.logoUrl||``,onChange:e=>p(`logoUrl`,e)}),(0,s.jsx)(Ue,{label:`Browser tab icon`,hint:`The tiny picture on the browser tab.`,value:d.faviconUrl||``,onChange:e=>p(`faviconUrl`,e)}),(0,s.jsx)(we,{label:`App name`,hint:`It goes in the top bar and on the browser tab.`,value:d.appName||``,onChange:e=>p(`appName`,e),placeholder:`Bright Studio`}),(0,s.jsx)(Te,{label:`What look would you like?`,hint:`What you do, who it is for, and the feeling you are after.`,value:d.brief||``,onChange:e=>p(`brief`,e),rows:4,placeholder:`A calm, modern look for a small physiotherapy clinic. Soft greens, lots of white space, nothing shouty. Rounded corners.`}),(0,s.jsx)(He,{title:`Copy this to your assistant`,prompt:Or(d),locked:!!kr(d)}),(0,s.jsxs)(`p`,{className:`text-[11.5px] text-foreground/45 font-medium leading-snug px-1`,children:[`Uploads are kept on your`,` `,(0,s.jsx)(c.Link,{to:`/assets`,className:`text-accent font-bold hover:underline`,children:`Assets page`}),` `,`too — edit the fields and copy the sentence again any time.`]})]}),(0,s.jsxs)(`div`,{className:`mt-10 pt-8 border-t border-[var(--panel-border)]/50 mb-5 flex flex-col-reverse sm:flex-row sm:flex-wrap sm:items-start sm:justify-between gap-3`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight`,children:`Change it by hand`}),(0,s.jsx)(`p`,{className:`text-[13.5px] font-medium text-foreground/55 mt-1.5`,children:`One setting at a time. Changes show up straight away and save themselves.`})]}),(0,s.jsxs)(`div`,{className:`flex items-center justify-end gap-2 sm:shrink-0`,children:[(0,s.jsx)(ke,{saving:m,savedAt:g}),(0,s.jsx)(Q,{icon:t.N,tone:`danger`,busy:v,disabled:!b,onClick:()=>k(`Start the whole look again?`,`Every colour, the font and the corners go back to how they were the day you installed, and your answers in the assistant section above clear too. This cannot be undone.`,M),children:`Start again`})]})]}),l?(0,s.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,s.jsxs)(Se,{icon:t.Ft,title:`Name and how it opens`,description:`What your site is called, and whether it opens light or dark.`,defaultOpen:!1,actions:(0,s.jsx)(Q,{icon:t.N,onClick:()=>k(`Reset the name?`,`The name and the opening mode go back to how they started. Your logo and your browser tab icon are left alone.`,()=>A(Ar)),children:`Reset`}),children:[(0,s.jsx)(we,{label:`Site name`,hint:`The name people see in the top bar and on the browser tab.`,value:l.appName||``,onChange:e=>T(`appName`,e),placeholder:`Your AI Firebase`}),(0,s.jsx)(Ue,{label:`Logo`,hint:`The picture in the top bar — changes straight away.`,value:l.logoUrl||``,onChange:e=>T(`logoUrl`,e),action:(l.logoUrl||``)===(o.logoUrl||``)?void 0:(0,s.jsx)(Q,{icon:t.N,onClick:()=>T(`logoUrl`,o.logoUrl||``),children:`Put the original back`})}),(0,s.jsx)(Ue,{label:`Browser tab icon`,hint:`The tiny picture on the browser tab — changes straight away.`,value:l.faviconUrl||``,onChange:e=>T(`faviconUrl`,e),action:(l.faviconUrl||``)===(o.faviconUrl||``)?void 0:(0,s.jsx)(Q,{icon:t.N,onClick:()=>T(`faviconUrl`,o.faviconUrl||``),children:`Put the original back`})}),(0,s.jsx)(Ee,{label:`How the site opens`,hint:`Light, dark, or whichever one the visitor already uses on their device.`,value:l.defaultTheme||`system`,onChange:e=>T(`defaultTheme`,e||`system`),allowEmpty:!1,options:[{value:`system`,label:`Whatever their device uses`},{value:`light`,label:`Always light`},{value:`dark`,label:`Always dark`}]}),(l.defaultTheme||`system`)===`system`&&(0,s.jsx)(De,{label:`Let visitors switch it themselves`,hint:`Shows the sun and moon button in the top bar.`,enabled:l.showThemeToggle!==!1,onChange:e=>T(`showThemeToggle`,e)})]}),sr.map(e=>N(e.key)),(0,s.jsxs)(Se,{icon:t.S,title:`Lettering and corners`,description:`The typeface, and how rounded everything looks.`,defaultOpen:!1,actions:(0,s.jsx)(Q,{icon:t.N,onClick:()=>k(`Reset the lettering and corners?`,`The typeface and every corner go back to how they started.`,()=>A(jr)),children:`Reset`}),children:[(0,s.jsx)(Ee,{label:`Typeface`,hint:`The lettering used everywhere on your site.`,value:l.fontFamily||`Inter`,onChange:e=>T(`fontFamily`,e||`Inter`),allowEmpty:!1,options:or.map(e=>({value:e,label:e}))}),(0,s.jsx)(Ee,{label:`Corners`,hint:`Keep the rounding we ship with, or set each one yourself.`,value:l.cornerRounding||`default`,onChange:e=>T(`cornerRounding`,e||`default`),allowEmpty:!1,options:[{value:`default`,label:`Standard rounding`},{value:`custom`,label:`Set them myself`}]}),l.cornerRounding===`custom`&&(0,s.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,s.jsx)(xr,{label:`Buttons`,hint:`How round every button is.`,value:l.cornerRadii?.buttonRadius??.75,onChange:e=>T(`cornerRadii`,{...l.cornerRadii||{},buttonRadius:e})}),(0,s.jsx)(xr,{label:`Boxes people type in`,hint:`Form fields and search boxes.`,value:l.cornerRadii?.inputRadius??.75,onChange:e=>T(`cornerRadii`,{...l.cornerRadii||{},inputRadius:e})}),(0,s.jsx)(xr,{label:`Cards`,hint:`The panels your content sits on.`,value:l.cornerRadii?.cardRadius??1.5,onChange:e=>T(`cornerRadii`,{...l.cornerRadii||{},cardRadius:e})}),(0,s.jsx)(xr,{label:`Pop-ups`,hint:`Dialogs and confirmation boxes.`,value:l.cornerRadii?.modalRadius??2.5,onChange:e=>T(`cornerRadii`,{...l.cornerRadii||{},modalRadius:e})})]})]})]}):(0,s.jsx)(`div`,{className:`flex items-center justify-center flex-1 text-foreground/40 py-16`,children:(0,s.jsx)(t.W,{className:`w-6 h-6 animate-spin text-accent`})})]})]}),(0,s.jsx)(me,{isOpen:!!S,title:S?.title||``,message:S?.message||``,confirmText:`Reset`,cancelText:`Keep it`,isProcessing:v,onCancel:()=>C(null),onConfirm:()=>{S?.apply(),C(null)}})]})}function Nr({tone:e,title:t,message:n,action:r}){let i=e===`red`?`border-red-500/20`:`border-amber-500/25`,a=e===`red`?`bg-red-500/5`:`bg-amber-500/5`,o=e===`red`?`text-red-500`:`text-amber-500`;return(0,s.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 min-h-[60vh] animate-in fade-in duration-500`,children:(0,s.jsxs)(`div`,{className:`glass-panel p-8 md:p-10 rounded-3xl border ${i} text-center shadow-xl max-w-sm w-full relative overflow-hidden`,children:[(0,s.jsx)(`div`,{className:`absolute inset-0 ${a}`}),(0,s.jsx)(`h2`,{className:`text-2xl font-black ${o} mb-3 relative z-10 tracking-tight`,children:t}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/70 font-medium leading-relaxed relative z-10 mb-6`,children:n}),(0,s.jsx)(`div`,{className:`relative z-10`,children:r})]})})}var Pr=`w-full block py-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground text-[14px] font-bold rounded-xl transition-colors`,Fr=`No access`,Ir=`You do not have access to view this page. If you think you should, ask whoever runs this app.`,Lr=()=>(0,s.jsx)(Nr,{tone:`amber`,title:Fr,message:Ir,action:(0,s.jsx)(c.Link,{to:`/dashboard`,className:Pr,children:`Back to dashboard`})}),Rr=Lr,zr=Lr,Br={route:`/page_1`,pageName:`New Page`,pageTitle:`My New Page`,template:`none`,form:``},Vr={tabName:`New Page`,iconName:``,route:`/new-page`,tabTitle:`Your Page`,template:`none`,form:``},Hr={tabName:`New Admin Page`,iconName:``,route:`/new-admin-page`,tabTitle:`Admin Page`,template:`none`,form:``},Ur={tabName:`New Team Page`,iconName:``,route:`/new-team-page`,tabTitle:`Team Page`,template:`none`,form:``},Wr=[{id:`home`,title:`Home`,path:`/`,type:`public`,isSystem:!0,enabled:!0},{id:`contact`,title:`Contact`,path:`/contact`,type:`public`,isSystem:!0,enabled:!0},{id:`guide`,title:`Guide`,path:`/guide`,type:`public`,isSystem:!0,enabled:!0},{id:`templates`,title:`Templates`,path:`/templates`,type:`public`,isSystem:!0,enabled:!0},{id:`support`,title:`Support`,path:`/support`,type:`user`,isSystem:!0,enabled:!0}],Gr=e=>[...e,...Wr.filter(t=>!e.some(e=>e.id===t.id))],Kr={public:`Anyone`,user:`Signed-in users`,internal:`Your team`,admin:`Admins only`},qr=e=>e.draft?`draft`:e.hidden?`hidden`:`live`,Jr={draft:`Draft`,live:`Live`,hidden:`Hidden`},Yr={draft:`Nothing is saved yet. Give it a web address and the page is created.`,live:`This page is live at its web address and listed in the menu.`,hidden:`This page still exists at its web address, but it is out of the menu.`},Xr=e=>(e||``).trim().toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9_-]/g,``),Zr=(e,t,n,r)=>{let i=e.findIndex(e=>e.id===t);if(i===-1)return null;let a=r&&e[0]?.id===r?1:0,o=n===`up`?Math.max(a,i-1):Math.min(e.length-1,i+1);if(o===i||o<a)return null;let s=[...e],[c]=s.splice(i,1);return s.splice(o,0,c),s},Qr=()=>Object.fromEntries(N()),$r=(e,t=!1)=>{let n={};for(let[r,i]of Object.entries(Qr())){let a=!!i.isPublic;if(a!==e)continue;let o=i.config||{};!t&&o.enabled===!1||(n[r]={id:r,title:a?o.pageName||o.pageTitle||o.title||r:o.tabName||o.tabTitle||o.title||r,path:o.route?o.route.startsWith(`/`)?o.route:`/`+o.route:`/`+r,type:a?`public`:E(o.pageType),isSystem:!1,enabled:o.enabled!==!1,fromFile:!0})}return n};function ei({value:e,onChange:n,busy:r}){return(0,s.jsx)(`div`,{className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,s.jsx)(t.a,{compact:!0,portal:!0,direction:`auto`,className:`console-select`,ariaLabel:`Who can open this page`,value:e,disabled:r,onChange:e=>n(e),options:v.map(e=>({value:e,label:Kr[e]}))})})}var ti=`Add it here — its web address, a name, and what you would like to see on it — then copy the sentence for your assistant.`,ni=`Add it here, then copy the sentence for your assistant.`,ri=[{value:`none`,label:`From scratch`},{value:`board`,label:`Board`},{value:`table`,label:`Table`},{value:`calendar`,label:`Calendar`},{value:`drive`,label:`Files`}],ii=[`board`,`table`,`calendar`,`drive`],ai={board:{is:`a board`,keeps:`its board frame and the card editor that is already in it`,open:`actions.openInlineEditor(columnId)`},table:{is:`a table`,keeps:`its table frame and the row and column controls that are already in it`,open:`actions.addRow()`},calendar:{is:`a calendar`,keeps:`its calendar frame — the month heading, Today, and the arrows — and the add-event form that is already in it`,open:`actions.openAddModal()`},drive:{is:`a file library`,keeps:`its file frame and the upload box that is already in it`,open:`openUploadModal()`}},oi=e=>{let t=ai[e];return t?`This page already works as ${t.is} and it stays one: it keeps ${t.keeps}, already styled to match my app. Design only what fills it, and open the one that is already there with ${t.open}. Never build your own add, edit or upload form on this page — one exists, and yours will not match.`:``},si=e=>(e||``).split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``),ci=(e,t)=>t?.contentKey||t?.tabName||t?.pageName||t?.pageId||e.title,li=(e,t)=>`src/your-ai-workflow-firebase-os/microcomponents/${si(ci(e,t))||`Page`}Content.tsx`,ui=(e,t)=>{let n=String(t?.route||``).trim();return n?n.startsWith(`/`)?n:`/`+n:e.path||``},di=(e,t)=>ui(e,t).replace(/^\/+/,``)?String(t?.brief||``).trim()?Mi(t)?`Say what the form should ask for, and this sentence is ready to copy.`:``:`Say what you would like to see on this page, and this sentence is ready to copy.`:`Give this page a web address and it will be created — then this sentence is ready to copy.`,fi=e=>{let t=String(e?.imageUrl||``).trim();return t?`Use this picture of mine on the page: ${t} — put it where it works best in your design, keep its proportions, and give it a short description for screen readers. Do not swap it for a placeholder or a picture of your own.`:``},pi=e=>{let t=String(e?.pageAdd||``).trim(),n=String(e?.pageChange||``).trim(),r=String(e?.pageRemove||``).trim(),i=fi(e),a=[];return t&&a.push(`Add this: ${t}`),n&&a.push(`Change this: ${n}`),r&&a.push(`Take this off the page: ${r}`),i&&a.push(i),a},mi=e=>pi(e).length>0,hi=(e,t)=>{let n=ui(e,t),r=String(t?.tabName||t?.pageName||``).trim(),i=r===`New page`?``:r,a=String(t?.template||``),o=String(t?.form||``).trim(),s=String(t?.brief||``).trim(),c=String(t?.formButton||``).trim(),l=String(t?.formSpot||``).trim();String(t?.formFields||``).trim();let u=t?.pageType?`private`:`public`,d=si(ci(e,t))||`Page`,f=d.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toLowerCase(),p=[`My app already has a page${i?` called ${i}`:``} at ${n}. It is already made and it is already in the menu — do not create a page, a web address or a settings file for it, and do not edit any other file.`,`Write one file: ${li(e,t)}, with a default export. That file is what the page shows.`,`Then add two lines to src/your-ai-workflow-firebase-os/microcomponents/registry.ts so the app loads your file: import ${d}Content from './${d}Content'; and registerMicrocomponent('${f}', ${d}Content); — registerMicrocomponent is imported there from 'your-ai-workflow-firebase-os'. Never remove another page's lines from that file.`,`Make it match the rest of my app: style with the app’s own theme styles so it looks right in light and dark. Do not pick your own colors. Build it from the app’s own pieces — import { SectionHeading, Card, Button } from 'your-ai-workflow-firebase-os': section titles are SectionHeading, boxed sections are Card, buttons are Button — so nothing gets a look of its own. The design should be minimal, modern and clean and match the app.`,`Everything below the page heading is yours to design however you like — one clean column of sections using the full width. Never stack panels inside panels, never let sections overlap, and when the content grows tall let the page scroll.`];ii.includes(a)&&p.push(oi(a)),o===`__new__`||t?.formIsNew?p.push(...gi(t,u)):o&&p.push(`Show my form ${ki(o)} on it with <ContactPopup formId='${o}' /> — never write a form by hand.`),o&&c&&p.push(`The form opens from a button that says ${c} — make that button part of the page's design, not an afterthought.`),o&&l&&p.push(`Where the form belongs on the page: ${l}`);let m=fi(t);return m&&p.push(m),p.push(`Here is what I would like on it: ${s||`___`}`),p.join(`
|
|
44
|
-
`)},
|
|
45
|
-
`)},
|
|
46
|
-
`)},
|
|
47
|
-
`)};function Pi({page:e,config:t,forms:n,saving:i,onSave:a,addressTaken:o,actions:c,footer:l,isNew:u,editing:d}){let f=e.type===`public`,p=f?`pageName`:`tabName`,m=f?`pageTitle`:`tabTitle`,[h,g]=(0,r.useState)(()=>({...t||{}})),[_,v]=(0,r.useState)(``),y=(e,t)=>g(n=>({...n,[e]:t})),b=e=>{g(t=>({...t,...e}));let n={...t||{},...h,...e};delete n._uiKey,a(n)},x=e=>{(t||{})[e]!==h[e]&&b({[e]:h[e]})},S=String(h.route??``).replace(/^\/+/,``),C=()=>{let n=Xr(S);if(!n){v(`Give this page a web address, for example pricing`);return}if(o(e.id,n)){v(`Another page already lives at this address. Pick a different one.`);return}v(``),n===String(t?.route??``).replace(/^\/+/,``)?y(`route`,`/`+n):b({route:`/`+n})},w=Xr(S),T={...t||{},...h,route:w?`/`+w:``,contentKey:t?.contentKey||w||void 0},E=String(h.form??``),D=!!h.formIsNew||E===`__new__`,[O]=(0,r.useState)(()=>!!String(t?.form??``).trim()),k=!!d&&O&&!!E,A=D&&!k;return(0,s.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,s.jsx)(we,{label:`Web address`,hint:u?`Where this page lives, e.g. /photos. The page is created as soon as you fill this in.`:`Where this page lives, e.g. /photos`,prefix:`/`,value:S,onChange:e=>{y(`route`,e),_&&v(``)},onBlur:C,error:_,placeholder:`photos`}),(0,s.jsx)(we,{label:f?`Name in the menu`:`Name in the dashboard`,hint:f?`What visitors see in the site menu.`:`What people see in the dashboard menu.`,value:h[p]??``,onChange:e=>y(p,e),onBlur:()=>x(p),placeholder:`Photos`}),(0,s.jsx)(we,{label:`Page heading`,hint:`The big heading people read at the top of the page.`,value:h[m]??``,onChange:e=>y(m,e),onBlur:()=>x(m),placeholder:`Our photos`}),!f&&(0,s.jsx)(Ve,{label:`Icon`,hint:`Shown next to the name in the dashboard menu.`,value:h.iconName??``,onChange:e=>b({iconName:e})}),!f&&!d&&(0,s.jsx)(Ee,{label:`Starting layout`,hint:`What the page starts as. Your assistant fills in the rest when you ask.`,value:ri.some(e=>e.value===h.template)?h.template:`none`,onChange:e=>b({template:e}),options:ri,allowEmpty:!1}),!k&&(0,s.jsx)(Ee,{label:`Form`,hint:`Answers arrive in your Inbox. Your assistant builds it with the page.`,value:D?`__new__`:E,onChange:e=>b(e===`__new__`?{form:`__new__`}:{form:e,formIsNew:!1}),options:[{value:`__new__`,label:`A new form made for this page`},...n.map(e=>({value:e,label:ki(e)}))],placeholder:`No form`}),A&&(0,s.jsx)(Te,{label:`What should the form ask?`,hint:`The questions in your own words — e.g. name, email, budget, what they need.`,value:h.formFields??``,onChange:e=>y(`formFields`,e),onBlur:()=>x(`formFields`),rows:2,placeholder:`Name, email, and what they would like to book`}),(A||!d&&!!E)&&(0,s.jsx)(we,{label:`The button that opens it`,hint:`What the button that opens the form says.`,value:h.formButton??``,onChange:e=>y(`formButton`,e),onBlur:()=>x(`formButton`),placeholder:`Get in touch`}),(A||!d&&!!E)&&(0,s.jsx)(we,{label:`Where the form goes`,hint:`Optional — where on the page it belongs, in your own words.`,value:h.formSpot??``,onChange:e=>y(`formSpot`,e),onBlur:()=>x(`formSpot`),placeholder:`At the bottom, after the packages`}),k&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Te,{label:`Change the form`,hint:`Say what should change about the form, then copy the sentence below.`,value:h.formChange??``,onChange:e=>y(`formChange`,e),onBlur:()=>x(`formChange`),rows:2,placeholder:`Add a phone number question after the email one`}),(0,s.jsx)(He,{compact:!0,title:`Copy this to change the form`,prompt:Ni(e,T),locked:!String(h.formChange??``).trim()})]}),d?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Te,{label:`What would you like to add?`,hint:`Anything new for the page. Leave it empty if nothing is missing.`,value:h.pageAdd??``,onChange:e=>y(`pageAdd`,e),onBlur:()=>x(`pageAdd`),rows:2,placeholder:`A section with three reviews from my customers.`}),(0,s.jsx)(Te,{label:`What would you like to change?`,hint:`Your assistant edits the page you have — anything you do not mention stays.`,value:h.pageChange??``,onChange:e=>y(`pageChange`,e),onBlur:()=>x(`pageChange`),rows:2,placeholder:`Show the albums three to a row, and put a search box above them.`}),(0,s.jsx)(Te,{label:`What would you like to remove?`,hint:`Anything the page should stop showing.`,value:h.pageRemove??``,onChange:e=>y(`pageRemove`,e),onBlur:()=>x(`pageRemove`),rows:2,placeholder:`The prices — I would rather people ask.`}),f&&(0,s.jsx)(Ue,{label:`A picture for this page`,hint:`Optional — a picture for your assistant to use on the page.`,value:h.imageUrl??``,onChange:e=>b({imageUrl:e}),tips:We}),!!String(h.brief??``).trim()&&(0,s.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] px-4 py-3`,children:[(0,s.jsx)(`p`,{className:`text-[11px] font-bold uppercase tracking-widest text-foreground/40 mb-1.5`,children:`What this page was built from`}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed whitespace-pre-line break-words [overflow-wrap:anywhere]`,children:String(h.brief)})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Te,{label:`What would you like to see on this page?`,hint:`What your assistant builds — it goes into the sentence below.`,value:h.brief??``,onChange:e=>y(`brief`,e),onBlur:()=>x(`brief`),rows:4,placeholder:`A photo gallery where I can upload pictures, put them in albums and open one full screen.`}),f&&(0,s.jsx)(Ue,{label:`A picture for this page`,hint:`Optional — a picture for your assistant to use on the page.`,value:h.imageUrl??``,onChange:e=>b({imageUrl:e}),tips:We})]}),l?.(T,{definingForm:A}),(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-[var(--panel-border)]/60`,children:[(0,s.jsx)(ke,{saving:i}),(0,s.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 ml-auto`,children:c})]})]})}function Fi({page:e,answers:t,saving:n,onSave:i}){let[a,o]=(0,r.useState)(()=>({...t||{}})),c=(e,t)=>o(n=>({...n,[e]:t})),l=e=>{(t||{})[e]!==a[e]&&i({[e]:a[e]})},u={...t||{},...a},d=yi[e.id],f=!mi(u);return(0,s.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,s.jsx)(Te,{label:`What would you like to add?`,hint:`Anything new for the page. Leave it empty if nothing is missing.`,value:a.pageAdd??``,onChange:e=>c(`pageAdd`,e),onBlur:()=>l(`pageAdd`),rows:2,placeholder:`A button that says Get in touch, opening my contact form.`}),(0,s.jsx)(Te,{label:`What would you like to change?`,hint:`In your own words. Everything you do not mention stays as it is.`,value:a.pageChange??``,onChange:e=>c(`pageChange`,e),onBlur:()=>l(`pageChange`),rows:2,placeholder:`The big heading should say Bright Studio.`}),(0,s.jsx)(Te,{label:`What would you like to remove?`,hint:`Anything the page should stop showing.`,value:a.pageRemove??``,onChange:e=>c(`pageRemove`,e),onBlur:()=>l(`pageRemove`),rows:2,placeholder:`The middle section — it repeats the heading.`}),e.type===`public`&&(0,s.jsx)(Ue,{label:`A picture for this page`,hint:`Optional — a picture for your assistant to use on the page.`,value:a.imageUrl??``,onChange:e=>{c(`imageUrl`,e),i({imageUrl:e})},tips:We}),(0,s.jsx)(He,{compact:!0,title:d.title,prompt:bi(e.id,u),locked:f}),(0,s.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,s.jsx)(ke,{saving:n})})]})}function Ii(){let{userRole:e}=ee(),n=(0,c.useLocation)(),[a,o]=(0,r.useState)(()=>{try{if(typeof window<`u`){let e=localStorage.getItem(`fbos_swr_pages`);if(e)return Gr(JSON.parse(e))}}catch{}return Wr}),[l,u]=(0,r.useState)(()=>{try{return sessionStorage.getItem(`fbos_pages_expandedId`)||null}catch{return null}}),d=(0,r.useRef)(l),[f,p]=(0,r.useState)(null),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(()=>{try{if(typeof window<`u`){let e=localStorage.getItem(`fbos_swr_page_configs`);if(e)return JSON.parse(e)}}catch{}return{}}),[v,y]=(0,r.useState)({}),[b,x]=(0,r.useState)(()=>{try{let e=localStorage.getItem(`fbos_swr_page_briefs`);if(e)return JSON.parse(e)}catch{}return{}}),S=(0,r.useRef)(b);(0,r.useEffect)(()=>{S.current=b},[b]),(0,r.useEffect)(()=>(0,i.onSnapshot)((0,i.doc)(t.Vt,`sys_configs`,`page_briefs`),e=>{let t=e.exists()?e.data():{};x(t);try{localStorage.setItem(`fbos_swr_page_briefs`,JSON.stringify(t))}catch{}},()=>{}),[]);let C=async(e,n)=>{let r={...S.current[e]||{},...n};x(t=>({...t,[e]:r})),y(t=>({...t,[e]:!0}));try{await(0,i.setDoc)((0,i.doc)(t.Vt,`sys_configs`,`page_briefs`),{[e]:r},{merge:!0})}catch(e){console.error(`Could not save the page answers`,e)}y(t=>({...t,[e]:!1}))},[w,T]=(0,r.useState)({}),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),[j,M]=(0,r.useState)(!1),N=(0,r.useRef)(null);(0,r.useEffect)(()=>{function e(e){N.current&&!N.current.contains(e.target)&&h(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let[P,F]=(0,r.useState)(new Set),[I,L]=(0,r.useState)(new Set),[R,z]=(0,r.useState)([]),[B,V]=(0,r.useState)([]),te=e=>(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden,...e.removed?{removed:!0}:{}});(0,r.useEffect)(()=>{let e=(0,i.onSnapshot)((0,i.doc)(t.Vt,`sys_configs`,`page_order`),e=>{let t=te(e.exists()&&e.data().order||[]);z(t),F(new Set(t.filter(e=>e.hidden).map(e=>e.id)))}),n=(0,i.onSnapshot)((0,i.doc)(t.Vt,`sys_configs`,`tab_order`),e=>{let t=te(e.exists()&&e.data().order||[]);V(t),L(new Set(t.filter(e=>e.hidden).map(e=>e.id)))});return()=>{e(),n()}},[]),(0,r.useEffect)(()=>{let e=n.pathname.split(`/pages/`)[1]?.split(`/`)[0];e&&!l&&a.some(t=>t.id===e)&&u(e)},[n.pathname,a]),(0,r.useEffect)(()=>{d.current=l;try{l?sessionStorage.setItem(`fbos_pages_expandedId`,l):sessionStorage.removeItem(`fbos_pages_expandedId`)}catch{}},[l]);let H=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=H.current;if(!e)return;try{let t=sessionStorage.getItem(`fbos_pages_scrollY`);t&&(e.scrollTop=parseInt(t,10))}catch{}let t=()=>{try{sessionStorage.setItem(`fbos_pages_scrollY`,String(e.scrollTop))}catch{}};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,r.useEffect)(()=>{(async()=>{try{let[e,n]=await Promise.all([(0,i.getDocs)((0,i.collection)(t.Vt,`sys_pages`)),(0,i.getDocs)((0,i.collection)(t.Vt,`sys_tabs`))]),r=[`home`,`drive`,`assets`,`contact`,`guide`,`templates`,`support`,`theme`,`page_order`,`tab_order`],a=[],s={};e.forEach(e=>{if(!r.includes(e.id)){let t=e.data();a.push({id:e.id,title:t.pageName||t.title||e.id,path:t.route||`/`+e.id,type:`public`,isSystem:!1,enabled:t.enabled!==!1}),s[e.id]=t}}),n.forEach(e=>{if(!r.includes(e.id)){let t=e.data(),n=E(t.pageType);a.push({id:e.id,title:t.tabName||t.title||e.id,path:t.route||`/`+e.id,type:n,isSystem:!1,enabled:t.enabled!==!1}),s[e.id]=t}});let c=Qr(),l={...$r(!0,!0),...$r(!1,!0)};for(let[e,t]of Object.entries(l)){if(s[e])continue;let n=a.find(e=>e.path===t.path);if(n){n.fromFile=!0;continue}a.push(t),s[e]=c[e]?.config||{}}o(e=>{let t=Gr(e.filter(e=>(e.isSystem||e.id.startsWith(`draft_`))&&e.id!==`drive`)),n=a.filter(e=>!t.some(t=>t.id===e.id)),r=[...t,...n];return typeof window<`u`&&localStorage.setItem(`fbos_swr_pages`,JSON.stringify(r)),r}),_(e=>{let t={...e,...s};return typeof window<`u`&&localStorage.setItem(`fbos_swr_page_configs`,JSON.stringify(t)),t})}catch(e){console.error(`Error loading custom pages`,e)}})()},[]);let[U,W]=(0,r.useState)([`contact`]),[G,K]=(0,r.useState)([`support`]);(0,r.useEffect)(()=>{let e=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},n={...t.u,...e},r=new Set([`contact`]),a=new Set([`support`]);Object.entries(n).forEach(([e,t])=>{t.formType===`private`?a.add(t.systemName||e):r.add(t.systemName||e)}),(0,i.getDocs)((0,i.collection)(t.Vt,`sys_forms`)).then(e=>{e.docs.forEach(e=>{e.data().formType===`private`?a.add(e.id):r.add(e.id)}),W(Array.from(r)),K(Array.from(a))}).catch(e=>{console.warn(`Failed fetching sys_forms in PagesAdmin:`,e),W(Array.from(r)),K(Array.from(a))})},[]);let q=async(e,n,r)=>{if(n.route&&!n.route.startsWith(`/`)&&(n.route=`/`+n.route),!String(n.route||``).replace(/^\/+/,``).trim()){_(t=>({...t,[e]:n}));return}let s=a.find(t=>t.id===e),c=r||s?.type||n.pageType||(e.startsWith(`pub_`)?`public`:void 0),l=c===`public`?`sys_pages`:`sys_tabs`;c&&c!==`public`?n.pageType=c:delete n.pageType;let f=Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0)),p=n.route?n.route.replace(/^\/+/,``).replace(/[^a-zA-Z0-9_-]/g,`_`).toLowerCase():e;f.contentKey||=p,n={...n,contentKey:f.contentKey},f.form===`__new__`&&(f.form=Ai(f),f.formIsNew=!0,n={...n,form:f.form,formIsNew:!0}),y(t=>({...t,[e]:!0,[p]:!0}));try{if(p!==e&&p.trim()!==``&&p!==`draft`){try{let{deleteDoc:n}=await import(`firebase/firestore`);await n((0,i.doc)(t.Vt,l,e))}catch{}await(0,i.setDoc)((0,i.doc)(t.Vt,l,p),f),o(t=>t.map(t=>t.id===e?{...t,id:p,_uiKey:t._uiKey||e,path:n.route,title:n.pageName||n.tabName||n.title||t.title}:t)),d.current===e&&(u(p),window.history.replaceState(null,``,`/pages/${p}`)),_(t=>{let r={...t};return r[p]=n,delete r[e],r});let r=c===`public`,a=r?`page_order`:`tab_order`,s=r?R:B;if(!s.some(e=>e.id===p)){let n=[...s.filter(t=>t.id!==e),{id:p,hidden:!1}];try{await(0,i.setDoc)((0,i.doc)(t.Vt,`sys_configs`,a),{order:n})}catch(e){console.error(`Failed to update tab order:`,e)}}}else await(0,i.setDoc)((0,i.doc)(t.Vt,l,e),f),_(t=>({...t,[e]:n})),o(t=>t.map(t=>t.id===e?{...t,path:n.route||t.path,title:n.pageName||n.tabName||n.title||t.title}:t))}catch(t){console.error(`Failed to save ${e} config:`,t)}finally{setTimeout(()=>{y(t=>({...t,[e]:!1,[p]:!1}))},500)}},J=e=>{let t=`draft_`+Math.floor(Math.random()*1e5),n={id:t,title:`New page`,path:``,type:e,isSystem:!1,enabled:!0},r=e===`public`?{route:``,pageName:``,pageTitle:``,form:``,formFields:``,formButton:``,formSpot:``,brief:``}:{route:``,tabName:``,tabTitle:``,iconName:``,template:`none`,form:``,formFields:``,formButton:``,formSpot:``,brief:``,pageType:e};o(e=>[...e,n]),_(e=>({...e,[t]:r})),u(t),h(!1),setTimeout(()=>{document.getElementById(`page-${t}`)?.scrollIntoView?.({behavior:`smooth`,block:`center`})},100)},Y=e=>e.id.startsWith(`draft_`);if(e!==`admin`)return(0,s.jsx)(`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,s.jsx)(Lr,{})});let ne=async(e,n,r)=>{let s=r===`public`,c=s?`page_order`:`tab_order`,l=s?R:B,u=(s?P:I).has(e);o(a.map(t=>t.id===e?{...t,enabled:u}:t));let d=[...l],f=d.findIndex(t=>t.id===e);f===-1?d.push({id:e,hidden:!0}):d[f]={...d[f],hidden:!u},await(0,i.setDoc)((0,i.doc)(t.Vt,`sys_configs`,c),{order:d})},re=e=>!!e.fromFile&&(e.type===`public`?R:B).some(t=>t.id===e.id&&t.removed),ie=async(e,n)=>{if(e.type===n)return;let r=e.type;o(t=>t.map(t=>t.id===e.id?{...t,type:n}:t)),y(t=>({...t,[e.id]:!0}));let a=Si(g[e.id],n);try{await(0,i.setDoc)((0,i.doc)(t.Vt,`sys_tabs`,e.id),a,{merge:!0}),_(t=>t[e.id]?{...t,[e.id]:{...t[e.id],pageType:n}}:t)}catch(t){console.error(`Failed to change the audience of ${e.id}:`,t),o(t=>t.map(t=>t.id===e.id?{...t,type:r}:t))}finally{y(t=>({...t,[e.id]:!1}))}},ae=(e,t)=>{if(!t){if(Y({id:e})){o(t=>t.filter(t=>t.id!==e)),_(t=>{let n={...t};return delete n[e],n}),l===e&&u(null);return}O(e)}},oe=async()=>{if(D){M(!0);try{let{deleteDoc:e,collection:n,getDocs:r,doc:i,getDoc:s,query:c,where:d}=await import(`firebase/firestore`),{ref:f,deleteObject:p}=await import(`firebase/storage`),m=a.find(e=>e.id===D),h=m?.type===`public`?`sys_pages`:`sys_tabs`;if(h===`sys_tabs`&&m){let a=g[D];if(!a)try{let e=await s(i(t.Vt,`sys_tabs`,D));e.exists()&&(a=e.data())}catch{}let o=(a?.tabName||a?.pageId||D).toLowerCase().replace(/[^a-z0-9]+/g,`_`),l=[`admin_${o}_records`,`mem_${o}_records`,`user_${o}_records`],u={[`admin_${o}_records`]:{prefix:`admin_files`,driveCollection:`admin_files`},[`mem_${o}_records`]:{prefix:`mem_files`,driveCollection:`mem_files`},[`user_${o}_records`]:{prefix:`user_files`,driveCollection:`user_files`}},m=[];for(let i of l)m.push((async()=>{try{let a=await r(n(t.Vt,i)),o=u[i],s=[];for(let i of a.docs){let a=i.data();a.recordType===`file`&&a.downloadURL&&o&&s.push((async()=>{try{let i=`${o.prefix}%2F`,s=a.downloadURL.split(i)[1]?.split(`?`)[0];s&&await p(f(t.Ut,`${o.prefix}/${decodeURIComponent(s)}`)).catch(()=>{});let l=await r(c(n(t.Vt,o.driveCollection),d(`downloadURL`,`==`,a.downloadURL)));await Promise.all(l.docs.map(t=>e(t.ref)))}catch(e){console.error(`Error deleting storage file:`,e)}})())}await Promise.all(s),await Promise.all(a.docs.map(t=>e(t.ref)));try{localStorage.removeItem(`fbos_records_${i}`)}catch{}}catch(e){console.error(`Error cleaning up collection ${i}:`,e)}})());for(let i of[`admin_files`,`mem_files`,`user_files`])m.push((async()=>{try{let a=await r(c(n(t.Vt,i),d(`sourceTab`,`==`,o)));await Promise.all(a.docs.map(async n=>{let r=n.data();if(r.downloadURL)try{let e=`${i}%2F`,n=r.downloadURL.split(e)[1]?.split(`?`)[0];n&&await p(f(t.Ut,`${i}/${decodeURIComponent(n)}`)).catch(()=>{})}catch{}await e(n.ref)}))}catch{}})());await Promise.all(m)}await e(i(t.Vt,h,D));let _=h===`sys_pages`?`page_order`:`tab_order`,v=h===`sys_pages`?R:B,{setDoc:y}=await import(`firebase/firestore`),b=m?.fromFile?[...v.filter(e=>e.id!==D),{id:D,hidden:!0,removed:!0}]:v.filter(e=>e.id!==D);await y(i(t.Vt,`sys_configs`,_),{order:b}),o(e=>e.filter(e=>e.id!==D)),l===D&&u(null)}catch(e){console.error(`Error deleting page:`,e)}M(!1),O(null)}},X=async(e,n)=>{if(e.isSystem)return;let r=e.type===`public`,o=r?`page_order`:`tab_order`,s=[...r?R:B];a.filter(e=>e.type===`public`===r&&!e.isSystem&&!s.some(t=>t.id===e.id)).forEach(e=>s.push({id:e.id,hidden:!1}));let c=Zr(s,e.id,n,r?`home`:void 0);if(c){r?z(c):V(c);try{await(0,i.setDoc)((0,i.doc)(t.Vt,`sys_configs`,o),{order:c})}catch(e){console.error(`Failed to reorder pages:`,e)}}},ce=(e,t)=>{let n=t.replace(/[^a-zA-Z0-9_-]/g,`_`).toLowerCase();return a.some(r=>{if(r.id===e)return!1;let i=String(g[r.id]?.route??r.path??``).replace(/^\/+/,``).toLowerCase();return i!==``&&i===t||r.id===n})},Z=e=>e===`admin`?Hr:e===`internal`?Ur:e===`public`?Br:Vr,ue=async()=>{let e=a.find(e=>e.id===k);if(!e){A(null);return}T(t=>({...t,[e.id]:!0}));let t=g[e.id]||{};await q(e.id,{...Z(e.type),...t.contentKey?{contentKey:t.contentKey}:{},...t.brief?{brief:t.brief}:{}}),T(t=>({...t,[e.id]:!1})),A(null)},de=[{id:`public`,title:`Anyone`,icon:t.nt,description:`On your website and in the site menu — open to everyone, signed in or not.`,filter:e=>e.type===`public`},{id:`user`,title:`Signed-in users`,icon:t.U,description:`In the dashboard for every signed-in person — each sees only their own.`,filter:e=>e.type===`user`},{id:`internal`,title:`Your team`,icon:t.ot,description:`In the dashboard for admins and your team — invisible to everyone else.`,filter:e=>e.type===`internal`},{id:`admin`,title:`Admins only`,icon:t.O,description:`In the dashboard, for admins alone.`,filter:e=>e.type===`admin`}];return(0,s.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,s.jsx)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:`Your Pages`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/pages`]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(`div`,{className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 sm:gap-6 mb-4 pb-3 md:mb-6 md:pb-6 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 md:px-10 md:pt-10`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`p`,{className:`hidden md:block text-[14px] font-medium text-foreground/60 leading-relaxed max-w-3xl`,children:`Add a page here, say what you would like on it, and copy the sentence it writes into your assistant's chat. Renaming, reordering, hiding and deleting all happen right here.`}),(0,s.jsx)(`p`,{className:`md:hidden text-[13px] font-semibold text-foreground/60`,children:`Your pages`})]}),(0,s.jsx)(`div`,{className:`relative z-50 shrink-0 flex items-center gap-1`,children:(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(t.o,{variant:`secondary`,onClick:()=>h(!m),className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-foreground/5 rounded-xl flex items-center justify-center shrink-0 transition-colors group cursor-pointer`,title:`Add a page`,children:(0,s.jsx)(t.F,{className:`w-4 h-4 text-foreground/60 group-hover:text-foreground transition-colors`})}),(0,s.jsx)(t.f,{children:m&&(0,s.jsxs)(t.d.div,{ref:N,initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:`absolute top-full mt-2 right-0 w-56 glass-popover border border-[var(--panel-border)] rounded-2xl p-2 z-50 flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`px-3 pt-1 pb-2 text-[10px] font-bold uppercase tracking-widest text-foreground/40`,children:`Add a page for`}),[`public`,`user`,`internal`,`admin`].map(e=>(0,s.jsx)(`button`,{onClick:()=>J(e),className:`text-left px-3 py-2 text-[13px] font-bold text-foreground/70 hover:text-foreground hover:bg-foreground/5 rounded-lg transition-colors cursor-pointer`,children:Kr[e]},e))]})})]})})]}),(0,s.jsx)(`div`,{ref:H,className:`px-4 sm:px-6 md:px-10 pb-6 md:pb-10 flex flex-col pt-6 sm:pt-7 md:pt-9 gap-4 overflow-y-auto relative min-h-[400px]`,children:de.map((e,n)=>{let r=a.filter(e.filter).filter(e=>!re(e)),i=e.id===`public`?R:B,o=r.sort((e,t)=>{if(e.id===`home`)return-1;if(t.id===`home`)return 1;let n=i.findIndex(t=>t.id===e.id),r=i.findIndex(e=>e.id===t.id);return n===-1&&r===-1?0:n===-1?1:r===-1?-1:n-r}),d=e.icon,m=e=>e.type===`public`?P.has(e.id):I.has(e.id),h=o.filter(e=>!m(e)),_=o.filter(e=>m(e)),y=(n,r)=>{let i=n.isSystem?yi[n.id]:void 0,a=l===n.id,o=Y(n),d=qr({draft:o,hidden:r}),m=!n.isSystem||!!i,h=!n.isSystem&&!o,_=a&&f===n.id,y=e=>{u(n.id),p(e===`edit`?n.id:null),window.history.replaceState(null,``,`/pages/${n.id}`)},x=o?`Not saved yet — give it a web address`:n.type===`public`?`In the site menu`:`In the dashboard`;return(0,s.jsxs)(`div`,{id:`page-${n.id}`,onClick:()=>{m&&(a?(u(null),p(null),window.history.replaceState(null,``,`/pages`)):y(`settings`))},className:`group flex flex-col py-3 px-3 sm:py-4 sm:px-5 glass-panel border transition-all rounded-2xl hover:shadow-sm ${m?`cursor-pointer hover:border-accent/40`:``} ${r?`opacity-60 bg-foreground/[0.01] border-[var(--panel-border)]/50`:`border-transparent hover:border-[var(--panel-border)]`}`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between w-full gap-2 sm:gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-start gap-2 flex-1 min-w-0`,children:[!n.isSystem&&!o&&(0,s.jsxs)(`div`,{className:`flex flex-col shrink-0 pt-0.5`,onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(`button`,{type:`button`,title:`Move up`,"aria-label":`Move ${n.title} up`,onClick:()=>X(n,`up`),className:Ci,children:(0,s.jsx)(t.yt,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`button`,{type:`button`,title:`Move down`,"aria-label":`Move ${n.title} down`,onClick:()=>X(n,`down`),className:Ci,children:(0,s.jsx)(t.St,{className:`w-3.5 h-3.5`})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,s.jsx)(`h3`,{className:`text-[14.5px] font-bold text-foreground tracking-tight truncate`,children:n.title}),!n.isSystem&&(0,s.jsx)(Di,{status:d}),n.fromFile&&(0,s.jsxs)(`span`,{className:wi,title:`Your assistant wrote this one as a file. Delete hides it and gives you the sentence that removes its files.`,children:[(0,s.jsx)(t.at,{className:`w-3 h-3`}),` Written as a file`]})]}),(0,s.jsxs)(`span`,{className:`text-[12px] font-medium text-foreground/45 truncate`,children:[x,n.path&&(0,s.jsxs)(s.Fragment,{children:[` · `,(0,s.jsx)(c.Link,{to:n.path,onClick:e=>e.stopPropagation(),className:`underline decoration-foreground/20 underline-offset-2 hover:text-accent hover:decoration-accent transition-colors`,title:`Open this page`,children:Oi(n.path)})]})]})]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2 shrink-0`,children:[n.type!==`public`&&!o&&(0,s.jsx)(`div`,{className:`hidden sm:block`,children:(0,s.jsx)(ei,{value:n.type,busy:v[n.id],onChange:e=>ie(n,e)})}),h&&(0,s.jsx)(Q,{icon:t._,title:`Edit this page with your assistant`,className:_?`text-accent border-accent/40 bg-accent/10`:``,onClick:e=>{e.stopPropagation(),y(_?`settings`:`edit`)},children:(0,s.jsx)(`span`,{className:`hidden md:inline`,children:`Edit with AI`})}),n.id!==`home`&&!o&&(0,s.jsx)(Q,{icon:r?t.ot:t.st,title:r?`Show this page`:`Hide this page`,onClick:e=>{e.stopPropagation(),ne(n.id,n.isSystem,n.type)},children:(0,s.jsx)(`span`,{className:`hidden md:inline`,children:r?`Show`:`Hide`})}),m?(0,s.jsx)(`div`,{className:`p-1.5 transition-transform duration-300 text-foreground/40 shrink-0 ${a?`rotate-180`:``}`,children:(0,s.jsx)(t.St,{className:`w-3.5 h-3.5`})}):(0,s.jsx)(`div`,{className:`w-[24px] shrink-0`})]})]}),(0,s.jsxs)(t.f,{children:[a&&i&&(0,s.jsx)(t.d.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50 pb-1`,onClick:e=>e.stopPropagation(),children:(0,s.jsx)(Fi,{page:n,answers:b[n.id],saving:v[n.id],onSave:e=>C(n.id,e)},n.id)}),a&&!n.isSystem&&g[n.id]&&(0,s.jsxs)(t.d.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50 pb-1`,onClick:e=>e.stopPropagation(),children:[n.type!==`public`&&!o&&(0,s.jsxs)(`div`,{className:`sm:hidden flex items-center justify-between gap-3 mb-5`,children:[(0,s.jsx)(`span`,{className:`text-[12px] font-semibold text-foreground/55`,children:`Who can open this page`}),(0,s.jsx)(ei,{value:n.type,busy:v[n.id],onChange:e=>ie(n,e)})]}),(0,s.jsx)(Pi,{page:n,config:g[n.id],forms:n.type===`public`?U:G,saving:v[n.id],isNew:o,editing:_,onSave:e=>q(n.id,e),addressTaken:ce,footer:(e,{definingForm:t})=>_?(0,s.jsx)(He,{compact:!0,title:`Copy this to change the page`,prompt:vi(n,e,t),locked:!!_i(e,t)}):(0,s.jsx)(He,{compact:!0,title:`Then copy this into your assistant’s chat`,description:h?`This one builds the page from scratch. If it has been built already, switch to Edit with AI so your assistant changes it instead of starting over.`:void 0,prompt:hi(n,e),locked:!!di(n,e)}),actions:(0,s.jsxs)(s.Fragment,{children:[!n.fromFile&&xi(g[n.id],Z(n.type))&&(0,s.jsx)(Q,{icon:t.N,tone:`danger`,busy:w[n.id],onClick:()=>A(n.id),children:`Reset`}),!n.isSystem&&(0,s.jsx)(Q,{icon:t.T,tone:`danger`,onClick:()=>ae(n.id,n.isSystem),children:`Delete`})]})},n._uiKey||n.id)]})]})]},`${e.id}-${n._uiKey||n.id}`)};return(0,s.jsx)(t.d.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col relative`,children:(0,s.jsx)(Se,{icon:d,title:e.title,description:e.description,children:o.length===0?(0,s.jsxs)(`div`,{className:`flex flex-col items-start sm:flex-row sm:items-center gap-3 rounded-2xl border border-dashed border-[var(--panel-border)] px-5 py-4`,children:[(0,s.jsx)(Q,{icon:t.F,onClick:()=>J(e.id),children:`Add a page`}),(0,s.jsxs)(`p`,{className:`text-[12.5px] text-foreground/55 font-medium leading-relaxed`,children:[(0,s.jsx)(`span`,{className:`sm:hidden`,children:ni}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:ti})]})]}):(0,s.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h.map(e=>y(e,!1)),(0,s.jsx)(`div`,{className:`flex items-center rounded-2xl border border-dashed border-[var(--panel-border)] px-5 py-3`,children:(0,s.jsx)(Q,{icon:t.F,onClick:()=>J(e.id),children:`Add a page`})}),_.length>0&&(0,s.jsxs)(`details`,{className:`mt-4 group/details`,children:[(0,s.jsxs)(`summary`,{className:`text-[11px] font-bold uppercase tracking-wider text-foreground/40 cursor-pointer list-none flex items-center gap-2 select-none hover:text-foreground/70 transition-colors w-fit pb-1 ml-1 outline-none`,children:[(0,s.jsx)(t.St,{className:`w-3.5 h-3.5 group-open/details:-rotate-180 transition-transform`}),`Hidden pages (`,_.length,`)`]}),(0,s.jsx)(`div`,{className:`flex flex-col gap-4 mt-4`,children:_.map(e=>y(e,!0))})]})]})})},e.id)})})]})]}),(0,s.jsx)(me,{isOpen:!!D,onCancel:()=>O(null),onConfirm:oe,title:`Delete this page?`,message:`The page and everything saved on it will be gone for good. This cannot be undone.`,confirmText:`Delete page`,isProcessing:j}),(0,s.jsx)(me,{isOpen:!!k,onCancel:()=>A(null),onConfirm:ue,title:`Reset this page?`,message:`Its name, heading, web address, icon and form go back to how they started. What people have saved on the page is kept.`,confirmText:`Reset page`,isProcessing:!!k&&!!w[k]})]})}var Li=new Set([`contact`,`support`]),Ri=[{value:`text`,label:`Short text`},{value:`textarea`,label:`Long text`},{value:`email`,label:`Email`},{value:`tel`,label:`Phone`},{value:`number`,label:`Number`},{value:`date`,label:`Date`},{value:`currency`,label:`Money`},{value:`checkbox`,label:`Yes-no`},{value:`select`,label:`Choose one`}],zi={age:`Age`},Bi=e=>Ri.find(t=>t.value===e)?.label||zi[e||``]||`Short text`,Vi=e=>Ri.some(t=>t.value===e)||!e?Ri:[...Ri,{value:e,label:Bi(e)}],Hi={public:`Anyone`,private:`Signed-in users`},Ui=e=>(e||``).toLowerCase().trim().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``),Wi=(e,t)=>{if(!t.includes(e))return e;let n=2;for(;t.includes(`${e}_${n}`);)n++;return`${e}_${n}`},Gi=(e,t,n)=>{if(!(!e.name||e.name===Ui(e.label||``)))return e.name;let r=Ui(t);return r?Wi(r,n.filter(t=>t!==e).map(e=>e.name)):``},Ki=()=>({name:``,type:`text`,label:``,placeholder:``,required:!1}),qi={firstForm:`Forms are made with their pages — add a page on the Pages screen and pick A new form made for this page. Every form then shows up here.`,forPage:(e,t)=>`Use the form called ${e||t} (its id is ${t}) on the page I name — show it with <ContactPopup formId='${t}' />. Do not create a form, do not change this form's fields, do not write a form by hand.`};function Ji({choices:e,onChange:n}){return(0,s.jsx)(Ce,{label:`Choices`,hint:`The options people pick from.`,children:(0,s.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.length===0&&(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/40 font-medium px-1`,children:`No choices yet — add the first one.`}),e.map((r,i)=>(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`input`,{type:`text`,value:r,"aria-label":`Choice ${i+1}`,placeholder:`e.g. Under 1,000`,onChange:t=>n(e.map((e,n)=>n===i?t.target.value:e)),className:_e}),(0,s.jsx)(Q,{icon:t.g,tone:`danger`,title:`Remove choice ${i+1}`,onClick:()=>n(e.filter((e,t)=>t!==i)),children:`Remove`})]},i)),(0,s.jsx)(`div`,{children:(0,s.jsx)(Q,{icon:t.F,onClick:()=>n([...e,``]),children:`Add choice`})})]})})}function Yi(){let{userRole:e}=ee(),n=(0,c.useNavigate)(),a=t.zt(),o=()=>{let e=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},n={...t.u,contact:a?.defaultConfigs?.contactForm||t.u.contact,support:a?.defaultConfigs?.supportForm||t.u.support};for(let[t,r]of Object.entries(e))n[t]=r;return n},[l,u]=(0,r.useState)(()=>{try{if(typeof window<`u`){let e=localStorage.getItem(`fbos_swr_forms`);if(e)return JSON.parse(e)}let e={...t.u,contact:a?.defaultConfigs?.contactForm||t.u.contact,support:a?.defaultConfigs?.supportForm||t.u.support},n=(typeof window<`u`?window.__FBOS_FORMS__:null)||{};for(let[t,r]of Object.entries(n))e[t]=r;let r={};for(let[t,n]of Object.entries(e)){let e=JSON.parse(JSON.stringify(n));e._uiKey=Math.random().toString(36).substring(7),r[t]=e}return r}catch{return{}}}),[d,f]=(0,r.useState)(()=>!(typeof window<`u`&&localStorage.getItem(`fbos_swr_forms`))),[p,m]=(0,r.useState)({}),[h,g]=(0,r.useState)(null),[_,v]=(0,r.useState)(new Set),[y,b]=(0,r.useState)({}),[x,S]=(0,r.useState)(null),[C,w]=(0,r.useState)(!1),[T,E]=(0,r.useState)({}),D=(0,r.useRef)({}),O=(e,t)=>{D.current={...D.current,[e]:t},E(D.current)};(0,r.useEffect)(()=>{k()},[]);let k=async()=>{try{f(!0);let e=await(0,i.getDocs)((0,i.collection)(t.Vt,`sys_forms`)),n={},r=new Set;e.forEach(e=>{if(e.id!==`pubForm`&&e.id!==`userForm`){let t=e.data();t._uiKey=l[e.id]?._uiKey||t._uiKey||Math.random().toString(36).substring(7),n[e.id]=t,r.add(e.id)}}),v(r);try{await(0,i.deleteDoc)((0,i.doc)(t.Vt,`sys_forms`,`pubForm`)),await(0,i.deleteDoc)((0,i.doc)(t.Vt,`sys_forms`,`userForm`))}catch{}let a=o();for(let[e,t]of Object.entries(a))if(!n[e]){let r={...t};r._uiKey=l[e]?._uiKey||Math.random().toString(36).substring(7),n[e]=r}else if(n[e]._uiKey=l[e]?._uiKey||n[e]._uiKey||Math.random().toString(36).substring(7),!n[e].fields||n[e].fields.length===0){let t=a[e];n[e].fields=t.fields||[]}let s={};for(let e of Object.keys(a))n[e]&&(s[e]=n[e]);for(let e of Object.keys(n))s[e]||(s[e]=n[e]);let c=window.location.pathname.split(`/forms/`)[1]?.split(`/`)[0];c&&s[c]&&b({[c]:!0}),D.current={},E({}),u(s),typeof window<`u`&&localStorage.setItem(`fbos_swr_forms`,JSON.stringify(s))}catch(e){console.error(`Failed to load forms:`,e)}finally{f(!1)}},A=async(e,n)=>{let r={...n};l[e]?._uiKey&&(r._uiKey=l[e]._uiKey),delete r.submitPage,e===`contact`?(r.systemName=`contact`,r.formType=`public`):e===`support`&&(r.systemName=`support`,r.formType=`private`);let a=r.systemName||e;if(a!==e&&a.trim()!==``){u(t=>{let n={};for(let i of Object.keys(t))i===e?n[a]=r:n[i]=t[i];return n}),y[e]&&b(t=>{let n={};for(let r of Object.keys(t))r===e?n[a]=t[r]:n[r]=t[r];return n}),m(e=>({...e,[a]:!0}));try{await(0,i.setDoc)((0,i.doc)(t.Vt,`sys_forms`,a),r),await(0,i.deleteDoc)((0,i.doc)(t.Vt,`sys_forms`,e)),localStorage.setItem(`fbos_custom_form_${a}`,`true`),localStorage.removeItem(`fbos_custom_form_${e}`),localStorage.setItem(`fbos_form_${a}`,JSON.stringify(r)),localStorage.removeItem(`fbos_form_${e}`)}catch(e){console.error(`Failed to migrate form map ID:`,e)}finally{setTimeout(()=>{m(e=>({...e,[a]:!1}))},500)}}else{u(t=>({...t,[e]:r})),m(t=>({...t,[e]:!0}));try{await(0,i.setDoc)((0,i.doc)(t.Vt,`sys_forms`,e),r),localStorage.setItem(`fbos_custom_form_${e}`,`true`),localStorage.setItem(`fbos_form_${e}`,JSON.stringify(r))}catch(e){console.error(`Failed to save form:`,e)}finally{setTimeout(()=>{m(t=>({...t,[e]:!1}))},500)}}},j=(e,t,n)=>O(e,{...t,...n}),M=(e,t,n)=>{let r={...t,...n};O(e,r),A(e,r)},N=e=>{let t=D.current[e];t&&A(e,t)},P=(e,t,n)=>M(e,t,{fields:n}),F=async e=>{if(!Li.has(e)){w(!0);try{await(0,i.deleteDoc)((0,i.doc)(t.Vt,`sys_forms`,e)),u(t=>{let n={...t};return delete n[e],n}),n(`/forms`)}catch(e){console.error(`Failed to delete form`,e)}finally{w(!1),S(null)}}},I=async e=>{if(!_.has(e)){S(null);return}w(!0);let n=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},r=Li.has(e)||!!n[e]||!!a?.defaultConfigs?.[e]||!!a?.defaultConfigs?.[`${e}Form`];try{r?(m(t=>({...t,[e]:!0})),await(0,i.deleteDoc)((0,i.doc)(t.Vt,`sys_forms`,e)),localStorage.removeItem(`fbos_form_${e}`),localStorage.removeItem(`fbos_custom_form_${e}`),await k(),setTimeout(()=>m(t=>({...t,[e]:!1})),500)):await A(e,o().contact||o().support)}catch(e){console.error(`Reset failed:`,e)}finally{w(!1),S(null)}};if(e!==`admin`)return(0,s.jsx)(`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,s.jsx)(Lr,{})});let L=e=>{b(t=>{let n={...t,[e]:!t[e]};if(n[e])window.history.replaceState(null,``,`/forms/${e}`);else{let e=Object.keys(n).filter(e=>n[e]);e.length>0?window.history.replaceState(null,``,`/forms/${e[0]}`):window.history.replaceState(null,``,`/forms`)}return n})},R=Object.keys(y).find(e=>y[e]),z=(e,n,r,i,a)=>{let o=(t,r)=>{let o=a.map((e,n)=>n===i?{...e,...t}:e);r?P(e,n,o):j(e,n,{fields:o})},c=t=>{let r=i+t;if(r<0||r>=a.length)return;let o=[...a];[o[i],o[r]]=[o[r],o[i]],P(e,n,o)},l=r.type!==`checkbox`&&r.type!==`select`&&r.type!==`date`;return(0,s.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] p-4 sm:p-5 flex flex-col gap-5`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,s.jsxs)(`span`,{className:`text-[13px] font-bold text-foreground`,children:[`Question `,i+1,` `,(0,s.jsxs)(`span`,{className:`text-foreground/40 font-medium`,children:[`· `,Bi(r.type)]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,s.jsx)(Q,{icon:t.Ot,disabled:i===0,title:`Move up`,onClick:()=>c(-1),children:`Up`}),(0,s.jsx)(Q,{icon:t.Mt,disabled:i===a.length-1,title:`Move down`,onClick:()=>c(1),children:`Down`}),(0,s.jsx)(Q,{icon:t.T,tone:`danger`,title:`Remove question ${i+1}`,onClick:()=>P(e,n,a.filter((e,t)=>t!==i)),children:`Remove`})]})]}),(0,s.jsx)(we,{label:`Question`,hint:`What you are asking for, in the words the person will read.`,value:r.label||``,placeholder:`e.g. What is your budget?`,onChange:e=>o({label:e,name:Gi(r,e,a)},!1),onBlur:()=>N(e)}),(0,s.jsx)(Ee,{label:`Kind of answer`,hint:`Sets the box people type into and what counts as a valid answer.`,value:r.type||`text`,options:Vi(r.type),allowEmpty:!1,onChange:e=>o(e===`select`?{type:e,options:r.options||[]}:{type:e},!0)}),(0,s.jsx)(De,{label:`Required`,hint:`On means the form cannot be sent until this is answered.`,enabled:!!r.required,onChange:e=>o({required:e},!0)}),r.type===`select`&&(0,s.jsx)(Ji,{choices:r.options||[],onChange:e=>o({options:e},!0)}),r.type===`currency`&&(0,s.jsx)(we,{label:`Currency symbol`,hint:`Shown inside the box, before the amount.`,value:r.currencySymbol||``,placeholder:`$`,onChange:e=>o({currencySymbol:e},!1),onBlur:()=>N(e)}),l&&(0,s.jsx)(we,{label:`Example answer`,hint:`Faint grey text inside the box, to show people what you expect.`,value:r.placeholder||``,placeholder:`e.g. jane@example.com`,onChange:e=>o({placeholder:e},!1),onBlur:()=>N(e)})]},i)},B=(e,n)=>{let r=T[e]||n,i=Li.has(e),a=r.formType||`public`,o=r.fields||[],c=_.has(e);return(0,s.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,s.jsxs)(Se,{icon:t.S,title:`Basics`,description:`What people see at the top of this form and on its button.`,children:[(0,s.jsx)(we,{label:`Form name`,hint:`The heading at the top of the form.`,value:r.title||``,placeholder:`e.g. Get in touch`,onChange:t=>j(e,r,{title:t}),onBlur:()=>N(e)}),(0,s.jsx)(we,{label:`Button text`,hint:`The words on the button that sends the form.`,value:r.buttonName||r.submitText||``,placeholder:`e.g. Send message`,onChange:t=>j(e,r,{buttonName:t,submitText:t}),onBlur:()=>N(e)})]}),(0,s.jsx)(Se,{icon:t.y,title:`Who it is for`,description:`Who can fill this in, and where their answers land.`,children:(0,s.jsx)(Ee,{label:`Who it is for`,hint:`Who can fill this in follows the page this form was made for, so it cannot change here. Changing it after answers arrive would file new answers under the wrong list in your Inbox.`,value:a,allowEmpty:!1,disabled:!0,options:[{value:`public`,label:`Anyone`},{value:`private`,label:`Signed-in users`}],onChange:t=>M(e,r,{formType:t})})}),(0,s.jsx)(Se,{icon:t.j,title:`After sending`,description:`What happens the moment someone sends this form.`,children:(0,s.jsx)(we,{label:`Where to send them next`,hint:`Leave this empty to show a thank-you message instead. Or give a web address, like /pricing, to take them there.`,value:r.redirectTo||``,placeholder:`/pricing`,onChange:t=>j(e,r,{redirectTo:t}),onBlur:()=>N(e)})}),(0,s.jsxs)(Se,{icon:t.G,title:`Questions`,description:`Everything this form asks for, in the order people answer it.`,actions:(0,s.jsx)(Q,{icon:t.F,onClick:()=>P(e,r,[...o,Ki()]),children:`Add question`}),children:[o.length===0?(0,s.jsx)(`p`,{className:`text-[12.5px] text-foreground/55 font-medium leading-relaxed`,children:`No questions yet. Add the first one with the button above.`}):o.map((t,n)=>z(e,r,t,n,o)),o.length>0&&(0,s.jsx)(`div`,{className:`flex justify-start`,children:(0,s.jsx)(Q,{icon:t.F,onClick:()=>P(e,r,[...o,Ki()]),children:`Add question`})})]}),(c||!i)&&(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[c&&(0,s.jsx)(Q,{icon:t.N,tone:`danger`,onClick:()=>S({kind:`reset`,id:e}),children:`Reset this form`}),!i&&(0,s.jsx)(Q,{icon:t.T,tone:`danger`,onClick:()=>S({kind:`delete`,id:e}),children:`Delete this form`})]}),(0,s.jsx)(He,{compact:!0,title:`Ask your assistant to put this form on a page`,prompt:qi.forPage(r.title||``,e)})]})};return(0,s.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,s.jsx)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:`Forms`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/forms`,R?`/${R}`:``]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(`div`,{className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,s.jsx)(`div`,{className:`flex items-start justify-between gap-3 sm:gap-6 mb-6 pb-6 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0 px-4 pt-5 sm:px-6 sm:pt-6 md:px-10 md:pt-10 bg-background/50`,children:(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-lg md:text-xl font-extrabold text-foreground tracking-tight`,children:`Your forms`}),(0,s.jsx)(`p`,{className:`hidden md:block text-[14px] font-medium text-foreground/60 mt-2 leading-relaxed`,children:`Look a form over and touch it up — its name, button text and questions. New forms are made on the Pages screen, with their page. Answers arrive in your Inbox.`})]})}),(0,s.jsx)(`div`,{className:`p-6 md:p-8 flex flex-col gap-4 overflow-y-auto`,children:Object.keys(l).length===0&&!d?(0,s.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 p-10 glass-panel rounded-3xl border border-[var(--panel-border)] border-dashed`,children:[(0,s.jsx)(t.P,{className:`w-6 h-6 text-foreground/40`}),(0,s.jsx)(`p`,{className:`text-[13px] font-bold text-foreground/60`,children:`You have no forms yet.`}),(0,s.jsx)(`p`,{className:`text-[12.5px] text-foreground/55 font-medium leading-relaxed text-center max-w-md`,children:qi.firstForm})]})}):(0,s.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,s.jsx)(t.f,{children:Object.entries(l).map(([e,n])=>{let r=T[e]||n,i=y[e],a=p[e],o=(r.fields||[]).length;return(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},transition:{duration:.35,ease:`easeOut`},onClick:()=>L(e),className:`group flex flex-col p-3 px-4 glass-panel border transition-all rounded-2xl hover:shadow-sm cursor-pointer hover:border-accent/40 ${i?`border-[var(--panel-border)] bg-background/50`:`border-transparent hover:border-[var(--panel-border)]`} flex-shrink-0 ${r.enabled===!1?`opacity-40 grayscale bg-foreground/[0.01] border-[var(--panel-border)]/50`:``}`,children:[(0,s.jsxs)(`div`,{className:`flex flex-row items-center justify-between w-full gap-2`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1 pr-2 sm:pr-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`h3`,{className:`text-[14px] font-bold text-foreground break-words ml-1 leading-snug`,children:r.title||`Untitled form`}),a&&(0,s.jsx)(t.W,{className:`w-3 h-3 animate-spin text-accent ml-2 shrink-0`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5 ml-1`,children:[(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold px-2.5 py-[3px] rounded-full border shrink-0 ${r.formType===`private`?`text-blue-500 border-blue-500/25 bg-blue-500/[0.07]`:`text-emerald-500 border-emerald-500/25 bg-emerald-500/[0.07]`}`,children:[(0,s.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${r.formType===`private`?`bg-blue-500`:`bg-emerald-500`}`}),Hi[r.formType||`public`]]}),(0,s.jsx)(`span`,{className:`text-[11px] font-medium text-foreground/45`,children:o===1?`1 question`:`${o} questions`})]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,s.jsx)(Q,{icon:t.ot,title:`Preview this form`,onClick:e=>{e.stopPropagation(),g(r)},children:(0,s.jsx)(`span`,{className:`hidden md:inline`,children:`Preview`})}),(0,s.jsx)(`div`,{className:`p-1.5 transition-transform duration-300 text-foreground/40 ${i?`rotate-180`:``}`,children:(0,s.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,s.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})})]})]}),(0,s.jsx)(t.f,{children:i&&(0,s.jsx)(t.d.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50`,onClick:e=>e.stopPropagation(),children:B(e,n)})})]},n._uiKey||e)})}),d&&(0,s.jsxs)(`div`,{className:`flex items-center justify-center gap-3 p-6 glass-panel rounded-2xl border border-[var(--panel-border)]/40 bg-foreground/[0.01] mt-2 animate-pulse`,children:[(0,s.jsx)(t.W,{className:`w-4 h-4 animate-spin text-accent`}),(0,s.jsx)(`span`,{className:`text-[12px] font-bold text-foreground/50 tracking-wider uppercase select-none`,children:`Loading your forms`})]})]})})]})]}),(0,s.jsx)(me,{isOpen:!!x,onCancel:()=>S(null),onConfirm:()=>{x&&(x.kind===`delete`?F(x.id):I(x.id))},title:x?.kind===`reset`?`Reset this form`:`Delete this form`,message:x?.kind===`reset`?`Undo every change made to ${l[x.id]?.title||x.id} and put it back the way it shipped. Answers already collected are kept.`:`Permanently delete ${x?l[x.id]?.title||x.id:``}. This cannot be undone. Answers already collected are kept.`,confirmText:x?.kind===`reset`?`Reset form`:`Delete form`,isProcessing:C}),h&&(0,s.jsx)(t.t,{formConfig:h,onClose:()=>g(null)})]})}var Xi=`src/your-ai-workflow-firebase-os`;function Zi(){let e=new Set;for(let[t,n]of N()){let r=n?.config?.route,i=typeof r==`string`&&r.trim()?r.startsWith(`/`)?r:`/`+r:`/`+t.toLowerCase();e.add(i)}return[...e].sort()}var Qi=e=>(e||``).split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``);function $i(e){let t=e?.contentKey||e?.tabName||e?.pageName||e?.pageId||`Page`;return`${Xi}/microcomponents/${Qi(String(t))||`Page`}Content.tsx`}function ea(e,t){let n=t.replace(/^.*\//,``).replace(/\.tsx$/,``),r=n.replace(/Content$/,``).replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toLowerCase();return[`My app has a page at ${e} and it is still empty after you said it was done. The ONLY thing that fills this page is one file: ${t}, with a default export, registered in ${Xi}/microcomponents/registry.ts.`,`Check these in order and fix whatever is wrong, without asking me questions:`,`1. The file exists at exactly that path and name — not another folder, not another spelling. If you put it somewhere else, move it there.`,`2. It has a default export. A named-only export is silently ignored.`,`3. ${Xi}/microcomponents/registry.ts contains these two lines: import ${n} from './${n}'; and registerMicrocomponent('${r}', ${n}); — registerMicrocomponent is imported there from 'your-ai-workflow-firebase-os'. Add them if they are missing, and never remove another page's lines.`,`4. You created nothing else for this page — no config file, no route, no page, and no edit to src/App.tsx or src/main.tsx. Undo any of those you made.`,`Then tell me, in one sentence, which of these was wrong.`].join(`
|
|
48
|
-
`)}function
|
|
49
|
-
`)}function na({config:e,customContent:n}){let{config:i}=t.Lt(),{userRole:a}=ee();return(0,r.useEffect)(()=>{document.title=e.pageName||e.pageTitle||i.appName||`Your AI Firebase`},[e.pageName,e.pageTitle,i.appName]),(0,s.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 relative min-h-screen`,children:[(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,s.jsx)(se,{children:e.pageTitle||e.pageName||`New Page`}),e.route&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]}),(0,s.jsx)(`div`,{className:`flex justify-between items-center mb-6 pt-2 border-b border-[var(--panel-border)] pb-6 relative z-20 overflow-x-auto no-scrollbar gap-4`,children:(0,s.jsxs)(`button`,{onClick:()=>window.history.back(),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 cursor-pointer shadow-sm text-foreground/70 whitespace-nowrap shrink-0`,children:[(0,s.jsx)(t.jt,{className:`w-4 h-4`}),` Go Back`]})}),(0,s.jsx)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl shadow-2xl relative flex flex-col flex-1 bg-background/50 h-full min-h-[400px]`,children:n?(0,s.jsx)(`div`,{className:`fbos-content-slot flex-1 p-4 md:p-8`,children:(0,s.jsx)(n,{config:e})}):e.form?(0,s.jsx)(`div`,{className:`fbos-content-slot flex-1 flex flex-col items-center justify-start p-4 md:p-8`,children:(0,s.jsx)(t.t,{isInline:!0,formId:e.form})}):(0,s.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center m-4 md:m-8 gap-6`,children:[(0,s.jsxs)(`div`,{className:`w-full glass-panel border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-16 text-center opacity-70`,children:[(0,s.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/70`,children:`This page is empty`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 max-w-sm leading-relaxed mx-auto`,children:`Open the Pages screen, say what you would like on it, and copy the sentence there into your assistant's chat.`})]}),C(a)&&(0,s.jsx)(`div`,{className:`w-full max-w-lg`,children:(0,s.jsx)(He,{compact:!0,title:`Already asked, and it is still empty? Paste this`,prompt:ea(e.route||`/`,$i(e))})})]})})]})}function ra({config:e,customContent:n}){let{user:a}=ee(),{config:c}=t.Lt(),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(!0),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(``),[v,y]=(0,r.useState)(``),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(null),w=(0,r.useRef)(null),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),j=e=>{if(A(e),e){let t=e.fileType||``;P(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},M=k,[N,P]=(0,r.useState)(!0),[F,I]=(0,r.useState)(!1),[L,R]=(0,r.useState)(null),[z,B]=(0,r.useState)(``),[V,te]=(0,r.useState)(``),[H,U]=(0,r.useState)([]),W=(0,r.useRef)(null),G=`user_${(e.tabName||e.pageId||`user_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`)}_records`;(0,r.useEffect)(()=>{document.title=e.tabTitle||e.tabName||c.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,c.appName]),(0,r.useEffect)(()=>{if(!a)return;try{let e=localStorage.getItem(`fbos_records_${G}`);e?(d(JSON.parse(e)),p(!1)):p(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}}),n=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Vt,G),(0,i.where)(`uid`,`==`,a.uid),(0,i.limit)(150)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),d(n),p(!1),localStorage.setItem(`fbos_records_${G}`,JSON.stringify(n))},e=>{console.error(`Error fetching records:`,e),p(!1)});return()=>n()},[a,G]),(0,r.useEffect)(()=>{f||localStorage.setItem(`fbos_records_${G}`,JSON.stringify(u))},[u,f,G]);let K=async e=>{if(e.preventDefault(),!(!a||!g.trim())){x(!0);try{let e=await(0,i.addDoc)((0,i.collection)(t.Vt,G),{name:g.trim(),note:v.trim(),uid:a.uid,recordType:`record`,createdAt:(0,i.serverTimestamp)()});d(t=>[{id:e.id,name:g.trim(),note:v.trim(),uid:a.uid,recordType:`record`,createdAt:Date.now()},...t]),_(``),y(``),h(!1)}catch(e){console.error(`Error saving record:`,e)}x(!1)}},q=async e=>{let n=e.target.files?.[0];if(!(!n||!a)){E(!0);try{let e=`user_files/${`${Date.now()}_${n.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`,r=(0,o.ref)(t.Ut,e);await(0,o.uploadBytes)(r,n,{customMetadata:{ownerId:a.uid}});let s=await(0,o.getDownloadURL)(r);if(w.current)w.current(n,s,{uid:a.uid,storagePath:e});else{let e=await(0,i.addDoc)((0,i.collection)(t.Vt,G),{name:n.name,note:`${n.type||`File`} · ${ve(n.size)}`,uid:a.uid,recordType:`file`,fileName:n.name,fileType:n.type||`unknown`,fileSize:n.size,downloadURL:s,createdAt:(0,i.serverTimestamp)()});d(t=>[{id:e.id,name:n.name,note:`${n.type||`File`} · ${ve(n.size)}`,uid:a.uid,recordType:`file`,fileName:n.name,fileType:n.type,fileSize:n.size,downloadURL:s,createdAt:Date.now()},...t])}}catch(e){console.error(`Error uploading file:`,e)}E(!1),W.current&&(W.current.value=``)}},J=async()=>{if(D){I(!0);try{let e=u.find(e=>e.id===D);if(await(0,i.deleteDoc)((0,i.doc)(t.Vt,G,D)),e?.recordType===`file`&&e.downloadURL)try{let n=e.downloadURL.split(`user_files%2F`)[1]?.split(`?`)[0];n&&await(0,o.deleteObject)((0,o.ref)(t.Ut,`user_files/${decodeURIComponent(n)}`)).catch(()=>{})}catch(e){console.error(`Error cleaning up user file:`,e)}d(e=>e.filter(e=>e.id!==D)),O(null)}catch(e){console.error(`Error deleting record:`,e)}I(!1)}},[Y,ne]=(0,r.useState)(null),[re,ie]=(0,r.useState)(``),[ae,oe]=(0,r.useState)(!1),[X,ce]=(0,r.useState)(null),Z=(0,r.useRef)([]),ue=e=>{if(e.recordType===`file`){ne(e.id),ie(e.name);return}R(e.id),B(e.name),te(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));U(n),Z.current=n.map(e=>e.key)},de=async()=>{if(!Y||!re.trim()){ne(null);return}let e=u.find(e=>e.id===Y);if(e&&e.name===re.trim()){ne(null);return}oe(!0);try{await(0,i.updateDoc)((0,i.doc)(t.Vt,G,Y),{name:re.trim()}),d(e=>e.map(e=>e.id===Y?{...e,name:re.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}oe(!1),ne(null)},fe=async()=>{await pe(),R(null)},pe=async()=>{if(!L||!z.trim())return;x(!0);let e={};H.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let n=H.map(e=>e.key.trim()).filter(Boolean),r=Z.current.filter(e=>!n.includes(e));r.forEach(t=>{e[t]=(0,i.deleteField)()});try{await(0,i.updateDoc)((0,i.doc)(t.Vt,G,L),{name:z.trim(),note:V.trim(),...e}),d(e=>e.map(e=>{if(e.id!==L)return e;let t={...e,name:z.trim(),note:V.trim()};return r.forEach(e=>{delete t[e]}),H.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),Z.current=n}catch(e){console.error(`Error saving record:`,e)}x(!1)},he=(e,n)=>e?e.startsWith(`image/`)?n?(0,s.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${n})`}}):(0,s.jsx)(t.et,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,s.jsx)(t.v,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,s.jsx)(t.it,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,s.jsx)(t.Pt,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,s.jsx)(t.ft,{className:`w-4 h-4`}):(0,s.jsx)(t.rt,{className:`w-4 h-4`}):(0,s.jsx)(t.it,{className:`w-4 h-4`}),ge=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,_e=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},ve=e=>{if(!e)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]},ye=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},be=(()=>{let n=(e.buttonStorageIcon||`upload`).trim(),r=n.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return t.p[r]?t.p[r]:t.p[n]?t.p[n]:t.x||t.F})(),xe=e.buttonStyle!==`secondary`,Q=e.buttonStorageStyle===`primary`;return(0,s.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,s.jsx)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:e.tabTitle||e.tabName||`User Page`}),e.route&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,s.jsx)(`input`,{type:`file`,ref:W,onChange:q,className:`hidden`}),!n&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 sm:gap-4 p-4 sm:p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:f?`Loading…`:`${u.length} ${u.length===1?`item`:`items`}`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.storage!==!1&&(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(t.d.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>W.current?.click(),disabled:T,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${Q?`btn-primary`:`btn-secondary`}`,children:[T?(0,s.jsx)(t.W,{className:`w-4 h-4 animate-spin`}):(0,s.jsx)(be,{className:`w-4 h-4`}),e.buttonStorageText&&(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,s.jsx)(t.d.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${xe?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,s.jsx)(t.F,{className:`w-4 h-4`}):(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,s.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[f&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,s.jsx)(t.W,{className:`w-8 h-8 text-accent animate-spin`})}),n?(0,s.jsx)(`div`,{className:`fbos-content-slot`,children:(0,s.jsx)(n,{config:e,actions:{records:u,loading:f,collection:G,user:a,saveRecord:async e=>{let n={id:`temp_`+Date.now(),uid:a.uid,recordType:`record`,createdAt:Date.now(),...e};d(e=>[n,...e]),await(0,i.addDoc)((0,i.collection)(t.Vt,G),{uid:a.uid,recordType:`record`,createdAt:(0,i.serverTimestamp)(),...e})},updateRecord:async(e,n)=>{d(t=>t.map(t=>t.id===e?{...t,...n}:t)),await(0,i.updateDoc)((0,i.doc)(t.Vt,G,e),n)},deleteRecord:async e=>{await(0,i.deleteDoc)((0,i.doc)(t.Vt,G,e))},startEdit:e=>ue(e),confirmDelete:e=>O(e),uploadFile:()=>W.current?.click(),openAddForm:()=>h(!0),setAddForm:e=>C(()=>e),setFileHandler:e=>{w.current=e}}})}):(0,s.jsxs)(s.Fragment,{children:[!f&&u.length===0&&(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,s.jsx)(t.F,{className:`w-6 h-6 text-accent/40`})}),(0,s.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files to get started`})]}),!f&&u.length>0&&(0,s.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,s.jsx)(t.f,{children:u.map((e,n)=>{let r=L===e.id;return(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},transition:{delay:n*.03,duration:.25},onClick:()=>ue(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative cursor-pointer ${r?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,s.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),ce(e.id),setTimeout(()=>ce(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:X===e.id?(0,s.jsx)(t.Ct,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,s.jsx)(t.K,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,s.jsx)(t.lt,{className:`w-3.5 h-3.5`})})]}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ue(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,s.jsx)(t.I,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),O(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.T,{className:`w-3.5 h-3.5`})})]}),(0,s.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,s.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&j(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${ge(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?he(e.fileType,e.downloadURL):(0,s.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[Y===e.id?(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,value:re,onChange:e=>ie(e.target.value),onBlur:()=>de(),onKeyDown:e=>{e.key===`Enter`&&de(),e.key===`Escape`&&ne(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>j(e)}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:ye(e.createdAt)})]})]}),e.note&&(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,s.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e))]},e.id)})})})]})]})]})]}),(0,s.jsx)(t.f,{children:m&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.d.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.d.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:S?r.default.createElement(S,{onSave:async e=>{x(!0);try{await(0,i.addDoc)((0,i.collection)(t.Vt,G),{uid:a.uid,recordType:`record`,createdAt:(0,i.serverTimestamp)(),...e}),h(!1)}catch(e){console.error(`Error saving record:`,e)}x(!1)},onClose:()=>!b&&h(!1),saving:b}):(0,s.jsxs)(`form`,{onSubmit:K,className:`p-5 flex flex-col gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,s.jsx)(t.g,{className:`w-4 h-4`})})]}),(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,s.jsx)(t.o,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,l.createPortal)((0,s.jsx)(t.f,{children:M&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,s.jsx)(t.d.div,{onClick:()=>j(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,s.jsx)(`button`,{onClick:()=>j(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 outline-none`,children:(0,s.jsx)(t.g,{className:`w-5 h-5`})}),(0,s.jsxs)(t.d.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,s.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,s.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,s.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:M.fileName||M.name}),(0,s.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[_e(M.fileType),` • `,ve(M.fileSize||0)]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(M.downloadURL),ce(`preview`),setTimeout(()=>ce(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:X===`preview`?(0,s.jsx)(t.Ct,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.K,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),ne(M.id),ie(M.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,s.jsx)(t.I,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),O(M.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.T,{className:`w-4 h-4`})}),(0,s.jsx)(`a`,{href:M.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,s.jsx)(t.lt,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>j(null),children:(0,s.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[N&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,s.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,s.jsx)(t.W,{className:`w-5 h-5 text-accent animate-spin`})})}),M.fileType?.startsWith(`image/`)?(0,s.jsx)(`img`,{onLoad:()=>P(!1),onError:()=>P(!1),src:M.downloadURL,alt:M.fileName||M.name,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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType?.startsWith(`video/`)?(0,s.jsx)(`video`,{onLoadedData:()=>P(!1),onError:()=>P(!1),src:M.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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType===`application/pdf`?(0,s.jsx)(`iframe`,{onLoad:()=>P(!1),src:M.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${N?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,s.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(),P(!1)},children:[(0,s.jsx)(t.it,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,s.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,s.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,s.jsx)(t.f,{children:L&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.d.div,{onClick:()=>fe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.d.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,s.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,s.jsx)(t.W,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>fe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,s.jsx)(t.g,{className:`w-4 h-4`})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`input`,{autoFocus:!0,required:!0,value:z,onChange:e=>B(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>pe(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:V,onChange:e=>{te(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>pe(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),H.map((e,n)=>(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let t=[...H];t[n].key=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>pe(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,s.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let t=[...H];t[n].value=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>pe(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>U(H.filter((e,t)=>t!==n)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,s.jsx)(t.g,{className:`w-3 h-3`})})]},n)),(0,s.jsxs)(`button`,{type:`button`,onClick:()=>U([...H,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,s.jsx)(t.F,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,s.jsx)(me,{isOpen:!!D,onCancel:()=>O(null),onConfirm:J,title:`Delete Record`,message:(0,s.jsxs)(s.Fragment,{children:[`Are you sure you want to delete `,(0,s.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:u.find(e=>e.id===D)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:F})]})}function ia({config:e,customContent:n}){let{user:a}=ee(),{config:c}=t.Lt(),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(!0),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(``),[v,y]=(0,r.useState)(``),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(null),w=(0,r.useRef)(null),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),j=e=>{if(A(e),e){let t=e.fileType||``;P(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},M=k,[N,P]=(0,r.useState)(!0),[F,I]=(0,r.useState)(!1),[L,R]=(0,r.useState)(null),[z,B]=(0,r.useState)(``),[V,te]=(0,r.useState)(``),[H,U]=(0,r.useState)([]),W=(0,r.useRef)(null),[G,K]=(0,r.useState)(null),q=(0,r.useRef)([]),J=`admin_${(e.tabName||e.pageId||`admin_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`)}_records`;(0,r.useEffect)(()=>{document.title=e.tabTitle||e.tabName||c.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,c.appName]);let Y=()=>({name:a.displayName||a.email?.split(`@`)[0]||`Admin`,email:a.email||``,avatar:a.photoURL||``});(0,r.useEffect)(()=>{if(!a)return;try{let e=localStorage.getItem(`fbos_records_${J}`);e?(d(JSON.parse(e)),p(!1)):p(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}}),n=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Vt,J),(0,i.orderBy)(`createdAt`,`desc`),(0,i.limit)(150)),t=>{let n=e(t.docs);d(n),p(!1),localStorage.setItem(`fbos_records_${J}`,JSON.stringify(n))},n=>{console.error(`Error listening to admin records:`,n);let r=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Vt,J),(0,i.limit)(150)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),d(n),p(!1),localStorage.setItem(`fbos_records_${J}`,JSON.stringify(n))});return()=>r()});return()=>n()},[a,J]);let ne=async e=>{if(e.preventDefault(),!(!a||!g.trim())){x(!0);try{let e=Y();await(0,i.addDoc)((0,i.collection)(t.Vt,J),{name:g.trim(),note:v.trim(),uid:a.uid,recordType:`record`,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,i.serverTimestamp)()}),_(``),y(``),h(!1)}catch(e){console.error(`Error saving admin record:`,e)}x(!1)}},re=async e=>{let n=e.target.files?.[0];if(!(!n||!a)){E(!0);try{let e=`admin_files/${`${Date.now()}_${n.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`,r=(0,o.ref)(t.Ut,e);await(0,o.uploadBytes)(r,n,{customMetadata:{ownerId:a.uid}});let s=await(0,o.getDownloadURL)(r);if(w.current)w.current(n,s,{uid:a.uid,storagePath:e});else{let e=Y();await(0,i.addDoc)((0,i.collection)(t.Vt,J),{name:n.name,note:`${n.type||`File`} · ${ye(n.size)}`,uid:a.uid,recordType:`file`,fileName:n.name,fileType:n.type||`unknown`,fileSize:n.size,downloadURL:s,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,i.serverTimestamp)()})}}catch(e){console.error(`Error uploading admin file:`,e)}E(!1),W.current&&(W.current.value=``)}},ie=async()=>{if(D){I(!0);try{let e=u.find(e=>e.id===D);if(await(0,i.deleteDoc)((0,i.doc)(t.Vt,J,D)),e?.recordType===`file`&&e.downloadURL)try{let n=e.downloadURL.split(`admin_files%2F`)[1]?.split(`?`)[0];n&&await(0,o.deleteObject)((0,o.ref)(t.Ut,`admin_files/${decodeURIComponent(n)}`)).catch(()=>{})}catch(e){console.error(`Error cleaning up admin file:`,e)}O(null)}catch(e){console.error(`Error deleting admin record:`,e)}I(!1)}},[ae,oe]=(0,r.useState)(null),[X,ce]=(0,r.useState)(``),[Z,ue]=(0,r.useState)(!1),de=e=>{if(e.recordType===`file`){oe(e.id),ce(e.name);return}R(e.id),B(e.name),te(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));U(n),q.current=n.map(e=>e.key)},fe=async()=>{if(!ae||!X.trim()){oe(null);return}let e=u.find(e=>e.id===ae);if(e&&e.name===X.trim()){oe(null);return}ue(!0);try{await(0,i.updateDoc)((0,i.doc)(t.Vt,J,ae),{name:X.trim()}),d(e=>e.map(e=>e.id===ae?{...e,name:X.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}ue(!1),oe(null)},pe=async()=>{if(!L||!z.trim()){R(null);return}x(!0);let e={};H.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let n=H.map(e=>e.key.trim()).filter(Boolean),r=q.current.filter(e=>!n.includes(e));r.forEach(t=>{e[t]=(0,i.deleteField)()});try{await(0,i.updateDoc)((0,i.doc)(t.Vt,J,L),{name:z.trim(),note:V.trim(),...e}),d(e=>e.map(e=>{if(e.id!==L)return e;let t={...e,name:z.trim(),note:V.trim()};return r.forEach(e=>{delete t[e]}),H.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),q.current=n}catch(e){console.error(`Error updating record:`,e)}x(!1),R(null)},he=async()=>{if(!L||!z.trim())return;let e={};H.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let n=H.map(e=>e.key.trim()).filter(Boolean),r=q.current.filter(e=>!n.includes(e));r.forEach(t=>{e[t]=(0,i.deleteField)()});try{await(0,i.updateDoc)((0,i.doc)(t.Vt,J,L),{name:z.trim(),note:V.trim(),...e}),d(e=>e.map(e=>{if(e.id!==L)return e;let t={...e,name:z.trim(),note:V.trim()};return r.forEach(e=>{delete t[e]}),H.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),q.current=n}catch(e){console.error(`Error silently saving record:`,e)}},ge=(e,n)=>e?e.startsWith(`image/`)?n?(0,s.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${n})`}}):(0,s.jsx)(t.et,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,s.jsx)(t.v,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,s.jsx)(t.it,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,s.jsx)(t.Pt,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,s.jsx)(t.ft,{className:`w-4 h-4`}):(0,s.jsx)(t.rt,{className:`w-4 h-4`}):(0,s.jsx)(t.it,{className:`w-4 h-4`}),_e=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,ve=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},ye=e=>{if(!e)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]},be=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},xe=(()=>{let n=(e.buttonStorageIcon||`upload`).trim(),r=n.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return t.p[r]?t.p[r]:t.p[n]?t.p[n]:t.x||t.F})(),Q=e.buttonStyle!==`secondary`,Se=e.buttonStorageStyle===`primary`,Ce=e=>e.uid===a?.uid,we=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Admin`,n=e.creatorEmail||``,r=e.creatorAvatar||``,i=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[r?(0,s.jsx)(`img`,{src:r,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:i}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,s.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};return(0,s.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,s.jsx)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:e.tabTitle||e.tabName||`Admin Page`}),e.route&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,s.jsx)(`input`,{type:`file`,ref:W,onChange:re,className:`hidden`}),!n&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 sm:gap-4 p-4 sm:p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:f?`Loading…`:`${u.length} ${u.length===1?`item`:`items`}`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.storage!==!1&&(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(t.d.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>W.current?.click(),disabled:T,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${Se?`btn-primary`:`btn-secondary`}`,children:[T?(0,s.jsx)(t.W,{className:`w-4 h-4 animate-spin`}):(0,s.jsx)(xe,{className:`w-4 h-4`}),e.buttonStorageText&&(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,s.jsx)(t.d.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${Q?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,s.jsx)(t.F,{className:`w-4 h-4`}):(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,s.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[f&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,s.jsx)(t.W,{className:`w-8 h-8 text-accent animate-spin`})}),n?(0,s.jsx)(`div`,{className:`fbos-content-slot`,children:(0,s.jsx)(n,{config:e,actions:{records:u,loading:f,collection:J,user:a,saveRecord:async e=>{let n=Y(),r={id:`temp_`+Date.now(),uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:Date.now(),...e};d(e=>[r,...e]),await(0,i.addDoc)((0,i.collection)(t.Vt,J),{uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:(0,i.serverTimestamp)(),...e})},updateRecord:async(e,n)=>{d(t=>t.map(t=>t.id===e?{...t,...n}:t)),await(0,i.updateDoc)((0,i.doc)(t.Vt,J,e),n)},deleteRecord:async e=>{await(0,i.deleteDoc)((0,i.doc)(t.Vt,J,e))},startEdit:e=>de(e),confirmDelete:e=>O(e),uploadFile:()=>W.current?.click(),openAddForm:()=>h(!0),setAddForm:e=>C(()=>e),setFileHandler:e=>{w.current=e}}})}):(0,s.jsxs)(s.Fragment,{children:[!f&&u.length===0&&(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,s.jsx)(t.F,{className:`w-6 h-6 text-accent/40`})}),(0,s.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files. All admins can view and contribute.`})]}),!f&&u.length>0&&(0,s.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,s.jsx)(t.f,{children:u.map((e,n)=>{let r=L===e.id,i=Ce(e);return(0,s.jsxs)(t.d.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>de(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative cursor-pointer ${r?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,s.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),K(e.id),setTimeout(()=>K(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:G===e.id?(0,s.jsx)(t.Ct,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,s.jsx)(t.K,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,s.jsx)(t.lt,{className:`w-3.5 h-3.5`})})]}),i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,s.jsx)(t.I,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),O(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.T,{className:`w-3.5 h-3.5`})})]})]}),(0,s.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,s.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&j(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${_e(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?ge(e.fileType,e.downloadURL):(0,s.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[ae===e.id?(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,value:X,onChange:e=>ce(e.target.value),onBlur:()=>fe(),onKeyDown:e=>{e.key===`Enter`&&fe(),e.key===`Escape`&&oe(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>j(e)}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:be(e.createdAt)})]})]}),e.note&&(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,s.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,s.jsx)(we,{record:e})]},e.id)})})})]})]})]})]}),(0,s.jsx)(t.f,{children:m&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.d.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.d.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:S?r.default.createElement(S,{onSave:async e=>{x(!0);try{let n=Y();await(0,i.addDoc)((0,i.collection)(t.Vt,J),{uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:(0,i.serverTimestamp)(),...e}),h(!1)}catch(e){console.error(`Error saving record:`,e)}x(!1)},onClose:()=>!b&&h(!1),saving:b}):(0,s.jsxs)(`form`,{onSubmit:ne,className:`p-5 flex flex-col gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,s.jsx)(t.g,{className:`w-4 h-4`})})]}),(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,s.jsx)(t.o,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,l.createPortal)((0,s.jsx)(t.f,{children:M&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,s.jsx)(t.d.div,{onClick:()=>j(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,s.jsx)(`button`,{onClick:()=>j(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 outline-none`,children:(0,s.jsx)(t.g,{className:`w-5 h-5`})}),(0,s.jsxs)(t.d.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,s.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,s.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,s.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:M.fileName||M.name}),(0,s.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[ve(M.fileType),` • `,ye(M.fileSize||0)]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(M.downloadURL),K(`preview`),setTimeout(()=>K(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:G===`preview`?(0,s.jsx)(t.Ct,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.K,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),oe(M.id),ce(M.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,s.jsx)(t.I,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),O(M.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.T,{className:`w-4 h-4`})}),(0,s.jsx)(`a`,{href:M.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,s.jsx)(t.lt,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>j(null),children:(0,s.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[N&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,s.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,s.jsx)(t.W,{className:`w-5 h-5 text-accent animate-spin`})})}),M.fileType?.startsWith(`image/`)?(0,s.jsx)(`img`,{onLoad:()=>P(!1),onError:()=>P(!1),src:M.downloadURL,alt:M.fileName||M.name,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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType?.startsWith(`video/`)?(0,s.jsx)(`video`,{onLoadedData:()=>P(!1),onError:()=>P(!1),src:M.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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType===`application/pdf`?(0,s.jsx)(`iframe`,{onLoad:()=>P(!1),src:M.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${N?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,s.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(),P(!1)},children:[(0,s.jsx)(t.it,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,s.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,s.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,s.jsx)(t.f,{children:L&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.d.div,{onClick:()=>pe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.d.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,s.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,s.jsx)(t.W,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>pe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,s.jsx)(t.g,{className:`w-4 h-4`})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`input`,{autoFocus:!0,required:!0,value:z,onChange:e=>B(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>he(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:V,onChange:e=>{te(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>he(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),H.map((e,n)=>(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let t=[...H];t[n].key=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>he(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,s.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let t=[...H];t[n].value=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>he(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>U(H.filter((e,t)=>t!==n)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,s.jsx)(t.g,{className:`w-3 h-3`})})]},n)),(0,s.jsxs)(`button`,{type:`button`,onClick:()=>U([...H,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,s.jsx)(t.F,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,s.jsx)(me,{isOpen:!!D,onCancel:()=>O(null),onConfirm:ie,title:`Delete Record`,message:(0,s.jsxs)(s.Fragment,{children:[`Are you sure you want to delete `,(0,s.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:u.find(e=>e.id===D)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:F})]})}function aa({config:e,customContent:n}){let{user:a}=ee(),{config:c}=t.Lt(),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(!0),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(``),[v,y]=(0,r.useState)(``),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(null),w=(0,r.useRef)(null),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),j=e=>{if(A(e),e){let t=e.fileType||``;P(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},M=k,[N,P]=(0,r.useState)(!0),[F,I]=(0,r.useState)(!1),[L,R]=(0,r.useState)(null),[z,B]=(0,r.useState)(``),[V,te]=(0,r.useState)(``),[H,U]=(0,r.useState)([]),W=(0,r.useRef)(null),[G,K]=(0,r.useState)(null),q=(0,r.useRef)([]),J=`mem_${(e.tabName||e.pageId||`internal_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`)}_records`;(0,r.useEffect)(()=>{document.title=e.tabTitle||e.tabName||c.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,c.appName]),(0,r.useEffect)(()=>{if(!a)return;try{let e=localStorage.getItem(`fbos_records_${J}`);e?(d(JSON.parse(e)),p(!1)):p(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}}),n=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Vt,J),(0,i.orderBy)(`createdAt`,`desc`),(0,i.limit)(150)),t=>{let n=e(t.docs);d(n),p(!1),localStorage.setItem(`fbos_records_${J}`,JSON.stringify(n))},n=>{console.error(`Error listening to shared records:`,n);let r=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Vt,J),(0,i.limit)(150)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),d(n),p(!1),localStorage.setItem(`fbos_records_${J}`,JSON.stringify(n))});return()=>r()});return()=>n()},[a,J]);let Y=()=>({name:a.displayName||a.email?.split(`@`)[0]||`Member`,email:a.email||``,avatar:a.photoURL||``}),ne=async e=>{if(e.preventDefault(),!(!a||!g.trim())){x(!0);try{let e=Y();await(0,i.addDoc)((0,i.collection)(t.Vt,J),{name:g.trim(),note:v.trim(),uid:a.uid,recordType:`record`,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,i.serverTimestamp)()}),_(``),y(``),h(!1)}catch(e){console.error(`Error saving shared record:`,e)}x(!1)}},re=async e=>{let n=e.target.files?.[0];if(!(!n||!a)){E(!0);try{let e=`mem_files/${`${Date.now()}_${n.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`,r=(0,o.ref)(t.Ut,e);await(0,o.uploadBytes)(r,n,{customMetadata:{ownerId:a.uid}});let s=await(0,o.getDownloadURL)(r);if(w.current)w.current(n,s,{uid:a.uid,storagePath:e});else{let e=Y();await(0,i.addDoc)((0,i.collection)(t.Vt,J),{name:n.name,note:`${n.type||`File`} · ${ye(n.size)}`,uid:a.uid,recordType:`file`,fileName:n.name,fileType:n.type||`unknown`,fileSize:n.size,downloadURL:s,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,i.serverTimestamp)()})}}catch(e){console.error(`Error uploading shared file:`,e)}E(!1),W.current&&(W.current.value=``)}},ie=async()=>{if(D){I(!0);try{let e=u.find(e=>e.id===D);if(await(0,i.deleteDoc)((0,i.doc)(t.Vt,J,D)),e?.recordType===`file`&&e.downloadURL)try{let n=e.downloadURL.split(`mem_files%2F`)[1]?.split(`?`)[0];n&&await(0,o.deleteObject)((0,o.ref)(t.Ut,`mem_files/${decodeURIComponent(n)}`)).catch(()=>{})}catch(e){console.error(`Error cleaning up shared file:`,e)}O(null)}catch(e){console.error(`Error deleting shared record:`,e)}I(!1)}},[ae,oe]=(0,r.useState)(null),[X,ce]=(0,r.useState)(``),[Z,ue]=(0,r.useState)(!1),de=e=>{if(e.recordType===`file`){oe(e.id),ce(e.name);return}R(e.id),B(e.name),te(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));U(n),q.current=n.map(e=>e.key)},fe=async()=>{if(!ae||!X.trim()){oe(null);return}let e=u.find(e=>e.id===ae);if(e&&e.name===X.trim()){oe(null);return}ue(!0);try{await(0,i.updateDoc)((0,i.doc)(t.Vt,J,ae),{name:X.trim()}),d(e=>e.map(e=>e.id===ae?{...e,name:X.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}ue(!1),oe(null)},pe=async()=>{await he(),R(null)},he=async()=>{if(!L||!z.trim())return;x(!0);let e={};H.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let n=H.map(e=>e.key.trim()).filter(Boolean),r=q.current.filter(e=>!n.includes(e));r.forEach(t=>{e[t]=(0,i.deleteField)()});try{await(0,i.updateDoc)((0,i.doc)(t.Vt,J,L),{name:z.trim(),note:V.trim(),...e}),d(e=>e.map(e=>{if(e.id!==L)return e;let t={...e,name:z.trim(),note:V.trim()};return r.forEach(e=>{delete t[e]}),H.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),q.current=n}catch(e){console.error(`Error saving record:`,e)}x(!1)},ge=(e,n)=>e?e.startsWith(`image/`)?n?(0,s.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${n})`}}):(0,s.jsx)(t.et,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,s.jsx)(t.v,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,s.jsx)(t.it,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,s.jsx)(t.Pt,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,s.jsx)(t.ft,{className:`w-4 h-4`}):(0,s.jsx)(t.rt,{className:`w-4 h-4`}):(0,s.jsx)(t.it,{className:`w-4 h-4`}),_e=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,ve=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},ye=e=>{if(!e)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]},be=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},xe=(()=>{let n=(e.buttonStorageIcon||`upload`).trim(),r=n.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return t.p[r]?t.p[r]:t.p[n]?t.p[n]:t.x||t.F})(),Q=e.buttonStyle!==`secondary`,Se=e.buttonStorageStyle===`primary`,Ce=e=>e.uid===a?.uid,we=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Member`,n=e.creatorEmail||``,r=e.creatorAvatar||``,i=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[r?(0,s.jsx)(`img`,{src:r,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:i}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,s.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};return(0,s.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,s.jsx)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:e.tabTitle||e.tabName||`Internal Page`}),e.route&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,s.jsx)(`input`,{type:`file`,ref:W,onChange:re,className:`hidden`}),!n&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 sm:gap-4 p-4 sm:p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:f?`Loading…`:`${u.length} ${u.length===1?`item`:`items`} · Internal`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.storage!==!1&&(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(t.d.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>W.current?.click(),disabled:T,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${Se?`btn-primary`:`btn-secondary`}`,children:[T?(0,s.jsx)(t.W,{className:`w-4 h-4 animate-spin`}):(0,s.jsx)(xe,{className:`w-4 h-4`}),e.buttonStorageText&&(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,s.jsx)(t.d.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${Q?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,s.jsx)(t.F,{className:`w-4 h-4`}):(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,s.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[f&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,s.jsx)(t.W,{className:`w-8 h-8 text-accent animate-spin`})}),n?(0,s.jsx)(`div`,{className:`fbos-content-slot`,children:(0,s.jsx)(n,{config:e,actions:{records:u,loading:f,collection:J,user:a,saveRecord:async e=>{let n=Y(),r={id:`temp_`+Date.now(),uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:Date.now(),...e};d(e=>[r,...e]),await(0,i.addDoc)((0,i.collection)(t.Vt,J),{uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:(0,i.serverTimestamp)(),...e})},updateRecord:async(e,n)=>{d(t=>t.map(t=>t.id===e?{...t,...n}:t)),await(0,i.updateDoc)((0,i.doc)(t.Vt,J,e),n)},deleteRecord:async e=>{await(0,i.deleteDoc)((0,i.doc)(t.Vt,J,e))},startEdit:e=>de(e),confirmDelete:e=>O(e),uploadFile:()=>W.current?.click(),openAddForm:()=>h(!0),setAddForm:e=>C(()=>e),setFileHandler:e=>{w.current=e}}})}):(0,s.jsxs)(s.Fragment,{children:[!f&&u.length===0&&(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,s.jsx)(t.F,{className:`w-6 h-6 text-accent/40`})}),(0,s.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files. All team members can view and contribute.`})]}),!f&&u.length>0&&(0,s.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,s.jsx)(t.f,{children:u.map(e=>{let n=L===e.id,r=Ce(e);return(0,s.jsxs)(t.d.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>r?de(e):null,className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative ${r?`cursor-pointer`:``} ${n?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,s.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),K(e.id),setTimeout(()=>K(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:G===e.id?(0,s.jsx)(t.Ct,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,s.jsx)(t.K,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,s.jsx)(t.lt,{className:`w-3.5 h-3.5`})})]}),r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,s.jsx)(t.I,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),O(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.T,{className:`w-3.5 h-3.5`})})]})]}),(0,s.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,s.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&j(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${_e(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?ge(e.fileType,e.downloadURL):(0,s.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[ae===e.id?(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,value:X,onChange:e=>ce(e.target.value),onBlur:()=>fe(),onKeyDown:e=>{e.key===`Enter`&&fe(),e.key===`Escape`&&oe(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>j(e)}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:be(e.createdAt)})]})]}),e.note&&(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,s.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,s.jsx)(we,{record:e})]},e.id)})})})]})]})]})]}),(0,s.jsx)(t.f,{children:m&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.d.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.d.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:S?r.default.createElement(S,{onSave:async e=>{x(!0);try{let n=Y();await(0,i.addDoc)((0,i.collection)(t.Vt,J),{uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:(0,i.serverTimestamp)(),...e}),h(!1)}catch(e){console.error(`Error saving record:`,e)}x(!1)},onClose:()=>!b&&h(!1),saving:b}):(0,s.jsxs)(`form`,{onSubmit:ne,className:`p-5 flex flex-col gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,s.jsx)(t.g,{className:`w-4 h-4`})})]}),(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,s.jsx)(t.o,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,l.createPortal)((0,s.jsx)(t.f,{children:M&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,s.jsx)(t.d.div,{onClick:()=>j(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,s.jsx)(`button`,{onClick:()=>j(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 outline-none`,children:(0,s.jsx)(t.g,{className:`w-5 h-5`})}),(0,s.jsxs)(t.d.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,s.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,s.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,s.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:M.fileName||M.name}),(0,s.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[ve(M.fileType),` • `,ye(M.fileSize||0)]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(M.downloadURL),K(`preview`),setTimeout(()=>K(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:G===`preview`?(0,s.jsx)(t.Ct,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.K,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),oe(M.id),ce(M.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,s.jsx)(t.I,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),O(M.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.T,{className:`w-4 h-4`})}),(0,s.jsx)(`a`,{href:M.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,s.jsx)(t.lt,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>j(null),children:(0,s.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[N&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,s.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,s.jsx)(t.W,{className:`w-5 h-5 text-accent animate-spin`})})}),M.fileType?.startsWith(`image/`)?(0,s.jsx)(`img`,{onLoad:()=>P(!1),onError:()=>P(!1),src:M.downloadURL,alt:M.fileName||M.name,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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType?.startsWith(`video/`)?(0,s.jsx)(`video`,{onLoadedData:()=>P(!1),onError:()=>P(!1),src:M.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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType===`application/pdf`?(0,s.jsx)(`iframe`,{onLoad:()=>P(!1),src:M.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${N?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,s.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(),P(!1)},children:[(0,s.jsx)(t.it,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,s.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,s.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,s.jsx)(t.f,{children:L&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.d.div,{onClick:()=>pe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.d.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,s.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,s.jsx)(t.W,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>pe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,s.jsx)(t.g,{className:`w-4 h-4`})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`input`,{autoFocus:!0,required:!0,value:z,onChange:e=>B(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>he(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:V,onChange:e=>{te(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>he(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),H.map((e,n)=>(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let t=[...H];t[n].key=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>he(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,s.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let t=[...H];t[n].value=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>he(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>U(H.filter((e,t)=>t!==n)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,s.jsx)(t.g,{className:`w-3 h-3`})})]},n)),(0,s.jsxs)(`button`,{type:`button`,onClick:()=>U([...H,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,s.jsx)(t.F,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,s.jsx)(me,{isOpen:!!D,onCancel:()=>O(null),onConfirm:ie,title:`Delete Record`,message:(0,s.jsxs)(s.Fragment,{children:[`Are you sure you want to delete `,(0,s.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:u.find(e=>e.id===D)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:F})]})}var oa=[`board`,`table`,`calendar`,`drive`],sa=[`inline_form`,`popup_form`],ca=e=>typeof e!=`string`||e===``||e===`none`||e===`custom`||![...oa,...sa].includes(e),la=(e,t)=>ca(e)||t&&!ua(e),ua=e=>typeof e==`string`&&oa.includes(e),da=`/src/your-ai-workflow-firebase-os/microcomponents`,fa=e=>(e||``).split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``),pa=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toLowerCase();return[t,t.replace(/_/g,``)]},ma=e=>{let t=[e?.contentKey,e?.tabName,e?.pageId,e?.pageName].filter(e=>typeof e==`string`&&e.trim()).map(e=>fa(e)).filter(Boolean);return[...new Set(t)].map(e=>`${e}Content.tsx`)},ha=e=>{if(typeof window>`u`)return!1;let t=window.__FBOS_MICROCOMPONENTS__;if(!t)return!1;let n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``);return[e?.contentKey,e?.tabName,e?.pageId,e?.pageName].filter(e=>typeof e==`string`&&e.trim()).some(e=>t[n(e)])},ga=new Map,_a=e=>{let t=ga.get(e);return t||(t=import(`${da}/${e}`).then(e=>typeof e?.default==`function`||typeof e?.default==`object`?e.default:null).catch(()=>null),ga.set(e,t)),t};async function va(e){if(typeof window>`u`||ha(e))return null;for(let t of ma(e)){let e=await _a(t);if(!e)continue;let[n,r]=pa(t.replace(/Content\.tsx$/,``)),i=window.__FBOS_MICROCOMPONENTS__||{};return window.__FBOS_MICROCOMPONENTS__={[n]:e,[r]:e,...i},e}return null}var ya=(e,t)=>{let n=t?E(e.pageType):`public`;return{...e,pageType:n,isPrivate:t,isAdmin:n===`admin`,isInternal:n===`internal`,isShared:n===`internal`}};function ba(){let e=(0,c.useLocation)(),{user:n,userRole:a,loading:o,roleResolved:l}=ee(),u=t.zt(),d=e=>{if(typeof window<`u`){let t=localStorage.getItem(`fbos_route_${e}`);if(t)try{let e=JSON.parse(t);if(e.form&&!e.formConfigOverride){let t=localStorage.getItem(`fbos_form_${e.form}`);t&&(e.formConfigOverride=JSON.parse(t))}return ya(e,e.isPrivate===!0)}catch{}}let n=(typeof window<`u`?window.__FBOS_PAGES__:null)||{},r=e.replace(/^\//,``);for(let[t,i]of Object.entries(n)){let n=i.config,a=i.isPublic,o=n.route||`/`+t;if(o===e||t===r)return ya({...n,route:o,contentKey:n.pageId||t,pageId:t},!a)}return e===`/contact`?{route:`/contact`,template:`popup_form`,form:`contact`,pageId:`contact`,contentKey:`contact`,pageName:`Contact`,formConfigOverride:u.defaultConfigs?.contactForm||t.qt}:e===`/support`?{route:`/support`,template:`popup_form`,form:`support`,pageId:`support`,contentKey:`support`,pageName:`Support`,formConfigOverride:u.defaultConfigs?.supportForm||t.Gt}:null},[f,p]=(0,r.useState)(()=>d(e.pathname)),[m,h]=(0,r.useState)(()=>!d(e.pathname));(0,r.useEffect)(()=>{let n=!0,r=d(e.pathname);if(r){p(r),h(!1);let e=r.pageName||r.tabName||r.title;e&&(document.title=e)}return(async()=>{try{let r=e.pathname;r.startsWith(`/`)&&(r=r.substring(1));let[a,o,s,c,l,d]=await Promise.allSettled([(0,i.getDoc)((0,i.doc)(t.Vt,`sys_pages`,r)),(0,i.getDoc)((0,i.doc)(t.Vt,`sys_tabs`,r)),(0,i.getDocs)((0,i.query)((0,i.collection)(t.Vt,`sys_pages`),(0,i.where)(`route`,`==`,e.pathname),(0,i.limit)(1))),(0,i.getDocs)((0,i.query)((0,i.collection)(t.Vt,`sys_pages`),(0,i.where)(`route`,`==`,r),(0,i.limit)(1))),(0,i.getDocs)((0,i.query)((0,i.collection)(t.Vt,`sys_tabs`),(0,i.where)(`route`,`==`,e.pathname),(0,i.limit)(1))),(0,i.getDocs)((0,i.query)((0,i.collection)(t.Vt,`sys_tabs`),(0,i.where)(`route`,`==`,r),(0,i.limit)(1)))]),f=null,m=null,g=(e,t)=>{f||e.status===`fulfilled`&&(e.value.exists&&e.value.exists()?(f=ya(e.value.data(),t),m=e.value.id):e.value.docs&&e.value.docs.length>0&&(f=ya(e.value.docs[0].data(),t),m=e.value.docs[0].id))};if(g(a,!1),g(s,!1),g(c,!1),g(o,!0),g(l,!0),g(d,!0),!f){let t=(typeof window<`u`?window.__FBOS_PAGES__:null)||{};for(let[n,i]of Object.entries(t)){let t=i.config,a=i.isPublic,o=t.route||`/`+n;if(o===e.pathname||n===r){f=ya({...t,route:o,contentKey:t.pageId||n,pageId:n},!a),m=n;break}}}if(f||(e.pathname===`/contact`?(f={route:`/contact`,template:`popup_form`,form:`contact`,pageName:`Contact`},m=`contact`):e.pathname===`/support`&&(f={route:`/support`,template:`popup_form`,form:`support`,pageName:`Support`},m=`support`)),!n)return;if(f){if((m===`contact`||m===`support`)&&!f.form&&(f.form=m),f.contentKey||=f.pageId||m,f.pageId=m,localStorage.setItem(`fbos_route_${e.pathname}`,JSON.stringify(f)),f.form){let e=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},r=n=>u.defaultConfigs?.[n]||u.defaultConfigs?.[`${n}Form`]||e[n]||(n===`contact`?t.qt:n===`support`?t.Gt:null);if(localStorage.getItem(`fbos_custom_form_${f.form}`)){try{let e=localStorage.getItem(`fbos_form_${f.form}`);e&&(f.formConfigOverride=JSON.parse(e))}catch{}(0,i.getDoc)((0,i.doc)(t.Vt,`sys_forms`,f.form)).then(async e=>{if(n)if(e.exists()){let t={...e.data(),id:e.id};p(e=>({...e,formConfigOverride:t})),localStorage.setItem(`fbos_form_${f.form}`,JSON.stringify(t))}else{let e=r(f.form);e&&(p(t=>({...t,formConfigOverride:e})),localStorage.setItem(`fbos_form_${f.form}`,JSON.stringify(e)),localStorage.removeItem(`fbos_custom_form_${f.form}`))}})}else{let e=r(f.form);e&&(f.formConfigOverride=e)}}let r=f.pageName||f.tabName||f.title;r&&(document.title=r),p(f),h(!1)}else p(`not-found`),h(!1),localStorage.removeItem(`fbos_route_${e.pathname}`)}catch{n&&m&&(p(`not-found`),h(!1))}})(),()=>{n=!1}},[e.pathname]);let[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(null),[b,x]=(0,r.useState)(!1),S=f&&f!==`not-found`&&typeof f==`object`?[f.contentKey,f.tabName,f.pageId,f.pageName].filter(Boolean).join(`|`):``;if((0,r.useEffect)(()=>{if(y(null),!S||ha(f)){x(!1);return}let e=!1;x(!0),va(f).then(t=>{e||(t&&y(()=>t),x(!1))});let t=setTimeout(()=>{e||x(!1)},4e3);return()=>{e=!0,clearTimeout(t)}},[S]),(0,r.useEffect)(()=>{let e;return m||o||!l||b?e=setTimeout(()=>_(!0),150):_(!1),()=>clearTimeout(e)},[m,o,l,b]),m||o||!l||b)return g?n?(0,s.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,s.jsxs)(`div`,{className:`mb-6`,children:[(0,s.jsx)(`div`,{className:`h-10 w-56 rounded-xl bg-foreground/5 animate-pulse mt-1`}),(0,s.jsx)(`div`,{className:`h-3 w-24 rounded bg-foreground/5 animate-pulse mt-3`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsx)(`div`,{className:`flex-1 glass-panel border border-[var(--panel-border)] rounded-3xl flex items-center justify-center min-h-[400px] bg-background shadow-2xl`,children:(0,s.jsx)(t.W,{className:`w-6 h-6 animate-spin text-accent`})})]})]}):(0,s.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[40vh] z-10`,children:(0,s.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border border-[var(--panel-border)]/40 bg-background/80 shadow-md flex items-center gap-3`,children:[(0,s.jsx)(t.W,{className:`w-4 h-4 animate-spin text-accent`}),(0,s.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/60 tracking-wide`,children:`Loading page...`})]})}):null;if(f===`not-found`)return(0,s.jsx)(`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,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1 text-center`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 bg-red-500/10 text-red-500 rounded-full flex items-center justify-center mb-6`,children:(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-8 h-8`,children:[(0,s.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,s.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,s.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}),(0,s.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-bold mb-3 text-foreground`,children:`Page Not Found`}),(0,s.jsx)(`p`,{className:`text-foreground/60 max-w-md`,children:`The route you are looking for does not exist or has been removed.`}),C(a)&&(()=>{let t=Zi();return(0,s.jsxs)(`div`,{className:`mt-8 w-full max-w-lg text-left flex flex-col gap-4`,children:[(0,s.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] px-5 py-4`,children:[(0,s.jsx)(`p`,{className:`text-[12px] font-extrabold tracking-tight text-gradient mb-1.5`,children:`Pages the app can see`}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/70 font-medium leading-relaxed`,children:t.length?t.join(` · `):`None yet. If your assistant says it created a page, the app has not picked its file up.`})]}),(0,s.jsx)(He,{title:`If your assistant just made this page, paste this`,prompt:ta(e.pathname)})]})})()]})});if((f.pageId===`support`||f.isPrivate)&&!n)return(0,s.jsx)(c.Navigate,{to:`/login`,state:{from:e}});if(!D(a,f.isPrivate?f.pageType:`public`))return f.isAdmin?(0,s.jsx)(zr,{}):(0,s.jsx)(Rr,{});let w=u.customRoutes?.[e.pathname]||(f&&f.route?u.customRoutes?.[f.route]:null),T=f.pageName?.toLowerCase().replace(/\s+/g,`_`)||f.pageId||`custom_page`,E=`pub_${T}`,O=u.microcomponents||(typeof window<`u`?window.__FBOS_MICROCOMPONENTS__:void 0),k=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``),A=[f.contentKey,f.tabName,f.pageId,f.pageName,f.pageName?.replace(/\s+/g,`_`)].filter(Boolean).map(e=>k(e)).reduce((e,t)=>e||O?.[t],void 0),j=w||A||v||void 0,M=f.route||f.pageId||`custom`;if(la(f.template,!!j))return f.isAdmin?(0,s.jsx)(ia,{config:f,customContent:j},M):f.isInternal?(0,s.jsx)(aa,{config:f,customContent:j},M):f.isPrivate?(0,s.jsx)(ra,{config:f,customContent:j},M):(0,s.jsx)(na,{config:f,customContent:j},M);if(f.template===`board`){let e=f.isAdmin?`admin_${f.pageId||T}`:f.isInternal?`mem_${f.pageId||T}`:f.isPrivate?`user_${f.pageId||T}`:E;return(0,s.jsx)(u.components?.TemplateBoard||Tt,{title:f.tabTitle||f.tabName||f.title||f.pageName||`Board`,subtitle:f.route,tasksCollection:`${e}_tasks`,categoriesCollection:`${e}_categories`,config:f,customContent:j},M)}if(f.template===`table`){let e=f.isAdmin?`admin_${f.pageId||T}`:f.isInternal?`mem_${f.pageId||T}`:f.isPrivate?`user_${f.pageId||T}`:E;return(0,s.jsx)(u.components?.TemplateTable||tr,{title:f.tabTitle||f.tabName||f.title||f.pageName||`Table`,subtitle:f.route,tableCollection:`${e}_table`,config:f,customContent:j},M)}if(f.template===`calendar`){let e=f.isAdmin?`admin_${f.pageId||T}`:f.isInternal?`mem_${f.pageId||T}`:f.isPrivate?`user_${f.pageId||T}`:E;return(0,s.jsx)(u.components?.TemplateCalendar||ir,{title:f.tabTitle||f.tabName||f.title||f.pageName||`Calendar`,subtitle:f.route,eventsCollection:`${e}_events`,defaultTimeFormat:f.defaultTimeFormat||f.defaulttimeformat||`12h`,config:f,customContent:j},M)}if(f.template===`drive`){let e=f.isAdmin?`admin_${f.pageId||T}`:f.isInternal?`mem_${f.pageId||T}`:f.isPrivate?`user_${f.pageId||T}`:E;return(0,s.jsx)(u.components?.TemplateDrive||it,{title:f.tabTitle||f.tabName||f.title||f.pageName||`Drive`,subtitle:f.route,filesCollection:`${e}_files`,config:f,customContent:j},M)}return f.template===`inline_form`?(0,s.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-start mt-8 relative z-10 w-full min-h-[60vh]`,children:(0,s.jsx)(t.t,{isInline:!0,formId:f.form,formConfig:f.formConfigOverride})}):(0,s.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 w-full min-h-[60vh]`,children:(0,s.jsx)(t.t,{formId:f.form,formConfig:f.formConfigOverride,onClose:()=>window.history.back()})})}var xa=r.default.createContext({}),Sa=Object.defineProperty,Ca=Object.getOwnPropertySymbols,wa=Object.prototype.hasOwnProperty,Ta=Object.prototype.propertyIsEnumerable,Ea=(e,t,n)=>t in e?Sa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Da=(e,t)=>{for(var n in t||={})wa.call(t,n)&&Ea(e,n,t[n]);if(Ca)for(var n of Ca(t))Ta.call(t,n)&&Ea(e,n,t[n]);return e},Oa=(0,r.forwardRef)((e,t)=>{let n=Da(Da({},r.useContext(xa)),e);return r.createElement(`svg`,Da({width:`1.5em`,height:`1.5em`,viewBox:`0 0 24 24`,strokeWidth:1.5,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,color:`currentColor`,ref:t},n),r.createElement(`path`,{d:`M22 12C22 17.5228 17.5228 22 12 22C10.1786 22 8.47087 21.513 7 20.6622L2 21.5L2.83209 16C2.29689 14.7751 2 13.4222 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}),r.createElement(`path`,{d:`M12.9604 13.8683L15.0399 13.4624L17 14.2149V16.0385C17 16.6449 16.4783 17.1073 15.8901 16.9783C14.3671 16.6444 11.5997 15.8043 9.67826 13.8683C7.84859 12.0248 7.22267 9.45734 7.01039 8.04128C6.92535 7.47406 7.3737 7 7.94306 7H9.83707L10.572 8.96888L10.1832 11.0701`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}))}),ka=`rules_version = '2';
|
|
43
|
+
`}),(0,s.jsxs)(`div`,{className:`relative group/date flex flex-col w-full`,children:[(0,s.jsx)(t.c,{type:`date`,label:`Date`,required:!0,value:F.dateStr,onChange:e=>I({...F,dateStr:e.target.value}),className:`pr-10`}),(0,s.jsx)(`div`,{className:`absolute right-4 bottom-4 pointer-events-none group-focus-within/date:text-accent text-foreground/40 transition-colors`,children:(0,s.jsx)(t.Dt,{className:`w-4 h-4`})})]}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[G?(0,s.jsx)(t.c,{type:`time`,label:`Time`,value:F.time,onChange:e=>I({...F,time:e.target.value}),required:!0}):(()=>{let{h:e,m:t,ampm:n}=X(F.time);return(0,s.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,s.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Time`}),(0,s.jsxs)(`div`,{className:`flex items-center h-12 glass-panel border border-[var(--panel-border)] rounded-xl px-3 gap-1 focus-within:border-accent transition-colors`,children:[(0,s.jsx)(`input`,{type:`number`,min:1,max:12,value:e,onChange:e=>I({...F,time:ce(Math.min(12,Math.max(1,parseInt(e.target.value)||12)),t,n)}),className:`w-8 text-center bg-transparent focus:outline-none text-foreground font-bold text-[15px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),(0,s.jsx)(`span`,{className:`text-foreground/40 font-bold text-[15px] select-none`,children:`:`}),(0,s.jsx)(`input`,{type:`number`,min:0,max:59,value:t.toString().padStart(2,`0`),onChange:t=>I({...F,time:ce(e,Math.min(59,Math.max(0,parseInt(t.target.value)||0)),n)}),className:`w-8 text-center bg-transparent focus:outline-none text-foreground font-bold text-[15px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>I({...F,time:ce(e,t,n===`AM`?`PM`:`AM`)}),className:`ml-auto px-2 py-0.5 rounded-md bg-accent/10 text-accent text-[11px] font-extrabold uppercase tracking-wider hover:bg-accent/20 transition-colors shrink-0`,children:n})]})]})})(),(0,s.jsx)(t.c,{type:`number`,min:`1`,max:`1440`,label:`Duration (min)`,value:F.duration,onChange:e=>I({...F,duration:e.target.value}),placeholder:`60`,required:!0})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,s.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest mt-1`,children:`Event Color`}),(0,s.jsx)(`div`,{className:`flex gap-2 items-center relative z-10 w-full h-[46px]`,children:vr.map(e=>(0,s.jsx)(`button`,{type:`button`,onClick:()=>I({...F,color:F.color===e.text?``:e.text}),className:`w-6 h-6 rounded-full shrink-0 ${e.bgCircle} hover:scale-110 transition-transform flex items-center justify-center border border-[var(--panel-border)]`,children:F.color===e.text&&(0,s.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full bg-background`})},e.name))})]}),(0,s.jsx)(`div`,{className:`pt-2`,children:(0,s.jsx)(t.s,{type:`submit`,isLoading:A,className:`w-full py-3`,children:F.id?`Save Changes`:`Create Event`})})]})]})]},`edit-modal`),(0,s.jsx)(_e,{isOpen:!!N,title:`Confirm Deletion`,message:(0,s.jsxs)(s.Fragment,{children:[`Are you sure you want to delete `,(0,s.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:N?.title}),` This action is permanent.`]}),onConfirm:Ce,onCancel:()=>{P(null)},isProcessing:ee,confirmText:`Yes, Delete`})]});return p?(0,s.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,s.jsx)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:d?.tabTitle||d?.tabName||e}),n&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),n]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[De(),ke()]})]}),Ae()]}):(0,s.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,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,s.jsx)(se,{children:e}),n&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),n]})]}),(0,s.jsxs)(`div`,{className:`flex flex-wrap justify-between items-center gap-2 mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:[o?(0,s.jsxs)(c.Link,{to:o,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`,children:[(0,s.jsx)(t.Mt,{className:`w-4 h-4`}),` Go Back`]}):(0,s.jsx)(`div`,{}),(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsx)(t.s,{variant:`secondary`,onClick:q,className:`px-3 h-10 text-[12px] font-bold rounded-xl flex items-center justify-center border-[var(--panel-border)] border shrink-0 hover:bg-foreground/5 shadow-sm text-foreground/70`,children:G?`24h`:`12h`}),(0,s.jsx)(t.s,{variant:`secondary`,onClick:J,className:`w-10 h-10 p-0 text-[14px] font-bold rounded-xl flex items-center justify-center border-[var(--panel-border)] border shrink-0`,children:S===`month`?(0,s.jsx)(t.Y,{className:`w-4 h-4 text-foreground/70`}):(0,s.jsx)(t.Dt,{className:`w-4 h-4 text-foreground/70`})}),Ee&&(0,s.jsxs)(t.s,{onClick:()=>be(),className:`px-6 py-2.5 text-[14px] font-bold rounded-xl shadow-lg flex items-center gap-2`,children:[(0,s.jsx)(t.I,{className:`w-4 h-4`}),` Event`]})]})]}),(0,s.jsxs)(t.f.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 flex-1`,children:[(0,s.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`}),ke()]}),Ae()]})}var xr=[{name:`Purple Standard`,preview:[`#2e1065`,`#cdc1ff`],dark:{buttonText:`#ffffff`,background:`#07070f`,backgroundSecondary:`#0a0a18`,accent:`#a78bfa`,gradient:[`#6d28d9`,`#a78bfa`],text:[`#f0eeff`,`#c4b5fd`,`#a78bfa`]},light:{buttonText:`#ffffff`,background:`#fcfaff`,backgroundSecondary:`#f7f3ff`,accent:`#7c3aed`,gradient:[`#5b21b6`,`#a78bfa`],text:[`#2e1065`,`#6d28d9`,`#cdc1ff`]}},{name:`Royal Navy`,preview:[`#1e3a8a`,`#60a5fa`],dark:{buttonText:`#ffffff`,background:`#050b14`,backgroundSecondary:`#0a192f`,accent:`#60a5fa`,gradient:[`#1d4ed8`,`#60a5fa`],text:[`#dbeafe`,`#93c5fd`,`#60a5fa`]},light:{buttonText:`#ffffff`,background:`#f8fafc`,backgroundSecondary:`#f1f5f9`,accent:`#2563eb`,gradient:[`#1e3a8a`,`#60a5fa`],text:[`#1e3a8a`,`#2563eb`,`#60a5fa`]}},{name:`Emerald Green`,preview:[`#064e3b`,`#10b981`],dark:{buttonText:`#ffffff`,background:`#050806`,backgroundSecondary:`#0a2218`,accent:`#34d399`,gradient:[`#047857`,`#34d399`],text:[`#d1fae5`,`#6ee7b7`,`#34d399`]},light:{buttonText:`#ffffff`,background:`#f6fbf8`,backgroundSecondary:`#eff7f2`,accent:`#059669`,gradient:[`#064e3b`,`#10b981`],text:[`#064e3b`,`#059669`,`#10b981`]}},{name:`Gold`,preview:[`#854d0e`,`#eab308`],dark:{buttonText:`#000000`,background:`#0f0905`,backgroundSecondary:`#1c1208`,accent:`#fcd34d`,gradient:[`#ca8a04`,`#facc15`],text:[`#fefce8`,`#fef08a`,`#facc15`]},light:{buttonText:`#ffffff`,background:`#fbfaf6`,backgroundSecondary:`#f5f2eb`,accent:`#d97706`,gradient:[`#854d0e`,`#eab308`],text:[`#854d0e`,`#ca8a04`,`#eab308`]}},{name:`Silver`,preview:[`#1e293b`,`#94a3b8`],dark:{buttonText:`#ffffff`,background:`#090e17`,backgroundSecondary:`#101725`,accent:`#cbd5e1`,gradient:[`#475569`,`#94a3b8`],text:[`#e2e8f0`,`#94a3b8`,`#cbd5e1`]},light:{buttonText:`#ffffff`,background:`#f8fafc`,backgroundSecondary:`#e2e8f0`,accent:`#64748b`,gradient:[`#1e293b`,`#94a3b8`],text:[`#1e293b`,`#475569`,`#94a3b8`]}},{name:`Barbie Pink`,preview:[`#d946ef`,`#f472b6`],dark:{buttonText:`#ffffff`,background:`#0c030a`,backgroundSecondary:`#1a0515`,accent:`#ff80ff`,gradient:[`#c026d3`,`#f472b6`],text:[`#ffeeff`,`#ffb3ff`,`#ff80ff`]},light:{buttonText:`#ffffff`,background:`#fcf5fa`,backgroundSecondary:`#f5ebf2`,accent:`#d946ef`,gradient:[`#c026d3`,`#ec4899`],text:[`#a21caf`,`#c026d3`,`#ec4899`]}},{name:`Orange`,preview:[`#7c2d12`,`#f97316`],dark:{buttonText:`#ffffff`,background:`#0a0200`,backgroundSecondary:`#1c0b05`,accent:`#fb923c`,gradient:[`#c2410c`,`#fb923c`],text:[`#fff7ed`,`#fdba74`,`#fb923c`]},light:{buttonText:`#ffffff`,background:`#fdf6f2`,backgroundSecondary:`#f5ebe4`,accent:`#ea580c`,gradient:[`#7c2d12`,`#f97316`],text:[`#7c2d12`,`#ea580c`,`#f97316`]}},{name:`Red`,preview:[`#7f1d1d`,`#ef4444`],dark:{buttonText:`#ffffff`,background:`#0a0000`,backgroundSecondary:`#2e0a0a`,accent:`#ef4444`,gradient:[`#b91c1c`,`#f87171`],text:[`#fef2f2`,`#fecaca`,`#f87171`]},light:{buttonText:`#ffffff`,background:`#fdf5f5`,backgroundSecondary:`#f5ebeb`,accent:`#dc2626`,gradient:[`#7f1d1d`,`#ef4444`],text:[`#7f1d1d`,`#dc2626`,`#ef4444`]}},{name:`Black & White`,preview:[`#ffffff`,`#000000`],dark:{buttonText:`#000000`,background:`#000000`,backgroundSecondary:`#111111`,accent:`#ffffff`,gradient:[`#ffffff`,`#e5e7eb`],text:[`#ffffff`,`#f3f4f6`,`#ffffff`]},light:{buttonText:`#ffffff`,background:`#ffffff`,backgroundSecondary:`#f3f4f6`,accent:`#000000`,gradient:[`#000000`,`#1f2937`],text:[`#000000`,`#1f2937`,`#374151`]}}],Sr=[`Inter`,`Outfit`,`Roboto`,`Space Grotesk`,`Plus Jakarta Sans`,`System UI`],Cr=[{key:`light`,label:`Light mode`,icon:t.O,description:`How the site looks for someone with light mode on.`},{key:`dark`,label:`Dark mode`,icon:t.B,description:`How the site looks for someone with dark mode on.`}],wr=be,Tr=`flex items-center gap-2 w-full h-10 px-1.5 rounded-[var(--input-radius,0.75rem)] border border-[var(--panel-border)] bg-[var(--panel-bg)] transition-all focus-within:border-accent hover:border-accent/40`,Er=`border border-[var(--panel-border)]/60`,Dr=e=>JSON.parse(JSON.stringify(e)),Or=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e)||typeof t!=`object`||!t||Array.isArray(t))return JSON.stringify(e)===JSON.stringify(t)?void 0:e;let n={};for(let r of Object.keys(e)){let i=Or(e[r],t[r]);i!==void 0&&(n[r]=i)}return Object.keys(n).length?n:void 0},kr=e=>{let t=(e||``).replace(`#`,``).trim();return t.length===3?[0,1,2].map(e=>parseInt(t[e]+t[e],16)):t.length===6?[0,2,4].map(e=>parseInt(t.substring(e,e+2),16)):null},Ar=(e,t,n)=>{let r=e=>Math.max(0,Math.min(255,Math.round(e)));return`#${[e,t,n].map(e=>r(e).toString(16).padStart(2,`0`)).join(``)}`},jr=e=>{let t=(e||``).trim();if(t.startsWith(`#`)){let e=kr(t);return e?Ar(e[0],e[1],e[2]):null}let n=t.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);return n?Ar(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3])):null},Mr=(e,t)=>{let n=kr(e);return n?Ar(n[0]*t,n[1]*t,n[2]*t):e},Nr=e=>e?Array.isArray(e)?e.length===1?e[0]:`linear-gradient(135deg, ${e.join(`, `)})`:e:``,Pr=(e,t)=>{let n=kr(jr(t)||t);if(!n)return{};let r=e=>`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${e})`;return{panelBg:e===`dark`?r(`0.05`):`rgba(255, 255, 255, 0.70)`,panelBorder:r(e===`dark`?`0.15`:`0.08`),glowColor:r(e===`dark`?`0.40`:`0.30`),selectionBg:r(e===`dark`?`0.40`:`0.30`)}};function Fr({label:e,hint:t,value:n,over:r,onChange:i}){let a=jr(n)||`#7c3aed`;return(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5 p-3.5 sm:p-4 ${ve}`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,s.jsx)(`label`,{className:`text-[12.5px] font-bold text-foreground truncate`,children:e}),(0,s.jsxs)(`label`,{className:`relative w-7 h-7 rounded-lg cursor-pointer overflow-hidden shrink-0 shadow-2xs transition-all hover:scale-105 active:scale-95 flex items-center justify-center focus-within:ring-2 focus-within:ring-accent ${Er}`,title:`Pick a colour for ${e}`,children:[(0,s.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-0`,style:{backgroundColor:r||`transparent`}}),(0,s.jsx)(`span`,{"aria-hidden":!0,"data-testid":`color-swatch`,className:`absolute inset-0`,style:{backgroundColor:n||`transparent`}}),(0,s.jsx)(`input`,{type:`color`,"aria-label":`${e} colour picker`,value:a,onChange:e=>i(e.target.value),className:`absolute inset-0 w-full h-full opacity-0 cursor-pointer p-0 border-0`})]})]}),t&&(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/45 font-medium leading-snug`,children:t}),(0,s.jsx)(`input`,{type:`text`,"aria-label":e,value:n??``,onChange:e=>i(e.target.value),className:wr})]})}function Ir({label:e,hint:n,value:r,onChange:i}){let a=Array.isArray(r)&&r.length?r:[`#7c3aed`,`#6d28d9`],o=(e,t)=>{let n=[...a];n[e]=t,i(n)};return(0,s.jsxs)(`div`,{className:`flex flex-col gap-2.5 p-3.5 sm:p-4 ${ve}`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,s.jsx)(`label`,{className:`text-[12.5px] font-bold text-foreground truncate`,children:e}),(0,s.jsx)(`div`,{"data-testid":`gradient-preview`,className:`w-16 h-5 rounded-lg border border-[var(--panel-border)]/60 shrink-0 shadow-2xs overflow-hidden`,style:{background:Nr(a)}})]}),n&&(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/45 font-medium leading-snug`,children:n}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 pt-1.5`,children:[a.map((n,r)=>(0,s.jsxs)(`div`,{className:Tr,children:[(0,s.jsx)(`label`,{className:`relative w-6 h-6 rounded-md cursor-pointer overflow-hidden shrink-0 transition-all hover:scale-105 active:scale-95 flex items-center justify-center ${Er}`,style:{backgroundColor:n||`transparent`},title:`Pick colour ${r+1} for ${e}`,children:(0,s.jsx)(`input`,{type:`color`,"aria-label":`${e} colour ${r+1} picker`,value:jr(n)||`#7c3aed`,onChange:e=>o(r,e.target.value),className:`absolute inset-0 w-full h-full opacity-0 cursor-pointer p-0 border-0`})}),(0,s.jsx)(`input`,{type:`text`,"aria-label":`${e} colour ${r+1}`,value:n,onChange:e=>o(r,e.target.value),className:`flex-1 min-w-0 h-full bg-transparent border-0 px-0 text-[12px] font-semibold text-foreground outline-none`}),a.length>2&&(0,s.jsx)(`button`,{type:`button`,onClick:()=>i(a.filter((e,t)=>t!==r)),"aria-label":`Remove colour ${r+1} from ${e}`,className:`w-6 h-6 rounded-md flex items-center justify-center text-foreground/35 hover:text-red-500 hover:bg-red-500/10 transition-colors cursor-pointer shrink-0`,children:(0,s.jsx)(t._,{className:`w-3.5 h-3.5`})})]},r)),a.length<6&&(0,s.jsxs)(`button`,{type:`button`,onClick:()=>i([...a,Mr(a[a.length-1]||`#6d28d9`,.9)]),className:`w-full h-9 px-3 rounded-lg border border-dashed border-accent/40 hover:border-accent bg-accent/[0.03] hover:bg-accent/10 text-accent text-[11.5px] font-bold flex items-center justify-center gap-1.5 transition-all active:scale-[0.99] cursor-pointer shadow-2xs mt-0.5`,children:[(0,s.jsx)(t.I,{className:`w-3.5 h-3.5`}),`Add another colour`]})]})]})}function Lr({label:e,hint:t,value:n,onChange:r}){let i=Number.isFinite(n)?n:0;return(0,s.jsx)(Ee,{label:e,hint:t,action:(0,s.jsxs)(`span`,{className:`text-[11px] font-bold text-foreground/50 tabular-nums shrink-0`,children:[Math.round(i*16),`px`]}),children:(0,s.jsx)(`input`,{type:`range`,min:0,max:3,step:.125,value:i,"aria-label":e,onChange:e=>r(parseFloat(e.target.value)),className:`w-full accent-accent cursor-pointer`})})}function Rr({title:e,onReset:n}){return(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-2 first:pt-0`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-black uppercase tracking-wider text-foreground/40`,children:e}),(0,s.jsx)(Q,{icon:t.P,compact:!0,title:`Reset ${e.toLowerCase()}`,onClick:n,children:`Reset`})]})}var zr=[`accent`,`foreground`,`background`,`backgroundSecondary`,`textGradient`,`notificationIconColor`],Br=[`buttonGradient`,`buttonHoverGradient`,`buttonText`,`secondaryButton`],Vr=[`panelBg`,`panelBorder`,`glowColor`,`selectionBg`,`selectionText`],Hr=`fbos_theme_ai_draft`,Ur=()=>{try{return JSON.parse(localStorage.getItem(Hr)||`{}`)}catch{return{}}},Wr=e=>{let t=String(e?.brief||``).trim(),n=String(e?.appName||``).trim(),r=String(e?.logoUrl||``).trim(),i=String(e?.faviconUrl||``).trim(),a=[`Design the look of my whole app. Here is what I am after: ${t||`___`}`,`Do it all in one file: src/your-ai-workflow-firebase-os/configs/theme.config.ts — the colours, the typeface and how rounded things are. Do not restyle by rewriting components, and do not put colours of your own anywhere else.`,`Set the dark colours and the light colours both, so my site reads well either way.`];return n&&a.push(`In that same file, set appName to exactly: ${n}`),r&&a.push(`In that same file, set logoUrl to exactly this link: ${r} — that is my logo for the top bar. Use my link character for character, take my colours from the picture, and never swap it for a placeholder or a picture of your own.`),i&&a.push(i===r?`Set faviconUrl to that same link — it is my browser tab icon too.`:`In that same file, set faviconUrl to exactly this link: ${i} — that is my browser tab icon. Use my link character for character.`),!r&&!i?a.push(`Leave logoUrl and faviconUrl exactly as they are. The logo and the browser tab icon are mine, and my Theme screen is the only place they change.`):r?i||a.push(`Leave faviconUrl exactly as it is — my browser tab icon is mine, and my Theme screen is the only place it changes.`):a.push(`Leave logoUrl exactly as it is — my logo is mine, and my Theme screen is the only place it changes.`),a.push(`Tell me what you picked and why, in one short paragraph.`),a.push(`If nothing changes on my site after you edit that file, say so — a look I have saved in the app wins over the file, and I can undo that with Start again on my Theme screen.`),a.join(`
|
|
44
|
+
`)},Gr=e=>String(e?.brief||``).trim()?``:`Say what look you are after, and this sentence is ready to copy.`,Kr=[`appName`,`defaultTheme`,`showThemeToggle`],qr=[`fontFamily`,`cornerRounding`,`cornerRadii`];function Jr(){let{activeConfig:e,theme:n}=t.Rt(),a=t.Bt(),o=(0,r.useMemo)(()=>Dr(a?.themeConfig||t.Gt),[a]),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(Ur),p=(e,t)=>f(n=>{let r={...n,[e]:t};try{localStorage.setItem(Hr,JSON.stringify(r))}catch{}return r}),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(null),[v,y]=(0,r.useState)(!1),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=(0,i.onSnapshot)((0,i.doc)(t.Ht,`sys_configs`,`theme`),e=>x(e.exists()));return()=>e()},[]);let w=r.default.useRef(null);(0,r.useEffect)(()=>{if(!e)return;let t=JSON.stringify(Dr(e)),n=l?JSON.stringify(l):null;n!==t&&(n&&n!==w.current||(w.current=t,u(JSON.parse(t))))},[e,l]),(0,r.useEffect)(()=>{try{let e=sessionStorage.getItem(`fbos_theme_scrollY`);e&&requestAnimationFrame(()=>window.scrollTo(0,parseInt(e,10)))}catch{}let e=()=>{try{sessionStorage.setItem(`fbos_theme_scrollY`,String(window.scrollY))}catch{}};return window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[]),(0,r.useEffect)(()=>{if(!l)return;let e=JSON.stringify(l);if(e===w.current)return;let n=setTimeout(async()=>{h(!0);try{let n=Or(l,o);n?await(0,i.setDoc)((0,i.doc)(t.Ht,`sys_configs`,`theme`),n):(await(0,i.deleteDoc)((0,i.doc)(t.Ht,`sys_configs`,`theme`)),localStorage.removeItem(`theme_config_cache`)),w.current=e,_(Date.now())}catch(e){console.error(`Auto-save failed`,e)}h(!1)},300);return()=>clearTimeout(n)},[l,o]);let T=(e,t)=>u(n=>({...n,[e]:t})),E=(e,t)=>u(n=>({...n,colors:{...n.colors,[e]:{...n.colors?.[e]||{},...t}}})),D=(e,t)=>u(n=>({...n,colors:{...n.colors,[e]:{...n.colors?.[e]||{},secondaryButton:{...n.colors?.[e]?.secondaryButton||{},...t}}}})),O=(e,t)=>E(e,{accent:t,notificationIconColor:t,...Pr(e,t)}),k=(e,t,n)=>C({title:e,message:t,apply:n}),A=e=>u(t=>{let n=Dr(t);return e.forEach(e=>{o[e]===void 0?delete n[e]:n[e]=Dr(o[e])}),n}),j=(e,t)=>u(n=>{let r=Dr(n),i=o.colors?.[e]||{};return r.colors=r.colors||{},r.colors[e]=r.colors[e]||{},t.forEach(t=>{i[t]===void 0?delete r.colors[e][t]:r.colors[e][t]=Dr(i[t])}),r}),ee=e=>{if(!l)return;let t=Dr(l);t.colors=t.colors||{},[`dark`,`light`].forEach(n=>{let r=e[n],i=t.colors[n]||{};t.colors[n]={...i,accent:r.accent,buttonGradient:[...r.gradient],buttonHoverGradient:[...r.gradient],buttonText:r.buttonText,notificationIconColor:r.accent,textGradient:[...r.text],foreground:r.text[0],background:r.background,backgroundSecondary:r.backgroundSecondary,...Pr(n,r.accent),...i.secondaryButton?{secondaryButton:{...i.secondaryButton,text:r.text[0]}}:{}}}),u(t)},M=async()=>{y(!0);try{let e=Dr(o);await(0,i.deleteDoc)((0,i.doc)(t.Ht,`sys_configs`,`theme`)),localStorage.removeItem(`theme_config_cache`),localStorage.removeItem(`theme-mode`),localStorage.removeItem(`last-seen-default-theme`),localStorage.removeItem(Hr),f({}),w.current=JSON.stringify(e),u(e)}catch{}setTimeout(()=>y(!1),600)},N=e=>{let r=Cr.find(t=>t.key===e),i=l?.colors?.[e]||{},a=o.colors?.[e]||{},c=i.background||a.background||`#ffffff`;return(0,s.jsxs)(Te,{icon:r.icon,title:r.label,description:r.description,defaultOpen:n===e,actions:(0,s.jsx)(Q,{icon:t.P,compact:!0,title:`Reset ${r.label.toLowerCase()}`,onClick:t=>{t.stopPropagation(),k(`Reset ${r.label.toLowerCase()}?`,`Every colour in ${r.label.toLowerCase()} — the brand colours, the buttons and the panels — goes back to how it started. The other mode is left alone.`,()=>j(e,[...zr,...Br,...Vr]))},children:`Reset`}),children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 p-3.5 sm:p-4 ${ve}`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,s.jsx)(`span`,{className:`text-[12.5px] font-bold text-foreground`,children:`Ready-made colour sets`}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/45 font-medium leading-snug`,children:`One click repaints light and dark together.`})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-3 overflow-x-auto no-scrollbar py-2.5 px-2.5 -mx-2.5`,children:xr.map(t=>{let n=i.accent===t[e].accent&&l?.colors?.[e]?.buttonGradient?.[0]===t[e].gradient[0],r=t.name===`Black & White`;return(0,s.jsx)(`button`,{type:`button`,onClick:()=>ee(t),"aria-label":t.name,title:t.name,className:`w-9 h-9 rounded-full shrink-0 outline-none transition-all shadow-sm relative cursor-pointer ${n?`ring-2 ring-accent ring-offset-2 ring-offset-[var(--bg-color)] scale-110 z-10`:`opacity-80 hover:opacity-100 hover:ring-2 hover:ring-foreground/25 hover:ring-offset-2 hover:ring-offset-[var(--bg-color)] hover:scale-105`}`,children:(0,s.jsx)(`span`,{className:`absolute inset-0 rounded-full border border-[var(--panel-border)]/60`,style:r?{backgroundColor:`#ffffff`,border:`3px solid #000000`}:{backgroundImage:`linear-gradient(135deg, ${t.preview[0]}, ${t.preview[1]})`}})},t.name)})})]}),(0,s.jsx)(Rr,{title:`Brand and colours`,onReset:()=>k(`Reset the colours?`,`The brand colour, the text and the two backgrounds in ${r.label.toLowerCase()} go back to how they started. Nothing else changes.`,()=>j(e,zr))}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 items-start`,children:[(0,s.jsx)(Fr,{over:c,label:`Brand colour`,hint:`Links, highlights and the main buttons. Panels follow it too.`,value:i.accent||a.accent||`#7c3aed`,onChange:t=>O(e,t)}),(0,s.jsx)(Fr,{over:c,label:`Text colour`,hint:`Primary typography colour used across the app.`,value:i.foreground||a.foreground||`#111827`,onChange:t=>E(e,{foreground:t})}),(0,s.jsx)(Fr,{over:c,label:`Page background`,hint:`Main background canvas colour under all content.`,value:i.background||a.background||`#ffffff`,onChange:t=>E(e,{background:t})}),(0,s.jsx)(Fr,{over:c,label:`Second background`,hint:`The colour the page background fades into.`,value:i.backgroundSecondary||a.backgroundSecondary||`#f9fafb`,onChange:t=>E(e,{backgroundSecondary:t})}),(0,s.jsx)(Fr,{over:c,label:`Notification dot`,hint:`Colour applied to notification badging.`,value:i.notificationIconColor||i.accent||a.notificationIconColor||`#7c3aed`,onChange:t=>E(e,{notificationIconColor:t})}),(0,s.jsx)(Ir,{label:`Heading colours`,hint:`The colours big headings fade through.`,value:i.textGradient||a.textGradient,onChange:t=>E(e,{textGradient:t})})]}),(0,s.jsx)(Rr,{title:`Buttons`,onReset:()=>k(`Reset the buttons?`,`Every button colour in ${r.label.toLowerCase()} goes back to how it started. Nothing else changes.`,()=>j(e,Br))}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3 items-start`,children:[(0,s.jsx)(Ir,{label:`Button colours`,hint:`The colours your main buttons fade through.`,value:i.buttonGradient||a.buttonGradient,onChange:t=>E(e,{buttonGradient:t})}),(0,s.jsx)(Ir,{label:`Button colours on hover`,hint:`How a main button looks under the pointer.`,value:i.buttonHoverGradient||a.buttonHoverGradient,onChange:t=>E(e,{buttonHoverGradient:t})}),(0,s.jsx)(Fr,{over:c,label:`Button text`,hint:`The writing on your main buttons.`,value:i.buttonText||a.buttonText||`#ffffff`,onChange:t=>E(e,{buttonText:t})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 mt-1`,children:[(0,s.jsx)(`span`,{className:`text-[10px] font-extrabold uppercase tracking-wider text-foreground/40`,children:`Quieter buttons`}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-3 items-start`,children:[(0,s.jsx)(Fr,{over:c,label:`Quiet button fill`,value:i.secondaryButton?.bg||a.secondaryButton?.bg||`rgba(0, 0, 0, 0.03)`,onChange:t=>D(e,{bg:t})}),(0,s.jsx)(Fr,{over:c,label:`Quiet button edge`,value:i.secondaryButton?.border||a.secondaryButton?.border||`rgba(0, 0, 0, 0.06)`,onChange:t=>D(e,{border:t})}),(0,s.jsx)(Fr,{over:c,label:`Quiet button text`,value:i.secondaryButton?.text||a.secondaryButton?.text||`#111827`,onChange:t=>D(e,{text:t})})]})]}),(0,s.jsx)(Rr,{title:`Panels and highlights`,onReset:()=>k(`Reset the panels?`,`Panels, edges, the focus glow and text highlighting in ${r.label.toLowerCase()} go back to how they started. Nothing else changes.`,()=>j(e,Vr))}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 items-start`,children:[(0,s.jsx)(Fr,{over:c,label:`Panel fill`,hint:`Background colour of cards and panels.`,value:i.panelBg||a.panelBg||`rgba(255, 255, 255, 0.70)`,onChange:t=>E(e,{panelBg:t})}),(0,s.jsx)(Fr,{over:c,label:`Panel edge`,hint:`Borders of panels, inputs and dropdowns.`,value:i.panelBorder||a.panelBorder||`rgba(0, 0, 0, 0.08)`,onChange:t=>E(e,{panelBorder:t})}),(0,s.jsx)(Fr,{over:c,label:`Focus glow`,hint:`The glow around the box someone is typing in.`,value:i.glowColor||a.glowColor||`rgba(124, 58, 237, 0.30)`,onChange:t=>E(e,{glowColor:t})}),(0,s.jsx)(Fr,{over:c,label:`Highlight`,hint:`The colour behind text someone has selected.`,value:i.selectionBg||a.selectionBg||`rgba(124, 58, 237, 0.30)`,onChange:t=>E(e,{selectionBg:t})}),(0,s.jsx)(Fr,{over:c,label:`Highlighted text`,hint:`The colour of the selected text itself.`,value:i.selectionText||a.selectionText||`#ffffff`,onChange:t=>E(e,{selectionText:t})})]})]},e)};return(0,s.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,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6`,children:[(0,s.jsx)(se,{children:`Theme`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/theme`]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-3xl p-4 sm:p-5 md:p-8 shadow-2xl relative bg-background flex flex-col min-h-[600px]`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,s.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-[17px] sm:text-xl font-extrabold text-foreground tracking-tight`,children:`Design it with your assistant`}),(0,s.jsxs)(`p`,{className:`text-[12.5px] sm:text-[13.5px] font-medium text-foreground/55 mt-1 sm:mt-1.5`,children:[(0,s.jsx)(`span`,{className:`sm:hidden`,children:`Fill these in for your assistant.`}),(0,s.jsx)(`span`,{className:`max-sm:hidden`,children:`Fill these in, then copy the sentence below into your assistant’s chat.`})]})]}),(0,s.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:(0,s.jsx)(Q,{icon:t.P,tone:`danger`,compact:!0,busy:v,disabled:!b,title:`Start the whole look again`,onClick:()=>k(`Start the whole look again?`,`Every colour, the font and the corners go back to how they were the day you installed, and your answers in the assistant section above clear too. This cannot be undone.`,M),children:`Start again`})})]}),(0,s.jsx)($e,{label:`Logo`,hint:`The picture in the top bar.`,value:d.logoUrl||``,onChange:e=>p(`logoUrl`,e),tips:tt}),(0,s.jsx)($e,{label:`Browser tab icon`,hint:`The tiny picture on the browser tab.`,value:d.faviconUrl||``,onChange:e=>p(`faviconUrl`,e),tips:nt}),(0,s.jsx)(De,{label:`App name`,hint:`It goes in the top bar and on the browser tab.`,value:d.appName||``,onChange:e=>p(`appName`,e),placeholder:`Bright Studio`}),(0,s.jsx)(ke,{label:`What look would you like?`,hint:`What you do, who it is for, and the feeling you are after.`,value:d.brief||``,onChange:e=>p(`brief`,e),placeholder:`A calm, modern look for a small physiotherapy clinic. Soft greens, lots of white space, nothing shouty. Rounded corners.`}),(0,s.jsx)(Ze,{title:`Copy this to your assistant`,prompt:Wr(d),locked:!!Gr(d)}),(0,s.jsxs)(`p`,{className:`text-[11.5px] text-foreground/45 font-medium leading-snug px-1`,children:[`Uploads are kept on your`,` `,(0,s.jsx)(c.Link,{to:`/assets`,className:`text-accent font-bold hover:underline`,children:`Assets page`}),` `,`too — edit the fields and copy the sentence again any time.`]})]}),(0,s.jsxs)(`div`,{className:`mt-10 pt-8 border-t border-[var(--panel-border)]/50 mb-5 flex items-start justify-between gap-3`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-[17px] sm:text-xl font-extrabold text-foreground tracking-tight`,children:`Change it by hand`}),(0,s.jsx)(`p`,{className:`text-[12.5px] sm:text-[13.5px] font-medium text-foreground/55 mt-1 sm:mt-1.5`,children:`One setting at a time. Changes show up straight away and save themselves.`})]}),(0,s.jsx)(`div`,{className:`shrink-0 flex items-center gap-2 pt-1`,children:(0,s.jsx)(Ne,{saving:m,savedAt:g})})]}),l?(0,s.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,s.jsxs)(Te,{icon:t.It,title:`Name and how it opens`,description:`What your site is called, and whether it opens light or dark.`,defaultOpen:!1,actions:(0,s.jsx)(Q,{icon:t.P,compact:!0,title:`Reset the name and how it opens`,onClick:()=>k(`Reset the name?`,`The name and the opening mode go back to how they started. Your logo and your browser tab icon are left alone.`,()=>A(Kr)),children:`Reset`}),children:[(0,s.jsx)(De,{label:`Site name`,hint:`The name people see in the top bar and on the browser tab.`,value:l.appName||``,onChange:e=>T(`appName`,e),placeholder:`Your AI Firebase`}),(0,s.jsx)($e,{label:`Logo`,hint:`The picture in the top bar — changes straight away.`,value:l.logoUrl||``,onChange:e=>T(`logoUrl`,e),tips:tt,action:(l.logoUrl||``)===(o.logoUrl||``)?void 0:(0,s.jsx)(Q,{icon:t.P,onClick:()=>T(`logoUrl`,o.logoUrl||``),children:`Put the original back`})}),(0,s.jsx)($e,{label:`Browser tab icon`,hint:`The tiny picture on the browser tab — changes straight away.`,value:l.faviconUrl||``,onChange:e=>T(`faviconUrl`,e),tips:nt,action:(l.faviconUrl||``)===(o.faviconUrl||``)?void 0:(0,s.jsx)(Q,{icon:t.P,onClick:()=>T(`faviconUrl`,o.faviconUrl||``),children:`Put the original back`})}),(0,s.jsx)(Ae,{label:`How the site opens`,hint:`Light, dark, or whichever one the visitor already uses on their device.`,value:l.defaultTheme||`system`,onChange:e=>T(`defaultTheme`,e||`system`),allowEmpty:!1,options:[{value:`system`,label:`Whatever their device uses`},{value:`light`,label:`Always light`},{value:`dark`,label:`Always dark`}]}),(l.defaultTheme||`system`)===`system`&&(0,s.jsx)(je,{label:`Let visitors switch it themselves`,hint:`Shows the sun and moon button in the top bar.`,enabled:l.showThemeToggle!==!1,onChange:e=>T(`showThemeToggle`,e)})]}),Cr.map(e=>N(e.key)),(0,s.jsxs)(Te,{icon:t.C,title:`Lettering and corners`,description:`The typeface, and how rounded everything looks.`,defaultOpen:!1,actions:(0,s.jsx)(Q,{icon:t.P,compact:!0,title:`Reset the lettering and corners`,onClick:()=>k(`Reset the lettering and corners?`,`The typeface and every corner go back to how they started.`,()=>A(qr)),children:`Reset`}),children:[(0,s.jsx)(Ae,{label:`Typeface`,hint:`The lettering used everywhere on your site.`,value:l.fontFamily||`Inter`,onChange:e=>T(`fontFamily`,e||`Inter`),allowEmpty:!1,options:Sr.map(e=>({value:e,label:e}))}),(0,s.jsx)(Ae,{label:`Corners`,hint:`Keep the rounding we ship with, or set each one yourself.`,value:l.cornerRounding||`default`,onChange:e=>T(`cornerRounding`,e||`default`),allowEmpty:!1,options:[{value:`default`,label:`Standard rounding`},{value:`custom`,label:`Set them myself`}]}),l.cornerRounding===`custom`&&(0,s.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,s.jsx)(Lr,{label:`Buttons`,hint:`How round every button is.`,value:l.cornerRadii?.buttonRadius??.75,onChange:e=>T(`cornerRadii`,{...l.cornerRadii||{},buttonRadius:e})}),(0,s.jsx)(Lr,{label:`Boxes people type in`,hint:`Form fields and search boxes.`,value:l.cornerRadii?.inputRadius??.75,onChange:e=>T(`cornerRadii`,{...l.cornerRadii||{},inputRadius:e})}),(0,s.jsx)(Lr,{label:`Cards`,hint:`The panels your content sits on.`,value:l.cornerRadii?.cardRadius??1.5,onChange:e=>T(`cornerRadii`,{...l.cornerRadii||{},cardRadius:e})}),(0,s.jsx)(Lr,{label:`Pop-ups`,hint:`Dialogs and confirmation boxes.`,value:l.cornerRadii?.modalRadius??2.5,onChange:e=>T(`cornerRadii`,{...l.cornerRadii||{},modalRadius:e})})]})]})]}):(0,s.jsx)(`div`,{className:`flex items-center justify-center flex-1 text-foreground/40 py-16`,children:(0,s.jsx)(t.G,{className:`w-6 h-6 animate-spin text-accent`})})]})]}),(0,s.jsx)(_e,{isOpen:!!S,title:S?.title||``,message:S?.message||``,confirmText:`Reset`,cancelText:`Keep it`,isProcessing:v,onCancel:()=>C(null),onConfirm:()=>{S?.apply(),C(null)}})]})}function Yr({tone:e,title:t,message:n,action:r}){let i=e===`red`?`border-red-500/20`:`border-amber-500/25`,a=e===`red`?`bg-red-500/5`:`bg-amber-500/5`,o=e===`red`?`text-red-500`:`text-amber-500`;return(0,s.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 min-h-[60vh] animate-in fade-in duration-500`,children:(0,s.jsxs)(`div`,{className:`glass-panel p-8 md:p-10 rounded-3xl border ${i} text-center shadow-xl max-w-sm w-full relative overflow-hidden`,children:[(0,s.jsx)(`div`,{className:`absolute inset-0 ${a}`}),(0,s.jsx)(`h2`,{className:`text-2xl font-black ${o} mb-3 relative z-10 tracking-tight`,children:t}),(0,s.jsx)(`p`,{className:`text-[14px] text-foreground/70 font-medium leading-relaxed relative z-10 mb-6`,children:n}),(0,s.jsx)(`div`,{className:`relative z-10`,children:r})]})})}var Xr=`w-full block py-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground text-[14px] font-bold rounded-xl transition-colors`,Zr=`No access`,Qr=`You do not have access to view this page. If you think you should, ask whoever runs this app.`,$r=()=>(0,s.jsx)(Yr,{tone:`amber`,title:Zr,message:Qr,action:(0,s.jsx)(c.Link,{to:`/dashboard`,className:Xr,children:`Back to dashboard`})}),ei=$r,ti=$r,ni={route:`/page_1`,pageName:`New Page`,pageTitle:`My New Page`,template:`none`,form:``},ri={tabName:`New Page`,iconName:``,route:`/new-page`,tabTitle:`Your Page`,template:`none`,form:``},ii={tabName:`New Admin Page`,iconName:``,route:`/new-admin-page`,tabTitle:`Admin Page`,template:`none`,form:``},ai={tabName:`New Team Page`,iconName:``,route:`/new-team-page`,tabTitle:`Team Page`,template:`none`,form:``},oi=[{id:`home`,title:`Home`,path:`/`,type:`public`,isSystem:!0,enabled:!0},{id:`contact`,title:`Contact`,path:`/contact`,type:`public`,isSystem:!0,enabled:!0},{id:`guide`,title:`Guide`,path:`/guide`,type:`public`,isSystem:!0,enabled:!0},{id:`templates`,title:`Templates`,path:`/templates`,type:`public`,isSystem:!0,enabled:!0},{id:`support`,title:`Support`,path:`/support`,type:`user`,isSystem:!0,enabled:!0}],si=e=>[...e,...oi.filter(t=>!e.some(e=>e.id===t.id))],ci={public:`Anyone`,user:`Signed-in users`,internal:`Your team`,admin:`Admins only`},li=e=>e.draft?`draft`:e.hidden?`hidden`:`live`,ui={draft:`Draft`,live:`Live`,hidden:`Hidden`},di={draft:`Nothing is saved yet. Give it a web address and the page is created.`,live:`This page is live at its web address and listed in the menu.`,hidden:`This page still exists at its web address, but it is out of the menu.`},fi=e=>(e||``).trim().toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9_-]/g,``),pi=(e,t,n,r)=>{let i=e.findIndex(e=>e.id===t);if(i===-1)return null;let a=r&&e[0]?.id===r?1:0,o=n===`up`?Math.max(a,i-1):Math.min(e.length-1,i+1);if(o===i||o<a)return null;let s=[...e],[c]=s.splice(i,1);return s.splice(o,0,c),s},mi=()=>Object.fromEntries(N()),hi=(e,t=!1)=>{let n={};for(let[r,i]of Object.entries(mi())){let a=!!i.isPublic;if(a!==e)continue;let o=i.config||{};!t&&o.enabled===!1||(n[r]={id:r,title:a?o.pageName||o.pageTitle||o.title||r:o.tabName||o.tabTitle||o.title||r,path:o.route?o.route.startsWith(`/`)?o.route:`/`+o.route:`/`+r,type:a?`public`:E(o.pageType),isSystem:!1,enabled:o.enabled!==!1,fromFile:!0})}return n};function gi({value:e,onChange:n,busy:r}){return(0,s.jsx)(`div`,{className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,s.jsx)(t.o,{compact:!0,portal:!0,direction:`auto`,className:`console-select`,ariaLabel:`Who can open this page`,value:e,disabled:r,onChange:e=>n(e),options:v.map(e=>({value:e,label:ci[e]}))})})}var _i=`Add it here — its web address, a name, and what you would like to see on it — then copy the sentence for your assistant.`,vi=`Add it here, then copy the sentence for your assistant.`,yi=[{value:`none`,label:`From scratch`},{value:`board`,label:`Board`},{value:`table`,label:`Table`},{value:`calendar`,label:`Calendar`},{value:`drive`,label:`Files`}],bi=[`board`,`table`,`calendar`,`drive`],xi={board:{is:`a board`,keeps:`its board frame and the card editor that is already in it`,open:`actions.openInlineEditor(columnId)`},table:{is:`a table`,keeps:`its table frame and the row and column controls that are already in it`,open:`actions.addRow()`},calendar:{is:`a calendar`,keeps:`its calendar frame — the month heading, Today, and the arrows — and the add-event form that is already in it`,open:`actions.openAddModal()`},drive:{is:`a file library`,keeps:`its file frame and the upload box that is already in it`,open:`openUploadModal()`}},Si=e=>{let t=xi[e];return t?`This page already works as ${t.is} and it stays one: it keeps ${t.keeps}, already styled to match my app. Design only what fills it, and open the one that is already there with ${t.open}. Never build your own add, edit or upload form on this page — one exists, and yours will not match.`:``},Ci=e=>(e||``).split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``),wi=(e,t)=>t?.contentKey||t?.tabName||t?.pageName||t?.pageId||e.title,Ti=(e,t)=>`src/your-ai-workflow-firebase-os/microcomponents/${Ci(wi(e,t))||`Page`}Content.tsx`,Ei=(e,t)=>{let n=String(t?.route||``).trim();return n?n.startsWith(`/`)?n:`/`+n:e.path||``},Di=(e,t)=>Ei(e,t).replace(/^\/+/,``)?String(t?.brief||``).trim()?Ji(t)?`Say what the form should ask for, and this sentence is ready to copy.`:``:`Say what you would like to see on this page, and this sentence is ready to copy.`:`Give this page a web address and it will be created — then this sentence is ready to copy.`,Oi=e=>{let t=String(e?.imageUrl||``).trim();return t?`Use this picture of mine on the page: ${t} — put it where it works best in your design, keep its proportions, and give it a short description for screen readers. Do not swap it for a placeholder or a picture of your own.`:``},ki=e=>{let t=String(e?.pageAdd||``).trim(),n=String(e?.pageChange||``).trim(),r=String(e?.pageRemove||``).trim(),i=Oi(e),a=[];return t&&a.push(`Add this: ${t}`),n&&a.push(`Change this: ${n}`),r&&a.push(`Take this off the page: ${r}`),i&&a.push(i),a},Ai=e=>ki(e).length>0,ji=(e,t)=>{let n=Ei(e,t),r=String(t?.tabName||t?.pageName||``).trim(),i=r===`New page`?``:r,a=String(t?.template||``),o=String(t?.form||``).trim(),s=String(t?.brief||``).trim(),c=String(t?.formButton||``).trim(),l=String(t?.formSpot||``).trim();String(t?.formFields||``).trim();let u=t?.pageType?`private`:`public`,d=Ci(wi(e,t))||`Page`,f=d.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toLowerCase(),p=[`My app already has a page${i?` called ${i}`:``} at ${n}. It is already made and it is already in the menu — do not create a page, a web address or a settings file for it, and do not edit any other file.`,`Write one file: ${Ti(e,t)}, with a default export. That file is what the page shows.`,`Then add two lines to src/your-ai-workflow-firebase-os/microcomponents/registry.ts so the app loads your file: import ${d}Content from './${d}Content'; and registerMicrocomponent('${f}', ${d}Content); — registerMicrocomponent is imported there from 'your-ai-workflow-firebase-os'. Never remove another page's lines from that file.`,`Make it match the rest of my app: style with the app’s own theme styles so it looks right in light and dark. Do not pick your own colors. Build it from the app’s own pieces — import { SectionHeading, Card, Button } from 'your-ai-workflow-firebase-os': section titles are SectionHeading, boxed sections are Card, buttons are Button — so nothing gets a look of its own. The design should be minimal, modern and clean and match the app.`,`Everything below the page heading is yours to design however you like — one clean column of sections using the full width. Never stack panels inside panels, never let sections overlap, and when the content grows tall let the page scroll.`];bi.includes(a)&&p.push(Si(a)),o===`__new__`||t?.formIsNew?p.push(...Mi(t,u)):o&&p.push(`Show my form ${Gi(o)} on it with <ContactPopup formId='${o}' /> — never write a form by hand.`),o&&c&&p.push(`The form opens from a button that says ${c} — make that button part of the page's design, not an afterthought.`),o&&l&&p.push(`Where the form belongs on the page: ${l}`);let m=Oi(t);return m&&p.push(m),p.push(`Here is what I would like on it: ${s||`___`}`),p.join(`
|
|
45
|
+
`)},Mi=(e,t)=>{let n=String(e?.form||``),r=n!==`__new__`&&n||Ki(e)||`page`,i=String(e?.formFields||``).trim(),a=String(e?.formButton||``).trim(),o=String(e?.formSpot||``).trim(),s=[`The page needs a form of its own. Create it as one more file, src/your-ai-workflow-firebase-os/configs/${r}Form.config.ts, the way my app's instructions describe a form, with systemName '${r}' and formType '${t}'. It should ask for: ${i||`___`}`,`Show that form on the page with <ContactPopup formId='${r}' /> — never build a form out of your own inputs.`];return a&&s.push(`The form opens from a button that says ${a} — make that button part of the page's design, not an afterthought.`),o&&s.push(`Where the form belongs on the page: ${o}`),s},Ni=(e,t=!1)=>Ai(e)?t&&!String(e?.formFields||``).trim()?`Say what the form should ask for, and this sentence is ready to copy.`:``:`Say what you would like added, changed or taken off this page, and this sentence is ready to copy.`,Pi=(e,t,n=!1)=>{let r=Ei(e,t),i=String(t?.tabName||t?.pageName||``).trim(),a=i===`New page`?``:i,o=ki(t),s=t?.pageType?`private`:`public`,c=[`My app already has a page${a?` called ${a}`:``} at ${r}, and the file it shows already exists: ${Ti(e,t)}.`,`Change that one file. Do not create a page, a web address, a settings file or a second content file, do not add or remove anything in registry.ts, and do not edit any other file.`,`Keep it matching the rest of my app: style with the app’s own theme styles so it looks right in light and dark. Do not pick your own colors. Anything new you draw uses the app’s own pieces — import { SectionHeading, Card, Button } from 'your-ai-workflow-firebase-os': section titles are SectionHeading, boxed sections are Card, buttons are Button.`,`Keep everything on the page that I have not asked you to change.`],l=Si(String(t?.template||``));return l&&c.push(l),n&&c.push(...Mi(t,s)),c.push(...o.length?o:[`Here is what I would like changed: ___`]),c.join(`
|
|
46
|
+
`)},Fi={home:{title:`Change the home page`,lead:[`My app already has a home page, and it is one file: src/your-ai-workflow-firebase-os/Home.tsx. Change that one file — do not create a page, a web address, a settings file or a HomeContent.tsx, and do not edit any other file.`,`Keep its named export exactly as it is: export function Home. Making it a default export breaks my site.`,`Keep it matching the rest of my app: style with the app’s own theme styles so it looks right in light and dark. Do not pick your own colors. Anything new you draw uses the app’s own pieces — import { SectionHeading, Card, Button } from 'your-ai-workflow-firebase-os': section titles are SectionHeading, boxed sections are Card, buttons are Button.`,`Keep everything on the page that I have not asked you to change.`]},contact:{title:`Change the contact page`,lead:[`My app already has a contact page at /contact and a contact form. Do not create a page, do not create a form, and do not change the questions the form asks.`,`Change what the page shows by writing one file: src/your-ai-workflow-firebase-os/microcomponents/ContactContent.tsx, with a default export. Then add two lines to src/your-ai-workflow-firebase-os/microcomponents/registry.ts: import ContactContent from './ContactContent'; and registerMicrocomponent('contact', ContactContent); — never remove another page's lines from that file.`,`Show my form with <ContactPopup formId='contact' /> — add isInline to build it into the page instead of opening it as a pop-up. Never build a form out of your own inputs.`,`Keep it matching the rest of my app: style with the app’s own theme styles so it looks right in light and dark. Do not pick your own colors. Anything new you draw uses the app’s own pieces — import { SectionHeading, Card, Button } from 'your-ai-workflow-firebase-os': section titles are SectionHeading, boxed sections are Card, buttons are Button.`,`Keep everything on the page that I have not asked you to change.`]},support:{title:`Change the support page`,lead:[`My app already has a support page at /support and a support form. Do not create a page, do not create a form, and do not change the questions the form asks.`,`Change what the page shows by writing one file: src/your-ai-workflow-firebase-os/microcomponents/SupportContent.tsx, with a default export. Then add two lines to src/your-ai-workflow-firebase-os/microcomponents/registry.ts: import SupportContent from './SupportContent'; and registerMicrocomponent('support', SupportContent); — never remove another page's lines from that file.`,`Show my form with <ContactPopup formId='support' /> — add isInline to build it into the page instead of opening it as a pop-up. Never build a form out of your own inputs.`,`Keep it matching the rest of my app: style with the app’s own theme styles so it looks right in light and dark. Do not pick your own colors. Anything new you draw uses the app’s own pieces — import { SectionHeading, Card, Button } from 'your-ai-workflow-firebase-os': section titles are SectionHeading, boxed sections are Card, buttons are Button.`,`Keep everything on the page that I have not asked you to change.`]}},Ii=(e,t)=>{let n=Fi[e];if(!n)return``;let r=ki(t);return[...n.lead,...r.length?r:[`Here is what I would like changed: ___`]].join(`
|
|
47
|
+
`)},Li=(e,t)=>{let n=e=>{let{_uiKey:t,pageType:n,route:r,contentKey:i,brief:a,...o}=e||{};return o},r=n(e),i=n(t),a=new Set([...Object.keys(r),...Object.keys(i)]);for(let e of a)if((r[e]??``)!==(i[e]??``))return!0;return!1},Ri=(e,t)=>{let{_uiKey:n,...r}=e||{};return Object.keys(r).length>0?{...r,pageType:t}:{pageType:t}},zi=`w-6 h-5 rounded-md flex items-center justify-center text-foreground/35 hover:text-foreground hover:bg-foreground/[0.07] transition-colors cursor-pointer`,Bi=`max-sm:hidden inline-flex items-center gap-1.5 text-[11px] font-semibold text-foreground/45 border border-[var(--panel-border)] bg-foreground/[0.02] px-2 py-[3px] rounded-full`,Vi={draft:`text-foreground/55 border-[var(--panel-border)] bg-foreground/[0.03]`,live:`text-emerald-500 border-emerald-500/25 bg-emerald-500/[0.07]`,hidden:`text-foreground/45 border-[var(--panel-border)]/70 bg-transparent`},Hi={draft:`bg-foreground/30`,live:`bg-emerald-500 shadow-[0_0_5px] shadow-emerald-500/60`,hidden:`bg-foreground/25`};function Ui({status:e}){return(0,s.jsxs)(`span`,{title:di[e],className:`inline-flex items-center gap-1.5 text-[11px] font-semibold px-2.5 py-[3px] rounded-full border ${Vi[e]}`,children:[(0,s.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Hi[e]}`}),ui[e]]})}var Wi=e=>{let t=typeof window<`u`?window.location.host:``;return t?`${t}${e}`:e},Gi=e=>e.replace(/[_-]+/g,` `).replace(/^./,e=>e.toUpperCase()),Ki=e=>String(e?.contentKey||``).toLowerCase().replace(/-+/g,`_`),qi=e=>String(e?.form||``)===`__new__`||!!e?.formIsNew,Ji=e=>qi(e)&&!String(e?.formFields||``).trim(),Yi=(e,t)=>{let n=String(t?.form||``).trim(),r=n===`__new__`?Ki(t):n,i=String(t?.formChange||``).trim();return[`My app has a form on the page at ${Ei(e,t)} — its id is '${r}'.`,`Change only that form, like this: ${i||`___`}`,`Change it where it is defined, keeping its id exactly '${r}' — do not make a second form, and do not touch the page or any other file.`].join(`
|
|
48
|
+
`)};function Xi({page:e,config:t,forms:n,saving:i,onSave:a,addressTaken:o,actions:c,footer:l,isNew:u,editing:d}){let f=e.type===`public`,p=f?`pageName`:`tabName`,m=f?`pageTitle`:`tabTitle`,[h,g]=(0,r.useState)(()=>({...t||{}})),[_,v]=(0,r.useState)(``),y=(e,t)=>g(n=>({...n,[e]:t})),b=e=>{g(t=>({...t,...e}));let n={...t||{},...h,...e};delete n._uiKey,a(n)},x=e=>{(t||{})[e]!==h[e]&&b({[e]:h[e]})},S=String(h.route??``).replace(/^\/+/,``),C=()=>{let n=fi(S);if(!n){v(`Give this page a web address, for example pricing`);return}if(o(e.id,n)){v(`Another page already lives at this address. Pick a different one.`);return}v(``),n===String(t?.route??``).replace(/^\/+/,``)?y(`route`,`/`+n):b({route:`/`+n})},w=fi(S),T={...t||{},...h,route:w?`/`+w:``,contentKey:t?.contentKey||w||void 0},E=String(h.form??``),D=!!h.formIsNew||E===`__new__`,[O]=(0,r.useState)(()=>!!String(t?.form??``).trim()),k=!!d&&O&&!!E,A=D&&!k;return(0,s.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-5`,children:[(0,s.jsx)(De,{label:`Web address`,hint:u?`Where this page lives, e.g. /photos. The page is created as soon as you fill this in.`:`Where this page lives, e.g. /photos`,prefix:`/`,value:S,onChange:e=>{y(`route`,e),_&&v(``)},onBlur:C,error:_,placeholder:`photos`}),(0,s.jsx)(De,{label:f?`Name in the menu`:`Name in the dashboard`,hint:f?`What visitors see in the site menu.`:`What people see in the dashboard menu.`,value:h[p]??``,onChange:e=>y(p,e),onBlur:()=>x(p),placeholder:`Photos`}),(0,s.jsx)(De,{label:`Page heading`,hint:`The big heading people read at the top of the page.`,value:h[m]??``,onChange:e=>y(m,e),onBlur:()=>x(m),placeholder:`Our photos`}),!f&&(0,s.jsx)(Ge,{label:`Icon`,hint:`Shown next to the name in the dashboard menu.`,value:h.iconName??``,onChange:e=>b({iconName:e})}),!f&&!d&&(0,s.jsx)(Ae,{label:`Starting layout`,hint:`What the page starts as. Your assistant fills in the rest when you ask.`,value:yi.some(e=>e.value===h.template)?h.template:`none`,onChange:e=>b({template:e}),options:yi,allowEmpty:!1}),!k&&(0,s.jsx)(Ae,{label:`Form`,hint:`Answers arrive in your Inbox. Your assistant builds it with the page.`,value:D?`__new__`:E,onChange:e=>b(e===`__new__`?{form:`__new__`}:{form:e,formIsNew:!1}),options:[{value:`__new__`,label:`A new form made for this page`},...n.map(e=>({value:e,label:Gi(e)}))],placeholder:`No form`}),A&&(0,s.jsx)(ke,{label:`What should the form ask?`,hint:`The questions in your own words — e.g. name, email, budget, what they need.`,value:h.formFields??``,onChange:e=>y(`formFields`,e),onBlur:()=>x(`formFields`),placeholder:`Name, email, and what they would like to book`}),(A||!d&&!!E)&&(0,s.jsx)(De,{label:`The button that opens it`,hint:`What the button that opens the form says.`,value:h.formButton??``,onChange:e=>y(`formButton`,e),onBlur:()=>x(`formButton`),placeholder:`Get in touch`}),(A||!d&&!!E)&&(0,s.jsx)(De,{label:`Where the form goes`,hint:`Optional — where on the page it belongs, in your own words.`,value:h.formSpot??``,onChange:e=>y(`formSpot`,e),onBlur:()=>x(`formSpot`),placeholder:`At the bottom, after the packages`}),k&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ke,{label:`Change the form`,hint:`Say what should change about the form, then copy the sentence below.`,value:h.formChange??``,onChange:e=>y(`formChange`,e),onBlur:()=>x(`formChange`),placeholder:`Add a phone number question after the email one`}),(0,s.jsx)(Ze,{compact:!0,title:`Copy this to change the form`,prompt:Yi(e,T),locked:!String(h.formChange??``).trim()})]}),d?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ke,{label:`What would you like to add?`,hint:`Anything new for the page. Leave it empty if nothing is missing.`,value:h.pageAdd??``,onChange:e=>y(`pageAdd`,e),onBlur:()=>x(`pageAdd`),placeholder:`A section with three reviews from my customers.`}),(0,s.jsx)(ke,{label:`What would you like to change?`,hint:`Your assistant edits the page you have — anything you do not mention stays.`,value:h.pageChange??``,onChange:e=>y(`pageChange`,e),onBlur:()=>x(`pageChange`),placeholder:`Show the albums three to a row, and put a search box above them.`}),(0,s.jsx)(ke,{label:`What would you like to remove?`,hint:`Anything the page should stop showing.`,value:h.pageRemove??``,onChange:e=>y(`pageRemove`,e),onBlur:()=>x(`pageRemove`),placeholder:`The prices — I would rather people ask.`}),f&&(0,s.jsx)($e,{label:`A picture for this page`,hint:`Optional — a picture for your assistant to use on the page.`,value:h.imageUrl??``,onChange:e=>b({imageUrl:e}),tips:et}),!!String(h.brief??``).trim()&&(0,s.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] px-4 py-3`,children:[(0,s.jsx)(`p`,{className:`text-[11px] font-bold uppercase tracking-widest text-foreground/40 mb-1.5`,children:`What this page was built from`}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed whitespace-pre-line break-words [overflow-wrap:anywhere]`,children:String(h.brief)})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ke,{label:`What would you like to see on this page?`,hint:`What your assistant builds — it goes into the sentence below.`,value:h.brief??``,onChange:e=>y(`brief`,e),onBlur:()=>x(`brief`),placeholder:`A photo gallery where I can upload pictures, put them in albums and open one full screen.`}),f&&(0,s.jsx)($e,{label:`A picture for this page`,hint:`Optional — a picture for your assistant to use on the page.`,value:h.imageUrl??``,onChange:e=>b({imageUrl:e}),tips:et})]}),l?.(T,{definingForm:A}),(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-[var(--panel-border)]/60`,children:[(0,s.jsx)(Ne,{saving:i}),(0,s.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 ml-auto`,children:c})]})]})}function Zi({page:e,answers:t,saving:n,onSave:i}){let[a,o]=(0,r.useState)(()=>({...t||{}})),c=(e,t)=>o(n=>({...n,[e]:t})),l=e=>{(t||{})[e]!==a[e]&&i({[e]:a[e]})},u={...t||{},...a},d=Fi[e.id],f=!Ai(u);return(0,s.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-5`,children:[(0,s.jsx)(ke,{label:`What would you like to add?`,hint:`Anything new for the page. Leave it empty if nothing is missing.`,value:a.pageAdd??``,onChange:e=>c(`pageAdd`,e),onBlur:()=>l(`pageAdd`),placeholder:`A button that says Get in touch, opening my contact form.`}),(0,s.jsx)(ke,{label:`What would you like to change?`,hint:`In your own words. Everything you do not mention stays as it is.`,value:a.pageChange??``,onChange:e=>c(`pageChange`,e),onBlur:()=>l(`pageChange`),placeholder:`The big heading should say Bright Studio.`}),(0,s.jsx)(ke,{label:`What would you like to remove?`,hint:`Anything the page should stop showing.`,value:a.pageRemove??``,onChange:e=>c(`pageRemove`,e),onBlur:()=>l(`pageRemove`),placeholder:`The middle section — it repeats the heading.`}),e.type===`public`&&(0,s.jsx)($e,{label:`A picture for this page`,hint:`Optional — a picture for your assistant to use on the page.`,value:a.imageUrl??``,onChange:e=>{c(`imageUrl`,e),i({imageUrl:e})},tips:et}),(0,s.jsx)(Ze,{compact:!0,title:d.title,prompt:Ii(e.id,u),locked:f}),(0,s.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,s.jsx)(Ne,{saving:n})})]})}function Qi(){let{userRole:e}=ee(),n=(0,c.useLocation)(),[a,o]=(0,r.useState)(()=>{try{if(typeof window<`u`){let e=localStorage.getItem(`fbos_swr_pages`);if(e)return si(JSON.parse(e))}}catch{}return oi}),[l,u]=(0,r.useState)(()=>{try{return sessionStorage.getItem(`fbos_pages_expandedId`)||null}catch{return null}}),d=(0,r.useRef)(l),[f,p]=(0,r.useState)(null),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(()=>{try{if(typeof window<`u`){let e=localStorage.getItem(`fbos_swr_page_configs`);if(e)return JSON.parse(e)}}catch{}return{}}),[v,y]=(0,r.useState)({}),[b,x]=(0,r.useState)(()=>{try{let e=localStorage.getItem(`fbos_swr_page_briefs`);if(e)return JSON.parse(e)}catch{}return{}}),S=(0,r.useRef)(b);(0,r.useEffect)(()=>{S.current=b},[b]),(0,r.useEffect)(()=>(0,i.onSnapshot)((0,i.doc)(t.Ht,`sys_configs`,`page_briefs`),e=>{let t=e.exists()?e.data():{};x(t);try{localStorage.setItem(`fbos_swr_page_briefs`,JSON.stringify(t))}catch{}},()=>{}),[]);let C=async(e,n)=>{let r={...S.current[e]||{},...n};x(t=>({...t,[e]:r})),y(t=>({...t,[e]:!0}));try{await(0,i.setDoc)((0,i.doc)(t.Ht,`sys_configs`,`page_briefs`),{[e]:r},{merge:!0})}catch(e){console.error(`Could not save the page answers`,e)}y(t=>({...t,[e]:!1}))},[w,T]=(0,r.useState)({}),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),[j,M]=(0,r.useState)(!1),N=(0,r.useRef)(null);(0,r.useEffect)(()=>{function e(e){N.current&&!N.current.contains(e.target)&&h(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let[P,F]=(0,r.useState)(new Set),[I,L]=(0,r.useState)(new Set),[R,z]=(0,r.useState)([]),[B,V]=(0,r.useState)([]),te=e=>(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden,...e.removed?{removed:!0}:{}});(0,r.useEffect)(()=>{let e=(0,i.onSnapshot)((0,i.doc)(t.Ht,`sys_configs`,`page_order`),e=>{let t=te(e.exists()&&e.data().order||[]);z(t),F(new Set(t.filter(e=>e.hidden).map(e=>e.id)))}),n=(0,i.onSnapshot)((0,i.doc)(t.Ht,`sys_configs`,`tab_order`),e=>{let t=te(e.exists()&&e.data().order||[]);V(t),L(new Set(t.filter(e=>e.hidden).map(e=>e.id)))});return()=>{e(),n()}},[]),(0,r.useEffect)(()=>{let e=n.pathname.split(`/pages/`)[1]?.split(`/`)[0];e&&!l&&a.some(t=>t.id===e)&&u(e)},[n.pathname,a]),(0,r.useEffect)(()=>{d.current=l;try{l?sessionStorage.setItem(`fbos_pages_expandedId`,l):sessionStorage.removeItem(`fbos_pages_expandedId`)}catch{}},[l]);let H=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=H.current;if(!e)return;try{let t=sessionStorage.getItem(`fbos_pages_scrollY`);t&&(e.scrollTop=parseInt(t,10))}catch{}let t=()=>{try{sessionStorage.setItem(`fbos_pages_scrollY`,String(e.scrollTop))}catch{}};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,r.useEffect)(()=>{(async()=>{try{let[e,n]=await Promise.all([(0,i.getDocs)((0,i.collection)(t.Ht,`sys_pages`)),(0,i.getDocs)((0,i.collection)(t.Ht,`sys_tabs`))]),r=[`home`,`drive`,`assets`,`contact`,`guide`,`templates`,`support`,`theme`,`page_order`,`tab_order`],a=[],s={};e.forEach(e=>{if(!r.includes(e.id)){let t=e.data();a.push({id:e.id,title:t.pageName||t.title||e.id,path:t.route||`/`+e.id,type:`public`,isSystem:!1,enabled:t.enabled!==!1}),s[e.id]=t}}),n.forEach(e=>{if(!r.includes(e.id)){let t=e.data(),n=E(t.pageType);a.push({id:e.id,title:t.tabName||t.title||e.id,path:t.route||`/`+e.id,type:n,isSystem:!1,enabled:t.enabled!==!1}),s[e.id]=t}});let c=mi(),l={...hi(!0,!0),...hi(!1,!0)};for(let[e,t]of Object.entries(l)){if(s[e])continue;let n=a.find(e=>e.path===t.path);if(n){n.fromFile=!0;continue}a.push(t),s[e]=c[e]?.config||{}}o(e=>{let t=si(e.filter(e=>(e.isSystem||e.id.startsWith(`draft_`))&&e.id!==`drive`)),n=a.filter(e=>!t.some(t=>t.id===e.id)),r=[...t,...n];return typeof window<`u`&&localStorage.setItem(`fbos_swr_pages`,JSON.stringify(r)),r}),_(e=>{let t={...e,...s};return typeof window<`u`&&localStorage.setItem(`fbos_swr_page_configs`,JSON.stringify(t)),t})}catch(e){console.error(`Error loading custom pages`,e)}})()},[]);let[U,W]=(0,r.useState)([`contact`]),[G,K]=(0,r.useState)([`support`]);(0,r.useEffect)(()=>{let e=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},n={...t.d,...e},r=new Set([`contact`]),a=new Set([`support`]);Object.entries(n).forEach(([e,t])=>{t.formType===`private`?a.add(t.systemName||e):r.add(t.systemName||e)}),(0,i.getDocs)((0,i.collection)(t.Ht,`sys_forms`)).then(e=>{e.docs.forEach(e=>{e.data().formType===`private`?a.add(e.id):r.add(e.id)}),W(Array.from(r)),K(Array.from(a))}).catch(e=>{console.warn(`Failed fetching sys_forms in PagesAdmin:`,e),W(Array.from(r)),K(Array.from(a))})},[]);let q=async(e,n,r)=>{if(n.route&&!n.route.startsWith(`/`)&&(n.route=`/`+n.route),!String(n.route||``).replace(/^\/+/,``).trim()){_(t=>({...t,[e]:n}));return}let s=a.find(t=>t.id===e),c=r||s?.type||n.pageType||(e.startsWith(`pub_`)?`public`:void 0),l=c===`public`?`sys_pages`:`sys_tabs`;c&&c!==`public`?n.pageType=c:delete n.pageType;let f=Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0)),p=n.route?n.route.replace(/^\/+/,``).replace(/[^a-zA-Z0-9_-]/g,`_`).toLowerCase():e;f.contentKey||=p,n={...n,contentKey:f.contentKey},f.form===`__new__`&&(f.form=Ki(f),f.formIsNew=!0,n={...n,form:f.form,formIsNew:!0}),y(t=>({...t,[e]:!0,[p]:!0}));try{if(p!==e&&p.trim()!==``&&p!==`draft`){try{let{deleteDoc:n}=await import(`firebase/firestore`);await n((0,i.doc)(t.Ht,l,e))}catch{}await(0,i.setDoc)((0,i.doc)(t.Ht,l,p),f),o(t=>t.map(t=>t.id===e?{...t,id:p,_uiKey:t._uiKey||e,path:n.route,title:n.pageName||n.tabName||n.title||t.title}:t)),d.current===e&&(u(p),window.history.replaceState(null,``,`/pages/${p}`)),_(t=>{let r={...t};return r[p]=n,delete r[e],r});let r=c===`public`,a=r?`page_order`:`tab_order`,s=r?R:B;if(!s.some(e=>e.id===p)){let n=[...s.filter(t=>t.id!==e),{id:p,hidden:!1}];try{await(0,i.setDoc)((0,i.doc)(t.Ht,`sys_configs`,a),{order:n})}catch(e){console.error(`Failed to update tab order:`,e)}}}else await(0,i.setDoc)((0,i.doc)(t.Ht,l,e),f),_(t=>({...t,[e]:n})),o(t=>t.map(t=>t.id===e?{...t,path:n.route||t.path,title:n.pageName||n.tabName||n.title||t.title}:t))}catch(t){console.error(`Failed to save ${e} config:`,t)}finally{setTimeout(()=>{y(t=>({...t,[e]:!1,[p]:!1}))},500)}},J=e=>{let t=`draft_`+Math.floor(Math.random()*1e5),n={id:t,title:`New page`,path:``,type:e,isSystem:!1,enabled:!0},r=e===`public`?{route:``,pageName:``,pageTitle:``,form:``,formFields:``,formButton:``,formSpot:``,brief:``}:{route:``,tabName:``,tabTitle:``,iconName:``,template:`none`,form:``,formFields:``,formButton:``,formSpot:``,brief:``,pageType:e};o(e=>[...e,n]),_(e=>({...e,[t]:r})),u(t),h(!1),setTimeout(()=>{document.getElementById(`page-${t}`)?.scrollIntoView?.({behavior:`smooth`,block:`center`})},100)},Y=e=>e.id.startsWith(`draft_`);if(e!==`admin`)return(0,s.jsx)(`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,s.jsx)($r,{})});let ne=async(e,n,r)=>{let s=r===`public`,c=s?`page_order`:`tab_order`,l=s?R:B,u=(s?P:I).has(e);o(a.map(t=>t.id===e?{...t,enabled:u}:t));let d=[...l],f=d.findIndex(t=>t.id===e);f===-1?d.push({id:e,hidden:!0}):d[f]={...d[f],hidden:!u},await(0,i.setDoc)((0,i.doc)(t.Ht,`sys_configs`,c),{order:d})},re=e=>!!e.fromFile&&(e.type===`public`?R:B).some(t=>t.id===e.id&&t.removed),ie=async(e,n)=>{if(e.type===n)return;let r=e.type;o(t=>t.map(t=>t.id===e.id?{...t,type:n}:t)),y(t=>({...t,[e.id]:!0}));let a=Ri(g[e.id],n);try{await(0,i.setDoc)((0,i.doc)(t.Ht,`sys_tabs`,e.id),a,{merge:!0}),_(t=>t[e.id]?{...t,[e.id]:{...t[e.id],pageType:n}}:t)}catch(t){console.error(`Failed to change the audience of ${e.id}:`,t),o(t=>t.map(t=>t.id===e.id?{...t,type:r}:t))}finally{y(t=>({...t,[e.id]:!1}))}},ae=(e,t)=>{if(!t){if(Y({id:e})){o(t=>t.filter(t=>t.id!==e)),_(t=>{let n={...t};return delete n[e],n}),l===e&&u(null);return}O(e)}},oe=async()=>{if(D){M(!0);try{let{deleteDoc:e,collection:n,getDocs:r,doc:i,getDoc:s,query:c,where:d}=await import(`firebase/firestore`),{ref:f,deleteObject:p}=await import(`firebase/storage`),m=a.find(e=>e.id===D),h=m?.type===`public`?`sys_pages`:`sys_tabs`;if(h===`sys_tabs`&&m){let a=g[D];if(!a)try{let e=await s(i(t.Ht,`sys_tabs`,D));e.exists()&&(a=e.data())}catch{}let o=(a?.tabName||a?.pageId||D).toLowerCase().replace(/[^a-z0-9]+/g,`_`),l=[`admin_${o}_records`,`mem_${o}_records`,`user_${o}_records`],u={[`admin_${o}_records`]:{prefix:`admin_files`,driveCollection:`admin_files`},[`mem_${o}_records`]:{prefix:`mem_files`,driveCollection:`mem_files`},[`user_${o}_records`]:{prefix:`user_files`,driveCollection:`user_files`}},m=[];for(let i of l)m.push((async()=>{try{let a=await r(n(t.Ht,i)),o=u[i],s=[];for(let i of a.docs){let a=i.data();a.recordType===`file`&&a.downloadURL&&o&&s.push((async()=>{try{let i=`${o.prefix}%2F`,s=a.downloadURL.split(i)[1]?.split(`?`)[0];s&&await p(f(t.Wt,`${o.prefix}/${decodeURIComponent(s)}`)).catch(()=>{});let l=await r(c(n(t.Ht,o.driveCollection),d(`downloadURL`,`==`,a.downloadURL)));await Promise.all(l.docs.map(t=>e(t.ref)))}catch(e){console.error(`Error deleting storage file:`,e)}})())}await Promise.all(s),await Promise.all(a.docs.map(t=>e(t.ref)));try{localStorage.removeItem(`fbos_records_${i}`)}catch{}}catch(e){console.error(`Error cleaning up collection ${i}:`,e)}})());for(let i of[`admin_files`,`mem_files`,`user_files`])m.push((async()=>{try{let a=await r(c(n(t.Ht,i),d(`sourceTab`,`==`,o)));await Promise.all(a.docs.map(async n=>{let r=n.data();if(r.downloadURL)try{let e=`${i}%2F`,n=r.downloadURL.split(e)[1]?.split(`?`)[0];n&&await p(f(t.Wt,`${i}/${decodeURIComponent(n)}`)).catch(()=>{})}catch{}await e(n.ref)}))}catch{}})());await Promise.all(m)}await e(i(t.Ht,h,D));let _=h===`sys_pages`?`page_order`:`tab_order`,v=h===`sys_pages`?R:B,{setDoc:y}=await import(`firebase/firestore`),b=m?.fromFile?[...v.filter(e=>e.id!==D),{id:D,hidden:!0,removed:!0}]:v.filter(e=>e.id!==D);await y(i(t.Ht,`sys_configs`,_),{order:b}),o(e=>e.filter(e=>e.id!==D)),l===D&&u(null)}catch(e){console.error(`Error deleting page:`,e)}M(!1),O(null)}},X=async(e,n)=>{if(e.isSystem)return;let r=e.type===`public`,o=r?`page_order`:`tab_order`,s=[...r?R:B];a.filter(e=>e.type===`public`===r&&!e.isSystem&&!s.some(t=>t.id===e.id)).forEach(e=>s.push({id:e.id,hidden:!1}));let c=pi(s,e.id,n,r?`home`:void 0);if(c){r?z(c):V(c);try{await(0,i.setDoc)((0,i.doc)(t.Ht,`sys_configs`,o),{order:c})}catch(e){console.error(`Failed to reorder pages:`,e)}}},ce=(e,t)=>{let n=t.replace(/[^a-zA-Z0-9_-]/g,`_`).toLowerCase();return a.some(r=>{if(r.id===e)return!1;let i=String(g[r.id]?.route??r.path??``).replace(/^\/+/,``).toLowerCase();return i!==``&&i===t||r.id===n})},Z=e=>e===`admin`?ii:e===`internal`?ai:e===`public`?ni:ri,ue=async()=>{let e=a.find(e=>e.id===k);if(!e){A(null);return}T(t=>({...t,[e.id]:!0}));let t=g[e.id]||{};await q(e.id,{...Z(e.type),...t.contentKey?{contentKey:t.contentKey}:{},...t.brief?{brief:t.brief}:{}}),T(t=>({...t,[e.id]:!1})),A(null)},de=[{id:`public`,title:`Anyone`,icon:t.rt,description:`On your website and in the site menu — open to everyone, signed in or not.`,filter:e=>e.type===`public`},{id:`user`,title:`Signed-in users`,icon:t.W,description:`In the dashboard for every signed-in person — each sees only their own.`,filter:e=>e.type===`user`},{id:`internal`,title:`Your team`,icon:t.st,description:`In the dashboard for admins and your team — invisible to everyone else.`,filter:e=>e.type===`internal`},{id:`admin`,title:`Admins only`,icon:t.k,description:`In the dashboard, for admins alone.`,filter:e=>e.type===`admin`}];return(0,s.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,s.jsx)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:`Your Pages`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/pages`]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(`div`,{className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,s.jsxs)(`div`,{className:`flex items-start justify-between gap-3 sm:gap-6 mb-4 pb-4 md:mb-6 md:pb-6 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 md:px-10 md:pt-10`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`div`,{className:`flex items-center min-h-[40px]`,children:(0,s.jsx)(`h2`,{className:`text-lg md:text-xl font-extrabold text-foreground tracking-tight leading-tight truncate`,children:`Your pages`})}),(0,s.jsxs)(`p`,{className:`text-[12.5px] md:text-[14px] font-medium text-foreground/60 leading-relaxed max-w-3xl`,children:[(0,s.jsx)(`span`,{className:`md:hidden`,children:`Add a page, say what goes on it, paste the sentence into your assistant.`}),(0,s.jsx)(`span`,{className:`max-md:hidden`,children:`Add a page here, say what you would like on it, and copy the sentence it writes into your assistant's chat. Renaming, reordering, hiding and deleting all happen right here.`})]})]}),(0,s.jsx)(`div`,{className:`relative z-50 shrink-0 flex items-center gap-1`,children:(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(t.s,{variant:`secondary`,onClick:()=>h(!m),className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-foreground/5 rounded-xl flex items-center justify-center shrink-0 transition-colors group cursor-pointer`,title:`Add a page`,children:(0,s.jsx)(t.I,{className:`w-4 h-4 text-foreground/60 group-hover:text-foreground transition-colors`})}),(0,s.jsx)(t.p,{children:m&&(0,s.jsxs)(t.f.div,{ref:N,initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:`absolute top-full mt-2 right-0 w-56 glass-popover border border-[var(--panel-border)] rounded-2xl p-2 z-50 flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`px-3 pt-1 pb-2 text-[10px] font-bold uppercase tracking-widest text-foreground/40`,children:`Add a page for`}),[`public`,`user`,`internal`,`admin`].map(e=>(0,s.jsx)(`button`,{onClick:()=>J(e),className:`text-left px-3 py-2 text-[13px] font-bold text-foreground/70 hover:text-foreground hover:bg-foreground/5 rounded-lg transition-colors cursor-pointer`,children:ci[e]},e))]})})]})})]}),(0,s.jsx)(`div`,{ref:H,className:`px-4 sm:px-6 md:px-10 pb-6 md:pb-10 flex flex-col pt-6 sm:pt-7 md:pt-9 gap-4 overflow-y-auto relative min-h-[400px]`,children:de.map((e,n)=>{let r=a.filter(e.filter).filter(e=>!re(e)),i=e.id===`public`?R:B,o=r.sort((e,t)=>{if(e.id===`home`)return-1;if(t.id===`home`)return 1;let n=i.findIndex(t=>t.id===e.id),r=i.findIndex(e=>e.id===t.id);return n===-1&&r===-1?0:n===-1?1:r===-1?-1:n-r}),d=e.icon,m=e=>e.type===`public`?P.has(e.id):I.has(e.id),h=o.filter(e=>!m(e)),_=o.filter(e=>m(e)),y=(n,r)=>{let i=n.isSystem?Fi[n.id]:void 0,a=l===n.id,o=Y(n),d=li({draft:o,hidden:r}),m=!n.isSystem||!!i,h=!n.isSystem&&!o,_=a&&f===n.id,y=e=>{u(n.id),p(e===`edit`?n.id:null),window.history.replaceState(null,``,`/pages/${n.id}`)},x=o?`Not saved yet — give it a web address`:n.type===`public`?`In the site menu`:`In the dashboard`;return(0,s.jsxs)(`div`,{id:`page-${n.id}`,onClick:()=>{m&&(a?(u(null),p(null),window.history.replaceState(null,``,`/pages`)):y(`settings`))},className:`group flex flex-col p-4 sm:py-4 sm:px-5 glass-panel border transition-all rounded-2xl hover:shadow-sm ${m?`cursor-pointer hover:border-accent/40`:``} ${r?`opacity-60 bg-foreground/[0.01] border-[var(--panel-border)]/50`:`border-transparent hover:border-[var(--panel-border)]`}`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between w-full gap-2 sm:gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-start gap-2 flex-1 min-w-0`,children:[!n.isSystem&&!o&&(0,s.jsxs)(`div`,{className:`flex flex-col shrink-0 pt-0.5 ${a?`max-sm:hidden`:``}`,onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(`button`,{type:`button`,title:`Move up`,"aria-label":`Move ${n.title} up`,onClick:()=>X(n,`up`),className:zi,children:(0,s.jsx)(t.bt,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`button`,{type:`button`,title:`Move down`,"aria-label":`Move ${n.title} down`,onClick:()=>X(n,`down`),className:zi,children:(0,s.jsx)(t.Ct,{className:`w-3.5 h-3.5`})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,s.jsx)(`h3`,{className:`text-[14.5px] font-bold text-foreground tracking-tight truncate`,children:n.title}),!n.isSystem&&(0,s.jsx)(Ui,{status:d}),n.fromFile&&(0,s.jsxs)(`span`,{className:Bi,title:`Your assistant wrote this one as a file. Delete hides it and gives you the sentence that removes its files.`,children:[(0,s.jsx)(t.ot,{className:`w-3 h-3`}),` Written as a file`]})]}),(0,s.jsxs)(`span`,{className:`text-[12px] font-medium text-foreground/45 truncate`,children:[x,n.path&&(0,s.jsxs)(s.Fragment,{children:[` · `,(0,s.jsx)(c.Link,{to:n.path,onClick:e=>e.stopPropagation(),className:`underline decoration-foreground/20 underline-offset-2 hover:text-accent hover:decoration-accent transition-colors`,title:`Open this page`,children:Wi(n.path)})]})]})]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2 shrink-0`,children:[n.type!==`public`&&!o&&(0,s.jsx)(`div`,{className:`max-sm:hidden block`,children:(0,s.jsx)(gi,{value:n.type,busy:v[n.id],onChange:e=>ie(n,e)})}),h&&(0,s.jsx)(Q,{icon:t.v,compact:!0,title:`Edit this page with your assistant`,className:_?`text-accent border-accent/40 bg-accent/10 max-sm:border-transparent max-sm:bg-accent/10`:``,onClick:e=>{e.stopPropagation(),y(_?`settings`:`edit`)},children:`Edit with AI`}),n.id!==`home`&&!o&&(0,s.jsx)(Q,{icon:r?t.st:t.ct,compact:!0,title:r?`Show this page`:`Hide this page`,onClick:e=>{e.stopPropagation(),ne(n.id,n.isSystem,n.type)},children:r?`Show`:`Hide`}),m?(0,s.jsx)(`div`,{className:`p-1.5 transition-transform duration-300 text-foreground/40 shrink-0 ${a?`rotate-180`:``}`,children:(0,s.jsx)(t.Ct,{className:`w-3.5 h-3.5`})}):(0,s.jsx)(`div`,{className:`w-[24px] shrink-0`})]})]}),(0,s.jsxs)(t.p,{children:[a&&i&&(0,s.jsx)(t.f.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50 pb-1`,onClick:e=>e.stopPropagation(),children:(0,s.jsx)(Zi,{page:n,answers:b[n.id],saving:v[n.id],onSave:e=>C(n.id,e)},n.id)}),a&&!n.isSystem&&g[n.id]&&(0,s.jsxs)(t.f.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50 pb-1`,onClick:e=>e.stopPropagation(),children:[n.type!==`public`&&!o&&(0,s.jsxs)(`div`,{className:`sm:hidden flex items-center justify-between gap-3 mb-5`,children:[(0,s.jsx)(`span`,{className:`text-[12px] font-semibold text-foreground/55`,children:`Who can open this page`}),(0,s.jsx)(gi,{value:n.type,busy:v[n.id],onChange:e=>ie(n,e)})]}),(0,s.jsx)(Xi,{page:n,config:g[n.id],forms:n.type===`public`?U:G,saving:v[n.id],isNew:o,editing:_,onSave:e=>q(n.id,e),addressTaken:ce,footer:(e,{definingForm:t})=>_?(0,s.jsx)(Ze,{compact:!0,title:`Copy this to change the page`,prompt:Pi(n,e,t),locked:!!Ni(e,t)}):(0,s.jsx)(Ze,{compact:!0,title:`Then copy this into your assistant’s chat`,description:h?`This one builds the page from scratch. If it has been built already, switch to Edit with AI so your assistant changes it instead of starting over.`:void 0,prompt:ji(n,e),locked:!!Di(n,e)}),actions:(0,s.jsxs)(s.Fragment,{children:[!n.fromFile&&Li(g[n.id],Z(n.type))&&(0,s.jsx)(Q,{icon:t.P,tone:`danger`,compact:!0,title:`Reset this page`,busy:w[n.id],onClick:()=>A(n.id),children:`Reset`}),!n.isSystem&&(0,s.jsx)(Q,{icon:t.E,tone:`danger`,compact:!0,title:`Delete this page`,onClick:()=>ae(n.id,n.isSystem),children:`Delete`})]})},n._uiKey||n.id)]})]})]},`${e.id}-${n._uiKey||n.id}`)};return(0,s.jsx)(t.f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col relative`,children:(0,s.jsx)(Te,{icon:d,title:e.title,description:e.description,children:o.length===0?(0,s.jsxs)(`div`,{className:`flex flex-col items-start sm:flex-row sm:items-center gap-3 rounded-2xl border border-dashed border-[var(--panel-border)] px-5 py-4`,children:[(0,s.jsx)(Q,{icon:t.I,onClick:()=>J(e.id),children:`Add a page`}),(0,s.jsxs)(`p`,{className:`text-[12.5px] text-foreground/55 font-medium leading-relaxed`,children:[(0,s.jsx)(`span`,{className:`sm:hidden`,children:vi}),(0,s.jsx)(`span`,{className:`max-sm:hidden`,children:_i})]})]}):(0,s.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h.map(e=>y(e,!1)),(0,s.jsx)(`div`,{className:`flex items-center rounded-2xl border border-dashed border-[var(--panel-border)] px-5 py-3`,children:(0,s.jsx)(Q,{icon:t.I,onClick:()=>J(e.id),children:`Add a page`})}),_.length>0&&(0,s.jsxs)(`details`,{className:`mt-4 group/details`,children:[(0,s.jsxs)(`summary`,{className:`text-[11px] font-bold uppercase tracking-wider text-foreground/40 cursor-pointer list-none flex items-center gap-2 select-none hover:text-foreground/70 transition-colors w-fit pb-1 ml-1 outline-none`,children:[(0,s.jsx)(t.Ct,{className:`w-3.5 h-3.5 group-open/details:-rotate-180 transition-transform`}),`Hidden pages (`,_.length,`)`]}),(0,s.jsx)(`div`,{className:`flex flex-col gap-4 mt-4`,children:_.map(e=>y(e,!0))})]})]})})},e.id)})})]})]}),(0,s.jsx)(_e,{isOpen:!!D,onCancel:()=>O(null),onConfirm:oe,title:`Delete this page?`,message:`The page and everything saved on it will be gone for good. This cannot be undone.`,confirmText:`Delete page`,isProcessing:j}),(0,s.jsx)(_e,{isOpen:!!k,onCancel:()=>A(null),onConfirm:ue,title:`Reset this page?`,message:`Its name, heading, web address, icon and form go back to how they started. What people have saved on the page is kept.`,confirmText:`Reset page`,isProcessing:!!k&&!!w[k]})]})}var $i=new Set([`contact`,`support`]),ea=[{value:`text`,label:`Short text`},{value:`textarea`,label:`Long text`},{value:`email`,label:`Email`},{value:`tel`,label:`Phone`},{value:`number`,label:`Number`},{value:`date`,label:`Date`},{value:`currency`,label:`Money`},{value:`checkbox`,label:`Yes-no`},{value:`select`,label:`Choose one`},{value:`file`,label:`File upload`}],ta={age:`Age`},na=e=>ea.find(t=>t.value===e)?.label||ta[e||``]||`Short text`,ra=e=>ea.some(t=>t.value===e)||!e?ea:[...ea,{value:e,label:na(e)}],ia={public:`Anyone`,private:`Signed-in users`},aa=e=>(e||``).toLowerCase().trim().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``),oa=(e,t)=>{if(!t.includes(e))return e;let n=2;for(;t.includes(`${e}_${n}`);)n++;return`${e}_${n}`},sa=(e,t,n)=>{if(!(!e.name||e.name===aa(e.label||``)))return e.name;let r=aa(t);return r?oa(r,n.filter(t=>t!==e).map(e=>e.name)):``},ca=()=>({name:``,type:`text`,label:``,placeholder:``,required:!1}),la={firstForm:`Forms are made with their pages — add a page on the Pages screen and pick A new form made for this page. Every form then shows up here.`,forPage:(e,t)=>`Use the form called ${e||t} (its id is ${t}) on the page I name — show it with <ContactPopup formId='${t}' />. Do not create a form, do not change this form's fields, do not write a form by hand.`};function ua({choices:e,onChange:n}){return(0,s.jsx)(Ee,{label:`Choices`,hint:`The options people pick from.`,children:(0,s.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.length===0&&(0,s.jsx)(`span`,{className:`text-[12px] text-foreground/40 font-medium px-1`,children:`No choices yet — add the first one.`}),e.map((r,i)=>(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`input`,{type:`text`,value:r,"aria-label":`Choice ${i+1}`,placeholder:`e.g. Under 1,000`,onChange:t=>n(e.map((e,n)=>n===i?t.target.value:e)),className:be}),(0,s.jsx)(Q,{icon:t._,tone:`danger`,title:`Remove choice ${i+1}`,onClick:()=>n(e.filter((e,t)=>t!==i)),children:`Remove`})]},i)),(0,s.jsx)(`div`,{children:(0,s.jsx)(Q,{icon:t.I,onClick:()=>n([...e,``]),children:`Add choice`})})]})})}function da(){let{userRole:e}=ee(),n=(0,c.useNavigate)(),a=t.Bt(),o=()=>{let e=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},n={...t.d,contact:a?.defaultConfigs?.contactForm||t.d.contact,support:a?.defaultConfigs?.supportForm||t.d.support};for(let[t,r]of Object.entries(e))n[t]=r;return n},[l,u]=(0,r.useState)(()=>{try{if(typeof window<`u`){let e=localStorage.getItem(`fbos_swr_forms`);if(e)return JSON.parse(e)}let e={...t.d,contact:a?.defaultConfigs?.contactForm||t.d.contact,support:a?.defaultConfigs?.supportForm||t.d.support},n=(typeof window<`u`?window.__FBOS_FORMS__:null)||{};for(let[t,r]of Object.entries(n))e[t]=r;let r={};for(let[t,n]of Object.entries(e)){let e=JSON.parse(JSON.stringify(n));e._uiKey=Math.random().toString(36).substring(7),r[t]=e}return r}catch{return{}}}),[d,f]=(0,r.useState)(()=>!(typeof window<`u`&&localStorage.getItem(`fbos_swr_forms`))),[p,m]=(0,r.useState)({}),[h,g]=(0,r.useState)(null),[_,v]=(0,r.useState)(new Set),[y,b]=(0,r.useState)({}),[x,S]=(0,r.useState)(null),[C,w]=(0,r.useState)(!1),[T,E]=(0,r.useState)({}),D=(0,r.useRef)({}),O=(e,t)=>{D.current={...D.current,[e]:t},E(D.current)};(0,r.useEffect)(()=>{k()},[]);let k=async()=>{try{f(!0);let e=await(0,i.getDocs)((0,i.collection)(t.Ht,`sys_forms`)),n={},r=new Set;e.forEach(e=>{if(e.id!==`pubForm`&&e.id!==`userForm`){let t=e.data();t._uiKey=l[e.id]?._uiKey||t._uiKey||Math.random().toString(36).substring(7),n[e.id]=t,r.add(e.id)}}),v(r);try{await(0,i.deleteDoc)((0,i.doc)(t.Ht,`sys_forms`,`pubForm`)),await(0,i.deleteDoc)((0,i.doc)(t.Ht,`sys_forms`,`userForm`))}catch{}let a=o();for(let[e,t]of Object.entries(a))if(!n[e]){let r={...t};r._uiKey=l[e]?._uiKey||Math.random().toString(36).substring(7),n[e]=r}else if(n[e]._uiKey=l[e]?._uiKey||n[e]._uiKey||Math.random().toString(36).substring(7),!n[e].fields||n[e].fields.length===0){let t=a[e];n[e].fields=t.fields||[]}let s={};for(let e of Object.keys(a))n[e]&&(s[e]=n[e]);for(let e of Object.keys(n))s[e]||(s[e]=n[e]);let c=window.location.pathname.split(`/forms/`)[1]?.split(`/`)[0];c&&s[c]&&b({[c]:!0}),D.current={},E({}),u(s),typeof window<`u`&&localStorage.setItem(`fbos_swr_forms`,JSON.stringify(s))}catch(e){console.error(`Failed to load forms:`,e)}finally{f(!1)}},A=async(e,n)=>{let r={...n};l[e]?._uiKey&&(r._uiKey=l[e]._uiKey),delete r.submitPage,e===`contact`?(r.systemName=`contact`,r.formType=`public`):e===`support`&&(r.systemName=`support`,r.formType=`private`);let a=r.systemName||e;if(a!==e&&a.trim()!==``){u(t=>{let n={};for(let i of Object.keys(t))i===e?n[a]=r:n[i]=t[i];return n}),y[e]&&b(t=>{let n={};for(let r of Object.keys(t))r===e?n[a]=t[r]:n[r]=t[r];return n}),m(e=>({...e,[a]:!0}));try{await(0,i.setDoc)((0,i.doc)(t.Ht,`sys_forms`,a),r),await(0,i.deleteDoc)((0,i.doc)(t.Ht,`sys_forms`,e)),localStorage.setItem(`fbos_custom_form_${a}`,`true`),localStorage.removeItem(`fbos_custom_form_${e}`),localStorage.setItem(`fbos_form_${a}`,JSON.stringify(r)),localStorage.removeItem(`fbos_form_${e}`)}catch(e){console.error(`Failed to migrate form map ID:`,e)}finally{setTimeout(()=>{m(e=>({...e,[a]:!1}))},500)}}else{u(t=>({...t,[e]:r})),m(t=>({...t,[e]:!0}));try{await(0,i.setDoc)((0,i.doc)(t.Ht,`sys_forms`,e),r),localStorage.setItem(`fbos_custom_form_${e}`,`true`),localStorage.setItem(`fbos_form_${e}`,JSON.stringify(r))}catch(e){console.error(`Failed to save form:`,e)}finally{setTimeout(()=>{m(t=>({...t,[e]:!1}))},500)}}},j=(e,t,n)=>O(e,{...t,...n}),M=(e,t,n)=>{let r={...t,...n};O(e,r),A(e,r)},N=e=>{let t=D.current[e];t&&A(e,t)},P=(e,t,n)=>M(e,t,{fields:n}),F=async e=>{if(!$i.has(e)){w(!0);try{await(0,i.deleteDoc)((0,i.doc)(t.Ht,`sys_forms`,e)),u(t=>{let n={...t};return delete n[e],n}),n(`/forms`)}catch(e){console.error(`Failed to delete form`,e)}finally{w(!1),S(null)}}},I=async e=>{if(!_.has(e)){S(null);return}w(!0);let n=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},r=$i.has(e)||!!n[e]||!!a?.defaultConfigs?.[e]||!!a?.defaultConfigs?.[`${e}Form`];try{r?(m(t=>({...t,[e]:!0})),await(0,i.deleteDoc)((0,i.doc)(t.Ht,`sys_forms`,e)),localStorage.removeItem(`fbos_form_${e}`),localStorage.removeItem(`fbos_custom_form_${e}`),await k(),setTimeout(()=>m(t=>({...t,[e]:!1})),500)):await A(e,o().contact||o().support)}catch(e){console.error(`Reset failed:`,e)}finally{w(!1),S(null)}};if(e!==`admin`)return(0,s.jsx)(`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,s.jsx)($r,{})});let L=e=>{b(t=>{let n={...t,[e]:!t[e]};if(n[e])window.history.replaceState(null,``,`/forms/${e}`);else{let e=Object.keys(n).filter(e=>n[e]);e.length>0?window.history.replaceState(null,``,`/forms/${e[0]}`):window.history.replaceState(null,``,`/forms`)}return n})},R=Object.keys(y).find(e=>y[e]),z=(e,n,r,i,a)=>{let o=(t,r)=>{let o=a.map((e,n)=>n===i?{...e,...t}:e);r?P(e,n,o):j(e,n,{fields:o})},c=t=>{let r=i+t;if(r<0||r>=a.length)return;let o=[...a];[o[i],o[r]]=[o[r],o[i]],P(e,n,o)},l=r.type!==`checkbox`&&r.type!==`select`&&r.type!==`date`&&r.type!==`file`;return(0,s.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] p-4 sm:p-5 flex flex-col gap-5`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,s.jsxs)(`span`,{className:`text-[13px] font-bold text-foreground`,children:[`Question `,i+1,` `,(0,s.jsxs)(`span`,{className:`text-foreground/40 font-medium`,children:[`· `,na(r.type)]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,s.jsx)(Q,{icon:t.kt,disabled:i===0,title:`Move up`,onClick:()=>c(-1),children:`Up`}),(0,s.jsx)(Q,{icon:t.Nt,disabled:i===a.length-1,title:`Move down`,onClick:()=>c(1),children:`Down`}),(0,s.jsx)(Q,{icon:t.E,tone:`danger`,title:`Remove question ${i+1}`,onClick:()=>P(e,n,a.filter((e,t)=>t!==i)),children:`Remove`})]})]}),(0,s.jsx)(De,{label:`Question`,hint:`What you are asking for, in the words the person will read.`,value:r.label||``,placeholder:`e.g. What is your budget?`,onChange:e=>o({label:e,name:sa(r,e,a)},!1),onBlur:()=>N(e)}),(0,s.jsx)(Ae,{label:`Kind of answer`,hint:`Sets the box people type into and what counts as a valid answer.`,value:r.type||`text`,options:ra(r.type),allowEmpty:!1,onChange:e=>o(e===`select`?{type:e,options:r.options||[]}:{type:e},!0)}),(0,s.jsx)(je,{label:`Required`,hint:`On means the form cannot be sent until this is answered.`,enabled:!!r.required,onChange:e=>o({required:e},!0)}),r.type===`select`&&(0,s.jsx)(ua,{choices:r.options||[],onChange:e=>o({options:e},!0)}),r.type===`file`&&(0,s.jsx)(De,{label:`Words on the upload box`,hint:`What the box says before a file is picked. Leave it empty for “Attach a file”.`,value:r.placeholder||``,placeholder:`Attach a file`,onChange:e=>o({placeholder:e},!1),onBlur:()=>N(e)}),r.type===`currency`&&(0,s.jsx)(De,{label:`Currency symbol`,hint:`Shown inside the box, before the amount.`,value:r.currencySymbol||``,placeholder:`$`,onChange:e=>o({currencySymbol:e},!1),onBlur:()=>N(e)}),l&&(0,s.jsx)(De,{label:`Example answer`,hint:`Faint grey text inside the box, to show people what you expect.`,value:r.placeholder||``,placeholder:`e.g. jane@example.com`,onChange:e=>o({placeholder:e},!1),onBlur:()=>N(e)})]},i)},B=(e,n)=>{let r=T[e]||n,i=$i.has(e),a=r.formType||`public`,o=r.fields||[],c=_.has(e);return(0,s.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,s.jsxs)(Te,{icon:t.C,title:`Basics`,description:`What people see at the top of this form and on its button.`,children:[(0,s.jsx)(De,{label:`Form name`,hint:`The heading at the top of the form.`,value:r.title||``,placeholder:`e.g. Get in touch`,onChange:t=>j(e,r,{title:t}),onBlur:()=>N(e)}),(0,s.jsx)(De,{label:`Button text`,hint:`The words on the button that sends the form.`,value:r.buttonName||r.submitText||``,placeholder:`e.g. Send message`,onChange:t=>j(e,r,{buttonName:t,submitText:t}),onBlur:()=>N(e)})]}),(0,s.jsx)(Te,{icon:t.b,title:`Who it is for`,description:`Who can fill this in, and where their answers land.`,children:(0,s.jsx)(Ae,{label:`Who it is for`,hint:`Who can fill this in follows the page this form was made for, so it cannot change here. Changing it after answers arrive would file new answers under the wrong list in your Inbox.`,value:a,allowEmpty:!1,disabled:!0,options:[{value:`public`,label:`Anyone`},{value:`private`,label:`Signed-in users`}],onChange:t=>M(e,r,{formType:t})})}),(0,s.jsx)(Te,{icon:t.M,title:`After sending`,description:`What happens the moment someone sends this form.`,children:(0,s.jsx)(De,{label:`Where to send them next`,hint:`Leave this empty to show a thank-you message instead. Or give a web address, like /pricing, to take them there.`,value:r.redirectTo||``,placeholder:`/pricing`,onChange:t=>j(e,r,{redirectTo:t}),onBlur:()=>N(e)})}),(0,s.jsxs)(Te,{icon:t.K,title:`Questions`,description:`Everything this form asks for, in the order people answer it.`,actions:(0,s.jsx)(Q,{icon:t.I,compact:!0,title:`Add a question`,onClick:()=>P(e,r,[...o,ca()]),children:`Add question`}),children:[o.length===0?(0,s.jsx)(`p`,{className:`text-[12.5px] text-foreground/55 font-medium leading-relaxed`,children:`No questions yet. Add the first one with the button above.`}):o.map((t,n)=>z(e,r,t,n,o)),o.length>0&&(0,s.jsx)(`div`,{className:`flex justify-start`,children:(0,s.jsx)(Q,{icon:t.I,onClick:()=>P(e,r,[...o,ca()]),children:`Add question`})})]}),(c||!i)&&(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[c&&(0,s.jsx)(Q,{icon:t.P,tone:`danger`,compact:!0,title:`Reset this form`,onClick:()=>S({kind:`reset`,id:e}),children:`Reset this form`}),!i&&(0,s.jsx)(Q,{icon:t.E,tone:`danger`,compact:!0,title:`Delete this form`,onClick:()=>S({kind:`delete`,id:e}),children:`Delete this form`})]}),(0,s.jsx)(Ze,{compact:!0,title:`Ask your assistant to put this form on a page`,prompt:la.forPage(r.title||``,e)})]})};return(0,s.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,s.jsx)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:`Forms`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/forms`,R?`/${R}`:``]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(`div`,{className:`flex flex-col glass-panel border-y sm:border border-[var(--panel-border)] rounded-none sm:rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background -mx-4 sm:mx-0`,children:[(0,s.jsx)(`div`,{className:`flex items-start justify-between gap-3 sm:gap-6 mb-4 pb-4 md:mb-6 md:pb-6 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0 px-4 pt-5 sm:px-6 sm:pt-6 md:px-10 md:pt-10 bg-background/50`,children:(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-lg md:text-xl font-extrabold text-foreground tracking-tight leading-tight md:leading-7`,children:`Your forms`}),(0,s.jsxs)(`p`,{className:`text-[12.5px] md:text-[14px] font-medium text-foreground/60 mt-1 md:mt-2 leading-relaxed`,children:[(0,s.jsx)(`span`,{className:`md:hidden`,children:`Look a form over and touch it up. Answers arrive in your Inbox.`}),(0,s.jsx)(`span`,{className:`max-md:hidden`,children:`Look a form over and touch it up — its name, button text and questions. New forms are made on the Pages screen, with their page. Answers arrive in your Inbox.`})]})]})}),(0,s.jsx)(`div`,{className:`p-4 sm:p-6 md:p-8 flex flex-col gap-4 overflow-y-auto`,children:Object.keys(l).length===0&&!d?(0,s.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 p-10 glass-panel rounded-3xl border border-[var(--panel-border)] border-dashed`,children:[(0,s.jsx)(t.F,{className:`w-6 h-6 text-foreground/40`}),(0,s.jsx)(`p`,{className:`text-[13px] font-bold text-foreground/60`,children:`You have no forms yet.`}),(0,s.jsx)(`p`,{className:`text-[12.5px] text-foreground/55 font-medium leading-relaxed text-center max-w-md`,children:la.firstForm})]})}):(0,s.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,s.jsx)(t.p,{children:Object.entries(l).map(([e,n])=>{let r=T[e]||n,i=y[e],a=p[e],o=(r.fields||[]).length;return(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},transition:{duration:.35,ease:`easeOut`},onClick:()=>L(e),className:`group flex flex-col p-3 px-4 glass-panel border transition-all rounded-2xl hover:shadow-sm cursor-pointer hover:border-accent/40 ${i?`border-[var(--panel-border)] bg-background/50`:`border-transparent hover:border-[var(--panel-border)]`} flex-shrink-0 ${r.enabled===!1?`opacity-40 grayscale bg-foreground/[0.01] border-[var(--panel-border)]/50`:``}`,children:[(0,s.jsxs)(`div`,{className:`flex flex-row items-start md:items-center justify-between w-full gap-2`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1 pr-2 sm:pr-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`h3`,{className:`text-[14px] font-bold text-foreground break-words ml-1 leading-snug`,children:r.title||`Untitled form`}),a&&(0,s.jsx)(t.G,{className:`w-3 h-3 animate-spin text-accent ml-2 shrink-0`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5 ml-1`,children:[(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold px-2.5 py-[3px] rounded-full border shrink-0 ${r.formType===`private`?`text-blue-500 border-blue-500/25 bg-blue-500/[0.07]`:`text-emerald-500 border-emerald-500/25 bg-emerald-500/[0.07]`}`,children:[(0,s.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${r.formType===`private`?`bg-blue-500`:`bg-emerald-500`}`}),ia[r.formType||`public`]]}),(0,s.jsx)(`span`,{className:`max-sm:hidden text-[11px] font-medium text-foreground/45`,children:o===1?`1 question`:`${o} questions`})]})]}),(0,s.jsxs)(`div`,{className:`max-md:hidden flex items-center gap-1.5 shrink-0`,children:[(0,s.jsx)(Q,{icon:t.st,title:`Preview this form`,onClick:e=>{e.stopPropagation(),g(r)},children:(0,s.jsx)(`span`,{className:`max-md:hidden`,children:`Preview`})}),(0,s.jsx)(`div`,{className:`p-1.5 transition-transform duration-300 text-foreground/40 ${i?`rotate-180`:``}`,children:(0,s.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,s.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})})]}),(0,s.jsxs)(`div`,{className:`flex md:hidden items-center gap-0.5 shrink-0 -mt-0.5 -mr-1.5`,children:[(0,s.jsx)(`button`,{type:`button`,title:`Preview this form`,"aria-label":`Preview this form`,onClick:e=>{e.stopPropagation(),g(r)},className:`w-8 h-8 flex items-center justify-center rounded-lg text-foreground/40 hover:text-accent hover:bg-foreground/5 transition-colors cursor-pointer`,children:(0,s.jsx)(t.st,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{type:`button`,title:i?`Close this form`:`Open this form`,"aria-label":i?`Close this form`:`Open this form`,"aria-expanded":i,onClick:t=>{t.stopPropagation(),L(e)},className:`w-8 h-8 flex items-center justify-center rounded-lg text-foreground/40 hover:text-accent hover:bg-foreground/5 transition-colors cursor-pointer`,children:(0,s.jsx)(t.Ct,{className:`w-4 h-4 transition-transform duration-300 ${i?`rotate-180`:``}`})})]})]}),(0,s.jsx)(t.p,{children:i&&(0,s.jsx)(t.f.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50`,onClick:e=>e.stopPropagation(),children:B(e,n)})})]},n._uiKey||e)})}),d&&(0,s.jsxs)(`div`,{className:`flex items-center justify-center gap-3 p-6 glass-panel rounded-2xl border border-[var(--panel-border)]/40 bg-foreground/[0.01] mt-2 animate-pulse`,children:[(0,s.jsx)(t.G,{className:`w-4 h-4 animate-spin text-accent`}),(0,s.jsx)(`span`,{className:`text-[12px] font-bold text-foreground/50 tracking-wider uppercase select-none`,children:`Loading your forms`})]})]})})]})]}),(0,s.jsx)(_e,{isOpen:!!x,onCancel:()=>S(null),onConfirm:()=>{x&&(x.kind===`delete`?F(x.id):I(x.id))},title:x?.kind===`reset`?`Reset this form`:`Delete this form`,message:x?.kind===`reset`?`Undo every change made to ${l[x.id]?.title||x.id} and put it back the way it shipped. Answers already collected are kept.`:`Permanently delete ${x?l[x.id]?.title||x.id:``}. This cannot be undone. Answers already collected are kept.`,confirmText:x?.kind===`reset`?`Reset form`:`Delete form`,isProcessing:C}),h&&(0,s.jsx)(t.t,{formConfig:h,onClose:()=>g(null)})]})}var fa=`src/your-ai-workflow-firebase-os`;function pa(){let e=new Set;for(let[t,n]of N()){let r=n?.config?.route,i=typeof r==`string`&&r.trim()?r.startsWith(`/`)?r:`/`+r:`/`+t.toLowerCase();e.add(i)}return[...e].sort()}var ma=e=>(e||``).split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``);function ha(e){let t=e?.contentKey||e?.tabName||e?.pageName||e?.pageId||`Page`;return`${fa}/microcomponents/${ma(String(t))||`Page`}Content.tsx`}function ga(e,t){let n=t.replace(/^.*\//,``).replace(/\.tsx$/,``),r=n.replace(/Content$/,``).replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toLowerCase();return[`My app has a page at ${e} and it is still empty after you said it was done. The ONLY thing that fills this page is one file: ${t}, with a default export, registered in ${fa}/microcomponents/registry.ts.`,`Check these in order and fix whatever is wrong, without asking me questions:`,`1. The file exists at exactly that path and name — not another folder, not another spelling. If you put it somewhere else, move it there.`,`2. It has a default export. A named-only export is silently ignored.`,`3. ${fa}/microcomponents/registry.ts contains these two lines: import ${n} from './${n}'; and registerMicrocomponent('${r}', ${n}); — registerMicrocomponent is imported there from 'your-ai-workflow-firebase-os'. Add them if they are missing, and never remove another page's lines.`,`4. You created nothing else for this page — no config file, no route, no page, and no edit to src/App.tsx or src/main.tsx. Undo any of those you made.`,`Then tell me, in one sentence, which of these was wrong.`].join(`
|
|
49
|
+
`)}function _a(e){return[`The page at ${e} shows "Page Not Found". The app only finds a page when its config file is picked up, so check these in order and fix whatever is wrong, without asking me questions.`,`1. The page's config file sits directly in ${fa}/configs/ and its name ends with Tab.config.ts (a page for signed-in users, my team or admins) or Page.config.ts (a page for anyone). Not in a subfolder, not any other name.`,`2. It exports one const whose name ends with Config, and its route is the single string '${e}'. A page has exactly one web address — remove any other addresses you registered for it.`,`3. ${fa}/configs/pagesRegistry.ts exists and src/main.tsx contains the line import './your-ai-workflow-firebase-os/configs/pagesRegistry'. If either is missing, run npm install so the package's postinstall script restores them.`,`4. Put src/App.tsx back to the version the package wrote: it only mounts <FirebaseOS />. Never add routes, a router or the customRoutes prop.`,`5. If the page is for my team, its config says pageType: 'internal'. Any form on it is a *Form.config.ts file shown through <ContactPopup formId="..." />, never a form you wrote by hand.`,`Then rebuild and tell me, in one sentence, which of these was wrong.`].join(`
|
|
50
|
+
`)}function va({config:e,customContent:n}){let{config:i}=t.Rt(),{userRole:a}=ee();return(0,r.useEffect)(()=>{document.title=e.pageName||e.pageTitle||i.appName||`Your AI Firebase`},[e.pageName,e.pageTitle,i.appName]),(0,s.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 relative min-h-screen`,children:[(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,s.jsx)(se,{children:e.pageTitle||e.pageName||`New Page`}),e.route&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]}),(0,s.jsx)(`div`,{className:`flex justify-between items-center mb-6 pt-2 border-b border-[var(--panel-border)] pb-6 relative z-20 overflow-x-auto no-scrollbar gap-4`,children:(0,s.jsxs)(`button`,{onClick:()=>window.history.back(),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 cursor-pointer shadow-sm text-foreground/70 whitespace-nowrap shrink-0`,children:[(0,s.jsx)(t.Mt,{className:`w-4 h-4`}),` Go Back`]})}),(0,s.jsx)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl shadow-2xl relative flex flex-col flex-1 bg-background/50 h-full min-h-[400px]`,children:n?(0,s.jsx)(`div`,{className:`fbos-content-slot flex-1 p-4 md:p-8`,children:(0,s.jsx)(n,{config:e})}):e.form?(0,s.jsx)(`div`,{className:`fbos-content-slot flex-1 flex flex-col items-center justify-start p-4 md:p-8`,children:(0,s.jsx)(t.t,{isInline:!0,formId:e.form})}):(0,s.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center m-4 md:m-8 gap-6`,children:[(0,s.jsxs)(`div`,{className:`w-full glass-panel border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-16 text-center opacity-70`,children:[(0,s.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/70`,children:`This page is empty`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 max-w-sm leading-relaxed mx-auto`,children:`Open the Pages screen, say what you would like on it, and copy the sentence there into your assistant's chat.`})]}),C(a)&&(0,s.jsx)(`div`,{className:`w-full max-w-lg`,children:(0,s.jsx)(Ze,{compact:!0,title:`Already asked, and it is still empty? Paste this`,prompt:ga(e.route||`/`,ha(e))})})]})})]})}function ya({config:e,customContent:n}){let{user:a}=ee(),{config:c}=t.Rt(),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(!0),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(``),[v,y]=(0,r.useState)(``),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(null),w=(0,r.useRef)(null),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),j=e=>{if(A(e),e){let t=e.fileType||``;P(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},M=k,[N,P]=(0,r.useState)(!0),[F,I]=(0,r.useState)(!1),[L,R]=(0,r.useState)(null),[z,B]=(0,r.useState)(``),[V,te]=(0,r.useState)(``),[H,U]=(0,r.useState)([]),W=(0,r.useRef)(null),G=`user_${(e.tabName||e.pageId||`user_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`)}_records`;(0,r.useEffect)(()=>{document.title=e.tabTitle||e.tabName||c.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,c.appName]),(0,r.useEffect)(()=>{if(!a)return;try{let e=localStorage.getItem(`fbos_records_${G}`);e?(d(JSON.parse(e)),p(!1)):p(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}}),n=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Ht,G),(0,i.where)(`uid`,`==`,a.uid),(0,i.limit)(150)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),d(n),p(!1),localStorage.setItem(`fbos_records_${G}`,JSON.stringify(n))},e=>{console.error(`Error fetching records:`,e),p(!1)});return()=>n()},[a,G]),(0,r.useEffect)(()=>{f||localStorage.setItem(`fbos_records_${G}`,JSON.stringify(u))},[u,f,G]);let K=async e=>{if(e.preventDefault(),!(!a||!g.trim())){x(!0);try{let e=await(0,i.addDoc)((0,i.collection)(t.Ht,G),{name:g.trim(),note:v.trim(),uid:a.uid,recordType:`record`,createdAt:(0,i.serverTimestamp)()});d(t=>[{id:e.id,name:g.trim(),note:v.trim(),uid:a.uid,recordType:`record`,createdAt:Date.now()},...t]),_(``),y(``),h(!1)}catch(e){console.error(`Error saving record:`,e)}x(!1)}},q=async e=>{let n=e.target.files?.[0];if(!(!n||!a)){E(!0);try{let e=`user_files/${`${Date.now()}_${n.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`,r=(0,o.ref)(t.Wt,e);await(0,o.uploadBytes)(r,n,{customMetadata:{ownerId:a.uid}});let s=await(0,o.getDownloadURL)(r);if(w.current)w.current(n,s,{uid:a.uid,storagePath:e});else{let e=await(0,i.addDoc)((0,i.collection)(t.Ht,G),{name:n.name,note:`${n.type||`File`} · ${ve(n.size)}`,uid:a.uid,recordType:`file`,fileName:n.name,fileType:n.type||`unknown`,fileSize:n.size,downloadURL:s,createdAt:(0,i.serverTimestamp)()});d(t=>[{id:e.id,name:n.name,note:`${n.type||`File`} · ${ve(n.size)}`,uid:a.uid,recordType:`file`,fileName:n.name,fileType:n.type,fileSize:n.size,downloadURL:s,createdAt:Date.now()},...t])}}catch(e){console.error(`Error uploading file:`,e)}E(!1),W.current&&(W.current.value=``)}},J=async()=>{if(D){I(!0);try{let e=u.find(e=>e.id===D);if(await(0,i.deleteDoc)((0,i.doc)(t.Ht,G,D)),e?.recordType===`file`&&e.downloadURL)try{let n=e.downloadURL.split(`user_files%2F`)[1]?.split(`?`)[0];n&&await(0,o.deleteObject)((0,o.ref)(t.Wt,`user_files/${decodeURIComponent(n)}`)).catch(()=>{})}catch(e){console.error(`Error cleaning up user file:`,e)}d(e=>e.filter(e=>e.id!==D)),O(null)}catch(e){console.error(`Error deleting record:`,e)}I(!1)}},[Y,ne]=(0,r.useState)(null),[re,ie]=(0,r.useState)(``),[ae,oe]=(0,r.useState)(!1),[X,ce]=(0,r.useState)(null),Z=(0,r.useRef)([]),ue=e=>{if(e.recordType===`file`){ne(e.id),ie(e.name);return}R(e.id),B(e.name),te(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));U(n),Z.current=n.map(e=>e.key)},de=async()=>{if(!Y||!re.trim()){ne(null);return}let e=u.find(e=>e.id===Y);if(e&&e.name===re.trim()){ne(null);return}oe(!0);try{await(0,i.updateDoc)((0,i.doc)(t.Ht,G,Y),{name:re.trim()}),d(e=>e.map(e=>e.id===Y?{...e,name:re.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}oe(!1),ne(null)},fe=async()=>{await pe(),R(null)},pe=async()=>{if(!L||!z.trim())return;x(!0);let e={};H.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let n=H.map(e=>e.key.trim()).filter(Boolean),r=Z.current.filter(e=>!n.includes(e));r.forEach(t=>{e[t]=(0,i.deleteField)()});try{await(0,i.updateDoc)((0,i.doc)(t.Ht,G,L),{name:z.trim(),note:V.trim(),...e}),d(e=>e.map(e=>{if(e.id!==L)return e;let t={...e,name:z.trim(),note:V.trim()};return r.forEach(e=>{delete t[e]}),H.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),Z.current=n}catch(e){console.error(`Error saving record:`,e)}x(!1)},me=(e,n)=>e?e.startsWith(`image/`)?n?(0,s.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${n})`}}):(0,s.jsx)(t.tt,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,s.jsx)(t.y,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,s.jsx)(t.at,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,s.jsx)(t.Ft,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,s.jsx)(t.pt,{className:`w-4 h-4`}):(0,s.jsx)(t.it,{className:`w-4 h-4`}):(0,s.jsx)(t.at,{className:`w-4 h-4`}),he=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,ge=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},ve=e=>{if(!e)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]},ye=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},be=(()=>{let n=(e.buttonStorageIcon||`upload`).trim(),r=n.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return t.m[r]?t.m[r]:t.m[n]?t.m[n]:t.S||t.I})(),xe=e.buttonStyle!==`secondary`,Se=e.buttonStorageStyle===`primary`;return(0,s.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,s.jsx)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:e.tabTitle||e.tabName||`User Page`}),e.route&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,s.jsx)(`input`,{type:`file`,ref:W,onChange:q,className:`hidden`}),!n&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 sm:gap-4 p-4 sm:p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:f?`Loading…`:`${u.length} ${u.length===1?`item`:`items`}`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.storage!==!1&&(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(t.f.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>W.current?.click(),disabled:T,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${Se?`btn-primary`:`btn-secondary`}`,children:[T?(0,s.jsx)(t.G,{className:`w-4 h-4 animate-spin`}):(0,s.jsx)(be,{className:`w-4 h-4`}),e.buttonStorageText&&(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,s.jsx)(t.f.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${xe?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,s.jsx)(t.I,{className:`w-4 h-4`}):(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,s.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[f&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,s.jsx)(t.G,{className:`w-8 h-8 text-accent animate-spin`})}),n?(0,s.jsx)(`div`,{className:`fbos-content-slot`,children:(0,s.jsx)(n,{config:e,actions:{records:u,loading:f,collection:G,user:a,saveRecord:async e=>{let n={id:`temp_`+Date.now(),uid:a.uid,recordType:`record`,createdAt:Date.now(),...e};d(e=>[n,...e]),await(0,i.addDoc)((0,i.collection)(t.Ht,G),{uid:a.uid,recordType:`record`,createdAt:(0,i.serverTimestamp)(),...e})},updateRecord:async(e,n)=>{d(t=>t.map(t=>t.id===e?{...t,...n}:t)),await(0,i.updateDoc)((0,i.doc)(t.Ht,G,e),n)},deleteRecord:async e=>{await(0,i.deleteDoc)((0,i.doc)(t.Ht,G,e))},startEdit:e=>ue(e),confirmDelete:e=>O(e),uploadFile:()=>W.current?.click(),openAddForm:()=>h(!0),setAddForm:e=>C(()=>e),setFileHandler:e=>{w.current=e}}})}):(0,s.jsxs)(s.Fragment,{children:[!f&&u.length===0&&(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,s.jsx)(t.I,{className:`w-6 h-6 text-accent/40`})}),(0,s.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files to get started`})]}),!f&&u.length>0&&(0,s.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,s.jsx)(t.p,{children:u.map((e,n)=>{let r=L===e.id;return(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},transition:{delay:n*.03,duration:.25},onClick:()=>ue(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative cursor-pointer ${r?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,s.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),ce(e.id),setTimeout(()=>ce(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:X===e.id?(0,s.jsx)(t.wt,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,s.jsx)(t.q,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,s.jsx)(t.ut,{className:`w-3.5 h-3.5`})})]}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ue(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,s.jsx)(t.L,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),O(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.E,{className:`w-3.5 h-3.5`})})]}),(0,s.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,s.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&j(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${he(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?me(e.fileType,e.downloadURL):(0,s.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[Y===e.id?(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,value:re,onChange:e=>ie(e.target.value),onBlur:()=>de(),onKeyDown:e=>{e.key===`Enter`&&de(),e.key===`Escape`&&ne(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>j(e)}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:ye(e.createdAt)})]})]}),e.note&&(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,s.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e))]},e.id)})})})]})]})]})]}),(0,s.jsx)(t.p,{children:m&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.f.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:S?r.default.createElement(S,{onSave:async e=>{x(!0);try{await(0,i.addDoc)((0,i.collection)(t.Ht,G),{uid:a.uid,recordType:`record`,createdAt:(0,i.serverTimestamp)(),...e}),h(!1)}catch(e){console.error(`Error saving record:`,e)}x(!1)},onClose:()=>!b&&h(!1),saving:b}):(0,s.jsxs)(`form`,{onSubmit:K,className:`p-5 flex flex-col gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,s.jsx)(t._,{className:`w-4 h-4`})})]}),(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,s.jsx)(t.s,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,l.createPortal)((0,s.jsx)(t.p,{children:M&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,s.jsx)(t.f.div,{onClick:()=>j(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,s.jsx)(`button`,{onClick:()=>j(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 outline-none`,children:(0,s.jsx)(t._,{className:`w-5 h-5`})}),(0,s.jsxs)(t.f.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,s.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,s.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,s.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:M.fileName||M.name}),(0,s.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[ge(M.fileType),` • `,ve(M.fileSize||0)]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(M.downloadURL),ce(`preview`),setTimeout(()=>ce(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:X===`preview`?(0,s.jsx)(t.wt,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.q,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),ne(M.id),ie(M.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,s.jsx)(t.L,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),O(M.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.E,{className:`w-4 h-4`})}),(0,s.jsx)(`a`,{href:M.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,s.jsx)(t.ut,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>j(null),children:(0,s.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[N&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,s.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,s.jsx)(t.G,{className:`w-5 h-5 text-accent animate-spin`})})}),M.fileType?.startsWith(`image/`)?(0,s.jsx)(`img`,{onLoad:()=>P(!1),onError:()=>P(!1),src:M.downloadURL,alt:M.fileName||M.name,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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType?.startsWith(`video/`)?(0,s.jsx)(`video`,{onLoadedData:()=>P(!1),onError:()=>P(!1),src:M.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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType===`application/pdf`?(0,s.jsx)(`iframe`,{onLoad:()=>P(!1),src:M.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${N?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,s.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(),P(!1)},children:[(0,s.jsx)(t.at,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,s.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,s.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,s.jsx)(t.p,{children:L&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{onClick:()=>fe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.f.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,s.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,s.jsx)(t.G,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>fe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,s.jsx)(t._,{className:`w-4 h-4`})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`input`,{autoFocus:!0,required:!0,value:z,onChange:e=>B(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>pe(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:V,onChange:e=>{te(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>pe(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),H.map((e,n)=>(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let t=[...H];t[n].key=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>pe(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,s.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let t=[...H];t[n].value=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>pe(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>U(H.filter((e,t)=>t!==n)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,s.jsx)(t._,{className:`w-3 h-3`})})]},n)),(0,s.jsxs)(`button`,{type:`button`,onClick:()=>U([...H,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,s.jsx)(t.I,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,s.jsx)(_e,{isOpen:!!D,onCancel:()=>O(null),onConfirm:J,title:`Delete Record`,message:(0,s.jsxs)(s.Fragment,{children:[`Are you sure you want to delete `,(0,s.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:u.find(e=>e.id===D)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:F})]})}function ba({config:e,customContent:n}){let{user:a}=ee(),{config:c}=t.Rt(),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(!0),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(``),[v,y]=(0,r.useState)(``),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(null),w=(0,r.useRef)(null),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),j=e=>{if(A(e),e){let t=e.fileType||``;P(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},M=k,[N,P]=(0,r.useState)(!0),[F,I]=(0,r.useState)(!1),[L,R]=(0,r.useState)(null),[z,B]=(0,r.useState)(``),[V,te]=(0,r.useState)(``),[H,U]=(0,r.useState)([]),W=(0,r.useRef)(null),[G,K]=(0,r.useState)(null),q=(0,r.useRef)([]),J=`admin_${(e.tabName||e.pageId||`admin_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`)}_records`;(0,r.useEffect)(()=>{document.title=e.tabTitle||e.tabName||c.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,c.appName]);let Y=()=>({name:a.displayName||a.email?.split(`@`)[0]||`Admin`,email:a.email||``,avatar:a.photoURL||``});(0,r.useEffect)(()=>{if(!a)return;try{let e=localStorage.getItem(`fbos_records_${J}`);e?(d(JSON.parse(e)),p(!1)):p(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}}),n=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Ht,J),(0,i.orderBy)(`createdAt`,`desc`),(0,i.limit)(150)),t=>{let n=e(t.docs);d(n),p(!1),localStorage.setItem(`fbos_records_${J}`,JSON.stringify(n))},n=>{console.error(`Error listening to admin records:`,n);let r=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Ht,J),(0,i.limit)(150)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),d(n),p(!1),localStorage.setItem(`fbos_records_${J}`,JSON.stringify(n))});return()=>r()});return()=>n()},[a,J]);let ne=async e=>{if(e.preventDefault(),!(!a||!g.trim())){x(!0);try{let e=Y();await(0,i.addDoc)((0,i.collection)(t.Ht,J),{name:g.trim(),note:v.trim(),uid:a.uid,recordType:`record`,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,i.serverTimestamp)()}),_(``),y(``),h(!1)}catch(e){console.error(`Error saving admin record:`,e)}x(!1)}},re=async e=>{let n=e.target.files?.[0];if(!(!n||!a)){E(!0);try{let e=`admin_files/${`${Date.now()}_${n.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`,r=(0,o.ref)(t.Wt,e);await(0,o.uploadBytes)(r,n,{customMetadata:{ownerId:a.uid}});let s=await(0,o.getDownloadURL)(r);if(w.current)w.current(n,s,{uid:a.uid,storagePath:e});else{let e=Y();await(0,i.addDoc)((0,i.collection)(t.Ht,J),{name:n.name,note:`${n.type||`File`} · ${ye(n.size)}`,uid:a.uid,recordType:`file`,fileName:n.name,fileType:n.type||`unknown`,fileSize:n.size,downloadURL:s,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,i.serverTimestamp)()})}}catch(e){console.error(`Error uploading admin file:`,e)}E(!1),W.current&&(W.current.value=``)}},ie=async()=>{if(D){I(!0);try{let e=u.find(e=>e.id===D);if(await(0,i.deleteDoc)((0,i.doc)(t.Ht,J,D)),e?.recordType===`file`&&e.downloadURL)try{let n=e.downloadURL.split(`admin_files%2F`)[1]?.split(`?`)[0];n&&await(0,o.deleteObject)((0,o.ref)(t.Wt,`admin_files/${decodeURIComponent(n)}`)).catch(()=>{})}catch(e){console.error(`Error cleaning up admin file:`,e)}O(null)}catch(e){console.error(`Error deleting admin record:`,e)}I(!1)}},[ae,oe]=(0,r.useState)(null),[X,ce]=(0,r.useState)(``),[Z,ue]=(0,r.useState)(!1),de=e=>{if(e.recordType===`file`){oe(e.id),ce(e.name);return}R(e.id),B(e.name),te(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));U(n),q.current=n.map(e=>e.key)},fe=async()=>{if(!ae||!X.trim()){oe(null);return}let e=u.find(e=>e.id===ae);if(e&&e.name===X.trim()){oe(null);return}ue(!0);try{await(0,i.updateDoc)((0,i.doc)(t.Ht,J,ae),{name:X.trim()}),d(e=>e.map(e=>e.id===ae?{...e,name:X.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}ue(!1),oe(null)},pe=async()=>{if(!L||!z.trim()){R(null);return}x(!0);let e={};H.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let n=H.map(e=>e.key.trim()).filter(Boolean),r=q.current.filter(e=>!n.includes(e));r.forEach(t=>{e[t]=(0,i.deleteField)()});try{await(0,i.updateDoc)((0,i.doc)(t.Ht,J,L),{name:z.trim(),note:V.trim(),...e}),d(e=>e.map(e=>{if(e.id!==L)return e;let t={...e,name:z.trim(),note:V.trim()};return r.forEach(e=>{delete t[e]}),H.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),q.current=n}catch(e){console.error(`Error updating record:`,e)}x(!1),R(null)},me=async()=>{if(!L||!z.trim())return;let e={};H.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let n=H.map(e=>e.key.trim()).filter(Boolean),r=q.current.filter(e=>!n.includes(e));r.forEach(t=>{e[t]=(0,i.deleteField)()});try{await(0,i.updateDoc)((0,i.doc)(t.Ht,J,L),{name:z.trim(),note:V.trim(),...e}),d(e=>e.map(e=>{if(e.id!==L)return e;let t={...e,name:z.trim(),note:V.trim()};return r.forEach(e=>{delete t[e]}),H.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),q.current=n}catch(e){console.error(`Error silently saving record:`,e)}},he=(e,n)=>e?e.startsWith(`image/`)?n?(0,s.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${n})`}}):(0,s.jsx)(t.tt,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,s.jsx)(t.y,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,s.jsx)(t.at,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,s.jsx)(t.Ft,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,s.jsx)(t.pt,{className:`w-4 h-4`}):(0,s.jsx)(t.it,{className:`w-4 h-4`}):(0,s.jsx)(t.at,{className:`w-4 h-4`}),ge=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,ve=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},ye=e=>{if(!e)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]},be=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},xe=(()=>{let n=(e.buttonStorageIcon||`upload`).trim(),r=n.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return t.m[r]?t.m[r]:t.m[n]?t.m[n]:t.S||t.I})(),Se=e.buttonStyle!==`secondary`,Ce=e.buttonStorageStyle===`primary`,we=e=>e.uid===a?.uid,Q=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Admin`,n=e.creatorEmail||``,r=e.creatorAvatar||``,i=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[r?(0,s.jsx)(`img`,{src:r,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:i}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,s.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};return(0,s.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,s.jsx)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:e.tabTitle||e.tabName||`Admin Page`}),e.route&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,s.jsx)(`input`,{type:`file`,ref:W,onChange:re,className:`hidden`}),!n&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 sm:gap-4 p-4 sm:p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:f?`Loading…`:`${u.length} ${u.length===1?`item`:`items`}`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.storage!==!1&&(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(t.f.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>W.current?.click(),disabled:T,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${Ce?`btn-primary`:`btn-secondary`}`,children:[T?(0,s.jsx)(t.G,{className:`w-4 h-4 animate-spin`}):(0,s.jsx)(xe,{className:`w-4 h-4`}),e.buttonStorageText&&(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,s.jsx)(t.f.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${Se?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,s.jsx)(t.I,{className:`w-4 h-4`}):(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,s.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[f&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,s.jsx)(t.G,{className:`w-8 h-8 text-accent animate-spin`})}),n?(0,s.jsx)(`div`,{className:`fbos-content-slot`,children:(0,s.jsx)(n,{config:e,actions:{records:u,loading:f,collection:J,user:a,saveRecord:async e=>{let n=Y(),r={id:`temp_`+Date.now(),uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:Date.now(),...e};d(e=>[r,...e]),await(0,i.addDoc)((0,i.collection)(t.Ht,J),{uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:(0,i.serverTimestamp)(),...e})},updateRecord:async(e,n)=>{d(t=>t.map(t=>t.id===e?{...t,...n}:t)),await(0,i.updateDoc)((0,i.doc)(t.Ht,J,e),n)},deleteRecord:async e=>{await(0,i.deleteDoc)((0,i.doc)(t.Ht,J,e))},startEdit:e=>de(e),confirmDelete:e=>O(e),uploadFile:()=>W.current?.click(),openAddForm:()=>h(!0),setAddForm:e=>C(()=>e),setFileHandler:e=>{w.current=e}}})}):(0,s.jsxs)(s.Fragment,{children:[!f&&u.length===0&&(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,s.jsx)(t.I,{className:`w-6 h-6 text-accent/40`})}),(0,s.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files. All admins can view and contribute.`})]}),!f&&u.length>0&&(0,s.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,s.jsx)(t.p,{children:u.map((e,n)=>{let r=L===e.id,i=we(e);return(0,s.jsxs)(t.f.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>de(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative cursor-pointer ${r?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,s.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),K(e.id),setTimeout(()=>K(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:G===e.id?(0,s.jsx)(t.wt,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,s.jsx)(t.q,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,s.jsx)(t.ut,{className:`w-3.5 h-3.5`})})]}),i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,s.jsx)(t.L,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),O(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.E,{className:`w-3.5 h-3.5`})})]})]}),(0,s.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,s.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&j(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${ge(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?he(e.fileType,e.downloadURL):(0,s.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[ae===e.id?(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,value:X,onChange:e=>ce(e.target.value),onBlur:()=>fe(),onKeyDown:e=>{e.key===`Enter`&&fe(),e.key===`Escape`&&oe(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>j(e)}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:be(e.createdAt)})]})]}),e.note&&(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,s.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,s.jsx)(Q,{record:e})]},e.id)})})})]})]})]})]}),(0,s.jsx)(t.p,{children:m&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.f.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:S?r.default.createElement(S,{onSave:async e=>{x(!0);try{let n=Y();await(0,i.addDoc)((0,i.collection)(t.Ht,J),{uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:(0,i.serverTimestamp)(),...e}),h(!1)}catch(e){console.error(`Error saving record:`,e)}x(!1)},onClose:()=>!b&&h(!1),saving:b}):(0,s.jsxs)(`form`,{onSubmit:ne,className:`p-5 flex flex-col gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,s.jsx)(t._,{className:`w-4 h-4`})})]}),(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,s.jsx)(t.s,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,l.createPortal)((0,s.jsx)(t.p,{children:M&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,s.jsx)(t.f.div,{onClick:()=>j(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,s.jsx)(`button`,{onClick:()=>j(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 outline-none`,children:(0,s.jsx)(t._,{className:`w-5 h-5`})}),(0,s.jsxs)(t.f.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,s.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,s.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,s.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:M.fileName||M.name}),(0,s.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[ve(M.fileType),` • `,ye(M.fileSize||0)]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(M.downloadURL),K(`preview`),setTimeout(()=>K(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:G===`preview`?(0,s.jsx)(t.wt,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.q,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),oe(M.id),ce(M.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,s.jsx)(t.L,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),O(M.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.E,{className:`w-4 h-4`})}),(0,s.jsx)(`a`,{href:M.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,s.jsx)(t.ut,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>j(null),children:(0,s.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[N&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,s.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,s.jsx)(t.G,{className:`w-5 h-5 text-accent animate-spin`})})}),M.fileType?.startsWith(`image/`)?(0,s.jsx)(`img`,{onLoad:()=>P(!1),onError:()=>P(!1),src:M.downloadURL,alt:M.fileName||M.name,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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType?.startsWith(`video/`)?(0,s.jsx)(`video`,{onLoadedData:()=>P(!1),onError:()=>P(!1),src:M.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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType===`application/pdf`?(0,s.jsx)(`iframe`,{onLoad:()=>P(!1),src:M.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${N?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,s.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(),P(!1)},children:[(0,s.jsx)(t.at,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,s.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,s.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,s.jsx)(t.p,{children:L&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{onClick:()=>pe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.f.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,s.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,s.jsx)(t.G,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>pe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,s.jsx)(t._,{className:`w-4 h-4`})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`input`,{autoFocus:!0,required:!0,value:z,onChange:e=>B(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>me(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:V,onChange:e=>{te(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>me(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),H.map((e,n)=>(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let t=[...H];t[n].key=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>me(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,s.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let t=[...H];t[n].value=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>me(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>U(H.filter((e,t)=>t!==n)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,s.jsx)(t._,{className:`w-3 h-3`})})]},n)),(0,s.jsxs)(`button`,{type:`button`,onClick:()=>U([...H,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,s.jsx)(t.I,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,s.jsx)(_e,{isOpen:!!D,onCancel:()=>O(null),onConfirm:ie,title:`Delete Record`,message:(0,s.jsxs)(s.Fragment,{children:[`Are you sure you want to delete `,(0,s.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:u.find(e=>e.id===D)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:F})]})}function xa({config:e,customContent:n}){let{user:a}=ee(),{config:c}=t.Rt(),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(!0),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(``),[v,y]=(0,r.useState)(``),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(null),w=(0,r.useRef)(null),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),j=e=>{if(A(e),e){let t=e.fileType||``;P(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},M=k,[N,P]=(0,r.useState)(!0),[F,I]=(0,r.useState)(!1),[L,R]=(0,r.useState)(null),[z,B]=(0,r.useState)(``),[V,te]=(0,r.useState)(``),[H,U]=(0,r.useState)([]),W=(0,r.useRef)(null),[G,K]=(0,r.useState)(null),q=(0,r.useRef)([]),J=`mem_${(e.tabName||e.pageId||`internal_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`)}_records`;(0,r.useEffect)(()=>{document.title=e.tabTitle||e.tabName||c.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,c.appName]),(0,r.useEffect)(()=>{if(!a)return;try{let e=localStorage.getItem(`fbos_records_${J}`);e?(d(JSON.parse(e)),p(!1)):p(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}}),n=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Ht,J),(0,i.orderBy)(`createdAt`,`desc`),(0,i.limit)(150)),t=>{let n=e(t.docs);d(n),p(!1),localStorage.setItem(`fbos_records_${J}`,JSON.stringify(n))},n=>{console.error(`Error listening to shared records:`,n);let r=(0,i.onSnapshot)((0,i.query)((0,i.collection)(t.Ht,J),(0,i.limit)(150)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),d(n),p(!1),localStorage.setItem(`fbos_records_${J}`,JSON.stringify(n))});return()=>r()});return()=>n()},[a,J]);let Y=()=>({name:a.displayName||a.email?.split(`@`)[0]||`Member`,email:a.email||``,avatar:a.photoURL||``}),ne=async e=>{if(e.preventDefault(),!(!a||!g.trim())){x(!0);try{let e=Y();await(0,i.addDoc)((0,i.collection)(t.Ht,J),{name:g.trim(),note:v.trim(),uid:a.uid,recordType:`record`,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,i.serverTimestamp)()}),_(``),y(``),h(!1)}catch(e){console.error(`Error saving shared record:`,e)}x(!1)}},re=async e=>{let n=e.target.files?.[0];if(!(!n||!a)){E(!0);try{let e=`mem_files/${`${Date.now()}_${n.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`,r=(0,o.ref)(t.Wt,e);await(0,o.uploadBytes)(r,n,{customMetadata:{ownerId:a.uid}});let s=await(0,o.getDownloadURL)(r);if(w.current)w.current(n,s,{uid:a.uid,storagePath:e});else{let e=Y();await(0,i.addDoc)((0,i.collection)(t.Ht,J),{name:n.name,note:`${n.type||`File`} · ${ye(n.size)}`,uid:a.uid,recordType:`file`,fileName:n.name,fileType:n.type||`unknown`,fileSize:n.size,downloadURL:s,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,i.serverTimestamp)()})}}catch(e){console.error(`Error uploading shared file:`,e)}E(!1),W.current&&(W.current.value=``)}},ie=async()=>{if(D){I(!0);try{let e=u.find(e=>e.id===D);if(await(0,i.deleteDoc)((0,i.doc)(t.Ht,J,D)),e?.recordType===`file`&&e.downloadURL)try{let n=e.downloadURL.split(`mem_files%2F`)[1]?.split(`?`)[0];n&&await(0,o.deleteObject)((0,o.ref)(t.Wt,`mem_files/${decodeURIComponent(n)}`)).catch(()=>{})}catch(e){console.error(`Error cleaning up shared file:`,e)}O(null)}catch(e){console.error(`Error deleting shared record:`,e)}I(!1)}},[ae,oe]=(0,r.useState)(null),[X,ce]=(0,r.useState)(``),[Z,ue]=(0,r.useState)(!1),de=e=>{if(e.recordType===`file`){oe(e.id),ce(e.name);return}R(e.id),B(e.name),te(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));U(n),q.current=n.map(e=>e.key)},fe=async()=>{if(!ae||!X.trim()){oe(null);return}let e=u.find(e=>e.id===ae);if(e&&e.name===X.trim()){oe(null);return}ue(!0);try{await(0,i.updateDoc)((0,i.doc)(t.Ht,J,ae),{name:X.trim()}),d(e=>e.map(e=>e.id===ae?{...e,name:X.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}ue(!1),oe(null)},pe=async()=>{await me(),R(null)},me=async()=>{if(!L||!z.trim())return;x(!0);let e={};H.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let n=H.map(e=>e.key.trim()).filter(Boolean),r=q.current.filter(e=>!n.includes(e));r.forEach(t=>{e[t]=(0,i.deleteField)()});try{await(0,i.updateDoc)((0,i.doc)(t.Ht,J,L),{name:z.trim(),note:V.trim(),...e}),d(e=>e.map(e=>{if(e.id!==L)return e;let t={...e,name:z.trim(),note:V.trim()};return r.forEach(e=>{delete t[e]}),H.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),q.current=n}catch(e){console.error(`Error saving record:`,e)}x(!1)},he=(e,n)=>e?e.startsWith(`image/`)?n?(0,s.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${n})`}}):(0,s.jsx)(t.tt,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,s.jsx)(t.y,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,s.jsx)(t.at,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,s.jsx)(t.Ft,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,s.jsx)(t.pt,{className:`w-4 h-4`}):(0,s.jsx)(t.it,{className:`w-4 h-4`}):(0,s.jsx)(t.at,{className:`w-4 h-4`}),ge=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,ve=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},ye=e=>{if(!e)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]},be=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},xe=(()=>{let n=(e.buttonStorageIcon||`upload`).trim(),r=n.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return t.m[r]?t.m[r]:t.m[n]?t.m[n]:t.S||t.I})(),Se=e.buttonStyle!==`secondary`,Ce=e.buttonStorageStyle===`primary`,we=e=>e.uid===a?.uid,Q=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Member`,n=e.creatorEmail||``,r=e.creatorAvatar||``,i=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[r?(0,s.jsx)(`img`,{src:r,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:i}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,s.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};return(0,s.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,s.jsx)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:e.tabTitle||e.tabName||`Internal Page`}),e.route&&(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,s.jsx)(`input`,{type:`file`,ref:W,onChange:re,className:`hidden`}),!n&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 sm:gap-4 p-4 sm:p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:f?`Loading…`:`${u.length} ${u.length===1?`item`:`items`} · Internal`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.storage!==!1&&(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(t.f.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>W.current?.click(),disabled:T,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${Ce?`btn-primary`:`btn-secondary`}`,children:[T?(0,s.jsx)(t.G,{className:`w-4 h-4 animate-spin`}):(0,s.jsx)(xe,{className:`w-4 h-4`}),e.buttonStorageText&&(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,s.jsx)(t.f.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${Se?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,s.jsx)(t.I,{className:`w-4 h-4`}):(0,s.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,s.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[f&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,s.jsx)(t.G,{className:`w-8 h-8 text-accent animate-spin`})}),n?(0,s.jsx)(`div`,{className:`fbos-content-slot`,children:(0,s.jsx)(n,{config:e,actions:{records:u,loading:f,collection:J,user:a,saveRecord:async e=>{let n=Y(),r={id:`temp_`+Date.now(),uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:Date.now(),...e};d(e=>[r,...e]),await(0,i.addDoc)((0,i.collection)(t.Ht,J),{uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:(0,i.serverTimestamp)(),...e})},updateRecord:async(e,n)=>{d(t=>t.map(t=>t.id===e?{...t,...n}:t)),await(0,i.updateDoc)((0,i.doc)(t.Ht,J,e),n)},deleteRecord:async e=>{await(0,i.deleteDoc)((0,i.doc)(t.Ht,J,e))},startEdit:e=>de(e),confirmDelete:e=>O(e),uploadFile:()=>W.current?.click(),openAddForm:()=>h(!0),setAddForm:e=>C(()=>e),setFileHandler:e=>{w.current=e}}})}):(0,s.jsxs)(s.Fragment,{children:[!f&&u.length===0&&(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,s.jsx)(t.I,{className:`w-6 h-6 text-accent/40`})}),(0,s.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files. All team members can view and contribute.`})]}),!f&&u.length>0&&(0,s.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,s.jsx)(t.p,{children:u.map(e=>{let n=L===e.id,r=we(e);return(0,s.jsxs)(t.f.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>r?de(e):null,className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative ${r?`cursor-pointer`:``} ${n?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,s.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),K(e.id),setTimeout(()=>K(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:G===e.id?(0,s.jsx)(t.wt,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,s.jsx)(t.q,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,s.jsx)(t.ut,{className:`w-3.5 h-3.5`})})]}),r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,s.jsx)(t.L,{className:`w-3.5 h-3.5`})}),(0,s.jsx)(`button`,{onClick:t=>{t.stopPropagation(),O(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.E,{className:`w-3.5 h-3.5`})})]})]}),(0,s.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,s.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&j(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${ge(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?he(e.fileType,e.downloadURL):(0,s.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,s.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[ae===e.id?(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,value:X,onChange:e=>ce(e.target.value),onBlur:()=>fe(),onKeyDown:e=>{e.key===`Enter`&&fe(),e.key===`Escape`&&oe(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,s.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>j(e)}),(0,s.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:be(e.createdAt)})]})]}),e.note&&(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,s.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,s.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,s.jsx)(Q,{record:e})]},e.id)})})})]})]})]})]}),(0,s.jsx)(t.p,{children:m&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.f.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:S?r.default.createElement(S,{onSave:async e=>{x(!0);try{let n=Y();await(0,i.addDoc)((0,i.collection)(t.Ht,J),{uid:a.uid,recordType:`record`,creatorName:n.name,creatorEmail:n.email,creatorAvatar:n.avatar,createdAt:(0,i.serverTimestamp)(),...e}),h(!1)}catch(e){console.error(`Error saving record:`,e)}x(!1)},onClose:()=>!b&&h(!1),saving:b}):(0,s.jsxs)(`form`,{onSubmit:ne,className:`p-5 flex flex-col gap-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,s.jsx)(t._,{className:`w-4 h-4`})})]}),(0,s.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,s.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,s.jsx)(t.s,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,l.createPortal)((0,s.jsx)(t.p,{children:M&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,s.jsx)(t.f.div,{onClick:()=>j(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,s.jsx)(`button`,{onClick:()=>j(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 outline-none`,children:(0,s.jsx)(t._,{className:`w-5 h-5`})}),(0,s.jsxs)(t.f.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,s.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,s.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,s.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:M.fileName||M.name}),(0,s.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[ve(M.fileType),` • `,ye(M.fileSize||0)]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(M.downloadURL),K(`preview`),setTimeout(()=>K(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:G===`preview`?(0,s.jsx)(t.wt,{className:`w-4 h-4 text-emerald-500`}):(0,s.jsx)(t.q,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),oe(M.id),ce(M.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,s.jsx)(t.L,{className:`w-4 h-4`})}),(0,s.jsx)(`button`,{onClick:()=>{j(null),O(M.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,s.jsx)(t.E,{className:`w-4 h-4`})}),(0,s.jsx)(`a`,{href:M.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,s.jsx)(t.ut,{className:`w-4 h-4`})})]})]}),(0,s.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>j(null),children:(0,s.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[N&&(0,s.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,s.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,s.jsx)(t.G,{className:`w-5 h-5 text-accent animate-spin`})})}),M.fileType?.startsWith(`image/`)?(0,s.jsx)(`img`,{onLoad:()=>P(!1),onError:()=>P(!1),src:M.downloadURL,alt:M.fileName||M.name,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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType?.startsWith(`video/`)?(0,s.jsx)(`video`,{onLoadedData:()=>P(!1),onError:()=>P(!1),src:M.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 ${N?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):M.fileType===`application/pdf`?(0,s.jsx)(`iframe`,{onLoad:()=>P(!1),src:M.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${N?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,s.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(),P(!1)},children:[(0,s.jsx)(t.at,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,s.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,s.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,s.jsx)(t.p,{children:L&&(0,s.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,s.jsx)(t.f.div,{onClick:()=>pe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,s.jsx)(t.f.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,s.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,s.jsx)(t.G,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>pe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,s.jsx)(t._,{className:`w-4 h-4`})})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`input`,{autoFocus:!0,required:!0,value:z,onChange:e=>B(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>me(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,s.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:V,onChange:e=>{te(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>me(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),H.map((e,n)=>(0,s.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,s.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let t=[...H];t[n].key=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>me(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,s.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let t=[...H];t[n].value=e.target.value,U(t)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>me(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,s.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>U(H.filter((e,t)=>t!==n)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,s.jsx)(t._,{className:`w-3 h-3`})})]},n)),(0,s.jsxs)(`button`,{type:`button`,onClick:()=>U([...H,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,s.jsx)(t.I,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,s.jsx)(_e,{isOpen:!!D,onCancel:()=>O(null),onConfirm:ie,title:`Delete Record`,message:(0,s.jsxs)(s.Fragment,{children:[`Are you sure you want to delete `,(0,s.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:u.find(e=>e.id===D)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:F})]})}var Sa=[`board`,`table`,`calendar`,`drive`],Ca=[`inline_form`,`popup_form`],wa=e=>typeof e!=`string`||e===``||e===`none`||e===`custom`||![...Sa,...Ca].includes(e),Ta=(e,t)=>wa(e)||t&&!Ea(e),Ea=e=>typeof e==`string`&&Sa.includes(e),Da=`/src/your-ai-workflow-firebase-os/microcomponents`,Oa=e=>(e||``).split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``),ka=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toLowerCase();return[t,t.replace(/_/g,``)]},Aa=e=>{let t=[e?.contentKey,e?.tabName,e?.pageId,e?.pageName].filter(e=>typeof e==`string`&&e.trim()).map(e=>Oa(e)).filter(Boolean);return[...new Set(t)].map(e=>`${e}Content.tsx`)},ja=e=>{if(typeof window>`u`)return!1;let t=window.__FBOS_MICROCOMPONENTS__;if(!t)return!1;let n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``);return[e?.contentKey,e?.tabName,e?.pageId,e?.pageName].filter(e=>typeof e==`string`&&e.trim()).some(e=>t[n(e)])},Ma=new Map,Na=e=>{let t=Ma.get(e);return t||(t=import(`${Da}/${e}`).then(e=>typeof e?.default==`function`||typeof e?.default==`object`?e.default:null).catch(()=>null),Ma.set(e,t)),t};async function Pa(e){if(typeof window>`u`||ja(e))return null;for(let t of Aa(e)){let e=await Na(t);if(!e)continue;let[n,r]=ka(t.replace(/Content\.tsx$/,``)),i=window.__FBOS_MICROCOMPONENTS__||{};return window.__FBOS_MICROCOMPONENTS__={[n]:e,[r]:e,...i},e}return null}var Fa=(e,t)=>{let n=t?E(e.pageType):`public`;return{...e,pageType:n,isPrivate:t,isAdmin:n===`admin`,isInternal:n===`internal`,isShared:n===`internal`}};function Ia(){let e=(0,c.useLocation)(),{user:n,userRole:a,loading:o,roleResolved:l}=ee(),u=t.Bt(),d=e=>{if(typeof window<`u`){let t=localStorage.getItem(`fbos_route_${e}`);if(t)try{let e=JSON.parse(t);if(e.form&&!e.formConfigOverride){let t=localStorage.getItem(`fbos_form_${e.form}`);t&&(e.formConfigOverride=JSON.parse(t))}return Fa(e,e.isPrivate===!0)}catch{}}let n=(typeof window<`u`?window.__FBOS_PAGES__:null)||{},r=e.replace(/^\//,``);for(let[t,i]of Object.entries(n)){let n=i.config,a=i.isPublic,o=n.route||`/`+t;if(o===e||t===r)return Fa({...n,route:o,contentKey:n.pageId||t,pageId:t},!a)}return e===`/contact`?{route:`/contact`,template:`popup_form`,form:`contact`,pageId:`contact`,contentKey:`contact`,pageName:`Contact`,formConfigOverride:u.defaultConfigs?.contactForm||t.Jt}:e===`/support`?{route:`/support`,template:`popup_form`,form:`support`,pageId:`support`,contentKey:`support`,pageName:`Support`,formConfigOverride:u.defaultConfigs?.supportForm||t.Kt}:null},[f,p]=(0,r.useState)(()=>d(e.pathname)),[m,h]=(0,r.useState)(()=>!d(e.pathname));(0,r.useEffect)(()=>{let n=!0,r=d(e.pathname);if(r){p(r),h(!1);let e=r.pageName||r.tabName||r.title;e&&(document.title=e)}return(async()=>{try{let r=e.pathname;r.startsWith(`/`)&&(r=r.substring(1));let[a,o,s,c,l,d]=await Promise.allSettled([(0,i.getDoc)((0,i.doc)(t.Ht,`sys_pages`,r)),(0,i.getDoc)((0,i.doc)(t.Ht,`sys_tabs`,r)),(0,i.getDocs)((0,i.query)((0,i.collection)(t.Ht,`sys_pages`),(0,i.where)(`route`,`==`,e.pathname),(0,i.limit)(1))),(0,i.getDocs)((0,i.query)((0,i.collection)(t.Ht,`sys_pages`),(0,i.where)(`route`,`==`,r),(0,i.limit)(1))),(0,i.getDocs)((0,i.query)((0,i.collection)(t.Ht,`sys_tabs`),(0,i.where)(`route`,`==`,e.pathname),(0,i.limit)(1))),(0,i.getDocs)((0,i.query)((0,i.collection)(t.Ht,`sys_tabs`),(0,i.where)(`route`,`==`,r),(0,i.limit)(1)))]),f=null,m=null,g=(e,t)=>{f||e.status===`fulfilled`&&(e.value.exists&&e.value.exists()?(f=Fa(e.value.data(),t),m=e.value.id):e.value.docs&&e.value.docs.length>0&&(f=Fa(e.value.docs[0].data(),t),m=e.value.docs[0].id))};if(g(a,!1),g(s,!1),g(c,!1),g(o,!0),g(l,!0),g(d,!0),!f){let t=(typeof window<`u`?window.__FBOS_PAGES__:null)||{};for(let[n,i]of Object.entries(t)){let t=i.config,a=i.isPublic,o=t.route||`/`+n;if(o===e.pathname||n===r){f=Fa({...t,route:o,contentKey:t.pageId||n,pageId:n},!a),m=n;break}}}if(f||(e.pathname===`/contact`?(f={route:`/contact`,template:`popup_form`,form:`contact`,pageName:`Contact`},m=`contact`):e.pathname===`/support`&&(f={route:`/support`,template:`popup_form`,form:`support`,pageName:`Support`},m=`support`)),!n)return;if(f){if((m===`contact`||m===`support`)&&!f.form&&(f.form=m),f.contentKey||=f.pageId||m,f.pageId=m,localStorage.setItem(`fbos_route_${e.pathname}`,JSON.stringify(f)),f.form){let e=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},r=n=>u.defaultConfigs?.[n]||u.defaultConfigs?.[`${n}Form`]||e[n]||(n===`contact`?t.Jt:n===`support`?t.Kt:null);if(localStorage.getItem(`fbos_custom_form_${f.form}`)){try{let e=localStorage.getItem(`fbos_form_${f.form}`);e&&(f.formConfigOverride=JSON.parse(e))}catch{}(0,i.getDoc)((0,i.doc)(t.Ht,`sys_forms`,f.form)).then(async e=>{if(n)if(e.exists()){let t={...e.data(),id:e.id};p(e=>({...e,formConfigOverride:t})),localStorage.setItem(`fbos_form_${f.form}`,JSON.stringify(t))}else{let e=r(f.form);e&&(p(t=>({...t,formConfigOverride:e})),localStorage.setItem(`fbos_form_${f.form}`,JSON.stringify(e)),localStorage.removeItem(`fbos_custom_form_${f.form}`))}})}else{let e=r(f.form);e&&(f.formConfigOverride=e)}}let r=f.pageName||f.tabName||f.title;r&&(document.title=r),p(f),h(!1)}else p(`not-found`),h(!1),localStorage.removeItem(`fbos_route_${e.pathname}`)}catch{n&&m&&(p(`not-found`),h(!1))}})(),()=>{n=!1}},[e.pathname]);let[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(null),[b,x]=(0,r.useState)(!1),S=f&&f!==`not-found`&&typeof f==`object`?[f.contentKey,f.tabName,f.pageId,f.pageName].filter(Boolean).join(`|`):``;if((0,r.useEffect)(()=>{if(y(null),!S||ja(f)){x(!1);return}let e=!1;x(!0),Pa(f).then(t=>{e||(t&&y(()=>t),x(!1))});let t=setTimeout(()=>{e||x(!1)},4e3);return()=>{e=!0,clearTimeout(t)}},[S]),(0,r.useEffect)(()=>{let e;return m||o||!l||b?e=setTimeout(()=>_(!0),150):_(!1),()=>clearTimeout(e)},[m,o,l,b]),m||o||!l||b)return g?n?(0,s.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,s.jsxs)(`div`,{className:`mb-6`,children:[(0,s.jsx)(`div`,{className:`h-10 w-56 rounded-xl bg-foreground/5 animate-pulse mt-1`}),(0,s.jsx)(`div`,{className:`h-3 w-24 rounded bg-foreground/5 animate-pulse mt-3`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,s.jsx)(le,{}),(0,s.jsx)(`div`,{className:`flex-1 glass-panel border border-[var(--panel-border)] rounded-3xl flex items-center justify-center min-h-[400px] bg-background shadow-2xl`,children:(0,s.jsx)(t.G,{className:`w-6 h-6 animate-spin text-accent`})})]})]}):(0,s.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[40vh] z-10`,children:(0,s.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border border-[var(--panel-border)]/40 bg-background/80 shadow-md flex items-center gap-3`,children:[(0,s.jsx)(t.G,{className:`w-4 h-4 animate-spin text-accent`}),(0,s.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/60 tracking-wide`,children:`Loading page...`})]})}):null;if(f===`not-found`)return(0,s.jsx)(`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,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1 text-center`,children:[(0,s.jsx)(`div`,{className:`w-16 h-16 bg-red-500/10 text-red-500 rounded-full flex items-center justify-center mb-6`,children:(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-8 h-8`,children:[(0,s.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,s.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,s.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}),(0,s.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-bold mb-3 text-foreground`,children:`Page Not Found`}),(0,s.jsx)(`p`,{className:`text-foreground/60 max-w-md`,children:`The route you are looking for does not exist or has been removed.`}),C(a)&&(()=>{let t=pa();return(0,s.jsxs)(`div`,{className:`mt-8 w-full max-w-lg text-left flex flex-col gap-4`,children:[(0,s.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] px-5 py-4`,children:[(0,s.jsx)(`p`,{className:`text-[12px] font-extrabold tracking-tight text-gradient mb-1.5`,children:`Pages the app can see`}),(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/70 font-medium leading-relaxed`,children:t.length?t.join(` · `):`None yet. If your assistant says it created a page, the app has not picked its file up.`})]}),(0,s.jsx)(Ze,{title:`If your assistant just made this page, paste this`,prompt:_a(e.pathname)})]})})()]})});if((f.pageId===`support`||f.isPrivate)&&!n)return(0,s.jsx)(c.Navigate,{to:`/login`,state:{from:e}});if(!D(a,f.isPrivate?f.pageType:`public`))return f.isAdmin?(0,s.jsx)(ti,{}):(0,s.jsx)(ei,{});let w=u.customRoutes?.[e.pathname]||(f&&f.route?u.customRoutes?.[f.route]:null),T=f.pageName?.toLowerCase().replace(/\s+/g,`_`)||f.pageId||`custom_page`,E=`pub_${T}`,O=u.microcomponents||(typeof window<`u`?window.__FBOS_MICROCOMPONENTS__:void 0),k=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``),A=[f.contentKey,f.tabName,f.pageId,f.pageName,f.pageName?.replace(/\s+/g,`_`)].filter(Boolean).map(e=>k(e)).reduce((e,t)=>e||O?.[t],void 0),j=w||A||v||void 0,M=f.route||f.pageId||`custom`;if(Ta(f.template,!!j))return f.isAdmin?(0,s.jsx)(ba,{config:f,customContent:j},M):f.isInternal?(0,s.jsx)(xa,{config:f,customContent:j},M):f.isPrivate?(0,s.jsx)(ya,{config:f,customContent:j},M):(0,s.jsx)(va,{config:f,customContent:j},M);if(f.template===`board`){let e=f.isAdmin?`admin_${f.pageId||T}`:f.isInternal?`mem_${f.pageId||T}`:f.isPrivate?`user_${f.pageId||T}`:E;return(0,s.jsx)(u.components?.TemplateBoard||Vt,{title:f.tabTitle||f.tabName||f.title||f.pageName||`Board`,subtitle:f.route,tasksCollection:`${e}_tasks`,categoriesCollection:`${e}_categories`,config:f,customContent:j},M)}if(f.template===`table`){let e=f.isAdmin?`admin_${f.pageId||T}`:f.isInternal?`mem_${f.pageId||T}`:f.isPrivate?`user_${f.pageId||T}`:E;return(0,s.jsx)(u.components?.TemplateTable||_r,{title:f.tabTitle||f.tabName||f.title||f.pageName||`Table`,subtitle:f.route,tableCollection:`${e}_table`,config:f,customContent:j},M)}if(f.template===`calendar`){let e=f.isAdmin?`admin_${f.pageId||T}`:f.isInternal?`mem_${f.pageId||T}`:f.isPrivate?`user_${f.pageId||T}`:E;return(0,s.jsx)(u.components?.TemplateCalendar||br,{title:f.tabTitle||f.tabName||f.title||f.pageName||`Calendar`,subtitle:f.route,eventsCollection:`${e}_events`,defaultTimeFormat:f.defaultTimeFormat||f.defaulttimeformat||`12h`,config:f,customContent:j},M)}if(f.template===`drive`){let e=f.isAdmin?`admin_${f.pageId||T}`:f.isInternal?`mem_${f.pageId||T}`:f.isPrivate?`user_${f.pageId||T}`:E;return(0,s.jsx)(u.components?.TemplateDrive||bt,{title:f.tabTitle||f.tabName||f.title||f.pageName||`Drive`,subtitle:f.route,filesCollection:`${e}_files`,config:f,customContent:j},M)}return f.template===`inline_form`?(0,s.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-start mt-8 relative z-10 w-full min-h-[60vh]`,children:(0,s.jsx)(t.t,{isInline:!0,formId:f.form,formConfig:f.formConfigOverride})}):(0,s.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 w-full min-h-[60vh]`,children:(0,s.jsx)(t.t,{formId:f.form,formConfig:f.formConfigOverride,onClose:()=>window.history.back()})})}var La=r.default.createContext({}),Ra=Object.defineProperty,za=Object.getOwnPropertySymbols,Ba=Object.prototype.hasOwnProperty,Va=Object.prototype.propertyIsEnumerable,Ha=(e,t,n)=>t in e?Ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ua=(e,t)=>{for(var n in t||={})Ba.call(t,n)&&Ha(e,n,t[n]);if(za)for(var n of za(t))Va.call(t,n)&&Ha(e,n,t[n]);return e},Wa=(0,r.forwardRef)((e,t)=>{let n=Ua(Ua({},r.useContext(La)),e);return r.createElement(`svg`,Ua({width:`1.5em`,height:`1.5em`,viewBox:`0 0 24 24`,strokeWidth:1.5,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,color:`currentColor`,ref:t},n),r.createElement(`path`,{d:`M22 12C22 17.5228 17.5228 22 12 22C10.1786 22 8.47087 21.513 7 20.6622L2 21.5L2.83209 16C2.29689 14.7751 2 13.4222 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}),r.createElement(`path`,{d:`M12.9604 13.8683L15.0399 13.4624L17 14.2149V16.0385C17 16.6449 16.4783 17.1073 15.8901 16.9783C14.3671 16.6444 11.5997 15.8043 9.67826 13.8683C7.84859 12.0248 7.22267 9.45734 7.01039 8.04128C6.92535 7.47406 7.3737 7 7.94306 7H9.83707L10.572 8.96888L10.1832 11.0701`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}))}),Ga=`rules_version = '2';
|
|
50
51
|
service cloud.firestore {
|
|
51
52
|
match /databases/{database}/documents {
|
|
52
53
|
|
|
@@ -231,7 +232,7 @@ service cloud.firestore {
|
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
}
|
|
234
|
-
`,
|
|
235
|
+
`,Ka=`rules_version = '2';
|
|
235
236
|
service firebase.storage {
|
|
236
237
|
match /b/{bucket}/o {
|
|
237
238
|
|
|
@@ -414,4 +415,4 @@ service firebase.storage {
|
|
|
414
415
|
}
|
|
415
416
|
}
|
|
416
417
|
}
|
|
417
|
-
`,ja=[{key:`VITE_FIREBASE_API_KEY`,label:`API Key`,shownAs:`apiKey`},{key:`VITE_FIREBASE_AUTH_DOMAIN`,label:`Auth Domain`,shownAs:`authDomain`},{key:`VITE_FIREBASE_PROJECT_ID`,label:`Project ID`,shownAs:`projectId`},{key:`VITE_FIREBASE_STORAGE_BUCKET`,label:`Storage Bucket`,shownAs:`storageBucket`},{key:`VITE_FIREBASE_MESSAGING_SENDER_ID`,label:`Messaging Sender ID`,shownAs:`messagingSenderId`},{key:`VITE_FIREBASE_APP_ID`,label:`App ID`,shownAs:`appId`}];function Ma(e){let t;try{if(t={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}?.[e],t&&typeof t==`string`&&t.trim()!==``)return t}catch{}try{if(t=(typeof window<`u`?window:globalThis)?.process?.env?.[e],t&&typeof t==`string`&&t.trim()!==``)return t}catch{}try{switch(e){case`VITE_FIREBASE_API_KEY`:t=void 0;break;case`VITE_FIREBASE_AUTH_DOMAIN`:t=void 0;break;case`VITE_FIREBASE_PROJECT_ID`:t=void 0;break;case`VITE_FIREBASE_STORAGE_BUCKET`:t=void 0;break;case`VITE_FIREBASE_MESSAGING_SENDER_ID`:t=void 0;break;case`VITE_FIREBASE_APP_ID`:t=void 0;break;case`VITE_ADMIN_EMAILS`:t=void 0;break}if(t&&typeof t==`string`&&t.trim()!==``)return t}catch{}return``}function Na(e,t){let n=Ma(e);if(n)return n;if(t?.firebaseConfig){let n={VITE_FIREBASE_API_KEY:`apiKey`,VITE_FIREBASE_AUTH_DOMAIN:`authDomain`,VITE_FIREBASE_PROJECT_ID:`projectId`,VITE_FIREBASE_STORAGE_BUCKET:`storageBucket`,VITE_FIREBASE_MESSAGING_SENDER_ID:`messagingSenderId`,VITE_FIREBASE_APP_ID:`appId`}[e];if(n&&t.firebaseConfig[n])return t.firebaseConfig[n]}return e===`VITE_ADMIN_EMAILS`&&t?.adminEmails?Array.isArray(t.adminEmails)?t.adminEmails.join(`,`):t.adminEmails||``:``}function Pa(e){let t=[],n=[],r=t=>Na(t,e);for(let{key:e,label:i}of ja){let a=r(e);a?a.trim()===``&&n.push(i):t.push(i)}let i=[...t,...n];return{allSet:i.length===0,missing:i,empty:n}}function Fa(){return Pa().allSet}var Ia=Aa;function La(e){let t=e.map(e=>e.trim().toLowerCase()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),n=t.length?t.map(e=>`'${e.replace(/'/g,``)}'`).join(`, `):`'your@email.com'`;return ka.replace(/(function adminEmails\(\) \{\s*return )\[[^\]]*\];/,`$1[${n}];`)}function Ra(e){return e.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}var za=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function Ba({code:e,label:n}){let[i,a]=r.default.useState(!1);return(0,s.jsxs)(t.d.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:()=>{navigator.clipboard?.writeText(e),a(!0),setTimeout(()=>a(!1),2e3)},className:`inline-flex items-center gap-2 px-4 py-2 mt-2 rounded-xl text-[13px] font-bold tracking-wide transition-all ${i?`bg-emerald-500/10 text-emerald-500 border border-emerald-500/20`:`btn-secondary shadow-sm`}`,children:[i?(0,s.jsx)(t.Ct,{className:`w-4 h-4`}):(0,s.jsx)(t.dt,{className:`w-4 h-4`}),i?`Copied to Clipboard!`:n]})}function Va({name:e,shownAs:n,hint:i}){let[a,o]=r.default.useState(!1);return(0,s.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-3 px-4 py-3 border-b border-[var(--panel-border)]/40 last:border-0`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`div`,{className:`text-[13.5px] font-bold text-foreground break-all sm:break-normal sm:truncate`,children:e}),(0,s.jsx)(`div`,{className:`text-[12.5px] text-foreground/50 font-medium`,children:i??(0,s.jsxs)(s.Fragment,{children:[`the value Firebase labels `,n]})})]}),(0,s.jsxs)(`button`,{type:`button`,onClick:()=>{navigator.clipboard?.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)},className:`inline-flex items-center gap-1.5 h-9 px-3 rounded-xl text-[12px] font-bold shrink-0 self-start sm:self-auto transition-all cursor-pointer active:scale-[0.98] ${a?`bg-emerald-500/10 text-emerald-500 border border-emerald-500/20`:`btn-secondary`}`,children:[a?(0,s.jsx)(t.Ct,{className:`w-3.5 h-3.5`}):(0,s.jsx)(t.dt,{className:`w-3.5 h-3.5`}),a?`Copied`:`Copy name`]})]})}function Ha({initialEmails:e}){let[n,i]=(0,r.useState)(e),[a,o]=(0,r.useState)(``),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)(``),f=e=>{i(e),a&&(o(``),l([])),u&&d(``)},p=()=>{let e=Ra(n);if(e.length===0){d(`Type an email address first — it is what the rules will name.`);return}let t=e.filter(e=>!za.test(e));if(t.length>0){d(`That does not look like an email address: ${t.join(`, `)}`);return}d(``),l(e.map(e=>e.trim().toLowerCase())),o(La(e))};return(0,s.jsxs)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-2xl p-5 mb-2 flex flex-col gap-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-3.5 min-w-0`,children:[(0,s.jsx)(`div`,{className:`w-10 h-10 rounded-2xl flex items-center justify-center shrink-0 border border-[var(--panel-border)]/50 bg-accent/10 text-accent`,children:(0,s.jsx)(t.k,{className:`w-5 h-5`})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,s.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground tracking-tight leading-tight truncate`,children:`Who runs this app?`}),(0,s.jsx)(`p`,{className:`text-[12px] text-foreground/50 font-normal leading-snug truncate`,children:`The email you sign in with becomes the owner — separate several with commas.`})]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-2`,children:[(0,s.jsx)(`input`,{type:`text`,value:n,"aria-label":`The email address you will sign in with`,placeholder:`you@yourcompany.com`,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),p())},className:`w-full h-10 px-3.5 rounded-[var(--input-radius,0.75rem)] border border-[var(--panel-border)] bg-[var(--panel-bg)] text-[13.5px] text-foreground outline-none transition-all duration-300 placeholder:text-foreground/35 hover:border-accent/40 focus:border-accent console-field ${u?`is-invalid border-red-500/60`:``}`}),(0,s.jsx)(`button`,{type:`button`,onClick:p,className:`btn-primary inline-flex items-center justify-center h-10 px-4 rounded-[var(--btn-radius,0.75rem)] text-[12.5px] font-bold text-white shrink-0 cursor-pointer active:scale-[0.98] transition-transform whitespace-nowrap`,children:`Generate the rules`})]}),u&&(0,s.jsx)(`p`,{className:`text-[12px] font-semibold text-red-500 leading-snug px-1`,children:u}),a&&(0,s.jsxs)(`div`,{className:`rounded-2xl border border-emerald-500/20 bg-emerald-500/[0.05] p-4 flex items-start gap-3.5`,children:[(0,s.jsx)(`span`,{className:`w-8 h-8 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shrink-0`,children:(0,s.jsx)(t.Ct,{className:`w-4 h-4 text-emerald-500`})}),(0,s.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,s.jsx)(`p`,{className:`text-[13px] font-bold text-foreground leading-snug`,children:`Your rules are ready.`}),(0,s.jsxs)(`p`,{"data-admin-emails":!0,className:`text-[12.5px] font-medium text-foreground/60 break-all leading-relaxed`,children:[`They name `,c.join(`, `),` as the owner. Paste them into Firebase, then sign in with that address — or reload the app, if you are already signed in — and it is yours. Nothing to rebuild, and no second list to keep in step with this one.`]}),(0,s.jsx)(`div`,{className:`mt-1.5`,children:(0,s.jsx)(Ba,{code:a,label:`Copy the rules`})})]})]})]})}function Ua({number:e,title:t,children:n}){return(0,s.jsxs)(`div`,{className:`flex flex-col relative pb-10 mb-10 border-b border-[var(--panel-border)]/50 last:border-0 last:pb-0 last:mb-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,s.jsx)(`span`,{className:`w-8 h-8 shrink-0 rounded-full bg-accent/10 border border-accent/20 text-accent flex items-center justify-center text-[14px] font-extrabold`,children:e}),(0,s.jsx)(`h3`,{className:`text-[17px] md:text-[19px] font-extrabold text-foreground tracking-tight`,children:t})]}),(0,s.jsx)(`div`,{className:`text-[14px] md:text-[15px] text-foreground/70 leading-relaxed space-y-4`,children:n})]})}function Wa({standalone:e}){let n=t.zt(),[i]=(0,r.useState)(()=>{let e=localStorage.getItem(`theme-mode`);return e===`light`?!1:e===`dark`?!0:window.matchMedia(`(prefers-color-scheme: dark)`).matches}),a=Ra(Na(`VITE_ADMIN_EMAILS`,n)).join(`, `);return(0,r.useEffect)(()=>{e&&document.documentElement.setAttribute(`data-theme`,i?`dark`:`light`)},[i,e]),(0,r.useEffect)(()=>{if(e&&t.Wt.faviconUrl){let e=document.querySelector(`link[rel*='icon']`);e||(e=document.createElement(`link`),e.rel=`icon`,document.head.appendChild(e)),e.href=t.Wt.faviconUrl}},[e]),(0,s.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col min-h-screen`,children:[(0,s.jsx)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:`Setup`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/setup`]})]})}),(0,s.jsx)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:(0,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`glass-panel border border-[var(--panel-border)] rounded-3xl p-4 sm:p-6 md:p-10 shadow-2xl relative overflow-hidden bg-background flex flex-col`,children:[(0,s.jsx)(`div`,{className:`mb-8 pb-6 border-b border-[var(--panel-border)]/50 relative z-10`,children:(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight sm:truncate`,children:`Connect your app to Firebase`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1.5 leading-snug sm:truncate`,children:`Firebase is Google's free service that stores your data and signs people in — about ten minutes, once.`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(t.d.a,{whileHover:{scale:1.05},whileTap:{scale:.95},href:`mailto:antonina@youraiworkflow.co`,title:`Email Support`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer btn-secondary`,children:(0,s.jsx)(t.V,{className:`w-4 h-4`})}),(0,s.jsx)(t.d.a,{whileHover:{scale:1.05},whileTap:{scale:.95},href:`https://wa.me/34632407883`,target:`_blank`,rel:`noopener noreferrer`,title:`WhatsApp Support`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer btn-secondary`,children:(0,s.jsx)(Oa,{className:`w-4 h-4 text-foreground/80`})})]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col relative z-10 p-4 sm:p-6 md:p-8 bg-foreground/[0.015] rounded-3xl border border-[var(--panel-border)]/50 mt-4`,children:[(0,s.jsx)(Ua,{number:1,title:`Create a Firebase project`,children:(0,s.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80`,children:[(0,s.jsxs)(`li`,{children:[`Open`,` `,(0,s.jsx)(`a`,{href:`https://console.firebase.google.com`,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent underline underline-offset-2 font-semibold hover:text-accent-deep transition-colors`,children:`console.firebase.google.com`}),` `,`and click `,(0,s.jsx)(`strong`,{children:`Add project`}),`. Sign in with your Google account if it asks.`]}),(0,s.jsxs)(`li`,{children:[`Type any name you like and click `,(0,s.jsx)(`strong`,{children:`Continue`}),`.`]}),(0,s.jsxs)(`li`,{children:[`If it offers `,(0,s.jsx)(`strong`,{children:`Enable Gemini in Firebase`}),`, switch it off.`]}),(0,s.jsxs)(`li`,{children:[`Switch off `,(0,s.jsx)(`strong`,{children:`Enable Google Analytics for this project`}),`.`]}),(0,s.jsxs)(`li`,{children:[`Click `,(0,s.jsx)(`strong`,{children:`Create project`}),`, wait, then click `,(0,s.jsx)(`strong`,{children:`Continue`}),`.`]})]})}),(0,s.jsx)(Ua,{number:2,title:`Add a web app and copy the six values`,children:(0,s.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80`,children:[(0,s.jsxs)(`li`,{children:[`On that page click `,(0,s.jsx)(`strong`,{children:`+ Add app`}),` under your project's name, then pick the `,(0,s.jsx)(`strong`,{children:`</> Web`}),` icon.`]}),(0,s.jsxs)(`li`,{children:[`Give it any nickname (`,(0,s.jsx)(`span`,{className:`text-accent`,children:`MyApp`}),` is fine). Leave `,(0,s.jsx)(`strong`,{children:`Firebase Hosting`}),` unticked.`]}),(0,s.jsxs)(`li`,{children:[`Click `,(0,s.jsx)(`strong`,{children:`Register app`}),`.`]}),(0,s.jsx)(`li`,{children:`Firebase now shows six values on screen, each with a label beside it — apiKey, authDomain, projectId, storageBucket, messagingSenderId and appId. You will copy them one at a time in the next step, so keep this tab open.`})]})}),(0,s.jsxs)(Ua,{number:3,title:`Paste the six values into Secrets`,children:[(0,s.jsxs)(`p`,{className:`text-foreground/80`,children:[`In Google AI Studio, open the `,(0,s.jsx)(`strong`,{children:`Secrets`}),` tab beside your app. For each row below: click `,(0,s.jsx)(`strong`,{children:`Add secret`}),`, copy the name here, paste it as the name, then paste the matching value from your Firebase tab. The names have to match letter for letter — use the Copy name button and don't retype them.`]}),(0,s.jsx)(`p`,{className:`text-foreground/80`,children:`Six rows, and that is all of them. Your own email address is not one of them — you type that straight into step 5 in a moment.`}),(0,s.jsx)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-2xl overflow-hidden bg-background`,children:ja.map(({key:e,shownAs:t})=>(0,s.jsx)(Va,{name:e,shownAs:t},e))})]}),(0,s.jsx)(Ua,{number:4,title:`Turn on sign-in`,children:(0,s.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80`,children:[(0,s.jsxs)(`li`,{children:[`In the Firebase menu on the left, open `,(0,s.jsx)(`strong`,{children:`Authentication`}),` and click `,(0,s.jsx)(`strong`,{children:`Get started`}),`.`]}),(0,s.jsxs)(`li`,{children:[`Open the `,(0,s.jsx)(`strong`,{children:`Sign-in method`}),` tab.`]}),(0,s.jsxs)(`li`,{children:[`Click `,(0,s.jsx)(`strong`,{children:`Email/Password`}),`, switch on the first toggle and `,(0,s.jsx)(`strong`,{children:`Save`}),`. (Leave email link off.)`]}),(0,s.jsxs)(`li`,{children:[`If you also want the `,(0,s.jsx)(`strong`,{children:`Sign in with Google`}),` button to work, click `,(0,s.jsx)(`strong`,{children:`Google`}),`, switch it on, pick your own address as the support email, and `,(0,s.jsx)(`strong`,{children:`Save`}),`.`]}),(0,s.jsxs)(`li`,{children:[`Open the `,(0,s.jsx)(`strong`,{children:`Settings`}),` tab, then `,(0,s.jsx)(`strong`,{children:`Authorized domains`}),`. Your app has to be listed here or nobody can sign in.`]}),(0,s.jsxs)(`li`,{children:[(0,s.jsx)(`strong`,{children:`To get your app's address:`}),` in AI Studio, right-click any link in your app's own menu and choose `,(0,s.jsx)(`strong`,{children:`Copy link address`}),`. Back in Firebase click`,` `,(0,s.jsx)(`strong`,{children:`Add domain`}),`, paste it, and save. It will look something like ais-dev-…run.app — that is the right thing.`]})]})}),(0,s.jsxs)(Ua,{number:5,title:`Create the database and publish its rules`,children:[(0,s.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80 mb-4`,children:[(0,s.jsxs)(`li`,{children:[`In the Firebase menu, open `,(0,s.jsx)(`strong`,{children:`Firestore Database`}),` and click `,(0,s.jsx)(`strong`,{children:`Create database`}),`.`]}),(0,s.jsxs)(`li`,{children:[`Pick `,(0,s.jsx)(`strong`,{children:`Standard edition`}),` if asked, choose the location closest to your people, start in `,(0,s.jsx)(`strong`,{children:`Production mode`}),`, and click Continue.`]}),(0,s.jsxs)(`li`,{children:[`In the box below, type the email address you will sign in with and click `,(0,s.jsx)(`strong`,{children:`Generate the rules`}),`.`]}),(0,s.jsxs)(`li`,{children:[`Click `,(0,s.jsx)(`strong`,{children:`Copy the rules`}),`, then in Firebase open the `,(0,s.jsx)(`strong`,{children:`Rules`}),` tab, select everything that is there, paste over it, and click `,(0,s.jsx)(`strong`,{children:`Publish`}),`.`]})]}),(0,s.jsx)(Ha,{initialEmails:a})]}),(0,s.jsxs)(Ua,{number:6,title:`Create storage and publish its rules`,children:[(0,s.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80 mb-4`,children:[(0,s.jsxs)(`li`,{children:[`In the Firebase menu, open `,(0,s.jsx)(`strong`,{children:`Storage`}),`. Google asks you to upgrade the project first: click `,(0,s.jsx)(`strong`,{children:`Upgrade project`}),` and pick the pay-as-you-go`,` `,(0,s.jsx)(`strong`,{children:`Blaze plan`}),`. Profile photos and attachments cost about $0.03 per gigabyte a month, so this is cents. Set a budget you are comfortable with (say $20), link a billing account, and continue.`]}),(0,s.jsxs)(`li`,{children:[`Click `,(0,s.jsx)(`strong`,{children:`Get started`}),`, choose a no-cost location, start in `,(0,s.jsx)(`strong`,{children:`Production mode`}),`, and click `,(0,s.jsx)(`strong`,{children:`Create`}),`.`]}),(0,s.jsx)(`li`,{children:`Once it exists, Firebase shows the storage address at the top (something like your-project.firebasestorage.app). If it is not exactly what you pasted into the storage secret in step 3, open Secrets and correct that one now.`}),(0,s.jsxs)(`li`,{children:[`Open the `,(0,s.jsx)(`strong`,{children:`Rules`}),` tab, select everything that is there, paste these over it, and click `,(0,s.jsx)(`strong`,{children:`Publish`}),`.`]})]}),(0,s.jsx)(Ba,{code:Ia,label:`Copy the storage rules`})]})]}),(0,s.jsx)(`div`,{className:`mt-8 relative z-10`,children:(0,s.jsx)(He,{description:`Reload the app once you have added the secrets. If it still asks you to set up, hand this to your assistant.`,prompt:`My Firebase keys are in the Secrets tab — can you check the app connects?`})})]})})]})}function Ga(){let{user:e}=ee(),n=(e?.displayName||e?.email?.split(`@`)[0]||`there`).split(` `)[0],r=n.charAt(0).toUpperCase()+n.slice(1);return(0,s.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,s.jsxs)(t.d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,s.jsxs)(se,{children:[`Welcome back, `,r,`.`]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/dashboard`]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,s.jsx)(`div`,{className:`flex justify-start`,children:(0,s.jsx)(le,{})}),(0,s.jsxs)(`div`,{className:`w-full flex-1 glass-panel rounded-3xl p-8 md:p-12 flex items-center justify-center relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,s.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/10 blur-[100px] rounded-full pointer-events-none`}),(0,s.jsx)(t.f,{mode:`wait`,children:(0,s.jsxs)(t.d.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.3},className:`text-center z-10`,children:[(0,s.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,s.jsx)(t.ut,{className:`w-6 h-6`})}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No data added here yet`}),(0,s.jsx)(`p`,{className:`text-foreground/40 font-medium`,children:`Keep moving forward, your data will appear here.`})]})})]})]})]})}var Ka=()=>(0,s.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center min-h-[60vh] z-10 animate-in fade-in duration-500`,children:[(0,s.jsx)(`div`,{className:`w-12 h-12 rounded-xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mb-6 shadow-xl`,children:(0,s.jsx)(t.ut,{className:`w-6 h-6 text-accent animate-pulse`})}),(0,s.jsxs)(`div`,{className:`flex items-center gap-3 glass-panel px-5 py-2.5 rounded-full border border-[var(--panel-border)]`,children:[(0,s.jsx)(`div`,{className:`w-4 h-4 border-2 border-accent border-t-transparent rounded-full animate-spin`}),(0,s.jsx)(`span`,{className:`text-[13px] font-bold tracking-widest uppercase text-foreground/70`,children:`Connecting`})]})]});function qa({level:e,children:t}){let{user:n,userRole:r,loading:i,userInactive:a,signOut:o,roleResolved:l}=ee(),u=(0,c.useLocation)();return i||!l?(0,s.jsx)(Ka,{}):n?a?(0,s.jsx)(Nr,{tone:`red`,title:`Access Denied`,message:`You don't have access to this app. Please contact the administrator.`,action:(0,s.jsx)(`button`,{onClick:()=>o(),className:Pr,children:`Sign Out`})}):n.emailVerified?e===`admin`&&!C(r)?(0,s.jsx)(zr,{}):e===`internal`&&!w(r)?(0,s.jsx)(Rr,{}):(0,s.jsx)(s.Fragment,{children:t}):(0,s.jsx)(c.Navigate,{to:`/verify`}):(0,s.jsx)(c.Navigate,{to:`/login?from=${encodeURIComponent(u.pathname)}`})}var Ja=({children:e})=>(0,s.jsx)(qa,{level:`signed-in`,children:e}),Ya=({children:e})=>(0,s.jsx)(qa,{level:`admin`,children:e});function Xa({children:e}){let{user:t,loading:n,roleResolved:r}=ee(),[i]=(0,c.useSearchParams)();return n||!r?(0,s.jsx)(Ka,{}):t&&t.emailVerified?(0,s.jsx)(c.Navigate,{to:i.get(`from`)||`/dashboard`,replace:!0}):(0,s.jsx)(s.Fragment,{children:e})}function Za({children:e}){let{user:t,loading:n,roleResolved:r}=ee();return n||!r?(0,s.jsx)(Ka,{}):t?t.emailVerified?(0,s.jsx)(c.Navigate,{to:`/dashboard`}):(0,s.jsx)(s.Fragment,{children:e}):(0,s.jsx)(c.Navigate,{to:`/`})}function Qa(){return(0,s.jsxs)(`div`,{className:`fixed top-0 left-0 w-full h-full pointer-events-none -z-0 overflow-hidden`,children:[(0,s.jsx)(t.d.div,{animate:{scale:[1,1.1,1],opacity:[.6,1,.6]},transition:{duration:12,repeat:1/0,ease:`easeInOut`},className:`absolute -top-[30%] md:-top-[400px] -right-[10%] md:-right-[200px] w-[500px] md:w-[800px] h-[500px] md:h-[800px] rounded-full bg-decorator-1 blur-[80px] md:blur-[120px]`}),(0,s.jsx)(t.d.div,{animate:{scale:[1,1.2,1],opacity:[.5,.9,.5]},transition:{duration:18,repeat:1/0,ease:`easeInOut`,delay:2},className:`absolute -bottom-[20%] md:-bottom-[300px] -left-[10%] md:-left-[100px] w-[400px] md:w-[600px] h-[400px] md:h-[600px] rounded-full bg-decorator-2 blur-[60px] md:blur-[100px]`})]})}function $a(){let e=t.zt().components?.Home||te;return(0,s.jsx)(j,{children:(0,s.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-hidden`,children:[(0,s.jsx)(V,{}),(0,s.jsxs)(c.Routes,{children:[(0,s.jsx)(c.Route,{path:`/`,element:(0,s.jsx)(Xa,{children:(0,s.jsx)(e,{})})}),(0,s.jsx)(c.Route,{path:`/register`,element:(0,s.jsx)(Xa,{children:(0,s.jsx)(ne,{})})}),(0,s.jsx)(c.Route,{path:`/login`,element:(0,s.jsx)(Xa,{children:(0,s.jsx)(re,{})})}),(0,s.jsx)(c.Route,{path:`/reset-password`,element:(0,s.jsx)(Xa,{children:(0,s.jsx)(ue,{})})}),(0,s.jsx)(c.Route,{path:`/verify`,element:(0,s.jsx)(Za,{children:(0,s.jsx)(ie,{})})}),(0,s.jsx)(c.Route,{path:`/guide`,element:(0,s.jsx)(bt,{})}),(0,s.jsx)(c.Route,{path:`/templates`,element:(0,s.jsx)(lt,{})}),(0,s.jsx)(c.Route,{path:`/templates/inline_form`,element:(0,s.jsx)(xt,{})}),(0,s.jsx)(c.Route,{path:`/templates/popup_form`,element:(0,s.jsx)(St,{})}),(0,s.jsx)(c.Route,{path:`/templates/confirmation`,element:(0,s.jsx)(Ct,{})}),(0,s.jsx)(c.Route,{path:`/templates/board`,element:(0,s.jsx)(Tt,{})}),(0,s.jsx)(c.Route,{path:`/templates/table`,element:(0,s.jsx)(tr,{})}),(0,s.jsx)(c.Route,{path:`/templates/calendar`,element:(0,s.jsx)(ir,{})}),(0,s.jsx)(c.Route,{path:`/templates/drive`,element:(0,s.jsx)(it,{})}),(0,s.jsx)(c.Route,{path:`/users`,element:(0,s.jsx)(Ya,{children:(0,s.jsx)(pe,{})})}),(0,s.jsx)(c.Route,{path:`/users/:id`,element:(0,s.jsx)(Ya,{children:(0,s.jsx)(pe,{})})}),(0,s.jsx)(c.Route,{path:`/inbox`,element:(0,s.jsx)(Ya,{children:(0,s.jsx)(nt,{})})}),(0,s.jsx)(c.Route,{path:`/submissions`,element:(0,s.jsx)(c.Navigate,{to:`/inbox`,replace:!0})}),(0,s.jsx)(c.Route,{path:`/requests`,element:(0,s.jsx)(c.Navigate,{to:`/inbox`,replace:!0})}),(0,s.jsx)(c.Route,{path:`/assets`,element:(0,s.jsx)(Ya,{children:(0,s.jsx)(ct,{})})}),(0,s.jsx)(c.Route,{path:`/drive/*`,element:(0,s.jsx)(c.Navigate,{to:`/assets`,replace:!0})}),(0,s.jsx)(c.Route,{path:`/theme`,element:(0,s.jsx)(Ya,{children:(0,s.jsx)(Mr,{})})}),(0,s.jsx)(c.Route,{path:`/pages/*`,element:(0,s.jsx)(Ya,{children:(0,s.jsx)(Ii,{})})}),(0,s.jsx)(c.Route,{path:`/forms/*`,element:(0,s.jsx)(Ya,{children:(0,s.jsx)(Yi,{})})}),(0,s.jsx)(c.Route,{path:`/settings`,element:(0,s.jsx)(c.Navigate,{to:`/pages`,replace:!0})}),(0,s.jsx)(c.Route,{path:`/profile`,element:(0,s.jsx)(Ja,{children:(0,s.jsx)(Z,{})})}),(0,s.jsx)(c.Route,{path:`/dashboard`,element:(0,s.jsx)(Ja,{children:(0,s.jsx)(Ga,{})})}),(0,s.jsx)(c.Route,{path:`/setup`,element:(0,s.jsx)(Wa,{})}),(0,s.jsx)(c.Route,{path:`*`,element:(0,s.jsx)(ba,{})})]}),(0,s.jsx)(Qa,{})]})})}function eo(){return(0,s.jsx)(c.BrowserRouter,{children:(0,s.jsx)(to,{})})}function to(){let e=t.zt();return e.firebaseConfig&&e.firebaseConfig.apiKey&&e.firebaseConfig.apiKey.trim()!==``&&e.firebaseConfig.projectId&&e.firebaseConfig.projectId.trim()!==``||Fa()?(0,s.jsx)($a,{}):(0,s.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-hidden`,children:[(0,s.jsx)(V,{standalone:!0}),(0,s.jsx)(Wa,{standalone:!0}),(0,s.jsx)(Qa,{})]})}function no(e){g();let n=e.firebaseConfig;return n&&n.apiKey&&n.apiKey.trim()!==``&&n.projectId&&n.projectId.trim()!==``&&t.Ht(n),(0,s.jsx)(t.Rt,{config:{firebaseConfig:e.firebaseConfig,adminEmails:e.adminEmails,basename:e.basename,onAuthChange:e.onAuthChange,themeConfig:e.themeConfig,components:e.components,customRoutes:e.customRoutes,microcomponents:e.microcomponents,defaultConfigs:e.defaultConfigs},children:(0,s.jsx)(t.It,{children:(0,s.jsx)(`div`,{className:`firebase-os flex-1 flex flex-col min-h-screen`,style:{background:`var(--bg-gradient)`,color:`var(--fg-color)`},children:(0,s.jsx)(eo,{})})})})}var ro=Object.assign({}),io={};for(let e in ro){let t=ro[e];if(!t?.default)continue;let n=e.replace(`./`,``).replace(`.tsx`,``);if(n===`registry`)continue;let r=n.replace(/Content$/,``).replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toLowerCase();io[r]=t.default,io[r.replace(/_/g,``)]=t.default}if(typeof window<`u`){let e=window.__FBOS_MICROCOMPONENTS__||{};window.__FBOS_MICROCOMPONENTS__={...io,...e}}var ao=(e,t)=>{let n=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=n.replace(/_/g,``);if(io[n]=t,io[r]=t,typeof window<`u`){let e=window.__FBOS_MICROCOMPONENTS__||{};window.__FBOS_MICROCOMPONENTS__={...e,[n]:t,[r]:t}}};function oo(...e){return t.c(t.l(e))}var so=({title:e,className:t,children:n,...r})=>(0,s.jsxs)(`div`,{className:oo(`border border-[var(--panel-border)] bg-[var(--panel-bg)] px-5 py-4`,t),style:{borderRadius:`var(--card-radius, 1rem)`},...r,children:[e?(0,s.jsx)(`p`,{className:`text-[12px] font-extrabold tracking-tight text-gradient mb-1.5`,children:e}):null,n]});so.displayName=`Card`;function co(...e){return t.c(t.l(e))}var lo=({sub:e,className:t,children:n,...r})=>(0,s.jsxs)(`div`,{className:co(`mb-4`,t),children:[(0,s.jsx)(`h2`,{className:`text-xl md:text-2xl font-extrabold tracking-tight text-foreground`,...r,children:n}),e?(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed mt-1`,children:e}):null]});lo.displayName=`SectionHeading`,exports.AdminNotifications=P,exports.Button=t.o,exports.Card=so,exports.ConfirmModal=me,exports.ContactPopup=t.t,exports.CustomSelect=t.a,exports.DashboardNav=le,exports.FirebaseOS=no,exports.Input=t.s,exports.Navbar=V,exports.PhoneInputField=n.t,exports.SectionHeading=lo,Object.defineProperty(exports,`auth`,{enumerable:!0,get:function(){return t.Bt}}),Object.defineProperty(exports,`db`,{enumerable:!0,get:function(){return t.Vt}}),exports.registerMicrocomponent=ao,Object.defineProperty(exports,`storage`,{enumerable:!0,get:function(){return t.Ut}}),exports.useAuth=ee,exports.useConfig=t.zt,exports.useTheme=t.Lt;
|
|
418
|
+
`,qa=[{key:`VITE_FIREBASE_API_KEY`,label:`API Key`,shownAs:`apiKey`},{key:`VITE_FIREBASE_AUTH_DOMAIN`,label:`Auth Domain`,shownAs:`authDomain`},{key:`VITE_FIREBASE_PROJECT_ID`,label:`Project ID`,shownAs:`projectId`},{key:`VITE_FIREBASE_STORAGE_BUCKET`,label:`Storage Bucket`,shownAs:`storageBucket`},{key:`VITE_FIREBASE_MESSAGING_SENDER_ID`,label:`Messaging Sender ID`,shownAs:`messagingSenderId`},{key:`VITE_FIREBASE_APP_ID`,label:`App ID`,shownAs:`appId`}];function Ja(e){let t;try{if(t={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}?.[e],t&&typeof t==`string`&&t.trim()!==``)return t}catch{}try{if(t=(typeof window<`u`?window:globalThis)?.process?.env?.[e],t&&typeof t==`string`&&t.trim()!==``)return t}catch{}try{switch(e){case`VITE_FIREBASE_API_KEY`:t=void 0;break;case`VITE_FIREBASE_AUTH_DOMAIN`:t=void 0;break;case`VITE_FIREBASE_PROJECT_ID`:t=void 0;break;case`VITE_FIREBASE_STORAGE_BUCKET`:t=void 0;break;case`VITE_FIREBASE_MESSAGING_SENDER_ID`:t=void 0;break;case`VITE_FIREBASE_APP_ID`:t=void 0;break;case`VITE_ADMIN_EMAILS`:t=void 0;break}if(t&&typeof t==`string`&&t.trim()!==``)return t}catch{}return``}function Ya(e,t){let n=Ja(e);if(n)return n;if(t?.firebaseConfig){let n={VITE_FIREBASE_API_KEY:`apiKey`,VITE_FIREBASE_AUTH_DOMAIN:`authDomain`,VITE_FIREBASE_PROJECT_ID:`projectId`,VITE_FIREBASE_STORAGE_BUCKET:`storageBucket`,VITE_FIREBASE_MESSAGING_SENDER_ID:`messagingSenderId`,VITE_FIREBASE_APP_ID:`appId`}[e];if(n&&t.firebaseConfig[n])return t.firebaseConfig[n]}return e===`VITE_ADMIN_EMAILS`&&t?.adminEmails?Array.isArray(t.adminEmails)?t.adminEmails.join(`,`):t.adminEmails||``:``}function Xa(e){let t=[],n=[],r=t=>Ya(t,e);for(let{key:e,label:i}of qa){let a=r(e);a?a.trim()===``&&n.push(i):t.push(i)}let i=[...t,...n];return{allSet:i.length===0,missing:i,empty:n}}function Za(){return Xa().allSet}var Qa=Ka;function $a(e){let t=e.map(e=>e.trim().toLowerCase()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),n=t.length?t.map(e=>`'${e.replace(/'/g,``)}'`).join(`, `):`'your@email.com'`;return Ga.replace(/(function adminEmails\(\) \{\s*return )\[[^\]]*\];/,`$1[${n}];`)}function eo(e){return e.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}var to=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function no({code:e,label:n}){let[i,a]=r.default.useState(!1);return(0,s.jsxs)(t.f.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:()=>{navigator.clipboard?.writeText(e),a(!0),setTimeout(()=>a(!1),2e3)},className:`inline-flex items-center gap-2 px-4 py-2 mt-2 rounded-xl text-[13px] font-bold tracking-wide transition-all ${i?`bg-emerald-500/10 text-emerald-500 border border-emerald-500/20`:`btn-secondary shadow-sm`}`,children:[i?(0,s.jsx)(t.wt,{className:`w-4 h-4`}):(0,s.jsx)(t.ft,{className:`w-4 h-4`}),i?`Copied to Clipboard!`:n]})}function ro({name:e,shownAs:n,hint:i}){let[a,o]=r.default.useState(!1);return(0,s.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-3 px-4 py-3 border-b border-[var(--panel-border)]/40 last:border-0`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`div`,{className:`text-[13.5px] font-bold text-foreground break-all sm:break-normal sm:truncate`,children:e}),(0,s.jsx)(`div`,{className:`text-[12.5px] text-foreground/50 font-medium`,children:i??(0,s.jsxs)(s.Fragment,{children:[`the value Firebase labels `,n]})})]}),(0,s.jsxs)(`button`,{type:`button`,onClick:()=>{navigator.clipboard?.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)},className:`inline-flex items-center gap-1.5 h-9 px-3 rounded-xl text-[12px] font-bold shrink-0 self-start sm:self-auto transition-all cursor-pointer active:scale-[0.98] ${a?`bg-emerald-500/10 text-emerald-500 border border-emerald-500/20`:`btn-secondary`}`,children:[a?(0,s.jsx)(t.wt,{className:`w-3.5 h-3.5`}):(0,s.jsx)(t.ft,{className:`w-3.5 h-3.5`}),a?`Copied`:`Copy name`]})]})}function io({initialEmails:e}){let[n,i]=(0,r.useState)(e),[a,o]=(0,r.useState)(``),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)(``),f=e=>{i(e),a&&(o(``),l([])),u&&d(``)},p=()=>{let e=eo(n);if(e.length===0){d(`Type an email address first — it is what the rules will name.`);return}let t=e.filter(e=>!to.test(e));if(t.length>0){d(`That does not look like an email address: ${t.join(`, `)}`);return}d(``),l(e.map(e=>e.trim().toLowerCase())),o($a(e))};return(0,s.jsxs)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-2xl p-5 mb-2 flex flex-col gap-4`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-3.5 min-w-0`,children:[(0,s.jsx)(`div`,{className:`w-10 h-10 rounded-2xl flex items-center justify-center shrink-0 border border-[var(--panel-border)]/50 bg-accent/10 text-accent`,children:(0,s.jsx)(t.A,{className:`w-5 h-5`})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,s.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground tracking-tight leading-tight truncate`,children:`Who runs this app?`}),(0,s.jsx)(`p`,{className:`text-[12px] text-foreground/50 font-normal leading-snug truncate`,children:`The email you sign in with becomes the owner — separate several with commas.`})]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-2`,children:[(0,s.jsx)(`input`,{type:`text`,value:n,"aria-label":`The email address you will sign in with`,placeholder:`you@yourcompany.com`,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),p())},className:`w-full h-10 px-3.5 rounded-[var(--input-radius,0.75rem)] border border-[var(--panel-border)] bg-[var(--panel-bg)] text-[13.5px] text-foreground outline-none transition-all duration-300 placeholder:text-foreground/35 hover:border-accent/40 focus:border-accent console-field ${u?`is-invalid border-red-500/60`:``}`}),(0,s.jsx)(`button`,{type:`button`,onClick:p,className:`btn-primary inline-flex items-center justify-center h-10 px-4 rounded-[var(--btn-radius,0.75rem)] text-[12.5px] font-bold text-white shrink-0 cursor-pointer active:scale-[0.98] transition-transform whitespace-nowrap`,children:`Generate the rules`})]}),u&&(0,s.jsx)(`p`,{className:`text-[12px] font-semibold text-red-500 leading-snug px-1`,children:u}),a&&(0,s.jsxs)(`div`,{className:`rounded-2xl border border-emerald-500/20 bg-emerald-500/[0.05] p-4 flex items-start gap-3.5`,children:[(0,s.jsx)(`span`,{className:`w-8 h-8 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shrink-0`,children:(0,s.jsx)(t.wt,{className:`w-4 h-4 text-emerald-500`})}),(0,s.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,s.jsx)(`p`,{className:`text-[13px] font-bold text-foreground leading-snug`,children:`Your rules are ready.`}),(0,s.jsxs)(`p`,{"data-admin-emails":!0,className:`text-[12.5px] font-medium text-foreground/60 break-all leading-relaxed`,children:[`They name `,c.join(`, `),` as the owner. Paste them into Firebase, then sign in with that address — or reload the app, if you are already signed in — and it is yours. Nothing to rebuild, and no second list to keep in step with this one.`]}),(0,s.jsx)(`div`,{className:`mt-1.5`,children:(0,s.jsx)(no,{code:a,label:`Copy the rules`})})]})]})]})}function ao({number:e,title:t,children:n}){return(0,s.jsxs)(`div`,{className:`flex flex-col relative pb-10 mb-10 border-b border-[var(--panel-border)]/50 last:border-0 last:pb-0 last:mb-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,s.jsx)(`span`,{className:`w-8 h-8 shrink-0 rounded-full bg-accent/10 border border-accent/20 text-accent flex items-center justify-center text-[14px] font-extrabold`,children:e}),(0,s.jsx)(`h3`,{className:`text-[17px] md:text-[19px] font-extrabold text-foreground tracking-tight`,children:t})]}),(0,s.jsx)(`div`,{className:`text-[14px] md:text-[15px] text-foreground/70 leading-relaxed space-y-4`,children:n})]})}function oo({standalone:e}){let n=t.Bt(),[i]=(0,r.useState)(()=>{let e=localStorage.getItem(`theme-mode`);return e===`light`?!1:e===`dark`?!0:window.matchMedia(`(prefers-color-scheme: dark)`).matches}),a=eo(Ya(`VITE_ADMIN_EMAILS`,n)).join(`, `);return(0,r.useEffect)(()=>{e&&document.documentElement.setAttribute(`data-theme`,i?`dark`:`light`)},[i,e]),(0,r.useEffect)(()=>{if(e&&t.Gt.faviconUrl){let e=document.querySelector(`link[rel*='icon']`);e||(e=document.createElement(`link`),e.rel=`icon`,document.head.appendChild(e)),e.href=t.Gt.faviconUrl}},[e]),(0,s.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col min-h-screen`,children:[(0,s.jsx)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(se,{children:`Setup`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/setup`]})]})}),(0,s.jsx)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:(0,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`glass-panel border border-[var(--panel-border)] rounded-3xl p-4 sm:p-6 md:p-10 shadow-2xl relative overflow-hidden bg-background flex flex-col`,children:[(0,s.jsx)(`div`,{className:`mb-8 pb-6 border-b border-[var(--panel-border)]/50 relative z-10`,children:(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight sm:truncate`,children:`Connect your app to Firebase`}),(0,s.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1.5 leading-snug sm:truncate`,children:`Firebase is Google's free service that stores your data and signs people in — about ten minutes, once.`})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,s.jsx)(t.f.a,{whileHover:{scale:1.05},whileTap:{scale:.95},href:`mailto:antonina@youraiworkflow.co`,title:`Email Support`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer btn-secondary`,children:(0,s.jsx)(t.H,{className:`w-4 h-4`})}),(0,s.jsx)(t.f.a,{whileHover:{scale:1.05},whileTap:{scale:.95},href:`https://wa.me/34632407883`,target:`_blank`,rel:`noopener noreferrer`,title:`WhatsApp Support`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer btn-secondary`,children:(0,s.jsx)(Wa,{className:`w-4 h-4 text-foreground/80`})})]})]})}),(0,s.jsxs)(`div`,{className:`flex flex-col relative z-10 p-4 sm:p-6 md:p-8 bg-foreground/[0.015] rounded-3xl border border-[var(--panel-border)]/50 mt-4`,children:[(0,s.jsx)(ao,{number:1,title:`Create a Firebase project`,children:(0,s.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80`,children:[(0,s.jsxs)(`li`,{children:[`Open`,` `,(0,s.jsx)(`a`,{href:`https://console.firebase.google.com`,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent underline underline-offset-2 font-semibold hover:text-accent-deep transition-colors`,children:`console.firebase.google.com`}),` `,`and click `,(0,s.jsx)(`strong`,{children:`Add project`}),`. Sign in with your Google account if it asks.`]}),(0,s.jsxs)(`li`,{children:[`Type any name you like and click `,(0,s.jsx)(`strong`,{children:`Continue`}),`.`]}),(0,s.jsxs)(`li`,{children:[`If it offers `,(0,s.jsx)(`strong`,{children:`Enable Gemini in Firebase`}),`, switch it off.`]}),(0,s.jsxs)(`li`,{children:[`Switch off `,(0,s.jsx)(`strong`,{children:`Enable Google Analytics for this project`}),`.`]}),(0,s.jsxs)(`li`,{children:[`Click `,(0,s.jsx)(`strong`,{children:`Create project`}),`, wait, then click `,(0,s.jsx)(`strong`,{children:`Continue`}),`.`]})]})}),(0,s.jsx)(ao,{number:2,title:`Add a web app and copy the six values`,children:(0,s.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80`,children:[(0,s.jsxs)(`li`,{children:[`On that page click `,(0,s.jsx)(`strong`,{children:`+ Add app`}),` under your project's name, then pick the `,(0,s.jsx)(`strong`,{children:`</> Web`}),` icon.`]}),(0,s.jsxs)(`li`,{children:[`Give it any nickname (`,(0,s.jsx)(`span`,{className:`text-accent`,children:`MyApp`}),` is fine). Leave `,(0,s.jsx)(`strong`,{children:`Firebase Hosting`}),` unticked.`]}),(0,s.jsxs)(`li`,{children:[`Click `,(0,s.jsx)(`strong`,{children:`Register app`}),`.`]}),(0,s.jsx)(`li`,{children:`Firebase now shows six values on screen, each with a label beside it — apiKey, authDomain, projectId, storageBucket, messagingSenderId and appId. You will copy them one at a time in the next step, so keep this tab open.`})]})}),(0,s.jsxs)(ao,{number:3,title:`Paste the six values into Secrets`,children:[(0,s.jsxs)(`p`,{className:`text-foreground/80`,children:[`In Google AI Studio, open the `,(0,s.jsx)(`strong`,{children:`Secrets`}),` tab beside your app. For each row below: click `,(0,s.jsx)(`strong`,{children:`Add secret`}),`, copy the name here, paste it as the name, then paste the matching value from your Firebase tab. The names have to match letter for letter — use the Copy name button and don't retype them.`]}),(0,s.jsx)(`p`,{className:`text-foreground/80`,children:`Six rows, and that is all of them. Your own email address is not one of them — you type that straight into step 5 in a moment.`}),(0,s.jsx)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-2xl overflow-hidden bg-background`,children:qa.map(({key:e,shownAs:t})=>(0,s.jsx)(ro,{name:e,shownAs:t},e))})]}),(0,s.jsx)(ao,{number:4,title:`Turn on sign-in`,children:(0,s.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80`,children:[(0,s.jsxs)(`li`,{children:[`In the Firebase menu on the left, open `,(0,s.jsx)(`strong`,{children:`Authentication`}),` and click `,(0,s.jsx)(`strong`,{children:`Get started`}),`.`]}),(0,s.jsxs)(`li`,{children:[`Open the `,(0,s.jsx)(`strong`,{children:`Sign-in method`}),` tab.`]}),(0,s.jsxs)(`li`,{children:[`Click `,(0,s.jsx)(`strong`,{children:`Email/Password`}),`, switch on the first toggle and `,(0,s.jsx)(`strong`,{children:`Save`}),`. (Leave email link off.)`]}),(0,s.jsxs)(`li`,{children:[`If you also want the `,(0,s.jsx)(`strong`,{children:`Sign in with Google`}),` button to work, click `,(0,s.jsx)(`strong`,{children:`Google`}),`, switch it on, pick your own address as the support email, and `,(0,s.jsx)(`strong`,{children:`Save`}),`.`]}),(0,s.jsxs)(`li`,{children:[`Open the `,(0,s.jsx)(`strong`,{children:`Settings`}),` tab, then `,(0,s.jsx)(`strong`,{children:`Authorized domains`}),`. Your app has to be listed here or nobody can sign in.`]}),(0,s.jsxs)(`li`,{children:[(0,s.jsx)(`strong`,{children:`To get your app's address:`}),` in AI Studio, right-click any link in your app's own menu and choose `,(0,s.jsx)(`strong`,{children:`Copy link address`}),`. Back in Firebase click`,` `,(0,s.jsx)(`strong`,{children:`Add domain`}),`, paste it, and save. It will look something like ais-dev-…run.app — that is the right thing.`]})]})}),(0,s.jsxs)(ao,{number:5,title:`Create the database and publish its rules`,children:[(0,s.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80 mb-4`,children:[(0,s.jsxs)(`li`,{children:[`In the Firebase menu, open `,(0,s.jsx)(`strong`,{children:`Firestore Database`}),` and click `,(0,s.jsx)(`strong`,{children:`Create database`}),`.`]}),(0,s.jsxs)(`li`,{children:[`Pick `,(0,s.jsx)(`strong`,{children:`Standard edition`}),` if asked, choose the location closest to your people, start in `,(0,s.jsx)(`strong`,{children:`Production mode`}),`, and click Continue.`]}),(0,s.jsxs)(`li`,{children:[`In the box below, type the email address you will sign in with and click `,(0,s.jsx)(`strong`,{children:`Generate the rules`}),`.`]}),(0,s.jsxs)(`li`,{children:[`Click `,(0,s.jsx)(`strong`,{children:`Copy the rules`}),`, then in Firebase open the `,(0,s.jsx)(`strong`,{children:`Rules`}),` tab, select everything that is there, paste over it, and click `,(0,s.jsx)(`strong`,{children:`Publish`}),`.`]})]}),(0,s.jsx)(io,{initialEmails:a})]}),(0,s.jsxs)(ao,{number:6,title:`Create storage and publish its rules`,children:[(0,s.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80 mb-4`,children:[(0,s.jsxs)(`li`,{children:[`In the Firebase menu, open `,(0,s.jsx)(`strong`,{children:`Storage`}),`. Google asks you to upgrade the project first: click `,(0,s.jsx)(`strong`,{children:`Upgrade project`}),` and pick the pay-as-you-go`,` `,(0,s.jsx)(`strong`,{children:`Blaze plan`}),`. Profile photos and attachments cost about $0.03 per gigabyte a month, so this is cents. Set a budget you are comfortable with (say $20), link a billing account, and continue.`]}),(0,s.jsxs)(`li`,{children:[`Click `,(0,s.jsx)(`strong`,{children:`Get started`}),`, choose a no-cost location, start in `,(0,s.jsx)(`strong`,{children:`Production mode`}),`, and click `,(0,s.jsx)(`strong`,{children:`Create`}),`.`]}),(0,s.jsx)(`li`,{children:`Once it exists, Firebase shows the storage address at the top (something like your-project.firebasestorage.app). If it is not exactly what you pasted into the storage secret in step 3, open Secrets and correct that one now.`}),(0,s.jsxs)(`li`,{children:[`Open the `,(0,s.jsx)(`strong`,{children:`Rules`}),` tab, select everything that is there, paste these over it, and click `,(0,s.jsx)(`strong`,{children:`Publish`}),`.`]})]}),(0,s.jsx)(no,{code:Qa,label:`Copy the storage rules`})]})]}),(0,s.jsx)(`div`,{className:`mt-8 relative z-10`,children:(0,s.jsx)(Ze,{description:`Reload the app once you have added the secrets. If it still asks you to set up, hand this to your assistant.`,prompt:`My Firebase keys are in the Secrets tab — can you check the app connects?`})})]})})]})}function so(){let{user:e}=ee(),n=(e?.displayName||e?.email?.split(`@`)[0]||`there`).split(` `)[0],r=n.charAt(0).toUpperCase()+n.slice(1);return(0,s.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,s.jsxs)(t.f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,s.jsxs)(se,{children:[`Welcome back, `,r,`.`]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,s.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/dashboard`]})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,s.jsx)(`div`,{className:`flex justify-start`,children:(0,s.jsx)(le,{})}),(0,s.jsxs)(`div`,{className:`w-full flex-1 glass-panel rounded-3xl p-8 md:p-12 flex items-center justify-center relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,s.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/10 blur-[100px] rounded-full pointer-events-none`}),(0,s.jsx)(t.p,{mode:`wait`,children:(0,s.jsxs)(t.f.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.3},className:`text-center z-10`,children:[(0,s.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,s.jsx)(t.dt,{className:`w-6 h-6`})}),(0,s.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No data added here yet`}),(0,s.jsx)(`p`,{className:`text-foreground/40 font-medium`,children:`Keep moving forward, your data will appear here.`})]})})]})]})]})}var co=()=>(0,s.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center min-h-[60vh] z-10 animate-in fade-in duration-500`,children:[(0,s.jsx)(`div`,{className:`w-12 h-12 rounded-xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mb-6 shadow-xl`,children:(0,s.jsx)(t.dt,{className:`w-6 h-6 text-accent animate-pulse`})}),(0,s.jsxs)(`div`,{className:`flex items-center gap-3 glass-panel px-5 py-2.5 rounded-full border border-[var(--panel-border)]`,children:[(0,s.jsx)(`div`,{className:`w-4 h-4 border-2 border-accent border-t-transparent rounded-full animate-spin`}),(0,s.jsx)(`span`,{className:`text-[13px] font-bold tracking-widest uppercase text-foreground/70`,children:`Connecting`})]})]});function lo({level:e,children:t}){let{user:n,userRole:r,loading:i,userInactive:a,signOut:o,roleResolved:l}=ee(),u=(0,c.useLocation)();return i||!l?(0,s.jsx)(co,{}):n?a?(0,s.jsx)(Yr,{tone:`red`,title:`Access Denied`,message:`You don't have access to this app. Please contact the administrator.`,action:(0,s.jsx)(`button`,{onClick:()=>o(),className:Xr,children:`Sign Out`})}):n.emailVerified?e===`admin`&&!C(r)?(0,s.jsx)(ti,{}):e===`internal`&&!w(r)?(0,s.jsx)(ei,{}):(0,s.jsx)(s.Fragment,{children:t}):(0,s.jsx)(c.Navigate,{to:`/verify`}):(0,s.jsx)(c.Navigate,{to:`/login?from=${encodeURIComponent(u.pathname)}`})}var uo=({children:e})=>(0,s.jsx)(lo,{level:`signed-in`,children:e}),fo=({children:e})=>(0,s.jsx)(lo,{level:`admin`,children:e});function po({children:e}){let{user:t,loading:n,roleResolved:r}=ee(),[i]=(0,c.useSearchParams)();return n||!r?(0,s.jsx)(co,{}):t&&t.emailVerified?(0,s.jsx)(c.Navigate,{to:i.get(`from`)||`/dashboard`,replace:!0}):(0,s.jsx)(s.Fragment,{children:e})}function mo({children:e}){let{user:t,loading:n,roleResolved:r}=ee();return n||!r?(0,s.jsx)(co,{}):t?t.emailVerified?(0,s.jsx)(c.Navigate,{to:`/dashboard`}):(0,s.jsx)(s.Fragment,{children:e}):(0,s.jsx)(c.Navigate,{to:`/`})}function ho(){return(0,s.jsxs)(`div`,{className:`fixed top-0 left-0 w-full h-full pointer-events-none -z-0 overflow-hidden`,children:[(0,s.jsx)(t.f.div,{animate:{scale:[1,1.1,1],opacity:[.6,1,.6]},transition:{duration:12,repeat:1/0,ease:`easeInOut`},className:`absolute -top-[30%] md:-top-[400px] -right-[10%] md:-right-[200px] w-[500px] md:w-[800px] h-[500px] md:h-[800px] rounded-full bg-decorator-1 blur-[80px] md:blur-[120px]`}),(0,s.jsx)(t.f.div,{animate:{scale:[1,1.2,1],opacity:[.5,.9,.5]},transition:{duration:18,repeat:1/0,ease:`easeInOut`,delay:2},className:`absolute -bottom-[20%] md:-bottom-[300px] -left-[10%] md:-left-[100px] w-[400px] md:w-[600px] h-[400px] md:h-[600px] rounded-full bg-decorator-2 blur-[60px] md:blur-[100px]`})]})}function go(){let e=t.Bt().components?.Home||te;return(0,s.jsx)(j,{children:(0,s.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-hidden`,children:[(0,s.jsx)(V,{}),(0,s.jsxs)(c.Routes,{children:[(0,s.jsx)(c.Route,{path:`/`,element:(0,s.jsx)(po,{children:(0,s.jsx)(e,{})})}),(0,s.jsx)(c.Route,{path:`/register`,element:(0,s.jsx)(po,{children:(0,s.jsx)(ne,{})})}),(0,s.jsx)(c.Route,{path:`/login`,element:(0,s.jsx)(po,{children:(0,s.jsx)(re,{})})}),(0,s.jsx)(c.Route,{path:`/reset-password`,element:(0,s.jsx)(po,{children:(0,s.jsx)(ue,{})})}),(0,s.jsx)(c.Route,{path:`/verify`,element:(0,s.jsx)(mo,{children:(0,s.jsx)(ie,{})})}),(0,s.jsx)(c.Route,{path:`/guide`,element:(0,s.jsx)(It,{})}),(0,s.jsx)(c.Route,{path:`/templates`,element:(0,s.jsx)(Tt,{})}),(0,s.jsx)(c.Route,{path:`/templates/inline_form`,element:(0,s.jsx)(Lt,{})}),(0,s.jsx)(c.Route,{path:`/templates/popup_form`,element:(0,s.jsx)(Rt,{})}),(0,s.jsx)(c.Route,{path:`/templates/confirmation`,element:(0,s.jsx)(zt,{})}),(0,s.jsx)(c.Route,{path:`/templates/board`,element:(0,s.jsx)(Vt,{})}),(0,s.jsx)(c.Route,{path:`/templates/table`,element:(0,s.jsx)(_r,{})}),(0,s.jsx)(c.Route,{path:`/templates/calendar`,element:(0,s.jsx)(br,{})}),(0,s.jsx)(c.Route,{path:`/templates/drive`,element:(0,s.jsx)(bt,{})}),(0,s.jsx)(c.Route,{path:`/users`,element:(0,s.jsx)(fo,{children:(0,s.jsx)(ge,{})})}),(0,s.jsx)(c.Route,{path:`/users/:id`,element:(0,s.jsx)(fo,{children:(0,s.jsx)(ge,{})})}),(0,s.jsx)(c.Route,{path:`/inbox`,element:(0,s.jsx)(fo,{children:(0,s.jsx)(vt,{})})}),(0,s.jsx)(c.Route,{path:`/submissions`,element:(0,s.jsx)(c.Navigate,{to:`/inbox`,replace:!0})}),(0,s.jsx)(c.Route,{path:`/requests`,element:(0,s.jsx)(c.Navigate,{to:`/inbox`,replace:!0})}),(0,s.jsx)(c.Route,{path:`/assets`,element:(0,s.jsx)(fo,{children:(0,s.jsx)(wt,{})})}),(0,s.jsx)(c.Route,{path:`/drive/*`,element:(0,s.jsx)(c.Navigate,{to:`/assets`,replace:!0})}),(0,s.jsx)(c.Route,{path:`/theme`,element:(0,s.jsx)(fo,{children:(0,s.jsx)(Jr,{})})}),(0,s.jsx)(c.Route,{path:`/pages/*`,element:(0,s.jsx)(fo,{children:(0,s.jsx)(Qi,{})})}),(0,s.jsx)(c.Route,{path:`/forms/*`,element:(0,s.jsx)(fo,{children:(0,s.jsx)(da,{})})}),(0,s.jsx)(c.Route,{path:`/settings`,element:(0,s.jsx)(c.Navigate,{to:`/pages`,replace:!0})}),(0,s.jsx)(c.Route,{path:`/profile`,element:(0,s.jsx)(uo,{children:(0,s.jsx)(Z,{})})}),(0,s.jsx)(c.Route,{path:`/dashboard`,element:(0,s.jsx)(uo,{children:(0,s.jsx)(so,{})})}),(0,s.jsx)(c.Route,{path:`/setup`,element:(0,s.jsx)(oo,{})}),(0,s.jsx)(c.Route,{path:`*`,element:(0,s.jsx)(Ia,{})})]}),(0,s.jsx)(ho,{})]})})}function _o(){return(0,s.jsx)(c.BrowserRouter,{children:(0,s.jsx)(vo,{})})}function vo(){let e=t.Bt();return e.firebaseConfig&&e.firebaseConfig.apiKey&&e.firebaseConfig.apiKey.trim()!==``&&e.firebaseConfig.projectId&&e.firebaseConfig.projectId.trim()!==``||Za()?(0,s.jsx)(go,{}):(0,s.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-hidden`,children:[(0,s.jsx)(V,{standalone:!0}),(0,s.jsx)(oo,{standalone:!0}),(0,s.jsx)(ho,{})]})}function yo(e){g();let n=e.firebaseConfig;return n&&n.apiKey&&n.apiKey.trim()!==``&&n.projectId&&n.projectId.trim()!==``&&t.Ut(n),(0,s.jsx)(t.zt,{config:{firebaseConfig:e.firebaseConfig,adminEmails:e.adminEmails,basename:e.basename,onAuthChange:e.onAuthChange,themeConfig:e.themeConfig,components:e.components,customRoutes:e.customRoutes,microcomponents:e.microcomponents,defaultConfigs:e.defaultConfigs},children:(0,s.jsx)(t.Lt,{children:(0,s.jsx)(`div`,{className:`firebase-os flex-1 flex flex-col min-h-screen`,style:{background:`var(--bg-gradient)`,color:`var(--fg-color)`},children:(0,s.jsx)(_o,{})})})})}var bo=Object.assign({}),xo={};for(let e in bo){let t=bo[e];if(!t?.default)continue;let n=e.replace(`./`,``).replace(`.tsx`,``);if(n===`registry`)continue;let r=n.replace(/Content$/,``).replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toLowerCase();xo[r]=t.default,xo[r.replace(/_/g,``)]=t.default}if(typeof window<`u`){let e=window.__FBOS_MICROCOMPONENTS__||{};window.__FBOS_MICROCOMPONENTS__={...xo,...e}}var So=(e,t)=>{let n=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=n.replace(/_/g,``);if(xo[n]=t,xo[r]=t,typeof window<`u`){let e=window.__FBOS_MICROCOMPONENTS__||{};window.__FBOS_MICROCOMPONENTS__={...e,[n]:t,[r]:t}}};function Co(...e){return t.l(t.u(e))}var wo=({title:e,className:t,children:n,...r})=>(0,s.jsxs)(`div`,{className:Co(`border border-[var(--panel-border)] bg-[var(--panel-bg)] px-5 py-4`,t),style:{borderRadius:`var(--card-radius, 1rem)`},...r,children:[e?(0,s.jsx)(`p`,{className:`text-[12px] font-extrabold tracking-tight text-gradient mb-1.5`,children:e}):null,n]});wo.displayName=`Card`;function To(...e){return t.l(t.u(e))}var Eo=({sub:e,className:t,children:n,...r})=>(0,s.jsxs)(`div`,{className:To(`mb-4`,t),children:[(0,s.jsx)(`h2`,{className:`text-xl md:text-2xl font-extrabold tracking-tight text-foreground`,...r,children:n}),e?(0,s.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed mt-1`,children:e}):null]});Eo.displayName=`SectionHeading`,exports.AdminNotifications=P,exports.Button=t.s,exports.Card=wo,exports.ConfirmModal=_e,exports.ContactPopup=t.t,exports.CustomSelect=t.o,exports.DashboardNav=le,exports.FirebaseOS=yo,exports.Input=t.c,exports.Navbar=V,exports.PhoneInputField=n.t,exports.SectionHeading=Eo,Object.defineProperty(exports,`auth`,{enumerable:!0,get:function(){return t.Vt}}),Object.defineProperty(exports,`db`,{enumerable:!0,get:function(){return t.Ht}}),exports.registerMicrocomponent=So,Object.defineProperty(exports,`storage`,{enumerable:!0,get:function(){return t.Wt}}),exports.useAuth=ee,exports.useConfig=t.Bt,exports.useTheme=t.Rt;
|