ghost 6.13.1 → 6.13.2
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/components/tryghost-i18n-6.13.2.tgz +0 -0
- package/core/built/admin/assets/{_baseAssignValue-CPzElAl9.js → _baseAssignValue-qTINVNgk.js} +1 -1
- package/core/built/admin/assets/{a-large-small-2Oh9oqBr.js → a-large-small-D-nhKFBX.js} +1 -1
- package/core/built/admin/assets/admin-x-settings/admin-x-settings.js +2 -2
- package/core/built/admin/assets/admin-x-settings/{code-editor-view-B5QudVu-.mjs → code-editor-view-CXaEQbfL.mjs} +2 -2
- package/core/built/admin/assets/admin-x-settings/{index-D3C8sdqQ.mjs → index-BrqKezEN.mjs} +30 -24
- package/core/built/admin/assets/admin-x-settings/{index-B66mLTSp.mjs → index-CwXvgyDY.mjs} +2 -2
- package/core/built/admin/assets/admin-x-settings/{index-CdWUpaGD.mjs → index-Dc7foGQ2.mjs} +2 -2
- package/core/built/admin/assets/admin-x-settings/{modals-lYrPGC_E.mjs → modals-Ba1hMizc.mjs} +2 -2
- package/core/built/admin/assets/{at-sign-BtKGpnjs.js → at-sign-DHUgIxNb.js} +1 -1
- package/core/built/admin/assets/{audience-select-DuSCQEyi.js → audience-select-C17Kh6Hl.js} +1 -1
- package/core/built/admin/assets/{avatar-flipboard-CcvOD0pV.js → avatar-flipboard-Cdj8uoBX.js} +1 -1
- package/core/built/admin/assets/{bluesky-sharing-Frg4QWOQ.js → bluesky-sharing-DYSv4ewp.js} +1 -1
- package/core/built/admin/assets/{chart-tL51cfF9.js → chart-BYGpVun6.js} +1 -1
- package/core/built/admin/assets/{chunk.397.a720333cfffc99c47e71.js → chunk.397.71f16fce8de382622bb4.js} +2 -2
- package/core/built/admin/assets/{chunk.524.6168e2262e63b155f63e.js → chunk.524.ccb5a082c09fdedaf1d0.js} +6 -6
- package/core/built/admin/assets/{chunk.582.45f8c5479d11e969ddc2.js → chunk.582.311f93280422738b8a5d.js} +7 -7
- package/core/built/admin/assets/{code-editor-view-BHiySSgi.js → code-editor-view-BnOaGsRA.js} +1 -1
- package/core/built/admin/assets/{comments-svHZXAlu.js → comments-DiZAz2yU.js} +1 -1
- package/core/built/admin/assets/{copy-B8yuX-e4.js → copy-CCj6xx5V.js} +1 -1
- package/core/built/admin/assets/{data-list-C_WXxmo3.js → data-list-By9zN-Ma.js} +1 -1
- package/core/built/admin/assets/{deleted-feed-item-OXPcC4Z2.js → deleted-feed-item-Dl0oQ0DH.js} +1 -1
- package/core/built/admin/assets/{edit-profile-DgMLvoyu.js → edit-profile-DZhjWF_f.js} +1 -1
- package/core/built/admin/assets/{empty-indicator-DOQCKEXD.js → empty-indicator-B7WXKrac.js} +1 -1
- package/core/built/admin/assets/{en-Z93BzXte.js → en-B8oRL8Ua.js} +1 -1
- package/core/built/admin/assets/{feed-BKXpQU0e.js → feed-DU5QhfRX.js} +1 -1
- package/core/built/admin/assets/{filters-dwDByCkK.js → filters-C-v3cGt0.js} +1 -1
- package/core/built/admin/assets/{gh-chart-CaA6rQiP.js → gh-chart-B98YGgzG.js} +1 -1
- package/core/built/admin/assets/{growth-DKtJYCNb.js → growth-_giTyVF8.js} +1 -1
- package/core/built/admin/assets/{hash-ZzZYv2ek.js → hash-B4UtN3nq.js} +1 -1
- package/core/built/admin/assets/{inbox-C5KDymI8.js → inbox-D336Mbic.js} +1 -1
- package/core/built/admin/assets/{index-VdGL6HfS.js → index-B3CWs1Pb.js} +1 -1
- package/core/built/admin/assets/{index-CM3YmTO5.js → index-Bl3YnEiK.js} +1 -1
- package/core/built/admin/assets/{index-OPvny56_.js → index-BuFp5nYK.js} +1 -1
- package/core/built/admin/assets/{index-BX3p0DcO.js → index-C9PDrFEW.js} +1 -1
- package/core/built/admin/assets/{index-DethZCE1.js → index-CEEPij-w.js} +1 -1
- package/core/built/admin/assets/{index-BNkw6KwF.js → index-CLdEbHsV.js} +1 -1
- package/core/built/admin/assets/{index-CQVI9TPr.js → index-CdIdIOil.js} +1 -1
- package/core/built/admin/assets/{index-B6mBuUxr.js → index-DI4OotZO.js} +1 -1
- package/core/built/admin/assets/{index-BniBHF2r.js → index-DXuLaG0T.js} +1 -1
- package/core/built/admin/assets/{index-6_RXbq08.css → index-DbjfIcZe.css} +1 -1
- package/core/built/admin/assets/{index-X_uC_0DD.js → index-Dq_j8mTf.js} +3 -3
- package/core/built/admin/assets/{index-DOORRiFo.js → index-cWfIWdIX.js} +1 -1
- package/core/built/admin/assets/{index-CF6UHTsD.js → index-iHz8ZTSi.js} +1 -1
- package/core/built/admin/assets/{index-D9gfkxEz.js → index-k2aVq6ms.js} +1 -1
- package/core/built/admin/assets/{index-syvYkr47.js → index-w7Tz4ytz.js} +1 -1
- package/core/built/admin/assets/koenig-lexical/index.css +2 -2
- package/core/built/admin/assets/koenig-lexical/koenig-lexical.js +21800 -23540
- package/core/built/admin/assets/koenig-lexical/koenig-lexical.umd.js +177 -177
- package/core/built/admin/assets/{koenig-lexical-D4CBYCN7.js → koenig-lexical-5o67f7C9.js} +155 -155
- package/core/built/admin/assets/{kpi-card-DOIcNxgg.js → kpi-card-XLCPc_4J.js} +1 -1
- package/core/built/admin/assets/{kpis-BrSBq5c9.js → kpis-Czdhg1qV.js} +1 -1
- package/core/built/admin/assets/{links-DkVK8XO7.js → links-CY3nuFg7.js} +1 -1
- package/core/built/admin/assets/{lucide-react-DNj9Mt50.js → lucide-react-B7CWr8XP.js} +1 -1
- package/core/built/admin/assets/{main-layout-A6BaeVIm.js → main-layout-CmX429hf.js} +1 -1
- package/core/built/admin/assets/{message-square-text-DJWDCab0.js → message-square-text-Cqodm1uC.js} +1 -1
- package/core/built/admin/assets/{minus-B7zQY2p1.js → minus-K1Fj4qFh.js} +1 -1
- package/core/built/admin/assets/{modals-DJQDv_48.js → modals-C0x0SG_a.js} +1 -1
- package/core/built/admin/assets/{moderation-DikYZSIC.js → moderation-DqX2eQNM.js} +1 -1
- package/core/built/admin/assets/{newsletter-ok4p5aPZ.js → newsletter-BaZVL4Rg.js} +1 -1
- package/core/built/admin/assets/{newsletters-ClUaZMbc.js → newsletters-DpmHk1Kf.js} +1 -1
- package/core/built/admin/assets/{note-C445n_od.js → note-Bqr3ECo6.js} +1 -1
- package/core/built/admin/assets/{overview-vPttXZEx.js → overview-CGTvSQfN.js} +1 -1
- package/core/built/admin/assets/{pagemenu-CUEgz3GC.js → pagemenu-z-Nc5-Yy.js} +1 -1
- package/core/built/admin/assets/{post-analytics-DPIgO2YG.js → post-analytics-DCAOPWEx.js} +1 -1
- package/core/built/admin/assets/{post-analytics-context-DGNsxT8V.js → post-analytics-context-DctS9fHu.js} +1 -1
- package/core/built/admin/assets/{post-analytics-header-B1f7HAy_.js → post-analytics-header-C6tJIKtV.js} +1 -1
- package/core/built/admin/assets/{post-share-modal-BIddzWjJ.js → post-share-modal-CtQTpIsC.js} +1 -1
- package/core/built/admin/assets/{posts-DOThg8yh.js → posts-D0erEci0.js} +1 -1
- package/core/built/admin/assets/{referrers-BK-mXdat.js → referrers-D4s1ncIT.js} +1 -1
- package/core/built/admin/assets/{repeat-CQvZJI02.js → repeat-BNamsVQr.js} +1 -1
- package/core/built/admin/assets/{reply-BET0l7FZ.js → reply-DqXFv78k.js} +1 -1
- package/core/built/admin/assets/{select-BH3t_tDB.js → select-CFBw9aAY.js} +1 -1
- package/core/built/admin/assets/{settings-CpkvyD93.js → settings-B_8Oslb0.js} +5 -5
- package/core/built/admin/assets/{settings-OIq7tQiJ.js → settings-BnZOyHrT.js} +1 -1
- package/core/built/admin/assets/{sort-button-DkfQ-8QJ.js → sort-button-K1rs2zWp.js} +1 -1
- package/core/built/admin/assets/{source-icon-DOOAvJR8.js → source-icon-KI6QTdIv.js} +1 -1
- package/core/built/admin/assets/{sprout-gjsBxaCU.js → sprout-C96gimQS.js} +1 -1
- package/core/built/admin/assets/{square-DsGufPa-.js → square-s6ZVKvbY.js} +1 -1
- package/core/built/admin/assets/{stats-Cu49FJzo.js → stats-C8Qt0L-1.js} +1 -1
- package/core/built/admin/assets/{stats-view-DUoDKh7r.js → stats-view-0eaQf_pM.js} +1 -1
- package/core/built/admin/assets/{step-1-QOnWlIzD.js → step-1-Gnp7iGGY.js} +1 -1
- package/core/built/admin/assets/{step-2-CDFj1bR5.js → step-2-DFbY2-K1.js} +1 -1
- package/core/built/admin/assets/{step-3-Cjmt9ecL.js → step-3-CoA_-aRF.js} +1 -1
- package/core/built/admin/assets/{table-PBYP6iVu.js → table-DpY57zP6.js} +1 -1
- package/core/built/admin/assets/{tabs--ia9i-R8.js → tabs-BTEs4Aby.js} +1 -1
- package/core/built/admin/assets/{tags-DwsoamaL.js → tags-CIEzegXe.js} +1 -1
- package/core/built/admin/assets/{tags-DK91bj9-.js → tags-DUcQDnmf.js} +1 -1
- package/core/built/admin/assets/{toggle-group-my6OlgUp.js → toggle-group-qaH0bKBM.js} +1 -1
- package/core/built/admin/assets/{topic-filter-Cdat1Ona.js → topic-filter-BmvO9gja.js} +1 -1
- package/core/built/admin/assets/{trash-C2kuVkXA.js → trash-DIVNO9rU.js} +1 -1
- package/core/built/admin/assets/{url-helpers-BuFo9dQz.js → url-helpers-Cn69VioM.js} +1 -1
- package/core/built/admin/assets/{use-growth-stats-DY2E0ltn.js → use-growth-stats-DPN4F7Mt.js} +1 -1
- package/core/built/admin/assets/{use-infinite-virtual-scroll-CS20HV8J.js → use-infinite-virtual-scroll-D5U6oSIq.js} +1 -1
- package/core/built/admin/assets/{use-simple-pagination-kb9H2Ssw.js → use-simple-pagination-_Ui1WbsL.js} +1 -1
- package/core/built/admin/assets/{user-round-check-Biw6QBQA.js → user-round-check-pBOLjTqi.js} +1 -1
- package/core/built/admin/assets/{wallet-cards-aM5Ct3OB.js → wallet-cards-yxIjXIK2.js} +1 -1
- package/core/built/admin/assets/{web-DiBDLMW8.js → web-CtBMATfv.js} +1 -1
- package/core/built/admin/index-forward.html +5 -5
- package/core/built/admin/index.html +3 -3
- package/core/server/services/member-welcome-emails/constants.js +1 -22
- package/core/server/services/member-welcome-emails/service.js +2 -20
- package/core/server/services/members/members-api/repositories/member-repository.js +7 -12
- package/package.json +13 -13
- package/yarn.lock +72 -89
- package/components/tryghost-i18n-6.13.1.tgz +0 -0
- /package/core/built/admin/assets/{chunk.397.a720333cfffc99c47e71.js.LICENSE.txt → chunk.397.71f16fce8de382622bb4.js.LICENSE.txt} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as o,j as n,ca as Cn,cb as Sn,B as A,b$ as Wn,cd as zn,cc as Kn,e as rn,cU as Yn,b as En,cY as gn,S as E,P as Vn,A as Qn,h as Zn,g as fn,d as Jn,n as Xn,bF as Gn,f as pn,F as an,i as on,cZ as ne,o as ee,a as te,u as ae,p as oe,L as re,aO as ie,D as de,t as ce,v as se,w as le,a9 as ge,c_ as pe,c$ as ue,bx as bn,by as he}from"./index-
|
|
1
|
+
import{r as o,j as n,ca as Cn,cb as Sn,B as A,b$ as Wn,cd as zn,cc as Kn,e as rn,cU as Yn,b as En,cY as gn,S as E,P as Vn,A as Qn,h as Zn,g as fn,d as Jn,n as Xn,bF as Gn,f as pn,F as an,i as on,cZ as ne,o as ee,a as te,u as ae,p as oe,L as re,aO as ie,D as de,t as ce,v as se,w as le,a9 as ge,c_ as pe,c$ as ue,bx as bn,by as he}from"./index-Dq_j8mTf.js";import{M as me}from"./minus-K1Fj4qFh.js";import{u as ke,D as fe,A as be,S as xn}from"./deleted-feed-item-Dl0oQ0DH.js";import{T as xe}from"./topic-filter-BmvO9gja.js";import{E as vn}from"./empty-indicator-B7WXKrac.js";import{I as yn}from"./inbox-D336Mbic.js";import"./trash-DIVNO9rU.js";const un=["1.5rem","1.6rem","1.7rem","1.8rem","2rem"],U={BACKGROUND_COLOR:"ghost-ap-background-color",FONT_SIZE:"ghost-ap-font-size",FONT_STYLE:"ghost-ap-font-style"},P={SYSTEM:{id:"system",color:"#fff",background:"bg-white dark:bg-black",button:"bg-white dark:bg-black",border:"border-black/[8%] dark:border-gray-950"},SEPIA:{id:"sepia",color:"#FCF8F1",background:"bg-[#FCF8F1]",button:"bg-[#FCF8F1] hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%]"},LIGHT:{id:"light",color:"#fff",background:"bg-white",button:"hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%] dark:border-gray-950"},DARK:{id:"dark",color:"#15171a",background:"bg-black",button:"text-white dark:bg-black dark:hover:bg-gray-900",border:"border-black/[8%] dark:border-gray-950"}},ve=()=>{const[a,s]=o.useState(()=>localStorage.getItem(U.BACKGROUND_COLOR)?.toUpperCase()||"SYSTEM"),[t,p]=o.useState(()=>{const r=localStorage.getItem(U.FONT_SIZE);return r?parseInt(r):2}),[c,k]=o.useState(()=>localStorage.getItem(U.FONT_STYLE)||"sans"),i=r=>{s(r),localStorage.setItem(U.BACKGROUND_COLOR,P[r].id)};return o.useEffect(()=>{localStorage.setItem(U.FONT_SIZE,t.toString())},[t]),o.useEffect(()=>{localStorage.setItem(U.FONT_STYLE,c)},[c]),{backgroundColor:a,currentFontSizeIndex:t,fontStyle:c,handleColorChange:i,setFontStyle:k,increaseFontSize:()=>{p(r=>Math.min(r+1,un.length-1))},decreaseFontSize:()=>{p(r=>Math.max(r-1,0))},resetFontSize:()=>p(2),fontSize:un[t]}},wn=({backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,onColorChange:p,onFontStyleChange:c,onDecreaseFontSize:k,onIncreaseFontSize:i,onResetFontSize:u,onOpenChange:v})=>{const h=l=>a===l,r=l=>t===l;return n.jsx(ye,{backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,isActiveColor:h,isActiveFont:r,onColorChange:p,onDecreaseFontSize:k,onFontStyleChange:c,onIncreaseFontSize:i,onOpenChange:v,onResetFontSize:u})},ye=({backgroundColor:a,isActiveColor:s,isActiveFont:t,onColorChange:p,onFontStyleChange:c,currentFontSizeIndex:k,onDecreaseFontSize:i,onIncreaseFontSize:u,onResetFontSize:v,onOpenChange:h})=>n.jsxs(Cn,{modal:!1,onOpenChange:h,children:[n.jsx(Sn,{asChild:!0,children:n.jsx(A,{className:`size-9 rounded-full ${P[a].button}`,variant:"ghost",children:n.jsx(Wn.Typography,{className:"!size-[18px]"})})}),n.jsx(zn,{align:"end",className:"w-[224px]",onCloseAutoFocus:r=>r.preventDefault(),onOpenAutoFocus:r=>r.preventDefault(),children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${s("SYSTEM")?"outline outline-2 outline-green":""}`,variant:"secondary",onClick:()=>p("SYSTEM"),children:"Auto"}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${s("SEPIA")?"outline outline-2 outline-green":"border border-[#ece6d9]"}`,onClick:()=>p("SEPIA")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${s("LIGHT")?"outline outline-2 outline-green":"border border-gray-200"}`,onClick:()=>p("LIGHT")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-925 ${s("DARK")?"outline outline-2 outline-green":""}`,onClick:()=>p("DARK")})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("sans")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("sans"),children:[n.jsx("span",{className:"text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"text-[1.1rem]",children:"System"})]}),n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("serif")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("serif"),children:[n.jsx("span",{className:"pt-1 font-serif text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"font-serif text-[1.2rem]",children:"Serif"})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===0,variant:"secondary",onClick:i,children:n.jsx(me,{})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900",variant:"secondary",onClick:v,children:n.jsx("span",{className:"text-[1.6rem] font-bold",children:"Aa"})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===un.length-1,variant:"secondary",onClick:u,children:n.jsx(Kn,{})})]})]})})]}),we=({tocItems:a,iframeElement:s,modalRef:t,className:p="!visible absolute inset-y-0 right-7 z-40 hidden lg:!block",onOpenChange:c})=>{const[k,i]=o.useState(null),u=rn.useRef(!1),v=h=>{if(!s?.contentDocument)return;const r=s.contentDocument.getElementById(h);r&&t.current&&(u.current=!0,i(h),t.current.scrollTo({top:r.offsetTop-20,behavior:"smooth"}),setTimeout(()=>{u.current=!1},1e3))};return o.useEffect(()=>{if(!s?.contentDocument||a.length<=1)return;const h=t.current;if(!h)return;const r=()=>{if(u.current)return;const d=s.contentDocument;if(!d)return;const _=h.scrollTop,F=100,D=a.map(S=>d.getElementById(S.id)).filter(S=>S!==null).map(S=>({id:S.id,top:S.offsetTop}));if(!D.length)return;const L=D.reduce((S,M)=>M.top-F<=_?M:S);i(L?.id||null)},l=()=>{requestAnimationFrame(r)};return h.addEventListener("scroll",l),r(),()=>{h.removeEventListener("scroll",l)}},[s,a,t]),a.length<=1?null:n.jsx("div",{className:p,children:n.jsx("div",{className:"sticky top-1/2 -translate-y-1/2",children:n.jsx(Se,{activeHeading:k||"",items:a,onItemClick:v,onOpenChange:c})})})},je={1:"w-3",2:"w-2",3:"w-1"},Ce={1:"pl-2",2:"pl-6",3:"pl-10"},Se=({items:a,activeHeading:s,onItemClick:t,onOpenChange:p})=>{const[c,k]=o.useState(!1),i=rn.useRef();if(rn.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),a.length===0)return null;const u=d=>Math.min(d,3),v=d=>je[u(d)],h=d=>Ce[u(d)],r=()=>{i.current&&clearTimeout(i.current),k(!0),p?.(!0)},l=()=>{i.current=setTimeout(()=>{k(!1),p?.(!1)},100)};return n.jsxs(Cn,{modal:!1,open:c,onOpenChange:k,children:[n.jsx(Sn,{asChild:!0,children:n.jsx("div",{className:"absolute right-2 top-1/2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black",onMouseEnter:r,onMouseLeave:l,children:a.map(d=>n.jsx("div",{className:`h-[2px] rounded-sm ${s===d.id?"bg-black dark:bg-white":"bg-gray-400 dark:bg-gray-700"} pr-1 transition-all ${v(d.level)}`},d.id))})}),n.jsx(zn,{align:"center",className:"w-[240px] p-2",side:"left",sideOffset:-28,onCloseAutoFocus:d=>d.preventDefault(),onMouseEnter:r,onMouseLeave:l,onOpenAutoFocus:d=>d.preventDefault(),children:n.jsx("nav",{"aria-label":"Table of contents navigation",className:"max-h-[60vh] overflow-y-auto",role:"navigation",children:a.map(d=>n.jsx("button",{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${s===d.id?"text-black dark:text-white":"text-gray-700 dark:text-gray-600"} hover:bg-gray-75 hover:text-gray-900 dark:hover:bg-grey-925 dark:hover:text-white ${h(d.level)}`,type:"button",onClick:()=>t(d.id),children:n.jsx("span",{className:"line-clamp-2",children:d.text})},d.id))})})]})},ze=()=>`<style>
|
|
2
2
|
|
|
3
3
|
/* Variables */
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,bB as A,e as u,b as g,bC as E,r as j,bx as T,by as z,L as S,E as M,c as P,bD as U,S as w,A as $,B,bp as L,n as C,h as v,d as W,s as _,bE as D,bF as H,f as O,P as q}from"./index-X_uC_0DD.js";import{A as V}from"./at-sign-BtKGpnjs.js";import{R as G,U as K}from"./user-round-check-Biw6QBQA.js";import{R as Q}from"./reply-BET0l7FZ.js";const I=({notificationType:a,size:l="lg",className:i})=>{let r,s="";const n="white",o=l==="sm"?13:20,c=l==="sm"?2:1.5;switch(a){case"follow":r=t.jsx(K,{className:`-mr-0.5 -mt-0.5 ${l==="sm"&&"size-[11px]"}`,color:n,size:o,strokeWidth:c}),s="bg-blue-600";break;case"like":r=t.jsx(A,{className:`${l==="sm"?"size-[11px]":"mt-px size-5"}`,color:n,strokeWidth:c}),s="bg-pink-600";break;case"reply":r=t.jsx(Q,{className:"mb-px mr-px",color:n,size:o,strokeWidth:c}),s="bg-purple-600";break;case"repost":r=t.jsx(G,{color:n,size:o,strokeWidth:c}),s="bg-green-500";break;case"mention":r=t.jsx(V,{className:`${l==="sm"?"size-[12px]":"size-5"}`,color:n,size:o,strokeWidth:c}),s="bg-orange-500";break}return t.jsx("div",{className:`flex ${l==="sm"?"size-5":"size-9"} items-center justify-center rounded-full ${s} ${i&&i}`,children:r})},Z=u.createContext(void 0),h=({isGrouped:a,centerAlign:l,children:i,onClick:r,url:s,className:n})=>t.jsx(Z.Provider,{value:{onClick:r,url:s},children:t.jsx("div",{className:`group relative -mx-4 -my-px ${a?"grid":"flex"} ${l?"items-center":"items-start"} cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left break-anywhere hover:bg-gray-75 ${n}`,role:"button",onClick:r,children:i})}),J=({size:a="lg",type:l})=>t.jsx("div",{className:"col-start-1 row-start-1",children:t.jsx(I,{notificationType:l,size:a})}),X=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-1 flex gap-2",children:a}),Y=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-2 -mt-0.5 grow overflow-hidden",children:a});h.Icon=J;h.Avatars=X;h.Content=Y;const ee=()=>t.jsx("div",{className:"h-px w-full bg-gray-150 dark:bg-gray-950"});function te(a){const r=new Date(a).getTime();return(Math.floor(r/864e5)*864e5).toString()}function se(a){const l={};let i=null,r=0;return a.forEach(s=>{s.type!==i&&(r+=1,i=s.type);let n="";const o=`_${te(s.createdAt)}`,c=`_seq${r}`;switch(s.type){case"like":s.post?.id&&(n=`like_${s.post.id}${o}${c}`);break;case"reply":n=`reply_${s.id}`;break;case"repost":s.post?.id&&(n=`repost_${s.post.id}${o}${c}`);break;case"follow":n=`follow_${o}${c}`;break;case"mention":n=`mention_${s.id}`;break}l[n]||(l[n]={id:s.id,type:s.type,actors:[],post:s.post,inReplyTo:s.inReplyTo,createdAt:s.createdAt}),l[n].actors.find(f=>f.id===s.actor.id)||l[n].actors.push(s.actor)}),Object.values(l)}const ae=({group:a})=>{const[l,...i]=a.actors,r=i.length>0,s="cursor-pointer font-semibold hover:underline text-black dark:text-white",n=g(),o=t.jsxs(t.Fragment,{children:[t.jsx(q,{actor:l,align:"center",isCurrentUser:!1,children:t.jsx("span",{className:s,onClick:c=>{c?.stopPropagation(),v(l.handle,n)},children:l.name})}),r&&` and ${i.length} ${i.length>1?"others":"other"}`]});switch(a.type){case"follow":return t.jsxs(t.Fragment,{children:[o," followed you"]});case"like":return t.jsxs(t.Fragment,{children:[o," liked your ",a.post?.type==="article"?"post":"note"]});case"repost":return t.jsxs(t.Fragment,{children:[o," reposted your ",a.post?.type==="article"?"post":"note"]});case"reply":if(a.inReplyTo&&typeof a.inReplyTo!="string")return o;break;case"mention":return o}return t.jsx(t.Fragment,{})},ne=({content:a,className:l,stripTags:i=[]})=>{const r=j.useRef(null),s=g();return j.useEffect(()=>{const n=r.current;if(!n)return;const o=c=>{const y=c.target.closest("a[data-profile]");if(y){const x=y.getAttribute("data-profile")?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(x||"")&&x&&(c.preventDefault(),c.stopPropagation(),v(x,s))}};return n.addEventListener("click",o),()=>{n.removeEventListener("click",o)}},[s,a]),t.jsx("div",{dangerouslySetInnerHTML:{__html:_(a||"",i)},ref:r,className:l})},oe=()=>{const[a,l]=u.useState({}),i=g(),r=e=>{l(d=>({...d,[e]:!d[e]}))},s=()=>{},n=5,{data:o,error:c,fetchNextPage:f,hasNextPage:y,isFetchingNextPage:x,isLoading:b}=E("index"),k=o?.pages.flatMap(e=>se(e.notifications))??Array(10).fill({actors:[{}]}),p=j.useRef(null),N=j.useRef(null);j.useEffect(()=>(p.current&&p.current.disconnect(),p.current=new IntersectionObserver(e=>{e[0].isIntersecting&&y&&!x&&f()}),N.current&&p.current.observe(N.current),()=>{p.current&&p.current.disconnect()}),[y,x,f]);const R=(e,d)=>{switch(e.type){case"like":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"reply":e.post&&e.inReplyTo&&i(`/notes/${encodeURIComponent(e.post.id)}`);break;case"repost":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"follow":e.actors.length>1?r(e.id||`${e.type}_${d}`):v(e.actors[0].handle,i);break;case"mention":e.post&&i(`/notes/${encodeURIComponent(e.post.id)}`);break}};return c&&T(c)?t.jsx(z,{errorCode:c.code,statusCode:c.statusCode}):t.jsx(S,{children:t.jsxs("div",{className:"z-0 flex w-full flex-col items-center",children:[b===!1&&k.length===0&&t.jsxs(M,{children:[t.jsx(P,{children:t.jsx(U,{})}),"Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here."]}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-8 flex w-full max-w-[620px] flex-col max-md:mt-5",children:k.map((e,d)=>t.jsxs(u.Fragment,{children:[t.jsxs(h,{centerAlign:e.actors.length<2&&e.type==="follow",className:"hover:bg-gray-75 dark:hover:bg-gray-950",isGrouped:e.actors.length>1,onClick:()=>R(e,d),children:[b?t.jsx(w,{className:"rounded-full",containerClassName:"flex h-10 w-10"}):e.actors.length>1?t.jsx(h.Icon,{type:e.type}):t.jsxs("div",{className:"relative",children:[t.jsx($,{author:{icon:{url:e.actors[0].avatarUrl||""},name:e.actors[0].name,handle:e.actors[0].handle},size:"notification"},e.actors[0].id),t.jsx(I,{className:"absolute -bottom-1 -right-1 z-10 border-2 border-white dark:border-black",notificationType:e.type,size:"sm"})]}),e.actors.length>1&&t.jsx(h.Avatars,{children:t.jsxs("div",{className:"flex w-full flex-col",children:[t.jsxs("div",{className:"relative flex items-center pl-2",children:[!a[e.id||`${e.type}_${d}`]&&e.actors.slice(0,n).map(m=>t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},className:"-ml-2 !bg-[#F3F3F3] outline outline-2 outline-white group-hover:!bg-[#EDEEF0] group-hover:outline-gray-75 dark:outline-black group-hover:dark:outline-gray-950",size:"notification"},m.id)),e.actors.length>n&&!a[e.id||`${e.type}_${d}`]&&t.jsx("div",{className:"absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white",children:`+${e.actors.length-n}`}),e.actors.length>1&&t.jsxs(B,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${a[e.id||`${e.type}_${d}`]?"ml-[-20px]":"ml-0 w-[28px]"}`,variant:"ghost",onClick:m=>{m?.stopPropagation(),r(e.id||`${e.type}_${d}`)},children:[t.jsx(L,{className:`${a[e.id||`${e.type}_${d}`]?"rotate-180":""}`,size:20,strokeWidth:1.5}),a[e.id||`${e.type}_${d}`]?"Hide":t.jsx("span",{className:"sr-only",children:"Show all"})]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${a[e.id||`${e.type}_${d}`]?"mb-2 max-h-[1384px] opacity-100":"max-h-0 opacity-0"}`,children:a[e.id||`${e.type}_${d}`]&&e.actors.length>1&&t.jsx("div",{className:"flex flex-col gap-2 pt-2",children:e.actors.map(m=>t.jsxs("div",{className:"group/item flex items-center justify-between gap-4 break-anywhere",onClick:F=>{F?.stopPropagation(),v(m.handle,i)},children:[t.jsxs("div",{className:"flex min-w-0 items-center",children:[t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},size:"xs"}),t.jsx("span",{className:"ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white",children:m.name}),t.jsx("span",{className:"ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600",children:m.handle})]}),e.type==="follow"&&!m.followedByMe&&t.jsx(C,{following:!1,handle:m.handle,variant:"link"})]},m.id))})})]})}),t.jsxs(h.Content,{children:[t.jsx("div",{children:b?t.jsxs(t.Fragment,{children:[t.jsx(w,{}),t.jsx(w,{className:"w-full max-w-60"})]}):t.jsxs("div",{className:"flex justify-between",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate",children:t.jsx(ae,{group:e})}),e.actors.length<2&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mt-px text-[8px] text-gray-700 dark:text-gray-600",children:"•"}),t.jsx("span",{className:"mt-0.5 text-sm text-gray-700 dark:text-gray-600",children:W(e,!1)})]})]}),e.actors.length===1&&(e.type==="follow"||e.type==="reply"||e.type==="mention")&&!e.actors[0].followedByMe&&t.jsx(C,{following:!1,handle:e.actors[0].handle,variant:"link"})]})}),(e.type==="reply"&&e.inReplyTo||e.type==="mention"||e.type==="like"&&!e.post?.name&&e.post?.content||e.type==="repost"&&!e.post?.name&&e.post?.content)&&(e.type!=="reply"&&e.type!=="mention"?t.jsxs("div",{className:"ap-note-content mt-0.5 line-clamp-1 text-pretty text-sm text-gray-700 dark:text-gray-600",children:[e.post?.type==="article"&&e.post?.title&&t.jsxs(t.Fragment,{children:[e.post.title," — "]}),t.jsx("span",{dangerouslySetInnerHTML:{__html:_(e.post?.content||"")}})]}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-925/30 group-hover:dark:bg-black/40",children:[t.jsx(ne,{className:"ap-note-content text-pretty",content:e.post?.content||"",stripTags:["a"]}),e.post&&e.post.attachments&&e.post.attachments.length>0&&t.jsx("div",{className:"notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]",children:D({...e.post,type:"Note",attachment:e.post.attachments})})]})})),(e.type==="reply"&&e.post||e.type==="mention")&&t.jsx("div",{className:"mt-1.5",children:t.jsx(H,{actor:{...e.actors[0],icon:{url:e.actors[0].avatarUrl||""},id:e.actors[0].url,preferredUsername:e.actors[0].handle?.replace(/^@([^@]+)@.*$/,"$1")||"unknown"},buttonClassName:"hover:bg-gray-200",commentCount:e.post.replyCount||0,layout:"notification",likeCount:e.post.likeCount||0,object:{...e.post,liked:e.post.likedByMe,reposted:e.post.repostedByMe},repostCount:e.post.repostCount||0,onLikeClick:s})})]})]}),d<k.length-1&&t.jsx("div",{className:"pl-[52px]",children:t.jsx(ee,{})})]},e.id||`${e.type}_${d}`))}),t.jsx("div",{ref:N,className:"h-1"}),x&&t.jsx("div",{className:"-mt-4 mb-8 flex flex-col items-center justify-center space-y-4 text-center",children:t.jsx(O,{size:"md"})})]})]})})};export{oe as default};
|
|
1
|
+
import{j as t,bB as A,e as u,b as g,bC as E,r as j,bx as T,by as z,L as S,E as M,c as P,bD as U,S as w,A as $,B,bp as L,n as C,h as v,d as W,s as _,bE as D,bF as H,f as O,P as q}from"./index-Dq_j8mTf.js";import{A as V}from"./at-sign-DHUgIxNb.js";import{R as G,U as K}from"./user-round-check-pBOLjTqi.js";import{R as Q}from"./reply-DqXFv78k.js";const I=({notificationType:a,size:l="lg",className:i})=>{let r,s="";const n="white",o=l==="sm"?13:20,c=l==="sm"?2:1.5;switch(a){case"follow":r=t.jsx(K,{className:`-mr-0.5 -mt-0.5 ${l==="sm"&&"size-[11px]"}`,color:n,size:o,strokeWidth:c}),s="bg-blue-600";break;case"like":r=t.jsx(A,{className:`${l==="sm"?"size-[11px]":"mt-px size-5"}`,color:n,strokeWidth:c}),s="bg-pink-600";break;case"reply":r=t.jsx(Q,{className:"mb-px mr-px",color:n,size:o,strokeWidth:c}),s="bg-purple-600";break;case"repost":r=t.jsx(G,{color:n,size:o,strokeWidth:c}),s="bg-green-500";break;case"mention":r=t.jsx(V,{className:`${l==="sm"?"size-[12px]":"size-5"}`,color:n,size:o,strokeWidth:c}),s="bg-orange-500";break}return t.jsx("div",{className:`flex ${l==="sm"?"size-5":"size-9"} items-center justify-center rounded-full ${s} ${i&&i}`,children:r})},Z=u.createContext(void 0),h=({isGrouped:a,centerAlign:l,children:i,onClick:r,url:s,className:n})=>t.jsx(Z.Provider,{value:{onClick:r,url:s},children:t.jsx("div",{className:`group relative -mx-4 -my-px ${a?"grid":"flex"} ${l?"items-center":"items-start"} cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left break-anywhere hover:bg-gray-75 ${n}`,role:"button",onClick:r,children:i})}),J=({size:a="lg",type:l})=>t.jsx("div",{className:"col-start-1 row-start-1",children:t.jsx(I,{notificationType:l,size:a})}),X=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-1 flex gap-2",children:a}),Y=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-2 -mt-0.5 grow overflow-hidden",children:a});h.Icon=J;h.Avatars=X;h.Content=Y;const ee=()=>t.jsx("div",{className:"h-px w-full bg-gray-150 dark:bg-gray-950"});function te(a){const r=new Date(a).getTime();return(Math.floor(r/864e5)*864e5).toString()}function se(a){const l={};let i=null,r=0;return a.forEach(s=>{s.type!==i&&(r+=1,i=s.type);let n="";const o=`_${te(s.createdAt)}`,c=`_seq${r}`;switch(s.type){case"like":s.post?.id&&(n=`like_${s.post.id}${o}${c}`);break;case"reply":n=`reply_${s.id}`;break;case"repost":s.post?.id&&(n=`repost_${s.post.id}${o}${c}`);break;case"follow":n=`follow_${o}${c}`;break;case"mention":n=`mention_${s.id}`;break}l[n]||(l[n]={id:s.id,type:s.type,actors:[],post:s.post,inReplyTo:s.inReplyTo,createdAt:s.createdAt}),l[n].actors.find(f=>f.id===s.actor.id)||l[n].actors.push(s.actor)}),Object.values(l)}const ae=({group:a})=>{const[l,...i]=a.actors,r=i.length>0,s="cursor-pointer font-semibold hover:underline text-black dark:text-white",n=g(),o=t.jsxs(t.Fragment,{children:[t.jsx(q,{actor:l,align:"center",isCurrentUser:!1,children:t.jsx("span",{className:s,onClick:c=>{c?.stopPropagation(),v(l.handle,n)},children:l.name})}),r&&` and ${i.length} ${i.length>1?"others":"other"}`]});switch(a.type){case"follow":return t.jsxs(t.Fragment,{children:[o," followed you"]});case"like":return t.jsxs(t.Fragment,{children:[o," liked your ",a.post?.type==="article"?"post":"note"]});case"repost":return t.jsxs(t.Fragment,{children:[o," reposted your ",a.post?.type==="article"?"post":"note"]});case"reply":if(a.inReplyTo&&typeof a.inReplyTo!="string")return o;break;case"mention":return o}return t.jsx(t.Fragment,{})},ne=({content:a,className:l,stripTags:i=[]})=>{const r=j.useRef(null),s=g();return j.useEffect(()=>{const n=r.current;if(!n)return;const o=c=>{const y=c.target.closest("a[data-profile]");if(y){const x=y.getAttribute("data-profile")?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(x||"")&&x&&(c.preventDefault(),c.stopPropagation(),v(x,s))}};return n.addEventListener("click",o),()=>{n.removeEventListener("click",o)}},[s,a]),t.jsx("div",{dangerouslySetInnerHTML:{__html:_(a||"",i)},ref:r,className:l})},oe=()=>{const[a,l]=u.useState({}),i=g(),r=e=>{l(d=>({...d,[e]:!d[e]}))},s=()=>{},n=5,{data:o,error:c,fetchNextPage:f,hasNextPage:y,isFetchingNextPage:x,isLoading:b}=E("index"),k=o?.pages.flatMap(e=>se(e.notifications))??Array(10).fill({actors:[{}]}),p=j.useRef(null),N=j.useRef(null);j.useEffect(()=>(p.current&&p.current.disconnect(),p.current=new IntersectionObserver(e=>{e[0].isIntersecting&&y&&!x&&f()}),N.current&&p.current.observe(N.current),()=>{p.current&&p.current.disconnect()}),[y,x,f]);const R=(e,d)=>{switch(e.type){case"like":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"reply":e.post&&e.inReplyTo&&i(`/notes/${encodeURIComponent(e.post.id)}`);break;case"repost":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"follow":e.actors.length>1?r(e.id||`${e.type}_${d}`):v(e.actors[0].handle,i);break;case"mention":e.post&&i(`/notes/${encodeURIComponent(e.post.id)}`);break}};return c&&T(c)?t.jsx(z,{errorCode:c.code,statusCode:c.statusCode}):t.jsx(S,{children:t.jsxs("div",{className:"z-0 flex w-full flex-col items-center",children:[b===!1&&k.length===0&&t.jsxs(M,{children:[t.jsx(P,{children:t.jsx(U,{})}),"Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here."]}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-8 flex w-full max-w-[620px] flex-col max-md:mt-5",children:k.map((e,d)=>t.jsxs(u.Fragment,{children:[t.jsxs(h,{centerAlign:e.actors.length<2&&e.type==="follow",className:"hover:bg-gray-75 dark:hover:bg-gray-950",isGrouped:e.actors.length>1,onClick:()=>R(e,d),children:[b?t.jsx(w,{className:"rounded-full",containerClassName:"flex h-10 w-10"}):e.actors.length>1?t.jsx(h.Icon,{type:e.type}):t.jsxs("div",{className:"relative",children:[t.jsx($,{author:{icon:{url:e.actors[0].avatarUrl||""},name:e.actors[0].name,handle:e.actors[0].handle},size:"notification"},e.actors[0].id),t.jsx(I,{className:"absolute -bottom-1 -right-1 z-10 border-2 border-white dark:border-black",notificationType:e.type,size:"sm"})]}),e.actors.length>1&&t.jsx(h.Avatars,{children:t.jsxs("div",{className:"flex w-full flex-col",children:[t.jsxs("div",{className:"relative flex items-center pl-2",children:[!a[e.id||`${e.type}_${d}`]&&e.actors.slice(0,n).map(m=>t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},className:"-ml-2 !bg-[#F3F3F3] outline outline-2 outline-white group-hover:!bg-[#EDEEF0] group-hover:outline-gray-75 dark:outline-black group-hover:dark:outline-gray-950",size:"notification"},m.id)),e.actors.length>n&&!a[e.id||`${e.type}_${d}`]&&t.jsx("div",{className:"absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white",children:`+${e.actors.length-n}`}),e.actors.length>1&&t.jsxs(B,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${a[e.id||`${e.type}_${d}`]?"ml-[-20px]":"ml-0 w-[28px]"}`,variant:"ghost",onClick:m=>{m?.stopPropagation(),r(e.id||`${e.type}_${d}`)},children:[t.jsx(L,{className:`${a[e.id||`${e.type}_${d}`]?"rotate-180":""}`,size:20,strokeWidth:1.5}),a[e.id||`${e.type}_${d}`]?"Hide":t.jsx("span",{className:"sr-only",children:"Show all"})]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${a[e.id||`${e.type}_${d}`]?"mb-2 max-h-[1384px] opacity-100":"max-h-0 opacity-0"}`,children:a[e.id||`${e.type}_${d}`]&&e.actors.length>1&&t.jsx("div",{className:"flex flex-col gap-2 pt-2",children:e.actors.map(m=>t.jsxs("div",{className:"group/item flex items-center justify-between gap-4 break-anywhere",onClick:F=>{F?.stopPropagation(),v(m.handle,i)},children:[t.jsxs("div",{className:"flex min-w-0 items-center",children:[t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},size:"xs"}),t.jsx("span",{className:"ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white",children:m.name}),t.jsx("span",{className:"ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600",children:m.handle})]}),e.type==="follow"&&!m.followedByMe&&t.jsx(C,{following:!1,handle:m.handle,variant:"link"})]},m.id))})})]})}),t.jsxs(h.Content,{children:[t.jsx("div",{children:b?t.jsxs(t.Fragment,{children:[t.jsx(w,{}),t.jsx(w,{className:"w-full max-w-60"})]}):t.jsxs("div",{className:"flex justify-between",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate",children:t.jsx(ae,{group:e})}),e.actors.length<2&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mt-px text-[8px] text-gray-700 dark:text-gray-600",children:"•"}),t.jsx("span",{className:"mt-0.5 text-sm text-gray-700 dark:text-gray-600",children:W(e,!1)})]})]}),e.actors.length===1&&(e.type==="follow"||e.type==="reply"||e.type==="mention")&&!e.actors[0].followedByMe&&t.jsx(C,{following:!1,handle:e.actors[0].handle,variant:"link"})]})}),(e.type==="reply"&&e.inReplyTo||e.type==="mention"||e.type==="like"&&!e.post?.name&&e.post?.content||e.type==="repost"&&!e.post?.name&&e.post?.content)&&(e.type!=="reply"&&e.type!=="mention"?t.jsxs("div",{className:"ap-note-content mt-0.5 line-clamp-1 text-pretty text-sm text-gray-700 dark:text-gray-600",children:[e.post?.type==="article"&&e.post?.title&&t.jsxs(t.Fragment,{children:[e.post.title," — "]}),t.jsx("span",{dangerouslySetInnerHTML:{__html:_(e.post?.content||"")}})]}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-925/30 group-hover:dark:bg-black/40",children:[t.jsx(ne,{className:"ap-note-content text-pretty",content:e.post?.content||"",stripTags:["a"]}),e.post&&e.post.attachments&&e.post.attachments.length>0&&t.jsx("div",{className:"notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]",children:D({...e.post,type:"Note",attachment:e.post.attachments})})]})})),(e.type==="reply"&&e.post||e.type==="mention")&&t.jsx("div",{className:"mt-1.5",children:t.jsx(H,{actor:{...e.actors[0],icon:{url:e.actors[0].avatarUrl||""},id:e.actors[0].url,preferredUsername:e.actors[0].handle?.replace(/^@([^@]+)@.*$/,"$1")||"unknown"},buttonClassName:"hover:bg-gray-200",commentCount:e.post.replyCount||0,layout:"notification",likeCount:e.post.likeCount||0,object:{...e.post,liked:e.post.likedByMe,reposted:e.post.repostedByMe},repostCount:e.post.repostCount||0,onLikeClick:s})})]})]}),d<k.length-1&&t.jsx("div",{className:"pl-[52px]",children:t.jsx(ee,{})})]},e.id||`${e.type}_${d}`))}),t.jsx("div",{ref:N,className:"h-1"}),x&&t.jsx("div",{className:"-mt-4 mb-8 flex flex-col items-center justify-center space-y-4 text-center",children:t.jsx(O,{size:"md"})})]})]})})};export{oe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as v,aq as N,ar as P,j as u,as as S,at as w,au as p,av as x,aw as F,ax as D,ay as T,az as V}from"./index-
|
|
1
|
+
import{r as v,aq as N,ar as P,j as u,as as S,at as w,au as p,av as x,aw as F,ax as D,ay as T,az as V}from"./index-Dq_j8mTf.js";var g="Tabs",[G]=S(g,[x]),C=x(),[L,m]=G(g),h=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,onValueChange:r,defaultValue:c,orientation:t="horizontal",dir:d,activationMode:b="automatic",...f}=e,s=N(d),[o,l]=P({prop:a,onChange:r,defaultProp:c??"",caller:g});return u.jsx(L,{scope:i,baseId:w(),value:o,onValueChange:l,orientation:t,dir:s,activationMode:b,children:u.jsx(p.div,{dir:s,"data-orientation":t,...f,ref:n})})});h.displayName=g;var I="TabsList",R=v.forwardRef((e,n)=>{const{__scopeTabs:i,loop:a=!0,...r}=e,c=m(I,i),t=C(i);return u.jsx(F,{asChild:!0,...t,orientation:c.orientation,dir:c.dir,loop:a,children:u.jsx(p.div,{role:"tablist","aria-orientation":c.orientation,...r,ref:n})})});R.displayName=I;var y="TabsTrigger",_=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,disabled:r=!1,...c}=e,t=m(y,i),d=C(i),b=j(t.baseId,a),f=M(t.baseId,a),s=a===t.value;return u.jsx(D,{asChild:!0,...d,focusable:!r,active:s,children:u.jsx(p.button,{type:"button",role:"tab","aria-selected":s,"aria-controls":f,"data-state":s?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:b,...c,ref:n,onMouseDown:T(e.onMouseDown,o=>{!r&&o.button===0&&o.ctrlKey===!1?t.onValueChange(a):o.preventDefault()}),onKeyDown:T(e.onKeyDown,o=>{[" ","Enter"].includes(o.key)&&t.onValueChange(a)}),onFocus:T(e.onFocus,()=>{const o=t.activationMode!=="manual";!s&&!r&&o&&t.onValueChange(a)})})})});_.displayName=y;var A="TabsContent",E=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,forceMount:r,children:c,...t}=e,d=m(A,i),b=j(d.baseId,a),f=M(d.baseId,a),s=a===d.value,o=v.useRef(s);return v.useEffect(()=>{const l=requestAnimationFrame(()=>o.current=!1);return()=>cancelAnimationFrame(l)},[]),u.jsx(V,{present:r||s,children:({present:l})=>u.jsx(p.div,{"data-state":s?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":b,hidden:!l,id:f,tabIndex:0,...t,ref:n,style:{...e.style,animationDuration:o.current?"0s":void 0},children:l&&c})})});E.displayName=A;function j(e,n){return`${e}-trigger-${n}`}function M(e,n){return`${e}-content-${n}`}var k=h,K=R,q=_,z=E;export{z as C,K as L,k as R,q as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as v,u as b,b as j,l as y,r as k,j as e,L as F,H as P,B,X as E,e as C,f as T,m as S,P as U,A,S as x,n as H,o as L,s as M}from"./index-
|
|
1
|
+
import{k as v,u as b,b as j,l as y,r as k,j as e,L as F,H as P,B,X as E,e as C,f as T,m as S,P as U,A,S as x,n as H,o as L,s as M}from"./index-Dq_j8mTf.js";import{T as I}from"./topic-filter-BmvO9gja.js";import{S as z}from"./sprout-C96gimQS.js";const f=({profile:s,update:l,isLoading:t,onOpenChange:r})=>{const o=S("index","me"),{data:m}=o,n=s.handle===m?.handle,p=()=>{l(s.id,{followedByMe:!0})},i=()=>{l(s.id,{followedByMe:!1})},c=j();return e.jsx("div",{className:"flex w-full cursor-pointer items-start gap-3 pt-4 [&:last-of-type>:nth-child(2)]:border-none",onClick:()=>{c(`/profile/${s.handle}`)},children:e.jsxs("div",{className:"flex w-full flex-col gap-1 border-b border-gray-200 pb-4 dark:border-gray-950",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(U,{actor:s,isCurrentUser:n,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(A,{author:{icon:{url:s.avatarUrl},name:s.name,handle:s.handle},onClick:()=>r?.(!1)}),e.jsxs("div",{className:"-mt-0.5 flex grow flex-col break-anywhere",children:[e.jsx("span",{className:"line-clamp-1 font-semibold text-black dark:text-white",children:t?e.jsx(x,{className:"w-full max-w-48"}):s.name}),e.jsx("span",{className:"line-clamp-1 text-md text-gray-700 dark:text-gray-600",children:t?e.jsx(x,{className:"w-32"}):s.handle})]})]})}),t?e.jsx("div",{className:"inline-flex items-center",children:e.jsx(x,{className:"w-24"})}):n?null:e.jsx(H,{className:"ml-auto",following:s.followedByMe,handle:s.handle,type:"primary",onFollow:p,onUnfollow:i})]}),e.jsx("div",{className:"pl-[52px]",children:t?e.jsx(x,{className:"w-full max-w-96"}):s.bio&&e.jsx("div",{dangerouslySetInnerHTML:{__html:L(M(s.bio,["a","br"]))},className:"ap-profile-content pointer-events-none mt-0 line-clamp-2 max-w-[460px] break-anywhere"})})]})})},Q=()=>{const{isExplainerClosed:s,setExplainerClosed:l}=v(),t=b(),r=j(),o=t.topic||"top",{exploreProfilesQuery:m,updateExploreProfile:n}=y("index",o),{data:p,isLoading:i,fetchNextPage:c,hasNextPage:h,isFetchingNextPage:u}=m,g=Array(10).fill(null).map((a,d)=>({id:`skeleton-${d}`,name:"",handle:"",avatarUrl:"",bio:"",url:"",followedByMe:!1})),w=p?.pages.flatMap(a=>a.accounts)||[];return k.useEffect(()=>{const a=document.querySelector(".load-more-trigger");if(!a)return;const d=new IntersectionObserver(N=>{N[0].isIntersecting&&h&&!u&&c()},{threshold:.1});return d.observe(a),()=>d.disconnect()},[h,u,c]),e.jsxs(F,{children:[!s&&e.jsxs("div",{className:"relative mb-6 flex items-start gap-1 rounded-md bg-gradient-to-r from-[#CFB0FF66] to-[#B6E8FF66] p-4 pr-10 dark:from-[#CFB0FF20] dark:to-[#B6E8FF20]",children:[e.jsx("div",{className:"min-w-[46px]",children:e.jsx(z,{className:"text-purple",size:46,strokeWidth:.75})}),e.jsxs("div",{className:"mt-1 flex flex-col gap-[2px]",children:[e.jsx(P,{className:"text-pretty",children:"The fastest way to grow your followers, is to follow others!"}),e.jsx("p",{className:"2xl:text-pretty text-balance text-sm text-black/60 dark:text-white/60",children:"Here are some recommendations to get you started, from Ghost publishers and other great accounts from around the social web."})]}),e.jsx(B,{className:"absolute right-4 top-[17px] size-6 opacity-40",variant:"link",onClick:()=>l(!0),children:e.jsx(E,{size:20})})]}),e.jsx(I,{currentTopic:o,excludeTopics:["following"],onTopicChange:a=>{a==="top"?r("/explore",{replace:!0}):r(`/explore/${a}`,{replace:!0})}}),e.jsx("div",{className:"mt-12 flex flex-col gap-12 pb-20 max-md:mt-5",children:i?e.jsx("div",{children:g.map(a=>e.jsx("div",{className:"mx-auto w-full max-w-[640px]",children:e.jsx(f,{isLoading:i,profile:a,update:()=>{}})},a.id))}):e.jsxs("div",{className:"mx-auto flex w-full max-w-[640px] flex-col items-center",children:[e.jsx("div",{className:"w-full",children:w.map(a=>e.jsx(C.Fragment,{children:e.jsx(f,{isLoading:!1,profile:a,update:n})},a.id))}),e.jsx("div",{className:"load-more-trigger h-4 w-full"}),u&&e.jsx("div",{className:"mt-2 flex w-full justify-center",children:e.jsx(T,{size:"sm"})})]})})]})};export{Q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aM as me,j as e,B as ue,r as T,b3 as ne,b4 as le,bR as Se,aj as o,cf as I,ah as A,cg as Z,aN as Te,ch as F,aW as Me,ap as ke,aY as Pe,a_ as ee,af as he,ag as re,e as xe,S as _e,ci as Be,bJ as Ee,bK as Ye,bL as Oe,bM as Ve,bN as Fe,bO as Re,bU as fe}from"./index-X_uC_0DD.js";import{s as ae,d as Ge,g as te,S as $e,a as Ae,D as Le,b as ze}from"./stats-view-DUoDKh7r.js";import{E as pe}from"./empty-indicator-DOQCKEXD.js";import{A as Ke,a as Ie}from"./wallet-cards-aM5Ct3OB.js";import{C as Ue,a as He,b as We,B as be}from"./chart-tL51cfF9.js";import{G as ge,C as qe,X as Qe,Y as Xe}from"./gh-chart-CaA6rQiP.js";import{T as ce,a as de,K as se,d as R,e as Je,b as U,c as je}from"./tabs--ia9i-R8.js";import{g as Ze}from"./audience-select-DuSCQEyi.js";import{B as ea,S as H}from"./sort-button-DkfQ-8QJ.js";import{S as aa,C as K,g as sa,a as ra,b as ta}from"./url-helpers-BuFo9dQz.js";import{e as X,c as M,f as b,g as na,a as we,b as De,d as G}from"./table-PBYP6iVu.js";import{g as oe}from"./currency-fEUUCkj0.js";import{g as la}from"./source-utils-B1S3ZHA2.js";import{a as ia,h as oa}from"./stats-Cu49FJzo.js";import{u as ca}from"./referrers-BK-mXdat.js";import{j as da,C as ve,c as ye,a as ma,b as ua,h as ha}from"./pagemenu-CUEgz3GC.js";import{u as pa}from"./use-growth-stats-DY2E0ltn.js";import{C as xa}from"./lucide-react-DNj9Mt50.js";import"./select-BH3t_tDB.js";import"./message-square-text-DJWDCab0.js";import"./sprout-gjsBxaCU.js";import"./_baseAssignValue-CPzElAl9.js";import"./index-BNkw6KwF.js";import"./a-large-small-2Oh9oqBr.js";import"./at-sign-BtKGpnjs.js";import"./copy-B8yuX-e4.js";import"./hash-ZzZYv2ek.js";import"./inbox-C5KDymI8.js";import"./minus-B7zQY2p1.js";import"./tags-DwsoamaL.js";import"./square-DsGufPa-.js";import"./user-round-check-Biw6QBQA.js";import"./repeat-CQvZJI02.js";import"./reply-BET0l7FZ.js";import"./trash-C2kuVkXA.js";const Ce=({className:i})=>{const h=me();return e.jsx(pe,{actions:e.jsx(ue,{variant:"outline",onClick:()=>h("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:i,description:"Enable member source tracking in settings to see which content drives member growth.",title:"Member sources have been disabled",children:e.jsx(Ke,{})})},fa=({chartData:i,subscriptionData:h,totals:g,initialTab:u="total-members",currencySymbol:p,isLoading:x})=>{const[s,j]=T.useState(u),[S,L]=T.useState("total"),{range:r}=ne(),{appSettings:_}=le(),W=me(),[E]=Se();T.useEffect(()=>{j(u)},[u]);const w=a=>{j(a);const n=new URLSearchParams(E);n.set("tab",a),W(`?${n.toString()}`,{replace:!0})},{totalMembers:Y,freeMembers:O,paidMembers:V,mrr:k,percentChanges:D,directions:t}=g,y=(a,n)=>{if(n===1){const C=A().format("YYYY-MM-DD"),$=a.find(J=>J.date===C);return[{date:C,signups:$?.signups||0,cancellations:$?.cancellations||0}]}const{startDate:d,endDate:m}=he(n),c=A(m).diff(A(d),"days"),v=Ge(n,c,"sum"),q=new Map(a.map(C=>[C.date,C])),Q=[],P=A(d),ie=A(m);for(;P.isSameOrBefore(ie);){let C,$;switch(v){case"weekly":C=P.startOf("week").format("YYYY-MM-DD"),$="week";break;case"monthly":C=P.startOf("month").format("YYYY-MM-DD"),$="month";break;default:C=P.format("YYYY-MM-DD"),$="day"}const J=q.get(C);J?Q.push(J):Q.push({date:C,signups:0,cancellations:0}),P.add(1,$)}return Q},f=T.useMemo(()=>{if(!i||i.length===0)return[];let a=[],n="value";switch(s){case"free-members":n="free";break;case"paid-members":n="paid";break;case"mrr":{n="mrr";break}default:n="value"}a=ae(i,r,n,"exact");let d=[];switch(s){case"free-members":d=a.map(m=>({...m,value:m.free,formattedValue:o(m.free),label:"Free members"}));break;case"paid-members":d=a.map(m=>({...m,value:m.paid,formattedValue:o(m.paid),label:"Paid members"}));break;case"mrr":d=a.map(m=>({...m,value:I(m.mrr),formattedValue:`${p}${o(I(m.mrr))}`,label:"MRR"}));break;default:d=a.map(m=>{const c=m.free+m.paid;return{...m,value:c,formattedValue:o(c),label:"Total members"}})}return d},[s,i,r,p]),N={"total-members":{color:"hsl(var(--chart-darkblue))"},"free-members":{color:"hsl(var(--chart-blue))"},"paid-members":{color:"hsl(var(--chart-purple))"},mrr:{color:"hsl(var(--chart-teal))"}},z=T.useMemo(()=>{if(s!=="paid-members")return[];if(h&&h.length>0){if(r===1){const c=A().format("YYYY-MM-DD"),v=h.find(q=>q.date===c);return[{date:Z(c,r),new:v?.signups||0,cancelled:-(v?.cancellations||0)}]}const a=ae(h,r,"signups","sum"),n=ae(h,r,"cancellations","sum"),d=a.map(c=>({date:c.date,signups:c.signups||0,cancellations:n.find(v=>v.date===c.date)?.cancellations||0}));return n.forEach(c=>{d.find(v=>v.date===c.date)||d.push({date:c.date,signups:0,cancellations:c.cancellations||0})}),d.sort((c,v)=>new Date(c.date).getTime()-new Date(v.date).getTime()),y(d,r).map(c=>({date:Z(c.date,r),new:c.signups||0,cancelled:-(c.cancellations||0)}))}else{if(!i||i.length===0)return[];if(r===1){const n=A().format("YYYY-MM-DD"),d=i.find(m=>m.date===n);return[{date:Z(n,r),new:d?.paid_subscribed||0,cancelled:-(d?.paid_canceled||0)}]}return ae(i,r,"paid","exact").map(n=>({date:Z(n.date,r),new:n.paid_subscribed||0,cancelled:-(n.paid_canceled||0)}))}},[s,i,h,r]),B={new:{label:"New",color:"hsl(var(--chart-teal))"},cancelled:{label:"Cancelled",color:"hsl(var(--chart-rose))"}};if(x)return e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(Te,{})});const l="-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]";return e.jsxs(ce,{defaultValue:u,variant:"kpis",children:[e.jsxs(de,{className:`-mx-6 ${_?.paidMembersEnabled?"hidden grid-cols-4 lg:!visible lg:!grid":"grid grid-cols-4"}`,children:[e.jsx(se,{className:_?.paidMembersEnabled?"":"cursor-auto after:hidden",value:"total-members",onClick:()=>{_?.paidMembersEnabled&&w("total-members")},children:e.jsx(R,{color:"hsl(var(--chart-darkblue))",diffDirection:r===F.allTime.value?"hidden":t.total,diffValue:D.total,label:"Total members",value:o(Y)})}),_?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(se,{value:"free-members",onClick:()=>{w("free-members")},children:e.jsx(R,{color:"hsl(var(--chart-blue))",diffDirection:r===F.allTime.value?"hidden":t.free,diffValue:D.free,label:"Free members",value:o(O)})}),e.jsx(se,{value:"paid-members",onClick:()=>{w("paid-members")},children:e.jsx(R,{color:"hsl(var(--chart-purple))",diffDirection:r===F.allTime.value?"hidden":t.paid,diffValue:D.paid,label:"Paid members",value:o(V)})}),e.jsx(se,{value:"mrr",onClick:()=>{w("mrr")},children:e.jsx(R,{color:"hsl(var(--chart-teal))",diffDirection:r===F.allTime.value?"hidden":t.mrr,diffValue:D.mrr,label:"MRR",value:`${p}${o(I(k))}`})})]})]}),_?.paidMembersEnabled&&e.jsxs(Me,{children:[e.jsx(ke,{className:"lg:hidden",asChild:!0,children:e.jsxs(Je,{children:[s==="total-members"&&e.jsx(R,{color:"hsl(var(--chart-darkblue))",diffDirection:r===F.allTime.value?"hidden":t.total,diffValue:D.total,label:"Total members",value:o(Y)}),s==="free-members"&&e.jsx(R,{color:"hsl(var(--chart-blue))",diffDirection:r===F.allTime.value?"hidden":t.free,diffValue:D.free,label:"Free members",value:o(O)}),s==="paid-members"&&e.jsx(R,{color:"hsl(var(--chart-purple))",diffDirection:r===F.allTime.value?"hidden":t.paid,diffValue:D.paid,label:"Paid members",value:o(V)}),s==="mrr"&&e.jsx(R,{color:"hsl(var(--chart-teal))",diffDirection:r===F.allTime.value?"hidden":t.mrr,diffValue:D.mrr,label:"MRR",value:`${p}${o(I(k))}`})]})}),e.jsxs(Pe,{align:"end",className:"w-56",children:[e.jsx(ee,{onClick:()=>w("total-members"),children:"Total members"}),e.jsx(ee,{onClick:()=>w("free-members"),children:"Free members"}),e.jsx(ee,{onClick:()=>w("paid-members"),children:"Paid members"}),e.jsx(ee,{onClick:()=>w("mrr"),children:"MRR"})]})]}),e.jsx("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:s==="paid-members"?e.jsxs(ce,{defaultValue:S,variant:"button-sm",onValueChange:a=>{L(a)},children:[e.jsx("div",{className:"mb-4 mt-2 flex w-full items-center justify-start",children:e.jsxs(de,{className:"flex items-center",children:[e.jsx(U,{value:"total",children:"Total"}),e.jsx(U,{value:"change",children:"Change"})]})}),e.jsx(je,{value:"total",children:e.jsx(ge,{className:l,color:N[s].color,data:f,dataFormatter:o,id:"paid-members",range:r})}),e.jsxs(je,{value:"change",children:[e.jsx(Ue,{className:"mt-6 aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]",config:B,children:e.jsxs(ea,{data:z,stackOffset:"sign",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tealGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-new)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-new)",stopOpacity:.6})]})}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"roseGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-cancelled)",stopOpacity:.6}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-cancelled)",stopOpacity:.8})]})}),e.jsx(qe,{vertical:!1}),e.jsx(Qe,{axisLine:!1,dataKey:"date",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Xe,{axisLine:!1,tickFormatter:a=>a<0?o(a*-1):o(a),tickLine:!1}),e.jsx(He,{content:e.jsx(We,{className:"!min-w-[120px] px-3 py-2",formatter:(a,n,d,m)=>{const c=Number(a);let v="0";c===0?v="0":v=c<0?o(c*-1):o(c);const q=Number(d?.payload?.new||0),Q=Number(d?.payload?.cancelled||0),P=q+Q,ie=P===0?"0":P>0?`+${o(P)}`:o(P);return e.jsxs("div",{className:"flex w-full flex-col",children:[m===0&&e.jsx("div",{className:"mb-1 text-sm font-medium text-foreground",children:d?.payload?.date}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50",style:{"--color-bg":`var(--color-${n})`}}),e.jsx("span",{className:"text-sm text-muted-foreground",children:B[n]?.label||n})]}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:v})]}),m===1&&e.jsxs("div",{className:"mt-1 flex w-full items-center justify-between gap-4 border-t pt-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Net change"}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:ie})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),e.jsx(be,{activeBar:{fillOpacity:1},dataKey:"new",fill:"url(#tealGradient)",fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:"a"}),e.jsx(be,{activeBar:{fillOpacity:1},dataKey:"cancelled",fill:"url(#roseGradient)",fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:"a"})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:B.new.color}}),"New"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:B.cancelled.color}}),"Cancelled"]})]})]})]}):e.jsx(ge,{className:l,color:N[s].color,data:f,dataFormatter:s==="mrr"?a=>`${p}${o(a)}`:o,id:"mrr",range:r})})]})},ba=(i,h="signups desc",g=50)=>{const{audience:u}=ne(),{startDate:p,endDate:x,timezone:s}=he(i),j={date_from:re(p),date_to:re(x),member_status:Ze(u),order:h,limit:g.toString()};return s&&(j.timezone=s),ca({searchParams:j})},Ne=({data:i,currencySymbol:h,limit:g,defaultSourceIconUrl:u})=>{const p=g?i.slice(0,g):i,{appSettings:x}=le();return e.jsx(X,{children:p.map(s=>e.jsxs(M,{className:"last:border-none",children:[e.jsx(b,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(aa,{defaultSourceIconUrl:u,displayName:s.displayName,iconSrc:s.iconSrc}),s.linkUrl?e.jsx("a",{className:"hover:underline",href:s.linkUrl,rel:"noreferrer",target:"_blank",children:s.displayName}):e.jsx("span",{children:s.displayName})]})}),e.jsxs(b,{className:"text-right font-mono text-sm",children:["+",o(s.free_members)]}),x?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(b,{className:"text-right font-mono text-sm",children:["+",o(s.paid_members)]}),e.jsxs(b,{className:"text-right font-mono text-sm",children:["+",h,o(I(s.mrr))]})]})]},s.source))})},ga=({range:i,limit:h=20,showViewAll:g=!1,sortBy:u,setSortBy:p})=>{const{data:x}=ne(),{data:s}=ia(),{appSettings:j}=le(),[S,L]=T.useState("free_members desc"),r=u||S,_=p||L,W=r.replace("free_members","signups").replace("paid_members","paid_conversions"),{data:E,isLoading:w}=ba(i,W,h),Y=x?.url,O="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",V=xe.useMemo(()=>{if(s?.stats&&s?.meta?.totals){const y=s.meta.totals;let f=y[0];if(!f)return oe("usd");for(const N of y)N.mrr>f.mrr&&(f=N);return oe(f.currency)}return oe("usd")},[s]),k=xe.useMemo(()=>E?.stats?E.stats.map(y=>{const f=y.source||"Direct",{domain:N}=la(f,Y),z=N?`https://www.faviconextractor.com/favicon/${N}?larger=true`:O,B=N&&f!=="Direct"?`https://${N}`:void 0;return{source:f,free_members:y.signups,paid_members:y.paid_conversions,mrr:y.mrr,iconSrc:z,displayName:f,linkUrl:B}}):[],[E,Y]),D="Top sources",t=`Where did your growth come from ${te(i)}`;return j?.analytics.membersTrackSources?w?e.jsx(X,{children:e.jsx(M,{className:"last:border-none",children:e.jsx(b,{className:"border-none py-2",colSpan:1,children:e.jsx(_e,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})})}):e.jsxs(e.Fragment,{children:[k.length>0?e.jsx(Ne,{currencySymbol:V,data:k,defaultSourceIconUrl:O,limit:h}):e.jsx(X,{children:e.jsx(M,{className:"last:border-none",children:e.jsx(b,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:j?.paidMembersEnabled?4:2,children:e.jsx(pe,{description:"Try adjusting your date range to see more data.",title:`No conversions ${te(i)}`,children:e.jsx(Be,{strokeWidth:1.5})})})})}),g&&k.length>h&&e.jsx(na,{className:"border-none bg-transparent hover:!bg-transparent",children:e.jsx(M,{children:e.jsx(b,{className:"border-none bg-transparent px-0 pb-0 hover:!bg-transparent",colSpan:4,children:e.jsxs(Ee,{children:[e.jsx(Ye,{asChild:!0,children:e.jsxs(ue,{variant:"outline",children:["View all ",e.jsx(Ie,{})]})}),e.jsxs(Oe,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[e.jsxs(Ve,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[e.jsx(Fe,{children:D}),e.jsx(Re,{children:t})]}),e.jsx("div",{className:"group/datalist",children:e.jsxs(we,{children:[e.jsx(De,{children:e.jsxs(M,{children:[e.jsx(G,{children:"Source"}),e.jsx(G,{className:"w-[110px] text-right",children:e.jsx(H,{activeSortBy:r,setSortBy:_,sortBy:"free_members desc",children:"Free members"})}),j?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-[110px] text-right",children:e.jsx(H,{activeSortBy:r,setSortBy:_,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(G,{className:"w-[110px] text-right",children:e.jsx(H,{activeSortBy:r,setSortBy:_,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),e.jsx(Ne,{currencySymbol:V,data:k,defaultSourceIconUrl:O})]})})]})]})})})})]}):e.jsx(X,{children:e.jsx(M,{className:"last:border-none",children:e.jsx(b,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:j?.paidMembersEnabled?4:2,children:e.jsx(Ce,{})})})})},ja=(i,h,g)=>{const u=i??30,p=h??"mrr desc",{startDate:x,endDate:s}=T.useMemo(()=>he(u),[u]),j=T.useMemo(()=>{const r={date_from:re(x),date_to:re(s),order:p};return g==="posts"?r.post_type="post":g==="pages"&&(r.post_type="page"),r},[x,s,p,g]),S=Object.fromEntries(Object.entries(j).filter(([,r])=>r!==void 0));return oa({searchParams:S})},as=()=>{const{range:i,site:h}=ne(),g=me(),[u,p]=T.useState("free_members desc"),[x,s]=T.useState(K.POSTS_AND_PAGES),[j]=Se(),{appSettings:S}=le(),L=j.get("tab")||"total-members",{isLoading:r,chartData:_,totals:W,currencySymbol:E,subscriptionData:w}=pa(i),{data:Y,isLoading:O}=ja(i,u,x),V=T.useMemo(()=>{const y=(Y?.stats||[]).reduce((l,a)=>{const n=a.post_id||(a.title&&a.title.trim()!==""?a.title:a.attribution_url);if(!n)return l;if(!l.has(n))l.set(n,a);else{const d=l.get(n);d.free_members+=a.free_members,d.paid_members+=a.paid_members,d.mrr+=a.mrr,l.set(n,d)}return l},new Map),f=Array.from(y.values()),N=f.reduce((l,a)=>l+a.free_members,0),z=f.reduce((l,a)=>l+a.paid_members,0),B=f.reduce((l,a)=>l+a.mrr,0);return f.map(l=>{let a=0;return u.includes("free_members")&&N>0?a=l.free_members/N:u.includes("paid_members")&&z>0?a=l.paid_members/z:u.includes("mrr")&&B>0&&(a=l.mrr/B),{title:l.title||l.attribution_url,post_id:l.post_id,attribution_url:l.attribution_url,attribution_type:l.attribution_type,attribution_id:l.attribution_id,free_members:l.free_members,paid_members:l.paid_members,mrr:l.mrr,percentage:a,published_at:l.published_at,url_exists:l.url_exists??!0}})},[Y,u]),k=r,D=r||O;return e.jsxs($e,{children:[e.jsx(Ae,{children:e.jsx(da,{children:e.jsx(Le,{})})}),e.jsxs(ze,{data:k?void 0:_,isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(ve,{"data-testid":"total-members-card",children:e.jsx(ye,{children:e.jsx(fa,{chartData:_,currencySymbol:E,initialTab:L,isLoading:k,subscriptionData:w,totals:W})})}),e.jsxs(ve,{className:"w-full overflow-x-auto","data-testid":"top-content-card",children:[e.jsxs(ma,{children:[e.jsx(ua,{children:sa(x)}),e.jsx(ha,{children:ra(x,i,te)})]}),e.jsx(ye,{children:e.jsxs(we,{children:[e.jsx(De,{children:e.jsxs(M,{className:"[&>th]:h-auto [&>th]:pb-2 [&>th]:pt-0",children:[e.jsx(G,{className:"min-w-[320px] pl-0",children:e.jsx(ce,{defaultValue:x,variant:"button-sm",onValueChange:t=>{s(t)},children:e.jsxs(de,{children:[e.jsx(U,{value:K.POSTS_AND_PAGES,children:"Posts & pages"}),e.jsx(U,{value:K.POSTS,children:"Posts"}),e.jsx(U,{value:K.PAGES,children:"Pages"}),e.jsx(U,{value:K.SOURCES,children:"Sources"})]})})}),e.jsx(G,{className:"w-[140px] text-right",children:S?.paidMembersEnabled?e.jsx(H,{activeSortBy:u,setSortBy:p,sortBy:"free_members desc",children:"Free members"}):e.jsx(e.Fragment,{children:"Free members"})}),S?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-[140px] text-right",children:e.jsx(H,{activeSortBy:u,setSortBy:p,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(G,{className:"w-[140px] text-right",children:e.jsx(H,{activeSortBy:u,setSortBy:p,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),x===K.SOURCES?e.jsx(ga,{limit:20,range:i,setSortBy:t=>p(t),showViewAll:!0,sortBy:u}):e.jsx(X,{children:D?e.jsx(M,{className:"last:border-none",children:e.jsx(b,{className:"border-none py-2",colSpan:1,children:e.jsx(_e,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})}):S?.analytics.membersTrackSources?V.length>0?V.map((t,y)=>e.jsxs(M,{className:"last:border-none",children:[e.jsx(b,{children:e.jsxs("div",{className:"group/link inline-flex flex-col items-start gap-px",children:[t.post_id&&t.attribution_type==="post"?e.jsx(ue,{className:"h-auto whitespace-normal p-0 text-left font-medium leading-tight hover:!underline",title:"View post analytics",variant:"link",onClick:ta(t.attribution_url,t.post_id,h.url||"",g,t.attribution_type),children:t.title}):e.jsx("span",{className:"font-medium",children:t.title}),t.published_at&&fe&&new Date(t.published_at).getTime()>0&&e.jsxs("span",{className:"text-muted-foreground",children:["Published on ",fe(t.published_at)]})]})}),e.jsxs(b,{className:"text-right font-mono text-sm",children:[t.free_members>0&&"+",o(t.free_members)]}),S?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(b,{className:"text-right font-mono text-sm",children:[t.paid_members>0&&"+",o(t.paid_members)]}),e.jsxs(b,{className:"text-right font-mono text-sm",children:[t.mrr>0&&"+",E,o(I(t.mrr))]})]})]},`${x}-${t.post_id||`${t.title}-${y}`}`)):e.jsx(M,{className:"border-none",children:e.jsx(b,{className:"py-12 group-hover:!bg-transparent",colSpan:S?.paidMembersEnabled?4:2,children:e.jsx(pe,{description:"Try adjusting your date range to see more data.",title:`No conversions ${te(i)}`,children:e.jsx(xa,{strokeWidth:1.5})})})}):e.jsx(M,{className:"last:border-none",children:e.jsx(b,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:S?.paidMembersEnabled?4:2,children:e.jsx(Ce,{})})})})]})})]})]})]})};export{as as default};
|
|
1
|
+
import{aM as me,j as e,B as ue,r as T,b3 as ne,b4 as le,bR as Se,aj as o,cf as I,ah as A,cg as Z,aN as Te,ch as F,aW as Me,ap as ke,aY as Pe,a_ as ee,af as he,ag as re,e as xe,S as _e,ci as Be,bJ as Ee,bK as Ye,bL as Oe,bM as Ve,bN as Fe,bO as Re,bU as fe}from"./index-Dq_j8mTf.js";import{s as ae,d as Ge,g as te,S as $e,a as Ae,D as Le,b as ze}from"./stats-view-0eaQf_pM.js";import{E as pe}from"./empty-indicator-B7WXKrac.js";import{A as Ke,a as Ie}from"./wallet-cards-yxIjXIK2.js";import{C as Ue,a as He,b as We,B as be}from"./chart-BYGpVun6.js";import{G as ge,C as qe,X as Qe,Y as Xe}from"./gh-chart-B98YGgzG.js";import{T as ce,a as de,K as se,d as R,e as Je,b as U,c as je}from"./tabs-BTEs4Aby.js";import{g as Ze}from"./audience-select-C17Kh6Hl.js";import{B as ea,S as H}from"./sort-button-K1rs2zWp.js";import{S as aa,C as K,g as sa,a as ra,b as ta}from"./url-helpers-Cn69VioM.js";import{e as X,c as M,f as b,g as na,a as we,b as De,d as G}from"./table-DpY57zP6.js";import{g as oe}from"./currency-fEUUCkj0.js";import{g as la}from"./source-utils-B1S3ZHA2.js";import{a as ia,h as oa}from"./stats-C8Qt0L-1.js";import{u as ca}from"./referrers-D4s1ncIT.js";import{j as da,C as ve,c as ye,a as ma,b as ua,h as ha}from"./pagemenu-z-Nc5-Yy.js";import{u as pa}from"./use-growth-stats-DPN4F7Mt.js";import{C as xa}from"./lucide-react-B7CWr8XP.js";import"./select-CFBw9aAY.js";import"./message-square-text-Cqodm1uC.js";import"./sprout-C96gimQS.js";import"./_baseAssignValue-qTINVNgk.js";import"./index-CLdEbHsV.js";import"./a-large-small-D-nhKFBX.js";import"./at-sign-DHUgIxNb.js";import"./copy-CCj6xx5V.js";import"./hash-B4UtN3nq.js";import"./inbox-D336Mbic.js";import"./minus-K1Fj4qFh.js";import"./tags-CIEzegXe.js";import"./square-s6ZVKvbY.js";import"./user-round-check-pBOLjTqi.js";import"./repeat-BNamsVQr.js";import"./reply-DqXFv78k.js";import"./trash-DIVNO9rU.js";const Ce=({className:i})=>{const h=me();return e.jsx(pe,{actions:e.jsx(ue,{variant:"outline",onClick:()=>h("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:i,description:"Enable member source tracking in settings to see which content drives member growth.",title:"Member sources have been disabled",children:e.jsx(Ke,{})})},fa=({chartData:i,subscriptionData:h,totals:g,initialTab:u="total-members",currencySymbol:p,isLoading:x})=>{const[s,j]=T.useState(u),[S,L]=T.useState("total"),{range:r}=ne(),{appSettings:_}=le(),W=me(),[E]=Se();T.useEffect(()=>{j(u)},[u]);const w=a=>{j(a);const n=new URLSearchParams(E);n.set("tab",a),W(`?${n.toString()}`,{replace:!0})},{totalMembers:Y,freeMembers:O,paidMembers:V,mrr:k,percentChanges:D,directions:t}=g,y=(a,n)=>{if(n===1){const C=A().format("YYYY-MM-DD"),$=a.find(J=>J.date===C);return[{date:C,signups:$?.signups||0,cancellations:$?.cancellations||0}]}const{startDate:d,endDate:m}=he(n),c=A(m).diff(A(d),"days"),v=Ge(n,c,"sum"),q=new Map(a.map(C=>[C.date,C])),Q=[],P=A(d),ie=A(m);for(;P.isSameOrBefore(ie);){let C,$;switch(v){case"weekly":C=P.startOf("week").format("YYYY-MM-DD"),$="week";break;case"monthly":C=P.startOf("month").format("YYYY-MM-DD"),$="month";break;default:C=P.format("YYYY-MM-DD"),$="day"}const J=q.get(C);J?Q.push(J):Q.push({date:C,signups:0,cancellations:0}),P.add(1,$)}return Q},f=T.useMemo(()=>{if(!i||i.length===0)return[];let a=[],n="value";switch(s){case"free-members":n="free";break;case"paid-members":n="paid";break;case"mrr":{n="mrr";break}default:n="value"}a=ae(i,r,n,"exact");let d=[];switch(s){case"free-members":d=a.map(m=>({...m,value:m.free,formattedValue:o(m.free),label:"Free members"}));break;case"paid-members":d=a.map(m=>({...m,value:m.paid,formattedValue:o(m.paid),label:"Paid members"}));break;case"mrr":d=a.map(m=>({...m,value:I(m.mrr),formattedValue:`${p}${o(I(m.mrr))}`,label:"MRR"}));break;default:d=a.map(m=>{const c=m.free+m.paid;return{...m,value:c,formattedValue:o(c),label:"Total members"}})}return d},[s,i,r,p]),N={"total-members":{color:"hsl(var(--chart-darkblue))"},"free-members":{color:"hsl(var(--chart-blue))"},"paid-members":{color:"hsl(var(--chart-purple))"},mrr:{color:"hsl(var(--chart-teal))"}},z=T.useMemo(()=>{if(s!=="paid-members")return[];if(h&&h.length>0){if(r===1){const c=A().format("YYYY-MM-DD"),v=h.find(q=>q.date===c);return[{date:Z(c,r),new:v?.signups||0,cancelled:-(v?.cancellations||0)}]}const a=ae(h,r,"signups","sum"),n=ae(h,r,"cancellations","sum"),d=a.map(c=>({date:c.date,signups:c.signups||0,cancellations:n.find(v=>v.date===c.date)?.cancellations||0}));return n.forEach(c=>{d.find(v=>v.date===c.date)||d.push({date:c.date,signups:0,cancellations:c.cancellations||0})}),d.sort((c,v)=>new Date(c.date).getTime()-new Date(v.date).getTime()),y(d,r).map(c=>({date:Z(c.date,r),new:c.signups||0,cancelled:-(c.cancellations||0)}))}else{if(!i||i.length===0)return[];if(r===1){const n=A().format("YYYY-MM-DD"),d=i.find(m=>m.date===n);return[{date:Z(n,r),new:d?.paid_subscribed||0,cancelled:-(d?.paid_canceled||0)}]}return ae(i,r,"paid","exact").map(n=>({date:Z(n.date,r),new:n.paid_subscribed||0,cancelled:-(n.paid_canceled||0)}))}},[s,i,h,r]),B={new:{label:"New",color:"hsl(var(--chart-teal))"},cancelled:{label:"Cancelled",color:"hsl(var(--chart-rose))"}};if(x)return e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(Te,{})});const l="-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]";return e.jsxs(ce,{defaultValue:u,variant:"kpis",children:[e.jsxs(de,{className:`-mx-6 ${_?.paidMembersEnabled?"hidden grid-cols-4 lg:!visible lg:!grid":"grid grid-cols-4"}`,children:[e.jsx(se,{className:_?.paidMembersEnabled?"":"cursor-auto after:hidden",value:"total-members",onClick:()=>{_?.paidMembersEnabled&&w("total-members")},children:e.jsx(R,{color:"hsl(var(--chart-darkblue))",diffDirection:r===F.allTime.value?"hidden":t.total,diffValue:D.total,label:"Total members",value:o(Y)})}),_?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(se,{value:"free-members",onClick:()=>{w("free-members")},children:e.jsx(R,{color:"hsl(var(--chart-blue))",diffDirection:r===F.allTime.value?"hidden":t.free,diffValue:D.free,label:"Free members",value:o(O)})}),e.jsx(se,{value:"paid-members",onClick:()=>{w("paid-members")},children:e.jsx(R,{color:"hsl(var(--chart-purple))",diffDirection:r===F.allTime.value?"hidden":t.paid,diffValue:D.paid,label:"Paid members",value:o(V)})}),e.jsx(se,{value:"mrr",onClick:()=>{w("mrr")},children:e.jsx(R,{color:"hsl(var(--chart-teal))",diffDirection:r===F.allTime.value?"hidden":t.mrr,diffValue:D.mrr,label:"MRR",value:`${p}${o(I(k))}`})})]})]}),_?.paidMembersEnabled&&e.jsxs(Me,{children:[e.jsx(ke,{className:"lg:hidden",asChild:!0,children:e.jsxs(Je,{children:[s==="total-members"&&e.jsx(R,{color:"hsl(var(--chart-darkblue))",diffDirection:r===F.allTime.value?"hidden":t.total,diffValue:D.total,label:"Total members",value:o(Y)}),s==="free-members"&&e.jsx(R,{color:"hsl(var(--chart-blue))",diffDirection:r===F.allTime.value?"hidden":t.free,diffValue:D.free,label:"Free members",value:o(O)}),s==="paid-members"&&e.jsx(R,{color:"hsl(var(--chart-purple))",diffDirection:r===F.allTime.value?"hidden":t.paid,diffValue:D.paid,label:"Paid members",value:o(V)}),s==="mrr"&&e.jsx(R,{color:"hsl(var(--chart-teal))",diffDirection:r===F.allTime.value?"hidden":t.mrr,diffValue:D.mrr,label:"MRR",value:`${p}${o(I(k))}`})]})}),e.jsxs(Pe,{align:"end",className:"w-56",children:[e.jsx(ee,{onClick:()=>w("total-members"),children:"Total members"}),e.jsx(ee,{onClick:()=>w("free-members"),children:"Free members"}),e.jsx(ee,{onClick:()=>w("paid-members"),children:"Paid members"}),e.jsx(ee,{onClick:()=>w("mrr"),children:"MRR"})]})]}),e.jsx("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:s==="paid-members"?e.jsxs(ce,{defaultValue:S,variant:"button-sm",onValueChange:a=>{L(a)},children:[e.jsx("div",{className:"mb-4 mt-2 flex w-full items-center justify-start",children:e.jsxs(de,{className:"flex items-center",children:[e.jsx(U,{value:"total",children:"Total"}),e.jsx(U,{value:"change",children:"Change"})]})}),e.jsx(je,{value:"total",children:e.jsx(ge,{className:l,color:N[s].color,data:f,dataFormatter:o,id:"paid-members",range:r})}),e.jsxs(je,{value:"change",children:[e.jsx(Ue,{className:"mt-6 aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]",config:B,children:e.jsxs(ea,{data:z,stackOffset:"sign",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tealGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-new)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-new)",stopOpacity:.6})]})}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"roseGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-cancelled)",stopOpacity:.6}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-cancelled)",stopOpacity:.8})]})}),e.jsx(qe,{vertical:!1}),e.jsx(Qe,{axisLine:!1,dataKey:"date",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Xe,{axisLine:!1,tickFormatter:a=>a<0?o(a*-1):o(a),tickLine:!1}),e.jsx(He,{content:e.jsx(We,{className:"!min-w-[120px] px-3 py-2",formatter:(a,n,d,m)=>{const c=Number(a);let v="0";c===0?v="0":v=c<0?o(c*-1):o(c);const q=Number(d?.payload?.new||0),Q=Number(d?.payload?.cancelled||0),P=q+Q,ie=P===0?"0":P>0?`+${o(P)}`:o(P);return e.jsxs("div",{className:"flex w-full flex-col",children:[m===0&&e.jsx("div",{className:"mb-1 text-sm font-medium text-foreground",children:d?.payload?.date}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50",style:{"--color-bg":`var(--color-${n})`}}),e.jsx("span",{className:"text-sm text-muted-foreground",children:B[n]?.label||n})]}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:v})]}),m===1&&e.jsxs("div",{className:"mt-1 flex w-full items-center justify-between gap-4 border-t pt-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Net change"}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:ie})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),e.jsx(be,{activeBar:{fillOpacity:1},dataKey:"new",fill:"url(#tealGradient)",fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:"a"}),e.jsx(be,{activeBar:{fillOpacity:1},dataKey:"cancelled",fill:"url(#roseGradient)",fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:"a"})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:B.new.color}}),"New"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:B.cancelled.color}}),"Cancelled"]})]})]})]}):e.jsx(ge,{className:l,color:N[s].color,data:f,dataFormatter:s==="mrr"?a=>`${p}${o(a)}`:o,id:"mrr",range:r})})]})},ba=(i,h="signups desc",g=50)=>{const{audience:u}=ne(),{startDate:p,endDate:x,timezone:s}=he(i),j={date_from:re(p),date_to:re(x),member_status:Ze(u),order:h,limit:g.toString()};return s&&(j.timezone=s),ca({searchParams:j})},Ne=({data:i,currencySymbol:h,limit:g,defaultSourceIconUrl:u})=>{const p=g?i.slice(0,g):i,{appSettings:x}=le();return e.jsx(X,{children:p.map(s=>e.jsxs(M,{className:"last:border-none",children:[e.jsx(b,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(aa,{defaultSourceIconUrl:u,displayName:s.displayName,iconSrc:s.iconSrc}),s.linkUrl?e.jsx("a",{className:"hover:underline",href:s.linkUrl,rel:"noreferrer",target:"_blank",children:s.displayName}):e.jsx("span",{children:s.displayName})]})}),e.jsxs(b,{className:"text-right font-mono text-sm",children:["+",o(s.free_members)]}),x?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(b,{className:"text-right font-mono text-sm",children:["+",o(s.paid_members)]}),e.jsxs(b,{className:"text-right font-mono text-sm",children:["+",h,o(I(s.mrr))]})]})]},s.source))})},ga=({range:i,limit:h=20,showViewAll:g=!1,sortBy:u,setSortBy:p})=>{const{data:x}=ne(),{data:s}=ia(),{appSettings:j}=le(),[S,L]=T.useState("free_members desc"),r=u||S,_=p||L,W=r.replace("free_members","signups").replace("paid_members","paid_conversions"),{data:E,isLoading:w}=ba(i,W,h),Y=x?.url,O="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",V=xe.useMemo(()=>{if(s?.stats&&s?.meta?.totals){const y=s.meta.totals;let f=y[0];if(!f)return oe("usd");for(const N of y)N.mrr>f.mrr&&(f=N);return oe(f.currency)}return oe("usd")},[s]),k=xe.useMemo(()=>E?.stats?E.stats.map(y=>{const f=y.source||"Direct",{domain:N}=la(f,Y),z=N?`https://www.faviconextractor.com/favicon/${N}?larger=true`:O,B=N&&f!=="Direct"?`https://${N}`:void 0;return{source:f,free_members:y.signups,paid_members:y.paid_conversions,mrr:y.mrr,iconSrc:z,displayName:f,linkUrl:B}}):[],[E,Y]),D="Top sources",t=`Where did your growth come from ${te(i)}`;return j?.analytics.membersTrackSources?w?e.jsx(X,{children:e.jsx(M,{className:"last:border-none",children:e.jsx(b,{className:"border-none py-2",colSpan:1,children:e.jsx(_e,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})})}):e.jsxs(e.Fragment,{children:[k.length>0?e.jsx(Ne,{currencySymbol:V,data:k,defaultSourceIconUrl:O,limit:h}):e.jsx(X,{children:e.jsx(M,{className:"last:border-none",children:e.jsx(b,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:j?.paidMembersEnabled?4:2,children:e.jsx(pe,{description:"Try adjusting your date range to see more data.",title:`No conversions ${te(i)}`,children:e.jsx(Be,{strokeWidth:1.5})})})})}),g&&k.length>h&&e.jsx(na,{className:"border-none bg-transparent hover:!bg-transparent",children:e.jsx(M,{children:e.jsx(b,{className:"border-none bg-transparent px-0 pb-0 hover:!bg-transparent",colSpan:4,children:e.jsxs(Ee,{children:[e.jsx(Ye,{asChild:!0,children:e.jsxs(ue,{variant:"outline",children:["View all ",e.jsx(Ie,{})]})}),e.jsxs(Oe,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[e.jsxs(Ve,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[e.jsx(Fe,{children:D}),e.jsx(Re,{children:t})]}),e.jsx("div",{className:"group/datalist",children:e.jsxs(we,{children:[e.jsx(De,{children:e.jsxs(M,{children:[e.jsx(G,{children:"Source"}),e.jsx(G,{className:"w-[110px] text-right",children:e.jsx(H,{activeSortBy:r,setSortBy:_,sortBy:"free_members desc",children:"Free members"})}),j?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-[110px] text-right",children:e.jsx(H,{activeSortBy:r,setSortBy:_,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(G,{className:"w-[110px] text-right",children:e.jsx(H,{activeSortBy:r,setSortBy:_,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),e.jsx(Ne,{currencySymbol:V,data:k,defaultSourceIconUrl:O})]})})]})]})})})})]}):e.jsx(X,{children:e.jsx(M,{className:"last:border-none",children:e.jsx(b,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:j?.paidMembersEnabled?4:2,children:e.jsx(Ce,{})})})})},ja=(i,h,g)=>{const u=i??30,p=h??"mrr desc",{startDate:x,endDate:s}=T.useMemo(()=>he(u),[u]),j=T.useMemo(()=>{const r={date_from:re(x),date_to:re(s),order:p};return g==="posts"?r.post_type="post":g==="pages"&&(r.post_type="page"),r},[x,s,p,g]),S=Object.fromEntries(Object.entries(j).filter(([,r])=>r!==void 0));return oa({searchParams:S})},as=()=>{const{range:i,site:h}=ne(),g=me(),[u,p]=T.useState("free_members desc"),[x,s]=T.useState(K.POSTS_AND_PAGES),[j]=Se(),{appSettings:S}=le(),L=j.get("tab")||"total-members",{isLoading:r,chartData:_,totals:W,currencySymbol:E,subscriptionData:w}=pa(i),{data:Y,isLoading:O}=ja(i,u,x),V=T.useMemo(()=>{const y=(Y?.stats||[]).reduce((l,a)=>{const n=a.post_id||(a.title&&a.title.trim()!==""?a.title:a.attribution_url);if(!n)return l;if(!l.has(n))l.set(n,a);else{const d=l.get(n);d.free_members+=a.free_members,d.paid_members+=a.paid_members,d.mrr+=a.mrr,l.set(n,d)}return l},new Map),f=Array.from(y.values()),N=f.reduce((l,a)=>l+a.free_members,0),z=f.reduce((l,a)=>l+a.paid_members,0),B=f.reduce((l,a)=>l+a.mrr,0);return f.map(l=>{let a=0;return u.includes("free_members")&&N>0?a=l.free_members/N:u.includes("paid_members")&&z>0?a=l.paid_members/z:u.includes("mrr")&&B>0&&(a=l.mrr/B),{title:l.title||l.attribution_url,post_id:l.post_id,attribution_url:l.attribution_url,attribution_type:l.attribution_type,attribution_id:l.attribution_id,free_members:l.free_members,paid_members:l.paid_members,mrr:l.mrr,percentage:a,published_at:l.published_at,url_exists:l.url_exists??!0}})},[Y,u]),k=r,D=r||O;return e.jsxs($e,{children:[e.jsx(Ae,{children:e.jsx(da,{children:e.jsx(Le,{})})}),e.jsxs(ze,{data:k?void 0:_,isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(ve,{"data-testid":"total-members-card",children:e.jsx(ye,{children:e.jsx(fa,{chartData:_,currencySymbol:E,initialTab:L,isLoading:k,subscriptionData:w,totals:W})})}),e.jsxs(ve,{className:"w-full overflow-x-auto","data-testid":"top-content-card",children:[e.jsxs(ma,{children:[e.jsx(ua,{children:sa(x)}),e.jsx(ha,{children:ra(x,i,te)})]}),e.jsx(ye,{children:e.jsxs(we,{children:[e.jsx(De,{children:e.jsxs(M,{className:"[&>th]:h-auto [&>th]:pb-2 [&>th]:pt-0",children:[e.jsx(G,{className:"min-w-[320px] pl-0",children:e.jsx(ce,{defaultValue:x,variant:"button-sm",onValueChange:t=>{s(t)},children:e.jsxs(de,{children:[e.jsx(U,{value:K.POSTS_AND_PAGES,children:"Posts & pages"}),e.jsx(U,{value:K.POSTS,children:"Posts"}),e.jsx(U,{value:K.PAGES,children:"Pages"}),e.jsx(U,{value:K.SOURCES,children:"Sources"})]})})}),e.jsx(G,{className:"w-[140px] text-right",children:S?.paidMembersEnabled?e.jsx(H,{activeSortBy:u,setSortBy:p,sortBy:"free_members desc",children:"Free members"}):e.jsx(e.Fragment,{children:"Free members"})}),S?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-[140px] text-right",children:e.jsx(H,{activeSortBy:u,setSortBy:p,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(G,{className:"w-[140px] text-right",children:e.jsx(H,{activeSortBy:u,setSortBy:p,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),x===K.SOURCES?e.jsx(ga,{limit:20,range:i,setSortBy:t=>p(t),showViewAll:!0,sortBy:u}):e.jsx(X,{children:D?e.jsx(M,{className:"last:border-none",children:e.jsx(b,{className:"border-none py-2",colSpan:1,children:e.jsx(_e,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})}):S?.analytics.membersTrackSources?V.length>0?V.map((t,y)=>e.jsxs(M,{className:"last:border-none",children:[e.jsx(b,{children:e.jsxs("div",{className:"group/link inline-flex flex-col items-start gap-px",children:[t.post_id&&t.attribution_type==="post"?e.jsx(ue,{className:"h-auto whitespace-normal p-0 text-left font-medium leading-tight hover:!underline",title:"View post analytics",variant:"link",onClick:ta(t.attribution_url,t.post_id,h.url||"",g,t.attribution_type),children:t.title}):e.jsx("span",{className:"font-medium",children:t.title}),t.published_at&&fe&&new Date(t.published_at).getTime()>0&&e.jsxs("span",{className:"text-muted-foreground",children:["Published on ",fe(t.published_at)]})]})}),e.jsxs(b,{className:"text-right font-mono text-sm",children:[t.free_members>0&&"+",o(t.free_members)]}),S?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(b,{className:"text-right font-mono text-sm",children:[t.paid_members>0&&"+",o(t.paid_members)]}),e.jsxs(b,{className:"text-right font-mono text-sm",children:[t.mrr>0&&"+",E,o(I(t.mrr))]})]})]},`${x}-${t.post_id||`${t.title}-${y}`}`)):e.jsx(M,{className:"border-none",children:e.jsx(b,{className:"py-12 group-hover:!bg-transparent",colSpan:S?.paidMembersEnabled?4:2,children:e.jsx(pe,{description:"Try adjusting your date range to see more data.",title:`No conversions ${te(i)}`,children:e.jsx(xa,{strokeWidth:1.5})})})}):e.jsx(M,{className:"last:border-none",children:e.jsx(b,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:S?.paidMembersEnabled?4:2,children:e.jsx(Ce,{})})})})]})})]})]})]})};export{as as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aM as Y,r as k,b3 as C,b4 as z,j as e,S as f,bU as se,B as A,aQ as M,aj as d,y as W,ai as Q,ci as te,aN as le,cf as H,e as ce,ch as q,cD as de,bP as me,cE as J,bS as ue,cF as pe,af as xe,ag as T,aT as U,_ as he}from"./index-X_uC_0DD.js";import{g as S,S as ge,a as fe,D as be,b as je}from"./stats-view-DUoDKh7r.js";import{C as $,a as D,b as F,h as R,c as V,E as ve,K as Ne,d as we,e as ye,u as ke,j as _e}from"./pagemenu-CUEgz3GC.js";import{E as P}from"./empty-indicator-DOQCKEXD.js";import{P as Ce}from"./post-share-modal-BIddzWjJ.js";import{g as Ae,c as Le}from"./post-helpers-gInwAwEv.js";import{S as Te,U as ae}from"./wallet-cards-aM5Ct3OB.js";import{h as Me,i as K,d as ze,j as We,L as $e,k as X,l as Z,C as De}from"./lucide-react-DNj9Mt50.js";import{G}from"./gh-chart-CaA6rQiP.js";import{g as Fe}from"./audience-select-DuSCQEyi.js";import{u as Re}from"./use-growth-stats-DY2E0ltn.js";import{u as Ve}from"./posts-DOThg8yh.js";import{i as Ee,j as Ie}from"./stats-Cu49FJzo.js";import"./select-BH3t_tDB.js";import"./message-square-text-DJWDCab0.js";import"./sprout-gjsBxaCU.js";import"./a-large-small-2Oh9oqBr.js";import"./at-sign-BtKGpnjs.js";import"./copy-B8yuX-e4.js";import"./hash-ZzZYv2ek.js";import"./inbox-C5KDymI8.js";import"./minus-B7zQY2p1.js";import"./tags-DwsoamaL.js";import"./square-DsGufPa-.js";import"./user-round-check-Biw6QBQA.js";import"./repeat-CQvZJI02.js";import"./reply-BET0l7FZ.js";import"./trash-C2kuVkXA.js";import"./chart-tL51cfF9.js";import"./_baseAssignValue-CPzElAl9.js";import"./currency-fEUUCkj0.js";const Ue=s=>s.email_only?"Sent":s.email?"Published and sent":"Published",Ge=({latestPostStats:s,isLoading:o})=>{const a=Y(),[r,i]=k.useState(!1),{site:l,settings:u}=C(),{appSettings:n}=z(),{emailTrackClicks:p,emailTrackOpens:t}=n?.analytics||{},c=l.title||String(u.find(g=>g.key==="title")?.value||"Ghost Site"),x=s?Ae(s,{membersTrackSources:n?.analytics.membersTrackSources}):null,b="group mr-2 flex flex-col gap-1.5 hover:cursor-pointer";return e.jsxs($,{className:"group/card bg-gradient-to-tr from-muted/40 to-muted/0 to-50%","data-testid":"latest-post",children:[e.jsxs(D,{children:[e.jsx(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:"Latest post performance"}),e.jsx(R,{className:"hidden",children:"How your last post did"})]}),e.jsxs(V,{className:"flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3",children:[o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex w-full items-center gap-6 px-6 xl:col-span-2",children:[e.jsx("div",{className:"w-full max-w-[232px] grow",children:e.jsx(f,{className:"aspect-[16/10] rounded-md"})}),e.jsxs("div",{className:"w-full grow",children:[e.jsx(f,{className:"w-full max-w-[420px]"}),e.jsx(f,{className:"w-1/2"})]})]}),e.jsx("div",{className:"flex flex-col items-stretch gap-2 px-6 text-sm",children:e.jsxs("div",{className:"grid grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsx(f,{className:"w-3/4"}),e.jsx(f,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(f,{className:"w-3/4"}),e.jsx(f,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(f,{className:"w-3/4"}),e.jsx(f,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(f,{className:"w-3/4"}),e.jsx(f,{className:"h-10 w-1/3"})]})]})})]}),!o&&s&&x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2",children:[s.feature_image&&e.jsx("div",{className:"aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]",style:{backgroundImage:`url(${s.feature_image})`}}),e.jsxs("div",{className:"flex grow flex-col items-start justify-center self-stretch",children:[e.jsx("div",{className:"text-lg font-semibold leading-tighter tracking-tight hover:cursor-pointer hover:opacity-75",onClick:()=>{!o&&s&&a(`/posts/analytics/${s.id}`,{crossApp:!0})},children:s.title}),e.jsxs("div",{className:"mt-0.5 text-sm text-muted-foreground",children:[s.authors&&s.authors.length>0&&e.jsxs("div",{children:["By ",s.authors.map(g=>g.name).join(", ")," – ",se(s.published_at)]}),e.jsx("div",{className:"mt-0.5",children:Ue(s)})]}),e.jsxs("div",{className:"mt-6 flex items-center gap-2",children:[!s.email_only&&e.jsx(Ce,{author:s.authors?.map(g=>g.name).join(", ")||"",description:"",faviconURL:l.icon||"",featureImageURL:s.feature_image||"",open:r,postExcerpt:s.excerpt||"",postTitle:s.title,postURL:s.url||"",siteTitle:c,onClose:()=>i(!1),onOpenChange:i,children:e.jsxs(A,{onClick:()=>i(!0),children:[e.jsx(Te,{})," Share post"]})}),e.jsxs(A,{className:s.email_only?"w-full":"",variant:"outline",onClick:()=>{a(`/posts/analytics/${s.id}`,{crossApp:!0})},children:[e.jsx(Me,{}),e.jsx("span",{className:"hidden md:!visible md:!block",children:s.email_only?"Post analytics":"Analytics"})]})]})]})]}),e.jsx("div",{className:"-ml-4 flex w-full flex-col items-stretch gap-2 pr-6 text-sm xl:h-full xl:max-w-none",children:e.jsxs("div",{className:"grid grid-cols-2 gap-6 pl-10 lg:border-l xl:h-full",children:[x.showWebMetrics&&n?.analytics.webAnalytics&&e.jsxs("div",{className:b,"data-testid":"latest-post-visitors",onClick:()=>{a(`/posts/analytics/${s.id}/web`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(M,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Visitors"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:d(s.visitors)})]}),x.showMemberGrowth&&e.jsxs("div",{className:W(b,x.showEmailMetrics&&(!x.showWebMetrics||!n?.analytics.webAnalytics)&&"row-[2/3] col-[1/2]"),"data-testid":"latest-post-members",onClick:()=>{a(`/posts/analytics/${s.id}/growth`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(ae,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Members"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.member_delta?e.jsxs(e.Fragment,{children:["+",d(s.member_delta)]}):0})]}),x.showEmailMetrics&&s.email&&e.jsxs(e.Fragment,{children:[t&&e.jsxs("div",{className:b,onClick:()=>{a(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(K,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Opens"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count?Q((s.email.opened_count||0)/s.email.email_count):"0%"})]}),p&&e.jsxs("div",{className:b,onClick:()=>{a(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(ze,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Clicks"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count&&s.count?.clicks?Q((s.count.clicks||0)/s.email.email_count):"0%"})]})]})]})})]}):!o&&e.jsx(P,{actions:e.jsx(A,{variant:"secondary",onClick:()=>{a("/editor/post",{crossApp:!0})},children:"New post"}),className:"w-full pb-10 xl:col-span-3",description:"Once it's live, you can track performance here",title:"Publish your first post",children:e.jsx(te,{strokeWidth:1.5})})]})]})},Be=()=>{const{data:s}=C();return{isLimited:a=>{const r=s?.config;return r?.hostSettings?.limits&&a==="limitAnalytics"?r.hostSettings.limits.limitAnalytics?.disabled===!0:!1}}},B=({title:s,iconName:o,description:a,color:r,diffDirection:i,diffValue:l,formattedValue:u,trendingFromValue:n,children:p,onClick:t})=>{const{range:c}=C(),x=o&&$e[o],b=ce.useMemo(()=>{if(!i||i==="empty"||c===q.allTime.value||!l)return"";const g=i==="up"?"up":i==="down"?"down":"at",N=S(c).replace("in the ","").replace(/^\(|\)$/g,"");return i==="same"?e.jsxs("span",{children:["You're trending at the same level as ",e.jsx("span",{className:"font-semibold",children:u})," compared to the ",e.jsx("span",{className:"font-semibold",children:N})]}):e.jsxs("span",{children:["You're trending ",e.jsxs("span",{className:"font-semibold",children:[g," ",l]})," from ",e.jsx("span",{className:"font-semibold",children:n})," compared to the ",N]})},[i,l,n,u,c]);return e.jsxs($,{className:"group","data-testid":s,children:[e.jsxs(D,{className:"hidden",children:[e.jsx(F,{children:s}),e.jsx(R,{children:a})]}),e.jsxs(Ne,{className:"relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4",children:[e.jsxs("div",{className:"flex grow flex-col gap-1.5 border-none pb-0",children:[e.jsxs(we,{className:t&&"transition-all group-hover:text-foreground",children:[r&&e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:r}}),x&&e.jsx(x,{size:16,strokeWidth:1.5}),s]}),e.jsx(ye,{diffDirection:c===q.allTime.value?"hidden":i,diffTooltip:b,diffValue:l,value:u})]}),t&&e.jsx(A,{className:"absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100",size:"sm",variant:"outline",onClick:t,children:"View more"})]}),e.jsx(V,{children:p})]})},Oe=({kpiValues:s,visitorsChartData:o,visitorsYRange:a,growthTotals:r,membersChartData:i,mrrChartData:l,currencySymbol:u,isLoading:n})=>{const p=Y(),{range:t}=C(),{appSettings:c}=z(),b=Be().isLimited("limitAnalytics"),g="-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:!cursor-pointer";if(n)return e.jsx(ve,{className:"flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:!cursor-pointer",children:e.jsx(le,{})});const _=c?.analytics.webAnalytics,N=b&&!_,E=!0,w=c?.paidMembersEnabled,L=[_,N,E,w].filter(Boolean).length;let j="lg:grid-cols-3";L===2?j="lg:grid-cols-2":L===1&&(j="lg:grid-cols-1");const I=`flex flex-col lg:grid ${j} gap-6`;return e.jsxs("div",{className:I,children:[_&&!N&&e.jsx(B,{description:"Number of individual people who visited your website",diffDirection:"empty",formattedValue:s.visits,iconName:"Globe",linkto:"/analytics/web/",title:"Unique visitors",onClick:()=>{p("/analytics/web/")},children:e.jsx(G,{className:g,color:"hsl(var(--chart-blue))",data:o,id:"visitors",range:t,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts",yAxisRange:a})}),N&&e.jsxs($,{children:[e.jsxs(D,{className:"hidden",children:[e.jsx(F,{children:"Unlock web analytics"}),e.jsx(R,{children:"Get the full picture of what's working with detailed, cookie-free traffic analytics."})]}),e.jsx(V,{className:"flex h-full items-center justify-center p-6",children:e.jsx(P,{actions:e.jsx(A,{variant:"outline",onClick:()=>p("/pro",{crossApp:!0}),children:"Upgrade now"}),className:"py-10",description:"Get the full picture of what's working with detailed, cookie-free traffic analytics.",title:"Unlock web analytics",children:e.jsx(We,{})})})]}),e.jsx(B,{description:"How number of members of your publication changed over time",diffDirection:r.directions.total,diffValue:r.percentChanges.total,formattedValue:d(r.totalMembers),iconName:"User",linkto:"/analytics/growth/",title:"Members",trendingFromValue:`${d(i[0].value)}`,onClick:()=>{p("/analytics/growth/?tab=total-members")},children:e.jsx(G,{className:g,color:"hsl(var(--chart-darkblue))",data:i,id:"members",range:t,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})}),w&&e.jsx(B,{description:"Monthly recurring revenue changes over time",diffDirection:r.directions.mrr,diffValue:r.percentChanges.mrr,formattedValue:`${u}${d(H(r.mrr))}`,iconName:"Coins",linkto:"/analytics/growth/",title:"MRR",trendingFromValue:`${u}${d(l[0].value)}`,onClick:()=>{p("/analytics/growth/?tab=mrr")},children:e.jsx(G,{className:g,color:"hsl(var(--chart-teal))",data:l,id:"mrr",range:t,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})})]})},He=({className:s})=>e.jsx("div",{className:W("rounded-sm bg-muted dark:bg-[#36373a] flex flex-col items-center justify-center gap-1 p-6",s),children:e.jsx(de,{className:"text-muted-foreground/50",size:18,strokeWidth:1.5})}),O=({className:s,metrics:o,title:a})=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:W("pointer-events-none absolute bottom-[calc(100%+2px)] left-1/2 z-50 min-w-[160px] -translate-x-1/2 rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100",s),children:[e.jsx("div",{className:"mb-1.5 whitespace-nowrap border-b pb-1.5 pr-10 font-medium text-muted-foreground",children:a}),e.jsx("div",{className:"flex flex-col gap-1.5",children:o?.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[r.icon,r.label]}),e.jsx("span",{className:"font-mono",children:r.metric})]},r.label))})]})}),Se=({topPostsData:s,isLoading:o})=>{const a=Y(),{range:r}=C(),{appSettings:i}=z(),l=i?.analytics.webAnalytics,u=i?.analytics.emailTrackClicks,n=i?.analytics.emailTrackOpens,p="flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground";return e.jsxs($,{className:"group/card w-full lg:col-span-2","data-testid":"top-posts-card",children:[e.jsxs(D,{children:[e.jsxs(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:["Top posts ",S(r)]}),e.jsx(R,{className:"hidden",children:"Most viewed posts in this period"})]}),e.jsx(V,{children:o?e.jsx(me,{className:"mt-6"}):e.jsxs(e.Fragment,{children:[s?.stats?.map(t=>e.jsxs("div",{className:'group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-accent before:opacity-80 before:content-[""] first:!border-border hover:cursor-pointer hover:border-transparent hover:before:block md:items-center dark:before:bg-accent/50 [&+div]:hover:border-transparent',children:[e.jsxs("div",{className:"z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]",onClick:()=>{a(`/posts/analytics/${t.post_id}`,{crossApp:!0})},children:[t.feature_image?e.jsx("div",{className:"hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:!visible sm:!block lg:w-[100px]",style:{backgroundImage:`url(${t.feature_image})`}}):e.jsx(He,{className:"hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:!visible sm:!flex lg:w-[100px]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"line-clamp-2 text-lg font-semibold leading-[1.35em]",children:t.title}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["By ",t.authors," – ",se(t.published_at)]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Le(t)})]})]}),e.jsxs("div",{className:"z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3",children:[l&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-visitors",onClick:c=>{c.stopPropagation(),a(`/posts/analytics/${t.post_id}/web`,{crossApp:!0})},children:[e.jsx(O,{metrics:[{icon:e.jsx(M,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Unique visitors",metric:d(t.views)}],title:"Web traffic"}),e.jsxs("div",{className:p,children:[e.jsx(M,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),J(t.views)]})]}),t.sent_count!==null&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]",onClick:c=>{c.stopPropagation(),a(`/posts/analytics/${t.post_id}/newsletter`,{crossApp:!0})},children:[e.jsx(O,{className:`${i?.analytics.membersTrackSources?"":"left-auto right-0 translate-x-0"}`,metrics:[{icon:e.jsx(X,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Sent",metric:d(t.sent_count||0)},...n?[{icon:e.jsx(K,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Opens",metric:d(t.opened_count||0)}]:[],...u?[{icon:e.jsx(Z,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Clicks",metric:d(t.clicked_count||0)}]:[]],title:"Newsletter performance"}),e.jsx("div",{className:p,children:n?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),t.open_rate?`${Math.round(t.open_rate)}%`:"0%"]}):u?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),t.click_rate?`${Math.round(t.click_rate)}%`:"0%"]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),J(t.sent_count||0)]})})]}),i?.analytics.membersTrackSources&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-members",onClick:c=>{c.stopPropagation(),a(`/posts/analytics/${t.post_id}/growth`,{crossApp:!0})},children:[e.jsx(O,{className:"left-auto right-0 translate-x-0",metrics:[{icon:e.jsx(ue,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Free",metric:t.free_members>0?`+${d(t.free_members)}`:"0"},...i?.paidMembersEnabled?[{icon:e.jsx(pe,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Paid",metric:t.paid_members>0?`+${d(t.paid_members)}`:"0"}]:[]],title:"New members"}),e.jsxs("div",{className:p,children:[e.jsx(ae,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),t.members>0?`+${d(t.members)}`:"0"]})]})]})]},t.post_id)),(!s?.stats||s.stats.length===0)&&e.jsx(P,{className:"w-full pb-10",title:`No posts ${S(r)}`,children:e.jsx(te,{strokeWidth:1.5})})]})})]})},Ke=()=>{const{data:{posts:[s]}={posts:[]},isLoading:o}=Ve({searchParams:{filter:"status:[published,sent]",order:"published_at DESC",limit:"1",include:"authors,email,count.clicks"}}),a=s,r=Ee(a?.id||"",{enabled:!!a?.id}),{data:i,isLoading:l}=r;return{data:k.useMemo(()=>{if(!a)return null;const n=i?.stats?.[0]||{id:a.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:a.id,uuid:a.uuid,title:a.title||"",slug:a.slug||"",feature_image:a.feature_image||null,published_at:a.published_at||"",url:a.url||"",excerpt:a.excerpt||"",email_only:a.email_only||!1,status:a.status,email:a.email,count:a.count,authors:a.authors||[],recipient_count:n.recipient_count,opened_count:n.opened_count,open_rate:n.open_rate,member_delta:n.member_delta,free_members:n.free_members,paid_members:n.paid_members,visitors:n.visitors,click_rate:null}},[a,i]),isLoading:o||!!a?.id&&l}},ee=({className:s,title:o,description:a,url:r,children:i})=>e.jsx("a",{className:W("block rounded-xl border bg-card p-6 transition-all hover:shadow-xs hover:bg-accent/50 group/card",s),href:r,rel:"noreferrer",target:"_blank",children:e.jsxs("div",{className:"flex items-center gap-6",children:[i,e.jsxs("div",{className:"flex flex-col gap-0.5 leading-tight",children:[e.jsx("span",{className:"text-base font-semibold",children:o}),e.jsx("span",{className:"text-sm font-normal text-gray-700",children:a})]})]})}),ks=()=>{const{appSettings:s}=z(),{statsConfig:o,isLoading:a,range:r,audience:i}=C(),{startDate:l,endDate:u,timezone:n}=xe(r),{isLoading:p,chartData:t,totals:c,currencySymbol:x}=Re(r),{data:b,isLoading:g}=Ke(),{data:_,isLoading:N}=Ie({searchParams:{date_from:T(l),date_to:T(u),limit:"5",timezone:n}}),E={site_uuid:o?.id||"",date_from:T(l),date_to:T(u),timezone:n,member_status:Fe(i)},{data:w,loading:L}=ke({endpoint:"api_kpis",statsConfig:o,params:E}),j=k.useMemo(()=>U(w||[],r,"visits","sum")?.map(h=>{const v=Number(h.visits),y=isNaN(v)?0:v;return{date:String(h.date),value:y,formattedValue:d(y),label:"Visitors"}}),[w,r]),I=k.useMemo(()=>{const h=[0,1];if(!j||j.length===0)return h;const v=j.map(m=>m.value).filter(m=>m>=0);return v.length===0?h:[0,Math.max(...v)||h[1]]},[j]),re=k.useMemo(()=>{if(!t||t.length===0)return[];let h=[];return h=U(t,r,"value","exact"),h.map(m=>({date:m.date,value:m.free+m.paid,formattedValue:d(m.free+m.paid),label:"Members"}))},[t,r]),ie=k.useMemo(()=>{if(!s?.paidMembersEnabled||!t||t.length===0)return[];let h=[];return h=U(t,r,"mrr","exact"),h.map(m=>({date:m.date,value:H(m.mrr),formattedValue:`${x}${d(H(m.mrr))}`,label:"MRR"}))},[t,r,x,s]),ne=k.useMemo(()=>{if(!w?.length)return{visits:"0"};const h=w.reduce((v,y)=>{const m=Number(y.visits);return v+(isNaN(m)?0:m)},0);return{visits:d(h)}},[w]),oe=a;return e.jsxs(ge,{children:[e.jsx(fe,{children:e.jsx(_e,{children:e.jsx(be,{excludeRanges:["today"]})})}),e.jsxs(je,{isLoading:oe,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(Oe,{currencySymbol:x,growthTotals:c,isLoading:L||p,kpiValues:ne,membersChartData:re,mrrChartData:ie,visitorsChartData:j,visitorsYRange:I}),e.jsx(Ge,{isLoading:g,latestPostStats:b}),e.jsx(Se,{isLoading:N,topPostsData:_}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsx(he,{className:"-mb-4 mt-4 lg:col-span-2",children:"Grow your audience"}),e.jsx(ee,{description:"Find out how to review the performance of your content and get the most out of post analytics in Ghost.",title:"Understanding analytics in Ghost",url:"https://ghost.org/help/native-analytics",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(De,{className:"text-[#00BBA7]",size:20,strokeWidth:1.5})})}),e.jsx(ee,{description:"Use these content distribution tactics to get more people to discover your work and increase engagement.",title:"How to get your content seen online",url:"https://ghost.org/resources/content-distribution/",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(M,{className:"text-[#FE9A00]",size:20,strokeWidth:1.5})})})]})]})]})};export{ks as default};
|
|
1
|
+
import{aM as Y,r as k,b3 as C,b4 as z,j as e,S as f,bU as se,B as A,aQ as M,aj as d,y as W,ai as Q,ci as te,aN as le,cf as H,e as ce,ch as q,cD as de,bP as me,cE as J,bS as ue,cF as pe,af as xe,ag as T,aT as U,_ as he}from"./index-Dq_j8mTf.js";import{g as S,S as ge,a as fe,D as be,b as je}from"./stats-view-0eaQf_pM.js";import{C as $,a as D,b as F,h as R,c as V,E as ve,K as Ne,d as we,e as ye,u as ke,j as _e}from"./pagemenu-z-Nc5-Yy.js";import{E as P}from"./empty-indicator-B7WXKrac.js";import{P as Ce}from"./post-share-modal-CtQTpIsC.js";import{g as Ae,c as Le}from"./post-helpers-gInwAwEv.js";import{S as Te,U as ae}from"./wallet-cards-yxIjXIK2.js";import{h as Me,i as K,d as ze,j as We,L as $e,k as X,l as Z,C as De}from"./lucide-react-B7CWr8XP.js";import{G}from"./gh-chart-B98YGgzG.js";import{g as Fe}from"./audience-select-C17Kh6Hl.js";import{u as Re}from"./use-growth-stats-DPN4F7Mt.js";import{u as Ve}from"./posts-D0erEci0.js";import{i as Ee,j as Ie}from"./stats-C8Qt0L-1.js";import"./select-CFBw9aAY.js";import"./message-square-text-Cqodm1uC.js";import"./sprout-C96gimQS.js";import"./a-large-small-D-nhKFBX.js";import"./at-sign-DHUgIxNb.js";import"./copy-CCj6xx5V.js";import"./hash-B4UtN3nq.js";import"./inbox-D336Mbic.js";import"./minus-K1Fj4qFh.js";import"./tags-CIEzegXe.js";import"./square-s6ZVKvbY.js";import"./user-round-check-pBOLjTqi.js";import"./repeat-BNamsVQr.js";import"./reply-DqXFv78k.js";import"./trash-DIVNO9rU.js";import"./chart-BYGpVun6.js";import"./_baseAssignValue-qTINVNgk.js";import"./currency-fEUUCkj0.js";const Ue=s=>s.email_only?"Sent":s.email?"Published and sent":"Published",Ge=({latestPostStats:s,isLoading:o})=>{const a=Y(),[r,i]=k.useState(!1),{site:l,settings:u}=C(),{appSettings:n}=z(),{emailTrackClicks:p,emailTrackOpens:t}=n?.analytics||{},c=l.title||String(u.find(g=>g.key==="title")?.value||"Ghost Site"),x=s?Ae(s,{membersTrackSources:n?.analytics.membersTrackSources}):null,b="group mr-2 flex flex-col gap-1.5 hover:cursor-pointer";return e.jsxs($,{className:"group/card bg-gradient-to-tr from-muted/40 to-muted/0 to-50%","data-testid":"latest-post",children:[e.jsxs(D,{children:[e.jsx(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:"Latest post performance"}),e.jsx(R,{className:"hidden",children:"How your last post did"})]}),e.jsxs(V,{className:"flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3",children:[o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex w-full items-center gap-6 px-6 xl:col-span-2",children:[e.jsx("div",{className:"w-full max-w-[232px] grow",children:e.jsx(f,{className:"aspect-[16/10] rounded-md"})}),e.jsxs("div",{className:"w-full grow",children:[e.jsx(f,{className:"w-full max-w-[420px]"}),e.jsx(f,{className:"w-1/2"})]})]}),e.jsx("div",{className:"flex flex-col items-stretch gap-2 px-6 text-sm",children:e.jsxs("div",{className:"grid grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsx(f,{className:"w-3/4"}),e.jsx(f,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(f,{className:"w-3/4"}),e.jsx(f,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(f,{className:"w-3/4"}),e.jsx(f,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(f,{className:"w-3/4"}),e.jsx(f,{className:"h-10 w-1/3"})]})]})})]}),!o&&s&&x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2",children:[s.feature_image&&e.jsx("div",{className:"aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]",style:{backgroundImage:`url(${s.feature_image})`}}),e.jsxs("div",{className:"flex grow flex-col items-start justify-center self-stretch",children:[e.jsx("div",{className:"text-lg font-semibold leading-tighter tracking-tight hover:cursor-pointer hover:opacity-75",onClick:()=>{!o&&s&&a(`/posts/analytics/${s.id}`,{crossApp:!0})},children:s.title}),e.jsxs("div",{className:"mt-0.5 text-sm text-muted-foreground",children:[s.authors&&s.authors.length>0&&e.jsxs("div",{children:["By ",s.authors.map(g=>g.name).join(", ")," – ",se(s.published_at)]}),e.jsx("div",{className:"mt-0.5",children:Ue(s)})]}),e.jsxs("div",{className:"mt-6 flex items-center gap-2",children:[!s.email_only&&e.jsx(Ce,{author:s.authors?.map(g=>g.name).join(", ")||"",description:"",faviconURL:l.icon||"",featureImageURL:s.feature_image||"",open:r,postExcerpt:s.excerpt||"",postTitle:s.title,postURL:s.url||"",siteTitle:c,onClose:()=>i(!1),onOpenChange:i,children:e.jsxs(A,{onClick:()=>i(!0),children:[e.jsx(Te,{})," Share post"]})}),e.jsxs(A,{className:s.email_only?"w-full":"",variant:"outline",onClick:()=>{a(`/posts/analytics/${s.id}`,{crossApp:!0})},children:[e.jsx(Me,{}),e.jsx("span",{className:"hidden md:!visible md:!block",children:s.email_only?"Post analytics":"Analytics"})]})]})]})]}),e.jsx("div",{className:"-ml-4 flex w-full flex-col items-stretch gap-2 pr-6 text-sm xl:h-full xl:max-w-none",children:e.jsxs("div",{className:"grid grid-cols-2 gap-6 pl-10 lg:border-l xl:h-full",children:[x.showWebMetrics&&n?.analytics.webAnalytics&&e.jsxs("div",{className:b,"data-testid":"latest-post-visitors",onClick:()=>{a(`/posts/analytics/${s.id}/web`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(M,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Visitors"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:d(s.visitors)})]}),x.showMemberGrowth&&e.jsxs("div",{className:W(b,x.showEmailMetrics&&(!x.showWebMetrics||!n?.analytics.webAnalytics)&&"row-[2/3] col-[1/2]"),"data-testid":"latest-post-members",onClick:()=>{a(`/posts/analytics/${s.id}/growth`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(ae,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Members"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.member_delta?e.jsxs(e.Fragment,{children:["+",d(s.member_delta)]}):0})]}),x.showEmailMetrics&&s.email&&e.jsxs(e.Fragment,{children:[t&&e.jsxs("div",{className:b,onClick:()=>{a(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(K,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Opens"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count?Q((s.email.opened_count||0)/s.email.email_count):"0%"})]}),p&&e.jsxs("div",{className:b,onClick:()=>{a(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(ze,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Clicks"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count&&s.count?.clicks?Q((s.count.clicks||0)/s.email.email_count):"0%"})]})]})]})})]}):!o&&e.jsx(P,{actions:e.jsx(A,{variant:"secondary",onClick:()=>{a("/editor/post",{crossApp:!0})},children:"New post"}),className:"w-full pb-10 xl:col-span-3",description:"Once it's live, you can track performance here",title:"Publish your first post",children:e.jsx(te,{strokeWidth:1.5})})]})]})},Be=()=>{const{data:s}=C();return{isLimited:a=>{const r=s?.config;return r?.hostSettings?.limits&&a==="limitAnalytics"?r.hostSettings.limits.limitAnalytics?.disabled===!0:!1}}},B=({title:s,iconName:o,description:a,color:r,diffDirection:i,diffValue:l,formattedValue:u,trendingFromValue:n,children:p,onClick:t})=>{const{range:c}=C(),x=o&&$e[o],b=ce.useMemo(()=>{if(!i||i==="empty"||c===q.allTime.value||!l)return"";const g=i==="up"?"up":i==="down"?"down":"at",N=S(c).replace("in the ","").replace(/^\(|\)$/g,"");return i==="same"?e.jsxs("span",{children:["You're trending at the same level as ",e.jsx("span",{className:"font-semibold",children:u})," compared to the ",e.jsx("span",{className:"font-semibold",children:N})]}):e.jsxs("span",{children:["You're trending ",e.jsxs("span",{className:"font-semibold",children:[g," ",l]})," from ",e.jsx("span",{className:"font-semibold",children:n})," compared to the ",N]})},[i,l,n,u,c]);return e.jsxs($,{className:"group","data-testid":s,children:[e.jsxs(D,{className:"hidden",children:[e.jsx(F,{children:s}),e.jsx(R,{children:a})]}),e.jsxs(Ne,{className:"relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4",children:[e.jsxs("div",{className:"flex grow flex-col gap-1.5 border-none pb-0",children:[e.jsxs(we,{className:t&&"transition-all group-hover:text-foreground",children:[r&&e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:r}}),x&&e.jsx(x,{size:16,strokeWidth:1.5}),s]}),e.jsx(ye,{diffDirection:c===q.allTime.value?"hidden":i,diffTooltip:b,diffValue:l,value:u})]}),t&&e.jsx(A,{className:"absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100",size:"sm",variant:"outline",onClick:t,children:"View more"})]}),e.jsx(V,{children:p})]})},Oe=({kpiValues:s,visitorsChartData:o,visitorsYRange:a,growthTotals:r,membersChartData:i,mrrChartData:l,currencySymbol:u,isLoading:n})=>{const p=Y(),{range:t}=C(),{appSettings:c}=z(),b=Be().isLimited("limitAnalytics"),g="-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:!cursor-pointer";if(n)return e.jsx(ve,{className:"flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:!cursor-pointer",children:e.jsx(le,{})});const _=c?.analytics.webAnalytics,N=b&&!_,E=!0,w=c?.paidMembersEnabled,L=[_,N,E,w].filter(Boolean).length;let j="lg:grid-cols-3";L===2?j="lg:grid-cols-2":L===1&&(j="lg:grid-cols-1");const I=`flex flex-col lg:grid ${j} gap-6`;return e.jsxs("div",{className:I,children:[_&&!N&&e.jsx(B,{description:"Number of individual people who visited your website",diffDirection:"empty",formattedValue:s.visits,iconName:"Globe",linkto:"/analytics/web/",title:"Unique visitors",onClick:()=>{p("/analytics/web/")},children:e.jsx(G,{className:g,color:"hsl(var(--chart-blue))",data:o,id:"visitors",range:t,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts",yAxisRange:a})}),N&&e.jsxs($,{children:[e.jsxs(D,{className:"hidden",children:[e.jsx(F,{children:"Unlock web analytics"}),e.jsx(R,{children:"Get the full picture of what's working with detailed, cookie-free traffic analytics."})]}),e.jsx(V,{className:"flex h-full items-center justify-center p-6",children:e.jsx(P,{actions:e.jsx(A,{variant:"outline",onClick:()=>p("/pro",{crossApp:!0}),children:"Upgrade now"}),className:"py-10",description:"Get the full picture of what's working with detailed, cookie-free traffic analytics.",title:"Unlock web analytics",children:e.jsx(We,{})})})]}),e.jsx(B,{description:"How number of members of your publication changed over time",diffDirection:r.directions.total,diffValue:r.percentChanges.total,formattedValue:d(r.totalMembers),iconName:"User",linkto:"/analytics/growth/",title:"Members",trendingFromValue:`${d(i[0].value)}`,onClick:()=>{p("/analytics/growth/?tab=total-members")},children:e.jsx(G,{className:g,color:"hsl(var(--chart-darkblue))",data:i,id:"members",range:t,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})}),w&&e.jsx(B,{description:"Monthly recurring revenue changes over time",diffDirection:r.directions.mrr,diffValue:r.percentChanges.mrr,formattedValue:`${u}${d(H(r.mrr))}`,iconName:"Coins",linkto:"/analytics/growth/",title:"MRR",trendingFromValue:`${u}${d(l[0].value)}`,onClick:()=>{p("/analytics/growth/?tab=mrr")},children:e.jsx(G,{className:g,color:"hsl(var(--chart-teal))",data:l,id:"mrr",range:t,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})})]})},He=({className:s})=>e.jsx("div",{className:W("rounded-sm bg-muted dark:bg-[#36373a] flex flex-col items-center justify-center gap-1 p-6",s),children:e.jsx(de,{className:"text-muted-foreground/50",size:18,strokeWidth:1.5})}),O=({className:s,metrics:o,title:a})=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:W("pointer-events-none absolute bottom-[calc(100%+2px)] left-1/2 z-50 min-w-[160px] -translate-x-1/2 rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100",s),children:[e.jsx("div",{className:"mb-1.5 whitespace-nowrap border-b pb-1.5 pr-10 font-medium text-muted-foreground",children:a}),e.jsx("div",{className:"flex flex-col gap-1.5",children:o?.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[r.icon,r.label]}),e.jsx("span",{className:"font-mono",children:r.metric})]},r.label))})]})}),Se=({topPostsData:s,isLoading:o})=>{const a=Y(),{range:r}=C(),{appSettings:i}=z(),l=i?.analytics.webAnalytics,u=i?.analytics.emailTrackClicks,n=i?.analytics.emailTrackOpens,p="flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground";return e.jsxs($,{className:"group/card w-full lg:col-span-2","data-testid":"top-posts-card",children:[e.jsxs(D,{children:[e.jsxs(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:["Top posts ",S(r)]}),e.jsx(R,{className:"hidden",children:"Most viewed posts in this period"})]}),e.jsx(V,{children:o?e.jsx(me,{className:"mt-6"}):e.jsxs(e.Fragment,{children:[s?.stats?.map(t=>e.jsxs("div",{className:'group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-accent before:opacity-80 before:content-[""] first:!border-border hover:cursor-pointer hover:border-transparent hover:before:block md:items-center dark:before:bg-accent/50 [&+div]:hover:border-transparent',children:[e.jsxs("div",{className:"z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]",onClick:()=>{a(`/posts/analytics/${t.post_id}`,{crossApp:!0})},children:[t.feature_image?e.jsx("div",{className:"hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:!visible sm:!block lg:w-[100px]",style:{backgroundImage:`url(${t.feature_image})`}}):e.jsx(He,{className:"hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:!visible sm:!flex lg:w-[100px]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"line-clamp-2 text-lg font-semibold leading-[1.35em]",children:t.title}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["By ",t.authors," – ",se(t.published_at)]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Le(t)})]})]}),e.jsxs("div",{className:"z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3",children:[l&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-visitors",onClick:c=>{c.stopPropagation(),a(`/posts/analytics/${t.post_id}/web`,{crossApp:!0})},children:[e.jsx(O,{metrics:[{icon:e.jsx(M,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Unique visitors",metric:d(t.views)}],title:"Web traffic"}),e.jsxs("div",{className:p,children:[e.jsx(M,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),J(t.views)]})]}),t.sent_count!==null&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]",onClick:c=>{c.stopPropagation(),a(`/posts/analytics/${t.post_id}/newsletter`,{crossApp:!0})},children:[e.jsx(O,{className:`${i?.analytics.membersTrackSources?"":"left-auto right-0 translate-x-0"}`,metrics:[{icon:e.jsx(X,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Sent",metric:d(t.sent_count||0)},...n?[{icon:e.jsx(K,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Opens",metric:d(t.opened_count||0)}]:[],...u?[{icon:e.jsx(Z,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Clicks",metric:d(t.clicked_count||0)}]:[]],title:"Newsletter performance"}),e.jsx("div",{className:p,children:n?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),t.open_rate?`${Math.round(t.open_rate)}%`:"0%"]}):u?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),t.click_rate?`${Math.round(t.click_rate)}%`:"0%"]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),J(t.sent_count||0)]})})]}),i?.analytics.membersTrackSources&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-members",onClick:c=>{c.stopPropagation(),a(`/posts/analytics/${t.post_id}/growth`,{crossApp:!0})},children:[e.jsx(O,{className:"left-auto right-0 translate-x-0",metrics:[{icon:e.jsx(ue,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Free",metric:t.free_members>0?`+${d(t.free_members)}`:"0"},...i?.paidMembersEnabled?[{icon:e.jsx(pe,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Paid",metric:t.paid_members>0?`+${d(t.paid_members)}`:"0"}]:[]],title:"New members"}),e.jsxs("div",{className:p,children:[e.jsx(ae,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),t.members>0?`+${d(t.members)}`:"0"]})]})]})]},t.post_id)),(!s?.stats||s.stats.length===0)&&e.jsx(P,{className:"w-full pb-10",title:`No posts ${S(r)}`,children:e.jsx(te,{strokeWidth:1.5})})]})})]})},Ke=()=>{const{data:{posts:[s]}={posts:[]},isLoading:o}=Ve({searchParams:{filter:"status:[published,sent]",order:"published_at DESC",limit:"1",include:"authors,email,count.clicks"}}),a=s,r=Ee(a?.id||"",{enabled:!!a?.id}),{data:i,isLoading:l}=r;return{data:k.useMemo(()=>{if(!a)return null;const n=i?.stats?.[0]||{id:a.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:a.id,uuid:a.uuid,title:a.title||"",slug:a.slug||"",feature_image:a.feature_image||null,published_at:a.published_at||"",url:a.url||"",excerpt:a.excerpt||"",email_only:a.email_only||!1,status:a.status,email:a.email,count:a.count,authors:a.authors||[],recipient_count:n.recipient_count,opened_count:n.opened_count,open_rate:n.open_rate,member_delta:n.member_delta,free_members:n.free_members,paid_members:n.paid_members,visitors:n.visitors,click_rate:null}},[a,i]),isLoading:o||!!a?.id&&l}},ee=({className:s,title:o,description:a,url:r,children:i})=>e.jsx("a",{className:W("block rounded-xl border bg-card p-6 transition-all hover:shadow-xs hover:bg-accent/50 group/card",s),href:r,rel:"noreferrer",target:"_blank",children:e.jsxs("div",{className:"flex items-center gap-6",children:[i,e.jsxs("div",{className:"flex flex-col gap-0.5 leading-tight",children:[e.jsx("span",{className:"text-base font-semibold",children:o}),e.jsx("span",{className:"text-sm font-normal text-gray-700",children:a})]})]})}),ks=()=>{const{appSettings:s}=z(),{statsConfig:o,isLoading:a,range:r,audience:i}=C(),{startDate:l,endDate:u,timezone:n}=xe(r),{isLoading:p,chartData:t,totals:c,currencySymbol:x}=Re(r),{data:b,isLoading:g}=Ke(),{data:_,isLoading:N}=Ie({searchParams:{date_from:T(l),date_to:T(u),limit:"5",timezone:n}}),E={site_uuid:o?.id||"",date_from:T(l),date_to:T(u),timezone:n,member_status:Fe(i)},{data:w,loading:L}=ke({endpoint:"api_kpis",statsConfig:o,params:E}),j=k.useMemo(()=>U(w||[],r,"visits","sum")?.map(h=>{const v=Number(h.visits),y=isNaN(v)?0:v;return{date:String(h.date),value:y,formattedValue:d(y),label:"Visitors"}}),[w,r]),I=k.useMemo(()=>{const h=[0,1];if(!j||j.length===0)return h;const v=j.map(m=>m.value).filter(m=>m>=0);return v.length===0?h:[0,Math.max(...v)||h[1]]},[j]),re=k.useMemo(()=>{if(!t||t.length===0)return[];let h=[];return h=U(t,r,"value","exact"),h.map(m=>({date:m.date,value:m.free+m.paid,formattedValue:d(m.free+m.paid),label:"Members"}))},[t,r]),ie=k.useMemo(()=>{if(!s?.paidMembersEnabled||!t||t.length===0)return[];let h=[];return h=U(t,r,"mrr","exact"),h.map(m=>({date:m.date,value:H(m.mrr),formattedValue:`${x}${d(H(m.mrr))}`,label:"MRR"}))},[t,r,x,s]),ne=k.useMemo(()=>{if(!w?.length)return{visits:"0"};const h=w.reduce((v,y)=>{const m=Number(y.visits);return v+(isNaN(m)?0:m)},0);return{visits:d(h)}},[w]),oe=a;return e.jsxs(ge,{children:[e.jsx(fe,{children:e.jsx(_e,{children:e.jsx(be,{excludeRanges:["today"]})})}),e.jsxs(je,{isLoading:oe,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(Oe,{currencySymbol:x,growthTotals:c,isLoading:L||p,kpiValues:ne,membersChartData:re,mrrChartData:ie,visitorsChartData:j,visitorsYRange:I}),e.jsx(Ge,{isLoading:g,latestPostStats:b}),e.jsx(Se,{isLoading:N,topPostsData:_}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsx(he,{className:"-mb-4 mt-4 lg:col-span-2",children:"Grow your audience"}),e.jsx(ee,{description:"Find out how to review the performance of your content and get the most out of post analytics in Ghost.",title:"Understanding analytics in Ghost",url:"https://ghost.org/help/native-analytics",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(De,{className:"text-[#00BBA7]",size:20,strokeWidth:1.5})})}),e.jsx(ee,{description:"Use these content distribution tactics to get more people to discover your work and increase engagement.",title:"How to get your content seen online",url:"https://ghost.org/resources/content-distribution/",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(M,{className:"text-[#FE9A00]",size:20,strokeWidth:1.5})})})]})]})]})};export{ks as default};
|