ghost 6.55.0 → 6.56.0
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-custom-field-types-0.0.0.tgz +0 -0
- package/components/tryghost-kg-default-cards-10.3.3.tgz +0 -0
- package/components/tryghost-kg-default-nodes-2.1.4.tgz +0 -0
- package/components/tryghost-kg-default-transforms-1.3.3.tgz +0 -0
- package/components/tryghost-kg-html-to-lexical-1.3.3.tgz +0 -0
- package/components/tryghost-kg-lexical-html-renderer-1.4.3.tgz +0 -0
- package/components/tryghost-nql-string-0.0.0.tgz +0 -0
- package/core/built/admin/assets/{Combination-CJG7Flp-.js → Combination-BCm9FL4o.js} +1 -1
- package/core/built/admin/assets/{PolarAngleAxis-BGjf7sBu.js → PolarAngleAxis-C4qtHy1B.js} +1 -1
- package/core/built/admin/assets/{RadialBarChart-zeFf9mBz.js → RadialBarChart-Bh09Stsj.js} +1 -1
- package/core/built/admin/assets/{account-migration-sjHLx5dy.js → account-migration-D3O_yVck.js} +1 -1
- package/core/built/admin/assets/activitypub/{account-migration-DoYXtnZ8.js → account-migration-D8FbP-Z-.js} +7 -7
- package/core/built/admin/assets/activitypub/activitypub.js +6 -6
- package/core/built/admin/assets/activitypub/{avatar-B3DEDB1l.js → avatar-11EA1VSs.js} +2 -2
- package/core/built/admin/assets/activitypub/{avatar-flipboard-Cqrg0XMx.js → avatar-flipboard-jfbLG-xe.js} +2 -2
- package/core/built/admin/assets/activitypub/{bluesky-sharing-Bxeh6MKW.js → bluesky-sharing-f1jTQe2P.js} +16 -16
- package/core/built/admin/assets/activitypub/{content-formatters-BpQARh28.js → content-formatters-nmTOPY9M.js} +3 -3
- package/core/built/admin/assets/activitypub/{copy-D9UWIAan.js → copy-BCwo9ep3.js} +2 -2
- package/core/built/admin/assets/activitypub/{dist-D8sFfdpC.js → dist-BEfX-0aW.js} +12 -12
- package/core/built/admin/assets/activitypub/{domain-CWueFW6q.js → domain-AaDlZlrA.js} +9 -9
- package/core/built/admin/assets/activitypub/{edit-profile-BGxPU7N5.js → edit-profile-DPi8Tl5M.js} +945 -945
- package/core/built/admin/assets/activitypub/{explore-DBK-u0Ch.js → explore-CxTzjILQ.js} +8 -8
- package/core/built/admin/assets/activitypub/{feed-Bcir5RQZ.js → feed-DPv5x2MX.js} +33 -33
- package/core/built/admin/assets/activitypub/{field-BV-CIT3d.js → field-DbgA8lat.js} +3 -3
- package/core/built/admin/assets/activitypub/{hash-BC9Q0N4c.js → hash-BWuZoYkA.js} +2 -2
- package/core/built/admin/assets/activitypub/{inbox-DQ4ZnC1m.js → inbox-35VDQ2K2.js} +2 -2
- package/core/built/admin/assets/activitypub/{inbox-yC0nfvzl.js → inbox-DSrF_i1O.js} +85 -85
- package/core/built/admin/assets/activitypub/{label-DTRS9TDk.js → label-CPjFBbo7.js} +3 -3
- package/core/built/admin/assets/activitypub/layout-CTgrezN7.js +1 -0
- package/core/built/admin/assets/activitypub/{moderation-Dwl9t0pb.js → moderation-BkDC1XVZ.js} +11 -11
- package/core/built/admin/assets/activitypub/{note-B-zKsZ7r.js → note-xEyH4xT-.js} +7 -7
- package/core/built/admin/assets/activitypub/{notifications-DjJZD54t.js → notifications-DClaL3ui.js} +9 -9
- package/core/built/admin/assets/activitypub/{preferences-CoU8vs6d.js → preferences-DpnOa-4Z.js} +20 -20
- package/core/built/admin/assets/activitypub/{profile-BAsaJekx.js → profile-Dvi9mz-6.js} +237 -237
- package/core/built/admin/assets/activitypub/{reply-CpdMeAO5.js → reply-Cs9ySd6Z.js} +2 -2
- package/core/built/admin/assets/activitypub/{routes-CLH3OVTP.js → routes-DFBeTnfn.js} +1139 -1150
- package/core/built/admin/assets/activitypub/{separator-BI1FLsYM.js → separator-C5u_VjzY.js} +3 -3
- package/core/built/admin/assets/activitypub/{settings-DA6pNJ-Q.js → settings-CV2fFu6D.js} +13 -13
- package/core/built/admin/assets/activitypub/{site-CQD42Pw5.js → site-_TgDd_EM.js} +81 -81
- package/core/built/admin/assets/activitypub/{step-1-DIDg4aHb.js → step-1-BfnNL2oF.js} +5 -5
- package/core/built/admin/assets/activitypub/{step-2-BfGe8BYt.js → step-2-DLndZkO-.js} +6 -6
- package/core/built/admin/assets/activitypub/{step-3-mE9spAqw.js → step-3-A-PZTtRE.js} +10 -10
- package/core/built/admin/assets/activitypub/{tabs-Cg0saow1.js → tabs-BUbz7tea.js} +317 -315
- package/core/built/admin/assets/activitypub/{topic-filter-DLHBZT93.js → topic-filter-BdX_xYYT.js} +3 -3
- package/core/built/admin/assets/activitypub/{use-activity-pub-queries-VzbN99u_.js → use-activity-pub-queries-EwuRemHh.js} +2 -2
- package/core/built/admin/assets/activitypub/{use-navigate-with-base-path-CAwXTmqH.js → use-navigate-with-base-path-cy4ACBc4.js} +92 -90
- package/core/built/admin/assets/activitypub/{use-reply-chain-data-Br4aOWOh.js → use-reply-chain-data-CyFcGfan.js} +5 -5
- package/core/built/admin/assets/activitypub/{x-C8tAnXly.js → x-7zk8mV2p.js} +2 -2
- package/core/built/admin/assets/{audience-DjEWNhp3.js → audience-CkBb2LlO.js} +1 -1
- package/core/built/admin/assets/{automated-emails-DRy7qY-J.js → automated-emails-6t2bIRWf.js} +1 -1
- package/core/built/admin/assets/{automations-Bx3VcFIL.js → automations-cMllU545.js} +1 -1
- package/core/built/admin/assets/{bluesky-sharing-ClMd0-Ft.js → bluesky-sharing-DPGpyD-G.js} +1 -1
- package/core/built/admin/assets/{box-BWbhXh21.js → box-By_EgGtm.js} +1 -1
- package/core/built/admin/assets/{breadcrumb-BD0U2ygg.js → breadcrumb-DIfcF5ow.js} +1 -1
- package/core/built/admin/assets/build-CsiH26uS.js +1 -0
- package/core/built/admin/assets/{card-DGoDJzrn.js → card-aUHX0hyR.js} +1 -1
- package/core/built/admin/assets/{chart-BuRT2Y6p.js → chart-BnXyfH11.js} +1 -1
- package/core/built/admin/assets/{chart-helpers-fjQKRVyY.js → chart-helpers-DV0FkdcD.js} +1 -1
- package/core/built/admin/assets/{checkbox-CWa28lgO.js → checkbox-BIl077a0.js} +1 -1
- package/core/built/admin/assets/{chunk.481.6c7395a49484bb4583aa.js → chunk.332.05991a101d67f732dec3.js} +43 -42
- package/core/built/admin/assets/chunk.524.87b52f4fada529df2c4c.js +25 -0
- package/core/built/admin/assets/chunk.582.340bcca873e806cbd4bb.js +27 -0
- package/core/built/admin/assets/{code-editor-view-CCr0rBWS.js → code-editor-view-C0aWNwdl.js} +1 -1
- package/core/built/admin/assets/comments-qwhIjH3c.js +1 -0
- package/core/built/admin/assets/{container-BYz2Ed39.js → container-LiZf3XdY.js} +1 -1
- package/core/built/admin/assets/{data-list-16rkJYYi.js → data-list-CupF7bjM.js} +1 -1
- package/core/built/admin/assets/{date-range-select-BFp58EMk.js → date-range-select-dXc-GsVe.js} +1 -1
- package/core/built/admin/assets/{disabled-sources-indicator-CUxMfiPa.js → disabled-sources-indicator-DYAXW-6V.js} +1 -1
- package/core/built/admin/assets/dist-BUKmD51u.js +1 -0
- package/core/built/admin/assets/{dist-2Tnz2Yfq.js → dist-CNlMj7ML.js} +1 -1
- package/core/built/admin/assets/{dist-DGzPJ_bO.js → dist-Cb5RSHSg.js} +1 -1
- package/core/built/admin/assets/{dist-P_ohUlTi.js → dist-CqO2lWS0.js} +1 -1
- package/core/built/admin/assets/domain-B5ogXUBa.js +1 -0
- package/core/built/admin/assets/{dropzone-DlK-K2DQ.js → dropzone-BnFG7dDP.js} +1 -1
- package/core/built/admin/assets/{edit-profile-BKT-REJw.js → edit-profile-B07jCZy9.js} +1 -1
- package/core/built/admin/assets/editor-DDYSOXGN.js +8 -0
- package/core/built/admin/assets/{empty-indicator-oX1u1Pkn.js → empty-indicator-WB1WgT9h.js} +1 -1
- package/core/built/admin/assets/{explore-ClUpJZOp.js → explore-Ca1y8HW_.js} +1 -1
- package/core/built/admin/assets/{feed-DF92dUMP.js → feed-x4iFMBP4.js} +1 -1
- package/core/built/admin/assets/{field-Do7lieBA.js → field-ChCAabZg.js} +1 -1
- package/core/built/admin/assets/filter-sources-LdtH1e-T.js +1 -0
- package/core/built/admin/assets/filters-CLehPo_D.js +1 -0
- package/core/built/admin/assets/filters-CjVKRP8U.js +1 -0
- package/core/built/admin/assets/{ghost-c4057474943effc568c5659ccc4909d7.js → ghost-7f01131115186d1af84ead76e79646dd.js} +149 -129
- package/core/built/admin/assets/{ghost-a9c788f6f0b1ea6cf0f14ca4b13f4496.css → ghost-d38c30b866e59f2e06a357b5eb844fe5.css} +1 -1
- package/core/built/admin/assets/{ghost-dark-db36d795d21c61426837df40af270966.css → ghost-dark-1bffd5099ba7a749303133efacf8480b.css} +1 -1
- package/core/built/admin/assets/{gift-link-modal-f9VIMNDv.js → gift-link-modal-Buqh2vXh.js} +1 -1
- package/core/built/admin/assets/{growth-B3I6gNLm.js → growth-DajOBdN0.js} +1 -1
- package/core/built/admin/assets/{growth-CVw1My4S.js → growth-Dy2UOSay.js} +2 -2
- package/core/built/admin/assets/{inbox-CFBSu4Ed.js → inbox-BUOLDoji.js} +12 -12
- package/core/built/admin/assets/index-08n05-rc.js +67 -0
- package/core/built/admin/assets/index-DgUzgFvS.css +1 -0
- package/core/built/admin/assets/{inline-EMAm3okk.js → inline-Cw-gigDW.js} +1 -1
- package/core/built/admin/assets/input-group-uSK3XT7b.js +1 -0
- package/core/built/admin/assets/{input-surface-BpAjZXY5.js → input-surface-BdOe4KzO.js} +1 -1
- package/core/built/admin/assets/koenig-lexical/koenig-lexical.js +9535 -9527
- package/core/built/admin/assets/koenig-lexical/koenig-lexical.umd.js +124 -124
- package/core/built/admin/assets/{koenig-lexical-f8vHRYvz.js → koenig-lexical-BFc4yFed.js} +86 -86
- package/core/built/admin/assets/{kpi-card-DSap9rAy.js → kpi-card-BN-E6WYX.js} +1 -1
- package/core/built/admin/assets/{kpi-card-DU0rn9Cj.js → kpi-card-CCt-qeWD.js} +1 -1
- package/core/built/admin/assets/{kpi-helpers-Dz33AV6h.js → kpi-helpers-DlxTbTs4.js} +1 -1
- package/core/built/admin/assets/{kpi-tabs-BtTTrKvJ.js → kpi-tabs-BlcUttpn.js} +1 -1
- package/core/built/admin/assets/{label-DS8Mi6G5.js → label-AVrxwmsz.js} +1 -1
- package/core/built/admin/assets/{label-picker-1DvSuLA1.js → label-picker-DVnpu_IF.js} +1 -1
- package/core/built/admin/assets/labels-DAIqKed7.js +1 -0
- package/core/built/admin/assets/layout-B0YLh7R9.js +1 -0
- package/core/built/admin/assets/link-helpers-D9LsDOkG.js +1 -0
- package/core/built/admin/assets/{list-page-B6ANtzkd.js → list-page-CdsnQR9N.js} +1 -1
- package/core/built/admin/assets/member-custom-fields-C8NpZYza.js +1 -0
- package/core/built/admin/assets/member-detail-CIVAdKXf.js +1 -0
- package/core/built/admin/assets/{members-CQpVFJu4.js → members-oLPiSkXD.js} +2 -2
- package/core/built/admin/assets/modals-CB7v-k3T.js +31 -0
- package/core/built/admin/assets/{moderation-DySbgyUS.js → moderation-CQ3urTFE.js} +1 -1
- package/core/built/admin/assets/newsletter-rbeDX9Wk.js +1 -0
- package/core/built/admin/assets/newsletters-vt3Ni1Ov.js +1 -0
- package/core/built/admin/assets/{note-C8kxrz6w.js → note-Dk877BTv.js} +1 -1
- package/core/built/admin/assets/{notifications-CgtSfX7t.js → notifications-CPlLjPxO.js} +1 -1
- package/core/built/admin/assets/{onboarding-route-4qtziA9d.js → onboarding-route-DdStOtjy.js} +1 -1
- package/core/built/admin/assets/{overview-Bf2sbznq.js → overview--4V-kx9c.js} +1 -1
- package/core/built/admin/assets/overview-DSLv30oz.js +1 -0
- package/core/built/admin/assets/{page-header-B3Wb9Jqv.js → page-header-pp4dWmOS.js} +1 -1
- package/core/built/admin/assets/{post-analytics-We-ko5Cb.js → post-analytics-BMJrI81R.js} +1 -1
- package/core/built/admin/assets/post-analytics-header-pU2m9ZuV.js +1 -0
- package/core/built/admin/assets/{post-analytics-provider-B6UynTGb.js → post-analytics-provider-Btml5vJI.js} +1 -1
- package/core/built/admin/assets/{post-share-modal-DFfO93_0.js → post-share-modal-AcUZkbfL.js} +1 -1
- package/core/built/admin/assets/preferences-Ru4CRPHC.js +5 -0
- package/core/built/admin/assets/profile-BNb1oj7D.js +1 -0
- package/core/built/admin/assets/{router-provider-C1R4AZ2o.js → router-provider-BmEZf6c6.js} +1 -1
- package/core/built/admin/assets/select-B0HteHrp.js +1 -0
- package/core/built/admin/assets/settings-B1C9Q3wo.js +4 -0
- package/core/built/admin/assets/{settings-WXNeWyU1.js → settings-BGgk7oCI.js} +1 -1
- package/core/built/admin/assets/{shade-app-B3heOAfz-CGXQwWeO.js → shade-app-B3heOAfz-BhQXxNkT.js} +1 -1
- package/core/built/admin/assets/{share-modal-DsgW3wbg.js → share-modal-BeuydaBf.js} +1 -1
- package/core/built/admin/assets/social-urls-DA2lXrhW.js +8 -0
- package/core/built/admin/assets/{sort-button-Bb_FCl7e.js → sort-button-Df4t2AL8.js} +1 -1
- package/core/built/admin/assets/{source-icon-BeaRxUn9.js → source-icon-ajoaKb41.js} +1 -1
- package/core/built/admin/assets/{stack-xiN0eQ6Z.js → stack-CIfOAAVf.js} +1 -1
- package/core/built/admin/assets/{stats-Bjj_kmJ1.js → stats-C_lfxZAw.js} +1 -1
- package/core/built/admin/assets/{stats-view-BxPbW6K1.js → stats-view-Cxot1iD8.js} +1 -1
- package/core/built/admin/assets/{step-1-B1e3-1F8.js → step-1-ogAA4lDr.js} +1 -1
- package/core/built/admin/assets/{step-2-C5WaeBJo.js → step-2-C5Xini-7.js} +1 -1
- package/core/built/admin/assets/{step-3-B46iVPwu.js → step-3-CZv1FV81.js} +2 -2
- package/core/built/admin/assets/{switch-z5Y6Uzt6.js → switch-CyQcwMAv.js} +1 -1
- package/core/built/admin/assets/{table-CB-4_HBJ.js → table-DFj1wiYv.js} +1 -1
- package/core/built/admin/assets/{tabs-CCEgKYzq.js → tabs-D4y1gqUd.js} +1 -1
- package/core/built/admin/assets/{tags-Cg2VJGmG.js → tags-Dmft-Y4O.js} +1 -1
- package/core/built/admin/assets/{text-DwtjwGkh.js → text-DU9Hv33_.js} +1 -1
- package/core/built/admin/assets/textarea-d9qEkMOP.js +1 -0
- package/core/built/admin/assets/{toggle-group-b3IlxvhV.js → toggle-group-R2QMFvXW.js} +1 -1
- package/core/built/admin/assets/{topic-filter-DAFT87tQ.js → topic-filter-DGDxDalo.js} +1 -1
- package/core/built/admin/assets/{use-analytics-data-S0FTd43s.js → use-analytics-data-C76v4LIp.js} +1 -1
- package/core/built/admin/assets/use-filter-params-WrdhAISv.js +1 -0
- package/core/built/admin/assets/{use-growth-stats-CIaiHOVb.js → use-growth-stats-aNXJOmQr.js} +1 -1
- package/core/built/admin/assets/{use-post-referrers-Cq2vBPrA.js → use-post-referrers-CG0SZioj.js} +1 -1
- package/core/built/admin/assets/{use-reply-chain-data-DBDRtGu-.js → use-reply-chain-data-RLdPKRmS.js} +1 -1
- package/core/built/admin/assets/{use-simple-pagination-CjYNxdwe.js → use-simple-pagination-DgcF69KI.js} +1 -1
- package/core/built/admin/assets/{use-tinybird-query-falHAtuK.js → use-tinybird-query-C1R_Kbmy.js} +1 -1
- package/core/built/admin/assets/{use-tinybird-token-D7-8ND1y.js → use-tinybird-token-C9fPjVM_.js} +1 -1
- package/core/built/admin/assets/{virtual-list-CvnC9zF2.js → virtual-list-BmTUzeoF.js} +1 -1
- package/core/built/admin/assets/{web-B_5GZRvH.js → web-BqW0b0_C.js} +1 -1
- package/core/built/admin/assets/web-Cy5GKMWM.js +2 -0
- package/core/built/admin/index.html +16 -16
- package/core/frontend/services/data/fetch-data.js +10 -5
- package/core/frontend/services/routing/api-adapter.js +115 -0
- package/core/frontend/services/routing/api-adapter.ts +157 -0
- package/core/frontend/services/routing/collection-router.js +5 -3
- package/core/frontend/services/routing/controllers/index.js +1 -1
- package/core/frontend/services/routing/controllers/rss.js +26 -31
- package/core/frontend/services/routing/controllers/rss.ts +66 -0
- package/core/frontend/services/routing/controllers/static.js +8 -7
- package/core/frontend/services/routing/parent-router.js +17 -4
- package/core/frontend/services/routing/permalink-adapter.js +26 -0
- package/core/frontend/services/routing/permalink-adapter.ts +23 -0
- package/core/frontend/services/routing/registry.js +59 -33
- package/core/frontend/services/routing/router-manager.js +9 -13
- package/core/frontend/services/routing/static-routes-router.js +4 -4
- package/core/frontend/services/routing/taxonomy-router.js +6 -2
- package/core/server/data/migrations/versions/6.56/2026-08-03-19-27-51-add-automation-run-step-id-to-automated-email-recipients.js +8 -0
- package/core/server/data/migrations/versions/6.56/2026-08-04-14-42-39-restrict-notification-add-permission-to-administrators.js +12 -0
- package/core/server/data/schema/fixtures/fixtures.json +2 -2
- package/core/server/data/schema/schema.js +1 -0
- package/core/server/models/post.js +10 -1
- package/core/server/services/automations/automations-repository.ts +3 -1
- package/core/server/services/automations/database-automations-repository.js +33 -14
- package/core/server/services/automations/database-automations-repository.ts +41 -15
- package/core/server/services/automations/get-scheduler-idempotency-key.js +13 -0
- package/core/server/services/automations/get-scheduler-idempotency-key.ts +8 -0
- package/core/server/services/automations/poll.js +3 -1
- package/core/server/services/automations/poll.ts +4 -1
- package/core/server/services/automations/service.js +5 -1
- package/core/server/services/automations/service.ts +5 -1
- package/core/server/services/gift-links/CONTEXT.md +9 -0
- package/core/server/services/gifts/CONTEXT.md +55 -0
- package/core/server/services/gifts/README.md +28 -0
- package/core/server/services/gifts/gift-bookshelf-repository.js +65 -45
- package/core/server/services/gifts/gift-bookshelf-repository.ts +203 -74
- package/core/server/services/gifts/gift-checkout-adapter.js +59 -0
- package/core/server/services/gifts/gift-checkout-offer.js +74 -0
- package/core/server/services/gifts/gift-checkout-offer.ts +127 -0
- package/core/server/services/gifts/gift-codec.js +63 -0
- package/core/server/services/gifts/gift-codec.ts +62 -0
- package/core/server/services/gifts/gift-controller.js +6 -31
- package/core/server/services/gifts/gift-controller.ts +6 -69
- package/core/server/services/gifts/gift-email-service.ts +3 -2
- package/core/server/services/gifts/gift-schema.js +34 -0
- package/core/server/services/gifts/gift-schema.ts +39 -0
- package/core/server/services/gifts/gift-service-wrapper.js +13 -11
- package/core/server/services/gifts/gift-service.js +265 -52
- package/core/server/services/gifts/gift-service.ts +431 -97
- package/core/server/services/gifts/gift.ts +16 -39
- package/core/server/services/link-tracking/link-click-repository.js +6 -1
- package/core/server/services/link-tracking/link-click-tracking-service.js +12 -3
- package/core/server/services/member-welcome-emails/member-welcome-email-renderer.js +4 -3
- package/core/server/services/member-welcome-emails/service.js +7 -3
- package/core/server/services/members/api.js +1 -2
- package/core/server/services/members/import-export/import/importer.ts +3 -2
- package/core/server/services/members/import-export/index.js +10 -2
- package/core/server/services/members/import-export/index.ts +14 -4
- package/core/server/services/members/members-api/controllers/router-controller.js +38 -36
- package/core/server/services/members/members-api/members-api.js +13 -7
- package/core/server/services/members/members-api/repositories/event-repository.js +4 -94
- package/core/server/services/members/members-api/services/member-bread-service.js +3 -3
- package/core/server/services/members/members-api/services/payments-service.js +6 -68
- package/core/server/services/members-custom-fields/schema.js +8 -1
- package/core/server/services/members-custom-fields/schema.ts +8 -0
- package/core/server/services/members-custom-fields/values-service.js +118 -2
- package/core/server/services/members-custom-fields/values-service.ts +134 -4
- package/core/server/services/oembed/oembed-service.js +44 -3
- package/core/server/services/posts/posts-service.js +11 -0
- package/core/server/services/route-settings/dynamic-routing-service.js +1 -3
- package/core/server/services/route-settings/route-settings-parser.js +25 -25
- package/core/server/services/route-settings/route-settings-parser.ts +27 -27
- package/core/server/services/route-settings/validation-errors.js +68 -4
- package/core/server/services/route-settings/validation-errors.ts +79 -4
- package/core/server/services/stats/posts-stats-service.js +27 -23
- package/core/server/services/stripe/services/webhook/charge-refunded-event-service.js +1 -1
- package/core/server/services/stripe/services/webhook/checkout-session-event-service.js +16 -4
- package/core/server/services/stripe/stripe-api.js +10 -0
- package/core/server/web/gift-preview/controller.js +10 -25
- package/core/shared/labs.js +2 -2
- package/package.json +10 -9
- package/pnpm-lock.yaml +28 -18
- package/pnpm-workspace.yaml +5 -4
- package/components/tryghost-kg-default-nodes-2.1.3.tgz +0 -0
- package/core/built/admin/assets/activitypub/layout-qx-bUL1k.js +0 -1
- package/core/built/admin/assets/chunk.524.cffd399783a519e404a9.js +0 -25
- package/core/built/admin/assets/chunk.582.eebf0d0b2d202bb746a5.js +0 -27
- package/core/built/admin/assets/comments-DyUSMUdj.js +0 -1
- package/core/built/admin/assets/dist-CjY-f5Z1.js +0 -1
- package/core/built/admin/assets/domain-C0bV2UV8.js +0 -1
- package/core/built/admin/assets/editor-Dp865O-4.js +0 -8
- package/core/built/admin/assets/filter-sources-BV2rnpfA.js +0 -1
- package/core/built/admin/assets/filters-CUXJ2Nm9.js +0 -1
- package/core/built/admin/assets/filters-DfbIWc_l.js +0 -1
- package/core/built/admin/assets/index-9Cw8z3rA.css +0 -1
- package/core/built/admin/assets/index-BGG7NckO.js +0 -67
- package/core/built/admin/assets/input-group-BSgG_lVw.js +0 -1
- package/core/built/admin/assets/labels-CDSUt4J_.js +0 -1
- package/core/built/admin/assets/layout-yQEi2qDM.js +0 -1
- package/core/built/admin/assets/link-helpers-7EYqvvHs.js +0 -1
- package/core/built/admin/assets/member-custom-fields-yOMHyAg9.js +0 -1
- package/core/built/admin/assets/member-detail-BAq7gDaa.js +0 -1
- package/core/built/admin/assets/modals-ReORvWnu.js +0 -31
- package/core/built/admin/assets/newsletter-CJQvtHqN.js +0 -1
- package/core/built/admin/assets/newsletters-B3QQXfGT.js +0 -1
- package/core/built/admin/assets/nql-BsgFMd93.js +0 -1
- package/core/built/admin/assets/overview-CBfePxcr.js +0 -1
- package/core/built/admin/assets/post-analytics-header-Bmc9su6q.js +0 -1
- package/core/built/admin/assets/preferences-DJPfHEGu.js +0 -5
- package/core/built/admin/assets/profile-DqBQp-gT.js +0 -1
- package/core/built/admin/assets/select-C5_xEt5b.js +0 -1
- package/core/built/admin/assets/settings-BwiVIXau.js +0 -4
- package/core/built/admin/assets/social-urls-BQPFEk1_.js +0 -8
- package/core/built/admin/assets/textarea-Bjccvh_E.js +0 -1
- package/core/built/admin/assets/use-filter-params-Gpoq2E1L.js +0 -1
- package/core/built/admin/assets/web-jFYWCKDn.js +0 -2
- package/core/server/services/gifts/gift-repository.js +0 -2
- package/core/server/services/gifts/gift-repository.ts +0 -29
- package/core/server/services/route-settings/activation-bridge.js +0 -174
- package/core/server/services/route-settings/activation-bridge.ts +0 -250
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{t as n}from"./react-Bb3IsNbi.js";import{t as r}from"./jsx-runtime-DX3WBWVO.js";import{m as i}from"./hooks-CixO01lL.js";import{t as a}from"./use-tinybird-query-
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{t as n}from"./react-Bb3IsNbi.js";import{t as r}from"./jsx-runtime-DX3WBWVO.js";import{m as i}from"./hooks-CixO01lL.js";import{t as a}from"./use-tinybird-query-C1R_Kbmy.js";import{n as o}from"./posts-DhXE7b6r.js";import{t as s}from"./analytics-53FOa2wq.js";import{f as c}from"./dist-Cb5RSHSg.js";import{Ar as l,Dr as u,Er as d,Ir as f,Or as p,Tn as m,Vs as h,Zn as g,kn as _,kr as v,s as y,wr as b}from"./index-08n05-rc.js";import{t as x}from"./share-modal-BeuydaBf.js";import{t as S}from"./pages-B4goRPUn.js";import{n as C,r as w}from"./gift-links-CsUhefWG.js";var T=e(n(),1);function E(e,t){return!e||!t?``:`${e}?gift=${encodeURIComponent(t)}`}var D={members:`members-only`,paid:`paid-members-only`,tiers:`paid-members-only`};function O(e){return e&&D[e]||``}var k=({postUuid:e,token:t,tokenLoading:n=!1,tokenError:r=null,enabled:i=!0})=>{let{data:o,isLoading:s}=h(),c=o?.config?.stats,{data:l,isLoading:u}=_(),d=m(l?.settings??null,`web_analytics_enabled`)??!1,f=(0,T.useMemo)(()=>({site_uuid:c?.id||``,post_uuid:e||``,gift_link:t||``}),[c?.id,e,t]),{data:p,loading:g,error:v}=a({endpoint:`api_gift_link_visits`,statsConfig:c||{id:``},params:f,enabled:i&&d&&!!c?.id&&!!e&&!!t}),y=g||s||u||n,b=v||r||null;return{usage:(0,T.useMemo)(()=>{if(!d||!t||b||!Array.isArray(p))return;let e=p[0];return{visits:Number(e?.visits)||0,views:Number(e?.views)||0}},[p,t,b,d]),loading:y,error:b}},A=({postId:e,resource:t=`posts`,enabled:n=!0})=>{let r=t===`posts`,{data:i,isLoading:a}=o({searchParams:{filter:`id:${e}`,include:y},enabled:n&&r}),{data:s,isLoading:c}=S({searchParams:{filter:`id:${e}`},enabled:n&&!r});if(r){let e=i?.posts?.[0];return{post:e&&{url:e.url,title:e.title,visibility:e.visibility,uuid:e.uuid},isLoading:a}}let l=s?.pages?.[0];return{post:l&&{url:l.url,title:l.title,visibility:l.visibility,uuid:l.uuid},isLoading:c}},j=t({default:()=>P}),M=r();function N(e){return e===0?`No visitors yet`:`${c(e)} ${e===1?`visitor`:`visitors`}`}var P=({open:e,onOpenChange:t,postId:n,resource:r=`posts`,source:a})=>{let o=i(),{mutateAsync:c}=w(),{mutateAsync:m}=C(),{post:h}=A({postId:n,resource:r,enabled:e}),[_,y]=(0,T.useState)(void 0),[S,D]=(0,T.useState)(`idle`),[O,j]=(0,T.useState)(!1),[P,F]=(0,T.useState)(!1),I=(0,T.useRef)(null),L=(0,T.useRef)(null),{usage:R}=k({postUuid:h?.uuid,token:_,enabled:e});(0,T.useEffect)(()=>{if(!e){L.current=null,F(!1);return}let t=L.current;(t?.postId!==n||t.resource!==r)&&(t={postId:n,resource:r,request:c({id:n,resource:r})},L.current=t);let i=!1;return F(!0),t.request.then(e=>{i||y(e.gift_links[0]?.token)}).catch(e=>{i||o(e)}).finally(()=>{i||F(!1)}),()=>{i=!0}},[e,n,r,c,o]),(0,T.useEffect)(()=>{S===`confirm`&&I.current?.focus()},[S]);let z=r===`pages`?`page`:`post`,B=h?.visibility??`unknown`,V=(0,T.useRef)(!1);(0,T.useEffect)(()=>{if(!e){V.current=!1;return}V.current||!h||(V.current=!0,s(`Gift Link Modal Opened`,{postType:z,visibility:B,source:a}))},[e,h,z,B,a]);let H=E(h?.url,_),U=`Anyone you share this link with will be able to access this ${z} without becoming a ${h?.visibility===`members`?`member`:`paid member`}.`,W=(0,T.useCallback)(async()=>{if(!O){j(!0);try{let e=await m({id:n,resource:r});y(e.gift_links[0]?.token),D(`idle`),s(`Gift Link Reset`,{postType:z,visibility:B,source:a})}catch(e){o(e)}finally{j(!1)}}},[O,m,n,r,o,z,B,a]),G=(0,T.useCallback)(e=>{e||D(`idle`),t(e)},[t]);return(0,M.jsx)(b,{open:e,onOpenChange:G,children:(0,M.jsxs)(d,{className:`max-w-lg gap-5`,children:[S===`idle`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(v,{className:`gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(l,{className:`text-xl leading-none`,children:`Gift link`}),R&&(0,M.jsx)(g,{"data-testid":`gift-link-views`,variant:`secondary`,children:N(R.visits)})]}),(0,M.jsx)(u,{className:`text-sm leading-5`,children:U})]}),(0,M.jsx)(x.CopyURLBox,{className:`w-full min-w-0`,copyURL:P?`Generating link…`:H,children:(0,M.jsx)(x.CopyButton,{className:`shrink-0`,copyURL:H,"data-testid":`copy-gift-link`,disabled:P||!H,icon:`link`,size:`sm`,onClick:()=>s(`Gift Link Copied`,{postType:z,visibility:B,source:a})})}),(0,M.jsxs)(p,{className:`sm:items-center sm:justify-between`,children:[(0,M.jsx)(f,{className:`border-destructive/20 text-destructive hover:border-destructive hover:bg-transparent hover:text-destructive dark:border-state-danger/50 dark:text-state-danger dark:hover:border-state-danger dark:hover:bg-transparent dark:hover:text-state-danger`,"data-testid":`reset-gift-link`,disabled:!H,variant:`outline`,onClick:()=>D(`confirm`),children:`Reset`}),(0,M.jsx)(f,{variant:`outline`,onClick:()=>G(!1),children:`Close`})]})]}),S===`confirm`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(v,{children:[(0,M.jsx)(l,{children:`Reset gift link`}),(0,M.jsxs)(u,{children:[`Are you sure you want to reset this link? Anyone with the current link will lose access to this `,z,`.`]})]}),(0,M.jsxs)(p,{children:[(0,M.jsx)(f,{ref:I,disabled:O,variant:`outline`,onClick:()=>D(`idle`),children:`Cancel`}),(0,M.jsx)(f,{"data-testid":`confirm-reset-gift-link`,disabled:O,variant:`destructive`,onClick:()=>{W()},children:O?`Resetting`:`Reset link`})]})]})]})})};export{O as i,j as n,k as r,P as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{i as r,n as i,t as a}from"./source-icon-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{i as r,n as i,t as a}from"./source-icon-ajoaKb41.js";import{m as o}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as s}from"./router-provider-BmEZf6c6.js";import{c,f as l}from"./dist-Cb5RSHSg.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./card-aUHX0hyR.js";import{t as g}from"./empty-indicator-WB1WgT9h.js";import{a as _,c as v,n as y,r as b,s as x,t as S}from"./table-DFj1wiYv.js";import{Bn as C,Fn as w,Hs as T,In as E,Ir as D,Jn as O,Ln as k,Mi as A,Pi as j,Rn as M,Uo as N,ar as P,ir as F,oa as I,zi as L,zn as R}from"./index-08n05-rc.js";import{t as z}from"./disabled-sources-indicator-DYAXW-6V.js";import{t as ee}from"./use-analytics-data-C76v4LIp.js";import{t as B}from"./member-route-0Aa52Ntz.js";import{a as V,i as H,n as U,r as W,t as G}from"./kpi-card-CCt-qeWD.js";import{r as K,t as q}from"./post-analytics-header-pU2m9ZuV.js";import{n as J,t as Y}from"./use-post-referrers-CG0SZioj.js";var X=e(t(),1),Z=n(),Q=`https://www.google.com/s2/favicons?domain=ghost.org&sz=64`,$=({headerStyle:e=`table`,children:t=`Source`,data:n,mode:r,defaultSourceIconUrl:i=Q})=>{let{appSettings:o}=T();if(r===`growth`)return(0,Z.jsxs)(S,{children:[(0,Z.jsx)(x,{children:(0,Z.jsxs)(v,{children:[(0,Z.jsx)(_,{className:`min-w-[320px]`,variant:e===`table`?`default`:`cardhead`,children:t}),(0,Z.jsx)(_,{className:`w-[110px] text-right`,children:`Free members`}),o?.paidMembersEnabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_,{className:`w-[110px] text-right`,children:`Paid members`}),(0,Z.jsx)(_,{className:`w-[100px] text-right`,children:`MRR impact`})]})]})}),(0,Z.jsx)(y,{children:n?.map(e=>(0,Z.jsxs)(v,{className:`last:border-none`,children:[(0,Z.jsx)(b,{children:e.linkUrl?(0,Z.jsxs)(`a`,{className:`group flex items-center gap-2`,href:e.linkUrl,rel:`noreferrer`,target:`_blank`,children:[(0,Z.jsx)(a,{defaultSourceIconUrl:i,displayName:e.displayName,iconSrc:e.iconSrc}),(0,Z.jsx)(`span`,{className:`group-hover:underline`,children:e.displayName})]}):(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(a,{defaultSourceIconUrl:i,displayName:e.displayName,iconSrc:e.iconSrc}),(0,Z.jsx)(`span`,{children:e.displayName})]})}),(0,Z.jsxs)(b,{className:`text-right font-mono text-sm`,children:[`+`,l(e.free_members||0)]}),o?.paidMembersEnabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(b,{className:`text-right font-mono text-sm`,children:[`+`,l(e.paid_members||0)]}),(0,Z.jsxs)(b,{className:`text-right font-mono text-sm`,children:[`+$`,l((e=>Math.round(e/100))(e.mrr||0))]})]})]},e.source))})]})},te=({title:e=`Top sources`,description:t,data:n,mode:a=`visits`,range:o=30,totalVisitors:s=0,siteUrl:l,siteIcon:_,defaultSourceIconUrl:v=Q,getPeriodText:y,className:b})=>{let{appSettings:x}=T(),S=X.useMemo(()=>r({data:n,mode:a,siteUrl:l,siteIcon:_,defaultSourceIconUrl:v}),[n,l,_,a,v]),O=X.useMemo(()=>i({processedData:S,totalVisitors:s,mode:a}),[S,s,a]),A=O.slice(0,10),j=t||(a===`growth`?`Where did your growth come from?`:`How readers found your ${o?`site`:`post`}${o&&y?` ${y(o)}`:``}`),N=a===`growth`?`Sources`:`Top sources`,P=a===`growth`?`Where did your growth come from?`:`How readers found your ${o?`site`:`post`}${o&&y?` ${y(o)}`:``}`;return(0,Z.jsxs)(h,{className:c(`group/datalist w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]`,b),"data-testid":`top-sources-card`,children:[A.length<=0&&(0,Z.jsxs)(u,{children:[(0,Z.jsx)(p,{children:e}),(0,Z.jsx)(m,{children:j})]}),(0,Z.jsx)(f,{children:a===`growth`&&!x?.analytics.membersTrackSources?(0,Z.jsx)(z,{className:`py-10`}):A.length>0?(0,Z.jsx)($,{data:A,defaultSourceIconUrl:v,getPeriodText:y,headerStyle:`card`,mode:a,range:o,children:(0,Z.jsxs)(u,{children:[(0,Z.jsx)(p,{children:e}),(0,Z.jsx)(m,{children:j})]})}):(0,Z.jsx)(`div`,{className:`py-20 text-center text-sm text-gray-700`,children:(0,Z.jsx)(g,{className:`h-full`,description:a===`growth`&&`Once someone signs up on this post, sources will show here`,title:`No sources data available ${y?y(o):``}`,children:(0,Z.jsx)(L,{strokeWidth:1.5})})})}),O.length>10&&(0,Z.jsx)(d,{children:(0,Z.jsxs)(w,{children:[(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsxs)(D,{variant:`outline`,children:[`View all `,(0,Z.jsx)(I,{})]})}),(0,Z.jsxs)(E,{className:`overflow-y-auto pt-0 sm:max-w-[420px]`,children:[(0,Z.jsxs)(M,{className:`sticky top-0 z-40 -mx-6 bg-surface-elevated/60 p-6 backdrop-blur`,children:[(0,Z.jsx)(R,{children:N}),(0,Z.jsx)(k,{children:P})]}),(0,Z.jsx)(`div`,{className:`group/datalist`,children:(0,Z.jsx)($,{data:O,defaultSourceIconUrl:v,getPeriodText:y,mode:a,range:o})})]})]})})]})},ne=()=>{let{site:e}=ee(),{postId:t}=o(),{stats:n,totals:r,isLoading:i,currencySymbol:a}=Y(t||``),{appSettings:c}=T(),d=s(),g=e=>d(B({filter:e})),_=e.url,v=e.icon,y=`flex flex-col items-stretch gap-6`,b=``;return c?.paidMembersEnabled||(y=`grid grid-cols-1 border rounded-md`,b=`border-none hover:shadow-none`),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{currentTab:`Growth`}),(0,Z.jsx)(K,{children:i?(0,Z.jsxs)(`div`,{className:y,children:[(0,Z.jsx)(h,{className:b,children:(0,Z.jsx)(f,{className:`grid grid-cols-3 p-0`,children:Array.from({length:3},(e,t)=>(0,Z.jsxs)(`div`,{className:`h-[98px] gap-1 border-r px-6 py-5 last:border-r-0`,children:[(0,Z.jsx)(F,{className:`w-2/3`}),(0,Z.jsx)(F,{className:`h-7 w-12`})]},t))})}),(0,Z.jsxs)(h,{className:b,children:[(0,Z.jsxs)(u,{children:[(0,Z.jsx)(p,{children:`Top sources`}),(0,Z.jsx)(m,{children:`Where did your growth come from?`})]}),(0,Z.jsxs)(f,{children:[(0,Z.jsx)(O,{}),(0,Z.jsx)(P,{className:`pt-6`})]})]})]}):(0,Z.jsxs)(`div`,{className:y,children:[(0,Z.jsxs)(h,{className:b,"data-testid":`members-card`,children:[(0,Z.jsxs)(u,{className:`hidden`,children:[(0,Z.jsx)(p,{children:`Newsletters`}),(0,Z.jsx)(m,{children:`How did this post perform`})]}),(0,Z.jsx)(f,{className:`p-0`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col md:grid md:items-stretch ${c?.paidMembersEnabled?`md:grid-cols-3`:`md:grid-cols-1`}`,children:[(0,Z.jsxs)(G,{className:`grow`,children:[(0,Z.jsx)(H,{onClick:()=>{g(`signup:'${t}'+conversion:-'${t}'`)},children:`View members →`}),(0,Z.jsxs)(W,{onClick:()=>{g(`signup:'${t}'+conversion:-'${t}'`)},children:[(0,Z.jsx)(j,{strokeWidth:1.5}),`Free members`]}),(0,Z.jsx)(U,{children:(0,Z.jsx)(V,{children:l(r?.free_members||0)})})]}),c?.paidMembersEnabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(G,{className:`grow`,children:[(0,Z.jsx)(H,{onClick:()=>{g(`conversion:'${t}'`)},children:`View members →`}),(0,Z.jsxs)(W,{onClick:()=>{g(`conversion:'${t}'`)},children:[(0,Z.jsx)(A,{strokeWidth:1.5}),`Paid members`]}),(0,Z.jsx)(U,{children:(0,Z.jsx)(V,{children:l(r?.paid_members||0)})})]}),(0,Z.jsxs)(G,{className:`grow`,children:[(0,Z.jsxs)(W,{children:[(0,Z.jsx)(N,{strokeWidth:1.5}),`MRR`]}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(V,{children:[`+`,a,J(r?.mrr||0)]})})]})]})]})})]}),!c?.paidMembersEnabled&&(0,Z.jsx)(O,{}),(0,Z.jsx)(te,{className:b,data:n,mode:`growth`,siteIcon:v,siteUrl:_})]})})]})};export{ne as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{d as r,g as i,l as a,n as o}from"./stats-Bjj_kmJ1.js";import{t as s}from"./currency-CQsJu8iC.js";import{r as c,t as l}from"./source-icon-BeaRxUn9.js";import{g as u}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as d}from"./router-provider-C1R4AZ2o.js";import{b as f,f as p,l as m,x as h,y as g}from"./dist-DGzPJ_bO.js";import{E as _}from"./_baseAssignValue-C_vooEQc.js";import{$ as v,C as y,E as b,I as x,J as S,K as C,P as w,Q as T,S as E,Y as D,Z as ee,_ as te,a as ne,at as re,b as ie,ct as ae,dt as oe,et as se,g as ce,i as le,it as ue,n as de,nt as fe,ot as O,r as pe,st as me,ut as he,w as ge,x as _e,y as ve}from"./chart-BuRT2Y6p.js";import{n as ye,t as be}from"./PolarAngleAxis-BGjf7sBu.js";import{a as xe,c as Se,i as k,l as Ce,n as A,r as we,t as Te,u as Ee}from"./chart-helpers-fjQKRVyY.js";import{n as De,t as j}from"./sort-button-Bb_FCl7e.js";import{i as Oe,r as ke,t as Ae}from"./tabs-CCEgKYzq.js";import{i as je,n as Me,o as Ne,s as Pe,t as Fe}from"./select-C5_xEt5b.js";import{a as Ie,n as M,o as Le,r as Re,t as N}from"./card-DGoDJzrn.js";import{t as P}from"./empty-indicator-oX1u1Pkn.js";import{a as F,c as I,i as ze,n as L,r as R,s as Be,t as Ve}from"./table-CB-4_HBJ.js";import{Bn as He,Br as z,Fn as Ue,Hr as B,In as We,Ir as Ge,Jn as Ke,Jr as qe,Ln as Je,Qr as Ye,Rn as Xe,Vs as Ze,Wr as Qe,Xr as $e,aa as et,cs as tt,i as nt,ii as rt,ir as it,jo as at,ls as ot,nr as st,os as ct,p as lt,u as V,zn as ut,zr as H}from"./index-BGG7NckO.js";import{n as dt,r as U,t as ft}from"./kpi-tabs-BtTTrKvJ.js";import{a as pt}from"./tiers-DYsa4DCo.js";import{i as mt,n as ht,r as gt,t as _t}from"./stats-view-BxPbW6K1.js";import{t as vt}from"./disabled-sources-indicator-CUxMfiPa.js";import{t as yt}from"./use-growth-stats-CIaiHOVb.js";import{t as bt}from"./use-analytics-data-S0FTd43s.js";import{n as xt}from"./audience-DjEWNhp3.js";import{n as St}from"./referrers-pmJT4k3-.js";import{i as Ct,r as wt,t as W}from"./content-helpers-CNBPrwsi.js";import{t as Tt}from"./url-helpers-CCyfRrKj.js";var G=e(t()),Et=e(oe()),Dt=e(x()),K=e(he()),q=e(_()),Ot;function J(e){"@babel/helpers - typeof";return J=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},J(e)}function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(this,arguments)}function kt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?kt(Object(n),!0).forEach(function(t){Z(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function At(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function jt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,Bt(r.key),r)}}function Mt(e,t,n){return t&&jt(e.prototype,t),n&&jt(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Nt(e,t,n){return t=Lt(t),Pt(e,It()?Reflect.construct(t,n||[],Lt(e).constructor):t.apply(e,n))}function Pt(e,t){if(t&&(J(t)===`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return Ft(e)}function Ft(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function It(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(It=function(){return!!e})()}function Lt(e){return Lt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Lt(e)}function Rt(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&zt(e,t)}function zt(e,t){return zt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},zt(e,t)}function Z(e,t,n){return t=Bt(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Bt(e){var t=Vt(e,`string`);return J(t)==`symbol`?t:t+``}function Vt(e,t){if(J(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(J(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Q=function(e){function t(e){var n;return At(this,t),n=Nt(this,t,[e]),Z(n,`pieRef`,null),Z(n,`sectorRefs`,[]),Z(n,`id`,ae(`recharts-pie-`)),Z(n,`handleAnimationEnd`,function(){var e=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),(0,q.default)(e)&&e()}),Z(n,`handleAnimationStart`,function(){var e=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),(0,q.default)(e)&&e()}),n.state={isAnimationFinished:!e.isAnimationActive,prevIsAnimationActive:e.isAnimationActive,prevAnimationId:e.animationId,sectorToFocus:0},n}return Rt(t,e),Mt(t,[{key:`isActiveIndex`,value:function(e){var t=this.props.activeIndex;return Array.isArray(t)?t.indexOf(e)!==-1:e===t}},{key:`hasActiveIndex`,value:function(){var e=this.props.activeIndex;return Array.isArray(e)?e.length!==0:e||e===0}},{key:`renderLabels`,value:function(e){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var n=this.props,r=n.label,i=n.labelLine,a=n.dataKey,o=n.valueKey,s=v(this.props,!1),c=v(r,!1),l=v(i,!1),u=r&&r.offsetRadius||20,d=e.map(function(e,n){var d=(e.startAngle+e.endAngle)/2,f=b(e.cx,e.cy,e.outerRadius+u,d),p=X(X(X(X({},s),e),{},{stroke:`none`},c),{},{index:n,textAnchor:t.getTextAnchor(f.x,e.cx)},f),m=X(X(X(X({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:n,points:[b(e.cx,e.cy,e.outerRadius,d),f]}),h=a;return(0,K.default)(a)&&(0,K.default)(o)?h=`value`:(0,K.default)(a)&&(h=o),G.createElement(T,{key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${n}`},i&&t.renderLabelLineItem(i,m,`line`),t.renderLabelItem(r,p,w(e,h)))});return G.createElement(T,{className:`recharts-pie-labels`},d)}},{key:`renderSectorsStatically`,value:function(e){var t=this,n=this.props,r=n.activeShape,i=n.blendStroke,a=n.inactiveShape;return e.map(function(n,o){if(n?.startAngle===0&&n?.endAngle===0&&e.length!==1)return null;var s=t.isActiveIndex(o),c=a&&t.hasActiveIndex()?a:null,l=s?r:c,u=X(X({},n),{},{stroke:i?n.fill:n.stroke,tabIndex:-1});return G.createElement(T,Y({ref:function(e){e&&!t.sectorRefs.includes(e)&&t.sectorRefs.push(e)},tabIndex:-1,className:`recharts-pie-sector`},fe(t.props,n,o),{key:`sector-${n?.startAngle}-${n?.endAngle}-${n.midAngle}-${o}`}),G.createElement(te,Y({option:l,isActive:s,shapeType:`sector`},u)))})}},{key:`renderSectorsWithAnimation`,value:function(){var e=this,t=this.props,n=t.sectors,r=t.isAnimationActive,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.animationId,c=this.state,l=c.prevSectors,u=c.prevIsAnimationActive;return G.createElement(ve,{begin:i,duration:a,isActive:r,easing:o,from:{t:0},to:{t:1},key:`pie-${s}-${u}`,onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(t){var r=t.t,i=[],a=(n&&n[0]).startAngle;return n.forEach(function(e,t){var n=l&&l[t],o=t>0?(0,Et.default)(e,`paddingAngle`,0):0;if(n){var s=re(n.endAngle-n.startAngle,e.endAngle-e.startAngle),c=X(X({},e),{},{startAngle:a+o,endAngle:a+s(r)+o});i.push(c),a=c.endAngle}else{var u=e.endAngle,d=e.startAngle,f=re(0,u-d)(r),p=X(X({},e),{},{startAngle:a+o,endAngle:a+f+o});i.push(p),a=p.endAngle}}),G.createElement(T,null,e.renderSectorsStatically(i))})}},{key:`attachKeyboardHandlers`,value:function(e){var t=this;e.onkeydown=function(e){if(!e.altKey)switch(e.key){case`ArrowLeft`:var n=++t.state.sectorToFocus%t.sectorRefs.length;t.sectorRefs[n].focus(),t.setState({sectorToFocus:n});break;case`ArrowRight`:var r=--t.state.sectorToFocus<0?t.sectorRefs.length-1:t.state.sectorToFocus%t.sectorRefs.length;t.sectorRefs[r].focus(),t.setState({sectorToFocus:r});break;case`Escape`:t.sectorRefs[t.state.sectorToFocus].blur(),t.setState({sectorToFocus:0});break;default:}}}},{key:`renderSectors`,value:function(){var e=this.props,t=e.sectors,n=e.isAnimationActive,r=this.state.prevSectors;return n&&t&&t.length&&(!r||!(0,Dt.default)(r,t))?this.renderSectorsWithAnimation():this.renderSectorsStatically(t)}},{key:`componentDidMount`,value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:`render`,value:function(){var e=this,t=this.props,n=t.hide,r=t.sectors,i=t.className,a=t.label,o=t.cx,s=t.cy,c=t.innerRadius,l=t.outerRadius,u=t.isAnimationActive,d=this.state.isAnimationFinished;if(n||!r||!r.length||!O(o)||!O(s)||!O(c)||!O(l))return null;var f=h(`recharts-pie`,i);return G.createElement(T,{tabIndex:this.props.rootTabIndex,className:f,ref:function(t){e.pieRef=t}},this.renderSectors(),a&&this.renderLabels(r),E.renderCallByParent(this.props,null,!1),(!u||d)&&_e.renderCallByParent(this.props,r,!1))}}],[{key:`getDerivedStateFromProps`,value:function(e,t){return t.prevIsAnimationActive===e.isAnimationActive?e.isAnimationActive&&e.animationId!==t.prevAnimationId?{prevAnimationId:e.animationId,curSectors:e.sectors,prevSectors:t.curSectors,isAnimationFinished:!0}:e.sectors===t.curSectors?null:{curSectors:e.sectors,isAnimationFinished:!0}:{prevIsAnimationActive:e.isAnimationActive,prevAnimationId:e.animationId,curSectors:e.sectors,prevSectors:[],isAnimationFinished:!0}}},{key:`getTextAnchor`,value:function(e,t){return e>t?`start`:e<t?`end`:`middle`}},{key:`renderLabelLineItem`,value:function(e,t,n){if(G.isValidElement(e))return G.cloneElement(e,t);if((0,q.default)(e))return e(t);var r=h(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className);return G.createElement(ie,Y({},t,{key:n,type:`linear`,className:r}))}},{key:`renderLabelItem`,value:function(e,t,n){if(G.isValidElement(e))return G.cloneElement(e,t);var r=n;if((0,q.default)(e)&&(r=e(t),G.isValidElement(r)))return r;var i=h(`recharts-pie-label-text`,typeof e!=`boolean`&&!(0,q.default)(e)?e.className:``);return G.createElement(C,Y({},t,{alignmentBaseline:`middle`,className:i}),r)}}])}(G.PureComponent);Ot=Q,Z(Q,`displayName`,`Pie`),Z(Q,`defaultProps`,{stroke:`#fff`,fill:`#808080`,legendType:`rect`,cx:`50%`,cy:`50%`,startAngle:0,endAngle:360,innerRadius:0,outerRadius:`80%`,paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!D.isSsr,animationBegin:400,animationDuration:1500,animationEasing:`ease`,nameKey:`name`,blendStroke:!1,rootTabIndex:0}),Z(Q,`parseDeltaAngle`,function(e,t){return me(t-e)*Math.min(Math.abs(t-e),360)}),Z(Q,`getRealPieData`,function(e){var t=e.data,n=e.children,r=v(e,!1),i=se(n,S);return t&&t.length?t.map(function(e,t){return X(X(X({payload:e},r),e),i&&i[t]&&i[t].props)}):i&&i.length?i.map(function(e){return X(X({},r),e.props)}):[]}),Z(Q,`parseCoordinateOfPie`,function(e,t){var n=t.top,r=t.left,i=t.width,a=t.height,o=ge(i,a);return{cx:r+ue(e.cx,i,i/2),cy:n+ue(e.cy,a,a/2),innerRadius:ue(e.innerRadius,o,0),outerRadius:ue(e.outerRadius,o,o*.8),maxRadius:e.maxRadius||Math.sqrt(i*i+a*a)/2}}),Z(Q,`getComposedData`,function(e){var t=e.item,n=e.offset,r=t.type.defaultProps===void 0?t.props:X(X({},t.type.defaultProps),t.props),i=Ot.getRealPieData(r);if(!i||!i.length)return null;var a=r.cornerRadius,o=r.startAngle,s=r.endAngle,c=r.paddingAngle,l=r.dataKey,u=r.nameKey,d=r.valueKey,f=r.tooltipType,p=Math.abs(r.minAngle),m=Ot.parseCoordinateOfPie(r,n),h=Ot.parseDeltaAngle(o,s),g=Math.abs(h),_=l;(0,K.default)(l)&&(0,K.default)(d)?(ee(!1,`Use "dataKey" to specify the value of pie,
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{d as r,g as i,l as a,n as o}from"./stats-C_lfxZAw.js";import{t as s}from"./currency-CQsJu8iC.js";import{r as c,t as l}from"./source-icon-ajoaKb41.js";import{g as u}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as d}from"./router-provider-BmEZf6c6.js";import{b as f,f as p,l as m,x as h,y as g}from"./dist-Cb5RSHSg.js";import{E as _}from"./_baseAssignValue-C_vooEQc.js";import{$ as v,C as y,E as b,I as x,J as S,K as C,P as w,Q as T,S as E,Y as D,Z as ee,_ as te,a as ne,at as re,b as ie,ct as ae,dt as oe,et as se,g as ce,i as le,it as ue,n as de,nt as fe,ot as O,r as pe,st as me,ut as he,w as ge,x as _e,y as ve}from"./chart-BnXyfH11.js";import{n as ye,t as be}from"./PolarAngleAxis-C4qtHy1B.js";import{a as xe,c as Se,i as k,l as Ce,n as A,r as we,t as Te,u as Ee}from"./chart-helpers-DV0FkdcD.js";import{n as De,t as j}from"./sort-button-Df4t2AL8.js";import{i as Oe,r as ke,t as Ae}from"./tabs-D4y1gqUd.js";import{i as je,n as Me,o as Ne,s as Pe,t as Fe}from"./select-B0HteHrp.js";import{a as Ie,n as M,o as Le,r as Re,t as N}from"./card-aUHX0hyR.js";import{t as P}from"./empty-indicator-WB1WgT9h.js";import{a as F,c as I,i as ze,n as L,r as R,s as Be,t as Ve}from"./table-DFj1wiYv.js";import{Bn as He,Br as z,Fn as Ue,Hr as B,Hs as We,In as Ge,Ir as Ke,Jn as qe,Jr as Je,Ln as Ye,Mo as Xe,Qr as Ze,Rn as Qe,Wr as $e,Xr as et,i as tt,ii as nt,ir as rt,ls as it,nr as at,oa as ot,p as st,ss as ct,u as V,us as lt,zn as ut,zr as H}from"./index-08n05-rc.js";import{n as dt,r as U,t as ft}from"./kpi-tabs-BlcUttpn.js";import{a as pt}from"./tiers-DYsa4DCo.js";import{i as mt,n as ht,r as gt,t as _t}from"./stats-view-Cxot1iD8.js";import{t as vt}from"./disabled-sources-indicator-DYAXW-6V.js";import{t as yt}from"./use-growth-stats-aNXJOmQr.js";import{t as bt}from"./use-analytics-data-C76v4LIp.js";import{n as xt}from"./audience-CkBb2LlO.js";import{n as St}from"./referrers-pmJT4k3-.js";import{i as Ct,r as wt,t as W}from"./content-helpers-CNBPrwsi.js";import{t as Tt}from"./url-helpers-CCyfRrKj.js";var G=e(t()),Et=e(oe()),Dt=e(x()),K=e(he()),q=e(_()),Ot;function J(e){"@babel/helpers - typeof";return J=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},J(e)}function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(this,arguments)}function kt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?kt(Object(n),!0).forEach(function(t){Z(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function At(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function jt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,Bt(r.key),r)}}function Mt(e,t,n){return t&&jt(e.prototype,t),n&&jt(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Nt(e,t,n){return t=Lt(t),Pt(e,It()?Reflect.construct(t,n||[],Lt(e).constructor):t.apply(e,n))}function Pt(e,t){if(t&&(J(t)===`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return Ft(e)}function Ft(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function It(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(It=function(){return!!e})()}function Lt(e){return Lt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Lt(e)}function Rt(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&zt(e,t)}function zt(e,t){return zt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},zt(e,t)}function Z(e,t,n){return t=Bt(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Bt(e){var t=Vt(e,`string`);return J(t)==`symbol`?t:t+``}function Vt(e,t){if(J(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(J(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Q=function(e){function t(e){var n;return At(this,t),n=Nt(this,t,[e]),Z(n,`pieRef`,null),Z(n,`sectorRefs`,[]),Z(n,`id`,ae(`recharts-pie-`)),Z(n,`handleAnimationEnd`,function(){var e=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),(0,q.default)(e)&&e()}),Z(n,`handleAnimationStart`,function(){var e=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),(0,q.default)(e)&&e()}),n.state={isAnimationFinished:!e.isAnimationActive,prevIsAnimationActive:e.isAnimationActive,prevAnimationId:e.animationId,sectorToFocus:0},n}return Rt(t,e),Mt(t,[{key:`isActiveIndex`,value:function(e){var t=this.props.activeIndex;return Array.isArray(t)?t.indexOf(e)!==-1:e===t}},{key:`hasActiveIndex`,value:function(){var e=this.props.activeIndex;return Array.isArray(e)?e.length!==0:e||e===0}},{key:`renderLabels`,value:function(e){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var n=this.props,r=n.label,i=n.labelLine,a=n.dataKey,o=n.valueKey,s=v(this.props,!1),c=v(r,!1),l=v(i,!1),u=r&&r.offsetRadius||20,d=e.map(function(e,n){var d=(e.startAngle+e.endAngle)/2,f=b(e.cx,e.cy,e.outerRadius+u,d),p=X(X(X(X({},s),e),{},{stroke:`none`},c),{},{index:n,textAnchor:t.getTextAnchor(f.x,e.cx)},f),m=X(X(X(X({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:n,points:[b(e.cx,e.cy,e.outerRadius,d),f]}),h=a;return(0,K.default)(a)&&(0,K.default)(o)?h=`value`:(0,K.default)(a)&&(h=o),G.createElement(T,{key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${n}`},i&&t.renderLabelLineItem(i,m,`line`),t.renderLabelItem(r,p,w(e,h)))});return G.createElement(T,{className:`recharts-pie-labels`},d)}},{key:`renderSectorsStatically`,value:function(e){var t=this,n=this.props,r=n.activeShape,i=n.blendStroke,a=n.inactiveShape;return e.map(function(n,o){if(n?.startAngle===0&&n?.endAngle===0&&e.length!==1)return null;var s=t.isActiveIndex(o),c=a&&t.hasActiveIndex()?a:null,l=s?r:c,u=X(X({},n),{},{stroke:i?n.fill:n.stroke,tabIndex:-1});return G.createElement(T,Y({ref:function(e){e&&!t.sectorRefs.includes(e)&&t.sectorRefs.push(e)},tabIndex:-1,className:`recharts-pie-sector`},fe(t.props,n,o),{key:`sector-${n?.startAngle}-${n?.endAngle}-${n.midAngle}-${o}`}),G.createElement(te,Y({option:l,isActive:s,shapeType:`sector`},u)))})}},{key:`renderSectorsWithAnimation`,value:function(){var e=this,t=this.props,n=t.sectors,r=t.isAnimationActive,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.animationId,c=this.state,l=c.prevSectors,u=c.prevIsAnimationActive;return G.createElement(ve,{begin:i,duration:a,isActive:r,easing:o,from:{t:0},to:{t:1},key:`pie-${s}-${u}`,onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(t){var r=t.t,i=[],a=(n&&n[0]).startAngle;return n.forEach(function(e,t){var n=l&&l[t],o=t>0?(0,Et.default)(e,`paddingAngle`,0):0;if(n){var s=re(n.endAngle-n.startAngle,e.endAngle-e.startAngle),c=X(X({},e),{},{startAngle:a+o,endAngle:a+s(r)+o});i.push(c),a=c.endAngle}else{var u=e.endAngle,d=e.startAngle,f=re(0,u-d)(r),p=X(X({},e),{},{startAngle:a+o,endAngle:a+f+o});i.push(p),a=p.endAngle}}),G.createElement(T,null,e.renderSectorsStatically(i))})}},{key:`attachKeyboardHandlers`,value:function(e){var t=this;e.onkeydown=function(e){if(!e.altKey)switch(e.key){case`ArrowLeft`:var n=++t.state.sectorToFocus%t.sectorRefs.length;t.sectorRefs[n].focus(),t.setState({sectorToFocus:n});break;case`ArrowRight`:var r=--t.state.sectorToFocus<0?t.sectorRefs.length-1:t.state.sectorToFocus%t.sectorRefs.length;t.sectorRefs[r].focus(),t.setState({sectorToFocus:r});break;case`Escape`:t.sectorRefs[t.state.sectorToFocus].blur(),t.setState({sectorToFocus:0});break;default:}}}},{key:`renderSectors`,value:function(){var e=this.props,t=e.sectors,n=e.isAnimationActive,r=this.state.prevSectors;return n&&t&&t.length&&(!r||!(0,Dt.default)(r,t))?this.renderSectorsWithAnimation():this.renderSectorsStatically(t)}},{key:`componentDidMount`,value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:`render`,value:function(){var e=this,t=this.props,n=t.hide,r=t.sectors,i=t.className,a=t.label,o=t.cx,s=t.cy,c=t.innerRadius,l=t.outerRadius,u=t.isAnimationActive,d=this.state.isAnimationFinished;if(n||!r||!r.length||!O(o)||!O(s)||!O(c)||!O(l))return null;var f=h(`recharts-pie`,i);return G.createElement(T,{tabIndex:this.props.rootTabIndex,className:f,ref:function(t){e.pieRef=t}},this.renderSectors(),a&&this.renderLabels(r),E.renderCallByParent(this.props,null,!1),(!u||d)&&_e.renderCallByParent(this.props,r,!1))}}],[{key:`getDerivedStateFromProps`,value:function(e,t){return t.prevIsAnimationActive===e.isAnimationActive?e.isAnimationActive&&e.animationId!==t.prevAnimationId?{prevAnimationId:e.animationId,curSectors:e.sectors,prevSectors:t.curSectors,isAnimationFinished:!0}:e.sectors===t.curSectors?null:{curSectors:e.sectors,isAnimationFinished:!0}:{prevIsAnimationActive:e.isAnimationActive,prevAnimationId:e.animationId,curSectors:e.sectors,prevSectors:[],isAnimationFinished:!0}}},{key:`getTextAnchor`,value:function(e,t){return e>t?`start`:e<t?`end`:`middle`}},{key:`renderLabelLineItem`,value:function(e,t,n){if(G.isValidElement(e))return G.cloneElement(e,t);if((0,q.default)(e))return e(t);var r=h(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className);return G.createElement(ie,Y({},t,{key:n,type:`linear`,className:r}))}},{key:`renderLabelItem`,value:function(e,t,n){if(G.isValidElement(e))return G.cloneElement(e,t);var r=n;if((0,q.default)(e)&&(r=e(t),G.isValidElement(r)))return r;var i=h(`recharts-pie-label-text`,typeof e!=`boolean`&&!(0,q.default)(e)?e.className:``);return G.createElement(C,Y({},t,{alignmentBaseline:`middle`,className:i}),r)}}])}(G.PureComponent);Ot=Q,Z(Q,`displayName`,`Pie`),Z(Q,`defaultProps`,{stroke:`#fff`,fill:`#808080`,legendType:`rect`,cx:`50%`,cy:`50%`,startAngle:0,endAngle:360,innerRadius:0,outerRadius:`80%`,paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!D.isSsr,animationBegin:400,animationDuration:1500,animationEasing:`ease`,nameKey:`name`,blendStroke:!1,rootTabIndex:0}),Z(Q,`parseDeltaAngle`,function(e,t){return me(t-e)*Math.min(Math.abs(t-e),360)}),Z(Q,`getRealPieData`,function(e){var t=e.data,n=e.children,r=v(e,!1),i=se(n,S);return t&&t.length?t.map(function(e,t){return X(X(X({payload:e},r),e),i&&i[t]&&i[t].props)}):i&&i.length?i.map(function(e){return X(X({},r),e.props)}):[]}),Z(Q,`parseCoordinateOfPie`,function(e,t){var n=t.top,r=t.left,i=t.width,a=t.height,o=ge(i,a);return{cx:r+ue(e.cx,i,i/2),cy:n+ue(e.cy,a,a/2),innerRadius:ue(e.innerRadius,o,0),outerRadius:ue(e.outerRadius,o,o*.8),maxRadius:e.maxRadius||Math.sqrt(i*i+a*a)/2}}),Z(Q,`getComposedData`,function(e){var t=e.item,n=e.offset,r=t.type.defaultProps===void 0?t.props:X(X({},t.type.defaultProps),t.props),i=Ot.getRealPieData(r);if(!i||!i.length)return null;var a=r.cornerRadius,o=r.startAngle,s=r.endAngle,c=r.paddingAngle,l=r.dataKey,u=r.nameKey,d=r.valueKey,f=r.tooltipType,p=Math.abs(r.minAngle),m=Ot.parseCoordinateOfPie(r,n),h=Ot.parseDeltaAngle(o,s),g=Math.abs(h),_=l;(0,K.default)(l)&&(0,K.default)(d)?(ee(!1,`Use "dataKey" to specify the value of pie,
|
|
2
2
|
the props "valueKey" will be deprecated in 1.1.0`),_=`value`):(0,K.default)(l)&&(ee(!1,`Use "dataKey" to specify the value of pie,
|
|
3
|
-
the props "valueKey" will be deprecated in 1.1.0`),_=d);var v=i.filter(function(e){return w(e,_,0)!==0}).length,y=(g>=360?v:v-1)*c,x=g-v*p-y,S=i.reduce(function(e,t){var n=w(t,_,0);return e+(O(n)?n:0)},0),C;if(S>0){var T;C=i.map(function(e,t){var n=w(e,_,0),r=w(e,u,t),i=(O(n)?n:0)/S,s=t?T.endAngle+me(h)*c*(n===0?0:1):o,l=s+me(h)*((n===0?0:p)+i*x),d=(s+l)/2,g=(m.innerRadius+m.outerRadius)/2;return T=X(X(X({percent:i,cornerRadius:a,name:r,tooltipPayload:[{name:r,value:n,payload:e,dataKey:_,type:f}],midAngle:d,middleRadius:g,tooltipPosition:b(m.cx,m.cy,g,d)},e),m),{},{value:w(e,_),startAngle:s,endAngle:l,payload:e,paddingAngle:me(h)*c}),T})}return X(X({},m),{},{sectors:C,data:i})});var Ht=ne({chartName:`PieChart`,GraphicalChild:Q,validateTooltipEventTypes:[`item`],defaultTooltipEventType:`item`,legendContent:`children`,axisComponents:[{axisType:`angleAxis`,AxisComp:be},{axisType:`radiusAxis`,AxisComp:ye}],formatAxisMap:y,defaultProps:{layout:`centric`,startAngle:0,endAngle:360,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`}}),$=n(),Ut=e=>e===`total-members`||e===`free-members`||e===`paid-members`||e===`mrr`,Wt=({active:e,payload:t,range:n,color:r,showBreakdown:i})=>{if(!e||!t?.length)return null;let a=t[0].payload,{date:o,formattedValue:s,label:c,comped:l,gift:u}=a,d=a.value-(l||0)-(u||0);return(0,$.jsxs)(`div`,{className:`min-w-[200px] rounded-lg border bg-background px-3 py-2 shadow-lg`,children:[o&&(0,$.jsx)(`div`,{className:`mb-1 text-sm text-foreground`,children:z(o,n||0)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Paid subscriptions`}),(0,$.jsx)(`div`,{className:`font-mono text-xs`,children:p(d)})]})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Gift subscriptions`}),(0,$.jsx)(`div`,{className:`font-mono text-xs`,children:u!==void 0&&u>0?p(u):`0`})]})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Complimentary`}),(0,$.jsx)(`div`,{className:`font-mono text-xs`,children:l!==void 0&&l>0?p(l):`0`})]})}),(0,$.jsx)(Ke,{})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`inline-block size-2 rounded-full opacity-50`,style:{backgroundColor:r||`var(--chart-purple)`}}),(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[c&&(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:c}),(0,$.jsx)(`div`,{className:`font-mono font-medium`,children:s})]})]})]})]})},Gt=({chartData:e,totals:t,initialTab:n,currencySymbol:r,isLoading:i,onTabChange:a})=>{let o=Ut(n)?n:`total-members`,[s,c]=(0,G.useState)(o),{range:l}=lt(),{appSettings:f}=Ze(),m=d(),[h]=u();(0,G.useEffect)(()=>{c(o)},[o]);let g=e=>{c(e);let t=new URLSearchParams(h);t.set(`tab`,e),m(`?${t.toString()}`,{replace:!0}),a&&a(e)},{totalMembers:_,freeMembers:v,paidMembers:y,mrr:b,percentChanges:x,directions:S}=t,{chartData:C,chartRange:w}=(0,G.useMemo)(()=>{if(!e||e.length===0)return{chartData:[],chartRange:l};let t=[],n=`value`;switch(s){case`free-members`:n=`free`;break;case`paid-members`:n=`paid`;break;case`mrr`:n=`mrr`;break;default:n=`value`}t=k(e,l,n,`exact`);let i=[];switch(s){case`free-members`:i=t.map(e=>({...e,value:e.free,formattedValue:p(e.free),label:`Free members`}));break;case`paid-members`:i=t.map(e=>({...e,value:e.paid,formattedValue:p(e.paid),label:`Paid members`,comped:e.comped,gift:e.gift,paid_subscribed:e.paid_subscribed}));break;case`mrr`:i=t.map(e=>({...e,value:H(e.mrr),formattedValue:`${r}${p(H(e.mrr))}`,label:`MRR`}));break;default:i=t.map(e=>{let t=e.free+e.paid;return{...e,value:t,formattedValue:p(t),label:`Total members`}})}return{chartData:i,chartRange:Te(l,e,{fieldName:n})}},[s,e,l,r]),T={"total-members":{color:`var(--chart-darkblue)`},"free-members":{color:`var(--chart-blue)`},"paid-members":{color:`var(--chart-purple)`},mrr:{color:`var(--chart-teal)`}};return i?(0,$.jsx)(`div`,{className:`-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center`,children:(0,$.jsx)(st,{})}):(0,$.jsxs)(Ae,{defaultValue:o,variant:`kpis`,children:[(0,$.jsxs)(ke,{className:`-mx-6 ${f?.paidMembersEnabled?`hidden grid-cols-4 lg:visible! lg:grid!`:`grid grid-cols-4`}`,children:[(0,$.jsx)(dt,{className:f?.paidMembersEnabled?``:`cursor-auto after:hidden`,value:`total-members`,onClick:()=>{f?.paidMembersEnabled&&g(`total-members`)},children:(0,$.jsx)(U,{color:`var(--chart-darkblue)`,diffDirection:l===V.allTime.value?`hidden`:S.total,diffValue:x.total,label:`Total members`,value:p(_)})}),f?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dt,{value:`free-members`,onClick:()=>{g(`free-members`)},children:(0,$.jsx)(U,{color:`var(--chart-blue)`,diffDirection:l===V.allTime.value?`hidden`:S.free,diffValue:x.free,label:`Free members`,value:p(v)})}),(0,$.jsx)(dt,{value:`paid-members`,onClick:()=>{g(`paid-members`)},children:(0,$.jsx)(U,{color:`var(--chart-purple)`,diffDirection:l===V.allTime.value?`hidden`:S.paid,diffValue:x.paid,label:`Paid members`,value:p(y)})}),(0,$.jsx)(dt,{value:`mrr`,onClick:()=>{g(`mrr`)},children:(0,$.jsx)(U,{color:`var(--chart-teal)`,diffDirection:l===V.allTime.value?`hidden`:S.mrr,diffValue:x.mrr,label:`MRR`,value:`${r}${p(H(b))}`})})]})]}),f?.paidMembersEnabled&&(0,$.jsxs)(qe,{children:[(0,$.jsx)(rt,{className:`lg:hidden`,asChild:!0,children:(0,$.jsxs)(ft,{children:[s===`total-members`&&(0,$.jsx)(U,{color:`var(--chart-darkblue)`,diffDirection:l===V.allTime.value?`hidden`:S.total,diffValue:x.total,label:`Total members`,value:p(_)}),s===`free-members`&&(0,$.jsx)(U,{color:`var(--chart-blue)`,diffDirection:l===V.allTime.value?`hidden`:S.free,diffValue:x.free,label:`Free members`,value:p(v)}),s===`paid-members`&&(0,$.jsx)(U,{color:`var(--chart-purple)`,diffDirection:l===V.allTime.value?`hidden`:S.paid,diffValue:x.paid,label:`Paid members`,value:p(y)}),s===`mrr`&&(0,$.jsx)(U,{color:`var(--chart-teal)`,diffDirection:l===V.allTime.value?`hidden`:S.mrr,diffValue:x.mrr,label:`MRR`,value:`${r}${p(H(b))}`})]})}),(0,$.jsxs)($e,{align:`end`,className:`w-56`,children:[(0,$.jsx)(Ye,{onClick:()=>g(`total-members`),children:`Total members`}),(0,$.jsx)(Ye,{onClick:()=>g(`free-members`),children:`Free members`}),(0,$.jsx)(Ye,{onClick:()=>g(`paid-members`),children:`Paid members`}),(0,$.jsx)(Ye,{onClick:()=>g(`mrr`),children:`MRR`})]})]}),(0,$.jsx)(`div`,{className:`my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:(0,$.jsx)(xe,{className:`-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]`,color:T[s].color,data:C,dataFormatter:s===`mrr`?e=>`${r}${p(e)}`:p,id:s,range:w,tooltipContent:s===`paid-members`?(0,$.jsx)(Wt,{color:T[`paid-members`].color,range:w,showBreakdown:!0}):void 0})})]})},Kt=(e,t=`signups desc`,n=50)=>{let{startDate:r,endDate:i,timezone:a}=Qe(e),o={date_from:B(r),date_to:B(i),member_status:xt(nt),order:t,limit:n.toString()};return a&&(o.timezone=a),St({searchParams:o})},qt=({data:e,currencySymbol:t,limit:n,defaultSourceIconUrl:r})=>{let i=n?e.slice(0,n):e,{appSettings:a}=Ze();return(0,$.jsx)(L,{children:i.map(e=>(0,$.jsxs)(I,{className:`last:border-none`,children:[(0,$.jsx)(R,{className:`font-medium`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(l,{defaultSourceIconUrl:r,displayName:e.displayName,iconSrc:e.iconSrc}),e.linkUrl?(0,$.jsx)(`a`,{className:`hover:underline`,href:e.linkUrl,rel:`noreferrer`,target:`_blank`,children:e.displayName}):(0,$.jsx)(`span`,{children:e.displayName})]})}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[`+`,p(e.free_members)]}),a?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[`+`,p(e.paid_members)]}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[`+`,t,p(H(e.mrr))]})]})]},e.source))})},Jt=({range:e,limit:t=20,showViewAll:n=!1,sortBy:r,setSortBy:i})=>{let{site:a}=bt(),{data:l}=o(),{appSettings:u}=Ze(),[d,f]=(0,G.useState)(`free_members desc`),p=r||d,m=i||f,{data:h,isLoading:g}=Kt(e,p.replace(`free_members`,`signups`).replace(`paid_members`,`paid_conversions`),t),_=a.url,v=`https://www.google.com/s2/favicons?domain=ghost.org&sz=64`,y=G.useMemo(()=>{if(l?.stats&&l?.meta?.totals){let e=l.meta.totals,t=e[0];if(!t)return s(`usd`);for(let n of e)n.mrr>t.mrr&&(t=n);return s(t.currency)}return s(`usd`)},[l]),b=G.useMemo(()=>h?.stats?h.stats.map(e=>{let t=e.source||`Direct`,{domain:n}=c(t,_),r=n?`https://www.faviconextractor.com/favicon/${n}?larger=true`:v,i=n&&t!==`Direct`?`https://${n}`:void 0;return{source:t,free_members:e.signups,paid_members:e.paid_conversions,mrr:e.mrr,iconSrc:r,displayName:t,linkUrl:i}}):[],[h,_]),x=`Where did your growth come from ${A(e)}`;return u?.analytics.membersTrackSources?g?(0,$.jsx)(L,{children:(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-2`,colSpan:1,children:(0,$.jsx)(it,{containerClassName:`space-y-2`,count:5,maxWidth:75,randomize:!0})})})}):(0,$.jsxs)($.Fragment,{children:[b.length>0?(0,$.jsx)(qt,{currencySymbol:y,data:b,defaultSourceIconUrl:v,limit:t}):(0,$.jsx)(L,{children:(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-12 group-hover:bg-transparent!`,colSpan:u?.paidMembersEnabled?4:2,children:(0,$.jsx)(P,{description:`Try adjusting your date range to see more data.`,title:`No conversions ${A(e)}`,children:(0,$.jsx)(at,{strokeWidth:1.5})})})})}),n&&b.length>t&&(0,$.jsx)(ze,{className:`border-none bg-transparent hover:bg-transparent!`,children:(0,$.jsx)(I,{children:(0,$.jsx)(R,{className:`border-none bg-transparent px-0 pb-0 hover:bg-transparent!`,colSpan:4,children:(0,$.jsxs)(Ue,{children:[(0,$.jsx)(He,{asChild:!0,children:(0,$.jsxs)(Ge,{variant:`outline`,children:[`View all `,(0,$.jsx)(et,{})]})}),(0,$.jsxs)(We,{className:`overflow-y-auto pt-0 sm:max-w-[420px]`,children:[(0,$.jsxs)(Xe,{className:`sticky top-0 z-40 -mx-6 bg-surface-elevated/60 p-6 backdrop-blur`,children:[(0,$.jsx)(ut,{children:`Top sources`}),(0,$.jsx)(Je,{children:x})]}),(0,$.jsx)(`div`,{className:`group/datalist`,children:(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:(0,$.jsxs)(I,{children:[(0,$.jsx)(F,{children:`Source`}),(0,$.jsx)(F,{className:`w-[110px] text-right`,children:(0,$.jsx)(j,{activeSortBy:p,setSortBy:m,sortBy:`free_members desc`,children:`Free members`})}),u?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{className:`w-[110px] text-right`,children:(0,$.jsx)(j,{activeSortBy:p,setSortBy:m,sortBy:`paid_members desc`,children:`Paid members`})}),(0,$.jsx)(F,{className:`w-[110px] text-right`,children:(0,$.jsx)(j,{activeSortBy:p,setSortBy:m,sortBy:`mrr desc`,children:`MRR impact`})})]})]})}),(0,$.jsx)(qt,{currencySymbol:y,data:b,defaultSourceIconUrl:v})]})})]})]})})})})]}):(0,$.jsx)(L,{children:(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-12 group-hover:bg-transparent!`,colSpan:u?.paidMembersEnabled?4:2,children:(0,$.jsx)(vt,{})})})})};f();var Yt=({active:e,payload:t})=>{if(e&&t&&t.length){let e=t[0];return(0,$.jsx)(`div`,{className:`rounded-lg border bg-background p-2 shadow-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:e.payload.color}}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`font-mono`,children:p(e.value)})]})})}return null},Xt=({isLoading:e,range:t})=>{let{data:n}=a(),{data:{tiers:r=[]}={}}=pt(),[i,o]=(0,G.useState)(`billing-period`),{startDate:s,endDate:c}=(0,G.useMemo)(()=>Qe(t),[t]),l=(0,G.useMemo)(()=>B(s),[s]),u=(0,G.useMemo)(()=>B(c),[c]),d=(0,G.useMemo)(()=>r.filter(e=>e.type===`paid`&&e.active).map(e=>({id:e.id,name:e.name})),[r]),f=(0,G.useMemo)(()=>{if(!n?.stats)return[];let e=g(l),t=g(u),r=n.stats.filter(n=>{let r=g(n.date);return r.isSameOrAfter(e)&&r.isSameOrBefore(t)}).reduce((e,t)=>{let n=t.cadence;return e[n]||(e[n]=0),e[n]+=t.signups,e},{});return Object.entries(r).map(([e,t],n)=>{let r=e,i=`url(#gradientPurple)`,a=`var(--chart-purple)`;return e===`month`?(r=`Monthly`,i=`url(#gradientPurple)`,a=`var(--chart-purple)`):e===`year`&&(r=`Annual`,i=`url(#gradientTeal)`,a=`var(--chart-teal)`),{id:`cadence-${n}`,name:r,count:t,fill:i,color:a}})},[n,l,u]),m=(0,G.useMemo)(()=>{if(!n?.stats||d.length===0)return[];let e=g(l),t=g(u),r=n.stats.filter(n=>{let r=g(n.date);return r.isSameOrAfter(e)&&r.isSameOrBefore(t)}).reduce((e,t)=>{let n=t.tier;return e[n]||(e[n]=0),e[n]+=t.signups,e},{}),i=[{gradient:`url(#gradientPurple)`,solid:`var(--chart-purple)`},{gradient:`url(#gradientTeal)`,solid:`var(--chart-teal)`},{gradient:`url(#gradientBlue)`,solid:`var(--chart-blue)`},{gradient:`url(#gradientRose)`,solid:`var(--chart-rose)`},{gradient:`url(#gradientOrange)`,solid:`var(--chart-orange)`},{gradient:`url(#gradientGreen)`,solid:`var(--chart-green)`},{gradient:`url(#gradientAmber)`,solid:`var(--chart-amber)`},{gradient:`url(#gradientYellow)`,solid:`var(--chart-yellow)`},{gradient:`url(#gradientDarkblue)`,solid:`var(--chart-darkblue)`},{gradient:`url(#gradientGray)`,solid:`var(--chart-darkgray)`}];return[...d.map(e=>{let t=r[e.id]||0;return{id:e.id,name:e.name,count:t}})].sort((e,t)=>t.count-e.count).map((e,t)=>{let n=t%i.length;return{...e,fill:i[n].gradient,color:i[n].solid}})},[n,d,l,u]),h=i===`billing-period`?f:m,_=(0,G.useMemo)(()=>h.reduce((e,t)=>e+t.count,0),[h]),v=(0,G.useMemo)(()=>{let e={count:{label:`Subscriptions`}};return h.forEach(t=>{e[t.id]={label:t.name,color:t.color}}),e},[h]),y=(0,G.useMemo)(()=>_===0?[]:h.map(e=>({label:e.name,count:e.count,percentage:e.count/_*100,color:e.color})),[h,_]);if(e||!n?.stats)return null;let b=h.length>0&&_>0;return(0,$.jsxs)(N,{children:[(0,$.jsx)(Ie,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Le,{children:`Paid subscription breakdown`}),(0,$.jsxs)(Re,{children:[`New paid subscriptions `,A(t)]})]}),d.length>1&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(Fe,{value:i,onValueChange:e=>o(e),children:[(0,$.jsx)(Ne,{className:`w-full`,children:(0,$.jsx)(Pe,{})}),(0,$.jsxs)(Me,{align:`end`,children:[(0,$.jsx)(je,{value:`billing-period`,children:`Billing period`}),(0,$.jsx)(je,{value:`tiers`,children:`Tiers`})]})]})})]})}),(0,$.jsx)(M,{children:b?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(de,{className:`mx-auto aspect-square h-[250px] min-h-[250px] w-full`,config:v,children:(0,$.jsxs)(Ht,{children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsxs)(`linearGradient`,{id:`gradientPurple`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-purple)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-purple)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientTeal`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-teal)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-teal)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientRose`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-rose)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-rose)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientBlue`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-blue)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-blue)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientOrange`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-orange)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-orange)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientGreen`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-green)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-green)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientAmber`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-amber)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-amber)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientYellow`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-yellow)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-yellow)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientDarkblue`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-darkblue)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-darkblue)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientGray`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-darkgray)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-darkgray)`,stopOpacity:.6})]})]}),(0,$.jsx)(pe,{content:(0,$.jsx)(Yt,{}),cursor:!1}),(0,$.jsx)(Q,{animationBegin:0,animationDuration:1e3,data:h,dataKey:`count`,innerRadius:70,nameKey:`name`,stroke:`var(--card)`,strokeWidth:5,children:(0,$.jsx)(E,{content:({viewBox:e})=>{if(e&&`cx`in e&&`cy`in e)return(0,$.jsxs)(`text`,{dominantBaseline:`middle`,textAnchor:`middle`,x:e.cx,y:e.cy,children:[(0,$.jsx)(`tspan`,{className:`fill-foreground text-2xl font-semibold tracking-tight`,x:e.cx,y:e.cy,children:p(_)}),(0,$.jsx)(`tspan`,{className:`fill-muted-foreground`,x:e.cx,y:(e.cy||0)+20,children:`Total`})]})}})})]})}),y.length>0&&(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center justify-center gap-x-6 gap-y-1 text-sm text-muted-foreground`,children:y.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:e.color}}),(0,$.jsx)(`span`,{className:`max-w-[150px] truncate whitespace-nowrap`,title:e.label,children:e.label}),(0,$.jsxs)(`span`,{className:`font-medium text-foreground`,children:[Math.round(Number(e.percentage)||0),`%`]})]},e.label))})]}):(0,$.jsx)(`div`,{className:`py-12`,children:(0,$.jsx)(P,{description:`No new paid subscriptions ${A(t)}.`,title:`No new subscribers`,children:(0,$.jsx)(ct,{strokeWidth:1.5})})})})]})};f();var Zt=(e,t,n)=>{if(t===1){let t=g().format(`YYYY-MM-DD`),n=e.find(e=>e.date===t);return[{date:t,signups:n?.signups||0,cancellations:n?.cancellations||0}]}let{startDate:r,endDate:i}=Qe(t),a=g(r).format(`YYYY-MM-DD`),o=new Map(e.map(e=>[e.date,e])),s=[],c=new Set;if(n===`monthly`){let e=g(r).startOf(`month`),t=g(i).startOf(`month`);for(;e.isSameOrBefore(t);){let t=e.format(`YYYY-MM-DD`),n=t<a?a:t;if(!c.has(n)){c.add(n);let e=o.get(n);e?s.push(e):s.push({date:n,signups:0,cancellations:0})}e.add(1,`month`)}}else if(n===`weekly`){let e=g(r).startOf(`week`),t=g(i).startOf(`week`);for(;e.isSameOrBefore(t);){let t=e.format(`YYYY-MM-DD`),n=t<a?a:t;if(!c.has(n)){c.add(n);let e=o.get(n);e?s.push(e):s.push({date:n,signups:0,cancellations:0})}e.add(1,`week`)}}else{let e=g(r),t=g(i);for(;e.isSameOrBefore(t);){let t=e.format(`YYYY-MM-DD`),n=o.get(t);n?s.push(n):s.push({date:t,signups:0,cancellations:0}),e.add(1,`day`)}}return s},Qt=e=>{let t=we(e);return t<30?[`daily`]:t>=91?[`weekly`,`monthly`]:[`daily`,`weekly`]},$t=e=>{let t=we(e);return t<30?`daily`:t>=91?`monthly`:`weekly`},en=({subscriptionData:e,memberData:t,range:n,isLoading:r})=>{let[i,a]=(0,G.useState)(()=>$t(n));(0,G.useEffect)(()=>{a($t(n))},[n]);let o=(0,G.useMemo)(()=>Qt(n),[n]),s=(0,G.useMemo)(()=>{switch(i){case`daily`:return`none`;case`weekly`:return`weekly`;case`monthly`:return`monthly`}},[i]),c=(0,G.useMemo)(()=>Te(n,[],{overrideStrategy:s}),[n,s]),l=(0,G.useMemo)(()=>{if(e&&e.length>0){if(n===1){let t=g().format(`YYYY-MM-DD`),r=e.find(e=>e.date===t);return[{date:z(t,n),rawDate:t,new:r?.signups||0,cancelled:-(r?.cancellations||0)}]}let t=k(e,n,`signups`,`sum`,s),r=k(e,n,`cancellations`,`sum`,s),i=new Map(r.map(e=>[e.date,e])),a=t.map(e=>({date:e.date,signups:e.signups||0,cancellations:i.get(e.date)?.cancellations||0})),o=new Set(a.map(e=>e.date));return r.forEach(e=>{o.has(e.date)||a.push({date:e.date,signups:0,cancellations:e.cancellations||0})}),a.sort((e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime()),Zt(a,n,s).map(e=>({date:z(e.date,c),rawDate:e.date,new:e.signups||0,cancelled:-(e.cancellations||0)}))}else{if(!t||t.length===0)return[];if(n===1){let e=g().format(`YYYY-MM-DD`),r=t.find(t=>t.date===e);return[{date:z(e,n),rawDate:e,new:r?.paid_subscribed||0,cancelled:-(r?.paid_canceled||0)}]}let e=k(t,n,`paid_subscribed`,`sum`,s),r=k(t,n,`paid_canceled`,`sum`,s),i=new Map(r.map(e=>[e.date,e])),a=e.map(e=>({date:e.date,paid_subscribed:e.paid_subscribed||0,paid_canceled:i.get(e.date)?.paid_canceled||0})),o=new Set(a.map(e=>e.date));return r.forEach(e=>{o.has(e.date)||a.push({date:e.date,paid_subscribed:0,paid_canceled:e.paid_canceled||0})}),a.sort((e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime()),a.map(e=>({date:z(e.date,c),rawDate:e.date,new:e.paid_subscribed||0,cancelled:-(e.paid_canceled||0)}))}},[t,e,n,s,c]),u={new:{label:`New`,color:`var(--chart-teal)`},cancelled:{label:`Cancelled`,color:`var(--chart-rose)`}},d=(0,G.useMemo)(()=>({new:l.reduce((e,t)=>e+t.new,0),cancelled:l.reduce((e,t)=>e+Math.abs(t.cancelled),0)}),[l]);if(r)return null;let f=l.length>0&&(d.new>0||d.cancelled>0),m=e=>e.charAt(0).toUpperCase()+e.slice(1);return(0,$.jsxs)(N,{"data-testid":`paid-members-change-card`,children:[(0,$.jsx)(Ie,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Le,{children:`Paid subscriptions`}),(0,$.jsxs)(Re,{children:[`New and cancelled paid subscriptions `,A(n)]})]}),o.length>1&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(Fe,{value:i,onValueChange:e=>a(e),children:[(0,$.jsx)(Ne,{className:`w-[110px]`,children:(0,$.jsx)(Pe,{})}),(0,$.jsx)(Me,{align:`end`,children:o.map(e=>(0,$.jsx)(je,{value:e,children:m(e)},e))})]})})]})}),(0,$.jsx)(M,{children:f?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(de,{className:`aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]`,config:u,children:(0,$.jsxs)(De,{data:l,stackOffset:`sign`,children:[(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`tealGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-new)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-new)`,stopOpacity:.6})]})}),(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`roseGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-cancelled)`,stopOpacity:.6}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-cancelled)`,stopOpacity:.8})]})}),(0,$.jsx)(Ee,{stroke:`var(--border)`,vertical:!1}),(0,$.jsx)(Ce,{axisLine:!1,dataKey:`date`,tickFormatter:()=>``,tickLine:!1,tickMargin:10}),(0,$.jsx)(Se,{axisLine:!1,tickFormatter:e=>p(e<0?e*-1:e),tickLine:!1}),(0,$.jsx)(pe,{content:(0,$.jsx)(le,{className:`min-w-[120px]! px-3 py-2`,formatter:(e,t,n,r)=>{let i=Number(e),a=`0`;a=i===0?`0`:p(i<0?i*-1:i);let o=n?.payload,s=Number(o?.new||0)+Number(o?.cancelled||0),l=s===0?`0`:s>0?`+${p(s)}`:p(s),d=o?.date,f=o?.rawDate;return f&&(d=z(f,c)),(0,$.jsxs)(`div`,{className:`flex w-full flex-col`,children:[r===0&&(0,$.jsx)(`div`,{className:`mb-1 text-sm font-medium text-foreground`,children:d}),(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`div`,{className:`size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50`,style:{"--color-bg":`var(--color-${t})`}}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:u[t]?.label||t})]}),(0,$.jsx)(`div`,{className:`ml-auto flex items-baseline gap-0.5 font-mono font-medium text-foreground tabular-nums`,children:a})]}),r===1&&(0,$.jsxs)(`div`,{className:`mt-1 flex w-full items-center justify-between gap-4 border-t pt-1`,children:[(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Net change`}),(0,$.jsx)(`div`,{className:`ml-auto flex items-baseline gap-0.5 font-mono font-medium text-foreground tabular-nums`,children:l})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),(0,$.jsx)(ce,{activeBar:{fillOpacity:1},dataKey:`new`,fill:`url(#tealGradient)`,fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:`a`}),(0,$.jsx)(ce,{activeBar:{fillOpacity:1},dataKey:`cancelled`,fill:`url(#roseGradient)`,fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:`a`})]})}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-center gap-6 text-sm text-muted-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:u.new.color}}),(0,$.jsx)(`span`,{children:`New`}),(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:p(d.new)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:u.cancelled.color}}),(0,$.jsx)(`span`,{children:`Cancelled`}),(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:p(d.cancelled)})]})]})]}):(0,$.jsx)(`div`,{className:`py-12`,children:(0,$.jsx)(P,{description:`No paid subscription changes ${A(n)}.`,title:`No paid member changes`,children:(0,$.jsx)(tt,{strokeWidth:1.5})})})})]})},tn=(e,t,n)=>{let i=e??30,a=t??`mrr desc`,{startDate:o,endDate:s}=(0,G.useMemo)(()=>Qe(i),[i]),c=(0,G.useMemo)(()=>{let e={date_from:B(o),date_to:B(s),order:a};return n===`posts`?e.post_type=`post`:n===`pages`&&(e.post_type=`page`),e},[o,s,a,n]);return r({searchParams:Object.fromEntries(Object.entries(c).filter(([,e])=>e!==void 0))})},nn=()=>{let{range:e}=lt(),{site:t,settings:n}=bt(),r=String(n.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),a=d(),[o,s]=(0,G.useState)(`free_members desc`),[c,l]=(0,G.useState)(W.POSTS_AND_PAGES),[f]=u(),{appSettings:h}=Ze(),g=f.get(`tab`)||`total-members`,[_,v]=(0,G.useState)(g);(0,G.useEffect)(()=>{g!==_&&v(g)},[g]);let{isLoading:y,chartData:b,totals:x,currencySymbol:S,subscriptionData:C}=yt(e),{data:w,isLoading:T}=tn(e,o,c),E=(0,G.useMemo)(()=>{let e=(w?.stats||[]).reduce((e,t)=>{let n=t.post_id||(t.title&&t.title.trim()!==``?t.title:t.attribution_url);if(!n)return e;if(!e.has(n))e.set(n,t);else{let r=e.get(n);r.free_members+=t.free_members,r.paid_members+=t.paid_members,r.mrr+=t.mrr,e.set(n,r)}return e},new Map),t=Array.from(e.values()),n=t.reduce((e,t)=>e+t.free_members,0),r=t.reduce((e,t)=>e+t.paid_members,0),i=t.reduce((e,t)=>e+t.mrr,0);return t.map(e=>{let t=0;return o.includes(`free_members`)&&n>0?t=e.free_members/n:o.includes(`paid_members`)&&r>0?t=e.paid_members/r:o.includes(`mrr`)&&i>0&&(t=e.mrr/i),{title:e.title||e.attribution_url,post_id:e.post_id,attribution_url:e.attribution_url,attribution_type:e.attribution_type,attribution_id:e.attribution_id,free_members:e.free_members,paid_members:e.paid_members,mrr:e.mrr,percentage:t,published_at:e.published_at,url_exists:e.url_exists??!0}})},[w,o]),D=y,ee=y||T;return(0,$.jsxs)(ht,{children:[(0,$.jsx)(gt,{children:(0,$.jsx)(i,{children:(0,$.jsx)(mt,{})})}),(0,$.jsxs)(_t,{data:D?void 0:b,isLoading:!1,loadingComponent:(0,$.jsx)($.Fragment,{}),children:[(0,$.jsx)(N,{"data-testid":`total-members-card`,children:(0,$.jsx)(M,{children:(0,$.jsx)(Gt,{chartData:b,currencySymbol:S,initialTab:g,isLoading:D,totals:x,onTabChange:v})})}),h?.paidMembersEnabled&&_===`paid-members`&&(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-[2fr_minmax(460px,1fr)]`,children:[(0,$.jsx)(en,{isLoading:D,memberData:b,range:e,subscriptionData:C}),(0,$.jsx)(Xt,{isLoading:D,range:e})]}),(0,$.jsxs)(N,{className:`w-full overflow-x-auto`,"data-testid":`top-content-card`,children:[(0,$.jsxs)(Ie,{children:[(0,$.jsx)(Le,{children:wt(c)}),(0,$.jsx)(Re,{children:Ct(c,e,A)})]}),(0,$.jsx)(M,{children:(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:(0,$.jsxs)(I,{className:`[&>th]:h-auto [&>th]:pt-0 [&>th]:pb-2`,children:[(0,$.jsx)(F,{className:`min-w-[320px] pl-0`,children:(0,$.jsx)(Ae,{defaultValue:c,variant:`button-sm`,onValueChange:e=>{l(e)},children:(0,$.jsxs)(ke,{children:[(0,$.jsx)(Oe,{value:W.POSTS_AND_PAGES,children:`Posts & pages`}),(0,$.jsx)(Oe,{value:W.POSTS,children:`Posts`}),(0,$.jsx)(Oe,{value:W.PAGES,children:`Pages`}),(0,$.jsx)(Oe,{value:W.SOURCES,children:`Sources`})]})})}),(0,$.jsx)(F,{className:`w-[140px] text-right`,children:h?.paidMembersEnabled?(0,$.jsx)(j,{activeSortBy:o,setSortBy:s,sortBy:`free_members desc`,children:`Free members`}):(0,$.jsx)($.Fragment,{children:`Free members`})}),h?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{className:`w-[140px] text-right`,children:(0,$.jsx)(j,{activeSortBy:o,setSortBy:s,sortBy:`paid_members desc`,children:`Paid members`})}),(0,$.jsx)(F,{className:`w-[140px] text-right`,children:(0,$.jsx)(j,{activeSortBy:o,setSortBy:s,sortBy:`mrr desc`,children:`MRR impact`})})]})]})}),c===W.SOURCES?(0,$.jsx)(Jt,{limit:20,range:e,setSortBy:e=>s(e),showViewAll:!0,sortBy:o}):(0,$.jsx)(L,{children:ee?(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-2`,colSpan:1,children:(0,$.jsx)(it,{containerClassName:`space-y-2`,count:5,maxWidth:75,randomize:!0})})}):h?.analytics.membersTrackSources?E.length>0?E.map((e,n)=>(0,$.jsxs)(I,{className:`last:border-none`,children:[(0,$.jsx)(R,{children:(0,$.jsxs)(`div`,{className:`group/link inline-flex flex-col items-start gap-px`,children:[e.post_id&&e.attribution_type===`post`?(0,$.jsx)(Ge,{className:`h-auto p-0 text-left leading-tight font-medium whitespace-normal hover:underline!`,title:`View post analytics`,variant:`link`,onClick:Tt(e.attribution_url,e.post_id,t.url||``,a,e.attribution_type),children:e.title}):(0,$.jsx)(`span`,{className:`font-medium`,children:e.title}),e.published_at&&m&&new Date(e.published_at).getTime()>0&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Published on `,m(e.published_at,r)]})]})}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[e.free_members>0&&`+`,p(e.free_members)]}),h?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[e.paid_members>0&&`+`,p(e.paid_members)]}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[e.mrr>0&&`+`,S,p(H(e.mrr))]})]})]},`${c}-${e.post_id||`${e.title}-${n}`}`)):(0,$.jsx)(I,{className:`border-none`,children:(0,$.jsx)(R,{className:`py-12 group-hover:bg-transparent!`,colSpan:h?.paidMembersEnabled?4:2,children:(0,$.jsx)(P,{description:`Try adjusting your date range to see more data.`,title:`No conversions ${A(e)}`,children:(0,$.jsx)(ot,{strokeWidth:1.5})})})}):(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-12 group-hover:bg-transparent!`,colSpan:h?.paidMembersEnabled?4:2,children:(0,$.jsx)(vt,{})})})})]})})]})]})]})};export{nn as default};
|
|
3
|
+
the props "valueKey" will be deprecated in 1.1.0`),_=d);var v=i.filter(function(e){return w(e,_,0)!==0}).length,y=(g>=360?v:v-1)*c,x=g-v*p-y,S=i.reduce(function(e,t){var n=w(t,_,0);return e+(O(n)?n:0)},0),C;if(S>0){var T;C=i.map(function(e,t){var n=w(e,_,0),r=w(e,u,t),i=(O(n)?n:0)/S,s=t?T.endAngle+me(h)*c*(n===0?0:1):o,l=s+me(h)*((n===0?0:p)+i*x),d=(s+l)/2,g=(m.innerRadius+m.outerRadius)/2;return T=X(X(X({percent:i,cornerRadius:a,name:r,tooltipPayload:[{name:r,value:n,payload:e,dataKey:_,type:f}],midAngle:d,middleRadius:g,tooltipPosition:b(m.cx,m.cy,g,d)},e),m),{},{value:w(e,_),startAngle:s,endAngle:l,payload:e,paddingAngle:me(h)*c}),T})}return X(X({},m),{},{sectors:C,data:i})});var Ht=ne({chartName:`PieChart`,GraphicalChild:Q,validateTooltipEventTypes:[`item`],defaultTooltipEventType:`item`,legendContent:`children`,axisComponents:[{axisType:`angleAxis`,AxisComp:be},{axisType:`radiusAxis`,AxisComp:ye}],formatAxisMap:y,defaultProps:{layout:`centric`,startAngle:0,endAngle:360,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`}}),$=n(),Ut=e=>e===`total-members`||e===`free-members`||e===`paid-members`||e===`mrr`,Wt=({active:e,payload:t,range:n,color:r,showBreakdown:i})=>{if(!e||!t?.length)return null;let a=t[0].payload,{date:o,formattedValue:s,label:c,comped:l,gift:u}=a,d=a.value-(l||0)-(u||0);return(0,$.jsxs)(`div`,{className:`min-w-[200px] rounded-lg border bg-background px-3 py-2 shadow-lg`,children:[o&&(0,$.jsx)(`div`,{className:`mb-1 text-sm text-foreground`,children:z(o,n||0)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Paid subscriptions`}),(0,$.jsx)(`div`,{className:`font-mono text-xs`,children:p(d)})]})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Gift subscriptions`}),(0,$.jsx)(`div`,{className:`font-mono text-xs`,children:u!==void 0&&u>0?p(u):`0`})]})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Complimentary`}),(0,$.jsx)(`div`,{className:`font-mono text-xs`,children:l!==void 0&&l>0?p(l):`0`})]})}),(0,$.jsx)(qe,{})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`inline-block size-2 rounded-full opacity-50`,style:{backgroundColor:r||`var(--chart-purple)`}}),(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[c&&(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:c}),(0,$.jsx)(`div`,{className:`font-mono font-medium`,children:s})]})]})]})]})},Gt=({chartData:e,totals:t,initialTab:n,currencySymbol:r,isLoading:i,onTabChange:a})=>{let o=Ut(n)?n:`total-members`,[s,c]=(0,G.useState)(o),{range:l}=st(),{appSettings:f}=We(),m=d(),[h]=u();(0,G.useEffect)(()=>{c(o)},[o]);let g=e=>{c(e);let t=new URLSearchParams(h);t.set(`tab`,e),m(`?${t.toString()}`,{replace:!0}),a&&a(e)},{totalMembers:_,freeMembers:v,paidMembers:y,mrr:b,percentChanges:x,directions:S}=t,{chartData:C,chartRange:w}=(0,G.useMemo)(()=>{if(!e||e.length===0)return{chartData:[],chartRange:l};let t=[],n=`value`;switch(s){case`free-members`:n=`free`;break;case`paid-members`:n=`paid`;break;case`mrr`:n=`mrr`;break;default:n=`value`}t=k(e,l,n,`exact`);let i=[];switch(s){case`free-members`:i=t.map(e=>({...e,value:e.free,formattedValue:p(e.free),label:`Free members`}));break;case`paid-members`:i=t.map(e=>({...e,value:e.paid,formattedValue:p(e.paid),label:`Paid members`,comped:e.comped,gift:e.gift,paid_subscribed:e.paid_subscribed}));break;case`mrr`:i=t.map(e=>({...e,value:H(e.mrr),formattedValue:`${r}${p(H(e.mrr))}`,label:`MRR`}));break;default:i=t.map(e=>{let t=e.free+e.paid;return{...e,value:t,formattedValue:p(t),label:`Total members`}})}return{chartData:i,chartRange:Te(l,e,{fieldName:n})}},[s,e,l,r]),T={"total-members":{color:`var(--chart-darkblue)`},"free-members":{color:`var(--chart-blue)`},"paid-members":{color:`var(--chart-purple)`},mrr:{color:`var(--chart-teal)`}};return i?(0,$.jsx)(`div`,{className:`-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center`,children:(0,$.jsx)(at,{})}):(0,$.jsxs)(Ae,{defaultValue:o,variant:`kpis`,children:[(0,$.jsxs)(ke,{className:`-mx-6 ${f?.paidMembersEnabled?`hidden grid-cols-4 lg:visible! lg:grid!`:`grid grid-cols-4`}`,children:[(0,$.jsx)(dt,{className:f?.paidMembersEnabled?``:`cursor-auto after:hidden`,value:`total-members`,onClick:()=>{f?.paidMembersEnabled&&g(`total-members`)},children:(0,$.jsx)(U,{color:`var(--chart-darkblue)`,diffDirection:l===V.allTime.value?`hidden`:S.total,diffValue:x.total,label:`Total members`,value:p(_)})}),f?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dt,{value:`free-members`,onClick:()=>{g(`free-members`)},children:(0,$.jsx)(U,{color:`var(--chart-blue)`,diffDirection:l===V.allTime.value?`hidden`:S.free,diffValue:x.free,label:`Free members`,value:p(v)})}),(0,$.jsx)(dt,{value:`paid-members`,onClick:()=>{g(`paid-members`)},children:(0,$.jsx)(U,{color:`var(--chart-purple)`,diffDirection:l===V.allTime.value?`hidden`:S.paid,diffValue:x.paid,label:`Paid members`,value:p(y)})}),(0,$.jsx)(dt,{value:`mrr`,onClick:()=>{g(`mrr`)},children:(0,$.jsx)(U,{color:`var(--chart-teal)`,diffDirection:l===V.allTime.value?`hidden`:S.mrr,diffValue:x.mrr,label:`MRR`,value:`${r}${p(H(b))}`})})]})]}),f?.paidMembersEnabled&&(0,$.jsxs)(Je,{children:[(0,$.jsx)(nt,{className:`lg:hidden`,asChild:!0,children:(0,$.jsxs)(ft,{children:[s===`total-members`&&(0,$.jsx)(U,{color:`var(--chart-darkblue)`,diffDirection:l===V.allTime.value?`hidden`:S.total,diffValue:x.total,label:`Total members`,value:p(_)}),s===`free-members`&&(0,$.jsx)(U,{color:`var(--chart-blue)`,diffDirection:l===V.allTime.value?`hidden`:S.free,diffValue:x.free,label:`Free members`,value:p(v)}),s===`paid-members`&&(0,$.jsx)(U,{color:`var(--chart-purple)`,diffDirection:l===V.allTime.value?`hidden`:S.paid,diffValue:x.paid,label:`Paid members`,value:p(y)}),s===`mrr`&&(0,$.jsx)(U,{color:`var(--chart-teal)`,diffDirection:l===V.allTime.value?`hidden`:S.mrr,diffValue:x.mrr,label:`MRR`,value:`${r}${p(H(b))}`})]})}),(0,$.jsxs)(et,{align:`end`,className:`w-56`,children:[(0,$.jsx)(Ze,{onClick:()=>g(`total-members`),children:`Total members`}),(0,$.jsx)(Ze,{onClick:()=>g(`free-members`),children:`Free members`}),(0,$.jsx)(Ze,{onClick:()=>g(`paid-members`),children:`Paid members`}),(0,$.jsx)(Ze,{onClick:()=>g(`mrr`),children:`MRR`})]})]}),(0,$.jsx)(`div`,{className:`my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:(0,$.jsx)(xe,{className:`-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]`,color:T[s].color,data:C,dataFormatter:s===`mrr`?e=>`${r}${p(e)}`:p,id:s,range:w,tooltipContent:s===`paid-members`?(0,$.jsx)(Wt,{color:T[`paid-members`].color,range:w,showBreakdown:!0}):void 0})})]})},Kt=(e,t=`signups desc`,n=50)=>{let{startDate:r,endDate:i,timezone:a}=$e(e),o={date_from:B(r),date_to:B(i),member_status:xt(tt),order:t,limit:n.toString()};return a&&(o.timezone=a),St({searchParams:o})},qt=({data:e,currencySymbol:t,limit:n,defaultSourceIconUrl:r})=>{let i=n?e.slice(0,n):e,{appSettings:a}=We();return(0,$.jsx)(L,{children:i.map(e=>(0,$.jsxs)(I,{className:`last:border-none`,children:[(0,$.jsx)(R,{className:`font-medium`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(l,{defaultSourceIconUrl:r,displayName:e.displayName,iconSrc:e.iconSrc}),e.linkUrl?(0,$.jsx)(`a`,{className:`hover:underline`,href:e.linkUrl,rel:`noreferrer`,target:`_blank`,children:e.displayName}):(0,$.jsx)(`span`,{children:e.displayName})]})}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[`+`,p(e.free_members)]}),a?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[`+`,p(e.paid_members)]}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[`+`,t,p(H(e.mrr))]})]})]},e.source))})},Jt=({range:e,limit:t=20,showViewAll:n=!1,sortBy:r,setSortBy:i})=>{let{site:a}=bt(),{data:l}=o(),{appSettings:u}=We(),[d,f]=(0,G.useState)(`free_members desc`),p=r||d,m=i||f,{data:h,isLoading:g}=Kt(e,p.replace(`free_members`,`signups`).replace(`paid_members`,`paid_conversions`),t),_=a.url,v=`https://www.google.com/s2/favicons?domain=ghost.org&sz=64`,y=G.useMemo(()=>{if(l?.stats&&l?.meta?.totals){let e=l.meta.totals,t=e[0];if(!t)return s(`usd`);for(let n of e)n.mrr>t.mrr&&(t=n);return s(t.currency)}return s(`usd`)},[l]),b=G.useMemo(()=>h?.stats?h.stats.map(e=>{let t=e.source||`Direct`,{domain:n}=c(t,_),r=n?`https://www.faviconextractor.com/favicon/${n}?larger=true`:v,i=n&&t!==`Direct`?`https://${n}`:void 0;return{source:t,free_members:e.signups,paid_members:e.paid_conversions,mrr:e.mrr,iconSrc:r,displayName:t,linkUrl:i}}):[],[h,_]),x=`Where did your growth come from ${A(e)}`;return u?.analytics.membersTrackSources?g?(0,$.jsx)(L,{children:(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-2`,colSpan:1,children:(0,$.jsx)(rt,{containerClassName:`space-y-2`,count:5,maxWidth:75,randomize:!0})})})}):(0,$.jsxs)($.Fragment,{children:[b.length>0?(0,$.jsx)(qt,{currencySymbol:y,data:b,defaultSourceIconUrl:v,limit:t}):(0,$.jsx)(L,{children:(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-12 group-hover:bg-transparent!`,colSpan:u?.paidMembersEnabled?4:2,children:(0,$.jsx)(P,{description:`Try adjusting your date range to see more data.`,title:`No conversions ${A(e)}`,children:(0,$.jsx)(Xe,{strokeWidth:1.5})})})})}),n&&b.length>t&&(0,$.jsx)(ze,{className:`border-none bg-transparent hover:bg-transparent!`,children:(0,$.jsx)(I,{children:(0,$.jsx)(R,{className:`border-none bg-transparent px-0 pb-0 hover:bg-transparent!`,colSpan:4,children:(0,$.jsxs)(Ue,{children:[(0,$.jsx)(He,{asChild:!0,children:(0,$.jsxs)(Ke,{variant:`outline`,children:[`View all `,(0,$.jsx)(ot,{})]})}),(0,$.jsxs)(Ge,{className:`overflow-y-auto pt-0 sm:max-w-[420px]`,children:[(0,$.jsxs)(Qe,{className:`sticky top-0 z-40 -mx-6 bg-surface-elevated/60 p-6 backdrop-blur`,children:[(0,$.jsx)(ut,{children:`Top sources`}),(0,$.jsx)(Ye,{children:x})]}),(0,$.jsx)(`div`,{className:`group/datalist`,children:(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:(0,$.jsxs)(I,{children:[(0,$.jsx)(F,{children:`Source`}),(0,$.jsx)(F,{className:`w-[110px] text-right`,children:(0,$.jsx)(j,{activeSortBy:p,setSortBy:m,sortBy:`free_members desc`,children:`Free members`})}),u?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{className:`w-[110px] text-right`,children:(0,$.jsx)(j,{activeSortBy:p,setSortBy:m,sortBy:`paid_members desc`,children:`Paid members`})}),(0,$.jsx)(F,{className:`w-[110px] text-right`,children:(0,$.jsx)(j,{activeSortBy:p,setSortBy:m,sortBy:`mrr desc`,children:`MRR impact`})})]})]})}),(0,$.jsx)(qt,{currencySymbol:y,data:b,defaultSourceIconUrl:v})]})})]})]})})})})]}):(0,$.jsx)(L,{children:(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-12 group-hover:bg-transparent!`,colSpan:u?.paidMembersEnabled?4:2,children:(0,$.jsx)(vt,{})})})})};f();var Yt=({active:e,payload:t})=>{if(e&&t&&t.length){let e=t[0];return(0,$.jsx)(`div`,{className:`rounded-lg border bg-background p-2 shadow-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:e.payload.color}}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`font-mono`,children:p(e.value)})]})})}return null},Xt=({isLoading:e,range:t})=>{let{data:n}=a(),{data:{tiers:r=[]}={}}=pt(),[i,o]=(0,G.useState)(`billing-period`),{startDate:s,endDate:c}=(0,G.useMemo)(()=>$e(t),[t]),l=(0,G.useMemo)(()=>B(s),[s]),u=(0,G.useMemo)(()=>B(c),[c]),d=(0,G.useMemo)(()=>r.filter(e=>e.type===`paid`&&e.active).map(e=>({id:e.id,name:e.name})),[r]),f=(0,G.useMemo)(()=>{if(!n?.stats)return[];let e=g(l),t=g(u),r=n.stats.filter(n=>{let r=g(n.date);return r.isSameOrAfter(e)&&r.isSameOrBefore(t)}).reduce((e,t)=>{let n=t.cadence;return e[n]||(e[n]=0),e[n]+=t.signups,e},{});return Object.entries(r).map(([e,t],n)=>{let r=e,i=`url(#gradientPurple)`,a=`var(--chart-purple)`;return e===`month`?(r=`Monthly`,i=`url(#gradientPurple)`,a=`var(--chart-purple)`):e===`year`&&(r=`Annual`,i=`url(#gradientTeal)`,a=`var(--chart-teal)`),{id:`cadence-${n}`,name:r,count:t,fill:i,color:a}})},[n,l,u]),m=(0,G.useMemo)(()=>{if(!n?.stats||d.length===0)return[];let e=g(l),t=g(u),r=n.stats.filter(n=>{let r=g(n.date);return r.isSameOrAfter(e)&&r.isSameOrBefore(t)}).reduce((e,t)=>{let n=t.tier;return e[n]||(e[n]=0),e[n]+=t.signups,e},{}),i=[{gradient:`url(#gradientPurple)`,solid:`var(--chart-purple)`},{gradient:`url(#gradientTeal)`,solid:`var(--chart-teal)`},{gradient:`url(#gradientBlue)`,solid:`var(--chart-blue)`},{gradient:`url(#gradientRose)`,solid:`var(--chart-rose)`},{gradient:`url(#gradientOrange)`,solid:`var(--chart-orange)`},{gradient:`url(#gradientGreen)`,solid:`var(--chart-green)`},{gradient:`url(#gradientAmber)`,solid:`var(--chart-amber)`},{gradient:`url(#gradientYellow)`,solid:`var(--chart-yellow)`},{gradient:`url(#gradientDarkblue)`,solid:`var(--chart-darkblue)`},{gradient:`url(#gradientGray)`,solid:`var(--chart-darkgray)`}];return[...d.map(e=>{let t=r[e.id]||0;return{id:e.id,name:e.name,count:t}})].sort((e,t)=>t.count-e.count).map((e,t)=>{let n=t%i.length;return{...e,fill:i[n].gradient,color:i[n].solid}})},[n,d,l,u]),h=i===`billing-period`?f:m,_=(0,G.useMemo)(()=>h.reduce((e,t)=>e+t.count,0),[h]),v=(0,G.useMemo)(()=>{let e={count:{label:`Subscriptions`}};return h.forEach(t=>{e[t.id]={label:t.name,color:t.color}}),e},[h]),y=(0,G.useMemo)(()=>_===0?[]:h.map(e=>({label:e.name,count:e.count,percentage:e.count/_*100,color:e.color})),[h,_]);if(e||!n?.stats)return null;let b=h.length>0&&_>0;return(0,$.jsxs)(N,{children:[(0,$.jsx)(Ie,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Le,{children:`Paid subscription breakdown`}),(0,$.jsxs)(Re,{children:[`New paid subscriptions `,A(t)]})]}),d.length>1&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(Fe,{value:i,onValueChange:e=>o(e),children:[(0,$.jsx)(Ne,{className:`w-full`,children:(0,$.jsx)(Pe,{})}),(0,$.jsxs)(Me,{align:`end`,children:[(0,$.jsx)(je,{value:`billing-period`,children:`Billing period`}),(0,$.jsx)(je,{value:`tiers`,children:`Tiers`})]})]})})]})}),(0,$.jsx)(M,{children:b?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(de,{className:`mx-auto aspect-square h-[250px] min-h-[250px] w-full`,config:v,children:(0,$.jsxs)(Ht,{children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsxs)(`linearGradient`,{id:`gradientPurple`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-purple)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-purple)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientTeal`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-teal)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-teal)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientRose`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-rose)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-rose)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientBlue`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-blue)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-blue)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientOrange`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-orange)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-orange)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientGreen`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-green)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-green)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientAmber`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-amber)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-amber)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientYellow`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-yellow)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-yellow)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientDarkblue`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-darkblue)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-darkblue)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientGray`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-darkgray)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-darkgray)`,stopOpacity:.6})]})]}),(0,$.jsx)(pe,{content:(0,$.jsx)(Yt,{}),cursor:!1}),(0,$.jsx)(Q,{animationBegin:0,animationDuration:1e3,data:h,dataKey:`count`,innerRadius:70,nameKey:`name`,stroke:`var(--card)`,strokeWidth:5,children:(0,$.jsx)(E,{content:({viewBox:e})=>{if(e&&`cx`in e&&`cy`in e)return(0,$.jsxs)(`text`,{dominantBaseline:`middle`,textAnchor:`middle`,x:e.cx,y:e.cy,children:[(0,$.jsx)(`tspan`,{className:`fill-foreground text-2xl font-semibold tracking-tight`,x:e.cx,y:e.cy,children:p(_)}),(0,$.jsx)(`tspan`,{className:`fill-muted-foreground`,x:e.cx,y:(e.cy||0)+20,children:`Total`})]})}})})]})}),y.length>0&&(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center justify-center gap-x-6 gap-y-1 text-sm text-muted-foreground`,children:y.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:e.color}}),(0,$.jsx)(`span`,{className:`max-w-[150px] truncate whitespace-nowrap`,title:e.label,children:e.label}),(0,$.jsxs)(`span`,{className:`font-medium text-foreground`,children:[Math.round(Number(e.percentage)||0),`%`]})]},e.label))})]}):(0,$.jsx)(`div`,{className:`py-12`,children:(0,$.jsx)(P,{description:`No new paid subscriptions ${A(t)}.`,title:`No new subscribers`,children:(0,$.jsx)(ct,{strokeWidth:1.5})})})})]})};f();var Zt=(e,t,n)=>{if(t===1){let t=g().format(`YYYY-MM-DD`),n=e.find(e=>e.date===t);return[{date:t,signups:n?.signups||0,cancellations:n?.cancellations||0}]}let{startDate:r,endDate:i}=$e(t),a=g(r).format(`YYYY-MM-DD`),o=new Map(e.map(e=>[e.date,e])),s=[],c=new Set;if(n===`monthly`){let e=g(r).startOf(`month`),t=g(i).startOf(`month`);for(;e.isSameOrBefore(t);){let t=e.format(`YYYY-MM-DD`),n=t<a?a:t;if(!c.has(n)){c.add(n);let e=o.get(n);e?s.push(e):s.push({date:n,signups:0,cancellations:0})}e.add(1,`month`)}}else if(n===`weekly`){let e=g(r).startOf(`week`),t=g(i).startOf(`week`);for(;e.isSameOrBefore(t);){let t=e.format(`YYYY-MM-DD`),n=t<a?a:t;if(!c.has(n)){c.add(n);let e=o.get(n);e?s.push(e):s.push({date:n,signups:0,cancellations:0})}e.add(1,`week`)}}else{let e=g(r),t=g(i);for(;e.isSameOrBefore(t);){let t=e.format(`YYYY-MM-DD`),n=o.get(t);n?s.push(n):s.push({date:t,signups:0,cancellations:0}),e.add(1,`day`)}}return s},Qt=e=>{let t=we(e);return t<30?[`daily`]:t>=91?[`weekly`,`monthly`]:[`daily`,`weekly`]},$t=e=>{let t=we(e);return t<30?`daily`:t>=91?`monthly`:`weekly`},en=({subscriptionData:e,memberData:t,range:n,isLoading:r})=>{let[i,a]=(0,G.useState)(()=>$t(n));(0,G.useEffect)(()=>{a($t(n))},[n]);let o=(0,G.useMemo)(()=>Qt(n),[n]),s=(0,G.useMemo)(()=>{switch(i){case`daily`:return`none`;case`weekly`:return`weekly`;case`monthly`:return`monthly`}},[i]),c=(0,G.useMemo)(()=>Te(n,[],{overrideStrategy:s}),[n,s]),l=(0,G.useMemo)(()=>{if(e&&e.length>0){if(n===1){let t=g().format(`YYYY-MM-DD`),r=e.find(e=>e.date===t);return[{date:z(t,n),rawDate:t,new:r?.signups||0,cancelled:-(r?.cancellations||0)}]}let t=k(e,n,`signups`,`sum`,s),r=k(e,n,`cancellations`,`sum`,s),i=new Map(r.map(e=>[e.date,e])),a=t.map(e=>({date:e.date,signups:e.signups||0,cancellations:i.get(e.date)?.cancellations||0})),o=new Set(a.map(e=>e.date));return r.forEach(e=>{o.has(e.date)||a.push({date:e.date,signups:0,cancellations:e.cancellations||0})}),a.sort((e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime()),Zt(a,n,s).map(e=>({date:z(e.date,c),rawDate:e.date,new:e.signups||0,cancelled:-(e.cancellations||0)}))}else{if(!t||t.length===0)return[];if(n===1){let e=g().format(`YYYY-MM-DD`),r=t.find(t=>t.date===e);return[{date:z(e,n),rawDate:e,new:r?.paid_subscribed||0,cancelled:-(r?.paid_canceled||0)}]}let e=k(t,n,`paid_subscribed`,`sum`,s),r=k(t,n,`paid_canceled`,`sum`,s),i=new Map(r.map(e=>[e.date,e])),a=e.map(e=>({date:e.date,paid_subscribed:e.paid_subscribed||0,paid_canceled:i.get(e.date)?.paid_canceled||0})),o=new Set(a.map(e=>e.date));return r.forEach(e=>{o.has(e.date)||a.push({date:e.date,paid_subscribed:0,paid_canceled:e.paid_canceled||0})}),a.sort((e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime()),a.map(e=>({date:z(e.date,c),rawDate:e.date,new:e.paid_subscribed||0,cancelled:-(e.paid_canceled||0)}))}},[t,e,n,s,c]),u={new:{label:`New`,color:`var(--chart-teal)`},cancelled:{label:`Cancelled`,color:`var(--chart-rose)`}},d=(0,G.useMemo)(()=>({new:l.reduce((e,t)=>e+t.new,0),cancelled:l.reduce((e,t)=>e+Math.abs(t.cancelled),0)}),[l]);if(r)return null;let f=l.length>0&&(d.new>0||d.cancelled>0),m=e=>e.charAt(0).toUpperCase()+e.slice(1);return(0,$.jsxs)(N,{"data-testid":`paid-members-change-card`,children:[(0,$.jsx)(Ie,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Le,{children:`Paid subscriptions`}),(0,$.jsxs)(Re,{children:[`New and cancelled paid subscriptions `,A(n)]})]}),o.length>1&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(Fe,{value:i,onValueChange:e=>a(e),children:[(0,$.jsx)(Ne,{className:`w-[110px]`,children:(0,$.jsx)(Pe,{})}),(0,$.jsx)(Me,{align:`end`,children:o.map(e=>(0,$.jsx)(je,{value:e,children:m(e)},e))})]})})]})}),(0,$.jsx)(M,{children:f?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(de,{className:`aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]`,config:u,children:(0,$.jsxs)(De,{data:l,stackOffset:`sign`,children:[(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`tealGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-new)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-new)`,stopOpacity:.6})]})}),(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`roseGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-cancelled)`,stopOpacity:.6}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-cancelled)`,stopOpacity:.8})]})}),(0,$.jsx)(Ee,{stroke:`var(--border)`,vertical:!1}),(0,$.jsx)(Ce,{axisLine:!1,dataKey:`date`,tickFormatter:()=>``,tickLine:!1,tickMargin:10}),(0,$.jsx)(Se,{axisLine:!1,tickFormatter:e=>p(e<0?e*-1:e),tickLine:!1}),(0,$.jsx)(pe,{content:(0,$.jsx)(le,{className:`min-w-[120px]! px-3 py-2`,formatter:(e,t,n,r)=>{let i=Number(e),a=`0`;a=i===0?`0`:p(i<0?i*-1:i);let o=n?.payload,s=Number(o?.new||0)+Number(o?.cancelled||0),l=s===0?`0`:s>0?`+${p(s)}`:p(s),d=o?.date,f=o?.rawDate;return f&&(d=z(f,c)),(0,$.jsxs)(`div`,{className:`flex w-full flex-col`,children:[r===0&&(0,$.jsx)(`div`,{className:`mb-1 text-sm font-medium text-foreground`,children:d}),(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`div`,{className:`size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50`,style:{"--color-bg":`var(--color-${t})`}}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:u[t]?.label||t})]}),(0,$.jsx)(`div`,{className:`ml-auto flex items-baseline gap-0.5 font-mono font-medium text-foreground tabular-nums`,children:a})]}),r===1&&(0,$.jsxs)(`div`,{className:`mt-1 flex w-full items-center justify-between gap-4 border-t pt-1`,children:[(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Net change`}),(0,$.jsx)(`div`,{className:`ml-auto flex items-baseline gap-0.5 font-mono font-medium text-foreground tabular-nums`,children:l})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),(0,$.jsx)(ce,{activeBar:{fillOpacity:1},dataKey:`new`,fill:`url(#tealGradient)`,fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:`a`}),(0,$.jsx)(ce,{activeBar:{fillOpacity:1},dataKey:`cancelled`,fill:`url(#roseGradient)`,fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:`a`})]})}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-center gap-6 text-sm text-muted-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:u.new.color}}),(0,$.jsx)(`span`,{children:`New`}),(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:p(d.new)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:u.cancelled.color}}),(0,$.jsx)(`span`,{children:`Cancelled`}),(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:p(d.cancelled)})]})]})]}):(0,$.jsx)(`div`,{className:`py-12`,children:(0,$.jsx)(P,{description:`No paid subscription changes ${A(n)}.`,title:`No paid member changes`,children:(0,$.jsx)(it,{strokeWidth:1.5})})})})]})},tn=(e,t,n)=>{let i=e??30,a=t??`mrr desc`,{startDate:o,endDate:s}=(0,G.useMemo)(()=>$e(i),[i]),c=(0,G.useMemo)(()=>{let e={date_from:B(o),date_to:B(s),order:a};return n===`posts`?e.post_type=`post`:n===`pages`&&(e.post_type=`page`),e},[o,s,a,n]);return r({searchParams:Object.fromEntries(Object.entries(c).filter(([,e])=>e!==void 0))})},nn=()=>{let{range:e}=st(),{site:t,settings:n}=bt(),r=String(n.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),a=d(),[o,s]=(0,G.useState)(`free_members desc`),[c,l]=(0,G.useState)(W.POSTS_AND_PAGES),[f]=u(),{appSettings:h}=We(),g=f.get(`tab`)||`total-members`,[_,v]=(0,G.useState)(g);(0,G.useEffect)(()=>{g!==_&&v(g)},[g]);let{isLoading:y,chartData:b,totals:x,currencySymbol:S,subscriptionData:C}=yt(e),{data:w,isLoading:T}=tn(e,o,c),E=(0,G.useMemo)(()=>{let e=(w?.stats||[]).reduce((e,t)=>{let n=t.post_id||(t.title&&t.title.trim()!==``?t.title:t.attribution_url);if(!n)return e;if(!e.has(n))e.set(n,t);else{let r=e.get(n);r.free_members+=t.free_members,r.paid_members+=t.paid_members,r.mrr+=t.mrr,e.set(n,r)}return e},new Map),t=Array.from(e.values()),n=t.reduce((e,t)=>e+t.free_members,0),r=t.reduce((e,t)=>e+t.paid_members,0),i=t.reduce((e,t)=>e+t.mrr,0);return t.map(e=>{let t=0;return o.includes(`free_members`)&&n>0?t=e.free_members/n:o.includes(`paid_members`)&&r>0?t=e.paid_members/r:o.includes(`mrr`)&&i>0&&(t=e.mrr/i),{title:e.title||e.attribution_url,post_id:e.post_id,attribution_url:e.attribution_url,attribution_type:e.attribution_type,attribution_id:e.attribution_id,free_members:e.free_members,paid_members:e.paid_members,mrr:e.mrr,percentage:t,published_at:e.published_at,url_exists:e.url_exists??!0}})},[w,o]),D=y,ee=y||T;return(0,$.jsxs)(ht,{children:[(0,$.jsx)(gt,{children:(0,$.jsx)(i,{children:(0,$.jsx)(mt,{})})}),(0,$.jsxs)(_t,{data:D?void 0:b,isLoading:!1,loadingComponent:(0,$.jsx)($.Fragment,{}),children:[(0,$.jsx)(N,{"data-testid":`total-members-card`,children:(0,$.jsx)(M,{children:(0,$.jsx)(Gt,{chartData:b,currencySymbol:S,initialTab:g,isLoading:D,totals:x,onTabChange:v})})}),h?.paidMembersEnabled&&_===`paid-members`&&(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-[2fr_minmax(460px,1fr)]`,children:[(0,$.jsx)(en,{isLoading:D,memberData:b,range:e,subscriptionData:C}),(0,$.jsx)(Xt,{isLoading:D,range:e})]}),(0,$.jsxs)(N,{className:`w-full overflow-x-auto`,"data-testid":`top-content-card`,children:[(0,$.jsxs)(Ie,{children:[(0,$.jsx)(Le,{children:wt(c)}),(0,$.jsx)(Re,{children:Ct(c,e,A)})]}),(0,$.jsx)(M,{children:(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:(0,$.jsxs)(I,{className:`[&>th]:h-auto [&>th]:pt-0 [&>th]:pb-2`,children:[(0,$.jsx)(F,{className:`min-w-[320px] pl-0`,children:(0,$.jsx)(Ae,{defaultValue:c,variant:`button-sm`,onValueChange:e=>{l(e)},children:(0,$.jsxs)(ke,{children:[(0,$.jsx)(Oe,{value:W.POSTS_AND_PAGES,children:`Posts & pages`}),(0,$.jsx)(Oe,{value:W.POSTS,children:`Posts`}),(0,$.jsx)(Oe,{value:W.PAGES,children:`Pages`}),(0,$.jsx)(Oe,{value:W.SOURCES,children:`Sources`})]})})}),(0,$.jsx)(F,{className:`w-[140px] text-right`,children:h?.paidMembersEnabled?(0,$.jsx)(j,{activeSortBy:o,setSortBy:s,sortBy:`free_members desc`,children:`Free members`}):(0,$.jsx)($.Fragment,{children:`Free members`})}),h?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{className:`w-[140px] text-right`,children:(0,$.jsx)(j,{activeSortBy:o,setSortBy:s,sortBy:`paid_members desc`,children:`Paid members`})}),(0,$.jsx)(F,{className:`w-[140px] text-right`,children:(0,$.jsx)(j,{activeSortBy:o,setSortBy:s,sortBy:`mrr desc`,children:`MRR impact`})})]})]})}),c===W.SOURCES?(0,$.jsx)(Jt,{limit:20,range:e,setSortBy:e=>s(e),showViewAll:!0,sortBy:o}):(0,$.jsx)(L,{children:ee?(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-2`,colSpan:1,children:(0,$.jsx)(rt,{containerClassName:`space-y-2`,count:5,maxWidth:75,randomize:!0})})}):h?.analytics.membersTrackSources?E.length>0?E.map((e,n)=>(0,$.jsxs)(I,{className:`last:border-none`,children:[(0,$.jsx)(R,{children:(0,$.jsxs)(`div`,{className:`group/link inline-flex flex-col items-start gap-px`,children:[e.post_id&&e.attribution_type===`post`?(0,$.jsx)(Ke,{className:`h-auto p-0 text-left leading-tight font-medium whitespace-normal hover:underline!`,title:`View post analytics`,variant:`link`,onClick:Tt(e.attribution_url,e.post_id,t.url||``,a,e.attribution_type),children:e.title}):(0,$.jsx)(`span`,{className:`font-medium`,children:e.title}),e.published_at&&m&&new Date(e.published_at).getTime()>0&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Published on `,m(e.published_at,r)]})]})}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[e.free_members>0&&`+`,p(e.free_members)]}),h?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[e.paid_members>0&&`+`,p(e.paid_members)]}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[e.mrr>0&&`+`,S,p(H(e.mrr))]})]})]},`${c}-${e.post_id||`${e.title}-${n}`}`)):(0,$.jsx)(I,{className:`border-none`,children:(0,$.jsx)(R,{className:`py-12 group-hover:bg-transparent!`,colSpan:h?.paidMembersEnabled?4:2,children:(0,$.jsx)(P,{description:`Try adjusting your date range to see more data.`,title:`No conversions ${A(e)}`,children:(0,$.jsx)(lt,{strokeWidth:1.5})})})}):(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-12 group-hover:bg-transparent!`,colSpan:h?.paidMembersEnabled?4:2,children:(0,$.jsx)(vt,{})})})})]})})]})]})]})};export{nn as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{t as n}from"./react-Bb3IsNbi.js";import{t as r}from"./jsx-runtime-DX3WBWVO.js";import{m as i}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as a}from"./router-provider-
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{t as n}from"./react-Bb3IsNbi.js";import{t as r}from"./jsx-runtime-DX3WBWVO.js";import{m as i}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as a}from"./router-provider-BmEZf6c6.js";import{a as o}from"./shade-app-B3heOAfz-BhQXxNkT.js";import{t as s}from"./empty-indicator-WB1WgT9h.js";import{$ as c,Ar as l,B as u,Dr as d,Er as f,Gt as p,H as m,Ir as h,It as g,Jn as _,Jt as v,Kt as y,L as b,Oa as x,Tt as S,Ua as C,Wt as w,Z as T,at as E,ct as D,dt as ee,et as O,ft as k,go as A,gr as j,ir as M,it as N,kr as P,kt as te,nt as ne,ot as F,qt as re,rr as ie,rt as ae,st as I,tt as oe,vr as L,wr as se,yr as R}from"./index-08n05-rc.js";import"./layout-B0YLh7R9.js";import{t as z}from"./topic-filter-DGDxDalo.js";import{i as ce,n as le,r as ue,t as de}from"./use-reply-chain-data-RLdPKRmS.js";var B=e(n(),1),V=r(),H=[`1.5rem`,`1.6rem`,`1.7rem`,`1.8rem`,`2rem`],U={BACKGROUND_COLOR:`ghost-ap-background-color`,FONT_SIZE:`ghost-ap-font-size`,FONT_FAMILY:`ghost-ap-font-family`,FONT_STYLE:`ghost-ap-font-style`},W={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`}},fe=()=>{let[e,t]=(0,B.useState)(()=>localStorage.getItem(U.BACKGROUND_COLOR)?.toUpperCase()||`SYSTEM`),[n,r]=(0,B.useState)(()=>{let e=localStorage.getItem(U.FONT_SIZE);return e?parseInt(e):2}),[i,a]=(0,B.useState)(()=>localStorage.getItem(U.FONT_STYLE)||`sans`);return(0,B.useEffect)(()=>{localStorage.setItem(U.FONT_SIZE,n.toString())},[n]),(0,B.useEffect)(()=>{localStorage.setItem(U.FONT_STYLE,i)},[i]),{backgroundColor:e,currentFontSizeIndex:n,fontStyle:i,handleColorChange:e=>{t(e),localStorage.setItem(U.BACKGROUND_COLOR,W[e].id)},setFontStyle:a,increaseFontSize:()=>{r(e=>Math.min(e+1,H.length-1))},decreaseFontSize:()=>{r(e=>Math.max(e-1,0))},resetFontSize:()=>r(2),fontSize:H[n]}},pe=({backgroundColor:e,currentFontSizeIndex:t,fontStyle:n,onColorChange:r,onFontStyleChange:i,onDecreaseFontSize:a,onIncreaseFontSize:o,onResetFontSize:s,onOpenChange:c})=>(0,V.jsx)(G,{backgroundColor:e,currentFontSizeIndex:t,fontStyle:n,isActiveColor:t=>e===t,isActiveFont:e=>n===e,onColorChange:r,onDecreaseFontSize:a,onFontStyleChange:i,onIncreaseFontSize:o,onOpenChange:c,onResetFontSize:s}),G=({backgroundColor:e,isActiveColor:t,isActiveFont:n,onColorChange:r,onFontStyleChange:i,currentFontSizeIndex:a,onDecreaseFontSize:s,onIncreaseFontSize:c,onResetFontSize:l,onOpenChange:u})=>(0,V.jsxs)(j,{modal:!1,onOpenChange:u,children:[(0,V.jsx)(R,{asChild:!0,children:(0,V.jsx)(h,{className:`size-9 rounded-full ${W[e].button}`,variant:`ghost`,children:(0,V.jsx)(o.Typography,{className:`size-[18px]!`})})}),(0,V.jsx)(L,{align:`end`,className:`w-[224px]`,onCloseAutoFocus:e=>e.preventDefault(),onOpenAutoFocus:e=>e.preventDefault(),children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-[6px]`,children:[(0,V.jsx)(h,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${t(`SYSTEM`)?`outline-2 outline-green`:``}`,variant:`secondary`,onClick:()=>r(`SYSTEM`),children:`Auto`}),(0,V.jsx)(h,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${t(`SEPIA`)?`outline-2 outline-green`:`border border-[#ece6d9]`}`,onClick:()=>r(`SEPIA`)}),(0,V.jsx)(h,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${t(`LIGHT`)?`outline-2 outline-green`:`border border-gray-200`}`,onClick:()=>r(`LIGHT`)}),(0,V.jsx)(h,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-950 ${t(`DARK`)?`outline-2 outline-green`:``}`,onClick:()=>r(`DARK`)})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(h,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900 ${n(`sans`)&&`outline-2 outline-green`}`,variant:`secondary`,onClick:()=>i(`sans`),children:[(0,V.jsx)(`span`,{className:`text-[2rem] leading-none font-bold`,children:`Aa`}),(0,V.jsx)(`span`,{className:`text-[1.1rem]`,children:`System`})]}),(0,V.jsxs)(h,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900 ${n(`serif`)&&`outline-2 outline-green`}`,variant:`secondary`,onClick:()=>i(`serif`),children:[(0,V.jsx)(`span`,{className:`pt-1 font-serif text-[2rem] leading-none font-bold`,children:`Aa`}),(0,V.jsx)(`span`,{className:`font-serif text-[1.2rem]`,children:`Serif`})]})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(h,{className:`h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]`,disabled:a===0,variant:`secondary`,onClick:s,children:(0,V.jsx)(C,{})}),(0,V.jsx)(h,{className:`h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900`,variant:`secondary`,onClick:l,children:(0,V.jsx)(`span`,{className:`text-[1.6rem] font-bold`,children:`Aa`})}),(0,V.jsx)(h,{className:`h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]`,disabled:a===H.length-1,variant:`secondary`,onClick:c,children:(0,V.jsx)(x,{})})]})]})})]}),me=({tocItems:e,iframeElement:t,modalRef:n,className:r=`visible! absolute inset-y-0 right-7 z-40 hidden lg:block!`,onOpenChange:i})=>{let[a,o]=(0,B.useState)(null),s=B.useRef(!1);return(0,B.useEffect)(()=>{if(!t?.contentDocument||e.length<=1)return;let r=n.current;if(!r)return;let i=()=>{if(s.current)return;let n=t.contentDocument;if(!n)return;let i=r.scrollTop,a=e.map(e=>n.getElementById(e.id)).filter(e=>e!==null).map(e=>({id:e.id,top:e.offsetTop}));if(!a.length)return;let c=a.reduce((e,t)=>t.top-100<=i?t:e);o(c?.id||null)},a=()=>{requestAnimationFrame(i)};return r.addEventListener(`scroll`,a),i(),()=>{r.removeEventListener(`scroll`,a)}},[t,e,n]),e.length<=1?null:(0,V.jsx)(`div`,{className:r,children:(0,V.jsx)(`div`,{className:`sticky top-1/2 -translate-y-1/2`,children:(0,V.jsx)(K,{activeHeading:a||``,items:e,onItemClick:e=>{if(!t?.contentDocument)return;let r=t.contentDocument.getElementById(e);r&&n.current&&(s.current=!0,o(e),n.current.scrollTo({top:r.offsetTop-20,behavior:`smooth`}),setTimeout(()=>{s.current=!1},1e3))},onOpenChange:i})})})},he={1:`w-3`,2:`w-2`,3:`w-1`},ge={1:`pl-2`,2:`pl-6`,3:`pl-10`},K=({items:e,activeHeading:t,onItemClick:n,onOpenChange:r})=>{let[i,a]=(0,B.useState)(!1),o=B.useRef();if(B.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),e.length===0)return null;let s=e=>Math.min(e,3),c=e=>he[s(e)],l=e=>ge[s(e)],u=()=>{o.current&&clearTimeout(o.current),a(!0),r?.(!0)},d=()=>{o.current=setTimeout(()=>{a(!1),r?.(!1)},100)};return(0,V.jsxs)(j,{modal:!1,open:i,onOpenChange:a,children:[(0,V.jsx)(R,{asChild:!0,children:(0,V.jsx)(`div`,{className:`absolute top-1/2 right-2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black`,onMouseEnter:u,onMouseLeave:d,children:e.map(e=>(0,V.jsx)(`div`,{className:`h-[2px] rounded-sm ${t===e.id?`bg-black dark:bg-white`:`bg-gray-400 dark:bg-gray-700`} pr-1 transition-all ${c(e.level)}`},e.id))})}),(0,V.jsx)(L,{align:`center`,className:`w-[240px] p-2`,side:`left`,sideOffset:-28,onCloseAutoFocus:e=>e.preventDefault(),onMouseEnter:u,onMouseLeave:d,onOpenAutoFocus:e=>e.preventDefault(),children:(0,V.jsx)(`nav`,{"aria-label":`Table of contents navigation`,className:`max-h-[60vh] overflow-y-auto`,role:`navigation`,children:e.map(e=>(0,V.jsx)(`button`,{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${t===e.id?`text-black dark:text-white`:`text-gray-700 dark:text-gray-600`} hover:bg-gray-100 hover:text-gray-900 dark:hover:bg-grey-950 dark:hover:text-white ${l(e.level)}`,type:`button`,onClick:()=>n(e.id),children:(0,V.jsx)(`span`,{className:`line-clamp-2`,children:e.text})},e.id))})})]})},_e=()=>`<style>
|
|
2
2
|
|
|
3
3
|
/* Variables */
|
|
4
4
|
|
|
@@ -3883,10 +3883,10 @@ a.kg-cta-button {
|
|
|
3883
3883
|
|
|
3884
3884
|
`),rt=Object.values(tt).map(e=>e.default).join(`
|
|
3885
3885
|
|
|
3886
|
-
`),it=({postUrl:e,heading:t,image:n,excerpt:r,authors:i,html:a,backgroundColor:o,fontSize:s,fontStyle:c,onHeadingsExtracted:l,onIframeLoad:u,onLoadingChange:d,isPopoverOpen:f})=>{let p=(0,B.useRef)(null),[m,h]=(0,B.useState)(!0),[g,_]=(0,B.useState)(`0px`),v=document.documentElement.classList.contains(`dark`)&&o===`SYSTEM`||o===`DARK`,
|
|
3886
|
+
`),it=({postUrl:e,heading:t,image:n,excerpt:r,authors:i,html:a,backgroundColor:o,fontSize:s,fontStyle:c,onHeadingsExtracted:l,onIframeLoad:u,onLoadingChange:d,isPopoverOpen:f})=>{let p=(0,B.useRef)(null),[m,h]=(0,B.useState)(!0),[g,_]=(0,B.useState)(`0px`),v=document.documentElement.classList.contains(`dark`)&&o===`SYSTEM`||o===`DARK`,y=_e(),b=typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(hover: none) and (pointer: coarse)`).matches,x=(0,B.useMemo)(()=>D(I(b?N(a):a)),[a,b]),S=`
|
|
3887
3887
|
<html class="has-${v?`light`:`dark`}-text has-${c}-body ${o===`SEPIA`&&`has-sepia-bg`}">
|
|
3888
3888
|
<head>
|
|
3889
|
-
${
|
|
3889
|
+
${y}
|
|
3890
3890
|
<style>
|
|
3891
3891
|
:root {
|
|
3892
3892
|
--font-size: ${s};
|
|
@@ -3977,14 +3977,14 @@ a.kg-cta-button {
|
|
|
3977
3977
|
</head>
|
|
3978
3978
|
<body>
|
|
3979
3979
|
<header class='gh-article-header gh-canvas'>
|
|
3980
|
-
<h1 class='gh-article-title is-title' data-test-article-heading>${
|
|
3981
|
-
${r?`<p class='gh-article-excerpt'>${
|
|
3982
|
-
<a href="${e&&
|
|
3980
|
+
<h1 class='gh-article-title is-title' data-test-article-heading>${E(t)}</h1>
|
|
3981
|
+
${r?`<p class='gh-article-excerpt'>${E(r)}</p>`:``}
|
|
3982
|
+
<a href="${e&&F(e)?E(e):`#`}" target="_blank" rel="noopener noreferrer" class="gh-article-meta">
|
|
3983
3983
|
${i&&i.length>0?`
|
|
3984
3984
|
<div class="gh-article-author-image">
|
|
3985
3985
|
${i.map(e=>`
|
|
3986
3986
|
<span>
|
|
3987
|
-
${e.profile_image?`<img src="${
|
|
3987
|
+
${e.profile_image?`<img src="${E(e.profile_image)}" alt="${E(e.name)}">`:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="24" width="24"><path d="M6.75 6a5.25 5.25 0 1 0 10.5 0 5.25 5.25 0 1 0 -10.5 0" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path><path d="M2.25 23.25a9.75 9.75 0 0 1 19.5 0" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path></svg>`}
|
|
3988
3988
|
</span>
|
|
3989
3989
|
`).join(``)}
|
|
3990
3990
|
</div>
|
|
@@ -3992,20 +3992,20 @@ a.kg-cta-button {
|
|
|
3992
3992
|
<div class="gh-article-meta-wrapper">
|
|
3993
3993
|
${i&&i.length>0?`
|
|
3994
3994
|
<span class="gh-article-author-name">
|
|
3995
|
-
${i.length>1?`${
|
|
3995
|
+
${i.length>1?`${E(i[0].name)} and ${i.length-1} ${i.length-1==1?`other`:`others`}`:E(i[0].name)}
|
|
3996
3996
|
</span>
|
|
3997
3997
|
`:``}
|
|
3998
|
-
<span class="gh-article-source">${e&&
|
|
3998
|
+
<span class="gh-article-source">${e&&F(e)?E(new URL(e).hostname):``} <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-external-link-icon lucide-external-link"><path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/></svg></span>
|
|
3999
3999
|
</div>
|
|
4000
4000
|
</a>
|
|
4001
4001
|
${n?`
|
|
4002
4002
|
<figure class='gh-article-image'>
|
|
4003
|
-
<img src='${
|
|
4003
|
+
<img src='${E(n)}' alt='${E(t)}' />
|
|
4004
4004
|
</figure>
|
|
4005
4005
|
`:``}
|
|
4006
4006
|
</header>
|
|
4007
4007
|
<div class='gh-content gh-canvas is-body'>
|
|
4008
|
-
${
|
|
4008
|
+
${x}
|
|
4009
4009
|
</div>
|
|
4010
4010
|
<script>
|
|
4011
4011
|
(function () {
|
|
@@ -4025,4 +4025,4 @@ a.kg-cta-button {
|
|
|
4025
4025
|
<\/script>
|
|
4026
4026
|
</body>
|
|
4027
4027
|
</html>
|
|
4028
|
-
`;return(0,B.useEffect)(()=>{let e=p.current;if(!e)return;e.srcdoc||=x;let t=t=>{if(t.data.type===`resize`){let n=`${t.data.bodyHeight+24}px`;_(n),e.style.height=n,t.data.isLoaded&&h(!1)}},n=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation();let t=new KeyboardEvent(`keydown`,{key:`Escape`,code:`Escape`,keyCode:27,which:27,bubbles:!0,cancelable:!0});document.dispatchEvent(t)}},r=()=>{let t=e.contentWindow;t&&t.addEventListener(`keydown`,n)};return e.addEventListener(`load`,r),window.addEventListener(`message`,t),()=>{window.removeEventListener(`message`,t),e.removeEventListener(`load`,r);let i=e.contentWindow;i&&i.removeEventListener(`keydown`,n)}},[x]),(0,B.useEffect)(()=>{let e=p.current;if(!e)return;let t=e.contentDocument||e.contentWindow?.document;if(!t)return;let n=t.documentElement;n.style.setProperty(`--font-size`,s),n.classList.remove(`has-sans-body`,`has-serif-body`),n.classList.add(`has-${c}-body`),n.classList.remove(`has-dark-text`,`has-light-text`),n.classList.add(`has-${v?`light`:`dark`}-text`),o===`SEPIA`?n.classList.add(`has-sepia-bg`):n.classList.remove(`has-sepia-bg`);let r=e.contentWindow;if(r&&typeof r.resizeIframe==`function`)r.resizeIframe();else{let e=new Event(`resize`);t.dispatchEvent(e)}},[s,c,o,v]),(0,B.useEffect)(()=>{let e=p.current;if(!e)return;let t=()=>{if(!e.contentDocument)return;let t=Array.from(e.contentDocument.querySelectorAll(`.gh-content > :is(h2, h3, h4, h5, h6)[id]`));if(t.length===0)return;let n=Math.min(...t.map(e=>parseInt(e.tagName[1]))),r=t.map((e,t)=>{let r=`heading-${t}`;e.id=r;let i=parseInt(e.tagName[1])-n+1;return{id:r,text:e.textContent||``,level:i,element:e}});l?.(r),u?.(e)};return e.addEventListener(`load`,t),()=>e.removeEventListener(`load`,t)},[l,u]),(0,B.useEffect)(()=>{d?.(m)},[m,d]),(0,V.jsx)(`div`,{className:`w-full pb-6`,children:(0,V.jsxs)(`div`,{className:`relative -mx-6`,children:[m&&(0,V.jsxs)(`div`,{className:`mx-auto mt-6 w-full max-w-[640px] max-lg:px-4`,children:[(0,V.jsxs)(`div`,{className:`mb-6 flex flex-col gap-2`,children:[(0,V.jsx)(j,{className:`h-8`}),(0,V.jsx)(j,{className:`h-8 w-full max-w-md`})]}),(0,V.jsx)(j,{className:`mt-2 h-4`,count:4,randomize:!0}),(0,V.jsx)(j,{className:`mt-8 h-[400px]`}),(0,V.jsx)(j,{className:`mt-2 h-4`,containerClassName:`block mt-7 mb-4`,count:8,randomize:!0})]}),(0,V.jsx)(`iframe`,{ref:p,id:`gh-ap-article-iframe`,style:{width:`100%`,border:`none`,height:g,overflow:`hidden`,opacity:+!m,transition:`opacity 0.2s ease-in-out`,pointerEvents:f?`none`:`auto`},title:`Embedded Content`})]})})},at=()=>(0,V.jsx)(`div`,{className:`h-px bg-black/[8%] dark:bg-gray-950`}),$=new Map,ot=({postId:e=null,onClose:t})=>{let{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,fontSize:a,handleColorChange:o,setFontStyle:s,increaseFontSize:l,decreaseFontSize:u,resetFontSize:d}=fe(),f=(0,B.useRef)(null),[p,m]=(0,B.useState)(!1),[g,_]=(0,B.useState)(!1),[v,ee]=(0,B.useState)(new Set),[x,S]=(0,B.useState)(new Set),[T,E]=(0,B.useState)(new Set),[k,A]=(0,B.useState)(!1),M=(0,B.useRef)(null),N=(0,B.useRef)(null),{post:ne,processedReplies:P,isLoading:I,loadMoreChildren:L,loadMoreChildReplies:se,hasMoreChildren:R,hasMoreChildReplies:z}=de(e??``,{includeAncestors:!1}),H=ne,U=H?.object,G=H?.actor,he=H?.object?.metadata?.ghostAuthors,ge=U?.replyCount??0;(0,B.useEffect)(()=>{if(!R)return;M.current&&M.current.disconnect();let e=f.current;if(e)return M.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&R&&!k){A(!0);try{await L()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{A(!1)}}},{root:e,rootMargin:`200px`}),N.current&&M.current.observe(N.current),()=>{M.current&&M.current.disconnect()}},[R,k,L]);function K(){}function _e(e){ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),S(t=>{let n=new Set(t);return n.add(e),n})),n})}async function ve(e,t){if(!T.has(e)){E(t=>new Set(t).add(e));try{se&&await se(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{E(t=>{let n=new Set(t);return n.delete(e),n})}}}let ye=()=>{},be=(0,B.useRef)(null),q=`640px`,[xe,Se]=(0,B.useState)(0),[J,Ce]=(0,B.useState)(!0),[Y]=h(Se,100);(0,B.useEffect)(()=>{let e=f.current,t=document.getElementById(`object-content`),n=()=>{if(J||!e||!t)return;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(n.height<=r.height){Y(100);return}let i=Math.max(0,r.top-n.top),a=t.offsetHeight-e.offsetHeight,o=Math.min(Math.max(i/a*100,0),100),s=Math.round(o/1)*1;Y(s)};if(J)return;let r=new MutationObserver(n);return t&&r.observe(t,{childList:!0,subtree:!0,characterData:!0}),e?.addEventListener(`scroll`,n),n(),()=>{e?.removeEventListener(`scroll`,n),r.disconnect()}},[J,Y]);let[X,we]=(0,B.useState)([]),[Te,Ee]=(0,B.useState)(null),[Z,De]=(0,B.useState)(null),Oe=(0,B.useCallback)(e=>{we(e)},[]),ke=(0,B.useCallback)(e=>{De(e)},[]);(0,B.useEffect)(()=>{if(!Z?.contentDocument||!X.length)return;let e=setTimeout(()=>{let e=f.current;if(!e)return;let t=()=>{let t=Z.contentDocument;if(!t||!t.documentElement)return;let n=e.scrollTop,r=X.map(e=>t.getElementById(e.id)).filter(e=>e!==null).map(e=>({element:e,id:e.id,top:e.offsetTop}));if(!r.length)return;let i=null;for(let e of r)if(e.top-100<=n)i=e;else break;Ee(i?.id||null)};return e.addEventListener(`scroll`,t),t(),()=>{e.removeEventListener(`scroll`,t)}},100);return()=>clearTimeout(e)},[Z,X,Te]);let Q=y();return(0,B.useEffect)(()=>{let t=f.current;return()=>{t&&e&&$.set(e,t.scrollTop)}},[e]),(0,B.useEffect)(()=>{if(!J&&!I&&e&&f.current){let t=$.get(e);t!==void 0&&t>0&&setTimeout(()=>{f.current&&(f.current.scrollTop=t)},100)}},[J,I,e]),I?(0,V.jsx)(`div`,{className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,children:(0,V.jsx)(`div`,{className:`flex h-full flex-col`,children:(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(F,{className:W[n].button,onClick:t})}),(0,V.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center gap-3 max-md:hidden`,children:[(0,V.jsx)(j,{className:`size-10 rounded-full`}),(0,V.jsxs)(`div`,{className:`grow pt-1`,children:[(0,V.jsx)(j,{className:`w-full`}),(0,V.jsx)(j,{className:`w-2/3`})]})]}),(0,V.jsx)(`div`,{className:`col-[3/4] flex items-center justify-end gap-2`,children:(0,V.jsx)(pe,{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,onColorChange:o,onDecreaseFontSize:u,onFontStyleChange:s,onIncreaseFontSize:l,onOpenChange:m,onResetFontSize:d})})]})}),(0,V.jsx)(`div`,{className:`relative flex-1 max-lg:px-4`,children:(0,V.jsxs)(`div`,{className:`mx-auto mt-11 w-full max-w-[640px]`,children:[(0,V.jsxs)(`div`,{className:`mb-6 flex flex-col gap-2`,children:[(0,V.jsx)(j,{className:`h-8`}),(0,V.jsx)(j,{className:`h-8 w-full max-w-md`})]}),(0,V.jsx)(j,{className:`mt-2 h-4`,count:4,randomize:!0}),(0,V.jsx)(j,{className:`mt-8 h-[400px]`}),(0,V.jsx)(j,{className:`mt-2 h-4`,containerClassName:`block mt-7 mb-4`,count:8,randomize:!0})]})})]})})}):ne?(0,V.jsx)(`div`,{ref:f,className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,"data-scrollable-container":!0,children:(0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(F,{className:W[n].button,onClick:t})}),(0,V.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center justify-between gap-3 max-md:hidden`,children:[(0,V.jsx)(ae,{actor:G,isCurrentUser:U.authored,children:(0,V.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`relative z-10 pt-0.5`,children:(0,V.jsx)(O,{author:G})}),(0,V.jsxs)(`div`,{className:`relative z-10 mt-0.5 flex min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>D(G,Q,e),children:[(0,V.jsx)(`div`,{className:`flex w-full`,children:(0,V.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap text-black hover:underline dark:text-white`,children:I?(0,V.jsx)(j,{className:`w-20`}):G.name})}),(0,V.jsxs)(`div`,{className:`flex w-full`,children:[!I&&(0,V.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:b(G)}),(0,V.jsx)(`span`,{className:`text-gray-700`,children:I?(0,V.jsx)(j,{className:`w-[120px]`}):c(U,!U.authored)})]})]})]})}),!U.authored&&!I&&(0,V.jsx)(te,{following:G.followedByMe??!1,handle:b(G)})]}),(0,V.jsx)(`div`,{className:`col-[3/4] flex items-center justify-end gap-2`,children:(0,V.jsx)(pe,{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,onColorChange:o,onDecreaseFontSize:u,onFontStyleChange:s,onIncreaseFontSize:l,onOpenChange:m,onResetFontSize:d})})]})}),(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(me,{iframeElement:Z,modalRef:f,tocItems:X,onOpenChange:_}),!I&&(0,V.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,V.jsxs)(`div`,{className:`mx-auto px-6 pt-5 pb-10`,style:{maxWidth:`904px`},children:[(0,V.jsxs)(`div`,{className:`flex flex-col items-center pb-8`,id:`object-content`,children:[(0,V.jsx)(it,{authors:he,backgroundColor:n,excerpt:U.summary??``,fontSize:a,fontStyle:i,heading:U.name,html:U.content??``,image:typeof U.image==`string`?U.image:U.image?.url,isPopoverOpen:p||g,postUrl:U?.url||``,onHeadingsExtracted:Oe,onIframeLoad:ke,onLoadingChange:Ce}),(0,V.jsx)(`div`,{className:`-ml-3 w-full`,style:{maxWidth:q},children:(0,V.jsx)(re,{actor:G,commentCount:ge,layout:`modal`,likeCount:U.likeCount??0,object:U,repostCount:U.repostCount??0,onLikeClick:ye})})]}),U.type===`Tombstone`&&(0,V.jsx)(ue,{last:!0}),(0,V.jsxs)(`div`,{className:`mx-auto w-full border-t border-black/[8%] dark:border-gray-950`,style:{maxWidth:q},children:[(0,V.jsx)(ce,{object:U}),(0,V.jsx)(at,{})]}),I&&(0,V.jsx)(ie,{size:`lg`}),(0,V.jsxs)(`div`,{ref:be,className:`mx-auto w-full`,style:{maxWidth:q},children:[P.map((t,n)=>{let r=n===P.length-1,i=t.mainReply.id,a=v.has(i),o=x.has(i),s=T.has(i),c=t.chain.length>0;return(0,V.jsxs)(B.Fragment,{children:[(0,V.jsx)(w,{actor:t.mainReply.actor,allowDelete:t.mainReply.object.authored,commentCount:t.mainReply.object.replyCount??0,isChainParent:c,isPending:C(t.mainReply.id),last:!c,layout:`reply`,likeCount:t.mainReply.object.likeCount??0,object:t.mainReply.object,parentId:U.id,repostCount:t.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{let n=f.current;n&&e&&$.set(e,n.scrollTop),Q(`/notes/${encodeURIComponent(t.mainReply.id)}`)},onDelete:K}),c&&t.chain[0]&&(0,V.jsx)(w,{actor:t.chain[0].actor,allowDelete:t.chain[0].object.authored,commentCount:t.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:C(t.chain[0].id),last:t.chain.length===1,layout:`reply`,likeCount:t.chain[0].object.likeCount??0,object:t.chain[0].object,parentId:U.id,repostCount:t.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{let n=f.current;n&&e&&$.set(e,n.scrollTop),Q(`/notes/${encodeURIComponent(t.chain[0].id)}`)},onDelete:K},t.chain[0].id),c&&a&&t.chain.slice(1).map((r,i)=>{let a=i===t.chain.slice(1).length-1,o=z&&z(n),s=a&&o;return(0,V.jsx)(w,{actor:r.actor,allowDelete:r.object.authored,commentCount:r.object.replyCount??0,isChainContinuation:!0,isPending:C(r.id),last:a&&!s,layout:`reply`,likeCount:r.object.likeCount??0,object:r.object,parentId:U.id,repostCount:r.object.repostCount??0,type:`Note`,onClick:()=>{let t=f.current;t&&e&&$.set(e,t.scrollTop),Q(`/notes/${encodeURIComponent(r.id)}`)},onDelete:K},r.id)}),c&&t.chain.length>1&&!a&&(0,V.jsx)(le,{variant:`expand`,onClick:()=>_e(i)}),c&&a&&o&&z&&z(n)&&(0,V.jsx)(le,{loading:s,variant:`loadMore`,onClick:()=>ve(i,n)}),!r&&(0,V.jsx)(at,{})]},t.mainReply.id)}),k&&(0,V.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,V.jsx)(ie,{size:`md`})})]}),R&&(0,V.jsx)(`div`,{ref:N,className:`h-1`})]})})]})]}),!I&&(0,V.jsxs)(`div`,{className:`pointer-events-none visible! sticky bottom-0 hidden items-end justify-between px-10 pb-[42px] lg:flex!`,children:[(0,V.jsx)(`div`,{className:`pointer-events-auto text-gray-600`,children:oe(U.content??``)}),(0,V.jsxs)(`div`,{className:`pointer-events-auto min-w-10 text-right text-gray-600 transition-all duration-200 ease-out`,children:[xe,`%`]},xe)]})]})})}):(0,V.jsx)(`div`,{className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,children:(0,V.jsx)(`div`,{className:`flex h-full flex-col`,children:(0,V.jsx)(`div`,{className:`relative flex-1`,children:(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(F,{className:W[n].button,onClick:t})}),(0,V.jsx)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center gap-3 max-md:hidden`,children:(0,V.jsx)(`div`,{className:`grow text-center`,children:(0,V.jsx)(`span`,{children:`Error loading article.`})})})]})})})})})},st=({isLoading:e,activities:t,currentTopic:n,fetchNextPage:r,hasNextPage:o,isFetchingNextPage:c,onTopicChange:d})=>{let m=y(),{canGoBack:h,goBack:g}=a(),[b,x]=(0,B.useState)(!1),S=i(),{topicsQuery:T}=v(),{data:E}=T,te=E&&E.topics.length>0;(0,B.useEffect)(()=>{x(!!S.postId)},[S.postId]);let D=(0,B.useRef)(null),O=(0,B.useRef)(null),k=(0,B.useRef)(null);(0,B.useEffect)(()=>(D.current&&D.current.disconnect(),D.current=new IntersectionObserver(e=>{e[0].isIntersecting&&o&&!c&&r()}),O.current&&D.current.observe(O.current),k.current&&D.current.observe(k.current),()=>{D.current&&D.current.disconnect()}),[o,c,r]);let j=Math.max(0,Math.floor(t.length*.75)-1);return(0,V.jsxs)(u,{children:[te&&(0,V.jsx)(z,{currentTopic:n,excludeTopics:[`top`],onTopicChange:d}),(0,V.jsx)(`div`,{className:`flex w-full flex-col`,children:(0,V.jsx)(`div`,{className:`w-full`,children:t.length>0?(0,V.jsx)(`div`,{className:`my-4`,children:(0,V.jsx)(`div`,{className:`mx-auto flex min-h-[calc(100dvh_-_117px)] items-start gap-11`,children:(0,V.jsx)(`div`,{className:`flex w-full min-w-0 flex-col items-center`,children:(0,V.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-start`,children:[(0,V.jsxs)(`ul`,{className:`mx-auto flex w-full flex-col`,"data-testid":`inbox-list`,children:[t.map((n,r)=>(0,V.jsxs)(`li`,{"data-testid":`inbox-item`,"data-test-view-article":!0,children:[(0,V.jsx)(w,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isLoading:e,isPending:C(n.id),layout:`inbox`,likeCount:n.object.likeCount??0,object:n.object,repostCount:n.object.repostCount??0,type:n.type,onClick:()=>{m(`/reader/${encodeURIComponent(n.id)}`)}}),r<t.length-1&&(0,V.jsx)(ee,{}),r===j&&(0,V.jsx)(`div`,{ref:O,className:`h-1`})]},`${n.id}-${n.type}-${r}`)),c&&(0,V.jsx)(`li`,{className:`flex flex-col items-center justify-center gap-4 text-center`,children:(0,V.jsx)(ie,{size:`md`})})]}),(0,V.jsx)(`div`,{ref:k,className:`h-1`})]})})})}):n===`following`?(0,V.jsx)(`div`,{className:`mt-[24vh]`,children:(0,V.jsx)(s,{actions:te?(0,V.jsx)(_,{onClick:()=>m(`/explore`),children:`Find accounts to follow →`}):(0,V.jsx)(_,{asChild:!0,children:(0,V.jsx)(`a`,{href:`https://explore.ghost.org/social-web`,rel:`noopener noreferrer`,target:`_blank`,children:`Find accounts to follow →`})}),description:`Start following publishers to see their long-form posts here.`,title:`Your Reader is empty`,children:(0,V.jsx)(A,{})})}):(0,V.jsx)(`div`,{className:`mt-[24vh]`,children:(0,V.jsx)(s,{description:`Explore other topics for more content.`,title:`Nothing here yet`,children:(0,V.jsx)(A,{})})})})}),(0,V.jsx)(se,{open:b,onOpenChange:e=>{e||(h?g():m(`/reader`)),x(e)},children:(0,V.jsxs)(p,{className:`inset-y-3 h-[calc(100vh-24px)] w-screen max-w-[calc(100vw-24px)] animate-none! p-0 focus:outline-hidden dark:bg-gray-950`,children:[(0,V.jsxs)(N,{className:`hidden`,children:[(0,V.jsx)(l,{children:`Reader`}),(0,V.jsx)(f,{children:`Ghost reader for long form articles`})]}),S.postId&&(0,V.jsx)(ot,{postId:S.postId,onClose:()=>{h?g():m(`/reader`)}})]})})]})},ct=()=>{let[e,t]=(0,B.useState)(`following`),{inboxQuery:n}=ne({enabled:e===`following`}),{discoveryFeedQuery:r}=S({enabled:e!==`following`,topic:e}),{data:i,error:a,fetchNextPage:o,hasNextPage:s,isFetchingNextPage:c,isLoading:l}=e===`following`?n:r,u=a&&m(a)&&a.statusCode===404&&e!==`following`;return a&&m(a)&&!u?(0,V.jsx)(x,{errorCode:a.code,statusCode:a.statusCode}):(0,V.jsx)(st,{activities:u?[]:i?.pages.flatMap(e=>e.posts)??Array.from({length:5},(e,t)=>({id:`placeholder-${t}`,object:{}})),currentTopic:e,fetchNextPage:o,hasNextPage:s,isFetchingNextPage:c,isLoading:l,onTopicChange:t})};export{ct as default};
|
|
4028
|
+
`;return(0,B.useEffect)(()=>{let e=p.current;if(!e)return;e.srcdoc||=S;let t=t=>{if(t.data.type===`resize`){let n=`${t.data.bodyHeight+24}px`;_(n),e.style.height=n,t.data.isLoaded&&h(!1)}},n=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation();let t=new KeyboardEvent(`keydown`,{key:`Escape`,code:`Escape`,keyCode:27,which:27,bubbles:!0,cancelable:!0});document.dispatchEvent(t)}},r=()=>{let t=e.contentWindow;t&&t.addEventListener(`keydown`,n)};return e.addEventListener(`load`,r),window.addEventListener(`message`,t),()=>{window.removeEventListener(`message`,t),e.removeEventListener(`load`,r);let i=e.contentWindow;i&&i.removeEventListener(`keydown`,n)}},[S]),(0,B.useEffect)(()=>{let e=p.current;if(!e)return;let t=e.contentDocument||e.contentWindow?.document;if(!t)return;let n=t.documentElement;n.style.setProperty(`--font-size`,s),n.classList.remove(`has-sans-body`,`has-serif-body`),n.classList.add(`has-${c}-body`),n.classList.remove(`has-dark-text`,`has-light-text`),n.classList.add(`has-${v?`light`:`dark`}-text`),o===`SEPIA`?n.classList.add(`has-sepia-bg`):n.classList.remove(`has-sepia-bg`);let r=e.contentWindow;if(r&&typeof r.resizeIframe==`function`)r.resizeIframe();else{let e=new Event(`resize`);t.dispatchEvent(e)}},[s,c,o,v]),(0,B.useEffect)(()=>{let e=p.current;if(!e)return;let t=()=>{if(!e.contentDocument)return;let t=Array.from(e.contentDocument.querySelectorAll(`.gh-content > :is(h2, h3, h4, h5, h6)[id]`));if(t.length===0)return;let n=Math.min(...t.map(e=>parseInt(e.tagName[1]))),r=t.map((e,t)=>{let r=`heading-${t}`;e.id=r;let i=parseInt(e.tagName[1])-n+1;return{id:r,text:e.textContent||``,level:i,element:e}});l?.(r),u?.(e)};return e.addEventListener(`load`,t),()=>e.removeEventListener(`load`,t)},[l,u]),(0,B.useEffect)(()=>{d?.(m)},[m,d]),(0,V.jsx)(`div`,{className:`w-full pb-6`,children:(0,V.jsxs)(`div`,{className:`relative -mx-6`,children:[m&&(0,V.jsxs)(`div`,{className:`mx-auto mt-6 w-full max-w-[640px] max-lg:px-4`,children:[(0,V.jsxs)(`div`,{className:`mb-6 flex flex-col gap-2`,children:[(0,V.jsx)(M,{className:`h-8`}),(0,V.jsx)(M,{className:`h-8 w-full max-w-md`})]}),(0,V.jsx)(M,{className:`mt-2 h-4`,count:4,randomize:!0}),(0,V.jsx)(M,{className:`mt-8 h-[400px]`}),(0,V.jsx)(M,{className:`mt-2 h-4`,containerClassName:`block mt-7 mb-4`,count:8,randomize:!0})]}),(0,V.jsx)(`iframe`,{ref:p,id:`gh-ap-article-iframe`,style:{width:`100%`,border:`none`,height:g,overflow:`hidden`,opacity:+!m,transition:`opacity 0.2s ease-in-out`,pointerEvents:f?`none`:`auto`},title:`Embedded Content`})]})})},at=()=>(0,V.jsx)(`div`,{className:`h-px bg-black/[8%] dark:bg-gray-950`}),$=new Map,ot=({postId:e=null,onClose:t})=>{let{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,fontSize:a,handleColorChange:o,setFontStyle:s,increaseFontSize:l,decreaseFontSize:u,resetFontSize:d}=fe(),f=(0,B.useRef)(null),[p,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(!1),[b,x]=(0,B.useState)(new Set),[S,C]=(0,B.useState)(new Set),[E,D]=(0,B.useState)(new Set),[A,j]=(0,B.useState)(!1),N=(0,B.useRef)(null),P=(0,B.useRef)(null),{post:te,processedReplies:F,isLoading:I,loadMoreChildren:L,loadMoreChildReplies:se,hasMoreChildren:R,hasMoreChildReplies:z}=de(e??``,{includeAncestors:!1}),H=te,U=H?.object,G=H?.actor,he=H?.object?.metadata?.ghostAuthors,ge=U?.replyCount??0;(0,B.useEffect)(()=>{if(!R)return;N.current&&N.current.disconnect();let e=f.current;if(e)return N.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&R&&!A){j(!0);try{await L()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{j(!1)}}},{root:e,rootMargin:`200px`}),P.current&&N.current.observe(P.current),()=>{N.current&&N.current.disconnect()}},[R,A,L]);function K(){}function _e(e){x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),C(t=>{let n=new Set(t);return n.add(e),n})),n})}async function ve(e,t){if(!E.has(e)){D(t=>new Set(t).add(e));try{se&&await se(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{D(t=>{let n=new Set(t);return n.delete(e),n})}}}let ye=()=>{},be=(0,B.useRef)(null),q=`640px`,[xe,Se]=(0,B.useState)(0),[J,Ce]=(0,B.useState)(!0),[Y]=m(Se,100);(0,B.useEffect)(()=>{let e=f.current,t=document.getElementById(`object-content`),n=()=>{if(J||!e||!t)return;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(n.height<=r.height){Y(100);return}let i=Math.max(0,r.top-n.top),a=t.offsetHeight-e.offsetHeight,o=Math.min(Math.max(i/a*100,0),100),s=Math.round(o/1)*1;Y(s)};if(J)return;let r=new MutationObserver(n);return t&&r.observe(t,{childList:!0,subtree:!0,characterData:!0}),e?.addEventListener(`scroll`,n),n(),()=>{e?.removeEventListener(`scroll`,n),r.disconnect()}},[J,Y]);let[X,we]=(0,B.useState)([]),[Te,Ee]=(0,B.useState)(null),[Z,De]=(0,B.useState)(null),Oe=(0,B.useCallback)(e=>{we(e)},[]),ke=(0,B.useCallback)(e=>{De(e)},[]);(0,B.useEffect)(()=>{if(!Z?.contentDocument||!X.length)return;let e=setTimeout(()=>{let e=f.current;if(!e)return;let t=()=>{let t=Z.contentDocument;if(!t||!t.documentElement)return;let n=e.scrollTop,r=X.map(e=>t.getElementById(e.id)).filter(e=>e!==null).map(e=>({element:e,id:e.id,top:e.offsetTop}));if(!r.length)return;let i=null;for(let e of r)if(e.top-100<=n)i=e;else break;Ee(i?.id||null)};return e.addEventListener(`scroll`,t),t(),()=>{e.removeEventListener(`scroll`,t)}},100);return()=>clearTimeout(e)},[Z,X,Te]);let Q=v();return(0,B.useEffect)(()=>{let t=f.current;return()=>{t&&e&&$.set(e,t.scrollTop)}},[e]),(0,B.useEffect)(()=>{if(!J&&!I&&e&&f.current){let t=$.get(e);t!==void 0&&t>0&&setTimeout(()=>{f.current&&(f.current.scrollTop=t)},100)}},[J,I,e]),I?(0,V.jsx)(`div`,{className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,children:(0,V.jsx)(`div`,{className:`flex h-full flex-col`,children:(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(re,{className:W[n].button,onClick:t})}),(0,V.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center gap-3 max-md:hidden`,children:[(0,V.jsx)(M,{className:`size-10 rounded-full`}),(0,V.jsxs)(`div`,{className:`grow pt-1`,children:[(0,V.jsx)(M,{className:`w-full`}),(0,V.jsx)(M,{className:`w-2/3`})]})]}),(0,V.jsx)(`div`,{className:`col-[3/4] flex items-center justify-end gap-2`,children:(0,V.jsx)(pe,{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,onColorChange:o,onDecreaseFontSize:u,onFontStyleChange:s,onIncreaseFontSize:l,onOpenChange:h,onResetFontSize:d})})]})}),(0,V.jsx)(`div`,{className:`relative flex-1 max-lg:px-4`,children:(0,V.jsxs)(`div`,{className:`mx-auto mt-11 w-full max-w-[640px]`,children:[(0,V.jsxs)(`div`,{className:`mb-6 flex flex-col gap-2`,children:[(0,V.jsx)(M,{className:`h-8`}),(0,V.jsx)(M,{className:`h-8 w-full max-w-md`})]}),(0,V.jsx)(M,{className:`mt-2 h-4`,count:4,randomize:!0}),(0,V.jsx)(M,{className:`mt-8 h-[400px]`}),(0,V.jsx)(M,{className:`mt-2 h-4`,containerClassName:`block mt-7 mb-4`,count:8,randomize:!0})]})})]})})}):te?(0,V.jsx)(`div`,{ref:f,className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,"data-scrollable-container":!0,children:(0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(re,{className:W[n].button,onClick:t})}),(0,V.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center justify-between gap-3 max-md:hidden`,children:[(0,V.jsx)(ae,{actor:G,isCurrentUser:U.authored,children:(0,V.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`relative z-10 pt-0.5`,children:(0,V.jsx)(k,{author:G})}),(0,V.jsxs)(`div`,{className:`relative z-10 mt-0.5 flex min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>O(G,Q,e),children:[(0,V.jsx)(`div`,{className:`flex w-full`,children:(0,V.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap text-black hover:underline dark:text-white`,children:I?(0,V.jsx)(M,{className:`w-20`}):G.name})}),(0,V.jsxs)(`div`,{className:`flex w-full`,children:[!I&&(0,V.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:y(G)}),(0,V.jsx)(`span`,{className:`text-gray-700`,children:I?(0,V.jsx)(M,{className:`w-[120px]`}):c(U,!U.authored)})]})]})]})}),!U.authored&&!I&&(0,V.jsx)(ee,{following:G.followedByMe??!1,handle:y(G)})]}),(0,V.jsx)(`div`,{className:`col-[3/4] flex items-center justify-end gap-2`,children:(0,V.jsx)(pe,{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,onColorChange:o,onDecreaseFontSize:u,onFontStyleChange:s,onIncreaseFontSize:l,onOpenChange:h,onResetFontSize:d})})]})}),(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(me,{iframeElement:Z,modalRef:f,tocItems:X,onOpenChange:_}),!I&&(0,V.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,V.jsxs)(`div`,{className:`mx-auto px-6 pt-5 pb-10`,style:{maxWidth:`904px`},children:[(0,V.jsxs)(`div`,{className:`flex flex-col items-center pb-8`,id:`object-content`,children:[(0,V.jsx)(it,{authors:he,backgroundColor:n,excerpt:U.summary??``,fontSize:a,fontStyle:i,heading:U.name,html:U.content??``,image:typeof U.image==`string`?U.image:U.image?.url,isPopoverOpen:p||g,postUrl:U?.url||``,onHeadingsExtracted:Oe,onIframeLoad:ke,onLoadingChange:Ce}),(0,V.jsx)(`div`,{className:`-ml-3 w-full`,style:{maxWidth:q},children:(0,V.jsx)(ne,{actor:G,commentCount:ge,layout:`modal`,likeCount:U.likeCount??0,object:U,repostCount:U.repostCount??0,onLikeClick:ye})})]}),U.type===`Tombstone`&&(0,V.jsx)(ue,{last:!0}),(0,V.jsxs)(`div`,{className:`mx-auto w-full border-t border-black/[8%] dark:border-gray-950`,style:{maxWidth:q},children:[(0,V.jsx)(ce,{object:U}),(0,V.jsx)(at,{})]}),I&&(0,V.jsx)(ie,{size:`lg`}),(0,V.jsxs)(`div`,{ref:be,className:`mx-auto w-full`,style:{maxWidth:q},children:[F.map((t,n)=>{let r=n===F.length-1,i=t.mainReply.id,a=b.has(i),o=S.has(i),s=E.has(i),c=t.chain.length>0;return(0,V.jsxs)(B.Fragment,{children:[(0,V.jsx)(T,{actor:t.mainReply.actor,allowDelete:t.mainReply.object.authored,commentCount:t.mainReply.object.replyCount??0,isChainParent:c,isPending:w(t.mainReply.id),last:!c,layout:`reply`,likeCount:t.mainReply.object.likeCount??0,object:t.mainReply.object,parentId:U.id,repostCount:t.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{let n=f.current;n&&e&&$.set(e,n.scrollTop),Q(`/notes/${encodeURIComponent(t.mainReply.id)}`)},onDelete:K}),c&&t.chain[0]&&(0,V.jsx)(T,{actor:t.chain[0].actor,allowDelete:t.chain[0].object.authored,commentCount:t.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:w(t.chain[0].id),last:t.chain.length===1,layout:`reply`,likeCount:t.chain[0].object.likeCount??0,object:t.chain[0].object,parentId:U.id,repostCount:t.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{let n=f.current;n&&e&&$.set(e,n.scrollTop),Q(`/notes/${encodeURIComponent(t.chain[0].id)}`)},onDelete:K},t.chain[0].id),c&&a&&t.chain.slice(1).map((r,i)=>{let a=i===t.chain.slice(1).length-1,o=z&&z(n),s=a&&o;return(0,V.jsx)(T,{actor:r.actor,allowDelete:r.object.authored,commentCount:r.object.replyCount??0,isChainContinuation:!0,isPending:w(r.id),last:a&&!s,layout:`reply`,likeCount:r.object.likeCount??0,object:r.object,parentId:U.id,repostCount:r.object.repostCount??0,type:`Note`,onClick:()=>{let t=f.current;t&&e&&$.set(e,t.scrollTop),Q(`/notes/${encodeURIComponent(r.id)}`)},onDelete:K},r.id)}),c&&t.chain.length>1&&!a&&(0,V.jsx)(le,{variant:`expand`,onClick:()=>_e(i)}),c&&a&&o&&z&&z(n)&&(0,V.jsx)(le,{loading:s,variant:`loadMore`,onClick:()=>ve(i,n)}),!r&&(0,V.jsx)(at,{})]},t.mainReply.id)}),A&&(0,V.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,V.jsx)(ie,{size:`md`})})]}),R&&(0,V.jsx)(`div`,{ref:P,className:`h-1`})]})})]})]}),!I&&(0,V.jsxs)(`div`,{className:`pointer-events-none visible! sticky bottom-0 hidden items-end justify-between px-10 pb-[42px] lg:flex!`,children:[(0,V.jsx)(`div`,{className:`pointer-events-auto text-gray-600`,children:oe(U.content??``)}),(0,V.jsxs)(`div`,{className:`pointer-events-auto min-w-10 text-right text-gray-600 transition-all duration-200 ease-out`,children:[xe,`%`]},xe)]})]})})}):(0,V.jsx)(`div`,{className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,children:(0,V.jsx)(`div`,{className:`flex h-full flex-col`,children:(0,V.jsx)(`div`,{className:`relative flex-1`,children:(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(re,{className:W[n].button,onClick:t})}),(0,V.jsx)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center gap-3 max-md:hidden`,children:(0,V.jsx)(`div`,{className:`grow text-center`,children:(0,V.jsx)(`span`,{children:`Error loading article.`})})})]})})})})})},st=({isLoading:e,activities:t,currentTopic:n,fetchNextPage:r,hasNextPage:o,isFetchingNextPage:c,onTopicChange:p})=>{let m=v(),{canGoBack:y,goBack:b}=a(),[x,S]=(0,B.useState)(!1),C=i(),{topicsQuery:E}=g(),{data:D}=E,ee=D&&D.topics.length>0;(0,B.useEffect)(()=>{S(!!C.postId)},[C.postId]);let O=(0,B.useRef)(null),k=(0,B.useRef)(null),j=(0,B.useRef)(null);(0,B.useEffect)(()=>(O.current&&O.current.disconnect(),O.current=new IntersectionObserver(e=>{e[0].isIntersecting&&o&&!c&&r()}),k.current&&O.current.observe(k.current),j.current&&O.current.observe(j.current),()=>{O.current&&O.current.disconnect()}),[o,c,r]);let M=Math.max(0,Math.floor(t.length*.75)-1);return(0,V.jsxs)(u,{children:[ee&&(0,V.jsx)(z,{currentTopic:n,excludeTopics:[`top`],onTopicChange:p}),(0,V.jsx)(`div`,{className:`flex w-full flex-col`,children:(0,V.jsx)(`div`,{className:`w-full`,children:t.length>0?(0,V.jsx)(`div`,{className:`my-4`,children:(0,V.jsx)(`div`,{className:`mx-auto flex min-h-[calc(100dvh_-_117px)] items-start gap-11`,children:(0,V.jsx)(`div`,{className:`flex w-full min-w-0 flex-col items-center`,children:(0,V.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-start`,children:[(0,V.jsxs)(`ul`,{className:`mx-auto flex w-full flex-col`,"data-testid":`inbox-list`,children:[t.map((n,r)=>(0,V.jsxs)(`li`,{"data-testid":`inbox-item`,"data-test-view-article":!0,children:[(0,V.jsx)(T,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isLoading:e,isPending:w(n.id),layout:`inbox`,likeCount:n.object.likeCount??0,object:n.object,repostCount:n.object.repostCount??0,type:n.type,onClick:()=>{m(`/reader/${encodeURIComponent(n.id)}`)}}),r<t.length-1&&(0,V.jsx)(_,{}),r===M&&(0,V.jsx)(`div`,{ref:k,className:`h-1`})]},`${n.id}-${n.type}-${r}`)),c&&(0,V.jsx)(`li`,{className:`flex flex-col items-center justify-center gap-4 text-center`,children:(0,V.jsx)(ie,{size:`md`})})]}),(0,V.jsx)(`div`,{ref:j,className:`h-1`})]})})})}):n===`following`?(0,V.jsx)(`div`,{className:`mt-[24vh]`,children:(0,V.jsx)(s,{actions:ee?(0,V.jsx)(h,{onClick:()=>m(`/explore`),children:`Find accounts to follow →`}):(0,V.jsx)(h,{asChild:!0,children:(0,V.jsx)(`a`,{href:`https://explore.ghost.org/social-web`,rel:`noopener noreferrer`,target:`_blank`,children:`Find accounts to follow →`})}),description:`Start following publishers to see their long-form posts here.`,title:`Your Reader is empty`,children:(0,V.jsx)(A,{})})}):(0,V.jsx)(`div`,{className:`mt-[24vh]`,children:(0,V.jsx)(s,{description:`Explore other topics for more content.`,title:`Nothing here yet`,children:(0,V.jsx)(A,{})})})})}),(0,V.jsx)(se,{open:x,onOpenChange:e=>{e||(y?b():m(`/reader`)),S(e)},children:(0,V.jsxs)(f,{className:`inset-y-3 h-[calc(100vh-24px)] w-screen max-w-[calc(100vw-24px)] animate-none! p-0 focus:outline-hidden dark:bg-gray-950`,children:[(0,V.jsxs)(P,{className:`hidden`,children:[(0,V.jsx)(l,{children:`Reader`}),(0,V.jsx)(d,{children:`Ghost reader for long form articles`})]}),C.postId&&(0,V.jsx)(ot,{postId:C.postId,onClose:()=>{y?b():m(`/reader`)}})]})})]})},ct=()=>{let[e,t]=(0,B.useState)(`following`),{inboxQuery:n}=te({enabled:e===`following`}),{discoveryFeedQuery:r}=S({enabled:e!==`following`,topic:e}),{data:i,error:a,fetchNextPage:o,hasNextPage:s,isFetchingNextPage:c,isLoading:l}=e===`following`?n:r,u=a&&p(a)&&a.statusCode===404&&e!==`following`;return a&&p(a)&&!u?(0,V.jsx)(b,{errorCode:a.code,statusCode:a.statusCode}):(0,V.jsx)(st,{activities:u?[]:i?.pages.flatMap(e=>e.posts)??Array.from({length:5},(e,t)=>({id:`placeholder-${t}`,object:{}})),currentTopic:e,fetchNextPage:o,hasNextPage:s,isFetchingNextPage:c,isLoading:l,onTopicChange:t})};export{ct as default};
|