your-ai-workflow-firebase-os 2.0.9 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Assets-COH4Ji57.js → Assets-BKXpQmMS.js} +2 -2
- package/dist/{Assets-D7fDckSi.cjs → Assets-DoZlHuud.cjs} +1 -1
- package/dist/{Billing-kk4ZMd3z.js → Billing-A6rwfQRT.js} +2 -2
- package/dist/{Billing-DkuJdls5.cjs → Billing-CBxVy-CG.cjs} +1 -1
- package/dist/{CopyLink-C5lKLyOU.cjs → CopyLink-D6QTWSoK.cjs} +1 -1
- package/dist/{CopyLink-CNjDLzOl.js → CopyLink-kROJG9Qf.js} +1 -1
- package/dist/{DashboardNav-GgEUpyTa.cjs → DashboardNav-Bc619nqn.cjs} +1 -1
- package/dist/{DashboardNav-CEd8gGPm.js → DashboardNav-CxS3Qnl-.js} +1 -1
- package/dist/{EmailAdmin-pbQ-f9Ge.js → EmailAdmin-DbWK_5Kw.js} +4 -4
- package/dist/{EmailAdmin-d_gWd48U.cjs → EmailAdmin-sa9C5jOw.cjs} +1 -1
- package/dist/{EventCard-DAsGsicK.cjs → EventCard-D57elnQo.cjs} +1 -1
- package/dist/{EventCard-BSGLYD64.js → EventCard-DnoR91KN.js} +1 -1
- package/dist/{FormsAdmin-5KTTp6zo.cjs → FormsAdmin-Ck7ssCHd.cjs} +1 -1
- package/dist/{FormsAdmin-BNI63vEk.js → FormsAdmin-DOes2Ajy.js} +4 -4
- package/dist/{Inbox-DjslBakx.cjs → Inbox-ChBLxjCi.cjs} +1 -1
- package/dist/{Inbox-D9Y5K8Se.js → Inbox-CyteB2LL.js} +2 -2
- package/dist/{MyBookings-CkEioQIj.cjs → MyBookings-B424zfVj.cjs} +1 -1
- package/dist/{MyBookings-B4DndHV6.js → MyBookings-DLQefkDS.js} +3 -3
- package/dist/{PageTitle-DQkvCB11.cjs → PageTitle-BL50s4qY.cjs} +1 -1
- package/dist/{PageTitle-DCoUQWw6.js → PageTitle-CkZriz8K.js} +1 -1
- package/dist/{PagesAdmin-YdYgmuEB.cjs → PagesAdmin-1U73GM_o.cjs} +1 -1
- package/dist/PagesAdmin-8smM_SDx.cjs +1 -0
- package/dist/{PagesAdmin-DzLJWKBJ.js → PagesAdmin-CORR24DJ.js} +8 -8
- package/dist/{PagesAdmin-D0qgoZtW.js → PagesAdmin-hhVAwuuy.js} +1 -1
- package/dist/{PaymentsAdmin-C3cEOeIs.js → PaymentsAdmin-CoaSATtY.js} +9 -9
- package/dist/{PaymentsAdmin-B5l-f0mp.cjs → PaymentsAdmin-DdP5FeXc.cjs} +1 -1
- package/dist/{ProviderMark--adeeajP.cjs → ProviderMark-BCQRu5Gs.cjs} +1 -1
- package/dist/{ProviderMark-BvEMlZAm.js → ProviderMark-Celkjuth.js} +1 -1
- package/dist/{PublishApp-Bc82Ijkq.cjs → PublishApp-CYHX36oo.cjs} +1 -1
- package/dist/{PublishApp-B9Fo6xN0.js → PublishApp-Dagc4TYm.js} +4 -4
- package/dist/{ScheduleAdmin-bk3GgxKP.js → ScheduleAdmin-D8siv7ZQ.js} +4 -4
- package/dist/{ScheduleAdmin-Dh_hW6p4.cjs → ScheduleAdmin-ohFzK-5E.cjs} +1 -1
- package/dist/{SchedulePicker-CN0755Ek.cjs → SchedulePicker-BpPGI5VZ.cjs} +1 -1
- package/dist/{SchedulePicker-DO4PewPJ.js → SchedulePicker-sZIZec9L.js} +1 -1
- package/dist/{Setup-_G-s5y5Q.js → Setup-DOGI-_8f.js} +2 -2
- package/dist/{Setup-R4r6_tbV.cjs → Setup-DiFnnzdd.cjs} +1 -1
- package/dist/{SetupPayments-CuFk9REC.cjs → SetupPayments-BLq0W5DU.cjs} +1 -1
- package/dist/{SetupPayments-CkolcOtv.js → SetupPayments-ICqCoZeQ.js} +3 -3
- package/dist/{SignInAdmin-BLEn0rId.js → SignInAdmin-CQzPqUui.js} +5 -5
- package/dist/{SignInAdmin-B1yLLaQu.cjs → SignInAdmin-JnhCefKY.cjs} +1 -1
- package/dist/{SupportBar-DI_XbEsG.js → SupportBar-0nIiQp-_.js} +105 -104
- package/dist/SupportBar-DR52UpBq.cjs +1 -0
- package/dist/{TemplateDrive-DNBwL0oy.js → TemplateDrive-6aV9Hmh3.js} +2 -2
- package/dist/{TemplateDrive-BJN-ReA_.cjs → TemplateDrive-ElNPzwv3.cjs} +1 -1
- package/dist/ThemeAdmin-B4CIxIjh.cjs +1 -0
- package/dist/ThemeAdmin-B9VnH5xH.js +2 -0
- package/dist/{ThemeAdmin-DkgmjW3g.cjs → ThemeAdmin-BhaTfgKX.cjs} +1 -1
- package/dist/{ThemeAdmin-Cnqefrz6.js → ThemeAdmin-C_8phTKX.js} +3 -3
- package/dist/{TransactionsAdmin-C5wQRR1g.cjs → TransactionsAdmin-BiV8VgD0.cjs} +1 -1
- package/dist/{TransactionsAdmin-Brs-CEcG.js → TransactionsAdmin-DAENRmVO.js} +3 -3
- package/dist/{Users-B16L9cKI.cjs → Users-Ayu_S4cd.cjs} +1 -1
- package/dist/{Users-CbI4K_Le.js → Users-CNRVFf3-.js} +5 -5
- package/dist/{appIcons-CCArfCDe.js → appIcons-DfjKL0tw.js} +1 -1
- package/dist/{appIcons-C90OKlV5.cjs → appIcons-Xjk-LuQ5.cjs} +1 -1
- package/dist/{arrivalRoads-Cc6AZM-d.cjs → arrivalRoads-1OeHArA0.cjs} +0 -0
- package/dist/{arrivalRoads-CGXm9Ntm.js → arrivalRoads-BZ4SWRAw.js} +0 -0
- package/dist/components/TutorialVideo.d.ts +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/{paidSessions-D-zHC4oG.cjs → paidSessions-BK9qlIyL.cjs} +1 -1
- package/dist/{paidSessions-B8e5RHi4.js → paidSessions-C9392hZH.js} +2 -2
- package/dist/{recordsKey-C4E2vOti.cjs → recordsKey-B3lWGd8C.cjs} +1 -1
- package/dist/{recordsKey-Cd216nq1.js → recordsKey-CJL-dAYF.js} +1 -1
- package/dist/{roles-BBDIJzox.cjs → roles-BmnoAilb.cjs} +1 -1
- package/dist/{roles-DiwP6-WQ.js → roles-D3T8p-hA.js} +2 -2
- package/dist/server.cjs.js +1 -1
- package/dist/server.es.js +1 -1
- package/dist/vite.cjs.js +1 -1
- package/dist/vite.es.js +1 -1
- package/dist/your-ai-workflow-firebase-os.cjs.js +13 -13
- package/dist/your-ai-workflow-firebase-os.es.js +2184 -2189
- package/package.json +1 -1
- package/scripts/postinstall.js +2 -1
- package/src/pages/Home.tsx +11 -14
- package/dist/PagesAdmin-KUxCI1Mr.cjs +0 -1
- package/dist/SupportBar-DLWruzQb.cjs +0 -1
- package/dist/ThemeAdmin-CoE_c5-P.cjs +0 -1
- package/dist/ThemeAdmin-DI7QaZ-0.js +0 -2
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-CiTBaPhY.cjs`),t=require(`./forms-CmNeTETW.cjs`),n=require(`./PageTitle-DQkvCB11.cjs`),r=require(`./TimeZoneField-Ckn1pKAL.cjs`),i=require(`./DashboardNav-GgEUpyTa.cjs`),a=require(`./Trouble-KQZyf6aY.cjs`),o=require(`./schedule-BAea6q8_.cjs`),s=require(`./chevron-down-lyDK1rfL.cjs`),c=require(`./TemplateDrive-BJN-ReA_.cjs`),l=require(`./arrow-left-C39sNUA7.cjs`),u=require(`./arrow-right-CGvbxks5.cjs`),d=require(`./mail-check-D_LNQw3l.cjs`),f=require(`./scheduleData-BXjNXVHY.cjs`),p=require(`./calendar-clock-D59cGNoL.cjs`),m=require(`./BookingCalendar-BcvJiyaq.cjs`),h=require(`./EventCard-DAsGsicK.cjs`),g=require(`./ContactPopup-D8aSSlmS.cjs`),_=require(`./chevron-left-DHTPst5Z.cjs`),v=require(`./FileViewerPopup-CkLUYCNo.cjs`),y=require(`./VideoPlayer-CggwpVXH.cjs`),b=require(`./ProviderMark--adeeajP.cjs`),x=require(`./FormNote-DP0GK9ya.cjs`),S=require(`./arrivalRoads-Cc6AZM-d.cjs`),C=require(`./x-Ci8c5p6T.cjs`),w=require(`./lock-xMnTQLRt.cjs`),T=require(`./plus-zsWFCu4F.cjs`),E=require(`./send-CWJXtO05.cjs`),D=require(`./shield-check-Bsd5oaif.cjs`),O=require(`./Said-W3KFi5uX.cjs`),k=require(`./trash-D-CpYHCs.cjs`);require(`./user-round-DUV_u2Tg.cjs`);const A=require(`./contentFallback-DVCrIUvK.cjs`),j=require(`./Popup-COnHpbrY.cjs`),M=require(`./Button-Ccy4wFZ1.cjs`),N=require(`./Loader-QHqQsXLr.cjs`),ee=require(`./mediaKind-ButDya5f.cjs`);require(`./bookingHold-DhS-tuuC.cjs`);const P=require(`./address-D88ICQCR.cjs`),te=require(`./formPage-DoDEEg1-.cjs`),F=require(`./email-Sya6gl4F.cjs`),I=require(`./registrationFields-DHHTptcl.cjs`),L=require(`./roles-BBDIJzox.cjs`),ne=require(`./notices-CKm9-Pqt.cjs`),R=require(`./transactions-CIU2NcKh.cjs`),z=require(`./tabAudience-2fJAN1aD.cjs`),re=require(`./ConfirmModal-BUNtss4a.cjs`),ie=require(`./recordsKey-C4E2vOti.cjs`),B=require(`./bookingPages-Dx1ViiwW.cjs`),V=require(`./pageFiles-Cn0YQ4Ur.cjs`),ae=require(`./recordLock-CiulizO1.cjs`),oe=require(`./AccessNotice-BClqr7A9.cjs`),se=require(`./Setup-R4r6_tbV.cjs`),ce=require(`./paidInFull-CZywIs-V.cjs`),H=require(`./ManagePlanButton-Buwfs2bU.cjs`),le=require(`./recordPrice-Cy7Km-eX.cjs`),U=require(`./people-BwWVVLfy.cjs`),ue=require(`./PhoneInputField-BxGBvuPB.cjs`);let W=require(`react`);W=e.a(W,1);let G=require(`react/jsx-runtime`),K=require(`firebase/auth`),q=require(`firebase/firestore`),J=require(`firebase/storage`),Y=require(`react-router-dom`),de=require(`react-dom`);var fe=Object.assign({"./contactForm.config.ts":t.o,"./supportForm.config.ts":t.i}),pe={};for(let e in fe){let t=fe[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};pe[r]=i,i.systemName&&(pe[i.systemName]=i,pe[i.systemName.toLowerCase()]=i)}if(typeof window<`u`){let e=window.__FBOS_FORMS__||{};window.__FBOS_FORMS__={...pe,...e}}var me=Object.assign({}),he={};for(let e in me){let t=me[e];if(!t)continue;let n=null;for(let e in t)if(e.endsWith(`Config`)){n=t[e];break}if(!n&&t?.default&&(n=t.default),!n)continue;let r=e.replace(`./`,``).replace(`.config.ts`,``).replace(/Registration$/,``).toLowerCase();he[r]=n}if(typeof window<`u`){let e=window.__FBOS_REGISTRATION__||{};window.__FBOS_REGISTRATION__={...he,...e}}var ge=Object.assign({}),_e=Object.assign({}),X={};for(let e in ge){let t=ge[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};X[r]=i,i.config.pageId&&(X[i.config.pageId]=i,X[i.config.pageId.toLowerCase()]=i)}for(let e in _e){let t=_e[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};X[r]=i,i.config.pageId&&(X[i.config.pageId]=i,X[i.config.pageId.toLowerCase()]=i)}if(typeof window<`u`){let e=window.__FBOS_PAGES__||{};window.__FBOS_PAGES__={...X,...e}}var ve=`.fbos-content-slot, .fbos-home-slot`,ye=`[data-picture]`,be=`[data-fbos-own]`,xe=/url\(\s*['"]?\s*(?:https?:|data:image|\/|[\w./-]+\.(?:png|jpe?g|webp|avif|gif|svg))/i,Z={img:`This page draws a picture with a plain <img>, so it holds no space while it loads, arrives in pieces down the screen, and downloads the full-size photograph however small the box is.`,background:`This page draws a picture as a background, so it holds no space while it loads, says nothing to somebody who cannot see it, and downloads the full-size photograph however small the box is.`},Q=`Paste this to your assistant: "Every picture on this page must use <Picture src={…} alt="…" className="…" /> imported from the app, not a plain <img> or a background image."`,Se=e=>`${Z[e]} ${Q}`,Ce=e=>!!e.closest(ve)&&!e.closest(`${ye}, ${be}`);function we(e){let t=new Set;for(let n of e.querySelectorAll(`img`))if(Ce(n)){t.add(`img`);break}for(let n of e.querySelectorAll(`[style*="background"]`)){let e=n.getAttribute(`style`)||``;if(xe.test(e)&&Ce(n)){t.add(`background`);break}}return t}function Te(e,t,n=()=>``){if(typeof MutationObserver>`u`)return()=>{};let r=new Set,i=0,a=()=>{let i=n();for(let n of we(e)){let e=`${i}#${n}`;r.has(e)||(r.add(e),t(n,Se(n)))}},o=e=>e.some(e=>e.type===`childList`||e.attributeName===`src`||(e.target.getAttribute?.(`style`)||``).includes(`url(`)),s=()=>{i||=requestAnimationFrame(()=>{i=0,a()})};a();let c=new MutationObserver(e=>{o(e)&&s()});return c.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`src`]}),()=>{c.disconnect(),i&&cancelAnimationFrame(i)}}var Ee=()=>{document.querySelectorAll(`.fbos-content-slot style, .fbos-home-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.`))})},De=e=>{for(let t=e;t;t=t.parentElement){if(t.classList.contains(`fbos-content-slot`)||t.classList.contains(`fbos-home-slot`))return!1;if(getComputedStyle(t).position===`fixed`)return!0}return!1},Oe=()=>{if(typeof window>`u`)return;let e=window.innerHeight*.6;document.querySelectorAll(`.fbos-content-slot *, .fbos-home-slot *`).forEach(t=>{if(!t.clientHeight||t.clientHeight<e||t.scrollHeight<=t.clientHeight+2)return;let n=getComputedStyle(t);n.overflowY!==`visible`&&(n.webkitLineClamp&&n.webkitLineClamp!==`none`||De(t)||(t.style.setProperty(`max-height`,`none`,`important`),t.style.setProperty(`height`,`auto`,`important`),t.scrollHeight>t.clientHeight+2&&t.style.setProperty(`overflow-y`,`visible`,`important`),typeof console<`u`&&console.warn(`FirebaseOS: a box in a content file was as tall as the screen and hid the rest of the page, which left the bottom unreachable on a phone — it was allowed to grow. Let the page be as long as it needs: no h-screen, max-h-screen or overflow-hidden around the whole page.`)))})},ke=`.fbos-content-slot, .fbos-home-slot`,Ae=()=>!!document.querySelector(ke),je=e=>{let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return t?!!t.closest?.(ke)||!!t.matches?.(ke)||!!t.querySelector?.(ke):!1},Me=e=>e.some(e=>je(e.target)||Array.from(e.addedNodes).some(je)),Ne=()=>{(0,W.useEffect)(()=>{if(typeof document>`u`||typeof MutationObserver>`u`)return;let e=()=>{Ae()&&(Ee(),Oe())},t=null,n=()=>{if(t!==null)return;let n=()=>{t=null,e()};t=typeof requestAnimationFrame==`function`?requestAnimationFrame(n):setTimeout(n,0)},r=()=>{t!==null&&(typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(t),clearTimeout(t),t=null)},i=n;e();let a=new MutationObserver(e=>{Me(e)&&n()});return a.observe(document.body,{childList:!0,subtree:!0}),window.addEventListener(`resize`,i),window.addEventListener(`orientationchange`,i),()=>{r(),a.disconnect(),window.removeEventListener(`resize`,i),window.removeEventListener(`orientationchange`,i)}},[])},Pe=`fbos_hand_drawn_pictures`,Fe=e=>{try{return(sessionStorage.getItem(Pe)||``).split(`|`).includes(e)}catch{return!1}},Ie=e=>{try{let t=(sessionStorage.getItem(Pe)||``).split(`|`).filter(Boolean);sessionStorage.setItem(Pe,[...new Set([...t,e])].join(`|`))}catch{}},Le=e=>{(0,W.useEffect)(()=>{if(!e||typeof document>`u`)return;let t=()=>typeof location>`u`?``:location.pathname;return Te(document.body,(e,n)=>{let i=`${t()}#${e}`;Fe(i)||(Ie(i),a.s(r.ti(n)))},t)},[e])};function Re(){let{isAdmin:e}=r.Ft();return Le(!!e),null}var ze={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};ze.node;var Be=s.n(ze),Ve={name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]};Ve.node;var He=s.n(Ve),Ue={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};Ue.node;var We=s.n(Ue),Ge={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Ge.node;var Ke=s.n(Ge),qe={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};qe.node;var Je=s.n(qe),Ye={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};Ye.node;var Xe=s.n(Ye),Ze={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Ze.node;var Qe=s.n(Ze),$e={name:`file-exclamation-point`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`file-warning`]};$e.node;var et=s.n($e),tt={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};tt.node;var nt=s.n(tt),rt={name:`layout-list`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}],[`path`,{d:`M14 4h7`,key:`3xa0d5`}],[`path`,{d:`M14 9h7`,key:`1icrd9`}],[`path`,{d:`M14 15h7`,key:`1mj8o2`}],[`path`,{d:`M14 20h7`,key:`11slyb`}]]};rt.node;var it=s.n(rt),at={name:`mail-warning`,size:24,node:[[`path`,{d:`M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5`,key:`e61zoh`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`M20 14v4`,key:`1hm744`}],[`path`,{d:`M20 22v.01`,key:`12bgn6`}]]};at.node;var ot=s.n(at),st={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};st.node;var ct=s.n(st),lt={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};lt.node;var ut=s.n(lt),dt={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};dt.node;var ft=s.n(dt),pt={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};pt.node;var mt=s.n(pt),ht={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};ht.node;var gt=s.n(ht),_t={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};_t.node;var vt=s.n(_t),yt={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};yt.node;var bt=s.n(yt),xt={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};xt.node;var St=s.n(xt),Ct=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAATRlWElmTU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAABqAAAAcgE7AAIAAAAJAAAA3IdpAAQAAAABAAAA5gAAAAAAAABgAAAAAQAAAGAAAAABQ2FudmEgZG9jPURBRzBuT2dSOVZFIHVzZXI9VUFHTW5pX05rRHcgYnJhbmQ9QkFHTW50Vy1oYkEgdGVtcGxhdGU9VGVhbCBNb2Rlcm4gR2FtaW5nIFlvdVR1YmUgQ2hhbm5lbCBMb2dvAEFudG9uaW5hAAAABpAAAAcAAAAEMDIxMJEBAAcAAAAEAQIDAKAAAAcAAAAEMDEwMKABAAMAAAABAAEAAKACAAQAAAABAAAAgKADAAQAAAABAAAAgAAAAAB8OpdMAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGZmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIj4KICAgICAgICAgPGV4aWY6Q29sb3JTcGFjZT42NTUzNTwvZXhpZjpDb2xvclNwYWNlPgogICAgICAgICA8ZXhpZjpQaXhlbFhEaW1lbnNpb24+ODAwPC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6RXhpZlZlcnNpb24+MDIxMDwvZXhpZjpFeGlmVmVyc2lvbj4KICAgICAgICAgPGV4aWY6Rmxhc2hQaXhWZXJzaW9uPjAxMDA8L2V4aWY6Rmxhc2hQaXhWZXJzaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+ODAwPC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6Q29tcG9uZW50c0NvbmZpZ3VyYXRpb24+CiAgICAgICAgICAgIDxyZGY6U2VxPgogICAgICAgICAgICAgICA8cmRmOmxpPjE8L3JkZjpsaT4KICAgICAgICAgICAgICAgPHJkZjpsaT4yPC9yZGY6bGk+CiAgICAgICAgICAgICAgIDxyZGY6bGk+MzwvcmRmOmxpPgogICAgICAgICAgICAgICA8cmRmOmxpPjA8L3JkZjpsaT4KICAgICAgICAgICAgPC9yZGY6U2VxPgogICAgICAgICA8L2V4aWY6Q29tcG9uZW50c0NvbmZpZ3VyYXRpb24+CiAgICAgICAgIDx4bXA6Q3JlYXRvclRvb2w+Q2FudmEgZG9jPURBRzBuT2dSOVZFIHVzZXI9VUFHTW5pX05rRHcgYnJhbmQ9QkFHTW50Vy1oYkEgdGVtcGxhdGU9VGVhbCBNb2Rlcm4gR2FtaW5nIFlvdVR1YmUgQ2hhbm5lbCBMb2dvPC94bXA6Q3JlYXRvclRvb2w+CiAgICAgICAgIDx0aWZmOlJlc29sdXRpb25Vbml0PjI8L3RpZmY6UmVzb2x1dGlvblVuaXQ+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgICAgIDx0aWZmOlhSZXNvbHV0aW9uPjk2PC90aWZmOlhSZXNvbHV0aW9uPgogICAgICAgICA8dGlmZjpZUmVzb2x1dGlvbj45NjwvdGlmZjpZUmVzb2x1dGlvbj4KICAgICAgICAgPGRjOnRpdGxlPgogICAgICAgICAgICA8cmRmOkFsdD4KICAgICAgICAgICAgICAgPHJkZjpsaSB4bWw6bGFuZz0ieC1kZWZhdWx0Ij5Mb2dvcyBmb3IgWWFpVyAtIDE8L3Jk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`,wt=`mem_notifications`,Tt=`case_notifications`,Et=e=>e===`admin`||e===`internal`,Dt=new Map;async function Ot(e){let t=Dt.get(e);if(typeof t==`boolean`)return t;try{let t=await(0,q.getDoc)((0,q.doc)(r.ui,`user_profiles`,e)),n=o.Sn(String(t.data()?.role||``));return Dt.set(e,n),n}catch{return!0}}async function kt(e,t){return await Ot(e)?t===e||Ot(t):!1}var At=[`email`,`Email`,`emailAddress`,`email_address`,`userEmail`,`contactEmail`,`submitterEmail`],jt=e=>{for(let t of At){let n=e[t];if(typeof n==`string`&&n.includes(`@`))return n.trim()}return``};async function Mt(e){let{toUid:t,toRole:n,title:i,body:a,link:o,email:s,about:c}=e||{},l=c&&typeof c==`object`?jt(c):``,u=!t&&!n&&!!l;if(!i||!t&&!n&&!u){console.warn(`notify(): needs a title and either toUid (one person) or toRole (an audience).`,e);return}let d=r.li.currentUser;if(!d){console.warn(`notify(): nobody is signed in, so there is no one to send as.`);return}let f=s===!0||u?F.n({toUid:String(t||``),toRole:String(n||``),title:i,body:a||``,link:o||``,...l?{about:{email:l}}:{}}):null;await Promise.all([u?null:Nt(e,d),f])}async function Nt(e,t){let{toUid:n,toRole:i,title:a,body:o,link:s}=e,l=String(i||``),u=[];if(n){if(u=await kt(t.uid,String(n))?[]:[c.E(String(n))],u[0]===`uid:`){console.warn(`notify(): toUid is the recipient’s uid — that one is empty, so the notification would reach nobody.`,e);return}}else if(!Et(l)){let t=c.D(l);if(t===`role:`){console.warn(`notify(): '${l}' is not an audience — pass 'admin', 'internal', or the role as you named it on the Users screen.`,e);return}u=[t]}let d={title:a,body:o||``,link:s||``,uid:t.uid,fromName:t.displayName||t.email||``};if(u.length){try{await(0,q.addDoc)((0,q.collection)(r.ui,Tt),{access:u,editors:u,...d,createdAt:Date.now()})}catch(e){console.warn(`notify(): the notification was not saved. Sending to a role — or to somebody who is not on your team — is kept in case_notifications, which needs the security rules re-pasted from the Setup screen. A sender who is signed out, unverified or deactivated is refused whatever the rules say.`,e)}return}try{await(0,q.addDoc)((0,q.collection)(r.ui,wt),{...n?{toUid:n}:{toRole:i},...d,createdAt:(0,q.serverTimestamp)()})}catch(e){console.warn(`notify(): the notification was not saved. If the sender is not on your team, re-paste your Firestore rules from /setup — sending from outside the team needs the mem_notifications line added in 1.14.21. A sender who is signed out, unverified or deactivated is refused whatever the rules say.`,e)}}var Pt=e=>{let t=String(e??``).trim();return t.startsWith(`/`)?(t.split(/[?#]/)[0].replace(/\/+$/,``)||`/`).toLowerCase():``},Ft=(e,t)=>Pt(t?.route?String(t.route).startsWith(`/`)?t.route:`/`+t.route:`/`+e);function It(e,{picks:t,records:r,files:a=i.x()}){let o=Pt(e);if(!o||o===`/`)return null;for(let[e,r]of Object.entries(i.n)){let i=Pt(r.path);if(o===i||o.startsWith(i+`/`))return n.p(t[e])??r.icon??null}let s={};for(let[e,t]of a)t?.isPublic||(s[e]={...t?.config||{},...r[e]||{}});for(let[e,t]of Object.entries(r)){let n=String(t?.fileId||``);n&&n!==e&&!r[n]?(s[e]={...s[n]||{},...t},delete s[n]):s[e]||(s[e]=t)}for(let[e,t]of Object.entries(s))if(Ft(e,t)===o)return n.p(t?.iconName)??n.g;return null}var Lt=()=>{try{let e=localStorage.getItem(`fbos_nav_tabs`),t=e?JSON.parse(e):null;return t&&typeof t==`object`?t:{}}catch{return{}}};function Rt(){let e=i.u(),[t,n]=(0,W.useState)(Lt);return(0,W.useEffect)(()=>r.Zr(`sys_tabs`,()=>(0,q.collection)(r.ui,`sys_tabs`),e=>{let t={};for(let n of e.docs||[])t[n.id]=n.data();n(t)},()=>{}),[]),n=>It(n,{picks:e,records:t})}function zt(e){return{id:`c_${e.id}`,type:`message`,title:String(e.title||`Notification`),subtitle:String(e.body||e.fromName||``),time:e.createdAt,link:typeof e.link==`string`&&e.link.startsWith(`/`)?e.link:void 0}}function Bt(e){return{id:`p_${e.id}`,type:`payment`,title:`New payment`,subtitle:r.Hn(e),time:e.at,link:`/transactions?open=${encodeURIComponent(e.id)}`}}function Vt(e){return{id:`p_${e.id}`,type:`payment`,title:`Order placed`,subtitle:r.Hn(e,!1),time:e.at,link:`/billing?open=${encodeURIComponent(e.id)}`}}var Ht={user:bt,booking:p.t,submission:n.h,request:Ke,verify:ot,role:mt,finish:b.n,message:d.n,payment:i.D};function Ut({n:e}){let t=Rt();return(0,W.createElement)(!e.standing&&t(e.link)||Ht[e.type]||Ke,{className:`w-4 h-4`})}function Wt(){let[e,t]=(0,W.useState)(!1),[n,i]=(0,W.useState)([]),a=(0,W.useRef)(null),s=(0,W.useRef)(null),[l,u]=(0,W.useState)(null),f=(0,Y.useNavigate)(),{user:p,userRole:m,roleConfirmed:h,profile:g,requestedRole:_}=r.Ft(),v=m===`admin`,y=r.Cn();L.l();let b=o.dn(p,g),x=o.Sn(m),S=c.F(Tt,{mine:!0,max:8}),C=r.zn(),w=r.Un(`sales`,p?.uid,v&&h&&C.configured),T=r.Un(`mine`,p?.uid,C.configured);(0,W.useEffect)(()=>{function e(e){a.current&&!a.current.contains(e.target)&&t(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let E=(0,W.useRef)({users:[],submissions:[],requests:[],direct:[],rolewide:[],bookings:[],booked:[],bookedByEmail:[],notices:[],sentToMe:[],sales:[],orders:[]}),D=(0,W.useRef)(!1);(0,W.useEffect)(()=>{D.current=!1},[p?.uid]);let O=(e,t)=>{E.current[e]=t;let n=E.current,r=new Set,a=[...n.users,...n.submissions,...n.requests,...n.direct,...n.rolewide,...n.bookings,...n.booked,...n.bookedByEmail,...n.notices,...n.sentToMe,...n.sales,...n.orders].filter(e=>r.has(e.id)?!1:(r.add(e.id),!0));a.sort((e,t)=>{let n=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return((t.time?.toDate?t.time.toDate().getTime():new Date(t.time).getTime())||0)-(n||0)}),i(a.slice(0,8))},k=(e,t)=>{D.current||(D.current=!0,console.warn(`AdminNotifications: this account could not read one of the notification feeds, so that part of the bell is empty. Most of them are the team's alone, and every one of them asks for a verified address.`,t)),O(e,[])};(0,W.useEffect)(()=>{let e=[];if(!h)return;if(v){let t=(0,q.query)((0,q.collection)(r.ui,`user_profiles`),(0,q.orderBy)(`createdAt`,`desc`),(0,q.limit)(5));e.push((0,q.onSnapshot)(t,e=>{O(`users`,e.docs.map(e=>{let t=e.data();return{id:`u_${e.id}`,type:`user`,title:`New user registered`,subtitle:t.email||t.phone||`Unknown`,time:t.createdAt,link:`/users/${e.id}`}}))},e=>k(`users`,e)));let n=(0,q.query)((0,q.collection)(r.ui,`user_submissions`),(0,q.orderBy)(`submittedAt`,`desc`),(0,q.limit)(5));e.push((0,q.onSnapshot)(n,e=>{O(`submissions`,e.docs.filter(e=>e.data()?.formId!==`booking`&&!o.nt(e.data()||{})&&!R.a(e.data()||{})).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,link:`/inbox?open=${encodeURIComponent(`anyone:${e.id}`)}`}}))},e=>k(`submissions`,e)));let i=(0,q.query)((0,q.collection)(r.ui,`user_requests`),(0,q.orderBy)(`submittedAt`,`desc`),(0,q.limit)(5));e.push((0,q.onSnapshot)(i,e=>{O(`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,link:`/inbox?open=${encodeURIComponent(`signedIn:${e.id}`)}`}}))},e=>k(`requests`,e)))}else O(`users`,[]),O(`submissions`,[]),O(`requests`,[]);let t=new Map;if(e.push(()=>{t.forEach(e=>e()),t.clear(),clearTimeout(void 0)}),O(`bookings`,[]),O(`booked`,[]),O(`bookedByEmail`,[]),p?.uid){let t=(0,q.query)((0,q.collection)(r.ui,ne.t),(0,q.where)(`uid`,`==`,p.uid)),n=e=>{let t=e.data()||{};return{id:`n_${e.id}`,type:`message`,title:String(t.title||`Notification`),subtitle:String(t.body||``),time:t.createdAt,link:typeof t.link==`string`&&t.link.startsWith(`/`)?t.link:void 0}};e.push((0,q.onSnapshot)(t,e=>{O(`notices`,e.docs.filter(e=>(e.data()||{}).kind===`notice`).map(n))},e=>k(`notices`,e)))}else O(`notices`,[]);if(p?.uid&&(v||x)){let t=e=>{let t=e.data();return{id:`m_${e.id}`,type:`message`,title:t.title||`Notification`,subtitle:t.body||t.fromName||``,time:t.createdAt,link:typeof t.link==`string`&&t.link.startsWith(`/`)?t.link:void 0}},n=(0,q.query)((0,q.collection)(r.ui,wt),(0,q.where)(`toUid`,`==`,p.uid));e.push((0,q.onSnapshot)(n,e=>O(`direct`,e.docs.map(t)),e=>k(`direct`,e)));let i=v?[`admin`,`internal`]:[`internal`],a=(0,q.query)((0,q.collection)(r.ui,wt),(0,q.orderBy)(`createdAt`,`desc`),(0,q.limit)(100));e.push((0,q.onSnapshot)(a,e=>O(`rolewide`,e.docs.filter(e=>i.includes((e.data()||{}).toRole)).map(t)),e=>k(`rolewide`,e)))}else O(`direct`,[]),O(`rolewide`,[]);return()=>e.forEach(e=>e())},[v,x,p?.uid,p?.email,h]),(0,W.useEffect)(()=>{let e=p?.uid?c.k(p.uid,m):[];O(`sentToMe`,e.length?S.records.filter(t=>c.w(t,e)).map(zt):[])},[S.records,p?.uid,m]),(0,W.useEffect)(()=>{O(`sales`,w.map(Bt))},[w]),(0,W.useEffect)(()=>{O(`orders`,T.map(Vt))},[T]);let[A,j]=(0,W.useState)(()=>typeof window<`u`?parseInt(localStorage.getItem(`admin_notifications_last_read`)||`0`,10):0),M=()=>{let n=!e;if(t(n),n){let e=s.current?.getBoundingClientRect();u(typeof window<`u`&&window.innerWidth<640&&e?e.bottom+8:null);let t=Date.now();j(t),typeof window<`u`&&localStorage.setItem(`admin_notifications_last_read`,t.toString())}},N=[];!y.loading&&I.y(g,m,y.finishRegistration,p?.uid)&&N.push({id:`finish-registration`,type:`finish`,title:`Finish registration`,subtitle:`There is still something we need from you.`,time:null,standing:!0,link:`/your-details`}),p&&_&&N.push({id:`role-request`,type:`role`,title:r.Qt,subtitle:r.Zt,time:null,standing:!0,urgent:!0,link:`/profile`}),b&&N.push({id:`verify-email`,type:`verify`,title:`Verify your email`,subtitle:`Open the link we sent to ${b} and you can sign in with it too. Nothing is waiting on it.`,time:null,standing:!0,link:`/verify`});let ee=N.length?[...N,...n]:n,P=ee.some(e=>{if(e.standing)return!0;if(e.silent)return!1;if(!e.time)return!0;let t=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return t>A||isNaN(t)}),te=e=>{t(!1),e.link?f(e.link):e.type===`user`?f(`/users`):e.type===`booking`?f(x?`/schedule`:`/my-bookings`):e.type===`submission`||e.type===`request`?f(`/inbox`):e.type===`verify`||e.type===`role`?f(`/profile`):e.type===`finish`?f(`/your-details`):e.type===`payment`&&f(v?`/transactions`:`/billing`)},F=e=>{if(!e)return``;let t=e.toDate?e.toDate():new Date(e),n=Date.now()-t.getTime();if(isNaN(n))return``;let r=Math.floor(n/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<7?`${a}d`:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`}).format(t)};return(0,G.jsxs)(`div`,{className:`relative z-50 flex-shrink-0`,ref:a,children:[(0,G.jsxs)(`button`,{ref:s,onClick:M,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":`Notifications`,children:[(0,G.jsx)(d.n,{className:`w-4 h-4`}),P&&(0,G.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-[var(--notification-icon-color)] rounded-full animate-pulse`})]}),(0,G.jsx)(r.rt,{children:e&&(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`${l===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:l===null?void 0:{top:l},children:[(0,G.jsxs)(`div`,{className:`px-4 border-b border-[var(--panel-border)]/50 pb-3 pt-4 flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`font-bold text-[14px] text-foreground tracking-wide`,children:`Notifications`}),(v||x)&&(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md`,children:v?`Admin`:`Team`})]}),(0,G.jsx)(`div`,{className:`max-h-[350px] overflow-y-auto w-full p-2 flex flex-col gap-1`,children:ee.length===0?(0,G.jsx)(`div`,{className:`p-6 text-center text-foreground/40 text-[13px] font-medium`,children:`No recent activity.`}):ee.map(e=>(0,G.jsxs)(`button`,{onClick:()=>te(e),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,G.jsx)(`div`,{className:`mt-0.5 w-8 h-8 rounded-full flex items-center justify-center shrink-0 ${e.urgent?`bg-red-500/10 text-red-500`:`bg-foreground/5 text-notification-icon`}`,children:(0,G.jsx)(Ut,{n:e})}),(0,G.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[13px] font-semibold text-foreground group-hover:text-accent transition-colors truncate flex-1 min-w-0`,children:e.title}),(0,G.jsx)(`span`,{className:`text-[10px] font-mono tracking-wide text-foreground/40 shrink-0`,children:F(e.time)})]}),(0,G.jsx)(`span`,{className:`text-[12px] text-foreground/60 ${e.standing?`leading-snug`:`truncate`}`,children:e.subtitle})]})]},e.id))})]})})]})}var Gt=[{id:`contact`,hidden:!1}],Kt={route:`/support`,template:`popup_form`,form:`support`,tabName:`Support`,iconName:``},qt={"/contact":n.h},Jt=e=>e&&qt[e]||n.g,Yt=`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`;function Xt({pages:e}){let[t,n]=(0,W.useState)(null),[a,o]=(0,W.useState)(!1),{rowRef:c,measureRef:l,visible:u}=i.s({count:e.length,listKey:e.map(e=>e.label+(e.submenu?` ▾`:``)).join(`|`),shown:!0,gap:28,moreButtonWidth:50}),d=e.slice(0,u),f=e.slice(u);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{ref:l,"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:e.map((e,t)=>(0,G.jsxs)(`span`,{"data-measure":!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,G.jsx)(s.t,{className:`w-3 h-3`})]},t))}),(0,G.jsxs)(`div`,{className:`flex items-center gap-7 w-full min-w-0 justify-end relative`,ref:c,children:[d.map((e,i)=>(0,G.jsxs)(`div`,{className:`relative shrink-0`,onMouseEnter:()=>n(e.label),onMouseLeave:()=>n(null),children:[e.path?(0,G.jsxs)(Y.Link,{to:e.path,className:Yt,children:[e.label,e.submenu&&(0,G.jsx)(s.t,{className:`w-3 h-3`})]}):(0,G.jsxs)(`button`,{onClick:e.action,className:Yt,children:[e.label,e.submenu&&(0,G.jsx)(s.t,{className:`w-3 h-3`})]}),e.submenu&&t===e.label&&(0,G.jsx)(`div`,{className:`absolute top-[100%] left-0 pt-2 z-50`,children:(0,G.jsx)(r.nt.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,G.jsx)(Y.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,G.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`}-${i}`)),f.length>0&&(0,G.jsxs)(`div`,{className:`relative flex items-center shrink-0`,onMouseEnter:()=>o(!0),children:[(0,G.jsx)(`button`,{onClick:()=>o(e=>!e),"aria-label":`More pages`,"aria-expanded":a,className:`p-1 rounded-lg transition-colors flex items-center ${a?`bg-foreground/5 text-accent`:`text-foreground/50 hover:bg-foreground/5 hover:text-accent`}`,children:(0,G.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,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,G.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`}),(0,G.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`})]})}),(0,G.jsx)(r.rt,{children:a&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>o(!1)}),(0,G.jsx)(r.nt.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:f.map((e,t)=>e.path?(0,G.jsx)(Y.Link,{to:e.path,onClick:()=>o(!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,G.jsx)(`button`,{onClick:()=>{e.action&&e.action(),o(!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))})]})})]})]})]})}function Zt({pages:e,onNavigate:t}){return(0,G.jsx)(G.Fragment,{children:e.map((e,n)=>{let r=Jt(e.path);return e.path?(0,G.jsxs)(Y.Link,{to:e.path,onClick:t,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 min-w-0`,children:[(0,G.jsx)(r,{className:`w-4 h-4 text-accent/70 shrink-0`}),` `,(0,G.jsx)(`span`,{className:`text-[14px] font-semibold truncate`,children:e.label})]},`${e.path}-${n}`):(0,G.jsxs)(`button`,{onClick:()=>{e.action&&e.action(),t?.()},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 min-w-0`,children:[(0,G.jsx)(r,{className:`w-4 h-4 text-accent/70 shrink-0`}),` `,(0,G.jsx)(`span`,{className:`text-[14px] font-semibold truncate`,children:e.label})]},`${e.label}-${n}`)})})}function Qt({pages:e,phone:t,onNavigate:n}){return t?(0,G.jsx)(Zt,{pages:e,onNavigate:n}):(0,G.jsx)(Xt,{pages:e})}var $t=e=>{if(!r.oi(e))return!1;let t=String(e?.message??e??``);return/\.(tsx|ts|jsx)\b|\/src\//.test(t)?!1:/https?:\/\/|\/assets\//.test(t)?!0:A.u()},en=e=>{if(e?.didNotArrive===!0||r.oi(e))return!0;let t=String(e?.message??e??``);return/Minified React error #306\b|lazy element type must resolve/i.test(t)},tn=e=>!!e&&typeof e==`object`&&e.$$typeof===Symbol.for(`react.lazy`),nn=class extends W.default.Component{state={failed:!1,passOn:null,reloading:!1};static getDerivedStateFromError(e){return{failed:!0,passOn:e,reloading:$t(e)&&r.ai()>0}}componentDidCatch(e){this.passesOn(e)||this.state.reloading&&r.ci(this.props.reload)||(this.state.reloading&&this.setState({reloading:!1}),A.o(this.props.which,e))}passesOn(e){return this.props.neverPutAside?!0:!!this.props.onlyMissing&&!en(e)}render(){if(this.state.failed&&this.passesOn(this.state.passOn)){let e=this.state.passOn;throw queueMicrotask(()=>A.o(this.props.which,e,`threw`)),e}return this.state.reloading?null:this.state.failed?this.props.fallback:this.props.children}};function rn(e){let t=r.mi().components?.Menu;return t?(0,G.jsx)(nn,{which:`menu`,fallback:(0,G.jsx)(Qt,{...e}),children:(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(t,{...e})})}):(0,G.jsx)(Qt,{...e})}var an=()=>document.querySelector(`[aria-modal="true"]`)!==null,on=e=>{let t=new MutationObserver(e);return t.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`aria-modal`]}),()=>t.disconnect()};function sn({isAdmin:e}){let t=A.d(e),i=a.i(),o=(0,W.useSyncExternalStore)(on,an,()=>!1),[s,c]=(0,W.useState)(!1);if(!t.length||o)return null;let l=r.ri(A.s(t));return(0,G.jsx)(`div`,{role:`status`,className:`fixed left-1/2 -translate-x-1/2 z-30 w-[calc(100%-2rem)] max-w-md transition-[bottom] duration-300 ${i?`bottom-40`:`bottom-[4.5rem]`}`,children:(0,G.jsxs)(`div`,{className:`glass-popover rounded-2xl px-4 py-3 flex items-center gap-3`,children:[(0,G.jsx)(et,{className:`w-4 h-4 shrink-0 text-accent`}),(0,G.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground/80 leading-snug flex-1 min-w-0`,children:[l.short.replace(A.i,``).trim(),(0,G.jsxs)(`span`,{className:`max-sm:hidden`,children:[` `,A.i]})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{navigator.clipboard?.writeText(l.message).catch(()=>{}),c(!0),setTimeout(()=>{c(!1),A.l(t)},1500)},"aria-label":s?`Copied`:`Copy the fix`,className:`shrink-0 inline-flex items-center justify-center gap-1.5 h-8 w-8 px-0 sm:w-auto sm:px-3 rounded-[var(--btn-radius,0.75rem)] text-[12px] font-semibold border ${s?`copy-btn-done border-[var(--panel-border)] text-foreground/60`:`copy-btn cursor-pointer`}`,children:[s?(0,G.jsx)(r.At,{className:`copy-icon w-3.5 h-3.5`}):(0,G.jsx)(n._,{className:`copy-icon w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`max-sm:hidden`,children:s?`Copied`:`Copy the fix`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>A.l(t),"aria-label":`Hide this`,className:`shrink-0 text-[13px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors`,children:`✕`})]})})}var cn=(0,W.createContext)({wide:!1,setWide:()=>{},cap:0,setCap:()=>{}});function ln({children:e}){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(0);return(0,G.jsx)(cn.Provider,{value:{wide:t,setWide:n,cap:r,setCap:i},children:e})}var un=()=>(0,W.useContext)(cn).wide,dn=()=>{let{wide:e,cap:t}=(0,W.useContext)(cn);return e?t:0};function fn(e=!0){let{setWide:t,setCap:n}=(0,W.useContext)(cn);(0,W.useLayoutEffect)(()=>{if(e)return t(!0),()=>t(!1)},[e,t]),(0,W.useLayoutEffect)(()=>{if(e)return _n()},[e]),(0,W.useLayoutEffect)(()=>{if(e)return gn(n)},[e,n])}var pn=.5,mn=400;function hn(e,t){if(!e||!t||typeof window>`u`)return 0;let n=getComputedStyle(t),r=(parseFloat(n.paddingLeft)||0)+(parseFloat(n.paddingRight)||0),i=window.innerHeight*pn,a=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let e=0,t=a.nextNode();t&&e<mn;t=a.nextNode(),e++){let e=t,n=getComputedStyle(e);if(n.position===`fixed`||n.display===`none`)continue;let a=parseFloat(n.maxWidth);if(!Number.isFinite(a)||a<960)continue;let o=e.getBoundingClientRect();if(o.width<=0||o.height<=0)continue;if(o.top>i)break;let s=e.parentElement?.getBoundingClientRect();if(!s)continue;let c=o.left-s.left,l=s.right-o.right;if(Math.abs(c-l)>2)continue;let u=a-(parseFloat(n.paddingLeft)||0)-(parseFloat(n.paddingRight)||0)-(parseFloat(n.borderLeftWidth)||0)-(parseFloat(n.borderRightWidth)||0);return Math.round(u+r)}return 0}function gn(e){if(typeof document>`u`)return()=>{};let t=0,n=()=>{t=0,e(hn(document.querySelector(`.fbos-home-slot, .fbos-page-canvas`),document.querySelector(`.firebase-os > nav, .firebase-os nav`)))},r=()=>{t||=requestAnimationFrame(n)};n();let i=[300,1e3,2500].map(e=>setTimeout(r,e)),a=document.querySelector(`.fbos-home-slot, .fbos-page-canvas`),o=a&&typeof MutationObserver<`u`?new MutationObserver(r):null;return o?.observe(a,{childList:!0,subtree:!0}),window.addEventListener(`resize`,r),()=>{i.forEach(clearTimeout),t&&cancelAnimationFrame(t),o?.disconnect(),window.removeEventListener(`resize`,r),e(0)}}function _n(){if(typeof document>`u`)return()=>{};let e=document.documentElement,t=document.querySelector(`.firebase-os > nav, .firebase-os nav`);if(!t)return()=>{};let n=()=>e.style.setProperty(`--menu-h`,`${Math.round(t.getBoundingClientRect().height)}px`);n();let r=typeof ResizeObserver<`u`?new ResizeObserver(n):null;return r?.observe(t),window.addEventListener(`resize`,n),()=>{r?.disconnect(),window.removeEventListener(`resize`,n),e.style.removeProperty(`--menu-h`)}}function vn({onNavigate:e}){let{user:t}=r.Ft(),{bought:n}=r.Ln(t?.uid);return n?(0,G.jsxs)(Y.Link,{to:`/billing`,onClick:e,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,G.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,G.jsx)(i.D,{className:`w-3 h-3 text-accent`})}),`Billing`]}):null}function yn({onNavigate:e}){return(0,G.jsx)(G.Fragment,{children:i.r().map(t=>{let n=t.icon;return(0,G.jsxs)(Y.Link,{to:t.path,onClick:e,"data-own-tab":t.id,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,G.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,G.jsx)(n,{className:`w-3 h-3 text-accent`})}),(0,G.jsx)(`span`,{className:`truncate min-w-0`,children:t.label})]},t.id)})})}var bn={contact:{label:`Contact`,path:`/contact`}},xn=`fbos_public_menu`,Sn=()=>{try{let e=localStorage.getItem(xn),t=e?JSON.parse(e):null;return t&&typeof t==`object`?t:{}}catch{return{}}},Cn=e=>{try{localStorage.setItem(xn,JSON.stringify({...Sn(),...e}))}catch{}},wn=new Set([`setup`,`templates`,`guide`]),Tn=1.6,En=`logo-shape:`,Dn={shape:`unknown`,ratio:0},On=e=>({shape:e>=Tn?`wide`:`square`,ratio:e}),kn=e=>{if(!e)return Dn;try{let t=localStorage.getItem(En+e);if(t===`wide`)return{shape:`wide`,ratio:0};if(t===`square`)return{shape:`square`,ratio:0};let n=Number(t);return t&&Number.isFinite(n)&&n>0?On(n):Dn}catch{return Dn}};function An(e){let[t,n]=(0,W.useState)(null),r=t&&t.url===e?t.measure:kn(e);return(0,W.useEffect)(()=>{if(!e||kn(e).shape!==`unknown`||typeof Image>`u`)return;let t=new Image;return t.onload=()=>{let r=Math.round(t.naturalWidth/Math.max(1,t.naturalHeight)*100)/100;try{localStorage.setItem(En+e,String(r))}catch{}n({url:e,measure:On(r)})},t.onerror=()=>n({url:e,measure:{shape:`square`,ratio:0}}),t.src=e,()=>{t.onload=null,t.onerror=null}},[e]),r}function jn({customMenu:e,standalone:t}){let{user:s,userRole:c,signOut:l,roleResolved:u,profileReady:d,profile:f}=r.Ft(),p=!!s&&u!==!1&&d!==!1,m=o.wn(c),[h,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(!1),[C,w]=(0,W.useState)(!1),T=String(f?.displayName||``).trim()||s?.displayName||s?.email?.split(`@`)[0]||``,E=T.charAt(0).toUpperCase()+T.slice(1),D=(0,G.jsx)(`span`,{className:`block h-3 w-16 rounded bg-foreground/5 animate-pulse`,"aria-hidden":`true`}),{theme:O,toggleTheme:k,activeConfig:A,canSwitchTheme:j}=i.N(),M=rn,N=async()=>{await l(),_(!1)},[ee,P]=(0,W.useState)(()=>Sn().info??{...bn}),[te,F]=(0,W.useState)(()=>Sn().order??Gt),[I,L]=(0,W.useState)(Kt.tabName);(0,W.useEffect)(()=>{if(!r.ui)return;let e=(0,q.onSnapshot)((0,q.collection)(r.ui,`sys_pages`),e=>{let t={...bn};for(let[e,n]of i.x()){if(!n.isPublic)continue;let r=n.config||{};if(r.enabled===!1)continue;let a=r.route?r.route.startsWith(`/`)?r.route:`/`+r.route:`/`+e;t[e]={label:r.pageName||r.pageTitle||r.title||e,path:a,iconName:r.iconName||``,offMenu:i.y(r)}}e.forEach(e=>{let n=e.data(),r=String(n.fileId||``),i=r&&t[r]||t[e.id];if(r&&r!==e.id&&delete t[r],n.enabled===!1)return;let a=n.pageName||n.title||bn[e.id]?.label||e.id,o=n.route||(e.id===`home`?`/`:`/`+e.id);t[e.id]={label:a,path:o,iconName:n.iconName||t[e.id]?.iconName||``,offMenu:i?.offMenu}});for(let e of wn)delete t[e];P(t),Cn({info:t})},e=>{a.s(e)}),t=(0,q.onSnapshot)((0,q.doc)(r.ui,`sys_configs`,`page_order`),e=>{let t=e.exists()&&Array.isArray(e.data().order)?i.c(e.data().order):Gt;F(t),Cn({order:t})},()=>{}),n=(0,q.onSnapshot)((0,q.doc)(r.ui,`sys_tabs`,`support`),e=>{e.exists()&&e.data().pageName&&L(e.data().pageName)},()=>{});return()=>{e(),t(),n()}},[]);let ne=(()=>{let e=new Set(te.filter(e=>e.hidden).map(e=>e.id)),t=new Set,n=[];return te.forEach(e=>{if(e.hidden||e.id===`home`)return;let r=ee[e.id];r&&(n.push({label:r.label,path:r.path,iconName:r.iconName}),t.add(e.id))}),Object.entries(ee).forEach(([r,i])=>{!t.has(r)&&!e.has(r)&&!i.offMenu&&r!==`home`&&i.path!==`/`&&i.path!==`/support`&&n.push({label:i.label,path:i.path,iconName:i.iconName})}),n})(),R=e||ne,z=t?[]:R.filter(e=>e.path&&n.p(e.iconName)),re=!t&&R.some(e=>n.d(e.iconName));(0,W.useEffect)(()=>{re&&n.m()},[re]);let ie=z.length?R.filter(e=>!z.includes(e)):R,[B,V]=(0,W.useState)(()=>typeof window<`u`&&window.innerWidth<640);(0,W.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{let e=window.innerWidth<640;V(t=>(t!==e&&_(!1),e))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let ae=!t&&!s&&!B,oe=un(),se=dn(),{shape:ce,ratio:H}=An(A?.logoUrl),le=ce===`square`&&!!A?.logoUrl&&H>1.05;return(0,G.jsxs)(`nav`,{className:`flex items-center justify-between w-full ${oe?`px-4 pt-4 pb-3 md:px-8 md:pt-10 md:pb-6`:`max-w-7xl px-4 py-4 md:px-8 md:py-10`} mx-auto z-40 relative`,style:se?{maxWidth:se}:void 0,children:[(0,G.jsx)(`div`,{className:`flex items-center min-w-0 z-50`,children:(0,G.jsx)(Y.Link,{to:`/`,className:`flex items-center gap-2 md:gap-2.5 lg:gap-3 group cursor-pointer z-50 min-w-0`,"aria-label":ce===`wide`?A?.appName||`Home`:void 0,children:ce===`wide`&&A?.logoUrl?(0,G.jsx)(`img`,{src:A.logoUrl,alt:A?.appName||``,"data-wide-logo":!0,draggable:!1,className:`h-6 md:h-7 lg:h-7 w-auto max-w-[140px] md:max-w-[180px] lg:max-w-[200px] object-contain object-left transition-opacity duration-300 group-active:opacity-80`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{"data-logo-tile":le?`wide`:`square`,"data-logo-ratio":le?String(H):void 0,style:le?{aspectRatio:String(H)}:void 0,className:`h-8 md:h-9 ${le?`w-auto`:`w-8 md:w-9 group-hover:rotate-180`} rounded-lg glass-panel flex items-center justify-center glow-hover shadow-lg transition-transform duration-500 group-active:scale-95 overflow-hidden shrink-0`,children:A?.logoUrl?(0,G.jsx)(r.O,{src:A.logoUrl,alt:`Logo`,fit:`contain`,priority:!0,className:`w-full h-full`,imgClassName:`max-md:p-0.5`}):(0,G.jsx)(`img`,{src:Ct,alt:``,"aria-hidden":`true`,draggable:!1,"data-brand-mark":!0,className:`w-full h-full object-cover`})}),(0,G.jsx)(`span`,{className:`font-display font-bold text-[17px] md:text-[19px] lg:text-[22px] tracking-tight text-gradient transition-all duration-300 drop-shadow-sm truncate`,children:A?.appName||``})]})})}),(0,G.jsx)(r.rt,{children:v&&(0,G.jsx)(g.t,{formId:`contact`,onClose:()=>y(!1)})}),(0,G.jsx)(r.rt,{children:b&&(0,G.jsx)(g.t,{formId:`support`,onClose:()=>x(!1)})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 md:gap-4 z-50 relative ml-auto flex-1 min-w-0 justify-end`,children:[ae&&(0,G.jsx)(`div`,{className:`flex items-center flex-1 min-w-0 justify-end mr-6`,children:(0,G.jsx)(M,{pages:ie,phone:!1})}),z.length>0&&(0,G.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:z.map((e,t)=>{let r=n.p(e.iconName)||n.g;return(0,G.jsx)(Y.Link,{to:e.path,"aria-label":e.label,title:e.label,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`,children:(0,G.jsx)(r,{className:`w-4 h-4`})},`${e.path}-${t}`)})}),!t&&!s&&(0,G.jsxs)(G.Fragment,{children:[j&&(0,G.jsx)(`button`,{onClick:k,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:O===`dark`?(0,G.jsx)(gt,{className:`w-4 h-4`}):(0,G.jsx)(ft,{className:`w-4 h-4`})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 shrink-0`,children:[!B&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y.Link,{to:`/login`,className:`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,G.jsx)(Y.Link,{to:`/register`,className:`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 shrink-0`,children:`Get Started`})]}),B&&(0,G.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,G.jsx)(`button`,{onClick:()=>_(h===`guest`?!1:`guest`),"aria-label":`Open menu`,"aria-expanded":h===`guest`,className:`w-9 h-9 rounded-xl glass-panel glow-hover border transition-all flex items-center justify-center ${h===`guest`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,G.jsx)(ct,{className:`w-5 h-5 text-accent/80`})}),(0,G.jsx)(r.rt,{children:h===`guest`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>_(!1)}),(0,G.jsxs)(r.nt.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,G.jsx)(M,{pages:ie,phone:!0,onNavigate:()=>_(!1)}),(0,G.jsx)(`div`,{className:`pt-2 mt-1 border-t border-[var(--panel-border)]/50 flex flex-col gap-1`,children:(0,G.jsxs)(Y.Link,{to:`/login`,onClick:()=>_(!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,G.jsx)(a.o,{className:`w-4 h-4 text-accent/70`}),` `,(0,G.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign In`})]})})]})]})})]})]})]}),!t&&p&&s&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,G.jsx)(Wt,{}),j&&(0,G.jsx)(`button`,{onClick:k,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:O===`dark`?(0,G.jsx)(gt,{className:`w-4 h-4`}):(0,G.jsx)(ft,{className:`w-4 h-4`})}),(0,G.jsxs)(`div`,{className:`relative z-50 flex-shrink-0`,children:[(0,G.jsxs)(`button`,{onClick:()=>_(h===`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 sm:border ${h===`user`?`sm:border-accent/50 sm:bg-foreground/5`:`sm:border-[var(--panel-border)] sm:hover:border-accent/30`}`,children:[(0,G.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 sm:border-0 transition-colors shrink-0 text-accent ${h===`user`?`border-accent/50`:`border-[var(--panel-border)] group-hover:border-accent/30`}`,children:s.photoURL&&!C?(0,G.jsx)(r.O,{src:s.photoURL,alt:`Profile`,className:`w-full h-full`,onError:()=>w(!0)}):(0,G.jsx)(bt,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,G.jsx)(`div`,{className:`max-sm:hidden sm:flex text-left mr-1 items-center min-w-[70px] max-w-[160px]`,children:E?(0,G.jsx)(`span`,{className:`text-[12px] font-extrabold leading-tight text-foreground truncate w-full`,children:E}):D})]}),(0,G.jsx)(r.rt,{children:h===`user`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>_(!1)}),(0,G.jsxs)(r.nt.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] max-h-[calc(100svh-6rem)] overflow-y-auto overscroll-contain glass-popover border border-[var(--panel-border)] rounded-2xl p-2 z-50 flex flex-col origin-top-right`,children:[(0,G.jsxs)(`div`,{className:`p-3 border-b border-[var(--panel-border)]/50 mb-1 flex flex-col gap-1.5`,children:[E?(0,G.jsx)(`span`,{className:`font-bold text-[15px] text-foreground truncate`,children:E}):(0,G.jsx)(`span`,{className:`block h-3.5 w-24 my-[3px] rounded bg-foreground/5 animate-pulse`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate font-mono`,children:s.email})]}),(0,G.jsxs)(`div`,{className:`py-1`,children:[(0,G.jsxs)(Y.Link,{to:`/dashboard`,onClick:()=>_(!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,G.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,G.jsx)(S._,{className:`w-3 h-3 text-accent`})}),`Dashboard`]}),(0,G.jsx)(yn,{onNavigate:()=>_(!1)}),m&&(0,G.jsxs)(Y.Link,{to:`/assets`,onClick:()=>_(!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,G.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,G.jsx)(i.k,{className:`w-3 h-3 text-accent`})}),`Assets`]}),c===`admin`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Y.Link,{to:`/users`,onClick:()=>_(!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,G.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,G.jsx)(i.S,{className:`w-3 h-3 text-accent`})}),`Users`]}),(0,G.jsxs)(Y.Link,{to:`/inbox`,onClick:()=>_(!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,G.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,G.jsx)(i.O,{className:`w-3 h-3 text-accent`})}),`Inbox`]}),(0,G.jsxs)(Y.Link,{to:`/pages`,onClick:()=>_(!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,G.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,G.jsx)(n.g,{className:`w-3 h-3 text-accent`})}),`Pages`]}),(0,G.jsxs)(Y.Link,{to:`/publish`,onClick:()=>_(!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,G.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,G.jsx)(i.w,{className:`w-3 h-3 text-accent`})}),`Publish App`]}),(0,G.jsxs)(Y.Link,{to:`/setup`,onClick:()=>_(!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,G.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,G.jsx)(St,{className:`w-3 h-3 text-accent`})}),`Setup`]})]}),c!==`admin`&&(0,G.jsxs)(Y.Link,{to:`/support`,onClick:()=>_(!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,G.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,G.jsx)(Ke,{className:`w-3 h-3 text-accent`})}),I]}),(0,G.jsx)(vn,{onNavigate:()=>_(!1)}),(0,G.jsxs)(Y.Link,{to:`/profile`,onClick:()=>_(!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,G.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,G.jsx)(bt,{className:`w-3 h-3 text-accent`})}),`Profile Settings`]})]}),(0,G.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,G.jsxs)(`button`,{onClick:N,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,G.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,G.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,G.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,G.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,G.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]})}),`Sign Out`]})})]})]})})]})]}),t&&(0,G.jsx)(G.Fragment,{children:j&&(0,G.jsx)(`button`,{onClick:k,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:O===`dark`?(0,G.jsx)(gt,{className:`w-4 h-4`}):(0,G.jsx)(ft,{className:`w-4 h-4`})})})]})]})}var Mn=`https://www.youtube.com/watch?v=Xl271wWblkY`;function Nn(){let[e,t]=(0,W.useState)(null),[n,i]=(0,W.useState)(!1);return(0,G.jsxs)(`main`,{className:`flex-1 flex flex-col items-center justify-center w-full px-4 md:px-8 mb-16 md:mb-24 z-10 relative`,children:[(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},className:`text-center mb-8 md:mb-12`,children:[(0,G.jsxs)(r.nt.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,G.jsx)(c.B,{className:`w-4 h-4 text-accent`}),` Build your whole app without code`]}),(0,G.jsx)(r.nt.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,G.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:`Everything your next app needs is already built — sign-ins, pages, payments, emails and files. Say what you want in plain words and watch it appear. No code, no servers, nothing to set up.`}),(0,G.jsxs)(r.nt.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,G.jsx)(Y.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-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`,children:`Sign In to Build`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),style:{borderRadius:`var(--btn-radius, 0.75rem)`},className:`group 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 gap-2.5 hover:-translate-y-1 active:scale-95 cursor-pointer`,children:[(0,G.jsx)(`span`,{className:`w-6 h-6 rounded-full bg-accent/15 text-accent flex items-center justify-center group-hover:bg-accent/25 transition-colors`,children:(0,G.jsx)(y.r,{className:`w-3 h-3 fill-current`})}),`Watch Tutorial`]})]})]}),(0,G.jsx)(j.t,{open:n,onClose:()=>i(!1),title:`Watch the tutorial`,sub:`From an empty project to a finished app.`,size:`lg`,children:n&&(0,G.jsx)(y.t,{src:Mn,title:`Watch the tutorial`,autoPlay:!0})}),(0,G.jsx)(r.rt,{children:e&&(0,G.jsx)(g.t,{onClose:()=>t(null),formId:e})})]})}var Pn=[.16,1,.3,1],Fn={hidden:{opacity:0,y:10},shown:{opacity:1,y:0,transition:{duration:.35,ease:Pn,delayChildren:.08,staggerChildren:.05}}},In={hidden:{opacity:0,y:8},shown:{opacity:1,y:0,transition:{duration:.35,ease:Pn}}};function Ln({width:e=`max-w-[480px]`,className:t,children:n}){let i=r.tt();return(0,G.jsxs)(r.nt.div,{initial:i?!1:`hidden`,animate:`shown`,variants:Fn,className:r.$(`w-full p-6 sm:p-8 md:p-10 rounded-3xl glass-panel relative shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,e,t),children:[(0,G.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl -z-10`}),n]})}function Rn({className:e,children:t}){return(0,G.jsx)(r.nt.div,{variants:In,className:e,children:t})}function zn({show:e,className:t,children:n}){let i=r.tt();return(0,G.jsx)(r.nt.div,{className:t,initial:i?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.25,ease:Pn},children:n},e)}function Bn({title:e,line:t,as:n=`h3`,align:i=`center`,className:a}){return(0,G.jsxs)(Rn,{className:r.$(`mb-6 sm:mb-7`,i===`center`?`text-center`:`text-left`,a),children:[(0,G.jsx)(n,{className:`text-[22px] sm:text-2xl font-semibold tracking-tight text-foreground leading-snug`,children:e}),t&&(0,G.jsx)(`p`,{className:`mt-1.5 text-[14px] text-foreground/60 leading-relaxed`,children:t})]})}function Vn({className:e,children:t}){return(0,G.jsx)(Rn,{className:r.$(`mt-6 pt-5 border-t border-[var(--panel-border)] text-center`,e),children:t})}var Hn=`text-[14px] text-foreground/60`,Un=`text-accent font-semibold hover:underline ml-1`;function Wn(){return(0,G.jsxs)(`div`,{"aria-busy":`true`,className:`flex flex-col gap-3.5`,children:[(0,G.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),(0,G.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),(0,G.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl opacity-60`})]})}function Gn({problem:e,onUse:t,signInHref:n}){let i=t&&e.tryInstead&&e.tryInstead!==`password`?e.tryInstead:null,a=i?b.t[i]:null;return(0,G.jsxs)(x.t,{className:`mb-4`,children:[e.text,e.tryInstead===`password`&&n&&(0,G.jsx)(Y.Link,{to:n,className:`mt-2 block font-bold text-accent hover:underline`,children:`Go to the sign-in page`}),i&&a&&t&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(i),className:`mt-2.5 w-full flex items-center justify-center gap-2 py-2 rounded-lg text-[13px] font-bold text-foreground bg-foreground/[0.06] hover:bg-foreground/10 transition-colors cursor-pointer`,children:[(0,G.jsx)(a,{className:`w-4 h-4 shrink-0`}),r.fn(i)?.button??`Use that instead`]})]})}function Kn({value:e,onChange:t,label:n=`The code we texted you`,autoFocus:r}){return(0,G.jsx)(g.y,{name:`code`,label:n,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,className:`max-sm:h-11 tracking-[0.3em] font-bold`,value:e,onChange:e=>t(e.target.value),autoFocus:r,required:!0})}function qn({step:e,onSignedIn:t,onCancel:n}){let[i,a]=(0,W.useState)(!0),[o,s]=(0,W.useState)(!1),[c,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(``),[m,h]=(0,W.useState)(null),g=(0,W.useRef)(null),_=(0,W.useRef)(!1),v=async e=>{h(await r.Kt(e,`sms2fa`,`That code could not be checked. Ask for a new one.`))},y=async()=>{h(null),a(!0);try{d(await e.send(g.current))}catch(e){await v(e)}finally{a(!1)}};return(0,W.useEffect)(()=>{_.current||(_.current=!0,y())},[]),(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2},children:[(0,G.jsx)(`div`,{ref:g}),m&&(0,G.jsx)(Gn,{problem:m}),(0,G.jsxs)(`div`,{className:`text-center mb-5`,children:[(0,G.jsx)(`p`,{className:`text-[15px] font-semibold text-foreground mb-1`,children:`One more step`}),(0,G.jsx)(`p`,{className:`text-[13.5px] text-foreground/60 leading-relaxed`,children:e.phone?(0,G.jsxs)(G.Fragment,{children:[`We texted a code to `,(0,G.jsx)(`span`,{className:`font-semibold text-foreground/80`,children:e.phone}),`. Type it in and you are in.`]}):(0,G.jsx)(G.Fragment,{children:`We texted you a code. Type it in and you are in.`})})]}),(0,G.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),h(null),s(!0);try{await e.finish(c,f.trim()),t()}catch(e){await v(e),s(!1)}},className:`flex flex-col gap-4`,children:[(0,G.jsx)(Kn,{value:f,onChange:p,autoFocus:!0}),(0,G.jsxs)(M.t,{type:`submit`,className:`w-full py-3 text-[15px] font-semibold`,isLoading:o||i,disabled:i||o||!c,children:[`Sign me in `,(0,G.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:y,disabled:i||o,className:`mt-3 w-full text-[13px] font-bold text-accent hover:underline disabled:opacity-40 disabled:no-underline cursor-pointer disabled:cursor-default`,children:`Send it again`}),n&&(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`mt-2 w-full inline-flex items-center justify-center gap-1.5 text-[13px] font-bold text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:[(0,G.jsx)(l.t,{className:`w-3.5 h-3.5 shrink-0`}),`Another way in`]})]})}var Jn=`password`,Yn=e=>!!e?.providerData?.some(e=>e?.providerId===Jn),Xn=e=>{let t=r.li?.currentUser;return t&&(!e||t.uid===e.uid)?t:e};function Zn(e){let t=Xn(e);if(!t)return[];try{return(0,K.multiFactor)(t).enrolledFactors??[]}catch{return[]}}var Qn=e=>Zn(e).length>0;function $n(e){let t=Zn(e)[0];return t?.phoneNumber||t?.displayName||``}var er=e=>!!e&&Yn(e)&&!Qn(e),tr=(e,t)=>t&&er(e),nr=`firebase-os:two-step-not-now`;function rr(e){if(e)try{sessionStorage.setItem(`${nr}:${e}`,`1`)}catch{}}function ir(e){if(!e)return!1;try{return sessionStorage.getItem(`${nr}:${e}`)===`1`}catch{return!1}}var ar=(e,t,n)=>tr(e,t)&&!(n&&ir(e?.uid)),or=(e,t)=>!!e&&(Qn(e)||t&&Yn(e)),sr=()=>{if(!r.li)throw Error(`Firebase is not initialized. Check your configuration.`);return r.li},cr=`Phone`,lr=e=>(0,K.multiFactor)(Xn(e)??e);async function ur(e,t,n){let i=await lr(e).getSession();return r.Yt(n,e=>new K.PhoneAuthProvider(sr()).verifyPhoneNumber({phoneNumber:t,session:i},e))}async function dr(e,t,n){let r=K.PhoneAuthProvider.credential(t,n);await lr(e).enroll(K.PhoneMultiFactorGenerator.assertion(r),cr)}async function fr(e){let t=lr(e);for(let e of[...t.enrolledFactors??[]])await t.unenroll(e)}function pr(e){if(e?.code!==`auth/multi-factor-auth-required`)return null;let t;try{t=(0,K.getMultiFactorResolver)(sr(),e)}catch{return null}let n=t.hints?.[0];return{phone:n?.phoneNumber||n?.displayName||``,send:e=>r.Yt(e,e=>new K.PhoneAuthProvider(sr()).verifyPhoneNumber({multiFactorHint:n,session:t.session},e)),finish:async(e,n)=>{let r=K.PhoneAuthProvider.credential(e,n);await t.resolveSignIn(K.PhoneMultiFactorGenerator.assertion(r))}}}var mr=r.si(()=>Promise.resolve().then(()=>require(`./PhoneInputField-WYdkNEym.cjs`))),hr=e=>r.hn(e).filter(e=>e.id!==`password`),gr=e=>{let t=e.inSentence.replace(/^an?\s+/i,``);return t.charAt(0).toUpperCase()+t.slice(1)};function _r({settings:e,onSignedIn:t,disabled:n,returnTo:i=`/login`,onPanelChange:a,signInHref:o,sentTo:s}){let c=hr(e),f=s&&c.some(e=>e.id===`emailLink`)?s:``,[p,m]=(0,W.useState)(null),[h,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(f?`emailLink`:null),[x,S]=(0,W.useState)(f),[C,w]=(0,W.useState)(f),[T,E]=(0,W.useState)(``),[D,O]=(0,W.useState)(``),[k,A]=(0,W.useState)(null),[j,N]=(0,W.useState)(null),ee=(0,W.useRef)(null),P=p!==null||n,te=v!==null||j!==null;(0,W.useEffect)(()=>{a?.(te)},[te]);let F=async(e,t)=>{let n=pr(e);if(n){N(n);return}_(await r.Kt(e,t,`That did not work. Try again, or use another way in.`))};(0,W.useEffect)(()=>{let e=r.Jt();e&&F(e.err,e.id)},[]);let I=async()=>{t()},L=async e=>{if(_(null),!r.Ht(e)){y(e),O(``),A(null),w(``);return}m(e);try{await r.qt(e)===`done`&&await I()}catch(t){await F(t,e)}finally{m(null)}},ne=async e=>{e.preventDefault(),_(null),m(`emailLink`);try{await r.Wt(x.trim(),i),w(x.trim())}catch(e){await F(e,`emailLink`)}finally{m(null)}},R=async()=>{_(null),m(`phone`);try{O(``),A(await r.Gt(T.trim(),ee.current))}catch(e){await F(e,`phone`)}finally{m(null)}},z=async e=>{e.preventDefault(),await R()},re=async e=>{e.preventDefault(),_(null),m(`phone`);try{await k.confirm(D.trim()),await I()}catch(e){await F(e,`phone`)}finally{m(null)}},ie=()=>{y(null),_(null),A(null),N(null),w(``),O(``)},B=()=>(0,G.jsxs)(`button`,{type:`button`,onClick:ie,className:`mt-3 w-full inline-flex items-center justify-center gap-1.5 text-[13px] font-bold text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:[(0,G.jsx)(l.t,{className:`w-3.5 h-3.5 shrink-0`}),`Another way in`]}),V=c.length===1&&!e.on.password;return(0,G.jsxs)(`div`,{children:[h&&(0,G.jsx)(Gn,{problem:h,onUse:L,signInHref:o}),(0,G.jsx)(`div`,{ref:ee}),j?(0,G.jsx)(qn,{step:j,onSignedIn:t,onCancel:V&&!v?void 0:ie}):v?(0,G.jsx)(r.nt.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2},children:(e=>e===`emailLink`?C?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] bg-foreground/[0.02] px-5 py-6 sm:py-7 text-center`,children:[(0,G.jsx)(`div`,{className:`w-12 h-12 mx-auto mb-4 rounded-2xl flex items-center justify-center bg-accent/10 text-accent ring-1 ring-inset ring-accent/20`,children:(0,G.jsx)(d.t,{className:`w-[22px] h-[22px]`})}),(0,G.jsx)(`p`,{className:`text-[16px] sm:text-[17px] font-extrabold tracking-tight text-foreground`,children:`Check your email`}),(0,G.jsx)(`p`,{className:`mt-1.5 text-[13px] text-foreground/50 font-medium`,children:`We sent a sign-in link to`}),(0,G.jsx)(`p`,{className:`mt-1 text-[14px] font-bold text-foreground break-all leading-snug`,children:C}),(0,G.jsx)(`p`,{className:`mt-3.5 text-[12.5px] text-foreground/50 font-medium leading-relaxed`,children:`Open it and you are in — there is no password to think of.`})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-center gap-3 text-[13px] font-bold`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>w(``),className:`text-accent hover:underline cursor-pointer`,children:`Send it again`}),!V&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`w-[1px] h-3.5 bg-[var(--panel-border)]`}),(0,G.jsxs)(`button`,{type:`button`,onClick:ie,className:`inline-flex items-center gap-1.5 text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:[(0,G.jsx)(l.t,{className:`w-3.5 h-3.5 shrink-0`}),`Another way in`]})]})]})]}):(0,G.jsxs)(`form`,{onSubmit:ne,className:`space-y-3`,children:[(0,G.jsx)(g.y,{name:`linkEmail`,label:`Your email`,type:`email`,placeholder:`name@example.com`,className:`max-sm:h-11`,value:x,onChange:e=>S(e.target.value),autoFocus:!V,required:!0}),(0,G.jsxs)(M.t,{type:`submit`,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,isLoading:p===`emailLink`,children:[`Email me a link `,(0,G.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]}),!V&&(0,G.jsx)(B,{})]}):e===`phone`?(0,G.jsxs)(`div`,{children:[k?(0,G.jsxs)(`form`,{onSubmit:re,className:`space-y-3`,children:[(0,G.jsx)(Kn,{value:D,onChange:O,autoFocus:!0}),(0,G.jsxs)(M.t,{type:`submit`,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,isLoading:p===`phone`,children:[`Sign me in `,(0,G.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-3 text-[13px] font-bold`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:R,disabled:p===`phone`,className:`text-accent hover:underline disabled:opacity-40 disabled:no-underline cursor-pointer disabled:cursor-default`,children:`Send it again`}),(0,G.jsx)(`span`,{className:`w-[1px] h-3.5 bg-[var(--panel-border)]`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{A(null),O(``),_(null)},className:`text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:`Use a different number`})]})]}):(0,G.jsxs)(`form`,{onSubmit:z,className:`space-y-3`,children:[(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,G.jsx)(mr,{field:{label:`Your phone number`,required:!0,placeholder:`7700 900123`},value:T,onChange:E})}),(0,G.jsxs)(M.t,{type:`submit`,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,isLoading:p===`phone`,children:[`Text me a code `,(0,G.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]})]}),!V&&(0,G.jsx)(B,{})]}):null)(v)}):c.length>3?(0,G.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2 sm:gap-2.5`,children:c.map(e=>{let t=b.t[e.id];return(0,G.jsxs)(M.t,{variant:`secondary`,onClick:()=>L(e.id),title:e.button,"aria-label":e.button,isLoading:p===e.id,disabled:P,className:`w-[88px] h-[68px] !px-1.5 text-[11px] font-bold tracking-tight rounded-xl transition-all hover:-translate-y-0.5 [&>span]:flex-col [&>span]:gap-1.5 [&>span]:w-full`,children:[(0,G.jsx)(t,{className:`w-[22px] h-[22px] shrink-0`}),(0,G.jsx)(`span`,{className:`w-full truncate text-center leading-none`,children:gr(e)})]},e.id)})}):(0,G.jsx)(`div`,{className:`space-y-3`,children:c.map(e=>{let t=b.t[e.id];return(0,G.jsxs)(M.t,{variant:`secondary`,onClick:()=>L(e.id),isLoading:p===e.id,disabled:P,className:`w-full py-2.5 sm:py-3 text-[15px] sm:text-base font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,children:[(0,G.jsx)(t,{className:`w-5 h-5 shrink-0`}),e.button]},e.id)})})]})}function vr({email:e,onSignedIn:t,onStartOver:n}){let[i,a]=(0,W.useState)(e),[o,s]=(0,W.useState)(!1),[c,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null);return f?(0,G.jsx)(qn,{step:f,onSignedIn:t,onCancel:n}):(0,G.jsxs)(`div`,{children:[c&&(0,G.jsx)(Gn,{problem:c}),(0,G.jsx)(`p`,{className:`text-[13.5px] text-foreground/60 font-medium leading-relaxed mb-4`,children:`Nearly there. This link did not bring your address with it, so tell us the one you asked us to send it to and you are in.`}),(0,G.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),d(null),s(!0);try{await r.Vt(i.trim()),t()}catch(e){let t=pr(e);if(t){p(t);return}d(await r.Kt(e,`emailLink`,`That link did not work. Ask for a new one.`,{email:i.trim()})),s(!1)}},className:`space-y-3`,children:[(0,G.jsx)(g.y,{name:`linkEmail`,label:`Your email`,type:`email`,placeholder:`name@example.com`,className:`max-sm:h-11`,value:i,onChange:e=>a(e.target.value),autoFocus:!0,required:!0}),(0,G.jsxs)(M.t,{type:`submit`,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,isLoading:o,children:[`Sign me in `,(0,G.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]}),n&&(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`mt-3 w-full inline-flex items-center justify-center gap-1.5 text-[13px] font-bold text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:[(0,G.jsx)(l.t,{className:`w-3.5 h-3.5 shrink-0`}),`Ask for a new link, or sign in another way`]})]})]})}var yr=`Signing you in…`;function br({note:e=`One moment.`}){return(0,G.jsxs)(`div`,{"aria-busy":`true`,className:`py-6 flex flex-col items-center gap-4 text-center`,children:[(0,G.jsx)(N.t,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:yr}),(0,G.jsx)(`p`,{className:`mt-1 text-[13px] text-foreground/55`,children:e})]})]})}function xr(){let[e,t]=(0,W.useState)(!1),n=(0,Y.useNavigate)();return{settling:e,signedIn:()=>{r.zt();let e=r.li?.currentUser;if(e&&!o.un(e)){n(`/verify`,{replace:!0});return}t(!0)}}}var Sr=[{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)}],Cr=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(`.`)),wr=e=>e.toLowerCase().replace(/[\s._-]/g,``),Tr=e=>Cr.has(wr(e||``)),Er=e=>Sr.map(t=>({rule:t,met:t.ok(e||``)}));function Dr(e){let t=e||``;if(!t)return`Choose a password.`;let n=Sr.find(e=>!e.ok(t));return n?`Your password needs ${n.label.toLowerCase()}.`:Tr(t)?`That password is one of the first anyone would guess. Please pick another.`:``}function Or(e,t){return t?e===t?``:`Both passwords must be the same.`:`Type your password a second time.`}function kr({value:e,className:t=``}){return(0,G.jsx)(`ul`,{className:`flex flex-col gap-1 ml-1 ${t}`,"aria-label":`Password requirements`,children:Er(e).map(({rule:e,met:t})=>(0,G.jsxs)(`li`,{className:`flex items-center gap-2 text-[12.5px] font-medium transition-colors ${t?`text-emerald-500`:`text-foreground/45`}`,children:[t?(0,G.jsx)(r.At,{className:`w-3.5 h-3.5 shrink-0`}):(0,G.jsx)(`span`,{className:`w-3.5 flex justify-center shrink-0`,children:(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-foreground/25`})}),e.label]},e.id))})}var Ar=`again`,jr=e=>`This account is half-made: nothing has been saved to it, and nothing can be until ${e||`the address on it`} is proved. Letting it go frees that address and takes you back to the form, where you fill in your details again with the address you want — and the next link goes to that one.`,Mr=(e=window.location.pathname)=>`${e.replace(/\/+$/,``).replace(/\/[^/]*$/,``)}/register?${Ar}=1`;async function Nr(e){let t=e||r.li.currentUser;if(t){r.Tn(t.uid);try{await(0,K.deleteUser)(t)}catch{await(0,K.signOut)(r.li).catch(()=>{})}}window.location.assign(Mr())}function Pr({as:e}={}){let[t,n]=(0,W.useState)(!1),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(``),[m,h]=(0,W.useState)(!1),_=(0,Y.useNavigate)(),[v]=(0,Y.useSearchParams)(),{registerUser:y}=r.Ft(),b=r.Cn(),{settling:S,signedIn:C}=xr(),w=v.has(Ar),T=(()=>{let e=new URLSearchParams(v);e.delete(`as`);let t=e.toString();return`/register${t?`?${t}`:``}`})(),E=async e=>{e.preventDefault(),n(!0),a(null);let t=new FormData(e.currentTarget),i=t.get(`email`),s=t.get(`firstName`),l=t.get(`lastName`),u=Dr(o),f=u?``:Or(o,c);if(d(u),p(f),u||f){a(u||f),n(!1);return}try{await y(i,o,s,l),_(`/verify`)}catch(e){e?.code===`auth/email-already-in-use`?a((0,G.jsxs)(`span`,{children:[(await r.Kt(e,`password`,``,{email:i})).text,` `,(0,G.jsx)(Y.Link,{to:`/login?email=${encodeURIComponent(i)}`,className:`font-bold`,children:`Sign in`})]})):e?.code===`auth/weak-password`?a(Dr(o)||`Please choose a stronger password.`):a((await r.Kt(e,`password`,`That did not work. Check your details and try again.`,{email:i})).text)}finally{n(!1)}},D=r._n(b),O=hr(b),k=S?`signing`:b.loading?`loading`:`form`;return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,G.jsxs)(Ln,{width:`max-w-[500px]`,children:[(0,G.jsx)(Bn,{title:e?r.an(e.id,e.name):`Create an account`,line:e?r.Xt:`Join Your AI Firebase and start building today.`}),i&&(0,G.jsx)(x.t,{className:`mb-5`,children:i}),!i&&w&&(0,G.jsx)(x.t,{tone:`note`,className:`mb-5`,children:`Start again with the address you want. Nothing was saved to the one you began with, and the next link goes wherever you type here.`}),(0,G.jsx)(Rn,{children:(0,G.jsx)(zn,{show:k,children:S?(0,G.jsx)(br,{}):b.loading?(0,G.jsx)(Wn,{}):(0,G.jsxs)(G.Fragment,{children:[D&&!m&&(0,G.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:E,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5`,children:[(0,G.jsx)(g.y,{name:`firstName`,label:`First Name`,type:`text`,placeholder:`John`,className:`max-sm:h-11`,required:!0}),(0,G.jsx)(g.y,{name:`lastName`,label:`Last Name`,type:`text`,placeholder:`Doe`,className:`max-sm:h-11`,required:!0})]}),(0,G.jsx)(g.y,{name:`email`,label:`Email`,type:`email`,placeholder:`name@example.com`,className:`max-sm:h-11`,required:!0}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,G.jsx)(g.y,{name:`password`,label:`Password`,type:`password`,placeholder:`••••••••`,className:`max-sm:h-11`,autoComplete:`new-password`,value:o,onChange:e=>{s(e.target.value),u&&d(``),f&&e.target.value===c&&p(``)},onBlur:()=>d(o?Dr(o):``),error:u,required:!0}),o&&(0,G.jsx)(kr,{value:o})]}),o&&(0,G.jsx)(g.y,{name:`confirmPassword`,label:`Confirm password`,type:`password`,placeholder:`••••••••`,className:`max-sm:h-11`,autoComplete:`new-password`,value:c,onChange:e=>{l(e.target.value),f&&p(``)},onBlur:()=>p(c?Or(o,c):``),error:f,required:!0}),(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(M.t,{type:`submit`,className:`w-full py-3 text-[15px] font-semibold`,isLoading:t,children:`Create Account`})})]}),D&&O.length>0&&!m&&(0,G.jsxs)(`div`,{className:`flex items-center gap-3 my-6`,children:[(0,G.jsx)(`span`,{className:`h-[1px] flex-1 bg-[var(--panel-border)]`}),(0,G.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/40`,children:`or`}),(0,G.jsx)(`span`,{className:`h-[1px] flex-1 bg-[var(--panel-border)]`})]}),O.length>0&&(0,G.jsx)(_r,{settings:b,onSignedIn:C,disabled:t,returnTo:`/login`,onPanelChange:h,signInHref:`/login`})]})})}),(0,G.jsxs)(Vn,{className:`space-y-2`,children:[e&&(0,G.jsxs)(`p`,{className:`text-[14px] text-foreground/60`,children:[`Registering as something else? `,(0,G.jsx)(Y.Link,{to:T,className:`text-accent font-semibold hover:underline ml-1`,children:`Choose again`})]}),(0,G.jsxs)(`p`,{className:Hn,children:[`Already have an account? `,(0,G.jsx)(Y.Link,{to:`/login`,className:Un,children:`Sign in`})]})]})]})})}var Fr=`member`;function Ir(e,t){let n=new URLSearchParams(e);return n.set(`as`,t),`/register?${n.toString()}`}function Lr({choices:e,search:t=``}){let i=e.length>3;return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,G.jsxs)(Ln,{width:i?`max-w-[640px]`:`max-w-[500px]`,children:[(0,G.jsx)(Bn,{title:`Create an account`,line:`What are you registering as?`}),(0,G.jsxs)(Rn,{children:[(0,G.jsx)(`div`,{role:`list`,"aria-label":`Register as`,className:`grid gap-3 ${i?`grid-cols-1 sm:grid-cols-2`:`grid-cols-1`}`,children:e.map((a,o)=>{let s=i&&e.length%2==1&&o===e.length-1;return(0,G.jsxs)(Y.Link,{role:`listitem`,to:Ir(t,a.id),className:`group flex items-center gap-3.5 min-w-0 px-4 py-3.5 rounded-2xl border border-[var(--panel-border)] bg-foreground/[0.02] hover:border-accent/50 hover:bg-foreground/[0.03] active:scale-[0.99] transition-all duration-300 ${s?`sm:col-span-2`:``}`,children:[(0,G.jsx)(n.c,{name:L.u(a.id),className:`w-[18px] h-[18px] shrink-0 text-accent`}),(0,G.jsx)(`span`,{className:`flex-1 min-w-0 text-[14.5px] font-semibold text-foreground leading-snug tracking-tight`,children:r.an(a.id,a.name)}),(0,G.jsx)(u.t,{className:`w-4 h-4 shrink-0 text-foreground/30 group-hover:text-accent group-hover:translate-x-0.5 transition-all`})]},a.id)})}),(0,G.jsx)(`p`,{className:`mt-4 text-[13px] text-foreground/50 text-center leading-relaxed`,children:r.Xt})]}),(0,G.jsxs)(Vn,{className:`space-y-2`,children:[(0,G.jsxs)(`p`,{className:Hn,children:[`Just want an account?`,(0,G.jsx)(Y.Link,{to:Ir(t,Fr),className:Un,children:`Register as a member`})]}),(0,G.jsxs)(`p`,{className:Hn,children:[`Already have an account?`,(0,G.jsx)(Y.Link,{to:`/login`,className:Un,children:`Sign in`})]})]})]})})}function Rr({settings:e}){let t=L.l(),[n]=(0,Y.useSearchParams)(),i=n.get(`as`),a=r.bn(e,t),o=i?r.yn(e,i,t):null,s=n.has(`preview`)?``:o?.id??``;return(0,W.useEffect)(()=>{e.loading||(s?r.on(s):r.rn())},[e.loading,s]),e.loading?(0,G.jsx)(Pr,{}):o?(0,G.jsx)(Pr,{as:o}):a.length&&!i?(0,G.jsx)(Lr,{choices:a,search:n.toString()}):(0,G.jsx)(Pr,{})}function zr(){let e=r.Cn();return!e.loading&&!e.registerAs.on?(r.rn(),(0,G.jsx)(Pr,{})):(0,G.jsx)(Rr,{settings:e})}function Br(){let[e,t]=(0,W.useState)(!1),[n,i]=(0,W.useState)(null),[a]=(0,Y.useSearchParams)(),o=(0,Y.useNavigate)(),[s]=(0,W.useState)(a.get(`email`)||``),[c]=(0,W.useState)(()=>a.get(`sent`)===`1`&&!!a.get(`email`)),[l]=(0,W.useState)(()=>a.get(`from`)||``),u=r.Cn(),{loading:d}=r.Ft(),[f,p]=(0,W.useState)(()=>r.Bt()?`finishing`:`no`),[m,h]=(0,W.useState)(null),[_,v]=(0,W.useState)(!1),y=()=>{p(`no`),h(null),i(null),o(`/login`,{replace:!0})},{settling:b,signedIn:S}=xr();(0,W.useEffect)(()=>{if(f!==`finishing`||d)return;let e=r.Ut();if(!e){p(`asking`);return}let t=!1;return r.Vt(e).then(()=>{t||S()}).catch(e=>{if(t)return;let n=pr(e);if(n){h(n);return}p(`asking`)}),()=>{t=!0}},[f,d]);let C=async e=>{e.preventDefault(),t(!0),i(null);let n=new FormData(e.currentTarget),a=n.get(`email`),o=n.get(`password`);try{if(!r.li)throw Error(`Firebase is not initialized. Check your configuration.`);await(0,K.signInWithEmailAndPassword)(r.li,a,o),S()}catch(e){let n=pr(e);if(n){h(n),t(!1);return}e?.code===`auth/invalid-credential`||e?.code===`auth/user-not-found`||e?.code===`auth/wrong-password`||e?.code===`auth/invalid-login-credentials`?i((0,G.jsxs)(`span`,{children:[`That email and password do not match.`,` `,(0,G.jsx)(Y.Link,{to:`/reset-password`,children:`Reset password?`}),T.length>0&&(0,G.jsx)(G.Fragment,{children:` If you first came in with one of the buttons below, use that button instead.`})]})):i((await r.Kt(e,`password`,`That did not work. Check your details and try again.`,{email:a})).text),t(!1)}},w=r._n(u),T=hr(u),E=c&&T.some(e=>e.id===`emailLink`)?s:``,D=b||f===`finishing`&&!m,O=D?`signing`:m?`step`:f===`asking`?`asking`:u.loading?`loading`:`form`;return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,G.jsxs)(Ln,{width:`max-w-[480px]`,children:[(0,G.jsx)(Bn,{title:`Welcome back`,line:`Sign in to Your AI Firebase.`}),n&&(0,G.jsx)(x.t,{className:`mb-5`,children:n}),!n&&c&&!E&&f===`no`&&!b&&(0,G.jsxs)(x.t,{tone:`done`,className:`mb-5`,children:[`We have emailed a sign-in link to `,s,`. Open it on this device and you go straight to your order — or sign in below.`]}),(0,G.jsx)(Rn,{children:(0,G.jsx)(zn,{show:O,children:D?(0,G.jsx)(br,{note:f===`finishing`?`One moment — your link checks out.`:void 0}):m?(0,G.jsx)(qn,{step:m,onSignedIn:S}):f===`asking`?(0,G.jsx)(vr,{email:s,onSignedIn:S,onStartOver:y}):u.loading?(0,G.jsx)(Wn,{}):(0,G.jsxs)(G.Fragment,{children:[w&&!_&&(0,G.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:C,children:[(0,G.jsx)(g.y,{name:`email`,label:`Email`,type:`email`,defaultValue:s,placeholder:`name@example.com`,className:`max-sm:h-11`,required:!0}),(0,G.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between items-baseline mb-1.5 mx-1`,children:[(0,G.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none`,children:`Password`}),(0,G.jsx)(Y.Link,{to:`/reset-password`,className:`text-[13px] font-semibold text-accent hover:underline`,children:`Forgot Password?`})]}),(0,G.jsx)(g.y,{name:`password`,type:`password`,placeholder:`••••••••`,className:`max-sm:h-11`,required:!0})]}),(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(M.t,{type:`submit`,className:`w-full py-3 text-[15px] font-semibold`,isLoading:e,children:`Sign In`})})]}),w&&T.length>0&&!_&&(0,G.jsxs)(`div`,{className:`flex items-center gap-3 my-6`,children:[(0,G.jsx)(`span`,{className:`h-[1px] flex-1 bg-[var(--panel-border)]`}),(0,G.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/40`,children:`or`}),(0,G.jsx)(`span`,{className:`h-[1px] flex-1 bg-[var(--panel-border)]`})]}),T.length>0&&(0,G.jsx)(_r,{settings:u,onSignedIn:S,disabled:e,returnTo:l?`/login?from=${encodeURIComponent(l)}`:`/login`,onPanelChange:v,sentTo:E})]})})}),(0,G.jsx)(Vn,{children:(0,G.jsxs)(`p`,{className:Hn,children:[`New here? `,(0,G.jsx)(Y.Link,{to:`/register`,className:Un,children:`Create account`})]})})]})})}var Vr=()=>{if(!r.li)throw Error(`Firebase is not initialized. Check your configuration.`);return r.li},Hr=`/confirm-email`,Ur=`address`,Wr=`firebase-os:address-link`;async function Gr(e,t){let n=new URL(Hr,window.location.origin);n.searchParams.set(`for`,t),n.searchParams.set(Ur,e),await(0,K.sendSignInLinkToEmail)(Vr(),e,{url:n.toString(),handleCodeInApp:!0})}function Kr(e=window.location.href){let t;try{t=new URL(e).searchParams}catch{return null}let n=String(t.get(`for`)||``).trim(),r=String(t.get(`address`)||``).trim();if(!n||!r)return null;try{if(!(0,K.isSignInWithEmailLink)(Vr(),e))return null}catch{return null}return{uid:n,address:r,url:e}}function qr(e){try{localStorage.setItem(Wr,JSON.stringify(e))}catch{}}function Jr(){try{let e=localStorage.getItem(Wr);if(!e)return null;let t=JSON.parse(e);return t?.uid&&t?.address&&t?.url?t:null}catch{return null}}var Yr=e=>!!e&&Jr()?.uid===e;function Xr(){try{localStorage.removeItem(Wr)}catch{}}async function Zr(e){let t=r.li?.currentUser??null;if(!t)return`signInFirst`;if(t.uid!==e.uid)return`wrongAccount`;if((t.email||``).toLowerCase()===e.address.toLowerCase()&&t.emailVerified)return`confirmed`;try{await(0,K.linkWithCredential)(t,K.EmailAuthProvider.credentialWithLink(e.address,e.url))}catch(e){let t=e?.code||``;return t===`auth/provider-already-linked`?`confirmed`:t===`auth/email-already-in-use`||t===`auth/credential-already-in-use`?`takenElsewhere`:t===`auth/invalid-action-code`||t===`auth/expired-action-code`||t===`auth/invalid-email`||t===`auth/argument-error`?`spent`:(console.warn(`The address could not be added to this sign-in.`,e),`failed`)}try{await t.getIdToken(!0)}catch{}try{await t.reload()}catch{}return`confirmed`}var Qr=5e3,$r=120,ei=30,ti=900;function ni(){let{user:e,profile:t,refreshUser:n,signOut:i}=r.Ft(),a=(0,Y.useNavigate)(),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),_=!o.un(e),v=_?e?.email||``:o.dn(e,t),y=(()=>{let t=(e?.providerData||[]).map(e=>e?.providerId).filter(Boolean);if(!t.length||t.includes(`password`))return``;let n=r.sn.find(e=>e.providerId&&e.providerId!==`password`&&t.includes(e.providerId));return n&&n.id!==`phone`?n.label:``})(),b=_&&!v;(0,W.useEffect)(()=>{if(!_||!e||b)return;let t=!1;return r.wn(e).then(e=>{!t&&e===`failed`&&f(`We could not send the link just now. Press Resend below to try again.`)}),()=>{t=!0}},[_,b,e?.uid]);let S=(0,W.useRef)(!1),C=async()=>{await r.li.currentUser?.getIdToken(!0),await n(),!S.current&&(S.current=!0,a(`/dashboard?${I.n}=1`))};(0,W.useEffect)(()=>{if(!_||b)return;let e=!1,t=!1,n=async()=>{let n=r.li.currentUser;if(!(e||t||S.current||document.hidden||!n)){t=!0;try{await n.reload(),!e&&n.emailVerified&&await C()}catch{}finally{t=!1}}},i=0,a=window.setInterval(()=>{i+=1;let e=Qr/1e3*i;if(e>ti){window.clearInterval(a);return}e>$r&&e%ei!==0||n()},Qr);return document.addEventListener(`visibilitychange`,n),window.addEventListener(`focus`,n),()=>{e=!0,window.clearInterval(a),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`focus`,n)}},[_,b]);let w=()=>a(I.h(t)?`/dashboard?${I.n}=1`:`/dashboard`,{replace:!0}),T=async()=>{c(!0),f(``);let e=!1;try{if(!r.li.currentUser)return;if(await r.li.currentUser.reload(),!_){await n();let e=o.dn(r.li.currentUser,t);f(e?`Not yet — open the link we sent to ${e}, and it is done. Nothing else is waiting on it.`:`Your email is confirmed.`);return}if(!r.li.currentUser.emailVerified){f(`Not yet — open the link in the email first, then press this. Check your spam folder if it has not arrived.`);return}await C(),e=!0}catch{f(`We could not check just now. Make sure you are online and try again.`)}finally{e||c(!1)}},E=async()=>{if(e&&!b){u(!0),f(``);try{_?(await(0,K.sendEmailVerification)(e),r.En(e.uid)):await Gr(v,e.uid),f(`Verification email sent! Please check your inbox.`)}catch(e){e?.code===`auth/too-many-requests`?f(`Failed to resend: please wait a minute before trying again.`):f(`Failed to resend. ${(await r.Kt(e,`password`,`Check your connection and try again in a moment.`)).text}`)}finally{u(!1)}}},D=d.includes(`Failed`)||d.includes(`could not`)||d.includes(`not verified`)||d.includes(`wrong`)||d.startsWith(`Not yet`);return(0,G.jsxs)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16`,children:[(0,G.jsxs)(Ln,{width:`max-w-[480px]`,className:`text-center`,children:[(0,G.jsx)(Bn,{as:`h1`,className:`mb-6 sm:mb-8`,title:b?`No address to verify`:`Verify your email`,line:b?(0,G.jsxs)(G.Fragment,{children:[y||`The way you signed in`,` did not give us an email address, so there is nothing here to send a link to and nothing to verify. An address is the one thing this app cannot do without: everything behind this screen is shut until it has one.`,y?(0,G.jsxs)(G.Fragment,{children:[` If this app is yours, it is one tick in your `,y,` setup — the setting that asks for the person's email address — and everybody who signs in after it arrives with one.`]}):(0,G.jsx)(G.Fragment,{children:` If this app is yours, the way in you used has to be set to ask for an email address.`}),` `,`Until then, sign in with an email address instead.`]}):_?(0,G.jsxs)(G.Fragment,{children:[y&&(0,G.jsxs)(G.Fragment,{children:[y,` signed you in, but it did not confirm your address — so we are checking it is yours. `]}),`We've sent a verification link to `,(0,G.jsx)(`span`,{className:`font-semibold text-foreground`,children:v}),`. Please check your inbox (and spam folder) to verify your account and access your dashboard.`]}):(0,G.jsxs)(G.Fragment,{children:[`We've sent a link to `,(0,G.jsx)(`span`,{className:`font-semibold text-foreground`,children:v}),`. Opening it adds the address to your sign-in, so you can use it to sign in as well as your phone — and you stay signed in here either way. Nothing is waiting on it: you can do this whenever you like.`]})}),(0,G.jsxs)(Rn,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[d&&(0,G.jsx)(x.t,{tone:D?`error`:`done`,children:d}),b?(0,G.jsx)(M.t,{variant:`primary`,onClick:()=>i(),className:`w-full py-3 text-[14px] font-semibold`,children:`Sign out`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(M.t,{variant:`primary`,onClick:T,isLoading:s,className:`w-full py-3 text-[14px] font-semibold`,children:`I've verified my email`}),(0,G.jsx)(M.t,{variant:`ghost`,onClick:E,isLoading:l,className:`w-full py-2.5 text-[14px] font-medium`,children:`Resend verification link`}),(0,G.jsx)(M.t,{variant:`ghost`,onClick:()=>_?m(!0):a(`/profile`),className:`w-full py-2 text-[13px] font-medium`,children:`Change my email address`}),!_&&(0,G.jsx)(M.t,{variant:`ghost`,onClick:w,className:`w-full py-2 text-[13px] font-medium`,children:`Skip for now`})]})]})]}),(0,G.jsx)(re.t,{isOpen:p,title:`Start again with another address?`,message:jr(v),confirmText:`Yes, start again`,cancelText:`Keep this address`,isProcessing:h,onCancel:()=>m(!1),onConfirm:async()=>{g(!0),await Nr(r.li.currentUser||e)}})]})}var ri={confirmed:{title:`Email confirmed`,body:`Your address is on your account now, and you can sign in with it as well as your phone.`},signInFirst:{title:`Nearly there`,body:`You opened this link in a browser you are not signed in on. Sign in and it finishes by itself — you will not need the link again.`},wrongAccount:{title:`That is a different account`,body:`This link adds an address to another account. Sign out here and sign back in as the person who asked for it — the link is kept, and it finishes by itself once they are in.`},takenElsewhere:{title:`That address is already in use`,body:`Another account here already has it. Give a different address on your profile, or sign in with the account that has this one.`},spent:{title:`That link has expired`,body:`Links can only be opened once, and they do not last for ever. Ask for a new one and it will come straight through.`},failed:{title:`That did not work`,body:`Check your connection and try again. If it keeps happening, ask for a new link.`}},ii=e=>({title:`Email verified`,body:`${e} is confirmed. You can sign in with it now as well as your phone.`,link:`/profile`});function ai(){let{user:e,loading:t,refreshUser:n,signOut:i}=r.Ft(),a=(0,Y.useNavigate)(),[o,s]=(0,W.useState)(null),c=(0,W.useRef)(null),l=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(t||l.current)return;let r=Kr()??Jr();if(!r){s(`spent`),l.current=!0;return}if(c.current=r,!e){qr(r),s(`signInFirst`);return}l.current=!0;let i=!1;return Zr(r).then(async e=>{i||(e===`confirmed`&&(Xr(),await ne.n(r.uid,ii(r.address)),await n().catch(()=>{})),e===`wrongAccount`?qr(r):e!==`signInFirst`&&Xr(),s(e))}),()=>{i=!0}},[t,e?.uid]);let u=o?ri[o]:null,d=o===`confirmed`;return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,G.jsx)(Ln,{width:`max-w-[480px]`,className:`text-center`,children:(0,G.jsx)(zn,{show:o??`working`,children:u?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Bn,{as:`h1`,className:`mb-6 sm:mb-8`,title:u.title,line:u.body}),(0,G.jsxs)(Rn,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[o===`signInFirst`?(0,G.jsx)(M.t,{variant:`primary`,onClick:()=>a(`/login?from=${encodeURIComponent(Hr)}`),className:`w-full py-3 text-[14px] font-semibold`,children:`Sign in to finish`}):o===`wrongAccount`?(0,G.jsx)(M.t,{variant:`primary`,onClick:()=>i(),className:`w-full py-3 text-[14px] font-semibold`,children:`Sign out`}):(0,G.jsx)(M.t,{variant:`primary`,onClick:()=>a(e?`/dashboard`:`/`),className:`w-full py-3 text-[14px] font-semibold`,children:d?`Carry on`:`Back to the app`}),o===`takenElsewhere`&&e&&(0,G.jsx)(M.t,{variant:`ghost`,onClick:()=>a(`/profile`),className:`w-full py-2.5 text-[14px] font-medium`,children:`Use a different address`}),o===`spent`&&e&&(0,G.jsx)(M.t,{variant:`ghost`,onClick:()=>a(`/verify`),className:`w-full py-2.5 text-[14px] font-medium`,children:`Send me a new link`}),o===`failed`&&(0,G.jsx)(M.t,{variant:`ghost`,onClick:()=>window.location.reload(),className:`w-full py-2.5 text-[14px] font-medium`,children:`Try again`})]})]}):(0,G.jsxs)(`div`,{"aria-busy":`true`,className:`py-6 flex flex-col items-center gap-4`,children:[(0,G.jsx)(N.t,{}),(0,G.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/70`,children:`Confirming your email…`})]})})})})}var oi=`user_phoneclaims`,si=`That number is already set up on another account. A phone number can only be used once here — use a different one, or take it off the other account first.`;async function ci(e){let t=String(e||``).replace(/[^\d+]/g,``);if(!t)return null;let n=globalThis.crypto?.subtle;if(!n)return null;try{let e=await n.digest(`SHA-256`,new TextEncoder().encode(t));return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}catch{return null}}async function li(e){let t=await ci(e);if(!t)return!0;try{return await(0,q.getDoc)((0,q.doc)(r.ui,oi,t)),!0}catch(e){return e?.code!==`permission-denied`}}var ui=`phoneClaim`;async function di(e,t){let n=await ci(e);if(!n||!t)return!0;try{await(0,q.setDoc)((0,q.doc)(r.ui,oi,n),{uid:t,createdAt:Date.now()})}catch(e){return e?.code!==`permission-denied`}try{await(0,q.setDoc)((0,q.doc)(r.ui,`user_profiles`,t),{[ui]:n},{merge:!0})}catch{}return!0}async function fi(e,t){let n=String(t??``).trim();if(n){try{await(0,q.deleteDoc)((0,q.doc)(r.ui,oi,n))}catch{}if(e)try{await(0,q.setDoc)((0,q.doc)(r.ui,`user_profiles`,e),{[ui]:``},{merge:!0})}catch{}}}var pi=r.si(()=>Promise.resolve().then(()=>require(`./PhoneInputField-WYdkNEym.cjs`)));function mi({onDone:e,doneWords:t=`Turn it on`}){let{user:n,refreshUser:i}=r.Ft(),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(``),[l,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(null),g=(0,W.useRef)(null),_=async(e,t)=>{h(await r.Kt(e,`sms2fa`,t))},v=async()=>{if(n){h(null),p(!0);try{if(d(``),!await li(a.trim())){h({text:si});return}c(await ur(n,a.trim(),g.current))}catch(e){await _(e,`That code could not be sent. Check the number and try again.`)}finally{p(!1)}}};return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{ref:g}),m&&(0,G.jsx)(Gn,{problem:m}),s?(0,G.jsxs)(r.nt.form,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2},onSubmit:async t=>{if(t.preventDefault(),!n)return;h(null),p(!0);let r=!Qn(n);try{if(await dr(n,s,l.trim()),!await di(a.trim(),n.uid)){r&&await fr(n).catch(()=>{}),await i(),h({text:si}),c(``),d(``);return}await i(),e()}catch(e){await _(e,`That code could not be checked. Ask for a new one.`)}finally{p(!1)}},className:`space-y-3`,children:[(0,G.jsxs)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:[`We texted a code to `,(0,G.jsx)(`span`,{className:`font-bold text-foreground/80`,children:a}),`.`]}),(0,G.jsx)(Kn,{value:l,onChange:d,autoFocus:!0}),(0,G.jsxs)(M.t,{type:`submit`,isLoading:f,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,children:[t,` `,(0,G.jsx)(r.At,{className:`ml-2 w-4 h-4 shrink-0`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-3 text-[13px] font-bold`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:v,disabled:f,className:`text-accent hover:underline disabled:opacity-40 disabled:no-underline cursor-pointer disabled:cursor-default`,children:`Send it again`}),(0,G.jsx)(`span`,{className:`w-[1px] h-3.5 bg-[var(--panel-border)]`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{c(``),d(``),h(null)},className:`text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:`Use a different number`})]})]}):(0,G.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),await v()},className:`space-y-3`,children:[(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,G.jsx)(pi,{field:{label:`Your phone number`,required:!0,placeholder:`7700 900123`},value:a,onChange:o})}),(0,G.jsxs)(M.t,{type:`submit`,isLoading:f,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,children:[`Text me a code `,(0,G.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]})]})]})}function hi(){let{user:e,signOut:t}=r.Ft(),n=r.Cn(),i=(0,Y.useNavigate)(),a=n.twoStepOptional;return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,G.jsxs)(Ln,{width:`max-w-[480px]`,children:[(0,G.jsx)(Bn,{title:a?`Make your account safer`:`One more step`,line:a?`Give us a number and we will text you a code when you sign in, as well as asking for your password. You can do this later if you would rather.`:`This app asks for a code by text as well as your password. Give us a number once, and from now on we will text you a code when you sign in.`}),(0,G.jsx)(Rn,{children:(0,G.jsx)(mi,{onDone:()=>i(`/dashboard`,{replace:!0}),doneWords:`Turn it on`})}),a&&(0,G.jsx)(Rn,{children:(0,G.jsx)(M.t,{variant:`secondary`,onClick:()=>{e?.uid&&rr(e.uid),i(`/dashboard`,{replace:!0})},className:`mt-3 w-full py-2.5 text-[14px] font-semibold`,children:`Not now`})}),(0,G.jsx)(Vn,{children:(0,G.jsx)(M.t,{variant:`ghost`,onClick:()=>t(),className:`w-full py-2 text-[13px] font-semibold`,children:`Sign out`})})]})})}var gi=r.si(()=>Promise.resolve().then(()=>require(`./PhoneInputField-WYdkNEym.cjs`))),_i=r.si(()=>Promise.resolve().then(()=>require(`./AddressField-CI8PP5ow.cjs`))),vi=`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`;function yi({field:e,value:t}){return(0,G.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,G.jsxs)(`label`,{className:`${vi} flex items-center gap-1.5`,children:[e.label,(0,G.jsx)(w.t,{className:`w-3 h-3 text-foreground/35 shrink-0`})]}),(0,G.jsx)(`div`,{"aria-label":e.label,"aria-readonly":`true`,className:`flex items-center h-12 w-full px-4 text-[15px] text-foreground/55 glass-panel opacity-70 cursor-not-allowed truncate`,style:{borderRadius:`var(--input-radius, 0.75rem)`},children:t}),(0,G.jsx)(`p`,{className:`text-[11px] text-foreground/40 mt-1.5 px-2 font-medium`,children:`Given when you registered, and fixed from then on.`})]})}function bi({fields:e,values:t,errors:n={},profile:i=null,disabled:a=!1,onChange:o,onCommit:s}){let c=(e,t)=>{for(let[n,r]of Object.entries(P.r(e,t)))o(n,r)},l=e=>!e.currentTarget.contains(e.relatedTarget),u=e=>s?.(e);return e.length?(0,G.jsx)(G.Fragment,{children:e.map(e=>{let s=t[e.key],d=n[e.key];return I.m(i,e)?(0,G.jsx)(yi,{field:e,value:I.a(i,e)},e.key):e.type===`tel`?(0,G.jsx)(`div`,{className:`w-full`,onBlur:t=>{l(t)&&u(e.key)},children:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,G.jsx)(gi,{field:e,value:String(s||``),onChange:t=>o(e.key,t)})})},e.key):e.type===`address`?(0,G.jsx)(`div`,{className:`w-full`,onBlur:t=>{l(t)&&u(e.key)},children:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,G.jsx)(_i,{id:`reg-${e.key}`,label:e.label,required:e.required,disabled:a,placeholder:e.placeholder,error:d,value:P.i(e.key,t),onChange:t=>c(e.key,t)})})},e.key):e.type===`textarea`?(0,G.jsx)(g.v,{id:`reg-${e.key}`,label:e.label,"aria-label":e.label,disabled:a,placeholder:e.placeholder,value:String(s||``),onChange:t=>o(e.key,t.target.value),onBlur:()=>u(e.key),error:d},e.key):e.type===`select`?(0,G.jsxs)(`div`,{className:`w-full`,children:[(0,G.jsx)(r.Z,{label:e.label,ariaLabel:e.label,direction:`auto`,disabled:a,value:String(s||``),options:[{value:``,label:(0,G.jsx)(`span`,{className:`text-foreground/40`,children:`Select an option...`})},...(e.options||[]).map(t=>({value:t,label:I.c(e,t)}))],onChange:t=>{o(e.key,t),u(e.key)}}),d&&(0,G.jsx)(`p`,{className:`text-xs text-red-500 font-medium mt-1`,children:d})]},e.key):e.type===`checkbox`?(0,G.jsxs)(`div`,{className:`w-full`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-3 w-full cursor-pointer group py-2`,children:[(0,G.jsxs)(`div`,{className:`relative flex items-center justify-center w-5 h-5 rounded border border-foreground/20 bg-background/50 group-hover:border-accent transition-colors shrink-0`,children:[(0,G.jsx)(`input`,{type:`checkbox`,"aria-label":e.label,disabled:a,checked:s===!0,onChange:t=>{o(e.key,t.target.checked),u(e.key)},className:`absolute opacity-0 w-full h-full cursor-pointer`}),s===!0&&(0,G.jsx)(`span`,{className:`w-2.5 h-2.5 bg-accent rounded-sm shrink-0`})]}),(0,G.jsx)(`span`,{className:`text-[14px] font-medium text-foreground/80 leading-snug group-hover:text-foreground transition-colors`,children:e.label})]}),d&&(0,G.jsx)(`p`,{className:`text-xs text-red-500 font-medium`,children:d})]},e.key):(0,G.jsx)(g.y,{label:e.label,"aria-label":e.label,type:e.type===`number`?`number`:e.type,disabled:a,placeholder:e.placeholder,error:d,className:`max-sm:h-11`,value:String(s??``),onChange:t=>o(e.key,t.target.value),onBlur:()=>u(e.key)},e.key)})}):null}var xi=e=>/^[^@\s]+@[^@\s.]+\.[^@\s]+$/.test(e.trim());function Si(){let{user:e,userRole:t,profile:n,signOut:i,refreshUser:a}=r.Ft(),s=r.Cn(),c=(0,Y.useNavigate)(),l=s.finishRegistration,d=o.wn(t)?[]:I.l(n,l),[f,p]=(0,W.useState)(()=>I.o(d,n)),[m,h]=(0,W.useState)({}),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(!1),[S,C]=(0,W.useState)(!1);(0,W.useEffect)(()=>{p(I.o(d,n))},[d.map(e=>e.key).join(`|`)]);let w=I._(n),T=w.includes(`name`),E=w.includes(`email`),[D,O]=(0,W.useState)(``),[k,A]=(0,W.useState)(``),[j,N]=(0,W.useState)(``),[ee,P]=(0,W.useState)(``),te=r.in(n),F=w.length+d.filter(e=>!I.p(n,e)).length,L=w.length+I.g(d,n).length>0?F===1?`There is one thing we still need before you go on.`:`There are a few things we still need before you go on.`:F===0?`Just check these over before you go on.`:F===1?`One question before you go on — it is not required.`:`A few questions before you go on — none of them is required.`,ne=(e=!1)=>c(e?`/verify`:I.h(n)?`/dashboard?${I.n}=1`:`/dashboard`,{replace:!0}),R=async t=>{if(t.preventDefault(),!e)return;v(``);let i=T&&!D.trim()?`Please tell us what to call you.`:``,o=E?k.trim()?xi(k)?``:`That does not look like an email address.`:`Please give us an email address.`:``;N(i),P(o);let s=I.i(d,f);if(h(s),i||o||Object.keys(s).length){v(`There is something to check below.`);return}b(!0);try{let t={};T&&(t.displayName=D.trim()),E&&(t.email=k.trim()),await(0,q.setDoc)((0,q.doc)(r.ui,`user_profiles`,e.uid),{...I.s(d,f,n),...t,...I.d()},{merge:!0}),T&&r.li.currentUser&&(0,K.updateProfile)(r.li.currentUser,{displayName:D.trim()}).then(()=>a()).catch(()=>{});let i=!1;E&&r.li.currentUser&&(i=await Gr(k.trim(),r.li.currentUser.uid).then(()=>!0).catch(e=>(console.warn(`The confirmation link could not be sent to the new address.`,e),!0))),ne(i)}catch(e){v(e?.code===`permission-denied`?`That could not be saved. Check that your email address is verified and that your account is still switched on.`:`That could not be saved. Check your connection and try again.`)}finally{b(!1)}},z=async()=>{e&&(C(!0),I.C(e.uid),await(0,q.setDoc)((0,q.doc)(r.ui,`user_profiles`,e.uid),I.d(),{merge:!0}).catch(()=>{}),ne())},re=y||S;return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,G.jsxs)(Ln,{width:`max-w-[500px]`,children:[(0,G.jsx)(Bn,{title:(0,G.jsx)(Ci,{request:te}),line:!s.loading&&(0,G.jsxs)(G.Fragment,{children:[L,te&&` Your registration goes to an admin for approval. Until then everything works as usual.`]})}),_&&(0,G.jsx)(x.t,{className:`mb-5`,children:_}),s.loading?(0,G.jsx)(Wn,{}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:R,noValidate:!0,children:[(T||E||d.length>0)&&(0,G.jsxs)(Rn,{className:`flex flex-col gap-5`,children:[T&&(0,G.jsx)(g.y,{name:`displayName`,label:`Your name`,type:`text`,placeholder:`Alex Taylor`,className:`max-sm:h-11`,value:D,onChange:e=>{O(e.target.value),j&&N(``)},error:j,autoFocus:!0,required:!0}),E&&(0,G.jsx)(g.y,{name:`email`,label:`Your email`,type:`email`,placeholder:`name@example.com`,className:`max-sm:h-11`,value:k,onChange:e=>{A(e.target.value),ee&&P(``)},error:ee,autoFocus:!T,required:!0}),(0,G.jsx)(bi,{fields:d,values:f,errors:m,profile:n,disabled:re,onChange:(e,t)=>{p(n=>({...n,[e]:t})),h(t=>t[e]?{...t,[e]:``}:t)}})]}),(0,G.jsx)(Rn,{className:`pt-1`,children:(0,G.jsxs)(M.t,{type:`submit`,isLoading:y,disabled:S,className:`w-full py-3 text-[15px] font-semibold`,children:[`Finish registration `,(0,G.jsx)(u.t,{className:`w-4 h-4 shrink-0`})]})})]}),l.skippable&&w.length===0&&(0,G.jsx)(Rn,{children:(0,G.jsx)(M.t,{variant:`secondary`,onClick:z,isLoading:S,disabled:y,className:`mt-3 w-full py-2.5 text-[14px] font-semibold`,children:`Skip for now`})})]}),(0,G.jsx)(Vn,{children:(0,G.jsx)(M.t,{variant:`ghost`,onClick:()=>i(),className:`w-full py-2 text-[13px] font-semibold`,children:`Sign out`})})]})})}function Ci({request:e}){return e?(0,G.jsx)(wi,{request:e}):(0,G.jsx)(G.Fragment,{children:I.u(null,``)})}function wi({request:e}){let t=L.l();return(0,G.jsx)(G.Fragment,{children:I.u(e,r.qr(e.role,t))})}var Ti=e=>({creatorName:e?.displayName||e?.email?.split(`@`)[0]||``,creatorAvatar:e?.photoURL||``}),Ei=e=>{let{creatorName:t,creatorAvatar:n}=Ti(e);return{editedUid:e?.uid||``,editedName:t,editedAvatar:n,editedAt:Date.now()}},Di=(e,t,n)=>{let r={},i=String(e.creatorEmail||``);return e.uid===t.uid&&!e.sourceId&&(!i||i===t.email||n.was&&e.creatorName===n.was)&&(n.name&&e.creatorName!==n.name&&(r.creatorName=n.name),n.avatar!==void 0&&(e.creatorAvatar||``)!==n.avatar&&(r.creatorAvatar=n.avatar)),e.editedUid===t.uid&&(n.name&&n.was&&e.editedName===n.was&&(r.editedName=n.name),n.avatar!==void 0&&t.name&&e.editedName===t.name&&(e.editedAvatar||``)!==n.avatar&&(r.editedAvatar=n.avatar)),Object.keys(r).length?r:null},Oi=(e,t)=>{if(e?.creatorName)return{name:e.creatorName,avatar:e.creatorAvatar||``};if(e?.uid&&t?.uid&&e.uid===t.uid){let e=Ti(t);return e.creatorName?{name:e.creatorName,avatar:e.creatorAvatar}:null}return null};function ki(){let{user:e,profile:t,refreshUser:n}=r.Ft(),i=r.Cn(),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(!1),p=i.on.sms2fa;if(i.loading||!or(e,p))return null;let m=Qn(e),h=$n(e);return(0,G.jsxs)(`div`,{className:`glass-panel w-full p-5 sm:p-8 rounded-3xl border border-[var(--panel-border)] shadow-2xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3 sm:gap-4`,children:[(0,G.jsx)(`div`,{className:`w-9 h-9 shrink-0 rounded-xl glass-panel border border-[var(--panel-border)] flex items-center justify-center`,children:(0,G.jsx)(D.t,{className:`w-[18px] h-[18px] text-accent`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`h3`,{className:`text-[16px] font-bold text-foreground mb-1`,children:`Two-step sign-in`}),(0,G.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium leading-relaxed`,children:m?`We text you a code when you sign in, as well as asking for your password.`:p?`This app asks for a code by text as well as your password. Add the number that should get it.`:`Add a phone number and we will text you a code when you sign in, as well as asking for your password.`})]})]}),(0,G.jsxs)(`div`,{className:`mt-5`,children:[l&&(0,G.jsx)(Gn,{problem:l}),d&&!l&&(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},className:`mb-4 p-3 rounded-xl border border-accent/20 bg-accent/10 text-accent flex items-center gap-2`,children:[(0,G.jsx)(r.At,{className:`w-4 h-4 shrink-0`}),(0,G.jsx)(`span`,{className:`text-[13.5px] font-semibold tracking-wide`,children:`Two-step sign-in is on. We will text that number next time you sign in.`})]}),m?(0,G.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-3 justify-between rounded-2xl border border-[var(--panel-border)]/60 p-3.5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-bold uppercase tracking-[0.2em] text-foreground/40 mb-1`,children:`Your number`}),(0,G.jsx)(`p`,{className:`text-[15px] font-bold text-foreground truncate`,children:h||`Set up`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`inline-flex items-center justify-center gap-1.5 h-9 px-3 rounded-xl border border-[var(--panel-border)] text-[13px] font-bold text-foreground/60 hover:text-red-500 hover:border-red-500/40 transition-colors cursor-pointer shrink-0`,children:[(0,G.jsx)(k.t,{className:`w-3.5 h-3.5 shrink-0`}),`Take it off`]})]}):(0,G.jsx)(mi,{onDone:()=>{f(!0),u(null)}})]}),(0,G.jsx)(re.t,{isOpen:a,title:`Take two-step sign-in off?`,message:p?`This app asks for a texted code, so you will be asked for a number again straight away. That is how you change the number you gave.`:`You will sign in with your password alone from then on.`,confirmText:`Take it off`,isProcessing:s,onConfirm:async()=>{if(e){u(null),c(!0);try{await fr(e),await fi(e.uid,t?.[ui]),await n(),f(!1),o(!1)}catch(e){u(await r.Kt(e,`sms2fa`,`That could not be taken off. Try again.`)),o(!1)}finally{c(!1)}}},onCancel:()=>o(!1)})]})}function Ai(){let{user:e,profile:t}=r.Ft(),n=I.l(t,r.Cn().finishRegistration),[i,a]=(0,W.useState)(()=>I.o(n,t)),[o,s]=(0,W.useState)({}),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),m=(0,W.useRef)(i),h=e=>{m.current=e,a(e)};if((0,W.useEffect)(()=>{h(I.o(n,t))},[n.map(e=>`${e.key}:${String(t?.[e.key]??``)}`).join(`|`)]),!n.length)return null;let g=e=>Object.entries(e).every(([e,n])=>(t?.[e]??``)===n);return(0,G.jsxs)(`div`,{className:`glass-panel w-full p-5 sm:p-8 rounded-3xl border border-[var(--panel-border)] shadow-2xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3 sm:gap-4`,children:[(0,G.jsx)(`div`,{className:`w-9 h-9 shrink-0 rounded-xl glass-panel border border-[var(--panel-border)] flex items-center justify-center`,children:(0,G.jsx)(b.n,{className:`w-[18px] h-[18px] text-accent`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-1`,children:[(0,G.jsx)(`h3`,{className:`text-[16px] font-bold text-foreground`,children:`Your details`}),(0,G.jsx)(r.p,{saving:u,savedAt:f})]}),(0,G.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium leading-relaxed`,children:`Change what you like — each one saves itself. Anything with a padlock was fixed when you gave it.`})]})]}),(0,G.jsxs)(`div`,{className:`mt-5 flex flex-col gap-4`,children:[c&&(0,G.jsx)(x.t,{children:c}),(0,G.jsx)(bi,{fields:n,values:i,errors:o,profile:t,onChange:(e,t)=>{h({...m.current,[e]:t}),s(t=>t[e]?{...t,[e]:``}:t)},onCommit:async i=>{let a=n.find(e=>e.key===i);if(!e||!a||I.m(t,a))return;let o=I.r(a,m.current[i]);if(s(e=>e[i]===o?e:{...e,[i]:o}),o)return;let c=I.s([a],m.current,t);if(!(!Object.keys(c).length||g(c))){l(``),d(!0);try{await(0,q.setDoc)((0,q.doc)(r.ui,`user_profiles`,e.uid),c,{merge:!0}),p(Date.now())}catch(e){l(e?.code===`permission-denied`?`That could not be saved. Check that your account is still switched on.`:`That could not be saved. Check your connection and try again.`)}finally{d(!1)}}}})]})]})}var ji=20,Mi=()=>{try{let e=localStorage.getItem(`fbos_nav_tabs`);if(!e)return null;let t=JSON.parse(e);return t&&typeof t==`object`?Object.entries(t):null}catch{return null}},Ni=async()=>(await(0,q.getDocs)((0,q.collection)(r.ui,`sys_tabs`))).docs.map(e=>[e.id,e.data()]);function Pi(){let{user:e,profile:t,refreshUser:a,isInternal:s}=r.Ft(),[c,l]=(0,W.useState)(e?.displayName||``),[u,d]=(0,W.useState)(e?.email||t?.email||``),[f,p]=(0,W.useState)(e?.photoURL||``),[m,h]=(0,W.useState)(``),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),[S,w]=(0,W.useState)(!1),[T,D]=(0,W.useState)(!1),[O,A]=(0,W.useState)(null),[j,M]=(0,W.useState)(``),[N,P]=(0,W.useState)(!1),[te,F]=(0,W.useState)(null),[I,L]=(0,W.useState)(``),ne=W.default.useRef(null),[R,z]=(0,W.useState)(!1),[re,ie]=(0,W.useState)(null),[B,V]=(0,W.useState)(``),[ae,oe]=(0,W.useState)(!1),[se,ce]=(0,W.useState)(null),[H,le]=(0,W.useState)(``);W.default.useEffect(()=>{l(e?.displayName||t?.displayName||``)},[e?.uid,e?.displayName,t?.displayName]),W.default.useEffect(()=>{d(e?.email||t?.email||``)},[e?.uid,e?.email,t?.email]),W.default.useEffect(()=>{p(e?.photoURL||``)},[e?.uid,e?.photoURL]);let U=async t=>{if(e)try{if(!s)return;let n=[`mem_files`,`admin_files`],i=Mi()??await Ni();for(let[e,t]of i){let r=(t.tabName||e).toLowerCase().replace(/[^a-z0-9]+/g,`_`),i=o.An(t.pageType),a=o.Pn(t)===`shared`;a&&i===`internal`&&n.push(`mem_${r}_records`),a&&i===`admin`&&n.push(`admin_${r}_records`)}n.length>ji&&(n.length=ji);let a={uid:e.uid,email:e.email,name:e.displayName};for(let i of n)try{let[n,o]=await Promise.all([(0,q.getDocs)((0,q.query)((0,q.collection)(r.ui,i),(0,q.where)(`uid`,`==`,e.uid))),(0,q.getDocs)((0,q.query)((0,q.collection)(r.ui,i),(0,q.where)(`editedUid`,`==`,e.uid)))]),s=new Map;for(let e of[...n.docs,...o.docs]){let n=s.has(e.id)?null:Di(e.data(),a,t);n&&s.set(e.id,{ref:e.ref,fields:n})}let c=[...s.values()];for(let e=0;e<c.length;e+=400){let t=(0,q.writeBatch)(r.ui);c.slice(e,e+400).forEach(e=>t.update(e.ref,e.fields)),await t.commit()}}catch{}}catch(e){console.error(`Error carrying the name or photo onto records:`,e)}},ue=async t=>{if(!e)return;let n=await ee._(t,{maxSide:512});if(n.size>2*1024*1024){M(`Over 2MB`);return}D(!0),w(!1),M(``);try{let t=`user_avatars/${e.uid}/file.png`,i=(0,J.ref)(r.fi,t);await(0,J.uploadBytes)(i,n,r.W(t,{ownerId:e.uid}));let o=await(0,J.getDownloadURL)(i);p(o);let s=(0,q.doc)(r.ui,`user_profiles`,e.uid);await Promise.all([(0,K.updateProfile)(e,{photoURL:o}),(0,q.updateDoc)(s,{avatar:o}),U({avatar:o})]),await a(),A(Date.now())}catch(e){console.error(e),M(`Not saved`)}finally{D(!1)}},Y=e=>{let t=e.target.files?.[0];t&&ue(t)},{over:de,dropProps:fe}=r.A({accept:`image/*`,disabled:T,onFiles:([e])=>ue(e),onReject:()=>M(`Not a picture`)}),pe=async()=>{if(e){D(!0),w(!1),M(``);try{let t=(0,J.ref)(r.fi,`user_avatars/${e.uid}/file.png`);p(``),D(!1);let n=(0,q.doc)(r.ui,`user_profiles`,e.uid);await Promise.all([(0,J.deleteObject)(t).catch(e=>console.error(e)),(0,K.updateProfile)(e,{photoURL:``}),(0,q.updateDoc)(n,{avatar:``}),U({avatar:``})]),await a(),A(Date.now())}catch(e){console.error(e),M(`Not removed`),D(!1)}}},me=()=>e?.displayName||t?.displayName||``,he=async()=>{if(!e)return;let t=c.trim();if(!t){l(me());return}if(t!==c&&l(t),t===me()||t===ne.current)return;ne.current=t;let n=me();P(!0),L(``);try{await(0,K.updateProfile)(e,{displayName:t}),await(0,q.updateDoc)((0,q.doc)(r.ui,`user_profiles`,e.uid),{displayName:t}).catch(()=>{}),await a(),F(Date.now()),U({name:t,was:n})}catch(e){console.error(e),ne.current=null,L(`Not saved`)}finally{P(!1)}},ge=u.trim(),_e=!!ge&&ge!==(e?.email||``),X=async()=>{if(!e||!_e||ae)return;let t=ge;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){ce({text:`That does not look like an email address yet.`,tone:`error`});return}oe(!0),ce(null);try{if(await(0,q.updateDoc)((0,q.doc)(r.ui,`user_profiles`,e.uid),{email:t}).catch(()=>{}),!e.email)await Gr(t,e.uid),ce({text:`We have emailed a link to ${t} — open it and the address is on your sign-in, so you can use it to sign in as well as your phone. You stay signed in here either way.`,tone:`done`});else{let n=await(0,K.fetchSignInMethodsForEmail)(r.li,t).catch(()=>[]);if(n&&n.length>0)throw Object.assign(Error(`email-already-in-use`),{code:`auth/email-already-in-use`});await(0,K.verifyBeforeUpdateEmail)(e,t),ce({text:`A link is on its way to your new address. Opening it moves your sign-in to it — and because that changes the account itself, you will be signed out here and will need to sign in again with the new address.`,tone:`done`})}le(t),await a()}catch(e){console.error(e),e?.code===`auth/requires-recent-login`?ce({text:`For your safety, sign out and sign back in, then change your address here.`,tone:`error`}):e?.code===`auth/email-already-in-use`?ce({text:`That email address already belongs to another account here. Use a different one, or sign in with the account that has it.`,tone:`error`}):ce({text:(await r.Kt(e,`password`,`The link could not be sent. Check your connection and try again.`,{email:t})).text,tone:`error`})}finally{oe(!1)}},ve=async()=>{if(!e||R||!m||!_||Dr(m))return;let t=Or(m,_);if(t){b(t);return}z(!0),V(``);try{await(0,K.updatePassword)(e,m),h(``),v(``),b(``),ie(Date.now())}catch(e){console.error(e),V(e?.code===`auth/requires-recent-login`?`For your safety, sign out and sign back in, then set your new password here. It has not been changed.`:(await r.Kt(e,`password`,`Your password could not be changed. Check your connection and try again.`)).text)}finally{z(!1)}},ye=e=>{e.currentTarget.contains(e.relatedTarget)||ve()},be=e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())};return(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-5 sm:mb-8`,children:[(0,G.jsx)(n.t,{children:`Profile Settings`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,G.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/profile`]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 flex-1 fbos-fade-in pb-20`,children:[(0,G.jsx)(`div`,{className:`flex justify-start`,children:(0,G.jsx)(i.t,{})}),(0,G.jsx)(`div`,{className:`w-full flex flex-col`,children:(0,G.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] fbos-tab-fill`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4 sm:gap-5 pb-6 border-b border-[var(--panel-border)]/50`,children:[(0,G.jsxs)(`div`,{...fe,className:`relative shrink-0 group/avatar rounded-full transition-shadow ${de?`ring-2 ring-accent ring-offset-2 ring-offset-background`:``}`,children:[(0,G.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:[T&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-10`,children:(0,G.jsx)(C.r,{className:`w-6 h-6 text-accent animate-spin`})}),f&&!S?(0,G.jsx)(r.O,{src:f,alt:`Avatar`,className:`w-full h-full`,onError:()=>w(!0)}):(0,G.jsx)(bt,{className:`w-7 h-7 sm:w-8 sm:h-8 text-accent`})]}),!T&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{title:f?`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,G.jsx)(Be,{className:`w-4 h-4 text-foreground`}),(0,G.jsx)(`input`,{type:`file`,accept:`image/*`,"aria-label":`Upload photo`,onChange:Y,className:`hidden`})]}),f&&(0,G.jsx)(`button`,{type:`button`,onClick:pe,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,G.jsx)(k.t,{className:`w-3 h-3`})})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`h3`,{className:`font-bold text-lg sm:text-xl text-foreground mb-1 truncate`,children:c||`User`}),(0,G.jsx)(`p`,{className:`text-[13px] text-foreground/40 mt-1 font-medium break-words`,children:e?.email})]}),(0,G.jsx)(r.p,{saving:T,savedAt:O,error:j})]}),(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`h3`,{className:`text-[16px] font-bold text-foreground`,children:`Account Details`}),(0,G.jsx)(r.p,{saving:N,savedAt:te,error:I})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,G.jsx)(g.y,{name:`name`,value:c,onChange:e=>l(e.target.value),onBlur:he,onKeyDown:be,label:`Display Name`,placeholder:`John Doe`}),(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(g.y,{name:`email`,type:`email`,value:u,onChange:e=>{d(e.target.value),se?.tone===`error`&&ce(null)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),X())},label:`Email Address`,placeholder:`name@example.com`}),(0,G.jsxs)(`div`,{className:`mt-1.5 px-2 flex items-center justify-between gap-3 min-h-8 sm:min-h-9`,children:[(0,G.jsx)(`p`,{className:`text-[11px] text-foreground/40 font-medium leading-snug`,children:_e?`Nothing changes until you open the link we email to it.`:`A new address is confirmed by a link we email to it.`}),_e&&(0,G.jsx)(r.o,{icon:E.t,onClick:()=>void X(),busy:ae,children:H===ge||!e?.email&&ge===t?.email?`Send again`:`Send link`})]}),se&&(0,G.jsx)(x.t,{tone:se.tone,className:`mt-2`,children:se.text})]})]})]}),(0,G.jsxs)(`div`,{className:`pt-6 border-t border-[var(--panel-border)]/50`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-4`,children:[(0,G.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground`,children:`Change Password`}),(0,G.jsx)(r.p,{saving:R,savedAt:re,error:B?`Not changed`:``})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,onBlur:ye,children:[(0,G.jsx)(g.y,{name:`password`,type:`password`,label:`New Password`,autoComplete:`new-password`,value:m,onChange:e=>{h(e.target.value),y&&e.target.value===_&&b(``),B&&V(``)},onKeyDown:be,placeholder:`At least 8 characters`}),(0,G.jsx)(g.y,{name:`confirmPassword`,type:`password`,label:`Confirm New Password`,autoComplete:`new-password`,value:_,onChange:e=>{v(e.target.value),y&&b(``),B&&V(``)},onBlur:()=>b(_?Or(m,_):``),onKeyDown:be,error:y,placeholder:`Type it a second time`})]}),m&&(0,G.jsx)(kr,{value:m,className:`mt-3`}),B&&(0,G.jsx)(x.t,{className:`mt-3`,children:B})]})]})}),(0,G.jsx)(ki,{}),(0,G.jsx)(Ai,{})]})]})}function Fi(){let[e,t]=(0,W.useState)(!1),[n,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(0),[s,c]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let e;return a>0&&(e=setInterval(()=>o(e=>e-1),1e3)),()=>clearInterval(e)},[a]),(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16 mt-6 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,G.jsxs)(Ln,{width:`max-w-[480px]`,className:`text-center`,children:[(0,G.jsx)(Bn,{title:`Reset Password`,line:`Enter your email to receive a recovery link.`}),n&&(0,G.jsx)(x.t,{tone:`done`,className:`mb-5 max-w-[360px] mx-auto`,children:n}),(0,G.jsx)(Rn,{children:(0,G.jsxs)(`form`,{className:`flex flex-col gap-5 text-left max-w-[360px] mx-auto`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let n=new FormData(e.currentTarget).get(`email`);try{await(0,K.sendPasswordResetEmail)(r.li,n)}catch(e){console.error(e)}finally{i(`If an account exists, a reset link has been sent. Check your inbox and spam folder.`);let e=s+1;c(e),o(e===1?60:120),t(!1)}},children:[(0,G.jsx)(g.y,{name:`email`,label:`Work Email`,type:`email`,placeholder:`name@company.com`,required:!0}),(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(M.t,{type:`submit`,className:`w-full py-3 text-[14px] font-semibold ${a>0?`opacity-60 shadow-none cursor-not-allowed pointer-events-none`:``}`,isLoading:e,disabled:a>0,children:a>0?`Resend link in ${(e=>`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`)(a)}`:s>0?`Resend reset password link`:`Send Reset Link`})})]})}),(0,G.jsx)(Vn,{children:(0,G.jsxs)(Y.Link,{to:`/login`,className:`inline-flex items-center gap-2 text-[14px] text-foreground/60 font-medium hover:text-accent transition-colors`,children:[(0,G.jsx)(l.t,{className:`w-4 h-4`}),`Back to Sign In`]})})]})})}var Ii=new Set,Li=new Set;function Ri(){let{pathname:e,search:t}=(0,Y.useLocation)();return(0,W.useEffect)(()=>{if(e===`/payment-complete`)return;let n=new URLSearchParams(t),i=e.startsWith(`/book/`);n.get(`booking_back`)===`1`&&!i&&g.s().then(e=>{!e||Li.has(e.pending.sessionId)||(Li.add(e.pending.sessionId),O.n(e.outcome===`letGo`?`${g.i.letGo} Pick a time again whenever you are ready.`:g.i[e.outcome],{for:7e3}))}).catch(()=>{});let a=n.get(`session_id`)||``;!a.startsWith(`cs_`)||Ii.has(a)||(Ii.add(a),r.An(a).then(async e=>{let{booked:t,held:n}=await g.o(a,e);if(!t||i)return;let r=e.receipt&&e.customerEmail?` A receipt is on its way to ${e.customerEmail}.`:``;O.n(e.paid?n?`Paid — ${t.when} is held for you while it is confirmed.${r}`:`${g.a}${r}`:`Thank you — ${t.when} is held for you while your payment clears.`,{for:9e3})}).catch(()=>{}))},[e,t]),null}var zi=`public_copies`,Bi=e=>Array.isArray(e)?e.map(e=>String(e??``)).filter(Boolean).sort():[];function Vi(e){let t=e&&typeof e.copies==`object`&&e.copies?e.copies:null;if(!t)return{};let n={};for(let[e,r]of Object.entries(t))/^[a-z][a-z0-9_]*$/.test(e)&&(n[e]={leaveOut:Bi(r?.leaveOut)});return n}function Hi(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t[r];e&&e.leaveOut.join(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-CiTBaPhY.cjs`),t=require(`./forms-CmNeTETW.cjs`),n=require(`./PageTitle-BL50s4qY.cjs`),r=require(`./TimeZoneField-Ckn1pKAL.cjs`),i=require(`./DashboardNav-Bc619nqn.cjs`),a=require(`./Trouble-KQZyf6aY.cjs`),o=require(`./schedule-BAea6q8_.cjs`),s=require(`./chevron-down-lyDK1rfL.cjs`),c=require(`./TemplateDrive-ElNPzwv3.cjs`),l=require(`./arrow-left-C39sNUA7.cjs`),u=require(`./arrow-right-CGvbxks5.cjs`),d=require(`./mail-check-D_LNQw3l.cjs`),f=require(`./scheduleData-BXjNXVHY.cjs`),p=require(`./calendar-clock-D59cGNoL.cjs`),m=require(`./BookingCalendar-BcvJiyaq.cjs`),h=require(`./EventCard-D57elnQo.cjs`),g=require(`./ContactPopup-D8aSSlmS.cjs`),_=require(`./chevron-left-DHTPst5Z.cjs`),v=require(`./SupportBar-DR52UpBq.cjs`),y=require(`./FileViewerPopup-CkLUYCNo.cjs`),b=require(`./VideoPlayer-CggwpVXH.cjs`),x=require(`./ProviderMark-BCQRu5Gs.cjs`),S=require(`./FormNote-DP0GK9ya.cjs`),C=require(`./arrivalRoads-1OeHArA0.cjs`),w=require(`./x-Ci8c5p6T.cjs`),T=require(`./lock-xMnTQLRt.cjs`),E=require(`./plus-zsWFCu4F.cjs`),D=require(`./send-CWJXtO05.cjs`),O=require(`./shield-check-Bsd5oaif.cjs`),k=require(`./Said-W3KFi5uX.cjs`),A=require(`./trash-D-CpYHCs.cjs`);require(`./user-round-DUV_u2Tg.cjs`);const j=require(`./contentFallback-DVCrIUvK.cjs`),M=require(`./Popup-COnHpbrY.cjs`),N=require(`./Button-Ccy4wFZ1.cjs`),P=require(`./Loader-QHqQsXLr.cjs`),ee=require(`./mediaKind-ButDya5f.cjs`);require(`./bookingHold-DhS-tuuC.cjs`);const F=require(`./address-D88ICQCR.cjs`),te=require(`./formPage-DoDEEg1-.cjs`),I=require(`./email-Sya6gl4F.cjs`),L=require(`./registrationFields-DHHTptcl.cjs`),ne=require(`./roles-BmnoAilb.cjs`),R=require(`./notices-CKm9-Pqt.cjs`),z=require(`./transactions-CIU2NcKh.cjs`),re=require(`./tabAudience-2fJAN1aD.cjs`),ie=require(`./ConfirmModal-BUNtss4a.cjs`),B=require(`./recordsKey-B3lWGd8C.cjs`),V=require(`./bookingPages-Dx1ViiwW.cjs`),ae=require(`./pageFiles-Cn0YQ4Ur.cjs`),oe=require(`./recordLock-CiulizO1.cjs`),H=require(`./AccessNotice-BClqr7A9.cjs`),se=require(`./Setup-DiFnnzdd.cjs`),U=require(`./paidInFull-CZywIs-V.cjs`),ce=require(`./ManagePlanButton-Buwfs2bU.cjs`),W=require(`./recordPrice-Cy7Km-eX.cjs`),le=require(`./people-BwWVVLfy.cjs`),G=require(`./PhoneInputField-BxGBvuPB.cjs`);let K=require(`react`);K=e.a(K,1);let q=require(`react/jsx-runtime`),ue=require(`firebase/auth`),J=require(`firebase/firestore`),de=require(`firebase/storage`),Y=require(`react-router-dom`),fe=require(`react-dom`);var pe=Object.assign({"./contactForm.config.ts":t.o,"./supportForm.config.ts":t.i}),me={};for(let e in pe){let t=pe[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};me[r]=i,i.systemName&&(me[i.systemName]=i,me[i.systemName.toLowerCase()]=i)}if(typeof window<`u`){let e=window.__FBOS_FORMS__||{};window.__FBOS_FORMS__={...me,...e}}var he=Object.assign({}),ge={};for(let e in he){let t=he[e];if(!t)continue;let n=null;for(let e in t)if(e.endsWith(`Config`)){n=t[e];break}if(!n&&t?.default&&(n=t.default),!n)continue;let r=e.replace(`./`,``).replace(`.config.ts`,``).replace(/Registration$/,``).toLowerCase();ge[r]=n}if(typeof window<`u`){let e=window.__FBOS_REGISTRATION__||{};window.__FBOS_REGISTRATION__={...ge,...e}}var _e=Object.assign({}),X=Object.assign({}),ve={};for(let e in _e){let t=_e[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};ve[r]=i,i.config.pageId&&(ve[i.config.pageId]=i,ve[i.config.pageId.toLowerCase()]=i)}for(let e in X){let t=X[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};ve[r]=i,i.config.pageId&&(ve[i.config.pageId]=i,ve[i.config.pageId.toLowerCase()]=i)}if(typeof window<`u`){let e=window.__FBOS_PAGES__||{};window.__FBOS_PAGES__={...ve,...e}}var ye=`.fbos-content-slot, .fbos-home-slot`,be=`[data-picture]`,xe=`[data-fbos-own]`,Z=/url\(\s*['"]?\s*(?:https?:|data:image|\/|[\w./-]+\.(?:png|jpe?g|webp|avif|gif|svg))/i,Q={img:`This page draws a picture with a plain <img>, so it holds no space while it loads, arrives in pieces down the screen, and downloads the full-size photograph however small the box is.`,background:`This page draws a picture as a background, so it holds no space while it loads, says nothing to somebody who cannot see it, and downloads the full-size photograph however small the box is.`},Se=`Paste this to your assistant: "Every picture on this page must use <Picture src={…} alt="…" className="…" /> imported from the app, not a plain <img> or a background image."`,Ce=e=>`${Q[e]} ${Se}`,we=e=>!!e.closest(ye)&&!e.closest(`${be}, ${xe}`);function Te(e){let t=new Set;for(let n of e.querySelectorAll(`img`))if(we(n)){t.add(`img`);break}for(let n of e.querySelectorAll(`[style*="background"]`)){let e=n.getAttribute(`style`)||``;if(Z.test(e)&&we(n)){t.add(`background`);break}}return t}function Ee(e,t,n=()=>``){if(typeof MutationObserver>`u`)return()=>{};let r=new Set,i=0,a=()=>{let i=n();for(let n of Te(e)){let e=`${i}#${n}`;r.has(e)||(r.add(e),t(n,Ce(n)))}},o=e=>e.some(e=>e.type===`childList`||e.attributeName===`src`||(e.target.getAttribute?.(`style`)||``).includes(`url(`)),s=()=>{i||=requestAnimationFrame(()=>{i=0,a()})};a();let c=new MutationObserver(e=>{o(e)&&s()});return c.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`src`]}),()=>{c.disconnect(),i&&cancelAnimationFrame(i)}}var De=()=>{document.querySelectorAll(`.fbos-content-slot style, .fbos-home-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.`))})},Oe=e=>{for(let t=e;t;t=t.parentElement){if(t.classList.contains(`fbos-content-slot`)||t.classList.contains(`fbos-home-slot`))return!1;if(getComputedStyle(t).position===`fixed`)return!0}return!1},ke=()=>{if(typeof window>`u`)return;let e=window.innerHeight*.6;document.querySelectorAll(`.fbos-content-slot *, .fbos-home-slot *`).forEach(t=>{if(!t.clientHeight||t.clientHeight<e||t.scrollHeight<=t.clientHeight+2)return;let n=getComputedStyle(t);n.overflowY!==`visible`&&(n.webkitLineClamp&&n.webkitLineClamp!==`none`||Oe(t)||(t.style.setProperty(`max-height`,`none`,`important`),t.style.setProperty(`height`,`auto`,`important`),t.scrollHeight>t.clientHeight+2&&t.style.setProperty(`overflow-y`,`visible`,`important`),typeof console<`u`&&console.warn(`FirebaseOS: a box in a content file was as tall as the screen and hid the rest of the page, which left the bottom unreachable on a phone — it was allowed to grow. Let the page be as long as it needs: no h-screen, max-h-screen or overflow-hidden around the whole page.`)))})},Ae=`.fbos-content-slot, .fbos-home-slot`,je=()=>!!document.querySelector(Ae),Me=e=>{let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return t?!!t.closest?.(Ae)||!!t.matches?.(Ae)||!!t.querySelector?.(Ae):!1},Ne=e=>e.some(e=>Me(e.target)||Array.from(e.addedNodes).some(Me)),Pe=()=>{(0,K.useEffect)(()=>{if(typeof document>`u`||typeof MutationObserver>`u`)return;let e=()=>{je()&&(De(),ke())},t=null,n=()=>{if(t!==null)return;let n=()=>{t=null,e()};t=typeof requestAnimationFrame==`function`?requestAnimationFrame(n):setTimeout(n,0)},r=()=>{t!==null&&(typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(t),clearTimeout(t),t=null)},i=n;e();let a=new MutationObserver(e=>{Ne(e)&&n()});return a.observe(document.body,{childList:!0,subtree:!0}),window.addEventListener(`resize`,i),window.addEventListener(`orientationchange`,i),()=>{r(),a.disconnect(),window.removeEventListener(`resize`,i),window.removeEventListener(`orientationchange`,i)}},[])},Fe=`fbos_hand_drawn_pictures`,Ie=e=>{try{return(sessionStorage.getItem(Fe)||``).split(`|`).includes(e)}catch{return!1}},Le=e=>{try{let t=(sessionStorage.getItem(Fe)||``).split(`|`).filter(Boolean);sessionStorage.setItem(Fe,[...new Set([...t,e])].join(`|`))}catch{}},Re=e=>{(0,K.useEffect)(()=>{if(!e||typeof document>`u`)return;let t=()=>typeof location>`u`?``:location.pathname;return Ee(document.body,(e,n)=>{let i=`${t()}#${e}`;Ie(i)||(Le(i),a.s(r.ti(n)))},t)},[e])};function ze(){let{isAdmin:e}=r.Ft();return Re(!!e),null}var Be={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};Be.node;var Ve=s.n(Be),He={name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]};He.node;var Ue=s.n(He),We={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};We.node;var Ge=s.n(We),Ke={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Ke.node;var qe=s.n(Ke),Je={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};Je.node;var Ye=s.n(Je),Xe={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};Xe.node;var Ze=s.n(Xe),Qe={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Qe.node;var $e=s.n(Qe),et={name:`file-exclamation-point`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`file-warning`]};et.node;var tt=s.n(et),nt={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};nt.node;var rt=s.n(nt),it={name:`layout-list`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}],[`path`,{d:`M14 4h7`,key:`3xa0d5`}],[`path`,{d:`M14 9h7`,key:`1icrd9`}],[`path`,{d:`M14 15h7`,key:`1mj8o2`}],[`path`,{d:`M14 20h7`,key:`11slyb`}]]};it.node;var at=s.n(it),ot={name:`mail-warning`,size:24,node:[[`path`,{d:`M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5`,key:`e61zoh`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`M20 14v4`,key:`1hm744`}],[`path`,{d:`M20 22v.01`,key:`12bgn6`}]]};ot.node;var st=s.n(ot),ct={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};ct.node;var lt=s.n(ct),ut={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};ut.node;var dt=s.n(ut),ft={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};ft.node;var pt=s.n(ft),mt={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};mt.node;var ht=s.n(mt),gt={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};gt.node;var _t=s.n(gt),vt={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};vt.node;var yt=s.n(vt),bt={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};bt.node;var xt=s.n(bt),St={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};St.node;var Ct=s.n(St),wt=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAATRlWElmTU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAABqAAAAcgE7AAIAAAAJAAAA3IdpAAQAAAABAAAA5gAAAAAAAABgAAAAAQAAAGAAAAABQ2FudmEgZG9jPURBRzBuT2dSOVZFIHVzZXI9VUFHTW5pX05rRHcgYnJhbmQ9QkFHTW50Vy1oYkEgdGVtcGxhdGU9VGVhbCBNb2Rlcm4gR2FtaW5nIFlvdVR1YmUgQ2hhbm5lbCBMb2dvAEFudG9uaW5hAAAABpAAAAcAAAAEMDIxMJEBAAcAAAAEAQIDAKAAAAcAAAAEMDEwMKABAAMAAAABAAEAAKACAAQAAAABAAAAgKADAAQAAAABAAAAgAAAAAB8OpdMAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGZmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIj4KICAgICAgICAgPGV4aWY6Q29sb3JTcGFjZT42NTUzNTwvZXhpZjpDb2xvclNwYWNlPgogICAgICAgICA8ZXhpZjpQaXhlbFhEaW1lbnNpb24+ODAwPC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6RXhpZlZlcnNpb24+MDIxMDwvZXhpZjpFeGlmVmVyc2lvbj4KICAgICAgICAgPGV4aWY6Rmxhc2hQaXhWZXJzaW9uPjAxMDA8L2V4aWY6Rmxhc2hQaXhWZXJzaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+ODAwPC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6Q29tcG9uZW50c0NvbmZpZ3VyYXRpb24+CiAgICAgICAgICAgIDxyZGY6U2VxPgogICAgICAgICAgICAgICA8cmRmOmxpPjE8L3JkZjpsaT4KICAgICAgICAgICAgICAgPHJkZjpsaT4yPC9yZGY6bGk+CiAgICAgICAgICAgICAgIDxyZGY6bGk+MzwvcmRmOmxpPgogICAgICAgICAgICAgICA8cmRmOmxpPjA8L3JkZjpsaT4KICAgICAgICAgICAgPC9yZGY6U2VxPgogICAgICAgICA8L2V4aWY6Q29tcG9uZW50c0NvbmZpZ3VyYXRpb24+CiAgICAgICAgIDx4bXA6Q3JlYXRvclRvb2w+Q2FudmEgZG9jPURBRzBuT2dSOVZFIHVzZXI9VUFHTW5pX05rRHcgYnJhbmQ9QkFHTW50Vy1oYkEgdGVtcGxhdGU9VGVhbCBNb2Rlcm4gR2FtaW5nIFlvdVR1YmUgQ2hhbm5lbCBMb2dvPC94bXA6Q3JlYXRvclRvb2w+CiAgICAgICAgIDx0aWZmOlJlc29sdXRpb25Vbml0PjI8L3RpZmY6UmVzb2x1dGlvblVuaXQ+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgICAgIDx0aWZmOlhSZXNvbHV0aW9uPjk2PC90aWZmOlhSZXNvbHV0aW9uPgogICAgICAgICA8dGlmZjpZUmVzb2x1dGlvbj45NjwvdGlmZjpZUmVzb2x1dGlvbj4KICAgICAgICAgPGRjOnRpdGxlPgogICAgICAgICAgICA8cmRmOkFsdD4KICAgICAgICAgICAgICAgPHJkZjpsaSB4bWw6bGFuZz0ieC1kZWZhdWx0Ij5Mb2dvcyBmb3IgWWFpVyAtIDE8L3Jk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`,Tt=`mem_notifications`,Et=`case_notifications`,Dt=e=>e===`admin`||e===`internal`,Ot=new Map;async function kt(e){let t=Ot.get(e);if(typeof t==`boolean`)return t;try{let t=await(0,J.getDoc)((0,J.doc)(r.ui,`user_profiles`,e)),n=o.Sn(String(t.data()?.role||``));return Ot.set(e,n),n}catch{return!0}}async function At(e,t){return await kt(e)?t===e||kt(t):!1}var jt=[`email`,`Email`,`emailAddress`,`email_address`,`userEmail`,`contactEmail`,`submitterEmail`],Mt=e=>{for(let t of jt){let n=e[t];if(typeof n==`string`&&n.includes(`@`))return n.trim()}return``};async function Nt(e){let{toUid:t,toRole:n,title:i,body:a,link:o,email:s,about:c}=e||{},l=c&&typeof c==`object`?Mt(c):``,u=!t&&!n&&!!l;if(!i||!t&&!n&&!u){console.warn(`notify(): needs a title and either toUid (one person) or toRole (an audience).`,e);return}let d=r.li.currentUser;if(!d){console.warn(`notify(): nobody is signed in, so there is no one to send as.`);return}let f=s===!0||u?I.n({toUid:String(t||``),toRole:String(n||``),title:i,body:a||``,link:o||``,...l?{about:{email:l}}:{}}):null;await Promise.all([u?null:Pt(e,d),f])}async function Pt(e,t){let{toUid:n,toRole:i,title:a,body:o,link:s}=e,l=String(i||``),u=[];if(n){if(u=await At(t.uid,String(n))?[]:[c.E(String(n))],u[0]===`uid:`){console.warn(`notify(): toUid is the recipient’s uid — that one is empty, so the notification would reach nobody.`,e);return}}else if(!Dt(l)){let t=c.D(l);if(t===`role:`){console.warn(`notify(): '${l}' is not an audience — pass 'admin', 'internal', or the role as you named it on the Users screen.`,e);return}u=[t]}let d={title:a,body:o||``,link:s||``,uid:t.uid,fromName:t.displayName||t.email||``};if(u.length){try{await(0,J.addDoc)((0,J.collection)(r.ui,Et),{access:u,editors:u,...d,createdAt:Date.now()})}catch(e){console.warn(`notify(): the notification was not saved. Sending to a role — or to somebody who is not on your team — is kept in case_notifications, which needs the security rules re-pasted from the Setup screen. A sender who is signed out, unverified or deactivated is refused whatever the rules say.`,e)}return}try{await(0,J.addDoc)((0,J.collection)(r.ui,Tt),{...n?{toUid:n}:{toRole:i},...d,createdAt:(0,J.serverTimestamp)()})}catch(e){console.warn(`notify(): the notification was not saved. If the sender is not on your team, re-paste your Firestore rules from /setup — sending from outside the team needs the mem_notifications line added in 1.14.21. A sender who is signed out, unverified or deactivated is refused whatever the rules say.`,e)}}var Ft=e=>{let t=String(e??``).trim();return t.startsWith(`/`)?(t.split(/[?#]/)[0].replace(/\/+$/,``)||`/`).toLowerCase():``},It=(e,t)=>Ft(t?.route?String(t.route).startsWith(`/`)?t.route:`/`+t.route:`/`+e);function Lt(e,{picks:t,records:r,files:a=i.x()}){let o=Ft(e);if(!o||o===`/`)return null;for(let[e,r]of Object.entries(i.n)){let i=Ft(r.path);if(o===i||o.startsWith(i+`/`))return n.p(t[e])??r.icon??null}let s={};for(let[e,t]of a)t?.isPublic||(s[e]={...t?.config||{},...r[e]||{}});for(let[e,t]of Object.entries(r)){let n=String(t?.fileId||``);n&&n!==e&&!r[n]?(s[e]={...s[n]||{},...t},delete s[n]):s[e]||(s[e]=t)}for(let[e,t]of Object.entries(s))if(It(e,t)===o)return n.p(t?.iconName)??n.g;return null}var Rt=()=>{try{let e=localStorage.getItem(`fbos_nav_tabs`),t=e?JSON.parse(e):null;return t&&typeof t==`object`?t:{}}catch{return{}}};function zt(){let e=i.u(),[t,n]=(0,K.useState)(Rt);return(0,K.useEffect)(()=>r.Zr(`sys_tabs`,()=>(0,J.collection)(r.ui,`sys_tabs`),e=>{let t={};for(let n of e.docs||[])t[n.id]=n.data();n(t)},()=>{}),[]),n=>Lt(n,{picks:e,records:t})}function Bt(e){return{id:`c_${e.id}`,type:`message`,title:String(e.title||`Notification`),subtitle:String(e.body||e.fromName||``),time:e.createdAt,link:typeof e.link==`string`&&e.link.startsWith(`/`)?e.link:void 0}}function Vt(e){return{id:`p_${e.id}`,type:`payment`,title:`New payment`,subtitle:r.Hn(e),time:e.at,link:`/transactions?open=${encodeURIComponent(e.id)}`}}function Ht(e){return{id:`p_${e.id}`,type:`payment`,title:`Order placed`,subtitle:r.Hn(e,!1),time:e.at,link:`/billing?open=${encodeURIComponent(e.id)}`}}var Ut={user:xt,booking:p.t,submission:n.h,request:qe,verify:st,role:ht,finish:x.n,message:d.n,payment:i.D};function Wt({n:e}){let t=zt();return(0,K.createElement)(!e.standing&&t(e.link)||Ut[e.type]||qe,{className:`w-4 h-4`})}function Gt(){let[e,t]=(0,K.useState)(!1),[n,i]=(0,K.useState)([]),a=(0,K.useRef)(null),s=(0,K.useRef)(null),[l,u]=(0,K.useState)(null),f=(0,Y.useNavigate)(),{user:p,userRole:m,roleConfirmed:h,profile:g,requestedRole:_}=r.Ft(),v=m===`admin`,y=r.Cn();ne.l();let b=o.dn(p,g),x=o.Sn(m),S=c.F(Et,{mine:!0,max:8}),C=r.zn(),w=r.Un(`sales`,p?.uid,v&&h&&C.configured),T=r.Un(`mine`,p?.uid,C.configured);(0,K.useEffect)(()=>{function e(e){a.current&&!a.current.contains(e.target)&&t(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let E=(0,K.useRef)({users:[],submissions:[],requests:[],direct:[],rolewide:[],bookings:[],booked:[],bookedByEmail:[],notices:[],sentToMe:[],sales:[],orders:[]}),D=(0,K.useRef)(!1);(0,K.useEffect)(()=>{D.current=!1},[p?.uid]);let O=(e,t)=>{E.current[e]=t;let n=E.current,r=new Set,a=[...n.users,...n.submissions,...n.requests,...n.direct,...n.rolewide,...n.bookings,...n.booked,...n.bookedByEmail,...n.notices,...n.sentToMe,...n.sales,...n.orders].filter(e=>r.has(e.id)?!1:(r.add(e.id),!0));a.sort((e,t)=>{let n=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return((t.time?.toDate?t.time.toDate().getTime():new Date(t.time).getTime())||0)-(n||0)}),i(a.slice(0,8))},k=(e,t)=>{D.current||(D.current=!0,console.warn(`AdminNotifications: this account could not read one of the notification feeds, so that part of the bell is empty. Most of them are the team's alone, and every one of them asks for a verified address.`,t)),O(e,[])};(0,K.useEffect)(()=>{let e=[];if(!h)return;if(v){let t=(0,J.query)((0,J.collection)(r.ui,`user_profiles`),(0,J.orderBy)(`createdAt`,`desc`),(0,J.limit)(5));e.push((0,J.onSnapshot)(t,e=>{O(`users`,e.docs.map(e=>{let t=e.data();return{id:`u_${e.id}`,type:`user`,title:`New user registered`,subtitle:t.email||t.phone||`Unknown`,time:t.createdAt,link:`/users/${e.id}`}}))},e=>k(`users`,e)));let n=(0,J.query)((0,J.collection)(r.ui,`user_submissions`),(0,J.orderBy)(`submittedAt`,`desc`),(0,J.limit)(5));e.push((0,J.onSnapshot)(n,e=>{O(`submissions`,e.docs.filter(e=>e.data()?.formId!==`booking`&&!o.nt(e.data()||{})&&!z.a(e.data()||{})).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,link:`/inbox?open=${encodeURIComponent(`anyone:${e.id}`)}`}}))},e=>k(`submissions`,e)));let i=(0,J.query)((0,J.collection)(r.ui,`user_requests`),(0,J.orderBy)(`submittedAt`,`desc`),(0,J.limit)(5));e.push((0,J.onSnapshot)(i,e=>{O(`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,link:`/inbox?open=${encodeURIComponent(`signedIn:${e.id}`)}`}}))},e=>k(`requests`,e)))}else O(`users`,[]),O(`submissions`,[]),O(`requests`,[]);let t=new Map;if(e.push(()=>{t.forEach(e=>e()),t.clear(),clearTimeout(void 0)}),O(`bookings`,[]),O(`booked`,[]),O(`bookedByEmail`,[]),p?.uid){let t=(0,J.query)((0,J.collection)(r.ui,R.t),(0,J.where)(`uid`,`==`,p.uid)),n=e=>{let t=e.data()||{};return{id:`n_${e.id}`,type:`message`,title:String(t.title||`Notification`),subtitle:String(t.body||``),time:t.createdAt,link:typeof t.link==`string`&&t.link.startsWith(`/`)?t.link:void 0}};e.push((0,J.onSnapshot)(t,e=>{O(`notices`,e.docs.filter(e=>(e.data()||{}).kind===`notice`).map(n))},e=>k(`notices`,e)))}else O(`notices`,[]);if(p?.uid&&(v||x)){let t=e=>{let t=e.data();return{id:`m_${e.id}`,type:`message`,title:t.title||`Notification`,subtitle:t.body||t.fromName||``,time:t.createdAt,link:typeof t.link==`string`&&t.link.startsWith(`/`)?t.link:void 0}},n=(0,J.query)((0,J.collection)(r.ui,Tt),(0,J.where)(`toUid`,`==`,p.uid));e.push((0,J.onSnapshot)(n,e=>O(`direct`,e.docs.map(t)),e=>k(`direct`,e)));let i=v?[`admin`,`internal`]:[`internal`],a=(0,J.query)((0,J.collection)(r.ui,Tt),(0,J.orderBy)(`createdAt`,`desc`),(0,J.limit)(100));e.push((0,J.onSnapshot)(a,e=>O(`rolewide`,e.docs.filter(e=>i.includes((e.data()||{}).toRole)).map(t)),e=>k(`rolewide`,e)))}else O(`direct`,[]),O(`rolewide`,[]);return()=>e.forEach(e=>e())},[v,x,p?.uid,p?.email,h]),(0,K.useEffect)(()=>{let e=p?.uid?c.k(p.uid,m):[];O(`sentToMe`,e.length?S.records.filter(t=>c.w(t,e)).map(Bt):[])},[S.records,p?.uid,m]),(0,K.useEffect)(()=>{O(`sales`,w.map(Vt))},[w]),(0,K.useEffect)(()=>{O(`orders`,T.map(Ht))},[T]);let[A,j]=(0,K.useState)(()=>typeof window<`u`?parseInt(localStorage.getItem(`admin_notifications_last_read`)||`0`,10):0),M=()=>{let n=!e;if(t(n),n){let e=s.current?.getBoundingClientRect();u(typeof window<`u`&&window.innerWidth<640&&e?e.bottom+8:null);let t=Date.now();j(t),typeof window<`u`&&localStorage.setItem(`admin_notifications_last_read`,t.toString())}},N=[];!y.loading&&L.y(g,m,y.finishRegistration,p?.uid)&&N.push({id:`finish-registration`,type:`finish`,title:`Finish registration`,subtitle:`There is still something we need from you.`,time:null,standing:!0,link:`/your-details`}),p&&_&&N.push({id:`role-request`,type:`role`,title:r.Qt,subtitle:r.Zt,time:null,standing:!0,urgent:!0,link:`/profile`}),b&&N.push({id:`verify-email`,type:`verify`,title:`Verify your email`,subtitle:`Open the link we sent to ${b} and you can sign in with it too. Nothing is waiting on it.`,time:null,standing:!0,link:`/verify`});let P=N.length?[...N,...n]:n,ee=P.some(e=>{if(e.standing)return!0;if(e.silent)return!1;if(!e.time)return!0;let t=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return t>A||isNaN(t)}),F=e=>{t(!1),e.link?f(e.link):e.type===`user`?f(`/users`):e.type===`booking`?f(x?`/schedule`:`/my-bookings`):e.type===`submission`||e.type===`request`?f(`/inbox`):e.type===`verify`||e.type===`role`?f(`/profile`):e.type===`finish`?f(`/your-details`):e.type===`payment`&&f(v?`/transactions`:`/billing`)},te=e=>{if(!e)return``;let t=e.toDate?e.toDate():new Date(e),n=Date.now()-t.getTime();if(isNaN(n))return``;let r=Math.floor(n/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<7?`${a}d`:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`}).format(t)};return(0,q.jsxs)(`div`,{className:`relative z-50 flex-shrink-0`,ref:a,children:[(0,q.jsxs)(`button`,{ref:s,onClick:M,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":`Notifications`,children:[(0,q.jsx)(d.n,{className:`w-4 h-4`}),ee&&(0,q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-[var(--notification-icon-color)] rounded-full animate-pulse`})]}),(0,q.jsx)(r.rt,{children:e&&(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`${l===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:l===null?void 0:{top:l},children:[(0,q.jsxs)(`div`,{className:`px-4 border-b border-[var(--panel-border)]/50 pb-3 pt-4 flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`font-bold text-[14px] text-foreground tracking-wide`,children:`Notifications`}),(v||x)&&(0,q.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md`,children:v?`Admin`:`Team`})]}),(0,q.jsx)(`div`,{className:`max-h-[350px] overflow-y-auto w-full p-2 flex flex-col gap-1`,children:P.length===0?(0,q.jsx)(`div`,{className:`p-6 text-center text-foreground/40 text-[13px] font-medium`,children:`No recent activity.`}):P.map(e=>(0,q.jsxs)(`button`,{onClick:()=>F(e),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,q.jsx)(`div`,{className:`mt-0.5 w-8 h-8 rounded-full flex items-center justify-center shrink-0 ${e.urgent?`bg-red-500/10 text-red-500`:`bg-foreground/5 text-notification-icon`}`,children:(0,q.jsx)(Wt,{n:e})}),(0,q.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[13px] font-semibold text-foreground group-hover:text-accent transition-colors truncate flex-1 min-w-0`,children:e.title}),(0,q.jsx)(`span`,{className:`text-[10px] font-mono tracking-wide text-foreground/40 shrink-0`,children:te(e.time)})]}),(0,q.jsx)(`span`,{className:`text-[12px] text-foreground/60 ${e.standing?`leading-snug`:`truncate`}`,children:e.subtitle})]})]},e.id))})]})})]})}var Kt=[{id:`contact`,hidden:!1}],qt={route:`/support`,template:`popup_form`,form:`support`,tabName:`Support`,iconName:``},Jt={"/contact":n.h},Yt=e=>e&&Jt[e]||n.g,Xt=`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`;function Zt({pages:e}){let[t,n]=(0,K.useState)(null),[a,o]=(0,K.useState)(!1),{rowRef:c,measureRef:l,visible:u}=i.s({count:e.length,listKey:e.map(e=>e.label+(e.submenu?` ▾`:``)).join(`|`),shown:!0,gap:28,moreButtonWidth:50}),d=e.slice(0,u),f=e.slice(u);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{ref:l,"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:e.map((e,t)=>(0,q.jsxs)(`span`,{"data-measure":!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,q.jsx)(s.t,{className:`w-3 h-3`})]},t))}),(0,q.jsxs)(`div`,{className:`flex items-center gap-7 w-full min-w-0 justify-end relative`,ref:c,children:[d.map((e,i)=>(0,q.jsxs)(`div`,{className:`relative shrink-0`,onMouseEnter:()=>n(e.label),onMouseLeave:()=>n(null),children:[e.path?(0,q.jsxs)(Y.Link,{to:e.path,className:Xt,children:[e.label,e.submenu&&(0,q.jsx)(s.t,{className:`w-3 h-3`})]}):(0,q.jsxs)(`button`,{onClick:e.action,className:Xt,children:[e.label,e.submenu&&(0,q.jsx)(s.t,{className:`w-3 h-3`})]}),e.submenu&&t===e.label&&(0,q.jsx)(`div`,{className:`absolute top-[100%] left-0 pt-2 z-50`,children:(0,q.jsx)(r.nt.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,q.jsx)(Y.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,q.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`}-${i}`)),f.length>0&&(0,q.jsxs)(`div`,{className:`relative flex items-center shrink-0`,onMouseEnter:()=>o(!0),children:[(0,q.jsx)(`button`,{onClick:()=>o(e=>!e),"aria-label":`More pages`,"aria-expanded":a,className:`p-1 rounded-lg transition-colors flex items-center ${a?`bg-foreground/5 text-accent`:`text-foreground/50 hover:bg-foreground/5 hover:text-accent`}`,children:(0,q.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,q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,q.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`}),(0,q.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`})]})}),(0,q.jsx)(r.rt,{children:a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>o(!1)}),(0,q.jsx)(r.nt.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:f.map((e,t)=>e.path?(0,q.jsx)(Y.Link,{to:e.path,onClick:()=>o(!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,q.jsx)(`button`,{onClick:()=>{e.action&&e.action(),o(!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))})]})})]})]})]})}function Qt({pages:e,onNavigate:t}){return(0,q.jsx)(q.Fragment,{children:e.map((e,n)=>{let r=Yt(e.path);return e.path?(0,q.jsxs)(Y.Link,{to:e.path,onClick:t,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 min-w-0`,children:[(0,q.jsx)(r,{className:`w-4 h-4 text-accent/70 shrink-0`}),` `,(0,q.jsx)(`span`,{className:`text-[14px] font-semibold truncate`,children:e.label})]},`${e.path}-${n}`):(0,q.jsxs)(`button`,{onClick:()=>{e.action&&e.action(),t?.()},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 min-w-0`,children:[(0,q.jsx)(r,{className:`w-4 h-4 text-accent/70 shrink-0`}),` `,(0,q.jsx)(`span`,{className:`text-[14px] font-semibold truncate`,children:e.label})]},`${e.label}-${n}`)})})}function $t({pages:e,phone:t,onNavigate:n}){return t?(0,q.jsx)(Qt,{pages:e,onNavigate:n}):(0,q.jsx)(Zt,{pages:e})}var en=e=>{if(!r.oi(e))return!1;let t=String(e?.message??e??``);return/\.(tsx|ts|jsx)\b|\/src\//.test(t)?!1:/https?:\/\/|\/assets\//.test(t)?!0:j.u()},tn=e=>{if(e?.didNotArrive===!0||r.oi(e))return!0;let t=String(e?.message??e??``);return/Minified React error #306\b|lazy element type must resolve/i.test(t)},nn=e=>!!e&&typeof e==`object`&&e.$$typeof===Symbol.for(`react.lazy`),rn=class extends K.default.Component{state={failed:!1,passOn:null,reloading:!1};static getDerivedStateFromError(e){return{failed:!0,passOn:e,reloading:en(e)&&r.ai()>0}}componentDidCatch(e){this.passesOn(e)||this.state.reloading&&r.ci(this.props.reload)||(this.state.reloading&&this.setState({reloading:!1}),j.o(this.props.which,e))}passesOn(e){return this.props.neverPutAside?!0:!!this.props.onlyMissing&&!tn(e)}render(){if(this.state.failed&&this.passesOn(this.state.passOn)){let e=this.state.passOn;throw queueMicrotask(()=>j.o(this.props.which,e,`threw`)),e}return this.state.reloading?null:this.state.failed?this.props.fallback:this.props.children}};function an(e){let t=r.mi().components?.Menu;return t?(0,q.jsx)(rn,{which:`menu`,fallback:(0,q.jsx)($t,{...e}),children:(0,q.jsx)(K.Suspense,{fallback:null,children:(0,q.jsx)(t,{...e})})}):(0,q.jsx)($t,{...e})}var on=()=>document.querySelector(`[aria-modal="true"]`)!==null,sn=e=>{let t=new MutationObserver(e);return t.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`aria-modal`]}),()=>t.disconnect()};function cn({isAdmin:e}){let t=j.d(e),i=a.i(),o=(0,K.useSyncExternalStore)(sn,on,()=>!1),[s,c]=(0,K.useState)(!1);if(!t.length||o)return null;let l=r.ri(j.s(t));return(0,q.jsx)(`div`,{role:`status`,className:`fixed left-1/2 -translate-x-1/2 z-30 w-[calc(100%-2rem)] max-w-md transition-[bottom] duration-300 ${i?`bottom-40`:`bottom-[4.5rem]`}`,children:(0,q.jsxs)(`div`,{className:`glass-popover rounded-2xl px-4 py-3 flex items-center gap-3`,children:[(0,q.jsx)(tt,{className:`w-4 h-4 shrink-0 text-accent`}),(0,q.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground/80 leading-snug flex-1 min-w-0`,children:[l.short.replace(j.i,``).trim(),(0,q.jsxs)(`span`,{className:`max-sm:hidden`,children:[` `,j.i]})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{navigator.clipboard?.writeText(l.message).catch(()=>{}),c(!0),setTimeout(()=>{c(!1),j.l(t)},1500)},"aria-label":s?`Copied`:`Copy the fix`,className:`shrink-0 inline-flex items-center justify-center gap-1.5 h-8 w-8 px-0 sm:w-auto sm:px-3 rounded-[var(--btn-radius,0.75rem)] text-[12px] font-semibold border ${s?`copy-btn-done border-[var(--panel-border)] text-foreground/60`:`copy-btn cursor-pointer`}`,children:[s?(0,q.jsx)(r.At,{className:`copy-icon w-3.5 h-3.5`}):(0,q.jsx)(n._,{className:`copy-icon w-3.5 h-3.5`}),(0,q.jsx)(`span`,{className:`max-sm:hidden`,children:s?`Copied`:`Copy the fix`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>j.l(t),"aria-label":`Hide this`,className:`shrink-0 text-[13px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors`,children:`✕`})]})})}var ln=(0,K.createContext)({wide:!1,setWide:()=>{},cap:0,setCap:()=>{}});function un({children:e}){let[t,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)(0);return(0,q.jsx)(ln.Provider,{value:{wide:t,setWide:n,cap:r,setCap:i},children:e})}var dn=()=>(0,K.useContext)(ln).wide,fn=()=>{let{wide:e,cap:t}=(0,K.useContext)(ln);return e?t:0};function pn(e=!0){let{setWide:t,setCap:n}=(0,K.useContext)(ln);(0,K.useLayoutEffect)(()=>{if(e)return t(!0),()=>t(!1)},[e,t]),(0,K.useLayoutEffect)(()=>{if(e)return vn()},[e]),(0,K.useLayoutEffect)(()=>{if(e)return _n(n)},[e,n])}var mn=.5,hn=400;function gn(e,t){if(!e||!t||typeof window>`u`)return 0;let n=getComputedStyle(t),r=(parseFloat(n.paddingLeft)||0)+(parseFloat(n.paddingRight)||0),i=window.innerHeight*mn,a=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let e=0,t=a.nextNode();t&&e<hn;t=a.nextNode(),e++){let e=t,n=getComputedStyle(e);if(n.position===`fixed`||n.display===`none`)continue;let a=parseFloat(n.maxWidth);if(!Number.isFinite(a)||a<960)continue;let o=e.getBoundingClientRect();if(o.width<=0||o.height<=0)continue;if(o.top>i)break;let s=e.parentElement?.getBoundingClientRect();if(!s)continue;let c=o.left-s.left,l=s.right-o.right;if(Math.abs(c-l)>2)continue;let u=a-(parseFloat(n.paddingLeft)||0)-(parseFloat(n.paddingRight)||0)-(parseFloat(n.borderLeftWidth)||0)-(parseFloat(n.borderRightWidth)||0);return Math.round(u+r)}return 0}function _n(e){if(typeof document>`u`)return()=>{};let t=0,n=()=>{t=0,e(gn(document.querySelector(`.fbos-home-slot, .fbos-page-canvas`),document.querySelector(`.firebase-os > nav, .firebase-os nav`)))},r=()=>{t||=requestAnimationFrame(n)};n();let i=[300,1e3,2500].map(e=>setTimeout(r,e)),a=document.querySelector(`.fbos-home-slot, .fbos-page-canvas`),o=a&&typeof MutationObserver<`u`?new MutationObserver(r):null;return o?.observe(a,{childList:!0,subtree:!0}),window.addEventListener(`resize`,r),()=>{i.forEach(clearTimeout),t&&cancelAnimationFrame(t),o?.disconnect(),window.removeEventListener(`resize`,r),e(0)}}function vn(){if(typeof document>`u`)return()=>{};let e=document.documentElement,t=document.querySelector(`.firebase-os > nav, .firebase-os nav`);if(!t)return()=>{};let n=()=>e.style.setProperty(`--menu-h`,`${Math.round(t.getBoundingClientRect().height)}px`);n();let r=typeof ResizeObserver<`u`?new ResizeObserver(n):null;return r?.observe(t),window.addEventListener(`resize`,n),()=>{r?.disconnect(),window.removeEventListener(`resize`,n),e.style.removeProperty(`--menu-h`)}}function yn({onNavigate:e}){let{user:t}=r.Ft(),{bought:n}=r.Ln(t?.uid);return n?(0,q.jsxs)(Y.Link,{to:`/billing`,onClick:e,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,q.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,q.jsx)(i.D,{className:`w-3 h-3 text-accent`})}),`Billing`]}):null}function bn({onNavigate:e}){return(0,q.jsx)(q.Fragment,{children:i.r().map(t=>{let n=t.icon;return(0,q.jsxs)(Y.Link,{to:t.path,onClick:e,"data-own-tab":t.id,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,q.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,q.jsx)(n,{className:`w-3 h-3 text-accent`})}),(0,q.jsx)(`span`,{className:`truncate min-w-0`,children:t.label})]},t.id)})})}var xn={contact:{label:`Contact`,path:`/contact`}},Sn=`fbos_public_menu`,Cn=()=>{try{let e=localStorage.getItem(Sn),t=e?JSON.parse(e):null;return t&&typeof t==`object`?t:{}}catch{return{}}},wn=e=>{try{localStorage.setItem(Sn,JSON.stringify({...Cn(),...e}))}catch{}},Tn=new Set([`setup`,`templates`,`guide`]),En=1.6,Dn=`logo-shape:`,On={shape:`unknown`,ratio:0},kn=e=>({shape:e>=En?`wide`:`square`,ratio:e}),An=e=>{if(!e)return On;try{let t=localStorage.getItem(Dn+e);if(t===`wide`)return{shape:`wide`,ratio:0};if(t===`square`)return{shape:`square`,ratio:0};let n=Number(t);return t&&Number.isFinite(n)&&n>0?kn(n):On}catch{return On}};function jn(e){let[t,n]=(0,K.useState)(null),r=t&&t.url===e?t.measure:An(e);return(0,K.useEffect)(()=>{if(!e||An(e).shape!==`unknown`||typeof Image>`u`)return;let t=new Image;return t.onload=()=>{let r=Math.round(t.naturalWidth/Math.max(1,t.naturalHeight)*100)/100;try{localStorage.setItem(Dn+e,String(r))}catch{}n({url:e,measure:kn(r)})},t.onerror=()=>n({url:e,measure:{shape:`square`,ratio:0}}),t.src=e,()=>{t.onload=null,t.onerror=null}},[e]),r}function Mn({customMenu:e,standalone:t}){let{user:s,userRole:c,signOut:l,roleResolved:u,profileReady:d,profile:f}=r.Ft(),p=!!s&&u!==!1&&d!==!1,m=o.wn(c),[h,_]=(0,K.useState)(!1),[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(!1),[S,w]=(0,K.useState)(!1),T=String(f?.displayName||``).trim()||s?.displayName||s?.email?.split(`@`)[0]||``,E=T.charAt(0).toUpperCase()+T.slice(1),D=(0,q.jsx)(`span`,{className:`block h-3 w-16 rounded bg-foreground/5 animate-pulse`,"aria-hidden":`true`}),{theme:O,toggleTheme:k,activeConfig:A,canSwitchTheme:j}=i.N(),M=an,N=async()=>{await l(),_(!1)},[P,ee]=(0,K.useState)(()=>Cn().info??{...xn}),[F,te]=(0,K.useState)(()=>Cn().order??Kt),[I,L]=(0,K.useState)(qt.tabName);(0,K.useEffect)(()=>{if(!r.ui)return;let e=(0,J.onSnapshot)((0,J.collection)(r.ui,`sys_pages`),e=>{let t={...xn};for(let[e,n]of i.x()){if(!n.isPublic)continue;let r=n.config||{};if(r.enabled===!1)continue;let a=r.route?r.route.startsWith(`/`)?r.route:`/`+r.route:`/`+e;t[e]={label:r.pageName||r.pageTitle||r.title||e,path:a,iconName:r.iconName||``,offMenu:i.y(r)}}e.forEach(e=>{let n=e.data(),r=String(n.fileId||``),i=r&&t[r]||t[e.id];if(r&&r!==e.id&&delete t[r],n.enabled===!1)return;let a=n.pageName||n.title||xn[e.id]?.label||e.id,o=n.route||(e.id===`home`?`/`:`/`+e.id);t[e.id]={label:a,path:o,iconName:n.iconName||t[e.id]?.iconName||``,offMenu:i?.offMenu}});for(let e of Tn)delete t[e];ee(t),wn({info:t})},e=>{a.s(e)}),t=(0,J.onSnapshot)((0,J.doc)(r.ui,`sys_configs`,`page_order`),e=>{let t=e.exists()&&Array.isArray(e.data().order)?i.c(e.data().order):Kt;te(t),wn({order:t})},()=>{}),n=(0,J.onSnapshot)((0,J.doc)(r.ui,`sys_tabs`,`support`),e=>{e.exists()&&e.data().pageName&&L(e.data().pageName)},()=>{});return()=>{e(),t(),n()}},[]);let ne=(()=>{let e=new Set(F.filter(e=>e.hidden).map(e=>e.id)),t=new Set,n=[];return F.forEach(e=>{if(e.hidden||e.id===`home`)return;let r=P[e.id];r&&(n.push({label:r.label,path:r.path,iconName:r.iconName}),t.add(e.id))}),Object.entries(P).forEach(([r,i])=>{!t.has(r)&&!e.has(r)&&!i.offMenu&&r!==`home`&&i.path!==`/`&&i.path!==`/support`&&n.push({label:i.label,path:i.path,iconName:i.iconName})}),n})(),R=e||ne,z=t?[]:R.filter(e=>e.path&&n.p(e.iconName)),re=!t&&R.some(e=>n.d(e.iconName));(0,K.useEffect)(()=>{re&&n.m()},[re]);let ie=z.length?R.filter(e=>!z.includes(e)):R,[B,V]=(0,K.useState)(()=>typeof window<`u`&&window.innerWidth<640);(0,K.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{let e=window.innerWidth<640;V(t=>(t!==e&&_(!1),e))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let ae=!t&&!s&&!B,oe=dn(),H=fn(),{shape:se,ratio:U}=jn(A?.logoUrl),ce=se===`square`&&!!A?.logoUrl&&U>1.05;return(0,q.jsxs)(`nav`,{className:`flex items-center justify-between w-full ${oe?`px-4 pt-4 pb-3 md:px-8 md:pt-10 md:pb-6`:`max-w-7xl px-4 py-4 md:px-8 md:py-10`} mx-auto z-40 relative`,style:H?{maxWidth:H}:void 0,children:[(0,q.jsx)(`div`,{className:`flex items-center min-w-0 z-50`,children:(0,q.jsx)(Y.Link,{to:`/`,className:`flex items-center gap-2 md:gap-2.5 lg:gap-3 group cursor-pointer z-50 min-w-0`,"aria-label":se===`wide`?A?.appName||`Home`:void 0,children:se===`wide`&&A?.logoUrl?(0,q.jsx)(`img`,{src:A.logoUrl,alt:A?.appName||``,"data-wide-logo":!0,draggable:!1,className:`h-6 md:h-7 lg:h-7 w-auto max-w-[140px] md:max-w-[180px] lg:max-w-[200px] object-contain object-left transition-opacity duration-300 group-active:opacity-80`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{"data-logo-tile":ce?`wide`:`square`,"data-logo-ratio":ce?String(U):void 0,style:ce?{aspectRatio:String(U)}:void 0,className:`h-8 md:h-9 ${ce?`w-auto`:`w-8 md:w-9 group-hover:rotate-180`} rounded-lg glass-panel flex items-center justify-center glow-hover shadow-lg transition-transform duration-500 group-active:scale-95 overflow-hidden shrink-0`,children:A?.logoUrl?(0,q.jsx)(r.O,{src:A.logoUrl,alt:`Logo`,fit:`contain`,priority:!0,className:`w-full h-full`,imgClassName:`max-md:p-0.5`}):(0,q.jsx)(`img`,{src:wt,alt:``,"aria-hidden":`true`,draggable:!1,"data-brand-mark":!0,className:`w-full h-full object-cover`})}),(0,q.jsx)(`span`,{className:`font-display font-bold text-[17px] md:text-[19px] lg:text-[22px] tracking-tight text-gradient transition-all duration-300 drop-shadow-sm truncate`,children:A?.appName||``})]})})}),(0,q.jsx)(r.rt,{children:v&&(0,q.jsx)(g.t,{formId:`contact`,onClose:()=>y(!1)})}),(0,q.jsx)(r.rt,{children:b&&(0,q.jsx)(g.t,{formId:`support`,onClose:()=>x(!1)})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 md:gap-4 z-50 relative ml-auto flex-1 min-w-0 justify-end`,children:[ae&&(0,q.jsx)(`div`,{className:`flex items-center flex-1 min-w-0 justify-end mr-6`,children:(0,q.jsx)(M,{pages:ie,phone:!1})}),z.length>0&&(0,q.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:z.map((e,t)=>{let r=n.p(e.iconName)||n.g;return(0,q.jsx)(Y.Link,{to:e.path,"aria-label":e.label,title:e.label,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`,children:(0,q.jsx)(r,{className:`w-4 h-4`})},`${e.path}-${t}`)})}),!t&&!s&&(0,q.jsxs)(q.Fragment,{children:[j&&(0,q.jsx)(`button`,{onClick:k,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:O===`dark`?(0,q.jsx)(_t,{className:`w-4 h-4`}):(0,q.jsx)(pt,{className:`w-4 h-4`})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 shrink-0`,children:[!B&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y.Link,{to:`/login`,className:`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,q.jsx)(Y.Link,{to:`/register`,className:`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 shrink-0`,children:`Get Started`})]}),B&&(0,q.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,q.jsx)(`button`,{onClick:()=>_(h===`guest`?!1:`guest`),"aria-label":`Open menu`,"aria-expanded":h===`guest`,className:`w-9 h-9 rounded-xl glass-panel glow-hover border transition-all flex items-center justify-center ${h===`guest`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,q.jsx)(lt,{className:`w-5 h-5 text-accent/80`})}),(0,q.jsx)(r.rt,{children:h===`guest`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>_(!1)}),(0,q.jsxs)(r.nt.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,q.jsx)(M,{pages:ie,phone:!0,onNavigate:()=>_(!1)}),(0,q.jsx)(`div`,{className:`pt-2 mt-1 border-t border-[var(--panel-border)]/50 flex flex-col gap-1`,children:(0,q.jsxs)(Y.Link,{to:`/login`,onClick:()=>_(!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,q.jsx)(a.o,{className:`w-4 h-4 text-accent/70`}),` `,(0,q.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign In`})]})})]})]})})]})]})]}),!t&&p&&s&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,q.jsx)(Gt,{}),j&&(0,q.jsx)(`button`,{onClick:k,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:O===`dark`?(0,q.jsx)(_t,{className:`w-4 h-4`}):(0,q.jsx)(pt,{className:`w-4 h-4`})}),(0,q.jsxs)(`div`,{className:`relative z-50 flex-shrink-0`,children:[(0,q.jsxs)(`button`,{onClick:()=>_(h===`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 sm:border ${h===`user`?`sm:border-accent/50 sm:bg-foreground/5`:`sm:border-[var(--panel-border)] sm:hover:border-accent/30`}`,children:[(0,q.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 sm:border-0 transition-colors shrink-0 text-accent ${h===`user`?`border-accent/50`:`border-[var(--panel-border)] group-hover:border-accent/30`}`,children:s.photoURL&&!S?(0,q.jsx)(r.O,{src:s.photoURL,alt:`Profile`,className:`w-full h-full`,onError:()=>w(!0)}):(0,q.jsx)(xt,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,q.jsx)(`div`,{className:`max-sm:hidden sm:flex text-left mr-1 items-center min-w-[70px] max-w-[160px]`,children:E?(0,q.jsx)(`span`,{className:`text-[12px] font-extrabold leading-tight text-foreground truncate w-full`,children:E}):D})]}),(0,q.jsx)(r.rt,{children:h===`user`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>_(!1)}),(0,q.jsxs)(r.nt.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] max-h-[calc(100svh-6rem)] overflow-y-auto overscroll-contain glass-popover border border-[var(--panel-border)] rounded-2xl p-2 z-50 flex flex-col origin-top-right`,children:[(0,q.jsxs)(`div`,{className:`p-3 border-b border-[var(--panel-border)]/50 mb-1 flex flex-col gap-1.5`,children:[E?(0,q.jsx)(`span`,{className:`font-bold text-[15px] text-foreground truncate`,children:E}):(0,q.jsx)(`span`,{className:`block h-3.5 w-24 my-[3px] rounded bg-foreground/5 animate-pulse`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate font-mono`,children:s.email})]}),(0,q.jsxs)(`div`,{className:`py-1`,children:[(0,q.jsxs)(Y.Link,{to:`/dashboard`,onClick:()=>_(!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,q.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,q.jsx)(C._,{className:`w-3 h-3 text-accent`})}),`Dashboard`]}),(0,q.jsx)(bn,{onNavigate:()=>_(!1)}),m&&(0,q.jsxs)(Y.Link,{to:`/assets`,onClick:()=>_(!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,q.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,q.jsx)(i.k,{className:`w-3 h-3 text-accent`})}),`Assets`]}),c===`admin`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Y.Link,{to:`/users`,onClick:()=>_(!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,q.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,q.jsx)(i.S,{className:`w-3 h-3 text-accent`})}),`Users`]}),(0,q.jsxs)(Y.Link,{to:`/inbox`,onClick:()=>_(!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,q.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,q.jsx)(i.O,{className:`w-3 h-3 text-accent`})}),`Inbox`]}),(0,q.jsxs)(Y.Link,{to:`/pages`,onClick:()=>_(!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,q.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,q.jsx)(n.g,{className:`w-3 h-3 text-accent`})}),`Pages`]}),(0,q.jsxs)(Y.Link,{to:`/publish`,onClick:()=>_(!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,q.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,q.jsx)(i.w,{className:`w-3 h-3 text-accent`})}),`Publish App`]}),(0,q.jsxs)(Y.Link,{to:`/setup`,onClick:()=>_(!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,q.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,q.jsx)(Ct,{className:`w-3 h-3 text-accent`})}),`Setup`]})]}),c!==`admin`&&(0,q.jsxs)(Y.Link,{to:`/support`,onClick:()=>_(!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,q.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,q.jsx)(qe,{className:`w-3 h-3 text-accent`})}),I]}),(0,q.jsx)(yn,{onNavigate:()=>_(!1)}),(0,q.jsxs)(Y.Link,{to:`/profile`,onClick:()=>_(!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,q.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,q.jsx)(xt,{className:`w-3 h-3 text-accent`})}),`Profile Settings`]})]}),(0,q.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,q.jsxs)(`button`,{onClick:N,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,q.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,q.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,q.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,q.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,q.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]})}),`Sign Out`]})})]})]})})]})]}),t&&(0,q.jsx)(q.Fragment,{children:j&&(0,q.jsx)(`button`,{onClick:k,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:O===`dark`?(0,q.jsx)(_t,{className:`w-4 h-4`}):(0,q.jsx)(pt,{className:`w-4 h-4`})})})]})]})}var Nn=`https://youtu.be/YOyuogCNq9Y`;function Pn(){let[e,t]=(0,K.useState)(null),[n,i]=(0,K.useState)(!1);return(0,q.jsxs)(`main`,{className:`flex-1 flex flex-col items-center justify-center w-full px-4 md:px-8 mb-16 md:mb-24 z-10 relative`,children:[(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},className:`text-center mb-8 md:mb-12`,children:[(0,q.jsxs)(r.nt.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,q.jsx)(c.B,{className:`w-4 h-4 text-accent`}),` Build your whole app without code`]}),(0,q.jsx)(r.nt.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,q.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:`Everything your next app needs is already built — sign-ins, pages, payments, emails and files. Say what you want in plain words and watch it appear. No code, no servers, nothing to set up.`}),(0,q.jsxs)(r.nt.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,q.jsx)(Y.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-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`,children:`Sign In to Build`}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),style:{borderRadius:`var(--btn-radius, 0.75rem)`},className:`group 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 gap-2.5 hover:-translate-y-1 active:scale-95 cursor-pointer`,children:[(0,q.jsx)(`span`,{className:`w-6 h-6 rounded-full bg-accent/15 text-accent flex items-center justify-center group-hover:bg-accent/25 transition-colors`,children:(0,q.jsx)(b.r,{className:`w-3 h-3 fill-current`})}),`Watch Tutorial`]})]})]}),(0,q.jsx)(v.n,{open:n,href:Nn,onClose:()=>i(!1),autoPlay:!0}),(0,q.jsx)(r.rt,{children:e&&(0,q.jsx)(g.t,{onClose:()=>t(null),formId:e})})]})}var Fn=[.16,1,.3,1],In={hidden:{opacity:0,y:10},shown:{opacity:1,y:0,transition:{duration:.35,ease:Fn,delayChildren:.08,staggerChildren:.05}}},Ln={hidden:{opacity:0,y:8},shown:{opacity:1,y:0,transition:{duration:.35,ease:Fn}}};function Rn({width:e=`max-w-[480px]`,className:t,children:n}){let i=r.tt();return(0,q.jsxs)(r.nt.div,{initial:i?!1:`hidden`,animate:`shown`,variants:In,className:r.$(`w-full p-6 sm:p-8 md:p-10 rounded-3xl glass-panel relative shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,e,t),children:[(0,q.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl -z-10`}),n]})}function zn({className:e,children:t}){return(0,q.jsx)(r.nt.div,{variants:Ln,className:e,children:t})}function Bn({show:e,className:t,children:n}){let i=r.tt();return(0,q.jsx)(r.nt.div,{className:t,initial:i?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.25,ease:Fn},children:n},e)}function Vn({title:e,line:t,as:n=`h3`,align:i=`center`,className:a}){return(0,q.jsxs)(zn,{className:r.$(`mb-6 sm:mb-7`,i===`center`?`text-center`:`text-left`,a),children:[(0,q.jsx)(n,{className:`text-[22px] sm:text-2xl font-semibold tracking-tight text-foreground leading-snug`,children:e}),t&&(0,q.jsx)(`p`,{className:`mt-1.5 text-[14px] text-foreground/60 leading-relaxed`,children:t})]})}function Hn({className:e,children:t}){return(0,q.jsx)(zn,{className:r.$(`mt-6 pt-5 border-t border-[var(--panel-border)] text-center`,e),children:t})}var Un=`text-[14px] text-foreground/60`,Wn=`text-accent font-semibold hover:underline ml-1`;function Gn(){return(0,q.jsxs)(`div`,{"aria-busy":`true`,className:`flex flex-col gap-3.5`,children:[(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl opacity-60`})]})}function Kn({problem:e,onUse:t,signInHref:n}){let i=t&&e.tryInstead&&e.tryInstead!==`password`?e.tryInstead:null,a=i?x.t[i]:null;return(0,q.jsxs)(S.t,{className:`mb-4`,children:[e.text,e.tryInstead===`password`&&n&&(0,q.jsx)(Y.Link,{to:n,className:`mt-2 block font-bold text-accent hover:underline`,children:`Go to the sign-in page`}),i&&a&&t&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>t(i),className:`mt-2.5 w-full flex items-center justify-center gap-2 py-2 rounded-lg text-[13px] font-bold text-foreground bg-foreground/[0.06] hover:bg-foreground/10 transition-colors cursor-pointer`,children:[(0,q.jsx)(a,{className:`w-4 h-4 shrink-0`}),r.fn(i)?.button??`Use that instead`]})]})}function qn({value:e,onChange:t,label:n=`The code we texted you`,autoFocus:r}){return(0,q.jsx)(g.y,{name:`code`,label:n,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,className:`max-sm:h-11 tracking-[0.3em] font-bold`,value:e,onChange:e=>t(e.target.value),autoFocus:r,required:!0})}function Jn({step:e,onSignedIn:t,onCancel:n}){let[i,a]=(0,K.useState)(!0),[o,s]=(0,K.useState)(!1),[c,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(null),g=(0,K.useRef)(null),_=(0,K.useRef)(!1),v=async e=>{h(await r.Kt(e,`sms2fa`,`That code could not be checked. Ask for a new one.`))},y=async()=>{h(null),a(!0);try{d(await e.send(g.current))}catch(e){await v(e)}finally{a(!1)}};return(0,K.useEffect)(()=>{_.current||(_.current=!0,y())},[]),(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2},children:[(0,q.jsx)(`div`,{ref:g}),m&&(0,q.jsx)(Kn,{problem:m}),(0,q.jsxs)(`div`,{className:`text-center mb-5`,children:[(0,q.jsx)(`p`,{className:`text-[15px] font-semibold text-foreground mb-1`,children:`One more step`}),(0,q.jsx)(`p`,{className:`text-[13.5px] text-foreground/60 leading-relaxed`,children:e.phone?(0,q.jsxs)(q.Fragment,{children:[`We texted a code to `,(0,q.jsx)(`span`,{className:`font-semibold text-foreground/80`,children:e.phone}),`. Type it in and you are in.`]}):(0,q.jsx)(q.Fragment,{children:`We texted you a code. Type it in and you are in.`})})]}),(0,q.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),h(null),s(!0);try{await e.finish(c,f.trim()),t()}catch(e){await v(e),s(!1)}},className:`flex flex-col gap-4`,children:[(0,q.jsx)(qn,{value:f,onChange:p,autoFocus:!0}),(0,q.jsxs)(N.t,{type:`submit`,className:`w-full py-3 text-[15px] font-semibold`,isLoading:o||i,disabled:i||o||!c,children:[`Sign me in `,(0,q.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:y,disabled:i||o,className:`mt-3 w-full text-[13px] font-bold text-accent hover:underline disabled:opacity-40 disabled:no-underline cursor-pointer disabled:cursor-default`,children:`Send it again`}),n&&(0,q.jsxs)(`button`,{type:`button`,onClick:n,className:`mt-2 w-full inline-flex items-center justify-center gap-1.5 text-[13px] font-bold text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:[(0,q.jsx)(l.t,{className:`w-3.5 h-3.5 shrink-0`}),`Another way in`]})]})}var Yn=`password`,Xn=e=>!!e?.providerData?.some(e=>e?.providerId===Yn),Zn=e=>{let t=r.li?.currentUser;return t&&(!e||t.uid===e.uid)?t:e};function Qn(e){let t=Zn(e);if(!t)return[];try{return(0,ue.multiFactor)(t).enrolledFactors??[]}catch{return[]}}var $n=e=>Qn(e).length>0;function er(e){let t=Qn(e)[0];return t?.phoneNumber||t?.displayName||``}var tr=e=>!!e&&Xn(e)&&!$n(e),nr=(e,t)=>t&&tr(e),rr=`firebase-os:two-step-not-now`;function ir(e){if(e)try{sessionStorage.setItem(`${rr}:${e}`,`1`)}catch{}}function ar(e){if(!e)return!1;try{return sessionStorage.getItem(`${rr}:${e}`)===`1`}catch{return!1}}var or=(e,t,n)=>nr(e,t)&&!(n&&ar(e?.uid)),sr=(e,t)=>!!e&&($n(e)||t&&Xn(e)),cr=()=>{if(!r.li)throw Error(`Firebase is not initialized. Check your configuration.`);return r.li},lr=`Phone`,ur=e=>(0,ue.multiFactor)(Zn(e)??e);async function dr(e,t,n){let i=await ur(e).getSession();return r.Yt(n,e=>new ue.PhoneAuthProvider(cr()).verifyPhoneNumber({phoneNumber:t,session:i},e))}async function fr(e,t,n){let r=ue.PhoneAuthProvider.credential(t,n);await ur(e).enroll(ue.PhoneMultiFactorGenerator.assertion(r),lr)}async function pr(e){let t=ur(e);for(let e of[...t.enrolledFactors??[]])await t.unenroll(e)}function mr(e){if(e?.code!==`auth/multi-factor-auth-required`)return null;let t;try{t=(0,ue.getMultiFactorResolver)(cr(),e)}catch{return null}let n=t.hints?.[0];return{phone:n?.phoneNumber||n?.displayName||``,send:e=>r.Yt(e,e=>new ue.PhoneAuthProvider(cr()).verifyPhoneNumber({multiFactorHint:n,session:t.session},e)),finish:async(e,n)=>{let r=ue.PhoneAuthProvider.credential(e,n);await t.resolveSignIn(ue.PhoneMultiFactorGenerator.assertion(r))}}}var hr=r.si(()=>Promise.resolve().then(()=>require(`./PhoneInputField-WYdkNEym.cjs`))),gr=e=>r.hn(e).filter(e=>e.id!==`password`),_r=e=>{let t=e.inSentence.replace(/^an?\s+/i,``);return t.charAt(0).toUpperCase()+t.slice(1)};function vr({settings:e,onSignedIn:t,disabled:n,returnTo:i=`/login`,onPanelChange:a,signInHref:o,sentTo:s}){let c=gr(e),f=s&&c.some(e=>e.id===`emailLink`)?s:``,[p,m]=(0,K.useState)(null),[h,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(f?`emailLink`:null),[b,S]=(0,K.useState)(f),[C,w]=(0,K.useState)(f),[T,E]=(0,K.useState)(``),[D,O]=(0,K.useState)(``),[k,A]=(0,K.useState)(null),[j,M]=(0,K.useState)(null),P=(0,K.useRef)(null),ee=p!==null||n,F=v!==null||j!==null;(0,K.useEffect)(()=>{a?.(F)},[F]);let te=async(e,t)=>{let n=mr(e);if(n){M(n);return}_(await r.Kt(e,t,`That did not work. Try again, or use another way in.`))};(0,K.useEffect)(()=>{let e=r.Jt();e&&te(e.err,e.id)},[]);let I=async()=>{t()},L=async e=>{if(_(null),!r.Ht(e)){y(e),O(``),A(null),w(``);return}m(e);try{await r.qt(e)===`done`&&await I()}catch(t){await te(t,e)}finally{m(null)}},ne=async e=>{e.preventDefault(),_(null),m(`emailLink`);try{await r.Wt(b.trim(),i),w(b.trim())}catch(e){await te(e,`emailLink`)}finally{m(null)}},R=async()=>{_(null),m(`phone`);try{O(``),A(await r.Gt(T.trim(),P.current))}catch(e){await te(e,`phone`)}finally{m(null)}},z=async e=>{e.preventDefault(),await R()},re=async e=>{e.preventDefault(),_(null),m(`phone`);try{await k.confirm(D.trim()),await I()}catch(e){await te(e,`phone`)}finally{m(null)}},ie=()=>{y(null),_(null),A(null),M(null),w(``),O(``)},B=()=>(0,q.jsxs)(`button`,{type:`button`,onClick:ie,className:`mt-3 w-full inline-flex items-center justify-center gap-1.5 text-[13px] font-bold text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:[(0,q.jsx)(l.t,{className:`w-3.5 h-3.5 shrink-0`}),`Another way in`]}),V=c.length===1&&!e.on.password;return(0,q.jsxs)(`div`,{children:[h&&(0,q.jsx)(Kn,{problem:h,onUse:L,signInHref:o}),(0,q.jsx)(`div`,{ref:P}),j?(0,q.jsx)(Jn,{step:j,onSignedIn:t,onCancel:V&&!v?void 0:ie}):v?(0,q.jsx)(r.nt.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2},children:(e=>e===`emailLink`?C?(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] bg-foreground/[0.02] px-5 py-6 sm:py-7 text-center`,children:[(0,q.jsx)(`div`,{className:`w-12 h-12 mx-auto mb-4 rounded-2xl flex items-center justify-center bg-accent/10 text-accent ring-1 ring-inset ring-accent/20`,children:(0,q.jsx)(d.t,{className:`w-[22px] h-[22px]`})}),(0,q.jsx)(`p`,{className:`text-[16px] sm:text-[17px] font-extrabold tracking-tight text-foreground`,children:`Check your email`}),(0,q.jsx)(`p`,{className:`mt-1.5 text-[13px] text-foreground/50 font-medium`,children:`We sent a sign-in link to`}),(0,q.jsx)(`p`,{className:`mt-1 text-[14px] font-bold text-foreground break-all leading-snug`,children:C}),(0,q.jsx)(`p`,{className:`mt-3.5 text-[12.5px] text-foreground/50 font-medium leading-relaxed`,children:`Open it and you are in — there is no password to think of.`})]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-center gap-3 text-[13px] font-bold`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>w(``),className:`text-accent hover:underline cursor-pointer`,children:`Send it again`}),!V&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`w-[1px] h-3.5 bg-[var(--panel-border)]`}),(0,q.jsxs)(`button`,{type:`button`,onClick:ie,className:`inline-flex items-center gap-1.5 text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:[(0,q.jsx)(l.t,{className:`w-3.5 h-3.5 shrink-0`}),`Another way in`]})]})]})]}):(0,q.jsxs)(`form`,{onSubmit:ne,className:`space-y-3`,children:[(0,q.jsx)(g.y,{name:`linkEmail`,label:`Your email`,type:`email`,placeholder:`name@example.com`,className:`max-sm:h-11`,value:b,onChange:e=>S(e.target.value),autoFocus:!V,required:!0}),(0,q.jsxs)(N.t,{type:`submit`,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,isLoading:p===`emailLink`,children:[`Email me a link `,(0,q.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]}),!V&&(0,q.jsx)(B,{})]}):e===`phone`?(0,q.jsxs)(`div`,{children:[k?(0,q.jsxs)(`form`,{onSubmit:re,className:`space-y-3`,children:[(0,q.jsx)(qn,{value:D,onChange:O,autoFocus:!0}),(0,q.jsxs)(N.t,{type:`submit`,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,isLoading:p===`phone`,children:[`Sign me in `,(0,q.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-center gap-3 text-[13px] font-bold`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:R,disabled:p===`phone`,className:`text-accent hover:underline disabled:opacity-40 disabled:no-underline cursor-pointer disabled:cursor-default`,children:`Send it again`}),(0,q.jsx)(`span`,{className:`w-[1px] h-3.5 bg-[var(--panel-border)]`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{A(null),O(``),_(null)},className:`text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:`Use a different number`})]})]}):(0,q.jsxs)(`form`,{onSubmit:z,className:`space-y-3`,children:[(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,q.jsx)(hr,{field:{label:`Your phone number`,required:!0,placeholder:`7700 900123`},value:T,onChange:E})}),(0,q.jsxs)(N.t,{type:`submit`,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,isLoading:p===`phone`,children:[`Text me a code `,(0,q.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]})]}),!V&&(0,q.jsx)(B,{})]}):null)(v)}):c.length>3?(0,q.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2 sm:gap-2.5`,children:c.map(e=>{let t=x.t[e.id];return(0,q.jsxs)(N.t,{variant:`secondary`,onClick:()=>L(e.id),title:e.button,"aria-label":e.button,isLoading:p===e.id,disabled:ee,className:`w-[88px] h-[68px] !px-1.5 text-[11px] font-bold tracking-tight rounded-xl transition-all hover:-translate-y-0.5 [&>span]:flex-col [&>span]:gap-1.5 [&>span]:w-full`,children:[(0,q.jsx)(t,{className:`w-[22px] h-[22px] shrink-0`}),(0,q.jsx)(`span`,{className:`w-full truncate text-center leading-none`,children:_r(e)})]},e.id)})}):(0,q.jsx)(`div`,{className:`space-y-3`,children:c.map(e=>{let t=x.t[e.id];return(0,q.jsxs)(N.t,{variant:`secondary`,onClick:()=>L(e.id),isLoading:p===e.id,disabled:ee,className:`w-full py-2.5 sm:py-3 text-[15px] sm:text-base font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,children:[(0,q.jsx)(t,{className:`w-5 h-5 shrink-0`}),e.button]},e.id)})})]})}function yr({email:e,onSignedIn:t,onStartOver:n}){let[i,a]=(0,K.useState)(e),[o,s]=(0,K.useState)(!1),[c,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(null);return f?(0,q.jsx)(Jn,{step:f,onSignedIn:t,onCancel:n}):(0,q.jsxs)(`div`,{children:[c&&(0,q.jsx)(Kn,{problem:c}),(0,q.jsx)(`p`,{className:`text-[13.5px] text-foreground/60 font-medium leading-relaxed mb-4`,children:`Nearly there. This link did not bring your address with it, so tell us the one you asked us to send it to and you are in.`}),(0,q.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),d(null),s(!0);try{await r.Vt(i.trim()),t()}catch(e){let t=mr(e);if(t){p(t);return}d(await r.Kt(e,`emailLink`,`That link did not work. Ask for a new one.`,{email:i.trim()})),s(!1)}},className:`space-y-3`,children:[(0,q.jsx)(g.y,{name:`linkEmail`,label:`Your email`,type:`email`,placeholder:`name@example.com`,className:`max-sm:h-11`,value:i,onChange:e=>a(e.target.value),autoFocus:!0,required:!0}),(0,q.jsxs)(N.t,{type:`submit`,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,isLoading:o,children:[`Sign me in `,(0,q.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]}),n&&(0,q.jsxs)(`button`,{type:`button`,onClick:n,className:`mt-3 w-full inline-flex items-center justify-center gap-1.5 text-[13px] font-bold text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:[(0,q.jsx)(l.t,{className:`w-3.5 h-3.5 shrink-0`}),`Ask for a new link, or sign in another way`]})]})]})}var br=`Signing you in…`;function xr({note:e=`One moment.`}){return(0,q.jsxs)(`div`,{"aria-busy":`true`,className:`py-6 flex flex-col items-center gap-4 text-center`,children:[(0,q.jsx)(P.t,{}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:br}),(0,q.jsx)(`p`,{className:`mt-1 text-[13px] text-foreground/55`,children:e})]})]})}function Sr(){let[e,t]=(0,K.useState)(!1),n=(0,Y.useNavigate)();return{settling:e,signedIn:()=>{r.zt();let e=r.li?.currentUser;if(e&&!o.un(e)){n(`/verify`,{replace:!0});return}t(!0)}}}var Cr=[{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)}],wr=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(`.`)),Tr=e=>e.toLowerCase().replace(/[\s._-]/g,``),Er=e=>wr.has(Tr(e||``)),Dr=e=>Cr.map(t=>({rule:t,met:t.ok(e||``)}));function Or(e){let t=e||``;if(!t)return`Choose a password.`;let n=Cr.find(e=>!e.ok(t));return n?`Your password needs ${n.label.toLowerCase()}.`:Er(t)?`That password is one of the first anyone would guess. Please pick another.`:``}function kr(e,t){return t?e===t?``:`Both passwords must be the same.`:`Type your password a second time.`}function Ar({value:e,className:t=``}){return(0,q.jsx)(`ul`,{className:`flex flex-col gap-1 ml-1 ${t}`,"aria-label":`Password requirements`,children:Dr(e).map(({rule:e,met:t})=>(0,q.jsxs)(`li`,{className:`flex items-center gap-2 text-[12.5px] font-medium transition-colors ${t?`text-emerald-500`:`text-foreground/45`}`,children:[t?(0,q.jsx)(r.At,{className:`w-3.5 h-3.5 shrink-0`}):(0,q.jsx)(`span`,{className:`w-3.5 flex justify-center shrink-0`,children:(0,q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-foreground/25`})}),e.label]},e.id))})}var jr=`again`,Mr=e=>`This account is half-made: nothing has been saved to it, and nothing can be until ${e||`the address on it`} is proved. Letting it go frees that address and takes you back to the form, where you fill in your details again with the address you want — and the next link goes to that one.`,Nr=(e=window.location.pathname)=>`${e.replace(/\/+$/,``).replace(/\/[^/]*$/,``)}/register?${jr}=1`;async function Pr(e){let t=e||r.li.currentUser;if(t){r.Tn(t.uid);try{await(0,ue.deleteUser)(t)}catch{await(0,ue.signOut)(r.li).catch(()=>{})}}window.location.assign(Nr())}function Fr({as:e}={}){let[t,n]=(0,K.useState)(!1),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(!1),_=(0,Y.useNavigate)(),[v]=(0,Y.useSearchParams)(),{registerUser:y}=r.Ft(),b=r.Cn(),{settling:x,signedIn:C}=Sr(),w=v.has(jr),T=(()=>{let e=new URLSearchParams(v);e.delete(`as`);let t=e.toString();return`/register${t?`?${t}`:``}`})(),E=async e=>{e.preventDefault(),n(!0),a(null);let t=new FormData(e.currentTarget),i=t.get(`email`),s=t.get(`firstName`),l=t.get(`lastName`),u=Or(o),f=u?``:kr(o,c);if(d(u),p(f),u||f){a(u||f),n(!1);return}try{await y(i,o,s,l),_(`/verify`)}catch(e){e?.code===`auth/email-already-in-use`?a((0,q.jsxs)(`span`,{children:[(await r.Kt(e,`password`,``,{email:i})).text,` `,(0,q.jsx)(Y.Link,{to:`/login?email=${encodeURIComponent(i)}`,className:`font-bold`,children:`Sign in`})]})):e?.code===`auth/weak-password`?a(Or(o)||`Please choose a stronger password.`):a((await r.Kt(e,`password`,`That did not work. Check your details and try again.`,{email:i})).text)}finally{n(!1)}},D=r._n(b),O=gr(b),k=x?`signing`:b.loading?`loading`:`form`;return(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,q.jsxs)(Rn,{width:`max-w-[500px]`,children:[(0,q.jsx)(Vn,{title:e?r.an(e.id,e.name):`Create an account`,line:e?r.Xt:`Join Your AI Firebase and start building today.`}),i&&(0,q.jsx)(S.t,{className:`mb-5`,children:i}),!i&&w&&(0,q.jsx)(S.t,{tone:`note`,className:`mb-5`,children:`Start again with the address you want. Nothing was saved to the one you began with, and the next link goes wherever you type here.`}),(0,q.jsx)(zn,{children:(0,q.jsx)(Bn,{show:k,children:x?(0,q.jsx)(xr,{}):b.loading?(0,q.jsx)(Gn,{}):(0,q.jsxs)(q.Fragment,{children:[D&&!m&&(0,q.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:E,children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5`,children:[(0,q.jsx)(g.y,{name:`firstName`,label:`First Name`,type:`text`,placeholder:`John`,className:`max-sm:h-11`,required:!0}),(0,q.jsx)(g.y,{name:`lastName`,label:`Last Name`,type:`text`,placeholder:`Doe`,className:`max-sm:h-11`,required:!0})]}),(0,q.jsx)(g.y,{name:`email`,label:`Email`,type:`email`,placeholder:`name@example.com`,className:`max-sm:h-11`,required:!0}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,q.jsx)(g.y,{name:`password`,label:`Password`,type:`password`,placeholder:`••••••••`,className:`max-sm:h-11`,autoComplete:`new-password`,value:o,onChange:e=>{s(e.target.value),u&&d(``),f&&e.target.value===c&&p(``)},onBlur:()=>d(o?Or(o):``),error:u,required:!0}),o&&(0,q.jsx)(Ar,{value:o})]}),o&&(0,q.jsx)(g.y,{name:`confirmPassword`,label:`Confirm password`,type:`password`,placeholder:`••••••••`,className:`max-sm:h-11`,autoComplete:`new-password`,value:c,onChange:e=>{l(e.target.value),f&&p(``)},onBlur:()=>p(c?kr(o,c):``),error:f,required:!0}),(0,q.jsx)(`div`,{className:`pt-1`,children:(0,q.jsx)(N.t,{type:`submit`,className:`w-full py-3 text-[15px] font-semibold`,isLoading:t,children:`Create Account`})})]}),D&&O.length>0&&!m&&(0,q.jsxs)(`div`,{className:`flex items-center gap-3 my-6`,children:[(0,q.jsx)(`span`,{className:`h-[1px] flex-1 bg-[var(--panel-border)]`}),(0,q.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/40`,children:`or`}),(0,q.jsx)(`span`,{className:`h-[1px] flex-1 bg-[var(--panel-border)]`})]}),O.length>0&&(0,q.jsx)(vr,{settings:b,onSignedIn:C,disabled:t,returnTo:`/login`,onPanelChange:h,signInHref:`/login`})]})})}),(0,q.jsxs)(Hn,{className:`space-y-2`,children:[e&&(0,q.jsxs)(`p`,{className:`text-[14px] text-foreground/60`,children:[`Registering as something else? `,(0,q.jsx)(Y.Link,{to:T,className:`text-accent font-semibold hover:underline ml-1`,children:`Choose again`})]}),(0,q.jsxs)(`p`,{className:Un,children:[`Already have an account? `,(0,q.jsx)(Y.Link,{to:`/login`,className:Wn,children:`Sign in`})]})]})]})})}var Ir=`member`;function Lr(e,t){let n=new URLSearchParams(e);return n.set(`as`,t),`/register?${n.toString()}`}function Rr({choices:e,search:t=``}){let i=e.length>3;return(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,q.jsxs)(Rn,{width:i?`max-w-[640px]`:`max-w-[500px]`,children:[(0,q.jsx)(Vn,{title:`Create an account`,line:`What are you registering as?`}),(0,q.jsxs)(zn,{children:[(0,q.jsx)(`div`,{role:`list`,"aria-label":`Register as`,className:`grid gap-3 ${i?`grid-cols-1 sm:grid-cols-2`:`grid-cols-1`}`,children:e.map((a,o)=>{let s=i&&e.length%2==1&&o===e.length-1;return(0,q.jsxs)(Y.Link,{role:`listitem`,to:Lr(t,a.id),className:`group flex items-center gap-3.5 min-w-0 px-4 py-3.5 rounded-2xl border border-[var(--panel-border)] bg-foreground/[0.02] hover:border-accent/50 hover:bg-foreground/[0.03] active:scale-[0.99] transition-all duration-300 ${s?`sm:col-span-2`:``}`,children:[(0,q.jsx)(n.c,{name:ne.u(a.id),className:`w-[18px] h-[18px] shrink-0 text-accent`}),(0,q.jsx)(`span`,{className:`flex-1 min-w-0 text-[14.5px] font-semibold text-foreground leading-snug tracking-tight`,children:r.an(a.id,a.name)}),(0,q.jsx)(u.t,{className:`w-4 h-4 shrink-0 text-foreground/30 group-hover:text-accent group-hover:translate-x-0.5 transition-all`})]},a.id)})}),(0,q.jsx)(`p`,{className:`mt-4 text-[13px] text-foreground/50 text-center leading-relaxed`,children:r.Xt})]}),(0,q.jsxs)(Hn,{className:`space-y-2`,children:[(0,q.jsxs)(`p`,{className:Un,children:[`Just want an account?`,(0,q.jsx)(Y.Link,{to:Lr(t,Ir),className:Wn,children:`Register as a member`})]}),(0,q.jsxs)(`p`,{className:Un,children:[`Already have an account?`,(0,q.jsx)(Y.Link,{to:`/login`,className:Wn,children:`Sign in`})]})]})]})})}function zr({settings:e}){let t=ne.l(),[n]=(0,Y.useSearchParams)(),i=n.get(`as`),a=r.bn(e,t),o=i?r.yn(e,i,t):null,s=n.has(`preview`)?``:o?.id??``;return(0,K.useEffect)(()=>{e.loading||(s?r.on(s):r.rn())},[e.loading,s]),e.loading?(0,q.jsx)(Fr,{}):o?(0,q.jsx)(Fr,{as:o}):a.length&&!i?(0,q.jsx)(Rr,{choices:a,search:n.toString()}):(0,q.jsx)(Fr,{})}function Br(){let e=r.Cn();return!e.loading&&!e.registerAs.on?(r.rn(),(0,q.jsx)(Fr,{})):(0,q.jsx)(zr,{settings:e})}function Vr(){let[e,t]=(0,K.useState)(!1),[n,i]=(0,K.useState)(null),[a]=(0,Y.useSearchParams)(),o=(0,Y.useNavigate)(),[s]=(0,K.useState)(a.get(`email`)||``),[c]=(0,K.useState)(()=>a.get(`sent`)===`1`&&!!a.get(`email`)),[l]=(0,K.useState)(()=>a.get(`from`)||``),u=r.Cn(),{loading:d}=r.Ft(),[f,p]=(0,K.useState)(()=>r.Bt()?`finishing`:`no`),[m,h]=(0,K.useState)(null),[_,v]=(0,K.useState)(!1),y=()=>{p(`no`),h(null),i(null),o(`/login`,{replace:!0})},{settling:b,signedIn:x}=Sr();(0,K.useEffect)(()=>{if(f!==`finishing`||d)return;let e=r.Ut();if(!e){p(`asking`);return}let t=!1;return r.Vt(e).then(()=>{t||x()}).catch(e=>{if(t)return;let n=mr(e);if(n){h(n);return}p(`asking`)}),()=>{t=!0}},[f,d]);let C=async e=>{e.preventDefault(),t(!0),i(null);let n=new FormData(e.currentTarget),a=n.get(`email`),o=n.get(`password`);try{if(!r.li)throw Error(`Firebase is not initialized. Check your configuration.`);await(0,ue.signInWithEmailAndPassword)(r.li,a,o),x()}catch(e){let n=mr(e);if(n){h(n),t(!1);return}e?.code===`auth/invalid-credential`||e?.code===`auth/user-not-found`||e?.code===`auth/wrong-password`||e?.code===`auth/invalid-login-credentials`?i((0,q.jsxs)(`span`,{children:[`That email and password do not match.`,` `,(0,q.jsx)(Y.Link,{to:`/reset-password`,children:`Reset password?`}),T.length>0&&(0,q.jsx)(q.Fragment,{children:` If you first came in with one of the buttons below, use that button instead.`})]})):i((await r.Kt(e,`password`,`That did not work. Check your details and try again.`,{email:a})).text),t(!1)}},w=r._n(u),T=gr(u),E=c&&T.some(e=>e.id===`emailLink`)?s:``,D=b||f===`finishing`&&!m,O=D?`signing`:m?`step`:f===`asking`?`asking`:u.loading?`loading`:`form`;return(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,q.jsxs)(Rn,{width:`max-w-[480px]`,children:[(0,q.jsx)(Vn,{title:`Welcome back`,line:`Sign in to Your AI Firebase.`}),n&&(0,q.jsx)(S.t,{className:`mb-5`,children:n}),!n&&c&&!E&&f===`no`&&!b&&(0,q.jsxs)(S.t,{tone:`done`,className:`mb-5`,children:[`We have emailed a sign-in link to `,s,`. Open it on this device and you go straight to your order — or sign in below.`]}),(0,q.jsx)(zn,{children:(0,q.jsx)(Bn,{show:O,children:D?(0,q.jsx)(xr,{note:f===`finishing`?`One moment — your link checks out.`:void 0}):m?(0,q.jsx)(Jn,{step:m,onSignedIn:x}):f===`asking`?(0,q.jsx)(yr,{email:s,onSignedIn:x,onStartOver:y}):u.loading?(0,q.jsx)(Gn,{}):(0,q.jsxs)(q.Fragment,{children:[w&&!_&&(0,q.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:C,children:[(0,q.jsx)(g.y,{name:`email`,label:`Email`,type:`email`,defaultValue:s,placeholder:`name@example.com`,className:`max-sm:h-11`,required:!0}),(0,q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,q.jsxs)(`div`,{className:`flex justify-between items-baseline mb-1.5 mx-1`,children:[(0,q.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none`,children:`Password`}),(0,q.jsx)(Y.Link,{to:`/reset-password`,className:`text-[13px] font-semibold text-accent hover:underline`,children:`Forgot Password?`})]}),(0,q.jsx)(g.y,{name:`password`,type:`password`,placeholder:`••••••••`,className:`max-sm:h-11`,required:!0})]}),(0,q.jsx)(`div`,{className:`pt-1`,children:(0,q.jsx)(N.t,{type:`submit`,className:`w-full py-3 text-[15px] font-semibold`,isLoading:e,children:`Sign In`})})]}),w&&T.length>0&&!_&&(0,q.jsxs)(`div`,{className:`flex items-center gap-3 my-6`,children:[(0,q.jsx)(`span`,{className:`h-[1px] flex-1 bg-[var(--panel-border)]`}),(0,q.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/40`,children:`or`}),(0,q.jsx)(`span`,{className:`h-[1px] flex-1 bg-[var(--panel-border)]`})]}),T.length>0&&(0,q.jsx)(vr,{settings:u,onSignedIn:x,disabled:e,returnTo:l?`/login?from=${encodeURIComponent(l)}`:`/login`,onPanelChange:v,sentTo:E})]})})}),(0,q.jsx)(Hn,{children:(0,q.jsxs)(`p`,{className:Un,children:[`New here? `,(0,q.jsx)(Y.Link,{to:`/register`,className:Wn,children:`Create account`})]})})]})})}var Hr=()=>{if(!r.li)throw Error(`Firebase is not initialized. Check your configuration.`);return r.li},Ur=`/confirm-email`,Wr=`address`,Gr=`firebase-os:address-link`;async function Kr(e,t){let n=new URL(Ur,window.location.origin);n.searchParams.set(`for`,t),n.searchParams.set(Wr,e),await(0,ue.sendSignInLinkToEmail)(Hr(),e,{url:n.toString(),handleCodeInApp:!0})}function qr(e=window.location.href){let t;try{t=new URL(e).searchParams}catch{return null}let n=String(t.get(`for`)||``).trim(),r=String(t.get(`address`)||``).trim();if(!n||!r)return null;try{if(!(0,ue.isSignInWithEmailLink)(Hr(),e))return null}catch{return null}return{uid:n,address:r,url:e}}function Jr(e){try{localStorage.setItem(Gr,JSON.stringify(e))}catch{}}function Yr(){try{let e=localStorage.getItem(Gr);if(!e)return null;let t=JSON.parse(e);return t?.uid&&t?.address&&t?.url?t:null}catch{return null}}var Xr=e=>!!e&&Yr()?.uid===e;function Zr(){try{localStorage.removeItem(Gr)}catch{}}async function Qr(e){let t=r.li?.currentUser??null;if(!t)return`signInFirst`;if(t.uid!==e.uid)return`wrongAccount`;if((t.email||``).toLowerCase()===e.address.toLowerCase()&&t.emailVerified)return`confirmed`;try{await(0,ue.linkWithCredential)(t,ue.EmailAuthProvider.credentialWithLink(e.address,e.url))}catch(e){let t=e?.code||``;return t===`auth/provider-already-linked`?`confirmed`:t===`auth/email-already-in-use`||t===`auth/credential-already-in-use`?`takenElsewhere`:t===`auth/invalid-action-code`||t===`auth/expired-action-code`||t===`auth/invalid-email`||t===`auth/argument-error`?`spent`:(console.warn(`The address could not be added to this sign-in.`,e),`failed`)}try{await t.getIdToken(!0)}catch{}try{await t.reload()}catch{}return`confirmed`}var $r=5e3,ei=120,ti=30,ni=900;function ri(){let{user:e,profile:t,refreshUser:n,signOut:i}=r.Ft(),a=(0,Y.useNavigate)(),[s,c]=(0,K.useState)(!1),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(!1),_=!o.un(e),v=_?e?.email||``:o.dn(e,t),y=(()=>{let t=(e?.providerData||[]).map(e=>e?.providerId).filter(Boolean);if(!t.length||t.includes(`password`))return``;let n=r.sn.find(e=>e.providerId&&e.providerId!==`password`&&t.includes(e.providerId));return n&&n.id!==`phone`?n.label:``})(),b=_&&!v;(0,K.useEffect)(()=>{if(!_||!e||b)return;let t=!1;return r.wn(e).then(e=>{!t&&e===`failed`&&f(`We could not send the link just now. Press Resend below to try again.`)}),()=>{t=!0}},[_,b,e?.uid]);let x=(0,K.useRef)(!1),C=async()=>{await r.li.currentUser?.getIdToken(!0),await n(),!x.current&&(x.current=!0,a(`/dashboard?${L.n}=1`))};(0,K.useEffect)(()=>{if(!_||b)return;let e=!1,t=!1,n=async()=>{let n=r.li.currentUser;if(!(e||t||x.current||document.hidden||!n)){t=!0;try{await n.reload(),!e&&n.emailVerified&&await C()}catch{}finally{t=!1}}},i=0,a=window.setInterval(()=>{i+=1;let e=$r/1e3*i;if(e>ni){window.clearInterval(a);return}e>ei&&e%ti!==0||n()},$r);return document.addEventListener(`visibilitychange`,n),window.addEventListener(`focus`,n),()=>{e=!0,window.clearInterval(a),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`focus`,n)}},[_,b]);let w=()=>a(L.h(t)?`/dashboard?${L.n}=1`:`/dashboard`,{replace:!0}),T=async()=>{c(!0),f(``);let e=!1;try{if(!r.li.currentUser)return;if(await r.li.currentUser.reload(),!_){await n();let e=o.dn(r.li.currentUser,t);f(e?`Not yet — open the link we sent to ${e}, and it is done. Nothing else is waiting on it.`:`Your email is confirmed.`);return}if(!r.li.currentUser.emailVerified){f(`Not yet — open the link in the email first, then press this. Check your spam folder if it has not arrived.`);return}await C(),e=!0}catch{f(`We could not check just now. Make sure you are online and try again.`)}finally{e||c(!1)}},E=async()=>{if(e&&!b){u(!0),f(``);try{_?(await(0,ue.sendEmailVerification)(e),r.En(e.uid)):await Kr(v,e.uid),f(`Verification email sent! Please check your inbox.`)}catch(e){e?.code===`auth/too-many-requests`?f(`Failed to resend: please wait a minute before trying again.`):f(`Failed to resend. ${(await r.Kt(e,`password`,`Check your connection and try again in a moment.`)).text}`)}finally{u(!1)}}},D=d.includes(`Failed`)||d.includes(`could not`)||d.includes(`not verified`)||d.includes(`wrong`)||d.startsWith(`Not yet`);return(0,q.jsxs)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16`,children:[(0,q.jsxs)(Rn,{width:`max-w-[480px]`,className:`text-center`,children:[(0,q.jsx)(Vn,{as:`h1`,className:`mb-6 sm:mb-8`,title:b?`No address to verify`:`Verify your email`,line:b?(0,q.jsxs)(q.Fragment,{children:[y||`The way you signed in`,` did not give us an email address, so there is nothing here to send a link to and nothing to verify. An address is the one thing this app cannot do without: everything behind this screen is shut until it has one.`,y?(0,q.jsxs)(q.Fragment,{children:[` If this app is yours, it is one tick in your `,y,` setup — the setting that asks for the person's email address — and everybody who signs in after it arrives with one.`]}):(0,q.jsx)(q.Fragment,{children:` If this app is yours, the way in you used has to be set to ask for an email address.`}),` `,`Until then, sign in with an email address instead.`]}):_?(0,q.jsxs)(q.Fragment,{children:[y&&(0,q.jsxs)(q.Fragment,{children:[y,` signed you in, but it did not confirm your address — so we are checking it is yours. `]}),`We've sent a verification link to `,(0,q.jsx)(`span`,{className:`font-semibold text-foreground`,children:v}),`. Please check your inbox (and spam folder) to verify your account and access your dashboard.`]}):(0,q.jsxs)(q.Fragment,{children:[`We've sent a link to `,(0,q.jsx)(`span`,{className:`font-semibold text-foreground`,children:v}),`. Opening it adds the address to your sign-in, so you can use it to sign in as well as your phone — and you stay signed in here either way. Nothing is waiting on it: you can do this whenever you like.`]})}),(0,q.jsxs)(zn,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[d&&(0,q.jsx)(S.t,{tone:D?`error`:`done`,children:d}),b?(0,q.jsx)(N.t,{variant:`primary`,onClick:()=>i(),className:`w-full py-3 text-[14px] font-semibold`,children:`Sign out`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(N.t,{variant:`primary`,onClick:T,isLoading:s,className:`w-full py-3 text-[14px] font-semibold`,children:`I've verified my email`}),(0,q.jsx)(N.t,{variant:`ghost`,onClick:E,isLoading:l,className:`w-full py-2.5 text-[14px] font-medium`,children:`Resend verification link`}),(0,q.jsx)(N.t,{variant:`ghost`,onClick:()=>_?m(!0):a(`/profile`),className:`w-full py-2 text-[13px] font-medium`,children:`Change my email address`}),!_&&(0,q.jsx)(N.t,{variant:`ghost`,onClick:w,className:`w-full py-2 text-[13px] font-medium`,children:`Skip for now`})]})]})]}),(0,q.jsx)(ie.t,{isOpen:p,title:`Start again with another address?`,message:Mr(v),confirmText:`Yes, start again`,cancelText:`Keep this address`,isProcessing:h,onCancel:()=>m(!1),onConfirm:async()=>{g(!0),await Pr(r.li.currentUser||e)}})]})}var ii={confirmed:{title:`Email confirmed`,body:`Your address is on your account now, and you can sign in with it as well as your phone.`},signInFirst:{title:`Nearly there`,body:`You opened this link in a browser you are not signed in on. Sign in and it finishes by itself — you will not need the link again.`},wrongAccount:{title:`That is a different account`,body:`This link adds an address to another account. Sign out here and sign back in as the person who asked for it — the link is kept, and it finishes by itself once they are in.`},takenElsewhere:{title:`That address is already in use`,body:`Another account here already has it. Give a different address on your profile, or sign in with the account that has this one.`},spent:{title:`That link has expired`,body:`Links can only be opened once, and they do not last for ever. Ask for a new one and it will come straight through.`},failed:{title:`That did not work`,body:`Check your connection and try again. If it keeps happening, ask for a new link.`}},ai=e=>({title:`Email verified`,body:`${e} is confirmed. You can sign in with it now as well as your phone.`,link:`/profile`});function oi(){let{user:e,loading:t,refreshUser:n,signOut:i}=r.Ft(),a=(0,Y.useNavigate)(),[o,s]=(0,K.useState)(null),c=(0,K.useRef)(null),l=(0,K.useRef)(!1);(0,K.useEffect)(()=>{if(t||l.current)return;let r=qr()??Yr();if(!r){s(`spent`),l.current=!0;return}if(c.current=r,!e){Jr(r),s(`signInFirst`);return}l.current=!0;let i=!1;return Qr(r).then(async e=>{i||(e===`confirmed`&&(Zr(),await R.n(r.uid,ai(r.address)),await n().catch(()=>{})),e===`wrongAccount`?Jr(r):e!==`signInFirst`&&Zr(),s(e))}),()=>{i=!0}},[t,e?.uid]);let u=o?ii[o]:null,d=o===`confirmed`;return(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,q.jsx)(Rn,{width:`max-w-[480px]`,className:`text-center`,children:(0,q.jsx)(Bn,{show:o??`working`,children:u?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Vn,{as:`h1`,className:`mb-6 sm:mb-8`,title:u.title,line:u.body}),(0,q.jsxs)(zn,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[o===`signInFirst`?(0,q.jsx)(N.t,{variant:`primary`,onClick:()=>a(`/login?from=${encodeURIComponent(Ur)}`),className:`w-full py-3 text-[14px] font-semibold`,children:`Sign in to finish`}):o===`wrongAccount`?(0,q.jsx)(N.t,{variant:`primary`,onClick:()=>i(),className:`w-full py-3 text-[14px] font-semibold`,children:`Sign out`}):(0,q.jsx)(N.t,{variant:`primary`,onClick:()=>a(e?`/dashboard`:`/`),className:`w-full py-3 text-[14px] font-semibold`,children:d?`Carry on`:`Back to the app`}),o===`takenElsewhere`&&e&&(0,q.jsx)(N.t,{variant:`ghost`,onClick:()=>a(`/profile`),className:`w-full py-2.5 text-[14px] font-medium`,children:`Use a different address`}),o===`spent`&&e&&(0,q.jsx)(N.t,{variant:`ghost`,onClick:()=>a(`/verify`),className:`w-full py-2.5 text-[14px] font-medium`,children:`Send me a new link`}),o===`failed`&&(0,q.jsx)(N.t,{variant:`ghost`,onClick:()=>window.location.reload(),className:`w-full py-2.5 text-[14px] font-medium`,children:`Try again`})]})]}):(0,q.jsxs)(`div`,{"aria-busy":`true`,className:`py-6 flex flex-col items-center gap-4`,children:[(0,q.jsx)(P.t,{}),(0,q.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/70`,children:`Confirming your email…`})]})})})})}var si=`user_phoneclaims`,ci=`That number is already set up on another account. A phone number can only be used once here — use a different one, or take it off the other account first.`;async function li(e){let t=String(e||``).replace(/[^\d+]/g,``);if(!t)return null;let n=globalThis.crypto?.subtle;if(!n)return null;try{let e=await n.digest(`SHA-256`,new TextEncoder().encode(t));return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}catch{return null}}async function ui(e){let t=await li(e);if(!t)return!0;try{return await(0,J.getDoc)((0,J.doc)(r.ui,si,t)),!0}catch(e){return e?.code!==`permission-denied`}}var di=`phoneClaim`;async function fi(e,t){let n=await li(e);if(!n||!t)return!0;try{await(0,J.setDoc)((0,J.doc)(r.ui,si,n),{uid:t,createdAt:Date.now()})}catch(e){return e?.code!==`permission-denied`}try{await(0,J.setDoc)((0,J.doc)(r.ui,`user_profiles`,t),{[di]:n},{merge:!0})}catch{}return!0}async function pi(e,t){let n=String(t??``).trim();if(n){try{await(0,J.deleteDoc)((0,J.doc)(r.ui,si,n))}catch{}if(e)try{await(0,J.setDoc)((0,J.doc)(r.ui,`user_profiles`,e),{[di]:``},{merge:!0})}catch{}}}var mi=r.si(()=>Promise.resolve().then(()=>require(`./PhoneInputField-WYdkNEym.cjs`)));function hi({onDone:e,doneWords:t=`Turn it on`}){let{user:n,refreshUser:i}=r.Ft(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),[l,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(null),g=(0,K.useRef)(null),_=async(e,t)=>{h(await r.Kt(e,`sms2fa`,t))},v=async()=>{if(n){h(null),p(!0);try{if(d(``),!await ui(a.trim())){h({text:ci});return}c(await dr(n,a.trim(),g.current))}catch(e){await _(e,`That code could not be sent. Check the number and try again.`)}finally{p(!1)}}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{ref:g}),m&&(0,q.jsx)(Kn,{problem:m}),s?(0,q.jsxs)(r.nt.form,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2},onSubmit:async t=>{if(t.preventDefault(),!n)return;h(null),p(!0);let r=!$n(n);try{if(await fr(n,s,l.trim()),!await fi(a.trim(),n.uid)){r&&await pr(n).catch(()=>{}),await i(),h({text:ci}),c(``),d(``);return}await i(),e()}catch(e){await _(e,`That code could not be checked. Ask for a new one.`)}finally{p(!1)}},className:`space-y-3`,children:[(0,q.jsxs)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed`,children:[`We texted a code to `,(0,q.jsx)(`span`,{className:`font-bold text-foreground/80`,children:a}),`.`]}),(0,q.jsx)(qn,{value:l,onChange:d,autoFocus:!0}),(0,q.jsxs)(N.t,{type:`submit`,isLoading:f,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,children:[t,` `,(0,q.jsx)(r.At,{className:`ml-2 w-4 h-4 shrink-0`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-center gap-3 text-[13px] font-bold`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:v,disabled:f,className:`text-accent hover:underline disabled:opacity-40 disabled:no-underline cursor-pointer disabled:cursor-default`,children:`Send it again`}),(0,q.jsx)(`span`,{className:`w-[1px] h-3.5 bg-[var(--panel-border)]`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{c(``),d(``),h(null)},className:`text-foreground/50 hover:text-accent transition-colors cursor-pointer`,children:`Use a different number`})]})]}):(0,q.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),await v()},className:`space-y-3`,children:[(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,q.jsx)(mi,{field:{label:`Your phone number`,required:!0,placeholder:`7700 900123`},value:a,onChange:o})}),(0,q.jsxs)(N.t,{type:`submit`,isLoading:f,className:`w-full py-2.5 sm:py-3 text-[15px] font-bold tracking-wide rounded-xl`,children:[`Text me a code `,(0,q.jsx)(u.t,{className:`ml-2 w-4 h-4 shrink-0`})]})]})]})}function gi(){let{user:e,signOut:t}=r.Ft(),n=r.Cn(),i=(0,Y.useNavigate)(),a=n.twoStepOptional;return(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,q.jsxs)(Rn,{width:`max-w-[480px]`,children:[(0,q.jsx)(Vn,{title:a?`Make your account safer`:`One more step`,line:a?`Give us a number and we will text you a code when you sign in, as well as asking for your password. You can do this later if you would rather.`:`This app asks for a code by text as well as your password. Give us a number once, and from now on we will text you a code when you sign in.`}),(0,q.jsx)(zn,{children:(0,q.jsx)(hi,{onDone:()=>i(`/dashboard`,{replace:!0}),doneWords:`Turn it on`})}),a&&(0,q.jsx)(zn,{children:(0,q.jsx)(N.t,{variant:`secondary`,onClick:()=>{e?.uid&&ir(e.uid),i(`/dashboard`,{replace:!0})},className:`mt-3 w-full py-2.5 text-[14px] font-semibold`,children:`Not now`})}),(0,q.jsx)(Hn,{children:(0,q.jsx)(N.t,{variant:`ghost`,onClick:()=>t(),className:`w-full py-2 text-[13px] font-semibold`,children:`Sign out`})})]})})}var _i=r.si(()=>Promise.resolve().then(()=>require(`./PhoneInputField-WYdkNEym.cjs`))),vi=r.si(()=>Promise.resolve().then(()=>require(`./AddressField-CI8PP5ow.cjs`))),yi=`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`;function bi({field:e,value:t}){return(0,q.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,q.jsxs)(`label`,{className:`${yi} flex items-center gap-1.5`,children:[e.label,(0,q.jsx)(T.t,{className:`w-3 h-3 text-foreground/35 shrink-0`})]}),(0,q.jsx)(`div`,{"aria-label":e.label,"aria-readonly":`true`,className:`flex items-center h-12 w-full px-4 text-[15px] text-foreground/55 glass-panel opacity-70 cursor-not-allowed truncate`,style:{borderRadius:`var(--input-radius, 0.75rem)`},children:t}),(0,q.jsx)(`p`,{className:`text-[11px] text-foreground/40 mt-1.5 px-2 font-medium`,children:`Given when you registered, and fixed from then on.`})]})}function xi({fields:e,values:t,errors:n={},profile:i=null,disabled:a=!1,onChange:o,onCommit:s}){let c=(e,t)=>{for(let[n,r]of Object.entries(F.r(e,t)))o(n,r)},l=e=>!e.currentTarget.contains(e.relatedTarget),u=e=>s?.(e);return e.length?(0,q.jsx)(q.Fragment,{children:e.map(e=>{let s=t[e.key],d=n[e.key];return L.m(i,e)?(0,q.jsx)(bi,{field:e,value:L.a(i,e)},e.key):e.type===`tel`?(0,q.jsx)(`div`,{className:`w-full`,onBlur:t=>{l(t)&&u(e.key)},children:(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,q.jsx)(_i,{field:e,value:String(s||``),onChange:t=>o(e.key,t)})})},e.key):e.type===`address`?(0,q.jsx)(`div`,{className:`w-full`,onBlur:t=>{l(t)&&u(e.key)},children:(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,q.jsx)(vi,{id:`reg-${e.key}`,label:e.label,required:e.required,disabled:a,placeholder:e.placeholder,error:d,value:F.i(e.key,t),onChange:t=>c(e.key,t)})})},e.key):e.type===`textarea`?(0,q.jsx)(g.v,{id:`reg-${e.key}`,label:e.label,"aria-label":e.label,disabled:a,placeholder:e.placeholder,value:String(s||``),onChange:t=>o(e.key,t.target.value),onBlur:()=>u(e.key),error:d},e.key):e.type===`select`?(0,q.jsxs)(`div`,{className:`w-full`,children:[(0,q.jsx)(r.Z,{label:e.label,ariaLabel:e.label,direction:`auto`,disabled:a,value:String(s||``),options:[{value:``,label:(0,q.jsx)(`span`,{className:`text-foreground/40`,children:`Select an option...`})},...(e.options||[]).map(t=>({value:t,label:L.c(e,t)}))],onChange:t=>{o(e.key,t),u(e.key)}}),d&&(0,q.jsx)(`p`,{className:`text-xs text-red-500 font-medium mt-1`,children:d})]},e.key):e.type===`checkbox`?(0,q.jsxs)(`div`,{className:`w-full`,children:[(0,q.jsxs)(`label`,{className:`flex items-center gap-3 w-full cursor-pointer group py-2`,children:[(0,q.jsxs)(`div`,{className:`relative flex items-center justify-center w-5 h-5 rounded border border-foreground/20 bg-background/50 group-hover:border-accent transition-colors shrink-0`,children:[(0,q.jsx)(`input`,{type:`checkbox`,"aria-label":e.label,disabled:a,checked:s===!0,onChange:t=>{o(e.key,t.target.checked),u(e.key)},className:`absolute opacity-0 w-full h-full cursor-pointer`}),s===!0&&(0,q.jsx)(`span`,{className:`w-2.5 h-2.5 bg-accent rounded-sm shrink-0`})]}),(0,q.jsx)(`span`,{className:`text-[14px] font-medium text-foreground/80 leading-snug group-hover:text-foreground transition-colors`,children:e.label})]}),d&&(0,q.jsx)(`p`,{className:`text-xs text-red-500 font-medium`,children:d})]},e.key):(0,q.jsx)(g.y,{label:e.label,"aria-label":e.label,type:e.type===`number`?`number`:e.type,disabled:a,placeholder:e.placeholder,error:d,className:`max-sm:h-11`,value:String(s??``),onChange:t=>o(e.key,t.target.value),onBlur:()=>u(e.key)},e.key)})}):null}var Si=e=>/^[^@\s]+@[^@\s.]+\.[^@\s]+$/.test(e.trim());function Ci(){let{user:e,userRole:t,profile:n,signOut:i,refreshUser:a}=r.Ft(),s=r.Cn(),c=(0,Y.useNavigate)(),l=s.finishRegistration,d=o.wn(t)?[]:L.l(n,l),[f,p]=(0,K.useState)(()=>L.o(d,n)),[m,h]=(0,K.useState)({}),[_,v]=(0,K.useState)(``),[y,b]=(0,K.useState)(!1),[x,C]=(0,K.useState)(!1);(0,K.useEffect)(()=>{p(L.o(d,n))},[d.map(e=>e.key).join(`|`)]);let w=L._(n),T=w.includes(`name`),E=w.includes(`email`),[D,O]=(0,K.useState)(``),[k,A]=(0,K.useState)(``),[j,M]=(0,K.useState)(``),[P,ee]=(0,K.useState)(``),F=r.in(n),te=w.length+d.filter(e=>!L.p(n,e)).length,I=w.length+L.g(d,n).length>0?te===1?`There is one thing we still need before you go on.`:`There are a few things we still need before you go on.`:te===0?`Just check these over before you go on.`:te===1?`One question before you go on — it is not required.`:`A few questions before you go on — none of them is required.`,ne=(e=!1)=>c(e?`/verify`:L.h(n)?`/dashboard?${L.n}=1`:`/dashboard`,{replace:!0}),R=async t=>{if(t.preventDefault(),!e)return;v(``);let i=T&&!D.trim()?`Please tell us what to call you.`:``,o=E?k.trim()?Si(k)?``:`That does not look like an email address.`:`Please give us an email address.`:``;M(i),ee(o);let s=L.i(d,f);if(h(s),i||o||Object.keys(s).length){v(`There is something to check below.`);return}b(!0);try{let t={};T&&(t.displayName=D.trim()),E&&(t.email=k.trim()),await(0,J.setDoc)((0,J.doc)(r.ui,`user_profiles`,e.uid),{...L.s(d,f,n),...t,...L.d()},{merge:!0}),T&&r.li.currentUser&&(0,ue.updateProfile)(r.li.currentUser,{displayName:D.trim()}).then(()=>a()).catch(()=>{});let i=!1;E&&r.li.currentUser&&(i=await Kr(k.trim(),r.li.currentUser.uid).then(()=>!0).catch(e=>(console.warn(`The confirmation link could not be sent to the new address.`,e),!0))),ne(i)}catch(e){v(e?.code===`permission-denied`?`That could not be saved. Check that your email address is verified and that your account is still switched on.`:`That could not be saved. Check your connection and try again.`)}finally{b(!1)}},z=async()=>{e&&(C(!0),L.C(e.uid),await(0,J.setDoc)((0,J.doc)(r.ui,`user_profiles`,e.uid),L.d(),{merge:!0}).catch(()=>{}),ne())},re=y||x;return(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 mb-8 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,q.jsxs)(Rn,{width:`max-w-[500px]`,children:[(0,q.jsx)(Vn,{title:(0,q.jsx)(wi,{request:F}),line:!s.loading&&(0,q.jsxs)(q.Fragment,{children:[I,F&&` Your registration goes to an admin for approval. Until then everything works as usual.`]})}),_&&(0,q.jsx)(S.t,{className:`mb-5`,children:_}),s.loading?(0,q.jsx)(Gn,{}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:R,noValidate:!0,children:[(T||E||d.length>0)&&(0,q.jsxs)(zn,{className:`flex flex-col gap-5`,children:[T&&(0,q.jsx)(g.y,{name:`displayName`,label:`Your name`,type:`text`,placeholder:`Alex Taylor`,className:`max-sm:h-11`,value:D,onChange:e=>{O(e.target.value),j&&M(``)},error:j,autoFocus:!0,required:!0}),E&&(0,q.jsx)(g.y,{name:`email`,label:`Your email`,type:`email`,placeholder:`name@example.com`,className:`max-sm:h-11`,value:k,onChange:e=>{A(e.target.value),P&&ee(``)},error:P,autoFocus:!T,required:!0}),(0,q.jsx)(xi,{fields:d,values:f,errors:m,profile:n,disabled:re,onChange:(e,t)=>{p(n=>({...n,[e]:t})),h(t=>t[e]?{...t,[e]:``}:t)}})]}),(0,q.jsx)(zn,{className:`pt-1`,children:(0,q.jsxs)(N.t,{type:`submit`,isLoading:y,disabled:x,className:`w-full py-3 text-[15px] font-semibold`,children:[`Finish registration `,(0,q.jsx)(u.t,{className:`w-4 h-4 shrink-0`})]})})]}),l.skippable&&w.length===0&&(0,q.jsx)(zn,{children:(0,q.jsx)(N.t,{variant:`secondary`,onClick:z,isLoading:x,disabled:y,className:`mt-3 w-full py-2.5 text-[14px] font-semibold`,children:`Skip for now`})})]}),(0,q.jsx)(Hn,{children:(0,q.jsx)(N.t,{variant:`ghost`,onClick:()=>i(),className:`w-full py-2 text-[13px] font-semibold`,children:`Sign out`})})]})})}function wi({request:e}){return e?(0,q.jsx)(Ti,{request:e}):(0,q.jsx)(q.Fragment,{children:L.u(null,``)})}function Ti({request:e}){let t=ne.l();return(0,q.jsx)(q.Fragment,{children:L.u(e,r.qr(e.role,t))})}var Ei=e=>({creatorName:e?.displayName||e?.email?.split(`@`)[0]||``,creatorAvatar:e?.photoURL||``}),Di=e=>{let{creatorName:t,creatorAvatar:n}=Ei(e);return{editedUid:e?.uid||``,editedName:t,editedAvatar:n,editedAt:Date.now()}},Oi=(e,t,n)=>{let r={},i=String(e.creatorEmail||``);return e.uid===t.uid&&!e.sourceId&&(!i||i===t.email||n.was&&e.creatorName===n.was)&&(n.name&&e.creatorName!==n.name&&(r.creatorName=n.name),n.avatar!==void 0&&(e.creatorAvatar||``)!==n.avatar&&(r.creatorAvatar=n.avatar)),e.editedUid===t.uid&&(n.name&&n.was&&e.editedName===n.was&&(r.editedName=n.name),n.avatar!==void 0&&t.name&&e.editedName===t.name&&(e.editedAvatar||``)!==n.avatar&&(r.editedAvatar=n.avatar)),Object.keys(r).length?r:null},ki=(e,t)=>{if(e?.creatorName)return{name:e.creatorName,avatar:e.creatorAvatar||``};if(e?.uid&&t?.uid&&e.uid===t.uid){let e=Ei(t);return e.creatorName?{name:e.creatorName,avatar:e.creatorAvatar}:null}return null};function Ai(){let{user:e,profile:t,refreshUser:n}=r.Ft(),i=r.Cn(),[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(!1),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)(!1),p=i.on.sms2fa;if(i.loading||!sr(e,p))return null;let m=$n(e),h=er(e);return(0,q.jsxs)(`div`,{className:`glass-panel w-full p-5 sm:p-8 rounded-3xl border border-[var(--panel-border)] shadow-2xl`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3 sm:gap-4`,children:[(0,q.jsx)(`div`,{className:`w-9 h-9 shrink-0 rounded-xl glass-panel border border-[var(--panel-border)] flex items-center justify-center`,children:(0,q.jsx)(O.t,{className:`w-[18px] h-[18px] text-accent`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(`h3`,{className:`text-[16px] font-bold text-foreground mb-1`,children:`Two-step sign-in`}),(0,q.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium leading-relaxed`,children:m?`We text you a code when you sign in, as well as asking for your password.`:p?`This app asks for a code by text as well as your password. Add the number that should get it.`:`Add a phone number and we will text you a code when you sign in, as well as asking for your password.`})]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[l&&(0,q.jsx)(Kn,{problem:l}),d&&!l&&(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},className:`mb-4 p-3 rounded-xl border border-accent/20 bg-accent/10 text-accent flex items-center gap-2`,children:[(0,q.jsx)(r.At,{className:`w-4 h-4 shrink-0`}),(0,q.jsx)(`span`,{className:`text-[13.5px] font-semibold tracking-wide`,children:`Two-step sign-in is on. We will text that number next time you sign in.`})]}),m?(0,q.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-3 justify-between rounded-2xl border border-[var(--panel-border)]/60 p-3.5`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`p`,{className:`text-[11px] font-bold uppercase tracking-[0.2em] text-foreground/40 mb-1`,children:`Your number`}),(0,q.jsx)(`p`,{className:`text-[15px] font-bold text-foreground truncate`,children:h||`Set up`})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`inline-flex items-center justify-center gap-1.5 h-9 px-3 rounded-xl border border-[var(--panel-border)] text-[13px] font-bold text-foreground/60 hover:text-red-500 hover:border-red-500/40 transition-colors cursor-pointer shrink-0`,children:[(0,q.jsx)(A.t,{className:`w-3.5 h-3.5 shrink-0`}),`Take it off`]})]}):(0,q.jsx)(hi,{onDone:()=>{f(!0),u(null)}})]}),(0,q.jsx)(ie.t,{isOpen:a,title:`Take two-step sign-in off?`,message:p?`This app asks for a texted code, so you will be asked for a number again straight away. That is how you change the number you gave.`:`You will sign in with your password alone from then on.`,confirmText:`Take it off`,isProcessing:s,onConfirm:async()=>{if(e){u(null),c(!0);try{await pr(e),await pi(e.uid,t?.[di]),await n(),f(!1),o(!1)}catch(e){u(await r.Kt(e,`sms2fa`,`That could not be taken off. Try again.`)),o(!1)}finally{c(!1)}}},onCancel:()=>o(!1)})]})}function ji(){let{user:e,profile:t}=r.Ft(),n=L.l(t,r.Cn().finishRegistration),[i,a]=(0,K.useState)(()=>L.o(n,t)),[o,s]=(0,K.useState)({}),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),m=(0,K.useRef)(i),h=e=>{m.current=e,a(e)};if((0,K.useEffect)(()=>{h(L.o(n,t))},[n.map(e=>`${e.key}:${String(t?.[e.key]??``)}`).join(`|`)]),!n.length)return null;let g=e=>Object.entries(e).every(([e,n])=>(t?.[e]??``)===n);return(0,q.jsxs)(`div`,{className:`glass-panel w-full p-5 sm:p-8 rounded-3xl border border-[var(--panel-border)] shadow-2xl`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3 sm:gap-4`,children:[(0,q.jsx)(`div`,{className:`w-9 h-9 shrink-0 rounded-xl glass-panel border border-[var(--panel-border)] flex items-center justify-center`,children:(0,q.jsx)(x.n,{className:`w-[18px] h-[18px] text-accent`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-1`,children:[(0,q.jsx)(`h3`,{className:`text-[16px] font-bold text-foreground`,children:`Your details`}),(0,q.jsx)(r.p,{saving:u,savedAt:f})]}),(0,q.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium leading-relaxed`,children:`Change what you like — each one saves itself. Anything with a padlock was fixed when you gave it.`})]})]}),(0,q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-4`,children:[c&&(0,q.jsx)(S.t,{children:c}),(0,q.jsx)(xi,{fields:n,values:i,errors:o,profile:t,onChange:(e,t)=>{h({...m.current,[e]:t}),s(t=>t[e]?{...t,[e]:``}:t)},onCommit:async i=>{let a=n.find(e=>e.key===i);if(!e||!a||L.m(t,a))return;let o=L.r(a,m.current[i]);if(s(e=>e[i]===o?e:{...e,[i]:o}),o)return;let c=L.s([a],m.current,t);if(!(!Object.keys(c).length||g(c))){l(``),d(!0);try{await(0,J.setDoc)((0,J.doc)(r.ui,`user_profiles`,e.uid),c,{merge:!0}),p(Date.now())}catch(e){l(e?.code===`permission-denied`?`That could not be saved. Check that your account is still switched on.`:`That could not be saved. Check your connection and try again.`)}finally{d(!1)}}}})]})]})}var Mi=20,Ni=()=>{try{let e=localStorage.getItem(`fbos_nav_tabs`);if(!e)return null;let t=JSON.parse(e);return t&&typeof t==`object`?Object.entries(t):null}catch{return null}},Pi=async()=>(await(0,J.getDocs)((0,J.collection)(r.ui,`sys_tabs`))).docs.map(e=>[e.id,e.data()]);function Fi(){let{user:e,profile:t,refreshUser:a,isInternal:s}=r.Ft(),[c,l]=(0,K.useState)(e?.displayName||``),[u,d]=(0,K.useState)(e?.email||t?.email||``),[f,p]=(0,K.useState)(e?.photoURL||``),[m,h]=(0,K.useState)(``),[_,v]=(0,K.useState)(``),[y,b]=(0,K.useState)(``),[x,C]=(0,K.useState)(!1),[T,E]=(0,K.useState)(!1),[O,k]=(0,K.useState)(null),[j,M]=(0,K.useState)(``),[N,P]=(0,K.useState)(!1),[F,te]=(0,K.useState)(null),[I,L]=(0,K.useState)(``),ne=K.default.useRef(null),[R,z]=(0,K.useState)(!1),[re,ie]=(0,K.useState)(null),[B,V]=(0,K.useState)(``),[ae,oe]=(0,K.useState)(!1),[H,se]=(0,K.useState)(null),[U,ce]=(0,K.useState)(``);K.default.useEffect(()=>{l(e?.displayName||t?.displayName||``)},[e?.uid,e?.displayName,t?.displayName]),K.default.useEffect(()=>{d(e?.email||t?.email||``)},[e?.uid,e?.email,t?.email]),K.default.useEffect(()=>{p(e?.photoURL||``)},[e?.uid,e?.photoURL]);let W=async t=>{if(e)try{if(!s)return;let n=[`mem_files`,`admin_files`],i=Ni()??await Pi();for(let[e,t]of i){let r=(t.tabName||e).toLowerCase().replace(/[^a-z0-9]+/g,`_`),i=o.An(t.pageType),a=o.Pn(t)===`shared`;a&&i===`internal`&&n.push(`mem_${r}_records`),a&&i===`admin`&&n.push(`admin_${r}_records`)}n.length>Mi&&(n.length=Mi);let a={uid:e.uid,email:e.email,name:e.displayName};for(let i of n)try{let[n,o]=await Promise.all([(0,J.getDocs)((0,J.query)((0,J.collection)(r.ui,i),(0,J.where)(`uid`,`==`,e.uid))),(0,J.getDocs)((0,J.query)((0,J.collection)(r.ui,i),(0,J.where)(`editedUid`,`==`,e.uid)))]),s=new Map;for(let e of[...n.docs,...o.docs]){let n=s.has(e.id)?null:Oi(e.data(),a,t);n&&s.set(e.id,{ref:e.ref,fields:n})}let c=[...s.values()];for(let e=0;e<c.length;e+=400){let t=(0,J.writeBatch)(r.ui);c.slice(e,e+400).forEach(e=>t.update(e.ref,e.fields)),await t.commit()}}catch{}}catch(e){console.error(`Error carrying the name or photo onto records:`,e)}},le=async t=>{if(!e)return;let n=await ee._(t,{maxSide:512});if(n.size>2*1024*1024){M(`Over 2MB`);return}E(!0),C(!1),M(``);try{let t=`user_avatars/${e.uid}/file.png`,i=(0,de.ref)(r.fi,t);await(0,de.uploadBytes)(i,n,r.W(t,{ownerId:e.uid}));let o=await(0,de.getDownloadURL)(i);p(o);let s=(0,J.doc)(r.ui,`user_profiles`,e.uid);await Promise.all([(0,ue.updateProfile)(e,{photoURL:o}),(0,J.updateDoc)(s,{avatar:o}),W({avatar:o})]),await a(),k(Date.now())}catch(e){console.error(e),M(`Not saved`)}finally{E(!1)}},G=e=>{let t=e.target.files?.[0];t&&le(t)},{over:Y,dropProps:fe}=r.A({accept:`image/*`,disabled:T,onFiles:([e])=>le(e),onReject:()=>M(`Not a picture`)}),pe=async()=>{if(e){E(!0),C(!1),M(``);try{let t=(0,de.ref)(r.fi,`user_avatars/${e.uid}/file.png`);p(``),E(!1);let n=(0,J.doc)(r.ui,`user_profiles`,e.uid);await Promise.all([(0,de.deleteObject)(t).catch(e=>console.error(e)),(0,ue.updateProfile)(e,{photoURL:``}),(0,J.updateDoc)(n,{avatar:``}),W({avatar:``})]),await a(),k(Date.now())}catch(e){console.error(e),M(`Not removed`),E(!1)}}},me=()=>e?.displayName||t?.displayName||``,he=async()=>{if(!e)return;let t=c.trim();if(!t){l(me());return}if(t!==c&&l(t),t===me()||t===ne.current)return;ne.current=t;let n=me();P(!0),L(``);try{await(0,ue.updateProfile)(e,{displayName:t}),await(0,J.updateDoc)((0,J.doc)(r.ui,`user_profiles`,e.uid),{displayName:t}).catch(()=>{}),await a(),te(Date.now()),W({name:t,was:n})}catch(e){console.error(e),ne.current=null,L(`Not saved`)}finally{P(!1)}},ge=u.trim(),_e=!!ge&&ge!==(e?.email||``),X=async()=>{if(!e||!_e||ae)return;let t=ge;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){se({text:`That does not look like an email address yet.`,tone:`error`});return}oe(!0),se(null);try{if(await(0,J.updateDoc)((0,J.doc)(r.ui,`user_profiles`,e.uid),{email:t}).catch(()=>{}),!e.email)await Kr(t,e.uid),se({text:`We have emailed a link to ${t} — open it and the address is on your sign-in, so you can use it to sign in as well as your phone. You stay signed in here either way.`,tone:`done`});else{let n=await(0,ue.fetchSignInMethodsForEmail)(r.li,t).catch(()=>[]);if(n&&n.length>0)throw Object.assign(Error(`email-already-in-use`),{code:`auth/email-already-in-use`});await(0,ue.verifyBeforeUpdateEmail)(e,t),se({text:`A link is on its way to your new address. Opening it moves your sign-in to it — and because that changes the account itself, you will be signed out here and will need to sign in again with the new address.`,tone:`done`})}ce(t),await a()}catch(e){console.error(e),e?.code===`auth/requires-recent-login`?se({text:`For your safety, sign out and sign back in, then change your address here.`,tone:`error`}):e?.code===`auth/email-already-in-use`?se({text:`That email address already belongs to another account here. Use a different one, or sign in with the account that has it.`,tone:`error`}):se({text:(await r.Kt(e,`password`,`The link could not be sent. Check your connection and try again.`,{email:t})).text,tone:`error`})}finally{oe(!1)}},ve=async()=>{if(!e||R||!m||!_||Or(m))return;let t=kr(m,_);if(t){b(t);return}z(!0),V(``);try{await(0,ue.updatePassword)(e,m),h(``),v(``),b(``),ie(Date.now())}catch(e){console.error(e),V(e?.code===`auth/requires-recent-login`?`For your safety, sign out and sign back in, then set your new password here. It has not been changed.`:(await r.Kt(e,`password`,`Your password could not be changed. Check your connection and try again.`)).text)}finally{z(!1)}},ye=e=>{e.currentTarget.contains(e.relatedTarget)||ve()},be=e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())};return(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-5 sm:mb-8`,children:[(0,q.jsx)(n.t,{children:`Profile Settings`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,q.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/profile`]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 flex-1 fbos-fade-in pb-20`,children:[(0,q.jsx)(`div`,{className:`flex justify-start`,children:(0,q.jsx)(i.t,{})}),(0,q.jsx)(`div`,{className:`w-full flex flex-col`,children:(0,q.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] fbos-tab-fill`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-4 sm:gap-5 pb-6 border-b border-[var(--panel-border)]/50`,children:[(0,q.jsxs)(`div`,{...fe,className:`relative shrink-0 group/avatar rounded-full transition-shadow ${Y?`ring-2 ring-accent ring-offset-2 ring-offset-background`:``}`,children:[(0,q.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:[T&&(0,q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-10`,children:(0,q.jsx)(w.r,{className:`w-6 h-6 text-accent animate-spin`})}),f&&!x?(0,q.jsx)(r.O,{src:f,alt:`Avatar`,className:`w-full h-full`,onError:()=>C(!0)}):(0,q.jsx)(xt,{className:`w-7 h-7 sm:w-8 sm:h-8 text-accent`})]}),!T&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{title:f?`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,q.jsx)(Ve,{className:`w-4 h-4 text-foreground`}),(0,q.jsx)(`input`,{type:`file`,accept:`image/*`,"aria-label":`Upload photo`,onChange:G,className:`hidden`})]}),f&&(0,q.jsx)(`button`,{type:`button`,onClick:pe,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,q.jsx)(A.t,{className:`w-3 h-3`})})]})]}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(`h3`,{className:`font-bold text-lg sm:text-xl text-foreground mb-1 truncate`,children:c||`User`}),(0,q.jsx)(`p`,{className:`text-[13px] text-foreground/40 mt-1 font-medium break-words`,children:e?.email})]}),(0,q.jsx)(r.p,{saving:T,savedAt:O,error:j})]}),(0,q.jsxs)(`div`,{className:`space-y-6`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`h3`,{className:`text-[16px] font-bold text-foreground`,children:`Account Details`}),(0,q.jsx)(r.p,{saving:N,savedAt:F,error:I})]}),(0,q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,q.jsx)(g.y,{name:`name`,value:c,onChange:e=>l(e.target.value),onBlur:he,onKeyDown:be,label:`Display Name`,placeholder:`John Doe`}),(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(g.y,{name:`email`,type:`email`,value:u,onChange:e=>{d(e.target.value),H?.tone===`error`&&se(null)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),X())},label:`Email Address`,placeholder:`name@example.com`}),(0,q.jsxs)(`div`,{className:`mt-1.5 px-2 flex items-center justify-between gap-3 min-h-8 sm:min-h-9`,children:[(0,q.jsx)(`p`,{className:`text-[11px] text-foreground/40 font-medium leading-snug`,children:_e?`Nothing changes until you open the link we email to it.`:`A new address is confirmed by a link we email to it.`}),_e&&(0,q.jsx)(r.o,{icon:D.t,onClick:()=>void X(),busy:ae,children:U===ge||!e?.email&&ge===t?.email?`Send again`:`Send link`})]}),H&&(0,q.jsx)(S.t,{tone:H.tone,className:`mt-2`,children:H.text})]})]})]}),(0,q.jsxs)(`div`,{className:`pt-6 border-t border-[var(--panel-border)]/50`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-4`,children:[(0,q.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground`,children:`Change Password`}),(0,q.jsx)(r.p,{saving:R,savedAt:re,error:B?`Not changed`:``})]}),(0,q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,onBlur:ye,children:[(0,q.jsx)(g.y,{name:`password`,type:`password`,label:`New Password`,autoComplete:`new-password`,value:m,onChange:e=>{h(e.target.value),y&&e.target.value===_&&b(``),B&&V(``)},onKeyDown:be,placeholder:`At least 8 characters`}),(0,q.jsx)(g.y,{name:`confirmPassword`,type:`password`,label:`Confirm New Password`,autoComplete:`new-password`,value:_,onChange:e=>{v(e.target.value),y&&b(``),B&&V(``)},onBlur:()=>b(_?kr(m,_):``),onKeyDown:be,error:y,placeholder:`Type it a second time`})]}),m&&(0,q.jsx)(Ar,{value:m,className:`mt-3`}),B&&(0,q.jsx)(S.t,{className:`mt-3`,children:B})]})]})}),(0,q.jsx)(Ai,{}),(0,q.jsx)(ji,{})]})]})}function Ii(){let[e,t]=(0,K.useState)(!1),[n,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(0),[s,c]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let e;return a>0&&(e=setInterval(()=>o(e=>e-1),1e3)),()=>clearInterval(e)},[a]),(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16 mt-6 md:mt-0 md:mb-0 md:pt-8 md:pb-32`,children:(0,q.jsxs)(Rn,{width:`max-w-[480px]`,className:`text-center`,children:[(0,q.jsx)(Vn,{title:`Reset Password`,line:`Enter your email to receive a recovery link.`}),n&&(0,q.jsx)(S.t,{tone:`done`,className:`mb-5 max-w-[360px] mx-auto`,children:n}),(0,q.jsx)(zn,{children:(0,q.jsxs)(`form`,{className:`flex flex-col gap-5 text-left max-w-[360px] mx-auto`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let n=new FormData(e.currentTarget).get(`email`);try{await(0,ue.sendPasswordResetEmail)(r.li,n)}catch(e){console.error(e)}finally{i(`If an account exists, a reset link has been sent. Check your inbox and spam folder.`);let e=s+1;c(e),o(e===1?60:120),t(!1)}},children:[(0,q.jsx)(g.y,{name:`email`,label:`Work Email`,type:`email`,placeholder:`name@company.com`,required:!0}),(0,q.jsx)(`div`,{className:`pt-1`,children:(0,q.jsx)(N.t,{type:`submit`,className:`w-full py-3 text-[14px] font-semibold ${a>0?`opacity-60 shadow-none cursor-not-allowed pointer-events-none`:``}`,isLoading:e,disabled:a>0,children:a>0?`Resend link in ${(e=>`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`)(a)}`:s>0?`Resend reset password link`:`Send Reset Link`})})]})}),(0,q.jsx)(Hn,{children:(0,q.jsxs)(Y.Link,{to:`/login`,className:`inline-flex items-center gap-2 text-[14px] text-foreground/60 font-medium hover:text-accent transition-colors`,children:[(0,q.jsx)(l.t,{className:`w-4 h-4`}),`Back to Sign In`]})})]})})}var Li=new Set,Ri=new Set;function zi(){let{pathname:e,search:t}=(0,Y.useLocation)();return(0,K.useEffect)(()=>{if(e===`/payment-complete`)return;let n=new URLSearchParams(t),i=e.startsWith(`/book/`);n.get(`booking_back`)===`1`&&!i&&g.s().then(e=>{!e||Ri.has(e.pending.sessionId)||(Ri.add(e.pending.sessionId),k.n(e.outcome===`letGo`?`${g.i.letGo} Pick a time again whenever you are ready.`:g.i[e.outcome],{for:7e3}))}).catch(()=>{});let a=n.get(`session_id`)||``;!a.startsWith(`cs_`)||Li.has(a)||(Li.add(a),r.An(a).then(async e=>{let{booked:t,held:n}=await g.o(a,e);if(!t||i)return;let r=e.receipt&&e.customerEmail?` A receipt is on its way to ${e.customerEmail}.`:``;k.n(e.paid?n?`Paid — ${t.when} is held for you while it is confirmed.${r}`:`${g.a}${r}`:`Thank you — ${t.when} is held for you while your payment clears.`,{for:9e3})}).catch(()=>{}))},[e,t]),null}var Bi=`public_copies`,Vi=e=>Array.isArray(e)?e.map(e=>String(e??``)).filter(Boolean).sort():[];function Hi(e){let t=e&&typeof e.copies==`object`&&e.copies?e.copies:null;if(!t)return{};let n={};for(let[e,r]of Object.entries(t))/^[a-z][a-z0-9_]*$/.test(e)&&(n[e]={leaveOut:Vi(r?.leaveOut)});return n}function Ui(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t[r];e&&e.leaveOut.join(`
|
|
2
2
|
`)===i.leaveOut.join(`
|
|
3
|
-
`)||(n[r]=i)}return n}function
|
|
4
|
-
`)}function
|
|
5
|
-
`)}var ra={sides:!1,top:!1},ia=4,aa=8,oa=24,sa=`button, input, select, textarea`,ca=(e,t,n)=>{for(let r=e instanceof Element?e:e.parentElement;r&&r!==t;r=r.parentElement){if(r.getAttribute(`aria-hidden`)===`true`||getComputedStyle(r).position===`fixed`)return!1;let e=r.getBoundingClientRect();if(e.width>=1&&(e.left<n.left-1||e.right>n.right+1))return!1}return!0};function la(e){let t={...ra},n=e.getBoundingClientRect();if(n.width<1)return t;let r=(r,i)=>{if(r.width<1||r.height<1||r.left<n.left-1||r.right>n.right+1)return;let a=r.left-n.left<ia||n.right-r.right<ia,o=r.top>=n.top-1&&r.top-n.top<aa;!(a&&!t.sides)&&!(o&&!t.top)||ca(i,e,n)&&(a&&(t.sides=!0),o&&(t.top=!0))},i=e.ownerDocument,a=i.createRange();if(typeof a.getBoundingClientRect==`function`){let n=i.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=n.nextNode();e;e=n.nextNode())if(e.nodeValue?.trim()&&(a.selectNodeContents(e),r(a.getBoundingClientRect(),e),t.sides&&t.top))return t}for(let n of e.querySelectorAll(sa))if(r(n.getBoundingClientRect(),n),t.sides&&t.top)return t;if(!t.top)for(let r of e.querySelectorAll(`img`)){let i=r.getBoundingClientRect();if(!(i.width<1||i.height<1)&&!(i.top<n.top-1||i.top-n.top>=oa)&&!(i.left<=n.left+1&&i.right>=n.right-1)&&!(!ca(r,e,n)||ga(r,e,n))){t.top=!0;break}}if(!t.sides)for(let r of e.querySelectorAll(`div, section, article, aside, ul, ol, li, a, label`)){if(!da(r))continue;let i=r.getBoundingClientRect();if(!(i.width<1||i.height<1||i.width>=n.width-1&&!ua(r))&&!(i.left<n.left-1||i.right>n.right+1)&&!(i.left-n.left>=ia&&n.right-i.right>=ia)&&ca(r,e,n)){t.sides=!0;break}}return t}var ua=e=>{let t=getComputedStyle(e),n=e.style;return(parseFloat(t.borderTopLeftRadius)||parseFloat(t.borderRadius)||parseFloat(n?.borderTopLeftRadius||n?.borderRadius||``)||0)>0},da=e=>{let t=getComputedStyle(e);return(parseFloat(t.borderLeftWidth||t.borderWidth)||0)>0&&!ha(t.borderLeftColor||t.borderColor)?!0:ua(e)&&!ha(t.backgroundColor)},fa=28,pa=200,ma=72,ha=e=>!e||e===`transparent`||/^rgba\([^)]*,\s*0\s*\)$/.test(e),ga=(e,t,n)=>{let r=t.ownerDocument,i=[r.body,r.documentElement].map(e=>getComputedStyle(e).backgroundColor);for(let r=e instanceof Element?e:e.parentElement;r&&r!==t;r=r.parentElement){let e=r.getBoundingClientRect();if(e.left>n.left+1||e.right<n.right-1||e.height>=n.height*.9)continue;let t=getComputedStyle(r);if(t.backgroundImage&&t.backgroundImage!==`none`||!ha(t.backgroundColor)&&!i.includes(t.backgroundColor))return!0}return!1};function _a(e){let t=e.getBoundingClientRect();if(t.width<1)return 0;let n=e.ownerDocument,r=n.createRange();if(typeof r.getBoundingClientRect!=`function`)return 0;let i=1/0,a=null,o=e=>e.width>=1&&e.height>=1&&e.left>=t.left-1&&e.right<=t.right+1&&e.top>=t.top-1&&e.top-t.top<pa,s=n.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let n=s.nextNode();n;n=s.nextNode()){if(!n.nodeValue?.trim()||!n.parentElement)continue;r.selectNodeContents(n);let s=r.getBoundingClientRect();if(!(!o(s)||!ca(n,e,t))&&(i=Math.min(i,s.top-t.top),!a)){let e=parseFloat(getComputedStyle(n.parentElement).fontSize)||0;e>=fa&&(a={size:e,at:n})}}if(!a||ga(a.at,e,t))return 0;for(let n of e.querySelectorAll(sa)){let r=n.getBoundingClientRect();o(r)&&ca(n,e,t)&&(i=Math.min(i,r.top-t.top))}let c=Math.min(ma,Math.round(a.size));return Math.max(0,Math.round(c-Math.max(0,i)))}var va={...ra,room:0},ya=[300,1e3,2500];function ba(e,t){let[n,r]=(0,W.useState)({page:t,given:va});return(0,W.useEffect)(()=>{let n=e.current;if(!n||typeof window>`u`)return;let i=va,a=!1,o,s=()=>{let e=la(n),o={sides:i.sides||e.sides,top:i.top||e.top,room:Math.max(i.room,_a(n))};(o.sides!==i.sides||o.top!==i.top||o.room!==i.room)&&(i=o,r({page:t,given:i})),a&&i.sides&&i.top&&p()},c=()=>{clearTimeout(o),o=setTimeout(s,200)},l=requestAnimationFrame(s),u=ya.map((e,t)=>setTimeout(()=>{a=t===ya.length-1,s()},e)),d=new MutationObserver(c);d.observe(n,{childList:!0,subtree:!0});let f=typeof ResizeObserver>`u`?null:new ResizeObserver(c);f?.observe(n);function p(){cancelAnimationFrame(l),u.forEach(clearTimeout),clearTimeout(o),d.disconnect(),f?.disconnect()}return p},[e,t]),n.page===t?n.given:va}function xa(e){let[t,n]=(0,W.useState)(null);return(0,W.useEffect)(()=>{if(e)return(0,q.onSnapshot)((0,q.collection)(r.ui,e),t=>{!t.metadata.fromCache&&!t.metadata.hasPendingWrites&&n({name:e,size:t.size})},()=>{})},[e]),t&&t.name===e?t.size:null}function Sa({job:e,kept:t}){let n=S.l(e,{records:xa(e.from),copies:xa(e.to),kept:t});return n?(0,G.jsx)(`aside`,{className:`w-full px-4 md:px-8 pb-6 text-xs text-foreground/60`,"aria-label":`What this page is shown from ${e.keeper.title}`,children:(0,G.jsxs)(`div`,{className:`max-w-3xl rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] px-4 py-3 flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`uppercase tracking-[0.18em] text-foreground/40`,children:`Only your team sees this`}),(0,G.jsx)(`p`,{className:`leading-relaxed`,children:n})]})}):null}function Ca({config:e}){let{userRole:t}=r.Ft();return o.Sn(t)?(0,G.jsx)(wa,{config:e}):null}function wa({config:e}){let t=ie.u(),n=Ui();if(!t||!n)return null;let r=S.d(t,e);if(!r)return null;let i=S.c(S.u(t),r.id);return i.length?(0,G.jsx)(`div`,{className:`w-full mt-auto pt-6`,children:i.map(e=>(0,G.jsx)(Sa,{job:e,kept:!!n[e.from]},`${e.from}${e.reader.id}`))}):null}function Ta({config:e,customContent:t}){let{config:a}=i.N(),{userRole:s}=r.Ft();fn(!!t);let l=(0,W.useRef)(null),u=ba(l,t);return(0,W.useEffect)(()=>{document.title=e.pageName||e.pageTitle||a.appName||`Your AI Firebase`},[e.pageName,e.pageTitle,a.appName]),t?(0,G.jsx)(c.p,{value:{prefix:`pub_`},children:(0,G.jsxs)(`main`,{ref:l,className:r.$(`fbos-content-slot fbos-page-canvas flex-1 w-full z-10 flex flex-col relative`,u.sides&&`px-4 md:px-8`,u.top&&`pt-6 md:pt-10`),style:u.room?{paddingTop:u.room}:void 0,"data-gutter-given":[u.sides&&`sides`,u.top&&`top`,u.room&&`title`].filter(Boolean).join(` `)||void 0,children:[(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(te.t,{config:e,children:(0,G.jsx)(t,{config:e})})}),(0,G.jsx)(Ca,{config:e})]})}):(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col relative min-h-screen`,children:[(0,G.jsx)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4 md:mb-6 min-w-0`,children:(0,G.jsx)(n.t,{children:e.pageTitle||e.pageName||`New Page`})}),(0,G.jsx)(r.nt.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:e.form?(0,G.jsx)(`div`,{className:`fbos-content-slot flex-1 flex flex-col items-center justify-start p-4 md:p-8`,children:(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(te.t,{config:e,children:(0,G.jsx)(g.t,{isInline:!0,formId:e.form})})})}):(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center m-4 md:m-8 gap-6`,children:[(0,G.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,G.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/70`,children:`This page is empty`}),(0,G.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.`})]}),o.wn(s)&&(0,G.jsx)(`div`,{className:`w-full max-w-lg`,children:(0,G.jsx)(n.o,{compact:!0,title:`Already asked, and it is still empty? Paste this`,prompt:ta(e.route||`/`,$i(e))})})]})})]})}var Ea=(...e)=>{for(let t of e)if(t&&typeof t==`object`&&!Array.isArray(t))return t;return null};function Da(e,t){let n=Ea(e,t);if(!n)throw Error(`saveRecord needs the record to save — actions.saveRecord({ name: …, price: … }). The collection is the page’s own and is never passed.`);return n}function Oa(e,t,n){let r=Ea(t,n);if(!r)throw Error(`updateRecord needs the record’s id and the change — actions.updateRecord(id, { stock: 4 }). The collection is the page’s own and is never passed.`);return{id:String((r===n?t:e)??``),data:r}}function ka(e,t){return String((typeof t==`string`&&t?t:e)??``)}function Aa(e){return(e||[]).map(e=>{let t=e.data()||{};return{...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt,id:e.id}})}function ja(e){if(!e||!(`id`in e))return e;let{id:t,...n}=e;return n}function Ma(e){let t=typeof e?.sourceId==`string`?e.sourceId.trim():``;return t?`from_${t.replace(/[^A-Za-z0-9_-]/g,`_`).slice(0,200)}`:null}var Na=(e,t)=>`${e}|${t}`,Pa=e=>Object.fromEntries(e.map(e=>[Na(e.record,e.variant),e.since])),Fa=e=>typeof e==`number`&&Number.isFinite(e),Ia=(e,t)=>t&&Array.isArray(e?.variants)&&e.variants.find(e=>e&&String(e.id??``)===String(t))||null;function La(e){let t=[];for(let n of e)if(!(!n||!n.id)){Fa(n.stock)&&Fa(n.stockSetAt)&&t.push({record:String(n.id),variant:``,since:n.stockSetAt});for(let e of Array.isArray(n.variants)?n.variants:[]){let r=String(e?.id??``);r&&Fa(e?.stock)&&Fa(e?.stockSetAt)&&t.push({record:String(n.id),variant:r,since:e.stockSetAt})}}return t.sort((e,t)=>(e.record+`|`+e.variant).localeCompare(t.record+`|`+t.variant))}function Ra(e,t,n,r){if(!t)return null;let i=Ia(t,n),a=i?i.stock:n?void 0:t.stock;return Fa(a)?Math.max(0,a-za(e,t,n,r)):null}function za(e,t,n,r){if(!t?.id)return 0;let i=Ia(t,n),a=i?i.stockSetAt:n?void 0:t.stockSetAt;if(!Fa(a))return 0;let o=r?.[Na(String(t.id),i?String(i.id):``)];if(r&&o!==a)return 0;let s=e[String(t.id)]?.[i?String(i.id):``];return Fa(s)&&s>0?s:0}function Ba(e,t,n=Date.now()){if(!e||typeof e!=`object`)return e;let r={...e};if(Fa(e.stock)&&(r.stockSetAt=!t||t.stock!==e.stock||!Fa(t.stockSetAt)?n:t.stockSetAt),Array.isArray(e.variants)){let i=Array.isArray(t?.variants)?t.variants:[];r.variants=e.variants.map(e=>{if(!e||typeof e!=`object`||!Fa(e.stock))return e;let t=i.find(t=>t&&String(t.id??``)===String(e.id??``));return!t||t.stock!==e.stock||!Fa(t.stockSetAt)?{...e,stockSetAt:n}:Fa(e.stockSetAt)?e:{...e,stockSetAt:t.stockSetAt}})}return r}var Va=60*1e3,Ha=`What is left in stock could not be checked just now — the counts shown are as last set.`,Ua={fetch:(e,t)=>fetch(e,t)};async function Wa(e){if(!e.length)return{sold:{},error:``,partial:!1};try{let t=await Ua.fetch(`/api/payments/sold`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({wants:e})});if(!t.ok)return{sold:{},error:Ha,partial:!1};let n=await t.json();return{sold:n&&typeof n.sold==`object`&&n.sold?n.sold:{},error:``,partial:n?.partial===!0}}catch{return{sold:{},error:Ha,partial:!1}}}function Ga(e){let t=(0,W.useMemo)(()=>La(Array.isArray(e)?e:[]),[e]),n=(0,W.useMemo)(()=>JSON.stringify(t),[t]),[r,i]=(0,W.useState)({sold:{},for:{}}),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),l=t.length>0&&!s,[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(0),m=(0,W.useRef)(t);return m.current=t,(0,W.useEffect)(()=>{if(!t.length)return;let e=!0,n=async()=>{let t=m.current,n=await Wa(t);e&&(n.error||(i({sold:n.sold,for:Pa(t)}),o(n.partial),p(Date.now())),d(n.error),c(!0))};n();let r=setInterval(()=>{document.visibilityState!==`hidden`&&n()},Va),a=()=>{document.visibilityState===`visible`&&n()};return document.addEventListener(`visibilitychange`,a),()=>{e=!1,clearInterval(r),document.removeEventListener(`visibilitychange`,a)}},[n]),(0,W.useMemo)(()=>({loading:l,error:u,asOf:f,partial:a,left:(e,t)=>Ra(r.sold,e,t,r.for),sold:(e,t)=>za(r.sold,e,t,r.for)}),[r,l,u,f,a])}function Ka({config:e,customContent:t}){let{user:a,userRole:s}=r.Ft(),{config:l}=i.N(),[u,d]=(0,W.useState)([]),[f,p]=(0,W.useState)(!0),[m,h]=(0,W.useState)(!1),[g,_]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),[x,w]=(0,W.useState)(!1),[E,D]=(0,W.useState)(``),[j,N]=(0,W.useState)(null),P=(0,W.useRef)(null),[F,I]=(0,W.useState)(null),[L,ne]=(0,W.useState)(null),R=e=>{if(ne(e),e){let t=e.fileType||``;oe(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},z=L,[B,oe]=(0,W.useState)(!0),[se,ce]=(0,W.useState)(!1),[H,le]=(0,W.useState)(null),[U,ue]=(0,W.useState)(``),[K,J]=(0,W.useState)(``),[Y,fe]=(0,W.useState)([]),pe=(0,W.useRef)(null),me=ie.o(e,`user_page`),he=o.Mn({...e,pageType:`user`}),ge=!he.startsWith(`user_`),_e=c.c(he),X=_e?ie.t(e,he):`${he}${me}_records`,ve=c.f(),ye=c.o({on:!ge&&!_e}),be=ye.uid||a?.uid||``,xe=c.F(X),Z=_e?xe.records:u,Q=_e?xe.loading:f,Se=e=>_e?c.C(e,ve):!0,Ce=s===`admin`,we=e=>Se(e)&&ae.d(e,s),Te=(0,W.useRef)(!1);(0,W.useEffect)(()=>{!Ce||Q||Te.current||!Z.length||(Te.current=!0,ae.a(X,Z,e,!0).catch(e=>console.warn(`Could not catch the delete lock up:`,e)).finally(()=>{Te.current=!1}))},[Ce,Q,Z,ae.l(e),X]);let Ee=ye.everyone?`${a?.uid}|everyone`:ye.uid||a?.uid||``,De=(0,W.useRef)(Ee),Oe=e=>c.d(he,X,e),[ke,Ae]=(0,W.useState)(()=>_e?c.u(X):``),je=()=>Ae(c.u(X));(0,W.useEffect)(()=>{document.title=e.tabTitle||e.tabName||l.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,l.appName]),(0,W.useEffect)(()=>{if(!a||_e)return;try{let e=S.o(X,Ee);e?(d(e),p(!1)):(d(e=>e.length?[]:e),p(!0)),De.current=Ee}catch{}let e=e=>Aa(e),t=(0,q.onSnapshot)(ge||ye.everyone?(0,q.query)((0,q.collection)(r.ui,X),(0,q.orderBy)(`createdAt`,`desc`),(0,q.limit)(150)):(0,q.query)((0,q.collection)(r.ui,X),(0,q.where)(`uid`,`==`,ye.uid||a.uid)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),d(n),p(!1),De.current=Ee,S.s(X,Ee,n)},e=>{console.warn(`${X}: this account cannot read its records here (${e?.code||`permission-denied`}). Signed-in pages need a verified email address; the records themselves are only ever the signer's own.`),d(e=>e.length?[]:e),p(!1)});return()=>t()},[a,X,ge,_e,ye.uid,ye.everyone,Ee]),(0,W.useEffect)(()=>{!f&&a&&!_e&&De.current===Ee&&S.s(X,Ee,u)},[u,f,X,a,_e,Ee]);let Me=async e=>Z.some(t=>t.id===e)||await(0,q.getDoc)((0,q.doc)(r.ui,X,e)).then(e=>e.exists()).catch(()=>!1),Ne=async(t,n)=>{let i={uid:be,recordType:`record`,...ae.u(e,s),...t};if(!_e){let e=Ma(t),n=e?(0,q.doc)(r.ui,X,e):(0,q.doc)((0,q.collection)(r.ui,X)),a={...i,createdAt:(0,q.serverTimestamp)()};return await(0,q.setDoc)(n,a),S.p(X,n.id,a),n.id}let o=n||ke||c.u(X);return await(0,q.setDoc)((0,q.doc)(r.ui,X,o),c.l({...Ti(a),...i},a.uid)),n||je(),o},Pe=async t=>{if(t.preventDefault(),!(!a||!g.trim())){w(!0);try{let t=await Ne({name:g.trim(),note:y.trim()});_e||d(n=>[{id:t,name:g.trim(),note:y.trim(),uid:a.uid,recordType:`record`,...ae.u(e,s),createdAt:Date.now()},...n]),_(``),b(``),h(!1)}catch(e){console.error(`Error saving record:`,e)}w(!1)}},Fe=c.b({upload:async(t,n)=>{if(!a)throw Error(`Sign in again before uploading.`);let r=await ee._(t),i=_e?P.current&&ke||c.u(X):``,o=`${Oe(i)}/${c.h(r.name)}`,l=await c.y(o,r,{customMetadata:{ownerId:a.uid},onProgress:n.progress,signal:n.signal});if(P.current)P.current(r,l,{uid:a.uid,storagePath:o,recordId:i});else{let t=await Ne({name:r.name,note:`${r.type||`File`} · ${tt(r.size)}`,recordType:`file`,fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:l,storagePath:o},i);_e||d(n=>[{id:t,name:r.name,note:`${r.type||`File`} · ${tt(r.size)}`,uid:a.uid,recordType:`file`,fileName:r.name,fileType:r.type,fileSize:r.size,downloadURL:l,storagePath:o,...ae.u(e,s),createdAt:Date.now()},...n])}},onFailed:e=>D(`${e.name}: ${e.error||`That upload did not work.`}`),onSettled:()=>Fe.clear()}),Ie=Fe.busy,Le=e=>{let t=Array.from(e.target.files||[]);e.target.value=``,!(!t.length||!a)&&(D(``),Fe.add(t))},Re=async()=>{if(F){ce(!0);try{let e=Z.find(e=>e.id===F);if(!ae.d(e,s)){O.n(`Nothing on this page can be deleted.`),I(null),ce(!1);return}await(0,q.deleteDoc)((0,q.doc)(r.ui,X,F)),await V.o(e,Z,Oe(F)),_e||d(e=>e.filter(e=>e.id!==F)),I(null)}catch(e){console.error(`Error deleting record:`,e)}ce(!1)}},[ze,Be]=(0,W.useState)(null),[Ve,He]=(0,W.useState)(``),[Ue,We]=(0,W.useState)(!1),[Ge,Ke]=(0,W.useState)(null),qe=(0,W.useRef)([]),Je=e=>{if(e.recordType===`file`){Be(e.id),He(e.name);return}le(e.id),ue(e.name),J(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`storagePath`,`createdAt`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));fe(n),qe.current=n.map(e=>e.key)},Ye=async()=>{if(!ze||!Ve.trim()){Be(null);return}let e=Z.find(e=>e.id===ze);if(e&&e.name===Ve.trim()){Be(null);return}We(!0);try{await(0,q.updateDoc)((0,q.doc)(r.ui,X,ze),{name:Ve.trim()}),d(e=>e.map(e=>e.id===ze?{...e,name:Ve.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}We(!1),Be(null)},Xe=async()=>{await Ze(),le(null)},Ze=async()=>{if(!H||!U.trim())return;w(!0);let e={};Y.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=Y.map(e=>e.key.trim()).filter(Boolean),n=qe.current.filter(e=>!t.includes(e));n.forEach(t=>{e[t]=(0,q.deleteField)()});try{await(0,q.updateDoc)((0,q.doc)(r.ui,X,H),{name:U.trim(),note:K.trim(),...e}),d(e=>e.map(e=>{if(e.id!==H)return e;let t={...e,name:U.trim(),note:K.trim()};return n.forEach(e=>{delete t[e]}),Y.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),qe.current=t}catch(e){console.error(`Error saving record:`,e)}w(!1)},Qe=(e,t)=>e?e.startsWith(`image/`)?t?(0,G.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,G.jsx)(v.c,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,G.jsx)(c.R,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,G.jsx)(v.u,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,G.jsx)(c.V,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,G.jsx)(c.B,{className:`w-4 h-4`}):(0,G.jsx)(v.l,{className:`w-4 h-4`}):(0,G.jsx)(v.u,{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-accent/10 text-accent`: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`,et=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)},tt=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]},nt=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},rt=n.p(e.buttonStorageIcon)||vt,it=e.buttonStyle!==`secondary`,at=e.buttonStorageStyle===`primary`;return(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,G.jsx)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(n.t,{children:e.tabTitle||e.tabName||`User Page`}),e.route&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,G.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,G.jsx)(i.t,{}),(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:t?`flex flex-col flex-1 relative`:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,G.jsx)(`input`,{type:`file`,multiple:!0,ref:pe,onChange:Le,className:`hidden`}),!t&&(0,G.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,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`h2`,{className:`text-xl font-bold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,G.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:Q?`Loading…`:`${Z.length} ${Z.length===1?`item`:`items`}`}),(E||_e&&xe.error)&&(0,G.jsx)(`p`,{className:`text-[12px] font-semibold text-red-500 mt-1 truncate`,role:`alert`,children:E||xe.error}),ye.someoneElse&&e.storage!==!1&&(0,G.jsx)(`p`,{className:`text-[12px] font-medium text-foreground/50 mt-1 max-sm:hidden`,children:`You are looking at somebody else’s page. Anything you add here is theirs, but a file would stay yours — so uploads are off until you switch back to your own.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,G.jsx)(c.a,{viewing:ye}),e.storage!==!1&&!ye.someoneElse&&(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>pe.current?.click(),title:Ie?Fe.done?`${Fe.done} of ${Fe.total} uploaded…`:`Uploading ${Fe.total===1?`your file`:`${Fe.total} files`}…`:e.buttonStorageText||`Upload files`,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`} ${at?`btn-primary`:`btn-secondary`}`,children:[Ie?(0,G.jsx)(C.r,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(rt,{className:`w-4 h-4`}),e.buttonStorageText&&(0,G.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,G.jsx)(r.nt.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`} ${it?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,G.jsx)(T.t,{className:`w-4 h-4`}):(0,G.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,G.jsxs)(`div`,{className:t?`flex-1 flex flex-col relative min-h-[400px]`:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[Q&&(0,G.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,G.jsx)(C.r,{className:`w-8 h-8 text-accent animate-spin`})}),t?(0,G.jsx)(c.p,{value:{prefix:he,collection:_e?X:``,recordId:_e?H||ke:``},children:(0,G.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill`,children:(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(te.t,{config:e,children:(0,G.jsx)(t,{config:e,actions:{records:Z,loading:Q,error:_e?xe.error:``,collection:X,user:a,...c.s(X,ve,_e,ke),saveRecord:async(t,n)=>{let r=ja(Da(t,n)),i=_e?null:Ma(r);if(i&&await Me(i))return i;let a=await Ne(Ba(r));return _e||d(t=>[{uid:be,recordType:`record`,...ae.u(e,s),createdAt:Date.now(),...r,id:a},...t.filter(e=>e.id!==a)]),a},updateRecord:async(e,t,n)=>{let{id:i,data:o}=Oa(e,t,n),s=ja(o),c={...Ei(a),...Ba(s,Z.find(e=>e.id===i))};_e||d(e=>e.map(e=>e.id===i?{...e,...c}:e)),await(0,q.updateDoc)((0,q.doc)(r.ui,X,i),c);let l=Z.find(e=>e.id===i);l&&S.p(X,i,{...l,...c})},deleteRecord:async(e,t)=>{let n=ka(e,t),i=Z.find(e=>e.id===n);if(!ae.d(i,s)){O.n(`Nothing on this page can be deleted.`);return}await(0,q.deleteDoc)((0,q.doc)(r.ui,X,n)),S.m(X,n),await V.o(i,Z,Oe(n))},startEdit:e=>Je(e),confirmDelete:e=>I(e),uploadFile:()=>{ye.someoneElse||pe.current?.click()},openAddForm:()=>h(!0),setAddForm:e=>N(()=>e),setFileHandler:e=>{P.current=e}}})})})})}):(0,G.jsxs)(G.Fragment,{children:[!Q&&Z.length===0&&(0,G.jsxs)(r.nt.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,G.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,G.jsx)(T.t,{className:`w-6 h-6 text-accent/40`})}),(0,G.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,G.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`})]}),!Q&&Z.length>0&&(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,G.jsx)(r.rt,{children:Z.map((e,t)=>{let n=H===e.id,i=Se(e),o=_e?Oi(e,a):null;return(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},transition:{delay:t*.03,duration:.25},onClick:()=>i&&Je(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative ${i?`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,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),Ke(e.id),setTimeout(()=>Ke(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:Ge===e.id?(0,G.jsx)(r.At,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,G.jsx)(c.z,{className:`w-3.5 h-3.5`})}),(0,G.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,G.jsx)(v.d,{className:`w-3.5 h-3.5`})})]}),i&&(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Je(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,G.jsx)(v.s,{className:`w-3.5 h-3.5`})}),i&&we(e)&&(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),I(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,G.jsx)(k.t,{className:`w-3.5 h-3.5`})})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,G.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&R(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`?Qe(e.fileType,e.downloadURL):(0,G.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,G.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[ze===e.id?(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:Ve,onChange:e=>He(e.target.value),onBlur:()=>Ye(),onKeyDown:e=>{e.key===`Enter`&&Ye(),e.key===`Escape`&&Be(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,G.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,G.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>R(e)}),(0,G.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:nt(e.createdAt)})]})]}),e.note&&(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),o&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[o.avatar?(0,G.jsx)(r.O,{src:o.avatar,alt:``,className:`w-5 h-5 rounded-full shrink-0`}):(0,G.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:o.name.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:o.name})]})]},e.id)})})})]})]})]})]}),(0,G.jsx)(r.rt,{children:m&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,G.jsx)(r.nt.div,{onClick:()=>!x&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,G.jsx)(r.nt.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:j?W.default.createElement(j,{onSave:async e=>{w(!0);try{await Ne(e),h(!1)}catch(e){console.error(`Error saving record:`,e)}w(!1)},onClose:()=>!x&&h(!1),saving:x}):(0,G.jsxs)(`form`,{onSubmit:Pe,className:`p-5 flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>!x&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,G.jsx)(C.t,{className:`w-4 h-4`})})]}),(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:x,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,G.jsx)(r.Q,{value:y,onChange:e=>b(e.target.value),placeholder:`Note (optional)`,disabled:x,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,G.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,G.jsx)(M.t,{type:`submit`,isLoading:x,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:x?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,de.createPortal)((0,G.jsx)(r.rt,{children:z&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,G.jsx)(r.nt.div,{onClick:()=>R(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,G.jsx)(`button`,{onClick:()=>R(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,G.jsx)(C.t,{className:`w-5 h-5`})}),(0,G.jsxs)(r.nt.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,G.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,G.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,G.jsx)(`span`,{className:`text-xl font-bold text-foreground truncate`,children:z.fileName||z.name}),(0,G.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[et(z.fileType),` • `,tt(z.fileSize||0)]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,G.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(z.downloadURL),Ke(`preview`),setTimeout(()=>Ke(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:Ge===`preview`?(0,G.jsx)(r.At,{className:`w-4 h-4 text-emerald-500`}):(0,G.jsx)(c.z,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>{R(null),Be(z.id),He(z.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,G.jsx)(v.s,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>{R(null),I(z.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,G.jsx)(k.t,{className:`w-4 h-4`})}),(0,G.jsx)(`a`,{href:z.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,G.jsx)(v.d,{className:`w-4 h-4`})})]})]}),(0,G.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>R(null),children:(0,G.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[B&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,G.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,G.jsx)(C.r,{className:`w-5 h-5 text-accent animate-spin`})})}),z.fileType?.startsWith(`image/`)?(0,G.jsx)(`img`,{onLoad:()=>oe(!1),onError:()=>oe(!1),src:z.downloadURL,alt:z.fileName||z.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 ${B?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):z.fileType?.startsWith(`video/`)?(0,G.jsx)(`video`,{onLoadedData:()=>oe(!1),onError:()=>oe(!1),src:z.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 ${B?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):z.fileType===`application/pdf`?(0,G.jsx)(`iframe`,{onLoad:()=>oe(!1),src:z.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${B?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,G.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(),oe(!1)},children:[(0,G.jsx)(v.u,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,G.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,G.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,G.jsx)(r.rt,{children:H&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,G.jsx)(r.nt.div,{onClick:()=>Xe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,G.jsx)(r.nt.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,G.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),x&&(0,G.jsx)(C.r,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>Xe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,G.jsx)(C.t,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,G.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,G.jsx)(`input`,{autoFocus:!0,required:!0,value:U,onChange:e=>ue(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Ze(),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,G.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,G.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,G.jsx)(r.Q,{value:K,onChange:e=>J(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>Ze(),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,G.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),Y.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,G.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...Y];n[t].key=e.target.value,fe(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Ze(),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,G.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...Y];n[t].value=e.target.value,fe(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Ze(),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,G.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>fe(Y.filter((e,n)=>n!==t)),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,G.jsx)(C.t,{className:`w-3 h-3`})})]},t)),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>fe([...Y,{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,G.jsx)(T.t,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,G.jsx)(re.t,{isOpen:!!F,onCancel:()=>I(null),onConfirm:Re,title:`Delete Record`,message:(0,G.jsxs)(G.Fragment,{children:[`Are you sure you want to delete `,(0,G.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:Z.find(e=>e.id===F)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:se})]})}var qa=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Admin`,n=e.creatorEmail||``,i=e.creatorAvatar||``,a=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[i?(0,G.jsx)(r.O,{src:i,alt:``,className:`w-5 h-5 rounded-full shrink-0`}):(0,G.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:a}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,G.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};function Ja({config:e,customContent:t}){let{user:a}=r.Ft(),{config:o}=i.N(),[s,l]=(0,W.useState)([]),[u,d]=(0,W.useState)(!0),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(``),[y,b]=(0,W.useState)(!1),[x,w]=(0,W.useState)(``),[E,D]=(0,W.useState)(null),O=(0,W.useRef)(null),[j,N]=(0,W.useState)(null),[P,F]=(0,W.useState)(null),I=e=>{if(F(e),e){let t=e.fileType||``;R(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},L=P,[ne,R]=(0,W.useState)(!0),[z,B]=(0,W.useState)(!1),[ae,oe]=(0,W.useState)(null),[se,ce]=(0,W.useState)(``),[H,le]=(0,W.useState)(``),[U,ue]=(0,W.useState)([]),K=(0,W.useRef)(null),[J,Y]=(0,W.useState)(null),fe=(0,W.useRef)([]),pe=`admin_${ie.o(e,`admin_page`)}_records`,me=V.i(`admin_`);(0,W.useEffect)(()=>{document.title=e.tabTitle||e.tabName||o.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,o.appName]);let he=()=>({name:a.displayName||a.email?.split(`@`)[0]||`Admin`,email:a.email||``,avatar:a.photoURL||``}),ge=a?.uid;(0,W.useEffect)(()=>{if(!ge)return;try{let e=S.o(pe,ge);e?(l(e),d(!1)):d(!0)}catch{}let e=e=>Aa(e),t=(0,q.onSnapshot)((0,q.query)((0,q.collection)(r.ui,pe),(0,q.orderBy)(`createdAt`,`desc`),(0,q.limit)(150)),t=>{let n=e(t.docs);l(n),d(!1),S.s(pe,ge,n)},e=>{console.warn(`${pe}: this account cannot read the records here (${e?.code||`permission-denied`}). An admins page needs a verified address and an account marked Admin on the Users screen.`),l(e=>e.length?[]:e),d(!1)});return()=>t()},[ge,pe]);let _e=async e=>{if(e.preventDefault(),!(!a||!m.trim())){b(!0);try{let e=he();await(0,q.addDoc)((0,q.collection)(r.ui,pe),{name:m.trim(),note:g.trim(),uid:a.uid,recordType:`record`,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,q.serverTimestamp)()}),h(``),_(``),p(!1)}catch(e){console.error(`Error saving admin record:`,e)}b(!1)}},X=c.b({upload:async(e,t)=>{if(!a)throw Error(`Sign in again before uploading.`);let n=await ee._(e),i=`${me}/${c.h(n.name)}`,o=await c.y(i,n,{customMetadata:{ownerId:a.uid},onProgress:t.progress,signal:t.signal});if(O.current)O.current(n,o,{uid:a.uid,storagePath:i});else{let e=he();await(0,q.addDoc)((0,q.collection)(r.ui,pe),{name:n.name,note:`${n.type||`File`} · ${Me(n.size)}`,uid:a.uid,recordType:`file`,fileName:n.name,fileType:n.type||`unknown`,fileSize:n.size,downloadURL:o,storagePath:i,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,q.serverTimestamp)()})}},onFailed:e=>w(`${e.name}: ${e.error||`That upload did not work.`}`),onSettled:()=>X.clear()}),ve=X.busy,ye=e=>{let t=Array.from(e.target.files||[]);e.target.value=``,!(!t.length||!a)&&(w(``),X.add(t))},be=async()=>{if(j){B(!0);try{let e=s.find(e=>e.id===j);await(0,q.deleteDoc)((0,q.doc)(r.ui,pe,j)),await V.o(e,s,me),N(null)}catch(e){console.error(`Error deleting admin record:`,e)}B(!1)}},[xe,Z]=(0,W.useState)(null),[Q,Se]=(0,W.useState)(``),[Ce,we]=(0,W.useState)(!1),Te=e=>{if(e.recordType===`file`){Z(e.id),Se(e.name);return}oe(e.id),ce(e.name),le(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`storagePath`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));ue(n),fe.current=n.map(e=>e.key)},Ee=async()=>{if(!xe||!Q.trim()){Z(null);return}let e=s.find(e=>e.id===xe);if(e&&e.name===Q.trim()){Z(null);return}we(!0);try{await(0,q.updateDoc)((0,q.doc)(r.ui,pe,xe),{name:Q.trim()}),l(e=>e.map(e=>e.id===xe?{...e,name:Q.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}we(!1),Z(null)},De=async()=>{if(!ae||!se.trim()){oe(null);return}b(!0);let e={};U.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=U.map(e=>e.key.trim()).filter(Boolean),n=fe.current.filter(e=>!t.includes(e));n.forEach(t=>{e[t]=(0,q.deleteField)()});try{await(0,q.updateDoc)((0,q.doc)(r.ui,pe,ae),{name:se.trim(),note:H.trim(),...e}),l(e=>e.map(e=>{if(e.id!==ae)return e;let t={...e,name:se.trim(),note:H.trim()};return n.forEach(e=>{delete t[e]}),U.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),fe.current=t}catch(e){console.error(`Error updating record:`,e)}b(!1),oe(null)},Oe=async()=>{if(!ae||!se.trim())return;let e={};U.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=U.map(e=>e.key.trim()).filter(Boolean),n=fe.current.filter(e=>!t.includes(e));n.forEach(t=>{e[t]=(0,q.deleteField)()});try{await(0,q.updateDoc)((0,q.doc)(r.ui,pe,ae),{name:se.trim(),note:H.trim(),...e}),l(e=>e.map(e=>{if(e.id!==ae)return e;let t={...e,name:se.trim(),note:H.trim()};return n.forEach(e=>{delete t[e]}),U.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),fe.current=t}catch(e){console.error(`Error silently saving record:`,e)}},ke=(e,t)=>e?e.startsWith(`image/`)?t?(0,G.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,G.jsx)(v.c,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,G.jsx)(c.R,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,G.jsx)(v.u,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,G.jsx)(c.V,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,G.jsx)(c.B,{className:`w-4 h-4`}):(0,G.jsx)(v.l,{className:`w-4 h-4`}):(0,G.jsx)(v.u,{className:`w-4 h-4`}),Ae=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-accent/10 text-accent`: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`,je=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)},Me=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]},Ne=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},Pe=n.p(e.buttonStorageIcon)||vt,Fe=e.buttonStyle!==`secondary`,Ie=e.buttonStorageStyle===`primary`,Le=e=>e.uid===a?.uid;return(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,G.jsx)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(n.t,{children:e.tabTitle||e.tabName||`Admin Page`}),e.route&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,G.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,G.jsx)(i.t,{}),(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:t?`flex flex-col flex-1 relative`:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,G.jsx)(`input`,{type:`file`,multiple:!0,ref:K,onChange:ye,className:`hidden`}),!t&&(0,G.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,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`h2`,{className:`text-xl font-bold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,G.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:u?`Loading…`:`${s.length} ${s.length===1?`item`:`items`}`}),x&&(0,G.jsx)(`p`,{className:`text-[12px] font-semibold text-red-500 mt-1 truncate`,role:`alert`,children:x})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.storage!==!1&&(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>K.current?.click(),title:ve?X.done?`${X.done} of ${X.total} uploaded…`:`Uploading ${X.total===1?`your file`:`${X.total} files`}…`:e.buttonStorageText||`Upload files`,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`} ${Ie?`btn-primary`:`btn-secondary`}`,children:[ve?(0,G.jsx)(C.r,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Pe,{className:`w-4 h-4`}),e.buttonStorageText&&(0,G.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,G.jsx)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>p(!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`} ${Fe?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,G.jsx)(T.t,{className:`w-4 h-4`}):(0,G.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,G.jsxs)(`div`,{className:t?`flex-1 flex flex-col relative min-h-[400px]`:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[u&&(0,G.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,G.jsx)(C.r,{className:`w-8 h-8 text-accent animate-spin`})}),t?(0,G.jsx)(c.p,{value:{prefix:`admin_`,collection:pe},children:(0,G.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill`,children:(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(te.t,{config:e,children:(0,G.jsx)(t,{config:e,actions:{records:s,loading:u,collection:pe,user:a,saveRecord:async(e,t)=>{let n=Ba(ja(Da(e,t))),i=Ma(n);if(i&&(s.some(e=>e.id===i)||await(0,q.getDoc)((0,q.doc)(r.ui,pe,i)).then(e=>e.exists()).catch(()=>!1)))return i;let o=i?(0,q.doc)(r.ui,pe,i):(0,q.doc)((0,q.collection)(r.ui,pe)),c=he(),u={uid:a.uid,recordType:`record`,creatorName:c.name,creatorEmail:c.email,creatorAvatar:c.avatar,createdAt:Date.now(),...n,id:o.id};l(e=>[u,...e.filter(e=>e.id!==u.id)]);let d={uid:a.uid,recordType:`record`,creatorName:c.name,creatorEmail:c.email,creatorAvatar:c.avatar,createdAt:(0,q.serverTimestamp)(),...n};return await(0,q.setDoc)(o,d),S.p(pe,o.id,d),o.id},updateRecord:async(e,t,n)=>{let{id:i,data:o}=Oa(e,t,n),c=ja(o),u={...Ei(a),...Ba(c,s.find(e=>e.id===i))};l(e=>e.map(e=>e.id===i?{...e,...u}:e)),await(0,q.updateDoc)((0,q.doc)(r.ui,pe,i),u);let d=s.find(e=>e.id===i);d&&S.p(pe,i,{...d,...u})},deleteRecord:async(e,t)=>{let n=ka(e,t),i=s.find(e=>e.id===n);await(0,q.deleteDoc)((0,q.doc)(r.ui,pe,n)),S.m(pe,n),await V.o(i,s,me)},startEdit:e=>Te(e),confirmDelete:e=>N(e),uploadFile:()=>K.current?.click(),openAddForm:()=>p(!0),setAddForm:e=>D(()=>e),setFileHandler:e=>{O.current=e}}})})})})}):(0,G.jsxs)(G.Fragment,{children:[!u&&s.length===0&&(0,G.jsxs)(r.nt.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,G.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,G.jsx)(T.t,{className:`w-6 h-6 text-accent/40`})}),(0,G.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,G.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.`})]}),!u&&s.length>0&&(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,G.jsx)(r.rt,{children:s.map((e,t)=>{let n=ae===e.id,i=Le(e);return(0,G.jsxs)(r.nt.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>Te(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative 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,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),Y(e.id),setTimeout(()=>Y(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:J===e.id?(0,G.jsx)(r.At,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,G.jsx)(c.z,{className:`w-3.5 h-3.5`})}),(0,G.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,G.jsx)(v.d,{className:`w-3.5 h-3.5`})})]}),i&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Te(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,G.jsx)(v.s,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),N(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,G.jsx)(k.t,{className:`w-3.5 h-3.5`})})]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,G.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&I(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 ${Ae(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?ke(e.fileType,e.downloadURL):(0,G.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,G.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[xe===e.id?(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:Q,onChange:e=>Se(e.target.value),onBlur:()=>Ee(),onKeyDown:e=>{e.key===`Enter`&&Ee(),e.key===`Escape`&&Z(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,G.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,G.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>I(e)}),(0,G.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:Ne(e.createdAt)})]})]}),e.note&&(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,G.jsx)(qa,{record:e})]},e.id)})})})]})]})]})]}),(0,G.jsx)(r.rt,{children:f&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,G.jsx)(r.nt.div,{onClick:()=>!y&&p(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,G.jsx)(r.nt.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:E?W.default.createElement(E,{onSave:async e=>{b(!0);try{let t=he();await(0,q.addDoc)((0,q.collection)(r.ui,pe),{uid:a.uid,recordType:`record`,creatorName:t.name,creatorEmail:t.email,creatorAvatar:t.avatar,createdAt:(0,q.serverTimestamp)(),...e}),p(!1)}catch(e){console.error(`Error saving record:`,e)}b(!1)},onClose:()=>!y&&p(!1),saving:y}):(0,G.jsxs)(`form`,{onSubmit:_e,className:`p-5 flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>!y&&p(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,G.jsx)(C.t,{className:`w-4 h-4`})})]}),(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:m,onChange:e=>h(e.target.value),placeholder:`Name *`,disabled:y,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,G.jsx)(r.Q,{value:g,onChange:e=>_(e.target.value),placeholder:`Note (optional)`,disabled:y,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,G.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,G.jsx)(M.t,{type:`submit`,isLoading:y,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:y?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,de.createPortal)((0,G.jsx)(r.rt,{children:L&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,G.jsx)(r.nt.div,{onClick:()=>I(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,G.jsx)(`button`,{onClick:()=>I(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,G.jsx)(C.t,{className:`w-5 h-5`})}),(0,G.jsxs)(r.nt.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,G.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,G.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,G.jsx)(`span`,{className:`text-xl font-bold text-foreground truncate`,children:L.fileName||L.name}),(0,G.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[je(L.fileType),` • `,Me(L.fileSize||0)]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,G.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(L.downloadURL),Y(`preview`),setTimeout(()=>Y(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:J===`preview`?(0,G.jsx)(r.At,{className:`w-4 h-4 text-emerald-500`}):(0,G.jsx)(c.z,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>{I(null),Z(L.id),Se(L.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,G.jsx)(v.s,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>{I(null),N(L.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,G.jsx)(k.t,{className:`w-4 h-4`})}),(0,G.jsx)(`a`,{href:L.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,G.jsx)(v.d,{className:`w-4 h-4`})})]})]}),(0,G.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>I(null),children:(0,G.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[ne&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,G.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,G.jsx)(C.r,{className:`w-5 h-5 text-accent animate-spin`})})}),L.fileType?.startsWith(`image/`)?(0,G.jsx)(`img`,{onLoad:()=>R(!1),onError:()=>R(!1),src:L.downloadURL,alt:L.fileName||L.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 ${ne?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):L.fileType?.startsWith(`video/`)?(0,G.jsx)(`video`,{onLoadedData:()=>R(!1),onError:()=>R(!1),src:L.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 ${ne?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):L.fileType===`application/pdf`?(0,G.jsx)(`iframe`,{onLoad:()=>R(!1),src:L.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${ne?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,G.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(),R(!1)},children:[(0,G.jsx)(v.u,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,G.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,G.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,G.jsx)(r.rt,{children:ae&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,G.jsx)(r.nt.div,{onClick:()=>De(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,G.jsx)(r.nt.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,G.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),y&&(0,G.jsx)(C.r,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>De(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,G.jsx)(C.t,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,G.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,G.jsx)(`input`,{autoFocus:!0,required:!0,value:se,onChange:e=>ce(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Oe(),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,G.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,G.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,G.jsx)(r.Q,{value:H,onChange:e=>le(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>Oe(),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,G.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),U.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,G.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...U];n[t].key=e.target.value,ue(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Oe(),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,G.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...U];n[t].value=e.target.value,ue(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Oe(),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,G.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>ue(U.filter((e,n)=>n!==t)),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,G.jsx)(C.t,{className:`w-3 h-3`})})]},t)),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>ue([...U,{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,G.jsx)(T.t,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,G.jsx)(re.t,{isOpen:!!j,onCancel:()=>N(null),onConfirm:be,title:`Delete Record`,message:(0,G.jsxs)(G.Fragment,{children:[`Are you sure you want to delete `,(0,G.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:s.find(e=>e.id===j)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:z})]})}var Ya=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Member`,n=e.creatorEmail||``,i=e.creatorAvatar||``,a=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[i?(0,G.jsx)(r.O,{src:i,alt:``,className:`w-5 h-5 rounded-full shrink-0`}):(0,G.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:a}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,G.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};function Xa({config:e,customContent:t}){let{user:a,userRole:s}=r.Ft(),{config:l}=i.N(),[u,d]=(0,W.useState)([]),[f,p]=(0,W.useState)(!0),[m,h]=(0,W.useState)(!1),[g,_]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),[x,w]=(0,W.useState)(!1),[E,D]=(0,W.useState)(``),[j,N]=(0,W.useState)(null),P=(0,W.useRef)(null),[F,I]=(0,W.useState)(null),[L,ne]=(0,W.useState)(null),R=e=>{if(ne(e),e){let t=e.fileType||``;oe(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},z=L,[B,oe]=(0,W.useState)(!0),[se,ce]=(0,W.useState)(!1),[H,le]=(0,W.useState)(null),[U,ue]=(0,W.useState)(``),[K,J]=(0,W.useState)(``),[Y,fe]=(0,W.useState)([]),pe=(0,W.useRef)(null),[me,he]=(0,W.useState)(null),ge=(0,W.useRef)([]),_e=ie.o(e,`internal_page`),X=o.Mn({...e,pageType:`internal`}),ve=X.startsWith(`user_`),ye=c.c(X),be=ye?ie.t(e,X):`${X}${_e}_records`,xe=c.f(),Z=c.o({on:ve}),Q=Z.uid||a?.uid||``,Se=c.F(be),Ce=ye?Se.records:u,we=ye?Se.loading:f,Te=e=>ye?c.C(e,xe):e.uid===a?.uid||Z.someoneElse,Ee=s===`admin`,De=e=>Te(e)&&ae.d(e,s),Oe=(0,W.useRef)(!1);(0,W.useEffect)(()=>{!Ee||we||Oe.current||!Ce.length||(Oe.current=!0,ae.a(be,Ce,e,!0).catch(e=>console.warn(`Could not catch the delete lock up:`,e)).finally(()=>{Oe.current=!1}))},[Ee,we,Ce,ae.l(e),be]);let ke=e=>c.d(X,be,e),[Ae,je]=(0,W.useState)(()=>ye?c.u(be):``),Me=()=>je(c.u(be));(0,W.useEffect)(()=>{document.title=e.tabTitle||e.tabName||l.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,l.appName]);let Ne=a?.uid,Pe=Z.uid||Ne||``,Fe=Z.everyone?`${Ne}|everyone`:Pe;(0,W.useEffect)(()=>{if(!Ne||ye)return;try{let e=S.o(be,Fe);e?(d(e),p(!1)):(d(e=>e.length?[]:e),p(!0))}catch{}let e=e=>Aa(e),t=(0,q.onSnapshot)(ve&&!Z.everyone?(0,q.query)((0,q.collection)(r.ui,be),(0,q.where)(`uid`,`==`,Pe)):(0,q.query)((0,q.collection)(r.ui,be),(0,q.orderBy)(`createdAt`,`desc`),(0,q.limit)(150)),t=>{let n=e(t.docs);ve&&!Z.everyone&&n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),d(n),p(!1),S.s(be,Fe,n)},e=>{console.warn(`${be}: this account cannot read the records here (${e?.code||`permission-denied`}). A team page needs a verified address and an account marked Internal or Admin on the Users screen.`),d(e=>e.length?[]:e),p(!1)});return()=>t()},[Ne,Pe,Fe,be,ve,ye,Z.everyone]);let Ie=async e=>Ce.some(t=>t.id===e)||await(0,q.getDoc)((0,q.doc)(r.ui,be,e)).then(e=>e.exists()).catch(()=>!1),Le=()=>({name:a.displayName||a.email?.split(`@`)[0]||`Member`,email:a.email||``,avatar:a.photoURL||``}),Re=async(t,n)=>{let i=Le(),o={uid:Q,recordType:`record`,creatorName:i.name,creatorEmail:i.email,creatorAvatar:i.avatar,...ae.u(e,s),...t};if(!ye){let e=Ma(t),n=e?(0,q.doc)(r.ui,be,e):(0,q.doc)((0,q.collection)(r.ui,be)),i={...o,createdAt:(0,q.serverTimestamp)()};return await(0,q.setDoc)(n,i),S.p(be,n.id,i),n.id}let l=n||Ae||c.u(be);return await(0,q.setDoc)((0,q.doc)(r.ui,be,l),c.l(o,a.uid)),n||Me(),l},ze=async e=>{if(e.preventDefault(),!(!a||!g.trim())){w(!0);try{await Re({name:g.trim(),note:y.trim()}),_(``),b(``),h(!1)}catch(e){console.error(`Error saving shared record:`,e)}w(!1)}},Be=c.b({upload:async(e,t)=>{if(!a)throw Error(`Sign in again before uploading.`);let n=await ee._(e),r=ye?P.current&&Ae||c.u(be):``,i=`${ke(r)}/${c.h(n.name)}`,o=await c.y(i,n,{customMetadata:{ownerId:a.uid},onProgress:t.progress,signal:t.signal});P.current?P.current(n,o,{uid:a.uid,storagePath:i,recordId:r}):await Re({name:n.name,note:`${n.type||`File`} · ${rt(n.size)}`,recordType:`file`,fileName:n.name,fileType:n.type||`unknown`,fileSize:n.size,downloadURL:o,storagePath:i},r)},onFailed:e=>D(`${e.name}: ${e.error||`That upload did not work.`}`),onSettled:()=>Be.clear()}),Ve=Be.busy,He=e=>{let t=Array.from(e.target.files||[]);e.target.value=``,!(!t.length||!a)&&(D(``),Be.add(t))},Ue=async()=>{if(F){ce(!0);try{let e=Ce.find(e=>e.id===F);if(!ae.d(e,s)){O.n(`Nothing on this page can be deleted.`),I(null),ce(!1);return}await(0,q.deleteDoc)((0,q.doc)(r.ui,be,F)),await V.o(e,Ce,ke(F)),I(null)}catch(e){console.error(`Error deleting shared record:`,e)}ce(!1)}},[We,Ge]=(0,W.useState)(null),[Ke,qe]=(0,W.useState)(``),[Je,Ye]=(0,W.useState)(!1),Xe=e=>{if(e.recordType===`file`){Ge(e.id),qe(e.name);return}le(e.id),ue(e.name),J(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`storagePath`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));fe(n),ge.current=n.map(e=>e.key)},Ze=async()=>{if(!We||!Ke.trim()){Ge(null);return}let e=Ce.find(e=>e.id===We);if(e&&e.name===Ke.trim()){Ge(null);return}Ye(!0);try{await(0,q.updateDoc)((0,q.doc)(r.ui,be,We),{name:Ke.trim()}),d(e=>e.map(e=>e.id===We?{...e,name:Ke.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}Ye(!1),Ge(null)},Qe=async()=>{await $e(),le(null)},$e=async()=>{if(!H||!U.trim())return;w(!0);let e={};Y.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=Y.map(e=>e.key.trim()).filter(Boolean),n=ge.current.filter(e=>!t.includes(e));n.forEach(t=>{e[t]=(0,q.deleteField)()});try{await(0,q.updateDoc)((0,q.doc)(r.ui,be,H),{name:U.trim(),note:K.trim(),...e}),d(e=>e.map(e=>{if(e.id!==H)return e;let t={...e,name:U.trim(),note:K.trim()};return n.forEach(e=>{delete t[e]}),Y.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),ge.current=t}catch(e){console.error(`Error saving record:`,e)}w(!1)},et=(e,t)=>e?e.startsWith(`image/`)?t?(0,G.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,G.jsx)(v.c,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,G.jsx)(c.R,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,G.jsx)(v.u,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,G.jsx)(c.V,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,G.jsx)(c.B,{className:`w-4 h-4`}):(0,G.jsx)(v.l,{className:`w-4 h-4`}):(0,G.jsx)(v.u,{className:`w-4 h-4`}),tt=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-accent/10 text-accent`: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`,nt=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)},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]},it=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},at=n.p(e.buttonStorageIcon)||vt,ot=e.buttonStyle!==`secondary`,st=e.buttonStorageStyle===`primary`;return(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,G.jsx)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(n.t,{children:e.tabTitle||e.tabName||`Internal Page`}),e.route&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,G.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,G.jsx)(i.t,{}),(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:t?`flex flex-col flex-1 relative`:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,G.jsx)(`input`,{type:`file`,multiple:!0,ref:pe,onChange:He,className:`hidden`}),!t&&(0,G.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,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`h2`,{className:`text-xl font-bold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,G.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:we?`Loading…`:`${Ce.length} ${Ce.length===1?`item`:`items`} · Internal`}),(E||ye&&Se.error)&&(0,G.jsx)(`p`,{className:`text-[12px] font-semibold text-red-500 mt-1 truncate`,role:`alert`,children:E||Se.error}),Z.someoneElse&&e.storage!==!1&&(0,G.jsx)(`p`,{className:`text-[12px] font-medium text-foreground/50 mt-1 max-sm:hidden`,children:`You are looking at somebody else’s page. Anything you add here is theirs, but a file would stay yours — so uploads are off until you switch back to your own.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,G.jsx)(c.a,{viewing:Z}),e.storage!==!1&&!Z.someoneElse&&(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>pe.current?.click(),title:Ve?Be.done?`${Be.done} of ${Be.total} uploaded…`:`Uploading ${Be.total===1?`your file`:`${Be.total} files`}…`:e.buttonStorageText||`Upload files`,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`} ${st?`btn-primary`:`btn-secondary`}`,children:[Ve?(0,G.jsx)(C.r,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(at,{className:`w-4 h-4`}),e.buttonStorageText&&(0,G.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,G.jsx)(r.nt.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`} ${ot?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,G.jsx)(T.t,{className:`w-4 h-4`}):(0,G.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,G.jsxs)(`div`,{className:t?`flex-1 flex flex-col relative min-h-[400px]`:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[we&&(0,G.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,G.jsx)(C.r,{className:`w-8 h-8 text-accent animate-spin`})}),t?(0,G.jsx)(c.p,{value:{prefix:X,collection:ye?be:``,recordId:ye?H||Ae:``},children:(0,G.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill`,children:(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(te.t,{config:e,children:(0,G.jsx)(t,{config:e,actions:{records:Ce,loading:we,error:ye?Se.error:``,collection:be,user:a,...c.s(be,xe,ye,Ae),saveRecord:async(t,n)=>{let r=Le(),i=ja(Da(t,n)),a=ye?null:Ma(i);if(a&&await Ie(a))return a;let o=await Re(Ba(i));return ye||d(t=>[{uid:Q,recordType:`record`,creatorName:r.name,creatorEmail:r.email,creatorAvatar:r.avatar,...ae.u(e,s),createdAt:Date.now(),...i,id:o},...t.filter(e=>e.id!==o)]),o},updateRecord:async(e,t,n)=>{let{id:i,data:o}=Oa(e,t,n),s=ja(o),c={...Ei(a),...Ba(s,Ce.find(e=>e.id===i))};ye||d(e=>e.map(e=>e.id===i?{...e,...c}:e)),await(0,q.updateDoc)((0,q.doc)(r.ui,be,i),c);let l=Ce.find(e=>e.id===i);l&&S.p(be,i,{...l,...c})},deleteRecord:async(e,t)=>{let n=ka(e,t),i=Ce.find(e=>e.id===n);if(!ae.d(i,s)){O.n(`Nothing on this page can be deleted.`);return}await(0,q.deleteDoc)((0,q.doc)(r.ui,be,n)),S.m(be,n),await V.o(i,Ce,ke(n))},startEdit:e=>Xe(e),confirmDelete:e=>I(e),uploadFile:()=>{Z.someoneElse||pe.current?.click()},openAddForm:()=>h(!0),setAddForm:e=>N(()=>e),setFileHandler:e=>{P.current=e}}})})})})}):(0,G.jsxs)(G.Fragment,{children:[!we&&Ce.length===0&&(0,G.jsxs)(r.nt.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,G.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,G.jsx)(T.t,{className:`w-6 h-6 text-accent/40`})}),(0,G.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,G.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.`})]}),!we&&Ce.length>0&&(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,G.jsx)(r.rt,{children:Ce.map(e=>{let t=H===e.id,n=Te(e);return(0,G.jsxs)(r.nt.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>n?Xe(e):null,className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative ${n?`cursor-pointer`:``} ${t?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),he(e.id),setTimeout(()=>he(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:me===e.id?(0,G.jsx)(r.At,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,G.jsx)(c.z,{className:`w-3.5 h-3.5`})}),(0,G.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,G.jsx)(v.d,{className:`w-3.5 h-3.5`})})]}),n&&(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Xe(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,G.jsx)(v.s,{className:`w-3.5 h-3.5`})}),n&&De(e)&&(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),I(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,G.jsx)(k.t,{className:`w-3.5 h-3.5`})})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,G.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&R(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 ${tt(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?et(e.fileType,e.downloadURL):(0,G.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,G.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[We===e.id?(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:Ke,onChange:e=>qe(e.target.value),onBlur:()=>Ze(),onKeyDown:e=>{e.key===`Enter`&&Ze(),e.key===`Escape`&&Ge(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,G.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,G.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>R(e)}),(0,G.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:it(e.createdAt)})]})]}),e.note&&(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,G.jsx)(Ya,{record:e})]},e.id)})})})]})]})]})]}),(0,G.jsx)(r.rt,{children:m&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,G.jsx)(r.nt.div,{onClick:()=>!x&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,G.jsx)(r.nt.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:j?W.default.createElement(j,{onSave:async e=>{w(!0);try{await Re(e),h(!1)}catch(e){console.error(`Error saving record:`,e)}w(!1)},onClose:()=>!x&&h(!1),saving:x}):(0,G.jsxs)(`form`,{onSubmit:ze,className:`p-5 flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>!x&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,G.jsx)(C.t,{className:`w-4 h-4`})})]}),(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:x,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,G.jsx)(r.Q,{value:y,onChange:e=>b(e.target.value),placeholder:`Note (optional)`,disabled:x,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,G.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,G.jsx)(M.t,{type:`submit`,isLoading:x,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:x?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,de.createPortal)((0,G.jsx)(r.rt,{children:z&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,G.jsx)(r.nt.div,{onClick:()=>R(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,G.jsx)(`button`,{onClick:()=>R(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,G.jsx)(C.t,{className:`w-5 h-5`})}),(0,G.jsxs)(r.nt.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,G.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,G.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,G.jsx)(`span`,{className:`text-xl font-bold text-foreground truncate`,children:z.fileName||z.name}),(0,G.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[nt(z.fileType),` • `,rt(z.fileSize||0)]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,G.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(z.downloadURL),he(`preview`),setTimeout(()=>he(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:me===`preview`?(0,G.jsx)(r.At,{className:`w-4 h-4 text-emerald-500`}):(0,G.jsx)(c.z,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>{R(null),Ge(z.id),qe(z.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,G.jsx)(v.s,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>{R(null),I(z.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,G.jsx)(k.t,{className:`w-4 h-4`})}),(0,G.jsx)(`a`,{href:z.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,G.jsx)(v.d,{className:`w-4 h-4`})})]})]}),(0,G.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>R(null),children:(0,G.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[B&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,G.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,G.jsx)(C.r,{className:`w-5 h-5 text-accent animate-spin`})})}),z.fileType?.startsWith(`image/`)?(0,G.jsx)(`img`,{onLoad:()=>oe(!1),onError:()=>oe(!1),src:z.downloadURL,alt:z.fileName||z.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 ${B?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):z.fileType?.startsWith(`video/`)?(0,G.jsx)(`video`,{onLoadedData:()=>oe(!1),onError:()=>oe(!1),src:z.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 ${B?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):z.fileType===`application/pdf`?(0,G.jsx)(`iframe`,{onLoad:()=>oe(!1),src:z.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${B?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,G.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(),oe(!1)},children:[(0,G.jsx)(v.u,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,G.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,G.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,G.jsx)(r.rt,{children:H&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,G.jsx)(r.nt.div,{onClick:()=>Qe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,G.jsx)(r.nt.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,G.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),x&&(0,G.jsx)(C.r,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>Qe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,G.jsx)(C.t,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,G.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,G.jsx)(`input`,{autoFocus:!0,required:!0,value:U,onChange:e=>ue(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>$e(),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,G.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,G.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,G.jsx)(r.Q,{value:K,onChange:e=>J(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>$e(),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,G.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),Y.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,G.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...Y];n[t].key=e.target.value,fe(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>$e(),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,G.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...Y];n[t].value=e.target.value,fe(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>$e(),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,G.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>fe(Y.filter((e,n)=>n!==t)),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,G.jsx)(C.t,{className:`w-3 h-3`})})]},t)),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>fe([...Y,{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,G.jsx)(T.t,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,G.jsx)(re.t,{isOpen:!!F,onCancel:()=>I(null),onConfirm:Ue,title:`Delete Record`,message:(0,G.jsxs)(G.Fragment,{children:[`Are you sure you want to delete `,(0,G.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:Ce.find(e=>e.id===F)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:se})]})}var Za=5,Qa=3,$a=8,eo=250,to=56,no=14,ro=8,io=`button, a, input, textarea, select, label, [role="button"], [role="listbox"], [role="option"], [contenteditable="true"], [data-no-drag]`,ao=!1,oo=()=>{ao||typeof window>`u`||(ao=!0,window.addEventListener(`touchmove`,()=>{},{passive:!1}))};function so(e){let[t,n]=(0,W.useState)(null),r=(0,W.useRef)(e);(0,W.useEffect)(()=>{r.current=e}),(0,W.useEffect)(oo,[]);let i=(0,W.useRef)(null),a=(0,W.useCallback)(e=>{let t=i.current;t&&(i.current=null,t.cleanup(),t.active&&(n(null),e===`drop`?r.current.onDrop(t.key):r.current.onCancel?.(t.key)))},[]);(0,W.useEffect)(()=>()=>a(`cancel`),[a]);let o=(0,W.useCallback)((e,t)=>{if(r.current.disabled||i.current||t.pointerType===`mouse`&&t.button!==0)return;let o=t.target,s=!!o.closest?.(`[data-drag-handle]`),c=s?null:o.closest?.(io);if(c&&!c.hasAttribute(`data-drag-ok`))return;let l=t.currentTarget,u=t.pointerType===`touch`,d=s?Qa:u?$a:Za,f=()=>{let e=i.current;if(!(!e||e.active)){e.active=!0,e.hold&&=(clearTimeout(e.hold),null);try{navigator.vibrate?.(8)}catch{}r.current.onStart?.(e.key),n({key:e.key,x:e.x,y:e.y,offsetX:e.startX-e.rect.left,offsetY:e.startY-e.rect.top,width:e.rect.width,height:e.rect.height}),r.current.onMove({x:e.x,y:e.y,at:e.at},e.key),e.frame=requestAnimationFrame(p)}},p=e=>{let t=i.current;if(!t||!t.active)return;t.at=e;let n=!1;t.y<to?(window.scrollBy(0,-no),n=!0):t.y>window.innerHeight-to&&(window.scrollBy(0,no),n=!0);let a=r.current.scroller?.();if(a){let e=a.getBoundingClientRect(),r=a.scrollLeft;t.x<e.left+to?a.scrollLeft-=ro:t.x>e.right-to&&(a.scrollLeft+=ro),a.scrollLeft!==r&&(n=!0)}n&&r.current.onMove({x:t.x,y:t.y,at:e},t.key),t.frame=requestAnimationFrame(p)},m=e=>{let t=i.current;if(!(!t||e.pointerId!==t.pointerId)){if(t.x=e.clientX,t.y=e.clientY,t.at=e.timeStamp,!t.active){if(!(Math.hypot(t.x-t.startX,t.y-t.startY)>d))return;if(u&&!s){a(`cancel`);return}f();return}n(e=>e&&{...e,x:t.x,y:t.y}),r.current.onMove({x:t.x,y:t.y,at:t.at},t.key)}},h=e=>{let t=i.current;if(!(!t||e.pointerId!==t.pointerId)){if(t.active){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),80)}a(`drop`)}},g=e=>{i.current&&e.pointerId===i.current.pointerId&&a(`cancel`)},_=e=>{e.key===`Escape`&&i.current?.active&&(e.preventDefault(),a(`cancel`))},v=e=>{i.current?.active&&e.cancelable&&e.preventDefault()},y=e=>{u&&e.preventDefault()},b=e=>e.preventDefault(),x=document.body.style.userSelect,S={key:e,pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,x:t.clientX,y:t.clientY,at:t.timeStamp,rect:l.getBoundingClientRect(),active:!1,hold:u&&!s?setTimeout(f,eo):null,frame:null,cleanup:()=>{S.hold&&clearTimeout(S.hold),S.frame!=null&&cancelAnimationFrame(S.frame),window.removeEventListener(`pointermove`,m),window.removeEventListener(`pointerup`,h),window.removeEventListener(`pointercancel`,g),window.removeEventListener(`keydown`,_,!0),window.removeEventListener(`touchmove`,v),window.removeEventListener(`contextmenu`,y,!0),window.removeEventListener(`dragstart`,b,!0),document.body.style.userSelect=x}};i.current=S,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,m),window.addEventListener(`pointerup`,h),window.addEventListener(`pointercancel`,g),window.addEventListener(`keydown`,_,!0),window.addEventListener(`touchmove`,v,{passive:!1}),window.addEventListener(`contextmenu`,y,!0),window.addEventListener(`dragstart`,b,!0)},[a]);return{dragging:t,bind:(0,W.useCallback)(e=>({"data-drag-key":e,onPointerDown:t=>o(e,t),style:{WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`}}),[o])}}var co={"data-drag-handle":``,style:{touchAction:`none`,cursor:`grab`}},lo=()=>[{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()}],uo=()=>`item_${Date.now()}`,fo=(e,t)=>({id:e,categoryId:t.categoryId,name:t.name||t.text||`Unnamed Item`,fields:t.fields||(t.value?[{key:`Label`,value:t.value}]:[]),order:t.order||0,uid:t.uid,creatorName:t.creatorName,creatorAvatar:t.creatorAvatar,access:t.access,editors:t.editors}),po=[{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 mo({title:e=`Board View`,subtitle:t=`/board`,backUrl:s,tasksCollection:l=`pub_tasks`,categoriesCollection:u=`pub_categories`,config:d,customContent:f}){let{user:p}=r.Ft(),m=!!d,h=d?.isInternal||d?.isShared;d?.isPrivate&&d?.isAdmin;let g=d?.isAdmin||h,_=o.Tn(l),y=c.f(),b=c.F(l),x=c.F(u),S=m?g||_||l.startsWith(`role_`):!0,w=e=>!_||c.C(e,y),E=c.o({on:l.startsWith(`user_`)&&!_,everyone:!1}),D=E.uid||p?.uid||``,[O,j]=(0,W.useState)(()=>_?c.u(l):``),N=(e,t,n,r)=>p?o.Tn(e)?n?c.l({uid:p.uid,...r?Ti(p):{},...t},p.uid):t:e.startsWith(`user_`)?{...t,uid:D||p.uid}:n?{uid:p.uid,...r?Ti(p):{},...t}:t:t,ee=!!f,P=d?.showButton!==!1&&!ee,te=d?.buttonText||`+`,F=d?.buttonStyle||`primary`,I=d?.keyName||`key`,L=d?.valueName||`value`,[ne,R]=(0,W.useState)([]),[z,ie]=(0,W.useState)([]),B=_?b.records.map(e=>fo(e.id,e)).sort((e,t)=>(e.order||0)-(t.order||0)):ne,V=_?x.records:z,[ae,oe]=(0,W.useState)(null),[se,ce]=(0,W.useState)(null),[H,le]=(0,W.useState)({name:``}),[U,ue]=(0,W.useState)([]),[K,J]=(0,W.useState)(null),Y=(0,W.useRef)(null),fe=e=>{Y.current=e,J(e)},pe=(0,W.useRef)(null),[me,he]=(0,W.useState)(null),[ge,_e]=(0,W.useState)(!1),[X,ve]=(0,W.useState)(null),[ye,be]=(0,W.useState)(``),[xe,Z]=(0,W.useState)(null),Q=E.uid||p?.uid;(0,W.useEffect)(()=>{let e=l.startsWith(`user_`),t=u.startsWith(`user_`);if(e&&!p||_)return;let n=e&&Q?`${l}|${Q}`:l,i=t&&Q?`${u}|${Q}`:u;try{let e=localStorage.getItem(`fbos_board_tasks_${n}`);e&&R(JSON.parse(e));let t=localStorage.getItem(`fbos_board_cats_${i}`);t&&ie(JSON.parse(t))}catch{}let o=(0,q.onSnapshot)(e&&Q?(0,q.query)((0,q.collection)(r.ui,l),(0,q.where)(`uid`,`==`,Q)):(0,q.collection)(r.ui,l),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,uid:n.uid,creatorName:n.creatorName,creatorAvatar:n.creatorAvatar})});let r=t.sort((e,t)=>(e.order||0)-(t.order||0));R(r),localStorage.setItem(`fbos_board_tasks_${n}`,JSON.stringify(r))},a.s),s=(0,q.onSnapshot)(t&&Q?(0,q.query)((0,q.collection)(r.ui,u),(0,q.where)(`uid`,`==`,Q)):(0,q.collection)(r.ui,u),e=>{let n=[];if(e.forEach(e=>{n.push({id:e.id,...e.data()})}),n.length===0){let e=lo(),n=Q?{uid:Q}:{},i=t&&Q?`_${Q}`:``;e.forEach(e=>(0,q.setDoc)((0,q.doc)(r.ui,u,`${e.id}${i}`),{...n,title:e.title,createdAt:e.createdAt}))}else ie(n),localStorage.setItem(`fbos_board_cats_${i}`,JSON.stringify(n))},a.s);return()=>{o(),s()}},[l,u,Q,_]);let Se=(0,W.useRef)(!1);(0,W.useEffect)(()=>{!_||!Q||x.loading||x.records.length||Se.current||(Se.current=!0,lo().forEach(e=>(0,q.setDoc)((0,q.doc)(r.ui,u,`${e.id}_${Q}`),c.l({uid:Q,title:e.title,createdAt:e.createdAt},Q))))},[_,Q,x.loading,x.records.length,u]);let Ce=(e,t)=>{t?(ce(t.id),le({id:t.id,name:t.name}),ue(t.fields?.length?[...t.fields,{key:``,value:``}]:[{key:``,value:``}])):(oe(e),le({name:``}),ue([{key:``,value:``}]))},we=(e,t,n)=>{let r=[...U];r[e]={key:t,value:n},e===U.length-1&&(t.trim()!==``||n.trim()!==``)&&r.push({key:``,value:``}),ue(r)},Te=async(e,t,n)=>{let i=B.find(t=>t.id===e);if(!i||!w(i))return;let a=B.filter(e=>e.categoryId===t).sort((e,t)=>(e.order||0)-(t.order||0)),o=a.filter(t=>t.id!==e),s=Math.max(0,Math.min(n,o.length));i.categoryId===t&&a.findIndex(t=>t.id===e)===s||[...o.slice(0,s),i,...o.slice(s)].forEach((e,n)=>{let i=N(l,{categoryId:t,order:n},!1,!1);(0,q.setDoc)((0,q.doc)(r.ui,l,e.id),i,{merge:!0})})},{dragging:Ee,bind:De}=so({scroller:()=>pe.current,onMove:({x:e,y:t},n)=>{let r=pe.current;if(!r)return;let i=null,a=1/0;for(let t of Array.from(r.querySelectorAll(`[data-board-column]`))){let n=t.getBoundingClientRect(),r=e<n.left?n.left-e:e>n.right?e-n.right:0;r<a&&(a=r,i=t)}let o=i?.dataset.boardColumn;if(!i||!o){fe(null);return}let s=Array.from(i.querySelectorAll(`[data-drag-key]`)).filter(e=>e.dataset.dragKey!==n).filter(e=>{let n=e.getBoundingClientRect();return t>n.top+n.height/2}).length,c=Y.current;(!c||c.categoryId!==o||c.index!==s)&&fe({categoryId:o,index:s})},onDrop:e=>{let t=Y.current;fe(null),t&&Te(e,t.categoryId,t.index)},onCancel:()=>fe(null)}),Oe=Ee?.key??null,ke=Oe?B.find(e=>e.id===Oe):void 0,Ae=async e=>{let t=H.id||uo(),n=H.name.trim(),i=n||`Untitled Item`,a=U.filter(e=>e.key.trim()!==``||e.value.trim()!==``),o=!0,s=H.id?B.find(e=>e.id===H.id):null;if(s){let e=JSON.stringify(s.fields||[]),t=JSON.stringify(a);s.name===i&&e===t&&(o=!1)}else !n&&a.length===0&&(o=!1);if(!o){oe(null),ce(null);return}he(H.id||`new`);let c=N(l,{categoryId:e,name:i,fields:a},!H.id,!0);await(0,q.setDoc)((0,q.doc)(r.ui,l,t),c,{merge:!0}),setTimeout(()=>{oe(null),ce(null),he(null)},400)},je=(e,t)=>{Z({type:`item`,id:e,title:t})},Me=async()=>{let e=`cat_${Date.now()}`,t=N(u,{title:``,createdAt:Date.now()},!0,!1);await(0,q.setDoc)((0,q.doc)(r.ui,u,e),t),ve(e),be(``),setTimeout(()=>{let e=document.getElementById(`board-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},150)},Ne=async(e,t)=>{ie(n=>n.map(n=>n.id===e?{...n,color:t}:n)),await(0,q.setDoc)((0,q.doc)(r.ui,u,e),{color:t},{merge:!0})},Pe=async e=>{ye.trim()?await(0,q.setDoc)((0,q.doc)(r.ui,u,e),{title:ye},{merge:!0}):await(0,q.deleteDoc)((0,q.doc)(r.ui,u,e)),ve(null)},Fe=(e,t)=>{Z({type:`category`,id:e,title:t})},Ie=async()=>{if(xe){_e(!0);try{if(xe.type===`item`)await(0,q.deleteDoc)((0,q.doc)(r.ui,l,xe.id)),ce(null);else{let e=B.filter(e=>e.categoryId===xe.id);for(let t of e)await(0,q.deleteDoc)((0,q.doc)(r.ui,l,t.id));await(0,q.deleteDoc)((0,q.doc)(r.ui,u,xe.id))}}catch{}_e(!1),Z(null)}},Le=[...V].sort((e,t)=>(e.createdAt||0)-(t.createdAt||0));return(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen overflow-x-clip`,children:[(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4 md:mb-6 flex items-center gap-3`,children:[!m&&s&&(0,G.jsx)(c.r,{to:s}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(n.t,{children:e}),t&&(0,G.jsxs)(`div`,{className:`max-sm:hidden sm:flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,G.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 min-h-0 pb-16`,children:[m&&(0,G.jsx)(i.t,{}),(0,G.jsxs)(r.nt.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 min-h-[400px] shadow-2xl bg-background relative z-10`,children:[(0,G.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,G.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 relative z-20`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`h2`,{className:`text-lg sm:text-xl font-bold text-foreground tracking-tight truncate`,children:d?.tabTitle||d?.tabName||e}),(0,G.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[B.length,` `,B.length===1?`item`:`items`,` · `,Le.length,` `,Le.length===1?`category`:`categories`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,G.jsx)(c.a,{viewing:E}),P&&(0,G.jsx)(M.t,{variant:F===`secondary`?`secondary`:void 0,onClick:Me,className:`px-3 py-2.5 text-[14px] font-bold rounded-xl shadow-lg hover:-translate-y-0.5 transition-all shrink-0`,children:te===`+`?(0,G.jsx)(T.t,{className:`w-4 h-4`}):te})]})]}),(0,G.jsx)(`div`,{className:`flex-1 w-full relative z-40 min-h-0 flex flex-col`,children:f?(0,G.jsx)(c.p,{value:{prefix:o.Mn(d||{}),collection:_?l:``,recordId:_?se||O:``},children:(0,G.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill w-full flex-1 overflow-y-auto p-4 md:p-6`,children:(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(f,{config:d,actions:{tasks:B,categories:V,collection:l,catCollection:u,user:p,error:_?b.error||x.error:``,...c.s(l,y,_,O),saveTask:async(e,t)=>{let n=e||uo(),i=N(l,t,!B.some(e=>e.id===n),!0);_&&n===O&&j(c.u(l)),R(e=>e.find(e=>e.id===n)?e.map(e=>e.id===n?{...e,...i}:e):[...e,{id:n,...i}]),await(0,q.setDoc)((0,q.doc)(r.ui,l,n),i,{merge:!0})},deleteTask:async e=>{R(t=>t.filter(t=>t.id!==e)),await(0,q.deleteDoc)((0,q.doc)(r.ui,l,e))},saveCategory:async(e,t)=>{let n=N(u,t,!V.some(t=>t.id===e),!1);ie(t=>t.find(t=>t.id===e)?t.map(t=>t.id===e?{...t,...n}:t):[...t,{id:e,...n}]),await(0,q.setDoc)((0,q.doc)(r.ui,u,e),n,{merge:!0})},deleteCategory:async e=>{ie(t=>t.filter(t=>t.id!==e)),await(0,q.deleteDoc)((0,q.doc)(r.ui,u,e))},openInlineEditor:(e,t)=>Ce(e,t)}})})})}):(0,G.jsxs)(`div`,{ref:pe,id:`board-container`,className:`w-full flex-1 min-h-0 flex flex-row gap-4 md:gap-6 overflow-x-auto p-4 md:p-6 snap-x snap-mandatory styled-scrollbars items-start`,children:[Le.map((e,t)=>{let n=B.filter(t=>t.categoryId===e.id);n.sort((e,t)=>(e.order||0)-(t.order||0));let i=po.find(t=>t.text===e.color)||po.find(e=>e.text===`text-accent`);i.text,i.bgLight,i.bgHover;let a=K?.categoryId===e.id,o=n.filter(e=>e.id!==Oe),s=a?o[K.index]?.id??null:null,c=a&&K.index>=o.length;return(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:t*.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 ${po.find(t=>t.text===e.color)?.bgCard||`bg-foreground/[0.02]`} ${po.find(t=>t.text===e.color)?.borderCard||`border-[var(--panel-border)]/50`}`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-2 relative z-[200]`,children:(0,G.jsxs)(`h3`,{className:`font-bold text-[14px] flex items-center w-full text-foreground/80 group relative z-[200]`,children:[X===e.id?(0,G.jsxs)(`div`,{className:`relative flex-1 w-full flex items-center pr-8 z-[200]`,children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Pe(e.id)}}),(0,G.jsx)(`input`,{value:ye,onChange:e=>be(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,G.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,G.jsx)(`button`,{onClick:async t=>{t.preventDefault(),t.stopPropagation(),await Ne(e.id,``),ve(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,G.jsx)(C.t,{className:`w-3 h-3`})}),(0,G.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),po.map(t=>(0,G.jsx)(`button`,{onMouseDown:async n=>{n.preventDefault(),await Ne(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,G.jsxs)(`div`,{className:`flex items-center gap-2 w-full hover:text-foreground transition-colors pr-8 ${w(e)?`cursor-pointer`:``}`,onClick:()=>{w(e)&&(ve(e.id),be(e.title))},children:[(0,G.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${po.find(t=>t.text===e.color)?.bgCircle||`bg-foreground/20`} transition-colors shrink-0`}),(0,G.jsx)(`span`,{className:`truncate flex-1 max-w-[200px] ${e.color||``}`,children:e.title||`Untitled Category`}),(0,G.jsx)(`span`,{className:`text-[11px] bg-foreground/10 text-foreground/60 px-1.5 py-0.5 rounded-md font-medium shrink-0`,children:n.length})]}),V.length>1&&w(e)&&(0,G.jsx)(`button`,{onClick:()=>Fe(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,G.jsx)(k.t,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsxs)(`div`,{"data-board-column":e.id,className:`flex flex-col gap-2.5 flex-1 overflow-y-auto styled-scrollbars pr-1 relative min-h-[150px] rounded-xl transition-colors ${a?`bg-foreground/5 border-dashed border border-accent/20`:``}`,children:[(0,G.jsx)(r.rt,{children:n.map(t=>se===t.id?(0,G.jsxs)(r.nt.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,G.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Ae(e.id)}}),(0,G.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:H.name,onChange:e=>le({...H,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Ae(e.id))}}),(0,G.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:U.map((t,n)=>(0,G.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,G.jsx)(`input`,{placeholder:I,value:t.key,onChange:e=>we(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&Ae(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||I.length)}ch`}}),(0,G.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,G.jsx)(`textarea`,{rows:1,placeholder:L,value:t.value,onChange:e=>we(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(),Ae(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))}),me===t.id&&(0,G.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,G.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]},t.id):(0,W.createElement)(r.nt.div,{...w(t)?De(t.id):{"data-drag-key":t.id},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},key:t.id,className:`bg-background/80 rounded-xl p-3 shadow-sm hover:shadow-md ${w(t)?`cursor-grab active:cursor-grabbing`:``} hover:border-accent/40 transition-all group flex flex-col gap-2 relative z-10 border ${s===t.id?`border-accent border-t-2 translate-y-1`:`border-[var(--panel-border)]`} ${Oe===t.id?`opacity-30 border-dashed border-2`:``}`},w(t)&&(0,G.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,G.jsx)(`span`,{...co,"aria-hidden":`true`,className:`p-1 rounded-md text-foreground/40 hover:text-foreground/70 transition-colors`,children:(0,G.jsx)(nt,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{onClick:n=>{n.stopPropagation(),Ce(e.id,t)},className:`p-1 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-accent transition-colors`,children:(0,G.jsx)(v.s,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),je(t.id,t.name)},className:`p-1 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,children:(0,G.jsx)(k.t,{className:`w-3.5 h-3.5`})})]}),(0,G.jsx)(`p`,{className:`text-[13px] text-foreground/90 font-medium leading-snug break-words pr-12`,children:t.name}),w(t)&&Le.length>1&&(0,G.jsx)(`div`,{className:`-ml-2 -mb-1 mt-0.5 flex items-center`,"data-no-drag":``,children:(0,G.jsx)(r.Z,{compact:!0,portal:!0,direction:`auto`,variant:`ghost`,ariaLabel:`Move “${t.name}” to another category`,value:e.id,options:Le.map(e=>({value:e.id,label:e.title||`Untitled Category`})),onChange:n=>{n!==e.id&&Te(t.id,n,0)}})}),t.fields&&t.fields.length>0&&(0,G.jsx)(`div`,{className:`flex flex-row flex-wrap gap-2 mt-2`,children:t.fields.map((e,t)=>(0,G.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,G.jsxs)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative -top-[1px] shrink-0 break-all`,children:[e.key,`:`]}),(0,G.jsx)(`span`,{className:`text-[12px] text-foreground/90 font-medium break-words leading-tight min-w-0`,children:e.value})]},t))}),(0,G.jsxs)(`div`,{className:`flex items-end justify-between mt-3 pt-3 border-t border-[var(--panel-border)]/50 w-full gap-2`,children:[(()=>{let e=S&&m?Oi(t,p):null;return e?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`,children:[e.avatar?(0,G.jsx)(r.O,{src:e.avatar,alt:``,className:`w-4 h-4 rounded-full shrink-0`}):(0,G.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:e.name[0].toUpperCase()}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold text-foreground/60 truncate max-w-[80px]`,children:e.name})]}):(0,G.jsx)(`div`,{className:`flex items-center gap-2 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`})})(),(0,G.jsx)(`span`,{className:`text-[10px] text-foreground/40 font-bold text-right pt-0.5 shrink-0 max-w-[50%] truncate flex-1`,children:t.id.startsWith(`item_`)?new Date(parseInt(t.id.split(`_`)[1])).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`Recently Added`})]})))}),c&&o.length>0&&(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`h-0.5 -mt-1 rounded-full bg-accent`}),ae===e.id?(0,G.jsxs)(r.nt.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,G.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Ae(e.id)}}),(0,G.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:H.name,onChange:e=>le({...H,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Ae(e.id))},autoFocus:!0}),(0,G.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:U.map((t,n)=>(0,G.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,G.jsx)(`input`,{placeholder:I,style:{width:`${Math.max(3,t.key.length||I.length)}ch`},value:t.key,onChange:e=>we(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&Ae(e.id),className:`no-glow bg-transparent outline-none text-[11px] text-foreground/50 font-bold placeholder:text-foreground/30 relative top-[1px]`}),(0,G.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,G.jsx)(`textarea`,{rows:1,placeholder:L,value:t.value,onChange:e=>we(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(),Ae(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))}),me===`new`&&(0,G.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,G.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]}):(0,G.jsxs)(`button`,{onClick:()=>Ce(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,G.jsx)(T.t,{className:`w-4 h-4`}),` Add Item`]})]})]},e.id)}),(0,G.jsx)(`div`,{className:`w-[10px] shrink-0 pointer-events-none`}),Ee&&ke&&typeof document<`u`&&(0,de.createPortal)((0,G.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none fixed z-[9995] rotate-[1.5deg] rounded-xl border border-accent/40 bg-background/95 p-3 shadow-2xl`,style:{left:Ee.x-Ee.offsetX,top:Ee.y-Ee.offsetY,width:Ee.width},children:(0,G.jsx)(`p`,{className:`text-[13px] text-foreground/90 font-medium leading-snug break-words`,children:ke.name})}),document.body)]})})]})]}),(0,G.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,G.jsx)(re.t,{isOpen:!!xe,title:`Confirm Deletion`,message:(0,G.jsxs)(G.Fragment,{children:[`Are you sure you want to delete `,(0,G.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:xe?.title}),` This action is permanent.`]}),onConfirm:Ie,onCancel:()=>Z(null),isProcessing:ge,confirmText:`Yes, Delete`})]})}function ho(e){return Array.isArray?Array.isArray(e):To(e)===`[object Array]`}function go(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 _o(e){return e==null?``:go(e)}function vo(e){return typeof e==`string`}function yo(e){return typeof e==`number`}function bo(e){return e===!0||e===!1||So(e)&&To(e)==`[object Boolean]`}function xo(e){return typeof e==`object`}function So(e){return xo(e)&&e!==null}function Co(e){return e!=null}function wo(e){return!e.trim().length}function To(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var Eo=`Incorrect 'index' type`,Do=e=>`Invalid value for key ${e}`,Oo=e=>`Pattern length exceeds max of ${e}.`,ko=e=>`Missing ${e} property in key`,Ao=e=>`Property 'weight' in key '${e}' must be a positive integer`,jo=Object.prototype.hasOwnProperty,Mo=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=No(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 No(e){let t=null,n=null,r=null,i=1,a=null;if(vo(e)||ho(e))r=e,t=Po(e),n=Fo(e);else{if(!jo.call(e,`name`))throw Error(ko(`name`));let o=e.name;if(r=o,jo.call(e,`weight`)&&(i=e.weight,i<=0))throw Error(Ao(o));t=Po(o),n=Fo(o),a=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:a}}function Po(e){return ho(e)?e:e.split(`.`)}function Fo(e){return ho(e)?e.join(`.`):e}function Io(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(Co(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!Co(s))return;if(a===t.length-1&&(vo(s)||yo(s)||bo(s)||typeof s==`bigint`))n.push(o===void 0?_o(s):{v:_o(s),i:o});else if(ho(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,vo(t)?t.split(`.`):t,0),r?n:n[0]}var Lo={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Ro={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},zo={location:0,threshold:.6,distance:100},Bo={useExtendedSearch:!1,useTokenSearch:!1,getFn:Io,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},$=Object.freeze({...Ro,...Lo,...zo,...Bo}),Vo=/[^ ]+/g;function Ho(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=t.match(Vo).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 Uo=class{constructor({getFn:e=$.getFn,fieldNormWeight:t=$.fieldNormWeight}={}){this.norm=Ho(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,vo(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();vo(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(!Co(e)||wo(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(Co(i)){if(ho(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(Co(n)){if(vo(n)){if(!wo(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(Co(n.v)){let t=vo(n.v)?n.v:_o(n.v);if(!wo(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[r]=e}else if(vo(i)&&!wo(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 Wo(e,t,{getFn:n=$.getFn,fieldNormWeight:r=$.fieldNormWeight}={}){let i=new Uo({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(No)),i.setSources(t),i.create(),i}function Go(e,{getFn:t=$.getFn,fieldNormWeight:n=$.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new Uo({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function Ko(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 qo=32;function Jo(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>qo)throw Error(Oo(qo));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=Ko(_,s);e.length?c&&(C.indices=e):C.isMatch=!1}return C}function Yo(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 Xo(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 Zo={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},Qo=RegExp(`[`+Object.keys(Zo).join(``)+`]`,`g`),$o=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(Qo,e=>Zo[e]):e=>e,es=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?$o(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:Yo(e),startIndex:t})},d=this.pattern.length;if(d>qo){let e=0,t=d%qo,n=d-t;for(;e<n;)u(this.pattern.substr(e,qo),e),e+=qo;if(t){let e=d-qo;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?$o(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}=Jo(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=Xo(u)),p}},ts=class{constructor(e){this.pattern=e}static isMultiMatch(e){return ns(e,this.multiRegex)}static isSingleMatch(e){return ns(e,this.singleRegex)}search(e){return{isMatch:!1,score:1}}};function ns(e,t){let n=e.match(t);return n?n[1]:null}var rs=class extends ts{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]}}},is=class extends ts{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]}}},as=class extends ts{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]}}},os=class extends ts{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]}}},ss=class extends ts{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]}}},cs=class extends ts{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]}}},ls=class extends ts{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 es(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)}},us=class extends ts{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}}},ds=[rs,us,as,os,cs,ss,is,ls],fs=ds.length,ps=`\0`,ms=`|`;function hs(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 gs(e,t={}){return e.replace(/\\\|/g,ps).split(ms).map(e=>{let n=hs(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<fs;){let e=ds[o],n=e.isMultiMatch(i);n&&(r.push(new e(n,t)),a=!0)}if(!a)for(o=-1;++o<fs;){let e=ds[o],n=e.isSingleMatch(i);if(n){r.push(new e(n,t));break}}}return r})}var _s=new Set([ls.type,us.type]),vs=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?$o(e):e,this.pattern=e,this.query=gs(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?$o(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&&(_s.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=Xo(o)),e}}return{isMatch:!1,score:1}}},ys=[];function bs(...e){ys.push(...e)}function xs(e,t){for(let n=0,r=ys.length;n<r;n+=1){let r=ys[n];if(r.condition(e,t))return new r(e,t)}return new es(e,t)}var Ss={AND:`$and`,OR:`$or`},Cs={PATH:`$path`,PATTERN:`$val`},ws=e=>!!(e[Ss.AND]||e[Ss.OR]),Ts=e=>!!e[Cs.PATH],Es=e=>!ho(e)&&xo(e)&&!ws(e),Ds=e=>({[Ss.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Os(e,t,{auto:n=!0}={}){let r=e=>{if(vo(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=xs(e,t)),r}let i=Object.keys(e),a=Ts(e);if(!a&&i.length>1&&!ws(e))return r(Ds(e));if(Es(e)){let r=a?e[Cs.PATH]:i[0],o=a?e[Cs.PATTERN]:e[r];if(!vo(o))throw Error(Do(r));let s={keyId:Fo(r),pattern:o};return n&&(s.searcher=xs(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];ho(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return ws(e)||(e=Ds(e)),r(e)}function ks(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 As(e,{ignoreFieldNorm:t=$.ignoreFieldNorm}){e.forEach(e=>{e.score=ks(e.matches,{ignoreFieldNorm:t})})}var js=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 Ms(e,t){let n=e.matches;t.matches=[],Co(n)&&n.forEach(e=>{if(!Co(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 Ns(e,t){t.score=e.score}function Ps(e,t,{includeMatches:n=$.includeMatches,includeScore:r=$.includeScore}={}){let i=[];return n&&i.push(Ms),r&&i.push(Ns),e.map(e=>{let{idx:n}=e,r={item:t[n],refIndex:n};return i.length&&i.forEach(t=>{t(e,r)}),r})}var Fs=/\b\w+\b/g;function Is({isCaseSensitive:e=!1,ignoreDiacritics:t=!1}={}){return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=$o(n)),n.match(Fs)||[]}}}function Ls(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 Rs(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 zs(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 Bs=class{constructor(e,t,n){this.options={...$,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Mo(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=xs(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 Uo))throw Error(Eo);if(this._myIndex=t||Wo(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=Is({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});this._invertedIndex=Ls(this._myIndex.records,this._myIndex.keys.length,e)}}add(e){if(Co(e)&&(this._docs.push(e),this._myIndex.add(e),this._invertedIndex)){let e=this._myIndex.records[this._myIndex.records.length-1],t=Is({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});Rs(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)zs(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&&zs(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(vo(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return yo(n)&&n>-1&&(e=e.slice(0,n)),e}let c=yo(n)&&n>0&&vo(e),l;if(c){let t=new js(n);vo(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=vo(e)?vo(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),As(l,{ignoreFieldNorm:s}),a&&l.sort(o),yo(n)&&n>-1&&(l=l.slice(0,n));return Ps(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(!Co(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=ks(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):a.push(r)}}),a}_searchLogical(e){let t=Os(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===Ss.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(Co(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(!Co(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=ks(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}),o}_findMatches({key:e,value:t,searcher:n}){if(!Co(t))return[];let r=[];if(ho(t))t.forEach(({v:t,i,n:a})=>{if(!Co(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}},Vs=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=Is({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 es(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=Xo(t)),o}};Bs.version=`7.3.0`,Bs.createIndex=Wo,Bs.parseIndex=Go,Bs.config=$,Bs.match=function(e,t,n){return xs(e,{...$,...n}).searchIn(t)},Bs.parseQuery=Os,bs(vs),bs(Vs),Bs.use=function(...e){e.forEach(e=>bs(e))};var Hs=[{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 Us({title:e=`Table View`,subtitle:t=`/table`,backUrl:l,tableCollection:u=`pub_table_data`,config:d,customContent:f}){let{user:p}=r.Ft(),m=!!d,h=d?.isInternal||d?.isShared;d?.isPrivate&&d?.isAdmin;let g=d?.isAdmin||h,_=o.Tn(u),y=c.f(),b=c.F(u),x=m?g||_||u.startsWith(`role_`):!0,[S,w]=(0,W.useState)(()=>_?c.u(u):``),E=c.o({on:u.startsWith(`user_`)&&!_,everyone:!1}),D=E.uid||p?.uid||``,O=(e,t)=>p?_?t?c.l({uid:p.uid,...Ti(p),...e},p.uid):e:u.startsWith(`user_`)?{...e,uid:D||p.uid}:t?{uid:p.uid,...e}:e:e,j=!!f,N=d?.showButton!==!1&&!j,ee=d?.buttonText||`+`,P=d?.buttonStyle||`secondary`,te=d?.showExportButton!==!1,[F,I]=(0,W.useState)([]),L=_?b.records:F,[ne,R]=(0,W.useState)(`demo`),[z,ie]=(0,W.useState)(!1),[B,V]=(0,W.useState)(!1),[ae,oe]=(0,W.useState)(``),[se,ce]=(0,W.useState)(!1),[H,le]=(0,W.useState)(null),[U,ue]=(0,W.useState)(null),[K,J]=(0,W.useState)(``),[Y,de]=(0,W.useState)(!1),[fe,pe]=(0,W.useState)(``),[me,he]=(0,W.useState)(null),[ge,_e]=(0,W.useState)(null),[X,ve]=(0,W.useState)(null),[ye,be]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=u.startsWith(`user_`);if(e&&!p||_)return;let t=e?`${u}|${D}`:u;try{let e=localStorage.getItem(`fbos_tables_${t}`);e&&I(JSON.parse(e))}catch{}let n=(0,q.onSnapshot)(e&&p?(0,q.query)((0,q.collection)(r.ui,u),(0,q.where)(`uid`,`==`,D||p.uid)):(0,q.collection)(r.ui,u),n=>{let i=[];if(n.forEach(e=>{i.push({id:e.id,...e.data()})}),i.length===0){let t={name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`,`Column 4`],...p?{uid:D||p.uid}:{},rows:[{id:`1`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``},{id:`2`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``}]};(0,q.setDoc)((0,q.doc)(r.ui,u,e&&p?`demo_${D||p.uid}`:`demo`),t)}else{let e=i.sort((e,t)=>(e.name||``).localeCompare(t.name||``));I(e),localStorage.setItem(`fbos_tables_${t}`,JSON.stringify(e))}},a.s);return()=>n()},[u,p,_,D]);let xe=(0,W.useRef)(!1);(0,W.useEffect)(()=>{!_||!p||b.loading||b.records.length||xe.current||(xe.current=!0,(0,q.setDoc)((0,q.doc)(r.ui,u,`demo_${p.uid}`),c.l({uid:p.uid,...Ti(p),name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`,`Column 4`],rows:[{id:`1`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``},{id:`2`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``}]},p.uid)))},[_,p,b.loading,b.records.length,u]);let Z=L.find(e=>e.id===ne)||L[0]||{columns:[],rows:[]},Q=!_||c.C(Z,y),Se=async e=>{Z.id&&(p&&u.startsWith(`user_`)&&(e.uid=D||p.uid),await(0,q.setDoc)((0,q.doc)(r.ui,u,Z.id),e,{merge:!0}))},Ce=()=>{if(!Z.rows||Z.rows.length===0)return;let e=Z.columns.join(`,`),t=Z.rows.map(e=>Z.columns.map(t=>`"${e[t]||``}"`).join(`,`)).join(`
|
|
6
|
-
`),n=new Blob([`${e}\n${t}`],{type:`text/csv`}),r=window.URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`export_${Z.name||`table`}.csv`,i.click(),window.URL.revokeObjectURL(r)},we=(e,t,n)=>{Se({...Z,rows:Z.rows.map(r=>r.id===e?{...r,[t]:n}:r)})},Te=()=>{let e=Ti(p),t={id:Date.now().toString(),...p?{_uid:p.uid,_creatorName:e.creatorName,_creatorAvatar:e.creatorAvatar}:{}};Z.columns.forEach(e=>t[e]=``),Se({...Z,rows:[...Z.rows||[],t]})},Ee=e=>{Se({...Z,rows:Z.rows.filter(t=>t.id!==e)})},De=()=>{X&&(X.kind===`row`?Ee(X.id):ke(X.name),ve(null))},Oe=()=>{let e=`Column ${(Z.columns?.length||0)+1}`;Z.columns?.includes(e)||(Se({...Z,columns:[...Z.columns||[],e]}),setTimeout(()=>{let e=document.getElementById(`table-scroll-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},100))},ke=e=>{let t=(Z.columns||[]).filter(t=>t!==e),n=(Z.rows||[]).map(t=>{let n={...t};return delete n[e],n}),r={...Z.colColors||{}};delete r[e],Se({...Z,columns:t,rows:n,colColors:r})},Ae=async e=>{e.trim()&&Z.id&&e!==Z.name&&await(0,q.setDoc)((0,q.doc)(r.ui,u,Z.id),{name:e},{merge:!0})},je=async()=>{ce(!0),ie(!1);let e=`tbl_${Date.now()}`;await(0,q.setDoc)((0,q.doc)(r.ui,u,e),{name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`],...p?{uid:p.uid}:{},rows:[]}),setTimeout(()=>{R(e),ce(!1)},600)},Me=e=>{let t=fe.trim();if(t&&t!==e&&!Z.columns?.includes(t)){let n=Z.columns.map(n=>n===e?t:n),r=(Z.rows||[]).map(n=>{let r={...n};return r[t]=r[e]||``,delete r[e],r}),i={...Z.colColors||{}};i[e]&&(i[t]=i[e],delete i[e]),Se({...Z,columns:n,rows:r,colColors:i})}ue(null)},Ne=e=>Oi({uid:e._uid,creatorName:e._creatorName,creatorAvatar:e._creatorAvatar},p),Pe=Z.rows||[];return K.trim()!==``&&(Pe=new Bs(Pe.map(e=>({...e,_creatorMatch:Ne(e)?.name||``})),{keys:(Z.columns||[]).concat([`_creatorMatch`]),threshold:.4,ignoreLocation:!0}).search(K).map(e=>{let{_creatorMatch:t,...n}=e.item;return n})),(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4 md:mb-6 flex items-center gap-3`,children:[!m&&l&&(0,G.jsx)(c.r,{to:l}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(n.t,{children:e}),t&&(0,G.jsxs)(`div`,{className:`max-sm:hidden sm:flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,G.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 min-h-0 pb-16`,children:[m&&(0,G.jsx)(i.t,{}),(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden shadow-2xl relative z-10 flex flex-col flex-1 min-h-[400px]`,children:[(0,G.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,G.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,G.jsxs)(`div`,{className:`flex flex-col min-w-0 relative`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,G.jsxs)(`div`,{className:`relative flex items-center`,children:[B?(0,G.jsx)(`div`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:e=>{V(!1),Ae(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:Z.name||`Unnamed Table`}):(0,G.jsx)(`h3`,{className:`font-bold text-[16px] text-foreground/90 hover:text-accent transition-colors truncate max-w-[38vw] sm:max-w-[200px] ${Q?`cursor-pointer`:``}`,onClick:()=>Q&&V(!0),title:Q?`Click to rename table`:void 0,children:Z.name||`Unnamed Table`}),(0,G.jsx)(r.rt,{children:z&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>ie(!1)}),(0,G.jsxs)(r.nt.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,G.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,G.jsx)(`div`,{className:`max-h-[250px] overflow-y-auto styled-scrollbars z-50 relative`,children:L.map(e=>(0,G.jsx)(`button`,{onClick:()=>{R(e.id),ie(!1)},className:`w-full px-4 py-2 text-[13px] font-bold text-left hover:bg-foreground/[0.03] transition-colors truncate ${ne===e.id?`text-accent bg-accent/5`:`text-foreground/70`}`,children:e.name||`Unnamed Table`},e.id))}),(0,G.jsx)(`div`,{className:`w-full h-[1px] bg-[var(--panel-border)]/50 my-1`}),(0,G.jsxs)(`button`,{onClick:je,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,G.jsx)(T.t,{className:`w-4 h-4`}),` Create New Table`]})]})]})})]}),(0,G.jsx)(`button`,{onClick:()=>ie(!z),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,G.jsx)(s.t,{className:`w-4 h-4 transition-transform ${z?`rotate-180 text-accent`:``}`})})]}),(0,G.jsxs)(`span`,{className:`opacity-40 text-[11px] font-bold mt-1 uppercase tracking-wider`,children:[(Z.rows||[]).length,` Records`]})]}),(0,G.jsx)(`div`,{className:`relative shrink-0 ${Y?`flex-1 min-w-[130px] max-w-[300px]`:``}`,children:Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(C.n,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-foreground/40`}),(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,"aria-label":`Search records`,placeholder:`Search records...`,value:K,onChange:e=>J(e.target.value),onBlur:()=>{K.trim()||de(!1)},onKeyDown:e=>{e.key===`Escape`&&(J(``),de(!1))},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,G.jsx)(`button`,{type:`button`,onClick:()=>de(!0),"aria-label":`Search records`,title:`Search records`,className:`w-10 h-10 flex items-center justify-center rounded-xl border border-[var(--panel-border)] text-foreground/50 hover:text-accent hover:bg-foreground/5 transition-colors`,children:(0,G.jsx)(C.n,{className:`w-4 h-4`})})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,G.jsx)(c.a,{viewing:E}),te&&(0,G.jsx)(M.t,{variant:`secondary`,onClick:Ce,className:`px-3 py-2.5 font-bold rounded-xl shadow-sm border border-[var(--panel-border)] flex items-center gap-2`,children:(0,G.jsx)(v.d,{className:`w-4 h-4`})}),N&&Q&&(0,G.jsx)(M.t,{variant:P===`primary`?void 0:`secondary`,onClick:Te,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:ee===`+`?(0,G.jsx)(T.t,{className:`w-4 h-4`}):ee})]})]}),(0,G.jsx)(`div`,{id:`table-scroll-container`,className:`overflow-auto w-full flex-1 min-h-[300px] relative styled-scrollbars`,children:f?(0,G.jsx)(c.p,{value:{prefix:o.Mn(d||{}),collection:_?u:``,recordId:_?Z.id||S:``},children:(0,G.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill p-4 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(f,{config:d,actions:{tables:L,activeTable:Z,collection:u,user:p,error:_?b.error:``,...c.s(u,y,_,S),saveTable:async(e,t)=>{let n=O(t,!L.some(t=>t.id===e));_&&e===S&&w(c.u(u)),I(t=>t.find(t=>t.id===e)?t.map(t=>t.id===e?{...t,...n}:t):[...t,{id:e,...n}]),await(0,q.setDoc)((0,q.doc)(r.ui,u,e),n,{merge:!0})},deleteTable:async e=>{I(t=>t.filter(t=>t.id!==e)),await(0,q.deleteDoc)((0,q.doc)(r.ui,u,e))},updateCell:(e,t,n)=>we(e,t,n),addRow:()=>Te(),addColumn:()=>Oe()}})})})}):(0,G.jsx)(r.rt,{mode:`wait`,children:se?(0,G.jsxs)(r.nt.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,G.jsx)(`div`,{className:`w-8 h-8 rounded-full border-2 border-accent border-r-transparent animate-spin mb-4`}),(0,G.jsx)(`p`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest`,children:`Generating Table`})]},`loader`):(0,G.jsxs)(r.nt.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,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)] transition-colors ${Z.headerColor?Hs.find(e=>e.text===Z.headerColor)?.bgAlt:`bg-foreground/[0.02]`}`,children:[(0,G.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 ${x?``:`hidden`}`,children:`Creator`}),(Z.columns||[]).map((e,t)=>{let n=(Z.colColors||{})[e],r=(Z.colorTimestamps||{})[`col_${e}`]||0;Z.headerColor;let a=(Z.colorTimestamps||{}).header||0,o=`bg-transparent`,s=`text-foreground/50`;if(n&&n!==`none`&&r>=a){let e=Hs.find(e=>e.text===n);e&&(o=e.bgCard,s=e.text)}return(0,G.jsx)(`th`,{className:`py-3 px-6 text-[12px] font-bold uppercase tracking-wider relative group h-[53px] min-w-[120px] ${s} ${o} border-r border-[var(--panel-border)]/20 last:border-r-0 select-none align-middle`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 w-full h-full`,children:[U===e?(0,G.jsx)(`div`,{className:`flex-1 min-w-[50px]`,children:(0,G.jsx)(`span`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>{ue(null),pe(t.currentTarget.textContent||``),(t.currentTarget.textContent||``).trim()!==``&&Me(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 ${s} block w-full whitespace-nowrap overflow-hidden cursor-text`,ref:e=>{e&&requestAnimationFrame(()=>{e.focus()})},children:fe})}):(0,G.jsx)(`div`,{className:`flex items-center gap-2 flex-1 overflow-hidden`,onClick:()=>{Q&&(ue(e),pe(e))},children:(0,G.jsx)(`span`,{className:`truncate cursor-text`,children:e})}),(0,G.jsxs)(`div`,{className:`relative shrink-0 flex items-center h-full gap-0.5`,children:[(0,G.jsx)(`button`,{onClick:()=>_e(ge===e?null:e),className:`p-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity hover:bg-foreground/10 ${n&&n!==`none`?`!opacity-100`:``} text-current`,children:(0,G.jsx)(i.E,{className:`w-4 h-4`})}),(Z.columns||[]).length>1&&(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Q&&ve({kind:`column`,name: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,G.jsx)(k.t,{className:`w-3.5 h-3.5`})}),ge===e&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>_e(null)}),(0,G.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,G.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...Z.colColors||{},[e]:`none`},r={...Z.colorTimestamps||{},[`col_${e}`]:Date.now()};Se({...Z,colColors:n,colorTimestamps:r}),_e(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,G.jsx)(C.t,{className:`w-3 h-3`})}),(0,G.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Hs.map(t=>(0,G.jsx)(`button`,{onClick:n=>{n.preventDefault(),n.stopPropagation();let r={...Z.colColors||{},[e]:t.text},i={...Z.colorTimestamps||{},[`col_${e}`]:Date.now()};Se({...Z,colColors:r,colorTimestamps:i}),_e(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_${t}_${e}`)}),(0,G.jsx)(`th`,{className:`py-4 px-4 w-14 border-l border-[var(--panel-border)]/30 relative`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5 relative z-20`,children:[(0,G.jsx)(`button`,{onClick:()=>be(!ye),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${Z.headerColor?Hs.find(e=>e.text===Z.headerColor)?.text:`text-foreground/30`}`,children:(0,G.jsx)(i.E,{className:`w-4 h-4`})}),ye&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>be(!1)}),(0,G.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,G.jsx)(`button`,{onClick:()=>{Se({...Z,headerColor:``}),be(!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,G.jsx)(C.t,{className:`w-3 h-3`})}),(0,G.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Hs.map(e=>(0,G.jsx)(`button`,{onClick:()=>{let t={...Z.colorTimestamps||{},header:Date.now()};Se({...Z,headerColor:e.text,colorTimestamps:t}),be(!1)},className:`w-4 h-4 rounded-full ${e.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},e.name))]})]}),(0,G.jsx)(`button`,{onClick:()=>Q&&Oe(),className:`p-1.5 rounded-lg text-foreground/40 hover:text-accent hover:bg-accent/10 transition-colors flex items-center justify-center ${Q?``:`hidden`}`,children:(0,G.jsx)(T.t,{className:`w-4 h-4`})})]})})]})}),(0,G.jsxs)(`tbody`,{children:[Pe.map((e,t)=>{let n=t%2==1,a=(Z.rowColors||{})[e.id],o=a?n?Hs.find(e=>e.text===a)?.bgAlt:Hs.find(e=>e.text===a)?.bgCard:n?`bg-foreground/[0.02]`:`bg-transparent`;return(0,G.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)]/30 hover:bg-foreground/[0.04] transition-colors group`,children:[(0,G.jsx)(`td`,{className:`py-4 px-6 whitespace-nowrap h-[53px] border-r border-[var(--panel-border)]/20 ${o} ${x?``:`hidden`}`,children:(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:m?(()=>{let t=Ne(e);return t?(0,G.jsxs)(G.Fragment,{children:[t.avatar?(0,G.jsx)(r.O,{src:t.avatar,alt:``,className:`w-5 h-5 rounded-full shrink-0`}):(0,G.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:t.name[0].toUpperCase()}),(0,G.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:t.name})]}):(0,G.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/30`,children:`—`})})():(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:`Guest`})]})})}),(Z.columns||[]).map(r=>{let i=H?.id===e.id&&H?.field===r,a=(Z.colColors||{})[r],o=(Z.colorTimestamps||{})[`col_${r}`]||0,s=(Z.rowColors||{})[e.id],c=(Z.colorTimestamps||{})[`row_${e.id}`]||0,l=``;l=c>o?s===`none`?``:s:o>c?a===`none`?``:a:s===`none`?``:s||a||``,l===`none`&&(l=``);let u=l?Hs.find(e=>e.text===l):null,d=u?n?u.bgAlt:u.bgCard:n?`bg-foreground/[0.02]`:`bg-transparent`,f=u?u.text:`text-foreground/80`;return(0,G.jsxs)(`td`,{className:`py-4 px-6 whitespace-pre-wrap min-w-[120px] text-[14px] font-medium relative ${d} align-top border-r border-[var(--panel-border)]/10 last:border-r-0`,onClick:()=>Q&&!i&&le({id:e.id,field:r}),children:[i?(0,G.jsx)(`textarea`,{autoFocus:!0,value:e[r]||``,onChange:t=>we(e.id,r,t.target.value),onBlur:()=>le(null),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&le(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 ${f} z-20 resize-none styled-scrollbars`}):null,(0,G.jsx)(`span`,{className:`block w-full min-h-[20px] break-words transition-all ${i?`opacity-0`:`opacity-100`} ${f} ${r===`Status`&&e[r]===`Active`&&!l?`text-green-500`:``}`,children:e[r]||(0,G.jsx)(`span`,{className:`opacity-30 italic font-normal`,children:`empty`})})]},`cell_${e.id||t}_${r}`)}),(0,G.jsx)(`td`,{className:`py-4 px-4 whitespace-nowrap text-right h-[53px] ${o} relative z-10`,children:(0,G.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,G.jsx)(`button`,{onClick:()=>he(me===e.id?null:e.id),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${a?Hs.find(e=>e.text===a)?.text:`text-foreground/40`}`,children:(0,G.jsx)(i.E,{className:`w-4 h-4`})}),me===e.id&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>he(null)}),(0,G.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,G.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...Z.rowColors||{},[e.id]:`none`},r={...Z.colorTimestamps||{},[`row_${e.id}`]:Date.now()};Se({...Z,rowColors:n,colorTimestamps:r}),he(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,G.jsx)(C.t,{className:`w-3 h-3`})}),(0,G.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Hs.map(t=>(0,G.jsx)(`button`,{onClick:()=>{let n={...Z.colorTimestamps||{},[`row_${e.id}`]:Date.now()};Se({...Z,rowColors:{...Z.rowColors||{},[e.id]:t.text},colorTimestamps:n}),he(null)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},t.name))]})]}),Q&&(0,G.jsx)(`button`,{onClick:()=>ve({kind:`row`,id:e.id}),title:`Delete row`,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,G.jsx)(k.t,{className:`w-4 h-4`})})]})})]},e.id||`row_${t}`)}),Pe.length===0&&(0,G.jsx)(`tr`,{children:(0,G.jsxs)(`td`,{colSpan:(Z.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 `,Z.name||`this table`,`.`]})}),(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:(Z.columns||[]).length+2,className:`py-2 px-4 border-none bg-foreground/[0.01]`,children:(0,G.jsx)(`div`,{className:`flex items-center gap-4`,children:(0,G.jsx)(`button`,{onClick:()=>Q&&Te(),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 ${Q?``:`hidden`}`,children:(0,G.jsx)(T.t,{className:`w-4 h-4`})})})})})]})]},`table`)})})]})]}),(0,G.jsx)(re.t,{isOpen:!!X,title:X?.kind===`column`?`Delete column`:`Delete row`,message:X?.kind===`column`?(0,G.jsxs)(G.Fragment,{children:[`Delete `,(0,G.jsx)(`strong`,{className:`text-foreground block my-1 break-words max-w-full text-center`,children:X.name}),` and everything filled in under it, in every row? This cannot be undone.`]}):(0,G.jsx)(G.Fragment,{children:`Delete this row and everything in it? This cannot be undone.`}),onConfirm:De,onCancel:()=>ve(null),confirmText:`Yes, delete`})]})}var Ws=[{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`}],Gs=e=>new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().split(`T`)[0],Ks=1,qs={dateStr:``,title:``,description:``,time:`12:00`,duration:`60`,color:``,guestEmail:``,customFields:{}};function Js({title:e=`Calendar View`,subtitle:t=`/calendar`,backUrl:a,eventsCollection:s=`pub_events`,defaultTimeFormat:l=`12h`,config:u,customContent:d}){let f=!!(u?.isPrivate||u?.isAdmin||u?.isInternal||u?.isShared);u?.isAdmin,u?.isInternal||u?.isShared,u?.isPrivate;let p=u?.showButton!==!1,m=u?.buttonText||`+`,h=u?.buttonStyle||`primary`,y=u?.showViewsButton!==!1,b=u?.viewsButtonStyle||`secondary`,x=u?.defaultView||`calendar`,S=u?.customFields||[],w=o.Tn(s)?`case`:s.startsWith(`user_`)?`user`:s.startsWith(`mem_`)||s.startsWith(`role_`)?`internal`:s.startsWith(`admin_`)?`admin_only`:`public`,E=w===`case`,D=c.o({on:w===`user`}),[O,j]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`cal_view_${s}`);if(e===`list`||e===`month`)return e}catch{}return x===`board`?`list`:`month`}),[N,ee]=(0,W.useState)([]),P=c.f(),te=c.F(s),F=E?te.records:N,[I,L]=(0,W.useState)(()=>E?c.u(s):``),[ne,R]=(0,W.useState)(!1),[z,ie]=(0,W.useState)(null),[B,V]=(0,W.useState)(!1),[ae,oe]=(0,W.useState)(!1),[se,ce]=(0,W.useState)(null),[H,le]=(0,W.useState)(qs),[U,ue]=(0,W.useState)(new Date),[J,de]=(0,W.useState)(null),[fe,pe]=(0,W.useState)(null),[me,he]=(0,W.useState)(!1),ge=D.uid||J?.uid||``,_e=`cal_24h_${s}`,[X,ve]=(0,W.useState)(()=>{try{let e=localStorage.getItem(_e);if(e!==null)return e===`true`}catch{}return l===`24h`}),ye=()=>{let e=!X;ve(e);try{localStorage.setItem(_e,String(e))}catch{}};(0,W.useEffect)(()=>{try{localStorage.setItem(`cal_view_${s}`,O)}catch{}},[O,s,w]);let be=()=>{let e=O===`month`?`list`:`month`;j(e);try{localStorage.setItem(`cal_view_${s}`,e)}catch{}},xe=()=>{try{return sessionStorage.getItem(`cal_guest_email`)||``}catch{return``}},Z=e=>{try{sessionStorage.setItem(`cal_guest_email`,e)}catch{}};(0,W.useEffect)(()=>(0,K.onAuthStateChanged)(r.li,async e=>{if(de(e),e&&w===`admin_only`)try{let t=await(0,q.getDoc)((0,q.doc)(r.ui,`user_profiles`,e.uid));t.exists()&&pe(t.data())}catch{}he(!0)}),[w]);let Q=Gs(new Date(U.getFullYear(),U.getMonth()-Ks,1)),Se=Gs(new Date(U.getFullYear(),U.getMonth()+Ks+1,0));(0,W.useEffect)(()=>{if(!me||E)return;if(w!==`public`&&!J){ee([]);return}let e=w===`user`?`${s}|${D.everyone?`everyone`:ge}`:s;try{let t=localStorage.getItem(`fbos_cal_${e}`);t&&ee(JSON.parse(t))}catch{}let t=(0,q.onSnapshot)(w===`user`&&J&&!D.everyone?(0,q.query)((0,q.collection)(r.ui,s),(0,q.where)(`uid`,`==`,ge)):(0,q.query)((0,q.collection)(r.ui,s),(0,q.where)(`dateStr`,`>=`,Q),(0,q.where)(`dateStr`,`<=`,Se)),t=>{let n=[];t.forEach(e=>n.push({id:e.id,...e.data()})),ee(n),localStorage.setItem(`fbos_cal_${e}`,JSON.stringify(n))},e=>console.error(`Calendar events:`,e));return()=>t()},[s,w,J?.uid,me,Q,Se,E,ge,D.everyone]);let Ce=e=>!!J&&J.uid===e.uid,we=e=>w===`public`?!1:w===`user`?!!J:E?c.C(e,P):Ce(e),Te=(e,t)=>!J||w===`public`?e:w===`user`?{...e,uid:ge||J.uid}:E?t?c.l({uid:J.uid,creatorEmail:J.email||``,creatorName:J.displayName||``,creatorAvatar:J.photoURL||``,...e},J.uid):e:t?{uid:J.uid,creatorEmail:J.email||``,creatorName:J.displayName||``,creatorAvatar:J.photoURL||``,...e}:e,Ee=e=>{if(!e)return``;if(X)return e;let[t,n]=e.split(`:`),r=parseInt(t,10),i=r>=12?`PM`:`AM`;return r=r%12||12,`${r}:${n} ${i}`},De=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`},Oe=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}},ke=(e,t,n)=>{let r=e%12;return n===`PM`&&(r+=12),`${r.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},Ae=Gs,je=()=>Ae(new Date),Me=new Date(U.getFullYear(),U.getMonth(),1),Ne=new Date(U.getFullYear(),U.getMonth()+1,0),Pe=Me.getDay(),Fe=Ne.getDate(),Ie=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Le=Array.from({length:42},(e,t)=>{let n=t-Pe+1,r=new Date(U.getFullYear(),U.getMonth(),n);return{day:r.getDate(),dateStr:Ae(r),isCurrentMonth:n>0&&n<=Fe}}),Re=()=>ue(O===`month`?new Date(U.getFullYear(),U.getMonth()-1,1):new Date(U.getFullYear(),U.getMonth(),U.getDate()-1)),ze=()=>ue(O===`month`?new Date(U.getFullYear(),U.getMonth()+1,1):new Date(U.getFullYear(),U.getMonth(),U.getDate()+1)),Be=e=>{if(w!==`public`&&!J)return;let t=new Date;t.setDate(t.getDate()+1);let n=new Date().getHours().toString().padStart(2,`0`);le({...qs,dateStr:e||Ae(t),time:`${n}:00`,guestEmail:w===`public`?xe():``,customFields:{}}),R(!0)},Ve=e=>{let t=e.time;if(t){let[e,n]=t.split(`:`);e&&n&&(t=`${e.padStart(2,`0`)}:${n}`)}le({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||{}}),R(!0)},He=async e=>{if(e.preventDefault(),H.title.trim()){V(!0);try{let e={dateStr:H.dateStr,title:H.title.trim(),description:H.description.trim(),time:H.time,duration:H.duration||`60`};if(H.color&&(e.color=H.color),S.length>0&&(e.customFields=H.customFields),!H.id)if(w===`public`){let t=H.guestEmail.trim();e.creatorEmail=t,Z(t)}else w===`user`||w===`internal`?(e.uid=J?.uid,e.creatorEmail=J?.email||``,e.creatorName=J?.displayName||``,e.creatorAvatar=J?.photoURL||``):w===`admin_only`&&(e.uid=J?.uid,e.creatorEmail=fe?.email||J?.email||``,e.creatorName=fe?.displayName||fe?.name||``,e.creatorAvatar=fe?.avatar||fe?.avatarUrl||J?.photoURL||``);let t=Te(e,!H.id);H.id?(await(0,q.setDoc)((0,q.doc)(r.ui,s,H.id),t,{merge:!0}),z?.id===H.id&&ie({...z,...e})):(await(0,q.setDoc)((0,q.doc)(r.ui,s,E?I||c.u(s):`ev_${Date.now()}`),t,{merge:!0}),E&&L(c.u(s))),R(!1)}catch(e){console.error(e)}V(!1)}},Ue=async()=>{if(se){oe(!0);try{await(0,q.deleteDoc)((0,q.doc)(r.ui,s,se.id)),z?.id===se.id&&ie(null),ce(null),R(!1)}catch{}oe(!1)}},We=e=>{if(w===`user`||!e.creatorEmail&&!e.creatorName)return null;let t=(e.creatorName||e.creatorEmail||`?`).charAt(0).toUpperCase(),n=Ws.find(t=>t.text===e.color);return(0,G.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,G.jsx)(r.O,{src:e.creatorAvatar,alt:``,className:`w-8 h-8 rounded-full shrink-0`}):(0,G.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,G.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[e.creatorName&&(0,G.jsx)(`span`,{className:`text-[13px] font-bold text-foreground/90 truncate`,children:e.creatorName}),e.creatorEmail&&(0,G.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate`,children:e.creatorEmail})]})]})},Ge=e=>{if(w===`user`||w===`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,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[e.creatorAvatar?(0,G.jsx)(r.O,{src:e.creatorAvatar,alt:``,className:`w-5 h-5 rounded-full shrink-0`}):(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),e.creatorEmail&&(0,G.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,e.creatorEmail]})]})]})};if(me&&w!==`public`&&!J)return(0,G.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen p-8`,children:(0,G.jsxs)(`div`,{className:`text-center glass-panel border border-[var(--panel-border)] rounded-3xl p-12 max-w-sm w-full`,children:[(0,G.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,G.jsx)(n.h,{className:`w-7 h-7 text-accent`})}),(0,G.jsx)(`h2`,{className:`text-2xl font-bold mb-2`,children:`Sign in required`}),(0,G.jsx)(`p`,{className:`text-foreground/50 text-[14px] mb-6`,children:`You need to be signed in to access this calendar.`}),(0,G.jsx)(Y.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(!me&&w!==`public`)return(0,G.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen`,children:(0,G.jsx)(C.r,{className:`w-8 h-8 animate-spin text-accent`})});let Ke=!!d,qe=(w===`public`||!!J)&&p&&!Ke,Je=()=>(0,G.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,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`h2`,{className:`text-xl font-bold text-foreground tracking-tight truncate`,children:u?.tabTitle||u?.tabName||e}),(0,G.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[F.length,` `,F.length===1?`event`:`events`,` · `,O===`month`?`Month`:`Board`,` View`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,G.jsx)(c.a,{viewing:D}),(0,G.jsx)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:ye,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:X?`24h`:`12h`}),y&&!Ke&&(0,G.jsx)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:be,title:O===`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 ${b===`primary`?`btn-primary`:`btn-secondary`}`,children:O===`month`?(0,G.jsx)(it,{className:`w-4 h-4`}):(0,G.jsx)(g.b,{className:`w-4 h-4`})}),qe&&(0,G.jsx)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>Be(),title:`Add event`,"aria-label":`Add event`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${m===`+`?`w-10`:`px-5`} ${h===`primary`?`btn-primary`:`btn-secondary`}`,children:m===`+`?(0,G.jsx)(T.t,{className:`w-4 h-4`}):(0,G.jsx)(`span`,{className:`text-[13px] font-bold`,children:m})})]})]}),Ye=()=>(0,G.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,G.jsx)(`h3`,{className:`text-lg md:text-xl font-bold tracking-tight ml-2 min-w-0`,children:O===`month`?U.toLocaleString(`default`,{month:`long`,year:`numeric`}):U.toLocaleString(`default`,{month:`long`,day:`numeric`,year:`numeric`})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`button`,{onClick:()=>ue(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,G.jsx)(`button`,{onClick:Re,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,G.jsx)(_.t,{className:`w-5 h-5`})}),(0,G.jsx)(`button`,{onClick:ze,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,G.jsx)(r.kt,{className:`w-5 h-5`})})]})]}),Ze=()=>(0,G.jsxs)(G.Fragment,{children:[Ye(),d?(0,G.jsx)(c.p,{value:{prefix:o.Mn(u||{}),collection:E?s:``,recordId:E?I:``},children:(0,G.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill p-4 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(d,{config:u,actions:{events:F,loading:E?te.loading:!me,error:E?te.error:``,collection:s,currentUser:J,...c.s(s,P,E,I),user:J,saveEvent:async e=>{let t=e.id||(E?I:``)||`ev_${Date.now()}`,n=Te(e,!F.some(e=>e.id===t));E&&t===I&&L(c.u(s)),ee(e=>e.find(e=>e.id===t)?e.map(e=>e.id===t?{...e,...n}:e):[...e,{id:t,...n}]),await(0,q.setDoc)((0,q.doc)(r.ui,s,t),n,{merge:!0})},deleteEvent:async e=>{ee(t=>t.filter(t=>t.id!==e)),await(0,q.deleteDoc)((0,q.doc)(r.ui,s,e))},openAddModal:e=>Be(e),openEditModal:e=>Ve(e),setViewingEvent:e=>ie(e),currentDate:U,setCurrentDate:ue,goToPrev:Re,goToNext:ze,goToToday:()=>ue(new Date)}})})})}):O===`month`?(0,G.jsx)(`div`,{className:`overflow-x-auto w-full flex-1`,children:(0,G.jsxs)(`div`,{className:`min-w-[800px] h-full flex flex-col`,children:[(0,G.jsx)(`div`,{className:`grid grid-cols-7 border-b border-[var(--panel-border)]/50 bg-foreground/[0.02]`,children:Ie.map(e=>(0,G.jsx)(`div`,{className:`py-3 text-center text-[12px] font-bold uppercase tracking-wider text-foreground/40`,children:e},e))}),(0,G.jsx)(`div`,{className:`grid grid-cols-7 auto-rows-auto bg-[var(--panel-border)] gap-[1px] relative flex-1`,children:Le.map((e,t)=>{let n=e.dateStr===je(),r=F.filter(t=>t.dateStr===e.dateStr);return(0,G.jsxs)(`div`,{onClick:()=>e.isCurrentMonth&&qe&&Be(e.dateStr),className:`min-h-[140px] p-2 bg-[var(--panel-bg)] flex flex-col relative group
|
|
7
|
-
${e.isCurrentMonth?qe?`hover:bg-foreground/[0.03] transition-colors cursor-cell`:``:`opacity-30 bg-background/50 pointer-events-none`}`,children:[(0,
|
|
3
|
+
`)||(n[r]=i)}return n}function Wi(){let[e,t]=(0,K.useState)(null);return(0,K.useEffect)(()=>(0,J.onSnapshot)((0,J.doc)(r.ui,`sys_configs`,Bi),e=>t(Hi(e.exists()?e.data():null)),()=>t({})),[]),e}async function Gi(e){if(Object.keys(e).length)try{await(0,J.setDoc)((0,J.doc)(r.ui,`sys_configs`,Bi),{copies:e},{merge:!0})}catch{}}function Ki({from:e,leaveOut:t}){return C.g(e,{leaveOut:t}),null}function qi(){let{userRole:e}=r.Ft();return o.Sn(e)?(0,q.jsx)(Ji,{}):null}function Ji(){let e=B.u(),t=Wi(),{pathname:n}=(0,Y.useLocation)(),r=(0,K.useMemo)(()=>e?C.u(e):[],[e]);if((0,K.useEffect)(()=>{if(!t||!r.length)return;let e={};for(let t of r){let n=C.f(t.from);n&&(e[t.from]={leaveOut:[...n].sort()})}let n=Ui(e,t);Object.keys(n).length&&Gi(n)},[r,t,n]),!t)return null;let i=new Map;for(let e of r)t[e.from]&&i.set(e.from,t[e.from].leaveOut);return(0,q.jsx)(q.Fragment,{children:[...i].map(([e,t])=>(0,q.jsx)(Ki,{from:e,leaveOut:t},e))})}r.si(()=>Promise.resolve().then(()=>require(`./PhoneInputField-WYdkNEym.cjs`)));function Yi({children:e,className:t,variant:n=`primary`,pendingLabel:i=`Opening checkout…`,disabled:a=!1,...s}){let{loading:c,configured:l}=r.zn(),u=r.Rr(),{userRole:d}=r.Ft(),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(null);return c?null:l?(0,q.jsxs)(`span`,{className:`inline-flex flex-col items-stretch gap-2`,children:[(0,q.jsx)(N.t,{variant:n,className:t,onClick:async()=>{if(f||a)return;if(p(!0),h(null),s.amount!=null&&!s.currency&&!u&&await r.Ir()){h(r.Pr),p(!1);return}let e=await r.Fn(s);e&&(h(e),p(!1))},disabled:f||a,children:f?i:e??`Pay`}),m&&(0,q.jsx)(`span`,{role:`alert`,className:`text-[13px] font-semibold text-red-400 leading-snug`,children:m})]}):o.wn(d)?(0,q.jsx)(`span`,{className:`text-[12.5px] font-medium text-foreground/50 leading-snug`,children:`Only admins see this: payments are not on yet, so this button is hidden. Connect Stripe and switch payments on at /payments and it appears here.`}):null}function Xi(){let{id:e=``}=(0,Y.useParams)(),{activeConfig:t}=i.N(),n=r.zn(),a=r.Rr(),s=a||`usd`,[c,l]=(0,K.useState)({loading:!0,product:null});(0,K.useEffect)(()=>{let t=!1;return(0,J.getDoc)((0,J.doc)(r.ui,r.Qn,e)).then(e=>{t||l({loading:!1,product:e.exists()?r.Dr(e.id,e.data()):null})}).catch(()=>{t||l({loading:!1,product:null})}),()=>{t=!0}},[e]);let u=c.product,d=u?.customPath.trim()||``;if(d)return(0,q.jsx)(Y.Navigate,{to:d.startsWith(`/`)?d:`/${d}`,replace:!0});let f=u?r.gr(u).filter(e=>r.br(e.amount)):[],p=u?.name.trim()||f[0]?.name.trim()||`Pay`;return(0,q.jsx)(`main`,{className:`flex-1 w-full max-w-3xl mx-auto px-4 pt-2 pb-16 md:pt-4 z-10 flex flex-col`,children:(0,q.jsx)(r.nt.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:`w-full rounded-3xl glass-panel border border-[var(--panel-border)] p-5 sm:p-8 md:p-10 shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:c.loading?(0,q.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-16 text-foreground/50`,children:[(0,q.jsx)(w.r,{className:`w-4 h-4 animate-spin text-accent`}),(0,q.jsx)(`span`,{className:`text-[13px] font-medium`,children:`Loading…`})]}):!u||u.kind!==`once`||!f.length?(0,q.jsxs)(`div`,{className:`flex flex-col items-center text-center py-8 gap-4`,children:[(0,q.jsx)(`div`,{className:`w-14 h-14 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-center shadow-xl`,children:(0,q.jsx)(k.i,{className:`w-7 h-7 text-accent`})}),(0,q.jsx)(`h1`,{className:`text-2xl md:text-3xl font-bold text-foreground tracking-tight`,children:`This payment link is no longer open`}),(0,q.jsx)(`p`,{className:`text-[14px] text-foreground/60 max-w-md`,children:`Ask whoever sent it for a new one.`}),(0,q.jsx)(Y.Link,{to:`/`,className:`text-[13px] font-bold text-accent hover:underline mt-2`,children:`Back to the site`})]}):(0,q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t?.appName&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-[0.2em] text-foreground/40`,children:t.appName}),(0,q.jsx)(`h1`,{className:`text-2xl sm:text-3xl md:text-4xl font-bold text-foreground tracking-tight`,children:p}),u.description.trim()&&(0,q.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/60 leading-relaxed mt-1 max-w-2xl whitespace-pre-line`,children:u.description.trim()})]}),!n.loading&&!n.configured&&(0,q.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60`,children:`Payments are not open right now — please try again later.`}),(0,q.jsx)(`div`,{className:`flex flex-col divide-y divide-[var(--panel-border)]/60 rounded-2xl border border-[var(--panel-border)]/60`,children:f.map((e,t)=>(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3.5`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[15px] font-semibold text-foreground truncate`,children:e.name.trim()||p}),(0,q.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/50`,children:g.n(r.br(e.amount)||0,s)})]}),(0,q.jsxs)(Yi,{amount:r.br(e.amount)||0,currency:a||void 0,productName:e.name.trim()||p,metadata:{productId:u.id,page:o.jt(u.id)},successPath:`/payment-complete`,cancelPath:o.jt(u.id),className:`px-5 py-2.5 text-[14px] font-bold`,children:[`Pay `,g.n(r.br(e.amount)||0,s)]})]},t))})]})})})}var Zi=`src/your-ai-workflow-firebase-os`;function Qi(){let e=new Set;for(let[t,n]of i.x()){let r=n?.config?.route,i=typeof r==`string`&&r.trim()?r.startsWith(`/`)?r:`/`+r:`/`+t.toLowerCase();e.add(i)}return[...e].sort()}var $i=e=>(e||``).split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``);function ea(e){let t=e?.contentKey||e?.tabName||e?.pageName||e?.pageId||`Page`;return`${Zi}/microcomponents/${$i(String(t))||`Page`}Content.tsx`}var ta=`This is a repair, not a redesign: whatever you have already written for this page stays exactly as it is — the same sections, the same words, the same pictures with the same links, the same layout and styling. What is wrong is the wiring above, so change only that, and nothing about how the page looks or what it says.`;function na(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 ${Zi}/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. ${Zi}/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.`,ta,`Then tell me, in one sentence, which of these was wrong.`].join(`
|
|
4
|
+
`)}function ra(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 ${Zi}/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. ${Zi}/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.`,ta,`Then rebuild and tell me, in one sentence, which of these was wrong.`].join(`
|
|
5
|
+
`)}var ia={sides:!1,top:!1},aa=4,oa=8,sa=24,ca=`button, input, select, textarea`,la=(e,t,n)=>{for(let r=e instanceof Element?e:e.parentElement;r&&r!==t;r=r.parentElement){if(r.getAttribute(`aria-hidden`)===`true`||getComputedStyle(r).position===`fixed`)return!1;let e=r.getBoundingClientRect();if(e.width>=1&&(e.left<n.left-1||e.right>n.right+1))return!1}return!0};function ua(e){let t={...ia},n=e.getBoundingClientRect();if(n.width<1)return t;let r=(r,i)=>{if(r.width<1||r.height<1||r.left<n.left-1||r.right>n.right+1)return;let a=r.left-n.left<aa||n.right-r.right<aa,o=r.top>=n.top-1&&r.top-n.top<oa;!(a&&!t.sides)&&!(o&&!t.top)||la(i,e,n)&&(a&&(t.sides=!0),o&&(t.top=!0))},i=e.ownerDocument,a=i.createRange();if(typeof a.getBoundingClientRect==`function`){let n=i.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=n.nextNode();e;e=n.nextNode())if(e.nodeValue?.trim()&&(a.selectNodeContents(e),r(a.getBoundingClientRect(),e),t.sides&&t.top))return t}for(let n of e.querySelectorAll(ca))if(r(n.getBoundingClientRect(),n),t.sides&&t.top)return t;if(!t.top)for(let r of e.querySelectorAll(`img`)){let i=r.getBoundingClientRect();if(!(i.width<1||i.height<1)&&!(i.top<n.top-1||i.top-n.top>=sa)&&!(i.left<=n.left+1&&i.right>=n.right-1)&&!(!la(r,e,n)||_a(r,e,n))){t.top=!0;break}}if(!t.sides)for(let r of e.querySelectorAll(`div, section, article, aside, ul, ol, li, a, label`)){if(!fa(r))continue;let i=r.getBoundingClientRect();if(!(i.width<1||i.height<1||i.width>=n.width-1&&!da(r))&&!(i.left<n.left-1||i.right>n.right+1)&&!(i.left-n.left>=aa&&n.right-i.right>=aa)&&la(r,e,n)){t.sides=!0;break}}return t}var da=e=>{let t=getComputedStyle(e),n=e.style;return(parseFloat(t.borderTopLeftRadius)||parseFloat(t.borderRadius)||parseFloat(n?.borderTopLeftRadius||n?.borderRadius||``)||0)>0},fa=e=>{let t=getComputedStyle(e);return(parseFloat(t.borderLeftWidth||t.borderWidth)||0)>0&&!ga(t.borderLeftColor||t.borderColor)?!0:da(e)&&!ga(t.backgroundColor)},pa=28,ma=200,ha=72,ga=e=>!e||e===`transparent`||/^rgba\([^)]*,\s*0\s*\)$/.test(e),_a=(e,t,n)=>{let r=t.ownerDocument,i=[r.body,r.documentElement].map(e=>getComputedStyle(e).backgroundColor);for(let r=e instanceof Element?e:e.parentElement;r&&r!==t;r=r.parentElement){let e=r.getBoundingClientRect();if(e.left>n.left+1||e.right<n.right-1||e.height>=n.height*.9)continue;let t=getComputedStyle(r);if(t.backgroundImage&&t.backgroundImage!==`none`||!ga(t.backgroundColor)&&!i.includes(t.backgroundColor))return!0}return!1};function va(e){let t=e.getBoundingClientRect();if(t.width<1)return 0;let n=e.ownerDocument,r=n.createRange();if(typeof r.getBoundingClientRect!=`function`)return 0;let i=1/0,a=null,o=e=>e.width>=1&&e.height>=1&&e.left>=t.left-1&&e.right<=t.right+1&&e.top>=t.top-1&&e.top-t.top<ma,s=n.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let n=s.nextNode();n;n=s.nextNode()){if(!n.nodeValue?.trim()||!n.parentElement)continue;r.selectNodeContents(n);let s=r.getBoundingClientRect();if(!(!o(s)||!la(n,e,t))&&(i=Math.min(i,s.top-t.top),!a)){let e=parseFloat(getComputedStyle(n.parentElement).fontSize)||0;e>=pa&&(a={size:e,at:n})}}if(!a||_a(a.at,e,t))return 0;for(let n of e.querySelectorAll(ca)){let r=n.getBoundingClientRect();o(r)&&la(n,e,t)&&(i=Math.min(i,r.top-t.top))}let c=Math.min(ha,Math.round(a.size));return Math.max(0,Math.round(c-Math.max(0,i)))}var ya={...ia,room:0},ba=[300,1e3,2500];function xa(e,t){let[n,r]=(0,K.useState)({page:t,given:ya});return(0,K.useEffect)(()=>{let n=e.current;if(!n||typeof window>`u`)return;let i=ya,a=!1,o,s=()=>{let e=ua(n),o={sides:i.sides||e.sides,top:i.top||e.top,room:Math.max(i.room,va(n))};(o.sides!==i.sides||o.top!==i.top||o.room!==i.room)&&(i=o,r({page:t,given:i})),a&&i.sides&&i.top&&p()},c=()=>{clearTimeout(o),o=setTimeout(s,200)},l=requestAnimationFrame(s),u=ba.map((e,t)=>setTimeout(()=>{a=t===ba.length-1,s()},e)),d=new MutationObserver(c);d.observe(n,{childList:!0,subtree:!0});let f=typeof ResizeObserver>`u`?null:new ResizeObserver(c);f?.observe(n);function p(){cancelAnimationFrame(l),u.forEach(clearTimeout),clearTimeout(o),d.disconnect(),f?.disconnect()}return p},[e,t]),n.page===t?n.given:ya}function Sa(e){let[t,n]=(0,K.useState)(null);return(0,K.useEffect)(()=>{if(e)return(0,J.onSnapshot)((0,J.collection)(r.ui,e),t=>{!t.metadata.fromCache&&!t.metadata.hasPendingWrites&&n({name:e,size:t.size})},()=>{})},[e]),t&&t.name===e?t.size:null}function Ca({job:e,kept:t}){let n=C.l(e,{records:Sa(e.from),copies:Sa(e.to),kept:t});return n?(0,q.jsx)(`aside`,{className:`w-full px-4 md:px-8 pb-6 text-xs text-foreground/60`,"aria-label":`What this page is shown from ${e.keeper.title}`,children:(0,q.jsxs)(`div`,{className:`max-w-3xl rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] px-4 py-3 flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`uppercase tracking-[0.18em] text-foreground/40`,children:`Only your team sees this`}),(0,q.jsx)(`p`,{className:`leading-relaxed`,children:n})]})}):null}function wa({config:e}){let{userRole:t}=r.Ft();return o.Sn(t)?(0,q.jsx)(Ta,{config:e}):null}function Ta({config:e}){let t=B.u(),n=Wi();if(!t||!n)return null;let r=C.d(t,e);if(!r)return null;let i=C.c(C.u(t),r.id);return i.length?(0,q.jsx)(`div`,{className:`w-full mt-auto pt-6`,children:i.map(e=>(0,q.jsx)(Ca,{job:e,kept:!!n[e.from]},`${e.from}${e.reader.id}`))}):null}function Ea({config:e,customContent:t}){let{config:a}=i.N(),{userRole:s}=r.Ft();pn(!!t);let l=(0,K.useRef)(null),u=xa(l,t);return(0,K.useEffect)(()=>{document.title=e.pageName||e.pageTitle||a.appName||`Your AI Firebase`},[e.pageName,e.pageTitle,a.appName]),t?(0,q.jsx)(c.p,{value:{prefix:`pub_`},children:(0,q.jsxs)(`main`,{ref:l,className:r.$(`fbos-content-slot fbos-page-canvas flex-1 w-full z-10 flex flex-col relative`,u.sides&&`px-4 md:px-8`,u.top&&`pt-6 md:pt-10`),style:u.room?{paddingTop:u.room}:void 0,"data-gutter-given":[u.sides&&`sides`,u.top&&`top`,u.room&&`title`].filter(Boolean).join(` `)||void 0,children:[(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(te.t,{config:e,children:(0,q.jsx)(t,{config:e})})}),(0,q.jsx)(wa,{config:e})]})}):(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col relative min-h-screen`,children:[(0,q.jsx)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4 md:mb-6 min-w-0`,children:(0,q.jsx)(n.t,{children:e.pageTitle||e.pageName||`New Page`})}),(0,q.jsx)(r.nt.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:e.form?(0,q.jsx)(`div`,{className:`fbos-content-slot flex-1 flex flex-col items-center justify-start p-4 md:p-8`,children:(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(te.t,{config:e,children:(0,q.jsx)(g.t,{isInline:!0,formId:e.form})})})}):(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center m-4 md:m-8 gap-6`,children:[(0,q.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,q.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/70`,children:`This page is empty`}),(0,q.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.`})]}),o.wn(s)&&(0,q.jsx)(`div`,{className:`w-full max-w-lg`,children:(0,q.jsx)(n.o,{compact:!0,title:`Already asked, and it is still empty? Paste this`,prompt:na(e.route||`/`,ea(e))})})]})})]})}var Da=(...e)=>{for(let t of e)if(t&&typeof t==`object`&&!Array.isArray(t))return t;return null};function Oa(e,t){let n=Da(e,t);if(!n)throw Error(`saveRecord needs the record to save — actions.saveRecord({ name: …, price: … }). The collection is the page’s own and is never passed.`);return n}function ka(e,t,n){let r=Da(t,n);if(!r)throw Error(`updateRecord needs the record’s id and the change — actions.updateRecord(id, { stock: 4 }). The collection is the page’s own and is never passed.`);return{id:String((r===n?t:e)??``),data:r}}function Aa(e,t){return String((typeof t==`string`&&t?t:e)??``)}function ja(e){return(e||[]).map(e=>{let t=e.data()||{};return{...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt,id:e.id}})}function Ma(e){if(!e||!(`id`in e))return e;let{id:t,...n}=e;return n}function Na(e){let t=typeof e?.sourceId==`string`?e.sourceId.trim():``;return t?`from_${t.replace(/[^A-Za-z0-9_-]/g,`_`).slice(0,200)}`:null}var Pa=(e,t)=>`${e}|${t}`,Fa=e=>Object.fromEntries(e.map(e=>[Pa(e.record,e.variant),e.since])),Ia=e=>typeof e==`number`&&Number.isFinite(e),La=(e,t)=>t&&Array.isArray(e?.variants)&&e.variants.find(e=>e&&String(e.id??``)===String(t))||null;function Ra(e){let t=[];for(let n of e)if(!(!n||!n.id)){Ia(n.stock)&&Ia(n.stockSetAt)&&t.push({record:String(n.id),variant:``,since:n.stockSetAt});for(let e of Array.isArray(n.variants)?n.variants:[]){let r=String(e?.id??``);r&&Ia(e?.stock)&&Ia(e?.stockSetAt)&&t.push({record:String(n.id),variant:r,since:e.stockSetAt})}}return t.sort((e,t)=>(e.record+`|`+e.variant).localeCompare(t.record+`|`+t.variant))}function za(e,t,n,r){if(!t)return null;let i=La(t,n),a=i?i.stock:n?void 0:t.stock;return Ia(a)?Math.max(0,a-Ba(e,t,n,r)):null}function Ba(e,t,n,r){if(!t?.id)return 0;let i=La(t,n),a=i?i.stockSetAt:n?void 0:t.stockSetAt;if(!Ia(a))return 0;let o=r?.[Pa(String(t.id),i?String(i.id):``)];if(r&&o!==a)return 0;let s=e[String(t.id)]?.[i?String(i.id):``];return Ia(s)&&s>0?s:0}function Va(e,t,n=Date.now()){if(!e||typeof e!=`object`)return e;let r={...e};if(Ia(e.stock)&&(r.stockSetAt=!t||t.stock!==e.stock||!Ia(t.stockSetAt)?n:t.stockSetAt),Array.isArray(e.variants)){let i=Array.isArray(t?.variants)?t.variants:[];r.variants=e.variants.map(e=>{if(!e||typeof e!=`object`||!Ia(e.stock))return e;let t=i.find(t=>t&&String(t.id??``)===String(e.id??``));return!t||t.stock!==e.stock||!Ia(t.stockSetAt)?{...e,stockSetAt:n}:Ia(e.stockSetAt)?e:{...e,stockSetAt:t.stockSetAt}})}return r}var Ha=60*1e3,Ua=`What is left in stock could not be checked just now — the counts shown are as last set.`,Wa={fetch:(e,t)=>fetch(e,t)};async function Ga(e){if(!e.length)return{sold:{},error:``,partial:!1};try{let t=await Wa.fetch(`/api/payments/sold`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({wants:e})});if(!t.ok)return{sold:{},error:Ua,partial:!1};let n=await t.json();return{sold:n&&typeof n.sold==`object`&&n.sold?n.sold:{},error:``,partial:n?.partial===!0}}catch{return{sold:{},error:Ua,partial:!1}}}function Ka(e){let t=(0,K.useMemo)(()=>Ra(Array.isArray(e)?e:[]),[e]),n=(0,K.useMemo)(()=>JSON.stringify(t),[t]),[r,i]=(0,K.useState)({sold:{},for:{}}),[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(!1),l=t.length>0&&!s,[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(0),m=(0,K.useRef)(t);return m.current=t,(0,K.useEffect)(()=>{if(!t.length)return;let e=!0,n=async()=>{let t=m.current,n=await Ga(t);e&&(n.error||(i({sold:n.sold,for:Fa(t)}),o(n.partial),p(Date.now())),d(n.error),c(!0))};n();let r=setInterval(()=>{document.visibilityState!==`hidden`&&n()},Ha),a=()=>{document.visibilityState===`visible`&&n()};return document.addEventListener(`visibilitychange`,a),()=>{e=!1,clearInterval(r),document.removeEventListener(`visibilitychange`,a)}},[n]),(0,K.useMemo)(()=>({loading:l,error:u,asOf:f,partial:a,left:(e,t)=>za(r.sold,e,t,r.for),sold:(e,t)=>Ba(r.sold,e,t,r.for)}),[r,l,u,f,a])}function qa({config:e,customContent:t}){let{user:a,userRole:s}=r.Ft(),{config:l}=i.N(),[u,d]=(0,K.useState)([]),[f,p]=(0,K.useState)(!0),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``),[v,b]=(0,K.useState)(``),[x,S]=(0,K.useState)(!1),[T,D]=(0,K.useState)(``),[O,M]=(0,K.useState)(null),P=(0,K.useRef)(null),[F,I]=(0,K.useState)(null),[L,ne]=(0,K.useState)(null),R=e=>{if(ne(e),e){let t=e.fileType||``;V(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},z=L,[re,V]=(0,K.useState)(!0),[H,se]=(0,K.useState)(!1),[U,ce]=(0,K.useState)(null),[W,le]=(0,K.useState)(``),[G,ue]=(0,K.useState)(``),[de,Y]=(0,K.useState)([]),pe=(0,K.useRef)(null),me=B.o(e,`user_page`),he=o.Mn({...e,pageType:`user`}),ge=!he.startsWith(`user_`),_e=c.c(he),X=_e?B.t(e,he):`${he}${me}_records`,ve=c.f(),ye=c.o({on:!ge&&!_e}),be=ye.uid||a?.uid||``,xe=c.F(X),Z=_e?xe.records:u,Q=_e?xe.loading:f,Se=e=>_e?c.C(e,ve):!0,Ce=s===`admin`,we=e=>Se(e)&&oe.d(e,s),Te=(0,K.useRef)(!1);(0,K.useEffect)(()=>{!Ce||Q||Te.current||!Z.length||(Te.current=!0,oe.a(X,Z,e,!0).catch(e=>console.warn(`Could not catch the delete lock up:`,e)).finally(()=>{Te.current=!1}))},[Ce,Q,Z,oe.l(e),X]);let Ee=ye.everyone?`${a?.uid}|everyone`:ye.uid||a?.uid||``,De=(0,K.useRef)(Ee),Oe=e=>c.d(he,X,e),[ke,Ae]=(0,K.useState)(()=>_e?c.u(X):``),je=()=>Ae(c.u(X));(0,K.useEffect)(()=>{document.title=e.tabTitle||e.tabName||l.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,l.appName]),(0,K.useEffect)(()=>{if(!a||_e)return;try{let e=C.o(X,Ee);e?(d(e),p(!1)):(d(e=>e.length?[]:e),p(!0)),De.current=Ee}catch{}let e=e=>ja(e),t=(0,J.onSnapshot)(ge||ye.everyone?(0,J.query)((0,J.collection)(r.ui,X),(0,J.orderBy)(`createdAt`,`desc`),(0,J.limit)(150)):(0,J.query)((0,J.collection)(r.ui,X),(0,J.where)(`uid`,`==`,ye.uid||a.uid)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),d(n),p(!1),De.current=Ee,C.s(X,Ee,n)},e=>{console.warn(`${X}: this account cannot read its records here (${e?.code||`permission-denied`}). Signed-in pages need a verified email address; the records themselves are only ever the signer's own.`),d(e=>e.length?[]:e),p(!1)});return()=>t()},[a,X,ge,_e,ye.uid,ye.everyone,Ee]),(0,K.useEffect)(()=>{!f&&a&&!_e&&De.current===Ee&&C.s(X,Ee,u)},[u,f,X,a,_e,Ee]);let Me=async e=>Z.some(t=>t.id===e)||await(0,J.getDoc)((0,J.doc)(r.ui,X,e)).then(e=>e.exists()).catch(()=>!1),Ne=async(t,n)=>{let i={uid:be,recordType:`record`,...oe.u(e,s),...t};if(!_e){let e=Na(t),n=e?(0,J.doc)(r.ui,X,e):(0,J.doc)((0,J.collection)(r.ui,X)),a={...i,createdAt:(0,J.serverTimestamp)()};return await(0,J.setDoc)(n,a),C.p(X,n.id,a),n.id}let o=n||ke||c.u(X);return await(0,J.setDoc)((0,J.doc)(r.ui,X,o),c.l({...Ei(a),...i},a.uid)),n||je(),o},Pe=async t=>{if(t.preventDefault(),!(!a||!g.trim())){S(!0);try{let t=await Ne({name:g.trim(),note:v.trim()});_e||d(n=>[{id:t,name:g.trim(),note:v.trim(),uid:a.uid,recordType:`record`,...oe.u(e,s),createdAt:Date.now()},...n]),_(``),b(``),h(!1)}catch(e){console.error(`Error saving record:`,e)}S(!1)}},Fe=c.b({upload:async(t,n)=>{if(!a)throw Error(`Sign in again before uploading.`);let r=await ee._(t),i=_e?P.current&&ke||c.u(X):``,o=`${Oe(i)}/${c.h(r.name)}`,l=await c.y(o,r,{customMetadata:{ownerId:a.uid},onProgress:n.progress,signal:n.signal});if(P.current)P.current(r,l,{uid:a.uid,storagePath:o,recordId:i});else{let t=await Ne({name:r.name,note:`${r.type||`File`} · ${tt(r.size)}`,recordType:`file`,fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:l,storagePath:o},i);_e||d(n=>[{id:t,name:r.name,note:`${r.type||`File`} · ${tt(r.size)}`,uid:a.uid,recordType:`file`,fileName:r.name,fileType:r.type,fileSize:r.size,downloadURL:l,storagePath:o,...oe.u(e,s),createdAt:Date.now()},...n])}},onFailed:e=>D(`${e.name}: ${e.error||`That upload did not work.`}`),onSettled:()=>Fe.clear()}),Ie=Fe.busy,Le=e=>{let t=Array.from(e.target.files||[]);e.target.value=``,!(!t.length||!a)&&(D(``),Fe.add(t))},Re=async()=>{if(F){se(!0);try{let e=Z.find(e=>e.id===F);if(!oe.d(e,s)){k.n(`Nothing on this page can be deleted.`),I(null),se(!1);return}await(0,J.deleteDoc)((0,J.doc)(r.ui,X,F)),await ae.o(e,Z,Oe(F)),_e||d(e=>e.filter(e=>e.id!==F)),I(null)}catch(e){console.error(`Error deleting record:`,e)}se(!1)}},[ze,Be]=(0,K.useState)(null),[Ve,He]=(0,K.useState)(``),[Ue,We]=(0,K.useState)(!1),[Ge,Ke]=(0,K.useState)(null),qe=(0,K.useRef)([]),Je=e=>{if(e.recordType===`file`){Be(e.id),He(e.name);return}ce(e.id),le(e.name),ue(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`storagePath`,`createdAt`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));Y(n),qe.current=n.map(e=>e.key)},Ye=async()=>{if(!ze||!Ve.trim()){Be(null);return}let e=Z.find(e=>e.id===ze);if(e&&e.name===Ve.trim()){Be(null);return}We(!0);try{await(0,J.updateDoc)((0,J.doc)(r.ui,X,ze),{name:Ve.trim()}),d(e=>e.map(e=>e.id===ze?{...e,name:Ve.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}We(!1),Be(null)},Xe=async()=>{await Ze(),ce(null)},Ze=async()=>{if(!U||!W.trim())return;S(!0);let e={};de.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=de.map(e=>e.key.trim()).filter(Boolean),n=qe.current.filter(e=>!t.includes(e));n.forEach(t=>{e[t]=(0,J.deleteField)()});try{await(0,J.updateDoc)((0,J.doc)(r.ui,X,U),{name:W.trim(),note:G.trim(),...e}),d(e=>e.map(e=>{if(e.id!==U)return e;let t={...e,name:W.trim(),note:G.trim()};return n.forEach(e=>{delete t[e]}),de.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),qe.current=t}catch(e){console.error(`Error saving record:`,e)}S(!1)},Qe=(e,t)=>e?e.startsWith(`image/`)?t?(0,q.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,q.jsx)(y.c,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,q.jsx)(c.R,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,q.jsx)(y.u,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,q.jsx)(c.V,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,q.jsx)(c.B,{className:`w-4 h-4`}):(0,q.jsx)(y.l,{className:`w-4 h-4`}):(0,q.jsx)(y.u,{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-accent/10 text-accent`: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`,et=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)},tt=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]},nt=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},rt=n.p(e.buttonStorageIcon)||yt,it=e.buttonStyle!==`secondary`,at=e.buttonStorageStyle===`primary`;return(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,q.jsx)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(n.t,{children:e.tabTitle||e.tabName||`User Page`}),e.route&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,q.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,q.jsx)(i.t,{}),(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:t?`flex flex-col flex-1 relative`:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,q.jsx)(`input`,{type:`file`,multiple:!0,ref:pe,onChange:Le,className:`hidden`}),!t&&(0,q.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,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-xl font-bold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,q.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:Q?`Loading…`:`${Z.length} ${Z.length===1?`item`:`items`}`}),(T||_e&&xe.error)&&(0,q.jsx)(`p`,{className:`text-[12px] font-semibold text-red-500 mt-1 truncate`,role:`alert`,children:T||xe.error}),ye.someoneElse&&e.storage!==!1&&(0,q.jsx)(`p`,{className:`text-[12px] font-medium text-foreground/50 mt-1 max-sm:hidden`,children:`You are looking at somebody else’s page. Anything you add here is theirs, but a file would stay yours — so uploads are off until you switch back to your own.`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,q.jsx)(c.a,{viewing:ye}),e.storage!==!1&&!ye.someoneElse&&(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>pe.current?.click(),title:Ie?Fe.done?`${Fe.done} of ${Fe.total} uploaded…`:`Uploading ${Fe.total===1?`your file`:`${Fe.total} files`}…`:e.buttonStorageText||`Upload files`,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`} ${at?`btn-primary`:`btn-secondary`}`,children:[Ie?(0,q.jsx)(w.r,{className:`w-4 h-4 animate-spin`}):(0,q.jsx)(rt,{className:`w-4 h-4`}),e.buttonStorageText&&(0,q.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,q.jsx)(r.nt.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`} ${it?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,q.jsx)(E.t,{className:`w-4 h-4`}):(0,q.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,q.jsxs)(`div`,{className:t?`flex-1 flex flex-col relative min-h-[400px]`:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[Q&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,q.jsx)(w.r,{className:`w-8 h-8 text-accent animate-spin`})}),t?(0,q.jsx)(c.p,{value:{prefix:he,collection:_e?X:``,recordId:_e?U||ke:``},children:(0,q.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill`,children:(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(te.t,{config:e,children:(0,q.jsx)(t,{config:e,actions:{records:Z,loading:Q,error:_e?xe.error:``,collection:X,user:a,...c.s(X,ve,_e,ke),saveRecord:async(t,n)=>{let r=Ma(Oa(t,n)),i=_e?null:Na(r);if(i&&await Me(i))return i;let a=await Ne(Va(r));return _e||d(t=>[{uid:be,recordType:`record`,...oe.u(e,s),createdAt:Date.now(),...r,id:a},...t.filter(e=>e.id!==a)]),a},updateRecord:async(e,t,n)=>{let{id:i,data:o}=ka(e,t,n),s=Ma(o),c={...Di(a),...Va(s,Z.find(e=>e.id===i))};_e||d(e=>e.map(e=>e.id===i?{...e,...c}:e)),await(0,J.updateDoc)((0,J.doc)(r.ui,X,i),c);let l=Z.find(e=>e.id===i);l&&C.p(X,i,{...l,...c})},deleteRecord:async(e,t)=>{let n=Aa(e,t),i=Z.find(e=>e.id===n);if(!oe.d(i,s)){k.n(`Nothing on this page can be deleted.`);return}await(0,J.deleteDoc)((0,J.doc)(r.ui,X,n)),C.m(X,n),await ae.o(i,Z,Oe(n))},startEdit:e=>Je(e),confirmDelete:e=>I(e),uploadFile:()=>{ye.someoneElse||pe.current?.click()},openAddForm:()=>h(!0),setAddForm:e=>M(()=>e),setFileHandler:e=>{P.current=e}}})})})})}):(0,q.jsxs)(q.Fragment,{children:[!Q&&Z.length===0&&(0,q.jsxs)(r.nt.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,q.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,q.jsx)(E.t,{className:`w-6 h-6 text-accent/40`})}),(0,q.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,q.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`})]}),!Q&&Z.length>0&&(0,q.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,q.jsx)(r.rt,{children:Z.map((e,t)=>{let n=U===e.id,i=Se(e),o=_e?ki(e,a):null;return(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},transition:{delay:t*.03,duration:.25},onClick:()=>i&&Je(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative ${i?`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,q.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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),Ke(e.id),setTimeout(()=>Ke(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:Ge===e.id?(0,q.jsx)(r.At,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,q.jsx)(c.z,{className:`w-3.5 h-3.5`})}),(0,q.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,q.jsx)(y.d,{className:`w-3.5 h-3.5`})})]}),i&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Je(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,q.jsx)(y.s,{className:`w-3.5 h-3.5`})}),i&&we(e)&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),I(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,q.jsx)(A.t,{className:`w-3.5 h-3.5`})})]}),(0,q.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,q.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&R(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`?Qe(e.fileType,e.downloadURL):(0,q.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,q.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[ze===e.id?(0,q.jsx)(`input`,{autoFocus:!0,type:`text`,value:Ve,onChange:e=>He(e.target.value),onBlur:()=>Ye(),onKeyDown:e=>{e.key===`Enter`&&Ye(),e.key===`Escape`&&Be(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,q.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>R(e)}),(0,q.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:nt(e.createdAt)})]})]}),e.note&&(0,q.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,q.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,q.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,q.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),o&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[o.avatar?(0,q.jsx)(r.O,{src:o.avatar,alt:``,className:`w-5 h-5 rounded-full shrink-0`}):(0,q.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:o.name.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}),(0,q.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:o.name})]})]},e.id)})})})]})]})]})]}),(0,q.jsx)(r.rt,{children:m&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>!x&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,q.jsx)(r.nt.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:O?K.default.createElement(O,{onSave:async e=>{S(!0);try{await Ne(e),h(!1)}catch(e){console.error(`Error saving record:`,e)}S(!1)},onClose:()=>!x&&h(!1),saving:x}):(0,q.jsxs)(`form`,{onSubmit:Pe,className:`p-5 flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>!x&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,q.jsx)(w.t,{className:`w-4 h-4`})})]}),(0,q.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:x,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,q.jsx)(r.Q,{value:v,onChange:e=>b(e.target.value),placeholder:`Note (optional)`,disabled:x,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,q.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,q.jsx)(N.t,{type:`submit`,isLoading:x,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:x?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,fe.createPortal)((0,q.jsx)(r.rt,{children:z&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>R(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,q.jsx)(`button`,{onClick:()=>R(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,q.jsx)(w.t,{className:`w-5 h-5`})}),(0,q.jsxs)(r.nt.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,q.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,q.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,q.jsx)(`span`,{className:`text-xl font-bold text-foreground truncate`,children:z.fileName||z.name}),(0,q.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[et(z.fileType),` • `,tt(z.fileSize||0)]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,q.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(z.downloadURL),Ke(`preview`),setTimeout(()=>Ke(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:Ge===`preview`?(0,q.jsx)(r.At,{className:`w-4 h-4 text-emerald-500`}):(0,q.jsx)(c.z,{className:`w-4 h-4`})}),(0,q.jsx)(`button`,{onClick:()=>{R(null),Be(z.id),He(z.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,q.jsx)(y.s,{className:`w-4 h-4`})}),(0,q.jsx)(`button`,{onClick:()=>{R(null),I(z.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,q.jsx)(A.t,{className:`w-4 h-4`})}),(0,q.jsx)(`a`,{href:z.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,q.jsx)(y.d,{className:`w-4 h-4`})})]})]}),(0,q.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>R(null),children:(0,q.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[re&&(0,q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,q.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,q.jsx)(w.r,{className:`w-5 h-5 text-accent animate-spin`})})}),z.fileType?.startsWith(`image/`)?(0,q.jsx)(`img`,{onLoad:()=>V(!1),onError:()=>V(!1),src:z.downloadURL,alt:z.fileName||z.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 ${re?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):z.fileType?.startsWith(`video/`)?(0,q.jsx)(`video`,{onLoadedData:()=>V(!1),onError:()=>V(!1),src:z.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 ${re?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):z.fileType===`application/pdf`?(0,q.jsx)(`iframe`,{onLoad:()=>V(!1),src:z.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${re?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,q.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(),V(!1)},children:[(0,q.jsx)(y.u,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,q.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,q.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,q.jsx)(r.rt,{children:U&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>Xe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,q.jsx)(r.nt.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,q.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),x&&(0,q.jsx)(w.r,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>Xe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,q.jsx)(w.t,{className:`w-4 h-4`})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,q.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,q.jsx)(`input`,{autoFocus:!0,required:!0,value:W,onChange:e=>le(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Ze(),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,q.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,q.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,q.jsx)(r.Q,{value:G,onChange:e=>ue(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>Ze(),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,q.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),de.map((e,t)=>(0,q.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,q.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...de];n[t].key=e.target.value,Y(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Ze(),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,q.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...de];n[t].value=e.target.value,Y(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Ze(),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,q.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>Y(de.filter((e,n)=>n!==t)),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,q.jsx)(w.t,{className:`w-3 h-3`})})]},t)),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>Y([...de,{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,q.jsx)(E.t,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,q.jsx)(ie.t,{isOpen:!!F,onCancel:()=>I(null),onConfirm:Re,title:`Delete Record`,message:(0,q.jsxs)(q.Fragment,{children:[`Are you sure you want to delete `,(0,q.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:Z.find(e=>e.id===F)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:H})]})}var Ja=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Admin`,n=e.creatorEmail||``,i=e.creatorAvatar||``,a=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[i?(0,q.jsx)(r.O,{src:i,alt:``,className:`w-5 h-5 rounded-full shrink-0`}):(0,q.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:a}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,q.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};function Ya({config:e,customContent:t}){let{user:a}=r.Ft(),{config:o}=i.N(),[s,l]=(0,K.useState)([]),[u,d]=(0,K.useState)(!0),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(``),[g,_]=(0,K.useState)(``),[v,b]=(0,K.useState)(!1),[x,S]=(0,K.useState)(``),[T,D]=(0,K.useState)(null),O=(0,K.useRef)(null),[k,M]=(0,K.useState)(null),[P,F]=(0,K.useState)(null),I=e=>{if(F(e),e){let t=e.fileType||``;R(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},L=P,[ne,R]=(0,K.useState)(!0),[z,re]=(0,K.useState)(!1),[V,oe]=(0,K.useState)(null),[H,se]=(0,K.useState)(``),[U,ce]=(0,K.useState)(``),[W,le]=(0,K.useState)([]),G=(0,K.useRef)(null),[ue,de]=(0,K.useState)(null),Y=(0,K.useRef)([]),pe=`admin_${B.o(e,`admin_page`)}_records`,me=ae.i(`admin_`);(0,K.useEffect)(()=>{document.title=e.tabTitle||e.tabName||o.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,o.appName]);let he=()=>({name:a.displayName||a.email?.split(`@`)[0]||`Admin`,email:a.email||``,avatar:a.photoURL||``}),ge=a?.uid;(0,K.useEffect)(()=>{if(!ge)return;try{let e=C.o(pe,ge);e?(l(e),d(!1)):d(!0)}catch{}let e=e=>ja(e),t=(0,J.onSnapshot)((0,J.query)((0,J.collection)(r.ui,pe),(0,J.orderBy)(`createdAt`,`desc`),(0,J.limit)(150)),t=>{let n=e(t.docs);l(n),d(!1),C.s(pe,ge,n)},e=>{console.warn(`${pe}: this account cannot read the records here (${e?.code||`permission-denied`}). An admins page needs a verified address and an account marked Admin on the Users screen.`),l(e=>e.length?[]:e),d(!1)});return()=>t()},[ge,pe]);let _e=async e=>{if(e.preventDefault(),!(!a||!m.trim())){b(!0);try{let e=he();await(0,J.addDoc)((0,J.collection)(r.ui,pe),{name:m.trim(),note:g.trim(),uid:a.uid,recordType:`record`,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,J.serverTimestamp)()}),h(``),_(``),p(!1)}catch(e){console.error(`Error saving admin record:`,e)}b(!1)}},X=c.b({upload:async(e,t)=>{if(!a)throw Error(`Sign in again before uploading.`);let n=await ee._(e),i=`${me}/${c.h(n.name)}`,o=await c.y(i,n,{customMetadata:{ownerId:a.uid},onProgress:t.progress,signal:t.signal});if(O.current)O.current(n,o,{uid:a.uid,storagePath:i});else{let e=he();await(0,J.addDoc)((0,J.collection)(r.ui,pe),{name:n.name,note:`${n.type||`File`} · ${Me(n.size)}`,uid:a.uid,recordType:`file`,fileName:n.name,fileType:n.type||`unknown`,fileSize:n.size,downloadURL:o,storagePath:i,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,J.serverTimestamp)()})}},onFailed:e=>S(`${e.name}: ${e.error||`That upload did not work.`}`),onSettled:()=>X.clear()}),ve=X.busy,ye=e=>{let t=Array.from(e.target.files||[]);e.target.value=``,!(!t.length||!a)&&(S(``),X.add(t))},be=async()=>{if(k){re(!0);try{let e=s.find(e=>e.id===k);await(0,J.deleteDoc)((0,J.doc)(r.ui,pe,k)),await ae.o(e,s,me),M(null)}catch(e){console.error(`Error deleting admin record:`,e)}re(!1)}},[xe,Z]=(0,K.useState)(null),[Q,Se]=(0,K.useState)(``),[Ce,we]=(0,K.useState)(!1),Te=e=>{if(e.recordType===`file`){Z(e.id),Se(e.name);return}oe(e.id),se(e.name),ce(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`storagePath`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));le(n),Y.current=n.map(e=>e.key)},Ee=async()=>{if(!xe||!Q.trim()){Z(null);return}let e=s.find(e=>e.id===xe);if(e&&e.name===Q.trim()){Z(null);return}we(!0);try{await(0,J.updateDoc)((0,J.doc)(r.ui,pe,xe),{name:Q.trim()}),l(e=>e.map(e=>e.id===xe?{...e,name:Q.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}we(!1),Z(null)},De=async()=>{if(!V||!H.trim()){oe(null);return}b(!0);let e={};W.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=W.map(e=>e.key.trim()).filter(Boolean),n=Y.current.filter(e=>!t.includes(e));n.forEach(t=>{e[t]=(0,J.deleteField)()});try{await(0,J.updateDoc)((0,J.doc)(r.ui,pe,V),{name:H.trim(),note:U.trim(),...e}),l(e=>e.map(e=>{if(e.id!==V)return e;let t={...e,name:H.trim(),note:U.trim()};return n.forEach(e=>{delete t[e]}),W.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),Y.current=t}catch(e){console.error(`Error updating record:`,e)}b(!1),oe(null)},Oe=async()=>{if(!V||!H.trim())return;let e={};W.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=W.map(e=>e.key.trim()).filter(Boolean),n=Y.current.filter(e=>!t.includes(e));n.forEach(t=>{e[t]=(0,J.deleteField)()});try{await(0,J.updateDoc)((0,J.doc)(r.ui,pe,V),{name:H.trim(),note:U.trim(),...e}),l(e=>e.map(e=>{if(e.id!==V)return e;let t={...e,name:H.trim(),note:U.trim()};return n.forEach(e=>{delete t[e]}),W.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),Y.current=t}catch(e){console.error(`Error silently saving record:`,e)}},ke=(e,t)=>e?e.startsWith(`image/`)?t?(0,q.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,q.jsx)(y.c,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,q.jsx)(c.R,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,q.jsx)(y.u,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,q.jsx)(c.V,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,q.jsx)(c.B,{className:`w-4 h-4`}):(0,q.jsx)(y.l,{className:`w-4 h-4`}):(0,q.jsx)(y.u,{className:`w-4 h-4`}),Ae=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-accent/10 text-accent`: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`,je=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)},Me=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]},Ne=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},Pe=n.p(e.buttonStorageIcon)||yt,Fe=e.buttonStyle!==`secondary`,Ie=e.buttonStorageStyle===`primary`,Le=e=>e.uid===a?.uid;return(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,q.jsx)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(n.t,{children:e.tabTitle||e.tabName||`Admin Page`}),e.route&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,q.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,q.jsx)(i.t,{}),(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:t?`flex flex-col flex-1 relative`:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,q.jsx)(`input`,{type:`file`,multiple:!0,ref:G,onChange:ye,className:`hidden`}),!t&&(0,q.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,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-xl font-bold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,q.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:u?`Loading…`:`${s.length} ${s.length===1?`item`:`items`}`}),x&&(0,q.jsx)(`p`,{className:`text-[12px] font-semibold text-red-500 mt-1 truncate`,role:`alert`,children:x})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.storage!==!1&&(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>G.current?.click(),title:ve?X.done?`${X.done} of ${X.total} uploaded…`:`Uploading ${X.total===1?`your file`:`${X.total} files`}…`:e.buttonStorageText||`Upload files`,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`} ${Ie?`btn-primary`:`btn-secondary`}`,children:[ve?(0,q.jsx)(w.r,{className:`w-4 h-4 animate-spin`}):(0,q.jsx)(Pe,{className:`w-4 h-4`}),e.buttonStorageText&&(0,q.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,q.jsx)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>p(!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`} ${Fe?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,q.jsx)(E.t,{className:`w-4 h-4`}):(0,q.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,q.jsxs)(`div`,{className:t?`flex-1 flex flex-col relative min-h-[400px]`:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[u&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,q.jsx)(w.r,{className:`w-8 h-8 text-accent animate-spin`})}),t?(0,q.jsx)(c.p,{value:{prefix:`admin_`,collection:pe},children:(0,q.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill`,children:(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(te.t,{config:e,children:(0,q.jsx)(t,{config:e,actions:{records:s,loading:u,collection:pe,user:a,saveRecord:async(e,t)=>{let n=Va(Ma(Oa(e,t))),i=Na(n);if(i&&(s.some(e=>e.id===i)||await(0,J.getDoc)((0,J.doc)(r.ui,pe,i)).then(e=>e.exists()).catch(()=>!1)))return i;let o=i?(0,J.doc)(r.ui,pe,i):(0,J.doc)((0,J.collection)(r.ui,pe)),c=he(),u={uid:a.uid,recordType:`record`,creatorName:c.name,creatorEmail:c.email,creatorAvatar:c.avatar,createdAt:Date.now(),...n,id:o.id};l(e=>[u,...e.filter(e=>e.id!==u.id)]);let d={uid:a.uid,recordType:`record`,creatorName:c.name,creatorEmail:c.email,creatorAvatar:c.avatar,createdAt:(0,J.serverTimestamp)(),...n};return await(0,J.setDoc)(o,d),C.p(pe,o.id,d),o.id},updateRecord:async(e,t,n)=>{let{id:i,data:o}=ka(e,t,n),c=Ma(o),u={...Di(a),...Va(c,s.find(e=>e.id===i))};l(e=>e.map(e=>e.id===i?{...e,...u}:e)),await(0,J.updateDoc)((0,J.doc)(r.ui,pe,i),u);let d=s.find(e=>e.id===i);d&&C.p(pe,i,{...d,...u})},deleteRecord:async(e,t)=>{let n=Aa(e,t),i=s.find(e=>e.id===n);await(0,J.deleteDoc)((0,J.doc)(r.ui,pe,n)),C.m(pe,n),await ae.o(i,s,me)},startEdit:e=>Te(e),confirmDelete:e=>M(e),uploadFile:()=>G.current?.click(),openAddForm:()=>p(!0),setAddForm:e=>D(()=>e),setFileHandler:e=>{O.current=e}}})})})})}):(0,q.jsxs)(q.Fragment,{children:[!u&&s.length===0&&(0,q.jsxs)(r.nt.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,q.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,q.jsx)(E.t,{className:`w-6 h-6 text-accent/40`})}),(0,q.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,q.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.`})]}),!u&&s.length>0&&(0,q.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,q.jsx)(r.rt,{children:s.map((e,t)=>{let n=V===e.id,i=Le(e);return(0,q.jsxs)(r.nt.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>Te(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative 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,q.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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),de(e.id),setTimeout(()=>de(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:ue===e.id?(0,q.jsx)(r.At,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,q.jsx)(c.z,{className:`w-3.5 h-3.5`})}),(0,q.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,q.jsx)(y.d,{className:`w-3.5 h-3.5`})})]}),i&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Te(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,q.jsx)(y.s,{className:`w-3.5 h-3.5`})}),(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),M(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,q.jsx)(A.t,{className:`w-3.5 h-3.5`})})]})]}),(0,q.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,q.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&I(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 ${Ae(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?ke(e.fileType,e.downloadURL):(0,q.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,q.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[xe===e.id?(0,q.jsx)(`input`,{autoFocus:!0,type:`text`,value:Q,onChange:e=>Se(e.target.value),onBlur:()=>Ee(),onKeyDown:e=>{e.key===`Enter`&&Ee(),e.key===`Escape`&&Z(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,q.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>I(e)}),(0,q.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:Ne(e.createdAt)})]})]}),e.note&&(0,q.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,q.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,q.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,q.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,q.jsx)(Ja,{record:e})]},e.id)})})})]})]})]})]}),(0,q.jsx)(r.rt,{children:f&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>!v&&p(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,q.jsx)(r.nt.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:T?K.default.createElement(T,{onSave:async e=>{b(!0);try{let t=he();await(0,J.addDoc)((0,J.collection)(r.ui,pe),{uid:a.uid,recordType:`record`,creatorName:t.name,creatorEmail:t.email,creatorAvatar:t.avatar,createdAt:(0,J.serverTimestamp)(),...e}),p(!1)}catch(e){console.error(`Error saving record:`,e)}b(!1)},onClose:()=>!v&&p(!1),saving:v}):(0,q.jsxs)(`form`,{onSubmit:_e,className:`p-5 flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>!v&&p(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,q.jsx)(w.t,{className:`w-4 h-4`})})]}),(0,q.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:m,onChange:e=>h(e.target.value),placeholder:`Name *`,disabled:v,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,q.jsx)(r.Q,{value:g,onChange:e=>_(e.target.value),placeholder:`Note (optional)`,disabled:v,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,q.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,q.jsx)(N.t,{type:`submit`,isLoading:v,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:v?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,fe.createPortal)((0,q.jsx)(r.rt,{children:L&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>I(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,q.jsx)(`button`,{onClick:()=>I(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,q.jsx)(w.t,{className:`w-5 h-5`})}),(0,q.jsxs)(r.nt.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,q.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,q.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,q.jsx)(`span`,{className:`text-xl font-bold text-foreground truncate`,children:L.fileName||L.name}),(0,q.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[je(L.fileType),` • `,Me(L.fileSize||0)]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,q.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(L.downloadURL),de(`preview`),setTimeout(()=>de(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:ue===`preview`?(0,q.jsx)(r.At,{className:`w-4 h-4 text-emerald-500`}):(0,q.jsx)(c.z,{className:`w-4 h-4`})}),(0,q.jsx)(`button`,{onClick:()=>{I(null),Z(L.id),Se(L.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,q.jsx)(y.s,{className:`w-4 h-4`})}),(0,q.jsx)(`button`,{onClick:()=>{I(null),M(L.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,q.jsx)(A.t,{className:`w-4 h-4`})}),(0,q.jsx)(`a`,{href:L.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,q.jsx)(y.d,{className:`w-4 h-4`})})]})]}),(0,q.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>I(null),children:(0,q.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[ne&&(0,q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,q.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,q.jsx)(w.r,{className:`w-5 h-5 text-accent animate-spin`})})}),L.fileType?.startsWith(`image/`)?(0,q.jsx)(`img`,{onLoad:()=>R(!1),onError:()=>R(!1),src:L.downloadURL,alt:L.fileName||L.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 ${ne?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):L.fileType?.startsWith(`video/`)?(0,q.jsx)(`video`,{onLoadedData:()=>R(!1),onError:()=>R(!1),src:L.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 ${ne?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):L.fileType===`application/pdf`?(0,q.jsx)(`iframe`,{onLoad:()=>R(!1),src:L.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${ne?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,q.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(),R(!1)},children:[(0,q.jsx)(y.u,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,q.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,q.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,q.jsx)(r.rt,{children:V&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>De(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,q.jsx)(r.nt.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,q.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),v&&(0,q.jsx)(w.r,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>De(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,q.jsx)(w.t,{className:`w-4 h-4`})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,q.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,q.jsx)(`input`,{autoFocus:!0,required:!0,value:H,onChange:e=>se(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Oe(),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,q.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,q.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,q.jsx)(r.Q,{value:U,onChange:e=>ce(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>Oe(),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,q.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),W.map((e,t)=>(0,q.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,q.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...W];n[t].key=e.target.value,le(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Oe(),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,q.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...W];n[t].value=e.target.value,le(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Oe(),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,q.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>le(W.filter((e,n)=>n!==t)),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,q.jsx)(w.t,{className:`w-3 h-3`})})]},t)),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>le([...W,{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,q.jsx)(E.t,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,q.jsx)(ie.t,{isOpen:!!k,onCancel:()=>M(null),onConfirm:be,title:`Delete Record`,message:(0,q.jsxs)(q.Fragment,{children:[`Are you sure you want to delete `,(0,q.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:s.find(e=>e.id===k)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:z})]})}var Xa=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Member`,n=e.creatorEmail||``,i=e.creatorAvatar||``,a=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[i?(0,q.jsx)(r.O,{src:i,alt:``,className:`w-5 h-5 rounded-full shrink-0`}):(0,q.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:a}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,q.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};function Za({config:e,customContent:t}){let{user:a,userRole:s}=r.Ft(),{config:l}=i.N(),[u,d]=(0,K.useState)([]),[f,p]=(0,K.useState)(!0),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``),[v,b]=(0,K.useState)(``),[x,S]=(0,K.useState)(!1),[T,D]=(0,K.useState)(``),[O,M]=(0,K.useState)(null),P=(0,K.useRef)(null),[F,I]=(0,K.useState)(null),[L,ne]=(0,K.useState)(null),R=e=>{if(ne(e),e){let t=e.fileType||``;V(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},z=L,[re,V]=(0,K.useState)(!0),[H,se]=(0,K.useState)(!1),[U,ce]=(0,K.useState)(null),[W,le]=(0,K.useState)(``),[G,ue]=(0,K.useState)(``),[de,Y]=(0,K.useState)([]),pe=(0,K.useRef)(null),[me,he]=(0,K.useState)(null),ge=(0,K.useRef)([]),_e=B.o(e,`internal_page`),X=o.Mn({...e,pageType:`internal`}),ve=X.startsWith(`user_`),ye=c.c(X),be=ye?B.t(e,X):`${X}${_e}_records`,xe=c.f(),Z=c.o({on:ve}),Q=Z.uid||a?.uid||``,Se=c.F(be),Ce=ye?Se.records:u,we=ye?Se.loading:f,Te=e=>ye?c.C(e,xe):e.uid===a?.uid||Z.someoneElse,Ee=s===`admin`,De=e=>Te(e)&&oe.d(e,s),Oe=(0,K.useRef)(!1);(0,K.useEffect)(()=>{!Ee||we||Oe.current||!Ce.length||(Oe.current=!0,oe.a(be,Ce,e,!0).catch(e=>console.warn(`Could not catch the delete lock up:`,e)).finally(()=>{Oe.current=!1}))},[Ee,we,Ce,oe.l(e),be]);let ke=e=>c.d(X,be,e),[Ae,je]=(0,K.useState)(()=>ye?c.u(be):``),Me=()=>je(c.u(be));(0,K.useEffect)(()=>{document.title=e.tabTitle||e.tabName||l.appName||`Your AI Firebase`},[e.tabTitle,e.tabName,l.appName]);let Ne=a?.uid,Pe=Z.uid||Ne||``,Fe=Z.everyone?`${Ne}|everyone`:Pe;(0,K.useEffect)(()=>{if(!Ne||ye)return;try{let e=C.o(be,Fe);e?(d(e),p(!1)):(d(e=>e.length?[]:e),p(!0))}catch{}let e=e=>ja(e),t=(0,J.onSnapshot)(ve&&!Z.everyone?(0,J.query)((0,J.collection)(r.ui,be),(0,J.where)(`uid`,`==`,Pe)):(0,J.query)((0,J.collection)(r.ui,be),(0,J.orderBy)(`createdAt`,`desc`),(0,J.limit)(150)),t=>{let n=e(t.docs);ve&&!Z.everyone&&n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),d(n),p(!1),C.s(be,Fe,n)},e=>{console.warn(`${be}: this account cannot read the records here (${e?.code||`permission-denied`}). A team page needs a verified address and an account marked Internal or Admin on the Users screen.`),d(e=>e.length?[]:e),p(!1)});return()=>t()},[Ne,Pe,Fe,be,ve,ye,Z.everyone]);let Ie=async e=>Ce.some(t=>t.id===e)||await(0,J.getDoc)((0,J.doc)(r.ui,be,e)).then(e=>e.exists()).catch(()=>!1),Le=()=>({name:a.displayName||a.email?.split(`@`)[0]||`Member`,email:a.email||``,avatar:a.photoURL||``}),Re=async(t,n)=>{let i=Le(),o={uid:Q,recordType:`record`,creatorName:i.name,creatorEmail:i.email,creatorAvatar:i.avatar,...oe.u(e,s),...t};if(!ye){let e=Na(t),n=e?(0,J.doc)(r.ui,be,e):(0,J.doc)((0,J.collection)(r.ui,be)),i={...o,createdAt:(0,J.serverTimestamp)()};return await(0,J.setDoc)(n,i),C.p(be,n.id,i),n.id}let l=n||Ae||c.u(be);return await(0,J.setDoc)((0,J.doc)(r.ui,be,l),c.l(o,a.uid)),n||Me(),l},ze=async e=>{if(e.preventDefault(),!(!a||!g.trim())){S(!0);try{await Re({name:g.trim(),note:v.trim()}),_(``),b(``),h(!1)}catch(e){console.error(`Error saving shared record:`,e)}S(!1)}},Be=c.b({upload:async(e,t)=>{if(!a)throw Error(`Sign in again before uploading.`);let n=await ee._(e),r=ye?P.current&&Ae||c.u(be):``,i=`${ke(r)}/${c.h(n.name)}`,o=await c.y(i,n,{customMetadata:{ownerId:a.uid},onProgress:t.progress,signal:t.signal});P.current?P.current(n,o,{uid:a.uid,storagePath:i,recordId:r}):await Re({name:n.name,note:`${n.type||`File`} · ${rt(n.size)}`,recordType:`file`,fileName:n.name,fileType:n.type||`unknown`,fileSize:n.size,downloadURL:o,storagePath:i},r)},onFailed:e=>D(`${e.name}: ${e.error||`That upload did not work.`}`),onSettled:()=>Be.clear()}),Ve=Be.busy,He=e=>{let t=Array.from(e.target.files||[]);e.target.value=``,!(!t.length||!a)&&(D(``),Be.add(t))},Ue=async()=>{if(F){se(!0);try{let e=Ce.find(e=>e.id===F);if(!oe.d(e,s)){k.n(`Nothing on this page can be deleted.`),I(null),se(!1);return}await(0,J.deleteDoc)((0,J.doc)(r.ui,be,F)),await ae.o(e,Ce,ke(F)),I(null)}catch(e){console.error(`Error deleting shared record:`,e)}se(!1)}},[We,Ge]=(0,K.useState)(null),[Ke,qe]=(0,K.useState)(``),[Je,Ye]=(0,K.useState)(!1),Xe=e=>{if(e.recordType===`file`){Ge(e.id),qe(e.name);return}ce(e.id),le(e.name),ue(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`storagePath`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));Y(n),ge.current=n.map(e=>e.key)},Ze=async()=>{if(!We||!Ke.trim()){Ge(null);return}let e=Ce.find(e=>e.id===We);if(e&&e.name===Ke.trim()){Ge(null);return}Ye(!0);try{await(0,J.updateDoc)((0,J.doc)(r.ui,be,We),{name:Ke.trim()}),d(e=>e.map(e=>e.id===We?{...e,name:Ke.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}Ye(!1),Ge(null)},Qe=async()=>{await $e(),ce(null)},$e=async()=>{if(!U||!W.trim())return;S(!0);let e={};de.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=de.map(e=>e.key.trim()).filter(Boolean),n=ge.current.filter(e=>!t.includes(e));n.forEach(t=>{e[t]=(0,J.deleteField)()});try{await(0,J.updateDoc)((0,J.doc)(r.ui,be,U),{name:W.trim(),note:G.trim(),...e}),d(e=>e.map(e=>{if(e.id!==U)return e;let t={...e,name:W.trim(),note:G.trim()};return n.forEach(e=>{delete t[e]}),de.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),ge.current=t}catch(e){console.error(`Error saving record:`,e)}S(!1)},et=(e,t)=>e?e.startsWith(`image/`)?t?(0,q.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,q.jsx)(y.c,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,q.jsx)(c.R,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,q.jsx)(y.u,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,q.jsx)(c.V,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,q.jsx)(c.B,{className:`w-4 h-4`}):(0,q.jsx)(y.l,{className:`w-4 h-4`}):(0,q.jsx)(y.u,{className:`w-4 h-4`}),tt=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-accent/10 text-accent`: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`,nt=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)},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]},it=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},at=n.p(e.buttonStorageIcon)||yt,ot=e.buttonStyle!==`secondary`,st=e.buttonStorageStyle===`primary`;return(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,q.jsx)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(n.t,{children:e.tabTitle||e.tabName||`Internal Page`}),e.route&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,q.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,q.jsx)(i.t,{}),(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:t?`flex flex-col flex-1 relative`:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,q.jsx)(`input`,{type:`file`,multiple:!0,ref:pe,onChange:He,className:`hidden`}),!t&&(0,q.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,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-xl font-bold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,q.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:we?`Loading…`:`${Ce.length} ${Ce.length===1?`item`:`items`} · Internal`}),(T||ye&&Se.error)&&(0,q.jsx)(`p`,{className:`text-[12px] font-semibold text-red-500 mt-1 truncate`,role:`alert`,children:T||Se.error}),Z.someoneElse&&e.storage!==!1&&(0,q.jsx)(`p`,{className:`text-[12px] font-medium text-foreground/50 mt-1 max-sm:hidden`,children:`You are looking at somebody else’s page. Anything you add here is theirs, but a file would stay yours — so uploads are off until you switch back to your own.`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,q.jsx)(c.a,{viewing:Z}),e.storage!==!1&&!Z.someoneElse&&(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>pe.current?.click(),title:Ve?Be.done?`${Be.done} of ${Be.total} uploaded…`:`Uploading ${Be.total===1?`your file`:`${Be.total} files`}…`:e.buttonStorageText||`Upload files`,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`} ${st?`btn-primary`:`btn-secondary`}`,children:[Ve?(0,q.jsx)(w.r,{className:`w-4 h-4 animate-spin`}):(0,q.jsx)(at,{className:`w-4 h-4`}),e.buttonStorageText&&(0,q.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})}),e.showButton!==!1&&(0,q.jsx)(r.nt.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`} ${ot?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,q.jsx)(E.t,{className:`w-4 h-4`}):(0,q.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,q.jsxs)(`div`,{className:t?`flex-1 flex flex-col relative min-h-[400px]`:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[we&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,q.jsx)(w.r,{className:`w-8 h-8 text-accent animate-spin`})}),t?(0,q.jsx)(c.p,{value:{prefix:X,collection:ye?be:``,recordId:ye?U||Ae:``},children:(0,q.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill`,children:(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(te.t,{config:e,children:(0,q.jsx)(t,{config:e,actions:{records:Ce,loading:we,error:ye?Se.error:``,collection:be,user:a,...c.s(be,xe,ye,Ae),saveRecord:async(t,n)=>{let r=Le(),i=Ma(Oa(t,n)),a=ye?null:Na(i);if(a&&await Ie(a))return a;let o=await Re(Va(i));return ye||d(t=>[{uid:Q,recordType:`record`,creatorName:r.name,creatorEmail:r.email,creatorAvatar:r.avatar,...oe.u(e,s),createdAt:Date.now(),...i,id:o},...t.filter(e=>e.id!==o)]),o},updateRecord:async(e,t,n)=>{let{id:i,data:o}=ka(e,t,n),s=Ma(o),c={...Di(a),...Va(s,Ce.find(e=>e.id===i))};ye||d(e=>e.map(e=>e.id===i?{...e,...c}:e)),await(0,J.updateDoc)((0,J.doc)(r.ui,be,i),c);let l=Ce.find(e=>e.id===i);l&&C.p(be,i,{...l,...c})},deleteRecord:async(e,t)=>{let n=Aa(e,t),i=Ce.find(e=>e.id===n);if(!oe.d(i,s)){k.n(`Nothing on this page can be deleted.`);return}await(0,J.deleteDoc)((0,J.doc)(r.ui,be,n)),C.m(be,n),await ae.o(i,Ce,ke(n))},startEdit:e=>Xe(e),confirmDelete:e=>I(e),uploadFile:()=>{Z.someoneElse||pe.current?.click()},openAddForm:()=>h(!0),setAddForm:e=>M(()=>e),setFileHandler:e=>{P.current=e}}})})})})}):(0,q.jsxs)(q.Fragment,{children:[!we&&Ce.length===0&&(0,q.jsxs)(r.nt.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,q.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,q.jsx)(E.t,{className:`w-6 h-6 text-accent/40`})}),(0,q.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,q.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.`})]}),!we&&Ce.length>0&&(0,q.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,q.jsx)(r.rt,{children:Ce.map(e=>{let t=U===e.id,n=Te(e);return(0,q.jsxs)(r.nt.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>n?Xe(e):null,className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative ${n?`cursor-pointer`:``} ${t?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,q.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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),he(e.id),setTimeout(()=>he(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:me===e.id?(0,q.jsx)(r.At,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,q.jsx)(c.z,{className:`w-3.5 h-3.5`})}),(0,q.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,q.jsx)(y.d,{className:`w-3.5 h-3.5`})})]}),n&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Xe(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,q.jsx)(y.s,{className:`w-3.5 h-3.5`})}),n&&De(e)&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),I(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,q.jsx)(A.t,{className:`w-3.5 h-3.5`})})]}),(0,q.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,q.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&R(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 ${tt(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?et(e.fileType,e.downloadURL):(0,q.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,q.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[We===e.id?(0,q.jsx)(`input`,{autoFocus:!0,type:`text`,value:Ke,onChange:e=>qe(e.target.value),onBlur:()=>Ze(),onKeyDown:e=>{e.key===`Enter`&&Ze(),e.key===`Escape`&&Ge(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,q.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>R(e)}),(0,q.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:it(e.createdAt)})]})]}),e.note&&(0,q.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,q.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,q.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,q.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,q.jsx)(Xa,{record:e})]},e.id)})})})]})]})]})]}),(0,q.jsx)(r.rt,{children:m&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>!x&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,q.jsx)(r.nt.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:O?K.default.createElement(O,{onSave:async e=>{S(!0);try{await Re(e),h(!1)}catch(e){console.error(`Error saving record:`,e)}S(!1)},onClose:()=>!x&&h(!1),saving:x}):(0,q.jsxs)(`form`,{onSubmit:ze,className:`p-5 flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>!x&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,q.jsx)(w.t,{className:`w-4 h-4`})})]}),(0,q.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:x,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,q.jsx)(r.Q,{value:v,onChange:e=>b(e.target.value),placeholder:`Note (optional)`,disabled:x,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,q.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,q.jsx)(N.t,{type:`submit`,isLoading:x,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:x?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,fe.createPortal)((0,q.jsx)(r.rt,{children:z&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>R(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,q.jsx)(`button`,{onClick:()=>R(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,q.jsx)(w.t,{className:`w-5 h-5`})}),(0,q.jsxs)(r.nt.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,q.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,q.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,q.jsx)(`span`,{className:`text-xl font-bold text-foreground truncate`,children:z.fileName||z.name}),(0,q.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[nt(z.fileType),` • `,rt(z.fileSize||0)]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,q.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(z.downloadURL),he(`preview`),setTimeout(()=>he(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:me===`preview`?(0,q.jsx)(r.At,{className:`w-4 h-4 text-emerald-500`}):(0,q.jsx)(c.z,{className:`w-4 h-4`})}),(0,q.jsx)(`button`,{onClick:()=>{R(null),Ge(z.id),qe(z.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,q.jsx)(y.s,{className:`w-4 h-4`})}),(0,q.jsx)(`button`,{onClick:()=>{R(null),I(z.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,q.jsx)(A.t,{className:`w-4 h-4`})}),(0,q.jsx)(`a`,{href:z.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,q.jsx)(y.d,{className:`w-4 h-4`})})]})]}),(0,q.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>R(null),children:(0,q.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[re&&(0,q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,q.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,q.jsx)(w.r,{className:`w-5 h-5 text-accent animate-spin`})})}),z.fileType?.startsWith(`image/`)?(0,q.jsx)(`img`,{onLoad:()=>V(!1),onError:()=>V(!1),src:z.downloadURL,alt:z.fileName||z.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 ${re?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):z.fileType?.startsWith(`video/`)?(0,q.jsx)(`video`,{onLoadedData:()=>V(!1),onError:()=>V(!1),src:z.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 ${re?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):z.fileType===`application/pdf`?(0,q.jsx)(`iframe`,{onLoad:()=>V(!1),src:z.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${re?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,q.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(),V(!1)},children:[(0,q.jsx)(y.u,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,q.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,q.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,q.jsx)(r.rt,{children:U&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>Qe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,q.jsx)(r.nt.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,q.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),x&&(0,q.jsx)(w.r,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>Qe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,q.jsx)(w.t,{className:`w-4 h-4`})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,q.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,q.jsx)(`input`,{autoFocus:!0,required:!0,value:W,onChange:e=>le(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>$e(),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,q.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,q.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,q.jsx)(r.Q,{value:G,onChange:e=>ue(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>$e(),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,q.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),de.map((e,t)=>(0,q.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,q.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...de];n[t].key=e.target.value,Y(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>$e(),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,q.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...de];n[t].value=e.target.value,Y(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>$e(),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,q.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>Y(de.filter((e,n)=>n!==t)),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,q.jsx)(w.t,{className:`w-3 h-3`})})]},t)),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>Y([...de,{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,q.jsx)(E.t,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,q.jsx)(ie.t,{isOpen:!!F,onCancel:()=>I(null),onConfirm:Ue,title:`Delete Record`,message:(0,q.jsxs)(q.Fragment,{children:[`Are you sure you want to delete `,(0,q.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:Ce.find(e=>e.id===F)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:H})]})}var Qa=5,$a=3,eo=8,to=250,no=56,ro=14,io=8,ao=`button, a, input, textarea, select, label, [role="button"], [role="listbox"], [role="option"], [contenteditable="true"], [data-no-drag]`,oo=!1,so=()=>{oo||typeof window>`u`||(oo=!0,window.addEventListener(`touchmove`,()=>{},{passive:!1}))};function co(e){let[t,n]=(0,K.useState)(null),r=(0,K.useRef)(e);(0,K.useEffect)(()=>{r.current=e}),(0,K.useEffect)(so,[]);let i=(0,K.useRef)(null),a=(0,K.useCallback)(e=>{let t=i.current;t&&(i.current=null,t.cleanup(),t.active&&(n(null),e===`drop`?r.current.onDrop(t.key):r.current.onCancel?.(t.key)))},[]);(0,K.useEffect)(()=>()=>a(`cancel`),[a]);let o=(0,K.useCallback)((e,t)=>{if(r.current.disabled||i.current||t.pointerType===`mouse`&&t.button!==0)return;let o=t.target,s=!!o.closest?.(`[data-drag-handle]`),c=s?null:o.closest?.(ao);if(c&&!c.hasAttribute(`data-drag-ok`))return;let l=t.currentTarget,u=t.pointerType===`touch`,d=s?$a:u?eo:Qa,f=()=>{let e=i.current;if(!(!e||e.active)){e.active=!0,e.hold&&=(clearTimeout(e.hold),null);try{navigator.vibrate?.(8)}catch{}r.current.onStart?.(e.key),n({key:e.key,x:e.x,y:e.y,offsetX:e.startX-e.rect.left,offsetY:e.startY-e.rect.top,width:e.rect.width,height:e.rect.height}),r.current.onMove({x:e.x,y:e.y,at:e.at},e.key),e.frame=requestAnimationFrame(p)}},p=e=>{let t=i.current;if(!t||!t.active)return;t.at=e;let n=!1;t.y<no?(window.scrollBy(0,-ro),n=!0):t.y>window.innerHeight-no&&(window.scrollBy(0,ro),n=!0);let a=r.current.scroller?.();if(a){let e=a.getBoundingClientRect(),r=a.scrollLeft;t.x<e.left+no?a.scrollLeft-=io:t.x>e.right-no&&(a.scrollLeft+=io),a.scrollLeft!==r&&(n=!0)}n&&r.current.onMove({x:t.x,y:t.y,at:e},t.key),t.frame=requestAnimationFrame(p)},m=e=>{let t=i.current;if(!(!t||e.pointerId!==t.pointerId)){if(t.x=e.clientX,t.y=e.clientY,t.at=e.timeStamp,!t.active){if(!(Math.hypot(t.x-t.startX,t.y-t.startY)>d))return;if(u&&!s){a(`cancel`);return}f();return}n(e=>e&&{...e,x:t.x,y:t.y}),r.current.onMove({x:t.x,y:t.y,at:t.at},t.key)}},h=e=>{let t=i.current;if(!(!t||e.pointerId!==t.pointerId)){if(t.active){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),80)}a(`drop`)}},g=e=>{i.current&&e.pointerId===i.current.pointerId&&a(`cancel`)},_=e=>{e.key===`Escape`&&i.current?.active&&(e.preventDefault(),a(`cancel`))},v=e=>{i.current?.active&&e.cancelable&&e.preventDefault()},y=e=>{u&&e.preventDefault()},b=e=>e.preventDefault(),x=document.body.style.userSelect,S={key:e,pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,x:t.clientX,y:t.clientY,at:t.timeStamp,rect:l.getBoundingClientRect(),active:!1,hold:u&&!s?setTimeout(f,to):null,frame:null,cleanup:()=>{S.hold&&clearTimeout(S.hold),S.frame!=null&&cancelAnimationFrame(S.frame),window.removeEventListener(`pointermove`,m),window.removeEventListener(`pointerup`,h),window.removeEventListener(`pointercancel`,g),window.removeEventListener(`keydown`,_,!0),window.removeEventListener(`touchmove`,v),window.removeEventListener(`contextmenu`,y,!0),window.removeEventListener(`dragstart`,b,!0),document.body.style.userSelect=x}};i.current=S,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,m),window.addEventListener(`pointerup`,h),window.addEventListener(`pointercancel`,g),window.addEventListener(`keydown`,_,!0),window.addEventListener(`touchmove`,v,{passive:!1}),window.addEventListener(`contextmenu`,y,!0),window.addEventListener(`dragstart`,b,!0)},[a]);return{dragging:t,bind:(0,K.useCallback)(e=>({"data-drag-key":e,onPointerDown:t=>o(e,t),style:{WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`}}),[o])}}var lo={"data-drag-handle":``,style:{touchAction:`none`,cursor:`grab`}},uo=()=>[{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()}],fo=()=>`item_${Date.now()}`,po=(e,t)=>({id:e,categoryId:t.categoryId,name:t.name||t.text||`Unnamed Item`,fields:t.fields||(t.value?[{key:`Label`,value:t.value}]:[]),order:t.order||0,uid:t.uid,creatorName:t.creatorName,creatorAvatar:t.creatorAvatar,access:t.access,editors:t.editors}),mo=[{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 ho({title:e=`Board View`,subtitle:t=`/board`,backUrl:s,tasksCollection:l=`pub_tasks`,categoriesCollection:u=`pub_categories`,config:d,customContent:f}){let{user:p}=r.Ft(),m=!!d,h=d?.isInternal||d?.isShared;d?.isPrivate&&d?.isAdmin;let g=d?.isAdmin||h,_=o.Tn(l),v=c.f(),b=c.F(l),x=c.F(u),S=m?g||_||l.startsWith(`role_`):!0,C=e=>!_||c.C(e,v),T=c.o({on:l.startsWith(`user_`)&&!_,everyone:!1}),D=T.uid||p?.uid||``,[O,k]=(0,K.useState)(()=>_?c.u(l):``),M=(e,t,n,r)=>p?o.Tn(e)?n?c.l({uid:p.uid,...r?Ei(p):{},...t},p.uid):t:e.startsWith(`user_`)?{...t,uid:D||p.uid}:n?{uid:p.uid,...r?Ei(p):{},...t}:t:t,P=!!f,ee=d?.showButton!==!1&&!P,F=d?.buttonText||`+`,te=d?.buttonStyle||`primary`,I=d?.keyName||`key`,L=d?.valueName||`value`,[ne,R]=(0,K.useState)([]),[z,re]=(0,K.useState)([]),B=_?b.records.map(e=>po(e.id,e)).sort((e,t)=>(e.order||0)-(t.order||0)):ne,V=_?x.records:z,[ae,oe]=(0,K.useState)(null),[H,se]=(0,K.useState)(null),[U,ce]=(0,K.useState)({name:``}),[W,le]=(0,K.useState)([]),[G,ue]=(0,K.useState)(null),de=(0,K.useRef)(null),Y=e=>{de.current=e,ue(e)},pe=(0,K.useRef)(null),[me,he]=(0,K.useState)(null),[ge,_e]=(0,K.useState)(!1),[X,ve]=(0,K.useState)(null),[ye,be]=(0,K.useState)(``),[xe,Z]=(0,K.useState)(null),Q=T.uid||p?.uid;(0,K.useEffect)(()=>{let e=l.startsWith(`user_`),t=u.startsWith(`user_`);if(e&&!p||_)return;let n=e&&Q?`${l}|${Q}`:l,i=t&&Q?`${u}|${Q}`:u;try{let e=localStorage.getItem(`fbos_board_tasks_${n}`);e&&R(JSON.parse(e));let t=localStorage.getItem(`fbos_board_cats_${i}`);t&&re(JSON.parse(t))}catch{}let o=(0,J.onSnapshot)(e&&Q?(0,J.query)((0,J.collection)(r.ui,l),(0,J.where)(`uid`,`==`,Q)):(0,J.collection)(r.ui,l),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,uid:n.uid,creatorName:n.creatorName,creatorAvatar:n.creatorAvatar})});let r=t.sort((e,t)=>(e.order||0)-(t.order||0));R(r),localStorage.setItem(`fbos_board_tasks_${n}`,JSON.stringify(r))},a.s),s=(0,J.onSnapshot)(t&&Q?(0,J.query)((0,J.collection)(r.ui,u),(0,J.where)(`uid`,`==`,Q)):(0,J.collection)(r.ui,u),e=>{let n=[];if(e.forEach(e=>{n.push({id:e.id,...e.data()})}),n.length===0){let e=uo(),n=Q?{uid:Q}:{},i=t&&Q?`_${Q}`:``;e.forEach(e=>(0,J.setDoc)((0,J.doc)(r.ui,u,`${e.id}${i}`),{...n,title:e.title,createdAt:e.createdAt}))}else re(n),localStorage.setItem(`fbos_board_cats_${i}`,JSON.stringify(n))},a.s);return()=>{o(),s()}},[l,u,Q,_]);let Se=(0,K.useRef)(!1);(0,K.useEffect)(()=>{!_||!Q||x.loading||x.records.length||Se.current||(Se.current=!0,uo().forEach(e=>(0,J.setDoc)((0,J.doc)(r.ui,u,`${e.id}_${Q}`),c.l({uid:Q,title:e.title,createdAt:e.createdAt},Q))))},[_,Q,x.loading,x.records.length,u]);let Ce=(e,t)=>{t?(se(t.id),ce({id:t.id,name:t.name}),le(t.fields?.length?[...t.fields,{key:``,value:``}]:[{key:``,value:``}])):(oe(e),ce({name:``}),le([{key:``,value:``}]))},we=(e,t,n)=>{let r=[...W];r[e]={key:t,value:n},e===W.length-1&&(t.trim()!==``||n.trim()!==``)&&r.push({key:``,value:``}),le(r)},Te=async(e,t,n)=>{let i=B.find(t=>t.id===e);if(!i||!C(i))return;let a=B.filter(e=>e.categoryId===t).sort((e,t)=>(e.order||0)-(t.order||0)),o=a.filter(t=>t.id!==e),s=Math.max(0,Math.min(n,o.length));i.categoryId===t&&a.findIndex(t=>t.id===e)===s||[...o.slice(0,s),i,...o.slice(s)].forEach((e,n)=>{let i=M(l,{categoryId:t,order:n},!1,!1);(0,J.setDoc)((0,J.doc)(r.ui,l,e.id),i,{merge:!0})})},{dragging:Ee,bind:De}=co({scroller:()=>pe.current,onMove:({x:e,y:t},n)=>{let r=pe.current;if(!r)return;let i=null,a=1/0;for(let t of Array.from(r.querySelectorAll(`[data-board-column]`))){let n=t.getBoundingClientRect(),r=e<n.left?n.left-e:e>n.right?e-n.right:0;r<a&&(a=r,i=t)}let o=i?.dataset.boardColumn;if(!i||!o){Y(null);return}let s=Array.from(i.querySelectorAll(`[data-drag-key]`)).filter(e=>e.dataset.dragKey!==n).filter(e=>{let n=e.getBoundingClientRect();return t>n.top+n.height/2}).length,c=de.current;(!c||c.categoryId!==o||c.index!==s)&&Y({categoryId:o,index:s})},onDrop:e=>{let t=de.current;Y(null),t&&Te(e,t.categoryId,t.index)},onCancel:()=>Y(null)}),Oe=Ee?.key??null,ke=Oe?B.find(e=>e.id===Oe):void 0,Ae=async e=>{let t=U.id||fo(),n=U.name.trim(),i=n||`Untitled Item`,a=W.filter(e=>e.key.trim()!==``||e.value.trim()!==``),o=!0,s=U.id?B.find(e=>e.id===U.id):null;if(s){let e=JSON.stringify(s.fields||[]),t=JSON.stringify(a);s.name===i&&e===t&&(o=!1)}else !n&&a.length===0&&(o=!1);if(!o){oe(null),se(null);return}he(U.id||`new`);let c=M(l,{categoryId:e,name:i,fields:a},!U.id,!0);await(0,J.setDoc)((0,J.doc)(r.ui,l,t),c,{merge:!0}),setTimeout(()=>{oe(null),se(null),he(null)},400)},je=(e,t)=>{Z({type:`item`,id:e,title:t})},Me=async()=>{let e=`cat_${Date.now()}`,t=M(u,{title:``,createdAt:Date.now()},!0,!1);await(0,J.setDoc)((0,J.doc)(r.ui,u,e),t),ve(e),be(``),setTimeout(()=>{let e=document.getElementById(`board-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},150)},Ne=async(e,t)=>{re(n=>n.map(n=>n.id===e?{...n,color:t}:n)),await(0,J.setDoc)((0,J.doc)(r.ui,u,e),{color:t},{merge:!0})},Pe=async e=>{ye.trim()?await(0,J.setDoc)((0,J.doc)(r.ui,u,e),{title:ye},{merge:!0}):await(0,J.deleteDoc)((0,J.doc)(r.ui,u,e)),ve(null)},Fe=(e,t)=>{Z({type:`category`,id:e,title:t})},Ie=async()=>{if(xe){_e(!0);try{if(xe.type===`item`)await(0,J.deleteDoc)((0,J.doc)(r.ui,l,xe.id)),se(null);else{let e=B.filter(e=>e.categoryId===xe.id);for(let t of e)await(0,J.deleteDoc)((0,J.doc)(r.ui,l,t.id));await(0,J.deleteDoc)((0,J.doc)(r.ui,u,xe.id))}}catch{}_e(!1),Z(null)}},Le=[...V].sort((e,t)=>(e.createdAt||0)-(t.createdAt||0));return(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen overflow-x-clip`,children:[(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4 md:mb-6 flex items-center gap-3`,children:[!m&&s&&(0,q.jsx)(c.r,{to:s}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(n.t,{children:e}),t&&(0,q.jsxs)(`div`,{className:`max-sm:hidden sm:flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,q.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 min-h-0 pb-16`,children:[m&&(0,q.jsx)(i.t,{}),(0,q.jsxs)(r.nt.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 min-h-[400px] shadow-2xl bg-background relative z-10`,children:[(0,q.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,q.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 relative z-20`,children:[(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-lg sm:text-xl font-bold text-foreground tracking-tight truncate`,children:d?.tabTitle||d?.tabName||e}),(0,q.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[B.length,` `,B.length===1?`item`:`items`,` · `,Le.length,` `,Le.length===1?`category`:`categories`]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,q.jsx)(c.a,{viewing:T}),ee&&(0,q.jsx)(N.t,{variant:te===`secondary`?`secondary`:void 0,onClick:Me,className:`px-3 py-2.5 text-[14px] font-bold rounded-xl shadow-lg hover:-translate-y-0.5 transition-all shrink-0`,children:F===`+`?(0,q.jsx)(E.t,{className:`w-4 h-4`}):F})]})]}),(0,q.jsx)(`div`,{className:`flex-1 w-full relative z-40 min-h-0 flex flex-col`,children:f?(0,q.jsx)(c.p,{value:{prefix:o.Mn(d||{}),collection:_?l:``,recordId:_?H||O:``},children:(0,q.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill w-full flex-1 overflow-y-auto p-4 md:p-6`,children:(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(f,{config:d,actions:{tasks:B,categories:V,collection:l,catCollection:u,user:p,error:_?b.error||x.error:``,...c.s(l,v,_,O),saveTask:async(e,t)=>{let n=e||fo(),i=M(l,t,!B.some(e=>e.id===n),!0);_&&n===O&&k(c.u(l)),R(e=>e.find(e=>e.id===n)?e.map(e=>e.id===n?{...e,...i}:e):[...e,{id:n,...i}]),await(0,J.setDoc)((0,J.doc)(r.ui,l,n),i,{merge:!0})},deleteTask:async e=>{R(t=>t.filter(t=>t.id!==e)),await(0,J.deleteDoc)((0,J.doc)(r.ui,l,e))},saveCategory:async(e,t)=>{let n=M(u,t,!V.some(t=>t.id===e),!1);re(t=>t.find(t=>t.id===e)?t.map(t=>t.id===e?{...t,...n}:t):[...t,{id:e,...n}]),await(0,J.setDoc)((0,J.doc)(r.ui,u,e),n,{merge:!0})},deleteCategory:async e=>{re(t=>t.filter(t=>t.id!==e)),await(0,J.deleteDoc)((0,J.doc)(r.ui,u,e))},openInlineEditor:(e,t)=>Ce(e,t)}})})})}):(0,q.jsxs)(`div`,{ref:pe,id:`board-container`,className:`w-full flex-1 min-h-0 flex flex-row gap-4 md:gap-6 overflow-x-auto p-4 md:p-6 snap-x snap-mandatory styled-scrollbars items-start`,children:[Le.map((e,t)=>{let n=B.filter(t=>t.categoryId===e.id);n.sort((e,t)=>(e.order||0)-(t.order||0));let i=mo.find(t=>t.text===e.color)||mo.find(e=>e.text===`text-accent`);i.text,i.bgLight,i.bgHover;let a=G?.categoryId===e.id,o=n.filter(e=>e.id!==Oe),s=a?o[G.index]?.id??null:null,c=a&&G.index>=o.length;return(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:t*.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 ${mo.find(t=>t.text===e.color)?.bgCard||`bg-foreground/[0.02]`} ${mo.find(t=>t.text===e.color)?.borderCard||`border-[var(--panel-border)]/50`}`,children:[(0,q.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-2 relative z-[200]`,children:(0,q.jsxs)(`h3`,{className:`font-bold text-[14px] flex items-center w-full text-foreground/80 group relative z-[200]`,children:[X===e.id?(0,q.jsxs)(`div`,{className:`relative flex-1 w-full flex items-center pr-8 z-[200]`,children:[(0,q.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Pe(e.id)}}),(0,q.jsx)(`input`,{value:ye,onChange:e=>be(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,q.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,q.jsx)(`button`,{onClick:async t=>{t.preventDefault(),t.stopPropagation(),await Ne(e.id,``),ve(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,q.jsx)(w.t,{className:`w-3 h-3`})}),(0,q.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),mo.map(t=>(0,q.jsx)(`button`,{onMouseDown:async n=>{n.preventDefault(),await Ne(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,q.jsxs)(`div`,{className:`flex items-center gap-2 w-full hover:text-foreground transition-colors pr-8 ${C(e)?`cursor-pointer`:``}`,onClick:()=>{C(e)&&(ve(e.id),be(e.title))},children:[(0,q.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${mo.find(t=>t.text===e.color)?.bgCircle||`bg-foreground/20`} transition-colors shrink-0`}),(0,q.jsx)(`span`,{className:`truncate flex-1 max-w-[200px] ${e.color||``}`,children:e.title||`Untitled Category`}),(0,q.jsx)(`span`,{className:`text-[11px] bg-foreground/10 text-foreground/60 px-1.5 py-0.5 rounded-md font-medium shrink-0`,children:n.length})]}),V.length>1&&C(e)&&(0,q.jsx)(`button`,{onClick:()=>Fe(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,q.jsx)(A.t,{className:`w-3.5 h-3.5`})})]})}),(0,q.jsxs)(`div`,{"data-board-column":e.id,className:`flex flex-col gap-2.5 flex-1 overflow-y-auto styled-scrollbars pr-1 relative min-h-[150px] rounded-xl transition-colors ${a?`bg-foreground/5 border-dashed border border-accent/20`:``}`,children:[(0,q.jsx)(r.rt,{children:n.map(t=>H===t.id?(0,q.jsxs)(r.nt.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,q.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Ae(e.id)}}),(0,q.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:U.name,onChange:e=>ce({...U,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Ae(e.id))}}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:W.map((t,n)=>(0,q.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,q.jsx)(`input`,{placeholder:I,value:t.key,onChange:e=>we(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&Ae(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||I.length)}ch`}}),(0,q.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,q.jsx)(`textarea`,{rows:1,placeholder:L,value:t.value,onChange:e=>we(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(),Ae(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))}),me===t.id&&(0,q.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,q.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]},t.id):(0,K.createElement)(r.nt.div,{...C(t)?De(t.id):{"data-drag-key":t.id},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},key:t.id,className:`bg-background/80 rounded-xl p-3 shadow-sm hover:shadow-md ${C(t)?`cursor-grab active:cursor-grabbing`:``} hover:border-accent/40 transition-all group flex flex-col gap-2 relative z-10 border ${s===t.id?`border-accent border-t-2 translate-y-1`:`border-[var(--panel-border)]`} ${Oe===t.id?`opacity-30 border-dashed border-2`:``}`},C(t)&&(0,q.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,q.jsx)(`span`,{...lo,"aria-hidden":`true`,className:`p-1 rounded-md text-foreground/40 hover:text-foreground/70 transition-colors`,children:(0,q.jsx)(rt,{className:`w-3.5 h-3.5`})}),(0,q.jsx)(`button`,{onClick:n=>{n.stopPropagation(),Ce(e.id,t)},className:`p-1 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-accent transition-colors`,children:(0,q.jsx)(y.s,{className:`w-3.5 h-3.5`})}),(0,q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),je(t.id,t.name)},className:`p-1 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,children:(0,q.jsx)(A.t,{className:`w-3.5 h-3.5`})})]}),(0,q.jsx)(`p`,{className:`text-[13px] text-foreground/90 font-medium leading-snug break-words pr-12`,children:t.name}),C(t)&&Le.length>1&&(0,q.jsx)(`div`,{className:`-ml-2 -mb-1 mt-0.5 flex items-center`,"data-no-drag":``,children:(0,q.jsx)(r.Z,{compact:!0,portal:!0,direction:`auto`,variant:`ghost`,ariaLabel:`Move “${t.name}” to another category`,value:e.id,options:Le.map(e=>({value:e.id,label:e.title||`Untitled Category`})),onChange:n=>{n!==e.id&&Te(t.id,n,0)}})}),t.fields&&t.fields.length>0&&(0,q.jsx)(`div`,{className:`flex flex-row flex-wrap gap-2 mt-2`,children:t.fields.map((e,t)=>(0,q.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,q.jsxs)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative -top-[1px] shrink-0 break-all`,children:[e.key,`:`]}),(0,q.jsx)(`span`,{className:`text-[12px] text-foreground/90 font-medium break-words leading-tight min-w-0`,children:e.value})]},t))}),(0,q.jsxs)(`div`,{className:`flex items-end justify-between mt-3 pt-3 border-t border-[var(--panel-border)]/50 w-full gap-2`,children:[(()=>{let e=S&&m?ki(t,p):null;return e?(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`,children:[e.avatar?(0,q.jsx)(r.O,{src:e.avatar,alt:``,className:`w-4 h-4 rounded-full shrink-0`}):(0,q.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:e.name[0].toUpperCase()}),(0,q.jsx)(`span`,{className:`text-[10px] font-bold text-foreground/60 truncate max-w-[80px]`,children:e.name})]}):(0,q.jsx)(`div`,{className:`flex items-center gap-2 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`})})(),(0,q.jsx)(`span`,{className:`text-[10px] text-foreground/40 font-bold text-right pt-0.5 shrink-0 max-w-[50%] truncate flex-1`,children:t.id.startsWith(`item_`)?new Date(parseInt(t.id.split(`_`)[1])).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`Recently Added`})]})))}),c&&o.length>0&&(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`h-0.5 -mt-1 rounded-full bg-accent`}),ae===e.id?(0,q.jsxs)(r.nt.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,q.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Ae(e.id)}}),(0,q.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:U.name,onChange:e=>ce({...U,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),Ae(e.id))},autoFocus:!0}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:W.map((t,n)=>(0,q.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,q.jsx)(`input`,{placeholder:I,style:{width:`${Math.max(3,t.key.length||I.length)}ch`},value:t.key,onChange:e=>we(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&Ae(e.id),className:`no-glow bg-transparent outline-none text-[11px] text-foreground/50 font-bold placeholder:text-foreground/30 relative top-[1px]`}),(0,q.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,q.jsx)(`textarea`,{rows:1,placeholder:L,value:t.value,onChange:e=>we(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(),Ae(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))}),me===`new`&&(0,q.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,q.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]}):(0,q.jsxs)(`button`,{onClick:()=>Ce(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,q.jsx)(E.t,{className:`w-4 h-4`}),` Add Item`]})]})]},e.id)}),(0,q.jsx)(`div`,{className:`w-[10px] shrink-0 pointer-events-none`}),Ee&&ke&&typeof document<`u`&&(0,fe.createPortal)((0,q.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none fixed z-[9995] rotate-[1.5deg] rounded-xl border border-accent/40 bg-background/95 p-3 shadow-2xl`,style:{left:Ee.x-Ee.offsetX,top:Ee.y-Ee.offsetY,width:Ee.width},children:(0,q.jsx)(`p`,{className:`text-[13px] text-foreground/90 font-medium leading-snug break-words`,children:ke.name})}),document.body)]})})]})]}),(0,q.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,q.jsx)(ie.t,{isOpen:!!xe,title:`Confirm Deletion`,message:(0,q.jsxs)(q.Fragment,{children:[`Are you sure you want to delete `,(0,q.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:xe?.title}),` This action is permanent.`]}),onConfirm:Ie,onCancel:()=>Z(null),isProcessing:ge,confirmText:`Yes, Delete`})]})}function go(e){return Array.isArray?Array.isArray(e):Eo(e)===`[object Array]`}function _o(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 vo(e){return e==null?``:_o(e)}function yo(e){return typeof e==`string`}function bo(e){return typeof e==`number`}function xo(e){return e===!0||e===!1||Co(e)&&Eo(e)==`[object Boolean]`}function So(e){return typeof e==`object`}function Co(e){return So(e)&&e!==null}function wo(e){return e!=null}function To(e){return!e.trim().length}function Eo(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var Do=`Incorrect 'index' type`,Oo=e=>`Invalid value for key ${e}`,ko=e=>`Pattern length exceeds max of ${e}.`,Ao=e=>`Missing ${e} property in key`,jo=e=>`Property 'weight' in key '${e}' must be a positive integer`,Mo=Object.prototype.hasOwnProperty,No=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=Po(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 Po(e){let t=null,n=null,r=null,i=1,a=null;if(yo(e)||go(e))r=e,t=Fo(e),n=Io(e);else{if(!Mo.call(e,`name`))throw Error(Ao(`name`));let o=e.name;if(r=o,Mo.call(e,`weight`)&&(i=e.weight,i<=0))throw Error(jo(o));t=Fo(o),n=Io(o),a=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:a}}function Fo(e){return go(e)?e:e.split(`.`)}function Io(e){return go(e)?e.join(`.`):e}function Lo(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(wo(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!wo(s))return;if(a===t.length-1&&(yo(s)||bo(s)||xo(s)||typeof s==`bigint`))n.push(o===void 0?vo(s):{v:vo(s),i:o});else if(go(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,yo(t)?t.split(`.`):t,0),r?n:n[0]}var Ro={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},zo={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},Bo={location:0,threshold:.6,distance:100},Vo={useExtendedSearch:!1,useTokenSearch:!1,getFn:Lo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},$=Object.freeze({...zo,...Ro,...Bo,...Vo}),Ho=/[^ ]+/g;function Uo(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=t.match(Ho).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 Wo=class{constructor({getFn:e=$.getFn,fieldNormWeight:t=$.fieldNormWeight}={}){this.norm=Uo(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,yo(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();yo(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(!wo(e)||To(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(wo(i)){if(go(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(wo(n)){if(yo(n)){if(!To(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(wo(n.v)){let t=yo(n.v)?n.v:vo(n.v);if(!To(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[r]=e}else if(yo(i)&&!To(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 Go(e,t,{getFn:n=$.getFn,fieldNormWeight:r=$.fieldNormWeight}={}){let i=new Wo({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(Po)),i.setSources(t),i.create(),i}function Ko(e,{getFn:t=$.getFn,fieldNormWeight:n=$.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new Wo({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function qo(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 Jo=32;function Yo(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>Jo)throw Error(ko(Jo));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=qo(_,s);e.length?c&&(C.indices=e):C.isMatch=!1}return C}function Xo(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 Zo(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 Qo={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},$o=RegExp(`[`+Object.keys(Qo).join(``)+`]`,`g`),es=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($o,e=>Qo[e]):e=>e,ts=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?es(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:Xo(e),startIndex:t})},d=this.pattern.length;if(d>Jo){let e=0,t=d%Jo,n=d-t;for(;e<n;)u(this.pattern.substr(e,Jo),e),e+=Jo;if(t){let e=d-Jo;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?es(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}=Yo(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=Zo(u)),p}},ns=class{constructor(e){this.pattern=e}static isMultiMatch(e){return rs(e,this.multiRegex)}static isSingleMatch(e){return rs(e,this.singleRegex)}search(e){return{isMatch:!1,score:1}}};function rs(e,t){let n=e.match(t);return n?n[1]:null}var is=class extends ns{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]}}},as=class extends ns{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]}}},os=class extends ns{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]}}},ss=class extends ns{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]}}},cs=class extends ns{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]}}},ls=class extends ns{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]}}},us=class extends ns{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 ts(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)}},ds=class extends ns{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}}},fs=[is,ds,os,ss,ls,cs,as,us],ps=fs.length,ms=`\0`,hs=`|`;function gs(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 _s(e,t={}){return e.replace(/\\\|/g,ms).split(hs).map(e=>{let n=gs(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<ps;){let e=fs[o],n=e.isMultiMatch(i);n&&(r.push(new e(n,t)),a=!0)}if(!a)for(o=-1;++o<ps;){let e=fs[o],n=e.isSingleMatch(i);if(n){r.push(new e(n,t));break}}}return r})}var vs=new Set([us.type,ds.type]),ys=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?es(e):e,this.pattern=e,this.query=_s(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?es(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&&(vs.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=Zo(o)),e}}return{isMatch:!1,score:1}}},bs=[];function xs(...e){bs.push(...e)}function Ss(e,t){for(let n=0,r=bs.length;n<r;n+=1){let r=bs[n];if(r.condition(e,t))return new r(e,t)}return new ts(e,t)}var Cs={AND:`$and`,OR:`$or`},ws={PATH:`$path`,PATTERN:`$val`},Ts=e=>!!(e[Cs.AND]||e[Cs.OR]),Es=e=>!!e[ws.PATH],Ds=e=>!go(e)&&So(e)&&!Ts(e),Os=e=>({[Cs.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function ks(e,t,{auto:n=!0}={}){let r=e=>{if(yo(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=Ss(e,t)),r}let i=Object.keys(e),a=Es(e);if(!a&&i.length>1&&!Ts(e))return r(Os(e));if(Ds(e)){let r=a?e[ws.PATH]:i[0],o=a?e[ws.PATTERN]:e[r];if(!yo(o))throw Error(Oo(r));let s={keyId:Io(r),pattern:o};return n&&(s.searcher=Ss(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];go(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return Ts(e)||(e=Os(e)),r(e)}function As(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 js(e,{ignoreFieldNorm:t=$.ignoreFieldNorm}){e.forEach(e=>{e.score=As(e.matches,{ignoreFieldNorm:t})})}var Ms=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 Ns(e,t){let n=e.matches;t.matches=[],wo(n)&&n.forEach(e=>{if(!wo(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 Ps(e,t){t.score=e.score}function Fs(e,t,{includeMatches:n=$.includeMatches,includeScore:r=$.includeScore}={}){let i=[];return n&&i.push(Ns),r&&i.push(Ps),e.map(e=>{let{idx:n}=e,r={item:t[n],refIndex:n};return i.length&&i.forEach(t=>{t(e,r)}),r})}var Is=/\b\w+\b/g;function Ls({isCaseSensitive:e=!1,ignoreDiacritics:t=!1}={}){return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=es(n)),n.match(Is)||[]}}}function Rs(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 zs(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 Bs(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 Vs=class{constructor(e,t,n){this.options={...$,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new No(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=Ss(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 Wo))throw Error(Do);if(this._myIndex=t||Go(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=Ls({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});this._invertedIndex=Rs(this._myIndex.records,this._myIndex.keys.length,e)}}add(e){if(wo(e)&&(this._docs.push(e),this._myIndex.add(e),this._invertedIndex)){let e=this._myIndex.records[this._myIndex.records.length-1],t=Ls({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});zs(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)Bs(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&&Bs(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(yo(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return bo(n)&&n>-1&&(e=e.slice(0,n)),e}let c=bo(n)&&n>0&&yo(e),l;if(c){let t=new Ms(n);yo(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=yo(e)?yo(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),js(l,{ignoreFieldNorm:s}),a&&l.sort(o),bo(n)&&n>-1&&(l=l.slice(0,n));return Fs(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(!wo(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=As(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):a.push(r)}}),a}_searchLogical(e){let t=ks(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===Cs.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(wo(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(!wo(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=As(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}),o}_findMatches({key:e,value:t,searcher:n}){if(!wo(t))return[];let r=[];if(go(t))t.forEach(({v:t,i,n:a})=>{if(!wo(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}},Hs=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=Ls({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 ts(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=Zo(t)),o}};Vs.version=`7.3.0`,Vs.createIndex=Go,Vs.parseIndex=Ko,Vs.config=$,Vs.match=function(e,t,n){return Ss(e,{...$,...n}).searchIn(t)},Vs.parseQuery=ks,xs(ys),xs(Hs),Vs.use=function(...e){e.forEach(e=>xs(e))};var Us=[{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 Ws({title:e=`Table View`,subtitle:t=`/table`,backUrl:l,tableCollection:u=`pub_table_data`,config:d,customContent:f}){let{user:p}=r.Ft(),m=!!d,h=d?.isInternal||d?.isShared;d?.isPrivate&&d?.isAdmin;let g=d?.isAdmin||h,_=o.Tn(u),v=c.f(),b=c.F(u),x=m?g||_||u.startsWith(`role_`):!0,[S,C]=(0,K.useState)(()=>_?c.u(u):``),T=c.o({on:u.startsWith(`user_`)&&!_,everyone:!1}),D=T.uid||p?.uid||``,O=(e,t)=>p?_?t?c.l({uid:p.uid,...Ei(p),...e},p.uid):e:u.startsWith(`user_`)?{...e,uid:D||p.uid}:t?{uid:p.uid,...e}:e:e,k=!!f,M=d?.showButton!==!1&&!k,P=d?.buttonText||`+`,ee=d?.buttonStyle||`secondary`,F=d?.showExportButton!==!1,[te,I]=(0,K.useState)([]),L=_?b.records:te,[ne,R]=(0,K.useState)(`demo`),[z,re]=(0,K.useState)(!1),[B,V]=(0,K.useState)(!1),[ae,oe]=(0,K.useState)(``),[H,se]=(0,K.useState)(!1),[U,ce]=(0,K.useState)(null),[W,le]=(0,K.useState)(null),[G,ue]=(0,K.useState)(``),[de,Y]=(0,K.useState)(!1),[fe,pe]=(0,K.useState)(``),[me,he]=(0,K.useState)(null),[ge,_e]=(0,K.useState)(null),[X,ve]=(0,K.useState)(null),[ye,be]=(0,K.useState)(!1);(0,K.useEffect)(()=>{let e=u.startsWith(`user_`);if(e&&!p||_)return;let t=e?`${u}|${D}`:u;try{let e=localStorage.getItem(`fbos_tables_${t}`);e&&I(JSON.parse(e))}catch{}let n=(0,J.onSnapshot)(e&&p?(0,J.query)((0,J.collection)(r.ui,u),(0,J.where)(`uid`,`==`,D||p.uid)):(0,J.collection)(r.ui,u),n=>{let i=[];if(n.forEach(e=>{i.push({id:e.id,...e.data()})}),i.length===0){let t={name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`,`Column 4`],...p?{uid:D||p.uid}:{},rows:[{id:`1`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``},{id:`2`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``}]};(0,J.setDoc)((0,J.doc)(r.ui,u,e&&p?`demo_${D||p.uid}`:`demo`),t)}else{let e=i.sort((e,t)=>(e.name||``).localeCompare(t.name||``));I(e),localStorage.setItem(`fbos_tables_${t}`,JSON.stringify(e))}},a.s);return()=>n()},[u,p,_,D]);let xe=(0,K.useRef)(!1);(0,K.useEffect)(()=>{!_||!p||b.loading||b.records.length||xe.current||(xe.current=!0,(0,J.setDoc)((0,J.doc)(r.ui,u,`demo_${p.uid}`),c.l({uid:p.uid,...Ei(p),name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`,`Column 4`],rows:[{id:`1`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``},{id:`2`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``}]},p.uid)))},[_,p,b.loading,b.records.length,u]);let Z=L.find(e=>e.id===ne)||L[0]||{columns:[],rows:[]},Q=!_||c.C(Z,v),Se=async e=>{Z.id&&(p&&u.startsWith(`user_`)&&(e.uid=D||p.uid),await(0,J.setDoc)((0,J.doc)(r.ui,u,Z.id),e,{merge:!0}))},Ce=()=>{if(!Z.rows||Z.rows.length===0)return;let e=Z.columns.join(`,`),t=Z.rows.map(e=>Z.columns.map(t=>`"${e[t]||``}"`).join(`,`)).join(`
|
|
6
|
+
`),n=new Blob([`${e}\n${t}`],{type:`text/csv`}),r=window.URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`export_${Z.name||`table`}.csv`,i.click(),window.URL.revokeObjectURL(r)},we=(e,t,n)=>{Se({...Z,rows:Z.rows.map(r=>r.id===e?{...r,[t]:n}:r)})},Te=()=>{let e=Ei(p),t={id:Date.now().toString(),...p?{_uid:p.uid,_creatorName:e.creatorName,_creatorAvatar:e.creatorAvatar}:{}};Z.columns.forEach(e=>t[e]=``),Se({...Z,rows:[...Z.rows||[],t]})},Ee=e=>{Se({...Z,rows:Z.rows.filter(t=>t.id!==e)})},De=()=>{X&&(X.kind===`row`?Ee(X.id):ke(X.name),ve(null))},Oe=()=>{let e=`Column ${(Z.columns?.length||0)+1}`;Z.columns?.includes(e)||(Se({...Z,columns:[...Z.columns||[],e]}),setTimeout(()=>{let e=document.getElementById(`table-scroll-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},100))},ke=e=>{let t=(Z.columns||[]).filter(t=>t!==e),n=(Z.rows||[]).map(t=>{let n={...t};return delete n[e],n}),r={...Z.colColors||{}};delete r[e],Se({...Z,columns:t,rows:n,colColors:r})},Ae=async e=>{e.trim()&&Z.id&&e!==Z.name&&await(0,J.setDoc)((0,J.doc)(r.ui,u,Z.id),{name:e},{merge:!0})},je=async()=>{se(!0),re(!1);let e=`tbl_${Date.now()}`;await(0,J.setDoc)((0,J.doc)(r.ui,u,e),{name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`],...p?{uid:p.uid}:{},rows:[]}),setTimeout(()=>{R(e),se(!1)},600)},Me=e=>{let t=fe.trim();if(t&&t!==e&&!Z.columns?.includes(t)){let n=Z.columns.map(n=>n===e?t:n),r=(Z.rows||[]).map(n=>{let r={...n};return r[t]=r[e]||``,delete r[e],r}),i={...Z.colColors||{}};i[e]&&(i[t]=i[e],delete i[e]),Se({...Z,columns:n,rows:r,colColors:i})}le(null)},Ne=e=>ki({uid:e._uid,creatorName:e._creatorName,creatorAvatar:e._creatorAvatar},p),Pe=Z.rows||[];return G.trim()!==``&&(Pe=new Vs(Pe.map(e=>({...e,_creatorMatch:Ne(e)?.name||``})),{keys:(Z.columns||[]).concat([`_creatorMatch`]),threshold:.4,ignoreLocation:!0}).search(G).map(e=>{let{_creatorMatch:t,...n}=e.item;return n})),(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4 md:mb-6 flex items-center gap-3`,children:[!m&&l&&(0,q.jsx)(c.r,{to:l}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(n.t,{children:e}),t&&(0,q.jsxs)(`div`,{className:`max-sm:hidden sm:flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,q.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 min-h-0 pb-16`,children:[m&&(0,q.jsx)(i.t,{}),(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden shadow-2xl relative z-10 flex flex-col flex-1 min-h-[400px]`,children:[(0,q.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,q.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,q.jsxs)(`div`,{className:`flex flex-col min-w-0 relative`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,q.jsxs)(`div`,{className:`relative flex items-center`,children:[B?(0,q.jsx)(`div`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:e=>{V(!1),Ae(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:Z.name||`Unnamed Table`}):(0,q.jsx)(`h3`,{className:`font-bold text-[16px] text-foreground/90 hover:text-accent transition-colors truncate max-w-[38vw] sm:max-w-[200px] ${Q?`cursor-pointer`:``}`,onClick:()=>Q&&V(!0),title:Q?`Click to rename table`:void 0,children:Z.name||`Unnamed Table`}),(0,q.jsx)(r.rt,{children:z&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>re(!1)}),(0,q.jsxs)(r.nt.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,q.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,q.jsx)(`div`,{className:`max-h-[250px] overflow-y-auto styled-scrollbars z-50 relative`,children:L.map(e=>(0,q.jsx)(`button`,{onClick:()=>{R(e.id),re(!1)},className:`w-full px-4 py-2 text-[13px] font-bold text-left hover:bg-foreground/[0.03] transition-colors truncate ${ne===e.id?`text-accent bg-accent/5`:`text-foreground/70`}`,children:e.name||`Unnamed Table`},e.id))}),(0,q.jsx)(`div`,{className:`w-full h-[1px] bg-[var(--panel-border)]/50 my-1`}),(0,q.jsxs)(`button`,{onClick:je,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,q.jsx)(E.t,{className:`w-4 h-4`}),` Create New Table`]})]})]})})]}),(0,q.jsx)(`button`,{onClick:()=>re(!z),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,q.jsx)(s.t,{className:`w-4 h-4 transition-transform ${z?`rotate-180 text-accent`:``}`})})]}),(0,q.jsxs)(`span`,{className:`opacity-40 text-[11px] font-bold mt-1 uppercase tracking-wider`,children:[(Z.rows||[]).length,` Records`]})]}),(0,q.jsx)(`div`,{className:`relative shrink-0 ${de?`flex-1 min-w-[130px] max-w-[300px]`:``}`,children:de?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(w.n,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-foreground/40`}),(0,q.jsx)(`input`,{autoFocus:!0,type:`text`,"aria-label":`Search records`,placeholder:`Search records...`,value:G,onChange:e=>ue(e.target.value),onBlur:()=>{G.trim()||Y(!1)},onKeyDown:e=>{e.key===`Escape`&&(ue(``),Y(!1))},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,q.jsx)(`button`,{type:`button`,onClick:()=>Y(!0),"aria-label":`Search records`,title:`Search records`,className:`w-10 h-10 flex items-center justify-center rounded-xl border border-[var(--panel-border)] text-foreground/50 hover:text-accent hover:bg-foreground/5 transition-colors`,children:(0,q.jsx)(w.n,{className:`w-4 h-4`})})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,q.jsx)(c.a,{viewing:T}),F&&(0,q.jsx)(N.t,{variant:`secondary`,onClick:Ce,className:`px-3 py-2.5 font-bold rounded-xl shadow-sm border border-[var(--panel-border)] flex items-center gap-2`,children:(0,q.jsx)(y.d,{className:`w-4 h-4`})}),M&&Q&&(0,q.jsx)(N.t,{variant:ee===`primary`?void 0:`secondary`,onClick:Te,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:P===`+`?(0,q.jsx)(E.t,{className:`w-4 h-4`}):P})]})]}),(0,q.jsx)(`div`,{id:`table-scroll-container`,className:`overflow-auto w-full flex-1 min-h-[300px] relative styled-scrollbars`,children:f?(0,q.jsx)(c.p,{value:{prefix:o.Mn(d||{}),collection:_?u:``,recordId:_?Z.id||S:``},children:(0,q.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill p-4 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(f,{config:d,actions:{tables:L,activeTable:Z,collection:u,user:p,error:_?b.error:``,...c.s(u,v,_,S),saveTable:async(e,t)=>{let n=O(t,!L.some(t=>t.id===e));_&&e===S&&C(c.u(u)),I(t=>t.find(t=>t.id===e)?t.map(t=>t.id===e?{...t,...n}:t):[...t,{id:e,...n}]),await(0,J.setDoc)((0,J.doc)(r.ui,u,e),n,{merge:!0})},deleteTable:async e=>{I(t=>t.filter(t=>t.id!==e)),await(0,J.deleteDoc)((0,J.doc)(r.ui,u,e))},updateCell:(e,t,n)=>we(e,t,n),addRow:()=>Te(),addColumn:()=>Oe()}})})})}):(0,q.jsx)(r.rt,{mode:`wait`,children:H?(0,q.jsxs)(r.nt.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,q.jsx)(`div`,{className:`w-8 h-8 rounded-full border-2 border-accent border-r-transparent animate-spin mb-4`}),(0,q.jsx)(`p`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest`,children:`Generating Table`})]},`loader`):(0,q.jsxs)(r.nt.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,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)] transition-colors ${Z.headerColor?Us.find(e=>e.text===Z.headerColor)?.bgAlt:`bg-foreground/[0.02]`}`,children:[(0,q.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 ${x?``:`hidden`}`,children:`Creator`}),(Z.columns||[]).map((e,t)=>{let n=(Z.colColors||{})[e],r=(Z.colorTimestamps||{})[`col_${e}`]||0;Z.headerColor;let a=(Z.colorTimestamps||{}).header||0,o=`bg-transparent`,s=`text-foreground/50`;if(n&&n!==`none`&&r>=a){let e=Us.find(e=>e.text===n);e&&(o=e.bgCard,s=e.text)}return(0,q.jsx)(`th`,{className:`py-3 px-6 text-[12px] font-bold uppercase tracking-wider relative group h-[53px] min-w-[120px] ${s} ${o} border-r border-[var(--panel-border)]/20 last:border-r-0 select-none align-middle`,children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 w-full h-full`,children:[W===e?(0,q.jsx)(`div`,{className:`flex-1 min-w-[50px]`,children:(0,q.jsx)(`span`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>{le(null),pe(t.currentTarget.textContent||``),(t.currentTarget.textContent||``).trim()!==``&&Me(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 ${s} block w-full whitespace-nowrap overflow-hidden cursor-text`,ref:e=>{e&&requestAnimationFrame(()=>{e.focus()})},children:fe})}):(0,q.jsx)(`div`,{className:`flex items-center gap-2 flex-1 overflow-hidden`,onClick:()=>{Q&&(le(e),pe(e))},children:(0,q.jsx)(`span`,{className:`truncate cursor-text`,children:e})}),(0,q.jsxs)(`div`,{className:`relative shrink-0 flex items-center h-full gap-0.5`,children:[(0,q.jsx)(`button`,{onClick:()=>_e(ge===e?null:e),className:`p-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity hover:bg-foreground/10 ${n&&n!==`none`?`!opacity-100`:``} text-current`,children:(0,q.jsx)(i.E,{className:`w-4 h-4`})}),(Z.columns||[]).length>1&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Q&&ve({kind:`column`,name: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,q.jsx)(A.t,{className:`w-3.5 h-3.5`})}),ge===e&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>_e(null)}),(0,q.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,q.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...Z.colColors||{},[e]:`none`},r={...Z.colorTimestamps||{},[`col_${e}`]:Date.now()};Se({...Z,colColors:n,colorTimestamps:r}),_e(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,q.jsx)(w.t,{className:`w-3 h-3`})}),(0,q.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Us.map(t=>(0,q.jsx)(`button`,{onClick:n=>{n.preventDefault(),n.stopPropagation();let r={...Z.colColors||{},[e]:t.text},i={...Z.colorTimestamps||{},[`col_${e}`]:Date.now()};Se({...Z,colColors:r,colorTimestamps:i}),_e(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_${t}_${e}`)}),(0,q.jsx)(`th`,{className:`py-4 px-4 w-14 border-l border-[var(--panel-border)]/30 relative`,children:(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5 relative z-20`,children:[(0,q.jsx)(`button`,{onClick:()=>be(!ye),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${Z.headerColor?Us.find(e=>e.text===Z.headerColor)?.text:`text-foreground/30`}`,children:(0,q.jsx)(i.E,{className:`w-4 h-4`})}),ye&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>be(!1)}),(0,q.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,q.jsx)(`button`,{onClick:()=>{Se({...Z,headerColor:``}),be(!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,q.jsx)(w.t,{className:`w-3 h-3`})}),(0,q.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Us.map(e=>(0,q.jsx)(`button`,{onClick:()=>{let t={...Z.colorTimestamps||{},header:Date.now()};Se({...Z,headerColor:e.text,colorTimestamps:t}),be(!1)},className:`w-4 h-4 rounded-full ${e.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},e.name))]})]}),(0,q.jsx)(`button`,{onClick:()=>Q&&Oe(),className:`p-1.5 rounded-lg text-foreground/40 hover:text-accent hover:bg-accent/10 transition-colors flex items-center justify-center ${Q?``:`hidden`}`,children:(0,q.jsx)(E.t,{className:`w-4 h-4`})})]})})]})}),(0,q.jsxs)(`tbody`,{children:[Pe.map((e,t)=>{let n=t%2==1,a=(Z.rowColors||{})[e.id],o=a?n?Us.find(e=>e.text===a)?.bgAlt:Us.find(e=>e.text===a)?.bgCard:n?`bg-foreground/[0.02]`:`bg-transparent`;return(0,q.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)]/30 hover:bg-foreground/[0.04] transition-colors group`,children:[(0,q.jsx)(`td`,{className:`py-4 px-6 whitespace-nowrap h-[53px] border-r border-[var(--panel-border)]/20 ${o} ${x?``:`hidden`}`,children:(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:m?(()=>{let t=Ne(e);return t?(0,q.jsxs)(q.Fragment,{children:[t.avatar?(0,q.jsx)(r.O,{src:t.avatar,alt:``,className:`w-5 h-5 rounded-full shrink-0`}):(0,q.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:t.name[0].toUpperCase()}),(0,q.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:t.name})]}):(0,q.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/30`,children:`—`})})():(0,q.jsxs)(q.Fragment,{children:[(0,q.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,q.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:`Guest`})]})})}),(Z.columns||[]).map(r=>{let i=U?.id===e.id&&U?.field===r,a=(Z.colColors||{})[r],o=(Z.colorTimestamps||{})[`col_${r}`]||0,s=(Z.rowColors||{})[e.id],c=(Z.colorTimestamps||{})[`row_${e.id}`]||0,l=``;l=c>o?s===`none`?``:s:o>c?a===`none`?``:a:s===`none`?``:s||a||``,l===`none`&&(l=``);let u=l?Us.find(e=>e.text===l):null,d=u?n?u.bgAlt:u.bgCard:n?`bg-foreground/[0.02]`:`bg-transparent`,f=u?u.text:`text-foreground/80`;return(0,q.jsxs)(`td`,{className:`py-4 px-6 whitespace-pre-wrap min-w-[120px] text-[14px] font-medium relative ${d} align-top border-r border-[var(--panel-border)]/10 last:border-r-0`,onClick:()=>Q&&!i&&ce({id:e.id,field:r}),children:[i?(0,q.jsx)(`textarea`,{autoFocus:!0,value:e[r]||``,onChange:t=>we(e.id,r,t.target.value),onBlur:()=>ce(null),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&ce(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 ${f} z-20 resize-none styled-scrollbars`}):null,(0,q.jsx)(`span`,{className:`block w-full min-h-[20px] break-words transition-all ${i?`opacity-0`:`opacity-100`} ${f} ${r===`Status`&&e[r]===`Active`&&!l?`text-green-500`:``}`,children:e[r]||(0,q.jsx)(`span`,{className:`opacity-30 italic font-normal`,children:`empty`})})]},`cell_${e.id||t}_${r}`)}),(0,q.jsx)(`td`,{className:`py-4 px-4 whitespace-nowrap text-right h-[53px] ${o} relative z-10`,children:(0,q.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,q.jsx)(`button`,{onClick:()=>he(me===e.id?null:e.id),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${a?Us.find(e=>e.text===a)?.text:`text-foreground/40`}`,children:(0,q.jsx)(i.E,{className:`w-4 h-4`})}),me===e.id&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>he(null)}),(0,q.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,q.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...Z.rowColors||{},[e.id]:`none`},r={...Z.colorTimestamps||{},[`row_${e.id}`]:Date.now()};Se({...Z,rowColors:n,colorTimestamps:r}),he(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,q.jsx)(w.t,{className:`w-3 h-3`})}),(0,q.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Us.map(t=>(0,q.jsx)(`button`,{onClick:()=>{let n={...Z.colorTimestamps||{},[`row_${e.id}`]:Date.now()};Se({...Z,rowColors:{...Z.rowColors||{},[e.id]:t.text},colorTimestamps:n}),he(null)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},t.name))]})]}),Q&&(0,q.jsx)(`button`,{onClick:()=>ve({kind:`row`,id:e.id}),title:`Delete row`,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,q.jsx)(A.t,{className:`w-4 h-4`})})]})})]},e.id||`row_${t}`)}),Pe.length===0&&(0,q.jsx)(`tr`,{children:(0,q.jsxs)(`td`,{colSpan:(Z.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 `,Z.name||`this table`,`.`]})}),(0,q.jsx)(`tr`,{children:(0,q.jsx)(`td`,{colSpan:(Z.columns||[]).length+2,className:`py-2 px-4 border-none bg-foreground/[0.01]`,children:(0,q.jsx)(`div`,{className:`flex items-center gap-4`,children:(0,q.jsx)(`button`,{onClick:()=>Q&&Te(),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 ${Q?``:`hidden`}`,children:(0,q.jsx)(E.t,{className:`w-4 h-4`})})})})})]})]},`table`)})})]})]}),(0,q.jsx)(ie.t,{isOpen:!!X,title:X?.kind===`column`?`Delete column`:`Delete row`,message:X?.kind===`column`?(0,q.jsxs)(q.Fragment,{children:[`Delete `,(0,q.jsx)(`strong`,{className:`text-foreground block my-1 break-words max-w-full text-center`,children:X.name}),` and everything filled in under it, in every row? This cannot be undone.`]}):(0,q.jsx)(q.Fragment,{children:`Delete this row and everything in it? This cannot be undone.`}),onConfirm:De,onCancel:()=>ve(null),confirmText:`Yes, delete`})]})}var Gs=[{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`}],Ks=e=>new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().split(`T`)[0],qs=1,Js={dateStr:``,title:``,description:``,time:`12:00`,duration:`60`,color:``,guestEmail:``,customFields:{}};function Ys({title:e=`Calendar View`,subtitle:t=`/calendar`,backUrl:a,eventsCollection:s=`pub_events`,defaultTimeFormat:l=`12h`,config:u,customContent:d}){let f=!!(u?.isPrivate||u?.isAdmin||u?.isInternal||u?.isShared);u?.isAdmin,u?.isInternal||u?.isShared,u?.isPrivate;let p=u?.showButton!==!1,m=u?.buttonText||`+`,h=u?.buttonStyle||`primary`,v=u?.showViewsButton!==!1,b=u?.viewsButtonStyle||`secondary`,x=u?.defaultView||`calendar`,S=u?.customFields||[],C=o.Tn(s)?`case`:s.startsWith(`user_`)?`user`:s.startsWith(`mem_`)||s.startsWith(`role_`)?`internal`:s.startsWith(`admin_`)?`admin_only`:`public`,T=C===`case`,D=c.o({on:C===`user`}),[O,k]=(0,K.useState)(()=>{try{let e=localStorage.getItem(`cal_view_${s}`);if(e===`list`||e===`month`)return e}catch{}return x===`board`?`list`:`month`}),[M,P]=(0,K.useState)([]),ee=c.f(),F=c.F(s),te=T?F.records:M,[I,L]=(0,K.useState)(()=>T?c.u(s):``),[ne,R]=(0,K.useState)(!1),[z,re]=(0,K.useState)(null),[B,V]=(0,K.useState)(!1),[ae,oe]=(0,K.useState)(!1),[H,se]=(0,K.useState)(null),[U,ce]=(0,K.useState)(Js),[W,le]=(0,K.useState)(new Date),[G,de]=(0,K.useState)(null),[fe,pe]=(0,K.useState)(null),[me,he]=(0,K.useState)(!1),ge=D.uid||G?.uid||``,_e=`cal_24h_${s}`,[X,ve]=(0,K.useState)(()=>{try{let e=localStorage.getItem(_e);if(e!==null)return e===`true`}catch{}return l===`24h`}),ye=()=>{let e=!X;ve(e);try{localStorage.setItem(_e,String(e))}catch{}};(0,K.useEffect)(()=>{try{localStorage.setItem(`cal_view_${s}`,O)}catch{}},[O,s,C]);let be=()=>{let e=O===`month`?`list`:`month`;k(e);try{localStorage.setItem(`cal_view_${s}`,e)}catch{}},xe=()=>{try{return sessionStorage.getItem(`cal_guest_email`)||``}catch{return``}},Z=e=>{try{sessionStorage.setItem(`cal_guest_email`,e)}catch{}};(0,K.useEffect)(()=>(0,ue.onAuthStateChanged)(r.li,async e=>{if(de(e),e&&C===`admin_only`)try{let t=await(0,J.getDoc)((0,J.doc)(r.ui,`user_profiles`,e.uid));t.exists()&&pe(t.data())}catch{}he(!0)}),[C]);let Q=Ks(new Date(W.getFullYear(),W.getMonth()-qs,1)),Se=Ks(new Date(W.getFullYear(),W.getMonth()+qs+1,0));(0,K.useEffect)(()=>{if(!me||T)return;if(C!==`public`&&!G){P([]);return}let e=C===`user`?`${s}|${D.everyone?`everyone`:ge}`:s;try{let t=localStorage.getItem(`fbos_cal_${e}`);t&&P(JSON.parse(t))}catch{}let t=(0,J.onSnapshot)(C===`user`&&G&&!D.everyone?(0,J.query)((0,J.collection)(r.ui,s),(0,J.where)(`uid`,`==`,ge)):(0,J.query)((0,J.collection)(r.ui,s),(0,J.where)(`dateStr`,`>=`,Q),(0,J.where)(`dateStr`,`<=`,Se)),t=>{let n=[];t.forEach(e=>n.push({id:e.id,...e.data()})),P(n),localStorage.setItem(`fbos_cal_${e}`,JSON.stringify(n))},e=>console.error(`Calendar events:`,e));return()=>t()},[s,C,G?.uid,me,Q,Se,T,ge,D.everyone]);let Ce=e=>!!G&&G.uid===e.uid,we=e=>C===`public`?!1:C===`user`?!!G:T?c.C(e,ee):Ce(e),Te=(e,t)=>!G||C===`public`?e:C===`user`?{...e,uid:ge||G.uid}:T?t?c.l({uid:G.uid,creatorEmail:G.email||``,creatorName:G.displayName||``,creatorAvatar:G.photoURL||``,...e},G.uid):e:t?{uid:G.uid,creatorEmail:G.email||``,creatorName:G.displayName||``,creatorAvatar:G.photoURL||``,...e}:e,Ee=e=>{if(!e)return``;if(X)return e;let[t,n]=e.split(`:`),r=parseInt(t,10),i=r>=12?`PM`:`AM`;return r=r%12||12,`${r}:${n} ${i}`},De=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`},Oe=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}},ke=(e,t,n)=>{let r=e%12;return n===`PM`&&(r+=12),`${r.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},Ae=Ks,je=()=>Ae(new Date),Me=new Date(W.getFullYear(),W.getMonth(),1),Ne=new Date(W.getFullYear(),W.getMonth()+1,0),Pe=Me.getDay(),Fe=Ne.getDate(),Ie=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Le=Array.from({length:42},(e,t)=>{let n=t-Pe+1,r=new Date(W.getFullYear(),W.getMonth(),n);return{day:r.getDate(),dateStr:Ae(r),isCurrentMonth:n>0&&n<=Fe}}),Re=()=>le(O===`month`?new Date(W.getFullYear(),W.getMonth()-1,1):new Date(W.getFullYear(),W.getMonth(),W.getDate()-1)),ze=()=>le(O===`month`?new Date(W.getFullYear(),W.getMonth()+1,1):new Date(W.getFullYear(),W.getMonth(),W.getDate()+1)),Be=e=>{if(C!==`public`&&!G)return;let t=new Date;t.setDate(t.getDate()+1);let n=new Date().getHours().toString().padStart(2,`0`);ce({...Js,dateStr:e||Ae(t),time:`${n}:00`,guestEmail:C===`public`?xe():``,customFields:{}}),R(!0)},Ve=e=>{let t=e.time;if(t){let[e,n]=t.split(`:`);e&&n&&(t=`${e.padStart(2,`0`)}:${n}`)}ce({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||{}}),R(!0)},He=async e=>{if(e.preventDefault(),U.title.trim()){V(!0);try{let e={dateStr:U.dateStr,title:U.title.trim(),description:U.description.trim(),time:U.time,duration:U.duration||`60`};if(U.color&&(e.color=U.color),S.length>0&&(e.customFields=U.customFields),!U.id)if(C===`public`){let t=U.guestEmail.trim();e.creatorEmail=t,Z(t)}else C===`user`||C===`internal`?(e.uid=G?.uid,e.creatorEmail=G?.email||``,e.creatorName=G?.displayName||``,e.creatorAvatar=G?.photoURL||``):C===`admin_only`&&(e.uid=G?.uid,e.creatorEmail=fe?.email||G?.email||``,e.creatorName=fe?.displayName||fe?.name||``,e.creatorAvatar=fe?.avatar||fe?.avatarUrl||G?.photoURL||``);let t=Te(e,!U.id);U.id?(await(0,J.setDoc)((0,J.doc)(r.ui,s,U.id),t,{merge:!0}),z?.id===U.id&&re({...z,...e})):(await(0,J.setDoc)((0,J.doc)(r.ui,s,T?I||c.u(s):`ev_${Date.now()}`),t,{merge:!0}),T&&L(c.u(s))),R(!1)}catch(e){console.error(e)}V(!1)}},Ue=async()=>{if(H){oe(!0);try{await(0,J.deleteDoc)((0,J.doc)(r.ui,s,H.id)),z?.id===H.id&&re(null),se(null),R(!1)}catch{}oe(!1)}},We=e=>{if(C===`user`||!e.creatorEmail&&!e.creatorName)return null;let t=(e.creatorName||e.creatorEmail||`?`).charAt(0).toUpperCase(),n=Gs.find(t=>t.text===e.color);return(0,q.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,q.jsx)(r.O,{src:e.creatorAvatar,alt:``,className:`w-8 h-8 rounded-full shrink-0`}):(0,q.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,q.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[e.creatorName&&(0,q.jsx)(`span`,{className:`text-[13px] font-bold text-foreground/90 truncate`,children:e.creatorName}),e.creatorEmail&&(0,q.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate`,children:e.creatorEmail})]})]})},Ge=e=>{if(C===`user`||C===`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,q.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[e.creatorAvatar?(0,q.jsx)(r.O,{src:e.creatorAvatar,alt:``,className:`w-5 h-5 rounded-full shrink-0`}):(0,q.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,q.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),e.creatorEmail&&(0,q.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,e.creatorEmail]})]})]})};if(me&&C!==`public`&&!G)return(0,q.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen p-8`,children:(0,q.jsxs)(`div`,{className:`text-center glass-panel border border-[var(--panel-border)] rounded-3xl p-12 max-w-sm w-full`,children:[(0,q.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,q.jsx)(n.h,{className:`w-7 h-7 text-accent`})}),(0,q.jsx)(`h2`,{className:`text-2xl font-bold mb-2`,children:`Sign in required`}),(0,q.jsx)(`p`,{className:`text-foreground/50 text-[14px] mb-6`,children:`You need to be signed in to access this calendar.`}),(0,q.jsx)(Y.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(!me&&C!==`public`)return(0,q.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen`,children:(0,q.jsx)(w.r,{className:`w-8 h-8 animate-spin text-accent`})});let Ke=!!d,qe=(C===`public`||!!G)&&p&&!Ke,Je=()=>(0,q.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,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-xl font-bold text-foreground tracking-tight truncate`,children:u?.tabTitle||u?.tabName||e}),(0,q.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[te.length,` `,te.length===1?`event`:`events`,` · `,O===`month`?`Month`:`Board`,` View`]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,q.jsx)(c.a,{viewing:D}),(0,q.jsx)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:ye,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:X?`24h`:`12h`}),v&&!Ke&&(0,q.jsx)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:be,title:O===`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 ${b===`primary`?`btn-primary`:`btn-secondary`}`,children:O===`month`?(0,q.jsx)(at,{className:`w-4 h-4`}):(0,q.jsx)(g.b,{className:`w-4 h-4`})}),qe&&(0,q.jsx)(r.nt.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>Be(),title:`Add event`,"aria-label":`Add event`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${m===`+`?`w-10`:`px-5`} ${h===`primary`?`btn-primary`:`btn-secondary`}`,children:m===`+`?(0,q.jsx)(E.t,{className:`w-4 h-4`}):(0,q.jsx)(`span`,{className:`text-[13px] font-bold`,children:m})})]})]}),Ye=()=>(0,q.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,q.jsx)(`h3`,{className:`text-lg md:text-xl font-bold tracking-tight ml-2 min-w-0`,children:O===`month`?W.toLocaleString(`default`,{month:`long`,year:`numeric`}):W.toLocaleString(`default`,{month:`long`,day:`numeric`,year:`numeric`})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`button`,{onClick:()=>le(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,q.jsx)(`button`,{onClick:Re,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,q.jsx)(_.t,{className:`w-5 h-5`})}),(0,q.jsx)(`button`,{onClick:ze,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,q.jsx)(r.kt,{className:`w-5 h-5`})})]})]}),Xe=()=>(0,q.jsxs)(q.Fragment,{children:[Ye(),d?(0,q.jsx)(c.p,{value:{prefix:o.Mn(u||{}),collection:T?s:``,recordId:T?I:``},children:(0,q.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill p-4 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(d,{config:u,actions:{events:te,loading:T?F.loading:!me,error:T?F.error:``,collection:s,currentUser:G,...c.s(s,ee,T,I),user:G,saveEvent:async e=>{let t=e.id||(T?I:``)||`ev_${Date.now()}`,n=Te(e,!te.some(e=>e.id===t));T&&t===I&&L(c.u(s)),P(e=>e.find(e=>e.id===t)?e.map(e=>e.id===t?{...e,...n}:e):[...e,{id:t,...n}]),await(0,J.setDoc)((0,J.doc)(r.ui,s,t),n,{merge:!0})},deleteEvent:async e=>{P(t=>t.filter(t=>t.id!==e)),await(0,J.deleteDoc)((0,J.doc)(r.ui,s,e))},openAddModal:e=>Be(e),openEditModal:e=>Ve(e),setViewingEvent:e=>re(e),currentDate:W,setCurrentDate:le,goToPrev:Re,goToNext:ze,goToToday:()=>le(new Date)}})})})}):O===`month`?(0,q.jsx)(`div`,{className:`overflow-x-auto w-full flex-1`,children:(0,q.jsxs)(`div`,{className:`min-w-[800px] h-full flex flex-col`,children:[(0,q.jsx)(`div`,{className:`grid grid-cols-7 border-b border-[var(--panel-border)]/50 bg-foreground/[0.02]`,children:Ie.map(e=>(0,q.jsx)(`div`,{className:`py-3 text-center text-[12px] font-bold uppercase tracking-wider text-foreground/40`,children:e},e))}),(0,q.jsx)(`div`,{className:`grid grid-cols-7 auto-rows-auto bg-[var(--panel-border)] gap-[1px] relative flex-1`,children:Le.map((e,t)=>{let n=e.dateStr===je(),r=te.filter(t=>t.dateStr===e.dateStr);return(0,q.jsxs)(`div`,{onClick:()=>e.isCurrentMonth&&qe&&Be(e.dateStr),className:`min-h-[140px] p-2 bg-[var(--panel-bg)] flex flex-col relative group
|
|
7
|
+
${e.isCurrentMonth?qe?`hover:bg-foreground/[0.03] transition-colors cursor-cell`:``:`opacity-30 bg-background/50 pointer-events-none`}`,children:[(0,q.jsx)(`div`,{className:`flex justify-between items-start mb-2 shrink-0`,children:(0,q.jsx)(`span`,{className:`w-8 h-8 rounded-full flex items-center justify-center text-[14px] font-bold ${n?`bg-accent text-white shadow-lg shadow-accent/20`:`text-foreground/70 group-hover:text-foreground`}`,children:e.day})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5 flex-1 w-full relative z-10 pb-1`,children:r.map(e=>{let t=Gs.find(t=>t.text===e.color),n=we(e);return(0,q.jsxs)(`div`,{className:`px-2 py-1.5 rounded-lg border transition-colors shadow-sm cursor-pointer group/ev relative ${t?t.bgCard+` `+t.borderCard:`bg-accent/20 border-accent/30 hover:bg-accent/40`}`,onClick:t=>{t.stopPropagation(),re(e)},children:[(0,q.jsx)(`p`,{className:`text-[12px] font-bold truncate leading-tight ${n?`pr-5`:``} ${t?t.text:`text-foreground`}`,children:e.title}),(0,q.jsx)(`p`,{className:`text-[10px] text-foreground/70 mt-0.5`,children:Ee(e.time)}),n&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Ve(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,q.jsx)(y.s,{className:`w-3 h-3`})})]},e.id)})})]},t)})}),(0,q.jsx)(`style`,{children:`
|
|
8
8
|
.styled-scrollbars::-webkit-scrollbar{width:4px}
|
|
9
9
|
.styled-scrollbars::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--accent-color) 30%,transparent);border-radius:4px}
|
|
10
10
|
input[type="time"]::-webkit-calendar-picker-indicator{display:none!important}
|
|
11
11
|
input[type="date"]{color-scheme:dark}
|
|
12
12
|
input[type="date"]::-webkit-calendar-picker-indicator{cursor:pointer;opacity:.5;transition:opacity .2s}
|
|
13
13
|
input[type="date"]::-webkit-calendar-picker-indicator:hover{opacity:1}
|
|
14
|
-
`})]})}):(0,
|
|
14
|
+
`})]})}):(0,q.jsxs)(`div`,{className:`flex flex-col p-4 md:p-8 overflow-y-auto w-full flex-1 gap-4`,children:[te.filter(e=>e.dateStr===Ae(W)).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>{let t=new Date(e.dateStr+`T12:00:00`),n=Gs.find(t=>t.text===e.color),r=we(e);return(0,q.jsxs)(`div`,{onClick:()=>re(e),className:`p-4 rounded-2xl border flex flex-col cursor-pointer transition-colors group ${n?n.bgCard+` `+n.borderCard+` hover:brightness-110`:`bg-foreground/[0.01] border-[var(--panel-border)]/70 hover:border-accent/40 hover:bg-foreground/[0.02]`}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,q.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 ${n?n.bgCard+` `+n.borderCard:`bg-foreground/5 border-[var(--panel-border)] group-hover:bg-accent/10 group-hover:border-accent/30`}`,children:[(0,q.jsx)(`span`,{className:`text-[10px] font-bold uppercase leading-none mb-0.5 ${n?n.text:`text-foreground/40 group-hover:text-accent/60`}`,children:t.toLocaleString(`default`,{month:`short`})}),(0,q.jsx)(`span`,{className:`text-[18px] font-black leading-none ${n?n.text:`group-hover:text-accent`}`,children:t.getDate()})]}),(0,q.jsx)(`div`,{className:`h-6 w-px bg-[var(--panel-border)] max-sm:hidden group-hover:bg-accent/30 transition-colors`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[(0,q.jsx)(`h4`,{className:`text-[15px] md:text-[16px] font-extrabold tracking-tight truncate ${n?n.text:`text-foreground group-hover:text-accent`}`,children:e.title}),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 text-[12px] text-foreground/50 font-medium`,children:[(0,q.jsx)(`span`,{children:Ee(e.time)}),(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(Ze,{className:`w-3 h-3`}),De(e.duration)]})]})]}),r&&(0,q.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,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Ve(e)},className:`p-2.5 rounded-xl text-foreground/50 hover:bg-foreground/10 hover:text-foreground transition-colors`,children:(0,q.jsx)(y.s,{className:`w-4 h-4`})}),(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),se(e)},className:`p-2.5 rounded-xl text-foreground/30 hover:bg-red-500/10 hover:text-red-500 transition-colors`,children:(0,q.jsx)(A.t,{className:`w-4 h-4`})})]})]}),f&&Ge(e)]},e.id)}),te.filter(e=>e.dateStr===Ae(W)).length===0&&(0,q.jsx)(`div`,{className:`p-12 text-center text-foreground/40 font-medium`,children:`No events scheduled for this day.`})]})]}),Qe=()=>(0,q.jsxs)(r.rt,{children:[z&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>re(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,q.jsxs)(r.nt.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 ${Gs.find(e=>e.text===z.color)?.borderCard||`border-[var(--panel-border)]`}`,children:[(0,q.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:[we(z)&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{onClick:()=>{re(null),Ve(z)},className:`p-2 rounded-xl text-foreground/50 hover:bg-foreground/10 hover:text-foreground transition-all`,title:`Edit`,children:(0,q.jsx)(y.s,{className:`w-4 h-4`})}),(0,q.jsx)(`button`,{onClick:()=>{se(z),re(null)},className:`p-2 rounded-xl text-foreground/50 hover:bg-red-500/10 hover:text-red-500 transition-all`,title:`Delete`,children:(0,q.jsx)(A.t,{className:`w-4 h-4`})}),(0,q.jsx)(`div`,{className:`w-px h-6 bg-[var(--panel-border)]/50 mx-1`})]}),(0,q.jsx)(`button`,{onClick:()=>re(null),className:`p-2 rounded-xl text-foreground/40 hover:bg-foreground/10 hover:text-foreground transition-all`,children:(0,q.jsx)(w.t,{className:`w-5 h-5`})})]}),(0,q.jsxs)(`div`,{className:`mb-6 mt-12 sm:mt-0 sm:pr-32`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,q.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${Gs.find(e=>e.text===z.color)?.bgCircle||`bg-accent`}`}),(0,q.jsx)(`span`,{className:`text-[11px] font-bold tracking-[0.2em] uppercase ${Gs.find(e=>e.text===z.color)?.text||`text-accent`}`,children:`Event Details`})]}),(0,q.jsx)(`h3`,{className:`text-xl sm:text-3xl font-black mb-3 tracking-tight leading-tight break-words ${Gs.find(e=>e.text===z.color)?.text||`text-foreground`}`,children:z.title}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 mt-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[14px] text-foreground/70 font-medium`,children:[(0,q.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,q.jsx)(g.b,{className:`w-4 h-4 text-foreground/50`})}),new Date(z.dateStr+`T12:00:00`).toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[14px] text-foreground/70 font-medium`,children:[(0,q.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,q.jsx)(Ze,{className:`w-4 h-4 text-foreground/50`})}),Ee(z.time),` `,(0,q.jsxs)(`span`,{className:`text-foreground/40 text-[12px] ml-1`,children:[`(`,De(z.duration),`)`]})]})]}),We(z)]}),(0,q.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`}),z.description?(0,q.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,q.jsx)(`div`,{className:`text-[14px] text-foreground/80 font-medium whitespace-pre-wrap leading-tight break-words`,children:z.description})}):(0,q.jsx)(`div`,{className:`p-4 mb-4 rounded-2xl border border-dashed border-[var(--panel-border)] bg-foreground/[0.01] text-center`,children:(0,q.jsx)(`p`,{className:`text-[12px] font-medium text-foreground/40`,children:`No description provided for this event.`})}),z.customFields&&Object.entries(z.customFields).filter(([,e])=>e).length>0&&(0,q.jsx)(`div`,{className:`flex flex-col gap-2 mb-2`,children:Object.entries(z.customFields).filter(([,e])=>e).map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex items-start gap-2 text-[13px]`,children:[(0,q.jsxs)(`span`,{className:`font-bold text-foreground/50 capitalize shrink-0`,children:[e,`:`]}),(0,q.jsx)(`span`,{className:`text-foreground/80 font-medium break-words min-w-0`,children:t})]},e))})]})]},`view-modal`),ne&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,q.jsx)(r.nt.div,{onClick:()=>R(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,q.jsxs)(r.nt.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,q.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1`,children:[U.id&&we({uid:U.uid})&&(0,q.jsx)(`button`,{onClick:()=>{R(!1),se({id:U.id,...U})},className:`p-2 rounded-xl text-foreground/30 hover:bg-red-500/10 hover:text-red-500 transition-all`,children:(0,q.jsx)(A.t,{className:`w-4 h-4`})}),(0,q.jsx)(`button`,{onClick:()=>R(!1),className:`p-2 rounded-xl text-foreground/40 hover:bg-foreground/10 hover:text-foreground transition-all`,children:(0,q.jsx)(w.t,{className:`w-5 h-5`})})]}),(0,q.jsxs)(`div`,{className:`mb-6 pr-12`,children:[(0,q.jsx)(`h3`,{className:`text-2xl font-bold mb-1 tracking-tight`,children:U.id?`Edit Event`:`Add Event`}),(0,q.jsx)(`p`,{className:`text-[14px] text-foreground/50`,children:U.id?`Modify your scheduled calendar block.`:`Schedule a new calendar block.`})]}),(0,q.jsxs)(`form`,{onSubmit:He,className:`space-y-4`,children:[C===`public`&&!U.id&&(0,q.jsx)(g.y,{label:`Your Email`,type:`email`,value:U.guestEmail,onChange:e=>ce({...U,guestEmail:e.target.value}),placeholder:`you@example.com`,required:!0}),(0,q.jsx)(g.y,{label:`Event Title`,value:U.title,onChange:e=>ce({...U,title:e.target.value}),placeholder:`e.g. Design Sync`,required:!0}),(0,q.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,q.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Description`}),(0,q.jsx)(`textarea`,{value:U.description,onChange:e=>ce({...U,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`})]}),S.map(e=>(0,q.jsx)(g.y,{label:e,value:U.customFields[e]||``,onChange:t=>ce({...U,customFields:{...U.customFields,[e]:t.target.value}}),placeholder:`Enter ${e.toLowerCase()}...`},e)),(0,q.jsx)(`style`,{children:`
|
|
15
15
|
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}
|
|
16
16
|
input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
|
|
17
17
|
input[type="number"]{-moz-appearance:textfield}
|
|
18
|
-
`}),(0,G.jsxs)(`div`,{className:`relative group/date flex flex-col w-full`,children:[(0,G.jsx)(g.y,{type:`date`,label:`Date`,required:!0,value:H.dateStr,onChange:e=>le({...H,dateStr:e.target.value}),className:`pr-10`}),(0,G.jsx)(`div`,{className:`absolute right-4 bottom-4 pointer-events-none group-focus-within/date:text-accent text-foreground/40 transition-colors`,children:(0,G.jsx)(g.b,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[X?(0,G.jsx)(g.y,{type:`time`,label:`Time`,value:H.time,onChange:e=>le({...H,time:e.target.value}),required:!0}):(()=>{let{h:e,m:t,ampm:n}=Oe(H.time);return(0,G.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,G.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Time`}),(0,G.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,G.jsx)(`input`,{type:`number`,min:1,max:12,value:e,onChange:e=>le({...H,time:ke(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,G.jsx)(`span`,{className:`text-foreground/40 font-bold text-[15px] select-none`,children:`:`}),(0,G.jsx)(`input`,{type:`number`,min:0,max:59,value:t.toString().padStart(2,`0`),onChange:t=>le({...H,time:ke(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,G.jsx)(`button`,{type:`button`,onClick:()=>le({...H,time:ke(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,G.jsx)(g.y,{type:`number`,min:`1`,max:`1440`,label:`Duration (min)`,value:H.duration,onChange:e=>le({...H,duration:e.target.value}),placeholder:`60`,required:!0})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest mt-1`,children:`Event Color`}),(0,G.jsx)(`div`,{className:`flex gap-2 items-center relative z-10 w-full h-[46px]`,children:Ws.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>le({...H,color:H.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:H.color===e.text&&(0,G.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full bg-background`})},e.name))})]}),(0,G.jsx)(`div`,{className:`pt-2`,children:(0,G.jsx)(M.t,{type:`submit`,isLoading:B,className:`w-full py-3`,children:H.id?`Save Changes`:`Create Event`})})]})]})]},`edit-modal`),(0,G.jsx)(re.t,{isOpen:!!se,title:`Confirm Deletion`,message:(0,G.jsxs)(G.Fragment,{children:[`Are you sure you want to delete `,(0,G.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:se?.title}),` This action is permanent.`]}),onConfirm:Ue,onCancel:()=>{ce(null)},isProcessing:ae,confirmText:`Yes, Delete`})]});return f?(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col`,children:[(0,G.jsx)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(n.t,{children:u?.tabTitle||u?.tabName||e}),t&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,G.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,G.jsx)(i.t,{}),(0,G.jsxs)(r.nt.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:[Je(),Ze()]})]}),Qe()]}):(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4 md:mb-6 flex items-center gap-3`,children:[a&&(0,G.jsx)(c.r,{to:a}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(n.t,{children:e}),t&&(0,G.jsxs)(`div`,{className:`max-sm:hidden sm:flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,G.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-6 flex-1 min-h-0 pb-16`,children:(0,G.jsxs)(r.nt.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 min-h-[400px] shadow-2xl bg-background relative`,children:[(0,G.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`}),Je(),Ze()]})}),Qe()]})}function Ys(e){let{user:t,methods:n}=e;if(!t)return null;if(!e.roleResolved||!e.profileReady)return`wait`;if(!o.un(t))return`/verify`;if(er(t)){if(n.loading)return`wait`;if(ar(t,n.on.sms2fa,n.twoStepOptional))return`/two-step`}return I.S(e.profile,{skippable:!0,perRole:!0})!==`member`&&n.loading?`wait`:I.f(e.profile,e.userRole,n.finishRegistration,t.uid)?`/your-details`:Yr(t.uid)?Hr:null}var Xs=`/register`,Zs=300*1e3,Qs=e=>{if(typeof window>`u`)return null;try{let t=localStorage.getItem(`fbos_route_${e}`);if(!t)return null;let{cachedAt:n,...r}=JSON.parse(t);return{config:r,cachedAt:typeof n==`number`?n:0}}catch{return null}},$s=(e,t)=>{try{localStorage.setItem(e,t)}catch{}},ec=e=>{try{localStorage.removeItem(e)}catch{}},tc=(e,t)=>{let n=t?o.jn(e.pageType):`public`;return{...e,pageType:n,isPrivate:t,isAdmin:n===`admin`,isInternal:n===`internal`,isShared:n===`internal`}};function nc({config:e}){let{userRole:t}=r.Ft(),i=A.t(e);return(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center m-4 md:m-8 gap-6 min-h-[40vh]`,children:[(0,G.jsxs)(`div`,{className:`w-full max-w-lg glass-panel border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-16 text-center opacity-70`,children:[(0,G.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/70`,children:`This page could not open`}),(0,G.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 max-w-sm leading-relaxed mx-auto`,children:`Everything else here still works. Please come back to it a little later.`})]}),o.wn(t)&&i&&(0,G.jsx)(`div`,{className:`w-full max-w-lg`,children:(0,G.jsx)(n.o,{compact:!0,title:`To put this page right, paste this to your assistant`,prompt:A.c(i.file,i.page,i.error)})})]})}function rc(){let e=(0,Y.useLocation)(),{user:a,userRole:s,loading:l,roleResolved:u,roleConfirmed:d,userInactive:f,signOut:p,profile:m,profileReady:h}=r.Ft(),_=r.Cn(),v=i.v(),y=r.mi();r.Rr();let b=e=>{let n=Qs(e);if(n)try{let e=n.config;if(e.form&&!e.formConfigOverride){let t=localStorage.getItem(`fbos_form_${e.form}`);t&&(e.formConfigOverride=JSON.parse(t))}return tc(e,e.isPrivate===!0)}catch{}let r=(typeof window<`u`?window.__FBOS_PAGES__:null)||{},i=e.replace(/^\//,``);for(let[t,n]of Object.entries(r)){let r=n.config,a=n.isPublic,o=r.route||`/`+t;if(o===e||t===i)return tc({...r,route:o,contentKey:r.pageId||t,pageId:t},!a)}return e===`/contact`?{route:`/contact`,template:`popup_form`,form:`contact`,pageId:`contact`,contentKey:`contact`,pageName:`Contact`,formConfigOverride:y.defaultConfigs?.contactForm||t.a}:e===`/support`?{route:`/support`,template:`popup_form`,form:`support`,pageId:`support`,contentKey:`support`,pageName:`Support`,formConfigOverride:y.defaultConfigs?.supportForm||t.r}:null},[x,S]=(0,W.useState)(()=>b(e.pathname)),[w,T]=(0,W.useState)(()=>!b(e.pathname)),E=(0,W.useRef)(e.pathname),D=d!==!1&&o.wn(s);(0,W.useEffect)(()=>{let n=!0,i=b(e.pathname);if(i){S(i),T(!1);let e=i.pageName||i.tabName||i.title;e&&(document.title=e)}else E.current!==e.pathname&&(S(null),T(!0));E.current=e.pathname;let a=Qs(e.pathname);return a&&!D&&Date.now()-a.cachedAt<Zs||(async()=>{try{let i=e.pathname;i.startsWith(`/`)&&(i=i.substring(1));let[a,o,s,c,l,u]=await Promise.allSettled([(0,q.getDoc)((0,q.doc)(r.ui,`sys_pages`,i)),(0,q.getDoc)((0,q.doc)(r.ui,`sys_tabs`,i)),(0,q.getDocs)((0,q.query)((0,q.collection)(r.ui,`sys_pages`),(0,q.where)(`route`,`==`,e.pathname),(0,q.limit)(1))),(0,q.getDocs)((0,q.query)((0,q.collection)(r.ui,`sys_pages`),(0,q.where)(`route`,`==`,i),(0,q.limit)(1))),(0,q.getDocs)((0,q.query)((0,q.collection)(r.ui,`sys_tabs`),(0,q.where)(`route`,`==`,e.pathname),(0,q.limit)(1))),(0,q.getDocs)((0,q.query)((0,q.collection)(r.ui,`sys_tabs`),(0,q.where)(`route`,`==`,i),(0,q.limit)(1)))]),d=null,f=null,p=(e,t)=>{d||e.status===`fulfilled`&&(e.value.exists&&e.value.exists()?(d=tc(e.value.data(),t),f=e.value.id):e.value.docs&&e.value.docs.length>0&&(d=tc(e.value.docs[0].data(),t),f=e.value.docs[0].id))};if(p(a,!1),p(s,!1),p(c,!1),p(o,!0),p(l,!0),p(u,!0),!d){let t=(typeof window<`u`?window.__FBOS_PAGES__:null)||{};for(let[n,r]of Object.entries(t)){let t=r.config,a=r.isPublic,o=t.route||`/`+n;if(o===e.pathname||n===i){d=tc({...t,route:o,contentKey:t.pageId||n,pageId:n},!a),f=n;break}}}if(d||(e.pathname===`/contact`?(d={route:`/contact`,template:`popup_form`,form:`contact`,pageName:`Contact`},f=`contact`):e.pathname===`/support`&&(d={route:`/support`,template:`popup_form`,form:`support`,pageName:`Support`},f=`support`)),!n)return;if(d){if((f===`contact`||f===`support`)&&!d.form&&(d.form=f),d.contentKey||=d.pageId||f,d.pageId=f,$s(`fbos_route_${e.pathname}`,JSON.stringify({...d,cachedAt:Date.now()})),d.form){let e=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},i=n=>y.defaultConfigs?.[n]||y.defaultConfigs?.[`${n}Form`]||e[n]||(n===`contact`?t.a:n===`support`?t.r:null),a=null;try{a=localStorage.getItem(`fbos_custom_form_${d.form}`)}catch{}if(a){try{let e=localStorage.getItem(`fbos_form_${d.form}`);e&&(d.formConfigOverride=JSON.parse(e))}catch{}(0,q.getDoc)((0,q.doc)(r.ui,`sys_forms`,d.form)).then(async e=>{if(n)if(e.exists()){let t={...e.data(),id:e.id};S(e=>({...e,formConfigOverride:t})),$s(`fbos_form_${d.form}`,JSON.stringify(t))}else{let e=i(d.form);e&&(S(t=>({...t,formConfigOverride:e})),$s(`fbos_form_${d.form}`,JSON.stringify(e)),ec(`fbos_custom_form_${d.form}`))}}).catch(()=>{})}else{let e=i(d.form);e&&(d.formConfigOverride=e)}}let i=d.pageName||d.tabName||d.title;i&&(document.title=i),S(d),T(!1)}else S(`not-found`),T(!1),ec(`fbos_route_${e.pathname}`)}catch{n&&!i&&(S(`not-found`),T(!1))}})(),()=>{n=!1}},[e.pathname,D]);let[O,k]=(0,W.useState)(!1),j=A.f(),[M,N]=(0,W.useState)(null),[ee,P]=(0,W.useState)(!1),te=x&&x!==`not-found`&&typeof x==`object`?[x.contentKey,x.tabName,x.pageId,x.pageName].filter(Boolean).join(`|`):``;(0,W.useEffect)(()=>{if(N(null),!j)return;if(!te||A.r(x)){P(!1);return}let e=!1;P(!0),A.n(x).then(t=>{e||(t&&N(()=>t),P(!1))});let t=setTimeout(()=>{e||P(!1)},4e3);return()=>{e=!0,clearTimeout(t)}},[te,j]);let F=!!a&&d===!1&&!!x&&typeof x==`object`&&x.isPrivate===!0,L=!!a&&_.loading&&!!x&&typeof x==`object`&&(x.pageId===`support`||x.isPrivate===!0)&&I.S(m,{skippable:!0,perRole:!0})!==`member`,ne=!u&&!!x&&typeof x==`object`&&(x.pageId===`support`||!!x.isPrivate);if((0,W.useEffect)(()=>{let e;return w||l||ne||F||L||ee||!j?e=setTimeout(()=>k(!0),150):k(!1),()=>clearTimeout(e)},[w,l,ne,F,L,ee,j]),w||l||ne||F||L||ee||!j)return O?a?(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,G.jsxs)(`div`,{className:`mb-6`,children:[(0,G.jsx)(`div`,{className:`h-10 w-56 rounded-xl bg-foreground/5 animate-pulse mt-1`}),(0,G.jsx)(`div`,{className:`h-3 w-24 rounded bg-foreground/5 animate-pulse mt-3`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,G.jsx)(i.t,{}),(0,G.jsx)(`div`,{className:`flex-1 fbos-tab-fill glass-panel border border-[var(--panel-border)] rounded-3xl flex items-center justify-center min-h-[400px] bg-background shadow-2xl`,children:(0,G.jsx)(C.r,{className:`w-6 h-6 animate-spin text-accent`})})]})]}):(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[40vh] z-10`,children:(0,G.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,G.jsx)(C.r,{className:`w-4 h-4 animate-spin text-accent`}),(0,G.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/60 tracking-wide`,children:`Loading page...`})]})}):null;if(x===`not-found`)return(0,G.jsx)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1 text-center`,children:[(0,G.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,G.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,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,G.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,G.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}),(0,G.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-bold mb-3 text-foreground`,children:`Page Not Found`}),(0,G.jsx)(`p`,{className:`text-foreground/60 max-w-md`,children:`The route you are looking for does not exist or has been removed.`}),o.wn(s)&&(()=>{let t=Zi();return(0,G.jsxs)(`div`,{className:`mt-8 w-full max-w-lg text-left flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] px-5 py-4`,children:[(0,G.jsx)(`p`,{className:`text-[12px] font-extrabold tracking-tight text-gradient mb-1.5`,children:`Pages the app can see`}),(0,G.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,G.jsx)(n.o,{title:`If your assistant just made this page, paste this`,prompt:na(e.pathname)})]})})()]})});if((x.pageId===`support`||x.isPrivate)&&!a)return(0,G.jsx)(Y.Navigate,{to:`/login?from=${encodeURIComponent(e.pathname)}`,replace:!0});let R=(x.pageId===`support`||x.isPrivate)&&a?Ys({user:a,profile:m,userRole:s,roleResolved:u,profileReady:h,methods:_}):null;if(R===`wait`)return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[40vh] z-10`,children:(0,G.jsx)(C.r,{className:`w-6 h-6 animate-spin text-accent`})});if((x.pageId===`support`||x.isPrivate)&&a&&f)return m?.removed===!0?(0,G.jsx)(Y.Navigate,{to:Xs,replace:!0}):(0,G.jsx)(oe.t,{tone:`red`,title:`Access Denied`,message:`You don't have access to this app. Please contact the administrator.`,action:(0,G.jsx)(`button`,{onClick:()=>p(),className:oe.a,children:`Sign Out`})});if(R)return(0,G.jsx)(Y.Navigate,{to:R,replace:!0});let z=o.wn(s)&&new URLSearchParams(e.search).has(`preview`);if(x.isPrivate&&!z&&o.Nn(x)&&!v.live)return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[40vh] z-10`,children:(0,G.jsx)(C.r,{className:`w-6 h-6 animate-spin text-accent`})});if(x.isPrivate&&!z&&!o.yn(s,x,v.groups))return(0,G.jsx)(oe.i,{});let re=y.customRoutes?.[e.pathname]||(x&&x.route?y.customRoutes?.[x.route]:null),B=`pub_${ie.i(x,!1)}`,V=x.isPrivate?`${o.Mn(x)}${ie.i(x,!0)}`:B,ae=y.microcomponents||(typeof window<`u`?window.__FBOS_MICROCOMPONENTS__:void 0),se=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``),ce=[x.contentKey,x.tabName,x.pageId,x.pageName,x.pageName?.replace(/\s+/g,`_`)].filter(Boolean).map(e=>se(e)).reduce((e,t)=>e||ae?.[t],void 0),H=re||ce||M||(ie.c(x.template,!1)&&A.t(x)?nc:void 0),le=x.route||x.pageId||`custom`;return ie.c(x.template,!!H)?x.isAdmin?(0,G.jsx)(Ja,{config:x,customContent:H},le):x.isInternal?(0,G.jsx)(Xa,{config:x,customContent:H},le):x.isPrivate?(0,G.jsx)(Ka,{config:x,customContent:H},le):(0,G.jsx)(Ta,{config:x,customContent:H},le):x.template===`board`?(0,G.jsx)(y.components?.TemplateBoard||mo,{title:x.tabTitle||x.tabName||x.title||x.pageName||`Board`,subtitle:x.route,tasksCollection:`${V}_tasks`,categoriesCollection:`${V}_categories`,config:x,customContent:H},le):x.template===`table`?(0,G.jsx)(y.components?.TemplateTable||Us,{title:x.tabTitle||x.tabName||x.title||x.pageName||`Table`,subtitle:x.route,tableCollection:`${V}_table`,config:x,customContent:H},le):x.template===`calendar`?(0,G.jsx)(y.components?.TemplateCalendar||Js,{title:x.tabTitle||x.tabName||x.title||x.pageName||`Calendar`,subtitle:x.route,eventsCollection:`${V}_events`,defaultTimeFormat:x.defaultTimeFormat||x.defaulttimeformat||`12h`,config:x,customContent:H},le):x.template===`drive`?(0,G.jsx)(y.components?.TemplateDrive||c.t,{title:x.tabTitle||x.tabName||x.title||x.pageName||`Drive`,subtitle:x.route,filesCollection:`${V}_files`,config:x,customContent:H},le):x.template===`inline_form`?(0,G.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-start mt-8 relative z-10 w-full min-h-[60vh]`,children:(0,G.jsx)(g.t,{isInline:!0,formId:x.form,formConfig:x.formConfigOverride})}):(0,G.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 w-full min-h-[60vh]`,children:(0,G.jsx)(g.t,{formId:x.form,formConfig:x.formConfigOverride,onClose:()=>window.history.back()})})}function ic(e,t=r.Lr()){let n=typeof e==`string`?e.trim()===``?NaN:Number(e):e;if(n==null||!Number.isFinite(n))return`—`;let i=(t||r.Lr()).toUpperCase();try{return new Intl.NumberFormat(void 0,{style:`currency`,currency:i}).format(n)}catch{return`${n} ${i}`}}var ac=e=>e.error?`error`:e.paid?`paid`:r.In(e)?`clearing`:`unpaid`,oc={checking:{icon:Xe,tint:`text-accent`,title:`Checking your payment…`},paid:{icon:We,tint:`text-accent`,title:`Thank you — your order is placed`},clearing:{icon:Xe,tint:`text-accent`,title:`Your payment is on its way`},unpaid:{icon:Xe,tint:`text-foreground/50`,title:`Not confirmed yet`},error:{icon:He,tint:`text-foreground/50`,title:`We could not confirm this payment`},cancelled:{icon:Je,tint:`text-foreground/50`,title:`Payment cancelled`}};function sc({cancelled:e=!1}){let[t]=(0,Y.useSearchParams)(),n=t.get(`session_id`)||``,{user:i}=r.Ft(),[a,o]=(0,W.useState)(`checking`),[s,c]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(e)return;let t=!1;return r.An(n).then(e=>{t||(c(e),o(ac(e)))}),()=>{t=!0}},[e,n]);let l=async()=>{o(`checking`);let e=await r.An(n);c(e),o(ac(e))},u=oc[e?`cancelled`:a],d=u.icon;return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16`,children:(0,G.jsxs)(r.nt.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,G.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,G.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 shadow-xl`,children:(0,G.jsx)(d,{className:`w-7 h-7 md:w-8 md:h-8 ${u.tint} ${!e&&a===`checking`?`animate-pulse`:``}`})}),(0,G.jsx)(`h1`,{className:`text-2xl md:text-3xl font-bold mb-3 text-foreground tracking-tight`,children:u.title}),(0,G.jsxs)(`div`,{className:`text-[14px] md:text-[15px] text-foreground/60 mb-6 md:mb-8 leading-[1.6] tracking-wide`,children:[e&&(0,G.jsx)(`p`,{children:`Nothing was charged. You can try again whenever you like.`}),!e&&a===`checking`&&(0,G.jsx)(`p`,{children:`One moment — confirming with the payment provider.`}),!e&&a===`paid`&&(0,G.jsxs)(`p`,{children:[s?.amountTotal!=null&&s?.currency?`Your payment of ${ic(s.amountTotal,s.currency)} went through.`:`Your payment went through.`,s?.receipt&&s.customerEmail?` A receipt is on its way to ${s.customerEmail}.`:``,i?` Your order is under Billing, and the bell will tell you if anything changes.`:s?.customerEmail?` Sign in with ${s.customerEmail} any time to see your order under Billing.`:``]}),!e&&a===`clearing`&&(0,G.jsxs)(`p`,{children:[`Your bank is still sending it, which can take a few days. Your order is in: there is nothing more to do, and please do not pay again.`,s?.receiptLater&&s.customerEmail?` We will email a receipt to ${s.customerEmail} once it arrives.`:``]}),!e&&a===`unpaid`&&(0,G.jsx)(`p`,{children:`The payment provider has not confirmed this payment yet. Some payment methods take a minute — check again shortly.`}),!e&&a===`error`&&(0,G.jsxs)(`p`,{children:[s?.error,` If you finished paying, your order is safe — please do not pay again.`]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[!e&&a===`paid`&&i&&(0,G.jsx)(Y.Link,{to:`/billing`,className:`w-full block py-2.5 md:py-3 btn-primary text-[14px] font-bold rounded-xl transition-colors text-center`,children:`See your order`}),!e&&(a===`unpaid`||a===`error`)&&(0,G.jsx)(M.t,{variant:`primary`,onClick:l,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl`,children:`Check again`}),(0,G.jsx)(Y.Link,{to:`/`,className:`w-full block py-2.5 md:py-3 bg-foreground/5 hover:bg-foreground/10 text-foreground text-[14px] font-bold rounded-xl transition-colors`,children:`Back to the site`})]})]})})}var cc={contentKey:`dashboard`};function lc(){let{user:e,profile:t}=r.Ft(),a=r.mi();r.Rr();let o=(0,Y.useNavigate)(),[s]=(0,Y.useSearchParams)(),[c]=(0,W.useState)(()=>s.get(I.n)===`1`);(0,W.useEffect)(()=>{if(!c)return;let e=new URLSearchParams(s);e.delete(I.n);let t=e.toString();o(`/dashboard${t?`?${t}`:``}`,{replace:!0})},[c]);let l=c&&I.h(t),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(()=>typeof window<`u`&&!A.r(cc));(0,W.useEffect)(()=>{if(A.r(cc))return;let e=!1;A.n(cc).then(t=>{e||(t&&d(()=>t),p(!1))});let t=setTimeout(()=>{e||p(!1)},4e3);return()=>{e=!0,clearTimeout(t)}},[]);let m=a.microcomponents?.dashboard||(typeof window<`u`?window.__FBOS_MICROCOMPONENTS__?.dashboard:void 0)||u||void 0,h=(String(t?.displayName||``).trim()||e?.displayName||e?.email?.split(`@`)[0]||`there`).split(` `)[0],g=h.charAt(0).toUpperCase()+h.slice(1),_=`${l?`Welcome`:`Welcome back`}, ${g}.`;return(0,G.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,G.jsx)(n.t,{children:_}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,G.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/dashboard`]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,G.jsx)(`div`,{className:`flex justify-start`,children:(0,G.jsx)(i.t,{})}),m?(0,G.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill relative w-full flex-1`,children:(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(m,{})})}):(0,G.jsxs)(`div`,{className:`w-full flex-1 glass-panel rounded-3xl relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)] p-8 md:p-12 flex items-center justify-center`,children:[(0,G.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`}),f?(0,G.jsx)(C.r,{className:`w-6 h-6 text-accent animate-spin relative z-10`}):(0,G.jsx)(r.rt,{mode:`wait`,children:(0,G.jsxs)(r.nt.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,G.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,G.jsx)(Qe,{className:`w-6 h-6`})}),(0,G.jsx)(`h2`,{className:`text-2xl font-bold text-foreground mb-2`,children:`No data added here yet`}),(0,G.jsx)(`p`,{className:`text-foreground/40 font-medium`,children:`Keep moving forward, your data will appear here.`})]})})]})]})]})}var uc=8e3,dc=2e4;function fc(e){let[t,n]=(0,W.useState)(()=>e<=0);return(0,W.useEffect)(()=>{if(e<=0)return;let t=setTimeout(()=>n(!0),e);return()=>clearTimeout(t)},[e]),t}function pc(){return{slow:fc(uc),stuck:fc(dc)}}var mc=e=>e&&/^\/(?![/\\])/.test(e)?e:null,hc=`Still trying to connect`,gc=`The app has not heard back. This is almost always the connection rather than anything you did — reloading usually picks it up.`,_c=`No connection`,vc=`This device is not online, so the app cannot finish opening. It will carry on by itself the moment you are back.`,yc=()=>{let{slow:e,stuck:t}=pc(),n=r.$r();return t||e&&n?(0,G.jsx)(a.t,{override:{title:n?_c:hc,message:n?vc:gc,next:`reload`}}):(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center min-h-[60vh] z-10 fbos-fade-in`,children:[(0,G.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,G.jsx)(Qe,{className:`w-6 h-6 text-accent animate-pulse`})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 glass-panel px-5 py-2.5 rounded-full border border-[var(--panel-border)]`,children:[(0,G.jsx)(`div`,{className:`w-4 h-4 border-2 border-accent border-t-transparent rounded-full animate-spin`}),(0,G.jsx)(`span`,{className:`text-[13px] font-bold tracking-widest uppercase text-foreground/70`,children:`Connecting`})]}),e&&(0,G.jsxs)(`div`,{className:`mt-6 max-w-xs w-full px-4 text-center fbos-fade-in`,children:[(0,G.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground/60 leading-relaxed mb-3`,children:`This is taking longer than it should.`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{typeof window<`u`&&window.location.reload()},className:`w-full flex items-center justify-center gap-2 py-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground text-[14px] font-bold rounded-xl transition-colors`,children:`Reload the page`})]})]})};function bc({level:e,children:t}){let{user:n,userRole:i,loading:a,userInactive:s,signOut:c,roleResolved:l,profile:u,profileReady:d}=r.Ft(),f=(0,Y.useLocation)(),p=r.Cn();if(a||!l)return(0,G.jsx)(yc,{});if(!n)return(0,G.jsx)(Y.Navigate,{to:`/login?from=${encodeURIComponent(f.pathname)}`,replace:!0});if(!d)return(0,G.jsx)(yc,{});if(s)return u?.removed===!0?(0,G.jsx)(Y.Navigate,{to:Xs,replace:!0}):(0,G.jsx)(oe.t,{tone:`red`,title:`Access Denied`,message:`You don't have access to this app. Please contact the administrator.`,action:(0,G.jsx)(`button`,{onClick:()=>c(),className:oe.a,children:`Sign Out`})});let m=Ys({user:n,profile:u,userRole:i,roleResolved:l,profileReady:d,methods:p});return m===`wait`?(0,G.jsx)(yc,{}):m?(0,G.jsx)(Y.Navigate,{to:m}):e===`admin`&&!o.wn(i)?(0,G.jsx)(oe.n,{}):e===`internal`&&!o.Sn(i)?(0,G.jsx)(oe.r,{}):(0,G.jsx)(G.Fragment,{children:t})}var xc=({children:e})=>(0,G.jsx)(bc,{level:`signed-in`,children:e}),Sc=({children:e})=>(0,G.jsx)(bc,{level:`admin`,children:e});function Cc({tab:e,children:t}){let{userRole:n}=r.Ft(),{audience:a,live:s}=i.o(e),c=z.i(n,a);return!c&&!s&&!o.wn(n)?(0,G.jsx)(yc,{}):(0,G.jsx)(bc,{level:c?`signed-in`:`admin`,children:t})}function wc({children:e,landing:t}){let{user:n,loading:i,roleResolved:a,profileReady:s,profile:c,userRole:l}=r.Ft(),u=r.Cn(),[d]=(0,Y.useSearchParams)(),[f]=(0,W.useState)(()=>r.Bt()),[p,m]=(0,W.useState)(!1);if(!i&&!n&&!p&&m(!0),i)return f?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsx)(yc,{});if(d.has(`preview`)||n&&s&&c?.removed===!0)return(0,G.jsx)(G.Fragment,{children:e});if(n&&o.un(n)){let r=Ys({user:n,profile:c,userRole:l,roleResolved:a,profileReady:s,methods:u});return r===`wait`||u.loading?p?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsx)(yc,{}):(0,G.jsx)(Y.Navigate,{to:r??mc(d.get(`from`))??t??`/dashboard`,replace:!0})}return(0,G.jsx)(G.Fragment,{children:e})}function Tc({children:e}){let{user:t,loading:n,roleResolved:i,profile:a,profileReady:s}=r.Ft();if(n||!i)return(0,G.jsx)(yc,{});if(!t)return(0,G.jsx)(Y.Navigate,{to:`/`});if(o.un(t)){if(!s)return(0,G.jsx)(yc,{});if(!o.dn(t,a))return(0,G.jsx)(Y.Navigate,{to:`/dashboard`})}return(0,G.jsx)(G.Fragment,{children:e})}function Ec({children:e}){let{user:t,loading:n,roleResolved:i}=r.Ft(),a=r.Cn();return n||!i?(0,G.jsx)(yc,{}):t?o.un(t)?a.loading?(0,G.jsx)(yc,{}):!a.on.sms2fa||!er(t)?(0,G.jsx)(Y.Navigate,{to:`/dashboard`}):(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsx)(Y.Navigate,{to:`/verify`}):(0,G.jsx)(Y.Navigate,{to:`/`})}function Dc({children:e}){let{user:t,userRole:n,loading:i,roleResolved:a,roleConfirmed:s,profile:c,profileReady:l}=r.Ft(),u=r.Cn();return i||!a?(0,G.jsx)(yc,{}):t?o.un(t)?!s||!l||u.loading?(0,G.jsx)(yc,{}):I.v(c,n,u.finishRegistration)?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsx)(Y.Navigate,{to:`/dashboard`}):(0,G.jsx)(Y.Navigate,{to:`/verify`}):(0,G.jsx)(Y.Navigate,{to:`/`})}var Oc=[`user_submissions`,`user_requests`],kc=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`&&e):[],Ac=e=>[...new Set(e.filter(e=>e&&e!==`uid:`&&e!==`role:`))],jc=new Set([`id`,`from`,`uid`,`formId`,`submittedAt`,`submitterAvatar`,`transaction`,`arrivedIn`,`appliedEntries`,`access`,`editors`,`archived`,`read`,`starred`]);function Mc(e,t){let n={};for(let[t,r]of Object.entries(e))!jc.has(t)&&r!==void 0&&(n[t]=r);let r=t&&t.kind===`charge`?t:null;return r?.paidWith&&n.paidWith===void 0&&(n.paidWith=r.paidWith),r?.receiptUrl&&n.receiptUrl===void 0&&(n.receiptUrl=r.receiptUrl),n}function Nc(e,t){let n=Object.entries(e).filter(([e,t])=>/e-?mail/i.test(e)&&typeof t==`string`).map(([,e])=>String(e)),r=e.buyer&&typeof e.buyer==`object`?String(e.buyer.email||``):``;return[...new Set([String(t?.email||``),String(e.submitterEmail||``),r,...n].map(c.T))].filter(e=>e!==`email:`).slice(0,3)}var Pc=e=>{if(!e)return 0;if(typeof e==`number`)return e;if(typeof e.toMillis==`function`)return e.toMillis();if(typeof e.seconds==`number`)return e.seconds*1e3;let t=new Date(e).getTime();return Number.isNaN(t)?0:t};function Fc(e,t,{roles:n=[],viewers:r=[],senderCanEdit:i=!1},a=null){let o=e.uid&&e.uid!==`guest`?c.E(e.uid):``,s=n.map(c.D),l=Nc(e,a),u=!o&&!t.email&&l.length?{email:l[0].slice(6)}:{};return{...t,...u,uid:o?e.uid:``,access:Ac([o,...l,...s,...r.map(c.D),...kc(t.access),...kc(t.editors)]),editors:Ac([...i?[o]:[],...s,...kc(t.editors)]),sourceId:e.id,formId:e.formId,createdAt:typeof t.createdAt==`number`?t.createdAt:Pc(e.submittedAt)||Date.now()}}function Ic(e,t,n){return!t||!e?.sourceId||e.uid!==t?!1:n===void 0?!kc(e.access).includes(c.E(t)):n}function Lc(e,t,n,r=[]){for(let i of t){let t=Object.values(i.collected||{});if(t.includes(e)&&ce.n(n,i,r.filter(n=>n.id!==e&&t.includes(n.id)))&&(i.kind===`charge`?i.paid:[`active`,`trialing`].includes(String(i.status))))return i}return null}var Rc=e=>{let t=Number(e?.total);return{...e,id:String(e?.sourceId||``),transaction:!0,items:Array.isArray(e?.items)?e.items:[],total:e?.total!=null&&Number.isFinite(t)?t:2**53-1}},zc=(e,t)=>{let n=new Set;for(let r of e){let e=Object.values(r.collected||{}).map(String);if(e.some(e=>t.includes(e)))for(let r of e)r&&!t.includes(r)&&n.add(r)}return[...n]},Bc=(e,t)=>{let n=new Map(t.filter(e=>e.id).map(e=>[e.id,e]));return[...e.map(e=>n.get(e.id)||e),...[...n.values()].filter(t=>!e.some(e=>e.id===t.id))]},Vc=5,Hc=60*1e3;async function Uc(e,t=[]){let n=new Map(t.map(e=>[e.id,e])),i=[];try{let a=await r.li?.currentUser?.getIdToken();if(!a)return{sales:i,error:``};let o=``,s=``;for(let r=0;r<Vc;r+=1){let c=new URLSearchParams;o&&c.set(`starting_after`,o),s&&c.set(`subscriptions_after`,s);let l=await fetch(`/api/payments/sales${r?`?${c}`:``}`,{headers:{Authorization:`Bearer ${a}`}});if(!l.ok){let e=``;try{e=String((await l.json())?.error||``)}catch{}return{sales:i,error:e||`Your payments could not be read, so nothing paid for could be let in just now.`}}let u=await l.json();if(i.push(...u?.charges||[],...u?.subscriptions||[]),e.every(e=>Lc(e,i,n.get(e),t))||!u?.chargesHasMore&&!u?.subscriptionsHasMore)break;o=u?.chargesAfter||o,s=u?.subscriptionsAfter||s}return{sales:i,error:``}}catch{return{sales:i,error:`Your payments could not be read, so nothing paid for could be let in just now.`}}}var Wc=e=>e?.code===`permission-denied`?`What came in from the other page could not be read. The security rules may need pasting again from the Setup screen.`:`What came in from the other page could not be read just now.`,Gc=1440*60*1e3,Kc=(e,t,n)=>[e.name,e.customerName,e.buyer?.name,t.submitterName,n?.name].map(e=>typeof e==`string`?e.trim():``).find(Boolean)||``;function qc(e,t,{roles:n=[],paid:r=!1,page:i,ring:a=!0},o,s=Date.now()){if(!a)return[];let c=Pc(e.submittedAt);if(c&&s-c>Gc)return[];let l=i?.path||(typeof window<`u`?window.location.pathname:``),u=i?.title?` on ${i.title}`:``,d=Kc(t,e,o),f=n.map(e=>({toRole:e,title:r?`New order${u}`:`Something new${u}`,body:d?`From ${d}`:``,link:l}));return e.uid&&e.uid!==`guest`&&f.push({toUid:e.uid,title:r?`We have your order`:`We have what you sent`,body:i?.title?`Follow it on ${i.title}.`:`You can follow it here.`,link:l}),f}var Jc=new Map,Yc=new Set,Xc=(e,t)=>`${e}|${t}`,Zc=(e,t)=>(Jc.get(Xc(e,t))||0)>0,Qc=e=>(Yc.add(e),()=>{Yc.delete(e)}),$c=(e,t)=>{Jc.set(e,Math.max(0,(Jc.get(e)||0)+t)),Yc.forEach(e=>e())};function el(e,t,n,i){let{formId:a,paid:o=!1}=t(),s=!0,c=new Map,l=new Map,u=new Set,d=!1,f=!1,p=async(n,i)=>{let a=t(),o;try{o=(a.make||Mc)(n,i)}catch{return`Something that came in could not be read into this page.`}if(!o)return``;let s=Fc(n,o,a,i),c=!1;try{await(0,q.runTransaction)(r.ui,async t=>{c=!1;let i=(0,q.doc)(r.ui,n.from,n.id),a=(0,q.doc)(r.ui,e,n.id),o=await t.get(i);!o.exists()||kc(o.data()?.arrivedIn).includes(e)||((await t.get(a)).exists()||(t.set(a,s),c=!0),t.update(i,{arrivedIn:(0,q.arrayUnion)(e)}))})}catch(e){return Wc(e)}if(c)for(let e of qc(n,s,a,i))Mt(e);return``},m=async t=>{let n=[];for(let i=0;i<t.length;i+=30){let a=await(0,q.getDocs)((0,q.query)((0,q.collection)(r.ui,e),(0,q.where)(`sourceId`,`in`,t.slice(i,i+30))));for(let e of a.docs)n.push(Rc(e.data()||{}))}return n},h=async()=>{if(d){f=!0;return}d=!0;try{let e=[...c.values()].flatMap(e=>[...e.values()]).filter(e=>!u.has(e.id));if(!e.length)return;let t=[],n=``,r=[...l.values()].flat(),a=r;if(o){let o=await Uc(e.map(e=>e.id),r);if(!s)return;t=o.sales,n=o.error;try{a=Bc(r,await m(zc(t,e.map(e=>e.id))))}catch(e){i(n||Wc(e));return}if(!s)return}for(let r of e){let e=o?Lc(r.id,t,r,a):null;if(o&&!e)continue;let i=await p(r,e);if(!s)return;i?n||=i:u.add(r.id)}i(n)}finally{d=!1,f&&s&&(f=!1,h())}},g=new Map,_=new Set,v=!1,y=async()=>{try{let t=await(0,q.getDocs)((0,q.query)((0,q.collection)(r.ui,e),(0,q.where)(`formId`,`==`,a),(0,q.where)(`uid`,`==`,n)));for(let i of t.docs){if(!s)return;let t=i.data()||{};Ic(t,n,g.get(String(t.sourceId)))&&await(0,q.updateDoc)((0,q.doc)(r.ui,e,i.id),{uid:``})}}catch{}},b=Oc.map(t=>(0,q.onSnapshot)((0,q.query)((0,q.collection)(r.ui,t),(0,q.where)(`formId`,`==`,a)),n=>{let r=new Map,i=[];for(let o of n.docs){let n=o.data()||{};g.set(o.id,!n.uid||n.uid===`guest`);let s={...n,id:o.id,uid:String(n.uid||`guest`),formId:a,from:t};i.push(s),!kc(n.arrivedIn).includes(e)&&r.set(o.id,s)}c.set(t,r),l.set(t,i),_.add(t),!v&&_.size===Oc.length&&(v=!0,y()),h()},e=>{s&&i(Wc(e))})),x=()=>o&&[...c.values()].some(e=>[...e.values()].some(e=>!u.has(e.id)&&Date.now()-(Pc(e.submittedAt)||Date.now())<72e5)),S=setInterval(()=>{x()&&h()},Hc),C=()=>{document.visibilityState===`visible`&&x()&&h()};return document.addEventListener(`visibilitychange`,C),()=>{s=!1,b.forEach(e=>e()),clearInterval(S),document.removeEventListener(`visibilitychange`,C)}}function tl(e,t,n){let{user:i,isAdmin:a,roleConfirmed:s}=r.Ft(),c=i?.uid||``,{formId:l,paid:u=!1}=t,d=(0,W.useRef)(t);(0,W.useEffect)(()=>{d.current=t});let[f,p]=(0,W.useState)(``),m=Xc(e,l),h=(0,W.useSyncExternalStore)(Qc,()=>n?!1:Zc(e,l)),g=!!c&&a&&s&&o.Tn(e)&&!!l&&!h;return(0,W.useEffect)(()=>{if(!(!n||!o.Tn(e)||!l))return $c(m,1),()=>$c(m,-1)},[n,m,e,l]),(0,W.useEffect)(()=>{if(g)return el(e,()=>d.current,c,p)},[g,e,l,u,c]),{error:g?f:``}}function nl(e,t){return tl(e,t,!0)}function rl(e,t){return tl(e,t,!1)}function il({road:e}){let{error:t}=rl(e.collection,{formId:e.formId,paid:e.paid,roles:e.roles,page:e.page});return(0,W.useEffect)(()=>{t&&a.s(r.ni(t,`none`))},[t]),null}function al(){return(0,G.jsx)(G.Fragment,{children:S.i().map(e=>(0,G.jsx)(il,{road:e},`${e.collection}|${e.formId}`))})}function ol(){let{pathname:e,hash:t}=(0,Y.useLocation)(),n=(0,Y.useNavigationType)();return(0,W.useLayoutEffect)(()=>{if(!(n===`POP`||t))try{window.scrollTo({top:0,left:0,behavior:`instant`})}catch{}},[e,t,n]),null}ol.displayName=`ScrollToTop`;var sl=()=>Promise.resolve().then(()=>require(`./Users-B16L9cKI.cjs`)).then(e=>({default:e.UsersTab})),cl=()=>Promise.resolve().then(()=>require(`./SignInAdmin-B1yLLaQu.cjs`)).then(e=>({default:e.SignInAdmin})),ll=()=>Promise.resolve().then(()=>require(`./Inbox-DjslBakx.cjs`)).then(e=>({default:e.Inbox})),ul=()=>Promise.resolve().then(()=>require(`./Assets-D7fDckSi.cjs`)).then(e=>({default:e.Assets})),dl=()=>Promise.resolve().then(()=>require(`./ThemeAdmin-CoE_c5-P.cjs`)).then(e=>({default:e.ThemeAdmin})),fl=()=>Promise.resolve().then(()=>require(`./PagesAdmin-KUxCI1Mr.cjs`)).then(e=>({default:e.PagesAdmin})),pl=()=>Promise.resolve().then(()=>require(`./FormsAdmin-5KTTp6zo.cjs`)).then(e=>({default:e.FormsAdmin})),ml=()=>Promise.resolve().then(()=>require(`./PaymentsAdmin-B5l-f0mp.cjs`)).then(e=>({default:e.PaymentsAdmin})),hl=()=>Promise.resolve().then(()=>require(`./TransactionsAdmin-C5wQRR1g.cjs`)).then(e=>({default:e.TransactionsAdmin})),gl=()=>Promise.resolve().then(()=>require(`./ScheduleAdmin-Dh_hW6p4.cjs`)).then(e=>({default:e.ScheduleAdmin})),_l=()=>Promise.resolve().then(()=>require(`./EmailAdmin-d_gWd48U.cjs`)).then(e=>({default:e.EmailAdmin})),vl=()=>Promise.resolve().then(()=>require(`./SetupPayments-CuFk9REC.cjs`)).then(e=>({default:e.SetupPayments})),yl=()=>Promise.resolve().then(()=>require(`./PublishApp-Bc82Ijkq.cjs`)).then(e=>({default:e.PublishApp})),bl=()=>Promise.resolve().then(()=>require(`./MyBookings-CkEioQIj.cjs`)).then(e=>({default:e.MyBookings})),xl=()=>Promise.resolve().then(()=>require(`./Billing-DkuJdls5.cjs`)).then(e=>({default:e.Billing})),Sl=r.si(sl),Cl=r.si(cl),wl=r.si(ll),Tl=r.si(ul),El=r.si(dl),Dl=r.si(fl),Ol=r.si(pl),kl=r.si(ml),Al=r.si(hl);r.si(gl);var jl=r.si(_l),Ml=r.si(vl),Nl=r.si(yl);r.si(bl);var Pl=r.si(xl),Fl=[...[],xl],Il=[sl,ll,hl,...[]],Ll=[fl,pl,dl,cl,ul,ml,_l,yl,vl];function Rl(){let{user:e,isAdmin:t,isInternal:n}=r.Ft();return(0,W.useEffect)(()=>{if(!e)return;let r=[...Fl,...t||n?Il:[],...t?Ll:[]],i=!1,a,o=e=>typeof window.requestIdleCallback==`function`?window.requestIdleCallback(e,{timeout:4e3}):window.setTimeout(e,1500),s=e=>typeof window.cancelIdleCallback==`function`?window.cancelIdleCallback(e):window.clearTimeout(e),c=()=>{let e=r.shift();!e||i||(a=o(()=>{e().catch(()=>{}).finally(c)}))};return c(),()=>{i=!0,a!==void 0&&s(a)}},[e,t,n]),null}function zl(){return(0,G.jsxs)(`div`,{className:`fixed top-0 left-0 w-full h-full pointer-events-none -z-0 overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`fbos-orb-1 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,G.jsx)(`div`,{className:`fbos-orb-2 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]`})]})}var Bl={pageId:`home`};function Vl({Page:e}){return fn(),r.Rr(),(0,G.jsx)(`div`,{className:`fbos-home-slot contents`,children:(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(te.t,{config:Bl,children:e===Nn?(0,G.jsx)(e,{}):(0,G.jsx)(nn,{which:`home`,fallback:(0,G.jsx)(Nn,{}),onlyMissing:!0,neverPutAside:!tn(e),children:(0,G.jsx)(e,{})})})})})}function Hl(){let{isAdmin:e}=r.Ft();return(0,G.jsx)(sn,{isAdmin:!!e})}function Ul(){let e=r.mi().components?.Home||Nn,t=(0,Y.useNavigate)(),n=(0,Y.useLocation)();return(0,G.jsx)(r.Nt,{onSignedOut:()=>t(`/`,{replace:!0}),onRemoved:()=>t(Xs,{replace:!0}),children:(0,G.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-clip`,children:[(0,G.jsxs)(ln,{children:[(0,G.jsx)(A.p,{size:`part`,children:(0,G.jsx)(jn,{})}),(0,G.jsx)(ol,{}),(0,G.jsx)(Ri,{}),(0,G.jsx)(Ki,{}),(0,G.jsxs)(A.p,{resetKey:n.pathname,children:[(0,G.jsx)(Rl,{}),(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(yc,{}),children:(0,G.jsxs)(Y.Routes,{children:[(0,G.jsx)(Y.Route,{path:`/`,element:(0,G.jsx)(wc,{children:(0,G.jsx)(Vl,{Page:e})})}),(0,G.jsx)(Y.Route,{path:`/register`,element:(0,G.jsx)(wc,{landing:`/dashboard?${I.n}=1`,children:(0,G.jsx)(zr,{})})}),(0,G.jsx)(Y.Route,{path:`/login`,element:(0,G.jsx)(wc,{children:(0,G.jsx)(Br,{})})}),(0,G.jsx)(Y.Route,{path:`/reset-password`,element:(0,G.jsx)(wc,{children:(0,G.jsx)(Fi,{})})}),(0,G.jsx)(Y.Route,{path:`/verify`,element:(0,G.jsx)(Tc,{children:(0,G.jsx)(ni,{})})}),(0,G.jsx)(Y.Route,{path:`/confirm-email`,element:(0,G.jsx)(ai,{})}),(0,G.jsx)(Y.Route,{path:`/two-step`,element:(0,G.jsx)(Ec,{children:(0,G.jsx)(hi,{})})}),(0,G.jsx)(Y.Route,{path:`/your-details`,element:(0,G.jsx)(Dc,{children:(0,G.jsx)(Si,{})})}),(0,G.jsx)(Y.Route,{path:`/book/:id`,element:(0,G.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/meet/:id`,element:(0,G.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/book`,element:(0,G.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/booking`,element:(0,G.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/pay/:id`,element:(0,G.jsx)(Yi,{})}),(0,G.jsx)(Y.Route,{path:`/payment-complete`,element:(0,G.jsx)(sc,{})}),(0,G.jsx)(Y.Route,{path:`/payment-cancelled`,element:(0,G.jsx)(sc,{cancelled:!0})}),(0,G.jsx)(Y.Route,{path:`/guide`,element:(0,G.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/templates`,element:(0,G.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/users`,element:(0,G.jsx)(Cc,{tab:`users`,children:(0,G.jsx)(Sl,{})})}),(0,G.jsx)(Y.Route,{path:`/users/:id`,element:(0,G.jsx)(Cc,{tab:`users`,children:(0,G.jsx)(Sl,{})})}),(0,G.jsx)(Y.Route,{path:`/sign-in`,element:(0,G.jsx)(Sc,{children:(0,G.jsx)(Cl,{})})}),(0,G.jsx)(Y.Route,{path:`/inbox`,element:(0,G.jsx)(Cc,{tab:`inbox`,children:(0,G.jsx)(wl,{})})}),(0,G.jsx)(Y.Route,{path:`/payments`,element:(0,G.jsx)(Sc,{children:(0,G.jsx)(kl,{})})}),(0,G.jsx)(Y.Route,{path:`/transactions`,element:(0,G.jsx)(Cc,{tab:`transactions`,children:(0,G.jsx)(Al,{})})}),(0,G.jsx)(Y.Route,{path:`/schedule`,element:(0,G.jsx)(Y.Navigate,{to:`/dashboard`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/my-calendar`,element:(0,G.jsx)(Y.Navigate,{to:`/dashboard`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/my-bookings`,element:(0,G.jsx)(Y.Navigate,{to:`/dashboard`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/calendar`,element:(0,G.jsx)(Y.Navigate,{to:`/dashboard`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/bookings`,element:(0,G.jsx)(Y.Navigate,{to:`/dashboard`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/email`,element:(0,G.jsx)(Sc,{children:(0,G.jsx)(jl,{})})}),(0,G.jsx)(Y.Route,{path:`/submissions`,element:(0,G.jsx)(Y.Navigate,{to:`/inbox`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/requests`,element:(0,G.jsx)(Y.Navigate,{to:`/inbox`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/assets`,element:(0,G.jsx)(Sc,{children:(0,G.jsx)(Tl,{})})}),(0,G.jsx)(Y.Route,{path:`/drive`,element:(0,G.jsx)(Y.Navigate,{to:`/assets`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/drive/:rest`,element:(0,G.jsx)(Y.Navigate,{to:`/assets`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/theme`,element:(0,G.jsx)(Sc,{children:(0,G.jsx)(El,{})})}),(0,G.jsx)(Y.Route,{path:`/pages/*`,element:(0,G.jsx)(Sc,{children:(0,G.jsx)(Dl,{})})}),(0,G.jsx)(Y.Route,{path:`/forms/*`,element:(0,G.jsx)(Sc,{children:(0,G.jsx)(Ol,{})})}),(0,G.jsx)(Y.Route,{path:`/settings`,element:(0,G.jsx)(Y.Navigate,{to:`/pages`,replace:!0})}),(0,G.jsx)(Y.Route,{path:`/profile`,element:(0,G.jsx)(xc,{children:(0,G.jsx)(Pi,{})})}),(0,G.jsx)(Y.Route,{path:`/billing`,element:(0,G.jsx)(xc,{children:(0,G.jsx)(Pl,{})})}),(0,G.jsx)(Y.Route,{path:`/dashboard`,element:(0,G.jsx)(xc,{children:(0,G.jsx)(lc,{})})}),(0,G.jsx)(Y.Route,{path:`/publish`,element:(0,G.jsx)(Sc,{children:(0,G.jsx)(Nl,{})})}),(0,G.jsx)(Y.Route,{path:`/setup`,element:(0,G.jsx)(se.r,{})}),(0,G.jsx)(Y.Route,{path:`/setup/payments`,element:(0,G.jsx)(Ml,{})}),(0,G.jsx)(Y.Route,{path:`*`,element:(0,G.jsx)(rc,{})})]})})]})]}),(0,G.jsx)(zl,{}),(0,G.jsx)(Re,{}),(0,G.jsx)(Hl,{}),(0,G.jsx)(al,{}),(0,G.jsx)(O.t,{})]})})}function Wl(){return(0,G.jsxs)(A.p,{children:[(0,G.jsx)(Y.BrowserRouter,{children:(0,G.jsx)(Gl,{})}),(0,G.jsx)(a.n,{})]})}function Gl(){let e=r.mi();return e.firebaseConfig&&e.firebaseConfig.apiKey&&e.firebaseConfig.apiKey.trim()!==``&&e.firebaseConfig.projectId&&e.firebaseConfig.projectId.trim()!==``||se.i()?(0,G.jsx)(Ul,{}):(0,G.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-clip`,children:[(0,G.jsx)(jn,{standalone:!0}),(0,G.jsx)(se.r,{standalone:!0}),(0,G.jsx)(zl,{})]})}function Kl(e){return(0,G.jsx)(`div`,{className:`firebase-os flex-1 flex flex-col min-h-screen`,style:{background:`var(--bg-gradient)`,color:`var(--fg-color)`},children:(0,G.jsx)(A.p,{children:(0,G.jsx)(ql,{...e})})})}function ql(e){Ne();let t=e.firebaseConfig;return t&&t.apiKey&&t.apiKey.trim()!==``&&t.projectId&&t.projectId.trim()!==``&&r.di(t),A.a(e.pageFiles),(0,G.jsx)(r.pi,{config:{firebaseConfig:e.firebaseConfig,basename:e.basename,onAuthChange:e.onAuthChange,themeConfig:e.themeConfig,components:e.components,customRoutes:e.customRoutes,microcomponents:e.microcomponents,pageFiles:e.pageFiles,defaultConfigs:e.defaultConfigs},children:(0,G.jsx)(i.M,{children:(0,G.jsx)(Wl,{})})})}var Jl=[`views`,`added`,`clicks`,`saves`,`shares`,`downloads`],Yl=`mem_tallies`,Xl=`Needs the rules pasted from /setup at 1.14.66 or later.`,Zl=Object.freeze({views:0,added:0,clicks:0,saves:0,shares:0,downloads:0}),Ql=e=>String(e??``).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40),$l=e=>String(e??``).trim().replace(/\//g,`_`).slice(0,120),eu=(e,t)=>{let n=Ql(e),r=$l(t);return n&&r?`${n}_${r}`:null};function tu(e){let t={...Zl};for(let n of Jl){let r=Math.floor(Number(e?.[n]));Number.isFinite(r)&&r>0&&(t[n]=r)}return t}var nu=new Set,ru=e=>{if(nu.has(e))return!0;try{return window.sessionStorage.getItem(e)===`1`}catch{return!1}},iu=e=>{nu.add(e);try{window.sessionStorage.setItem(e,`1`)}catch{}},au=()=>{let e=r.li?.currentUser?.uid;if(!e)return!1;try{let t=window.localStorage.getItem(r.Pt(e));return t===`admin`||t===`internal`}catch{return!1}},ou=!1;async function su(e,t,n=`views`){try{let i=eu(e,t);if(!i||!Jl.includes(n))return console.error(`tally('${e}', '${t}', '${n}'): a tally needs what is counted ('products'), the record's id, and one of ${Jl.join(`, `)}.`),!1;let a=`fbos.tally.${i}.${n}`;return ru(a)||au()?!1:(iu(a),await(0,q.setDoc)((0,q.doc)(r.ui,Yl,i),{thing:Ql(e),of:$l(t),[n]:(0,q.increment)(1)},{merge:!0}),!0)}catch(e){return!ou&&e?.code===`permission-denied`&&(ou=!0,console.warn(`tally(): the database refused the count. ${Xl}`)),!1}}function cu(e){let{accessLevel:t}=r.Ft(),n=t===`admin`||t===`internal`,i=Ql(e),[a,o]=(0,W.useState)(new Map),[s,c]=(0,W.useState)(!0),[l,u]=(0,W.useState)(null);return(0,W.useEffect)(()=>{if(!n||!i){o(new Map),c(!1);return}return c(!0),u(null),(0,q.onSnapshot)((0,q.query)((0,q.collection)(r.ui,Yl),(0,q.where)(`thing`,`==`,i)),e=>{let t=new Map;e.docs.forEach(e=>{let n=e.data()||{};t.set(String(n.of??``),tu(n))}),o(t),c(!1)},e=>{u(r.ii(e,`The counts could not be read.`)),c(!1)})},[n,i]),(0,W.useMemo)(()=>{let e={...Zl};for(let t of a.values())for(let n of Jl)e[n]+=t[n];return{loading:s,error:l,of:e=>a.get($l(e))||Zl,total:e}},[a,s,l])}var lu=e=>typeof e==`string`?e.trim():e==null?``:String(e).trim(),uu=e=>{let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:0},du=e=>Math.round(e*100);function fu(e){let t=[];for(let n of Array.isArray(e)?e:[]){let e=lu(n?.name),r=Math.floor(uu(n?.quantity??1));if(!e||r<1)continue;let i={};try{i=JSON.parse(JSON.stringify(n))||{}}catch{i={}}let a={...i,name:e,quantity:r,price:uu(n?.price)};for(let e of[`id`,`options`,`picture`])lu(n?.[e])?a[e]=lu(n[e]):delete a[e];t.push(a)}return t}var pu=e=>(Array.isArray(e)?e:[]).map(e=>({label:lu(e?.label),amount:uu(e?.amount)})).filter(e=>e.label&&e.amount!==0),mu=e=>e.reduce((e,t)=>e+du(t.price)*t.quantity,0)/100,hu=(e,t=[])=>(du(mu(e))+t.reduce((e,t)=>e+du(t.amount),0))/100;function gu(e,t=`usd`,n=480){let r=e.map(e=>`${e.quantity} × ${e.name}${e.options?` — ${e.options}`:``} · ${ic(e.price*e.quantity,t)}`),i=``;for(let e=0;e<r.length;e+=1){let t=i?`${i}; ${r[e]}`:r[e],a=r.length-e-1;if((t+(a?`; and ${a} more`:``)).length>n)return i?`${i}; and ${r.length-e} more`:r[e].slice(0,n);i=t}return i}var _u=new Set([`uid`,`formId`,`submittedAt`,`submitterName`,`submitterEmail`,`submitterAvatar`,`transaction`,`arrivedIn`,`access`,`editors`]);function vu(e,t,n,r,i){let a={items:e,extras:t,subtotal:mu(e),total:hu(e,t),currency:(n||`usd`).toLowerCase(),name:lu(r.name),email:lu(r.email),phone:lu(r.phone),address:lu(r.address)},o={};try{o=JSON.parse(JSON.stringify(i||{}))||{}}catch{o={}}for(let[e,t]of Object.entries(o))e in a||_u.has(e)||(a[e]=t);return a}var yu=`fbos_checkout_entry`,bu=(e,t)=>JSON.stringify([e,t]);function xu(e){try{let t=JSON.parse(window.sessionStorage.getItem(yu)||`null`);return t&&t.print===e&&typeof t.id==`string`?t.id:``}catch{return``}}function Su(){try{window.sessionStorage.removeItem(yu)}catch{}}var Cu=`fbos_checkout_guest`;function wu(e){try{e?window.sessionStorage.setItem(Cu,e):window.sessionStorage.removeItem(Cu)}catch{}}function Tu(){try{let e=window.sessionStorage.getItem(Cu)||``;return window.sessionStorage.removeItem(Cu),e}catch{return``}}async function Eu(e,t){let n=bu(e,t),i=xu(n);if(i)return i;let a=r.li?.currentUser,o=await(0,q.addDoc)((0,q.collection)(r.ui,`user_submissions`),{...t,...a?{uid:a.uid,submitterName:a.displayName||t.name,submitterEmail:a.email||t.email,submitterAvatar:a.photoURL||``}:{uid:`guest`},formId:e,transaction:!0,submittedAt:(0,q.serverTimestamp)()});try{window.sessionStorage.setItem(yu,JSON.stringify({print:n,id:o.id}))}catch{}return o.id}var Du=e=>{let t=Math.floor(Number(e));return Number.isFinite(t)&&t>0?t:0},Ou=e=>String(e.variantId??e.variant??``).trim();function ku(e,t,n){let r=n.filter(t=>String(t.id??``)===e&&Du(t.quantity)>0);if(!r.length)return null;let i=String(t?.name??t?.title??r[0].name??``),a=[],o=Array.isArray(t?.variants)?t.variants.map(e=>({...e})):null,s=typeof t?.stock==`number`?t.stock:null,c=!1,l=!1;for(let t of r){let n=Du(t.quantity),r=Ou(t),u=o&&r?o.findIndex(e=>String(e?.id??``)===r):-1;if(o&&u>=0&&typeof o[u].stock==`number`){let t=o[u].stock,s=Math.max(0,t-n);o[u].stock=s,c=!0,a.push({id:e,variantId:r,name:i,variantName:String(o[u].name??``),quantity:n,from:t,to:s})}else if(s!==null){let t=s,r=Math.max(0,t-n);s=r,l=!0,a.push({id:e,name:i,quantity:n,from:t,to:r})}}if(!a.length)return null;let u={};return c&&(u.variants=o),l&&(u.stock=s),{fields:u,changes:a}}var Au=e=>({id:e.id,who:{name:String(e.name||e.submitterName||``),email:String(e.email||e.submitterEmail||``)},at:Pc(e.submittedAt)||Date.now(),items:fu(e.items)}),ju=e=>e?.code===`permission-denied`?`The orders could not be read to take their stock. The security rules may need pasting again from the Setup screen.`:`The stock for what was sold could not be updated just now.`;function Mu(e,t,n){let{formId:i}=t(),a=!0,o=new Map,s=new Map,c=new Set,l=!1,u=!1,d=async n=>{let i=Au(n),a=[...new Set(i.items.map(e=>String(e.id??``)).filter(Boolean))],o=[];try{await(0,q.runTransaction)(r.ui,async t=>{o=[];let s=(0,q.doc)(r.ui,n.from,n.id),c=await t.get(s);if(!c.exists()||kc(c.data()?.stockTakenIn).includes(e))return;let l=[];for(let n of a){let i=await t.get((0,q.doc)(r.ui,e,n));l.push({id:n,data:i.exists()?i.data():null})}for(let{id:n,data:a}of l){let s=a?ku(n,a,i.items):null;s&&(t.update((0,q.doc)(r.ui,e,n),{...s.fields,editedName:i.who.name||`A customer`,editedAt:i.at}),o.push(...s.changes))}t.update(s,{stockTakenIn:(0,q.arrayUnion)(e)})})}catch(e){return ju(e)}if(o.length)try{t().onTaken?.(i,o)}catch{}return``},f=async()=>{if(l){u=!0;return}l=!0;try{let e=[...o.values()].flatMap(e=>[...e.values()]).filter(e=>!c.has(e.id));if(!e.length)return;let t=[...s.values()].flat(),r=await Uc(e.map(e=>e.id),t);if(!a)return;let i=r.error;for(let n of e){if(!Lc(n.id,r.sales,n,t))continue;let e=await d(n);if(!a)return;e?i||=e:c.add(n.id)}n(i)}finally{l=!1,u&&a&&(u=!1,f())}},p=Oc.map(t=>(0,q.onSnapshot)((0,q.query)((0,q.collection)(r.ui,t),(0,q.where)(`formId`,`==`,i)),n=>{let r=new Map,a=[];for(let o of n.docs){let n=o.data()||{},s={...n,id:o.id,uid:String(n.uid||`guest`),formId:i,from:t};a.push(s),!kc(n.stockTakenIn).includes(e)&&r.set(o.id,s)}o.set(t,r),s.set(t,a),f()},e=>{a&&n(ju(e))})),m=()=>[...o.values()].some(e=>[...e.values()].some(e=>!c.has(e.id)&&Date.now()-(Pc(e.submittedAt)||Date.now())<72e5)),h=setInterval(()=>{m()&&f()},Hc),g=()=>{document.visibilityState===`visible`&&m()&&f()};return document.addEventListener(`visibilitychange`,g),()=>{a=!1,p.forEach(e=>e()),clearInterval(h),document.removeEventListener(`visibilitychange`,g)}}var Nu=/^(?:mem|admin|role_[a-z][a-z0-9]*)_[A-Za-z0-9_]+$/;function Pu(e,t){let{user:n,isAdmin:i,roleConfirmed:a}=r.Ft(),o=n?.uid||``,{formId:s}=t,c=(0,W.useRef)(t);(0,W.useEffect)(()=>{c.current=t});let[l,u]=(0,W.useState)(``),d=Nu.test(String(e||``)),f=!!o&&i&&a&&d&&!!s;return(0,W.useEffect)(()=>{d||console.error(`useStockFromOrders('${e}'): stock is kept by the page that keeps the products — a mem_, admin_ or role_<id>_ collection. Never a pub_ one: that is the app's own copy (usePublicCopy), and it follows the record by itself.`)},[d,e]),(0,W.useEffect)(()=>{if(f)return Mu(e,()=>c.current,u)},[f,e,s,o]),{error:f?l:``}}var Fu=r.si(()=>Promise.resolve().then(()=>require(`./PhoneInputField-WYdkNEym.cjs`))),Iu=r.si(()=>Promise.resolve().then(()=>require(`./AddressField-CI8PP5ow.cjs`))),Lu={},Ru=`address`,zu=/^[^\s@,;]+@[^\s@,;.]+(\.[^\s@,;.]+)*\.[a-z]{2,}$/i;function Bu(e=e=>{let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t)}){return`${e(24).map(e=>`ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789`[e%57]).join(``)}Aa9!`}function Vu(e){let t={};return e.name&&(t.name=e.name),e.email&&(t.email=e.email),e.phone&&(t.phone=e.phone),e.address&&(t.address=e.address),t}function Hu(e,t){let n={};return e.name.trim()||(n.name=`Please give your name.`),zu.test(e.email.trim())||(n.email=`Please give a real email address — the receipt goes there.`),t.phone===!0&&!e.phone.trim().replace(/^\+\d{1,3}$/,``)&&(n.phone=`Please give a phone number.`),t.address===!0&&!P.c(P.u(e.address))&&(n.address=`Please give the address.`),n}var Uu=`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,Wu=`leading-snug break-words [overflow-wrap:anywhere]`;function Gu({phone:e,address:t,onReady:n,onEditing:i,heading:a=`Your details`,continueLabel:o=`Continue`,wide:s=!1,className:c=``}){let{user:l,profile:u,profileReady:d,loading:f}=r.Ft(),p=r.Cn(),m=String(l?.displayName||u?.displayName||``).trim(),h=String(l?.email||u?.email||``).trim(),_=String(l?.phoneNumber||u?.phone||``).trim(),v=P.i(Ru,u||{}),[y,b]=(0,W.useState)(m),[S,C]=(0,W.useState)(h),[w,T]=(0,W.useState)(_),[E,D]=(0,W.useState)(v),[O,k]=(0,W.useState)({}),[A,j]=(0,W.useState)(``),[N,ee]=(0,W.useState)(!1),[te,F]=(0,W.useState)(null),[I,L]=(0,W.useState)(!1),ne=g._(g.p,Lu),R=ne.ready?ne.value:Lu,z=String(R.name||``)||m,re=String(R.email||``)||h,ie=String(R.phone||``)||_,B=R.address&&P.c(R.address)?{...P.n,...R.address}:v,V=(0,W.useRef)(!1);(0,W.useEffect)(()=>{V.current||(b(z),C(re),T(ie),D(B))},[`${z}|${re}|${ie}|${P.s(B)}`]);let ae=ne.setValue;(0,W.useEffect)(()=>{V.current&&ae({name:y,email:S,phone:w,address:E})},[y,S,w,E,ae]);let oe=(0,W.useRef)(``),se=!!l?.uid,ce=se&&d&&!!m&&zu.test(h)&&(e!==!0||!!_)&&(t!==!0||P.c(v));(0,W.useEffect)(()=>{if(!ce||I||te||!l?.uid||oe.current===l.uid)return;oe.current=l.uid;let e=Ku(l.uid,m,h,_,v);F(e),n(e,{pressed:!1})},[ce,I,te,l?.uid]);let H=(0,W.useRef)(se),le=ne.clear;(0,W.useEffect)(()=>{let e=H.current&&!se;H.current=se,!se&&(oe.current=``,F(null),L(!1),e&&le())},[se,le]);let U={phone:e,address:t},ue=!p.loading&&p.on?.emailLink===!0,J=(e,t)=>{V.current=!0,t(),O[e]&&k(t=>{let{[e]:n,...r}=t;return r}),A&&j(``)},Y=async()=>{if(N)return;let e=Hu({name:y,email:S,phone:w,address:E},U);if(k(e),Object.keys(e).length){j(`There is something to check below.`);return}ee(!0),j(``);let t=y.trim(),i=S.trim(),a=w.trim(),o=P.u(E);try{let e=l?.uid||``,s=!1,c=r.li.currentUser;if(e)c&&t&&t!==m&&await(0,K.updateProfile)(c,{displayName:t}).catch(()=>{});else{let n=await(0,K.createUserWithEmailAndPassword)(r.li,i,Bu());c=n.user,e=n.user.uid,s=!0,await(0,K.updateProfile)(n.user,{displayName:t}).catch(()=>{}),await n.user.getIdToken(!0).catch(()=>{})}let u={uid:e,displayName:t,...s?{email:i,createdAt:new Date().toISOString()}:{},...a?{phone:a}:{},...P.c(o)?P.r(Ru,o):{}};try{await(0,q.setDoc)((0,q.doc)(r.ui,`user_profiles`,e),u,{merge:!0})}catch(e){if(console.warn(`BuyerDetails: the details could not be written to the profile.`,e),!s)throw e}s&&c&&r.wn(c);let d=Ku(e,t,s?i:h||i,a,o,{registered:s});oe.current=e,F(d),L(!1),n(d,{pressed:!0})}catch(e){if(e?.code===`auth/email-already-in-use`){let e=Ku(``,t,i,a,o,{guest:!0});F(e),L(!1),n(e,{pressed:!0})}else e?.code?j((await r.Kt(e,`password`,`That did not work. Check your details and try again.`,{email:i})).text):j(r.ii(e,`Your details could not be saved. Please try again.`))}finally{ee(!1)}};if(f||se&&!d)return(0,G.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl ${c}`,"aria-hidden":!0});if(te&&!I){let e=[te.email,te.phone].map(e=>String(e||``).trim()).filter(Boolean),t=P.a(te.addressParts);return(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.3,ease:`easeOut`},className:`rounded-2xl border border-[var(--panel-border)] bg-foreground/[0.035] px-4 py-3.5 text-left ${c}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/45 leading-tight select-none`,children:`Paying as`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{V.current=!0,L(!0),i?.()},className:`text-[13px] font-semibold text-accent hover:underline cursor-pointer leading-tight shrink-0`,children:`Change`})]}),(0,G.jsx)(`p`,{className:`${Wu} mt-1 text-[14.5px] font-semibold text-foreground`,children:te.name}),(e.length>0||t.length>0)&&(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-0.5 text-[13.5px] text-foreground/65`,children:[e.map(e=>(0,G.jsx)(`span`,{className:Wu,children:e},e)),t.length>0&&(0,G.jsx)(`span`,{className:`flex flex-col gap-0.5 ${e.length?`mt-2`:``}`,children:t.map((e,t)=>(0,G.jsx)(`span`,{className:Wu,children:e},t))})]}),te.guest&&ue&&(0,G.jsx)(`p`,{className:`mt-3 pt-3 border-t border-[var(--panel-border)]/70 text-[12.5px] text-foreground/50 leading-snug`,children:`We will email you a link to your order once you have paid.`})]})}return(0,G.jsxs)(`form`,{className:`flex flex-col gap-4 w-full ${c}`,onSubmit:e=>{e.preventDefault(),Y()},noValidate:!0,children:[a&&(0,G.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground tracking-tight`,children:a}),A&&(0,G.jsx)(x.t,{tone:`error`,children:A}),(0,G.jsx)(g.y,{label:`Full name`,"aria-label":`Full name`,name:`name`,autoComplete:`name`,placeholder:`John Doe`,value:y,error:O.name,disabled:N,onChange:e=>J(`name`,()=>b(e.target.value)),className:`max-sm:h-11`}),(0,G.jsx)(g.y,{label:`Email`,"aria-label":`Email`,name:`email`,type:`email`,autoComplete:`email`,placeholder:`name@example.com`,value:S,error:O.email,disabled:N||se&&!!h,onChange:e=>J(`email`,()=>C(e.target.value)),className:`max-sm:h-11`}),e&&(0,G.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,G.jsx)(Fu,{field:{label:e===`optional`?`Phone (optional)`:`Phone`,required:e===!0},value:w,onChange:e=>J(`phone`,()=>T(e))})}),O.phone&&(0,G.jsx)(`p`,{className:`text-xs text-red-500 font-medium mt-1 ml-1`,children:O.phone})]}),t&&(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,G.jsx)(Iu,{id:`buyer-address`,label:t===`optional`?`Address (optional)`:`Address`,required:t===!0,disabled:N,error:O.address,value:E,onChange:e=>J(`address`,()=>D(e))})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(M.t,{type:`submit`,isLoading:N,disabled:N,className:`w-full ${s?`py-3.5 text-[15px]`:`sm:w-auto sm:self-start py-2.5 text-[14px]`} px-6 font-bold tracking-wide rounded-xl`,children:o}),!se&&(0,G.jsx)(`p`,{className:`${Uu} mb-0`,children:`This makes your account, so you can find your order again. We will email you a link to confirm your address.`})]})]})}function Ku(e,t,n,r,i,{registered:a=!1,guest:o=!1}={}){let s={name:t,email:n,phone:r,address:P.c(i)?P.s(i):``};return{uid:e,...s,addressParts:P.c(i)?i:{...P.n},metadata:Vu(s),registered:a,guest:o}}var qu=`flex items-baseline justify-between gap-4 text-[14px]`,Ju=`w-full py-3.5 text-[15px] font-bold tracking-wide`;function Yu({formId:e,items:t,collection:n,extras:i,currency:a,phone:s,address:c,carry:l,productName:u,metadata:d,successPath:f,cancelPath:p,summary:m=!0,payLabel:h=`Pay`,className:g=``}){let{loading:_,configured:v}=r.zn(),y=r.Rr(),b=a||y||`usd`,{userRole:x}=r.Ft(),{pathname:S,search:C}=(0,Y.useLocation)(),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(!1),[O,k]=(0,W.useState)(``),A=(0,W.useMemo)(()=>fu(t),[t]),j=(0,W.useMemo)(()=>pu(i),[i]),N=hu(A,j);if(_)return null;if(!v)return o.wn(x)?(0,G.jsx)(`span`,{className:`text-[12.5px] font-medium text-foreground/50 leading-snug`,children:`Only admins see this: payments are not on yet, so the checkout is hidden. Connect Stripe and switch payments on at /payments and it appears here.`}):null;if(!A.length)return(0,G.jsx)(`p`,{className:`text-[14px] text-foreground/55 ${g}`,children:`There is nothing in your basket yet.`});let ee=A.some(e=>!!e.picture),P=`${h} ${ic(N,b)}`,te=async t=>{if(E||!t||N<=0)return;let i=t;if(D(!0),k(``),!a&&!y&&await r.Ir()){k(r.Pr),D(!1);return}let o=``;try{o=await Eu(e,vu(A,j,b,i,l))}catch(e){k(r.ii(e,`Your order could not be saved, so no payment was taken. Please try again.`)),D(!1);return}wu(i.guest?i.email:``);let s=await r.Fn({amount:N,currency:b,productName:u||(A.length===1?A[0].name:`Order of ${A.reduce((e,t)=>e+t.quantity,0)} items`),lines:A.map(e=>({name:e.name,amount:e.price,quantity:e.quantity,record:e.id?String(e.id):void 0,variant:e.variantId==null?e.variant==null?void 0:String(e.variant):String(e.variantId),options:e.options,collection:e.collection?String(e.collection):n||void 0})),extras:j,metadata:{...d,...i.metadata,orderEntryId:o,items:gu(A,b),total:String(N)},successPath:f||S,cancelPath:p||`${S}${C}`});s&&(k(s),D(!1))};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-8 ${g}`,children:[m&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[A.map((e,t)=>ee?(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-[14px]`,children:[(0,G.jsx)(`div`,{className:`relative w-12 h-12 shrink-0 rounded-xl overflow-hidden bg-foreground/5`,children:e.picture&&(0,G.jsx)(r.O,{src:e.picture,alt:``,fit:`cover`,className:`absolute inset-0`})}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 flex flex-col leading-snug`,children:[(0,G.jsx)(`span`,{className:`truncate font-medium text-foreground/85`,children:e.name}),(0,G.jsx)(`span`,{className:`truncate text-[13px] text-foreground/50`,children:[e.options,e.quantity>1?`× ${e.quantity}`:``].filter(Boolean).join(` · `)})]}),(0,G.jsx)(`span`,{className:`shrink-0 tabular-nums text-foreground/80`,children:ic(e.price*e.quantity,b)})]},`${e.id||e.name}-${t}`):(0,G.jsxs)(`div`,{className:qu,children:[(0,G.jsxs)(`span`,{className:`min-w-0 text-foreground/80`,children:[e.quantity,` × `,e.name,e.options&&(0,G.jsxs)(`span`,{className:`text-foreground/50`,children:[` — `,e.options]})]}),(0,G.jsx)(`span`,{className:`shrink-0 tabular-nums text-foreground/80`,children:ic(e.price*e.quantity,b)})]},`${e.id||e.name}-${t}`)),j.length>0&&(0,G.jsxs)(`div`,{className:`${qu} text-foreground/55`,children:[(0,G.jsx)(`span`,{children:`Subtotal`}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:ic(mu(A),b)})]}),j.map(e=>(0,G.jsxs)(`div`,{className:`${qu} text-foreground/55`,children:[(0,G.jsx)(`span`,{children:e.label}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:ic(e.amount,b)})]},e.label)),(0,G.jsxs)(`div`,{className:`${qu} pt-3 border-t border-[var(--panel-border)] font-semibold text-foreground`,children:[(0,G.jsx)(`span`,{children:`Total`}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:ic(N,b)})]})]}),(0,G.jsx)(Gu,{phone:s,address:c,wide:!0,continueLabel:P,onReady:(e,t)=>{T(e),t?.pressed&&te(e)},onEditing:()=>T(null)}),w&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(M.t,{onClick:()=>te(w),isLoading:E,disabled:E||N<=0,className:Ju,children:P}),!O&&(0,G.jsx)(`span`,{className:`text-[12.5px] text-foreground/45 leading-snug text-center`,children:E?`Opening the secure payment page…`:`Secure payment. Your card is entered on the next page.`}),O&&(0,G.jsx)(`span`,{role:`alert`,className:`text-[13px] font-semibold text-foreground/80 leading-snug`,children:O})]})]})}var Xu=new Map,Zu=new Set,Qu=new Map,$u=new Map;function ed({basket:e,orderPath:t,onPaid:n,title:i=`Thank you — your order is in`,thanks:a=`Your payment went through.`,orderLabel:o=`View your order`}){let[s,c]=(0,Y.useSearchParams)(),l=(0,Y.useNavigate)(),{user:u,loading:d}=r.Ft(),f=r.Cn(),p=s.get(`session_id`)||``,[m,h]=(0,W.useState)(null),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)(null),[x,S]=(0,W.useState)(!1),C=(0,W.useRef)(n);(0,W.useEffect)(()=>{C.current=n}),(0,W.useEffect)(()=>{if(!p.startsWith(`cs_`))return;let t=!0,n=Xu.get(p)||r.An(p);return Xu.set(p,n),n.then(n=>{if((n.paid||r.In(n))&&!Zu.has(p)){Zu.add(p),e&&g.h(e),g.h(g.p),Su();let t=Tu();if(n.paid){t&&Qu.set(p,t);try{C.current?.(n)}catch{}}}if(t){if(h(n),n.paid&&v({session:p,guest:Qu.get(p)||``}),n.error){Xu.delete(p);return}c(e=>{let t=new URLSearchParams(e);return t.delete(`session_id`),t},{replace:!0})}}),()=>{t=!1}},[p,e,c]);let w=_&&!d&&!u?_.guest:``,T=!f.loading&&f.on?.emailLink===!0,E=t||`/billing`;(0,W.useEffect)(()=>{if(!w||!T||!_)return;let e=!0,t=$u.get(_.session)||r.Wt(w,`/login?from=${encodeURIComponent(E)}`).then(()=>!0,()=>!1);return $u.set(_.session,t),t.then(t=>{e&&b(t)}),()=>{e=!1}},[w,T,_,E]);let D=x?`idle`:m?m.paid?`paid`:r.In(m)?`clearing`:`unpaid`:p.startsWith(`cs_`)?`asking`:`idle`;if(D===`idle`)return null;let O=()=>S(!0);if(D===`asking`)return(0,G.jsx)(j.t,{open:!0,onClose:O,busy:!0,size:`sm`,children:(0,G.jsx)(N.t,{block:!0,label:`Confirming your payment…`})});if(D===`clearing`)return(0,G.jsx)(j.t,{open:!0,onClose:O,size:`sm`,title:`Your payment is on its way`,footer:(0,G.jsx)(M.t,{onClick:O,className:`w-full`,children:`Done`}),children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 text-[14px] text-foreground/70 leading-relaxed`,children:[(0,G.jsx)(`p`,{children:`Your bank is still sending it, which can take a few days. Your order is in: there is nothing more to do, and please do not pay again.`}),m?.receiptLater&&m.customerEmail&&(0,G.jsxs)(`p`,{children:[`We will email a receipt to `,m.customerEmail,` once it arrives.`]})]})});if(D===`unpaid`)return(0,G.jsx)(j.t,{open:!0,onClose:O,size:`sm`,title:m?.error?`We could not check your payment just now`:`Your payment did not go through`,footer:(0,G.jsx)(M.t,{onClick:O,className:`w-full`,children:m?.error?`Close`:`Back to your basket`}),children:(0,G.jsx)(`p`,{className:`text-[14px] text-foreground/70 leading-relaxed`,children:m?.error?`${m.error} If you finished paying, your order is safe — please do not pay again.`:`Nothing was taken, and your basket is just as you left it.`})});let k=m?.amountTotal==null?``:ic(m.amountTotal,m.currency||void 0),A=m?.receipt&&m.customerEmail,ee=!w||f.loading?``:T&&y===null?`sending`:T&&y?`sent`:`sign-in`,P=`/login?email=${encodeURIComponent(w)}&from=${encodeURIComponent(E)}${ee===`sent`?`&sent=1`:``}`,te=u?E:w?P:t;return(0,G.jsx)(j.t,{open:!0,onClose:O,size:`sm`,title:i,footer:te?(0,G.jsx)(M.t,{onClick:()=>{O(),l(te)},className:`w-full`,children:o}):(0,G.jsx)(M.t,{onClick:O,className:`w-full`,children:`Done`}),children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 text-[14px] text-foreground/70 leading-relaxed`,children:[(0,G.jsxs)(`p`,{children:[a,k?` ${k} paid.`:``]}),A&&(0,G.jsxs)(`p`,{children:[`A receipt is on its way to `,m?.customerEmail,`.`]}),ee===`sending`&&(0,G.jsxs)(`p`,{children:[`Emailing a sign-in link to `,w,`…`]}),ee===`sent`&&(0,G.jsxs)(`p`,{children:[`We have emailed a sign-in link to `,w,` — open it, or sign in here, to see your order.`]}),ee===`sign-in`&&(0,G.jsxs)(`p`,{children:[T?`The sign-in link could not be emailed just now. `:``,`Sign in with `,w,` to see your order.`]})]})})}var td=e=>`${String(e.id||e.name||``).trim()}|${String(e.options||``).trim()}`,nd=e=>{let t=Math.floor(Number(e.max));return Number.isFinite(t)&&t>0?t:1/0};function rd(e){return fu(e).map(e=>{let t=nd(e);return e.quantity>t?{...e,quantity:t}:e})}function id(e,t){let[n]=rd([{...t,quantity:t.quantity??1}]);if(!n)return e;let r=td(n),i=e.findIndex(e=>td(e)===r);if(i<0)return[...e,n];let a={...e[i],...n,quantity:e[i].quantity+n.quantity};return rd(e.map((e,t)=>t===i?a:e))}function ad(e,t,n){let r=Math.floor(Number(n));return!Number.isFinite(r)||r<1?e.filter(e=>td(e)!==t):rd(e.map(e=>td(e)===t?{...e,quantity:r}:e))}var od=e=>e.variantId==null?e.variant==null?``:String(e.variant):String(e.variantId),sd=(e,t)=>{if(!t)return!0;let n=(Array.isArray(e.variants)?e.variants:[]).map(e=>e&&typeof e==`object`?e.id:void 0);return!n.length||n.some(e=>e==null||e===``)?!0:n.some(e=>String(e)===t)};function cd(e,t,n,r){if(!t)return{lines:e,gone:[]};let i=!1,a=[],o=[];for(let s of e){if(String(s.id??``)!==t||s.collection&&String(s.collection)!==r){o.push(s);continue}if(!n||!sd(n,od(s))){i=!0,a.push(String(s.name||``));continue}let e=le.t(n,od(s));if(e==null||e===Number(s.price)){o.push(s);continue}i=!0,o.push({...s,price:e})}return{lines:i?o:e,gone:a}}function ld(e,t,n,r){let i=pd(e),a=[];i.setLines(e=>{let i=cd(e,t,n,r);return a=i.gone,i.lines}),a.length&&i.setGone(a)}var ud=new Map,dd={lines:[],open:!1,gone:[]};function fd(e){try{return rd(JSON.parse(window.localStorage.getItem(g.g(e))||`[]`))}catch{return[]}}function pd(e){let t=ud.get(e);if(t)return t;let n={lines:fd(e),open:!1,gone:[]},r=new Set,i=e=>{n=e,r.forEach(e=>e())},a=t=>{t.detail===e&&i({lines:[],open:!1,gone:[]})},o=t=>{t.key===g.g(e)&&i({...n,lines:fd(e)})},s={get:()=>n,subscribe(e){return r.size||(window.addEventListener(g.m,a),window.addEventListener(`storage`,o)),r.add(e),()=>{r.delete(e),!r.size&&(window.removeEventListener(g.m,a),window.removeEventListener(`storage`,o))}},setLines(t){let r=t(n.lines);if(r!==n.lines){try{r.length?window.localStorage.setItem(g.g(e),JSON.stringify(r)):window.localStorage.removeItem(g.g(e))}catch{}i({...n,lines:r})}},setOpen(e){e!==n.open&&i({...n,open:e,gone:e?n.gone:[]})},setGone(e){let t=[...new Set([...n.gone,...e.filter(Boolean)])];t.length!==n.gone.length&&i({...n,gone:t})},added:null};return ud.set(e,s),s}function md(e,t){let n=pd(e);return n.added=t,()=>{n.added===t&&(n.added=null)}}function hd(e=`basket`){let t=pd(e),n=(0,W.useSyncExternalStore)(t.subscribe,t.get,()=>dd);return(0,W.useMemo)(()=>{let r=e=>typeof e==`string`?e:td(e);return{name:e,lines:n.lines,count:n.lines.reduce((e,t)=>e+t.quantity,0),subtotal:mu(n.lines),open:n.open,gone:n.gone,add(e,n){t.setLines(t=>id(t,e)),n?.quiet||t.setOpen(!0);try{t.added?.(e)}catch{}},setQuantity:(e,n)=>t.setLines(t=>ad(t,r(e),n)),remove:e=>t.setLines(t=>ad(t,r(e),0)),clear:()=>t.setLines(e=>e.length?[]:e),show:()=>t.setOpen(!0),hide:()=>t.setOpen(!1)}},[e,n,t])}var gd=`bag`,_d=`flex items-baseline justify-between gap-4 text-[14px]`,vd=`w-10 h-10 inline-flex items-center justify-center rounded-full text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors cursor-pointer disabled:opacity-25 disabled:cursor-default disabled:hover:bg-transparent`,yd=e=>e.length<2?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`;function bd({subtotal:e,extras:t,total:n,currency:r,count:i}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(t.length>0||i!=null)&&(0,G.jsxs)(`div`,{className:`${_d} text-foreground/55`,children:[(0,G.jsx)(`span`,{children:i==null?`Subtotal`:`${i} ${i===1?`item`:`items`}`}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:ic(e,r)})]}),t.map(e=>(0,G.jsxs)(`div`,{className:`${_d} text-foreground/55`,children:[(0,G.jsx)(`span`,{children:e.label}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:ic(e.amount,r)})]},e.label)),(0,G.jsxs)(`div`,{className:`${_d} font-semibold text-foreground`,children:[(0,G.jsx)(`span`,{children:t.length?`Total`:`Subtotal`}),(0,G.jsx)(`span`,{className:`tabular-nums text-[16px]`,children:ic(n,r)})]})]})}function xd({name:e=`basket`,formId:t,collection:n,extras:i,currency:a,phone:s,address:c,carry:u,productName:d,metadata:f,successPath:p,payLabel:m,send:h,title:_=h?`Your list`:`Your bag`,checkoutTitle:v=h?`Your details`:`Checkout`,checkoutLabel:y=h?`Send my list`:`Checkout`,emptyWords:b=h?`Your list is empty`:`Your bag is empty`,note:x,onOpenLine:S,tally:C,sentWords:w=`Sent — thank you`,onSent:E}){let D=hd(e),k=r.Rr(),A=a||k||`usd`;(0,W.useEffect)(()=>{if(C)return md(e,e=>{e.id&&su(C,String(e.id),`added`)})},[e,C]);let N=n?[...new Set(D.lines.filter(e=>e.id&&(!e.collection||e.collection===n)).map(e=>String(e.id)))].sort().join(`
|
|
19
|
-
`):``;(0,
|
|
20
|
-
`).map(t=>{try{return(0,q.onSnapshot)((0,q.doc)(r.ui,n,t),r=>{r.metadata.fromCache||ld(e,t,r.exists()?r.data():null,n)},()=>{})}catch{return()=>{}}});return()=>t.forEach(e=>e())},[e,n,N]);let{loading:ee,configured:P}=r.zn(),{userRole:te}=r.Ft(),{pathname:F,search:I}=(0,Y.useLocation)(),[L,ne]=(0,Y.useSearchParams)(),[R,z]=(0,W.useState)(`bag`),[re,ie]=(0,W.useState)(!1),B=L.get(gd);(0,W.useEffect)(()=>{B&&(D.lines.length&&(z(B===`checkout`?`checkout`:`bag`),D.show()),ne(e=>{let t=new URLSearchParams(e);return t.delete(gd),t},{replace:!0}))},[B]),(0,W.useEffect)(()=>{if(D.open)return;let e=window.setTimeout(()=>{z(`bag`),ie(!1)},300);return()=>window.clearTimeout(e)},[D.open]);let V=D.lines,ae=V.length?R:`bag`,oe=pu(i),se=hu(V,oe),ce=V.some(e=>!!e.picture),H=D.gone.length>0?(0,G.jsx)(`p`,{role:`status`,className:`text-[13px] text-foreground/55 leading-snug pb-3 mb-1 border-b border-[var(--panel-border)]`,children:`${yd(D.gone)} ${D.gone.length===1?`is`:`are`} no longer for sale, so ${D.gone.length===1?`it has`:`they have`} been taken out of your ${h?`list`:`bag`}.`}):null,le=!h&&!ee&&!P&&!o.wn(te),U=!h||V.some(e=>Number(e.price)>0);(0,W.useEffect)(()=>{V.length&&ie(!1)},[V.length]);let ue=h?{...u||{},items:fu(V),...U?{extras:oe,subtotal:D.subtotal,total:se,currency:A.toLowerCase()}:{}}:void 0,K=(()=>{let e=new URLSearchParams(I);return e.set(gd,`checkout`),`${F}?${e.toString()}`})(),J=S?e=>{D.hide(),S(e)}:null,de=ae===`bag`&&V.length>0?(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[U&&(0,G.jsx)(bd,{subtotal:D.subtotal,extras:oe,total:se,currency:A}),x&&(0,G.jsx)(`p`,{className:`text-[13px] text-foreground/50 leading-snug`,children:x}),le?(0,G.jsx)(`p`,{className:`text-[13px] text-foreground/55 leading-snug text-center`,children:`Ordering is not open yet.`}):h?(0,G.jsx)(M.t,{onClick:()=>z(`checkout`),className:`w-full py-3.5 text-[15px] font-bold tracking-wide`,children:y}):(0,G.jsx)(M.t,{onClick:()=>z(`checkout`),disabled:se<=0,className:`w-full py-3.5 text-[15px] font-bold tracking-wide`,children:`${y} · ${ic(se,A)}`})]}):void 0;return(0,G.jsxs)(j.t,{open:D.open,onClose:D.hide,side:`right`,title:ae===`checkout`?v:_,sub:ae===`checkout`?(0,G.jsxs)(`button`,{type:`button`,onClick:()=>z(`bag`),className:`inline-flex items-center gap-1.5 -ml-1 px-1 py-1 text-[13px] font-semibold text-foreground/55 hover:text-foreground transition-colors cursor-pointer`,children:[(0,G.jsx)(l.t,{className:`w-3.5 h-3.5`}),` `,h?`Back to your list`:`Back to your bag`]}):void 0,footer:de,children:[!(re&&!V.length)&&H,re&&!V.length?(0,G.jsxs)(`div`,{role:`status`,className:`flex flex-col items-center text-center gap-3 py-16`,children:[(0,G.jsx)(r.At,{className:`w-9 h-9 text-accent`,strokeWidth:1.75}),(0,G.jsx)(`p`,{className:`text-[15px] font-semibold text-foreground/80`,children:w}),(0,G.jsx)(`p`,{className:`text-[13px] text-foreground/50 leading-snug`,children:`We have your list and will be in touch.`}),(0,G.jsx)(M.t,{variant:`secondary`,onClick:D.hide,className:`mt-3`,children:`Keep looking`})]}):V.length?ae===`checkout`&&h?(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 pt-2`,children:[U?(0,G.jsx)(bd,{subtotal:D.subtotal,extras:oe,total:se,currency:A,count:D.count}):(0,G.jsx)(`p`,{className:`${_d} text-foreground/55`,children:`${D.count} ${D.count===1?`item`:`items`} on your list`}),(0,G.jsx)(g.t,{formId:t,isInline:!0,bare:!0,extra:ue,onSubmitted:(e,t)=>{ie(!0),D.clear(),E?.(e,t)}})]}):ae===`checkout`?(0,G.jsxs)(`div`,{className:`flex flex-col gap-7 pt-2`,children:[(0,G.jsx)(bd,{subtotal:D.subtotal,extras:oe,total:se,currency:A,count:D.count}),(0,G.jsx)(Yu,{formId:t,collection:n,items:V,extras:i,currency:a,phone:s,address:c,carry:u,productName:d,metadata:f,successPath:p,cancelPath:K,payLabel:m,summary:!1})]}):(0,G.jsx)(`ul`,{"aria-label":`In your bag`,className:`flex flex-col`,children:(0,G.jsx)(r.rt,{initial:!1,children:V.map(e=>{let t=td(e),n=Number(e.max)>0?Math.floor(Number(e.max)):1/0,i=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-[14.5px] font-semibold text-foreground/90 leading-snug line-clamp-2`,children:e.name}),e.options&&(0,G.jsx)(`span`,{className:`text-[13px] text-foreground/50 leading-snug truncate`,children:e.options})]});return(0,G.jsx)(r.nt.li,{layout:!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,height:0},transition:{duration:.2},className:`overflow-hidden border-b border-[var(--panel-border)] last:border-b-0`,children:(0,G.jsxs)(`div`,{className:`flex gap-4 py-4`,children:[ce&&(0,G.jsxs)(`div`,{className:`relative w-[72px] h-[72px] shrink-0 rounded-2xl overflow-hidden bg-foreground/5`,children:[e.picture&&(0,G.jsx)(r.O,{src:e.picture,alt:``,fit:`cover`,className:`absolute inset-0`}),J&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`Open ${e.name}`,onClick:()=>J(e),className:`absolute inset-0 cursor-pointer`})]}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1 flex flex-col gap-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[J?(0,G.jsx)(`button`,{type:`button`,onClick:()=>J(e),className:`min-w-0 flex flex-col gap-0.5 text-left cursor-pointer`,children:i}):(0,G.jsx)(`span`,{className:`min-w-0 flex flex-col gap-0.5`,children:i}),U&&(0,G.jsxs)(`span`,{className:`shrink-0 flex flex-col items-end leading-snug`,children:[(0,G.jsx)(`span`,{className:`text-[14.5px] tabular-nums text-foreground/85`,children:ic(e.price*e.quantity,A)}),e.quantity>1&&(0,G.jsxs)(`span`,{className:`text-[12px] tabular-nums text-foreground/45`,children:[ic(e.price,A),` each`]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 -ml-2.5 mt-0.5`,children:[(0,G.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":`One less ${e.name}`,disabled:e.quantity<=1,onClick:()=>D.setQuantity(t,e.quantity-1),className:vd,children:(0,G.jsx)(ut,{className:`w-4 h-4`})}),(0,G.jsx)(`span`,{"aria-live":`polite`,"aria-label":`${e.quantity} of ${e.name}`,className:`w-7 text-center text-[14.5px] font-semibold tabular-nums text-foreground/85`,children:e.quantity}),(0,G.jsx)(`button`,{type:`button`,"aria-label":`One more ${e.name}`,disabled:e.quantity>=n,onClick:()=>D.setQuantity(t,e.quantity+1),className:vd,children:(0,G.jsx)(T.t,{className:`w-4 h-4`})})]}),(0,G.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,onClick:()=>D.remove(t),className:`px-2 py-2 text-[13px] font-semibold text-foreground/45 hover:text-foreground transition-colors cursor-pointer`,children:`Remove`})]}),e.quantity>=n&&(0,G.jsx)(`span`,{className:`text-[12.5px] text-foreground/50 leading-snug`,children:`That is all there is of it.`})]})]})},t)})})}):(0,G.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-3 py-16`,children:[(0,G.jsx)(O.i,{className:`w-9 h-9 text-foreground/20`,strokeWidth:1.5}),(0,G.jsx)(`p`,{className:`text-[15px] font-semibold text-foreground/80`,children:b}),(0,G.jsx)(`p`,{className:`text-[13px] text-foreground/50 leading-snug`,children:`What you add waits here until you are ready.`}),(0,G.jsx)(M.t,{variant:`secondary`,onClick:D.hide,className:`mt-3`,children:`Keep looking`})]})]})}xd.displayName=`Basket`;var Sd=e=>(0,W.isValidElement)(e)&&(e.type===`svg`||/^(?:Shopping|Lucide)?(?:Bag|Basket|Cart)\w*$/.test(String(e.type.displayName||``)));function Cd({name:e=`basket`,label:t=`Bag`,className:n,children:i}){let a=hd(e),o=a.count,s=W.Children.toArray(i).filter(e=>!Sd(e));return(0,G.jsxs)(`button`,{type:`button`,onClick:a.show,"aria-label":`${t}, ${o} ${o===1?`item`:`items`}`,className:r.$(`relative inline-flex items-center justify-center gap-2 h-11 min-w-11 px-2.5 rounded-full text-foreground/75 hover:text-foreground hover:bg-foreground/5 transition-colors cursor-pointer`,n),children:[(0,G.jsx)(O.i,{className:`w-[22px] h-[22px]`,strokeWidth:1.75}),s,(0,G.jsx)(r.rt,{children:o>0&&(0,G.jsx)(r.nt.span,{initial:{scale:.6,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.6,opacity:0},transition:{duration:.18},className:`absolute top-0.5 right-0 min-w-[18px] h-[18px] px-1 inline-flex items-center justify-center rounded-full bg-accent text-[var(--button-fg,#fff)] text-[11px] font-bold tabular-nums leading-none`,children:(0,G.jsx)(r.nt.span,{initial:{scale:1.5},animate:{scale:1},transition:{duration:.2},children:o>99?`99+`:o},o)},`count`)})]})}Cd.displayName=`BasketButton`;var wd=`w-full py-3.5 text-[15px] font-bold tracking-wide`;function Td({children:e,price:t,about:n,phone:i,address:a,disabled:s=!1,variant:c=`primary`,className:l,...u}){let{loading:d,configured:f}=r.zn(),p=r.Rr(),{userRole:m}=r.Ft(),{pathname:h,search:g}=(0,Y.useLocation)(),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(null),[x,S]=(0,W.useState)(!1),[C,w]=(0,W.useState)(``);if(d)return null;if(!f)return o.wn(m)?(0,G.jsx)(`span`,{className:`text-[12.5px] font-medium text-foreground/50 leading-snug`,children:`Only admins see this: payments are not on yet, so this button is hidden. Connect Stripe and switch payments on at /payments and it appears here.`}):null;let T=u.mode===`subscription`,E=u.amount==null?u.currency:u.currency||p||`usd`,D=t?.trim()||(u.amount==null?``:ic(u.amount*(u.quantity||1),E)),O=u.productName?.trim()||(T?`Your plan`:`Your order`),k=[T?`Subscribe`:`Pay`,D].filter(Boolean).join(` · `),A=async e=>{if(x||!e)return;if(S(!0),w(``),u.amount!=null&&!u.currency&&!p&&await r.Ir()){w(r.Pr),S(!1);return}wu(e.guest?e.email:``);let t=await r.Fn({...u,...E?{currency:E}:{},metadata:{page:h,...u.metadata,...e.metadata},successPath:u.successPath||h,cancelPath:u.cancelPath||`${h}${g}`});t&&(w(t),S(!1))};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(M.t,{variant:c,className:l,disabled:s,onClick:()=>{w(``),v(!0)},children:e??(T?`Subscribe`:`Buy`)}),(0,G.jsx)(j.t,{open:_,onClose:()=>v(!1),busy:x,size:`sm`,title:O,sub:D||void 0,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-7 pt-2`,children:[n&&(0,G.jsx)(`p`,{className:`text-[14px] text-foreground/65 leading-relaxed`,children:n}),(0,G.jsx)(Gu,{phone:i,address:a,wide:!0,continueLabel:k,onReady:(e,t)=>{b(e),t?.pressed&&A(e)},onEditing:()=>b(null)}),y&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(M.t,{onClick:()=>A(y),isLoading:x,disabled:x,className:wd,children:k}),!C&&(0,G.jsx)(`span`,{className:`text-[12.5px] text-foreground/45 leading-snug text-center`,children:x?`Opening the secure payment page…`:`Secure payment. Your card is entered on the next page.`})]}),C&&(0,G.jsx)(`span`,{role:`alert`,className:`text-[13px] font-semibold text-foreground/80 leading-snug`,children:C})]})})]})}Td.displayName=`BuyButton`;var Ed=e=>/[^\d.,\s]/.test(e);function Dd(e,t=r.Lr()){let n=String(e||``).trim();if(!n)return``;if(Ed(n))return n;let i=r.br(n);return i==null?n:ic(i,t)}function Od(e,t,n,i){if(!t.on)return null;let a=r.pr(t,n).trim();if(!/^price_[A-Za-z0-9]+$/.test(a))return null;let o=Dd(t.amount,i);return{rhythm:e,priceId:a,amount:r.br(t.amount),figure:o,words:`${o} per ${e===`monthly`?`month`:`year`}`.trim()}}var kd=e=>{let t=e.split(/\r?\n/).map(e=>e.replace(/^\s*(?:[-–•*·✓]|\d+[.)])\s*/,``).trim()).filter(Boolean);return t.length>1?t:[]};function Ad(e,t,n=[],i=r.Lr()){if(!e||e.kind!==`subscription`)return[];let a=new Set(n.filter(e=>e.active&&e.priceId).map(e=>e.priceId)),o=[];for(let n of e.plans){let e=Od(`monthly`,n.monthly,t,i),r=Od(`yearly`,n.yearly,t,i);if(!e&&!r)continue;let s=n.description.trim(),c=kd(s);o.push({name:n.name.trim()||`Plan`,description:c.length?``:s,includes:c,roleId:n.roleId||``,monthly:e,yearly:r,mine:e&&a.has(e.priceId)?`monthly`:r&&a.has(r.priceId)?`yearly`:null})}return o}function jd(e){let t=e.monthly?.amount,n=e.yearly?.amount;return!t||!n||n>=t*12?0:Math.round((1-n/(t*12))*100)}function Md(e,t){let{loading:n,mode:i}=r.zn();r.Rr();let a=t||r.Lr(),o=r.Rn(),[s,c]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(e)return(0,q.onSnapshot)((0,q.doc)(r.ui,r.Qn,e),t=>c({id:e,product:t.exists()?r.Dr(t.id,t.data()):null}),()=>c({id:e,product:null}))},[e]);let l=s?.id===e?s.product:null,u=!!e&&(n||s?.id!==e||o.loading);return(0,W.useMemo)(()=>{let e=u?[]:Ad(l,i===`live`,o.subscriptions,a);return{loading:u,name:l?.name.trim()||``,description:l?.description.trim()||``,plans:e,subscribed:e.some(e=>e.mine),metadata:{},unsure:!!o.error}},[u,l,i,o.subscriptions,o.error,a])}var Nd=`text-[12.5px] font-medium text-foreground/50 leading-snug`;function Pd({product:e,featured:t,featuredLabel:n=`Recommended`,currency:i,phone:a,address:s,successPath:c,className:l}){let{loading:u,configured:d}=r.zn(),{userRole:f}=r.Ft(),p=Md(e,i),[m,h]=(0,W.useState)(null);if(p.loading||u)return(0,G.jsx)(`div`,{"aria-hidden":!0,className:r.$(`grid gap-5 sm:grid-cols-2 lg:grid-cols-3`,l),children:[0,1,2].map(e=>(0,G.jsx)(`div`,{className:`h-72 glass-panel rounded-3xl animate-pulse`},e))});let g=o.wn(f),{plans:_}=p;if(!_.length)return g?(0,G.jsx)(`span`,{className:Nd,children:`Only admins see this: this subscription has no finished plan yet, so there is nothing to show here. Finish it at /payments and it appears.`}):null;let v=_.some(e=>e.monthly&&e.yearly),y=_.find(e=>e.mine)?.mine||null,b=m||y||`monthly`,x=Math.max(0,..._.map(jd)),S=t?.trim().toLowerCase()||``;return(0,G.jsxs)(`div`,{className:r.$(`flex flex-col items-center gap-10 w-full`,l),children:[!d&&g&&(0,G.jsx)(`span`,{className:Nd,children:`Only admins see this: payments are not on yet, so the buttons are hidden. Connect Stripe and switch payments on at /payments and they appear here.`}),v&&(0,G.jsx)(`div`,{role:`group`,"aria-label":`How often you pay`,className:`inline-flex items-center p-1 rounded-full glass-panel`,children:[`monthly`,`yearly`].map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-pressed":b===e,onClick:()=>h(e),className:r.$(`h-10 px-5 rounded-full text-[14px] font-semibold transition-colors cursor-pointer`,b===e?`bg-accent text-[var(--button-fg,#fff)] shadow-sm`:`text-foreground/55 hover:text-foreground`),children:e===`monthly`?`Monthly`:x?`Yearly · save ${x}%`:`Yearly`},e))}),(0,G.jsx)(`div`,{className:r.$(`grid gap-5 w-full`,_.length===1?`max-w-md`:_.length===2?`sm:grid-cols-2 max-w-3xl`:`sm:grid-cols-2 lg:grid-cols-3`),children:_.map((e,t)=>{let i=e[b]||e.monthly||e.yearly;if(!i)return null;let o=!!S&&e.name.toLowerCase()===S,l=i.rhythm===`yearly`?jd(e):0;return(0,G.jsxs)(r.nt.div,{initial:{opacity:0,y:14},animate:{opacity:1,y:0},transition:{duration:.35,delay:t*.06,ease:[.16,1,.3,1]},className:r.$(`relative flex flex-col gap-7 p-7 sm:p-8 rounded-3xl glass-panel text-left`,o&&`ring-1 ring-accent/70`),children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 min-h-6`,children:[(0,G.jsx)(`h3`,{className:`text-[15px] font-bold tracking-tight text-foreground/75`,children:e.name}),e.mine?(0,G.jsx)(`span`,{className:`px-2.5 py-1 rounded-full bg-foreground/10 text-[11.5px] font-bold text-foreground/70`,children:`Your plan`}):o?(0,G.jsx)(`span`,{className:`px-2.5 py-1 rounded-full bg-accent/15 text-[11.5px] font-bold text-accent`,children:n}):null]}),(0,G.jsxs)(`p`,{className:`flex items-baseline gap-2 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`text-4xl font-bold tracking-tight text-foreground tabular-nums`,children:i.figure}),(0,G.jsxs)(`span`,{className:`text-[14px] font-medium text-foreground/50`,children:[`per `,i.rhythm===`monthly`?`month`:`year`]})]}),l>0&&(0,G.jsxs)(`p`,{className:`text-[13px] text-foreground/55 -mt-2`,children:[l,`% less than paying monthly.`]}),e.description&&(0,G.jsx)(`p`,{className:`text-[14px] text-foreground/65 leading-relaxed`,children:e.description})]}),e.includes.length>0&&(0,G.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.includes.map(e=>(0,G.jsxs)(`li`,{className:`flex items-start gap-3 text-[14px] text-foreground/75 leading-snug`,children:[(0,G.jsx)(r.At,{className:`w-4 h-4 mt-0.5 shrink-0 text-accent`,strokeWidth:2.5}),(0,G.jsx)(`span`,{children:e})]},e))}),(0,G.jsx)(`div`,{className:`mt-auto flex flex-col`,children:p.subscribed?(0,G.jsx)(H.t,{variant:e.mine?`secondary`:`primary`,className:`w-full py-3 text-[14.5px] font-bold`,children:e.mine?`Manage your plan`:`Switch to ${e.name}`}):d&&p.unsure?(0,G.jsx)(`span`,{className:Nd,children:`Your current plan could not be checked just now. Try again in a moment.`}):d?(0,G.jsx)(Td,{priceId:i.priceId,mode:`subscription`,productName:p.name?`${p.name} — ${e.name}`:e.name,price:i.words,about:e.description||void 0,phone:a,address:s,successPath:c,metadata:{...p.metadata,plan:e.name,billed:i.rhythm},variant:o||_.length===1?`primary`:`secondary`,className:`w-full py-3 text-[14.5px] font-bold`,children:`Choose ${e.name}`}):null})]},e.name)})})]})}Pd.displayName=`Plans`;var Fd=Object.assign({}),Id={};for(let e in Fd){let t=Fd[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();Id[r]=t.default,Id[r.replace(/_/g,``)]=t.default}if(typeof window<`u`){let e=window.__FBOS_MICROCOMPONENTS__||{};window.__FBOS_MICROCOMPONENTS__={...Id,...e}}var Ld=(e,t)=>{let n=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=n.replace(/_/g,``);if(Id[n]=t,Id[r]=t,typeof window<`u`){let e=window.__FBOS_MICROCOMPONENTS__||{};window.__FBOS_MICROCOMPONENTS__={...e,[n]:t,[r]:t}}},Rd=({title:e,className:t,children:n,...i})=>(0,G.jsxs)(`div`,{className:r.$(`border border-[var(--panel-border)] bg-[var(--panel-bg)] px-5 py-4`,t),style:{borderRadius:`var(--card-radius, 1rem)`},...i,children:[e?(0,G.jsx)(`p`,{className:`text-[12px] font-extrabold tracking-tight text-gradient mb-1.5`,children:e}):null,n]});Rd.displayName=`Card`;var zd=({sub:e,className:t,children:n,...i})=>(0,G.jsxs)(`div`,{className:r.$(`mb-4`,t),children:[(0,G.jsx)(`h2`,{className:`text-xl md:text-2xl font-bold tracking-tight text-foreground`,...i,children:n}),e?(0,G.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed mt-1`,children:e}):null]});zd.displayName=`SectionHeading`;var Bd=`button, a, input, textarea, select, label, [role="button"], [role="listbox"], [role="option"]`,Vd=`[&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!p-0 [&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!m-0 [&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!border-0 [&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!rounded-none [&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!bg-transparent [&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!shadow-none`,Hd=`flex h-8 w-6 shrink-0 items-center justify-center rounded-md text-foreground/40 transition-[opacity,color,background-color] duration-150 hover:bg-foreground/[0.07] hover:text-foreground/80 [@media(hover:hover)]:opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`;function Ud({stages:e,items:t,stageOf:n,keyOf:i,card:a,onMove:o,onOpen:s,canMove:c,loading:l=!1,empty:u=`Nothing here yet`,className:d}){let f=(0,W.useRef)(null),p=e=>i?i(e):String(e.id??``),m=e[0]?.id??``,h=t=>e.some(e=>e.id===t)?t:m,[g,_]=(0,W.useState)({}),[v,y]=(0,W.useState)(null),b=(0,W.useRef)(null),x=e=>{b.current=e,y(e)},S=(0,W.useMemo)(()=>new Map(t.map(e=>[p(e),e])),[t]);(0,W.useEffect)(()=>{let e=Object.entries(g).filter(([e,t])=>{let r=S.get(e);return!r||t.settled&&h(n(r))===t.stage});e.length&&_(t=>{let n={...t};for(let[t]of e)delete n[t];return n})},[g,S]);let C=(0,W.useMemo)(()=>{let r=new Map(e.map(e=>[e.id,[]]));for(let e of t)g[p(e)]||r.get(h(n(e)))?.push(e);for(let[e,t]of Object.entries(g)){let n=S.get(e),i=r.get(t.stage);n&&i&&i.splice(Math.min(t.index,i.length),0,n)}return r},[t,g,e]),w=(e,t,i)=>{let a=p(e),s=h(n(e));if(t===s&&i===(C.get(s)||[]).findIndex(e=>p(e)===a)||c&&t!==s&&!c(e,t))return;_(e=>({...e,[a]:{stage:t,index:i,settled:!1}}));let l=()=>_(e=>e[a]?{...e,[a]:{...e[a],settled:!0}}:e),u=()=>_(e=>{let t={...e};return delete t[a],t}),d;try{d=o(e,t,i)}catch(e){u(),O.n(r.ii(e,`That could not be moved.`));return}d&&typeof d.then==`function`?d.then(()=>{l(),setTimeout(u,1500)},e=>{u(),O.n(r.ii(e,`That could not be moved.`))}):(l(),setTimeout(u,5e3))},{dragging:T,bind:E}=so({disabled:l,scroller:()=>f.current,onMove:({x:e,y:t},r)=>{let i=f.current,a=S.get(r);if(!i||!a)return;let o=Array.from(i.querySelectorAll(`[data-pipeline-stage]`)),s=null,l=1/0;for(let t of o){let n=t.getBoundingClientRect(),r=e<n.left?n.left-e:e>n.right?e-n.right:0;r<l&&(l=r,s=t)}let u=s?.dataset.pipelineStage;if(!s||!u){x(null);return}if(c&&u!==h(n(a))&&!c(a,u)){x(null);return}let d=Array.from(s.querySelectorAll(`[data-drag-key]`)).filter(e=>e.dataset.dragKey!==r).filter(e=>{let n=e.getBoundingClientRect();return t>n.top+n.height/2}).length,p=b.current;(!p||p.stage!==u||p.index!==d)&&x({stage:u,index:d})},onDrop:e=>{let t=S.get(e),n=b.current;x(null),t&&n&&w(t,n.stage,n.index)},onCancel:()=>x(null)}),D=T?S.get(T.key):void 0,k=`rounded-xl border border-[var(--panel-border)] bg-[var(--panel-bg)] p-3 text-left`,A=e=>t=>{let n=t.target.closest?.(Bd);n&&n!==t.currentTarget||s?.(e)},j=e=>t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),s?.(e))};return(0,G.jsxs)(`div`,{ref:f,className:r.$(`flex w-full items-start gap-3 overflow-x-auto pb-3 md:gap-4`,T?`snap-none`:`snap-x snap-mandatory sm:snap-none`,d),children:[e.map(t=>{let i=C.get(t.id)||[],o=T?i.findIndex(e=>p(e)===T.key):-1,d=!!T&&v?.stage===t.id,f=d&&o>-1&&v.index===o,m=d&&T&&!f?(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`rounded-xl border-2 border-dashed border-accent/50 bg-accent/5`,style:{height:T.height}},`__slot`):null,g=i.map(t=>{let i=p(t),o=h(n(t)),l=e.filter(e=>e.id===o||!c||c(t,e.id));return(0,G.jsxs)(`div`,{...E(i),...s?{role:`button`,tabIndex:0,"data-drag-ok":``,onClick:A(t),onKeyDown:j(t)}:{"data-drag-ok":``},className:r.$(k,`group relative cursor-grab transition-[border-color,box-shadow,opacity] duration-200 hover:border-accent/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,T?.key===i&&`opacity-30`),children:[(0,G.jsx)(`div`,{className:r.$(`min-w-0`,Vd),children:a(t)}),(0,G.jsxs)(`div`,{className:`-mb-1.5 mt-2.5 flex items-center justify-between gap-2 border-t border-[var(--panel-border)] pt-1.5`,children:[l.length>1?(0,G.jsx)(`div`,{className:`-ml-2 flex min-w-0 items-center [&_[role=button]]:!h-8 [&_[role=button]]:!px-2`,"data-no-drag":``,children:(0,G.jsx)(r.Z,{compact:!0,portal:!0,direction:`auto`,variant:`ghost`,ariaLabel:`Move to another stage`,value:o,options:l.map(e=>({value:e.id,label:e.label})),onChange:e=>{e!==o&&w(t,e,0)}})}):(0,G.jsx)(`span`,{className:`min-w-0 truncate py-1.5 text-[12.5px] font-semibold leading-5 text-foreground/60`,children:e.find(e=>e.id===o)?.label}),(0,G.jsx)(`span`,{...co,"aria-hidden":`true`,"data-pipeline-grip":``,className:r.$(Hd,`-mr-1.5`),children:(0,G.jsx)(nt,{className:`h-4 w-4`})})]})]},i)});if(m){let e=v.index;g.splice(Math.min(o>-1&&e>o?e+1:e,g.length),0,m)}return(0,G.jsxs)(`section`,{"data-pipeline-stage":t.id,"aria-label":t.label,className:r.$(`flex w-[84%] shrink-0 snap-start flex-col rounded-2xl border p-3 transition-colors duration-200 sm:w-auto sm:min-w-[15rem] sm:flex-1`,d?`border-accent/60 bg-accent/5`:`border-[var(--panel-border)] bg-background/40`),children:[(0,G.jsxs)(`header`,{className:`mb-3 flex items-center justify-between gap-2 px-1`,children:[(0,G.jsx)(`h3`,{className:`truncate text-sm font-bold text-foreground`,children:t.label}),!l&&(0,G.jsx)(`span`,{className:`flex h-6 min-w-6 items-center justify-center rounded-full border border-[var(--panel-border)] px-1.5 text-xs font-bold text-foreground/70`,children:i.length})]}),t.hint&&(0,G.jsx)(`p`,{className:`-mt-2 mb-3 px-1 text-xs leading-snug text-foreground/50`,children:t.hint}),(0,G.jsx)(`div`,{className:`flex min-h-16 flex-col gap-2.5`,children:l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(N.n,{className:`h-24 rounded-xl`}),(0,G.jsx)(N.n,{className:`h-24 rounded-xl`})]}):g.length?g:(0,G.jsx)(`div`,{className:r.$(`rounded-xl border border-dashed border-[var(--panel-border)] px-3 py-5 text-center text-xs text-foreground/40`,Vd),children:u})})]},t.id)}),T&&D!==void 0&&typeof document<`u`&&(0,de.createPortal)((0,G.jsx)(`div`,{"aria-hidden":`true`,"data-pipeline-ghost":``,className:`pointer-events-none fixed z-[9995] rotate-[1.5deg] rounded-xl bg-background opacity-95 shadow-2xl`,style:{left:T.x-T.offsetX,top:T.y-T.offsetY,width:T.width},children:(0,G.jsx)(`div`,{className:k,children:(0,G.jsx)(`div`,{className:r.$(`min-w-0`,Vd),children:a(D)})})}),document.body)]})}Ud.displayName=`Pipeline`;var Wd=new WeakMap,Gd=0,Kd=e=>{let t=Wd.get(e);return t||(t=`\u0000item${++Gd}`,Wd.set(e,t)),t},qd=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]);function Jd({items:e,keyOf:t,item:n,onReorder:i,label:a,grip:o,disabled:s=!1,className:c}){let l=(0,W.useRef)(null),u=e=>{if(t)return String(t(e)??``);if(typeof e==`string`||typeof e==`number`)return String(e);let n=e?.id;return n!=null&&n!==``?String(n):e&&typeof e==`object`?Kd(e):``},d=(o??(/\b(?:grid|columns-\d)/.test(c||``)?`corner`:`end`))===`corner`,f=new Map,p=e.map(e=>{let t=u(e),n=f.get(t)??0;return f.set(t,n+1),n===0?t:`${t}\u0000${n}`}),m=new Map(e.map((e,t)=>[p[t],e])),h=p.join(`\0`),[g,_]=(0,W.useState)(null),v=(0,W.useRef)(null),y=e=>{v.current=e,_(e?{keys:e,from:h}:null)},b=(0,W.useRef)(0),x=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=x.current;e&&(x.current=null,l.current?.querySelector(`[data-drag-key="${CSS.escape(e)}"] [data-drag-handle]`)?.focus())});let S=()=>Array.from(l.current?.querySelectorAll(`:scope > [data-drag-key]`)||[]).map(e=>e.dataset.dragKey||``),C=e=>{if(qd(e,p)){y(null);return}y(e);let t=()=>{v.current===e&&y(null)},n;try{n=i(e.map(e=>m.get(e)))}catch(e){t(),O.n(r.ii(e,`The new order could not be saved.`));return}n&&typeof n.then==`function`?n.then(()=>setTimeout(t,1500),e=>{t(),O.n(r.ii(e,`The new order could not be saved.`))}):setTimeout(t,3e3)},{dragging:w,bind:T}=so({disabled:s,onStart:()=>y(S()),onMove:({x:e,y:t,at:n},r)=>{let i=l.current;if(!i||n<b.current)return;let a=null,o=1/0;for(let n of Array.from(i.querySelectorAll(`:scope > [data-drag-key]`))){let r=n.getBoundingClientRect(),i=Math.hypot(e-(r.left+r.width/2),t-(r.top+r.height/2));i<o&&(o=i,a=n.dataset.dragKey||null)}let s=v.current||S();if(!a||a===r)return;let c=s.filter(e=>e!==r);c.splice(s.indexOf(a),0,r),b.current=n+140,y(c)},onDrop:()=>C(v.current||S()),onCancel:()=>y(null)}),E=g&&(w||g.from===h)?g.keys:null,D=(E||p).filter(e=>m.has(e));for(let e of p)D.includes(e)||D.push(e);let k=e=>t=>{let n=t.key===`ArrowUp`||t.key===`ArrowLeft`?-1:+(t.key===`ArrowDown`||t.key===`ArrowRight`);if(!n)return;t.preventDefault();let r=D.indexOf(e),i=r+n;if(i<0||i>=D.length)return;let a=[...D];a.splice(r,1),a.splice(i,0,e),x.current=e,C(a)},A=w?m.get(w.key):void 0;return(0,G.jsxs)(`div`,{ref:l,className:r.$(c||`flex flex-col gap-2`),children:[D.map((e,t)=>{let i=m.get(e),o=a?a(i,t):`item ${t+1} of ${D.length}`,c=s?null:(0,G.jsx)(`button`,{type:`button`,...co,onKeyDown:k(e),"aria-label":`Move ${o} — drag, or use the arrow keys`,className:r.$(`flex h-10 w-8 shrink-0 items-center justify-center rounded-lg text-foreground/40 transition-colors hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,d&&`absolute right-1.5 top-1.5 w-10 border border-[var(--panel-border)] bg-background/80 text-foreground/70 backdrop-blur-sm`),children:(0,G.jsx)(nt,{className:`h-4 w-4`,"aria-hidden":`true`})});return(0,G.jsxs)(r.nt.div,{layout:!!w||!!E,transition:{type:`spring`,stiffness:500,damping:40},...T(e),className:r.$(`relative min-w-0`,!d&&`flex items-center gap-2`,!s&&`cursor-grab`,w?.key===e&&`opacity-30`),children:[d?n(i,t):(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:n(i,t)}),c]},e)}),w&&A!==void 0&&typeof document<`u`&&(0,de.createPortal)((0,G.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none fixed z-[9995] rotate-[1.5deg] opacity-95 shadow-2xl`,style:{left:w.x-w.offsetX,top:w.y-w.offsetY,width:w.width},children:d?n(A,D.indexOf(w.key)):(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:n(A,D.indexOf(w.key))}),(0,G.jsx)(`span`,{className:`w-8 shrink-0`})]})}),document.body)]})}Jd.displayName=`Sortable`;var Yd=`button, a, input, textarea, select, label, [role="button"], [role="listbox"], [role="option"]`,Xd=e=>{if(e==null||e===``)return null;if(e instanceof Date)return e.getTime();if(typeof e==`boolean`)return+!!e;let t=e;return typeof t.toMillis==`function`?t.toMillis():e},Zd=e=>{if(e==null)return``;if(e instanceof Date)return e.toLocaleDateString();let t=e;return typeof t.toDate==`function`?t.toDate().toLocaleDateString():String(e)},Qd=`(min-width: 768px)`;function $d(){let[e,t]=(0,W.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia(Qd).matches);return(0,W.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(Qd),n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function ef({rows:e,columns:t,keyOf:n,onOpen:i,actions:a,loading:o=!1,empty:s=`Nothing here yet`,search:c=!1,sort:l,className:u}){let d=(e,t)=>n?n(e):String(e.id??t),[f,p]=(0,W.useState)(l?{key:l.key,dir:l.dir||`asc`}:null),[m,h]=(0,W.useState)(``),g=$d(),_=(0,W.useMemo)(()=>{let n=m.trim().toLowerCase(),r=n?e.filter(e=>t.some(t=>t.value&&Zd(t.value(e)).toLowerCase().includes(n))):e,i=f&&t.find(e=>e.key===f.key);if(i&&i.value){let e=i.value,t=f.dir===`asc`?1:-1;r=[...r].sort((n,r)=>{let i=Xd(e(n)),a=Xd(e(r));return i===null||a===null?i===a?0:i===null?1:-1:typeof i==`number`&&typeof a==`number`?(i-a)*t:String(i).localeCompare(String(a),void 0,{numeric:!0,sensitivity:`base`})*t})}return r},[e,t,f,m]),v=e=>p(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`}),y=(e,t)=>e.cell?e.cell(t):e.value?Zd(e.value(t)):null,b=e=>t=>{let n=t.target.closest?.(Yd);n&&n!==t.currentTarget||i?.(e)},x=e=>t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i?.(e))},[S,...w]=t,T=w.find(e=>e.align===`right`&&e.phone!==!1),E=w.filter(e=>e!==T&&e.phone!==!1),D=!o&&_.length===0,O=m.trim()&&e.length?`Nothing matches “${m.trim()}”`:s;return(0,G.jsxs)(`div`,{className:r.$(`w-full`,u),children:[c&&(0,G.jsxs)(`label`,{className:`relative mb-4 flex w-full items-center sm:max-w-xs`,children:[(0,G.jsx)(C.n,{className:`pointer-events-none absolute left-3.5 z-10 h-4 w-4 text-foreground/40`,"aria-hidden":`true`}),(0,G.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:typeof c==`string`?c:`Search`,"aria-label":typeof c==`string`?c:`Search`,className:`glass-panel glow-focus block h-11 w-full pl-10 pr-4 text-sm text-foreground placeholder:text-foreground/40 focus:border-accent focus:outline-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}})]}),g&&(0,G.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-[var(--panel-border)] bg-background/30`,children:(0,G.jsxs)(`table`,{className:`w-full border-collapse text-left text-sm`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)] bg-background/50`,children:[t.map(e=>{let t=!!e.value&&e.sortable!==!1,n=f?.key===e.key?f.dir:null;return(0,G.jsx)(`th`,{scope:`col`,"aria-sort":n===`asc`?`ascending`:n===`desc`?`descending`:void 0,className:r.$(`px-4 py-3 text-xs font-semibold uppercase tracking-wide text-foreground/50`,e.align===`right`&&`text-right`),children:t?(0,G.jsxs)(`button`,{type:`button`,onClick:()=>v(e.key),className:r.$(`inline-flex items-center gap-1 uppercase tracking-wide transition-colors hover:text-foreground focus:outline-none focus-visible:text-foreground`,n&&`text-foreground`),children:[e.label,n===`asc`&&(0,G.jsx)(r.jt,{className:`h-3 w-3`,"aria-hidden":`true`}),n===`desc`&&(0,G.jsx)(r.Mt,{className:`h-3 w-3`,"aria-hidden":`true`})]}):e.label},e.key)}),a&&(0,G.jsx)(`th`,{scope:`col`,className:`px-4 py-3`,children:(0,G.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,G.jsxs)(`tbody`,{className:`divide-y divide-[var(--panel-border)]`,children:[o&&[0,1,2,3].map(e=>(0,G.jsxs)(`tr`,{children:[t.map(e=>(0,G.jsx)(`td`,{className:`px-4 py-3.5`,children:(0,G.jsx)(N.n,{className:`h-4 w-3/4 rounded-md`})},e.key)),a&&(0,G.jsx)(`td`,{className:`px-4 py-3.5`})]},e)),D&&(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:t.length+ +!!a,className:`px-4 py-12 text-center text-sm text-foreground/50`,children:O})}),!o&&_.map((e,n)=>(0,G.jsxs)(`tr`,{onClick:i?b(e):void 0,className:r.$(`transition-colors`,i&&`cursor-pointer hover:bg-foreground/[0.03]`),children:[t.map((t,n)=>(0,G.jsx)(`td`,{className:r.$(`px-4 py-3.5 align-middle text-foreground/80`,t.align===`right`&&`text-right tabular-nums`,n===0&&`font-semibold text-foreground`),children:n===0&&i?(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`text-left font-semibold hover:underline focus:outline-none focus-visible:underline`,children:y(t,e)}):y(t,e)},t.key)),a&&(0,G.jsx)(`td`,{className:`px-4 py-2.5 text-right`,children:(0,G.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:a(e)})})]},d(e,n)))]})]})}),!g&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[o&&[0,1,2].map(e=>(0,G.jsx)(N.n,{className:`h-24`},e)),D&&(0,G.jsx)(`p`,{className:`rounded-2xl border border-dashed border-[var(--panel-border)] px-4 py-10 text-center text-sm text-foreground/50`,children:O}),!o&&_.map((e,t)=>(0,G.jsxs)(`div`,{...i?{role:`button`,tabIndex:0,onClick:b(e),onKeyDown:x(e)}:{},className:r.$(`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] p-4 text-left`,i&&`cursor-pointer transition-colors hover:border-accent/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsx)(`div`,{className:`min-w-0 text-[15px] font-semibold text-foreground`,children:S?y(S,e):null}),T&&(0,G.jsx)(`div`,{className:`shrink-0 text-[15px] font-semibold tabular-nums text-foreground`,children:y(T,e)})]}),E.length>0&&(0,G.jsx)(`dl`,{className:`mt-2.5 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-sm`,children:E.map(t=>(0,G.jsxs)(`div`,{className:`contents`,children:[(0,G.jsx)(`dt`,{className:`text-foreground/50`,children:t.label}),(0,G.jsx)(`dd`,{className:`min-w-0 text-right text-foreground/80`,children:y(t,e)})]},t.key))}),a&&(0,G.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 border-t border-[var(--panel-border)] pt-3`,children:a(e)})]},d(e,t)))]})]})}ef.displayName=`DataTable`;var tf=/^(?:mem|admin|role_[a-z][a-z0-9]*)_[A-Za-z0-9_]+$/,nf=e=>tf.test(String(e||``))&&!/_history$/.test(e)?`${e}_history`:null,rf=e=>e==null||e===``?void 0:String(e);function af(e,t,n={},r=null,i=Date.now()){let a=Ti(r),o=!!n.by?.name,s={recordId:String(e),what:String(t||``).trim(),creatorName:o?String(n.by.name):a.creatorName||`Somebody`,creatorAvatar:o?String(n.by.avatar||``):a.creatorAvatar,uid:r?.uid||``,createdAt:o&&Number.isFinite(n.at)&&n.at>0?n.at:i},c=rf(n.from),l=rf(n.to);return c!==void 0&&(s.from=c),l!==void 0&&(s.to=l),s}async function of(e,t,n,i={}){let a=nf(e);if(!a||!t||!String(n||``).trim()){console.error(`logHistory('${e}', '${t}', '${n}'): a history line needs the record's own collection (mem_, admin_ or role_<id>_ — never an admin_ one when the team makes the changes), the record's id, and what was done.`);return}try{await(0,q.addDoc)((0,q.collection)(r.ui,a),af(t,n,i,r.li?.currentUser||null))}catch(e){console.warn(`logHistory: the line "${n}" could not be saved — ${r.ii(e,`the database refused it.`)}`)}}function sf(e,t){let n=nf(e),i=String(t||``),[a,o]=(0,W.useState)({loading:!0,error:null,lines:[]});return(0,W.useEffect)(()=>{if(!n||!i){o({loading:!1,error:null,lines:[]});return}return o({loading:!0,error:null,lines:[]}),(0,q.onSnapshot)((0,q.query)((0,q.collection)(r.ui,n),(0,q.where)(`recordId`,`==`,i)),e=>{let t=e.docs.map(e=>({...e.data()||{},id:e.id}));t.sort((e,t)=>Number(t.createdAt||0)-Number(e.createdAt||0)),o({loading:!1,error:null,lines:t})},e=>o({loading:!1,error:r.ii(e,`The history could not be read.`),lines:[]}))},[n,i]),a}var cf=e=>{if(!e)return 0;if(typeof e==`number`)return e;if(e instanceof Date)return e.getTime();let t=e;if(typeof t.toMillis==`function`)return t.toMillis();if(typeof t.seconds==`number`)return t.seconds*1e3;let n=Date.parse(String(e));return Number.isFinite(n)?n:0},lf=(e,t)=>`${e} ${t}${e===1?``:`s`} ago`,uf=(e,t=Date.now())=>{let n=cf(e);if(!n)return``;let r=Math.floor(Math.max(0,t-n)/6e4);if(r<1)return`just now`;if(r<60)return lf(r,`minute`);let i=Math.floor(r/60);if(i<24)return lf(i,`hour`);let a=Math.floor(i/24);return a===1?`yesterday`:a<7?lf(a,`day`):new Date(n).toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})},df=(e,t=!1)=>{if(!e)return null;if(t){let t=String(e.editedName||``).trim();return t?{name:t,avatar:String(e.editedAvatar||``),at:e.editedAt}:null}let n=String(e.creatorName||``).trim()||String(e.creatorEmail||``).split(`@`)[0];return n?{name:n,avatar:String(e.creatorAvatar||``),at:e.createdAt}:null},ff=e=>e.split(/\s+/).filter(Boolean).map(e=>e[0]).join(``).toUpperCase().slice(0,2);function pf({name:e,avatar:t,size:n=`sm`}){let i=n===`md`?`w-7 h-7 text-[10px]`:`w-5 h-5 text-[8px]`;return t?(0,G.jsx)(r.O,{src:t,alt:``,className:r.$(i,`rounded-full shrink-0`)}):(0,G.jsx)(`span`,{"aria-hidden":`true`,className:r.$(i,`rounded-full bg-accent/15 text-accent flex items-center justify-center font-extrabold shrink-0`),children:ff(e)})}function mf({record:e,edited:t=!1,label:n,noTime:i=!1,size:a=`sm`,className:o}){let s=df(e,t);if(!s)return null;let c=n??(t?`Edited by`:``),l=i?``:uf(s.at);return(0,G.jsxs)(`span`,{className:r.$(`inline-flex items-center gap-2 min-w-0 max-w-full align-middle`,o),children:[(0,G.jsx)(pf,{name:s.name,avatar:s.avatar,size:a}),(0,G.jsxs)(`span`,{className:r.$(`truncate font-semibold text-foreground/55`,a===`md`?`text-[13px]`:`text-[11px]`),children:[c&&(0,G.jsxs)(`span`,{className:`font-medium text-foreground/40`,children:[c,` `]}),s.name,l&&(0,G.jsxs)(`span`,{className:`font-medium text-foreground/35`,children:[` · `,l]})]})]})}var hf=e=>{let t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1),i=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return i(t,n)?`Today`:i(t,r)?`Yesterday`:t.toLocaleDateString(void 0,{day:`numeric`,month:`long`,year:t.getFullYear()===n.getFullYear()?void 0:`numeric`})};function gf(e){let t=[];for(let n of e){let e=hf(Number(n.createdAt||0)),r=t[t.length-1];r&&r.day===e?r.lines.push(n):t.push({day:e,lines:[n]})}return t}function _f({collection:e,of:t,empty:n=`Nothing has happened to this yet.`,max:i,className:a}){let{loading:o,error:s,lines:c}=sf(e,t);return o?(0,G.jsx)(`div`,{className:r.$(`py-6 flex justify-center`,a),children:(0,G.jsx)(N.t,{})}):s?(0,G.jsx)(`p`,{className:r.$(`text-[14px] text-foreground/60`,a),children:s}):c.length?(0,G.jsx)(`div`,{className:r.$(`flex flex-col gap-6`,a),children:gf(i?c.slice(0,i):c).map(e=>(0,G.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`h4`,{className:`text-[12px] font-semibold text-foreground/40 mb-1`,children:e.day}),(0,G.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--panel-border)]`,children:e.lines.map(e=>(0,G.jsxs)(`li`,{className:`py-3 flex flex-col gap-1.5 min-w-0`,children:[(0,G.jsxs)(`p`,{className:`text-[14px] text-foreground leading-snug break-words`,children:[e.what,(e.from!==void 0||e.to!==void 0)&&(0,G.jsxs)(`span`,{className:`text-foreground/55`,children:[`: `,e.from!==void 0&&(0,G.jsx)(`span`,{children:e.from}),e.from!==void 0&&e.to!==void 0&&(0,G.jsx)(u.t,{className:`inline w-3.5 h-3.5 mx-1.5 -mt-0.5`,"aria-label":`to`}),e.to!==void 0&&(0,G.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.to})]})]}),(0,G.jsx)(mf,{record:e})]},e.id))})]},e.day))}):(0,G.jsx)(`p`,{className:r.$(`text-[14px] text-foreground/45`,a),children:n})}var vf=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function yf(e){let t=String(e??``).trim().toLowerCase(),n=t.startsWith(`#`)?t:`#${t}`;return vf.test(n)?n.length===4?`#${n[1]}${n[1]}${n[2]}${n[2]}${n[3]}${n[3]}`:n:``}function bf(e){let t=Array.isArray(e)?e:e?[e]:[],n=[];for(let e of t){let t=yf(e);t&&!n.includes(t)&&n.push(t)}return n}var xf={sm:`w-5 h-5`,md:`w-7 h-7`,lg:`w-10 h-10`},Sf=`shadow-[inset_0_0_0_2px_var(--bg-color),inset_0_0_0_4px_var(--fg-color)]`;function Cf({color:e,name:t,size:n=`md`,selected:i,onClick:a,className:o}){let s=yf(e),c=t||s||`No colour`,l=r.$(`inline-block rounded-full shrink-0 border border-foreground/20 transition-shadow`,xf[n],i&&Sf,o);return a?(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},"aria-label":c,"aria-pressed":!!i,title:c,className:r.$(l,`cursor-pointer hover:border-foreground/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),style:{backgroundColor:s||void 0}}):(0,G.jsx)(`span`,{role:`img`,"aria-label":c,title:c,"data-swatch":``,className:l,style:{backgroundColor:s||void 0}})}function wf({color:e,onPicked:t,label:n,title:i,className:a,children:o}){let s=(0,W.useRef)(null),[c,l]=(0,W.useState)(e),u=(0,W.useRef)(t);return(0,W.useEffect)(()=>{u.current=t}),(0,W.useEffect)(()=>{l(e)},[e]),(0,W.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>u.current(e.value);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,G.jsxs)(`label`,{className:r.$(`relative inline-flex items-center justify-center cursor-pointer`,a),title:i,children:[o,(0,G.jsx)(`input`,{type:`color`,value:c,"aria-label":n,ref:s,onChange:e=>l(e.target.value),className:`absolute inset-0 w-full h-full opacity-0 cursor-pointer`})]})}function Tf({label:e,value:t,onChange:n,multiple:i,max:a=12,error:o,disabled:s}){let c=(0,W.useId)(),l=bf(t),[u,d]=(0,W.useState)(``),f=i?l.length>=a:!1,p=e=>n(i?e:e[0]||``),m=e=>{let t=yf(e);t&&(p(i?l.includes(t)?l:[...l,t].slice(0,a):[t]),d(``))},h=yf(u),g=(e,t)=>{let n=yf(t);!n||n===e||p(l.includes(n)?l.filter(t=>t!==e):l.map(t=>t===e?n:t))};return(0,G.jsxs)(`div`,{className:`flex flex-col w-full`,children:[e&&(0,G.jsx)(`span`,{id:`${c}-label`,className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:e}),(0,G.jsxs)(`div`,{role:`group`,"aria-labelledby":e?`${c}-label`:void 0,className:r.$(`glass-panel flex flex-wrap items-center gap-3 px-4 py-3`,o&&`border-red-500/50`,s&&`opacity-50 pointer-events-none`),style:{borderRadius:`var(--input-radius, 0.75rem)`},children:[l.map(e=>(0,G.jsxs)(`span`,{className:`relative inline-flex group`,children:[(0,G.jsx)(wf,{color:e,onPicked:t=>g(e,t),label:`Change ${e}`,title:`${e} — press to change it`,className:`rounded-full`,children:(0,G.jsx)(Cf,{color:e,size:`lg`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(l.filter(t=>t!==e)),"aria-label":`Remove ${e}`,className:`absolute -top-1.5 -right-1.5 w-5 h-5 inline-flex items-center justify-center rounded-full bg-background text-foreground/70 border border-[var(--panel-border)] cursor-pointer hover:text-foreground`,children:(0,G.jsx)(C.t,{className:`w-3 h-3`,"aria-hidden":!0})})]},e)),!f&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(wf,{color:`#c8b6a6`,onPicked:m,label:i?`Pick a colour to add`:`Pick a colour`,title:`Pick a colour`,className:`w-10 h-10 rounded-full border border-dashed border-foreground/30 text-foreground/50 hover:text-foreground hover:border-foreground/60 transition-colors overflow-hidden`,children:(0,G.jsx)(T.t,{className:`w-4 h-4 pointer-events-none`,"aria-hidden":!0})}),(0,G.jsx)(`input`,{type:`text`,inputMode:`text`,value:u,placeholder:`#d8c3a5`,"aria-label":`Or type a hex colour`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),m(u))},onBlur:()=>m(u),className:`w-24 bg-transparent text-[14px] text-foreground placeholder:text-foreground/30 focus:outline-none border-b border-transparent focus:border-accent py-1`}),h&&(0,G.jsx)(Cf,{color:h,size:`sm`})]})]}),o&&(0,G.jsx)(`p`,{className:`text-xs text-red-500 font-medium mt-1`,children:o})]})}var Ef=700,Df=e=>{let t=String(e),n=t.indexOf(`.`);return n<0?0:t.length-n-1};function Of(e,{min:t=0,max:n,step:r=1}={}){let i=String(e??``).trim().replace(`,`,`.`);if(!i)return null;let a=Number(i);if(!Number.isFinite(a))return null;let o=Df(r),s=Number(a.toFixed(o)),c=n!=null&&Number.isFinite(Number(n))?Number(n):1/0;return Math.min(c,Math.max(t,s))}var kf={sm:{button:`w-9 h-9`,icon:`w-3.5 h-3.5`,box:`text-[14px]`},md:{button:`w-10 h-10`,icon:`w-4 h-4`,box:`text-[15px]`}};function Af({label:e,name:t,value:n,onChange:i,onSettled:a,min:o=0,max:s,step:c=1,size:l=`md`,error:u,disabled:d,className:f}){let p=(0,W.useId)(),m={min:o,max:s,step:c},h=Of(n,m)??o,[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(n);n!==b&&(x(n),y(null));let S=v??h,C=(0,W.useRef)(null),w=(0,W.useRef)(h),E=(0,W.useRef)(null),D=(0,W.useRef)(a);(0,W.useEffect)(()=>{D.current=a});let O=()=>{E.current!=null&&window.clearTimeout(E.current),E.current=null;let e=C.current;C.current=null,e!=null&&e!==w.current&&D.current?.(w.current,e)};(0,W.useEffect)(()=>O,[]);let k=e=>{y(e),e!==(C.current==null?h:w.current)&&(C.current??=h,w.current=e,i(e),E.current!=null&&window.clearTimeout(E.current),E.current=window.setTimeout(O,Ef))},A=()=>(g==null?null:Of(g,m))??S,j=e=>{let t=Of(A()+e,m);t!=null&&(_(null),k(t))},M=Df(c)>0,N=M?/[^0-9.,-]/g:/[^0-9-]/g,ee=e=>{let t=e.replace(N,``);_(t);let n=Number(t.replace(`,`,`.`));t&&Number.isFinite(n)&&Of(t,m)===n&&k(n)},P=()=>{let e=g==null?null:Of(g,m);_(null),e!=null&&k(e),O()},te=g??String(S),F=t||e||``,I=S<=o,L=s!=null&&S>=Number(s),ne=kf[l],R=r.$(ne.button,`inline-flex items-center justify-center rounded-full shrink-0 text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors cursor-pointer`,`focus:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-25 disabled:cursor-default disabled:hover:bg-transparent`);return(0,G.jsxs)(`div`,{className:r.$(`inline-flex flex-col`,f),children:[e&&(0,G.jsx)(`span`,{id:`${p}-label`,className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:e}),(0,G.jsxs)(`div`,{role:`group`,"aria-labelledby":e?`${p}-label`:void 0,className:r.$(`glass-panel inline-flex items-center self-start rounded-full p-0.5`,u&&`border-red-500/50`,d&&`opacity-50 pointer-events-none`),children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":`One less ${F}`.trim(),disabled:d||I,onClick:()=>j(-c),className:R,children:(0,G.jsx)(ut,{className:ne.icon,"aria-hidden":!0})}),(0,G.jsx)(`input`,{type:`text`,inputMode:M?`decimal`:`numeric`,role:`spinbutton`,"aria-label":F||`How many`,"aria-valuenow":S,"aria-valuemin":o,"aria-valuemax":s==null?void 0:Number(s),"aria-invalid":u?!0:void 0,disabled:d,value:te,onChange:e=>ee(e.target.value),onFocus:e=>e.target.select(),onBlur:P,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`ArrowUp`?(e.preventDefault(),j(c)):e.key===`ArrowDown`&&(e.preventDefault(),j(-c))},style:{width:`${Math.max(2,te.length)+1}ch`},className:r.$(`bg-transparent text-center font-semibold tabular-nums text-foreground/85 focus:outline-none`,ne.box)}),(0,G.jsx)(`button`,{type:`button`,"aria-label":`One more ${F}`.trim(),disabled:d||L,onClick:()=>j(c),className:R,children:(0,G.jsx)(T.t,{className:ne.icon,"aria-hidden":!0})})]}),u&&(0,G.jsx)(`p`,{className:`text-xs text-red-500 font-medium mt-1`,children:u})]})}Af.displayName=`NumberStepper`;var jf=e=>{let t=Number(e);return Number.isFinite(t)&&t>0?t:0};function Mf(e,t){let n=e.map(jf),r=Math.max(jf(t),...n,0);return r?n.map(e=>e?Math.max(1,Math.round(e/r*1e3)/10):0):n.map(()=>0)}var Nf=e=>e.toLocaleString();function Pf({items:e,max:t,format:n=Nf,size:i=`md`,label:a,className:o}){let[s,c]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(e)},[]);let l=Mf(e.map(e=>e.value),t),u=i===`sm`;return(0,G.jsx)(`ul`,{"aria-label":a,className:r.$(`flex flex-col min-w-0`,u?`gap-2`:`gap-3.5`,o),children:e.map((e,t)=>(0,G.jsxs)(`li`,{className:`group/bar flex flex-col gap-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:r.$(`flex items-baseline justify-between gap-3 min-w-0`,u?`text-[12px]`:`text-[14px]`),children:[(0,G.jsx)(`span`,{className:`text-foreground/60 truncate`,children:e.label}),(0,G.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[(0,G.jsx)(`span`,{className:`font-semibold text-foreground`,children:n(jf(e.value))}),e.note&&(0,G.jsxs)(`span`,{className:`text-foreground/45`,children:[` · `,e.note]})]})]}),(0,G.jsx)(`div`,{"aria-hidden":!0,className:r.$(`w-full`,u?`h-1.5`:`h-2.5`),children:(0,G.jsx)(`div`,{className:`h-full rounded-r bg-accent/70 group-hover/bar:bg-accent transition-[width,background-color] duration-700 ease-out motion-reduce:transition-none`,style:{width:`${s?l[t]:0}%`}})})]},`${e.label}-${t}`))})}var Ff=(...e)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return``},If=[`assigneeUid`,`assigneeId`,`assigneeName`,`assigneeEmail`,`assigneePhoto`,`assigneeAvatar`,`assignedToUid`,`assignedToName`],Lf=e=>{if(!e)return null;let t=`heldByUid`in e||`heldByName`in e,n=t?Ff(e.heldByUid):Ff(e.assigneeUid,e.assignedToUid,e.assigneeId),r=t?Ff(e.heldByName):Ff(e.assigneeName,e.assignedToName);return!n&&!r?null:{uid:n,name:r,photo:t?Ff(e.heldByPhoto):Ff(e.assigneePhoto,e.assigneeAvatar)}},Rf=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`&&!!e):null;function zf(e,t,n=Date.now()){let r=Lf(e),i=r?.uid&&r.uid!==t?.uid&&r.uid!==e.uid?c.E(r.uid):``,a=t?.uid?c.E(t.uid):``,o=Rf(e.access),s=Rf(e.editors),l=e=>[...new Set([...e.filter(e=>e!==i),...a?[a]:[]])],u={};for(let t of If)t in e&&(u[t]=(0,q.deleteField)());return{...u,...o&&s?{access:l(o),editors:l(s)}:a?{access:(0,q.arrayUnion)(a),editors:(0,q.arrayUnion)(a)}:i?{access:(0,q.arrayRemove)(i),editors:(0,q.arrayRemove)(i)}:{},heldByUid:t?.uid||``,heldByName:t?.name||``,heldByPhoto:t?.photo||``,heldAt:n}}var Bf=``;function Vf({person:e,small:t}){return(0,G.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-2 align-middle`,children:[(0,G.jsx)(pf,{name:e.name,avatar:e.photo,size:t?`sm`:`md`}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-col text-left leading-tight`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:e.name}),e.email&&e.email!==e.name&&(0,G.jsx)(`span`,{"data-handover-email":``,className:`truncate text-xs font-medium text-foreground/45`,children:e.email})]})]})}function Hf({entry:e,collection:t,role:n=`internal`,name:i=``,link:a,label:s,compact:l=!1,readOnly:u=!1,onHanded:d,className:f}){let{user:p,userRole:m,isAdmin:h}=r.Ft(),g=String(p?.uid||``),_=(0,W.useMemo)(()=>g?c.k(g,m):[],[g,m]),v=o.Tn(t),y=!u&&!!e?.id&&v&&!!g&&(h||c.C(e,_))&&ae.f(e,h?`admin`:m),b=U.r(y?n:``),[x,S]=(0,W.useState)(void 0),C=Lf(e),w=x===void 0?C:x,T=w?.uid?b.people.find(e=>e.uid===w.uid):void 0,E=w?{uid:w.uid,name:T?.name||w.name||`Somebody`,photo:T?.photo||w.photo}:null;if(!e)return null;let D=!!s&&!l,k=D&&(0,G.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/70`,children:s});if(!y){let e=(0,G.jsx)(`span`,{"data-handover":`holder`,className:r.$(`inline-flex min-w-0 max-w-full items-center font-semibold text-foreground/70`,l?`text-xs`:`text-sm`,D?``:f),children:E?(0,G.jsx)(Vf,{person:E,small:l}):(0,G.jsx)(`span`,{className:`font-medium text-foreground/40`,children:`Nobody yet`})});return D?(0,G.jsxs)(`div`,{className:r.$(`flex min-w-0 flex-col gap-1.5`,f),children:[k,e]}):e}let A=async n=>{if(n===(w?.uid||Bf)||x!==void 0)return;let o=n?b.people.find(e=>e.uid===n):null;if(n&&!o)return;let s=o?{uid:o.uid,name:o.name,photo:o.photo}:null;S(s);try{let n=(0,q.doc)(r.ui,t,String(e.id));await(0,q.runTransaction)(r.ui,async t=>{let r=await t.get(n);if(!r.exists())throw Object.assign(Error(`That one is not there any more.`),{code:`not-found`});t.update(n,{...Ei(p),...zf({...r.data(),id:e.id},s)})}),O.n(s?`Handed to ${s.name}`:`Taken back`),s&&s.uid!==g&&Mt({toUid:s.uid,title:i?`${i} is yours now`:`Something was handed to you`,body:`${Ff(p?.displayName,String(p?.email||``).split(`@`)[0])||`Somebody`} handed it to you.`,link:a||(typeof window<`u`?window.location.pathname:``)}),d?.(s)}catch(e){let t=e?.code;O.n(r.ii(e,t===`permission-denied`?`That one is not yours to hand over.`:t===`not-found`?`That one is not there any more.`:`That could not be handed over just now.`))}finally{S(void 0)}},j=r.qr(n),M=!b.loading&&!b.people.length;if(b.error||M)return(0,G.jsxs)(`div`,{"data-handover":`nobody`,className:r.$(`flex min-w-0 flex-col gap-1.5`,f),children:[k,E&&(0,G.jsx)(`span`,{className:`text-sm font-semibold text-foreground/70`,children:(0,G.jsx)(Vf,{person:E,small:l})}),(0,G.jsx)(`p`,{className:`text-xs leading-snug text-foreground/50`,children:b.error||(n===`internal`?`Nobody is on your team yet — people are put on it on the Users screen.`:`Nobody is marked ${j} yet — people are marked on the Users screen.`)})]});let N=[...E?[{value:Bf,label:(0,G.jsx)(`span`,{className:`text-foreground/60`,children:`Nobody`})}]:[],...E&&E.uid&&!T?[{value:E.uid,label:(0,G.jsx)(Vf,{person:E,small:!0}),disabled:!0}]:[],...b.people.map(e=>({value:e.uid,label:(0,G.jsx)(Vf,{person:e,small:!0})}))];return(0,G.jsx)(`div`,{"data-handover":`picker`,"data-no-drag":``,className:r.$(`min-w-0 [&_[role=button]_[data-handover-email]]:hidden`,l?`inline-flex max-w-full`:`w-full`,f),onClick:e=>e.stopPropagation(),children:(0,G.jsx)(r.Z,{compact:l,portal:!0,direction:`auto`,label:l?void 0:s,ariaLabel:s||`Hand to somebody`,value:E?.uid||Bf,disabled:b.loading||x!==void 0,placeholder:(0,G.jsx)(`span`,{className:`text-foreground/50`,children:b.loading?`Loading people…`:`Hand to…`}),options:b.loading&&E?[{value:E.uid,label:(0,G.jsx)(Vf,{person:E,small:!0})}]:N,onChange:A})})}Hf.displayName=`HandOver`;var Uf=e=>e.replace(/[-_]+/g,` `).replace(/^./,e=>e.toUpperCase());function Wf(e,t={}){let n=t.param||`step`,[r,i]=(0,Y.useSearchParams)(),a=(0,W.useMemo)(()=>e.map(e=>typeof e==`string`?{id:e,label:Uf(e)}:e),[e.map(e=>typeof e==`string`?e:`${e.id}:${e.label}`).join(`|`)]),o=r.get(n),s=a.findIndex(e=>e.id===o),l=s<0?0:s,u=a[l]?.id??``,d=c.x(),f=(0,W.useRef)(d);f.current=d;let p=(0,W.useCallback)(e=>{let t=f.current;if(t>0){O.n(t===1?`One file is still going up. One moment.`:`${t} files are still going up. One moment.`);return}i(t=>{let r=new URLSearchParams(t);return r.set(n,e),r})},[n,i]),m=(0,W.useCallback)(()=>{let e=a[Math.min(l+1,a.length-1)];e&&e.id!==u&&p(e.id)},[p,l,a,u]),h=(0,W.useCallback)(()=>{let e=a[Math.max(l-1,0)];e&&e.id!==u&&p(e.id)},[p,l,a,u]),g=(0,W.useCallback)(()=>{i(e=>{let t=new URLSearchParams(e);return t.delete(n),t},{replace:!0})},[n,i]);return{step:u,index:l,count:a.length,isFirst:l===0,isLast:l===a.length-1,next:m,back:h,goTo:p,reset:g,waiting:d>0,bar:{steps:a,current:u,onGo:p}}}function Gf({steps:e,current:t,onGo:n,free:i=!1,className:a}){let o=(0,W.useRef)(null),s=e.findIndex(e=>e.id===t),c=s<0?0:s,l=(0,W.useRef)(!0);if((0,W.useEffect)(()=>{if(l.current){l.current=!1;return}let e=o.current;!e||typeof e.getBoundingClientRect!=`function`||e.getBoundingClientRect().top<0&&e.scrollIntoView?.({block:`start`,behavior:`smooth`})},[t]),!e.length)return null;let u=e[c];return(0,G.jsxs)(`nav`,{ref:o,"aria-label":`Steps`,className:r.$(`w-full scroll-mt-24`,a),children:[(0,G.jsxs)(`div`,{className:`sm:hidden`,children:[(0,G.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[(0,G.jsxs)(`span`,{className:`text-foreground/50`,children:[`Step `,c+1,` of `,e.length,` · `]}),u.label]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 w-full overflow-hidden rounded-full bg-foreground/10`,"aria-hidden":`true`,children:(0,G.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out motion-reduce:transition-none`,style:{width:`${(c+1)/e.length*100}%`}})})]}),(0,G.jsx)(`ol`,{className:`items-center gap-2 max-sm:hidden sm:flex`,children:e.map((t,a)=>{let o=a<c,s=a===c,l=!!n&&!s&&(o||i),u=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:r.$(`flex h-7 w-7 shrink-0 items-center justify-center rounded-full border text-[12px] font-bold transition-colors`,s&&`border-transparent [background:var(--button-bg)] text-[var(--button-fg)]`,o&&`border-accent/40 bg-accent/10 text-accent`,!s&&!o&&`border-[var(--panel-border)] text-foreground/40`),children:o?(0,G.jsx)(r.At,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}):a+1}),(0,G.jsx)(`span`,{className:r.$(`truncate text-[13px] font-semibold`,s?`text-foreground`:o?`text-foreground/70`:`text-foreground/40`),children:t.label})]});return(0,G.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,"aria-current":s?`step`:void 0,children:[l?(0,G.jsx)(`button`,{type:`button`,onClick:()=>n?.(t.id),className:`flex min-w-0 items-center gap-2 rounded-full py-1 pr-2 transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:u}):(0,G.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 py-1 pr-2`,children:u}),a<e.length-1&&(0,G.jsx)(`span`,{"aria-hidden":`true`,className:r.$(`h-px w-6 shrink-0 lg:w-10`,o?`bg-accent/40`:`bg-[var(--panel-border)]`)})]},t.id)})})]})}Gf.displayName=`StepBar`;var Kf=48,qf=8,Jf=2.5,Yf=5;function Xf(e,t){if(!t||t.width<=0||t.height<=0||e.width<=0||e.height<=0)return{x:[0,1],y:[0,1]};let n=Math.min(e.width/t.width,e.height/t.height),r=t.width*n/e.width,i=t.height*n/e.height;return{x:[(1-r)/2,(1+r)/2],y:[(1-i)/2,(1+i)/2]}}function Zf(e,[t,n]){if(e<=1)return[.5,.5];if(e*(n-t)>=1)return[e*t/(e-1),(e*n-1)/(e-1)];let r=(e*((t+n)/2)-.5)/(e-1);return[r,r]}var Qf=(e,[t,n])=>Math.min(n,Math.max(t,e));function $f({pictures:e,index:t,onIndex:n,onClose:i,zoom:a=!1}){let o=(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?{src:e}:e&&typeof e==`object`&&typeof e.src==`string`?e:{src:``}),s=t!==null&&t>=0&&t<o.length,c=s?t:0,l=o.length>1,u=r.tt(),d=(0,W.useRef)(()=>{}),f=(0,W.useRef)(null);(0,W.useEffect)(()=>{d.current=e=>{l&&n((c+e+o.length)%o.length)}}),(0,W.useEffect)(()=>{if(!s)return;let e=()=>{f.current=null};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[s]),(0,W.useEffect)(()=>{if(!s)return;let e=e=>{e.key===`ArrowLeft`&&(e.preventDefault(),d.current(-1)),e.key===`ArrowRight`&&(e.preventDefault(),d.current(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s]);let p=o[c],m=()=>({s:1,x:.5,y:.5,by:`press`}),[h,g]=(0,W.useState)(m),y=s?`${c}:${p?.src}`:null;(0,W.useEffect)(()=>{f.current=null},[y]);let[b,x]=(0,W.useState)(y);y!==b&&(x(y),g(m()));let S=h.s>1,C=(0,W.useRef)(null),w=(0,W.useRef)(new Map),T=(0,W.useRef)(null),E=()=>{let e=f.current;if(e&&e.exact)return e;let t=C.current?.getBoundingClientRect(),n={left:t?.left||0,top:t?.top||0,width:t?.width||0,height:t?.height||0},i=[...C.current?.querySelectorAll(`img`)||[]].reverse().find(e=>e.naturalWidth>0),a=p&&r.k(p.src)||(p?.width&&p?.height?{width:p.width,height:p.height}:void 0)||(i?{width:i.naturalWidth,height:i.naturalHeight}:void 0),o={box:n,span:Xf(n,a),exact:!!a&&n.width>0&&n.height>0};return f.current=o,o},D=()=>{f.current=null},O=(e,t,n,r)=>{if(e<=1)return{s:1,x:t,y:n,by:r};let{span:i}=E();return{s:e,x:Qf(t,Zf(e,i.x)),y:Qf(n,Zf(e,i.y)),by:r}},k=(e,t,n,r)=>{let{box:i,span:a}=E(),o=i.width?Math.min(1,Math.max(0,(e-i.left)/i.width)):.5,s=i.height?Math.min(1,Math.max(0,(t-i.top)/i.height)):.5,[c,l]=Zf(n,a.x),[u,d]=Zf(n,a.y);return{s:n,x:c+o*(l-c),y:u+s*(d-u),by:r}},A=()=>{let[e,t]=[...w.current.values()];return Math.hypot(e.x-t.x,e.y-t.y)||1},M=e=>{if(!(e.pointerType===`mouse`&&e.button!==0)){D(),w.current.set(e.pointerId,{x:e.clientX,y:e.clientY});try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}if(w.current.size===1)T.current={x:e.clientX,y:e.clientY,last:{x:e.clientX,y:e.clientY},moved:!1,pinched:!1};else if(w.current.size===2&&T.current&&(T.current.moved=!0,T.current.pinched=!0,T.current.pinch={dist:A(),s:h.s},!S)){let{box:e}=E(),[t,n]=[...w.current.values()];g({s:1,x:e.width?((t.x+n.x)/2-e.left)/e.width:.5,y:e.height?((t.y+n.y)/2-e.top)/e.height:.5,by:`finger`})}}},N=e=>{if(!w.current.has(e.pointerId)){e.pointerType===`mouse`&&S&&g(k(e.clientX,e.clientY,h.s,`mouse`));return}w.current.set(e.pointerId,{x:e.clientX,y:e.clientY});let t=T.current;if(!t)return;if(t.pinch&&w.current.size>=2){g(O(Math.min(Yf,Math.max(1,t.pinch.s*A()/t.pinch.dist)),h.x,h.y,`finger`));return}let n=e.clientX-t.last.x,r=e.clientY-t.last.y;if(t.last={x:e.clientX,y:e.clientY},Math.hypot(e.clientX-t.x,e.clientY-t.y)>qf&&(t.moved=!0),!S)return;if(e.pointerType===`mouse`){g(k(e.clientX,e.clientY,h.s,`mouse`));return}let{box:i}=E();!i.width||!i.height||g(O(h.s,h.x-n/i.width/(h.s-1),h.y-r/i.height/(h.s-1),`finger`))},ee=e=>{if(!w.current.delete(e.pointerId))return;let t=T.current;if(w.current.size>0){if(t){t.pinch=void 0;let[e]=[...w.current.values()];t.last=e}return}if(T.current=null,!t)return;if(t.pinched){h.s<1.15&&g({...h,s:1,by:`press`});return}if(!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=qf){g(S?{...h,s:1,by:`press`}:k(e.clientX,e.clientY,Jf,`press`));return}if(S)return;let n=e.clientX-t.x;Math.abs(n)>Kf&&Math.abs(n)>Math.abs(e.clientY-t.y)*1.5&&d.current(n<0?1:-1)},P=e=>{w.current.delete(e.pointerId),w.current.size||(T.current=null)},te=`cubic-bezier(0.22, 1, 0.36, 1)`,F=u||h.by===`finger`||h.by===`mouse`?`none`:`transform 350ms ${te}, transform-origin 350ms ${te}`,I=`absolute z-10 flex h-11 w-11 items-center justify-center rounded-full border border-[var(--panel-border)] bg-background/80 text-foreground backdrop-blur-sm transition-colors hover:bg-background focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 cursor-pointer`;return(0,G.jsx)(j.t,{open:s,onClose:i,size:`xl`,title:l?`${c+1} of ${o.length}`:void 0,className:`px-3 pb-4 sm:px-5 sm:pb-5`,children:p&&(0,G.jsxs)(`figure`,{className:`select-none`,children:[(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`div`,{ref:C,"data-lightbox-stage":!0,className:`relative overflow-hidden rounded-xl`,style:{touchAction:`none`,cursor:S?`zoom-out`:`zoom-in`},onPointerDown:M,onPointerMove:N,onPointerUp:ee,onPointerCancel:P,children:(0,G.jsx)(`div`,{className:`h-[62dvh] w-full sm:h-[72vh]`,style:{transform:`scale(${h.s})`,transformOrigin:`${h.x*100}% ${h.y*100}%`,transition:F,willChange:S?`transform`:void 0},children:(0,G.jsx)(r.O,{src:p.src,alt:p.alt||p.caption||``,fit:`contain`,priority:!0,draggable:!1,className:`h-full w-full`,preload:l?[o[(c+1)%o.length].src,o[(c-1+o.length)%o.length].src].filter(Boolean):void 0})})}),l&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":`Previous picture`,onClick:()=>d.current(-1),className:`${I} left-2 top-1/2 -translate-y-1/2`,children:(0,G.jsx)(_.t,{className:`h-5 w-5`,"aria-hidden":`true`})}),(0,G.jsx)(`button`,{type:`button`,"aria-label":`Next picture`,onClick:()=>d.current(1),className:`${I} right-2 top-1/2 -translate-y-1/2`,children:(0,G.jsx)(r.kt,{className:`h-5 w-5`,"aria-hidden":`true`})})]}),(0,G.jsx)(`button`,{type:`button`,"aria-label":S?`Zoom out`:`Zoom in`,onClick:()=>g(S?{...h,s:1,by:`press`}:O(Jf,.5,.5,`press`)),className:`${I} bottom-3 right-3`,children:S?(0,G.jsx)(v.o,{className:`h-5 w-5`,"aria-hidden":`true`}):(0,G.jsx)(v.a,{className:`h-5 w-5`,"aria-hidden":`true`})})]}),p.caption&&(0,G.jsx)(`figcaption`,{className:`mt-3 text-center text-sm text-foreground/70`,children:p.caption})]})})}$f.displayName=`Lightbox`;var ep=/^(?:https?:\/\/|mailto:|tel:|\/(?!\/))/i,tp=/\*\*([^*]+)\*\*|\*([^*\n]+)\*|\[([^\]]+)\]\(([^)\s]+)\)|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])/g;function np(e,t){let n=[],r=0,i=0;for(let a of e.matchAll(tp)){let o=a.index??0;o>r&&n.push(e.slice(r,o));let s=`${t}-${i++}`;if(a[1]!=null)n.push((0,G.jsx)(`strong`,{className:`font-semibold text-foreground`,children:a[1]},s));else if(a[2]!=null)n.push((0,G.jsx)(`em`,{children:a[2]},s));else{let e=a[4]??a[5],t=a[3]??a[5];if(e&&ep.test(e)){let r=/^https?:/i.test(e);n.push((0,G.jsx)(`a`,{href:e,...r?{target:`_blank`,rel:`noopener noreferrer`}:{},className:`font-medium text-accent underline decoration-accent/40 underline-offset-4 transition-colors hover:decoration-accent`,children:t},s))}else n.push(t)}r=o+a[0].length}return r<e.length&&n.push(e.slice(r)),n}var rp=(e,t)=>e.map((e,n)=>(0,G.jsxs)(W.Fragment,{children:[n>0&&(0,G.jsx)(`br`,{}),np(e,`${t}-l${n}`)]},`${t}-l${n}`)),ip=/^!\[([^\]]*)\]\((https?:\/\/[^)\s]+)\)$/;function ap({text:e,className:t}){let n=String(e??``).replace(/\r\n?/g,`
|
|
18
|
+
`}),(0,q.jsxs)(`div`,{className:`relative group/date flex flex-col w-full`,children:[(0,q.jsx)(g.y,{type:`date`,label:`Date`,required:!0,value:U.dateStr,onChange:e=>ce({...U,dateStr:e.target.value}),className:`pr-10`}),(0,q.jsx)(`div`,{className:`absolute right-4 bottom-4 pointer-events-none group-focus-within/date:text-accent text-foreground/40 transition-colors`,children:(0,q.jsx)(g.b,{className:`w-4 h-4`})})]}),(0,q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[X?(0,q.jsx)(g.y,{type:`time`,label:`Time`,value:U.time,onChange:e=>ce({...U,time:e.target.value}),required:!0}):(()=>{let{h:e,m:t,ampm:n}=Oe(U.time);return(0,q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,q.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Time`}),(0,q.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,q.jsx)(`input`,{type:`number`,min:1,max:12,value:e,onChange:e=>ce({...U,time:ke(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,q.jsx)(`span`,{className:`text-foreground/40 font-bold text-[15px] select-none`,children:`:`}),(0,q.jsx)(`input`,{type:`number`,min:0,max:59,value:t.toString().padStart(2,`0`),onChange:t=>ce({...U,time:ke(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,q.jsx)(`button`,{type:`button`,onClick:()=>ce({...U,time:ke(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,q.jsx)(g.y,{type:`number`,min:`1`,max:`1440`,label:`Duration (min)`,value:U.duration,onChange:e=>ce({...U,duration:e.target.value}),placeholder:`60`,required:!0})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest mt-1`,children:`Event Color`}),(0,q.jsx)(`div`,{className:`flex gap-2 items-center relative z-10 w-full h-[46px]`,children:Gs.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>ce({...U,color:U.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:U.color===e.text&&(0,q.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full bg-background`})},e.name))})]}),(0,q.jsx)(`div`,{className:`pt-2`,children:(0,q.jsx)(N.t,{type:`submit`,isLoading:B,className:`w-full py-3`,children:U.id?`Save Changes`:`Create Event`})})]})]})]},`edit-modal`),(0,q.jsx)(ie.t,{isOpen:!!H,title:`Confirm Deletion`,message:(0,q.jsxs)(q.Fragment,{children:[`Are you sure you want to delete `,(0,q.jsx)(`strong`,{className:`text-foreground font-extrabold break-words mx-1`,children:H?.title}),` This action is permanent.`]}),onConfirm:Ue,onCancel:()=>{se(null)},isProcessing:ae,confirmText:`Yes, Delete`})]});return f?(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col`,children:[(0,q.jsx)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(n.t,{children:u?.tabTitle||u?.tabName||e}),t&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,q.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,q.jsx)(i.t,{}),(0,q.jsxs)(r.nt.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:[Je(),Xe()]})]}),Qe()]}):(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4 md:mb-6 flex items-center gap-3`,children:[a&&(0,q.jsx)(c.r,{to:a}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(n.t,{children:e}),t&&(0,q.jsxs)(`div`,{className:`max-sm:hidden sm:flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,q.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]})]}),(0,q.jsx)(`div`,{className:`flex flex-col gap-6 flex-1 min-h-0 pb-16`,children:(0,q.jsxs)(r.nt.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 min-h-[400px] shadow-2xl bg-background relative`,children:[(0,q.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`}),Je(),Xe()]})}),Qe()]})}function Xs(e){let{user:t,methods:n}=e;if(!t)return null;if(!e.roleResolved||!e.profileReady)return`wait`;if(!o.un(t))return`/verify`;if(tr(t)){if(n.loading)return`wait`;if(or(t,n.on.sms2fa,n.twoStepOptional))return`/two-step`}return L.S(e.profile,{skippable:!0,perRole:!0})!==`member`&&n.loading?`wait`:L.f(e.profile,e.userRole,n.finishRegistration,t.uid)?`/your-details`:Xr(t.uid)?Ur:null}var Zs=`/register`,Qs=300*1e3,$s=e=>{if(typeof window>`u`)return null;try{let t=localStorage.getItem(`fbos_route_${e}`);if(!t)return null;let{cachedAt:n,...r}=JSON.parse(t);return{config:r,cachedAt:typeof n==`number`?n:0}}catch{return null}},ec=(e,t)=>{try{localStorage.setItem(e,t)}catch{}},tc=e=>{try{localStorage.removeItem(e)}catch{}},nc=(e,t)=>{let n=t?o.jn(e.pageType):`public`;return{...e,pageType:n,isPrivate:t,isAdmin:n===`admin`,isInternal:n===`internal`,isShared:n===`internal`}};function rc({config:e}){let{userRole:t}=r.Ft(),i=j.t(e);return(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center m-4 md:m-8 gap-6 min-h-[40vh]`,children:[(0,q.jsxs)(`div`,{className:`w-full max-w-lg glass-panel border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-16 text-center opacity-70`,children:[(0,q.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/70`,children:`This page could not open`}),(0,q.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 max-w-sm leading-relaxed mx-auto`,children:`Everything else here still works. Please come back to it a little later.`})]}),o.wn(t)&&i&&(0,q.jsx)(`div`,{className:`w-full max-w-lg`,children:(0,q.jsx)(n.o,{compact:!0,title:`To put this page right, paste this to your assistant`,prompt:j.c(i.file,i.page,i.error)})})]})}function ic(){let e=(0,Y.useLocation)(),{user:a,userRole:s,loading:l,roleResolved:u,roleConfirmed:d,userInactive:f,signOut:p,profile:m,profileReady:h}=r.Ft(),_=r.Cn(),v=i.v(),y=r.mi();r.Rr();let b=e=>{let n=$s(e);if(n)try{let e=n.config;if(e.form&&!e.formConfigOverride){let t=localStorage.getItem(`fbos_form_${e.form}`);t&&(e.formConfigOverride=JSON.parse(t))}return nc(e,e.isPrivate===!0)}catch{}let r=(typeof window<`u`?window.__FBOS_PAGES__:null)||{},i=e.replace(/^\//,``);for(let[t,n]of Object.entries(r)){let r=n.config,a=n.isPublic,o=r.route||`/`+t;if(o===e||t===i)return nc({...r,route:o,contentKey:r.pageId||t,pageId:t},!a)}return e===`/contact`?{route:`/contact`,template:`popup_form`,form:`contact`,pageId:`contact`,contentKey:`contact`,pageName:`Contact`,formConfigOverride:y.defaultConfigs?.contactForm||t.a}:e===`/support`?{route:`/support`,template:`popup_form`,form:`support`,pageId:`support`,contentKey:`support`,pageName:`Support`,formConfigOverride:y.defaultConfigs?.supportForm||t.r}:null},[x,S]=(0,K.useState)(()=>b(e.pathname)),[C,T]=(0,K.useState)(()=>!b(e.pathname)),E=(0,K.useRef)(e.pathname),D=d!==!1&&o.wn(s);(0,K.useEffect)(()=>{let n=!0,i=b(e.pathname);if(i){S(i),T(!1);let e=i.pageName||i.tabName||i.title;e&&(document.title=e)}else E.current!==e.pathname&&(S(null),T(!0));E.current=e.pathname;let a=$s(e.pathname);return a&&!D&&Date.now()-a.cachedAt<Qs||(async()=>{try{let i=e.pathname;i.startsWith(`/`)&&(i=i.substring(1));let[a,o,s,c,l,u]=await Promise.allSettled([(0,J.getDoc)((0,J.doc)(r.ui,`sys_pages`,i)),(0,J.getDoc)((0,J.doc)(r.ui,`sys_tabs`,i)),(0,J.getDocs)((0,J.query)((0,J.collection)(r.ui,`sys_pages`),(0,J.where)(`route`,`==`,e.pathname),(0,J.limit)(1))),(0,J.getDocs)((0,J.query)((0,J.collection)(r.ui,`sys_pages`),(0,J.where)(`route`,`==`,i),(0,J.limit)(1))),(0,J.getDocs)((0,J.query)((0,J.collection)(r.ui,`sys_tabs`),(0,J.where)(`route`,`==`,e.pathname),(0,J.limit)(1))),(0,J.getDocs)((0,J.query)((0,J.collection)(r.ui,`sys_tabs`),(0,J.where)(`route`,`==`,i),(0,J.limit)(1)))]),d=null,f=null,p=(e,t)=>{d||e.status===`fulfilled`&&(e.value.exists&&e.value.exists()?(d=nc(e.value.data(),t),f=e.value.id):e.value.docs&&e.value.docs.length>0&&(d=nc(e.value.docs[0].data(),t),f=e.value.docs[0].id))};if(p(a,!1),p(s,!1),p(c,!1),p(o,!0),p(l,!0),p(u,!0),!d){let t=(typeof window<`u`?window.__FBOS_PAGES__:null)||{};for(let[n,r]of Object.entries(t)){let t=r.config,a=r.isPublic,o=t.route||`/`+n;if(o===e.pathname||n===i){d=nc({...t,route:o,contentKey:t.pageId||n,pageId:n},!a),f=n;break}}}if(d||(e.pathname===`/contact`?(d={route:`/contact`,template:`popup_form`,form:`contact`,pageName:`Contact`},f=`contact`):e.pathname===`/support`&&(d={route:`/support`,template:`popup_form`,form:`support`,pageName:`Support`},f=`support`)),!n)return;if(d){if((f===`contact`||f===`support`)&&!d.form&&(d.form=f),d.contentKey||=d.pageId||f,d.pageId=f,ec(`fbos_route_${e.pathname}`,JSON.stringify({...d,cachedAt:Date.now()})),d.form){let e=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},i=n=>y.defaultConfigs?.[n]||y.defaultConfigs?.[`${n}Form`]||e[n]||(n===`contact`?t.a:n===`support`?t.r:null),a=null;try{a=localStorage.getItem(`fbos_custom_form_${d.form}`)}catch{}if(a){try{let e=localStorage.getItem(`fbos_form_${d.form}`);e&&(d.formConfigOverride=JSON.parse(e))}catch{}(0,J.getDoc)((0,J.doc)(r.ui,`sys_forms`,d.form)).then(async e=>{if(n)if(e.exists()){let t={...e.data(),id:e.id};S(e=>({...e,formConfigOverride:t})),ec(`fbos_form_${d.form}`,JSON.stringify(t))}else{let e=i(d.form);e&&(S(t=>({...t,formConfigOverride:e})),ec(`fbos_form_${d.form}`,JSON.stringify(e)),tc(`fbos_custom_form_${d.form}`))}}).catch(()=>{})}else{let e=i(d.form);e&&(d.formConfigOverride=e)}}let i=d.pageName||d.tabName||d.title;i&&(document.title=i),S(d),T(!1)}else S(`not-found`),T(!1),tc(`fbos_route_${e.pathname}`)}catch{n&&!i&&(S(`not-found`),T(!1))}})(),()=>{n=!1}},[e.pathname,D]);let[O,k]=(0,K.useState)(!1),A=j.f(),[M,N]=(0,K.useState)(null),[P,ee]=(0,K.useState)(!1),F=x&&x!==`not-found`&&typeof x==`object`?[x.contentKey,x.tabName,x.pageId,x.pageName].filter(Boolean).join(`|`):``;(0,K.useEffect)(()=>{if(N(null),!A)return;if(!F||j.r(x)){ee(!1);return}let e=!1;ee(!0),j.n(x).then(t=>{e||(t&&N(()=>t),ee(!1))});let t=setTimeout(()=>{e||ee(!1)},4e3);return()=>{e=!0,clearTimeout(t)}},[F,A]);let te=!!a&&d===!1&&!!x&&typeof x==`object`&&x.isPrivate===!0,I=!!a&&_.loading&&!!x&&typeof x==`object`&&(x.pageId===`support`||x.isPrivate===!0)&&L.S(m,{skippable:!0,perRole:!0})!==`member`,ne=!u&&!!x&&typeof x==`object`&&(x.pageId===`support`||!!x.isPrivate);if((0,K.useEffect)(()=>{let e;return C||l||ne||te||I||P||!A?e=setTimeout(()=>k(!0),150):k(!1),()=>clearTimeout(e)},[C,l,ne,te,I,P,A]),C||l||ne||te||I||P||!A)return O?a?(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`div`,{className:`h-10 w-56 rounded-xl bg-foreground/5 animate-pulse mt-1`}),(0,q.jsx)(`div`,{className:`h-3 w-24 rounded bg-foreground/5 animate-pulse mt-3`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,q.jsx)(i.t,{}),(0,q.jsx)(`div`,{className:`flex-1 fbos-tab-fill glass-panel border border-[var(--panel-border)] rounded-3xl flex items-center justify-center min-h-[400px] bg-background shadow-2xl`,children:(0,q.jsx)(w.r,{className:`w-6 h-6 animate-spin text-accent`})})]})]}):(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[40vh] z-10`,children:(0,q.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,q.jsx)(w.r,{className:`w-4 h-4 animate-spin text-accent`}),(0,q.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/60 tracking-wide`,children:`Loading page...`})]})}):null;if(x===`not-found`)return(0,q.jsx)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1 text-center`,children:[(0,q.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,q.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,q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,q.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,q.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}),(0,q.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-bold mb-3 text-foreground`,children:`Page Not Found`}),(0,q.jsx)(`p`,{className:`text-foreground/60 max-w-md`,children:`The route you are looking for does not exist or has been removed.`}),o.wn(s)&&(()=>{let t=Qi();return(0,q.jsxs)(`div`,{className:`mt-8 w-full max-w-lg text-left flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] px-5 py-4`,children:[(0,q.jsx)(`p`,{className:`text-[12px] font-extrabold tracking-tight text-gradient mb-1.5`,children:`Pages the app can see`}),(0,q.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,q.jsx)(n.o,{title:`If your assistant just made this page, paste this`,prompt:ra(e.pathname)})]})})()]})});if((x.pageId===`support`||x.isPrivate)&&!a)return(0,q.jsx)(Y.Navigate,{to:`/login?from=${encodeURIComponent(e.pathname)}`,replace:!0});let R=(x.pageId===`support`||x.isPrivate)&&a?Xs({user:a,profile:m,userRole:s,roleResolved:u,profileReady:h,methods:_}):null;if(R===`wait`)return(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[40vh] z-10`,children:(0,q.jsx)(w.r,{className:`w-6 h-6 animate-spin text-accent`})});if((x.pageId===`support`||x.isPrivate)&&a&&f)return m?.removed===!0?(0,q.jsx)(Y.Navigate,{to:Zs,replace:!0}):(0,q.jsx)(H.t,{tone:`red`,title:`Access Denied`,message:`You don't have access to this app. Please contact the administrator.`,action:(0,q.jsx)(`button`,{onClick:()=>p(),className:H.a,children:`Sign Out`})});if(R)return(0,q.jsx)(Y.Navigate,{to:R,replace:!0});let z=o.wn(s)&&new URLSearchParams(e.search).has(`preview`);if(x.isPrivate&&!z&&o.Nn(x)&&!v.live)return(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[40vh] z-10`,children:(0,q.jsx)(w.r,{className:`w-6 h-6 animate-spin text-accent`})});if(x.isPrivate&&!z&&!o.yn(s,x,v.groups))return(0,q.jsx)(H.i,{});let re=y.customRoutes?.[e.pathname]||(x&&x.route?y.customRoutes?.[x.route]:null),ie=`pub_${B.i(x,!1)}`,V=x.isPrivate?`${o.Mn(x)}${B.i(x,!0)}`:ie,ae=y.microcomponents||(typeof window<`u`?window.__FBOS_MICROCOMPONENTS__:void 0),oe=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``),se=[x.contentKey,x.tabName,x.pageId,x.pageName,x.pageName?.replace(/\s+/g,`_`)].filter(Boolean).map(e=>oe(e)).reduce((e,t)=>e||ae?.[t],void 0),U=re||se||M||(B.c(x.template,!1)&&j.t(x)?rc:void 0),ce=x.route||x.pageId||`custom`;return B.c(x.template,!!U)?x.isAdmin?(0,q.jsx)(Ya,{config:x,customContent:U},ce):x.isInternal?(0,q.jsx)(Za,{config:x,customContent:U},ce):x.isPrivate?(0,q.jsx)(qa,{config:x,customContent:U},ce):(0,q.jsx)(Ea,{config:x,customContent:U},ce):x.template===`board`?(0,q.jsx)(y.components?.TemplateBoard||ho,{title:x.tabTitle||x.tabName||x.title||x.pageName||`Board`,subtitle:x.route,tasksCollection:`${V}_tasks`,categoriesCollection:`${V}_categories`,config:x,customContent:U},ce):x.template===`table`?(0,q.jsx)(y.components?.TemplateTable||Ws,{title:x.tabTitle||x.tabName||x.title||x.pageName||`Table`,subtitle:x.route,tableCollection:`${V}_table`,config:x,customContent:U},ce):x.template===`calendar`?(0,q.jsx)(y.components?.TemplateCalendar||Ys,{title:x.tabTitle||x.tabName||x.title||x.pageName||`Calendar`,subtitle:x.route,eventsCollection:`${V}_events`,defaultTimeFormat:x.defaultTimeFormat||x.defaulttimeformat||`12h`,config:x,customContent:U},ce):x.template===`drive`?(0,q.jsx)(y.components?.TemplateDrive||c.t,{title:x.tabTitle||x.tabName||x.title||x.pageName||`Drive`,subtitle:x.route,filesCollection:`${V}_files`,config:x,customContent:U},ce):x.template===`inline_form`?(0,q.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-start mt-8 relative z-10 w-full min-h-[60vh]`,children:(0,q.jsx)(g.t,{isInline:!0,formId:x.form,formConfig:x.formConfigOverride})}):(0,q.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 w-full min-h-[60vh]`,children:(0,q.jsx)(g.t,{formId:x.form,formConfig:x.formConfigOverride,onClose:()=>window.history.back()})})}function ac(e,t=r.Lr()){let n=typeof e==`string`?e.trim()===``?NaN:Number(e):e;if(n==null||!Number.isFinite(n))return`—`;let i=(t||r.Lr()).toUpperCase();try{return new Intl.NumberFormat(void 0,{style:`currency`,currency:i}).format(n)}catch{return`${n} ${i}`}}var oc=e=>e.error?`error`:e.paid?`paid`:r.In(e)?`clearing`:`unpaid`,sc={checking:{icon:Ze,tint:`text-accent`,title:`Checking your payment…`},paid:{icon:Ge,tint:`text-accent`,title:`Thank you — your order is placed`},clearing:{icon:Ze,tint:`text-accent`,title:`Your payment is on its way`},unpaid:{icon:Ze,tint:`text-foreground/50`,title:`Not confirmed yet`},error:{icon:Ue,tint:`text-foreground/50`,title:`We could not confirm this payment`},cancelled:{icon:Ye,tint:`text-foreground/50`,title:`Payment cancelled`}};function cc({cancelled:e=!1}){let[t]=(0,Y.useSearchParams)(),n=t.get(`session_id`)||``,{user:i}=r.Ft(),[a,o]=(0,K.useState)(`checking`),[s,c]=(0,K.useState)(null);(0,K.useEffect)(()=>{if(e)return;let t=!1;return r.An(n).then(e=>{t||(c(e),o(oc(e)))}),()=>{t=!0}},[e,n]);let l=async()=>{o(`checking`);let e=await r.An(n);c(e),o(oc(e))},u=sc[e?`cancelled`:a],d=u.icon;return(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16`,children:(0,q.jsxs)(r.nt.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,q.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,q.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 shadow-xl`,children:(0,q.jsx)(d,{className:`w-7 h-7 md:w-8 md:h-8 ${u.tint} ${!e&&a===`checking`?`animate-pulse`:``}`})}),(0,q.jsx)(`h1`,{className:`text-2xl md:text-3xl font-bold mb-3 text-foreground tracking-tight`,children:u.title}),(0,q.jsxs)(`div`,{className:`text-[14px] md:text-[15px] text-foreground/60 mb-6 md:mb-8 leading-[1.6] tracking-wide`,children:[e&&(0,q.jsx)(`p`,{children:`Nothing was charged. You can try again whenever you like.`}),!e&&a===`checking`&&(0,q.jsx)(`p`,{children:`One moment — confirming with the payment provider.`}),!e&&a===`paid`&&(0,q.jsxs)(`p`,{children:[s?.amountTotal!=null&&s?.currency?`Your payment of ${ac(s.amountTotal,s.currency)} went through.`:`Your payment went through.`,s?.receipt&&s.customerEmail?` A receipt is on its way to ${s.customerEmail}.`:``,i?` Your order is under Billing, and the bell will tell you if anything changes.`:s?.customerEmail?` Sign in with ${s.customerEmail} any time to see your order under Billing.`:``]}),!e&&a===`clearing`&&(0,q.jsxs)(`p`,{children:[`Your bank is still sending it, which can take a few days. Your order is in: there is nothing more to do, and please do not pay again.`,s?.receiptLater&&s.customerEmail?` We will email a receipt to ${s.customerEmail} once it arrives.`:``]}),!e&&a===`unpaid`&&(0,q.jsx)(`p`,{children:`The payment provider has not confirmed this payment yet. Some payment methods take a minute — check again shortly.`}),!e&&a===`error`&&(0,q.jsxs)(`p`,{children:[s?.error,` If you finished paying, your order is safe — please do not pay again.`]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[!e&&a===`paid`&&i&&(0,q.jsx)(Y.Link,{to:`/billing`,className:`w-full block py-2.5 md:py-3 btn-primary text-[14px] font-bold rounded-xl transition-colors text-center`,children:`See your order`}),!e&&(a===`unpaid`||a===`error`)&&(0,q.jsx)(N.t,{variant:`primary`,onClick:l,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl`,children:`Check again`}),(0,q.jsx)(Y.Link,{to:`/`,className:`w-full block py-2.5 md:py-3 bg-foreground/5 hover:bg-foreground/10 text-foreground text-[14px] font-bold rounded-xl transition-colors`,children:`Back to the site`})]})]})})}var lc={contentKey:`dashboard`};function uc(){let{user:e,profile:t}=r.Ft(),a=r.mi();r.Rr();let o=(0,Y.useNavigate)(),[s]=(0,Y.useSearchParams)(),[c]=(0,K.useState)(()=>s.get(L.n)===`1`);(0,K.useEffect)(()=>{if(!c)return;let e=new URLSearchParams(s);e.delete(L.n);let t=e.toString();o(`/dashboard${t?`?${t}`:``}`,{replace:!0})},[c]);let l=c&&L.h(t),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(()=>typeof window<`u`&&!j.r(lc));(0,K.useEffect)(()=>{if(j.r(lc))return;let e=!1;j.n(lc).then(t=>{e||(t&&d(()=>t),p(!1))});let t=setTimeout(()=>{e||p(!1)},4e3);return()=>{e=!0,clearTimeout(t)}},[]);let m=a.microcomponents?.dashboard||(typeof window<`u`?window.__FBOS_MICROCOMPONENTS__?.dashboard:void 0)||u||void 0,h=(String(t?.displayName||``).trim()||e?.displayName||e?.email?.split(`@`)[0]||`there`).split(` `)[0],g=h.charAt(0).toUpperCase()+h.slice(1),_=`${l?`Welcome`:`Welcome back`}, ${g}.`;return(0,q.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 pt-2 md:p-8 md:pt-4 z-10 flex flex-col min-h-screen`,children:[(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,q.jsx)(n.t,{children:_}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,q.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/dashboard`]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,q.jsx)(`div`,{className:`flex justify-start`,children:(0,q.jsx)(i.t,{})}),m?(0,q.jsx)(`div`,{className:`fbos-content-slot fbos-tab-fill relative w-full flex-1`,children:(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(m,{})})}):(0,q.jsxs)(`div`,{className:`w-full flex-1 glass-panel rounded-3xl relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)] p-8 md:p-12 flex items-center justify-center`,children:[(0,q.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`}),f?(0,q.jsx)(w.r,{className:`w-6 h-6 text-accent animate-spin relative z-10`}):(0,q.jsx)(r.rt,{mode:`wait`,children:(0,q.jsxs)(r.nt.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,q.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,q.jsx)($e,{className:`w-6 h-6`})}),(0,q.jsx)(`h2`,{className:`text-2xl font-bold text-foreground mb-2`,children:`No data added here yet`}),(0,q.jsx)(`p`,{className:`text-foreground/40 font-medium`,children:`Keep moving forward, your data will appear here.`})]})})]})]})]})}var dc=8e3,fc=2e4;function pc(e){let[t,n]=(0,K.useState)(()=>e<=0);return(0,K.useEffect)(()=>{if(e<=0)return;let t=setTimeout(()=>n(!0),e);return()=>clearTimeout(t)},[e]),t}function mc(){return{slow:pc(dc),stuck:pc(fc)}}var hc=e=>e&&/^\/(?![/\\])/.test(e)?e:null,gc=`Still trying to connect`,_c=`The app has not heard back. This is almost always the connection rather than anything you did — reloading usually picks it up.`,vc=`No connection`,yc=`This device is not online, so the app cannot finish opening. It will carry on by itself the moment you are back.`,bc=()=>{let{slow:e,stuck:t}=mc(),n=r.$r();return t||e&&n?(0,q.jsx)(a.t,{override:{title:n?vc:gc,message:n?yc:_c,next:`reload`}}):(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center min-h-[60vh] z-10 fbos-fade-in`,children:[(0,q.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,q.jsx)($e,{className:`w-6 h-6 text-accent animate-pulse`})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 glass-panel px-5 py-2.5 rounded-full border border-[var(--panel-border)]`,children:[(0,q.jsx)(`div`,{className:`w-4 h-4 border-2 border-accent border-t-transparent rounded-full animate-spin`}),(0,q.jsx)(`span`,{className:`text-[13px] font-bold tracking-widest uppercase text-foreground/70`,children:`Connecting`})]}),e&&(0,q.jsxs)(`div`,{className:`mt-6 max-w-xs w-full px-4 text-center fbos-fade-in`,children:[(0,q.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground/60 leading-relaxed mb-3`,children:`This is taking longer than it should.`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{typeof window<`u`&&window.location.reload()},className:`w-full flex items-center justify-center gap-2 py-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground text-[14px] font-bold rounded-xl transition-colors`,children:`Reload the page`})]})]})};function xc({level:e,children:t}){let{user:n,userRole:i,loading:a,userInactive:s,signOut:c,roleResolved:l,profile:u,profileReady:d}=r.Ft(),f=(0,Y.useLocation)(),p=r.Cn();if(a||!l)return(0,q.jsx)(bc,{});if(!n)return(0,q.jsx)(Y.Navigate,{to:`/login?from=${encodeURIComponent(f.pathname)}`,replace:!0});if(!d)return(0,q.jsx)(bc,{});if(s)return u?.removed===!0?(0,q.jsx)(Y.Navigate,{to:Zs,replace:!0}):(0,q.jsx)(H.t,{tone:`red`,title:`Access Denied`,message:`You don't have access to this app. Please contact the administrator.`,action:(0,q.jsx)(`button`,{onClick:()=>c(),className:H.a,children:`Sign Out`})});let m=Xs({user:n,profile:u,userRole:i,roleResolved:l,profileReady:d,methods:p});return m===`wait`?(0,q.jsx)(bc,{}):m?(0,q.jsx)(Y.Navigate,{to:m}):e===`admin`&&!o.wn(i)?(0,q.jsx)(H.n,{}):e===`internal`&&!o.Sn(i)?(0,q.jsx)(H.r,{}):(0,q.jsx)(q.Fragment,{children:t})}var Sc=({children:e})=>(0,q.jsx)(xc,{level:`signed-in`,children:e}),Cc=({children:e})=>(0,q.jsx)(xc,{level:`admin`,children:e});function wc({tab:e,children:t}){let{userRole:n}=r.Ft(),{audience:a,live:s}=i.o(e),c=re.i(n,a);return!c&&!s&&!o.wn(n)?(0,q.jsx)(bc,{}):(0,q.jsx)(xc,{level:c?`signed-in`:`admin`,children:t})}function Tc({children:e,landing:t}){let{user:n,loading:i,roleResolved:a,profileReady:s,profile:c,userRole:l}=r.Ft(),u=r.Cn(),[d]=(0,Y.useSearchParams)(),[f]=(0,K.useState)(()=>r.Bt()),[p,m]=(0,K.useState)(!1);if(!i&&!n&&!p&&m(!0),i)return f?(0,q.jsx)(q.Fragment,{children:e}):(0,q.jsx)(bc,{});if(d.has(`preview`)||n&&s&&c?.removed===!0)return(0,q.jsx)(q.Fragment,{children:e});if(n&&o.un(n)){let r=Xs({user:n,profile:c,userRole:l,roleResolved:a,profileReady:s,methods:u});return r===`wait`||u.loading?p?(0,q.jsx)(q.Fragment,{children:e}):(0,q.jsx)(bc,{}):(0,q.jsx)(Y.Navigate,{to:r??hc(d.get(`from`))??t??`/dashboard`,replace:!0})}return(0,q.jsx)(q.Fragment,{children:e})}function Ec({children:e}){let{user:t,loading:n,roleResolved:i,profile:a,profileReady:s}=r.Ft();if(n||!i)return(0,q.jsx)(bc,{});if(!t)return(0,q.jsx)(Y.Navigate,{to:`/`});if(o.un(t)){if(!s)return(0,q.jsx)(bc,{});if(!o.dn(t,a))return(0,q.jsx)(Y.Navigate,{to:`/dashboard`})}return(0,q.jsx)(q.Fragment,{children:e})}function Dc({children:e}){let{user:t,loading:n,roleResolved:i}=r.Ft(),a=r.Cn();return n||!i?(0,q.jsx)(bc,{}):t?o.un(t)?a.loading?(0,q.jsx)(bc,{}):!a.on.sms2fa||!tr(t)?(0,q.jsx)(Y.Navigate,{to:`/dashboard`}):(0,q.jsx)(q.Fragment,{children:e}):(0,q.jsx)(Y.Navigate,{to:`/verify`}):(0,q.jsx)(Y.Navigate,{to:`/`})}function Oc({children:e}){let{user:t,userRole:n,loading:i,roleResolved:a,roleConfirmed:s,profile:c,profileReady:l}=r.Ft(),u=r.Cn();return i||!a?(0,q.jsx)(bc,{}):t?o.un(t)?!s||!l||u.loading?(0,q.jsx)(bc,{}):L.v(c,n,u.finishRegistration)?(0,q.jsx)(q.Fragment,{children:e}):(0,q.jsx)(Y.Navigate,{to:`/dashboard`}):(0,q.jsx)(Y.Navigate,{to:`/verify`}):(0,q.jsx)(Y.Navigate,{to:`/`})}var kc=[`user_submissions`,`user_requests`],Ac=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`&&e):[],jc=e=>[...new Set(e.filter(e=>e&&e!==`uid:`&&e!==`role:`))],Mc=new Set([`id`,`from`,`uid`,`formId`,`submittedAt`,`submitterAvatar`,`transaction`,`arrivedIn`,`appliedEntries`,`access`,`editors`,`archived`,`read`,`starred`]);function Nc(e,t){let n={};for(let[t,r]of Object.entries(e))!Mc.has(t)&&r!==void 0&&(n[t]=r);let r=t&&t.kind===`charge`?t:null;return r?.paidWith&&n.paidWith===void 0&&(n.paidWith=r.paidWith),r?.receiptUrl&&n.receiptUrl===void 0&&(n.receiptUrl=r.receiptUrl),n}function Pc(e,t){let n=Object.entries(e).filter(([e,t])=>/e-?mail/i.test(e)&&typeof t==`string`).map(([,e])=>String(e)),r=e.buyer&&typeof e.buyer==`object`?String(e.buyer.email||``):``;return[...new Set([String(t?.email||``),String(e.submitterEmail||``),r,...n].map(c.T))].filter(e=>e!==`email:`).slice(0,3)}var Fc=e=>{if(!e)return 0;if(typeof e==`number`)return e;if(typeof e.toMillis==`function`)return e.toMillis();if(typeof e.seconds==`number`)return e.seconds*1e3;let t=new Date(e).getTime();return Number.isNaN(t)?0:t};function Ic(e,t,{roles:n=[],viewers:r=[],senderCanEdit:i=!1},a=null){let o=e.uid&&e.uid!==`guest`?c.E(e.uid):``,s=n.map(c.D),l=Pc(e,a),u=!o&&!t.email&&l.length?{email:l[0].slice(6)}:{};return{...t,...u,uid:o?e.uid:``,access:jc([o,...l,...s,...r.map(c.D),...Ac(t.access),...Ac(t.editors)]),editors:jc([...i?[o]:[],...s,...Ac(t.editors)]),sourceId:e.id,formId:e.formId,createdAt:typeof t.createdAt==`number`?t.createdAt:Fc(e.submittedAt)||Date.now()}}function Lc(e,t,n){return!t||!e?.sourceId||e.uid!==t?!1:n===void 0?!Ac(e.access).includes(c.E(t)):n}function Rc(e,t,n,r=[]){for(let i of t){let t=Object.values(i.collected||{});if(t.includes(e)&&U.n(n,i,r.filter(n=>n.id!==e&&t.includes(n.id)))&&(i.kind===`charge`?i.paid:[`active`,`trialing`].includes(String(i.status))))return i}return null}var zc=e=>{let t=Number(e?.total);return{...e,id:String(e?.sourceId||``),transaction:!0,items:Array.isArray(e?.items)?e.items:[],total:e?.total!=null&&Number.isFinite(t)?t:2**53-1}},Bc=(e,t)=>{let n=new Set;for(let r of e){let e=Object.values(r.collected||{}).map(String);if(e.some(e=>t.includes(e)))for(let r of e)r&&!t.includes(r)&&n.add(r)}return[...n]},Vc=(e,t)=>{let n=new Map(t.filter(e=>e.id).map(e=>[e.id,e]));return[...e.map(e=>n.get(e.id)||e),...[...n.values()].filter(t=>!e.some(e=>e.id===t.id))]},Hc=5,Uc=60*1e3;async function Wc(e,t=[]){let n=new Map(t.map(e=>[e.id,e])),i=[];try{let a=await r.li?.currentUser?.getIdToken();if(!a)return{sales:i,error:``};let o=``,s=``;for(let r=0;r<Hc;r+=1){let c=new URLSearchParams;o&&c.set(`starting_after`,o),s&&c.set(`subscriptions_after`,s);let l=await fetch(`/api/payments/sales${r?`?${c}`:``}`,{headers:{Authorization:`Bearer ${a}`}});if(!l.ok){let e=``;try{e=String((await l.json())?.error||``)}catch{}return{sales:i,error:e||`Your payments could not be read, so nothing paid for could be let in just now.`}}let u=await l.json();if(i.push(...u?.charges||[],...u?.subscriptions||[]),e.every(e=>Rc(e,i,n.get(e),t))||!u?.chargesHasMore&&!u?.subscriptionsHasMore)break;o=u?.chargesAfter||o,s=u?.subscriptionsAfter||s}return{sales:i,error:``}}catch{return{sales:i,error:`Your payments could not be read, so nothing paid for could be let in just now.`}}}var Gc=e=>e?.code===`permission-denied`?`What came in from the other page could not be read. The security rules may need pasting again from the Setup screen.`:`What came in from the other page could not be read just now.`,Kc=1440*60*1e3,qc=(e,t,n)=>[e.name,e.customerName,e.buyer?.name,t.submitterName,n?.name].map(e=>typeof e==`string`?e.trim():``).find(Boolean)||``;function Jc(e,t,{roles:n=[],paid:r=!1,page:i,ring:a=!0},o,s=Date.now()){if(!a)return[];let c=Fc(e.submittedAt);if(c&&s-c>Kc)return[];let l=i?.path||(typeof window<`u`?window.location.pathname:``),u=i?.title?` on ${i.title}`:``,d=qc(t,e,o),f=n.map(e=>({toRole:e,title:r?`New order${u}`:`Something new${u}`,body:d?`From ${d}`:``,link:l}));return e.uid&&e.uid!==`guest`&&f.push({toUid:e.uid,title:r?`We have your order`:`We have what you sent`,body:i?.title?`Follow it on ${i.title}.`:`You can follow it here.`,link:l}),f}var Yc=new Map,Xc=new Set,Zc=(e,t)=>`${e}|${t}`,Qc=(e,t)=>(Yc.get(Zc(e,t))||0)>0,$c=e=>(Xc.add(e),()=>{Xc.delete(e)}),el=(e,t)=>{Yc.set(e,Math.max(0,(Yc.get(e)||0)+t)),Xc.forEach(e=>e())};function tl(e,t,n,i){let{formId:a,paid:o=!1}=t(),s=!0,c=new Map,l=new Map,u=new Set,d=!1,f=!1,p=async(n,i)=>{let a=t(),o;try{o=(a.make||Nc)(n,i)}catch{return`Something that came in could not be read into this page.`}if(!o)return``;let s=Ic(n,o,a,i),c=!1;try{await(0,J.runTransaction)(r.ui,async t=>{c=!1;let i=(0,J.doc)(r.ui,n.from,n.id),a=(0,J.doc)(r.ui,e,n.id),o=await t.get(i);!o.exists()||Ac(o.data()?.arrivedIn).includes(e)||((await t.get(a)).exists()||(t.set(a,s),c=!0),t.update(i,{arrivedIn:(0,J.arrayUnion)(e)}))})}catch(e){return Gc(e)}if(c)for(let e of Jc(n,s,a,i))Nt(e);return``},m=async t=>{let n=[];for(let i=0;i<t.length;i+=30){let a=await(0,J.getDocs)((0,J.query)((0,J.collection)(r.ui,e),(0,J.where)(`sourceId`,`in`,t.slice(i,i+30))));for(let e of a.docs)n.push(zc(e.data()||{}))}return n},h=async()=>{if(d){f=!0;return}d=!0;try{let e=[...c.values()].flatMap(e=>[...e.values()]).filter(e=>!u.has(e.id));if(!e.length)return;let t=[],n=``,r=[...l.values()].flat(),a=r;if(o){let o=await Wc(e.map(e=>e.id),r);if(!s)return;t=o.sales,n=o.error;try{a=Vc(r,await m(Bc(t,e.map(e=>e.id))))}catch(e){i(n||Gc(e));return}if(!s)return}for(let r of e){let e=o?Rc(r.id,t,r,a):null;if(o&&!e)continue;let i=await p(r,e);if(!s)return;i?n||=i:u.add(r.id)}i(n)}finally{d=!1,f&&s&&(f=!1,h())}},g=new Map,_=new Set,v=!1,y=async()=>{try{let t=await(0,J.getDocs)((0,J.query)((0,J.collection)(r.ui,e),(0,J.where)(`formId`,`==`,a),(0,J.where)(`uid`,`==`,n)));for(let i of t.docs){if(!s)return;let t=i.data()||{};Lc(t,n,g.get(String(t.sourceId)))&&await(0,J.updateDoc)((0,J.doc)(r.ui,e,i.id),{uid:``})}}catch{}},b=kc.map(t=>(0,J.onSnapshot)((0,J.query)((0,J.collection)(r.ui,t),(0,J.where)(`formId`,`==`,a)),n=>{let r=new Map,i=[];for(let o of n.docs){let n=o.data()||{};g.set(o.id,!n.uid||n.uid===`guest`);let s={...n,id:o.id,uid:String(n.uid||`guest`),formId:a,from:t};i.push(s),!Ac(n.arrivedIn).includes(e)&&r.set(o.id,s)}c.set(t,r),l.set(t,i),_.add(t),!v&&_.size===kc.length&&(v=!0,y()),h()},e=>{s&&i(Gc(e))})),x=()=>o&&[...c.values()].some(e=>[...e.values()].some(e=>!u.has(e.id)&&Date.now()-(Fc(e.submittedAt)||Date.now())<72e5)),S=setInterval(()=>{x()&&h()},Uc),C=()=>{document.visibilityState===`visible`&&x()&&h()};return document.addEventListener(`visibilitychange`,C),()=>{s=!1,b.forEach(e=>e()),clearInterval(S),document.removeEventListener(`visibilitychange`,C)}}function nl(e,t,n){let{user:i,isAdmin:a,roleConfirmed:s}=r.Ft(),c=i?.uid||``,{formId:l,paid:u=!1}=t,d=(0,K.useRef)(t);(0,K.useEffect)(()=>{d.current=t});let[f,p]=(0,K.useState)(``),m=Zc(e,l),h=(0,K.useSyncExternalStore)($c,()=>n?!1:Qc(e,l)),g=!!c&&a&&s&&o.Tn(e)&&!!l&&!h;return(0,K.useEffect)(()=>{if(!(!n||!o.Tn(e)||!l))return el(m,1),()=>el(m,-1)},[n,m,e,l]),(0,K.useEffect)(()=>{if(g)return tl(e,()=>d.current,c,p)},[g,e,l,u,c]),{error:g?f:``}}function rl(e,t){return nl(e,t,!0)}function il(e,t){return nl(e,t,!1)}function al({road:e}){let{error:t}=il(e.collection,{formId:e.formId,paid:e.paid,roles:e.roles,page:e.page});return(0,K.useEffect)(()=>{t&&a.s(r.ni(t,`none`))},[t]),null}function ol(){return(0,q.jsx)(q.Fragment,{children:C.i().map(e=>(0,q.jsx)(al,{road:e},`${e.collection}|${e.formId}`))})}function sl(){let{pathname:e,hash:t}=(0,Y.useLocation)(),n=(0,Y.useNavigationType)();return(0,K.useLayoutEffect)(()=>{if(!(n===`POP`||t))try{window.scrollTo({top:0,left:0,behavior:`instant`})}catch{}},[e,t,n]),null}sl.displayName=`ScrollToTop`;var cl=()=>Promise.resolve().then(()=>require(`./Users-Ayu_S4cd.cjs`)).then(e=>({default:e.UsersTab})),ll=()=>Promise.resolve().then(()=>require(`./SignInAdmin-JnhCefKY.cjs`)).then(e=>({default:e.SignInAdmin})),ul=()=>Promise.resolve().then(()=>require(`./Inbox-ChBLxjCi.cjs`)).then(e=>({default:e.Inbox})),dl=()=>Promise.resolve().then(()=>require(`./Assets-DoZlHuud.cjs`)).then(e=>({default:e.Assets})),fl=()=>Promise.resolve().then(()=>require(`./ThemeAdmin-B4CIxIjh.cjs`)).then(e=>({default:e.ThemeAdmin})),pl=()=>Promise.resolve().then(()=>require(`./PagesAdmin-8smM_SDx.cjs`)).then(e=>({default:e.PagesAdmin})),ml=()=>Promise.resolve().then(()=>require(`./FormsAdmin-Ck7ssCHd.cjs`)).then(e=>({default:e.FormsAdmin})),hl=()=>Promise.resolve().then(()=>require(`./PaymentsAdmin-DdP5FeXc.cjs`)).then(e=>({default:e.PaymentsAdmin})),gl=()=>Promise.resolve().then(()=>require(`./TransactionsAdmin-BiV8VgD0.cjs`)).then(e=>({default:e.TransactionsAdmin})),_l=()=>Promise.resolve().then(()=>require(`./ScheduleAdmin-ohFzK-5E.cjs`)).then(e=>({default:e.ScheduleAdmin})),vl=()=>Promise.resolve().then(()=>require(`./EmailAdmin-sa9C5jOw.cjs`)).then(e=>({default:e.EmailAdmin})),yl=()=>Promise.resolve().then(()=>require(`./SetupPayments-BLq0W5DU.cjs`)).then(e=>({default:e.SetupPayments})),bl=()=>Promise.resolve().then(()=>require(`./PublishApp-CYHX36oo.cjs`)).then(e=>({default:e.PublishApp})),xl=()=>Promise.resolve().then(()=>require(`./MyBookings-B424zfVj.cjs`)).then(e=>({default:e.MyBookings})),Sl=()=>Promise.resolve().then(()=>require(`./Billing-CBxVy-CG.cjs`)).then(e=>({default:e.Billing})),Cl=r.si(cl),wl=r.si(ll),Tl=r.si(ul),El=r.si(dl),Dl=r.si(fl),Ol=r.si(pl),kl=r.si(ml),Al=r.si(hl),jl=r.si(gl);r.si(_l);var Ml=r.si(vl),Nl=r.si(yl),Pl=r.si(bl);r.si(xl);var Fl=r.si(Sl),Il=[...[],Sl],Ll=[cl,ul,gl,...[]],Rl=[pl,ml,fl,ll,dl,hl,vl,bl,yl];function zl(){let{user:e,isAdmin:t,isInternal:n}=r.Ft();return(0,K.useEffect)(()=>{if(!e)return;let r=[...Il,...t||n?Ll:[],...t?Rl:[]],i=!1,a,o=e=>typeof window.requestIdleCallback==`function`?window.requestIdleCallback(e,{timeout:4e3}):window.setTimeout(e,1500),s=e=>typeof window.cancelIdleCallback==`function`?window.cancelIdleCallback(e):window.clearTimeout(e),c=()=>{let e=r.shift();!e||i||(a=o(()=>{e().catch(()=>{}).finally(c)}))};return c(),()=>{i=!0,a!==void 0&&s(a)}},[e,t,n]),null}function Bl(){return(0,q.jsxs)(`div`,{className:`fixed top-0 left-0 w-full h-full pointer-events-none -z-0 overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`fbos-orb-1 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,q.jsx)(`div`,{className:`fbos-orb-2 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]`})]})}var Vl={pageId:`home`};function Hl({Page:e}){return pn(),r.Rr(),(0,q.jsx)(`div`,{className:`fbos-home-slot contents`,children:(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(te.t,{config:Vl,children:e===Pn?(0,q.jsx)(e,{}):(0,q.jsx)(rn,{which:`home`,fallback:(0,q.jsx)(Pn,{}),onlyMissing:!0,neverPutAside:!nn(e),children:(0,q.jsx)(e,{})})})})})}function Ul(){let{isAdmin:e}=r.Ft();return(0,q.jsx)(cn,{isAdmin:!!e})}function Wl(){let e=r.mi().components?.Home||Pn,t=(0,Y.useNavigate)(),n=(0,Y.useLocation)();return(0,q.jsx)(r.Nt,{onSignedOut:()=>t(`/`,{replace:!0}),onRemoved:()=>t(Zs,{replace:!0}),children:(0,q.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-clip`,children:[(0,q.jsxs)(un,{children:[(0,q.jsx)(j.p,{size:`part`,children:(0,q.jsx)(Mn,{})}),(0,q.jsx)(sl,{}),(0,q.jsx)(zi,{}),(0,q.jsx)(qi,{}),(0,q.jsxs)(j.p,{resetKey:n.pathname,children:[(0,q.jsx)(zl,{}),(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(bc,{}),children:(0,q.jsxs)(Y.Routes,{children:[(0,q.jsx)(Y.Route,{path:`/`,element:(0,q.jsx)(Tc,{children:(0,q.jsx)(Hl,{Page:e})})}),(0,q.jsx)(Y.Route,{path:`/register`,element:(0,q.jsx)(Tc,{landing:`/dashboard?${L.n}=1`,children:(0,q.jsx)(Br,{})})}),(0,q.jsx)(Y.Route,{path:`/login`,element:(0,q.jsx)(Tc,{children:(0,q.jsx)(Vr,{})})}),(0,q.jsx)(Y.Route,{path:`/reset-password`,element:(0,q.jsx)(Tc,{children:(0,q.jsx)(Ii,{})})}),(0,q.jsx)(Y.Route,{path:`/verify`,element:(0,q.jsx)(Ec,{children:(0,q.jsx)(ri,{})})}),(0,q.jsx)(Y.Route,{path:`/confirm-email`,element:(0,q.jsx)(oi,{})}),(0,q.jsx)(Y.Route,{path:`/two-step`,element:(0,q.jsx)(Dc,{children:(0,q.jsx)(gi,{})})}),(0,q.jsx)(Y.Route,{path:`/your-details`,element:(0,q.jsx)(Oc,{children:(0,q.jsx)(Ci,{})})}),(0,q.jsx)(Y.Route,{path:`/book/:id`,element:(0,q.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/meet/:id`,element:(0,q.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/book`,element:(0,q.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/booking`,element:(0,q.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/pay/:id`,element:(0,q.jsx)(Xi,{})}),(0,q.jsx)(Y.Route,{path:`/payment-complete`,element:(0,q.jsx)(cc,{})}),(0,q.jsx)(Y.Route,{path:`/payment-cancelled`,element:(0,q.jsx)(cc,{cancelled:!0})}),(0,q.jsx)(Y.Route,{path:`/guide`,element:(0,q.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/templates`,element:(0,q.jsx)(Y.Navigate,{to:`/`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/users`,element:(0,q.jsx)(wc,{tab:`users`,children:(0,q.jsx)(Cl,{})})}),(0,q.jsx)(Y.Route,{path:`/users/:id`,element:(0,q.jsx)(wc,{tab:`users`,children:(0,q.jsx)(Cl,{})})}),(0,q.jsx)(Y.Route,{path:`/sign-in`,element:(0,q.jsx)(Cc,{children:(0,q.jsx)(wl,{})})}),(0,q.jsx)(Y.Route,{path:`/inbox`,element:(0,q.jsx)(wc,{tab:`inbox`,children:(0,q.jsx)(Tl,{})})}),(0,q.jsx)(Y.Route,{path:`/payments`,element:(0,q.jsx)(Cc,{children:(0,q.jsx)(Al,{})})}),(0,q.jsx)(Y.Route,{path:`/transactions`,element:(0,q.jsx)(wc,{tab:`transactions`,children:(0,q.jsx)(jl,{})})}),(0,q.jsx)(Y.Route,{path:`/schedule`,element:(0,q.jsx)(Y.Navigate,{to:`/dashboard`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/my-calendar`,element:(0,q.jsx)(Y.Navigate,{to:`/dashboard`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/my-bookings`,element:(0,q.jsx)(Y.Navigate,{to:`/dashboard`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/calendar`,element:(0,q.jsx)(Y.Navigate,{to:`/dashboard`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/bookings`,element:(0,q.jsx)(Y.Navigate,{to:`/dashboard`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/email`,element:(0,q.jsx)(Cc,{children:(0,q.jsx)(Ml,{})})}),(0,q.jsx)(Y.Route,{path:`/submissions`,element:(0,q.jsx)(Y.Navigate,{to:`/inbox`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/requests`,element:(0,q.jsx)(Y.Navigate,{to:`/inbox`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/assets`,element:(0,q.jsx)(Cc,{children:(0,q.jsx)(El,{})})}),(0,q.jsx)(Y.Route,{path:`/drive`,element:(0,q.jsx)(Y.Navigate,{to:`/assets`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/drive/:rest`,element:(0,q.jsx)(Y.Navigate,{to:`/assets`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/theme`,element:(0,q.jsx)(Cc,{children:(0,q.jsx)(Dl,{})})}),(0,q.jsx)(Y.Route,{path:`/pages/*`,element:(0,q.jsx)(Cc,{children:(0,q.jsx)(Ol,{})})}),(0,q.jsx)(Y.Route,{path:`/forms/*`,element:(0,q.jsx)(Cc,{children:(0,q.jsx)(kl,{})})}),(0,q.jsx)(Y.Route,{path:`/settings`,element:(0,q.jsx)(Y.Navigate,{to:`/pages`,replace:!0})}),(0,q.jsx)(Y.Route,{path:`/profile`,element:(0,q.jsx)(Sc,{children:(0,q.jsx)(Fi,{})})}),(0,q.jsx)(Y.Route,{path:`/billing`,element:(0,q.jsx)(Sc,{children:(0,q.jsx)(Fl,{})})}),(0,q.jsx)(Y.Route,{path:`/dashboard`,element:(0,q.jsx)(Sc,{children:(0,q.jsx)(uc,{})})}),(0,q.jsx)(Y.Route,{path:`/publish`,element:(0,q.jsx)(Cc,{children:(0,q.jsx)(Pl,{})})}),(0,q.jsx)(Y.Route,{path:`/setup`,element:(0,q.jsx)(se.r,{})}),(0,q.jsx)(Y.Route,{path:`/setup/payments`,element:(0,q.jsx)(Nl,{})}),(0,q.jsx)(Y.Route,{path:`*`,element:(0,q.jsx)(ic,{})})]})})]})]}),(0,q.jsx)(Bl,{}),(0,q.jsx)(ze,{}),(0,q.jsx)(Ul,{}),(0,q.jsx)(ol,{}),(0,q.jsx)(k.t,{})]})})}function Gl(){return(0,q.jsxs)(j.p,{children:[(0,q.jsx)(Y.BrowserRouter,{children:(0,q.jsx)(Kl,{})}),(0,q.jsx)(a.n,{})]})}function Kl(){let e=r.mi();return e.firebaseConfig&&e.firebaseConfig.apiKey&&e.firebaseConfig.apiKey.trim()!==``&&e.firebaseConfig.projectId&&e.firebaseConfig.projectId.trim()!==``||se.i()?(0,q.jsx)(Wl,{}):(0,q.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-clip`,children:[(0,q.jsx)(Mn,{standalone:!0}),(0,q.jsx)(se.r,{standalone:!0}),(0,q.jsx)(Bl,{})]})}function ql(e){return(0,q.jsx)(`div`,{className:`firebase-os flex-1 flex flex-col min-h-screen`,style:{background:`var(--bg-gradient)`,color:`var(--fg-color)`},children:(0,q.jsx)(j.p,{children:(0,q.jsx)(Jl,{...e})})})}function Jl(e){Pe();let t=e.firebaseConfig;return t&&t.apiKey&&t.apiKey.trim()!==``&&t.projectId&&t.projectId.trim()!==``&&r.di(t),j.a(e.pageFiles),(0,q.jsx)(r.pi,{config:{firebaseConfig:e.firebaseConfig,basename:e.basename,onAuthChange:e.onAuthChange,themeConfig:e.themeConfig,components:e.components,customRoutes:e.customRoutes,microcomponents:e.microcomponents,pageFiles:e.pageFiles,defaultConfigs:e.defaultConfigs},children:(0,q.jsx)(i.M,{children:(0,q.jsx)(Gl,{})})})}var Yl=[`views`,`added`,`clicks`,`saves`,`shares`,`downloads`],Xl=`mem_tallies`,Zl=`Needs the rules pasted from /setup at 1.14.66 or later.`,Ql=Object.freeze({views:0,added:0,clicks:0,saves:0,shares:0,downloads:0}),$l=e=>String(e??``).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40),eu=e=>String(e??``).trim().replace(/\//g,`_`).slice(0,120),tu=(e,t)=>{let n=$l(e),r=eu(t);return n&&r?`${n}_${r}`:null};function nu(e){let t={...Ql};for(let n of Yl){let r=Math.floor(Number(e?.[n]));Number.isFinite(r)&&r>0&&(t[n]=r)}return t}var ru=new Set,iu=e=>{if(ru.has(e))return!0;try{return window.sessionStorage.getItem(e)===`1`}catch{return!1}},au=e=>{ru.add(e);try{window.sessionStorage.setItem(e,`1`)}catch{}},ou=()=>{let e=r.li?.currentUser?.uid;if(!e)return!1;try{let t=window.localStorage.getItem(r.Pt(e));return t===`admin`||t===`internal`}catch{return!1}},su=!1;async function cu(e,t,n=`views`){try{let i=tu(e,t);if(!i||!Yl.includes(n))return console.error(`tally('${e}', '${t}', '${n}'): a tally needs what is counted ('products'), the record's id, and one of ${Yl.join(`, `)}.`),!1;let a=`fbos.tally.${i}.${n}`;return iu(a)||ou()?!1:(au(a),await(0,J.setDoc)((0,J.doc)(r.ui,Xl,i),{thing:$l(e),of:eu(t),[n]:(0,J.increment)(1)},{merge:!0}),!0)}catch(e){return!su&&e?.code===`permission-denied`&&(su=!0,console.warn(`tally(): the database refused the count. ${Zl}`)),!1}}function lu(e){let{accessLevel:t}=r.Ft(),n=t===`admin`||t===`internal`,i=$l(e),[a,o]=(0,K.useState)(new Map),[s,c]=(0,K.useState)(!0),[l,u]=(0,K.useState)(null);return(0,K.useEffect)(()=>{if(!n||!i){o(new Map),c(!1);return}return c(!0),u(null),(0,J.onSnapshot)((0,J.query)((0,J.collection)(r.ui,Xl),(0,J.where)(`thing`,`==`,i)),e=>{let t=new Map;e.docs.forEach(e=>{let n=e.data()||{};t.set(String(n.of??``),nu(n))}),o(t),c(!1)},e=>{u(r.ii(e,`The counts could not be read.`)),c(!1)})},[n,i]),(0,K.useMemo)(()=>{let e={...Ql};for(let t of a.values())for(let n of Yl)e[n]+=t[n];return{loading:s,error:l,of:e=>a.get(eu(e))||Ql,total:e}},[a,s,l])}var uu=e=>typeof e==`string`?e.trim():e==null?``:String(e).trim(),du=e=>{let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:0},fu=e=>Math.round(e*100);function pu(e){let t=[];for(let n of Array.isArray(e)?e:[]){let e=uu(n?.name),r=Math.floor(du(n?.quantity??1));if(!e||r<1)continue;let i={};try{i=JSON.parse(JSON.stringify(n))||{}}catch{i={}}let a={...i,name:e,quantity:r,price:du(n?.price)};for(let e of[`id`,`options`,`picture`])uu(n?.[e])?a[e]=uu(n[e]):delete a[e];t.push(a)}return t}var mu=e=>(Array.isArray(e)?e:[]).map(e=>({label:uu(e?.label),amount:du(e?.amount)})).filter(e=>e.label&&e.amount!==0),hu=e=>e.reduce((e,t)=>e+fu(t.price)*t.quantity,0)/100,gu=(e,t=[])=>(fu(hu(e))+t.reduce((e,t)=>e+fu(t.amount),0))/100;function _u(e,t=`usd`,n=480){let r=e.map(e=>`${e.quantity} × ${e.name}${e.options?` — ${e.options}`:``} · ${ac(e.price*e.quantity,t)}`),i=``;for(let e=0;e<r.length;e+=1){let t=i?`${i}; ${r[e]}`:r[e],a=r.length-e-1;if((t+(a?`; and ${a} more`:``)).length>n)return i?`${i}; and ${r.length-e} more`:r[e].slice(0,n);i=t}return i}var vu=new Set([`uid`,`formId`,`submittedAt`,`submitterName`,`submitterEmail`,`submitterAvatar`,`transaction`,`arrivedIn`,`access`,`editors`]);function yu(e,t,n,r,i){let a={items:e,extras:t,subtotal:hu(e),total:gu(e,t),currency:(n||`usd`).toLowerCase(),name:uu(r.name),email:uu(r.email),phone:uu(r.phone),address:uu(r.address)},o={};try{o=JSON.parse(JSON.stringify(i||{}))||{}}catch{o={}}for(let[e,t]of Object.entries(o))e in a||vu.has(e)||(a[e]=t);return a}var bu=`fbos_checkout_entry`,xu=(e,t)=>JSON.stringify([e,t]);function Su(e){try{let t=JSON.parse(window.sessionStorage.getItem(bu)||`null`);return t&&t.print===e&&typeof t.id==`string`?t.id:``}catch{return``}}function Cu(){try{window.sessionStorage.removeItem(bu)}catch{}}var wu=`fbos_checkout_guest`;function Tu(e){try{e?window.sessionStorage.setItem(wu,e):window.sessionStorage.removeItem(wu)}catch{}}function Eu(){try{let e=window.sessionStorage.getItem(wu)||``;return window.sessionStorage.removeItem(wu),e}catch{return``}}async function Du(e,t){let n=xu(e,t),i=Su(n);if(i)return i;let a=r.li?.currentUser,o=await(0,J.addDoc)((0,J.collection)(r.ui,`user_submissions`),{...t,...a?{uid:a.uid,submitterName:a.displayName||t.name,submitterEmail:a.email||t.email,submitterAvatar:a.photoURL||``}:{uid:`guest`},formId:e,transaction:!0,submittedAt:(0,J.serverTimestamp)()});try{window.sessionStorage.setItem(bu,JSON.stringify({print:n,id:o.id}))}catch{}return o.id}var Ou=e=>{let t=Math.floor(Number(e));return Number.isFinite(t)&&t>0?t:0},ku=e=>String(e.variantId??e.variant??``).trim();function Au(e,t,n){let r=n.filter(t=>String(t.id??``)===e&&Ou(t.quantity)>0);if(!r.length)return null;let i=String(t?.name??t?.title??r[0].name??``),a=[],o=Array.isArray(t?.variants)?t.variants.map(e=>({...e})):null,s=typeof t?.stock==`number`?t.stock:null,c=!1,l=!1;for(let t of r){let n=Ou(t.quantity),r=ku(t),u=o&&r?o.findIndex(e=>String(e?.id??``)===r):-1;if(o&&u>=0&&typeof o[u].stock==`number`){let t=o[u].stock,s=Math.max(0,t-n);o[u].stock=s,c=!0,a.push({id:e,variantId:r,name:i,variantName:String(o[u].name??``),quantity:n,from:t,to:s})}else if(s!==null){let t=s,r=Math.max(0,t-n);s=r,l=!0,a.push({id:e,name:i,quantity:n,from:t,to:r})}}if(!a.length)return null;let u={};return c&&(u.variants=o),l&&(u.stock=s),{fields:u,changes:a}}var ju=e=>({id:e.id,who:{name:String(e.name||e.submitterName||``),email:String(e.email||e.submitterEmail||``)},at:Fc(e.submittedAt)||Date.now(),items:pu(e.items)}),Mu=e=>e?.code===`permission-denied`?`The orders could not be read to take their stock. The security rules may need pasting again from the Setup screen.`:`The stock for what was sold could not be updated just now.`;function Nu(e,t,n){let{formId:i}=t(),a=!0,o=new Map,s=new Map,c=new Set,l=!1,u=!1,d=async n=>{let i=ju(n),a=[...new Set(i.items.map(e=>String(e.id??``)).filter(Boolean))],o=[];try{await(0,J.runTransaction)(r.ui,async t=>{o=[];let s=(0,J.doc)(r.ui,n.from,n.id),c=await t.get(s);if(!c.exists()||Ac(c.data()?.stockTakenIn).includes(e))return;let l=[];for(let n of a){let i=await t.get((0,J.doc)(r.ui,e,n));l.push({id:n,data:i.exists()?i.data():null})}for(let{id:n,data:a}of l){let s=a?Au(n,a,i.items):null;s&&(t.update((0,J.doc)(r.ui,e,n),{...s.fields,editedName:i.who.name||`A customer`,editedAt:i.at}),o.push(...s.changes))}t.update(s,{stockTakenIn:(0,J.arrayUnion)(e)})})}catch(e){return Mu(e)}if(o.length)try{t().onTaken?.(i,o)}catch{}return``},f=async()=>{if(l){u=!0;return}l=!0;try{let e=[...o.values()].flatMap(e=>[...e.values()]).filter(e=>!c.has(e.id));if(!e.length)return;let t=[...s.values()].flat(),r=await Wc(e.map(e=>e.id),t);if(!a)return;let i=r.error;for(let n of e){if(!Rc(n.id,r.sales,n,t))continue;let e=await d(n);if(!a)return;e?i||=e:c.add(n.id)}n(i)}finally{l=!1,u&&a&&(u=!1,f())}},p=kc.map(t=>(0,J.onSnapshot)((0,J.query)((0,J.collection)(r.ui,t),(0,J.where)(`formId`,`==`,i)),n=>{let r=new Map,a=[];for(let o of n.docs){let n=o.data()||{},s={...n,id:o.id,uid:String(n.uid||`guest`),formId:i,from:t};a.push(s),!Ac(n.stockTakenIn).includes(e)&&r.set(o.id,s)}o.set(t,r),s.set(t,a),f()},e=>{a&&n(Mu(e))})),m=()=>[...o.values()].some(e=>[...e.values()].some(e=>!c.has(e.id)&&Date.now()-(Fc(e.submittedAt)||Date.now())<72e5)),h=setInterval(()=>{m()&&f()},Uc),g=()=>{document.visibilityState===`visible`&&m()&&f()};return document.addEventListener(`visibilitychange`,g),()=>{a=!1,p.forEach(e=>e()),clearInterval(h),document.removeEventListener(`visibilitychange`,g)}}var Pu=/^(?:mem|admin|role_[a-z][a-z0-9]*)_[A-Za-z0-9_]+$/;function Fu(e,t){let{user:n,isAdmin:i,roleConfirmed:a}=r.Ft(),o=n?.uid||``,{formId:s}=t,c=(0,K.useRef)(t);(0,K.useEffect)(()=>{c.current=t});let[l,u]=(0,K.useState)(``),d=Pu.test(String(e||``)),f=!!o&&i&&a&&d&&!!s;return(0,K.useEffect)(()=>{d||console.error(`useStockFromOrders('${e}'): stock is kept by the page that keeps the products — a mem_, admin_ or role_<id>_ collection. Never a pub_ one: that is the app's own copy (usePublicCopy), and it follows the record by itself.`)},[d,e]),(0,K.useEffect)(()=>{if(f)return Nu(e,()=>c.current,u)},[f,e,s,o]),{error:f?l:``}}var Iu=r.si(()=>Promise.resolve().then(()=>require(`./PhoneInputField-WYdkNEym.cjs`))),Lu=r.si(()=>Promise.resolve().then(()=>require(`./AddressField-CI8PP5ow.cjs`))),Ru={},zu=`address`,Bu=/^[^\s@,;]+@[^\s@,;.]+(\.[^\s@,;.]+)*\.[a-z]{2,}$/i;function Vu(e=e=>{let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t)}){return`${e(24).map(e=>`ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789`[e%57]).join(``)}Aa9!`}function Hu(e){let t={};return e.name&&(t.name=e.name),e.email&&(t.email=e.email),e.phone&&(t.phone=e.phone),e.address&&(t.address=e.address),t}function Uu(e,t){let n={};return e.name.trim()||(n.name=`Please give your name.`),Bu.test(e.email.trim())||(n.email=`Please give a real email address — the receipt goes there.`),t.phone===!0&&!e.phone.trim().replace(/^\+\d{1,3}$/,``)&&(n.phone=`Please give a phone number.`),t.address===!0&&!F.c(F.u(e.address))&&(n.address=`Please give the address.`),n}var Wu=`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,Gu=`leading-snug break-words [overflow-wrap:anywhere]`;function Ku({phone:e,address:t,onReady:n,onEditing:i,heading:a=`Your details`,continueLabel:o=`Continue`,wide:s=!1,className:c=``}){let{user:l,profile:u,profileReady:d,loading:f}=r.Ft(),p=r.Cn(),m=String(l?.displayName||u?.displayName||``).trim(),h=String(l?.email||u?.email||``).trim(),_=String(l?.phoneNumber||u?.phone||``).trim(),v=F.i(zu,u||{}),[y,b]=(0,K.useState)(m),[x,C]=(0,K.useState)(h),[w,T]=(0,K.useState)(_),[E,D]=(0,K.useState)(v),[O,k]=(0,K.useState)({}),[A,j]=(0,K.useState)(``),[M,P]=(0,K.useState)(!1),[ee,te]=(0,K.useState)(null),[I,L]=(0,K.useState)(!1),ne=g._(g.p,Ru),R=ne.ready?ne.value:Ru,z=String(R.name||``)||m,re=String(R.email||``)||h,ie=String(R.phone||``)||_,B=R.address&&F.c(R.address)?{...F.n,...R.address}:v,V=(0,K.useRef)(!1);(0,K.useEffect)(()=>{V.current||(b(z),C(re),T(ie),D(B))},[`${z}|${re}|${ie}|${F.s(B)}`]);let ae=ne.setValue;(0,K.useEffect)(()=>{V.current&&ae({name:y,email:x,phone:w,address:E})},[y,x,w,E,ae]);let oe=(0,K.useRef)(``),H=!!l?.uid,se=H&&d&&!!m&&Bu.test(h)&&(e!==!0||!!_)&&(t!==!0||F.c(v));(0,K.useEffect)(()=>{if(!se||I||ee||!l?.uid||oe.current===l.uid)return;oe.current=l.uid;let e=qu(l.uid,m,h,_,v);te(e),n(e,{pressed:!1})},[se,I,ee,l?.uid]);let U=(0,K.useRef)(H),ce=ne.clear;(0,K.useEffect)(()=>{let e=U.current&&!H;U.current=H,!H&&(oe.current=``,te(null),L(!1),e&&ce())},[H,ce]);let W={phone:e,address:t},le=!p.loading&&p.on?.emailLink===!0,G=(e,t)=>{V.current=!0,t(),O[e]&&k(t=>{let{[e]:n,...r}=t;return r}),A&&j(``)},de=async()=>{if(M)return;let e=Uu({name:y,email:x,phone:w,address:E},W);if(k(e),Object.keys(e).length){j(`There is something to check below.`);return}P(!0),j(``);let t=y.trim(),i=x.trim(),a=w.trim(),o=F.u(E);try{let e=l?.uid||``,s=!1,c=r.li.currentUser;if(e)c&&t&&t!==m&&await(0,ue.updateProfile)(c,{displayName:t}).catch(()=>{});else{let n=await(0,ue.createUserWithEmailAndPassword)(r.li,i,Vu());c=n.user,e=n.user.uid,s=!0,await(0,ue.updateProfile)(n.user,{displayName:t}).catch(()=>{}),await n.user.getIdToken(!0).catch(()=>{})}let u={uid:e,displayName:t,...s?{email:i,createdAt:new Date().toISOString()}:{},...a?{phone:a}:{},...F.c(o)?F.r(zu,o):{}};try{await(0,J.setDoc)((0,J.doc)(r.ui,`user_profiles`,e),u,{merge:!0})}catch(e){if(console.warn(`BuyerDetails: the details could not be written to the profile.`,e),!s)throw e}s&&c&&r.wn(c);let d=qu(e,t,s?i:h||i,a,o,{registered:s});oe.current=e,te(d),L(!1),n(d,{pressed:!0})}catch(e){if(e?.code===`auth/email-already-in-use`){let e=qu(``,t,i,a,o,{guest:!0});te(e),L(!1),n(e,{pressed:!0})}else e?.code?j((await r.Kt(e,`password`,`That did not work. Check your details and try again.`,{email:i})).text):j(r.ii(e,`Your details could not be saved. Please try again.`))}finally{P(!1)}};if(f||H&&!d)return(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl ${c}`,"aria-hidden":!0});if(ee&&!I){let e=[ee.email,ee.phone].map(e=>String(e||``).trim()).filter(Boolean),t=F.a(ee.addressParts);return(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.3,ease:`easeOut`},className:`rounded-2xl border border-[var(--panel-border)] bg-foreground/[0.035] px-4 py-3.5 text-left ${c}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/45 leading-tight select-none`,children:`Paying as`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{V.current=!0,L(!0),i?.()},className:`text-[13px] font-semibold text-accent hover:underline cursor-pointer leading-tight shrink-0`,children:`Change`})]}),(0,q.jsx)(`p`,{className:`${Gu} mt-1 text-[14.5px] font-semibold text-foreground`,children:ee.name}),(e.length>0||t.length>0)&&(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-0.5 text-[13.5px] text-foreground/65`,children:[e.map(e=>(0,q.jsx)(`span`,{className:Gu,children:e},e)),t.length>0&&(0,q.jsx)(`span`,{className:`flex flex-col gap-0.5 ${e.length?`mt-2`:``}`,children:t.map((e,t)=>(0,q.jsx)(`span`,{className:Gu,children:e},t))})]}),ee.guest&&le&&(0,q.jsx)(`p`,{className:`mt-3 pt-3 border-t border-[var(--panel-border)]/70 text-[12.5px] text-foreground/50 leading-snug`,children:`We will email you a link to your order once you have paid.`})]})}return(0,q.jsxs)(`form`,{className:`flex flex-col gap-4 w-full ${c}`,onSubmit:e=>{e.preventDefault(),de()},noValidate:!0,children:[a&&(0,q.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground tracking-tight`,children:a}),A&&(0,q.jsx)(S.t,{tone:`error`,children:A}),(0,q.jsx)(g.y,{label:`Full name`,"aria-label":`Full name`,name:`name`,autoComplete:`name`,placeholder:`John Doe`,value:y,error:O.name,disabled:M,onChange:e=>G(`name`,()=>b(e.target.value)),className:`max-sm:h-11`}),(0,q.jsx)(g.y,{label:`Email`,"aria-label":`Email`,name:`email`,type:`email`,autoComplete:`email`,placeholder:`name@example.com`,value:x,error:O.email,disabled:M||H&&!!h,onChange:e=>G(`email`,()=>C(e.target.value)),className:`max-sm:h-11`}),e&&(0,q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,q.jsx)(Iu,{field:{label:e===`optional`?`Phone (optional)`:`Phone`,required:e===!0},value:w,onChange:e=>G(`phone`,()=>T(e))})}),O.phone&&(0,q.jsx)(`p`,{className:`text-xs text-red-500 font-medium mt-1 ml-1`,children:O.phone})]}),t&&(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel animate-pulse rounded-xl`}),children:(0,q.jsx)(Lu,{id:`buyer-address`,label:t===`optional`?`Address (optional)`:`Address`,required:t===!0,disabled:M,error:O.address,value:E,onChange:e=>G(`address`,()=>D(e))})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(N.t,{type:`submit`,isLoading:M,disabled:M,className:`w-full ${s?`py-3.5 text-[15px]`:`sm:w-auto sm:self-start py-2.5 text-[14px]`} px-6 font-bold tracking-wide rounded-xl`,children:o}),!H&&(0,q.jsx)(`p`,{className:`${Wu} mb-0`,children:`This makes your account, so you can find your order again. We will email you a link to confirm your address.`})]})]})}function qu(e,t,n,r,i,{registered:a=!1,guest:o=!1}={}){let s={name:t,email:n,phone:r,address:F.c(i)?F.s(i):``};return{uid:e,...s,addressParts:F.c(i)?i:{...F.n},metadata:Hu(s),registered:a,guest:o}}var Ju=`flex items-baseline justify-between gap-4 text-[14px]`,Yu=`w-full py-3.5 text-[15px] font-bold tracking-wide`;function Xu({formId:e,items:t,collection:n,extras:i,currency:a,phone:s,address:c,carry:l,productName:u,metadata:d,successPath:f,cancelPath:p,summary:m=!0,payLabel:h=`Pay`,className:g=``}){let{loading:_,configured:v}=r.zn(),y=r.Rr(),b=a||y||`usd`,{userRole:x}=r.Ft(),{pathname:S,search:C}=(0,Y.useLocation)(),[w,T]=(0,K.useState)(null),[E,D]=(0,K.useState)(!1),[O,k]=(0,K.useState)(``),A=(0,K.useMemo)(()=>pu(t),[t]),j=(0,K.useMemo)(()=>mu(i),[i]),M=gu(A,j);if(_)return null;if(!v)return o.wn(x)?(0,q.jsx)(`span`,{className:`text-[12.5px] font-medium text-foreground/50 leading-snug`,children:`Only admins see this: payments are not on yet, so the checkout is hidden. Connect Stripe and switch payments on at /payments and it appears here.`}):null;if(!A.length)return(0,q.jsx)(`p`,{className:`text-[14px] text-foreground/55 ${g}`,children:`There is nothing in your basket yet.`});let P=A.some(e=>!!e.picture),ee=`${h} ${ac(M,b)}`,F=async t=>{if(E||!t||M<=0)return;let i=t;if(D(!0),k(``),!a&&!y&&await r.Ir()){k(r.Pr),D(!1);return}let o=``;try{o=await Du(e,yu(A,j,b,i,l))}catch(e){k(r.ii(e,`Your order could not be saved, so no payment was taken. Please try again.`)),D(!1);return}Tu(i.guest?i.email:``);let s=await r.Fn({amount:M,currency:b,productName:u||(A.length===1?A[0].name:`Order of ${A.reduce((e,t)=>e+t.quantity,0)} items`),lines:A.map(e=>({name:e.name,amount:e.price,quantity:e.quantity,record:e.id?String(e.id):void 0,variant:e.variantId==null?e.variant==null?void 0:String(e.variant):String(e.variantId),options:e.options,collection:e.collection?String(e.collection):n||void 0})),extras:j,metadata:{...d,...i.metadata,orderEntryId:o,items:_u(A,b),total:String(M)},successPath:f||S,cancelPath:p||`${S}${C}`});s&&(k(s),D(!1))};return(0,q.jsxs)(`div`,{className:`flex flex-col gap-8 ${g}`,children:[m&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[A.map((e,t)=>P?(0,q.jsxs)(`div`,{className:`flex items-center gap-3 text-[14px]`,children:[(0,q.jsx)(`div`,{className:`relative w-12 h-12 shrink-0 rounded-xl overflow-hidden bg-foreground/5`,children:e.picture&&(0,q.jsx)(r.O,{src:e.picture,alt:``,fit:`cover`,className:`absolute inset-0`})}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 flex flex-col leading-snug`,children:[(0,q.jsx)(`span`,{className:`truncate font-medium text-foreground/85`,children:e.name}),(0,q.jsx)(`span`,{className:`truncate text-[13px] text-foreground/50`,children:[e.options,e.quantity>1?`× ${e.quantity}`:``].filter(Boolean).join(` · `)})]}),(0,q.jsx)(`span`,{className:`shrink-0 tabular-nums text-foreground/80`,children:ac(e.price*e.quantity,b)})]},`${e.id||e.name}-${t}`):(0,q.jsxs)(`div`,{className:Ju,children:[(0,q.jsxs)(`span`,{className:`min-w-0 text-foreground/80`,children:[e.quantity,` × `,e.name,e.options&&(0,q.jsxs)(`span`,{className:`text-foreground/50`,children:[` — `,e.options]})]}),(0,q.jsx)(`span`,{className:`shrink-0 tabular-nums text-foreground/80`,children:ac(e.price*e.quantity,b)})]},`${e.id||e.name}-${t}`)),j.length>0&&(0,q.jsxs)(`div`,{className:`${Ju} text-foreground/55`,children:[(0,q.jsx)(`span`,{children:`Subtotal`}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:ac(hu(A),b)})]}),j.map(e=>(0,q.jsxs)(`div`,{className:`${Ju} text-foreground/55`,children:[(0,q.jsx)(`span`,{children:e.label}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:ac(e.amount,b)})]},e.label)),(0,q.jsxs)(`div`,{className:`${Ju} pt-3 border-t border-[var(--panel-border)] font-semibold text-foreground`,children:[(0,q.jsx)(`span`,{children:`Total`}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:ac(M,b)})]})]}),(0,q.jsx)(Ku,{phone:s,address:c,wide:!0,continueLabel:ee,onReady:(e,t)=>{T(e),t?.pressed&&F(e)},onEditing:()=>T(null)}),w&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(N.t,{onClick:()=>F(w),isLoading:E,disabled:E||M<=0,className:Yu,children:ee}),!O&&(0,q.jsx)(`span`,{className:`text-[12.5px] text-foreground/45 leading-snug text-center`,children:E?`Opening the secure payment page…`:`Secure payment. Your card is entered on the next page.`}),O&&(0,q.jsx)(`span`,{role:`alert`,className:`text-[13px] font-semibold text-foreground/80 leading-snug`,children:O})]})]})}var Zu=new Map,Qu=new Set,$u=new Map,ed=new Map;function td({basket:e,orderPath:t,onPaid:n,title:i=`Thank you — your order is in`,thanks:a=`Your payment went through.`,orderLabel:o=`View your order`}){let[s,c]=(0,Y.useSearchParams)(),l=(0,Y.useNavigate)(),{user:u,loading:d}=r.Ft(),f=r.Cn(),p=s.get(`session_id`)||``,[m,h]=(0,K.useState)(null),[_,v]=(0,K.useState)(null),[y,b]=(0,K.useState)(null),[x,S]=(0,K.useState)(!1),C=(0,K.useRef)(n);(0,K.useEffect)(()=>{C.current=n}),(0,K.useEffect)(()=>{if(!p.startsWith(`cs_`))return;let t=!0,n=Zu.get(p)||r.An(p);return Zu.set(p,n),n.then(n=>{if((n.paid||r.In(n))&&!Qu.has(p)){Qu.add(p),e&&g.h(e),g.h(g.p),Cu();let t=Eu();if(n.paid){t&&$u.set(p,t);try{C.current?.(n)}catch{}}}if(t){if(h(n),n.paid&&v({session:p,guest:$u.get(p)||``}),n.error){Zu.delete(p);return}c(e=>{let t=new URLSearchParams(e);return t.delete(`session_id`),t},{replace:!0})}}),()=>{t=!1}},[p,e,c]);let w=_&&!d&&!u?_.guest:``,T=!f.loading&&f.on?.emailLink===!0,E=t||`/billing`;(0,K.useEffect)(()=>{if(!w||!T||!_)return;let e=!0,t=ed.get(_.session)||r.Wt(w,`/login?from=${encodeURIComponent(E)}`).then(()=>!0,()=>!1);return ed.set(_.session,t),t.then(t=>{e&&b(t)}),()=>{e=!1}},[w,T,_,E]);let D=x?`idle`:m?m.paid?`paid`:r.In(m)?`clearing`:`unpaid`:p.startsWith(`cs_`)?`asking`:`idle`;if(D===`idle`)return null;let O=()=>S(!0);if(D===`asking`)return(0,q.jsx)(M.t,{open:!0,onClose:O,busy:!0,size:`sm`,children:(0,q.jsx)(P.t,{block:!0,label:`Confirming your payment…`})});if(D===`clearing`)return(0,q.jsx)(M.t,{open:!0,onClose:O,size:`sm`,title:`Your payment is on its way`,footer:(0,q.jsx)(N.t,{onClick:O,className:`w-full`,children:`Done`}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-[14px] text-foreground/70 leading-relaxed`,children:[(0,q.jsx)(`p`,{children:`Your bank is still sending it, which can take a few days. Your order is in: there is nothing more to do, and please do not pay again.`}),m?.receiptLater&&m.customerEmail&&(0,q.jsxs)(`p`,{children:[`We will email a receipt to `,m.customerEmail,` once it arrives.`]})]})});if(D===`unpaid`)return(0,q.jsx)(M.t,{open:!0,onClose:O,size:`sm`,title:m?.error?`We could not check your payment just now`:`Your payment did not go through`,footer:(0,q.jsx)(N.t,{onClick:O,className:`w-full`,children:m?.error?`Close`:`Back to your basket`}),children:(0,q.jsx)(`p`,{className:`text-[14px] text-foreground/70 leading-relaxed`,children:m?.error?`${m.error} If you finished paying, your order is safe — please do not pay again.`:`Nothing was taken, and your basket is just as you left it.`})});let k=m?.amountTotal==null?``:ac(m.amountTotal,m.currency||void 0),A=m?.receipt&&m.customerEmail,j=!w||f.loading?``:T&&y===null?`sending`:T&&y?`sent`:`sign-in`,ee=`/login?email=${encodeURIComponent(w)}&from=${encodeURIComponent(E)}${j===`sent`?`&sent=1`:``}`,F=u?E:w?ee:t;return(0,q.jsx)(M.t,{open:!0,onClose:O,size:`sm`,title:i,footer:F?(0,q.jsx)(N.t,{onClick:()=>{O(),l(F)},className:`w-full`,children:o}):(0,q.jsx)(N.t,{onClick:O,className:`w-full`,children:`Done`}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-[14px] text-foreground/70 leading-relaxed`,children:[(0,q.jsxs)(`p`,{children:[a,k?` ${k} paid.`:``]}),A&&(0,q.jsxs)(`p`,{children:[`A receipt is on its way to `,m?.customerEmail,`.`]}),j===`sending`&&(0,q.jsxs)(`p`,{children:[`Emailing a sign-in link to `,w,`…`]}),j===`sent`&&(0,q.jsxs)(`p`,{children:[`We have emailed a sign-in link to `,w,` — open it, or sign in here, to see your order.`]}),j===`sign-in`&&(0,q.jsxs)(`p`,{children:[T?`The sign-in link could not be emailed just now. `:``,`Sign in with `,w,` to see your order.`]})]})})}var nd=e=>`${String(e.id||e.name||``).trim()}|${String(e.options||``).trim()}`,rd=e=>{let t=Math.floor(Number(e.max));return Number.isFinite(t)&&t>0?t:1/0};function id(e){return pu(e).map(e=>{let t=rd(e);return e.quantity>t?{...e,quantity:t}:e})}function ad(e,t){let[n]=id([{...t,quantity:t.quantity??1}]);if(!n)return e;let r=nd(n),i=e.findIndex(e=>nd(e)===r);if(i<0)return[...e,n];let a={...e[i],...n,quantity:e[i].quantity+n.quantity};return id(e.map((e,t)=>t===i?a:e))}function od(e,t,n){let r=Math.floor(Number(n));return!Number.isFinite(r)||r<1?e.filter(e=>nd(e)!==t):id(e.map(e=>nd(e)===t?{...e,quantity:r}:e))}var sd=e=>e.variantId==null?e.variant==null?``:String(e.variant):String(e.variantId),cd=(e,t)=>{if(!t)return!0;let n=(Array.isArray(e.variants)?e.variants:[]).map(e=>e&&typeof e==`object`?e.id:void 0);return!n.length||n.some(e=>e==null||e===``)?!0:n.some(e=>String(e)===t)};function ld(e,t,n,r){if(!t)return{lines:e,gone:[]};let i=!1,a=[],o=[];for(let s of e){if(String(s.id??``)!==t||s.collection&&String(s.collection)!==r){o.push(s);continue}if(!n||!cd(n,sd(s))){i=!0,a.push(String(s.name||``));continue}let e=W.t(n,sd(s));if(e==null||e===Number(s.price)){o.push(s);continue}i=!0,o.push({...s,price:e})}return{lines:i?o:e,gone:a}}function ud(e,t,n,r){let i=md(e),a=[];i.setLines(e=>{let i=ld(e,t,n,r);return a=i.gone,i.lines}),a.length&&i.setGone(a)}var dd=new Map,fd={lines:[],open:!1,gone:[]};function pd(e){try{return id(JSON.parse(window.localStorage.getItem(g.g(e))||`[]`))}catch{return[]}}function md(e){let t=dd.get(e);if(t)return t;let n={lines:pd(e),open:!1,gone:[]},r=new Set,i=e=>{n=e,r.forEach(e=>e())},a=t=>{t.detail===e&&i({lines:[],open:!1,gone:[]})},o=t=>{t.key===g.g(e)&&i({...n,lines:pd(e)})},s={get:()=>n,subscribe(e){return r.size||(window.addEventListener(g.m,a),window.addEventListener(`storage`,o)),r.add(e),()=>{r.delete(e),!r.size&&(window.removeEventListener(g.m,a),window.removeEventListener(`storage`,o))}},setLines(t){let r=t(n.lines);if(r!==n.lines){try{r.length?window.localStorage.setItem(g.g(e),JSON.stringify(r)):window.localStorage.removeItem(g.g(e))}catch{}i({...n,lines:r})}},setOpen(e){e!==n.open&&i({...n,open:e,gone:e?n.gone:[]})},setGone(e){let t=[...new Set([...n.gone,...e.filter(Boolean)])];t.length!==n.gone.length&&i({...n,gone:t})},added:null};return dd.set(e,s),s}function hd(e,t){let n=md(e);return n.added=t,()=>{n.added===t&&(n.added=null)}}function gd(e=`basket`){let t=md(e),n=(0,K.useSyncExternalStore)(t.subscribe,t.get,()=>fd);return(0,K.useMemo)(()=>{let r=e=>typeof e==`string`?e:nd(e);return{name:e,lines:n.lines,count:n.lines.reduce((e,t)=>e+t.quantity,0),subtotal:hu(n.lines),open:n.open,gone:n.gone,add(e,n){t.setLines(t=>ad(t,e)),n?.quiet||t.setOpen(!0);try{t.added?.(e)}catch{}},setQuantity:(e,n)=>t.setLines(t=>od(t,r(e),n)),remove:e=>t.setLines(t=>od(t,r(e),0)),clear:()=>t.setLines(e=>e.length?[]:e),show:()=>t.setOpen(!0),hide:()=>t.setOpen(!1)}},[e,n,t])}var _d=`bag`,vd=`flex items-baseline justify-between gap-4 text-[14px]`,yd=`w-10 h-10 inline-flex items-center justify-center rounded-full text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors cursor-pointer disabled:opacity-25 disabled:cursor-default disabled:hover:bg-transparent`,bd=e=>e.length<2?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`;function xd({subtotal:e,extras:t,total:n,currency:r,count:i}){return(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(t.length>0||i!=null)&&(0,q.jsxs)(`div`,{className:`${vd} text-foreground/55`,children:[(0,q.jsx)(`span`,{children:i==null?`Subtotal`:`${i} ${i===1?`item`:`items`}`}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:ac(e,r)})]}),t.map(e=>(0,q.jsxs)(`div`,{className:`${vd} text-foreground/55`,children:[(0,q.jsx)(`span`,{children:e.label}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:ac(e.amount,r)})]},e.label)),(0,q.jsxs)(`div`,{className:`${vd} font-semibold text-foreground`,children:[(0,q.jsx)(`span`,{children:t.length?`Total`:`Subtotal`}),(0,q.jsx)(`span`,{className:`tabular-nums text-[16px]`,children:ac(n,r)})]})]})}function Sd({name:e=`basket`,formId:t,collection:n,extras:i,currency:a,phone:s,address:c,carry:u,productName:d,metadata:f,successPath:p,payLabel:m,send:h,title:_=h?`Your list`:`Your bag`,checkoutTitle:v=h?`Your details`:`Checkout`,checkoutLabel:y=h?`Send my list`:`Checkout`,emptyWords:b=h?`Your list is empty`:`Your bag is empty`,note:x,onOpenLine:S,tally:C,sentWords:w=`Sent — thank you`,onSent:T}){let D=gd(e),O=r.Rr(),A=a||O||`usd`;(0,K.useEffect)(()=>{if(C)return hd(e,e=>{e.id&&cu(C,String(e.id),`added`)})},[e,C]);let j=n?[...new Set(D.lines.filter(e=>e.id&&(!e.collection||e.collection===n)).map(e=>String(e.id)))].sort().join(`
|
|
19
|
+
`):``;(0,K.useEffect)(()=>{if(!n||!j)return;let t=j.split(`
|
|
20
|
+
`).map(t=>{try{return(0,J.onSnapshot)((0,J.doc)(r.ui,n,t),r=>{r.metadata.fromCache||ud(e,t,r.exists()?r.data():null,n)},()=>{})}catch{return()=>{}}});return()=>t.forEach(e=>e())},[e,n,j]);let{loading:P,configured:ee}=r.zn(),{userRole:F}=r.Ft(),{pathname:te,search:I}=(0,Y.useLocation)(),[L,ne]=(0,Y.useSearchParams)(),[R,z]=(0,K.useState)(`bag`),[re,ie]=(0,K.useState)(!1),B=L.get(_d);(0,K.useEffect)(()=>{B&&(D.lines.length&&(z(B===`checkout`?`checkout`:`bag`),D.show()),ne(e=>{let t=new URLSearchParams(e);return t.delete(_d),t},{replace:!0}))},[B]),(0,K.useEffect)(()=>{if(D.open)return;let e=window.setTimeout(()=>{z(`bag`),ie(!1)},300);return()=>window.clearTimeout(e)},[D.open]);let V=D.lines,ae=V.length?R:`bag`,oe=mu(i),H=gu(V,oe),se=V.some(e=>!!e.picture),U=D.gone.length>0?(0,q.jsx)(`p`,{role:`status`,className:`text-[13px] text-foreground/55 leading-snug pb-3 mb-1 border-b border-[var(--panel-border)]`,children:`${bd(D.gone)} ${D.gone.length===1?`is`:`are`} no longer for sale, so ${D.gone.length===1?`it has`:`they have`} been taken out of your ${h?`list`:`bag`}.`}):null,ce=!h&&!P&&!ee&&!o.wn(F),W=!h||V.some(e=>Number(e.price)>0);(0,K.useEffect)(()=>{V.length&&ie(!1)},[V.length]);let le=h?{...u||{},items:pu(V),...W?{extras:oe,subtotal:D.subtotal,total:H,currency:A.toLowerCase()}:{}}:void 0,G=(()=>{let e=new URLSearchParams(I);return e.set(_d,`checkout`),`${te}?${e.toString()}`})(),ue=S?e=>{D.hide(),S(e)}:null,de=ae===`bag`&&V.length>0?(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[W&&(0,q.jsx)(xd,{subtotal:D.subtotal,extras:oe,total:H,currency:A}),x&&(0,q.jsx)(`p`,{className:`text-[13px] text-foreground/50 leading-snug`,children:x}),ce?(0,q.jsx)(`p`,{className:`text-[13px] text-foreground/55 leading-snug text-center`,children:`Ordering is not open yet.`}):h?(0,q.jsx)(N.t,{onClick:()=>z(`checkout`),className:`w-full py-3.5 text-[15px] font-bold tracking-wide`,children:y}):(0,q.jsx)(N.t,{onClick:()=>z(`checkout`),disabled:H<=0,className:`w-full py-3.5 text-[15px] font-bold tracking-wide`,children:`${y} · ${ac(H,A)}`})]}):void 0;return(0,q.jsxs)(M.t,{open:D.open,onClose:D.hide,side:`right`,title:ae===`checkout`?v:_,sub:ae===`checkout`?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>z(`bag`),className:`inline-flex items-center gap-1.5 -ml-1 px-1 py-1 text-[13px] font-semibold text-foreground/55 hover:text-foreground transition-colors cursor-pointer`,children:[(0,q.jsx)(l.t,{className:`w-3.5 h-3.5`}),` `,h?`Back to your list`:`Back to your bag`]}):void 0,footer:de,children:[!(re&&!V.length)&&U,re&&!V.length?(0,q.jsxs)(`div`,{role:`status`,className:`flex flex-col items-center text-center gap-3 py-16`,children:[(0,q.jsx)(r.At,{className:`w-9 h-9 text-accent`,strokeWidth:1.75}),(0,q.jsx)(`p`,{className:`text-[15px] font-semibold text-foreground/80`,children:w}),(0,q.jsx)(`p`,{className:`text-[13px] text-foreground/50 leading-snug`,children:`We have your list and will be in touch.`}),(0,q.jsx)(N.t,{variant:`secondary`,onClick:D.hide,className:`mt-3`,children:`Keep looking`})]}):V.length?ae===`checkout`&&h?(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 pt-2`,children:[W?(0,q.jsx)(xd,{subtotal:D.subtotal,extras:oe,total:H,currency:A,count:D.count}):(0,q.jsx)(`p`,{className:`${vd} text-foreground/55`,children:`${D.count} ${D.count===1?`item`:`items`} on your list`}),(0,q.jsx)(g.t,{formId:t,isInline:!0,bare:!0,extra:le,onSubmitted:(e,t)=>{ie(!0),D.clear(),T?.(e,t)}})]}):ae===`checkout`?(0,q.jsxs)(`div`,{className:`flex flex-col gap-7 pt-2`,children:[(0,q.jsx)(xd,{subtotal:D.subtotal,extras:oe,total:H,currency:A,count:D.count}),(0,q.jsx)(Xu,{formId:t,collection:n,items:V,extras:i,currency:a,phone:s,address:c,carry:u,productName:d,metadata:f,successPath:p,cancelPath:G,payLabel:m,summary:!1})]}):(0,q.jsx)(`ul`,{"aria-label":`In your bag`,className:`flex flex-col`,children:(0,q.jsx)(r.rt,{initial:!1,children:V.map(e=>{let t=nd(e),n=Number(e.max)>0?Math.floor(Number(e.max)):1/0,i=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-[14.5px] font-semibold text-foreground/90 leading-snug line-clamp-2`,children:e.name}),e.options&&(0,q.jsx)(`span`,{className:`text-[13px] text-foreground/50 leading-snug truncate`,children:e.options})]});return(0,q.jsx)(r.nt.li,{layout:!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,height:0},transition:{duration:.2},className:`overflow-hidden border-b border-[var(--panel-border)] last:border-b-0`,children:(0,q.jsxs)(`div`,{className:`flex gap-4 py-4`,children:[se&&(0,q.jsxs)(`div`,{className:`relative w-[72px] h-[72px] shrink-0 rounded-2xl overflow-hidden bg-foreground/5`,children:[e.picture&&(0,q.jsx)(r.O,{src:e.picture,alt:``,fit:`cover`,className:`absolute inset-0`}),ue&&(0,q.jsx)(`button`,{type:`button`,"aria-label":`Open ${e.name}`,onClick:()=>ue(e),className:`absolute inset-0 cursor-pointer`})]}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 flex flex-col gap-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[ue?(0,q.jsx)(`button`,{type:`button`,onClick:()=>ue(e),className:`min-w-0 flex flex-col gap-0.5 text-left cursor-pointer`,children:i}):(0,q.jsx)(`span`,{className:`min-w-0 flex flex-col gap-0.5`,children:i}),W&&(0,q.jsxs)(`span`,{className:`shrink-0 flex flex-col items-end leading-snug`,children:[(0,q.jsx)(`span`,{className:`text-[14.5px] tabular-nums text-foreground/85`,children:ac(e.price*e.quantity,A)}),e.quantity>1&&(0,q.jsxs)(`span`,{className:`text-[12px] tabular-nums text-foreground/45`,children:[ac(e.price,A),` each`]})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 -ml-2.5 mt-0.5`,children:[(0,q.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":`One less ${e.name}`,disabled:e.quantity<=1,onClick:()=>D.setQuantity(t,e.quantity-1),className:yd,children:(0,q.jsx)(dt,{className:`w-4 h-4`})}),(0,q.jsx)(`span`,{"aria-live":`polite`,"aria-label":`${e.quantity} of ${e.name}`,className:`w-7 text-center text-[14.5px] font-semibold tabular-nums text-foreground/85`,children:e.quantity}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`One more ${e.name}`,disabled:e.quantity>=n,onClick:()=>D.setQuantity(t,e.quantity+1),className:yd,children:(0,q.jsx)(E.t,{className:`w-4 h-4`})})]}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,onClick:()=>D.remove(t),className:`px-2 py-2 text-[13px] font-semibold text-foreground/45 hover:text-foreground transition-colors cursor-pointer`,children:`Remove`})]}),e.quantity>=n&&(0,q.jsx)(`span`,{className:`text-[12.5px] text-foreground/50 leading-snug`,children:`That is all there is of it.`})]})]})},t)})})}):(0,q.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-3 py-16`,children:[(0,q.jsx)(k.i,{className:`w-9 h-9 text-foreground/20`,strokeWidth:1.5}),(0,q.jsx)(`p`,{className:`text-[15px] font-semibold text-foreground/80`,children:b}),(0,q.jsx)(`p`,{className:`text-[13px] text-foreground/50 leading-snug`,children:`What you add waits here until you are ready.`}),(0,q.jsx)(N.t,{variant:`secondary`,onClick:D.hide,className:`mt-3`,children:`Keep looking`})]})]})}Sd.displayName=`Basket`;var Cd=e=>(0,K.isValidElement)(e)&&(e.type===`svg`||/^(?:Shopping|Lucide)?(?:Bag|Basket|Cart)\w*$/.test(String(e.type.displayName||``)));function wd({name:e=`basket`,label:t=`Bag`,className:n,children:i}){let a=gd(e),o=a.count,s=K.Children.toArray(i).filter(e=>!Cd(e));return(0,q.jsxs)(`button`,{type:`button`,onClick:a.show,"aria-label":`${t}, ${o} ${o===1?`item`:`items`}`,className:r.$(`relative inline-flex items-center justify-center gap-2 h-11 min-w-11 px-2.5 rounded-full text-foreground/75 hover:text-foreground hover:bg-foreground/5 transition-colors cursor-pointer`,n),children:[(0,q.jsx)(k.i,{className:`w-[22px] h-[22px]`,strokeWidth:1.75}),s,(0,q.jsx)(r.rt,{children:o>0&&(0,q.jsx)(r.nt.span,{initial:{scale:.6,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.6,opacity:0},transition:{duration:.18},className:`absolute top-0.5 right-0 min-w-[18px] h-[18px] px-1 inline-flex items-center justify-center rounded-full bg-accent text-[var(--button-fg,#fff)] text-[11px] font-bold tabular-nums leading-none`,children:(0,q.jsx)(r.nt.span,{initial:{scale:1.5},animate:{scale:1},transition:{duration:.2},children:o>99?`99+`:o},o)},`count`)})]})}wd.displayName=`BasketButton`;var Td=`w-full py-3.5 text-[15px] font-bold tracking-wide`;function Ed({children:e,price:t,about:n,phone:i,address:a,disabled:s=!1,variant:c=`primary`,className:l,...u}){let{loading:d,configured:f}=r.zn(),p=r.Rr(),{userRole:m}=r.Ft(),{pathname:h,search:g}=(0,Y.useLocation)(),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(null),[x,S]=(0,K.useState)(!1),[C,w]=(0,K.useState)(``);if(d)return null;if(!f)return o.wn(m)?(0,q.jsx)(`span`,{className:`text-[12.5px] font-medium text-foreground/50 leading-snug`,children:`Only admins see this: payments are not on yet, so this button is hidden. Connect Stripe and switch payments on at /payments and it appears here.`}):null;let T=u.mode===`subscription`,E=u.amount==null?u.currency:u.currency||p||`usd`,D=t?.trim()||(u.amount==null?``:ac(u.amount*(u.quantity||1),E)),O=u.productName?.trim()||(T?`Your plan`:`Your order`),k=[T?`Subscribe`:`Pay`,D].filter(Boolean).join(` · `),A=async e=>{if(x||!e)return;if(S(!0),w(``),u.amount!=null&&!u.currency&&!p&&await r.Ir()){w(r.Pr),S(!1);return}Tu(e.guest?e.email:``);let t=await r.Fn({...u,...E?{currency:E}:{},metadata:{page:h,...u.metadata,...e.metadata},successPath:u.successPath||h,cancelPath:u.cancelPath||`${h}${g}`});t&&(w(t),S(!1))};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(N.t,{variant:c,className:l,disabled:s,onClick:()=>{w(``),v(!0)},children:e??(T?`Subscribe`:`Buy`)}),(0,q.jsx)(M.t,{open:_,onClose:()=>v(!1),busy:x,size:`sm`,title:O,sub:D||void 0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-7 pt-2`,children:[n&&(0,q.jsx)(`p`,{className:`text-[14px] text-foreground/65 leading-relaxed`,children:n}),(0,q.jsx)(Ku,{phone:i,address:a,wide:!0,continueLabel:k,onReady:(e,t)=>{b(e),t?.pressed&&A(e)},onEditing:()=>b(null)}),y&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(N.t,{onClick:()=>A(y),isLoading:x,disabled:x,className:Td,children:k}),!C&&(0,q.jsx)(`span`,{className:`text-[12.5px] text-foreground/45 leading-snug text-center`,children:x?`Opening the secure payment page…`:`Secure payment. Your card is entered on the next page.`})]}),C&&(0,q.jsx)(`span`,{role:`alert`,className:`text-[13px] font-semibold text-foreground/80 leading-snug`,children:C})]})})]})}Ed.displayName=`BuyButton`;var Dd=e=>/[^\d.,\s]/.test(e);function Od(e,t=r.Lr()){let n=String(e||``).trim();if(!n)return``;if(Dd(n))return n;let i=r.br(n);return i==null?n:ac(i,t)}function kd(e,t,n,i){if(!t.on)return null;let a=r.pr(t,n).trim();if(!/^price_[A-Za-z0-9]+$/.test(a))return null;let o=Od(t.amount,i);return{rhythm:e,priceId:a,amount:r.br(t.amount),figure:o,words:`${o} per ${e===`monthly`?`month`:`year`}`.trim()}}var Ad=e=>{let t=e.split(/\r?\n/).map(e=>e.replace(/^\s*(?:[-–•*·✓]|\d+[.)])\s*/,``).trim()).filter(Boolean);return t.length>1?t:[]};function jd(e,t,n=[],i=r.Lr()){if(!e||e.kind!==`subscription`)return[];let a=new Set(n.filter(e=>e.active&&e.priceId).map(e=>e.priceId)),o=[];for(let n of e.plans){let e=kd(`monthly`,n.monthly,t,i),r=kd(`yearly`,n.yearly,t,i);if(!e&&!r)continue;let s=n.description.trim(),c=Ad(s);o.push({name:n.name.trim()||`Plan`,description:c.length?``:s,includes:c,roleId:n.roleId||``,monthly:e,yearly:r,mine:e&&a.has(e.priceId)?`monthly`:r&&a.has(r.priceId)?`yearly`:null})}return o}function Md(e){let t=e.monthly?.amount,n=e.yearly?.amount;return!t||!n||n>=t*12?0:Math.round((1-n/(t*12))*100)}function Nd(e,t){let{loading:n,mode:i}=r.zn();r.Rr();let a=t||r.Lr(),o=r.Rn(),[s,c]=(0,K.useState)(null);(0,K.useEffect)(()=>{if(e)return(0,J.onSnapshot)((0,J.doc)(r.ui,r.Qn,e),t=>c({id:e,product:t.exists()?r.Dr(t.id,t.data()):null}),()=>c({id:e,product:null}))},[e]);let l=s?.id===e?s.product:null,u=!!e&&(n||s?.id!==e||o.loading);return(0,K.useMemo)(()=>{let e=u?[]:jd(l,i===`live`,o.subscriptions,a);return{loading:u,name:l?.name.trim()||``,description:l?.description.trim()||``,plans:e,subscribed:e.some(e=>e.mine),metadata:{},unsure:!!o.error}},[u,l,i,o.subscriptions,o.error,a])}var Pd=`text-[12.5px] font-medium text-foreground/50 leading-snug`;function Fd({product:e,featured:t,featuredLabel:n=`Recommended`,currency:i,phone:a,address:s,successPath:c,className:l}){let{loading:u,configured:d}=r.zn(),{userRole:f}=r.Ft(),p=Nd(e,i),[m,h]=(0,K.useState)(null);if(p.loading||u)return(0,q.jsx)(`div`,{"aria-hidden":!0,className:r.$(`grid gap-5 sm:grid-cols-2 lg:grid-cols-3`,l),children:[0,1,2].map(e=>(0,q.jsx)(`div`,{className:`h-72 glass-panel rounded-3xl animate-pulse`},e))});let g=o.wn(f),{plans:_}=p;if(!_.length)return g?(0,q.jsx)(`span`,{className:Pd,children:`Only admins see this: this subscription has no finished plan yet, so there is nothing to show here. Finish it at /payments and it appears.`}):null;let v=_.some(e=>e.monthly&&e.yearly),y=_.find(e=>e.mine)?.mine||null,b=m||y||`monthly`,x=Math.max(0,..._.map(Md)),S=t?.trim().toLowerCase()||``;return(0,q.jsxs)(`div`,{className:r.$(`flex flex-col items-center gap-10 w-full`,l),children:[!d&&g&&(0,q.jsx)(`span`,{className:Pd,children:`Only admins see this: payments are not on yet, so the buttons are hidden. Connect Stripe and switch payments on at /payments and they appear here.`}),v&&(0,q.jsx)(`div`,{role:`group`,"aria-label":`How often you pay`,className:`inline-flex items-center p-1 rounded-full glass-panel`,children:[`monthly`,`yearly`].map(e=>(0,q.jsx)(`button`,{type:`button`,"aria-pressed":b===e,onClick:()=>h(e),className:r.$(`h-10 px-5 rounded-full text-[14px] font-semibold transition-colors cursor-pointer`,b===e?`bg-accent text-[var(--button-fg,#fff)] shadow-sm`:`text-foreground/55 hover:text-foreground`),children:e===`monthly`?`Monthly`:x?`Yearly · save ${x}%`:`Yearly`},e))}),(0,q.jsx)(`div`,{className:r.$(`grid gap-5 w-full`,_.length===1?`max-w-md`:_.length===2?`sm:grid-cols-2 max-w-3xl`:`sm:grid-cols-2 lg:grid-cols-3`),children:_.map((e,t)=>{let i=e[b]||e.monthly||e.yearly;if(!i)return null;let o=!!S&&e.name.toLowerCase()===S,l=i.rhythm===`yearly`?Md(e):0;return(0,q.jsxs)(r.nt.div,{initial:{opacity:0,y:14},animate:{opacity:1,y:0},transition:{duration:.35,delay:t*.06,ease:[.16,1,.3,1]},className:r.$(`relative flex flex-col gap-7 p-7 sm:p-8 rounded-3xl glass-panel text-left`,o&&`ring-1 ring-accent/70`),children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 min-h-6`,children:[(0,q.jsx)(`h3`,{className:`text-[15px] font-bold tracking-tight text-foreground/75`,children:e.name}),e.mine?(0,q.jsx)(`span`,{className:`px-2.5 py-1 rounded-full bg-foreground/10 text-[11.5px] font-bold text-foreground/70`,children:`Your plan`}):o?(0,q.jsx)(`span`,{className:`px-2.5 py-1 rounded-full bg-accent/15 text-[11.5px] font-bold text-accent`,children:n}):null]}),(0,q.jsxs)(`p`,{className:`flex items-baseline gap-2 flex-wrap`,children:[(0,q.jsx)(`span`,{className:`text-4xl font-bold tracking-tight text-foreground tabular-nums`,children:i.figure}),(0,q.jsxs)(`span`,{className:`text-[14px] font-medium text-foreground/50`,children:[`per `,i.rhythm===`monthly`?`month`:`year`]})]}),l>0&&(0,q.jsxs)(`p`,{className:`text-[13px] text-foreground/55 -mt-2`,children:[l,`% less than paying monthly.`]}),e.description&&(0,q.jsx)(`p`,{className:`text-[14px] text-foreground/65 leading-relaxed`,children:e.description})]}),e.includes.length>0&&(0,q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.includes.map(e=>(0,q.jsxs)(`li`,{className:`flex items-start gap-3 text-[14px] text-foreground/75 leading-snug`,children:[(0,q.jsx)(r.At,{className:`w-4 h-4 mt-0.5 shrink-0 text-accent`,strokeWidth:2.5}),(0,q.jsx)(`span`,{children:e})]},e))}),(0,q.jsx)(`div`,{className:`mt-auto flex flex-col`,children:p.subscribed?(0,q.jsx)(ce.t,{variant:e.mine?`secondary`:`primary`,className:`w-full py-3 text-[14.5px] font-bold`,children:e.mine?`Manage your plan`:`Switch to ${e.name}`}):d&&p.unsure?(0,q.jsx)(`span`,{className:Pd,children:`Your current plan could not be checked just now. Try again in a moment.`}):d?(0,q.jsx)(Ed,{priceId:i.priceId,mode:`subscription`,productName:p.name?`${p.name} — ${e.name}`:e.name,price:i.words,about:e.description||void 0,phone:a,address:s,successPath:c,metadata:{...p.metadata,plan:e.name,billed:i.rhythm},variant:o||_.length===1?`primary`:`secondary`,className:`w-full py-3 text-[14.5px] font-bold`,children:`Choose ${e.name}`}):null})]},e.name)})})]})}Fd.displayName=`Plans`;var Id=Object.assign({}),Ld={};for(let e in Id){let t=Id[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();Ld[r]=t.default,Ld[r.replace(/_/g,``)]=t.default}if(typeof window<`u`){let e=window.__FBOS_MICROCOMPONENTS__||{};window.__FBOS_MICROCOMPONENTS__={...Ld,...e}}var Rd=(e,t)=>{let n=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=n.replace(/_/g,``);if(Ld[n]=t,Ld[r]=t,typeof window<`u`){let e=window.__FBOS_MICROCOMPONENTS__||{};window.__FBOS_MICROCOMPONENTS__={...e,[n]:t,[r]:t}}},zd=({title:e,className:t,children:n,...i})=>(0,q.jsxs)(`div`,{className:r.$(`border border-[var(--panel-border)] bg-[var(--panel-bg)] px-5 py-4`,t),style:{borderRadius:`var(--card-radius, 1rem)`},...i,children:[e?(0,q.jsx)(`p`,{className:`text-[12px] font-extrabold tracking-tight text-gradient mb-1.5`,children:e}):null,n]});zd.displayName=`Card`;var Bd=({sub:e,className:t,children:n,...i})=>(0,q.jsxs)(`div`,{className:r.$(`mb-4`,t),children:[(0,q.jsx)(`h2`,{className:`text-xl md:text-2xl font-bold tracking-tight text-foreground`,...i,children:n}),e?(0,q.jsx)(`p`,{className:`text-[13px] text-foreground/60 font-medium leading-relaxed mt-1`,children:e}):null]});Bd.displayName=`SectionHeading`;var Vd=`button, a, input, textarea, select, label, [role="button"], [role="listbox"], [role="option"]`,Hd=`[&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!p-0 [&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!m-0 [&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!border-0 [&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!rounded-none [&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!bg-transparent [&>:is(div,section,article):only-child:not([class*=inline],[class*=w-fit],[class*=w-max],[class*=rounded-full],[class*=text-white],[class*=text-background],:has(>:is(img,video,[data-picture]):only-child))]:!shadow-none`,Ud=`flex h-8 w-6 shrink-0 items-center justify-center rounded-md text-foreground/40 transition-[opacity,color,background-color] duration-150 hover:bg-foreground/[0.07] hover:text-foreground/80 [@media(hover:hover)]:opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`;function Wd({stages:e,items:t,stageOf:n,keyOf:i,card:a,onMove:o,onOpen:s,canMove:c,loading:l=!1,empty:u=`Nothing here yet`,className:d}){let f=(0,K.useRef)(null),p=e=>i?i(e):String(e.id??``),m=e[0]?.id??``,h=t=>e.some(e=>e.id===t)?t:m,[g,_]=(0,K.useState)({}),[v,y]=(0,K.useState)(null),b=(0,K.useRef)(null),x=e=>{b.current=e,y(e)},S=(0,K.useMemo)(()=>new Map(t.map(e=>[p(e),e])),[t]);(0,K.useEffect)(()=>{let e=Object.entries(g).filter(([e,t])=>{let r=S.get(e);return!r||t.settled&&h(n(r))===t.stage});e.length&&_(t=>{let n={...t};for(let[t]of e)delete n[t];return n})},[g,S]);let C=(0,K.useMemo)(()=>{let r=new Map(e.map(e=>[e.id,[]]));for(let e of t)g[p(e)]||r.get(h(n(e)))?.push(e);for(let[e,t]of Object.entries(g)){let n=S.get(e),i=r.get(t.stage);n&&i&&i.splice(Math.min(t.index,i.length),0,n)}return r},[t,g,e]),w=(e,t,i)=>{let a=p(e),s=h(n(e));if(t===s&&i===(C.get(s)||[]).findIndex(e=>p(e)===a)||c&&t!==s&&!c(e,t))return;_(e=>({...e,[a]:{stage:t,index:i,settled:!1}}));let l=()=>_(e=>e[a]?{...e,[a]:{...e[a],settled:!0}}:e),u=()=>_(e=>{let t={...e};return delete t[a],t}),d;try{d=o(e,t,i)}catch(e){u(),k.n(r.ii(e,`That could not be moved.`));return}d&&typeof d.then==`function`?d.then(()=>{l(),setTimeout(u,1500)},e=>{u(),k.n(r.ii(e,`That could not be moved.`))}):(l(),setTimeout(u,5e3))},{dragging:T,bind:E}=co({disabled:l,scroller:()=>f.current,onMove:({x:e,y:t},r)=>{let i=f.current,a=S.get(r);if(!i||!a)return;let o=Array.from(i.querySelectorAll(`[data-pipeline-stage]`)),s=null,l=1/0;for(let t of o){let n=t.getBoundingClientRect(),r=e<n.left?n.left-e:e>n.right?e-n.right:0;r<l&&(l=r,s=t)}let u=s?.dataset.pipelineStage;if(!s||!u){x(null);return}if(c&&u!==h(n(a))&&!c(a,u)){x(null);return}let d=Array.from(s.querySelectorAll(`[data-drag-key]`)).filter(e=>e.dataset.dragKey!==r).filter(e=>{let n=e.getBoundingClientRect();return t>n.top+n.height/2}).length,p=b.current;(!p||p.stage!==u||p.index!==d)&&x({stage:u,index:d})},onDrop:e=>{let t=S.get(e),n=b.current;x(null),t&&n&&w(t,n.stage,n.index)},onCancel:()=>x(null)}),D=T?S.get(T.key):void 0,O=`rounded-xl border border-[var(--panel-border)] bg-[var(--panel-bg)] p-3 text-left`,A=e=>t=>{let n=t.target.closest?.(Vd);n&&n!==t.currentTarget||s?.(e)},j=e=>t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),s?.(e))};return(0,q.jsxs)(`div`,{ref:f,className:r.$(`flex w-full items-start gap-3 overflow-x-auto pb-3 md:gap-4`,T?`snap-none`:`snap-x snap-mandatory sm:snap-none`,d),children:[e.map(t=>{let i=C.get(t.id)||[],o=T?i.findIndex(e=>p(e)===T.key):-1,d=!!T&&v?.stage===t.id,f=d&&o>-1&&v.index===o,m=d&&T&&!f?(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`rounded-xl border-2 border-dashed border-accent/50 bg-accent/5`,style:{height:T.height}},`__slot`):null,g=i.map(t=>{let i=p(t),o=h(n(t)),l=e.filter(e=>e.id===o||!c||c(t,e.id));return(0,q.jsxs)(`div`,{...E(i),...s?{role:`button`,tabIndex:0,"data-drag-ok":``,onClick:A(t),onKeyDown:j(t)}:{"data-drag-ok":``},className:r.$(O,`group relative cursor-grab transition-[border-color,box-shadow,opacity] duration-200 hover:border-accent/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,T?.key===i&&`opacity-30`),children:[(0,q.jsx)(`div`,{className:r.$(`min-w-0`,Hd),children:a(t)}),(0,q.jsxs)(`div`,{className:`-mb-1.5 mt-2.5 flex items-center justify-between gap-2 border-t border-[var(--panel-border)] pt-1.5`,children:[l.length>1?(0,q.jsx)(`div`,{className:`-ml-2 flex min-w-0 items-center [&_[role=button]]:!h-8 [&_[role=button]]:!px-2`,"data-no-drag":``,children:(0,q.jsx)(r.Z,{compact:!0,portal:!0,direction:`auto`,variant:`ghost`,ariaLabel:`Move to another stage`,value:o,options:l.map(e=>({value:e.id,label:e.label})),onChange:e=>{e!==o&&w(t,e,0)}})}):(0,q.jsx)(`span`,{className:`min-w-0 truncate py-1.5 text-[12.5px] font-semibold leading-5 text-foreground/60`,children:e.find(e=>e.id===o)?.label}),(0,q.jsx)(`span`,{...lo,"aria-hidden":`true`,"data-pipeline-grip":``,className:r.$(Ud,`-mr-1.5`),children:(0,q.jsx)(rt,{className:`h-4 w-4`})})]})]},i)});if(m){let e=v.index;g.splice(Math.min(o>-1&&e>o?e+1:e,g.length),0,m)}return(0,q.jsxs)(`section`,{"data-pipeline-stage":t.id,"aria-label":t.label,className:r.$(`flex w-[84%] shrink-0 snap-start flex-col rounded-2xl border p-3 transition-colors duration-200 sm:w-auto sm:min-w-[15rem] sm:flex-1`,d?`border-accent/60 bg-accent/5`:`border-[var(--panel-border)] bg-background/40`),children:[(0,q.jsxs)(`header`,{className:`mb-3 flex items-center justify-between gap-2 px-1`,children:[(0,q.jsx)(`h3`,{className:`truncate text-sm font-bold text-foreground`,children:t.label}),!l&&(0,q.jsx)(`span`,{className:`flex h-6 min-w-6 items-center justify-center rounded-full border border-[var(--panel-border)] px-1.5 text-xs font-bold text-foreground/70`,children:i.length})]}),t.hint&&(0,q.jsx)(`p`,{className:`-mt-2 mb-3 px-1 text-xs leading-snug text-foreground/50`,children:t.hint}),(0,q.jsx)(`div`,{className:`flex min-h-16 flex-col gap-2.5`,children:l?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(P.n,{className:`h-24 rounded-xl`}),(0,q.jsx)(P.n,{className:`h-24 rounded-xl`})]}):g.length?g:(0,q.jsx)(`div`,{className:r.$(`rounded-xl border border-dashed border-[var(--panel-border)] px-3 py-5 text-center text-xs text-foreground/40`,Hd),children:u})})]},t.id)}),T&&D!==void 0&&typeof document<`u`&&(0,fe.createPortal)((0,q.jsx)(`div`,{"aria-hidden":`true`,"data-pipeline-ghost":``,className:`pointer-events-none fixed z-[9995] rotate-[1.5deg] rounded-xl bg-background opacity-95 shadow-2xl`,style:{left:T.x-T.offsetX,top:T.y-T.offsetY,width:T.width},children:(0,q.jsx)(`div`,{className:O,children:(0,q.jsx)(`div`,{className:r.$(`min-w-0`,Hd),children:a(D)})})}),document.body)]})}Wd.displayName=`Pipeline`;var Gd=new WeakMap,Kd=0,qd=e=>{let t=Gd.get(e);return t||(t=`\u0000item${++Kd}`,Gd.set(e,t)),t},Jd=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]);function Yd({items:e,keyOf:t,item:n,onReorder:i,label:a,grip:o,disabled:s=!1,className:c}){let l=(0,K.useRef)(null),u=e=>{if(t)return String(t(e)??``);if(typeof e==`string`||typeof e==`number`)return String(e);let n=e?.id;return n!=null&&n!==``?String(n):e&&typeof e==`object`?qd(e):``},d=(o??(/\b(?:grid|columns-\d)/.test(c||``)?`corner`:`end`))===`corner`,f=new Map,p=e.map(e=>{let t=u(e),n=f.get(t)??0;return f.set(t,n+1),n===0?t:`${t}\u0000${n}`}),m=new Map(e.map((e,t)=>[p[t],e])),h=p.join(`\0`),[g,_]=(0,K.useState)(null),v=(0,K.useRef)(null),y=e=>{v.current=e,_(e?{keys:e,from:h}:null)},b=(0,K.useRef)(0),x=(0,K.useRef)(null);(0,K.useEffect)(()=>{let e=x.current;e&&(x.current=null,l.current?.querySelector(`[data-drag-key="${CSS.escape(e)}"] [data-drag-handle]`)?.focus())});let S=()=>Array.from(l.current?.querySelectorAll(`:scope > [data-drag-key]`)||[]).map(e=>e.dataset.dragKey||``),C=e=>{if(Jd(e,p)){y(null);return}y(e);let t=()=>{v.current===e&&y(null)},n;try{n=i(e.map(e=>m.get(e)))}catch(e){t(),k.n(r.ii(e,`The new order could not be saved.`));return}n&&typeof n.then==`function`?n.then(()=>setTimeout(t,1500),e=>{t(),k.n(r.ii(e,`The new order could not be saved.`))}):setTimeout(t,3e3)},{dragging:w,bind:T}=co({disabled:s,onStart:()=>y(S()),onMove:({x:e,y:t,at:n},r)=>{let i=l.current;if(!i||n<b.current)return;let a=null,o=1/0;for(let n of Array.from(i.querySelectorAll(`:scope > [data-drag-key]`))){let r=n.getBoundingClientRect(),i=Math.hypot(e-(r.left+r.width/2),t-(r.top+r.height/2));i<o&&(o=i,a=n.dataset.dragKey||null)}let s=v.current||S();if(!a||a===r)return;let c=s.filter(e=>e!==r);c.splice(s.indexOf(a),0,r),b.current=n+140,y(c)},onDrop:()=>C(v.current||S()),onCancel:()=>y(null)}),E=g&&(w||g.from===h)?g.keys:null,D=(E||p).filter(e=>m.has(e));for(let e of p)D.includes(e)||D.push(e);let O=e=>t=>{let n=t.key===`ArrowUp`||t.key===`ArrowLeft`?-1:+(t.key===`ArrowDown`||t.key===`ArrowRight`);if(!n)return;t.preventDefault();let r=D.indexOf(e),i=r+n;if(i<0||i>=D.length)return;let a=[...D];a.splice(r,1),a.splice(i,0,e),x.current=e,C(a)},A=w?m.get(w.key):void 0;return(0,q.jsxs)(`div`,{ref:l,className:r.$(c||`flex flex-col gap-2`),children:[D.map((e,t)=>{let i=m.get(e),o=a?a(i,t):`item ${t+1} of ${D.length}`,c=s?null:(0,q.jsx)(`button`,{type:`button`,...lo,onKeyDown:O(e),"aria-label":`Move ${o} — drag, or use the arrow keys`,className:r.$(`flex h-10 w-8 shrink-0 items-center justify-center rounded-lg text-foreground/40 transition-colors hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,d&&`absolute right-1.5 top-1.5 w-10 border border-[var(--panel-border)] bg-background/80 text-foreground/70 backdrop-blur-sm`),children:(0,q.jsx)(rt,{className:`h-4 w-4`,"aria-hidden":`true`})});return(0,q.jsxs)(r.nt.div,{layout:!!w||!!E,transition:{type:`spring`,stiffness:500,damping:40},...T(e),className:r.$(`relative min-w-0`,!d&&`flex items-center gap-2`,!s&&`cursor-grab`,w?.key===e&&`opacity-30`),children:[d?n(i,t):(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:n(i,t)}),c]},e)}),w&&A!==void 0&&typeof document<`u`&&(0,fe.createPortal)((0,q.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none fixed z-[9995] rotate-[1.5deg] opacity-95 shadow-2xl`,style:{left:w.x-w.offsetX,top:w.y-w.offsetY,width:w.width},children:d?n(A,D.indexOf(w.key)):(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:n(A,D.indexOf(w.key))}),(0,q.jsx)(`span`,{className:`w-8 shrink-0`})]})}),document.body)]})}Yd.displayName=`Sortable`;var Xd=`button, a, input, textarea, select, label, [role="button"], [role="listbox"], [role="option"]`,Zd=e=>{if(e==null||e===``)return null;if(e instanceof Date)return e.getTime();if(typeof e==`boolean`)return+!!e;let t=e;return typeof t.toMillis==`function`?t.toMillis():e},Qd=e=>{if(e==null)return``;if(e instanceof Date)return e.toLocaleDateString();let t=e;return typeof t.toDate==`function`?t.toDate().toLocaleDateString():String(e)},$d=`(min-width: 768px)`;function ef(){let[e,t]=(0,K.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia($d).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia($d),n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function tf({rows:e,columns:t,keyOf:n,onOpen:i,actions:a,loading:o=!1,empty:s=`Nothing here yet`,search:c=!1,sort:l,className:u}){let d=(e,t)=>n?n(e):String(e.id??t),[f,p]=(0,K.useState)(l?{key:l.key,dir:l.dir||`asc`}:null),[m,h]=(0,K.useState)(``),g=ef(),_=(0,K.useMemo)(()=>{let n=m.trim().toLowerCase(),r=n?e.filter(e=>t.some(t=>t.value&&Qd(t.value(e)).toLowerCase().includes(n))):e,i=f&&t.find(e=>e.key===f.key);if(i&&i.value){let e=i.value,t=f.dir===`asc`?1:-1;r=[...r].sort((n,r)=>{let i=Zd(e(n)),a=Zd(e(r));return i===null||a===null?i===a?0:i===null?1:-1:typeof i==`number`&&typeof a==`number`?(i-a)*t:String(i).localeCompare(String(a),void 0,{numeric:!0,sensitivity:`base`})*t})}return r},[e,t,f,m]),v=e=>p(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`}),y=(e,t)=>e.cell?e.cell(t):e.value?Qd(e.value(t)):null,b=e=>t=>{let n=t.target.closest?.(Xd);n&&n!==t.currentTarget||i?.(e)},x=e=>t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i?.(e))},[S,...C]=t,T=C.find(e=>e.align===`right`&&e.phone!==!1),E=C.filter(e=>e!==T&&e.phone!==!1),D=!o&&_.length===0,O=m.trim()&&e.length?`Nothing matches “${m.trim()}”`:s;return(0,q.jsxs)(`div`,{className:r.$(`w-full`,u),children:[c&&(0,q.jsxs)(`label`,{className:`relative mb-4 flex w-full items-center sm:max-w-xs`,children:[(0,q.jsx)(w.n,{className:`pointer-events-none absolute left-3.5 z-10 h-4 w-4 text-foreground/40`,"aria-hidden":`true`}),(0,q.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:typeof c==`string`?c:`Search`,"aria-label":typeof c==`string`?c:`Search`,className:`glass-panel glow-focus block h-11 w-full pl-10 pr-4 text-sm text-foreground placeholder:text-foreground/40 focus:border-accent focus:outline-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}})]}),g&&(0,q.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-[var(--panel-border)] bg-background/30`,children:(0,q.jsxs)(`table`,{className:`w-full border-collapse text-left text-sm`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)] bg-background/50`,children:[t.map(e=>{let t=!!e.value&&e.sortable!==!1,n=f?.key===e.key?f.dir:null;return(0,q.jsx)(`th`,{scope:`col`,"aria-sort":n===`asc`?`ascending`:n===`desc`?`descending`:void 0,className:r.$(`px-4 py-3 text-xs font-semibold uppercase tracking-wide text-foreground/50`,e.align===`right`&&`text-right`),children:t?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>v(e.key),className:r.$(`inline-flex items-center gap-1 uppercase tracking-wide transition-colors hover:text-foreground focus:outline-none focus-visible:text-foreground`,n&&`text-foreground`),children:[e.label,n===`asc`&&(0,q.jsx)(r.jt,{className:`h-3 w-3`,"aria-hidden":`true`}),n===`desc`&&(0,q.jsx)(r.Mt,{className:`h-3 w-3`,"aria-hidden":`true`})]}):e.label},e.key)}),a&&(0,q.jsx)(`th`,{scope:`col`,className:`px-4 py-3`,children:(0,q.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,q.jsxs)(`tbody`,{className:`divide-y divide-[var(--panel-border)]`,children:[o&&[0,1,2,3].map(e=>(0,q.jsxs)(`tr`,{children:[t.map(e=>(0,q.jsx)(`td`,{className:`px-4 py-3.5`,children:(0,q.jsx)(P.n,{className:`h-4 w-3/4 rounded-md`})},e.key)),a&&(0,q.jsx)(`td`,{className:`px-4 py-3.5`})]},e)),D&&(0,q.jsx)(`tr`,{children:(0,q.jsx)(`td`,{colSpan:t.length+ +!!a,className:`px-4 py-12 text-center text-sm text-foreground/50`,children:O})}),!o&&_.map((e,n)=>(0,q.jsxs)(`tr`,{onClick:i?b(e):void 0,className:r.$(`transition-colors`,i&&`cursor-pointer hover:bg-foreground/[0.03]`),children:[t.map((t,n)=>(0,q.jsx)(`td`,{className:r.$(`px-4 py-3.5 align-middle text-foreground/80`,t.align===`right`&&`text-right tabular-nums`,n===0&&`font-semibold text-foreground`),children:n===0&&i?(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`text-left font-semibold hover:underline focus:outline-none focus-visible:underline`,children:y(t,e)}):y(t,e)},t.key)),a&&(0,q.jsx)(`td`,{className:`px-4 py-2.5 text-right`,children:(0,q.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:a(e)})})]},d(e,n)))]})]})}),!g&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[o&&[0,1,2].map(e=>(0,q.jsx)(P.n,{className:`h-24`},e)),D&&(0,q.jsx)(`p`,{className:`rounded-2xl border border-dashed border-[var(--panel-border)] px-4 py-10 text-center text-sm text-foreground/50`,children:O}),!o&&_.map((e,t)=>(0,q.jsxs)(`div`,{...i?{role:`button`,tabIndex:0,onClick:b(e),onKeyDown:x(e)}:{},className:r.$(`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] p-4 text-left`,i&&`cursor-pointer transition-colors hover:border-accent/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsx)(`div`,{className:`min-w-0 text-[15px] font-semibold text-foreground`,children:S?y(S,e):null}),T&&(0,q.jsx)(`div`,{className:`shrink-0 text-[15px] font-semibold tabular-nums text-foreground`,children:y(T,e)})]}),E.length>0&&(0,q.jsx)(`dl`,{className:`mt-2.5 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-sm`,children:E.map(t=>(0,q.jsxs)(`div`,{className:`contents`,children:[(0,q.jsx)(`dt`,{className:`text-foreground/50`,children:t.label}),(0,q.jsx)(`dd`,{className:`min-w-0 text-right text-foreground/80`,children:y(t,e)})]},t.key))}),a&&(0,q.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 border-t border-[var(--panel-border)] pt-3`,children:a(e)})]},d(e,t)))]})]})}tf.displayName=`DataTable`;var nf=/^(?:mem|admin|role_[a-z][a-z0-9]*)_[A-Za-z0-9_]+$/,rf=e=>nf.test(String(e||``))&&!/_history$/.test(e)?`${e}_history`:null,af=e=>e==null||e===``?void 0:String(e);function of(e,t,n={},r=null,i=Date.now()){let a=Ei(r),o=!!n.by?.name,s={recordId:String(e),what:String(t||``).trim(),creatorName:o?String(n.by.name):a.creatorName||`Somebody`,creatorAvatar:o?String(n.by.avatar||``):a.creatorAvatar,uid:r?.uid||``,createdAt:o&&Number.isFinite(n.at)&&n.at>0?n.at:i},c=af(n.from),l=af(n.to);return c!==void 0&&(s.from=c),l!==void 0&&(s.to=l),s}async function sf(e,t,n,i={}){let a=rf(e);if(!a||!t||!String(n||``).trim()){console.error(`logHistory('${e}', '${t}', '${n}'): a history line needs the record's own collection (mem_, admin_ or role_<id>_ — never an admin_ one when the team makes the changes), the record's id, and what was done.`);return}try{await(0,J.addDoc)((0,J.collection)(r.ui,a),of(t,n,i,r.li?.currentUser||null))}catch(e){console.warn(`logHistory: the line "${n}" could not be saved — ${r.ii(e,`the database refused it.`)}`)}}function cf(e,t){let n=rf(e),i=String(t||``),[a,o]=(0,K.useState)({loading:!0,error:null,lines:[]});return(0,K.useEffect)(()=>{if(!n||!i){o({loading:!1,error:null,lines:[]});return}return o({loading:!0,error:null,lines:[]}),(0,J.onSnapshot)((0,J.query)((0,J.collection)(r.ui,n),(0,J.where)(`recordId`,`==`,i)),e=>{let t=e.docs.map(e=>({...e.data()||{},id:e.id}));t.sort((e,t)=>Number(t.createdAt||0)-Number(e.createdAt||0)),o({loading:!1,error:null,lines:t})},e=>o({loading:!1,error:r.ii(e,`The history could not be read.`),lines:[]}))},[n,i]),a}var lf=e=>{if(!e)return 0;if(typeof e==`number`)return e;if(e instanceof Date)return e.getTime();let t=e;if(typeof t.toMillis==`function`)return t.toMillis();if(typeof t.seconds==`number`)return t.seconds*1e3;let n=Date.parse(String(e));return Number.isFinite(n)?n:0},uf=(e,t)=>`${e} ${t}${e===1?``:`s`} ago`,df=(e,t=Date.now())=>{let n=lf(e);if(!n)return``;let r=Math.floor(Math.max(0,t-n)/6e4);if(r<1)return`just now`;if(r<60)return uf(r,`minute`);let i=Math.floor(r/60);if(i<24)return uf(i,`hour`);let a=Math.floor(i/24);return a===1?`yesterday`:a<7?uf(a,`day`):new Date(n).toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})},ff=(e,t=!1)=>{if(!e)return null;if(t){let t=String(e.editedName||``).trim();return t?{name:t,avatar:String(e.editedAvatar||``),at:e.editedAt}:null}let n=String(e.creatorName||``).trim()||String(e.creatorEmail||``).split(`@`)[0];return n?{name:n,avatar:String(e.creatorAvatar||``),at:e.createdAt}:null},pf=e=>e.split(/\s+/).filter(Boolean).map(e=>e[0]).join(``).toUpperCase().slice(0,2);function mf({name:e,avatar:t,size:n=`sm`}){let i=n===`md`?`w-7 h-7 text-[10px]`:`w-5 h-5 text-[8px]`;return t?(0,q.jsx)(r.O,{src:t,alt:``,className:r.$(i,`rounded-full shrink-0`)}):(0,q.jsx)(`span`,{"aria-hidden":`true`,className:r.$(i,`rounded-full bg-accent/15 text-accent flex items-center justify-center font-extrabold shrink-0`),children:pf(e)})}function hf({record:e,edited:t=!1,label:n,noTime:i=!1,size:a=`sm`,className:o}){let s=ff(e,t);if(!s)return null;let c=n??(t?`Edited by`:``),l=i?``:df(s.at);return(0,q.jsxs)(`span`,{className:r.$(`inline-flex items-center gap-2 min-w-0 max-w-full align-middle`,o),children:[(0,q.jsx)(mf,{name:s.name,avatar:s.avatar,size:a}),(0,q.jsxs)(`span`,{className:r.$(`truncate font-semibold text-foreground/55`,a===`md`?`text-[13px]`:`text-[11px]`),children:[c&&(0,q.jsxs)(`span`,{className:`font-medium text-foreground/40`,children:[c,` `]}),s.name,l&&(0,q.jsxs)(`span`,{className:`font-medium text-foreground/35`,children:[` · `,l]})]})]})}var gf=e=>{let t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1),i=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return i(t,n)?`Today`:i(t,r)?`Yesterday`:t.toLocaleDateString(void 0,{day:`numeric`,month:`long`,year:t.getFullYear()===n.getFullYear()?void 0:`numeric`})};function _f(e){let t=[];for(let n of e){let e=gf(Number(n.createdAt||0)),r=t[t.length-1];r&&r.day===e?r.lines.push(n):t.push({day:e,lines:[n]})}return t}function vf({collection:e,of:t,empty:n=`Nothing has happened to this yet.`,max:i,className:a}){let{loading:o,error:s,lines:c}=cf(e,t);return o?(0,q.jsx)(`div`,{className:r.$(`py-6 flex justify-center`,a),children:(0,q.jsx)(P.t,{})}):s?(0,q.jsx)(`p`,{className:r.$(`text-[14px] text-foreground/60`,a),children:s}):c.length?(0,q.jsx)(`div`,{className:r.$(`flex flex-col gap-6`,a),children:_f(i?c.slice(0,i):c).map(e=>(0,q.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`h4`,{className:`text-[12px] font-semibold text-foreground/40 mb-1`,children:e.day}),(0,q.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--panel-border)]`,children:e.lines.map(e=>(0,q.jsxs)(`li`,{className:`py-3 flex flex-col gap-1.5 min-w-0`,children:[(0,q.jsxs)(`p`,{className:`text-[14px] text-foreground leading-snug break-words`,children:[e.what,(e.from!==void 0||e.to!==void 0)&&(0,q.jsxs)(`span`,{className:`text-foreground/55`,children:[`: `,e.from!==void 0&&(0,q.jsx)(`span`,{children:e.from}),e.from!==void 0&&e.to!==void 0&&(0,q.jsx)(u.t,{className:`inline w-3.5 h-3.5 mx-1.5 -mt-0.5`,"aria-label":`to`}),e.to!==void 0&&(0,q.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.to})]})]}),(0,q.jsx)(hf,{record:e})]},e.id))})]},e.day))}):(0,q.jsx)(`p`,{className:r.$(`text-[14px] text-foreground/45`,a),children:n})}var yf=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function bf(e){let t=String(e??``).trim().toLowerCase(),n=t.startsWith(`#`)?t:`#${t}`;return yf.test(n)?n.length===4?`#${n[1]}${n[1]}${n[2]}${n[2]}${n[3]}${n[3]}`:n:``}function xf(e){let t=Array.isArray(e)?e:e?[e]:[],n=[];for(let e of t){let t=bf(e);t&&!n.includes(t)&&n.push(t)}return n}var Sf={sm:`w-5 h-5`,md:`w-7 h-7`,lg:`w-10 h-10`},Cf=`shadow-[inset_0_0_0_2px_var(--bg-color),inset_0_0_0_4px_var(--fg-color)]`;function wf({color:e,name:t,size:n=`md`,selected:i,onClick:a,className:o}){let s=bf(e),c=t||s||`No colour`,l=r.$(`inline-block rounded-full shrink-0 border border-foreground/20 transition-shadow`,Sf[n],i&&Cf,o);return a?(0,q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},"aria-label":c,"aria-pressed":!!i,title:c,className:r.$(l,`cursor-pointer hover:border-foreground/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),style:{backgroundColor:s||void 0}}):(0,q.jsx)(`span`,{role:`img`,"aria-label":c,title:c,"data-swatch":``,className:l,style:{backgroundColor:s||void 0}})}function Tf({color:e,onPicked:t,label:n,title:i,className:a,children:o}){let s=(0,K.useRef)(null),[c,l]=(0,K.useState)(e),u=(0,K.useRef)(t);return(0,K.useEffect)(()=>{u.current=t}),(0,K.useEffect)(()=>{l(e)},[e]),(0,K.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>u.current(e.value);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,q.jsxs)(`label`,{className:r.$(`relative inline-flex items-center justify-center cursor-pointer`,a),title:i,children:[o,(0,q.jsx)(`input`,{type:`color`,value:c,"aria-label":n,ref:s,onChange:e=>l(e.target.value),className:`absolute inset-0 w-full h-full opacity-0 cursor-pointer`})]})}function Ef({label:e,value:t,onChange:n,multiple:i,max:a=12,error:o,disabled:s}){let c=(0,K.useId)(),l=xf(t),[u,d]=(0,K.useState)(``),f=i?l.length>=a:!1,p=e=>n(i?e:e[0]||``),m=e=>{let t=bf(e);t&&(p(i?l.includes(t)?l:[...l,t].slice(0,a):[t]),d(``))},h=bf(u),g=(e,t)=>{let n=bf(t);!n||n===e||p(l.includes(n)?l.filter(t=>t!==e):l.map(t=>t===e?n:t))};return(0,q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[e&&(0,q.jsx)(`span`,{id:`${c}-label`,className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:e}),(0,q.jsxs)(`div`,{role:`group`,"aria-labelledby":e?`${c}-label`:void 0,className:r.$(`glass-panel flex flex-wrap items-center gap-3 px-4 py-3`,o&&`border-red-500/50`,s&&`opacity-50 pointer-events-none`),style:{borderRadius:`var(--input-radius, 0.75rem)`},children:[l.map(e=>(0,q.jsxs)(`span`,{className:`relative inline-flex group`,children:[(0,q.jsx)(Tf,{color:e,onPicked:t=>g(e,t),label:`Change ${e}`,title:`${e} — press to change it`,className:`rounded-full`,children:(0,q.jsx)(wf,{color:e,size:`lg`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>p(l.filter(t=>t!==e)),"aria-label":`Remove ${e}`,className:`absolute -top-1.5 -right-1.5 w-5 h-5 inline-flex items-center justify-center rounded-full bg-background text-foreground/70 border border-[var(--panel-border)] cursor-pointer hover:text-foreground`,children:(0,q.jsx)(w.t,{className:`w-3 h-3`,"aria-hidden":!0})})]},e)),!f&&(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-2 min-w-0`,children:[(0,q.jsx)(Tf,{color:`#c8b6a6`,onPicked:m,label:i?`Pick a colour to add`:`Pick a colour`,title:`Pick a colour`,className:`w-10 h-10 rounded-full border border-dashed border-foreground/30 text-foreground/50 hover:text-foreground hover:border-foreground/60 transition-colors overflow-hidden`,children:(0,q.jsx)(E.t,{className:`w-4 h-4 pointer-events-none`,"aria-hidden":!0})}),(0,q.jsx)(`input`,{type:`text`,inputMode:`text`,value:u,placeholder:`#d8c3a5`,"aria-label":`Or type a hex colour`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),m(u))},onBlur:()=>m(u),className:`w-24 bg-transparent text-[14px] text-foreground placeholder:text-foreground/30 focus:outline-none border-b border-transparent focus:border-accent py-1`}),h&&(0,q.jsx)(wf,{color:h,size:`sm`})]})]}),o&&(0,q.jsx)(`p`,{className:`text-xs text-red-500 font-medium mt-1`,children:o})]})}var Df=700,Of=e=>{let t=String(e),n=t.indexOf(`.`);return n<0?0:t.length-n-1};function kf(e,{min:t=0,max:n,step:r=1}={}){let i=String(e??``).trim().replace(`,`,`.`);if(!i)return null;let a=Number(i);if(!Number.isFinite(a))return null;let o=Of(r),s=Number(a.toFixed(o)),c=n!=null&&Number.isFinite(Number(n))?Number(n):1/0;return Math.min(c,Math.max(t,s))}var Af={sm:{button:`w-9 h-9`,icon:`w-3.5 h-3.5`,box:`text-[14px]`},md:{button:`w-10 h-10`,icon:`w-4 h-4`,box:`text-[15px]`}};function jf({label:e,name:t,value:n,onChange:i,onSettled:a,min:o=0,max:s,step:c=1,size:l=`md`,error:u,disabled:d,className:f}){let p=(0,K.useId)(),m={min:o,max:s,step:c},h=kf(n,m)??o,[g,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),[b,x]=(0,K.useState)(n);n!==b&&(x(n),y(null));let S=v??h,C=(0,K.useRef)(null),w=(0,K.useRef)(h),T=(0,K.useRef)(null),D=(0,K.useRef)(a);(0,K.useEffect)(()=>{D.current=a});let O=()=>{T.current!=null&&window.clearTimeout(T.current),T.current=null;let e=C.current;C.current=null,e!=null&&e!==w.current&&D.current?.(w.current,e)};(0,K.useEffect)(()=>O,[]);let k=e=>{y(e),e!==(C.current==null?h:w.current)&&(C.current??=h,w.current=e,i(e),T.current!=null&&window.clearTimeout(T.current),T.current=window.setTimeout(O,Df))},A=()=>(g==null?null:kf(g,m))??S,j=e=>{let t=kf(A()+e,m);t!=null&&(_(null),k(t))},M=Of(c)>0,N=M?/[^0-9.,-]/g:/[^0-9-]/g,P=e=>{let t=e.replace(N,``);_(t);let n=Number(t.replace(`,`,`.`));t&&Number.isFinite(n)&&kf(t,m)===n&&k(n)},ee=()=>{let e=g==null?null:kf(g,m);_(null),e!=null&&k(e),O()},F=g??String(S),te=t||e||``,I=S<=o,L=s!=null&&S>=Number(s),ne=Af[l],R=r.$(ne.button,`inline-flex items-center justify-center rounded-full shrink-0 text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors cursor-pointer`,`focus:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-25 disabled:cursor-default disabled:hover:bg-transparent`);return(0,q.jsxs)(`div`,{className:r.$(`inline-flex flex-col`,f),children:[e&&(0,q.jsx)(`span`,{id:`${p}-label`,className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:e}),(0,q.jsxs)(`div`,{role:`group`,"aria-labelledby":e?`${p}-label`:void 0,className:r.$(`glass-panel inline-flex items-center self-start rounded-full p-0.5`,u&&`border-red-500/50`,d&&`opacity-50 pointer-events-none`),children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":`One less ${te}`.trim(),disabled:d||I,onClick:()=>j(-c),className:R,children:(0,q.jsx)(dt,{className:ne.icon,"aria-hidden":!0})}),(0,q.jsx)(`input`,{type:`text`,inputMode:M?`decimal`:`numeric`,role:`spinbutton`,"aria-label":te||`How many`,"aria-valuenow":S,"aria-valuemin":o,"aria-valuemax":s==null?void 0:Number(s),"aria-invalid":u?!0:void 0,disabled:d,value:F,onChange:e=>P(e.target.value),onFocus:e=>e.target.select(),onBlur:ee,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`ArrowUp`?(e.preventDefault(),j(c)):e.key===`ArrowDown`&&(e.preventDefault(),j(-c))},style:{width:`${Math.max(2,F.length)+1}ch`},className:r.$(`bg-transparent text-center font-semibold tabular-nums text-foreground/85 focus:outline-none`,ne.box)}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`One more ${te}`.trim(),disabled:d||L,onClick:()=>j(c),className:R,children:(0,q.jsx)(E.t,{className:ne.icon,"aria-hidden":!0})})]}),u&&(0,q.jsx)(`p`,{className:`text-xs text-red-500 font-medium mt-1`,children:u})]})}jf.displayName=`NumberStepper`;var Mf=e=>{let t=Number(e);return Number.isFinite(t)&&t>0?t:0};function Nf(e,t){let n=e.map(Mf),r=Math.max(Mf(t),...n,0);return r?n.map(e=>e?Math.max(1,Math.round(e/r*1e3)/10):0):n.map(()=>0)}var Pf=e=>e.toLocaleString();function Ff({items:e,max:t,format:n=Pf,size:i=`md`,label:a,className:o}){let[s,c]=(0,K.useState)(!1);(0,K.useEffect)(()=>{let e=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(e)},[]);let l=Nf(e.map(e=>e.value),t),u=i===`sm`;return(0,q.jsx)(`ul`,{"aria-label":a,className:r.$(`flex flex-col min-w-0`,u?`gap-2`:`gap-3.5`,o),children:e.map((e,t)=>(0,q.jsxs)(`li`,{className:`group/bar flex flex-col gap-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:r.$(`flex items-baseline justify-between gap-3 min-w-0`,u?`text-[12px]`:`text-[14px]`),children:[(0,q.jsx)(`span`,{className:`text-foreground/60 truncate`,children:e.label}),(0,q.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[(0,q.jsx)(`span`,{className:`font-semibold text-foreground`,children:n(Mf(e.value))}),e.note&&(0,q.jsxs)(`span`,{className:`text-foreground/45`,children:[` · `,e.note]})]})]}),(0,q.jsx)(`div`,{"aria-hidden":!0,className:r.$(`w-full`,u?`h-1.5`:`h-2.5`),children:(0,q.jsx)(`div`,{className:`h-full rounded-r bg-accent/70 group-hover/bar:bg-accent transition-[width,background-color] duration-700 ease-out motion-reduce:transition-none`,style:{width:`${s?l[t]:0}%`}})})]},`${e.label}-${t}`))})}var If=(...e)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return``},Lf=[`assigneeUid`,`assigneeId`,`assigneeName`,`assigneeEmail`,`assigneePhoto`,`assigneeAvatar`,`assignedToUid`,`assignedToName`],Rf=e=>{if(!e)return null;let t=`heldByUid`in e||`heldByName`in e,n=t?If(e.heldByUid):If(e.assigneeUid,e.assignedToUid,e.assigneeId),r=t?If(e.heldByName):If(e.assigneeName,e.assignedToName);return!n&&!r?null:{uid:n,name:r,photo:t?If(e.heldByPhoto):If(e.assigneePhoto,e.assigneeAvatar)}},zf=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`&&!!e):null;function Bf(e,t,n=Date.now()){let r=Rf(e),i=r?.uid&&r.uid!==t?.uid&&r.uid!==e.uid?c.E(r.uid):``,a=t?.uid?c.E(t.uid):``,o=zf(e.access),s=zf(e.editors),l=e=>[...new Set([...e.filter(e=>e!==i),...a?[a]:[]])],u={};for(let t of Lf)t in e&&(u[t]=(0,J.deleteField)());return{...u,...o&&s?{access:l(o),editors:l(s)}:a?{access:(0,J.arrayUnion)(a),editors:(0,J.arrayUnion)(a)}:i?{access:(0,J.arrayRemove)(i),editors:(0,J.arrayRemove)(i)}:{},heldByUid:t?.uid||``,heldByName:t?.name||``,heldByPhoto:t?.photo||``,heldAt:n}}var Vf=``;function Hf({person:e,small:t}){return(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-2 align-middle`,children:[(0,q.jsx)(mf,{name:e.name,avatar:e.photo,size:t?`sm`:`md`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col text-left leading-tight`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:e.name}),e.email&&e.email!==e.name&&(0,q.jsx)(`span`,{"data-handover-email":``,className:`truncate text-xs font-medium text-foreground/45`,children:e.email})]})]})}function Uf({entry:e,collection:t,role:n=`internal`,name:i=``,link:a,label:s,compact:l=!1,readOnly:u=!1,onHanded:d,className:f}){let{user:p,userRole:m,isAdmin:h}=r.Ft(),g=String(p?.uid||``),_=(0,K.useMemo)(()=>g?c.k(g,m):[],[g,m]),v=o.Tn(t),y=!u&&!!e?.id&&v&&!!g&&(h||c.C(e,_))&&oe.f(e,h?`admin`:m),b=le.r(y?n:``),[x,S]=(0,K.useState)(void 0),C=Rf(e),w=x===void 0?C:x,T=w?.uid?b.people.find(e=>e.uid===w.uid):void 0,E=w?{uid:w.uid,name:T?.name||w.name||`Somebody`,photo:T?.photo||w.photo}:null;if(!e)return null;let D=!!s&&!l,O=D&&(0,q.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/70`,children:s});if(!y){let e=(0,q.jsx)(`span`,{"data-handover":`holder`,className:r.$(`inline-flex min-w-0 max-w-full items-center font-semibold text-foreground/70`,l?`text-xs`:`text-sm`,D?``:f),children:E?(0,q.jsx)(Hf,{person:E,small:l}):(0,q.jsx)(`span`,{className:`font-medium text-foreground/40`,children:`Nobody yet`})});return D?(0,q.jsxs)(`div`,{className:r.$(`flex min-w-0 flex-col gap-1.5`,f),children:[O,e]}):e}let A=async n=>{if(n===(w?.uid||Vf)||x!==void 0)return;let o=n?b.people.find(e=>e.uid===n):null;if(n&&!o)return;let s=o?{uid:o.uid,name:o.name,photo:o.photo}:null;S(s);try{let n=(0,J.doc)(r.ui,t,String(e.id));await(0,J.runTransaction)(r.ui,async t=>{let r=await t.get(n);if(!r.exists())throw Object.assign(Error(`That one is not there any more.`),{code:`not-found`});t.update(n,{...Di(p),...Bf({...r.data(),id:e.id},s)})}),k.n(s?`Handed to ${s.name}`:`Taken back`),s&&s.uid!==g&&Nt({toUid:s.uid,title:i?`${i} is yours now`:`Something was handed to you`,body:`${If(p?.displayName,String(p?.email||``).split(`@`)[0])||`Somebody`} handed it to you.`,link:a||(typeof window<`u`?window.location.pathname:``)}),d?.(s)}catch(e){let t=e?.code;k.n(r.ii(e,t===`permission-denied`?`That one is not yours to hand over.`:t===`not-found`?`That one is not there any more.`:`That could not be handed over just now.`))}finally{S(void 0)}},j=r.qr(n),M=!b.loading&&!b.people.length;if(b.error||M)return(0,q.jsxs)(`div`,{"data-handover":`nobody`,className:r.$(`flex min-w-0 flex-col gap-1.5`,f),children:[O,E&&(0,q.jsx)(`span`,{className:`text-sm font-semibold text-foreground/70`,children:(0,q.jsx)(Hf,{person:E,small:l})}),(0,q.jsx)(`p`,{className:`text-xs leading-snug text-foreground/50`,children:b.error||(n===`internal`?`Nobody is on your team yet — people are put on it on the Users screen.`:`Nobody is marked ${j} yet — people are marked on the Users screen.`)})]});let N=[...E?[{value:Vf,label:(0,q.jsx)(`span`,{className:`text-foreground/60`,children:`Nobody`})}]:[],...E&&E.uid&&!T?[{value:E.uid,label:(0,q.jsx)(Hf,{person:E,small:!0}),disabled:!0}]:[],...b.people.map(e=>({value:e.uid,label:(0,q.jsx)(Hf,{person:e,small:!0})}))];return(0,q.jsx)(`div`,{"data-handover":`picker`,"data-no-drag":``,className:r.$(`min-w-0 [&_[role=button]_[data-handover-email]]:hidden`,l?`inline-flex max-w-full`:`w-full`,f),onClick:e=>e.stopPropagation(),children:(0,q.jsx)(r.Z,{compact:l,portal:!0,direction:`auto`,label:l?void 0:s,ariaLabel:s||`Hand to somebody`,value:E?.uid||Vf,disabled:b.loading||x!==void 0,placeholder:(0,q.jsx)(`span`,{className:`text-foreground/50`,children:b.loading?`Loading people…`:`Hand to…`}),options:b.loading&&E?[{value:E.uid,label:(0,q.jsx)(Hf,{person:E,small:!0})}]:N,onChange:A})})}Uf.displayName=`HandOver`;var Wf=e=>e.replace(/[-_]+/g,` `).replace(/^./,e=>e.toUpperCase());function Gf(e,t={}){let n=t.param||`step`,[r,i]=(0,Y.useSearchParams)(),a=(0,K.useMemo)(()=>e.map(e=>typeof e==`string`?{id:e,label:Wf(e)}:e),[e.map(e=>typeof e==`string`?e:`${e.id}:${e.label}`).join(`|`)]),o=r.get(n),s=a.findIndex(e=>e.id===o),l=s<0?0:s,u=a[l]?.id??``,d=c.x(),f=(0,K.useRef)(d);f.current=d;let p=(0,K.useCallback)(e=>{let t=f.current;if(t>0){k.n(t===1?`One file is still going up. One moment.`:`${t} files are still going up. One moment.`);return}i(t=>{let r=new URLSearchParams(t);return r.set(n,e),r})},[n,i]),m=(0,K.useCallback)(()=>{let e=a[Math.min(l+1,a.length-1)];e&&e.id!==u&&p(e.id)},[p,l,a,u]),h=(0,K.useCallback)(()=>{let e=a[Math.max(l-1,0)];e&&e.id!==u&&p(e.id)},[p,l,a,u]),g=(0,K.useCallback)(()=>{i(e=>{let t=new URLSearchParams(e);return t.delete(n),t},{replace:!0})},[n,i]);return{step:u,index:l,count:a.length,isFirst:l===0,isLast:l===a.length-1,next:m,back:h,goTo:p,reset:g,waiting:d>0,bar:{steps:a,current:u,onGo:p}}}function Kf({steps:e,current:t,onGo:n,free:i=!1,className:a}){let o=(0,K.useRef)(null),s=e.findIndex(e=>e.id===t),c=s<0?0:s,l=(0,K.useRef)(!0);if((0,K.useEffect)(()=>{if(l.current){l.current=!1;return}let e=o.current;!e||typeof e.getBoundingClientRect!=`function`||e.getBoundingClientRect().top<0&&e.scrollIntoView?.({block:`start`,behavior:`smooth`})},[t]),!e.length)return null;let u=e[c];return(0,q.jsxs)(`nav`,{ref:o,"aria-label":`Steps`,className:r.$(`w-full scroll-mt-24`,a),children:[(0,q.jsxs)(`div`,{className:`sm:hidden`,children:[(0,q.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[(0,q.jsxs)(`span`,{className:`text-foreground/50`,children:[`Step `,c+1,` of `,e.length,` · `]}),u.label]}),(0,q.jsx)(`div`,{className:`mt-2 h-1 w-full overflow-hidden rounded-full bg-foreground/10`,"aria-hidden":`true`,children:(0,q.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out motion-reduce:transition-none`,style:{width:`${(c+1)/e.length*100}%`}})})]}),(0,q.jsx)(`ol`,{className:`items-center gap-2 max-sm:hidden sm:flex`,children:e.map((t,a)=>{let o=a<c,s=a===c,l=!!n&&!s&&(o||i),u=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:r.$(`flex h-7 w-7 shrink-0 items-center justify-center rounded-full border text-[12px] font-bold transition-colors`,s&&`border-transparent [background:var(--button-bg)] text-[var(--button-fg)]`,o&&`border-accent/40 bg-accent/10 text-accent`,!s&&!o&&`border-[var(--panel-border)] text-foreground/40`),children:o?(0,q.jsx)(r.At,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}):a+1}),(0,q.jsx)(`span`,{className:r.$(`truncate text-[13px] font-semibold`,s?`text-foreground`:o?`text-foreground/70`:`text-foreground/40`),children:t.label})]});return(0,q.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,"aria-current":s?`step`:void 0,children:[l?(0,q.jsx)(`button`,{type:`button`,onClick:()=>n?.(t.id),className:`flex min-w-0 items-center gap-2 rounded-full py-1 pr-2 transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:u}):(0,q.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 py-1 pr-2`,children:u}),a<e.length-1&&(0,q.jsx)(`span`,{"aria-hidden":`true`,className:r.$(`h-px w-6 shrink-0 lg:w-10`,o?`bg-accent/40`:`bg-[var(--panel-border)]`)})]},t.id)})})]})}Kf.displayName=`StepBar`;var qf=48,Jf=8,Yf=2.5,Xf=5;function Zf(e,t){if(!t||t.width<=0||t.height<=0||e.width<=0||e.height<=0)return{x:[0,1],y:[0,1]};let n=Math.min(e.width/t.width,e.height/t.height),r=t.width*n/e.width,i=t.height*n/e.height;return{x:[(1-r)/2,(1+r)/2],y:[(1-i)/2,(1+i)/2]}}function Qf(e,[t,n]){if(e<=1)return[.5,.5];if(e*(n-t)>=1)return[e*t/(e-1),(e*n-1)/(e-1)];let r=(e*((t+n)/2)-.5)/(e-1);return[r,r]}var $f=(e,[t,n])=>Math.min(n,Math.max(t,e));function ep({pictures:e,index:t,onIndex:n,onClose:i,zoom:a=!1}){let o=(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?{src:e}:e&&typeof e==`object`&&typeof e.src==`string`?e:{src:``}),s=t!==null&&t>=0&&t<o.length,c=s?t:0,l=o.length>1,u=r.tt(),d=(0,K.useRef)(()=>{}),f=(0,K.useRef)(null);(0,K.useEffect)(()=>{d.current=e=>{l&&n((c+e+o.length)%o.length)}}),(0,K.useEffect)(()=>{if(!s)return;let e=()=>{f.current=null};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[s]),(0,K.useEffect)(()=>{if(!s)return;let e=e=>{e.key===`ArrowLeft`&&(e.preventDefault(),d.current(-1)),e.key===`ArrowRight`&&(e.preventDefault(),d.current(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s]);let p=o[c],m=()=>({s:1,x:.5,y:.5,by:`press`}),[h,g]=(0,K.useState)(m),v=s?`${c}:${p?.src}`:null;(0,K.useEffect)(()=>{f.current=null},[v]);let[b,x]=(0,K.useState)(v);v!==b&&(x(v),g(m()));let S=h.s>1,C=(0,K.useRef)(null),w=(0,K.useRef)(new Map),T=(0,K.useRef)(null),E=()=>{let e=f.current;if(e&&e.exact)return e;let t=C.current?.getBoundingClientRect(),n={left:t?.left||0,top:t?.top||0,width:t?.width||0,height:t?.height||0},i=[...C.current?.querySelectorAll(`img`)||[]].reverse().find(e=>e.naturalWidth>0),a=p&&r.k(p.src)||(p?.width&&p?.height?{width:p.width,height:p.height}:void 0)||(i?{width:i.naturalWidth,height:i.naturalHeight}:void 0),o={box:n,span:Zf(n,a),exact:!!a&&n.width>0&&n.height>0};return f.current=o,o},D=()=>{f.current=null},O=(e,t,n,r)=>{if(e<=1)return{s:1,x:t,y:n,by:r};let{span:i}=E();return{s:e,x:$f(t,Qf(e,i.x)),y:$f(n,Qf(e,i.y)),by:r}},k=(e,t,n,r)=>{let{box:i,span:a}=E(),o=i.width?Math.min(1,Math.max(0,(e-i.left)/i.width)):.5,s=i.height?Math.min(1,Math.max(0,(t-i.top)/i.height)):.5,[c,l]=Qf(n,a.x),[u,d]=Qf(n,a.y);return{s:n,x:c+o*(l-c),y:u+s*(d-u),by:r}},A=()=>{let[e,t]=[...w.current.values()];return Math.hypot(e.x-t.x,e.y-t.y)||1},j=e=>{if(!(e.pointerType===`mouse`&&e.button!==0)){D(),w.current.set(e.pointerId,{x:e.clientX,y:e.clientY});try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}if(w.current.size===1)T.current={x:e.clientX,y:e.clientY,last:{x:e.clientX,y:e.clientY},moved:!1,pinched:!1};else if(w.current.size===2&&T.current&&(T.current.moved=!0,T.current.pinched=!0,T.current.pinch={dist:A(),s:h.s},!S)){let{box:e}=E(),[t,n]=[...w.current.values()];g({s:1,x:e.width?((t.x+n.x)/2-e.left)/e.width:.5,y:e.height?((t.y+n.y)/2-e.top)/e.height:.5,by:`finger`})}}},N=e=>{if(!w.current.has(e.pointerId)){e.pointerType===`mouse`&&S&&g(k(e.clientX,e.clientY,h.s,`mouse`));return}w.current.set(e.pointerId,{x:e.clientX,y:e.clientY});let t=T.current;if(!t)return;if(t.pinch&&w.current.size>=2){g(O(Math.min(Xf,Math.max(1,t.pinch.s*A()/t.pinch.dist)),h.x,h.y,`finger`));return}let n=e.clientX-t.last.x,r=e.clientY-t.last.y;if(t.last={x:e.clientX,y:e.clientY},Math.hypot(e.clientX-t.x,e.clientY-t.y)>Jf&&(t.moved=!0),!S)return;if(e.pointerType===`mouse`){g(k(e.clientX,e.clientY,h.s,`mouse`));return}let{box:i}=E();!i.width||!i.height||g(O(h.s,h.x-n/i.width/(h.s-1),h.y-r/i.height/(h.s-1),`finger`))},P=e=>{if(!w.current.delete(e.pointerId))return;let t=T.current;if(w.current.size>0){if(t){t.pinch=void 0;let[e]=[...w.current.values()];t.last=e}return}if(T.current=null,!t)return;if(t.pinched){h.s<1.15&&g({...h,s:1,by:`press`});return}if(!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=Jf){g(S?{...h,s:1,by:`press`}:k(e.clientX,e.clientY,Yf,`press`));return}if(S)return;let n=e.clientX-t.x;Math.abs(n)>qf&&Math.abs(n)>Math.abs(e.clientY-t.y)*1.5&&d.current(n<0?1:-1)},ee=e=>{w.current.delete(e.pointerId),w.current.size||(T.current=null)},F=`cubic-bezier(0.22, 1, 0.36, 1)`,te=u||h.by===`finger`||h.by===`mouse`?`none`:`transform 350ms ${F}, transform-origin 350ms ${F}`,I=`absolute z-10 flex h-11 w-11 items-center justify-center rounded-full border border-[var(--panel-border)] bg-background/80 text-foreground backdrop-blur-sm transition-colors hover:bg-background focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 cursor-pointer`;return(0,q.jsx)(M.t,{open:s,onClose:i,size:`xl`,title:l?`${c+1} of ${o.length}`:void 0,className:`px-3 pb-4 sm:px-5 sm:pb-5`,children:p&&(0,q.jsxs)(`figure`,{className:`select-none`,children:[(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(`div`,{ref:C,"data-lightbox-stage":!0,className:`relative overflow-hidden rounded-xl`,style:{touchAction:`none`,cursor:S?`zoom-out`:`zoom-in`},onPointerDown:j,onPointerMove:N,onPointerUp:P,onPointerCancel:ee,children:(0,q.jsx)(`div`,{className:`h-[62dvh] w-full sm:h-[72vh]`,style:{transform:`scale(${h.s})`,transformOrigin:`${h.x*100}% ${h.y*100}%`,transition:te,willChange:S?`transform`:void 0},children:(0,q.jsx)(r.O,{src:p.src,alt:p.alt||p.caption||``,fit:`contain`,priority:!0,draggable:!1,className:`h-full w-full`,preload:l?[o[(c+1)%o.length].src,o[(c-1+o.length)%o.length].src].filter(Boolean):void 0})})}),l&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":`Previous picture`,onClick:()=>d.current(-1),className:`${I} left-2 top-1/2 -translate-y-1/2`,children:(0,q.jsx)(_.t,{className:`h-5 w-5`,"aria-hidden":`true`})}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Next picture`,onClick:()=>d.current(1),className:`${I} right-2 top-1/2 -translate-y-1/2`,children:(0,q.jsx)(r.kt,{className:`h-5 w-5`,"aria-hidden":`true`})})]}),(0,q.jsx)(`button`,{type:`button`,"aria-label":S?`Zoom out`:`Zoom in`,onClick:()=>g(S?{...h,s:1,by:`press`}:O(Yf,.5,.5,`press`)),className:`${I} bottom-3 right-3`,children:S?(0,q.jsx)(y.o,{className:`h-5 w-5`,"aria-hidden":`true`}):(0,q.jsx)(y.a,{className:`h-5 w-5`,"aria-hidden":`true`})})]}),p.caption&&(0,q.jsx)(`figcaption`,{className:`mt-3 text-center text-sm text-foreground/70`,children:p.caption})]})})}ep.displayName=`Lightbox`;var tp=/^(?:https?:\/\/|mailto:|tel:|\/(?!\/))/i,np=/\*\*([^*]+)\*\*|\*([^*\n]+)\*|\[([^\]]+)\]\(([^)\s]+)\)|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])/g;function rp(e,t){let n=[],r=0,i=0;for(let a of e.matchAll(np)){let o=a.index??0;o>r&&n.push(e.slice(r,o));let s=`${t}-${i++}`;if(a[1]!=null)n.push((0,q.jsx)(`strong`,{className:`font-semibold text-foreground`,children:a[1]},s));else if(a[2]!=null)n.push((0,q.jsx)(`em`,{children:a[2]},s));else{let e=a[4]??a[5],t=a[3]??a[5];if(e&&tp.test(e)){let r=/^https?:/i.test(e);n.push((0,q.jsx)(`a`,{href:e,...r?{target:`_blank`,rel:`noopener noreferrer`}:{},className:`font-medium text-accent underline decoration-accent/40 underline-offset-4 transition-colors hover:decoration-accent`,children:t},s))}else n.push(t)}r=o+a[0].length}return r<e.length&&n.push(e.slice(r)),n}var ip=(e,t)=>e.map((e,n)=>(0,q.jsxs)(K.Fragment,{children:[n>0&&(0,q.jsx)(`br`,{}),rp(e,`${t}-l${n}`)]},`${t}-l${n}`)),ap=/^!\[([^\]]*)\]\((https?:\/\/[^)\s]+)\)$/;function op({text:e,className:t}){let n=String(e??``).replace(/\r\n?/g,`
|
|
21
21
|
`).trim();if(!n)return null;let i=n.split(/\n{2,}/).map(e=>e.split(`
|
|
22
|
-
`).map(e=>e.trimEnd()).filter(e=>e.trim()!==``)),a=[];return i.forEach((e,t)=>{if(!e.length)return;let n=`b${t}`,i=e[0].trim(),o=e.length===1&&i.match(/^(#{1,3})\s+(.+)$/),s=e.length===1&&i.match(
|
|
23
|
-
`),j=(0,
|
|
24
|
-
`):[]},[A]);let M=e=>{j.current=e;let n=e.map(e=>D.current.find(t=>t.url===e)).filter(Boolean);l?t(e,n):t(e[0]||``,n[0]||null)},N=e=>{let t=D.current.find(t=>t.url===e);t&&c.m(t.storagePath)},
|
|
22
|
+
`).map(e=>e.trimEnd()).filter(e=>e.trim()!==``)),a=[];return i.forEach((e,t)=>{if(!e.length)return;let n=`b${t}`,i=e[0].trim(),o=e.length===1&&i.match(/^(#{1,3})\s+(.+)$/),s=e.length===1&&i.match(ap);if(o){let e=o[1].length>1;a.push(e?(0,q.jsx)(`h3`,{className:`mt-10 text-xl font-bold tracking-tight text-foreground first:mt-0`,children:rp(o[2],n)},n):(0,q.jsx)(`h2`,{className:`mt-12 text-2xl font-bold tracking-tight text-foreground first:mt-0 md:text-3xl`,children:rp(o[2],n)},n))}else s?a.push((0,q.jsx)(r.O,{src:s[2],alt:s[1],className:`my-2 w-full overflow-hidden rounded-2xl`},n)):e.every(e=>/^\s*[-*•]\s+/.test(e))?a.push((0,q.jsx)(`ul`,{className:`list-disc space-y-2 pl-6 marker:text-foreground/40`,children:e.map((e,t)=>(0,q.jsx)(`li`,{children:rp(e.replace(/^\s*[-*•]\s+/,``),`${n}-${t}`)},t))},n)):e.every(e=>/^\s*\d+[.)]\s+/.test(e))?a.push((0,q.jsx)(`ol`,{className:`list-decimal space-y-2 pl-6 marker:font-semibold marker:text-foreground/50`,children:e.map((e,t)=>(0,q.jsx)(`li`,{children:rp(e.replace(/^\s*\d+[.)]\s+/,``),`${n}-${t}`)},t))},n)):e.every(e=>/^\s*>\s?/.test(e))?a.push((0,q.jsx)(`blockquote`,{className:`border-l-2 border-accent/50 pl-5 text-foreground/70 italic`,children:ip(e.map(e=>e.replace(/^\s*>\s?/,``)),n)},n)):a.push((0,q.jsx)(`p`,{children:ip(e,n)},n))}),(0,q.jsx)(`div`,{className:r.$(`flex w-full max-w-[70ch] flex-col gap-5 text-[17px] leading-8 text-foreground/80 break-words`,t),children:a})}op.displayName=`Article`;var sp=`relative w-[88px] h-[88px] shrink-0 rounded-[var(--card-radius,1rem)] overflow-hidden border border-[var(--panel-border)] bg-[var(--panel-bg)]`,cp=sp.replace(`w-[88px] h-[88px]`,`w-[112px] h-[112px]`),lp=(e,t=``)=>t.startsWith(`image/`)||e.startsWith(`data:image/`)||/\.(?:jpe?g|png|gif|webp|avif|svg)(?:[?#]|$)/i.test(e),up=e=>{try{return ee.x(decodeURIComponent(new URL(e).pathname.split(`/o/`)[1]||new URL(e).pathname).split(`/`).pop()||``).replace(/^\d{10,}_[a-z0-9]+_/,``)||`Your file`}catch{return`Your file`}};function dp({item:e,onStop:t,tile:n=sp}){return(0,q.jsxs)(`div`,{className:n,children:[e.file.type.startsWith(`image/`)?(0,q.jsx)(c.n,{file:e.file,className:`w-full h-full object-cover opacity-60`}):(0,q.jsxs)(`span`,{className:`flex flex-col items-center justify-center gap-1 w-full h-full p-2 text-center`,children:[(0,q.jsx)(y.u,{className:`w-5 h-5 text-accent/40`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[10px] font-semibold text-foreground/40 leading-tight line-clamp-2 break-all`,children:e.file.name})]}),(0,q.jsx)(`span`,{role:`progressbar`,"aria-label":`Uploading ${e.file.name}`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(e.progress*100),className:`absolute left-2 right-2 bottom-2 h-1 rounded-full bg-foreground/15 overflow-hidden`,children:(0,q.jsx)(`span`,{className:`block h-full rounded-full bg-accent transition-[width] duration-200`,style:{width:`${Math.max(4,e.progress*100)}%`}})}),(0,q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Stop ${e.file.name}`,title:`Stop`,className:`absolute top-1 right-1 w-6 h-6 rounded-lg flex items-center justify-center bg-background/85 text-foreground/60 hover:text-red-500 transition-colors cursor-pointer`,children:(0,q.jsx)(w.t,{className:`w-3.5 h-3.5`})})]})}function fp({value:e,onChange:t,label:i,hint:a,accept:s=`image/*`,multiple:l=!1,max:u,sortable:d=!1,shared:f=!1,disabled:p=!1,className:m}){let{user:h,userRole:g,isAdmin:_}=r.Ft(),v=c._(),b=v.prefix||(h?`user_`:`pub_`),[x,S]=(0,K.useState)(``),[C,T]=(0,K.useState)([]),D=(0,K.useRef)([]),O=(0,K.useRef)(new Map),k=Array.isArray(e)?e.filter(Boolean):e?[e]:[],A=k.join(`
|
|
23
|
+
`),j=(0,K.useRef)(k);(0,K.useEffect)(()=>{j.current=A?A.split(`
|
|
24
|
+
`):[]},[A]);let M=e=>{j.current=e;let n=e.map(e=>D.current.find(t=>t.url===e)).filter(Boolean);l?t(e,n):t(e[0]||``,n[0]||null)},N=e=>{let t=D.current.find(t=>t.url===e);t&&c.m(t.storagePath)},P=c.b({stopOnUnmount:!0,upload:(e,t)=>c.g(e,{prefix:b,shared:f,user:h?{uid:h.uid,internal:o.Sn(g),admin:!!_||o.wn(g)}:null,onProgress:t.progress,signal:t.signal,collection:v.collection,recordId:v.recordId}),onUploaded:(e,t)=>{D.current=[...D.current,e],T(D.current),O.current.set(e.url,t.seq),P.remove(t.id),l?M(c.v([...j.current,e.url],O.current)):(j.current.forEach(N),M([e.url]))},onFailed:e=>{S(l?`${e.file.name}: ${e.error}`:e.error||``),P.remove(e.id)}}),ee=P.items.filter(e=>e.state===`waiting`||e.state===`uploading`),F=ee.length>0,te=l&&!!u&&k.length+ee.length>=u,I=e=>{if(p)return;let t=e;l?u&&(t=e.slice(0,Math.max(0,u-j.current.length-ee.length))):(ee.forEach(e=>P.remove(e.id)),t=e.slice(0,1)),t.length&&(S(``),P.add(t))},L=e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&I(t)},ne=e=>{e.forEach(e=>O.current.delete(e)),M(e)},R=e=>{S(``),N(e),M(j.current.filter(t=>t!==e))},{over:z,dropProps:re}=r.A({accept:s,multiple:l,disabled:p||te,onFiles:I,onReject:()=>S(s.startsWith(`image`)?`That is not a picture — drop a JPG or a PNG.`:`That kind of file does not go here.`)}),ie=(0,q.jsx)(`input`,{type:`file`,accept:s,multiple:l,disabled:p||te,onChange:L,"aria-label":i?`Upload ${i}`:`Upload a file`,className:`sr-only`}),B=d&&l,V=(e,t)=>{let n=C.find(t=>t.url===e);return(0,q.jsxs)(`div`,{className:B?cp:sp,children:[lp(e,n?.type)?(0,q.jsx)(r.O,{src:e,alt:i||up(e),className:`absolute inset-0`}):(0,q.jsxs)(`span`,{className:`flex flex-col items-center justify-center gap-1 w-full h-full p-2 text-center`,children:[(0,q.jsx)(y.u,{className:`w-5 h-5 text-accent/60`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[10px] font-semibold text-foreground/50 leading-tight line-clamp-2 break-all`,children:n?.name||up(e)})]}),!p&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>R(e),"aria-label":`Remove ${i||up(e)}`,title:`Remove`,className:r.$(`absolute top-1 w-6 h-6 rounded-lg flex items-center justify-center bg-background/85 text-foreground/60 hover:text-red-500 transition-colors cursor-pointer`,B?`left-1`:`right-1`),children:(0,q.jsx)(w.t,{className:`w-3.5 h-3.5`})}),B&&(t===0?(0,q.jsx)(`span`,{className:`absolute bottom-1 left-1 px-2 py-0.5 rounded-md bg-foreground text-background text-[10px] font-bold`,children:`Main`}):!p&&(0,q.jsx)(`button`,{type:`button`,disabled:F,title:F?`Once every picture has landed`:`Make this the main picture`,onClick:()=>ne([e,...j.current.filter(t=>t!==e)]),className:`absolute bottom-1 left-1 px-2 py-0.5 rounded-md bg-background/85 text-foreground/70 hover:text-foreground text-[10px] font-bold cursor-pointer backdrop-blur-sm disabled:opacity-40 disabled:cursor-default disabled:hover:text-foreground/70`,children:`Make main`}))]})},ae=z?l?`Drop them here`:`Drop it here`:a||(s.startsWith(`image`)?`Upload ${l?`pictures`:`a picture`}, or drop ${l?`them`:`one`} here`:`Upload ${l?`files`:`a file`}, or drop ${l?`them`:`one`} here`);return(0,q.jsxs)(`div`,{className:r.$(`flex flex-col gap-2 min-w-0`,m),...re,children:[i&&(0,q.jsx)(`span`,{className:`text-[12px] font-extrabold tracking-tight text-foreground/60`,children:i}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[B&&k.length>0?(0,q.jsx)(Yd,{items:k,onReorder:ne,grip:`corner`,disabled:p||F,className:`flex flex-wrap items-start gap-2`,label:(e,t)=>`${i||up(e)} ${t+1} of ${k.length}`,item:(e,t)=>V(e,t)}):k.map((e,t)=>(0,q.jsx)(K.default.Fragment,{children:V(e,t)},e)),ee.map(e=>(0,q.jsx)(dp,{item:e,onStop:()=>P.remove(e.id),tile:B?cp:sp},e.id)),!te&&(0,q.jsxs)(`label`,{title:i?`Upload ${i}`:`Upload a file`,className:r.$(`group flex items-center gap-3 min-w-0 transition-colors`,k.length||ee.length?r.$(B?cp:sp,`flex-col items-center justify-center gap-1 text-foreground/40 hover:text-accent hover:border-accent/40`):r.$(`flex-1 w-full px-4 py-4 rounded-[var(--card-radius,1rem)] border border-dashed`,z?`border-accent bg-accent/[0.04]`:`border-[var(--panel-border)] hover:border-accent/40`),p?`opacity-50 pointer-events-none`:`cursor-pointer`),children:[k.length||ee.length?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(E.t,{className:`w-5 h-5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[10px] font-bold`,children:z?`Drop`:l?`Add`:`Swap`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:r.$(`w-10 h-10 shrink-0 rounded-xl flex items-center justify-center border transition-colors`,z?`border-accent text-accent`:`border-[var(--panel-border)] text-foreground/40 group-hover:text-accent group-hover:border-accent/40`),children:(0,q.jsx)(n.v,{className:`w-4 h-4`})}),(0,q.jsx)(`span`,{className:r.$(`text-[13px] font-semibold truncate`,z?`text-accent`:`text-foreground/50`),children:ae})]}),ie]})]}),x&&(0,q.jsx)(`span`,{className:`text-[12px] font-semibold text-red-500`,children:x})]})}var pp=r.si(()=>Promise.resolve().then(()=>require(`./AddressField-CI8PP5ow.cjs`)).then(e=>({default:e.AddressField}))),mp=({label:e,required:t})=>(0,q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,q.jsxs)(`span`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:[e,` `,t&&(0,q.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,q.jsx)(`div`,{className:`h-12 w-full glass-panel opacity-60`,style:{borderRadius:`var(--input-radius, 0.75rem)`}})]});function hp(e){return(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(mp,{label:e.label,required:e.required}),children:(0,q.jsx)(pp,{...e})})}exports.AddressField=hp,exports.AdminNotifications=Gt,exports.Article=op,exports.Bars=Ff,exports.Basket=Sd,exports.BasketButton=wd,exports.Button=N.t,exports.BuyButton=Ed,exports.BuyerDetails=Ku,exports.Card=zd,exports.Checkout=Xu,exports.CheckoutReturn=td,exports.ConfirmModal=ie.t,exports.ContactPopup=g.t,exports.CustomSelect=r.Z,exports.DashboardNav=i.t,exports.DataTable=tf,exports.EMPTY_ADDRESS=F.n,exports.EVERYONE=c.S,exports.EventCard=h.r,exports.FileViewer=y.n,exports.FileViewerPopup=y.t,exports.FirebaseOS=ql,exports.HandOver=Uf,exports.History=vf,exports.Input=g.y,exports.Lightbox=ep,exports.Loader=P.t,exports.MadeBy=hf,exports.ManagePlanButton=ce.t,exports.Navbar=Mn,exports.NumberStepper=jf,exports.PayButton=Yi,exports.PhoneInputField=G.t,exports.Picture=r.O,exports.Pipeline=Wd,exports.Plans=Fd,exports.Popup=M.t,exports.PublicMenu=$t,exports.Reveal=r.T,exports.RevealList=r.E,exports.SectionHeading=Bd,exports.Skeleton=P.n,exports.Sortable=Yd,exports.StepBar=Kf,exports.Swap=r.D,exports.Swatch=wf,exports.SwatchField=Ef,exports.TALLY_COUNTERS=Yl,exports.TextArea=g.v,exports.TimeChips=m.l,exports.TutorialVideo=v.n,exports.UploadBox=fp,exports.VideoPlayer=b.t,exports.acceptBooking=f.t,Object.defineProperty(exports,`auth`,{enumerable:!0,get:function(){return r.li}}),exports.availableSlots=o.k,exports.availableSlotsFor=o.A,exports.barShares=Nf,exports.blockedWindows=o.N,exports.bookingPath=o.U,exports.canEdit=c.C,exports.canSee=c.w,exports.cancelBooking=f.r,exports.composeAddress=F.s,exports.confirmPayment=r.An,exports.countOf=kf,exports.dayBlocked=o.Y,exports.daysLine=o.X,Object.defineProperty(exports,`db`,{enumerable:!0,get:function(){return r.ui}}),exports.emailAnyone=I.t,exports.emailOwner=I.r,exports.emailPerson=I.i,exports.emailStatus=I.a,exports.eventName=o.it,exports.forPerson=c.E,exports.forRole=c.D,exports.hasAddress=F.c,exports.historyCollection=rf,exports.holderOf=Rf,exports.hoursSummary=o.mt,exports.isPublished=c.O,exports.keysOf=c.k,exports.logHistory=sf,exports.madeBy=ff,exports.meetPath=V.l,exports.money=ac,exports.notify=Nt,exports.oneEach=o.Et,exports.openBillingPortal=r.Nn,exports.partySlots=o.At,exports.payPath=o.jt,exports.publish=c.A,exports.registerMicrocomponent=Rd,exports.say=k.n,exports.scheduleName=o.It,exports.scheduleTitle=o.Vt,exports.sendTo=c.j,exports.shadeOf=bf,exports.shadesOf=xf,exports.slotsFor=o.Qt,exports.startCheckout=r.Fn,Object.defineProperty(exports,`storage`,{enumerable:!0,get:function(){return r.fi}}),exports.takeBack=c.M,exports.tally=cu,exports.timeZoneLabel=o.nn,exports.togetherSlots=o.on,exports.troubleSentence=r.ii,exports.unpublish=c.N,exports.unsay=k.r,exports.useAuth=r.Ft,exports.useBasket=gd,exports.useBookings=f.v,exports.useCase=c.P,exports.useCases=c.F,exports.useCasesFromForm=rl,exports.useConfig=r.mi,exports.useHistory=cf,exports.useMemberSchedules=f.y,exports.useMyBookings=f.b,exports.useMyPayments=r.Rn,exports.usePaymentsEnabled=r.zn,exports.usePeople=le.r,exports.usePlans=Nd,exports.usePublicCopy=C.g,exports.usePublished=c.I,exports.useSales=r.Bn,exports.useSteps=Gf,exports.useStock=Ka,exports.useStockFromOrders=Fu,exports.useTakenSlots=f.C,exports.useTallies=lu,exports.useTeamHours=f.w,exports.useTheme=i.N,exports.useVisitorState=g._,exports.whenWords=df,exports.withAccess=c.L,exports.withStockSetAt=Va;
|