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,8 +1,8 @@
|
|
|
1
1
|
import { b as e, d as t, m as n, p as r, y as i } from "./mediaKind-BtaMpGy8.js";
|
|
2
|
-
import "./PageTitle-
|
|
2
|
+
import "./PageTitle-CkZriz8K.js";
|
|
3
3
|
import { Ft as a, U as o, W as s, fi as c, nt as l, o as u, ui as d } from "./TimeZoneField-oIMwb5_X.js";
|
|
4
4
|
import { n as f } from "./chevron-down--LwXEv9w.js";
|
|
5
|
-
import { t as p } from "./TemplateDrive-
|
|
5
|
+
import { t as p } from "./TemplateDrive-6aV9Hmh3.js";
|
|
6
6
|
import { r as m } from "./x-hax8aKt8.js";
|
|
7
7
|
import { t as h } from "./trash-6Wj66gJi.js";
|
|
8
8
|
import { t as g } from "./ConfirmModal-BW9e6Y7d.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./chunk-CiTBaPhY.cjs`),require(`./PageTitle-
|
|
1
|
+
require(`./chunk-CiTBaPhY.cjs`),require(`./PageTitle-BL50s4qY.cjs`);const e=require(`./TimeZoneField-Ckn1pKAL.cjs`),t=require(`./chevron-down-lyDK1rfL.cjs`),n=require(`./TemplateDrive-ElNPzwv3.cjs`),r=require(`./x-Ci8c5p6T.cjs`),i=require(`./trash-D-CpYHCs.cjs`),a=require(`./mediaKind-ButDya5f.cjs`),o=require(`./ConfirmModal-BUNtss4a.cjs`),s=require(`./fileBytes-BLDZ-2kj.cjs`),c=require(`./SystemTabContent-BWhRHoXx.cjs`);let l=require(`react`),u=require(`react/jsx-runtime`),d=require(`firebase/firestore`),f=require(`firebase/storage`);var p={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};p.node;var m=t.n(p),h=[`pub_files`,`pub_files/pages`,`pub_form_uploads/pages`],g=/^image\/(jpe?g|png|webp|avif)$/i;async function _(t){try{let n=await(0,f.listAll)((0,f.ref)(e.fi,t)),r=n.items.map(e=>e.fullPath).filter(e=>!a.d(e)),i=await Promise.all(n.prefixes.map(e=>_(e.fullPath)));return[...r,...i.flat()]}catch{return[]}}var v=t=>RegExp(`max-age=${e.U}`).test(String(t||``));async function y(t){try{return await(0,f.getMetadata)((0,f.ref)(e.fi,t)),!0}catch{return!1}}async function b(t,n){let r=``;try{let i=await(0,f.getMetadata)((0,f.ref)(e.fi,t));r=String(i.contentType||``),v(i.cacheControl)||(await(0,f.updateMetadata)((0,f.ref)(e.fi,t),{cacheControl:e.W(t).cacheControl,...i.customMetadata?{customMetadata:i.customMetadata}:{}}),n.headersFixed++)}catch{n.skipped++;return}if(!g.test(r))return;let i=[{path:a.p(t),make:a.m},{path:a.y(t),make:a.b}].filter(e=>e.path),o=[];for(let e of i)await y(e.path)||o.push(e);if(!o.length)return;let c;try{c=await s.t(await(0,f.getDownloadURL)((0,f.ref)(e.fi,t)))}catch{n.skipped++;return}let l=t.slice(t.lastIndexOf(`/`)+1),u=new File([c],l,{type:r||c.type});for(let t of o)try{let r=await t.make(u,l);if(!r)continue;await(0,f.uploadBytes)((0,f.ref)(e.fi,t.path),r,e.W(t.path)),n.companionsMade++}catch{}}async function x(e={}){let{onProgress:t,signal:n}=e,r={done:0,total:0,headersFixed:0,companionsMade:0,skipped:0},i=await Promise.all(h.map(_)),a=[...new Set(i.flat())];r.total=a.length,t?.({...r});let o=0;return await Promise.all(Array.from({length:Math.min(4,a.length)},async()=>{for(;o<a.length;){if(n?.aborted)return;let e=a[o++];await b(e,r),r.done++,t?.({...r})}})),{...r}}var S=[`mem_files`,`user_files`,`admin_files`],C=e=>!e.sourceTab;function w(){let[t,n]=(0,l.useState)(null),[a,s]=(0,l.useState)(!1),[c,p]=(0,l.useState)(!1),[m,h]=(0,l.useState)(``),[g,_]=(0,l.useState)(0);(0,l.useEffect)(()=>{let t=!1;return Promise.all(S.map(async t=>{try{return(await(0,d.getDocs)((0,d.collection)(e.ui,t))).docs.map(e=>({collectionName:t,id:e.id,...e.data()}))}catch{return[]}})).then(e=>{t||n(e.flat())}),()=>{t=!0}},[]);let v=async()=>{if(!t)return;p(!0),h(``);let r=0;for(let n of t)try{let t=n.storagePath||n.downloadURL;t&&C(n)&&await(0,f.deleteObject)((0,f.ref)(e.fi,t)).catch(()=>{}),await(0,d.deleteDoc)((0,d.doc)(e.ui,n.collectionName,n.id)),_(e=>e+1)}catch(e){r+=1,console.error(`Could not delete ${n.collectionName}/${n.id}:`,e)}r>0?(h(`${r} file${r===1?``:`s`} could not be deleted. Reload and try again.`),n((await Promise.all(S.map(async t=>{try{return(await(0,d.getDocs)((0,d.collection)(e.ui,t))).docs.map(e=>({collectionName:t,id:e.id,...e.data()}))}catch{return[]}}))).flat())):n([]),p(!1),s(!1)};if(!t||t.length===0)return null;let y=t.filter(C).length,b=S.map(e=>({name:e,n:t.filter(t=>t.collectionName===e).length})).filter(e=>e.n>0);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(e.nt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`mt-6 glass-panel border border-amber-500/25 bg-amber-500/[0.03] rounded-2xl md:rounded-3xl p-4 md:p-8`,children:[(0,u.jsxs)(`h3`,{className:`text-[17px] font-bold text-foreground tracking-tight mb-2`,children:[t.length,` leftover record`,t.length===1?``:`s`,` from the old Drive`]}),(0,u.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed mb-3 max-w-2xl`,children:`Drive used to have Internal, User and Admin folders. They are gone — this page is the only built-in folder now, and each page you have built keeps its own files. Nothing reads these records any more.`}),(0,u.jsxs)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed mb-3 max-w-2xl`,children:[y>0?`${y} ${y===1?`was`:`were`} uploaded through the old Drive screen, so ${y===1?`its file is`:`their files are`} deleted too. `:``,t.length-y>0?`${t.length-y} belong to files a page still shows, so only the leftover record goes — the ${t.length-y===1?`file stays`:`files stay`} where ${t.length-y===1?`it is`:`they are`}.`:``]}),(0,u.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium mb-5`,children:b.map(e=>`${e.n} in ${e.name}`).join(` · `)}),m&&(0,u.jsx)(`p`,{className:`text-[13px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded-xl p-3 mb-4`,children:m}),(0,u.jsxs)(`button`,{onClick:()=>s(!0),disabled:c,className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-bold bg-red-500/10 hover:bg-red-500/20 text-red-500 border border-red-500/20 transition-colors disabled:opacity-50`,children:[c?(0,u.jsx)(r.r,{className:`w-4 h-4 animate-spin`}):(0,u.jsx)(i.t,{className:`w-4 h-4`}),c?`Deleting ${g} of ${t.length}…`:`Clean up all ${t.length} permanently`]})]}),(0,u.jsx)(o.t,{isOpen:a,title:`Delete the old Drive files`,message:(0,u.jsxs)(u.Fragment,{children:[`This permanently deletes `,(0,u.jsxs)(`strong`,{className:`text-foreground`,children:[t.length,` leftover record`,t.length===1?``:`s`]}),` `,`from `,b.map(e=>e.name).join(`, `),y>0&&(0,u.jsxs)(u.Fragment,{children:[`, along with the `,(0,u.jsxs)(`strong`,{className:`text-foreground`,children:[y,` file`,y===1?``:`s`]}),` uploaded through the old Drive screen`]}),`. It cannot be undone, and it covers every user's uploads, not only your own. Files that a page still shows are left alone.`]}),onConfirm:v,onCancel:()=>s(!1),isProcessing:c,confirmText:`Yes, delete them`})]})}function T(){let[t,n]=(0,l.useState)(null),[i,a]=(0,l.useState)(!1),[o,s]=(0,l.useState)(``),c=(0,l.useRef)(null);return(0,l.useEffect)(()=>()=>c.current?.abort(),[]),(0,u.jsxs)(e.nt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`mt-6 glass-panel border border-[var(--panel-border)] rounded-2xl md:rounded-3xl p-4 md:p-6`,children:[(0,u.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,u.jsxs)(`div`,{className:`min-w-0`,children:[(0,u.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground tracking-tight`,children:`Make pictures load faster`}),(0,u.jsx)(`p`,{className:`max-sm:hidden text-[13px] text-foreground/55 leading-relaxed mt-1 max-w-2xl`,children:`Pictures you added a while ago are still sent at full size every time somebody looks at them. This gives them the same light versions and the same settings everything you add now gets. Your pictures are not changed and nothing is deleted.`})]}),i?(0,u.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,u.jsx)(`span`,{className:`text-[12.5px] font-semibold text-foreground/60 whitespace-nowrap`,children:t?`${t.done} of ${t.total}`:`Looking…`}),(0,u.jsx)(e.o,{icon:r.r,onClick:()=>c.current?.abort(),compact:!0,children:`Stop`})]}):(0,u.jsx)(e.o,{icon:m,onClick:async()=>{let e=new AbortController;c.current=e,a(!0),s(``),n(null);try{let t=await x({signal:e.signal,onProgress:n}),r=[t.companionsMade>0?`${t.companionsMade} light version${t.companionsMade===1?``:`s`} made`:``,t.headersFixed>0?`${t.headersFixed} picture${t.headersFixed===1?``:`s`} set to stay in the browser`:``].filter(Boolean);s(e.signal.aborted?`Stopped. Nothing was lost — start again whenever you like.`:r.length?`Done — ${r.join(`, `)}.`:`Everything is already fast.`)}catch{s(`That did not finish. Nothing was changed by the part that stopped — try again.`)}a(!1),n(null),c.current=null},compact:!0,children:`Make them fast`})]}),o&&!i&&(0,u.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/70 mt-3`,children:o})]})}function E(){let{isAdmin:t}=e.Ft();return(0,u.jsx)(n.t,{title:`Assets`,subtitle:`/assets`,filesCollection:`pub_files`,config:{isAdmin:!0,pageId:`assets`},footer:t?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(T,{}),(0,u.jsx)(w,{})]}):null,addition:(0,u.jsx)(c.n,{tab:`assets`})})}exports.Assets=E;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as e } from "./PageTitle-
|
|
1
|
+
import { t as e } from "./PageTitle-CkZriz8K.js";
|
|
2
2
|
import { Ft as t, Ot as n, Rn as r, h as i, nt as a, rt as o, u as s, w as c } from "./TimeZoneField-oIMwb5_X.js";
|
|
3
|
-
import { D as l, t as u } from "./DashboardNav-
|
|
3
|
+
import { D as l, t as u } from "./DashboardNav-CxS3Qnl-.js";
|
|
4
4
|
import { t as d } from "./chevron-down--LwXEv9w.js";
|
|
5
5
|
import { r as f } from "./x-hax8aKt8.js";
|
|
6
6
|
import { c as p, o as m, r as h } from "./transactions-ycKW6zHa.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./chunk-CiTBaPhY.cjs`);const e=require(`./PageTitle-DQkvCB11.cjs`),t=require(`./TimeZoneField-Ckn1pKAL.cjs`),n=require(`./DashboardNav-GgEUpyTa.cjs`),r=require(`./chevron-down-lyDK1rfL.cjs`),i=require(`./x-Ci8c5p6T.cjs`),a=require(`./transactions-CIU2NcKh.cjs`),o=require(`./ManagePlanButton-Buwfs2bU.cjs`),s=require(`./openOnArrival-FiXqw4WM.cjs`);let c=require(`react`),l=require(`react/jsx-runtime`),u=require(`react-router-dom`);function d(e){return e.status===`past_due`?{label:`Past due`,tone:`bad`}:e.active?{label:`Active`,tone:`good`}:{label:`Cancelled`,tone:`quiet`}}function f(e){return e.fullyRefunded?{label:`Refunded`,tone:`quiet`}:(e.amountRefunded||0)>0?{label:`Partly refunded`,tone:`good`}:e.paid?{label:`Paid`,tone:`good`}:{label:`Not paid`,tone:`quiet`}}function p(e){return!e.currentPeriodEnd||!e.active?``:e.cancelAtPeriodEnd?`Ends on ${y(e.currentPeriodEnd)}`:`Renews on ${y(e.currentPeriodEnd)}`}var m=e=>e.productName||e.description||`One-off payment`,h=e=>{if(/^and \d+ more$/i.test(e))return{words:e,price:``,quantity:0,more:!0};let t=e.lastIndexOf(` · `),n=t>0?e.slice(t+3).trim():``,r=/\d/.test(n),i=r?e.slice(0,t).trim():e,a=i.match(/^(\d+)\s*[×x]\s/);return{words:i,price:r?n:``,quantity:a?Number(a[1]):0,more:!1}};function g(e,t){let n=typeof e==`string`?e.trim():``;if(!n)return[];let r=a.c(n);return r&&typeof r==`object`?(Array.isArray(r)?r:[r]).filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)).map(e=>{let{words:n,price:r}=a.o(e,t),i=Number(e.quantity??e.qty);return{words:n,price:r,quantity:Number.isFinite(i)&&i>0?i:0,more:!1}}).filter(e=>e.words||e.price):n.split(`; `).map(e=>e.trim()).filter(Boolean).map(h)}function _(e){return!e.length||e.some(e=>e.more||!e.quantity)?null:e.reduce((e,t)=>e+t.quantity,0)}function v(e,t=g(e.items,e.currency)){let n=_(t),r=m(e),i=n&&n>1&&!/\bitems?\b/i.test(r)?`${n} items`:``;return[y(e.created),i].filter(Boolean).join(` · `)}var y=e=>e?new Date(e*1e3).toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`}):``,b=e=>e?new Date(e*1e3).toLocaleString(void 0,{day:`numeric`,month:`short`,year:`numeric`,hour:`numeric`,minute:`2-digit`}):``;function x(e){let t=[];return e.created&&t.push([e.paid?`Paid on`:`Date`,b(e.created)]),e.paidWith&&t.push([`Paid with`,e.paidWith]),(e.amountRefunded||0)>0&&t.push([`Refunded`,a.r(e.amountRefunded,e.currency)]),t}function S(e){let t=[];return e.amount!=null&&e.currency&&t.push([`Billing`,`${a.r(e.amount,e.currency)}${e.interval?` every ${e.interval}`:``}`]),p(e)&&t.push([e.cancelAtPeriodEnd?`Ends on`:`Renews on`,y(e.currentPeriodEnd)]),e.quantity>1&&t.push([`Seats`,String(e.quantity)]),e.status===`past_due`&&t.push([`Card`,`Stripe is retrying your card — update it under Manage plan.`]),t}var C=`grid grid-cols-[minmax(0,1fr)_auto_1rem] md:grid-cols-[minmax(0,1.5fr)_6.5rem_7rem_8.5rem_1rem] gap-x-3 md:gap-x-6 px-4 md:px-5`,w=`${C} items-center`;function T({chip:e,className:t=``}){let n=e.tone===`good`?`bg-emerald-500`:e.tone===`bad`?`bg-red-500`:`bg-foreground/25`;return(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-[12.5px] font-medium text-foreground/60 leading-tight whitespace-nowrap ${t}`,children:[(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`w-1.5 h-1.5 rounded-full shrink-0 ${n}`}),e.label]})}var E=`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-3`;function D({label:e,value:n}){return(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`span`,{className:`${t.u} block leading-tight mb-0.5`,children:e}),(0,l.jsx)(`span`,{className:`block text-[13.5px] text-foreground/85 leading-snug break-words [overflow-wrap:anywhere]`,children:n})]})}function O({title:e,line:t,children:n}){return(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap px-1`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`p`,{className:`text-[14px] font-bold text-foreground leading-tight`,children:e}),(0,l.jsx)(`p`,{className:`text-[12px] font-medium text-foreground/45 leading-snug mt-0.5`,children:t})]}),n]})}function k({first:e,second:t}){return(0,l.jsxs)(`div`,{className:`max-md:hidden ${w} py-2.5 text-[11.5px] font-medium text-foreground/40`,children:[(0,l.jsx)(`span`,{children:e}),(0,l.jsx)(`span`,{children:t}),(0,l.jsx)(`span`,{children:`Status`}),(0,l.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,l.jsx)(`span`,{})]})}function A({lines:e}){return(0,l.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,l.jsx)(`h3`,{className:`px-4 md:px-5 ${t.u} block leading-tight mb-0.5`,children:`What you bought`}),e.map((e,t)=>(0,l.jsxs)(`div`,{className:`${C} items-baseline`,children:[(0,l.jsx)(`span`,{className:`md:col-span-3 min-w-0 leading-snug break-words [overflow-wrap:anywhere] ${e.more?`text-[13px] text-foreground/45`:`text-[13.5px] text-foreground/85`}`,children:e.words}),(0,l.jsx)(`span`,{className:`text-right text-[13.5px] text-foreground/85 tabular-nums whitespace-nowrap leading-snug`,children:e.price})]},t))]})}function j({rowKey:e,what:n,sub:i,when:a,amount:o,per:s,chip:c,bought:u=[],facts:d,receiptUrl:f,open:p,onToggle:m}){return(0,l.jsxs)(`div`,{"data-ledger-row":e,className:`scroll-mt-6 ${p?`bg-foreground/[0.02]`:``}`,children:[(0,l.jsxs)(`button`,{type:`button`,onClick:m,"aria-expanded":p,className:`w-full ${w} py-3 text-left cursor-pointer transition-colors hover:bg-foreground/[0.03]`,children:[(0,l.jsxs)(`span`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,l.jsx)(`span`,{className:`text-[13.5px] font-bold text-foreground leading-tight truncate`,children:n}),(0,l.jsx)(`span`,{className:`md:hidden text-[12px] font-medium text-foreground/45 leading-tight truncate`,children:i})]}),(0,l.jsx)(`span`,{className:`max-md:hidden text-[12.5px] font-medium text-foreground/45 tabular-nums whitespace-nowrap truncate leading-tight`,children:a}),(0,l.jsx)(T,{chip:c,className:`max-md:hidden`}),(0,l.jsxs)(`span`,{className:`flex flex-col items-end gap-1 min-w-0`,children:[(0,l.jsxs)(`span`,{className:`text-[13.5px] font-semibold text-foreground tabular-nums whitespace-nowrap leading-tight`,children:[o||(0,l.jsx)(`span`,{className:`text-foreground/25 font-medium`,children:`—`}),o&&s&&(0,l.jsxs)(`span`,{className:`text-[12.5px] text-foreground/40 font-medium`,children:[` `,s]})]}),(0,l.jsx)(T,{chip:c,className:`md:hidden !text-[11.5px] !gap-1.5`})]}),(0,l.jsx)(r.t,{className:`w-4 h-4 text-foreground/35 shrink-0 justify-self-end transition-transform ${p?`rotate-180`:``}`})]}),(0,l.jsx)(t.rt,{initial:!1,children:p&&(0,l.jsx)(t.nt.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:t.w,className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`pb-4 md:pb-5 flex flex-col gap-4`,children:[(0,l.jsx)(`div`,{className:`mx-4 md:mx-5 border-t border-[var(--panel-border)]/50`}),u.length>0&&(0,l.jsx)(A,{lines:u}),d.length>0&&(0,l.jsx)(`div`,{className:`px-4 md:px-5 ${E}`,children:d.map(([e,t])=>(0,l.jsx)(D,{label:e,value:t},e))}),f&&(0,l.jsx)(`div`,{className:`mx-4 md:mx-5 border-t border-[var(--panel-border)]/50 pt-3`,children:(0,l.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 text-[12.5px] font-bold text-accent hover:underline`,children:[`Stripe receipt`,(0,l.jsx)(t.Ot,{className:`w-3.5 h-3.5`})]})})]})})})]})}function M({email:r,loading:u,subscriptions:h,payments:_,error:b,initialOpen:C=null,focus:w=null,onFocused:T}){let[E,D]=(0,c.useState)(C),A=e=>D(t=>t===e?null:e),M=!u&&!b&&h.length===0&&_.length===0;return s.t(w,!u&&!!w&&(_.some(e=>e.id===w)||h.some(e=>e.id===w)),D,T),(0,l.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,l.jsxs)(t.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6`,children:[(0,l.jsx)(e.t,{children:`Billing`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/billing`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(n.t,{}),(0,l.jsx)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-3xl p-4 sm:p-5 md:p-8 shadow-2xl relative bg-background flex flex-col fbos-tab-fill min-h-[400px] gap-6`,children:u?(0,l.jsx)(`div`,{className:`flex items-center justify-center flex-1 text-foreground/40 py-16`,children:(0,l.jsx)(i.r,{className:`w-6 h-6 animate-spin text-accent`})}):b?(0,l.jsx)(t.h,{tone:`error`,children:b}):M?(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1 gap-3 py-16 text-center`,children:[(0,l.jsx)(n.D,{className:`w-8 h-8 text-foreground/20`}),(0,l.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 max-w-md leading-relaxed`,children:[`Nothing has been bought on this account`,r?(0,l.jsxs)(l.Fragment,{children:[` — `,(0,l.jsx)(`span`,{className:`text-foreground/70`,children:r})]}):null,`. A payment made with a different email address at checkout lives with that email: sign in with the address you paid with to see it here.`]})]}):(0,l.jsxs)(l.Fragment,{children:[h.length>0&&(0,l.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,l.jsx)(O,{title:h.length===1?`Your plan`:`Your plans`,line:`Change card, switch or cancel on Stripe's own page.`,children:(0,l.jsx)(o.t,{variant:`secondary`,className:`h-9 px-3.5 text-[12.5px] font-semibold`})}),(0,l.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)]/60 divide-y divide-[var(--panel-border)]/60 overflow-hidden`,children:[(0,l.jsx)(k,{first:`Plan`,second:`Renews`}),h.map(e=>{let t=d(e),n=p(e),r=e.amount!=null&&e.currency?a.r(e.amount,e.currency):``;return(0,l.jsx)(j,{rowKey:e.id,what:e.productName||`Subscription`,sub:n||t.label,when:n?y(e.currentPeriodEnd):`—`,amount:r,per:e.interval?`/ ${e.interval}`:``,chip:t,facts:S(e),open:E===e.id,onToggle:()=>A(e.id)},e.id)})]})]}),_.length>0&&(0,l.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,l.jsx)(O,{title:`Your payments`,line:`Every payment on this account, straight from Stripe.`}),(0,l.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)]/60 divide-y divide-[var(--panel-border)]/60 overflow-hidden`,children:[(0,l.jsx)(k,{first:`What`,second:`When`}),_.map(e=>{let t=g(e.items,e.currency);return(0,l.jsx)(j,{rowKey:e.id,what:m(e),sub:v(e,t),when:y(e.created),amount:a.r(e.amount,e.currency),chip:f(e),bought:t,facts:x(e),receiptUrl:e.receiptUrl,open:E===e.id,onToggle:()=>A(e.id)},e.id)})]})]})]})})]})]})}function N(){let{user:e}=t.Ft(),{loading:n,subscriptions:r,payments:i,error:a}=t.Rn(),[o,s]=(0,u.useSearchParams)();return(0,l.jsx)(M,{email:e?.email||null,loading:n,subscriptions:r,payments:i,error:a,focus:o.get(`open`),onFocused:()=>s(e=>{let t=new URLSearchParams(e);return t.delete(`open`),t},{replace:!0})})}exports.Billing=N;
|
|
1
|
+
require(`./chunk-CiTBaPhY.cjs`);const e=require(`./PageTitle-BL50s4qY.cjs`),t=require(`./TimeZoneField-Ckn1pKAL.cjs`),n=require(`./DashboardNav-Bc619nqn.cjs`),r=require(`./chevron-down-lyDK1rfL.cjs`),i=require(`./x-Ci8c5p6T.cjs`),a=require(`./transactions-CIU2NcKh.cjs`),o=require(`./ManagePlanButton-Buwfs2bU.cjs`),s=require(`./openOnArrival-FiXqw4WM.cjs`);let c=require(`react`),l=require(`react/jsx-runtime`),u=require(`react-router-dom`);function d(e){return e.status===`past_due`?{label:`Past due`,tone:`bad`}:e.active?{label:`Active`,tone:`good`}:{label:`Cancelled`,tone:`quiet`}}function f(e){return e.fullyRefunded?{label:`Refunded`,tone:`quiet`}:(e.amountRefunded||0)>0?{label:`Partly refunded`,tone:`good`}:e.paid?{label:`Paid`,tone:`good`}:{label:`Not paid`,tone:`quiet`}}function p(e){return!e.currentPeriodEnd||!e.active?``:e.cancelAtPeriodEnd?`Ends on ${y(e.currentPeriodEnd)}`:`Renews on ${y(e.currentPeriodEnd)}`}var m=e=>e.productName||e.description||`One-off payment`,h=e=>{if(/^and \d+ more$/i.test(e))return{words:e,price:``,quantity:0,more:!0};let t=e.lastIndexOf(` · `),n=t>0?e.slice(t+3).trim():``,r=/\d/.test(n),i=r?e.slice(0,t).trim():e,a=i.match(/^(\d+)\s*[×x]\s/);return{words:i,price:r?n:``,quantity:a?Number(a[1]):0,more:!1}};function g(e,t){let n=typeof e==`string`?e.trim():``;if(!n)return[];let r=a.c(n);return r&&typeof r==`object`?(Array.isArray(r)?r:[r]).filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)).map(e=>{let{words:n,price:r}=a.o(e,t),i=Number(e.quantity??e.qty);return{words:n,price:r,quantity:Number.isFinite(i)&&i>0?i:0,more:!1}}).filter(e=>e.words||e.price):n.split(`; `).map(e=>e.trim()).filter(Boolean).map(h)}function _(e){return!e.length||e.some(e=>e.more||!e.quantity)?null:e.reduce((e,t)=>e+t.quantity,0)}function v(e,t=g(e.items,e.currency)){let n=_(t),r=m(e),i=n&&n>1&&!/\bitems?\b/i.test(r)?`${n} items`:``;return[y(e.created),i].filter(Boolean).join(` · `)}var y=e=>e?new Date(e*1e3).toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`}):``,b=e=>e?new Date(e*1e3).toLocaleString(void 0,{day:`numeric`,month:`short`,year:`numeric`,hour:`numeric`,minute:`2-digit`}):``;function x(e){let t=[];return e.created&&t.push([e.paid?`Paid on`:`Date`,b(e.created)]),e.paidWith&&t.push([`Paid with`,e.paidWith]),(e.amountRefunded||0)>0&&t.push([`Refunded`,a.r(e.amountRefunded,e.currency)]),t}function S(e){let t=[];return e.amount!=null&&e.currency&&t.push([`Billing`,`${a.r(e.amount,e.currency)}${e.interval?` every ${e.interval}`:``}`]),p(e)&&t.push([e.cancelAtPeriodEnd?`Ends on`:`Renews on`,y(e.currentPeriodEnd)]),e.quantity>1&&t.push([`Seats`,String(e.quantity)]),e.status===`past_due`&&t.push([`Card`,`Stripe is retrying your card — update it under Manage plan.`]),t}var C=`grid grid-cols-[minmax(0,1fr)_auto_1rem] md:grid-cols-[minmax(0,1.5fr)_6.5rem_7rem_8.5rem_1rem] gap-x-3 md:gap-x-6 px-4 md:px-5`,w=`${C} items-center`;function T({chip:e,className:t=``}){let n=e.tone===`good`?`bg-emerald-500`:e.tone===`bad`?`bg-red-500`:`bg-foreground/25`;return(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-[12.5px] font-medium text-foreground/60 leading-tight whitespace-nowrap ${t}`,children:[(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`w-1.5 h-1.5 rounded-full shrink-0 ${n}`}),e.label]})}var E=`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-3`;function D({label:e,value:n}){return(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`span`,{className:`${t.u} block leading-tight mb-0.5`,children:e}),(0,l.jsx)(`span`,{className:`block text-[13.5px] text-foreground/85 leading-snug break-words [overflow-wrap:anywhere]`,children:n})]})}function O({title:e,line:t,children:n}){return(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap px-1`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`p`,{className:`text-[14px] font-bold text-foreground leading-tight`,children:e}),(0,l.jsx)(`p`,{className:`text-[12px] font-medium text-foreground/45 leading-snug mt-0.5`,children:t})]}),n]})}function k({first:e,second:t}){return(0,l.jsxs)(`div`,{className:`max-md:hidden ${w} py-2.5 text-[11.5px] font-medium text-foreground/40`,children:[(0,l.jsx)(`span`,{children:e}),(0,l.jsx)(`span`,{children:t}),(0,l.jsx)(`span`,{children:`Status`}),(0,l.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,l.jsx)(`span`,{})]})}function A({lines:e}){return(0,l.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,l.jsx)(`h3`,{className:`px-4 md:px-5 ${t.u} block leading-tight mb-0.5`,children:`What you bought`}),e.map((e,t)=>(0,l.jsxs)(`div`,{className:`${C} items-baseline`,children:[(0,l.jsx)(`span`,{className:`md:col-span-3 min-w-0 leading-snug break-words [overflow-wrap:anywhere] ${e.more?`text-[13px] text-foreground/45`:`text-[13.5px] text-foreground/85`}`,children:e.words}),(0,l.jsx)(`span`,{className:`text-right text-[13.5px] text-foreground/85 tabular-nums whitespace-nowrap leading-snug`,children:e.price})]},t))]})}function j({rowKey:e,what:n,sub:i,when:a,amount:o,per:s,chip:c,bought:u=[],facts:d,receiptUrl:f,open:p,onToggle:m}){return(0,l.jsxs)(`div`,{"data-ledger-row":e,className:`scroll-mt-6 ${p?`bg-foreground/[0.02]`:``}`,children:[(0,l.jsxs)(`button`,{type:`button`,onClick:m,"aria-expanded":p,className:`w-full ${w} py-3 text-left cursor-pointer transition-colors hover:bg-foreground/[0.03]`,children:[(0,l.jsxs)(`span`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,l.jsx)(`span`,{className:`text-[13.5px] font-bold text-foreground leading-tight truncate`,children:n}),(0,l.jsx)(`span`,{className:`md:hidden text-[12px] font-medium text-foreground/45 leading-tight truncate`,children:i})]}),(0,l.jsx)(`span`,{className:`max-md:hidden text-[12.5px] font-medium text-foreground/45 tabular-nums whitespace-nowrap truncate leading-tight`,children:a}),(0,l.jsx)(T,{chip:c,className:`max-md:hidden`}),(0,l.jsxs)(`span`,{className:`flex flex-col items-end gap-1 min-w-0`,children:[(0,l.jsxs)(`span`,{className:`text-[13.5px] font-semibold text-foreground tabular-nums whitespace-nowrap leading-tight`,children:[o||(0,l.jsx)(`span`,{className:`text-foreground/25 font-medium`,children:`—`}),o&&s&&(0,l.jsxs)(`span`,{className:`text-[12.5px] text-foreground/40 font-medium`,children:[` `,s]})]}),(0,l.jsx)(T,{chip:c,className:`md:hidden !text-[11.5px] !gap-1.5`})]}),(0,l.jsx)(r.t,{className:`w-4 h-4 text-foreground/35 shrink-0 justify-self-end transition-transform ${p?`rotate-180`:``}`})]}),(0,l.jsx)(t.rt,{initial:!1,children:p&&(0,l.jsx)(t.nt.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:t.w,className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`pb-4 md:pb-5 flex flex-col gap-4`,children:[(0,l.jsx)(`div`,{className:`mx-4 md:mx-5 border-t border-[var(--panel-border)]/50`}),u.length>0&&(0,l.jsx)(A,{lines:u}),d.length>0&&(0,l.jsx)(`div`,{className:`px-4 md:px-5 ${E}`,children:d.map(([e,t])=>(0,l.jsx)(D,{label:e,value:t},e))}),f&&(0,l.jsx)(`div`,{className:`mx-4 md:mx-5 border-t border-[var(--panel-border)]/50 pt-3`,children:(0,l.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 text-[12.5px] font-bold text-accent hover:underline`,children:[`Stripe receipt`,(0,l.jsx)(t.Ot,{className:`w-3.5 h-3.5`})]})})]})})})]})}function M({email:r,loading:u,subscriptions:h,payments:_,error:b,initialOpen:C=null,focus:w=null,onFocused:T}){let[E,D]=(0,c.useState)(C),A=e=>D(t=>t===e?null:e),M=!u&&!b&&h.length===0&&_.length===0;return s.t(w,!u&&!!w&&(_.some(e=>e.id===w)||h.some(e=>e.id===w)),D,T),(0,l.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,l.jsxs)(t.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6`,children:[(0,l.jsx)(e.t,{children:`Billing`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/billing`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(n.t,{}),(0,l.jsx)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-3xl p-4 sm:p-5 md:p-8 shadow-2xl relative bg-background flex flex-col fbos-tab-fill min-h-[400px] gap-6`,children:u?(0,l.jsx)(`div`,{className:`flex items-center justify-center flex-1 text-foreground/40 py-16`,children:(0,l.jsx)(i.r,{className:`w-6 h-6 animate-spin text-accent`})}):b?(0,l.jsx)(t.h,{tone:`error`,children:b}):M?(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1 gap-3 py-16 text-center`,children:[(0,l.jsx)(n.D,{className:`w-8 h-8 text-foreground/20`}),(0,l.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 max-w-md leading-relaxed`,children:[`Nothing has been bought on this account`,r?(0,l.jsxs)(l.Fragment,{children:[` — `,(0,l.jsx)(`span`,{className:`text-foreground/70`,children:r})]}):null,`. A payment made with a different email address at checkout lives with that email: sign in with the address you paid with to see it here.`]})]}):(0,l.jsxs)(l.Fragment,{children:[h.length>0&&(0,l.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,l.jsx)(O,{title:h.length===1?`Your plan`:`Your plans`,line:`Change card, switch or cancel on Stripe's own page.`,children:(0,l.jsx)(o.t,{variant:`secondary`,className:`h-9 px-3.5 text-[12.5px] font-semibold`})}),(0,l.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)]/60 divide-y divide-[var(--panel-border)]/60 overflow-hidden`,children:[(0,l.jsx)(k,{first:`Plan`,second:`Renews`}),h.map(e=>{let t=d(e),n=p(e),r=e.amount!=null&&e.currency?a.r(e.amount,e.currency):``;return(0,l.jsx)(j,{rowKey:e.id,what:e.productName||`Subscription`,sub:n||t.label,when:n?y(e.currentPeriodEnd):`—`,amount:r,per:e.interval?`/ ${e.interval}`:``,chip:t,facts:S(e),open:E===e.id,onToggle:()=>A(e.id)},e.id)})]})]}),_.length>0&&(0,l.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,l.jsx)(O,{title:`Your payments`,line:`Every payment on this account, straight from Stripe.`}),(0,l.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)]/60 divide-y divide-[var(--panel-border)]/60 overflow-hidden`,children:[(0,l.jsx)(k,{first:`What`,second:`When`}),_.map(e=>{let t=g(e.items,e.currency);return(0,l.jsx)(j,{rowKey:e.id,what:m(e),sub:v(e,t),when:y(e.created),amount:a.r(e.amount,e.currency),chip:f(e),bought:t,facts:x(e),receiptUrl:e.receiptUrl,open:E===e.id,onToggle:()=>A(e.id)},e.id)})]})]})]})})]})]})}function N(){let{user:e}=t.Ft(),{loading:n,subscriptions:r,payments:i,error:a}=t.Rn(),[o,s]=(0,u.useSearchParams)();return(0,l.jsx)(M,{email:e?.email||null,loading:n,subscriptions:r,payments:i,error:a,focus:o.get(`open`),onFocused:()=>s(e=>{let t=new URLSearchParams(e);return t.delete(`open`),t},{replace:!0})})}exports.Billing=N;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./chunk-CiTBaPhY.cjs`);const e=require(`./PageTitle-
|
|
1
|
+
require(`./chunk-CiTBaPhY.cjs`);const e=require(`./PageTitle-BL50s4qY.cjs`),t=require(`./TimeZoneField-Ckn1pKAL.cjs`),n=require(`./schedule-BAea6q8_.cjs`);let r=require(`react`),i=require(`react/jsx-runtime`);function a({title:a,path:o,hint:s}){let[c,l]=(0,r.useState)(!1),u=n.C(o);return(0,i.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)]`,children:[(0,i.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col`,children:[(0,i.jsx)(`span`,{className:`text-[13px] font-semibold text-foreground/80 truncate`,children:a}),(0,i.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/45 truncate`,children:s||u})]}),(0,i.jsx)(t.C,{to:o,title:`View ${a}`,children:`View page`}),(0,i.jsx)(t.o,{icon:c?t.At:e._,compact:!0,title:`Copy the link to ${a}`,onClick:()=>{try{navigator.clipboard?.writeText(u)?.catch(()=>{})}catch{}l(!0),setTimeout(()=>l(!1),1500)},children:c?`Copied`:`Copy link`})]})}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./chunk-CiTBaPhY.cjs`),t=require(`./PageTitle-DQkvCB11.cjs`),n=require(`./TimeZoneField-Ckn1pKAL.cjs`),r=require(`./schedule-BAea6q8_.cjs`),i=require(`./chevron-down-lyDK1rfL.cjs`),a=require(`./scheduleData-BXjNXVHY.cjs`),o=require(`./tabAudience-2fJAN1aD.cjs`);let s=require(`react`);s=e.a(s,1);let c=require(`react/jsx-runtime`),l=require(`firebase/firestore`),u=require(`react-router-dom`);var d=typeof window<`u`?s.useLayoutEffect:s.useEffect,f=(0,s.createContext)(void 0),p=`'Inter', system-ui, sans-serif`,m=e=>e.trim().replace(/\s+/g,`+`);function h(e,t){let n=[[`--display-family`,String(t?.display||``).trim()],[`--body-family`,String(t?.body||``).trim()]];for(let[t,r]of n){if(!r){e.style.removeProperty(t);continue}let n=`theme-font-${m(r).toLowerCase().replace(/[^a-z0-9+]/g,``)}`;if(typeof document<`u`&&!document.getElementById(n)){let e=document.createElement(`link`);e.id=n,e.rel=`stylesheet`,e.href=`https://fonts.googleapis.com/css2?family=${m(r)}:wght@300;400;500;600;700;800&display=swap`,document.head.appendChild(e)}e.style.setProperty(t,`'${r.replace(/'/g,``)}', ${p}`)}}var g=e=>{let t=e?.defaultTheme;return t!==`light`&&t!==`dark`||e?.showThemeToggle?null:t},_={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}},drop(e){try{localStorage.removeItem(e)}catch{}}};function v({children:e,scopeSelector:r}){let i=n.mi(),a=(0,s.useMemo)(()=>i?.themeConfig||t.b,[i?.themeConfig]),o=g(a),l=!!a.showThemeToggle;(0,s.useEffect)(()=>{try{localStorage.removeItem(`theme_config_cache`),localStorage.removeItem(`theme_saved_cache`)}catch{}console.info(`Your AI Firebase ${t.y} · colours from theme.config.ts`)},[]);let[u,p]=(0,s.useState)(()=>{if(o)return o;if(typeof window>`u`)return a.defaultTheme||`system`;let e=_.get(`theme-mode`),t=_.get(`last-seen-default-theme`);return a.defaultTheme&&a.defaultTheme!==t?(_.set(`last-seen-default-theme`,a.defaultTheme),_.drop(`theme-mode`),a.defaultTheme):e||a.defaultTheme||`system`}),[m,v]=(0,s.useState)(()=>{if(o)return o;if(typeof window>`u`)return a.defaultTheme===`light`?`light`:`dark`;let e=_.get(`theme-mode`),t=_.get(`last-seen-default-theme`),n=e||a.defaultTheme||`system`;return a.defaultTheme&&a.defaultTheme!==t&&(n=a.defaultTheme),n===`system`?window.matchMedia(`(prefers-color-scheme: light)`).matches?`light`:`dark`:n});return(0,s.useEffect)(()=>{let e=a.defaultTheme;e&&(o&&p(o),e!==_.get(`last-seen-default-theme`)&&(_.set(`last-seen-default-theme`,e),_.drop(`theme-mode`),p(e)))},[a.defaultTheme,o]),(0,s.useEffect)(()=>{let e=e=>{u===`system`&&v(e.matches?`light`:`dark`)},t=window.matchMedia(`(prefers-color-scheme: light)`);return u===`system`?(v(t.matches?`light`:`dark`),t.addEventListener(`change`,e)):v(u),()=>t.removeEventListener(`change`,e)},[u]),d(()=>{let e=(r?document.querySelector(r):document.documentElement)||document.documentElement,t=m===`dark`?a.colors.dark:a.colors.light;e.style.setProperty(`--bg-color`,t.background),e.style.setProperty(`--bg-secondary-color`,t.backgroundSecondary||t.background),e.style.setProperty(`--fg-color`,t.foreground),e.style.setProperty(`--accent-color`,t.accent);let n=m===`dark`;e.style.setProperty(`--panel-bg`,t.panelBg||`color-mix(in srgb, ${t.accent} ${n?`5%`:`4%`}, transparent)`),e.style.setProperty(`--panel-border`,t.panelBorder||`color-mix(in srgb, ${t.accent} 15%, transparent)`);let i=(e,t,n)=>{if(!e||e.length===0)return t||`transparent`;if(e.length===1)return e[0];let r=e.map((t,n)=>`${t} ${Math.round(n/(e.length-1)*100)}%`).join(`, `);return n===`conic`?`conic-gradient(from 180deg at 50% 100%, ${r})`:`linear-gradient(135deg, ${r})`},o=`linear-gradient(135deg, color-mix(in oklab, ${t.accent} ${n?`70%`:`78%`}, black) 0%, ${t.accent} 100%)`,s=`linear-gradient(135deg, color-mix(in oklab, ${t.accent} ${n?`80%`:`85%`}, black) 0%, color-mix(in oklab, ${t.accent} 72%, white) 100%)`;e.style.setProperty(`--button-bg`,i(t.buttonGradient,o,t.buttonGradientShape)),e.style.setProperty(`--button-fg`,t.buttonText||`#ffffff`),e.style.setProperty(`--button-hover-bg`,i(t.buttonHoverGradient||t.buttonGradient,s,t.buttonGradientShape)),e.style.setProperty(`--text-gradient`,i(t.textGradient,`linear-gradient(135deg, ${t.foreground} 0%, ${t.accent} 100%)`)),e.style.setProperty(`--glow-color`,t.glowColor||`color-mix(in srgb, ${t.accent} ${n?`40%`:`30%`}, transparent)`),e.style.setProperty(`--notification-icon-color`,t.notificationIconColor||t.accent);let c=t.secondaryButton?.bg||(m===`dark`?`rgba(255, 255, 255, 0.05)`:`rgba(0, 0, 0, 0.03)`),l=t.secondaryButton?.border||(m===`dark`?`rgba(255, 255, 255, 0.1)`:`rgba(0, 0, 0, 0.06)`),d=t.secondaryButton?.text||t.foreground;if(e.style.setProperty(`--btn-sec-bg`,c),e.style.setProperty(`--btn-sec-border`,l),e.style.setProperty(`--btn-sec-text`,d),e.style.setProperty(`--selection-bg`,t.selectionBg||`color-mix(in srgb, var(--accent-color) 40%, transparent)`),e.style.setProperty(`--selection-text`,t.selectionText||`#ffffff`),e.setAttribute(`data-theme`,m),_.set(`theme-mode`,u),a.cornerRounding===`custom`&&a.cornerRadii?(e.style.setProperty(`--btn-radius`,`${parseFloat(String(a.cornerRadii.buttonRadius))||0}rem`),e.style.setProperty(`--card-radius`,`${parseFloat(String(a.cornerRadii.cardRadius))||0}rem`),e.style.setProperty(`--input-radius`,`${parseFloat(String(a.cornerRadii.inputRadius))||0}rem`),e.style.setProperty(`--modal-radius`,`${parseFloat(String(a.cornerRadii.modalRadius))||0}rem`)):(e.style.setProperty(`--btn-radius`,`0.75rem`),e.style.setProperty(`--card-radius`,`1.5rem`),e.style.setProperty(`--input-radius`,`0.75rem`),e.style.setProperty(`--modal-radius`,`1.5rem`)),!document.getElementById(`inter-font`)){let e=document.createElement(`link`);e.id=`inter-font`,e.rel=`stylesheet`,e.href=`https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap`,document.head.appendChild(e)}h(e,a.fonts),e.style.fontSize=`16px`,e.style.setProperty(`--weight-h1`,`800`),e.style.setProperty(`--weight-h2`,`700`),e.style.setProperty(`--weight-h3`,`700`),e.style.setProperty(`--leading-normal`,`1.5`);let f=document.querySelector(`link[rel*='icon']`);f||(f=document.createElement(`link`),f.rel=`icon`,document.head.appendChild(f)),a.faviconUrl&&(f.href=a.faviconUrl),a.appName&&(document.title=a.appName)},[m,u,a]),(0,c.jsx)(f.Provider,{value:{theme:m,setTheme:e=>{o||p(e)},toggleTheme:()=>{o||p(m===`light`?`dark`:`light`)},isSystem:u===`system`,setIsSystem:e=>{o||p(e?`system`:m)},config:a,activeConfig:a,canSwitchTheme:l},children:e})}var y=()=>{let e=(0,s.useContext)(f);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e},b={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};b.node;var x=i.n(b),S={name:`ellipsis-vertical`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]],aliases:[`more-vertical`]};S.node;var ee=i.n(S),C={name:`fingerprint-pattern`,size:24,node:[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]],aliases:[`fingerprint`]};C.node;var w=i.n(C),T={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};T.node;var te=i.n(T),ne={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};ne.node;var E=i.n(ne),D={name:`nfc`,size:24,node:[[`path`,{d:`M6 8.32a7.43 7.43 0 0 1 0 7.36`,key:`9iaqei`}],[`path`,{d:`M9.46 6.21a11.76 11.76 0 0 1 0 11.58`,key:`1yha7l`}],[`path`,{d:`M12.91 4.1a15.91 15.91 0 0 1 .01 15.8`,key:`4iu2gk`}],[`path`,{d:`M16.37 2a20.16 20.16 0 0 1 0 20`,key:`sap9u2`}]]};D.node;var O=i.n(D),k={name:`palette`,size:24,node:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]};k.node;var A=i.n(k),j={name:`rectangle-ellipsis`,size:24,node:[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M17 12h.01`,key:`1m0b6t`}],[`path`,{d:`M7 12h.01`,key:`eqddd0`}]],aliases:[`form-input`]};j.node;var M=i.n(j),N={name:`rocket`,size:24,node:[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]};N.node;var re=i.n(N),P={name:`rotate-cw-fading-clock`,size:24,node:[[`path`,{d:`M12 3a9.75 9.75 0 0 1 6.74 2.74`,key:`1k3kxf`}],[`path`,{d:`M18.74 5.74 21 8`,key:`1eb40o`}],[`path`,{d:`M21 8V3`,key:`1et280`}],[`path`,{d:`M7.5 19.794c-6-3.464-6-12.124 0-15.588`,key:`19r0lp`}],[`path`,{d:`M7.5 4.206A9 9 0 0 1 12 3`,key:`s8r11`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}],[`path`,{d:`M14 20.775A9 9 0 0 1 12 21`,key:`184rgu`}],[`path`,{d:`M19 17.656a9 9 0 0 1-1.5 1.456`,key:`7qgp6l`}],[`path`,{d:`M21 12a9 9 0 0 1-.228 2`,key:`1h378y`}],[`path`,{d:`M21 8h-5`,key:`k0yzmk`}]]};P.node;var ie=i.n(P),ae={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};ae.node;var oe=i.n(ae);function se(){return(typeof window<`u`?window.__FBOS_PAGES__:null)||{}}function ce(e=se()){let t=new Set,n=[];for(let[r,i]of Object.entries(e))!i||t.has(i)||(t.add(i),n.push([r,i]));return n}var F=e=>e?.inMenu===!1,le=(e,t,n)=>{let r=e.find(e=>e.id===t);return r?r.hidden===!0:F(n)},I=`sys_groups`,ue=`fbos_groups`,de=(e,t)=>({id:e,name:String(t?.name||e),roles:r._n(t?.roles),...typeof t?.createdAt==`number`?{createdAt:t.createdAt}:{}}),fe=(e,t)=>e.name.localeCompare(t.name),pe=()=>{try{let e=localStorage.getItem(ue),t=e?JSON.parse(e):null;return Array.isArray(t)?t.filter(e=>r.On(e?.id)).map(e=>de(e.id,e)):null}catch{return null}},L=null,R=null,z=null,B=e=>{L=e,R?.forEach(t=>t(e))};function me(e){let t=!R;return R||=new Set,R.add(e),t?z=(0,l.onSnapshot)((0,l.collection)(n.ui,I),e=>{let t=[];e.forEach(e=>{r.On(e.id)&&t.push(de(e.id,e.data()))}),t.sort(fe);try{localStorage.setItem(ue,JSON.stringify(t))}catch{}B({groups:t,live:!0})},()=>B({groups:L?.groups??pe()??[],live:!0})):L?.live&&e(L),()=>{R?.delete(e),!R?.size&&(z?.(),z=null,R=null)}}function V(){let[e,t]=(0,s.useState)(()=>{if(L)return L;let e=pe();return e?{groups:e,live:!1}:null});return(0,s.useEffect)(()=>me(t),[]),{groups:e?.groups??[],loaded:!!e,live:!!e?.live}}function he(e,t,n=``){let i=String(e||``).trim();if(!i)return`Type a name for the group first — Sales, say, or North branch.`;if(!r.On(r.Ln(i)))return`Use a name with at least two letters in it.`;let a=t.find(e=>e.id!==n&&(e.name.trim().toLowerCase()===i.toLowerCase()||!n&&e.id===r.Ln(i)));return a?`You already have a group called ${a.name}.`:``}async function ge(e){let t=String(e||``).trim().slice(0,48),i={id:r.Ln(t),name:t,roles:[],createdAt:Date.now()};return await(0,l.setDoc)((0,l.doc)(n.ui,I,i.id),{name:i.name,roles:[],createdAt:i.createdAt}),i}async function _e(e,t){let i=String(t||``).trim().slice(0,48);!i||!r.On(e)||await(0,l.setDoc)((0,l.doc)(n.ui,I,e),{name:i},{merge:!0})}async function ve(e,t){if(!r.On(e))return;let i=r._n(t),a=L;L&&B({...L,groups:L.groups.map(t=>t.id===e?{...t,roles:i}:t)});try{await(0,l.setDoc)((0,l.doc)(n.ui,I,e),{roles:i},{merge:!0})}catch(e){throw a&&B(a),e}}async function ye(e){let t=[];return r.On(e)&&(await(0,l.getDocs)((0,l.collection)(n.ui,`sys_tabs`))).forEach(n=>{r.Nn(n.data())===e&&t.push(n.id)}),t}async function be(e){if(r.On(e)){for(let t of await ye(e))await(0,l.setDoc)((0,l.doc)(n.ui,`sys_tabs`,t),{group:``},{merge:!0});await(0,l.deleteDoc)((0,l.doc)(n.ui,I,e))}}async function xe(e){let t=await(0,l.getDocs)((0,l.collection)(n.ui,I));for(let i of t.docs){let t=r._n(i.data()?.roles);t.includes(e)&&await(0,l.setDoc)((0,l.doc)(n.ui,I,i.id),{roles:t.filter(t=>t!==e)},{merge:!0})}}var H={collection:`sys_configs`,doc:`tab_icons`},Se=`fbos_tab_icons`,Ce=e=>{let t={};if(e&&typeof e==`object`)for(let[n,r]of Object.entries(e)){let e=typeof r==`string`?r.trim():``;e&&(t[n]=e)}return t},U=()=>{try{let e=localStorage.getItem(Se);return e?Ce(JSON.parse(e)):null}catch{return null}},W=null,G=null,we=null,K=e=>{W=e,G?.forEach(t=>t(e))};function Te(e){let t=!G;return G||=new Set,G.add(e),t?we=(0,l.onSnapshot)((0,l.doc)(n.ui,H.collection,H.doc),e=>{let t=Ce(e.exists()?e.data():{});try{localStorage.setItem(Se,JSON.stringify(t))}catch{}K(t)},()=>K(W??U()??{})):W&&e(W),()=>{G?.delete(e),!G?.size&&(we?.(),we=null,G=null)}}function Ee(){let[e,t]=(0,s.useState)(()=>W??U()??{});return(0,s.useEffect)(()=>Te(t),[]),e}async function De(e,t){let r=String(t||``).trim(),i=W,a={...W??U()??{}};r?a[e]=r:delete a[e],K(a);try{await(0,l.setDoc)((0,l.doc)(n.ui,H.collection,H.doc),{[e]:r},{merge:!0})}catch(e){throw i&&K(i),e}}var Oe={drive:`assets`,submissions:`inbox`,requests:`inbox`},ke=new Set([`setup`]),Ae=e=>{let t=(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden}).map(e=>({...e,id:Oe[e.id]||e.id})).filter(e=>!ke.has(e.id));return t.filter((e,n)=>t.findIndex(t=>t.id===e.id)===n)},je=[{id:`inbox`,hidden:!1},{id:`users`,hidden:!1},{id:`signin`,hidden:!1},{id:`pages`,hidden:!1},{id:`mybookings`,hidden:!1},{id:`billing`,hidden:!1},{id:`payments`,hidden:!1},{id:`transactions`,hidden:!1},{id:`email`,hidden:!1},{id:`schedule`,hidden:!1},{id:`forms`,hidden:!1},{id:`theme`,hidden:!1},{id:`assets`,hidden:!1},{id:`publish`,hidden:!1}],Me=/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i,q=e=>{let t=String(e??``).trim();return Me.test(t)?t:``};function Ne(e,t){let n=String(e??``).trim();if(!n||/^data:/i.test(n))return``;try{let e=new URL(n,t||void 0);return/^https?:$/.test(e.protocol)?e.href:``}catch{return``}}function Pe(e,t){let n=e?.colors?.light||{},r=Array.isArray(n.buttonGradient)?n.buttonGradient.map(q).filter(Boolean).slice(0,2):[];return{appName:String(e?.appName||``).replace(/\s+/g,` `).trim().slice(0,60),logoUrl:Ne(e?.logoUrl,t),appUrl:Ne(t,``),accent:q(n.accent),foreground:q(n.foreground),buttonText:q(n.buttonText),buttonGradient:r,panelBg:q(n.panelBg),panelBorder:q(n.panelBorder)}}function Fe(e){return{appName:String(e?.appName||``),logoUrl:String(e?.logoUrl||``),appUrl:String(e?.appUrl||``),accent:String(e?.accent||``),foreground:String(e?.foreground||``),buttonText:String(e?.buttonText||``),buttonGradient:Array.isArray(e?.buttonGradient)?e.buttonGradient.map(String):[],panelBg:String(e?.panelBg||``),panelBorder:String(e?.panelBorder||``)}}var Ie=``,Le=e=>/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/i.test(e);function Re(){let e=null;try{e=y().activeConfig}catch{e=null}let t=!!n.Ft()?.isAdmin,r=typeof window<`u`?window.location.origin:``,i=e&&t?JSON.stringify(Pe(e,r)):``;(0,s.useEffect)(()=>{if(!i||!n.ui||i===Ie)return;let e=!1;return(async()=>{try{let t=(0,l.doc)(n.ui,`sys_configs`,`emailBrand`),a=await(0,l.getDoc)(t);if(e)return;let o=a.exists()?Fe(a.data()):null,s=JSON.parse(i);Le(r)&&o?.appUrl&&(s.appUrl=o.appUrl),(!o||JSON.stringify(o)!==JSON.stringify(s))&&await(0,l.setDoc)(t,s),Ie=i}catch{}})(),()=>{e=!0}},[i])}function ze(e,t,n,r){let i=0,a=!0;for(let r=0;r<e.length;r++)if(i+=e[r]+(r>0?n:0),i>t){a=!1;break}if(a)return e.length;let o=0,s=0;for(let i=0;i<e.length;i++){let a=o+e[i]+(i>0?n:0);if(a+r>t)break;o=a,s++}return Math.max(s,1)}function Be({count:e,listKey:t,shown:n,gap:r,moreButtonWidth:i}){let a=(0,s.useRef)(null),o=(0,s.useRef)(null),[c,l]=(0,s.useState)(null);return(0,s.useLayoutEffect)(()=>{if(!n)return;let s=!0,c=0,u=()=>{let n=a.current,c=o.current;if(!s||!n||!c)return;let u=window.getComputedStyle(n),d=n.clientWidth-(parseFloat(u.paddingLeft)||0)-(parseFloat(u.paddingRight)||0);if(d<=0)return;let f=c.querySelectorAll(`[data-measure]`);if(f.length!==e)return;let p=parseFloat(u.columnGap);l({listKey:t,count:ze(Array.from(f,e=>e.offsetWidth),d,Number.isFinite(p)?p:r,i)})},d=()=>{cancelAnimationFrame(c),c=requestAnimationFrame(u)};u(),document.fonts?.ready.then(d).catch(()=>{});let f=typeof ResizeObserver>`u`?null:new ResizeObserver(d);return f&&a.current&&f.observe(a.current),()=>{s=!1,cancelAnimationFrame(c),f?.disconnect()}},[e,t,n,r,i]),{rowRef:a,measureRef:o,visible:c&&c.listKey===t?Math.min(c.count,e):e}}var Ve=`fbos_tab_access`,He=()=>{try{let e=localStorage.getItem(Ve),t=e?JSON.parse(e):null;return t&&typeof t==`object`?t:null}catch{return null}},J=null,Y=null,Ue=null,X=e=>{J=e,Y?.forEach(t=>t(e))};function We(e){let t=!Y;return Y||=new Set,Y.add(e),t?Ue=(0,l.onSnapshot)((0,l.doc)(n.ui,o.t.collection,o.t.doc),e=>{let t=e.exists()?e.data():{};try{localStorage.setItem(Ve,JSON.stringify(t))}catch{}X({access:t,live:!0})},()=>X({access:J?.access??He()??{},live:!0})):J?.live&&e(J),()=>{Y?.delete(e),!Y?.size&&(Ue?.(),Ue=null,Y=null)}}function Ge(){let[e,t]=(0,s.useState)(()=>{if(J)return J;let e=He();return e?{access:e,live:!1}:null});return(0,s.useEffect)(()=>We(t),[]),{access:e?.access??{},loaded:!!e,live:!!e?.live}}function Ke(e){let{access:t,loaded:n,live:r}=Ge();return{audience:o.o(t,e),loaded:n,live:r}}async function qe(e,t){let r=J,i=o.n(t);X({access:{...J?.access??He()??{},[e]:i},live:J?.live??!1});try{await(0,l.setDoc)((0,l.doc)(n.ui,o.t.collection,o.t.doc),{[e]:i},{merge:!0})}catch(e){throw r&&X(r),e}}var Z=r.Bn(`admin`),Q={inbox:{path:`/inbox`,label:`Inbox`,icon:E,roles:Z},users:{path:`/users`,label:`Users`,icon:oe,roles:Z},signin:{path:`/sign-in`,label:`Sign in`,icon:w,roles:Z},pages:{path:`/pages`,label:`Pages`,icon:t.g,roles:Z},mybookings:{path:`/my-bookings`,label:`My bookings`,icon:a.W,roles:r.Bn(`user`)},billing:{path:`/billing`,label:`Billing`,icon:O,roles:r.Bn(`user`)},payments:{path:`/payments`,label:`Payments`,icon:x,roles:Z},transactions:{path:`/transactions`,label:`Transactions`,icon:O,roles:Z},email:{path:`/email`,label:`Email`,icon:t.h,roles:Z},schedule:{path:`/schedule`,label:`Schedule`,icon:ie,roles:r.Bn(`internal`)},forms:{path:`/forms`,label:`Forms`,icon:M,roles:Z},theme:{path:`/theme`,label:`Theme`,icon:A,roles:Z},assets:{path:`/assets`,label:`Assets`,icon:te,roles:Z},publish:{path:`/publish`,label:`Publish App`,icon:re,roles:Z}},Je=e=>{let t=e=>e.id in Q;return[...e.filter(e=>!t(e)),...e.filter(t)]};function $(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Ye(){let[e,t]=(0,s.useState)(()=>$(`fbos_nav_tabs`)??{}),[r,i]=(0,s.useState)(()=>{let e=$(`fbos_nav_order`);return Array.isArray(e)?Ae(e):je}),[a,o]=(0,s.useState)(()=>$(`fbos_nav_tabs`)!==null),[c,u]=(0,s.useState)(()=>$(`fbos_nav_order`)!==null);return(0,s.useEffect)(()=>{let e=(0,l.onSnapshot)((0,l.collection)(n.ui,`sys_tabs`),e=>{let n={};e.forEach(e=>{n[e.id]=e.data()}),t(n),o(!0);try{localStorage.setItem(`fbos_nav_tabs`,JSON.stringify(n))}catch{}},()=>{o(!0)}),r=(0,l.onSnapshot)((0,l.doc)(n.ui,`sys_configs`,`tab_order`),e=>{let t=e.exists()&&Array.isArray(e.data().order)?Ae(e.data().order):je;i(t),u(!0);try{localStorage.setItem(`fbos_nav_order`,JSON.stringify(t))}catch{}},()=>{u(!0)}),a=setTimeout(()=>{o(!0),u(!0)},3e3);return()=>{e(),r(),clearTimeout(a)}},[]),{tabOverrides:e,tabOrder:r,loaded:a&&c}}function Xe({tabOverrides:e,tabOrder:n,hasBooking:i=!1,hasBought:a=!1,paymentsOn:s=!1,tabIcons:c={},tabAccess:l}){let u={};Object.entries(Q).forEach(([e,n])=>{e===`schedule`||e===`mybookings`||e===`mybookings`&&!i||e===`billing`&&!a||e===`transactions`&&!s||(u[e]={id:e,...n,icon:t.p(c[e])??n.icon},o.r(e)&&(u[e].roles=o.c(o.o(l,e))))});let d={...e};for(let[t,n]of ce())n.isPublic||(d[t]={...n.config,...e[t]});for(let[t,n]of Object.entries(e)){let r=String(n?.fileId||``);r&&r!==t&&!e[r]&&(F(d[r])&&d[t]?.inMenu===void 0&&(d[t]={...d[t],inMenu:!1}),delete d[r])}Object.entries(d).forEach(([e,n])=>{let i=u[e],a=t.p(n?.iconName)??i?.icon??t.g,o=i?.roles??Z;n?.pageType&&!Q[e]&&(o=r.Gn(n));let s=n?.route?n.route.startsWith(`/`)?n.route:`/`+n.route:i?.path??`/`+e,c=n?.tabName||n?.pageTitle||n?.pageName||i?.label||e,l=Q[e]?``:r.Nn(n);u[e]={id:e,path:s,label:c,icon:a,roles:o,group:l}});let f=[],p=new Set;n.forEach(e=>{e.hidden||p.has(e.id)||u[e.id]&&(f.push(u[e.id]),p.add(e.id))});let m=[],h=[];return Object.keys(u).forEach(e=>{if(p.has(e))return;let t=n.find(t=>t.id===e);t?.hidden||!t&&F(d[e])||(e in d&&!t?m.push(u[e]):h.push(u[e]))}),m.length>0&&f.unshift(...m),h.length>0&&f.push(...h),Je(f)}function Ze(e,t,n,i){return r.Un(e.roles,r.Kn(t,n))?e.group?!i.live&&!i.groups.some(t=>t.id===e.group)?!1:r.Fn(t,{group:e.group},i.groups):!0:!1}function Qe(){let{user:e,userRole:t}=n.Ft(),{tabOverrides:r,tabOrder:i,loaded:a}=Ye(),o=V();return a?Xe({tabOverrides:r,tabOrder:i}).filter(e=>!(e.id in Q)).filter(n=>Ze(n,t,!!e,o)):[]}function $e({customTabs:e=[]}){let{pathname:r}=(0,u.useLocation)(),{user:i,userRole:o,roleResolved:l}=n.Ft();Re();let d=a.b(``,``).bookings.length>0,f=n.zn(),[p]=(0,s.useState)(()=>$(`fbos_nav_payments`)===!0),m=f.loading?p:f.configured;(0,s.useEffect)(()=>{if(!f.loading)try{localStorage.setItem(`fbos_nav_payments`,JSON.stringify(f.configured))}catch{}},[f.loading,f.configured]);let h=i?.uid||``,g=n.Ln(h),[_]=(0,s.useState)(()=>{let e=$(`fbos_nav_billing`);return!!h&&e?.uid===h&&e?.bought===!0}),v=g.loading?_:g.bought;(0,s.useEffect)(()=>{if(!(g.loading||!h))try{localStorage.setItem(`fbos_nav_billing`,JSON.stringify({uid:h,bought:g.bought}))}catch{}},[g.loading,g.bought,h]);let y=Ge(),b=Ee(),x=V(),[S,C]=(0,s.useState)(!1),w=(0,s.useRef)(null),{tabOverrides:T,tabOrder:te,loaded:ne}=Ye(),E=l!==!1&≠(0,s.useEffect)(()=>{function e(e){w.current&&!w.current.contains(e.target)&&C(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let D=[...Xe({tabOverrides:T,tabOrder:te,hasBooking:d,hasBought:v,paymentsOn:m,tabIcons:b,tabAccess:y.access}),...e.map(e=>({...e,id:e.path}))].filter(e=>Ze(e,o,!!i,x)),O=D.some(e=>t.f(e.icon));(0,s.useEffect)(()=>{O&&t.m()},[O]);let{rowRef:k,measureRef:A,visible:j}=Be({count:D.length,listKey:D.map(e=>e.id+e.label).join(`|`),shown:E&&D.length>0,gap:40,moreButtonWidth:52}),M=D.slice(0,j),N=D.slice(j),re=D.map(e=>e.path).filter(e=>{let t=e.replace(/\/+$/,``);return r===e||t!==``&&r.startsWith(t+`/`)}).sort((e,t)=>t.length-e.length)[0],P=e=>e.path===re,ie=N.some(e=>P(e));return E?D.length===0?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`div`,{ref:A,"aria-hidden":`true`,className:`flex items-center gap-5 md:gap-10 whitespace-nowrap px-1`,style:{position:`fixed`,top:-9999,left:0,visibility:`hidden`,pointerEvents:`none`},children:D.map((e,t)=>{let n=e.icon;return(0,c.jsxs)(`span`,{"data-measure":!0,className:`flex items-center gap-2 text-[13px] md:text-[14.5px] font-semibold shrink-0 pb-2.5 md:pb-3`,children:[(0,c.jsx)(n,{className:`w-4 h-4 md:w-[18px] md:h-[18px]`}),e.label]},t)})}),(0,c.jsxs)(`div`,{ref:k,className:`w-full flex items-center gap-5 md:gap-10 mb-5 border-b border-[var(--panel-border)] px-1 whitespace-nowrap relative`,children:[M.map(e=>{let t=P(e),n=e.icon;return(0,c.jsxs)(u.Link,{to:e.path||`/`,className:`flex items-center gap-2 text-[13px] md:text-[14.5px] font-semibold transition-all duration-300 pb-2.5 md:pb-3 -mb-[1px] border-b-2 shrink-0 ${t?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,children:[(0,c.jsx)(n,{className:`w-4 h-4 md:w-[18px] md:h-[18px]`}),e.label]},e.path||e.id)}),N.length>0&&(0,c.jsxs)(`div`,{className:`relative shrink-0 ml-auto`,ref:w,children:[(0,c.jsx)(`button`,{onClick:()=>C(!S),className:`flex items-center justify-center transition-all duration-300 pb-2.5 md:pb-3 -mb-[1px] border-b-2 cursor-pointer ${ie?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,title:`More items`,children:(0,c.jsx)(ee,{className:`w-[18px] h-[18px] md:w-5 md:h-5`})}),(0,c.jsx)(n.rt,{children:S&&(0,c.jsx)(n.nt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:`absolute top-[100%] right-0 mt-2 min-w-[200px] glass-popover border border-[var(--panel-border)] rounded-2xl z-50 flex flex-col py-2 overflow-hidden`,children:N.map(e=>{let t=P(e),n=e.icon;return(0,c.jsxs)(u.Link,{to:e.path||`/`,onClick:()=>C(!1),className:`flex items-center gap-3 px-5 py-3 text-[14px] font-medium transition-colors ${t?`text-accent bg-accent/5`:`text-foreground/70 hover:text-foreground hover:bg-foreground/5`}`,children:[(0,c.jsx)(n,{className:`w-4 h-4`}),e.label]},e.path||e.id)})})})]})]})]}):(0,c.jsx)(`div`,{className:`w-full flex items-center gap-5 md:gap-10 mb-5 border-b border-[var(--panel-border)] px-1 whitespace-nowrap relative`,children:[56,72,64].map((e,t)=>(0,c.jsxs)(`span`,{className:`flex items-center gap-2 pb-2.5 md:pb-3 h-[30px] md:h-[33px] shrink-0`,"aria-hidden":`true`,children:[(0,c.jsx)(`span`,{className:`w-4 h-4 md:w-[18px] md:h-[18px] rounded-md bg-foreground/5 animate-pulse`}),(0,c.jsx)(`span`,{className:`h-3.5 rounded bg-foreground/5 animate-pulse`,style:{width:e}})]},t))})}Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return qe}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return F}});
|
|
1
|
+
const e=require(`./chunk-CiTBaPhY.cjs`),t=require(`./PageTitle-BL50s4qY.cjs`),n=require(`./TimeZoneField-Ckn1pKAL.cjs`),r=require(`./schedule-BAea6q8_.cjs`),i=require(`./chevron-down-lyDK1rfL.cjs`),a=require(`./scheduleData-BXjNXVHY.cjs`),o=require(`./tabAudience-2fJAN1aD.cjs`);let s=require(`react`);s=e.a(s,1);let c=require(`react/jsx-runtime`),l=require(`firebase/firestore`),u=require(`react-router-dom`);var d=typeof window<`u`?s.useLayoutEffect:s.useEffect,f=(0,s.createContext)(void 0),p=`'Inter', system-ui, sans-serif`,m=e=>e.trim().replace(/\s+/g,`+`);function h(e,t){let n=[[`--display-family`,String(t?.display||``).trim()],[`--body-family`,String(t?.body||``).trim()]];for(let[t,r]of n){if(!r){e.style.removeProperty(t);continue}let n=`theme-font-${m(r).toLowerCase().replace(/[^a-z0-9+]/g,``)}`;if(typeof document<`u`&&!document.getElementById(n)){let e=document.createElement(`link`);e.id=n,e.rel=`stylesheet`,e.href=`https://fonts.googleapis.com/css2?family=${m(r)}:wght@300;400;500;600;700;800&display=swap`,document.head.appendChild(e)}e.style.setProperty(t,`'${r.replace(/'/g,``)}', ${p}`)}}var g=e=>{let t=e?.defaultTheme;return t!==`light`&&t!==`dark`||e?.showThemeToggle?null:t},_={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}},drop(e){try{localStorage.removeItem(e)}catch{}}};function v({children:e,scopeSelector:r}){let i=n.mi(),a=(0,s.useMemo)(()=>i?.themeConfig||t.b,[i?.themeConfig]),o=g(a),l=!!a.showThemeToggle;(0,s.useEffect)(()=>{try{localStorage.removeItem(`theme_config_cache`),localStorage.removeItem(`theme_saved_cache`)}catch{}console.info(`Your AI Firebase ${t.y} · colours from theme.config.ts`)},[]);let[u,p]=(0,s.useState)(()=>{if(o)return o;if(typeof window>`u`)return a.defaultTheme||`system`;let e=_.get(`theme-mode`),t=_.get(`last-seen-default-theme`);return a.defaultTheme&&a.defaultTheme!==t?(_.set(`last-seen-default-theme`,a.defaultTheme),_.drop(`theme-mode`),a.defaultTheme):e||a.defaultTheme||`system`}),[m,v]=(0,s.useState)(()=>{if(o)return o;if(typeof window>`u`)return a.defaultTheme===`light`?`light`:`dark`;let e=_.get(`theme-mode`),t=_.get(`last-seen-default-theme`),n=e||a.defaultTheme||`system`;return a.defaultTheme&&a.defaultTheme!==t&&(n=a.defaultTheme),n===`system`?window.matchMedia(`(prefers-color-scheme: light)`).matches?`light`:`dark`:n});return(0,s.useEffect)(()=>{let e=a.defaultTheme;e&&(o&&p(o),e!==_.get(`last-seen-default-theme`)&&(_.set(`last-seen-default-theme`,e),_.drop(`theme-mode`),p(e)))},[a.defaultTheme,o]),(0,s.useEffect)(()=>{let e=e=>{u===`system`&&v(e.matches?`light`:`dark`)},t=window.matchMedia(`(prefers-color-scheme: light)`);return u===`system`?(v(t.matches?`light`:`dark`),t.addEventListener(`change`,e)):v(u),()=>t.removeEventListener(`change`,e)},[u]),d(()=>{let e=(r?document.querySelector(r):document.documentElement)||document.documentElement,t=m===`dark`?a.colors.dark:a.colors.light;e.style.setProperty(`--bg-color`,t.background),e.style.setProperty(`--bg-secondary-color`,t.backgroundSecondary||t.background),e.style.setProperty(`--fg-color`,t.foreground),e.style.setProperty(`--accent-color`,t.accent);let n=m===`dark`;e.style.setProperty(`--panel-bg`,t.panelBg||`color-mix(in srgb, ${t.accent} ${n?`5%`:`4%`}, transparent)`),e.style.setProperty(`--panel-border`,t.panelBorder||`color-mix(in srgb, ${t.accent} 15%, transparent)`);let i=(e,t,n)=>{if(!e||e.length===0)return t||`transparent`;if(e.length===1)return e[0];let r=e.map((t,n)=>`${t} ${Math.round(n/(e.length-1)*100)}%`).join(`, `);return n===`conic`?`conic-gradient(from 180deg at 50% 100%, ${r})`:`linear-gradient(135deg, ${r})`},o=`linear-gradient(135deg, color-mix(in oklab, ${t.accent} ${n?`70%`:`78%`}, black) 0%, ${t.accent} 100%)`,s=`linear-gradient(135deg, color-mix(in oklab, ${t.accent} ${n?`80%`:`85%`}, black) 0%, color-mix(in oklab, ${t.accent} 72%, white) 100%)`;e.style.setProperty(`--button-bg`,i(t.buttonGradient,o,t.buttonGradientShape)),e.style.setProperty(`--button-fg`,t.buttonText||`#ffffff`),e.style.setProperty(`--button-hover-bg`,i(t.buttonHoverGradient||t.buttonGradient,s,t.buttonGradientShape)),e.style.setProperty(`--text-gradient`,i(t.textGradient,`linear-gradient(135deg, ${t.foreground} 0%, ${t.accent} 100%)`)),e.style.setProperty(`--glow-color`,t.glowColor||`color-mix(in srgb, ${t.accent} ${n?`40%`:`30%`}, transparent)`),e.style.setProperty(`--notification-icon-color`,t.notificationIconColor||t.accent);let c=t.secondaryButton?.bg||(m===`dark`?`rgba(255, 255, 255, 0.05)`:`rgba(0, 0, 0, 0.03)`),l=t.secondaryButton?.border||(m===`dark`?`rgba(255, 255, 255, 0.1)`:`rgba(0, 0, 0, 0.06)`),d=t.secondaryButton?.text||t.foreground;if(e.style.setProperty(`--btn-sec-bg`,c),e.style.setProperty(`--btn-sec-border`,l),e.style.setProperty(`--btn-sec-text`,d),e.style.setProperty(`--selection-bg`,t.selectionBg||`color-mix(in srgb, var(--accent-color) 40%, transparent)`),e.style.setProperty(`--selection-text`,t.selectionText||`#ffffff`),e.setAttribute(`data-theme`,m),_.set(`theme-mode`,u),a.cornerRounding===`custom`&&a.cornerRadii?(e.style.setProperty(`--btn-radius`,`${parseFloat(String(a.cornerRadii.buttonRadius))||0}rem`),e.style.setProperty(`--card-radius`,`${parseFloat(String(a.cornerRadii.cardRadius))||0}rem`),e.style.setProperty(`--input-radius`,`${parseFloat(String(a.cornerRadii.inputRadius))||0}rem`),e.style.setProperty(`--modal-radius`,`${parseFloat(String(a.cornerRadii.modalRadius))||0}rem`)):(e.style.setProperty(`--btn-radius`,`0.75rem`),e.style.setProperty(`--card-radius`,`1.5rem`),e.style.setProperty(`--input-radius`,`0.75rem`),e.style.setProperty(`--modal-radius`,`1.5rem`)),!document.getElementById(`inter-font`)){let e=document.createElement(`link`);e.id=`inter-font`,e.rel=`stylesheet`,e.href=`https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap`,document.head.appendChild(e)}h(e,a.fonts),e.style.fontSize=`16px`,e.style.setProperty(`--weight-h1`,`800`),e.style.setProperty(`--weight-h2`,`700`),e.style.setProperty(`--weight-h3`,`700`),e.style.setProperty(`--leading-normal`,`1.5`);let f=document.querySelector(`link[rel*='icon']`);f||(f=document.createElement(`link`),f.rel=`icon`,document.head.appendChild(f)),a.faviconUrl&&(f.href=a.faviconUrl),a.appName&&(document.title=a.appName)},[m,u,a]),(0,c.jsx)(f.Provider,{value:{theme:m,setTheme:e=>{o||p(e)},toggleTheme:()=>{o||p(m===`light`?`dark`:`light`)},isSystem:u===`system`,setIsSystem:e=>{o||p(e?`system`:m)},config:a,activeConfig:a,canSwitchTheme:l},children:e})}var y=()=>{let e=(0,s.useContext)(f);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e},b={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};b.node;var x=i.n(b),S={name:`ellipsis-vertical`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]],aliases:[`more-vertical`]};S.node;var ee=i.n(S),C={name:`fingerprint-pattern`,size:24,node:[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]],aliases:[`fingerprint`]};C.node;var w=i.n(C),T={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};T.node;var te=i.n(T),ne={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};ne.node;var E=i.n(ne),D={name:`nfc`,size:24,node:[[`path`,{d:`M6 8.32a7.43 7.43 0 0 1 0 7.36`,key:`9iaqei`}],[`path`,{d:`M9.46 6.21a11.76 11.76 0 0 1 0 11.58`,key:`1yha7l`}],[`path`,{d:`M12.91 4.1a15.91 15.91 0 0 1 .01 15.8`,key:`4iu2gk`}],[`path`,{d:`M16.37 2a20.16 20.16 0 0 1 0 20`,key:`sap9u2`}]]};D.node;var O=i.n(D),k={name:`palette`,size:24,node:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]};k.node;var A=i.n(k),j={name:`rectangle-ellipsis`,size:24,node:[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M17 12h.01`,key:`1m0b6t`}],[`path`,{d:`M7 12h.01`,key:`eqddd0`}]],aliases:[`form-input`]};j.node;var M=i.n(j),N={name:`rocket`,size:24,node:[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]};N.node;var re=i.n(N),P={name:`rotate-cw-fading-clock`,size:24,node:[[`path`,{d:`M12 3a9.75 9.75 0 0 1 6.74 2.74`,key:`1k3kxf`}],[`path`,{d:`M18.74 5.74 21 8`,key:`1eb40o`}],[`path`,{d:`M21 8V3`,key:`1et280`}],[`path`,{d:`M7.5 19.794c-6-3.464-6-12.124 0-15.588`,key:`19r0lp`}],[`path`,{d:`M7.5 4.206A9 9 0 0 1 12 3`,key:`s8r11`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}],[`path`,{d:`M14 20.775A9 9 0 0 1 12 21`,key:`184rgu`}],[`path`,{d:`M19 17.656a9 9 0 0 1-1.5 1.456`,key:`7qgp6l`}],[`path`,{d:`M21 12a9 9 0 0 1-.228 2`,key:`1h378y`}],[`path`,{d:`M21 8h-5`,key:`k0yzmk`}]]};P.node;var ie=i.n(P),ae={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};ae.node;var oe=i.n(ae);function se(){return(typeof window<`u`?window.__FBOS_PAGES__:null)||{}}function ce(e=se()){let t=new Set,n=[];for(let[r,i]of Object.entries(e))!i||t.has(i)||(t.add(i),n.push([r,i]));return n}var F=e=>e?.inMenu===!1,le=(e,t,n)=>{let r=e.find(e=>e.id===t);return r?r.hidden===!0:F(n)},I=`sys_groups`,ue=`fbos_groups`,de=(e,t)=>({id:e,name:String(t?.name||e),roles:r._n(t?.roles),...typeof t?.createdAt==`number`?{createdAt:t.createdAt}:{}}),fe=(e,t)=>e.name.localeCompare(t.name),pe=()=>{try{let e=localStorage.getItem(ue),t=e?JSON.parse(e):null;return Array.isArray(t)?t.filter(e=>r.On(e?.id)).map(e=>de(e.id,e)):null}catch{return null}},L=null,R=null,z=null,B=e=>{L=e,R?.forEach(t=>t(e))};function me(e){let t=!R;return R||=new Set,R.add(e),t?z=(0,l.onSnapshot)((0,l.collection)(n.ui,I),e=>{let t=[];e.forEach(e=>{r.On(e.id)&&t.push(de(e.id,e.data()))}),t.sort(fe);try{localStorage.setItem(ue,JSON.stringify(t))}catch{}B({groups:t,live:!0})},()=>B({groups:L?.groups??pe()??[],live:!0})):L?.live&&e(L),()=>{R?.delete(e),!R?.size&&(z?.(),z=null,R=null)}}function V(){let[e,t]=(0,s.useState)(()=>{if(L)return L;let e=pe();return e?{groups:e,live:!1}:null});return(0,s.useEffect)(()=>me(t),[]),{groups:e?.groups??[],loaded:!!e,live:!!e?.live}}function he(e,t,n=``){let i=String(e||``).trim();if(!i)return`Type a name for the group first — Sales, say, or North branch.`;if(!r.On(r.Ln(i)))return`Use a name with at least two letters in it.`;let a=t.find(e=>e.id!==n&&(e.name.trim().toLowerCase()===i.toLowerCase()||!n&&e.id===r.Ln(i)));return a?`You already have a group called ${a.name}.`:``}async function ge(e){let t=String(e||``).trim().slice(0,48),i={id:r.Ln(t),name:t,roles:[],createdAt:Date.now()};return await(0,l.setDoc)((0,l.doc)(n.ui,I,i.id),{name:i.name,roles:[],createdAt:i.createdAt}),i}async function _e(e,t){let i=String(t||``).trim().slice(0,48);!i||!r.On(e)||await(0,l.setDoc)((0,l.doc)(n.ui,I,e),{name:i},{merge:!0})}async function ve(e,t){if(!r.On(e))return;let i=r._n(t),a=L;L&&B({...L,groups:L.groups.map(t=>t.id===e?{...t,roles:i}:t)});try{await(0,l.setDoc)((0,l.doc)(n.ui,I,e),{roles:i},{merge:!0})}catch(e){throw a&&B(a),e}}async function ye(e){let t=[];return r.On(e)&&(await(0,l.getDocs)((0,l.collection)(n.ui,`sys_tabs`))).forEach(n=>{r.Nn(n.data())===e&&t.push(n.id)}),t}async function be(e){if(r.On(e)){for(let t of await ye(e))await(0,l.setDoc)((0,l.doc)(n.ui,`sys_tabs`,t),{group:``},{merge:!0});await(0,l.deleteDoc)((0,l.doc)(n.ui,I,e))}}async function xe(e){let t=await(0,l.getDocs)((0,l.collection)(n.ui,I));for(let i of t.docs){let t=r._n(i.data()?.roles);t.includes(e)&&await(0,l.setDoc)((0,l.doc)(n.ui,I,i.id),{roles:t.filter(t=>t!==e)},{merge:!0})}}var H={collection:`sys_configs`,doc:`tab_icons`},Se=`fbos_tab_icons`,Ce=e=>{let t={};if(e&&typeof e==`object`)for(let[n,r]of Object.entries(e)){let e=typeof r==`string`?r.trim():``;e&&(t[n]=e)}return t},U=()=>{try{let e=localStorage.getItem(Se);return e?Ce(JSON.parse(e)):null}catch{return null}},W=null,G=null,we=null,K=e=>{W=e,G?.forEach(t=>t(e))};function Te(e){let t=!G;return G||=new Set,G.add(e),t?we=(0,l.onSnapshot)((0,l.doc)(n.ui,H.collection,H.doc),e=>{let t=Ce(e.exists()?e.data():{});try{localStorage.setItem(Se,JSON.stringify(t))}catch{}K(t)},()=>K(W??U()??{})):W&&e(W),()=>{G?.delete(e),!G?.size&&(we?.(),we=null,G=null)}}function Ee(){let[e,t]=(0,s.useState)(()=>W??U()??{});return(0,s.useEffect)(()=>Te(t),[]),e}async function De(e,t){let r=String(t||``).trim(),i=W,a={...W??U()??{}};r?a[e]=r:delete a[e],K(a);try{await(0,l.setDoc)((0,l.doc)(n.ui,H.collection,H.doc),{[e]:r},{merge:!0})}catch(e){throw i&&K(i),e}}var Oe={drive:`assets`,submissions:`inbox`,requests:`inbox`},ke=new Set([`setup`]),Ae=e=>{let t=(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden}).map(e=>({...e,id:Oe[e.id]||e.id})).filter(e=>!ke.has(e.id));return t.filter((e,n)=>t.findIndex(t=>t.id===e.id)===n)},je=[{id:`inbox`,hidden:!1},{id:`users`,hidden:!1},{id:`signin`,hidden:!1},{id:`pages`,hidden:!1},{id:`mybookings`,hidden:!1},{id:`billing`,hidden:!1},{id:`payments`,hidden:!1},{id:`transactions`,hidden:!1},{id:`email`,hidden:!1},{id:`schedule`,hidden:!1},{id:`forms`,hidden:!1},{id:`theme`,hidden:!1},{id:`assets`,hidden:!1},{id:`publish`,hidden:!1}],Me=/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i,q=e=>{let t=String(e??``).trim();return Me.test(t)?t:``};function Ne(e,t){let n=String(e??``).trim();if(!n||/^data:/i.test(n))return``;try{let e=new URL(n,t||void 0);return/^https?:$/.test(e.protocol)?e.href:``}catch{return``}}function Pe(e,t){let n=e?.colors?.light||{},r=Array.isArray(n.buttonGradient)?n.buttonGradient.map(q).filter(Boolean).slice(0,2):[];return{appName:String(e?.appName||``).replace(/\s+/g,` `).trim().slice(0,60),logoUrl:Ne(e?.logoUrl,t),appUrl:Ne(t,``),accent:q(n.accent),foreground:q(n.foreground),buttonText:q(n.buttonText),buttonGradient:r,panelBg:q(n.panelBg),panelBorder:q(n.panelBorder)}}function Fe(e){return{appName:String(e?.appName||``),logoUrl:String(e?.logoUrl||``),appUrl:String(e?.appUrl||``),accent:String(e?.accent||``),foreground:String(e?.foreground||``),buttonText:String(e?.buttonText||``),buttonGradient:Array.isArray(e?.buttonGradient)?e.buttonGradient.map(String):[],panelBg:String(e?.panelBg||``),panelBorder:String(e?.panelBorder||``)}}var Ie=``,Le=e=>/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/i.test(e);function Re(){let e=null;try{e=y().activeConfig}catch{e=null}let t=!!n.Ft()?.isAdmin,r=typeof window<`u`?window.location.origin:``,i=e&&t?JSON.stringify(Pe(e,r)):``;(0,s.useEffect)(()=>{if(!i||!n.ui||i===Ie)return;let e=!1;return(async()=>{try{let t=(0,l.doc)(n.ui,`sys_configs`,`emailBrand`),a=await(0,l.getDoc)(t);if(e)return;let o=a.exists()?Fe(a.data()):null,s=JSON.parse(i);Le(r)&&o?.appUrl&&(s.appUrl=o.appUrl),(!o||JSON.stringify(o)!==JSON.stringify(s))&&await(0,l.setDoc)(t,s),Ie=i}catch{}})(),()=>{e=!0}},[i])}function ze(e,t,n,r){let i=0,a=!0;for(let r=0;r<e.length;r++)if(i+=e[r]+(r>0?n:0),i>t){a=!1;break}if(a)return e.length;let o=0,s=0;for(let i=0;i<e.length;i++){let a=o+e[i]+(i>0?n:0);if(a+r>t)break;o=a,s++}return Math.max(s,1)}function Be({count:e,listKey:t,shown:n,gap:r,moreButtonWidth:i}){let a=(0,s.useRef)(null),o=(0,s.useRef)(null),[c,l]=(0,s.useState)(null);return(0,s.useLayoutEffect)(()=>{if(!n)return;let s=!0,c=0,u=()=>{let n=a.current,c=o.current;if(!s||!n||!c)return;let u=window.getComputedStyle(n),d=n.clientWidth-(parseFloat(u.paddingLeft)||0)-(parseFloat(u.paddingRight)||0);if(d<=0)return;let f=c.querySelectorAll(`[data-measure]`);if(f.length!==e)return;let p=parseFloat(u.columnGap);l({listKey:t,count:ze(Array.from(f,e=>e.offsetWidth),d,Number.isFinite(p)?p:r,i)})},d=()=>{cancelAnimationFrame(c),c=requestAnimationFrame(u)};u(),document.fonts?.ready.then(d).catch(()=>{});let f=typeof ResizeObserver>`u`?null:new ResizeObserver(d);return f&&a.current&&f.observe(a.current),()=>{s=!1,cancelAnimationFrame(c),f?.disconnect()}},[e,t,n,r,i]),{rowRef:a,measureRef:o,visible:c&&c.listKey===t?Math.min(c.count,e):e}}var Ve=`fbos_tab_access`,He=()=>{try{let e=localStorage.getItem(Ve),t=e?JSON.parse(e):null;return t&&typeof t==`object`?t:null}catch{return null}},J=null,Y=null,Ue=null,X=e=>{J=e,Y?.forEach(t=>t(e))};function We(e){let t=!Y;return Y||=new Set,Y.add(e),t?Ue=(0,l.onSnapshot)((0,l.doc)(n.ui,o.t.collection,o.t.doc),e=>{let t=e.exists()?e.data():{};try{localStorage.setItem(Ve,JSON.stringify(t))}catch{}X({access:t,live:!0})},()=>X({access:J?.access??He()??{},live:!0})):J?.live&&e(J),()=>{Y?.delete(e),!Y?.size&&(Ue?.(),Ue=null,Y=null)}}function Ge(){let[e,t]=(0,s.useState)(()=>{if(J)return J;let e=He();return e?{access:e,live:!1}:null});return(0,s.useEffect)(()=>We(t),[]),{access:e?.access??{},loaded:!!e,live:!!e?.live}}function Ke(e){let{access:t,loaded:n,live:r}=Ge();return{audience:o.o(t,e),loaded:n,live:r}}async function qe(e,t){let r=J,i=o.n(t);X({access:{...J?.access??He()??{},[e]:i},live:J?.live??!1});try{await(0,l.setDoc)((0,l.doc)(n.ui,o.t.collection,o.t.doc),{[e]:i},{merge:!0})}catch(e){throw r&&X(r),e}}var Z=r.Bn(`admin`),Q={inbox:{path:`/inbox`,label:`Inbox`,icon:E,roles:Z},users:{path:`/users`,label:`Users`,icon:oe,roles:Z},signin:{path:`/sign-in`,label:`Sign in`,icon:w,roles:Z},pages:{path:`/pages`,label:`Pages`,icon:t.g,roles:Z},mybookings:{path:`/my-bookings`,label:`My bookings`,icon:a.W,roles:r.Bn(`user`)},billing:{path:`/billing`,label:`Billing`,icon:O,roles:r.Bn(`user`)},payments:{path:`/payments`,label:`Payments`,icon:x,roles:Z},transactions:{path:`/transactions`,label:`Transactions`,icon:O,roles:Z},email:{path:`/email`,label:`Email`,icon:t.h,roles:Z},schedule:{path:`/schedule`,label:`Schedule`,icon:ie,roles:r.Bn(`internal`)},forms:{path:`/forms`,label:`Forms`,icon:M,roles:Z},theme:{path:`/theme`,label:`Theme`,icon:A,roles:Z},assets:{path:`/assets`,label:`Assets`,icon:te,roles:Z},publish:{path:`/publish`,label:`Publish App`,icon:re,roles:Z}},Je=e=>{let t=e=>e.id in Q;return[...e.filter(e=>!t(e)),...e.filter(t)]};function $(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Ye(){let[e,t]=(0,s.useState)(()=>$(`fbos_nav_tabs`)??{}),[r,i]=(0,s.useState)(()=>{let e=$(`fbos_nav_order`);return Array.isArray(e)?Ae(e):je}),[a,o]=(0,s.useState)(()=>$(`fbos_nav_tabs`)!==null),[c,u]=(0,s.useState)(()=>$(`fbos_nav_order`)!==null);return(0,s.useEffect)(()=>{let e=(0,l.onSnapshot)((0,l.collection)(n.ui,`sys_tabs`),e=>{let n={};e.forEach(e=>{n[e.id]=e.data()}),t(n),o(!0);try{localStorage.setItem(`fbos_nav_tabs`,JSON.stringify(n))}catch{}},()=>{o(!0)}),r=(0,l.onSnapshot)((0,l.doc)(n.ui,`sys_configs`,`tab_order`),e=>{let t=e.exists()&&Array.isArray(e.data().order)?Ae(e.data().order):je;i(t),u(!0);try{localStorage.setItem(`fbos_nav_order`,JSON.stringify(t))}catch{}},()=>{u(!0)}),a=setTimeout(()=>{o(!0),u(!0)},3e3);return()=>{e(),r(),clearTimeout(a)}},[]),{tabOverrides:e,tabOrder:r,loaded:a&&c}}function Xe({tabOverrides:e,tabOrder:n,hasBooking:i=!1,hasBought:a=!1,paymentsOn:s=!1,tabIcons:c={},tabAccess:l}){let u={};Object.entries(Q).forEach(([e,n])=>{e===`schedule`||e===`mybookings`||e===`mybookings`&&!i||e===`billing`&&!a||e===`transactions`&&!s||(u[e]={id:e,...n,icon:t.p(c[e])??n.icon},o.r(e)&&(u[e].roles=o.c(o.o(l,e))))});let d={...e};for(let[t,n]of ce())n.isPublic||(d[t]={...n.config,...e[t]});for(let[t,n]of Object.entries(e)){let r=String(n?.fileId||``);r&&r!==t&&!e[r]&&(F(d[r])&&d[t]?.inMenu===void 0&&(d[t]={...d[t],inMenu:!1}),delete d[r])}Object.entries(d).forEach(([e,n])=>{let i=u[e],a=t.p(n?.iconName)??i?.icon??t.g,o=i?.roles??Z;n?.pageType&&!Q[e]&&(o=r.Gn(n));let s=n?.route?n.route.startsWith(`/`)?n.route:`/`+n.route:i?.path??`/`+e,c=n?.tabName||n?.pageTitle||n?.pageName||i?.label||e,l=Q[e]?``:r.Nn(n);u[e]={id:e,path:s,label:c,icon:a,roles:o,group:l}});let f=[],p=new Set;n.forEach(e=>{e.hidden||p.has(e.id)||u[e.id]&&(f.push(u[e.id]),p.add(e.id))});let m=[],h=[];return Object.keys(u).forEach(e=>{if(p.has(e))return;let t=n.find(t=>t.id===e);t?.hidden||!t&&F(d[e])||(e in d&&!t?m.push(u[e]):h.push(u[e]))}),m.length>0&&f.unshift(...m),h.length>0&&f.push(...h),Je(f)}function Ze(e,t,n,i){return r.Un(e.roles,r.Kn(t,n))?e.group?!i.live&&!i.groups.some(t=>t.id===e.group)?!1:r.Fn(t,{group:e.group},i.groups):!0:!1}function Qe(){let{user:e,userRole:t}=n.Ft(),{tabOverrides:r,tabOrder:i,loaded:a}=Ye(),o=V();return a?Xe({tabOverrides:r,tabOrder:i}).filter(e=>!(e.id in Q)).filter(n=>Ze(n,t,!!e,o)):[]}function $e({customTabs:e=[]}){let{pathname:r}=(0,u.useLocation)(),{user:i,userRole:o,roleResolved:l}=n.Ft();Re();let d=a.b(``,``).bookings.length>0,f=n.zn(),[p]=(0,s.useState)(()=>$(`fbos_nav_payments`)===!0),m=f.loading?p:f.configured;(0,s.useEffect)(()=>{if(!f.loading)try{localStorage.setItem(`fbos_nav_payments`,JSON.stringify(f.configured))}catch{}},[f.loading,f.configured]);let h=i?.uid||``,g=n.Ln(h),[_]=(0,s.useState)(()=>{let e=$(`fbos_nav_billing`);return!!h&&e?.uid===h&&e?.bought===!0}),v=g.loading?_:g.bought;(0,s.useEffect)(()=>{if(!(g.loading||!h))try{localStorage.setItem(`fbos_nav_billing`,JSON.stringify({uid:h,bought:g.bought}))}catch{}},[g.loading,g.bought,h]);let y=Ge(),b=Ee(),x=V(),[S,C]=(0,s.useState)(!1),w=(0,s.useRef)(null),{tabOverrides:T,tabOrder:te,loaded:ne}=Ye(),E=l!==!1&≠(0,s.useEffect)(()=>{function e(e){w.current&&!w.current.contains(e.target)&&C(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let D=[...Xe({tabOverrides:T,tabOrder:te,hasBooking:d,hasBought:v,paymentsOn:m,tabIcons:b,tabAccess:y.access}),...e.map(e=>({...e,id:e.path}))].filter(e=>Ze(e,o,!!i,x)),O=D.some(e=>t.f(e.icon));(0,s.useEffect)(()=>{O&&t.m()},[O]);let{rowRef:k,measureRef:A,visible:j}=Be({count:D.length,listKey:D.map(e=>e.id+e.label).join(`|`),shown:E&&D.length>0,gap:40,moreButtonWidth:52}),M=D.slice(0,j),N=D.slice(j),re=D.map(e=>e.path).filter(e=>{let t=e.replace(/\/+$/,``);return r===e||t!==``&&r.startsWith(t+`/`)}).sort((e,t)=>t.length-e.length)[0],P=e=>e.path===re,ie=N.some(e=>P(e));return E?D.length===0?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`div`,{ref:A,"aria-hidden":`true`,className:`flex items-center gap-5 md:gap-10 whitespace-nowrap px-1`,style:{position:`fixed`,top:-9999,left:0,visibility:`hidden`,pointerEvents:`none`},children:D.map((e,t)=>{let n=e.icon;return(0,c.jsxs)(`span`,{"data-measure":!0,className:`flex items-center gap-2 text-[13px] md:text-[14.5px] font-semibold shrink-0 pb-2.5 md:pb-3`,children:[(0,c.jsx)(n,{className:`w-4 h-4 md:w-[18px] md:h-[18px]`}),e.label]},t)})}),(0,c.jsxs)(`div`,{ref:k,className:`w-full flex items-center gap-5 md:gap-10 mb-5 border-b border-[var(--panel-border)] px-1 whitespace-nowrap relative`,children:[M.map(e=>{let t=P(e),n=e.icon;return(0,c.jsxs)(u.Link,{to:e.path||`/`,className:`flex items-center gap-2 text-[13px] md:text-[14.5px] font-semibold transition-all duration-300 pb-2.5 md:pb-3 -mb-[1px] border-b-2 shrink-0 ${t?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,children:[(0,c.jsx)(n,{className:`w-4 h-4 md:w-[18px] md:h-[18px]`}),e.label]},e.path||e.id)}),N.length>0&&(0,c.jsxs)(`div`,{className:`relative shrink-0 ml-auto`,ref:w,children:[(0,c.jsx)(`button`,{onClick:()=>C(!S),className:`flex items-center justify-center transition-all duration-300 pb-2.5 md:pb-3 -mb-[1px] border-b-2 cursor-pointer ${ie?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,title:`More items`,children:(0,c.jsx)(ee,{className:`w-[18px] h-[18px] md:w-5 md:h-5`})}),(0,c.jsx)(n.rt,{children:S&&(0,c.jsx)(n.nt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:`absolute top-[100%] right-0 mt-2 min-w-[200px] glass-popover border border-[var(--panel-border)] rounded-2xl z-50 flex flex-col py-2 overflow-hidden`,children:N.map(e=>{let t=P(e),n=e.icon;return(0,c.jsxs)(u.Link,{to:e.path||`/`,onClick:()=>C(!1),className:`flex items-center gap-3 px-5 py-3 text-[14px] font-medium transition-colors ${t?`text-accent bg-accent/5`:`text-foreground/70 hover:text-foreground hover:bg-foreground/5`}`,children:[(0,c.jsx)(n,{className:`w-4 h-4`}),e.label]},e.path||e.id)})})})]})]})]}):(0,c.jsx)(`div`,{className:`w-full flex items-center gap-5 md:gap-10 mb-5 border-b border-[var(--panel-border)] px-1 whitespace-nowrap relative`,children:[56,72,64].map((e,t)=>(0,c.jsxs)(`span`,{className:`flex items-center gap-2 pb-2.5 md:pb-3 h-[30px] md:h-[33px] shrink-0`,"aria-hidden":`true`,children:[(0,c.jsx)(`span`,{className:`w-4 h-4 md:w-[18px] md:h-[18px] rounded-md bg-foreground/5 animate-pulse`}),(0,c.jsx)(`span`,{className:`h-3.5 rounded bg-foreground/5 animate-pulse`,style:{width:e}})]},t))})}Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return qe}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return F}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as e, f as t, g as n, h as r, m as i, p as a, y as o } from "./PageTitle-
|
|
1
|
+
import { b as e, f as t, g as n, h as r, m as i, p as a, y as o } from "./PageTitle-CkZriz8K.js";
|
|
2
2
|
import { Ft as s, Ln as c, mi as l, nt as u, rt as d, ui as f, zn as p } from "./TimeZoneField-oIMwb5_X.js";
|
|
3
3
|
import { Bn as m, Fn as ee, Gn as h, Kn as g, Ln as _, Nn as te, On as v, Un as ne, _n as y } from "./schedule-C13m_kiO.js";
|
|
4
4
|
import { n as b } from "./chevron-down--LwXEv9w.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { _ as e, h as t, t as n } from "./PageTitle-
|
|
1
|
+
import { _ as e, h as t, t as n } from "./PageTitle-CkZriz8K.js";
|
|
2
2
|
import { At as r, Dt as i, Ot as a, S as o, _ as s, a as c, b as l, g as u, h as d, li as f, m as p, nt as m, o as h, s as g, ui as _, v } from "./TimeZoneField-oIMwb5_X.js";
|
|
3
|
-
import { t as y } from "./DashboardNav-
|
|
3
|
+
import { t as y } from "./DashboardNav-CxS3Qnl-.js";
|
|
4
4
|
import { a as ee } from "./Trouble-CtFq7tjk.js";
|
|
5
5
|
import { n as b } from "./chevron-down--LwXEv9w.js";
|
|
6
6
|
import { t as x } from "./arrow-right-C6OLl8Zh.js";
|
|
7
7
|
import { n as S, t as C } from "./mail-check-DlwCj48-.js";
|
|
8
|
-
import { t as w } from "./SupportBar-
|
|
8
|
+
import { t as w } from "./SupportBar-0nIiQp-_.js";
|
|
9
9
|
import { r as T } from "./x-hax8aKt8.js";
|
|
10
10
|
import { t as E } from "./plus-BKrt0Qx5.js";
|
|
11
11
|
import { t as te } from "./power-BrOGO3tj.js";
|
|
@@ -13,7 +13,7 @@ import { t as D } from "./send-D-Vm6vU4.js";
|
|
|
13
13
|
import { n as O, r as k, t as A } from "./serviceSwitches-CZHwvVfP.js";
|
|
14
14
|
import { n as ne } from "./serviceStatus-C9izcuQz.js";
|
|
15
15
|
import { t as j } from "./ownerMail-DepG5-Qw.js";
|
|
16
|
-
import { ConnectCard as M, EmailSetupSteps as N } from "./SetupPayments-
|
|
16
|
+
import { ConnectCard as M, EmailSetupSteps as N } from "./SetupPayments-ICqCoZeQ.js";
|
|
17
17
|
import { useCallback as P, useEffect as F, useRef as re, useState as I } from "react";
|
|
18
18
|
import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
|
|
19
19
|
import { doc as B, onSnapshot as V, setDoc as H } from "firebase/firestore";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./chunk-CiTBaPhY.cjs`);const e=require(`./PageTitle-DQkvCB11.cjs`),t=require(`./TimeZoneField-Ckn1pKAL.cjs`),n=require(`./DashboardNav-GgEUpyTa.cjs`),r=require(`./Trouble-KQZyf6aY.cjs`),i=require(`./chevron-down-lyDK1rfL.cjs`),a=require(`./arrow-right-CGvbxks5.cjs`),o=require(`./mail-check-D_LNQw3l.cjs`),s=require(`./SupportBar-DLWruzQb.cjs`),c=require(`./x-Ci8c5p6T.cjs`),l=require(`./plus-zsWFCu4F.cjs`),u=require(`./power-Bs_nchQG.cjs`),d=require(`./send-CWJXtO05.cjs`),f=require(`./serviceSwitches-mhJbQBrV.cjs`),p=require(`./serviceStatus-Cde96_OO.cjs`),m=require(`./ownerMail-BS9SjJ2u.cjs`),h=require(`./SetupPayments-CuFk9REC.cjs`);let g=require(`react`),_=require(`react/jsx-runtime`),v=require(`firebase/firestore`),y=require(`react-router-dom`);var b={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};b.node;var x=i.n(b),S={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};S.node;var C=i.n(S),w={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};w.node;var T=i.n(w),E={name:`receipt`,size:24,node:[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};E.node;var D=i.n(E),O={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};O.node;var k=i.n(O);function A({trailing:e,onSent:n}){let[r,i]=(0,g.useState)(`idle`),[a,o]=(0,g.useState)(``);return(0,_.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2.5 flex-wrap`,children:[(0,_.jsx)(t.o,{icon:x,busy:r===`sending`,onClick:async()=>{i(`sending`),o(``);try{let e=await t.li?.currentUser?.getIdToken().catch(()=>null),r=await fetch(`/api/email/test`,{method:`POST`,headers:{"Content-Type":`application/json`,...e?{Authorization:`Bearer ${e}`}:{}},body:`{}`}),a=await r.json().catch(()=>({}));r.ok&&a?.ok?(i(`sent`),o(String(a.message||`Sent. If it is not there within a minute, look in spam.`)),n?.(typeof a.from==`string`&&a.from.trim()?a.from:null)):(i(`failed`),o(String(a?.error||`That test could not be sent. Try again in a moment.`)))}catch{i(`failed`),o(`The server could not be reached. Try again in a moment.`)}},title:`Sends the test email to your own address`,children:`Send yourself a test email`}),e]}),r===`sent`&&(0,_.jsx)(t.h,{children:a}),r===`failed`&&(0,_.jsxs)(t.h,{tone:`error`,children:[`It did not send. `,a]})]})}var{collection:j,doc:M}=f.t.email;function N(){let[e,n]=(0,g.useState)({loading:!0,testedFrom:null});return(0,g.useEffect)(()=>(0,v.onSnapshot)((0,v.doc)(t.ui,j,M),e=>{let t=e.exists()?e.data()?.testedFrom:null;n({loading:!1,testedFrom:typeof t==`string`&&t.trim()?t:null})},()=>n({loading:!1,testedFrom:null})),[]),{loading:e.loading,testedFrom:e.testedFrom,mark:async e=>{if(e.trim()){n({loading:!1,testedFrom:e});try{await(0,v.setDoc)((0,v.doc)(t.ui,j,M),{testedFrom:e},{merge:!0})}catch(e){console.error(`Could not remember the test send`,e)}}}}}var P=1e4,F=30;function I(e){return e===`verified`?{state:`saved`,label:`Verified`}:e===`pending`?{state:`saving`,label:`Checking`}:e===`failed`||e===`partially_failed`||e===`temporary_failure`?{state:`error`,label:`Not verified yet`}:e===`partially_verified`?{state:`saving`,label:`Nearly there`}:{state:`off`,label:`Records to add`}}function L(e){return e===`verified`?{state:`saved`,label:`Found`}:e===`pending`?{state:`saving`,label:`Checking`}:e===`failed`||e===`temporary_failure`?{state:`error`,label:`Not found yet`}:null}var R=e=>e===`pending`||e===`partially_verified`;async function z(e,n={}){let r=await t.li?.currentUser?.getIdToken().catch(()=>null),i=await fetch(e,{method:n.method||`GET`,headers:{"Content-Type":`application/json`,...r?{Authorization:`Bearer ${r}`}:{}},...n.body===void 0?{}:{body:JSON.stringify(n.body)}}),a=await i.json().catch(()=>({}));return{ok:i.ok,body:a}}var{collection:B,doc:V}=f.t.email,H=e=>(0,v.setDoc)((0,v.doc)(t.ui,B,V),e,{merge:!0}),U=`The server could not be reached. Try again in a moment.`;function W({text:n,what:r}){let[i,a]=(0,g.useState)(!1);return(0,_.jsxs)(`button`,{type:`button`,title:`Copy the ${r}`,"aria-label":i?`Copied`:`Copy`,onClick:()=>{navigator.clipboard?.writeText(n),a(!0),setTimeout(()=>a(!1),2e3)},className:`${t.a} max-sm:w-8 max-sm:px-0 max-sm:gap-0 self-start`,children:[i?(0,_.jsx)(t.At,{className:`w-3.5 h-3.5 shrink-0 text-accent`}):(0,_.jsx)(e._,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`max-sm:hidden`,children:i?`Copied`:`Copy`})]})}function G({record:e}){let n=L(e.status);return(0,_.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-4 py-3.5 border-b border-[var(--panel-border)]/40 last:border-0 min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,_.jsx)(`span`,{className:`inline-flex items-center h-6 px-2 rounded-lg bg-accent/10 text-accent text-[11.5px] font-extrabold tracking-wide shrink-0`,children:e.type}),(0,_.jsx)(`span`,{className:`text-[12.5px] font-semibold text-foreground/60 truncate flex-1 min-w-0`,children:e.type===`MX`&&e.priority!==null?`Priority ${e.priority}`:e.record}),n&&(0,_.jsx)(t._,{state:n.state,label:n.label})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-2.5 gap-y-2.5`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,_.jsx)(`span`,{className:`text-[11.5px] font-semibold text-foreground/40`,children:`Name`}),(0,_.jsx)(`code`,{className:`text-[12.5px] font-semibold text-foreground break-all`,children:e.name}),(0,_.jsxs)(`span`,{className:t.s,children:[`In full, where your domain company asks for it:`,` `,(0,_.jsx)(`code`,{className:`break-all`,children:e.fullName})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,_.jsx)(W,{text:e.name,what:`name`}),(0,_.jsx)(W,{text:e.fullName,what:`name in full`})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,_.jsx)(`span`,{className:`text-[11.5px] font-semibold text-foreground/40`,children:`Value`}),(0,_.jsx)(`code`,{className:`text-[12px] text-foreground/80 break-all line-clamp-3`,children:e.value})]}),(0,_.jsx)(W,{text:e.value,what:`value`})]})]})}function K({keyState:e,from:n,onChanged:i,askEvery:a=P}){let[o,s]=(0,g.useState)(null),[c,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(``),[h,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(0),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(``),[D,O]=(0,g.useState)(``),k=(0,g.useRef)(!0);(0,g.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let A=(0,g.useCallback)(async()=>{try{let{ok:e,body:t}=await z(`/api/email/domain`);if(!k.current)return;e?s(t?.domain||null):v(String(t?.error||U))}catch{k.current&&v(U)}finally{k.current&&u(!0)}},[]);(0,g.useEffect)(()=>{e===`works`?A():u(!0)},[e,A]);let j=o?.status||``,M=j===`verified`;(0,g.useEffect)(()=>{if(!R(j)||x>=F)return;let e=setTimeout(()=>{S(e=>e+1),A()},a);return()=>clearTimeout(e)},[j,x,A,a]);let N=(0,g.useRef)(null);(0,g.useEffect)(()=>{c&&(N.current===!1&&M&&i(),N.current=M)},[M,c,i]);let L=async()=>{m(`add`),v(``),b(!1);try{let{ok:e,body:t}=await z(`/api/email/domain`,{method:`POST`,body:{domain:d}});if(!e||!t?.domain){v(String(t?.error||U)),b(t?.cause===`taken`||t?.cause===`other`||t?.cause===`sending-only`);return}await H({domain:t.domain.name}),s(t.domain),S(0),i()}catch{v(`Your domain could not be saved. Check that you are signed in as an admin.`)}finally{m(``)}},B=async()=>{m(`verify`),v(``);try{let{ok:e,body:t}=await z(`/api/email/domain/verify`,{method:`POST`});!e||!t?.domain?v(String(t?.error||U)):(s(t.domain),S(0))}catch{v(U)}finally{m(``)}},V=async()=>{m(`other`),v(``),b(!1);try{await H({domain:``}),s(null),f(``),S(0),i()}catch{v(`Your domain could not be changed. Check that you are signed in as an admin.`)}finally{m(``)}},W=async e=>{m(`from`),v(``);try{await H({from:e}),w(!1),i()}catch{v(`The address could not be saved. Check that you are signed in as an admin.`)}finally{m(``)}};if(e===`sending-only`)return(0,_.jsxs)(t.m,{icon:t.Dt,title:`Your domain`,description:`Your key can only send email.`,actions:(0,_.jsx)(t._,{state:`off`,label:`Needs Full access`}),children:[(0,_.jsxs)(t.h,{children:[`Your key was made with sending access only, so your app cannot add your domain for you. Either make a new key in Resend with `,(0,_.jsx)(`strong`,{children:`Full access`}),` and paste it as RESEND_KEY, or add your domain on Resend’s own Domains page and type the address your mail should go out as here.`]}),(0,_.jsxs)(`a`,{href:`https://resend.com/domains`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 px-1 text-[12px] font-bold text-accent hover:underline w-fit`,children:[`Open Domains in Resend`,(0,_.jsx)(t.Ot,{className:`w-3 h-3`})]}),(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-end gap-2.5`,children:[(0,_.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,_.jsx)(t.b,{label:`The address your mail goes out as`,value:D,onChange:O,placeholder:`hello@yourbusiness.com`,hint:`It has to be at a domain Resend shows as verified.`})}),(0,_.jsx)(t.o,{icon:t.At,busy:p===`from`,disabled:!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(D.trim()),onClick:()=>W(D.trim()),className:`sm:mb-[1.35rem]`,children:`Save`})]}),h&&(0,_.jsx)(t.h,{tone:`error`,children:h})]});if(e!==`works`)return null;let K=o?I(j):{state:`off`,label:`Not added yet`},q=j===`failed`||j===`partially_failed`||j===`temporary_failure`,J=R(j)&&x>=F;return(0,_.jsxs)(t.m,{icon:t.Dt,title:`Your domain`,description:o?M?`${o.name} is verified. Your email reaches anybody.`:`Three records to add where you bought ${o.name}.`:`Until it is verified, email reaches only you.`,actions:(0,_.jsx)(`span`,{className:`max-sm:hidden`,children:c?(0,_.jsx)(t._,{state:K.state,label:K.label}):(0,_.jsx)(t._,{state:`saving`,label:`Checking`})}),defaultOpen:!0,children:[c?o?M?(0,_.jsxs)(_.Fragment,{children:[C?(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-end gap-2.5`,children:[(0,_.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,_.jsx)(t.b,{label:`Your mail goes out as`,value:T,onChange:e=>E(e.replace(/[\s@]/g,``)),placeholder:`hello`,hint:`Then @${o.name}`})}),(0,_.jsx)(t.o,{icon:t.At,busy:p===`from`,disabled:!T.trim(),onClick:()=>W(`${T.trim().toLowerCase()}@${o.name}`),className:`sm:mb-[1.35rem]`,children:`Save`})]}):(0,_.jsxs)(`p`,{className:`px-1 text-[13px] text-foreground/70`,children:[`Your mail goes out as `,(0,_.jsx)(`span`,{className:`font-bold text-foreground`,children:n||`hello@${o.name}`}),`.`,` `,(0,_.jsx)(`button`,{type:`button`,onClick:()=>{E(String(n||``).split(`@`)[0]||`hello`),w(!0)},className:`text-accent font-bold hover:underline cursor-pointer`,children:`Change`})]}),(0,_.jsxs)(`details`,{className:`px-1`,children:[(0,_.jsx)(`summary`,{className:`text-[12px] font-semibold text-foreground/45 hover:text-accent cursor-pointer select-none`,children:`The records that verified it`}),(0,_.jsx)(`div`,{className:`mt-3 glass-panel border border-[var(--panel-border)] rounded-2xl overflow-hidden bg-background`,children:o.records.map(e=>(0,_.jsx)(G,{record:e},`${e.type}:${e.fullName}`))})]})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(t.h,{children:[`Add these `,o.records.length===3?`three`:o.records.length,` records where you bought`,` `,o.name,`, in its DNS settings. They sit beside what is there already and do not change where your own email arrives. Copy each one exactly.`]}),(0,_.jsx)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-2xl overflow-hidden bg-background`,children:o.records.map(e=>(0,_.jsx)(G,{record:e},`${e.type}:${e.fullName}`))}),q||J?(0,_.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,_.jsx)(t.h,{children:`Resend could not find every record yet. A new record can take from a few minutes to a few hours to show. Check each one above was copied exactly, then check again.`}),(0,_.jsx)(t.o,{icon:r.a,busy:p===`verify`,onClick:B,className:`self-start`,children:`Check again`})]}):R(j)?(0,_.jsx)(t.h,{children:`Resend is checking your records. This screen shows the answer when it comes.`}):(0,_.jsx)(t.o,{icon:t.At,busy:p===`verify`,onClick:B,className:`self-start`,children:`I have added them`}),(0,_.jsxs)(`p`,{className:`px-1 text-[12px] text-foreground/45`,children:[`Not the right domain?`,` `,(0,_.jsx)(`button`,{type:`button`,onClick:V,disabled:!!p,className:`text-accent font-bold hover:underline cursor-pointer disabled:opacity-50`,children:`Use a different domain`})]})]}):(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-end gap-2.5`,children:[(0,_.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,_.jsx)(t.b,{label:`Your domain`,value:d,onChange:f,placeholder:`yourbusiness.com`,hint:`The part after www. No domain yet? Buy one from any domain company, then come back.`})}),(0,_.jsx)(t.o,{icon:l.t,busy:p===`add`,disabled:!d.trim(),onClick:L,className:`sm:mb-[1.35rem]`,children:`Add`})]})}):null,h&&(0,_.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,_.jsx)(t.h,{tone:`error`,children:h}),y&&(0,_.jsxs)(`a`,{href:`https://resend.com/domains`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 px-1 text-[12px] font-bold text-accent hover:underline w-fit`,children:[`Open Domains in Resend`,(0,_.jsx)(t.Ot,{className:`w-3 h-3`})]})]})]})}var q=e=>[{title:`Receipts and sale alerts`,body:`Each payment emails the buyer a receipt and tells you what sold.`,icon:D,where:{label:`Payment emails, above`}},{title:`Hear about each form entry`,body:`Someone sends a form on one of your pages, and it comes to you by email.`,icon:o.n,where:{path:`/pages`,label:`Pages screen`}},{title:`Confirm to the people who write in`,body:`Whoever sends a form gets a note that it arrived, with your words in it.`,icon:o.t,where:{path:`/pages`,label:`Pages screen`}},{title:`Notifications by email`,body:`A page that rings the bell can send the same news by email.`,icon:C,where:{path:`/pages`,label:`Pages screen`}},{title:`Write to anyone from your app`,body:`A page for your team can write to any address, from ${e}.`,icon:d.t,where:{path:`/pages`,label:`Pages screen`}}],J=e=>e?{description:`Every page you told to send email does. Switch it off to stop all of it at once.`,chip:{state:`saved`,label:`On`}}:{description:`Nothing sends. Your pages keep their settings and wait for this to come back on.`,chip:{state:`off`,label:`Off`}},Y=5e3,X=e=>{let t=new Date(e),n=t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return t.toDateString()===new Date().toDateString()?n:`${t.toLocaleDateString([],{day:`numeric`,month:`short`})}, ${n}`};function Z({from:e}){return(0,_.jsx)(`div`,{className:`flex flex-col divide-y divide-[var(--panel-border)]/60 rounded-2xl border border-[var(--panel-border)]/60`,children:q(e).map(e=>{let t=e.icon,n=`max-sm:hidden sm:inline-flex row-start-1 row-span-2 col-start-3 self-center justify-self-end items-center gap-1.5 text-[11.5px] font-semibold text-foreground/45 whitespace-nowrap`;return(0,_.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)] sm:grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 sm:gap-x-3.5 gap-y-0.5 px-4 py-3`,children:[(0,_.jsx)(`div`,{className:`row-start-1 row-span-2 col-start-1 self-center w-9 h-9 rounded-xl flex items-center justify-center shrink-0 border border-[var(--panel-border)]/50 bg-accent/10 text-accent`,children:(0,_.jsx)(t,{className:`w-4 h-4`})}),(0,_.jsx)(`span`,{className:`row-start-1 col-start-2 min-w-0 text-[13px] font-bold text-foreground leading-tight self-end`,children:e.title}),(0,_.jsx)(`span`,{className:`row-start-2 col-start-2 min-w-0 text-[12px] text-foreground/50 font-normal leading-snug self-start`,children:e.body}),e.where.path?(0,_.jsxs)(y.Link,{to:e.where.path,className:`${n} hover:text-accent transition-colors`,children:[e.where.label,(0,_.jsx)(a.t,{className:`w-3 h-3`})]}):(0,_.jsx)(`span`,{className:n,children:e.where.label})]},e.title)})})}function Q(){return(0,_.jsx)(t.m,{icon:e.h,title:`Waiting for your app`,description:`Asking again every few seconds.`,actions:(0,_.jsx)(t._,{state:`saving`,label:`Checking`}),collapsible:!1,children:(0,_.jsx)(t.h,{children:`Your app’s server is not answering yet. After you press Apply in AI Studio it starts again, which takes a few seconds. This screen asks again on its own and fills in the moment it answers.`})})}function $({refusal:e}){return(0,_.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)]/60 bg-foreground/[0.02] px-4 py-3 flex flex-col gap-1`,children:[(0,_.jsxs)(`span`,{className:`text-[12.5px] font-bold text-foreground/80`,children:[`The last email that could not go: to `,e.to,`, `,X(e.at)]}),(0,_.jsx)(`span`,{className:`text-[12.5px] text-foreground/60 leading-relaxed`,children:e.reason})]})}function ee({status:e,owner:n,ownerError:r,choose:i}){let a=N(),s=n?.count??e.ownerCount,c=!e.senderVerified;return(0,_.jsxs)(t.m,{icon:o.t,title:`Your mail`,description:n?.me?`Sales and form alerts come to ${n.me}.`:s?`Where sales and form alerts go.`:`Sales and form alerts have nowhere to go yet.`,actions:(0,_.jsx)(`span`,{className:`max-sm:hidden`,children:(0,_.jsx)(t._,{state:s?`saved`:`off`,label:s?`Reaches ${s} address${s===1?``:`es`}`:`Nowhere yet`})}),children:[c&&(0,_.jsxs)(t.h,{children:[(0,_.jsx)(`span`,{className:`font-bold text-foreground/70`,children:`Right now your email reaches only you.`}),` It goes out from Resend’s practice address, `,e.from,`, which delivers only to the address you made your Resend account with: a test to yourself arrives when that is the address you sign in with here, your admins get nothing yet, and neither does a customer. Verify your domain above to reach anybody.`]}),(0,_.jsx)(t.g,{label:`Who hears about sales and form entries`,value:n?.who??`admins`,onChange:e=>i(e===`me`?`me`:`admins`),options:[{value:`admins`,label:`Me and all my admins`},{value:`me`,label:`Only me`}],allowEmpty:!1,hint:`Your admins are found for you: nobody has to type an address. When a customer presses Reply, it comes to you.`}),n&&!n.me&&(0,_.jsx)(t.h,{children:`Your account has no email address, so only your admins hear. Add one to your profile to hear too.`}),r&&(0,_.jsx)(t.h,{tone:`error`,children:r}),(0,_.jsx)(A,{onSent:e=>{e&&a.mark(e)},trailing:(0,_.jsxs)(`a`,{href:`https://resend.com/emails`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-[12px] font-bold text-accent hover:underline`,children:[`See everything sent, in Resend`,(0,_.jsx)(t.Ot,{className:`w-3 h-3`})]})}),e.lastRefusal&&(0,_.jsx)($,{refusal:e.lastRefusal})]})}function te({status:e,sending:n,ownerCount:r}){let i=f.n(),[a,o]=(0,g.useState)(``),s=async(e,t)=>o(await i.set(e,t)||``),c=n?e.senderVerified?``:`Customers get these once your domain is verified.`:`Email is switched off above.`,l=n?r?``:`Your own mail has nowhere to go yet.`:`Email is switched off above.`;return(0,_.jsxs)(t.m,{icon:D,title:`Payment emails`,description:`For every payment in your app, one pair of switches.`,children:[(0,_.jsx)(t.S,{label:`Email buyers a receipt`,hint:c||`In your app’s look, with what they bought and a link to Stripe’s own receipt.`,enabled:i.receipts,onChange:e=>s(`receipts`,e),disabled:i.loading||!!c}),(0,_.jsx)(t.S,{label:`Email me each sale`,hint:l||`What sold and who bought it, with a button to your Transactions.`,enabled:i.saleAlerts,onChange:e=>s(`saleAlerts`,e),disabled:i.loading||!!l}),a&&(0,_.jsx)(t.h,{tone:`error`,children:a})]})}function ne(){let{status:r,error:i,reread:o}=p.n(0,!0),l=f.r(`email`),[d,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(null),[E,D]=(0,g.useState)(``);(0,g.useEffect)(()=>{if(!i)return;let e=setInterval(()=>{o()},Y);return()=>clearInterval(e)},[i,o]);let O=!!i&&!r?.configured,A=()=>{b(!1),o().then(()=>S(!0))},j=!!r?.configured&&r?.key!==`refused`;(0,g.useEffect)(()=>{if(!j)return;let e=!0;return m.t().then(({state:t,error:n})=>{e&&(t&&w(t),D(n||``))}),()=>{e=!1}},[j]);let M=(0,g.useCallback)(async e=>{w(t=>t&&{...t,who:e});let{state:t,error:n}=await m.t(e);t&&w(t),D(n||``)},[]),N=(0,g.useCallback)(()=>{o()},[o]),P=J(l.on);return(0,_.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,_.jsxs)(t.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6`,children:[(0,_.jsx)(e.t,{children:`Email`}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,_.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/email`]})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,_.jsx)(n.t,{}),(0,_.jsx)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-3xl p-4 sm:p-5 md:p-8 shadow-2xl relative bg-background flex flex-col fbos-tab-fill min-h-[600px]`,children:!r||O?O?(0,_.jsx)(Q,{}):(0,_.jsx)(`div`,{className:`flex items-center justify-center flex-1 text-foreground/40 py-16`,children:(0,_.jsx)(c.r,{className:`w-6 h-6 animate-spin text-accent`})}):r.configured?(0,_.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,_.jsx)(t.v,{icon:u.t,title:`Send email`,description:P.description,chip:P.chip,enabled:l.loading?null:l.on,onChange:async e=>v(await l.set(e)||``),children:d?(0,_.jsx)(t.h,{tone:`error`,children:d}):null}),r.key===`refused`?(0,_.jsxs)(t.m,{icon:T,title:`Your key`,description:`Resend did not accept it.`,actions:(0,_.jsx)(t._,{state:`error`,label:`Key refused`}),collapsible:!1,children:[(0,_.jsx)(t.h,{children:`Resend did not accept the key in RESEND_KEY: it was mistyped, deleted in Resend, or made for another account. Make a new one with Full access and paste it in its place.`}),y?(0,_.jsx)(h.EmailSetupSteps,{onConfirm:A}):(0,_.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),className:`inline-flex items-center gap-1.5 w-fit h-9 px-4 rounded-[var(--btn-radius,0.75rem)] text-[12.5px] font-bold border border-accent/40 bg-accent/10 text-accent hover:bg-accent/15 transition-all active:scale-[0.98] cursor-pointer`,children:[`Show me how`,(0,_.jsx)(a.t,{className:`w-3.5 h-3.5`})]})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(K,{keyState:r.key,from:r.from,onChanged:N}),(0,_.jsx)(ee,{status:r,owner:C,ownerError:E,choose:M}),(0,_.jsx)(te,{status:r,sending:l.on,ownerCount:C?.count??r.ownerCount}),(0,_.jsx)(t.m,{icon:k,title:`What you can do with email`,description:`Payment emails are switched on here; form emails and notifications on each page’s row.`,children:(0,_.jsx)(Z,{from:r.from||``})})]})]}):(0,_.jsx)(h.ConnectCard,{icon:e.h,title:`Connect email`,description:`This app is not sending email yet.`,stepsDescription:`Two steps: a Resend account with its key, then that one key pasted.`,button:`Set up email`,secret:`RESEND_KEY`,open:y,onOpen:()=>b(!0),confirmed:x,steps:(0,_.jsx)(h.EmailSetupSteps,{onConfirm:A}),children:(0,_.jsx)(t.h,{children:`Email runs through Resend, and connecting it is one pasted key, the way payments are. Then you add your domain right here, and this screen fills itself: who your email reaches, and where your own mail goes.`})})})]}),(0,_.jsx)(s.t,{})]})}exports.EmailAdmin=ne;
|
|
1
|
+
require(`./chunk-CiTBaPhY.cjs`);const e=require(`./PageTitle-BL50s4qY.cjs`),t=require(`./TimeZoneField-Ckn1pKAL.cjs`),n=require(`./DashboardNav-Bc619nqn.cjs`),r=require(`./Trouble-KQZyf6aY.cjs`),i=require(`./chevron-down-lyDK1rfL.cjs`),a=require(`./arrow-right-CGvbxks5.cjs`),o=require(`./mail-check-D_LNQw3l.cjs`),s=require(`./SupportBar-DR52UpBq.cjs`),c=require(`./x-Ci8c5p6T.cjs`),l=require(`./plus-zsWFCu4F.cjs`),u=require(`./power-Bs_nchQG.cjs`),d=require(`./send-CWJXtO05.cjs`),f=require(`./serviceSwitches-mhJbQBrV.cjs`),p=require(`./serviceStatus-Cde96_OO.cjs`),m=require(`./ownerMail-BS9SjJ2u.cjs`),h=require(`./SetupPayments-BLq0W5DU.cjs`);let g=require(`react`),_=require(`react/jsx-runtime`),v=require(`firebase/firestore`),y=require(`react-router-dom`);var b={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};b.node;var x=i.n(b),S={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};S.node;var C=i.n(S),w={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};w.node;var T=i.n(w),E={name:`receipt`,size:24,node:[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};E.node;var D=i.n(E),O={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};O.node;var k=i.n(O);function A({trailing:e,onSent:n}){let[r,i]=(0,g.useState)(`idle`),[a,o]=(0,g.useState)(``);return(0,_.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2.5 flex-wrap`,children:[(0,_.jsx)(t.o,{icon:x,busy:r===`sending`,onClick:async()=>{i(`sending`),o(``);try{let e=await t.li?.currentUser?.getIdToken().catch(()=>null),r=await fetch(`/api/email/test`,{method:`POST`,headers:{"Content-Type":`application/json`,...e?{Authorization:`Bearer ${e}`}:{}},body:`{}`}),a=await r.json().catch(()=>({}));r.ok&&a?.ok?(i(`sent`),o(String(a.message||`Sent. If it is not there within a minute, look in spam.`)),n?.(typeof a.from==`string`&&a.from.trim()?a.from:null)):(i(`failed`),o(String(a?.error||`That test could not be sent. Try again in a moment.`)))}catch{i(`failed`),o(`The server could not be reached. Try again in a moment.`)}},title:`Sends the test email to your own address`,children:`Send yourself a test email`}),e]}),r===`sent`&&(0,_.jsx)(t.h,{children:a}),r===`failed`&&(0,_.jsxs)(t.h,{tone:`error`,children:[`It did not send. `,a]})]})}var{collection:j,doc:M}=f.t.email;function N(){let[e,n]=(0,g.useState)({loading:!0,testedFrom:null});return(0,g.useEffect)(()=>(0,v.onSnapshot)((0,v.doc)(t.ui,j,M),e=>{let t=e.exists()?e.data()?.testedFrom:null;n({loading:!1,testedFrom:typeof t==`string`&&t.trim()?t:null})},()=>n({loading:!1,testedFrom:null})),[]),{loading:e.loading,testedFrom:e.testedFrom,mark:async e=>{if(e.trim()){n({loading:!1,testedFrom:e});try{await(0,v.setDoc)((0,v.doc)(t.ui,j,M),{testedFrom:e},{merge:!0})}catch(e){console.error(`Could not remember the test send`,e)}}}}}var P=1e4,F=30;function I(e){return e===`verified`?{state:`saved`,label:`Verified`}:e===`pending`?{state:`saving`,label:`Checking`}:e===`failed`||e===`partially_failed`||e===`temporary_failure`?{state:`error`,label:`Not verified yet`}:e===`partially_verified`?{state:`saving`,label:`Nearly there`}:{state:`off`,label:`Records to add`}}function L(e){return e===`verified`?{state:`saved`,label:`Found`}:e===`pending`?{state:`saving`,label:`Checking`}:e===`failed`||e===`temporary_failure`?{state:`error`,label:`Not found yet`}:null}var R=e=>e===`pending`||e===`partially_verified`;async function z(e,n={}){let r=await t.li?.currentUser?.getIdToken().catch(()=>null),i=await fetch(e,{method:n.method||`GET`,headers:{"Content-Type":`application/json`,...r?{Authorization:`Bearer ${r}`}:{}},...n.body===void 0?{}:{body:JSON.stringify(n.body)}}),a=await i.json().catch(()=>({}));return{ok:i.ok,body:a}}var{collection:B,doc:V}=f.t.email,H=e=>(0,v.setDoc)((0,v.doc)(t.ui,B,V),e,{merge:!0}),U=`The server could not be reached. Try again in a moment.`;function W({text:n,what:r}){let[i,a]=(0,g.useState)(!1);return(0,_.jsxs)(`button`,{type:`button`,title:`Copy the ${r}`,"aria-label":i?`Copied`:`Copy`,onClick:()=>{navigator.clipboard?.writeText(n),a(!0),setTimeout(()=>a(!1),2e3)},className:`${t.a} max-sm:w-8 max-sm:px-0 max-sm:gap-0 self-start`,children:[i?(0,_.jsx)(t.At,{className:`w-3.5 h-3.5 shrink-0 text-accent`}):(0,_.jsx)(e._,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`max-sm:hidden`,children:i?`Copied`:`Copy`})]})}function G({record:e}){let n=L(e.status);return(0,_.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-4 py-3.5 border-b border-[var(--panel-border)]/40 last:border-0 min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,_.jsx)(`span`,{className:`inline-flex items-center h-6 px-2 rounded-lg bg-accent/10 text-accent text-[11.5px] font-extrabold tracking-wide shrink-0`,children:e.type}),(0,_.jsx)(`span`,{className:`text-[12.5px] font-semibold text-foreground/60 truncate flex-1 min-w-0`,children:e.type===`MX`&&e.priority!==null?`Priority ${e.priority}`:e.record}),n&&(0,_.jsx)(t._,{state:n.state,label:n.label})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-2.5 gap-y-2.5`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,_.jsx)(`span`,{className:`text-[11.5px] font-semibold text-foreground/40`,children:`Name`}),(0,_.jsx)(`code`,{className:`text-[12.5px] font-semibold text-foreground break-all`,children:e.name}),(0,_.jsxs)(`span`,{className:t.s,children:[`In full, where your domain company asks for it:`,` `,(0,_.jsx)(`code`,{className:`break-all`,children:e.fullName})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,_.jsx)(W,{text:e.name,what:`name`}),(0,_.jsx)(W,{text:e.fullName,what:`name in full`})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,_.jsx)(`span`,{className:`text-[11.5px] font-semibold text-foreground/40`,children:`Value`}),(0,_.jsx)(`code`,{className:`text-[12px] text-foreground/80 break-all line-clamp-3`,children:e.value})]}),(0,_.jsx)(W,{text:e.value,what:`value`})]})]})}function K({keyState:e,from:n,onChanged:i,askEvery:a=P}){let[o,s]=(0,g.useState)(null),[c,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(``),[h,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(0),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(``),[D,O]=(0,g.useState)(``),k=(0,g.useRef)(!0);(0,g.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let A=(0,g.useCallback)(async()=>{try{let{ok:e,body:t}=await z(`/api/email/domain`);if(!k.current)return;e?s(t?.domain||null):v(String(t?.error||U))}catch{k.current&&v(U)}finally{k.current&&u(!0)}},[]);(0,g.useEffect)(()=>{e===`works`?A():u(!0)},[e,A]);let j=o?.status||``,M=j===`verified`;(0,g.useEffect)(()=>{if(!R(j)||x>=F)return;let e=setTimeout(()=>{S(e=>e+1),A()},a);return()=>clearTimeout(e)},[j,x,A,a]);let N=(0,g.useRef)(null);(0,g.useEffect)(()=>{c&&(N.current===!1&&M&&i(),N.current=M)},[M,c,i]);let L=async()=>{m(`add`),v(``),b(!1);try{let{ok:e,body:t}=await z(`/api/email/domain`,{method:`POST`,body:{domain:d}});if(!e||!t?.domain){v(String(t?.error||U)),b(t?.cause===`taken`||t?.cause===`other`||t?.cause===`sending-only`);return}await H({domain:t.domain.name}),s(t.domain),S(0),i()}catch{v(`Your domain could not be saved. Check that you are signed in as an admin.`)}finally{m(``)}},B=async()=>{m(`verify`),v(``);try{let{ok:e,body:t}=await z(`/api/email/domain/verify`,{method:`POST`});!e||!t?.domain?v(String(t?.error||U)):(s(t.domain),S(0))}catch{v(U)}finally{m(``)}},V=async()=>{m(`other`),v(``),b(!1);try{await H({domain:``}),s(null),f(``),S(0),i()}catch{v(`Your domain could not be changed. Check that you are signed in as an admin.`)}finally{m(``)}},W=async e=>{m(`from`),v(``);try{await H({from:e}),w(!1),i()}catch{v(`The address could not be saved. Check that you are signed in as an admin.`)}finally{m(``)}};if(e===`sending-only`)return(0,_.jsxs)(t.m,{icon:t.Dt,title:`Your domain`,description:`Your key can only send email.`,actions:(0,_.jsx)(t._,{state:`off`,label:`Needs Full access`}),children:[(0,_.jsxs)(t.h,{children:[`Your key was made with sending access only, so your app cannot add your domain for you. Either make a new key in Resend with `,(0,_.jsx)(`strong`,{children:`Full access`}),` and paste it as RESEND_KEY, or add your domain on Resend’s own Domains page and type the address your mail should go out as here.`]}),(0,_.jsxs)(`a`,{href:`https://resend.com/domains`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 px-1 text-[12px] font-bold text-accent hover:underline w-fit`,children:[`Open Domains in Resend`,(0,_.jsx)(t.Ot,{className:`w-3 h-3`})]}),(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-end gap-2.5`,children:[(0,_.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,_.jsx)(t.b,{label:`The address your mail goes out as`,value:D,onChange:O,placeholder:`hello@yourbusiness.com`,hint:`It has to be at a domain Resend shows as verified.`})}),(0,_.jsx)(t.o,{icon:t.At,busy:p===`from`,disabled:!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(D.trim()),onClick:()=>W(D.trim()),className:`sm:mb-[1.35rem]`,children:`Save`})]}),h&&(0,_.jsx)(t.h,{tone:`error`,children:h})]});if(e!==`works`)return null;let K=o?I(j):{state:`off`,label:`Not added yet`},q=j===`failed`||j===`partially_failed`||j===`temporary_failure`,J=R(j)&&x>=F;return(0,_.jsxs)(t.m,{icon:t.Dt,title:`Your domain`,description:o?M?`${o.name} is verified. Your email reaches anybody.`:`Three records to add where you bought ${o.name}.`:`Until it is verified, email reaches only you.`,actions:(0,_.jsx)(`span`,{className:`max-sm:hidden`,children:c?(0,_.jsx)(t._,{state:K.state,label:K.label}):(0,_.jsx)(t._,{state:`saving`,label:`Checking`})}),defaultOpen:!0,children:[c?o?M?(0,_.jsxs)(_.Fragment,{children:[C?(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-end gap-2.5`,children:[(0,_.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,_.jsx)(t.b,{label:`Your mail goes out as`,value:T,onChange:e=>E(e.replace(/[\s@]/g,``)),placeholder:`hello`,hint:`Then @${o.name}`})}),(0,_.jsx)(t.o,{icon:t.At,busy:p===`from`,disabled:!T.trim(),onClick:()=>W(`${T.trim().toLowerCase()}@${o.name}`),className:`sm:mb-[1.35rem]`,children:`Save`})]}):(0,_.jsxs)(`p`,{className:`px-1 text-[13px] text-foreground/70`,children:[`Your mail goes out as `,(0,_.jsx)(`span`,{className:`font-bold text-foreground`,children:n||`hello@${o.name}`}),`.`,` `,(0,_.jsx)(`button`,{type:`button`,onClick:()=>{E(String(n||``).split(`@`)[0]||`hello`),w(!0)},className:`text-accent font-bold hover:underline cursor-pointer`,children:`Change`})]}),(0,_.jsxs)(`details`,{className:`px-1`,children:[(0,_.jsx)(`summary`,{className:`text-[12px] font-semibold text-foreground/45 hover:text-accent cursor-pointer select-none`,children:`The records that verified it`}),(0,_.jsx)(`div`,{className:`mt-3 glass-panel border border-[var(--panel-border)] rounded-2xl overflow-hidden bg-background`,children:o.records.map(e=>(0,_.jsx)(G,{record:e},`${e.type}:${e.fullName}`))})]})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(t.h,{children:[`Add these `,o.records.length===3?`three`:o.records.length,` records where you bought`,` `,o.name,`, in its DNS settings. They sit beside what is there already and do not change where your own email arrives. Copy each one exactly.`]}),(0,_.jsx)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-2xl overflow-hidden bg-background`,children:o.records.map(e=>(0,_.jsx)(G,{record:e},`${e.type}:${e.fullName}`))}),q||J?(0,_.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,_.jsx)(t.h,{children:`Resend could not find every record yet. A new record can take from a few minutes to a few hours to show. Check each one above was copied exactly, then check again.`}),(0,_.jsx)(t.o,{icon:r.a,busy:p===`verify`,onClick:B,className:`self-start`,children:`Check again`})]}):R(j)?(0,_.jsx)(t.h,{children:`Resend is checking your records. This screen shows the answer when it comes.`}):(0,_.jsx)(t.o,{icon:t.At,busy:p===`verify`,onClick:B,className:`self-start`,children:`I have added them`}),(0,_.jsxs)(`p`,{className:`px-1 text-[12px] text-foreground/45`,children:[`Not the right domain?`,` `,(0,_.jsx)(`button`,{type:`button`,onClick:V,disabled:!!p,className:`text-accent font-bold hover:underline cursor-pointer disabled:opacity-50`,children:`Use a different domain`})]})]}):(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-end gap-2.5`,children:[(0,_.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,_.jsx)(t.b,{label:`Your domain`,value:d,onChange:f,placeholder:`yourbusiness.com`,hint:`The part after www. No domain yet? Buy one from any domain company, then come back.`})}),(0,_.jsx)(t.o,{icon:l.t,busy:p===`add`,disabled:!d.trim(),onClick:L,className:`sm:mb-[1.35rem]`,children:`Add`})]})}):null,h&&(0,_.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,_.jsx)(t.h,{tone:`error`,children:h}),y&&(0,_.jsxs)(`a`,{href:`https://resend.com/domains`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 px-1 text-[12px] font-bold text-accent hover:underline w-fit`,children:[`Open Domains in Resend`,(0,_.jsx)(t.Ot,{className:`w-3 h-3`})]})]})]})}var q=e=>[{title:`Receipts and sale alerts`,body:`Each payment emails the buyer a receipt and tells you what sold.`,icon:D,where:{label:`Payment emails, above`}},{title:`Hear about each form entry`,body:`Someone sends a form on one of your pages, and it comes to you by email.`,icon:o.n,where:{path:`/pages`,label:`Pages screen`}},{title:`Confirm to the people who write in`,body:`Whoever sends a form gets a note that it arrived, with your words in it.`,icon:o.t,where:{path:`/pages`,label:`Pages screen`}},{title:`Notifications by email`,body:`A page that rings the bell can send the same news by email.`,icon:C,where:{path:`/pages`,label:`Pages screen`}},{title:`Write to anyone from your app`,body:`A page for your team can write to any address, from ${e}.`,icon:d.t,where:{path:`/pages`,label:`Pages screen`}}],J=e=>e?{description:`Every page you told to send email does. Switch it off to stop all of it at once.`,chip:{state:`saved`,label:`On`}}:{description:`Nothing sends. Your pages keep their settings and wait for this to come back on.`,chip:{state:`off`,label:`Off`}},Y=5e3,X=e=>{let t=new Date(e),n=t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return t.toDateString()===new Date().toDateString()?n:`${t.toLocaleDateString([],{day:`numeric`,month:`short`})}, ${n}`};function Z({from:e}){return(0,_.jsx)(`div`,{className:`flex flex-col divide-y divide-[var(--panel-border)]/60 rounded-2xl border border-[var(--panel-border)]/60`,children:q(e).map(e=>{let t=e.icon,n=`max-sm:hidden sm:inline-flex row-start-1 row-span-2 col-start-3 self-center justify-self-end items-center gap-1.5 text-[11.5px] font-semibold text-foreground/45 whitespace-nowrap`;return(0,_.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)] sm:grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 sm:gap-x-3.5 gap-y-0.5 px-4 py-3`,children:[(0,_.jsx)(`div`,{className:`row-start-1 row-span-2 col-start-1 self-center w-9 h-9 rounded-xl flex items-center justify-center shrink-0 border border-[var(--panel-border)]/50 bg-accent/10 text-accent`,children:(0,_.jsx)(t,{className:`w-4 h-4`})}),(0,_.jsx)(`span`,{className:`row-start-1 col-start-2 min-w-0 text-[13px] font-bold text-foreground leading-tight self-end`,children:e.title}),(0,_.jsx)(`span`,{className:`row-start-2 col-start-2 min-w-0 text-[12px] text-foreground/50 font-normal leading-snug self-start`,children:e.body}),e.where.path?(0,_.jsxs)(y.Link,{to:e.where.path,className:`${n} hover:text-accent transition-colors`,children:[e.where.label,(0,_.jsx)(a.t,{className:`w-3 h-3`})]}):(0,_.jsx)(`span`,{className:n,children:e.where.label})]},e.title)})})}function Q(){return(0,_.jsx)(t.m,{icon:e.h,title:`Waiting for your app`,description:`Asking again every few seconds.`,actions:(0,_.jsx)(t._,{state:`saving`,label:`Checking`}),collapsible:!1,children:(0,_.jsx)(t.h,{children:`Your app’s server is not answering yet. After you press Apply in AI Studio it starts again, which takes a few seconds. This screen asks again on its own and fills in the moment it answers.`})})}function $({refusal:e}){return(0,_.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)]/60 bg-foreground/[0.02] px-4 py-3 flex flex-col gap-1`,children:[(0,_.jsxs)(`span`,{className:`text-[12.5px] font-bold text-foreground/80`,children:[`The last email that could not go: to `,e.to,`, `,X(e.at)]}),(0,_.jsx)(`span`,{className:`text-[12.5px] text-foreground/60 leading-relaxed`,children:e.reason})]})}function ee({status:e,owner:n,ownerError:r,choose:i}){let a=N(),s=n?.count??e.ownerCount,c=!e.senderVerified;return(0,_.jsxs)(t.m,{icon:o.t,title:`Your mail`,description:n?.me?`Sales and form alerts come to ${n.me}.`:s?`Where sales and form alerts go.`:`Sales and form alerts have nowhere to go yet.`,actions:(0,_.jsx)(`span`,{className:`max-sm:hidden`,children:(0,_.jsx)(t._,{state:s?`saved`:`off`,label:s?`Reaches ${s} address${s===1?``:`es`}`:`Nowhere yet`})}),children:[c&&(0,_.jsxs)(t.h,{children:[(0,_.jsx)(`span`,{className:`font-bold text-foreground/70`,children:`Right now your email reaches only you.`}),` It goes out from Resend’s practice address, `,e.from,`, which delivers only to the address you made your Resend account with: a test to yourself arrives when that is the address you sign in with here, your admins get nothing yet, and neither does a customer. Verify your domain above to reach anybody.`]}),(0,_.jsx)(t.g,{label:`Who hears about sales and form entries`,value:n?.who??`admins`,onChange:e=>i(e===`me`?`me`:`admins`),options:[{value:`admins`,label:`Me and all my admins`},{value:`me`,label:`Only me`}],allowEmpty:!1,hint:`Your admins are found for you: nobody has to type an address. When a customer presses Reply, it comes to you.`}),n&&!n.me&&(0,_.jsx)(t.h,{children:`Your account has no email address, so only your admins hear. Add one to your profile to hear too.`}),r&&(0,_.jsx)(t.h,{tone:`error`,children:r}),(0,_.jsx)(A,{onSent:e=>{e&&a.mark(e)},trailing:(0,_.jsxs)(`a`,{href:`https://resend.com/emails`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-[12px] font-bold text-accent hover:underline`,children:[`See everything sent, in Resend`,(0,_.jsx)(t.Ot,{className:`w-3 h-3`})]})}),e.lastRefusal&&(0,_.jsx)($,{refusal:e.lastRefusal})]})}function te({status:e,sending:n,ownerCount:r}){let i=f.n(),[a,o]=(0,g.useState)(``),s=async(e,t)=>o(await i.set(e,t)||``),c=n?e.senderVerified?``:`Customers get these once your domain is verified.`:`Email is switched off above.`,l=n?r?``:`Your own mail has nowhere to go yet.`:`Email is switched off above.`;return(0,_.jsxs)(t.m,{icon:D,title:`Payment emails`,description:`For every payment in your app, one pair of switches.`,children:[(0,_.jsx)(t.S,{label:`Email buyers a receipt`,hint:c||`In your app’s look, with what they bought and a link to Stripe’s own receipt.`,enabled:i.receipts,onChange:e=>s(`receipts`,e),disabled:i.loading||!!c}),(0,_.jsx)(t.S,{label:`Email me each sale`,hint:l||`What sold and who bought it, with a button to your Transactions.`,enabled:i.saleAlerts,onChange:e=>s(`saleAlerts`,e),disabled:i.loading||!!l}),a&&(0,_.jsx)(t.h,{tone:`error`,children:a})]})}function ne(){let{status:r,error:i,reread:o}=p.n(0,!0),l=f.r(`email`),[d,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(null),[E,D]=(0,g.useState)(``);(0,g.useEffect)(()=>{if(!i)return;let e=setInterval(()=>{o()},Y);return()=>clearInterval(e)},[i,o]);let O=!!i&&!r?.configured,A=()=>{b(!1),o().then(()=>S(!0))},j=!!r?.configured&&r?.key!==`refused`;(0,g.useEffect)(()=>{if(!j)return;let e=!0;return m.t().then(({state:t,error:n})=>{e&&(t&&w(t),D(n||``))}),()=>{e=!1}},[j]);let M=(0,g.useCallback)(async e=>{w(t=>t&&{...t,who:e});let{state:t,error:n}=await m.t(e);t&&w(t),D(n||``)},[]),N=(0,g.useCallback)(()=>{o()},[o]),P=J(l.on);return(0,_.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,_.jsxs)(t.nt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6`,children:[(0,_.jsx)(e.t,{children:`Email`}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,_.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/email`]})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,_.jsx)(n.t,{}),(0,_.jsx)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-3xl p-4 sm:p-5 md:p-8 shadow-2xl relative bg-background flex flex-col fbos-tab-fill min-h-[600px]`,children:!r||O?O?(0,_.jsx)(Q,{}):(0,_.jsx)(`div`,{className:`flex items-center justify-center flex-1 text-foreground/40 py-16`,children:(0,_.jsx)(c.r,{className:`w-6 h-6 animate-spin text-accent`})}):r.configured?(0,_.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,_.jsx)(t.v,{icon:u.t,title:`Send email`,description:P.description,chip:P.chip,enabled:l.loading?null:l.on,onChange:async e=>v(await l.set(e)||``),children:d?(0,_.jsx)(t.h,{tone:`error`,children:d}):null}),r.key===`refused`?(0,_.jsxs)(t.m,{icon:T,title:`Your key`,description:`Resend did not accept it.`,actions:(0,_.jsx)(t._,{state:`error`,label:`Key refused`}),collapsible:!1,children:[(0,_.jsx)(t.h,{children:`Resend did not accept the key in RESEND_KEY: it was mistyped, deleted in Resend, or made for another account. Make a new one with Full access and paste it in its place.`}),y?(0,_.jsx)(h.EmailSetupSteps,{onConfirm:A}):(0,_.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),className:`inline-flex items-center gap-1.5 w-fit h-9 px-4 rounded-[var(--btn-radius,0.75rem)] text-[12.5px] font-bold border border-accent/40 bg-accent/10 text-accent hover:bg-accent/15 transition-all active:scale-[0.98] cursor-pointer`,children:[`Show me how`,(0,_.jsx)(a.t,{className:`w-3.5 h-3.5`})]})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(K,{keyState:r.key,from:r.from,onChanged:N}),(0,_.jsx)(ee,{status:r,owner:C,ownerError:E,choose:M}),(0,_.jsx)(te,{status:r,sending:l.on,ownerCount:C?.count??r.ownerCount}),(0,_.jsx)(t.m,{icon:k,title:`What you can do with email`,description:`Payment emails are switched on here; form emails and notifications on each page’s row.`,children:(0,_.jsx)(Z,{from:r.from||``})})]})]}):(0,_.jsx)(h.ConnectCard,{icon:e.h,title:`Connect email`,description:`This app is not sending email yet.`,stepsDescription:`Two steps: a Resend account with its key, then that one key pasted.`,button:`Set up email`,secret:`RESEND_KEY`,open:y,onOpen:()=>b(!0),confirmed:x,steps:(0,_.jsx)(h.EmailSetupSteps,{onConfirm:A}),children:(0,_.jsx)(t.h,{children:`Email runs through Resend, and connecting it is one pasted key, the way payments are. Then you add your domain right here, and this screen fills itself: who your email reaches, and where your own mail goes.`})})})]}),(0,_.jsx)(s.t,{})]})}exports.EmailAdmin=ne;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./chunk-CiTBaPhY.cjs`),require(`./PageTitle-
|
|
1
|
+
require(`./chunk-CiTBaPhY.cjs`),require(`./PageTitle-BL50s4qY.cjs`);const e=require(`./TimeZoneField-Ckn1pKAL.cjs`),t=require(`./schedule-BAea6q8_.cjs`),n=require(`./chevron-down-lyDK1rfL.cjs`);let r=require(`react/jsx-runtime`);var i={name:`calendar-x-2`,size:24,node:[[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`m17 16 5 5`,key:`1a37d9`}],[`path`,{d:`m17 21 5-5`,key:`1b797a`}],[`path`,{d:`M21 12V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h8`,key:`14ws7l`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}]]};i.node;var a=n.n(i),o=(e,n=`host`)=>e.heldOnly?`Held time`:n===`booker`?e.scheduleName.trim()||`A meeting`:t.it(e),s=(e,t=`host`)=>e.heldOnly?`Held with no booking behind it`:e.own?`Your own event`:t===`booker`?e.memberName.trim()?`With ${e.memberName.trim()}`:`Booked`:e.scheduleName||e.email||`Booked`,c=(e,n=`host`)=>n===`booker`&&!e.heldOnly?t.B(e):o(e,n),l=e=>!e.pending||e.cancelled||e.own||e.heldOnly?``:e.partySize>1?`${e.partyAccepted} of ${e.partySize}`:`Pending`;function u({value:e,onChange:n}){return(0,r.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:t.f.map(i=>{let a=i.value===e;return(0,r.jsx)(`button`,{type:`button`,title:i.label,"aria-label":i.label,"aria-pressed":a,onClick:()=>n(i.value),className:`w-8 h-8 rounded-full transition-all cursor-pointer active:scale-95 flex items-center justify-center ${i.value?`border-2`:`border-2 border-dashed`} ${a?`scale-105`:`hover:scale-105`}`,style:{background:t.at(i.value,a?55:30),borderColor:a?t.rt(i.value):t.at(i.value,40)},children:a&&(0,r.jsx)(`span`,{className:`w-2 h-2 rounded-full`,style:{background:t.rt(i.value)}})},i.value||`theme`)})})}function d({className:e=``}){return(0,r.jsx)(`span`,{className:`inline-flex items-center h-[18px] px-1.5 rounded-md shrink-0 border border-red-500/25 bg-red-500/10 text-[10px] font-bold uppercase tracking-[0.08em] text-red-500/90 ${e}`,children:`Cancelled`})}function f({label:e=`Pending`,className:t=``}){return(0,r.jsx)(`span`,{title:`Waiting to be accepted`,className:`inline-flex items-center h-[18px] px-1.5 rounded-md shrink-0 border border-amber-500/25 bg-amber-500/10 text-[10px] font-bold uppercase tracking-[0.08em] text-amber-600 dark:text-amber-400 ${t}`,children:e})}function p({className:e=``}){return(0,r.jsx)(`span`,{title:`Held with nothing booked`,className:`inline-flex items-center h-[18px] px-1.5 rounded-md shrink-0 border border-[var(--panel-border)] bg-foreground/[0.04] text-[10px] font-bold uppercase tracking-[0.08em] text-foreground/45 ${e}`,children:`Held`})}function m({booking:n,zone:i,chip:a,withMember:c=!1,side:u=`host`,onOpen:m,now:h}){let g=n.end<(h?h():new Date).toISOString(),_=n.cancelled,v=l(n),y=n.color;return(0,r.jsxs)(`button`,{type:`button`,onClick:m,"aria-label":`${t.st(new Date(n.start),i)} — ${o(n,u)}${_?` (cancelled)`:``}`,className:`group relative w-full text-left rounded-2xl border overflow-hidden flex items-stretch gap-2.5 p-2.5 transition-all cursor-pointer active:scale-[0.99] ${g&&!_?`opacity-60`:``} ${_||n.heldOnly?`border-dashed border-[var(--panel-border)]/60 bg-foreground/[0.02]`:``}`,style:_||n.heldOnly?void 0:{background:t.at(y,7),borderColor:t.at(y,26)},children:[(0,r.jsx)(`span`,{"aria-hidden":!0,className:`w-1 rounded-full shrink-0 ${_||n.heldOnly?`bg-foreground/15`:``}`,style:_||n.heldOnly?void 0:{background:t.at(y,85)}}),(0,r.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-0 bg-foreground/0 group-hover:bg-foreground/[0.04] transition-colors`}),(0,r.jsxs)(`span`,{className:`relative flex-1 min-w-0 flex flex-col gap-0.5 py-0.5`,children:[(0,r.jsxs)(`span`,{className:`flex items-baseline gap-2 min-w-0`,children:[(0,r.jsx)(`span`,{className:`text-[12.5px] font-bold tabular-nums shrink-0 ${_?`text-foreground/45 line-through`:`text-foreground`}`,children:t.st(new Date(n.start),i)}),(0,r.jsx)(`span`,{className:`text-[12.5px] font-semibold truncate ${_?`text-foreground/45 line-through`:`text-foreground/80`}`,children:o(n,u)})]}),(0,r.jsxs)(`span`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,r.jsx)(`span`,{className:`text-[11.5px] font-medium text-foreground/45 truncate`,children:c&&n.memberName?`${n.memberName} · ${s(n,u)}`:s(n,u)}),_?(0,r.jsx)(d,{}):n.heldOnly?(0,r.jsx)(p,{}):v?(0,r.jsx)(f,{label:v}):a&&(0,r.jsx)(e._,{state:a.state,label:a.label})]})]})]})}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return d}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./PageTitle-
|
|
1
|
+
import "./PageTitle-CkZriz8K.js";
|
|
2
2
|
import { _ as e } from "./TimeZoneField-oIMwb5_X.js";
|
|
3
3
|
import { B as t, at as n, f as r, it as i, rt as a, st as o } from "./schedule-C13m_kiO.js";
|
|
4
4
|
import { n as s } from "./chevron-down--LwXEv9w.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./chunk-CiTBaPhY.cjs`);const e=require(`./forms-CmNeTETW.cjs`),t=require(`./PageTitle-DQkvCB11.cjs`),n=require(`./TimeZoneField-Ckn1pKAL.cjs`),r=require(`./DashboardNav-GgEUpyTa.cjs`),i=require(`./schedule-BAea6q8_.cjs`),a=require(`./chevron-down-lyDK1rfL.cjs`),o=require(`./scheduleData-BXjNXVHY.cjs`),s=require(`./ContactPopup-D8aSSlmS.cjs`),c=require(`./SupportBar-DLWruzQb.cjs`),l=require(`./eye-DU2g57PD.cjs`),u=require(`./VideoPlayer-CggwpVXH.cjs`),d=require(`./x-Ci8c5p6T.cjs`),f=require(`./plus-zsWFCu4F.cjs`),ee=require(`./send-CWJXtO05.cjs`),p=require(`./trash-D-CpYHCs.cjs`),te=require(`./ConfirmModal-BUNtss4a.cjs`),ne=require(`./AccessNotice-BClqr7A9.cjs`),re=require(`./useIsPhone-CoiQVcCo.cjs`),m=require(`./SchedulePicker-CN0755Ek.cjs`);let h=require(`react`),g=require(`react/jsx-runtime`),_=require(`firebase/firestore`),ie=require(`react-router-dom`);var v={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};v.node;var ae=a.n(v),y={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};y.node;var oe=a.n(y),b=e=>String(e&&typeof e==`object`?e.label??e.value??``:e??``),x=(e,t)=>e&&typeof e==`object`?{...e,label:t}:t,S=new Set([`contact`,`support`]),C=[{value:`text`,label:`Short text`},{value:`textarea`,label:`Long text`},{value:`email`,label:`Email`},{value:`tel`,label:`Phone`},{value:`address`,label:`Address`},{value:`number`,label:`Number`},{value:`date`,label:`Date`},{value:`currency`,label:`Money`},{value:`checkbox`,label:`Yes-no`},{value:`select`,label:`Choose one`},{value:`file`,label:`File upload`}],w={value:`schedule`,label:`A time to book`},T={age:`Age`},E=e=>[...C,w].find(t=>t.value===e)?.label||T[e||``]||`Short text`,se=(e,t=!1)=>{let n=t||e===`schedule`?[...C,w]:C;return n.some(t=>t.value===e)||!e?n:[...n,{value:e,label:E(e)}]},ce=(e,t)=>{let n=i.en(e).map(e=>{let n=t.find(t=>t.id===e);return n?i.Vt(n):``}).filter(Boolean);return n.length?n.join(`, `):`nothing picked yet`},le={public:`Anyone`,private:`Signed-in users`},D=e=>(e||``).toLowerCase().trim().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``),O=(e,t)=>{if(!t.includes(e))return e;let n=2;for(;t.includes(`${e}_${n}`);)n++;return`${e}_${n}`},ue=(e,t,n)=>{if(!(!e.name||e.name===D(e.label||``)))return e.name;let r=D(t);return r?O(r,n.filter(t=>t!==e).map(e=>e.name)):``},k=()=>({name:``,type:`text`,label:``,placeholder:``,required:!1}),de={firstForm:`Forms are made with their pages — add a page on the Pages screen and pick A new form made for this page. Every form then shows up here.`};function A({choices:e,onChange:t}){return(0,g.jsx)(n.i,{label:`Choices`,hint:`The options people pick from.`,children:(0,g.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.length===0&&(0,g.jsx)(`span`,{className:`text-[12px] text-foreground/40 font-medium px-1`,children:`No choices yet — add the first one.`}),e.map((r,i)=>(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`input`,{type:`text`,value:b(r),"aria-label":`Choice ${i+1}`,placeholder:`e.g. Under 1,000`,onChange:n=>t(e.map((e,t)=>t===i?x(e,n.target.value):e)),className:n.c}),(0,g.jsx)(n.o,{icon:d.t,tone:`danger`,title:`Remove choice ${i+1}`,onClick:()=>t(e.filter((e,t)=>t!==i)),children:`Remove`})]},i)),(0,g.jsx)(`div`,{children:(0,g.jsx)(n.o,{icon:f.t,onClick:()=>t([...e,``]),children:`Add choice`})})]})})}function j(){let{userRole:v}=n.Ft(),y=(0,ie.useNavigate)(),b=n.mi(),x=()=>{let t=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},n={...e.t,contact:b?.defaultConfigs?.contactForm||e.t.contact,support:b?.defaultConfigs?.supportForm||e.t.support};for(let[e,r]of Object.entries(t))n[e]=r;return n},[C,w]=(0,h.useState)(()=>{try{if(typeof window<`u`){let e=localStorage.getItem(`fbos_swr_forms`);if(e)return JSON.parse(e)}let t={...e.t,contact:b?.defaultConfigs?.contactForm||e.t.contact,support:b?.defaultConfigs?.supportForm||e.t.support},n=(typeof window<`u`?window.__FBOS_FORMS__:null)||{};for(let[e,r]of Object.entries(n))t[e]=r;let r={};for(let[e,n]of Object.entries(t)){let t=JSON.parse(JSON.stringify(n));t._uiKey=Math.random().toString(36).substring(7),r[e]=t}return r}catch{return{}}}),[T,E]=(0,h.useState)(()=>!(typeof window<`u`&&localStorage.getItem(`fbos_swr_forms`))),[D,O]=(0,h.useState)({}),[j,M]=(0,h.useState)(null),[N,fe]=(0,h.useState)(new Set),P=re.n(),{schedules:F}=o.y(),[I,L]=(0,h.useState)({}),R=(0,h.useRef)(null),[z,B]=(0,h.useState)(null),[pe,V]=(0,h.useState)(!1),[H,U]=(0,h.useState)({}),W=(0,h.useRef)({}),G=(e,t)=>{W.current={...W.current,[e]:t},U(W.current)};(0,h.useEffect)(()=>{K()},[]);let K=async()=>{try{E(!0);let e=await(0,_.getDocs)((0,_.collection)(n.ui,`sys_forms`)),t={},r=new Set;e.forEach(e=>{if(e.id!==`pubForm`&&e.id!==`userForm`){let n=e.data();n._uiKey=C[e.id]?._uiKey||n._uiKey||Math.random().toString(36).substring(7),t[e.id]=n,r.add(e.id)}}),fe(r);for(let t of[`pubForm`,`userForm`])e.docs.some(e=>e.id===t)&&(0,_.deleteDoc)((0,_.doc)(n.ui,`sys_forms`,t)).catch(()=>{});let i=x();for(let[e,n]of Object.entries(i))if(!t[e]){let r={...n};r._uiKey=C[e]?._uiKey||Math.random().toString(36).substring(7),t[e]=r}else if(t[e]._uiKey=C[e]?._uiKey||t[e]._uiKey||Math.random().toString(36).substring(7),!t[e].fields||t[e].fields.length===0){let n=i[e];t[e].fields=n.fields||[]}let a={};for(let e of Object.keys(i))t[e]&&(a[e]=t[e]);for(let e of Object.keys(t))a[e]||(a[e]=t[e]);let o=window.location.pathname.split(`/forms/`)[1]?.split(`/`)[0];o&&a[o]&&L(e=>({...e,[o]:!0}));let s=(e,t)=>{let n=e=>{if(!e)return``;let{_uiKey:t,...n}=e;return JSON.stringify(n)};return!!e&&!!t&&n(e)===n(t)},c={};for(let[e,t]of Object.entries(W.current))s(C[e],a[e])&&(c[e]=t);W.current=c,U(c),w(a);try{localStorage.setItem(`fbos_swr_forms`,JSON.stringify(a))}catch{}}catch(e){console.error(`Failed to load forms:`,e)}finally{E(!1)}},q=async(e,t)=>{let r={...t};C[e]?._uiKey&&(r._uiKey=C[e]._uiKey),delete r.submitPage,e===`contact`?(r.systemName=`contact`,r.formType=`public`):e===`support`&&(r.systemName=`support`,r.formType=`private`);let i=r.systemName||e;if(i!==e&&i.trim()!==``){w(t=>{let n={};for(let a of Object.keys(t))a===e?n[i]=r:n[a]=t[a];return n}),I[e]&&L(t=>{let n={};for(let r of Object.keys(t))r===e?n[i]=t[r]:n[r]=t[r];return n}),O(e=>({...e,[i]:!0}));try{await(0,_.setDoc)((0,_.doc)(n.ui,`sys_forms`,i),r),await(0,_.deleteDoc)((0,_.doc)(n.ui,`sys_forms`,e)),localStorage.setItem(`fbos_custom_form_${i}`,`true`),localStorage.removeItem(`fbos_custom_form_${e}`),localStorage.setItem(`fbos_form_${i}`,JSON.stringify(r)),localStorage.removeItem(`fbos_form_${e}`)}catch(e){console.error(`Failed to migrate form map ID:`,e)}finally{setTimeout(()=>{O(e=>({...e,[i]:!1}))},500)}}else{w(t=>({...t,[e]:r})),O(t=>({...t,[e]:!0}));try{await(0,_.setDoc)((0,_.doc)(n.ui,`sys_forms`,e),r),localStorage.setItem(`fbos_custom_form_${e}`,`true`),localStorage.setItem(`fbos_form_${e}`,JSON.stringify(r))}catch(e){console.error(`Failed to save form:`,e)}finally{setTimeout(()=>{O(t=>({...t,[e]:!1}))},500)}}},J=(e,t,n)=>G(e,{...t,...n}),Y=(e,t,n)=>{let r={...t,...n};G(e,r),q(e,r)},X=e=>{let t=W.current[e];t&&q(e,t)},Z=(e,t,n)=>Y(e,t,{fields:n}),me=async e=>{if(!S.has(e)){V(!0);try{await(0,_.deleteDoc)((0,_.doc)(n.ui,`sys_forms`,e)),w(t=>{let n={...t};return delete n[e],n}),y(`/forms`)}catch(e){console.error(`Failed to delete form`,e)}finally{V(!1),B(null)}}},he=async e=>{if(!N.has(e)){B(null);return}V(!0);let t=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},r=S.has(e)||!!t[e]||!!b?.defaultConfigs?.[e]||!!b?.defaultConfigs?.[`${e}Form`];try{r?(O(t=>({...t,[e]:!0})),await(0,_.deleteDoc)((0,_.doc)(n.ui,`sys_forms`,e)),localStorage.removeItem(`fbos_form_${e}`),localStorage.removeItem(`fbos_custom_form_${e}`),await K(),setTimeout(()=>O(t=>({...t,[e]:!1})),500)):await q(e,x().contact||x().support)}catch(e){console.error(`Reset failed:`,e)}finally{V(!1),B(null)}};if(v!==`admin`)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.jsx)(ne.i,{})});let Q=e=>{L(t=>{let n={...t,[e]:!t[e]};if(n[e])window.history.replaceState(null,``,`/forms/${e}`);else{let e=Object.keys(n).filter(e=>n[e]);e.length>0?window.history.replaceState(null,``,`/forms/${e[0]}`):window.history.replaceState(null,``,`/forms`)}return n})},$=Object.keys(I).find(e=>I[e]),ge=(e,t,r,a,o)=>{let s=(n,r)=>{let i=o.map((e,t)=>t===a?{...e,...n}:e);r?Z(e,t,i):J(e,t,{fields:i})},c=n=>{let i=n===`schedule`?{type:n,look:`compact`,schedules:[]}:n===`select`?{type:n,options:r.options||[]}:{type:n};Z(e,t,o.map((e,t)=>{if(t!==a)return e;let r={...e,...i};return n!==`schedule`&&(delete r.members,delete r.schedules,delete r.look,delete r.together),r}))},l=n=>{let r=a+n;if(r<0||r>=o.length)return;let i=[...o];[i[a],i[r]]=[i[r],i[a]],Z(e,t,i)},u=r.type!==`checkbox`&&r.type!==`select`&&r.type!==`date`&&r.type!==`file`&&r.type!==`schedule`;return(0,g.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] p-4 sm:p-5 flex flex-col gap-5`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,g.jsxs)(`span`,{className:`text-[13px] font-bold text-foreground`,children:[`Question `,a+1,r.type===`schedule`&&(0,g.jsxs)(`span`,{className:`font-medium text-foreground/50`,children:[` · A time to book — `,ce(r,F)]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(n.o,{icon:n.jt,disabled:a===0,title:`Move up`,onClick:()=>l(-1),children:`Up`}),(0,g.jsx)(n.o,{icon:n.Mt,disabled:a===o.length-1,title:`Move down`,onClick:()=>l(1),children:`Down`}),(0,g.jsx)(n.o,{icon:p.t,tone:`danger`,title:`Remove question ${a+1}`,onClick:()=>Z(e,t,o.filter((e,t)=>t!==a)),children:`Remove`})]})]}),(0,g.jsx)(n.b,{label:`Question`,hint:`What you are asking for, in the words the person will read.`,value:r.label||``,placeholder:`e.g. What is your budget?`,onChange:e=>s({label:e,name:ue(r,e,o)},!1),onBlur:()=>X(e)}),(0,g.jsx)(n.g,{label:`Kind of answer`,hint:`Sets the box people type into and what counts as a valid answer.`,value:r.type||`text`,options:se(r.type,!1),allowEmpty:!1,onChange:c}),(0,g.jsx)(n.S,{label:`Required`,hint:`On means the form cannot be sent until this is answered.`,hintWideOnly:!0,enabled:!!r.required,onChange:e=>s({required:e},!0)}),r.type===`select`&&(0,g.jsx)(A,{choices:r.options||[],onChange:e=>s({options:e},!0)}),r.type===`schedule`&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(n.i,{label:`What can be booked`,hint:`Pick a schedule from the Schedule screen — one per person. Visitors see the free times in their own time zone; nobody can take a time twice.`,error:i.en(r).length?void 0:`Pick at least one schedule`,children:(0,g.jsx)(m.t,{schedules:F,selected:i.en(r),onPick:e=>{s({schedules:i.Mt(i.en(r),e,F)},!0)}})}),i.an(F.filter(e=>i.en(r).includes(e.id)))&&(0,g.jsx)(n.g,{label:`Who is the booking with?`,hint:`One of them: the visitor picks a person, then one of that person's own times. All of them: only the times every one of them is free are offered, and one booking goes in all their calendars. Both: the visitor chooses.`,value:i.$t(r),options:i.a,allowEmpty:!1,onChange:e=>s({party:i.$t({party:e}),together:e===`all`},!0)}),(0,g.jsx)(n.g,{label:`How should the booking look?`,value:r.look||`compact`,options:i.r,allowEmpty:!1,onChange:e=>s({look:e===`calendar`?`calendar`:`compact`},!0)})]}),r.type===`file`&&(0,g.jsx)(n.b,{label:`Words on the upload box`,hint:`What the box says before anything is picked. People can attach several files. Leave it empty for “Attach files”.`,value:r.placeholder||``,placeholder:`Attach files`,onChange:e=>s({placeholder:e},!1),onBlur:()=>X(e)}),r.type===`currency`&&(0,g.jsx)(n.b,{label:`Currency symbol`,hint:`Shown inside the box, before the amount.`,value:r.currencySymbol||``,placeholder:`$`,onChange:e=>s({currencySymbol:e},!1),onBlur:()=>X(e)}),u&&(0,g.jsx)(n.b,{label:`Example answer`,hint:`Faint grey text inside the box, to show people what you expect.`,value:r.placeholder||``,placeholder:`e.g. jane@example.com`,onChange:e=>s({placeholder:e},!1),onBlur:()=>X(e)})]},a)},_e=(e,t)=>{let i=H[e]||t,a=S.has(e),o=i.formType||`public`,s=i.fields||[],c=N.has(e);return(0,g.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,g.jsxs)(n.m,{icon:oe,title:`Basics`,description:`What people see at the top of this form and on its button.`,children:[(0,g.jsx)(n.b,{label:`Form name`,hint:`The heading at the top of the form.`,value:i.title||``,placeholder:`e.g. Get in touch`,onChange:t=>J(e,i,{title:t}),onBlur:()=>X(e)}),(0,g.jsx)(n.b,{label:`Button text`,hint:`The words on the button that sends the form.`,value:i.buttonName||i.submitText||``,placeholder:`e.g. Send message`,onChange:t=>J(e,i,{buttonName:t,submitText:t}),onBlur:()=>X(e)})]}),(0,g.jsx)(n.m,{icon:r.S,title:`Who it is for`,description:`Who can fill this in, and where their answers land.`,children:(0,g.jsx)(n.g,{label:`Who it is for`,hint:`Who can fill this in follows the page this form was made for, so it cannot change here. Changing it after answers arrive would file new answers under the wrong list in your Inbox.`,value:o,allowEmpty:!1,disabled:!0,options:[{value:`public`,label:`Anyone`},{value:`private`,label:`Signed-in users`}],onChange:t=>Y(e,i,{formType:t})})}),(0,g.jsx)(n.m,{icon:ee.t,title:`After sending`,description:`What happens the moment someone sends this form.`,children:(0,g.jsx)(n.b,{label:`Where to send them next`,hint:`Leave this empty to show a thank-you message instead. Or give a web address, like /pricing, to take them there.`,value:i.redirectTo||``,placeholder:`/pricing`,onChange:t=>J(e,i,{redirectTo:t}),onBlur:()=>X(e)})}),(0,g.jsxs)(n.m,{icon:ae,title:`Questions`,description:`Everything this form asks for, in the order people answer it.`,actions:({open:t})=>(0,g.jsx)(n.o,{icon:f.t,compact:!0,title:`Add a question`,onClick:()=>{t(),Z(e,i,[...s,k()])},children:`Add question`}),children:[s.length===0?(0,g.jsx)(`p`,{className:`text-[12.5px] text-foreground/55 font-medium leading-relaxed`,children:`No questions yet. Add the first one with the button above.`}):s.map((t,n)=>ge(e,i,t,n,s)),s.length>0&&(0,g.jsx)(`div`,{className:`flex justify-start`,children:(0,g.jsx)(n.o,{icon:f.t,onClick:()=>Z(e,i,[...s,k()]),children:`Add question`})})]}),(c||!a)&&(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[c&&(0,g.jsx)(n.o,{icon:u.n,tone:`danger`,compact:!0,title:`Reset this form`,onClick:()=>B({kind:`reset`,id:e}),children:`Reset this form`}),!a&&(0,g.jsx)(n.o,{icon:p.t,tone:`danger`,compact:!0,title:`Delete this form`,onClick:()=>B({kind:`delete`,id:e}),children:`Delete this form`})]})]})};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)(n.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)(t.t,{children:`Forms`}),(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`}),`/forms`,$?`/${$}`:``]})]})}),(0,g.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,g.jsx)(r.t,{}),(0,g.jsxs)(`div`,{className:`flex flex-col glass-panel border-y sm:border border-[var(--panel-border)] rounded-none sm:rounded-3xl overflow-hidden flex-1 fbos-tab-fill shadow-2xl bg-background -mx-4 sm:mx-0`,children:[(0,g.jsx)(`div`,{className:`flex items-start justify-between gap-3 sm:gap-6 mb-4 pb-4 md:mb-4 md:pb-5 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0 px-4 pt-5 sm:px-6 sm:pt-6 md:px-10 md:pt-8 bg-background/50`,children:(0,g.jsxs)(`div`,{className:`min-w-0`,children:[(0,g.jsx)(`h2`,{className:`text-lg md:text-xl font-bold text-foreground tracking-tight leading-tight md:leading-7`,children:`Your forms`}),(0,g.jsxs)(`p`,{className:`text-[12.5px] md:text-[14px] font-medium text-foreground/60 mt-1 md:mt-2 leading-relaxed`,children:[(0,g.jsx)(`span`,{className:`md:hidden`,children:`Look a form over and touch it up. Answers arrive in your Inbox.`}),(0,g.jsx)(`span`,{className:`max-md:hidden`,children:`Look a form over and touch it up — its name, button text and questions. New forms are made on the Pages screen, with their page. Answers arrive in your Inbox.`})]})]})}),(0,g.jsx)(`div`,{className:`p-4 sm:p-6 md:px-8 md:pb-8 md:pt-3 flex flex-col gap-4 overflow-y-auto`,children:Object.keys(C).length===0&&!T?(0,g.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 p-10 glass-panel rounded-3xl border border-[var(--panel-border)] border-dashed`,children:[(0,g.jsx)(r.T,{className:`w-6 h-6 text-foreground/40`}),(0,g.jsx)(`p`,{className:`text-[13px] font-bold text-foreground/60`,children:`You have no forms yet.`}),(0,g.jsx)(`p`,{className:`text-[12.5px] text-foreground/55 font-medium leading-relaxed text-center max-w-md`,children:de.firstForm})]})}):(0,g.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,g.jsx)(n.rt,{children:Object.entries(C).map(([e,t])=>{let r=H[e]||t,i=I[e],o=D[e],s=(r.fields||[]).length;return(0,g.jsxs)(n.nt.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},transition:{duration:.35,ease:`easeOut`},onMouseDown:e=>{R.current={x:e.clientX,y:e.clientY}},onClick:t=>{let n=R.current;R.current=null,m.n(t,n)&&Q(e)},className:`group flex flex-col p-3 px-4 glass-panel border transition-all rounded-2xl hover:shadow-sm cursor-pointer hover:border-accent/40 ${i?`border-[var(--panel-border)] bg-background/50`:`border-transparent hover:border-[var(--panel-border)]`} flex-shrink-0 ${r.enabled===!1?`opacity-40 grayscale bg-foreground/[0.01] border-[var(--panel-border)]/50`:``}`,children:[(0,g.jsxs)(`div`,{className:`flex flex-row justify-between w-full gap-2 ${P?`items-start`:`items-center`}`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1 pr-2 sm:pr-4`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`h3`,{className:`text-[14px] font-bold text-foreground break-words ml-1 leading-snug`,children:r.title||`Untitled form`}),o&&(0,g.jsx)(d.r,{className:`w-3 h-3 animate-spin text-accent ml-2 shrink-0`})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5 ml-1`,children:[(0,g.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold px-2.5 py-[3px] rounded-full border shrink-0 ${r.formType===`private`?`text-blue-500 border-blue-500/25 bg-blue-500/[0.07]`:`text-emerald-500 border-emerald-500/25 bg-emerald-500/[0.07]`}`,children:[(0,g.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${r.formType===`private`?`bg-blue-500`:`bg-emerald-500`}`}),le[r.formType||`public`]]}),(0,g.jsx)(`span`,{className:`max-sm:hidden text-[11px] font-medium text-foreground/45`,children:s===1?`1 question`:`${s} questions`})]})]}),P?(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0 -mt-0.5 -mr-1.5`,children:[(0,g.jsx)(`button`,{type:`button`,title:`Preview this form`,"aria-label":`Preview this form`,onClick:e=>{e.stopPropagation(),M(r)},className:`w-8 h-8 flex items-center justify-center rounded-lg text-foreground/40 hover:text-accent hover:bg-foreground/5 transition-colors cursor-pointer`,children:(0,g.jsx)(l.t,{className:`w-4 h-4`})}),(0,g.jsx)(`button`,{type:`button`,title:i?`Close this form`:`Open this form`,"aria-label":i?`Close this form`:`Open this form`,"aria-expanded":i,onClick:t=>{t.stopPropagation(),Q(e)},className:`w-8 h-8 flex items-center justify-center rounded-lg text-foreground/40 hover:text-accent hover:bg-foreground/5 transition-colors cursor-pointer`,children:(0,g.jsx)(a.t,{className:`w-4 h-4 transition-transform duration-300 ${i?`rotate-180`:``}`})})]}):(0,g.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,g.jsx)(n.o,{icon:l.t,title:`Preview this form`,onClick:e=>{e.stopPropagation(),M(r)},children:`Preview`}),(0,g.jsx)(`button`,{type:`button`,title:i?`Close this form`:`Open this form`,"aria-label":i?`Close this form`:`Open this form`,"aria-expanded":i,onClick:t=>{t.stopPropagation(),Q(e)},className:`w-9 h-9 flex items-center justify-center rounded-[var(--btn-radius,0.75rem)] text-foreground/40 hover:text-accent hover:bg-foreground/[0.06] transition-colors cursor-pointer`,children:(0,g.jsx)(a.t,{className:`w-4 h-4 transition-transform duration-300 ${i?`rotate-180`:``}`})})]})]}),(0,g.jsx)(n.rt,{children:i&&(0,g.jsx)(n.nt.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:n.w,className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50`,onClick:e=>e.stopPropagation(),children:_e(e,t)})})]},t._uiKey||e)})}),T&&(0,g.jsxs)(`div`,{className:`flex items-center justify-center gap-3 p-6 glass-panel rounded-2xl border border-[var(--panel-border)]/40 bg-foreground/[0.01] mt-2 animate-pulse`,children:[(0,g.jsx)(d.r,{className:`w-4 h-4 animate-spin text-accent`}),(0,g.jsx)(`span`,{className:`text-[12px] font-bold text-foreground/50 tracking-wider uppercase select-none`,children:`Loading your forms`})]})]})})]})]}),(0,g.jsx)(te.t,{isOpen:!!z,onCancel:()=>B(null),onConfirm:()=>{z&&(z.kind===`delete`?me(z.id):he(z.id))},title:z?.kind===`reset`?`Reset this form`:`Delete this form`,message:z?.kind===`reset`?`Undo every change made to ${C[z.id]?.title||z.id} and put it back the way it shipped. Answers already collected are kept.`:`Permanently delete ${z?C[z.id]?.title||z.id:``}. This cannot be undone. Answers already collected are kept.`,confirmText:z?.kind===`reset`?`Reset form`:`Delete form`,isProcessing:pe}),j&&(0,g.jsx)(s.t,{formConfig:j,onClose:()=>M(null)}),(0,g.jsx)(c.t,{})]})}exports.FormsAdmin=j;
|
|
1
|
+
require(`./chunk-CiTBaPhY.cjs`);const e=require(`./forms-CmNeTETW.cjs`),t=require(`./PageTitle-BL50s4qY.cjs`),n=require(`./TimeZoneField-Ckn1pKAL.cjs`),r=require(`./DashboardNav-Bc619nqn.cjs`),i=require(`./schedule-BAea6q8_.cjs`),a=require(`./chevron-down-lyDK1rfL.cjs`),o=require(`./scheduleData-BXjNXVHY.cjs`),s=require(`./ContactPopup-D8aSSlmS.cjs`),c=require(`./SupportBar-DR52UpBq.cjs`),l=require(`./eye-DU2g57PD.cjs`),u=require(`./VideoPlayer-CggwpVXH.cjs`),d=require(`./x-Ci8c5p6T.cjs`),f=require(`./plus-zsWFCu4F.cjs`),ee=require(`./send-CWJXtO05.cjs`),p=require(`./trash-D-CpYHCs.cjs`),te=require(`./ConfirmModal-BUNtss4a.cjs`),ne=require(`./AccessNotice-BClqr7A9.cjs`),re=require(`./useIsPhone-CoiQVcCo.cjs`),m=require(`./SchedulePicker-BpPGI5VZ.cjs`);let h=require(`react`),g=require(`react/jsx-runtime`),_=require(`firebase/firestore`),ie=require(`react-router-dom`);var v={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};v.node;var ae=a.n(v),y={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};y.node;var oe=a.n(y),b=e=>String(e&&typeof e==`object`?e.label??e.value??``:e??``),x=(e,t)=>e&&typeof e==`object`?{...e,label:t}:t,S=new Set([`contact`,`support`]),C=[{value:`text`,label:`Short text`},{value:`textarea`,label:`Long text`},{value:`email`,label:`Email`},{value:`tel`,label:`Phone`},{value:`address`,label:`Address`},{value:`number`,label:`Number`},{value:`date`,label:`Date`},{value:`currency`,label:`Money`},{value:`checkbox`,label:`Yes-no`},{value:`select`,label:`Choose one`},{value:`file`,label:`File upload`}],w={value:`schedule`,label:`A time to book`},T={age:`Age`},E=e=>[...C,w].find(t=>t.value===e)?.label||T[e||``]||`Short text`,se=(e,t=!1)=>{let n=t||e===`schedule`?[...C,w]:C;return n.some(t=>t.value===e)||!e?n:[...n,{value:e,label:E(e)}]},ce=(e,t)=>{let n=i.en(e).map(e=>{let n=t.find(t=>t.id===e);return n?i.Vt(n):``}).filter(Boolean);return n.length?n.join(`, `):`nothing picked yet`},le={public:`Anyone`,private:`Signed-in users`},D=e=>(e||``).toLowerCase().trim().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``),O=(e,t)=>{if(!t.includes(e))return e;let n=2;for(;t.includes(`${e}_${n}`);)n++;return`${e}_${n}`},ue=(e,t,n)=>{if(!(!e.name||e.name===D(e.label||``)))return e.name;let r=D(t);return r?O(r,n.filter(t=>t!==e).map(e=>e.name)):``},k=()=>({name:``,type:`text`,label:``,placeholder:``,required:!1}),de={firstForm:`Forms are made with their pages — add a page on the Pages screen and pick A new form made for this page. Every form then shows up here.`};function A({choices:e,onChange:t}){return(0,g.jsx)(n.i,{label:`Choices`,hint:`The options people pick from.`,children:(0,g.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.length===0&&(0,g.jsx)(`span`,{className:`text-[12px] text-foreground/40 font-medium px-1`,children:`No choices yet — add the first one.`}),e.map((r,i)=>(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`input`,{type:`text`,value:b(r),"aria-label":`Choice ${i+1}`,placeholder:`e.g. Under 1,000`,onChange:n=>t(e.map((e,t)=>t===i?x(e,n.target.value):e)),className:n.c}),(0,g.jsx)(n.o,{icon:d.t,tone:`danger`,title:`Remove choice ${i+1}`,onClick:()=>t(e.filter((e,t)=>t!==i)),children:`Remove`})]},i)),(0,g.jsx)(`div`,{children:(0,g.jsx)(n.o,{icon:f.t,onClick:()=>t([...e,``]),children:`Add choice`})})]})})}function j(){let{userRole:v}=n.Ft(),y=(0,ie.useNavigate)(),b=n.mi(),x=()=>{let t=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},n={...e.t,contact:b?.defaultConfigs?.contactForm||e.t.contact,support:b?.defaultConfigs?.supportForm||e.t.support};for(let[e,r]of Object.entries(t))n[e]=r;return n},[C,w]=(0,h.useState)(()=>{try{if(typeof window<`u`){let e=localStorage.getItem(`fbos_swr_forms`);if(e)return JSON.parse(e)}let t={...e.t,contact:b?.defaultConfigs?.contactForm||e.t.contact,support:b?.defaultConfigs?.supportForm||e.t.support},n=(typeof window<`u`?window.__FBOS_FORMS__:null)||{};for(let[e,r]of Object.entries(n))t[e]=r;let r={};for(let[e,n]of Object.entries(t)){let t=JSON.parse(JSON.stringify(n));t._uiKey=Math.random().toString(36).substring(7),r[e]=t}return r}catch{return{}}}),[T,E]=(0,h.useState)(()=>!(typeof window<`u`&&localStorage.getItem(`fbos_swr_forms`))),[D,O]=(0,h.useState)({}),[j,M]=(0,h.useState)(null),[N,fe]=(0,h.useState)(new Set),P=re.n(),{schedules:F}=o.y(),[I,L]=(0,h.useState)({}),R=(0,h.useRef)(null),[z,B]=(0,h.useState)(null),[pe,V]=(0,h.useState)(!1),[H,U]=(0,h.useState)({}),W=(0,h.useRef)({}),G=(e,t)=>{W.current={...W.current,[e]:t},U(W.current)};(0,h.useEffect)(()=>{K()},[]);let K=async()=>{try{E(!0);let e=await(0,_.getDocs)((0,_.collection)(n.ui,`sys_forms`)),t={},r=new Set;e.forEach(e=>{if(e.id!==`pubForm`&&e.id!==`userForm`){let n=e.data();n._uiKey=C[e.id]?._uiKey||n._uiKey||Math.random().toString(36).substring(7),t[e.id]=n,r.add(e.id)}}),fe(r);for(let t of[`pubForm`,`userForm`])e.docs.some(e=>e.id===t)&&(0,_.deleteDoc)((0,_.doc)(n.ui,`sys_forms`,t)).catch(()=>{});let i=x();for(let[e,n]of Object.entries(i))if(!t[e]){let r={...n};r._uiKey=C[e]?._uiKey||Math.random().toString(36).substring(7),t[e]=r}else if(t[e]._uiKey=C[e]?._uiKey||t[e]._uiKey||Math.random().toString(36).substring(7),!t[e].fields||t[e].fields.length===0){let n=i[e];t[e].fields=n.fields||[]}let a={};for(let e of Object.keys(i))t[e]&&(a[e]=t[e]);for(let e of Object.keys(t))a[e]||(a[e]=t[e]);let o=window.location.pathname.split(`/forms/`)[1]?.split(`/`)[0];o&&a[o]&&L(e=>({...e,[o]:!0}));let s=(e,t)=>{let n=e=>{if(!e)return``;let{_uiKey:t,...n}=e;return JSON.stringify(n)};return!!e&&!!t&&n(e)===n(t)},c={};for(let[e,t]of Object.entries(W.current))s(C[e],a[e])&&(c[e]=t);W.current=c,U(c),w(a);try{localStorage.setItem(`fbos_swr_forms`,JSON.stringify(a))}catch{}}catch(e){console.error(`Failed to load forms:`,e)}finally{E(!1)}},q=async(e,t)=>{let r={...t};C[e]?._uiKey&&(r._uiKey=C[e]._uiKey),delete r.submitPage,e===`contact`?(r.systemName=`contact`,r.formType=`public`):e===`support`&&(r.systemName=`support`,r.formType=`private`);let i=r.systemName||e;if(i!==e&&i.trim()!==``){w(t=>{let n={};for(let a of Object.keys(t))a===e?n[i]=r:n[a]=t[a];return n}),I[e]&&L(t=>{let n={};for(let r of Object.keys(t))r===e?n[i]=t[r]:n[r]=t[r];return n}),O(e=>({...e,[i]:!0}));try{await(0,_.setDoc)((0,_.doc)(n.ui,`sys_forms`,i),r),await(0,_.deleteDoc)((0,_.doc)(n.ui,`sys_forms`,e)),localStorage.setItem(`fbos_custom_form_${i}`,`true`),localStorage.removeItem(`fbos_custom_form_${e}`),localStorage.setItem(`fbos_form_${i}`,JSON.stringify(r)),localStorage.removeItem(`fbos_form_${e}`)}catch(e){console.error(`Failed to migrate form map ID:`,e)}finally{setTimeout(()=>{O(e=>({...e,[i]:!1}))},500)}}else{w(t=>({...t,[e]:r})),O(t=>({...t,[e]:!0}));try{await(0,_.setDoc)((0,_.doc)(n.ui,`sys_forms`,e),r),localStorage.setItem(`fbos_custom_form_${e}`,`true`),localStorage.setItem(`fbos_form_${e}`,JSON.stringify(r))}catch(e){console.error(`Failed to save form:`,e)}finally{setTimeout(()=>{O(t=>({...t,[e]:!1}))},500)}}},J=(e,t,n)=>G(e,{...t,...n}),Y=(e,t,n)=>{let r={...t,...n};G(e,r),q(e,r)},X=e=>{let t=W.current[e];t&&q(e,t)},Z=(e,t,n)=>Y(e,t,{fields:n}),me=async e=>{if(!S.has(e)){V(!0);try{await(0,_.deleteDoc)((0,_.doc)(n.ui,`sys_forms`,e)),w(t=>{let n={...t};return delete n[e],n}),y(`/forms`)}catch(e){console.error(`Failed to delete form`,e)}finally{V(!1),B(null)}}},he=async e=>{if(!N.has(e)){B(null);return}V(!0);let t=(typeof window<`u`?window.__FBOS_FORMS__:null)||{},r=S.has(e)||!!t[e]||!!b?.defaultConfigs?.[e]||!!b?.defaultConfigs?.[`${e}Form`];try{r?(O(t=>({...t,[e]:!0})),await(0,_.deleteDoc)((0,_.doc)(n.ui,`sys_forms`,e)),localStorage.removeItem(`fbos_form_${e}`),localStorage.removeItem(`fbos_custom_form_${e}`),await K(),setTimeout(()=>O(t=>({...t,[e]:!1})),500)):await q(e,x().contact||x().support)}catch(e){console.error(`Reset failed:`,e)}finally{V(!1),B(null)}};if(v!==`admin`)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.jsx)(ne.i,{})});let Q=e=>{L(t=>{let n={...t,[e]:!t[e]};if(n[e])window.history.replaceState(null,``,`/forms/${e}`);else{let e=Object.keys(n).filter(e=>n[e]);e.length>0?window.history.replaceState(null,``,`/forms/${e[0]}`):window.history.replaceState(null,``,`/forms`)}return n})},$=Object.keys(I).find(e=>I[e]),ge=(e,t,r,a,o)=>{let s=(n,r)=>{let i=o.map((e,t)=>t===a?{...e,...n}:e);r?Z(e,t,i):J(e,t,{fields:i})},c=n=>{let i=n===`schedule`?{type:n,look:`compact`,schedules:[]}:n===`select`?{type:n,options:r.options||[]}:{type:n};Z(e,t,o.map((e,t)=>{if(t!==a)return e;let r={...e,...i};return n!==`schedule`&&(delete r.members,delete r.schedules,delete r.look,delete r.together),r}))},l=n=>{let r=a+n;if(r<0||r>=o.length)return;let i=[...o];[i[a],i[r]]=[i[r],i[a]],Z(e,t,i)},u=r.type!==`checkbox`&&r.type!==`select`&&r.type!==`date`&&r.type!==`file`&&r.type!==`schedule`;return(0,g.jsxs)(`div`,{className:`rounded-2xl border border-[var(--panel-border)] bg-[var(--panel-bg)] p-4 sm:p-5 flex flex-col gap-5`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,g.jsxs)(`span`,{className:`text-[13px] font-bold text-foreground`,children:[`Question `,a+1,r.type===`schedule`&&(0,g.jsxs)(`span`,{className:`font-medium text-foreground/50`,children:[` · A time to book — `,ce(r,F)]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(n.o,{icon:n.jt,disabled:a===0,title:`Move up`,onClick:()=>l(-1),children:`Up`}),(0,g.jsx)(n.o,{icon:n.Mt,disabled:a===o.length-1,title:`Move down`,onClick:()=>l(1),children:`Down`}),(0,g.jsx)(n.o,{icon:p.t,tone:`danger`,title:`Remove question ${a+1}`,onClick:()=>Z(e,t,o.filter((e,t)=>t!==a)),children:`Remove`})]})]}),(0,g.jsx)(n.b,{label:`Question`,hint:`What you are asking for, in the words the person will read.`,value:r.label||``,placeholder:`e.g. What is your budget?`,onChange:e=>s({label:e,name:ue(r,e,o)},!1),onBlur:()=>X(e)}),(0,g.jsx)(n.g,{label:`Kind of answer`,hint:`Sets the box people type into and what counts as a valid answer.`,value:r.type||`text`,options:se(r.type,!1),allowEmpty:!1,onChange:c}),(0,g.jsx)(n.S,{label:`Required`,hint:`On means the form cannot be sent until this is answered.`,hintWideOnly:!0,enabled:!!r.required,onChange:e=>s({required:e},!0)}),r.type===`select`&&(0,g.jsx)(A,{choices:r.options||[],onChange:e=>s({options:e},!0)}),r.type===`schedule`&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(n.i,{label:`What can be booked`,hint:`Pick a schedule from the Schedule screen — one per person. Visitors see the free times in their own time zone; nobody can take a time twice.`,error:i.en(r).length?void 0:`Pick at least one schedule`,children:(0,g.jsx)(m.t,{schedules:F,selected:i.en(r),onPick:e=>{s({schedules:i.Mt(i.en(r),e,F)},!0)}})}),i.an(F.filter(e=>i.en(r).includes(e.id)))&&(0,g.jsx)(n.g,{label:`Who is the booking with?`,hint:`One of them: the visitor picks a person, then one of that person's own times. All of them: only the times every one of them is free are offered, and one booking goes in all their calendars. Both: the visitor chooses.`,value:i.$t(r),options:i.a,allowEmpty:!1,onChange:e=>s({party:i.$t({party:e}),together:e===`all`},!0)}),(0,g.jsx)(n.g,{label:`How should the booking look?`,value:r.look||`compact`,options:i.r,allowEmpty:!1,onChange:e=>s({look:e===`calendar`?`calendar`:`compact`},!0)})]}),r.type===`file`&&(0,g.jsx)(n.b,{label:`Words on the upload box`,hint:`What the box says before anything is picked. People can attach several files. Leave it empty for “Attach files”.`,value:r.placeholder||``,placeholder:`Attach files`,onChange:e=>s({placeholder:e},!1),onBlur:()=>X(e)}),r.type===`currency`&&(0,g.jsx)(n.b,{label:`Currency symbol`,hint:`Shown inside the box, before the amount.`,value:r.currencySymbol||``,placeholder:`$`,onChange:e=>s({currencySymbol:e},!1),onBlur:()=>X(e)}),u&&(0,g.jsx)(n.b,{label:`Example answer`,hint:`Faint grey text inside the box, to show people what you expect.`,value:r.placeholder||``,placeholder:`e.g. jane@example.com`,onChange:e=>s({placeholder:e},!1),onBlur:()=>X(e)})]},a)},_e=(e,t)=>{let i=H[e]||t,a=S.has(e),o=i.formType||`public`,s=i.fields||[],c=N.has(e);return(0,g.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,g.jsxs)(n.m,{icon:oe,title:`Basics`,description:`What people see at the top of this form and on its button.`,children:[(0,g.jsx)(n.b,{label:`Form name`,hint:`The heading at the top of the form.`,value:i.title||``,placeholder:`e.g. Get in touch`,onChange:t=>J(e,i,{title:t}),onBlur:()=>X(e)}),(0,g.jsx)(n.b,{label:`Button text`,hint:`The words on the button that sends the form.`,value:i.buttonName||i.submitText||``,placeholder:`e.g. Send message`,onChange:t=>J(e,i,{buttonName:t,submitText:t}),onBlur:()=>X(e)})]}),(0,g.jsx)(n.m,{icon:r.S,title:`Who it is for`,description:`Who can fill this in, and where their answers land.`,children:(0,g.jsx)(n.g,{label:`Who it is for`,hint:`Who can fill this in follows the page this form was made for, so it cannot change here. Changing it after answers arrive would file new answers under the wrong list in your Inbox.`,value:o,allowEmpty:!1,disabled:!0,options:[{value:`public`,label:`Anyone`},{value:`private`,label:`Signed-in users`}],onChange:t=>Y(e,i,{formType:t})})}),(0,g.jsx)(n.m,{icon:ee.t,title:`After sending`,description:`What happens the moment someone sends this form.`,children:(0,g.jsx)(n.b,{label:`Where to send them next`,hint:`Leave this empty to show a thank-you message instead. Or give a web address, like /pricing, to take them there.`,value:i.redirectTo||``,placeholder:`/pricing`,onChange:t=>J(e,i,{redirectTo:t}),onBlur:()=>X(e)})}),(0,g.jsxs)(n.m,{icon:ae,title:`Questions`,description:`Everything this form asks for, in the order people answer it.`,actions:({open:t})=>(0,g.jsx)(n.o,{icon:f.t,compact:!0,title:`Add a question`,onClick:()=>{t(),Z(e,i,[...s,k()])},children:`Add question`}),children:[s.length===0?(0,g.jsx)(`p`,{className:`text-[12.5px] text-foreground/55 font-medium leading-relaxed`,children:`No questions yet. Add the first one with the button above.`}):s.map((t,n)=>ge(e,i,t,n,s)),s.length>0&&(0,g.jsx)(`div`,{className:`flex justify-start`,children:(0,g.jsx)(n.o,{icon:f.t,onClick:()=>Z(e,i,[...s,k()]),children:`Add question`})})]}),(c||!a)&&(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[c&&(0,g.jsx)(n.o,{icon:u.n,tone:`danger`,compact:!0,title:`Reset this form`,onClick:()=>B({kind:`reset`,id:e}),children:`Reset this form`}),!a&&(0,g.jsx)(n.o,{icon:p.t,tone:`danger`,compact:!0,title:`Delete this form`,onClick:()=>B({kind:`delete`,id:e}),children:`Delete this form`})]})]})};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)(n.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)(t.t,{children:`Forms`}),(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`}),`/forms`,$?`/${$}`:``]})]})}),(0,g.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,g.jsx)(r.t,{}),(0,g.jsxs)(`div`,{className:`flex flex-col glass-panel border-y sm:border border-[var(--panel-border)] rounded-none sm:rounded-3xl overflow-hidden flex-1 fbos-tab-fill shadow-2xl bg-background -mx-4 sm:mx-0`,children:[(0,g.jsx)(`div`,{className:`flex items-start justify-between gap-3 sm:gap-6 mb-4 pb-4 md:mb-4 md:pb-5 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0 px-4 pt-5 sm:px-6 sm:pt-6 md:px-10 md:pt-8 bg-background/50`,children:(0,g.jsxs)(`div`,{className:`min-w-0`,children:[(0,g.jsx)(`h2`,{className:`text-lg md:text-xl font-bold text-foreground tracking-tight leading-tight md:leading-7`,children:`Your forms`}),(0,g.jsxs)(`p`,{className:`text-[12.5px] md:text-[14px] font-medium text-foreground/60 mt-1 md:mt-2 leading-relaxed`,children:[(0,g.jsx)(`span`,{className:`md:hidden`,children:`Look a form over and touch it up. Answers arrive in your Inbox.`}),(0,g.jsx)(`span`,{className:`max-md:hidden`,children:`Look a form over and touch it up — its name, button text and questions. New forms are made on the Pages screen, with their page. Answers arrive in your Inbox.`})]})]})}),(0,g.jsx)(`div`,{className:`p-4 sm:p-6 md:px-8 md:pb-8 md:pt-3 flex flex-col gap-4 overflow-y-auto`,children:Object.keys(C).length===0&&!T?(0,g.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 p-10 glass-panel rounded-3xl border border-[var(--panel-border)] border-dashed`,children:[(0,g.jsx)(r.T,{className:`w-6 h-6 text-foreground/40`}),(0,g.jsx)(`p`,{className:`text-[13px] font-bold text-foreground/60`,children:`You have no forms yet.`}),(0,g.jsx)(`p`,{className:`text-[12.5px] text-foreground/55 font-medium leading-relaxed text-center max-w-md`,children:de.firstForm})]})}):(0,g.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,g.jsx)(n.rt,{children:Object.entries(C).map(([e,t])=>{let r=H[e]||t,i=I[e],o=D[e],s=(r.fields||[]).length;return(0,g.jsxs)(n.nt.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},transition:{duration:.35,ease:`easeOut`},onMouseDown:e=>{R.current={x:e.clientX,y:e.clientY}},onClick:t=>{let n=R.current;R.current=null,m.n(t,n)&&Q(e)},className:`group flex flex-col p-3 px-4 glass-panel border transition-all rounded-2xl hover:shadow-sm cursor-pointer hover:border-accent/40 ${i?`border-[var(--panel-border)] bg-background/50`:`border-transparent hover:border-[var(--panel-border)]`} flex-shrink-0 ${r.enabled===!1?`opacity-40 grayscale bg-foreground/[0.01] border-[var(--panel-border)]/50`:``}`,children:[(0,g.jsxs)(`div`,{className:`flex flex-row justify-between w-full gap-2 ${P?`items-start`:`items-center`}`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1 pr-2 sm:pr-4`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`h3`,{className:`text-[14px] font-bold text-foreground break-words ml-1 leading-snug`,children:r.title||`Untitled form`}),o&&(0,g.jsx)(d.r,{className:`w-3 h-3 animate-spin text-accent ml-2 shrink-0`})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5 ml-1`,children:[(0,g.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold px-2.5 py-[3px] rounded-full border shrink-0 ${r.formType===`private`?`text-blue-500 border-blue-500/25 bg-blue-500/[0.07]`:`text-emerald-500 border-emerald-500/25 bg-emerald-500/[0.07]`}`,children:[(0,g.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${r.formType===`private`?`bg-blue-500`:`bg-emerald-500`}`}),le[r.formType||`public`]]}),(0,g.jsx)(`span`,{className:`max-sm:hidden text-[11px] font-medium text-foreground/45`,children:s===1?`1 question`:`${s} questions`})]})]}),P?(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0 -mt-0.5 -mr-1.5`,children:[(0,g.jsx)(`button`,{type:`button`,title:`Preview this form`,"aria-label":`Preview this form`,onClick:e=>{e.stopPropagation(),M(r)},className:`w-8 h-8 flex items-center justify-center rounded-lg text-foreground/40 hover:text-accent hover:bg-foreground/5 transition-colors cursor-pointer`,children:(0,g.jsx)(l.t,{className:`w-4 h-4`})}),(0,g.jsx)(`button`,{type:`button`,title:i?`Close this form`:`Open this form`,"aria-label":i?`Close this form`:`Open this form`,"aria-expanded":i,onClick:t=>{t.stopPropagation(),Q(e)},className:`w-8 h-8 flex items-center justify-center rounded-lg text-foreground/40 hover:text-accent hover:bg-foreground/5 transition-colors cursor-pointer`,children:(0,g.jsx)(a.t,{className:`w-4 h-4 transition-transform duration-300 ${i?`rotate-180`:``}`})})]}):(0,g.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,g.jsx)(n.o,{icon:l.t,title:`Preview this form`,onClick:e=>{e.stopPropagation(),M(r)},children:`Preview`}),(0,g.jsx)(`button`,{type:`button`,title:i?`Close this form`:`Open this form`,"aria-label":i?`Close this form`:`Open this form`,"aria-expanded":i,onClick:t=>{t.stopPropagation(),Q(e)},className:`w-9 h-9 flex items-center justify-center rounded-[var(--btn-radius,0.75rem)] text-foreground/40 hover:text-accent hover:bg-foreground/[0.06] transition-colors cursor-pointer`,children:(0,g.jsx)(a.t,{className:`w-4 h-4 transition-transform duration-300 ${i?`rotate-180`:``}`})})]})]}),(0,g.jsx)(n.rt,{children:i&&(0,g.jsx)(n.nt.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:n.w,className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50`,onClick:e=>e.stopPropagation(),children:_e(e,t)})})]},t._uiKey||e)})}),T&&(0,g.jsxs)(`div`,{className:`flex items-center justify-center gap-3 p-6 glass-panel rounded-2xl border border-[var(--panel-border)]/40 bg-foreground/[0.01] mt-2 animate-pulse`,children:[(0,g.jsx)(d.r,{className:`w-4 h-4 animate-spin text-accent`}),(0,g.jsx)(`span`,{className:`text-[12px] font-bold text-foreground/50 tracking-wider uppercase select-none`,children:`Loading your forms`})]})]})})]})]}),(0,g.jsx)(te.t,{isOpen:!!z,onCancel:()=>B(null),onConfirm:()=>{z&&(z.kind===`delete`?me(z.id):he(z.id))},title:z?.kind===`reset`?`Reset this form`:`Delete this form`,message:z?.kind===`reset`?`Undo every change made to ${C[z.id]?.title||z.id} and put it back the way it shipped. Answers already collected are kept.`:`Permanently delete ${z?C[z.id]?.title||z.id:``}. This cannot be undone. Answers already collected are kept.`,confirmText:z?.kind===`reset`?`Reset form`:`Delete form`,isProcessing:pe}),j&&(0,g.jsx)(s.t,{formConfig:j,onClose:()=>M(null)}),(0,g.jsx)(c.t,{})]})}exports.FormsAdmin=j;
|