ghost 6.55.0 → 6.57.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.
Files changed (483) hide show
  1. package/bin/validate-adapters.js +74 -0
  2. package/bin/validate-adapters.ts +87 -0
  3. package/bin/warm-compile-cache.sh +60 -0
  4. package/components/tryghost-custom-field-types-0.0.0.tgz +0 -0
  5. package/components/tryghost-kg-default-cards-10.3.3.tgz +0 -0
  6. package/components/tryghost-kg-default-nodes-2.1.4.tgz +0 -0
  7. package/components/tryghost-kg-default-transforms-1.3.3.tgz +0 -0
  8. package/components/tryghost-kg-html-to-lexical-1.3.3.tgz +0 -0
  9. package/components/tryghost-kg-lexical-html-renderer-1.4.3.tgz +0 -0
  10. package/components/tryghost-nql-string-0.0.0.tgz +0 -0
  11. package/components/tryghost-parse-email-address-0.0.0.tgz +0 -0
  12. package/core/app.js +1 -1
  13. package/core/boot.js +21 -25
  14. package/core/bridge.js +10 -12
  15. package/core/built/admin/assets/Combination-BDvCdg1t.js +41 -0
  16. package/core/built/admin/assets/{PolarAngleAxis-BGjf7sBu.js → PolarAngleAxis-C4qtHy1B.js} +1 -1
  17. package/core/built/admin/assets/{RadialBarChart-zeFf9mBz.js → RadialBarChart-Bh09Stsj.js} +1 -1
  18. package/core/built/admin/assets/about-C7O-AgRZ.js +1 -0
  19. package/core/built/admin/assets/{account-migration-sjHLx5dy.js → account-migration-Cv_ol1ko.js} +1 -1
  20. package/core/built/admin/assets/action-list-lGzZLHc8.js +1 -0
  21. package/core/built/admin/assets/activitypub/{account-migration-DoYXtnZ8.js → account-migration-DHFbePl6.js} +7 -7
  22. package/core/built/admin/assets/activitypub/activitypub.js +6 -6
  23. package/core/built/admin/assets/activitypub/{avatar-B3DEDB1l.js → avatar-CT4tS2_S.js} +2 -2
  24. package/core/built/admin/assets/activitypub/{avatar-flipboard-Cqrg0XMx.js → avatar-flipboard-ByYWKipo.js} +2 -2
  25. package/core/built/admin/assets/activitypub/{bluesky-sharing-Bxeh6MKW.js → bluesky-sharing-srVnSHDz.js} +16 -16
  26. package/core/built/admin/assets/activitypub/{content-formatters-BpQARh28.js → content-formatters-C2sos5Ht.js} +3 -3
  27. package/core/built/admin/assets/activitypub/{copy-D9UWIAan.js → copy-B1UBTOoZ.js} +2 -2
  28. package/core/built/admin/assets/activitypub/{dist-D8sFfdpC.js → dist-MPsb2WZ1.js} +12 -12
  29. package/core/built/admin/assets/activitypub/{domain-CWueFW6q.js → domain-DzcM9Dzo.js} +9 -9
  30. package/core/built/admin/assets/activitypub/{edit-profile-BGxPU7N5.js → edit-profile-CsQ_4xAk.js} +945 -945
  31. package/core/built/admin/assets/activitypub/{explore-DBK-u0Ch.js → explore-CJe0DZBK.js} +8 -8
  32. package/core/built/admin/assets/activitypub/{feed-Bcir5RQZ.js → feed-CKV3qWON.js} +33 -33
  33. package/core/built/admin/assets/activitypub/{field-BV-CIT3d.js → field-DckHfDJf.js} +3 -3
  34. package/core/built/admin/assets/activitypub/{hash-BC9Q0N4c.js → hash-Dlp8RM55.js} +2 -2
  35. package/core/built/admin/assets/activitypub/{inbox-DQ4ZnC1m.js → inbox-CsPy4R0M.js} +2 -2
  36. package/core/built/admin/assets/activitypub/{inbox-yC0nfvzl.js → inbox-DAsjzUUe.js} +85 -85
  37. package/core/built/admin/assets/activitypub/{label-DTRS9TDk.js → label-DWyo9E5T.js} +3 -3
  38. package/core/built/admin/assets/activitypub/layout-DM_3pqsU.js +1 -0
  39. package/core/built/admin/assets/activitypub/{moderation-Dwl9t0pb.js → moderation-B0Inc03M.js} +11 -11
  40. package/core/built/admin/assets/activitypub/{note-B-zKsZ7r.js → note-CSE54lER.js} +7 -7
  41. package/core/built/admin/assets/activitypub/{notifications-DjJZD54t.js → notifications-RSwbKqdh.js} +9 -9
  42. package/core/built/admin/assets/activitypub/{preferences-CoU8vs6d.js → preferences-CE231n2_.js} +20 -20
  43. package/core/built/admin/assets/activitypub/{profile-BAsaJekx.js → profile-aaQ1j1Eo.js} +237 -237
  44. package/core/built/admin/assets/activitypub/{reply-CpdMeAO5.js → reply-Cjb0Vs3m.js} +2 -2
  45. package/core/built/admin/assets/activitypub/{routes-CLH3OVTP.js → routes-Djb0mc9k.js} +1139 -1150
  46. package/core/built/admin/assets/activitypub/{separator-BI1FLsYM.js → separator-D8pROI5n.js} +3 -3
  47. package/core/built/admin/assets/activitypub/{settings-DA6pNJ-Q.js → settings-DMc32IQl.js} +13 -13
  48. package/core/built/admin/assets/activitypub/{site-CQD42Pw5.js → site-DVIcsohX.js} +81 -81
  49. package/core/built/admin/assets/activitypub/{step-1-DIDg4aHb.js → step-1-9Yey9usF.js} +5 -5
  50. package/core/built/admin/assets/activitypub/{step-2-BfGe8BYt.js → step-2-DdYmKRXV.js} +6 -6
  51. package/core/built/admin/assets/activitypub/{step-3-mE9spAqw.js → step-3-hdSkcjZU.js} +10 -10
  52. package/core/built/admin/assets/activitypub/{tabs-Cg0saow1.js → tabs-CUqseYzQ.js} +317 -315
  53. package/core/built/admin/assets/activitypub/{topic-filter-DLHBZT93.js → topic-filter-Coni6OXM.js} +3 -3
  54. package/core/built/admin/assets/activitypub/{use-activity-pub-queries-VzbN99u_.js → use-activity-pub-queries-MeHTPMQv.js} +2 -2
  55. package/core/built/admin/assets/activitypub/{use-navigate-with-base-path-CAwXTmqH.js → use-navigate-with-base-path-B046AM38.js} +115 -96
  56. package/core/built/admin/assets/activitypub/{use-reply-chain-data-Br4aOWOh.js → use-reply-chain-data-1AO-Xob6.js} +5 -5
  57. package/core/built/admin/assets/activitypub/{x-C8tAnXly.js → x-BRfRYd16.js} +2 -2
  58. package/core/built/admin/assets/add-integration-modal-m9Dv6f77.js +1 -0
  59. package/core/built/admin/assets/add-newsletter-modal-CPSVZL2H.js +1 -0
  60. package/core/built/admin/assets/add-recommendation-modal-Ci9Z5yat.js +1 -0
  61. package/core/built/admin/assets/analytics-DqSCVV8U.js +1 -0
  62. package/core/built/admin/assets/announcement-bar-modal-DU3avV7d.js +1 -0
  63. package/core/built/admin/assets/api-keys-BK0LylyK.js +1 -0
  64. package/core/built/admin/assets/api-keys-_iCT4dxr.js +1 -0
  65. package/core/built/admin/assets/{audience-DjEWNhp3.js → audience-DTJtXXWY.js} +1 -1
  66. package/core/built/admin/assets/automated-emails-PayPCT8L.js +1 -0
  67. package/core/built/admin/assets/{automations-DhKeS_U5.js → automations-162q5HjL.js} +1 -1
  68. package/core/built/admin/assets/{automations-Bx3VcFIL.js → automations-dtQ_MRZ7.js} +1 -1
  69. package/core/built/admin/assets/{bluesky-sharing-ClMd0-Ft.js → bluesky-sharing-B8Es3AuV.js} +1 -1
  70. package/core/built/admin/assets/{box-BWbhXh21.js → box-By_EgGtm.js} +1 -1
  71. package/core/built/admin/assets/brand-icon-09YqFZjV.js +1 -0
  72. package/core/built/admin/assets/{breadcrumb-BD0U2ygg.js → breadcrumb-tg5zL--z.js} +1 -1
  73. package/core/built/admin/assets/build-CsiH26uS.js +1 -0
  74. package/core/built/admin/assets/{card-DGoDJzrn.js → card-aUHX0hyR.js} +1 -1
  75. package/core/built/admin/assets/{chart-BuRT2Y6p.js → chart-BnXyfH11.js} +1 -1
  76. package/core/built/admin/assets/{chart-helpers-fjQKRVyY.js → chart-helpers-CZElTGYL.js} +1 -1
  77. package/core/built/admin/assets/checkbox-Cyo-x7mC.js +1 -0
  78. package/core/built/admin/assets/chunk.524.cd5498dd4e195f679266.js +25 -0
  79. package/core/built/admin/assets/chunk.582.6f92ec1f03734bf2ea3f.js +27 -0
  80. package/core/built/admin/assets/{chunk.481.6c7395a49484bb4583aa.js → chunk.873.b8fc05a8ab877fb819ed.js} +62 -60
  81. package/core/built/admin/assets/code-editor-view-Dq1rQ4tS.js +1 -0
  82. package/core/built/admin/assets/color-picker-field-BonBgxhU.js +1 -0
  83. package/core/built/admin/assets/color-utils-BsrwXuDz.js +1 -0
  84. package/core/built/admin/assets/combobox-uX5r_paI.js +1 -0
  85. package/core/built/admin/assets/command-DxwBO2pF.js +1 -0
  86. package/core/built/admin/assets/comments-Dn-RO-nU.js +1 -0
  87. package/core/built/admin/assets/components-CwL6a6As-B0E0-NBJ.js +1 -0
  88. package/core/built/admin/assets/confirmation-modal-B6D6mk6R.js +1 -0
  89. package/core/built/admin/assets/{container-BYz2Ed39.js → container-LiZf3XdY.js} +1 -1
  90. package/core/built/admin/assets/content-api-modal-BxQ-7T6u.js +1 -0
  91. package/core/built/admin/assets/copy-field-BAxL4Zqn.js +1 -0
  92. package/core/built/admin/assets/currency-Dy4Tc2R2.js +1 -0
  93. package/core/built/admin/assets/custom-integration-modal---d_l7lc.js +1 -0
  94. package/core/built/admin/assets/{data-list-16rkJYYi.js → data-list-CupF7bjM.js} +1 -1
  95. package/core/built/admin/assets/{date-range-select-BFp58EMk.js → date-range-select-PB2n1HZf.js} +1 -1
  96. package/core/built/admin/assets/debounce-Dg2fW5Rg.js +3 -0
  97. package/core/built/admin/assets/design-and-theme-modal-DYRT207a.js +23 -0
  98. package/core/built/admin/assets/dirty-confirm-dialog-BnDJ39ao.js +1 -0
  99. package/core/built/admin/assets/disabled-sources-indicator-iMHrkyV3.js +1 -0
  100. package/core/built/admin/assets/dist-B2PvRwLn.js +1 -0
  101. package/core/built/admin/assets/{dist-DGzPJ_bO.js → dist-Cb5RSHSg.js} +1 -1
  102. package/core/built/admin/assets/{dist-P_ohUlTi.js → dist-CqO2lWS02.js} +1 -1
  103. package/core/built/admin/assets/{dist-pHiOxyxa.js → dist-D5vhMdXf.js} +1 -1
  104. package/core/built/admin/assets/dist-DlCyLrOC.js +1 -0
  105. package/core/built/admin/assets/dist-WeOIvSYM.js +23 -0
  106. package/core/built/admin/assets/{dist-DyViJwIy.js → dist-cFzKLG7y.js} +3 -3
  107. package/core/built/admin/assets/dist-j1xxxnY8.js +1 -0
  108. package/core/built/admin/assets/dist-myQaY0ka.js +1 -0
  109. package/core/built/admin/assets/domain-BR8FIdjD.js +1 -0
  110. package/core/built/admin/assets/{dropzone-DlK-K2DQ.js → dropzone-hNxmUvwD.js} +1 -1
  111. package/core/built/admin/assets/{edit-profile-BKT-REJw.js → edit-profile-CENrkY0l.js} +1 -1
  112. package/core/built/admin/assets/editor-B18D0lm8.js +8 -0
  113. package/core/built/admin/assets/embed-signup-form-modal-BsCYUMvQ.js +9 -0
  114. package/core/built/admin/assets/{empty-indicator-oX1u1Pkn.js → empty-indicator-WB1WgT9h.js} +1 -1
  115. package/core/built/admin/assets/{explore-ClUpJZOp.js → explore-BmrnljWw.js} +1 -1
  116. package/core/built/admin/assets/{feed-DF92dUMP.js → feed-Dy4li6i8.js} +1 -1
  117. package/core/built/admin/assets/{field-Do7lieBA.js → field-Dh_lwk13.js} +1 -1
  118. package/core/built/admin/assets/filter-sources-D2zDuJH5.js +1 -0
  119. package/core/built/admin/assets/filters-3JBQcNtJ.js +1 -0
  120. package/core/built/admin/assets/filters-CFt_BDe4.js +1 -0
  121. package/core/built/admin/assets/first-promoter-modal-D6Rjxugw.js +1 -0
  122. package/core/built/admin/assets/format-url-C-t8G6Qd.js +1 -0
  123. package/core/built/admin/assets/{ghost-a9c788f6f0b1ea6cf0f14ca4b13f4496.css → ghost-d38c30b866e59f2e06a357b5eb844fe5.css} +1 -1
  124. package/core/built/admin/assets/{ghost-c4057474943effc568c5659ccc4909d7.js → ghost-d683fbeb945b13155ea669caa5d8db41.js} +420 -398
  125. package/core/built/admin/assets/{ghost-dark-db36d795d21c61426837df40af270966.css → ghost-dark-1bffd5099ba7a749303133efacf8480b.css} +1 -1
  126. package/core/built/admin/assets/{gift-link-modal-f9VIMNDv.js → gift-link-modal-zMtlJhLQ.js} +1 -1
  127. package/core/built/admin/assets/{gift-links-CsUhefWG.js → gift-links-CVuqLhsZ.js} +1 -1
  128. package/core/built/admin/assets/global-data-provider-B949LDXJ.js +1 -0
  129. package/core/built/admin/assets/grid-CUciBfjf.js +1 -0
  130. package/core/built/admin/assets/{growth-CVw1My4S.js → growth-C38Xtp8D.js} +2 -2
  131. package/core/built/admin/assets/{growth-B3I6gNLm.js → growth-CFws67_i.js} +1 -1
  132. package/core/built/admin/assets/history-modal-ILAOkbxH.js +1 -0
  133. package/core/built/admin/assets/{hooks-CixO01lL.js → hooks-D6EE7BIt.js} +2 -2
  134. package/core/built/admin/assets/html-field-9a9Id_2q.js +1 -0
  135. package/core/built/admin/assets/iframe-buffering-e8vH4-Qn.js +1 -0
  136. package/core/built/admin/assets/images-CrQKVc9Q.js +1 -0
  137. package/core/built/admin/assets/{inbox-CFBSu4Ed.js → inbox-BrSRzyvz.js} +6 -6
  138. package/core/built/admin/assets/index-BHy2DZX-.js +67 -0
  139. package/core/built/admin/assets/index-Ds2iUoF6.css +1 -0
  140. package/core/built/admin/assets/index.es-B9tvf-t4.js +1 -0
  141. package/core/built/admin/assets/{inline-EMAm3okk.js → inline-Cw-gigDW.js} +1 -1
  142. package/core/built/admin/assets/input-group-6vEPvX9S.js +1 -0
  143. package/core/built/admin/assets/{input-surface-BpAjZXY5.js → input-surface-BdOe4KzO.js} +1 -1
  144. package/core/built/admin/assets/integration-header-B4DyXV06.js +1 -0
  145. package/core/built/admin/assets/integrations-BT6_iJvu.js +1 -0
  146. package/core/built/admin/assets/invite-user-modal-5xDCEw90.js +1 -0
  147. package/core/built/admin/assets/isEmail-BOfC647y.js +1 -0
  148. package/core/built/admin/assets/koenig-editor-base-BWLEB9Vf.js +1 -0
  149. package/core/built/admin/assets/koenig-lexical/koenig-lexical.js +9535 -9527
  150. package/core/built/admin/assets/koenig-lexical/koenig-lexical.umd.js +124 -124
  151. package/core/built/admin/assets/{koenig-lexical-f8vHRYvz.js → koenig-lexical-Cj62r_y9.js} +86 -86
  152. package/core/built/admin/assets/{kpi-card-DSap9rAy.js → kpi-card-DOUnkZcN.js} +1 -1
  153. package/core/built/admin/assets/{kpi-card-DU0rn9Cj.js → kpi-card-IHDo8Q56.js} +1 -1
  154. package/core/built/admin/assets/{kpi-helpers-Dz33AV6h.js → kpi-helpers-CjUdECAK.js} +1 -1
  155. package/core/built/admin/assets/{kpi-tabs-BtTTrKvJ.js → kpi-tabs-X3DkOYbI.js} +1 -1
  156. package/core/built/admin/assets/{label-DS8Mi6G5.js → label-Dq6QaOuS.js} +1 -1
  157. package/core/built/admin/assets/label-picker-8YlhS2U3.js +1 -0
  158. package/core/built/admin/assets/labels-DAPjKPy2.js +1 -0
  159. package/core/built/admin/assets/layout-TMj4P-vv.js +1 -0
  160. package/core/built/admin/assets/limit-modal-BRPsit_B.js +1 -0
  161. package/core/built/admin/assets/link-helpers-Bzkk68GD.js +1 -0
  162. package/core/built/admin/assets/{list-page-B6ANtzkd.js → list-page-CdsnQR9N.js} +1 -1
  163. package/core/built/admin/assets/member-custom-fields-CmvsuuV_.js +1 -0
  164. package/core/built/admin/assets/member-detail-DCvRrkmJ.js +1 -0
  165. package/core/built/admin/assets/members-DxbSKngD.js +11 -0
  166. package/core/built/admin/assets/modal-page-BMTzFHVO.js +1 -0
  167. package/core/built/admin/assets/{moderation-DySbgyUS.js → moderation-Da5lhhWh.js} +1 -1
  168. package/core/built/admin/assets/multi-select-combobox-CYdkH7KQ.js +1 -0
  169. package/core/built/admin/assets/navigation-modal-BIoTwtMy.js +1 -0
  170. package/core/built/admin/assets/newsletter-BptlVoJm.js +1 -0
  171. package/core/built/admin/assets/newsletter-detail-modal-BIvxqE0N.js +1 -0
  172. package/core/built/admin/assets/newsletter-emails-Bf8IZLsP.js +1 -0
  173. package/core/built/admin/assets/newsletters-BgrIZk0V.js +1 -0
  174. package/core/built/admin/assets/{newsletters-BXJbJgA-.js → newsletters-Du0lzskS.js} +1 -1
  175. package/core/built/admin/assets/{note-C8kxrz6w.js → note-DYcLOmDb.js} +1 -1
  176. package/core/built/admin/assets/{notifications-CgtSfX7t.js → notifications-B2SPFIV9.js} +1 -1
  177. package/core/built/admin/assets/{offers-DEniVRD5.js → offers-Um6ab71O.js} +1 -1
  178. package/core/built/admin/assets/offers-container-modal-BZnZITMw.js +1 -0
  179. package/core/built/admin/assets/{onboarding-route-4qtziA9d.js → onboarding-route-DgdfxkQh.js} +1 -1
  180. package/core/built/admin/assets/overview-BYQJXSog.js +1 -0
  181. package/core/built/admin/assets/overview-Dt2_mR6U.js +1 -0
  182. package/core/built/admin/assets/{page-header-B3Wb9Jqv.js → page-header-CpmxJj5B.js} +1 -1
  183. package/core/built/admin/assets/{pages-B4goRPUn.js → pages-BVMnpI2O.js} +1 -1
  184. package/core/built/admin/assets/pintura-modal-B4MuBuuO.js +1 -0
  185. package/core/built/admin/assets/portal-frame-BF0NBIji.js +1 -0
  186. package/core/built/admin/assets/portal-modal-DMVbm0oy.js +1 -0
  187. package/core/built/admin/assets/{post-analytics-We-ko5Cb.js → post-analytics-CXWBOGyP.js} +1 -1
  188. package/core/built/admin/assets/post-analytics-header-ChzjXVPt.js +1 -0
  189. package/core/built/admin/assets/{post-analytics-provider-B6UynTGb.js → post-analytics-provider-Cgw4U_fw.js} +1 -1
  190. package/core/built/admin/assets/{post-share-modal-DFfO93_0.js → post-share-modal-B9Vmk_XM.js} +1 -1
  191. package/core/built/admin/assets/{posts-DhXE7b6r.js → posts-CxG7v0-M.js} +1 -1
  192. package/core/built/admin/assets/preferences-BfzJmnsd.js +5 -0
  193. package/core/built/admin/assets/preview-chrome-BOVO6_PE.js +1 -0
  194. package/core/built/admin/assets/preview-modal-Dw_HtD6S.js +1 -0
  195. package/core/built/admin/assets/profile-BT5vtv9b.js +1 -0
  196. package/core/built/admin/assets/radio-group-I7ou7PoJ.js +1 -0
  197. package/core/built/admin/assets/{referrers-pmJT4k3-.js → referrers-B9QDAfYm.js} +1 -1
  198. package/core/built/admin/assets/{router-provider-C1R4AZ2o.js → router-provider-DSQfprxH.js} +1 -1
  199. package/core/built/admin/assets/select-D9oU1IoM.js +1 -0
  200. package/core/built/admin/assets/settings-CfZFbyu_.js +4 -0
  201. package/core/built/admin/assets/{settings-WXNeWyU1.js → settings-CpvHWix7.js} +1 -1
  202. package/core/built/admin/assets/settings-breadcrumbs-K0USP2nw.js +1 -0
  203. package/core/built/admin/assets/{shade-app-B3heOAfz-CGXQwWeO.js → shade-app-B3heOAfz-BhQXxNkT.js} +1 -1
  204. package/core/built/admin/assets/{share-modal-DsgW3wbg.js → share-modal-ClIyPzc5.js} +1 -1
  205. package/core/built/admin/assets/slack-modal-1XXqOfiw.js +1 -0
  206. package/core/built/admin/assets/social-urls-CHQ9cTAK.js +1 -0
  207. package/core/built/admin/assets/{sort-button-Bb_FCl7e.js → sort-button-CdBsm40v.js} +1 -1
  208. package/core/built/admin/assets/{source-icon-BeaRxUn9.js → source-icon-CEYmVLXR.js} +1 -1
  209. package/core/built/admin/assets/{stack-xiN0eQ6Z.js → stack-CIfOAAVf.js} +1 -1
  210. package/core/built/admin/assets/{stats-Bjj_kmJ1.js → stats-D8nZCTy5.js} +1 -1
  211. package/core/built/admin/assets/{stats-view-BxPbW6K1.js → stats-view-CugFVf0g.js} +1 -1
  212. package/core/built/admin/assets/{step-1-B1e3-1F8.js → step-1-DOYjrORn.js} +1 -1
  213. package/core/built/admin/assets/{step-2-C5WaeBJo.js → step-2-vA6RsarH.js} +1 -1
  214. package/core/built/admin/assets/{step-3-B46iVPwu.js → step-3-BtIBxMId.js} +2 -2
  215. package/core/built/admin/assets/stripe-button-UFP4QRXd.js +1 -0
  216. package/core/built/admin/assets/stripe-connect-modal-C_L3uM6n.js +1 -0
  217. package/core/built/admin/assets/switch-CE2NuMn-.js +1 -0
  218. package/core/built/admin/assets/{table-CB-4_HBJ.js → table-TMCgCQK7.js} +1 -1
  219. package/core/built/admin/assets/tabs-Dd6oOKbv.js +1 -0
  220. package/core/built/admin/assets/tag-detail-D3l-UJPR.js +1 -0
  221. package/core/built/admin/assets/tags-BwCgmr5v.js +1 -0
  222. package/core/built/admin/assets/tags-WdKQGWR8.js +1 -0
  223. package/core/built/admin/assets/testimonials-modal-CqWp-xXJ.js +1 -0
  224. package/core/built/admin/assets/{text-DwtjwGkh.js → text-DU9Hv33_.js} +1 -1
  225. package/core/built/admin/assets/textarea-d9qEkMOP.js +1 -0
  226. package/core/built/admin/assets/tier-detail-modal-BkcR2u0A.js +1 -0
  227. package/core/built/admin/assets/{tiers-DYsa4DCo.js → tiers-Da6kxHQP.js} +1 -1
  228. package/core/built/admin/assets/toggle-group-Guorw93z.js +1 -0
  229. package/core/built/admin/assets/{topic-filter-DAFT87tQ.js → topic-filter-CbgoWIHn.js} +1 -1
  230. package/core/built/admin/assets/transistor-modal-DuNnnpal.js +1 -0
  231. package/core/built/admin/assets/unsplash-modal-y2bVwTHH.js +1 -0
  232. package/core/built/admin/assets/{use-analytics-data-S0FTd43s.js → use-analytics-data-B-b4wNSC.js} +1 -1
  233. package/core/built/admin/assets/use-check-theme-limit-error-m09J38Mq.js +2 -0
  234. package/core/built/admin/assets/use-feature-flag-ud0Qz8vt.js +1 -0
  235. package/core/built/admin/assets/{use-filter-params-Gpoq2E1L.js → use-filter-params-BnbBDc7T.js} +1 -1
  236. package/core/built/admin/assets/use-filterable-api-iMpDZBxD.js +1 -0
  237. package/core/built/admin/assets/use-form-vRjI0Kwk.js +1 -0
  238. package/core/built/admin/assets/{use-growth-stats-CIaiHOVb.js → use-growth-stats-DPU5rt3W.js} +1 -1
  239. package/core/built/admin/assets/use-hash-link-navigation-guard-B9j6HIrV.js +1 -0
  240. package/core/built/admin/assets/use-limiter-BkN3E4gw.js +2 -0
  241. package/core/built/admin/assets/use-pintura-config-C_z8HTG2.js +1 -0
  242. package/core/built/admin/assets/use-pintura-editor-DNgbkhGp.js +1 -0
  243. package/core/built/admin/assets/{use-post-referrers-Cq2vBPrA.js → use-post-referrers-C2mXyrp-.js} +1 -1
  244. package/core/built/admin/assets/use-query-params-DHhhu8wi.js +1 -0
  245. package/core/built/admin/assets/{use-reply-chain-data-DBDRtGu-.js → use-reply-chain-data-DaK8q2qQ.js} +1 -1
  246. package/core/built/admin/assets/use-setting-group-YlYcoNyP.js +1 -0
  247. package/core/built/admin/assets/use-settings-navigation-Bf1g1rEh.js +1 -0
  248. package/core/built/admin/assets/{use-simple-pagination-CjYNxdwe.js → use-simple-pagination-D9ckKo5-.js} +1 -1
  249. package/core/built/admin/assets/{use-tinybird-query-falHAtuK.js → use-tinybird-query-GSa32hVw.js} +1 -1
  250. package/core/built/admin/assets/{use-tinybird-token-D7-8ND1y.js → use-tinybird-token-CKLOZFsw.js} +1 -1
  251. package/core/built/admin/assets/use-url-input-z-p0Kewm.js +5 -0
  252. package/core/built/admin/assets/user-detail-modal-BMxOA4Sv.js +1 -0
  253. package/core/built/admin/assets/{users-Dkv8NQZe.js → users-B6hIds6n.js} +1 -1
  254. package/core/built/admin/assets/validator-Cr0sMKuW.js +7 -0
  255. package/core/built/admin/assets/{virtual-list-CvnC9zF2.js → virtual-list-RHeEL05L.js} +1 -1
  256. package/core/built/admin/assets/{web-jFYWCKDn.js → web-Bw2QMO5u.js} +2 -2
  257. package/core/built/admin/assets/web-xJtcwMy4.js +1 -0
  258. package/core/built/admin/assets/zapier-modal-BP2f4-vY.js +1 -0
  259. package/core/built/admin/index.html +20 -18
  260. package/core/frontend/helpers/authors.js +1 -1
  261. package/core/frontend/helpers/link.js +3 -8
  262. package/core/frontend/helpers/tags.js +1 -1
  263. package/core/frontend/meta/author-url.js +2 -2
  264. package/core/frontend/meta/url.js +4 -4
  265. package/core/frontend/services/data/fetch-data.js +10 -5
  266. package/core/frontend/services/proxy.js +1 -1
  267. package/core/frontend/services/routing/api-adapter.js +115 -0
  268. package/core/frontend/services/routing/api-adapter.ts +157 -0
  269. package/core/frontend/services/routing/collection-router.js +5 -3
  270. package/core/frontend/services/routing/controllers/index.js +1 -1
  271. package/core/frontend/services/routing/controllers/rss.js +26 -31
  272. package/core/frontend/services/routing/controllers/rss.ts +66 -0
  273. package/core/frontend/services/routing/controllers/static.js +8 -7
  274. package/core/frontend/services/routing/events.js +20 -6
  275. package/core/frontend/services/routing/parent-router.js +17 -4
  276. package/core/frontend/services/routing/permalink-adapter.js +13 -0
  277. package/core/frontend/services/routing/permalink-adapter.ts +10 -0
  278. package/core/frontend/services/routing/registry.js +59 -33
  279. package/core/frontend/services/routing/router-manager.js +24 -22
  280. package/core/frontend/services/routing/static-routes-router.js +4 -4
  281. package/core/frontend/services/routing/taxonomy-router.js +6 -2
  282. package/core/frontend/services/sitemap/base-site-map-generator.js +1 -28
  283. package/core/frontend/services/sitemap/site-map-manager.js +22 -57
  284. package/core/server/adapters/route-settings/utils.js +10 -2
  285. package/core/server/adapters/route-settings/utils.ts +12 -2
  286. package/core/server/api/endpoints/email-post.js +1 -1
  287. package/core/server/api/endpoints/previews.js +1 -1
  288. package/core/server/api/endpoints/search-index-public.js +3 -3
  289. package/core/server/api/endpoints/search-index.js +4 -4
  290. package/core/server/api/endpoints/utils/serializers/input/authors.js +2 -2
  291. package/core/server/api/endpoints/utils/serializers/input/comments.js +1 -1
  292. package/core/server/api/endpoints/utils/serializers/input/pages.js +3 -3
  293. package/core/server/api/endpoints/utils/serializers/input/posts.js +3 -3
  294. package/core/server/api/endpoints/utils/serializers/input/tags.js +1 -1
  295. package/core/server/api/endpoints/utils/serializers/input/users.js +2 -2
  296. package/core/server/api/endpoints/utils/serializers/input/utils/url.js +31 -13
  297. package/core/server/api/endpoints/utils/serializers/output/mappers/posts.js +2 -2
  298. package/core/server/api/endpoints/utils/serializers/output/mappers/tags.js +2 -2
  299. package/core/server/api/endpoints/utils/serializers/output/mappers/users.js +8 -0
  300. package/core/server/api/endpoints/utils/serializers/output/utils/url.js +18 -11
  301. 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
  302. package/core/server/data/migrations/versions/6.56/2026-08-04-14-42-39-restrict-notification-add-permission-to-administrators.js +12 -0
  303. package/core/server/data/migrations/versions/6.57/2026-08-04-18-00-00-store-custom-field-values-as-leaf-rows.js +74 -0
  304. package/core/server/data/migrations/versions/6.57/2026-08-04-18-54-14-reset-automation-email-analytics.js +25 -0
  305. package/core/server/data/schema/commands.js +21 -5
  306. package/core/server/data/schema/fixtures/fixtures.json +2 -2
  307. package/core/server/data/schema/schema.js +25 -5
  308. package/core/server/lib/common/to-plain.ts +1 -1
  309. package/core/server/models/post.js +12 -3
  310. package/core/server/services/adapter-manager/adapter-manager.js +1 -45
  311. package/core/server/services/adapter-manager/adapter-manager.ts +2 -48
  312. package/core/server/services/adapter-manager/adapter-paths.js +24 -0
  313. package/core/server/services/adapter-manager/adapter-paths.ts +21 -0
  314. package/core/server/services/adapter-manager/base-classes.js +22 -0
  315. package/core/server/services/adapter-manager/base-classes.ts +22 -0
  316. package/core/server/services/adapter-manager/index.js +4 -27
  317. package/core/server/services/adapter-manager/index.ts +4 -31
  318. package/core/server/services/adapter-manager/utils.js +50 -0
  319. package/core/server/services/adapter-manager/utils.ts +57 -0
  320. package/core/server/services/audience-feedback/audience-feedback-controller.js +1 -1
  321. package/core/server/services/audience-feedback/audience-feedback-service.js +2 -2
  322. package/core/server/services/automations/automations-repository.ts +3 -1
  323. package/core/server/services/automations/database-automations-repository.js +33 -14
  324. package/core/server/services/automations/database-automations-repository.ts +41 -15
  325. package/core/server/services/automations/get-scheduler-idempotency-key.js +13 -0
  326. package/core/server/services/automations/get-scheduler-idempotency-key.ts +8 -0
  327. package/core/server/services/automations/poll.js +3 -1
  328. package/core/server/services/automations/poll.ts +4 -1
  329. package/core/server/services/automations/service.js +7 -3
  330. package/core/server/services/automations/service.ts +7 -3
  331. package/core/server/services/comments/comments-service-emails.js +1 -1
  332. package/core/server/services/comments/comments-service.js +1 -1
  333. package/core/server/services/email-analytics/email-analytics-service-wrapper.js +11 -2
  334. package/core/server/services/email-analytics/email-analytics-service.js +1 -1
  335. package/core/server/services/email-service/email-service-wrapper.js +2 -1
  336. package/core/server/services/email-service/mailgun-email-provider.js +15 -0
  337. package/core/server/services/gift-links/CONTEXT.md +9 -0
  338. package/core/server/services/gifts/CONTEXT.md +55 -0
  339. package/core/server/services/gifts/README.md +28 -0
  340. package/core/server/services/gifts/gift-bookshelf-repository.js +65 -45
  341. package/core/server/services/gifts/gift-bookshelf-repository.ts +203 -74
  342. package/core/server/services/gifts/gift-checkout-adapter.js +59 -0
  343. package/core/server/services/gifts/gift-checkout-offer.js +74 -0
  344. package/core/server/services/gifts/gift-checkout-offer.ts +127 -0
  345. package/core/server/services/gifts/gift-codec.js +63 -0
  346. package/core/server/services/gifts/gift-codec.ts +62 -0
  347. package/core/server/services/gifts/gift-controller.js +6 -31
  348. package/core/server/services/gifts/gift-controller.ts +6 -69
  349. package/core/server/services/gifts/gift-email-service.ts +3 -2
  350. package/core/server/services/gifts/gift-schema.js +34 -0
  351. package/core/server/services/gifts/gift-schema.ts +39 -0
  352. package/core/server/services/gifts/gift-service-wrapper.js +13 -11
  353. package/core/server/services/gifts/gift-service.js +265 -52
  354. package/core/server/services/gifts/gift-service.ts +431 -97
  355. package/core/server/services/gifts/gift.ts +16 -39
  356. package/core/server/services/indexnow-ping/indexnow-ping-service.js +1 -1
  357. package/core/server/services/indexnow-ping/indexnow-ping-service.ts +2 -4
  358. package/core/server/services/lib/mailgun-client.js +3 -3
  359. package/core/server/services/link-tracking/link-click-repository.js +6 -1
  360. package/core/server/services/link-tracking/link-click-tracking-service.js +12 -3
  361. package/core/server/services/media-inliner/external-media-inliner.js +12 -8
  362. package/core/server/services/member-attribution/url-translator.js +5 -7
  363. package/core/server/services/member-welcome-emails/member-welcome-email-renderer.js +4 -3
  364. package/core/server/services/member-welcome-emails/service.js +79 -15
  365. package/core/server/services/members/api.js +2 -3
  366. package/core/server/services/members/import-export/import/completion-email.js +8 -4
  367. package/core/server/services/members/import-export/import/completion-email.ts +9 -4
  368. package/core/server/services/members/import-export/import/importer.js +25 -4
  369. package/core/server/services/members/import-export/import/importer.ts +27 -6
  370. package/core/server/services/members/import-export/import/row.ts +5 -1
  371. package/core/server/services/members/import-export/index.js +6 -2
  372. package/core/server/services/members/import-export/index.ts +10 -4
  373. package/core/server/services/members/members-api/controllers/router-controller.js +38 -36
  374. package/core/server/services/members/members-api/members-api.js +13 -7
  375. package/core/server/services/members/members-api/repositories/event-repository.js +4 -94
  376. package/core/server/services/members/members-api/services/member-bread-service.js +3 -3
  377. package/core/server/services/members/members-api/services/payments-service.js +6 -68
  378. package/core/server/services/members-custom-fields/queries.js +4 -13
  379. package/core/server/services/members-custom-fields/queries.ts +4 -13
  380. package/core/server/services/members-custom-fields/schema.js +19 -21
  381. package/core/server/services/members-custom-fields/schema.ts +18 -20
  382. package/core/server/services/members-custom-fields/storage.js +94 -27
  383. package/core/server/services/members-custom-fields/storage.ts +114 -39
  384. package/core/server/services/members-custom-fields/values-service.js +98 -103
  385. package/core/server/services/members-custom-fields/values-service.ts +116 -114
  386. package/core/server/services/mentions/resource-service.js +1 -1
  387. package/core/server/services/mentions/service.js +2 -2
  388. package/core/server/services/oembed/oembed-service.js +44 -3
  389. package/core/server/services/posts/posts-service.js +11 -0
  390. package/core/server/services/route-settings/dynamic-routing-service.js +10 -62
  391. package/core/server/services/route-settings/route-settings-parser.js +25 -25
  392. package/core/server/services/route-settings/route-settings-parser.ts +27 -27
  393. package/core/server/services/route-settings/validation-errors.js +68 -4
  394. package/core/server/services/route-settings/validation-errors.ts +79 -4
  395. package/core/server/services/slack-ping/slack-ping-service.js +2 -2
  396. package/core/server/services/slack-ping/slack-ping-service.ts +3 -5
  397. package/core/server/services/stats/content-stats-service.js +3 -3
  398. package/core/server/services/stats/posts-stats-service.js +29 -25
  399. package/core/server/services/stripe/services/webhook/charge-refunded-event-service.js +1 -1
  400. package/core/server/services/stripe/services/webhook/checkout-session-event-service.js +16 -4
  401. package/core/server/services/stripe/stripe-api.js +10 -0
  402. package/core/server/services/url/config.js +90 -135
  403. package/core/server/services/url/index.js +6 -49
  404. package/core/server/services/url/lazy-find-resource.js +14 -11
  405. package/core/server/services/url/lazy-find-resource.ts +14 -11
  406. package/core/server/services/url/lazy-url-service.js +174 -94
  407. package/core/server/services/url/lazy-url-service.ts +233 -97
  408. package/core/server/services/url/routable-resources.js +62 -71
  409. package/core/server/services/url/router-filter.js +12 -4
  410. package/core/server/services/url/router-filter.ts +12 -4
  411. package/core/server/services/webhooks/index.js +1 -1
  412. package/core/server/services/webhooks/serialize.js +2 -1
  413. package/core/server/web/gift-preview/controller.js +10 -25
  414. package/core/shared/config/env/config.testing-mysql.json +1 -2
  415. package/core/shared/config/env/config.testing.json +1 -2
  416. package/core/shared/events/index.js +1 -2
  417. package/core/shared/labs.js +4 -4
  418. package/package.json +10 -10
  419. package/pnpm-lock.yaml +27 -20
  420. package/pnpm-workspace.yaml +3 -2
  421. package/tsconfig.json +1 -0
  422. package/components/tryghost-kg-default-nodes-2.1.3.tgz +0 -0
  423. package/core/built/admin/assets/Combination-CJG7Flp-.js +0 -41
  424. package/core/built/admin/assets/activitypub/layout-qx-bUL1k.js +0 -1
  425. package/core/built/admin/assets/automated-emails-DRy7qY-J.js +0 -7
  426. package/core/built/admin/assets/checkbox-CWa28lgO.js +0 -1
  427. package/core/built/admin/assets/chunk.524.cffd399783a519e404a9.js +0 -25
  428. package/core/built/admin/assets/chunk.582.eebf0d0b2d202bb746a5.js +0 -27
  429. package/core/built/admin/assets/code-editor-view-CCr0rBWS.js +0 -1
  430. package/core/built/admin/assets/comments-DyUSMUdj.js +0 -1
  431. package/core/built/admin/assets/disabled-sources-indicator-CUxMfiPa.js +0 -1
  432. package/core/built/admin/assets/dist-2Tnz2Yfq.js +0 -1
  433. package/core/built/admin/assets/dist-CjY-f5Z1.js +0 -1
  434. package/core/built/admin/assets/dist-DDY6GRVz.js +0 -1
  435. package/core/built/admin/assets/dist-DG78yroX.js +0 -23
  436. package/core/built/admin/assets/domain-C0bV2UV8.js +0 -1
  437. package/core/built/admin/assets/editor-Dp865O-4.js +0 -8
  438. package/core/built/admin/assets/esm-CFX93H5M.js +0 -2
  439. package/core/built/admin/assets/filter-sources-BV2rnpfA.js +0 -1
  440. package/core/built/admin/assets/filters-CUXJ2Nm9.js +0 -1
  441. package/core/built/admin/assets/filters-DfbIWc_l.js +0 -1
  442. package/core/built/admin/assets/index-9Cw8z3rA.css +0 -1
  443. package/core/built/admin/assets/index-BGG7NckO.js +0 -67
  444. package/core/built/admin/assets/input-group-BSgG_lVw.js +0 -1
  445. package/core/built/admin/assets/label-picker-1DvSuLA1.js +0 -1
  446. package/core/built/admin/assets/labels-CDSUt4J_.js +0 -1
  447. package/core/built/admin/assets/layout-yQEi2qDM.js +0 -1
  448. package/core/built/admin/assets/link-helpers-7EYqvvHs.js +0 -1
  449. package/core/built/admin/assets/member-custom-fields-yOMHyAg9.js +0 -1
  450. package/core/built/admin/assets/member-detail-BAq7gDaa.js +0 -1
  451. package/core/built/admin/assets/members-CQpVFJu4.js +0 -10
  452. package/core/built/admin/assets/modals-ReORvWnu.js +0 -31
  453. package/core/built/admin/assets/newsletter-CJQvtHqN.js +0 -1
  454. package/core/built/admin/assets/newsletters-B3QQXfGT.js +0 -1
  455. package/core/built/admin/assets/nql-BsgFMd93.js +0 -1
  456. package/core/built/admin/assets/overview-Bf2sbznq.js +0 -1
  457. package/core/built/admin/assets/overview-CBfePxcr.js +0 -1
  458. package/core/built/admin/assets/post-analytics-header-Bmc9su6q.js +0 -1
  459. package/core/built/admin/assets/preferences-DJPfHEGu.js +0 -5
  460. package/core/built/admin/assets/profile-DqBQp-gT.js +0 -1
  461. package/core/built/admin/assets/select-C5_xEt5b.js +0 -1
  462. package/core/built/admin/assets/settings-BwiVIXau.js +0 -4
  463. package/core/built/admin/assets/social-urls-BQPFEk1_.js +0 -8
  464. package/core/built/admin/assets/switch-z5Y6Uzt6.js +0 -1
  465. package/core/built/admin/assets/tabs-CCEgKYzq.js +0 -1
  466. package/core/built/admin/assets/tags-Cg2VJGmG.js +0 -1
  467. package/core/built/admin/assets/textarea-Bjccvh_E.js +0 -1
  468. package/core/built/admin/assets/toggle-group-b3IlxvhV.js +0 -1
  469. package/core/built/admin/assets/web-B_5GZRvH.js +0 -1
  470. package/core/server/services/gifts/gift-repository.js +0 -2
  471. package/core/server/services/gifts/gift-repository.ts +0 -29
  472. package/core/server/services/route-settings/activation-bridge.js +0 -174
  473. package/core/server/services/route-settings/activation-bridge.ts +0 -250
  474. package/core/server/services/url/local-file-cache.js +0 -75
  475. package/core/server/services/url/queue.js +0 -260
  476. package/core/server/services/url/resource.js +0 -102
  477. package/core/server/services/url/resources.js +0 -480
  478. package/core/server/services/url/url-generator.js +0 -276
  479. package/core/server/services/url/url-service-facade.js +0 -366
  480. package/core/server/services/url/url-service-facade.ts +0 -519
  481. package/core/server/services/url/url-service.js +0 -387
  482. package/core/server/services/url/urls.js +0 -140
  483. package/core/shared/events/url-resource-updated-event.js +0 -33
@@ -0,0 +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{x as r}from"./dist-Cb5RSHSg.js";import{t as i}from"./inline-Cw-gigDW.js";import{i as a,n as o,r as s,t as c}from"./tabs-Dd6oOKbv.js";import{o as l,t as u}from"./use-settings-navigation-Bf1g1rEh.js";import{i as d,o as f,t as p}from"./field-Dh_lwk13.js";import{i as m,n as h,t as g}from"./use-url-input-z-p0Kewm.js";import{Da as _,On as v,Pr as y,Yi as b,cr as x}from"./index-BHy2DZX-.js";import{t as S}from"./validator-Cr0sMKuW.js";import{t as C}from"./use-setting-group-YlYcoNyP.js";import{t as w}from"./format-url-C-t8G6Qd.js";var T=e(S(),1),E=e(t(),1),D=e=>!!(e.label&&!e.label.match(/^\s*$/)||e.url!==`/`),O=({items:e,setItems:t})=>{let n=h({items:(0,E.useMemo)(()=>e.map(e=>({...e,errors:{}})),[e]),setItems:(0,E.useCallback)(e=>{t(e.map(({url:e,label:t})=>({url:e,label:t})))},[t]),blank:{url:`/`,label:``,errors:{}},canAddNewItem:D}),r=new RegExp(/^(\/|#|[a-zA-Z0-9-]+:)/),i=e=>{let t={};return(!e.label||e.label.match(/^\s*$/))&&(t.label=`You must specify a label`),(!e.url||e.url.match(/\s/)||!T.default.isURL(e.url,{require_protocol:!0})&&!e.url.match(r))&&(t.url=`You must specify a valid URL or relative path`),t},a=(e,t)=>{let r=n.items.find(t=>t.id===e);n.updateItem(e,{...r.item,...t})},o=()=>{let e=i(n.newItem);Object.values(e).some(e=>e)?n.setNewItem({...n.newItem,errors:e}):n.addItem()},s=e=>{n.removeItem(e)},c=(e,t)=>{n.moveItem(e,t)},l=(e,t)=>{if(e===`new`)n.setNewItem({...n.newItem,errors:{...n.newItem.errors,[t]:void 0}});else{let r=n.items.find(t=>t.id===e).item;n.updateItem(e,{...r,errors:{...r.errors,[t]:void 0}})}};return{items:n.items.map(({item:e,id:t})=>({...e,id:t})),updateItem:a,addItem:o,removeItem:s,moveItem:c,newItem:{...n.newItem,id:`new`},setNewItem:e=>n.setNewItem({...n.newItem,...e}),clearError:l,validate:()=>{let e=!0;if(n.items.forEach(({item:t,id:r})=>{let a=i(t);Object.values(a).some(e=>e)&&(e=!1,n.updateItem(r,{...t,errors:a}))}),D(n.newItem)){let t=i(n.newItem);Object.values(t).some(e=>e)&&(e=!1,n.setNewItem({...n.newItem,errors:t}))}return e}}},k=n(),A=({baseUrl:e,item:t,updateItem:n,addItem:a,clearError:o,labelPlaceholder:s,unstyled:c,textFieldClasses:l,action:u,className:m,...h})=>{let _=g({baseUrl:e,nullable:!0,value:t.url,onChange:e=>n?.({url:e||``})});return(0,k.jsxs)(`div`,{className:r(`flex w-full items-start gap-3`,m),"data-testid":`navigation-item-editor`,...h,children:[(0,k.jsx)(`div`,{className:`flex flex-1 pt-1`,children:(0,k.jsxs)(p,{className:`grow`,"data-invalid":!!t.errors.label||void 0,children:[(0,k.jsx)(f,{className:`sr-only`,htmlFor:`navigation-label-${t.id}`,children:`Label`}),(0,k.jsx)(x,{"aria-invalid":!!t.errors.label||void 0,className:r(c&&`border-0 bg-transparent shadow-none focus-visible:ring-0`,l),id:`navigation-label-${t.id}`,placeholder:s,value:t.label,onChange:e=>n?.({label:e.target.value}),onKeyDown:e=>{n?.({label:e.target.value}),e.key===`Enter`&&(e.preventDefault(),a?.()),t.errors.label&&o?.(`label`)}}),t.errors.label&&(0,k.jsx)(d,{children:t.errors.label})]})}),(0,k.jsxs)(p,{className:`flex-1 pt-1`,"data-invalid":!!t.errors.url||void 0,children:[(0,k.jsx)(f,{className:`sr-only`,htmlFor:`navigation-url-${t.id}`,children:`URL`}),(0,k.jsx)(x,{"aria-invalid":!!t.errors.url||void 0,className:l,id:`navigation-url-${t.id}`,value:_.displayValue,onBlur:_.commitValue,onChange:e=>_.setDisplayValue(e.target.value),onFocus:_.handleFocus,onKeyDown:t=>{_.handleKeyDown(t);let r=w(t.target.value,e,!0);n?.({url:r.save||``})},onKeyUp:r=>{if(r.key===`Enter`){r.preventDefault();let t=w(r.target.value,e,!0);n?.({url:t.save||``}),a?.()}t.errors.url&&o?.(`url`)}}),t.errors.url&&(0,k.jsx)(d,{children:t.errors.url})]}),u&&(0,k.jsx)(i,{align:`center`,className:`h-[calc(var(--control-height)+0.25rem)] shrink-0 translate-y-px pt-1`,children:u})]})},j=({baseUrl:e,navigation:t})=>(0,k.jsxs)(`div`,{className:`w-full pt-2`,children:[(0,k.jsx)(m,{dragHandleClass:`translate-y-0.5`,getDragHandleLabel:e=>`Reorder ${e.label||`navigation item`}`,items:t.items,itemSeparator:!1,renderItem:n=>(0,k.jsx)(A,{action:(0,k.jsx)(y,{"aria-label":`Delete navigation item`,size:`icon`,type:`button`,variant:`ghost`,onClick:()=>t.removeItem(n.id),children:(0,k.jsx)(b,{})}),baseUrl:e,clearError:e=>t.clearError(n.id,e),item:n,updateItem:e=>t.updateItem(n.id,e)}),onMove:t.moveItem}),(0,k.jsxs)(i,{align:`start`,gap:`md`,children:[(0,k.jsx)(i,{align:`center`,className:`h-[calc(var(--control-height)+0.5rem)] shrink-0 translate-y-0.5 pt-2`,children:(0,k.jsx)(_,{className:`size-4 text-muted-foreground`})}),(0,k.jsx)(A,{action:(0,k.jsx)(y,{"aria-label":`Add navigation item`,"data-testid":`add-button`,size:`icon`,type:`button`,variant:`ghost`,onClick:t.addItem,children:(0,k.jsx)(_,{})}),addItem:t.addItem,baseUrl:e,className:`mt-1`,clearError:e=>t.clearError(t.newItem.id,e),"data-testid":`new-navigation-item`,item:t.newItem,labelPlaceholder:`New item label`,updateItem:t.setNewItem})]})]});function M(){let{updateRoute:e}=u(),{localSettings:t,updateSetting:n,saveState:r,handleSave:i,siteData:d}=C(),[f,p]=v(t,[`navigation`,`secondary_navigation`]),m=(0,E.useMemo)(()=>JSON.parse(f||`[]`),[f]),h=(0,E.useMemo)(()=>JSON.parse(p||`[]`),[p]),g=(0,E.useCallback)(e=>{n(`navigation`,JSON.stringify(e))},[n]),_=(0,E.useCallback)(e=>{n(`secondary_navigation`,JSON.stringify(e))},[n]),y=O({items:m,setItems:g}),b=O({items:h,setItems:_}),[x,S]=(0,E.useState)(`primary-nav`);return(0,k.jsx)(l,{buttonsDisabled:r===`saving`,cancelLabel:`Close`,dirty:t.some(e=>e.dirty),okLabel:r===`saving`?`Saving...`:`Save`,scrolling:!0,size:`lg`,stickyFooter:!0,testId:`navigation-modal`,title:`Navigation`,onClose:()=>{e(`navigation`)},onOk:async()=>{y.validate()&&b.validate()&&(await i(),e(`navigation`))},children:(0,k.jsx)(`div`,{className:`mt-6 mb-1`,children:(0,k.jsxs)(c,{value:x,variant:`underline`,onValueChange:S,children:[(0,k.jsxs)(s,{children:[(0,k.jsx)(a,{value:`primary-nav`,children:`Primary`}),(0,k.jsx)(a,{value:`secondary-nav`,children:`Secondary`})]}),(0,k.jsx)(o,{value:`primary-nav`,children:(0,k.jsx)(j,{baseUrl:d.url,navigation:y})}),(0,k.jsx)(o,{value:`secondary-nav`,children:(0,k.jsx)(j,{baseUrl:d.url,navigation:b})})]})})})}export{M as default};
@@ -0,0 +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}from"./hooks-D6EE7BIt.js";import{n as i}from"./dist-Ndy-PuGN.js";import{i as a,r as o}from"./stats-D8nZCTy5.js";import{t as s}from"./posts-CxG7v0-M.js";import{o as c}from"./post-helpers-C5OQMBoi.js";import{m as l}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as u}from"./router-provider-DSQfprxH.js";import{_ as d,f,m as p,p as m}from"./dist-Cb5RSHSg.js";import{i as h,r as g,t as _}from"./tabs-Dd6oOKbv.js";import{a as v,i as y,n as b,o as x,r as S,t as C}from"./card-aUHX0hyR.js";import{c as w,l as T,n as ee,o as te,r as ne,s as re,t as ie,u as ae}from"./data-list-CupF7bjM.js";import{i as oe,n as se,o as E,r as D,t as O}from"./use-simple-pagination-D9ckKo5-.js";import{Fa as ce,Gr as k,Pr as A,Ps as le,Qi as j,Ss as ue,Ur as M,Vs as de,Xn as N,Zi as P,aa as F,cr as fe,es as I,ir as pe,nr as L,sr as me,tr as he}from"./index-BHy2DZX-.js";import{t as ge}from"./member-route-0Aa52Ntz.js";import{a as R,i as z,n as B,r as V,t as H}from"./kpi-card-IHDo8Q56.js";import{r as _e,t as ve}from"./post-analytics-header-ChzjXVPt.js";import{n as ye}from"./post-analytics-context-D0Mw-Pmv.js";import{a as be,i as xe,n as U,o as W,r as G}from"./link-helpers-Bzkk68GD.js";var K=r({dataType:`FeedbackResponseType`,path:e=>`/feedback/${e}/`}),q=e(t(),1),J=(e,t)=>{let{data:n,isLoading:r,error:i}=K(e,{searchParams:{limit:`50`,...t===void 0?{}:{score:t.toString()}}});return{feedback:(0,q.useMemo)(()=>n?.feedback?n.feedback:[],[n]),isLoading:r,error:i}},Y=n(),Se=({feedbackStats:e})=>{let{postId:t}=l(),n=u(),[r,i]=(0,q.useState)(`positive`),{feedback:a,isLoading:o}=J(t||``,+(r===`positive`)),{totalPages:s,paginatedData:c,nextPage:f,previousPage:w,hasNextPage:T,hasPreviousPage:ee}=O({data:a,itemsPerPage:9}),te=o;return(0,Y.jsxs)(C,{children:[(0,Y.jsxs)(v,{className:`pb-5`,children:[(0,Y.jsx)(x,{children:`Feedback`}),(0,Y.jsx)(S,{children:`What did your readers think?`})]}),e.totalFeedback>0?(0,Y.jsxs)(b,{className:`pb-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsx)(_,{className:`pb-3`,defaultValue:`positive`,value:r,variant:`button`,onValueChange:e=>i(e),children:(0,Y.jsxs)(g,{className:`gap-1`,children:[(0,Y.jsx)(h,{className:`h-7`,value:`positive`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(P,{size:14,strokeWidth:1.25}),(0,Y.jsx)(`span`,{className:`hidden font-medium sm:visible! sm:inline!`,children:`More like this`}),(0,Y.jsx)(`span`,{className:`font-semibold tracking-tight`,children:m(e.positiveFeedback/e.totalFeedback)})]})}),(0,Y.jsx)(h,{className:`h-7`,value:`negative`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(j,{size:14,strokeWidth:1.25}),(0,Y.jsx)(`span`,{className:`hidden font-medium sm:visible! sm:inline!`,children:`Less like this`}),(0,Y.jsx)(`span`,{className:`font-semibold tracking-tight`,children:m(e.negativeFeedback/e.totalFeedback)})]})})]})}),(0,Y.jsx)(le,{className:`mr-2 mb-3 lg:hidden xl:visible! xl:block!`,children:`Date`})]}),(0,Y.jsx)(N,{}),te?(0,Y.jsx)(me,{className:`mt-3`,lines:3}):c&&c.length>0?(0,Y.jsx)(`div`,{className:`flex w-full flex-col py-3`,children:c.map(e=>(0,Y.jsxs)(`div`,{className:`flex h-10 w-full items-center justify-between gap-3 rounded-sm border-none px-2 text-sm hover:cursor-pointer hover:bg-accent`,onClick:()=>{n(`/members/${e.member.id}`,{crossApp:!0})},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,Y.jsxs)(he,{className:`size-7`,children:[e.member?.avatar_image&&(0,Y.jsx)(`img`,{className:`absolute aspect-square size-full`,src:e.member?.avatar_image}),(0,Y.jsx)(L,{className:`text-white`,style:{backgroundColor:`${d(M(e.member),`45`,`55`)}`},children:k(e.member)})]}),M(e.member)]}),(0,Y.jsx)(`div`,{className:`whitespace-nowrap text-muted-foreground`,children:p(e.created_at)})]},e.id))}):(0,Y.jsx)(`div`,{className:`flex h-full items-center justify-center py-8 text-center text-sm text-muted-foreground`,children:(0,Y.jsxs)(`div`,{children:[`No `,r===`positive`?`positive`:`negative`,` feedback yet`]})})]}):(0,Y.jsxs)(b,{className:`flex grow flex-col items-center justify-center text-center text-sm text-muted-foreground`,children:[(0,Y.jsx)(`div`,{children:`No members have given feedback yet`}),(0,Y.jsx)(`div`,{children:`When someone does, you'll see their response here.`})]}),e.totalFeedback>0&&(0,Y.jsx)(y,{className:`grow-0`,children:(0,Y.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,Y.jsxs)(A,{variant:`outline`,onClick:()=>{let e=`(feedback.post_id:'${t}'+feedback.score:1)`,i=`(feedback.post_id:'${t}'+feedback.score:0)`,a=`${encodeURIComponent(e)}&post=${t}`,o=`${encodeURIComponent(i)}&post=${t}`;n(`/members?filter=${r===`positive`?a:o}`,{crossApp:!0})},children:[`View all`,(0,Y.jsx)(F,{})]}),s>1&&(0,Y.jsx)(se,{className:`pb-0`,children:(0,Y.jsxs)(D,{children:[(0,Y.jsx)(E,{disabled:!ee,onClick:w}),(0,Y.jsx)(oe,{disabled:!T,onClick:f})]})})]})})]})},Ce=e=>{let{data:t,isLoading:n}=s(e),{data:r,isLoading:i}=s(e,{searchParams:{include:`count.positive_feedback,count.negative_feedback`}}),c=(0,q.useMemo)(()=>t?.posts[0],[t]),l=(0,q.useMemo)(()=>r?.posts[0],[r]),u=(0,q.useMemo)(()=>c?{sent:c.email?.email_count||0,opened:c.email?.opened_count||0,clicked:c.count?.clicks||0,openedRate:c.email?.opened_count?c.email.opened_count/c.email.email_count:0,clickedRate:c.count?.clicks&&c.email?.email_count?c.count.clicks/c.email.email_count:0}:{sent:0,opened:0,clicked:0,openedRate:0,clickedRate:0},[c]),d=(0,q.useMemo)(()=>{if(!l?.count)return{positiveFeedback:0,negativeFeedback:0,totalFeedback:0};let e=l.count.positive_feedback||0,t=l.count.negative_feedback||0;return{positiveFeedback:e,negativeFeedback:t,totalFeedback:e+t}},[l]),f=(0,q.useMemo)(()=>c?.newsletter?.id,[c]),{data:p,isLoading:m}=o({searchParams:f?{newsletter_id:f}:{},enabled:!!f}),h=(0,q.useMemo)(()=>p?.stats?p.stats.map(e=>e.post_id):[],[p]),{data:g,isLoading:_}=a({searchParams:f&&h.length>0?{newsletter_id:f,post_ids:h.join(`,`)}:{},enabled:!!f&&h.length>0}),v=(0,q.useMemo)(()=>{if(!p?.stats)return;let e=p.stats,t=g?.stats||[],n=new Map;t.forEach(e=>{n.set(e.post_id,e)});let r=e.map(e=>{let t=n.get(e.post_id);return{...e,total_clicks:t?.total_clicks||0,click_rate:t?.click_rate||0}});return{...p,stats:r}},[p,g]),y=m||_,{data:b,isLoading:x,refetch:S}=be({searchParams:{filter:`post_id:'${e}'`}}),C=(0,q.useMemo)(()=>{if(!v||!v.stats)return{openRate:0,clickRate:0};let e=v.stats;if(e.length===0)return{openRate:0,clickRate:0};let t=e.reduce((e,t)=>e+(t.open_rate||0),0),n=e.reduce((e,t)=>e+(t.click_rate||0),0);return{openRate:Number((t/e.length).toFixed(2)),clickRate:Number((n/e.length).toFixed(2))}},[v]),w=(0,q.useMemo)(()=>G(b),[b]);return{post:c,stats:u,feedbackStats:d,averageStats:(0,q.useMemo)(()=>({openedRate:C.openRate,clickedRate:C.clickRate}),[C]),topLinks:w,refetchTopLinks:S,isLoading:n||i||y||x}},we=({breakpoints:e={sm:1080,md:1280,lg:1360}}={})=>{let[t,n]=(0,q.useState)(`md`);return(0,q.useEffect)(()=>{let t=()=>{let t=window.innerWidth;t<e.sm?n(`sm`):t<e.md?n(`md`):n(`lg`)};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e]),{chartSize:t,isSmall:t===`sm`,isMedium:t===`md`,isLarge:t===`lg`}},Te=()=>(0,Y.jsx)(`div`,{className:`absolute top-1/2 -right-4 z-10 hidden size-8 -translate-y-1/2 items-center justify-center rounded-full border bg-background text-muted-foreground md:visible! md:flex!`,children:(0,Y.jsx)(I,{className:`ml-0.5`,size:16,strokeWidth:1.5})}),Ee=({dataColor:e,value:t,avgValue:n})=>(0,Y.jsxs)(`div`,{className:`absolute top-6 left-1/2 z-50 flex w-[200px] -translate-x-1/2 flex-col items-stretch gap-1.5 rounded-md bg-background px-4 py-2 text-sm opacity-0 shadow-md transition-all group-hover/block:top-3 group-hover/block:opacity-100`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,Y.jsx)(`div`,{className:`size-2 rounded-full bg-chart-blue opacity-50`,style:{backgroundColor:e}}),`This newsletter`]}),(0,Y.jsx)(`div`,{className:`text-right font-mono`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,Y.jsx)(`div`,{className:`size-2 rounded-full bg-chart-gray opacity-80`}),`Average`]}),(0,Y.jsx)(`div`,{className:`text-right font-mono`,children:n})]})]}),X=()=>{let e=u(),[t,n]=(0,q.useState)(null),[r,a]=(0,q.useState)(``),o=(0,q.useRef)(null),s=(0,q.useRef)(null),{chartSize:l}=we(),{appSettings:d}=de(),{emailTrackClicks:p,emailTrackOpens:h}=d?.analytics||{},{post:g,isPostLoading:_,postId:k}=ye(),j=t=>e(ge({filter:t}),{crossApp:!0}),M=g,P=c(M);(0,q.useEffect)(()=>{!_&&!P&&e(`/posts/analytics/${k}`)},[e,k,_,P]);let{stats:F,averageStats:I,topLinks:L,isLoading:he,refetchTopLinks:be}=Ce(k),{mutate:G}=xe(),K=(0,q.useMemo)(()=>{if(!M?.count)return{positiveFeedback:0,negativeFeedback:0,totalFeedback:0};let e=M.count.positive_feedback||0,t=M.count.negative_feedback||0;return{positiveFeedback:e,negativeFeedback:t,totalFeedback:e+t}},[M]),J=(0,q.useMemo)(()=>M?.newsletter?.feedback_enabled===!0,[M]),X=(0,q.useMemo)(()=>K.totalFeedback>0?!0:J,[K.totalFeedback,J]),De=e=>{let t=U(L,e);t&&(n(e),a(t.link.to))},Oe=()=>{if(!t)return;let e=U(L,t);if(!e)return;let o=r.trim();if(o===``||o===e.link.to){n(null),a(``);return}G({originalUrl:e.link.originalTo,editedUrl:r,postId:k},{onSuccess:()=>{n(null),a(``),be()},onError:()=>{i.error(`Couldn’t update the link. Please try again.`)}})},{totalPages:ke,paginatedData:Ae,nextPage:je,previousPage:Me,hasNextPage:Ne,hasPreviousPage:Pe}=O({data:L,itemsPerPage:10});(0,q.useEffect)(()=>{if(t&&o.current){o.current.focus();let e=U(L,t),i=t=>{s.current&&!s.current.contains(t.target)&&r===e?.link.to&&(n(null),a(``))};return document.addEventListener(`mousedown`,i),()=>{document.removeEventListener(`mousedown`,i)}}},[t,r,L]);let Z=he||_,Fe=[{datatype:`Sent`,value:1,fill:`url(#gradientPurple)`,color:`var(--chart-purple)`}],Ie={percentage:{label:`O`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},Le=[{datatype:`Average`,value:I.openedRate,fill:`url(#gradientGray)`,color:`var(--chart-gray)`},{datatype:`This newsletter`,value:F.openedRate,fill:`url(#gradientBlue)`,color:`var(--chart-blue)`}],Re={percentage:{label:`Opened`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},ze=[{datatype:`Average`,value:I.clickedRate,fill:`url(#gradientGray)`,color:`var(--chart-gray)`},{datatype:`This newsletter`,value:F.clickedRate,fill:`url(#gradientTeal)`,color:`var(--chart-teal)`}],Be={percentage:{label:`Clicked`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},Q=`grid-cols-3`,$=`aspect-[16/10] w-full max-w-[320px] sm:aspect-[2/1] md:aspect-[10/14] md:max-w-none lg:aspect-square`;return(!p||!h)&&(Q=`grid-cols-2`,$=`aspect-[16/10] w-full max-w-[320px] sm:aspect-[2/1] md:aspect-square md:max-w-none lg:aspect-[15/10]`),!p&&!h&&(Q=`grid-cols-1`,$=`aspect-square w-full sm:aspect-[16/10] md:max-w-[320px] md:max-h-[320px] lg:aspect-[12/10]`),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ve,{currentTab:`Newsletter`}),(0,Y.jsx)(_e,{children:(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 ${X&&p&&`lg:grid-cols-2`}`,children:[(0,Y.jsxs)(C,{className:X&&p?`lg:col-span-2`:``,children:[(0,Y.jsxs)(v,{className:`hidden`,children:[(0,Y.jsx)(x,{children:`Newsletters`}),(0,Y.jsx)(S,{children:`How did this post perform`})]}),Z?(0,Y.jsx)(b,{className:`h-[25vw] p-6`,children:(0,Y.jsx)(pe,{})}):(0,Y.jsxs)(b,{className:`p-0`,children:[(0,Y.jsxs)(`div`,{className:`grid ${Q} items-stretch border-b`,children:[(0,Y.jsxs)(H,{className:`group relative isolate grow p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(z,{onClick:()=>{j(`emails.post_id:${k}`)},children:`View members →`}),(0,Y.jsxs)(V,{onClick:()=>{j(`emails.post_id:${k}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-purple opacity-50`}),`Sent`]}),(0,Y.jsx)(B,{children:(0,Y.jsx)(R,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.sent)})})]}),h&&(0,Y.jsxs)(H,{className:`p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(z,{onClick:()=>{j(`opened_emails.post_id:${k}`)},children:`View members →`}),(0,Y.jsxs)(V,{onClick:()=>{j(`opened_emails.post_id:${k}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-blue opacity-50`}),`Opened`]}),(0,Y.jsx)(B,{children:(0,Y.jsx)(R,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.opened)})})]}),p&&(0,Y.jsxs)(H,{className:`group relative isolate grow p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(z,{onClick:()=>{j(`clicked_links.post_id:${k}`)},children:`View members →`}),(0,Y.jsxs)(V,{onClick:()=>{j(`clicked_links.post_id:${k}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-teal opacity-50`}),`Clicked`]}),(0,Y.jsx)(B,{children:(0,Y.jsx)(R,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.clicked)})})]})]}),(0,Y.jsxs)(`div`,{className:`$ mx-auto grid grid-cols-1 items-center justify-center gap-4 transition-all md:gap-0 ${Q===`grid-cols-2`&&`md:grid-cols-2`} ${Q===`grid-cols-3`&&`md:grid-cols-3`}`,children:[(0,Y.jsxs)(`div`,{className:`relative border-r-0 px-6 ${(h||p)&&`md:border-r`}`,children:[(0,Y.jsx)(W,{className:$,config:Ie,data:Fe,percentageLabel:`Sent`,percentageValue:m(1),size:l,tooltip:!1}),(h||p)&&(0,Y.jsx)(Te,{})]}),h&&(0,Y.jsxs)(`div`,{className:`group/block relative border-r-0 px-6 transition-all hover:bg-muted/25 ${p&&`md:border-r`}`,children:[(0,Y.jsx)(Ee,{avgValue:m(I.openedRate),dataColor:`var(--chart-blue)`,value:m(F.openedRate)}),(0,Y.jsx)(W,{className:$,config:Re,data:Le,percentageLabel:`Open rate`,percentageValue:m(F.openedRate),size:l,tooltip:!1}),p&&(0,Y.jsx)(Te,{})]}),p&&(0,Y.jsxs)(`div`,{className:`group/block relative px-6 transition-all hover:bg-muted/25`,children:[(0,Y.jsx)(Ee,{avgValue:m(I.clickedRate),dataColor:`var(--chart-teal)`,value:m(F.clickedRate)}),(0,Y.jsx)(W,{className:$,config:Be,data:ze,percentageLabel:`Click rate`,percentageValue:m(F.clickedRate),size:l,tooltip:!1})]})]})]})]}),X&&(0,Y.jsx)(Se,{feedbackStats:K}),p&&(0,Y.jsxs)(C,{className:`group/datalist overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between p-6`,children:[(0,Y.jsxs)(v,{className:`p-0`,children:[(0,Y.jsx)(x,{children:`Newsletter clicks`}),(0,Y.jsx)(S,{children:`Which links resonated with your readers`})]}),(0,Y.jsx)(le,{className:`mr-2`,children:`Members`})]}),Z?(0,Y.jsxs)(b,{className:`p-6 pt-0`,children:[(0,Y.jsx)(N,{}),(0,Y.jsx)(me,{className:`mt-6`})]}):(0,Y.jsxs)(b,{className:`pb-0`,children:[(0,Y.jsx)(N,{}),L.length>0?(0,Y.jsx)(ie,{className:``,children:(0,Y.jsx)(ne,{children:Ae?.map(e=>{let n=F.clicked>0?e.count/F.clicked:0,i=e.link.link_id,c=e.link.title,l=e.link.to,u=e.link.edited;return(0,Y.jsxs)(ae,{children:[t!==i&&(0,Y.jsx)(ee,{style:{width:`${n?Math.round(n*100):0}%`}}),(0,Y.jsx)(te,{className:`w-full`,children:t===i?(0,Y.jsxs)(`div`,{ref:s,className:`flex w-full items-center gap-2`,children:[(0,Y.jsx)(fe,{ref:o,className:`z-50 h-7 w-full border-border bg-background text-sm`,value:r,onChange:e=>a(e.target.value)}),(0,Y.jsx)(A,{size:`sm`,onClick:Oe,children:`Update`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A,{className:`mr-2 shrink-0 bg-background`,size:`sm`,variant:`outline`,onClick:()=>De(i),children:(0,Y.jsx)(ce,{})}),(0,Y.jsx)(`a`,{className:`block truncate font-medium hover:underline`,href:l,rel:`noreferrer`,target:`_blank`,title:c,children:c}),u&&(0,Y.jsx)(`span`,{className:`ml-1 text-gray-500`,children:`(edited)`})]})}),(0,Y.jsxs)(re,{children:[(0,Y.jsx)(w,{children:f(e.count||0)}),(0,Y.jsx)(T,{children:m(n)})]})]},i)})})}):(0,Y.jsx)(`div`,{className:`py-20 text-center text-sm text-gray-700`,children:`You have no links in your post.`})]}),!Z&&L.length>1&&(0,Y.jsx)(y,{children:(0,Y.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`mt-2 flex items-start gap-2 pl-4 text-sm text-green`,children:[(0,Y.jsx)(ue,{size:20,strokeWidth:1.5}),`Sent a broken link? You can update it!`]}),ke>1&&(0,Y.jsx)(se,{className:`pb-0`,children:(0,Y.jsxs)(D,{children:[(0,Y.jsx)(E,{disabled:!Pe,onClick:Me}),(0,Y.jsx)(oe,{disabled:!Ne,onClick:je})]})})]})})]})]})})]})};export{X as default};
@@ -0,0 +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{m as r}from"./hooks-D6EE7BIt.js";import{n as i}from"./dist-Ndy-PuGN.js";import{t as a}from"./use-form-vRjI0Kwk.js";import{m as o}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{x as s}from"./dist-Cb5RSHSg.js";import{t as c}from"./inline-Cw-gigDW.js";import{t as l}from"./stack-CIfOAAVf.js";import{i as u,n as d,r as f,t as p}from"./tabs-Dd6oOKbv.js";import{t as m}from"./switch-CE2NuMn-.js";import{i as h,n as g,o as _,s as v,t as y}from"./select-D9oU1IoM.js";import{s as b,t as x}from"./use-settings-navigation-Bf1g1rEh.js";import{a as S,c as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./field-Dh_lwk13.js";import{t as A}from"./textarea-d9qEkMOP.js";import{n as ee,t as j}from"./toggle-group-Guorw93z.js";import{r as te}from"./components-CwL6a6As-B0E0-NBJ.js";import{Dn as M,Ir as N,Lr as P,Ls as F,On as I,Pr as L,Qi as R,Rs as ne,Ui as z,Wi as B,Xn as V,Zi as re,bo as ie,ca as ae,cr as H,hs as oe,ma as se,na as ce,qa as le,qo as ue,sa as U,ta as de,zr as fe,zs as pe}from"./index-BHy2DZX-.js";import{i as me,r as he}from"./newsletters-Du0lzskS.js";import{t as ge}from"./validator-Cr0sMKuW.js";import{n as _e}from"./confirmation-modal-B6D6mk6R.js";import{t as ve}from"./limit-modal-BRPsit_B.js";import{n as ye,t as be}from"./use-limiter-BkN3E4gw.js";import{n as W}from"./global-data-provider-B949LDXJ.js";import{t as xe}from"./use-setting-group-YlYcoNyP.js";import{t as Se}from"./use-feature-flag-ud0Qz8vt.js";import{t as G}from"./color-picker-field-BonBgxhU.js";import{i as Ce,r as we,t as K}from"./newsletter-emails-Bf8IZLsP.js";import{t as Te}from"./html-field-9a9Id_2q.js";import{t as q}from"./color-utils-BsrwXuDz.js";import{t as Ee}from"./preview-modal-Dw_HtD6S.js";``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href,``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href,``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href,``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href;var J=n(),De=({senderName:e,senderEmail:t,senderReplyTo:n,headerImage:r,headerIcon:i,headerTitle:a,headerSubtitle:o,showPostTitleSection:c,showExcerpt:l,titleAlignment:u,titleFontCategory:d,titleFontWeight:f,bodyFontCategory:p,authorPlaceholder:m,showCommentCta:h,showFeatureImage:g,showFeedback:_,showShareButton:v,showLatestPosts:y,showSubscriptionDetails:b,siteTitle:x,footerContent:S,showBadge:C,backgroundColor:w,headerBackgroundColor:T,accentColor:E,textColor:D,secondaryTextColor:O,headerTextColor:k,secondaryHeaderTextColor:A,postTitleColor:ee,sectionTitleColor:j,dividerColor:M,buttonColor:N,buttonTextColor:P,linkColor:F,buttonCorners:I,buttonStyle:L,imageCorners:z,linkStyle:B,dividerStyle:V})=>{let ie=i||a,{config:ae}=W(),H=new Date().toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`numeric`}),oe=new Date().getFullYear(),ce=S?S.replace(/<a/g,`<a target="_blank" rel="noopener noreferrer"`):``,ue;ue=ne(ae)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`From: `}),(0,J.jsxs)(`span`,{children:[e,` (`,t,`)`]})]}),(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`Reply-to: `}),n||t]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:e}),(0,J.jsxs)(`span`,{children:[` `,t]})]}),(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`To:`}),` Jamie Larson jamie@example.com`]})]});let U=`mb-5 text-pretty leading-[1.7] text-black`;return U=d===`serif`&&p===`serif`?s(U,`mb-8 font-serif text-[2.0rem] leading-tight`):d!==`serif`&&p===`serif`?s(U,`mb-8 text-[1.7rem] leading-tight tracking-tight`):d===`serif`&&p!==`serif`?s(U,`mb-8 font-serif text-[2.0rem] leading-tight`):s(U,`mb-8 text-[1.9rem] leading-tight tracking-tight`),u===`center`&&(U=s(U,`text-center`)),(0,J.jsx)(`div`,{className:`relative flex grow flex-col`,children:(0,J.jsx)(`div`,{className:`absolute inset-0 m-5 flex items-center justify-center`,children:(0,J.jsxs)(`div`,{className:`mx-auto my-0 flex max-h-full w-full max-w-[700px] flex-col overflow-hidden rounded-[4px] text-black shadow-sm`,children:[(0,J.jsx)(`div`,{className:`flex-column flex min-h-[77px] justify-center gap-1 rounded-t-sm border-b border-grey-200 bg-white px-6 text-grey-700`,children:ue}),(0,J.jsxs)(`div`,{className:`overflow-y-auto`,style:{backgroundColor:w},children:[(0,J.jsxs)(`div`,{className:`px-[7rem]`,style:{backgroundColor:T},children:[r&&(0,J.jsx)(`div`,{children:(0,J.jsx)(`img`,{alt:``,className:`mb-4 block pt-6`,src:r})}),ie&&(0,J.jsxs)(`div`,{className:`py-3`,children:[i&&(0,J.jsx)(`img`,{alt:``,className:`mx-auto mb-2 size-10`,role:`presentation`,src:i}),a&&(0,J.jsx)(`h4`,{className:`mb-1 text-center text-[1.6rem] leading-tight font-bold tracking-tight text-grey-900 uppercase`,style:{color:k},children:a}),o&&(0,J.jsx)(`h5`,{className:`mb-1 text-center text-[1.3rem] font-normal text-grey-700`,style:{color:A},children:o})]}),c&&(0,J.jsxs)(`div`,{className:s(`flex flex-col py-8`,u===`center`?`items-center`:`items-start`),children:[(0,J.jsx)(`h2`,{className:s(`text-4xl leading-supertight font-bold text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`,u===`center`?`text-center`:`text-left`,l?`mb-2`:`mb-8`),style:{color:ee},children:`Your email newsletter`}),l&&(0,J.jsx)(`p`,{className:U,style:{color:k},children:`A subtitle to highlight key points and engage your readers.`}),(0,J.jsxs)(`div`,{className:s(`flex w-full justify-between text-center text-md leading-none text-grey-700`,u===`center`?`flex-col gap-1`:`flex-row`),children:[(0,J.jsxs)(`p`,{className:`pb-1 text-[1.3rem]`,style:{color:A},children:[`By `,m,(0,J.jsx)(`span`,{className:`before:pr-1 before:pl-0.5 before:content-['•']`,children:H})]}),(0,J.jsx)(`p`,{className:`pb-1 text-[1.3rem] underline`,style:{color:A},children:(0,J.jsx)(`span`,{children:`View in browser`})})]})]}),g&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:s(`h-[unset] w-full max-w-[600px] bg-cover bg-no-repeat`,c?``:`pt-6`),children:(0,J.jsx)(`img`,{alt:`Feature`,className:s(`min-h-full min-w-full shrink-0`,z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href})}),(0,J.jsx)(`div`,{className:`mt-1 w-full max-w-[600px] pb-8 text-center text-[1.3rem] text-grey-700`,style:{color:A},children:`Feature image caption`})]})]}),(0,J.jsxs)(`div`,{className:s(`px-[7rem]`,T!==`transparent`&&`pt-10`),children:[(0,J.jsxs)(`div`,{className:s(`max-w-[600px] border-b border-grey-200 pb-[52px] leading-[27.2px] text-black`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`,p===`serif`?`font-serif text-[1.8rem]`:`text-[1.7rem] tracking-tight`,g||c?``:`pt-8`),style:{borderColor:M},children:[(0,J.jsx)(`p`,{className:`mb-6`,style:{color:D},children:`This is what your content will look like when you send one of your posts as an email newsletter to your subscribers.`}),(0,J.jsx)(`p`,{className:`mb-6`,style:{color:D},children:`Over there on the right you'll see some settings that allow you to customize the look and feel of this template – from colors and typography to layout and buttons – to make it perfectly suited to your brand.`}),(0,J.jsx)(`p`,{className:`mb-[52px]`,style:{color:D},children:`Email templates are exceptionally finnicky to make, but we've spent a long time optimising this one to make it work beautifully across devices, email clients and content types. So, you can trust that every email you send with Ghost will look great and work well. Just like the rest of your site.`}),(0,J.jsx)(`hr`,{className:s(`my-[52px] border-[#e0e7eb]`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-t-0 border-b-2 border-dotted`),style:{borderColor:M}}),(0,J.jsx)(`h3`,{className:s(`mb-[13px] text-[2.6rem] leading-supertight`,d===`serif`&&`font-serif`,d===`sans_serif`&&`font-sans`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`Need inspiration?`}),(0,J.jsxs)(`p`,{className:`mb-[27px]`,style:{color:D},children:[`We've put together a `,(0,J.jsx)(`a`,{className:s(B===`underline`&&`underline`,B===`bold`&&`font-bold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:{color:F||E},target:`_blank`,children:`quick guide`}),` that walks through all of the available settings, along with a few examples of what's possible.`]}),(0,J.jsx)(`a`,{className:s(`inline-block border px-[18px] py-2 font-sans text-[15px]`,I===`rounded`&&`rounded-[6px]`,I===`pill`&&`rounded-full`,I===`square`&&`rounded-none`,L===`outline`?`bg-transparent`:`border-transparent text-white`,B===`bold`?`font-bold`:`font-semibold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:L===`outline`?{borderColor:N||E,color:N||E}:{backgroundColor:N||E,color:P},target:`_blank`,children:`Learn more`})]}),(_||h||v)&&(0,J.jsx)(`div`,{className:s(`grid gap-5 border-b border-grey-200 px-6 py-5`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:M},children:(0,J.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-4`,children:[_&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(re,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`More like this`})]}),(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(R,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Less like this`})]})]}),h&&(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(le,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Comment`})]}),v&&(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(se,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Share`})]})]})}),y&&(0,J.jsxs)(`div`,{className:s(`border-b border-grey-200 py-6`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:M},children:[(0,J.jsx)(`h3`,{className:`mt-2 mb-4 pb-1 text-[1.2rem] font-semibold tracking-wide text-black uppercase`,style:{color:D},children:`Keep reading`}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:s(`mt-0.5 text-[1.9rem] text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`The three latest posts published on your site`}),(0,J.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:O},children:`Posts sent as an email only will never be shown here.`})]}),(0,J.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,J.jsx)(`img`,{alt:`Latest post`,className:s(z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href})})]}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:s(`mt-0.5 text-[1.9rem] text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`Displayed at the bottom of each newsletter`}),(0,J.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:O},children:`Giving your readers one more place to discover your stories.`})]}),(0,J.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,J.jsx)(`img`,{alt:`Latest post`,className:s(z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href})})]}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:s(`mt-0.5 text-[1.9rem] text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`To keep your work front and center`}),(0,J.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:O},children:`Making sure that your audience stays engaged.`})]}),(0,J.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,J.jsx)(`img`,{alt:`Latest post`,className:s(z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href})})]})]}),b&&(0,J.jsxs)(`div`,{className:s(`border-b border-grey-200 py-8`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:M},children:[(0,J.jsx)(`h4`,{className:`mb-3 text-[1.2rem] tracking-wide text-black uppercase`,style:{color:D},children:`Subscription details`}),(0,J.jsxs)(`p`,{className:`m-0 mb-4 text-base`,style:{color:D},children:[`You are receiving this because you are a paid subscriber to `,x,`. Your subscription will renew on 17 Jul 2024.`]}),(0,J.jsxs)(`div`,{className:`flex`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 text-base`,children:[(0,J.jsx)(`p`,{style:{color:D},children:`Name: Jamie Larson`}),(0,J.jsx)(`p`,{style:{color:D},children:`Email: jamie@example.com`}),(0,J.jsx)(`p`,{style:{color:D},children:`Member since: 17 July 2023`})]}),(0,J.jsx)(`span`,{className:s(`w-full self-end text-right text-base whitespace-nowrap`,B===`underline`&&`underline`,B===`bold`&&`font-bold`),style:{color:F||E},children:`Manage subscription`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col items-center pt-10`,children:[(0,J.jsx)(`div`,{dangerouslySetInnerHTML:{__html:ce||``},className:`text px-8 py-3 text-center text-[1.3rem] leading-base break-words text-grey-700 [&_a]:underline`,style:{color:O}}),(0,J.jsxs)(`div`,{className:`px-8 pt-3 pb-14 text-center text-[1.3rem] text-grey-700`,children:[(0,J.jsxs)(`span`,{style:{color:O},children:[x,` © `,oe,` — `]}),(0,J.jsx)(`span`,{className:`pointer-events-none cursor-auto underline`,style:{color:O},children:`Unsubscribe`})]}),C&&(0,J.jsx)(`div`,{className:`flex flex-col items-center pt-[10px] pb-[40px]`,children:(0,J.jsxs)(`a`,{className:`pointer-events-none inline-flex cursor-auto items-center px-2 py-1 text-[1.25rem] font-semibold tracking-tight text-grey-900`,href:`https://ghost.org`,style:{color:D},children:[(0,J.jsx)(te,{className:`mr-[6px] size-4`}),(0,J.jsx)(`span`,{children:`Powered by Ghost`})]})})]})]})]})]})})})},Y=e(t(),1),Oe=({newsletter:e})=>{let{currentUser:t,settings:n,siteData:r,config:i}=W(),[a,o,s,c,l]=I(n,[`title`,`icon`,`comments_enabled`,`support_email_address`,`default_email_address`]),u=null;e.show_header_title?u=a||null:e.show_header_name&&(u=e.name);let d=e.show_header_title&&e.show_header_name?e.name:void 0,f=e.show_comment_cta&&s!==`off`,p=e.feedback_enabled,m=e.show_share_button,h=()=>{let t=e.background_color;return/#([0-9a-f]{3}){1,2}$/i.test(t)?t:`#ffffff`},g=()=>{let t=e.header_background_color;return!t||t===`transparent`?`transparent`:/#([0-9a-f]{3}){1,2}$/i.test(t)?t:`transparent`},_=()=>{let t=e.button_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===null?q(h()).hex():r.accent_color},v=()=>{let t=e.button_style,n=_();if(n&&t===`fill`)return q(n).hex()},y=()=>{let t=e.link_color===void 0?`accent`:e.link_color;return t===`accent`?r.accent_color:/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:q(h()).hex()},b=()=>{let t=e.post_title_color;if(/#([0-9a-f]{3}){1,2}$/i.test(t||``))return t;if(t===`accent`)return r.accent_color;let n=g();return q(n===`transparent`?h():n).hex()},x=()=>{let t=e.section_title_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:q(h()).hex()},S=()=>{let t=e.divider_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:`#e0e7eb`},C=q(h()).hex(),w=q(h()).alpha(.5).toString(),T=g()===`transparent`?C:q(g()).hex(),E=g()===`transparent`?w:q(g()).alpha(.5).toString(),D={backgroundColor:h(),headerBackgroundColor:g(),postTitleColor:b()||void 0,sectionTitleColor:x()||void 0,buttonColor:_()||void 0,buttonTextColor:v()||void 0,linkColor:y()||void 0,dividerColor:S()||void 0,textColor:C,secondaryTextColor:w,headerTextColor:T,secondaryHeaderTextColor:E};return(0,J.jsx)(De,{accentColor:r.accent_color,authorPlaceholder:t.name||t.email,backgroundColor:D.backgroundColor||`#ffffff`,bodyFontCategory:e.body_font_category,buttonCorners:e.button_corners||`rounded`,buttonStyle:e.button_style||`fill`,dividerStyle:e.divider_style||`solid`,footerContent:e.footer_content,headerBackgroundColor:D.headerBackgroundColor||`transparent`,headerIcon:e.show_header_icon?o:void 0,headerImage:e.header_image,headerSubtitle:d,headerTitle:u,imageCorners:e.image_corners||`square`,linkStyle:e.link_style||`underline`,senderEmail:we(e,i,l),senderName:e.sender_name||a,senderReplyTo:K(e,i,c,l),showBadge:e.show_badge,showCommentCta:f,showExcerpt:e.show_excerpt,showFeatureImage:e.show_feature_image,showFeedback:p,showLatestPosts:e.show_latest_posts,showPostTitleSection:e.show_post_title_section,showShareButton:m,showSubscriptionDetails:e.show_subscription_details,siteTitle:a,titleAlignment:e.title_alignment,titleFontCategory:e.title_font_category,titleFontWeight:e.title_font_weight||`bold`,...D})},X=e(ge(),1),Z=({label:e,value:t,options:n,onValueChange:r})=>(0,J.jsx)(j,{"aria-label":e,type:`single`,value:t,onValueChange:e=>e&&r(e),children:n.map(e=>(0,J.jsxs)(N,{children:[(0,J.jsx)(fe,{asChild:!0,children:(0,J.jsx)(ee,{"aria-label":e.label,disabled:e.disabled,value:e.value,children:e.icon})}),(0,J.jsx)(P,{children:e.label})]},e.value))}),ke=({newsletter:e,updateNewsletter:t,errors:n,clearError:r})=>{let{settings:i,config:a}=W(),[o,s]=I(i,[`default_email_address`,`support_email_address`]),[c,l]=(0,Y.useState)(K(e,a,s,o)||``),u=we(e,a,o),d=(0,Y.useCallback)(e=>{l(e.target.value),t({sender_reply_to:e.target.value||`newsletter`})},[t,l]);return(0,J.jsxs)(k,{"data-invalid":!!n.sender_reply_to||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-reply-to`,children:`Reply-to email`}),(0,J.jsx)(H,{"aria-invalid":!!n.sender_reply_to||void 0,id:`newsletter-reply-to`,maxLength:191,placeholder:u||``,value:c,onBlur:()=>{let t=K(e,a,s,o)||``;l(t)},onChange:d,onKeyDown:()=>r(`sender_reply_to`)}),n.sender_reply_to&&(0,J.jsx)(w,{children:n.sender_reply_to})]})},Ae=({newsletter:e,onlyOne:t,updateNewsletter:n,validate:a,errors:o,clearError:s})=>{let{updateRoute:ee}=x(),{mutateAsync:j}=me(),te=ye(),{settings:N,config:P,siteData:R}=W(),[re,se]=I(N,[`icon`,`default_email_address`]),[le,fe]=(0,Y.useState)(`generalSettings`),{localSettings:pe}=xe(),[ge]=I(pe,[`title`]),Se=r(),{data:{newsletters:K}={}}=he(),Ee=[`all`,`paid`].includes(M(N,`comments_enabled`)||``),De=we(e,P,se),[Oe,X]=(0,Y.useState)(K||[]),Ae=Oe.filter(e=>e.status===`active`);(0,Y.useEffect)(()=>{X(K||[])},[K]);let je=[{value:`serif`,label:`Elegant serif`,className:`font-serif`},{value:`sans_serif`,label:`Clean sans-serif`}],Q={sans_serif:{options:[{value:`normal`,label:`Regular`,className:`font-normal`},{value:`medium`,label:`Medium`,className:`font-medium`},{value:`semibold`,label:`Semi-bold`,className:`font-semibold`},{value:`bold`,label:`Bold`,className:`font-bold`}]},serif:{options:[{value:`normal`,label:`Regular`,className:`font-normal`},{value:`bold`,label:`Bold`,className:`font-bold`}],map:{medium:`normal`,semibold:`bold`}}},$=()=>e.background_color===`light`?!1:q(e.background_color).hex().toLowerCase()===`#ffffff`,Me=async()=>{if(e.status===`active`)b.show(_e,{title:`Archive newsletter`,prompt:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mb-6`,children:[`Your newsletter `,(0,J.jsx)(`strong`,{children:e.name}),` will no longer be visible to members or available as an option when publishing new posts.`]}),(0,J.jsx)(`div`,{children:`Existing posts previously sent as this newsletter will remain unchanged.`})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async t=>{try{await j({...e,status:`archived`}),t?.remove(),i.success(`Newsletter archived`)}catch(e){Se(e)}}});else{try{await te?.errorIfWouldGoOverLimit(`newsletters`)}catch(e){if(e instanceof be){b.show(ve,{prompt:e.message||`Your current plan doesn't support more newsletters.`,onOk:()=>ee({route:`/pro`,isExternal:!0})});return}else throw e}b.show(_e,{title:`Reactivate newsletter`,prompt:(0,J.jsxs)(J.Fragment,{children:[`Reactivating `,(0,J.jsx)(`strong`,{children:e.name}),` will immediately make it visible to members and re-enable it as an option when publishing new posts.`]}),okLabel:`Reactivate`,onOk:async t=>{await j({...e,status:`active`}),t?.remove(),i.success(`Newsletter reactivated`)}})}},Ne=()=>{if(!ne(P))return(0,J.jsxs)(k,{"data-invalid":!!o.sender_email||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,J.jsx)(H,{"aria-invalid":!!o.sender_email||void 0,id:`newsletter-sender-email`,placeholder:De||``,value:e.sender_email||``,onChange:e=>n({sender_email:e.target.value}),onKeyDown:()=>s(`sender_email`)}),o.sender_email&&(0,J.jsx)(w,{children:o.sender_email})]});if(F(P))return(0,J.jsxs)(k,{"data-invalid":!!o.sender_email||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,J.jsx)(H,{"aria-invalid":!!o.sender_email||void 0,id:`newsletter-sender-email`,maxLength:191,placeholder:se,value:e.sender_email||``,onChange:e=>{n({sender_email:e.target.value})},onKeyDown:()=>s(`sender_email`)}),o.sender_email&&(0,J.jsx)(w,{children:o.sender_email})]})},Pe=Q[e.title_font_category||`sans_serif`].options,Fe=[{id:`generalSettings`,title:`General`,contents:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Name and description`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(k,{"data-invalid":!!o.name||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-detail-name`,children:`Name`}),(0,J.jsx)(H,{"aria-invalid":!!o.name||void 0,id:`newsletter-detail-name`,maxLength:191,placeholder:`Weekly Roundup`,value:e.name||``,onChange:e=>n({name:e.target.value}),onKeyDown:()=>s(`name`)}),o.name&&(0,J.jsx)(w,{children:o.name})]}),(0,J.jsxs)(k,{children:[(0,J.jsx)(E,{htmlFor:`newsletter-description`,children:`Description`}),(0,J.jsx)(A,{id:`newsletter-description`,maxLength:2e3,rows:2,value:e.description||``,onChange:e=>n({description:e.target.value})})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Email info`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(k,{children:[(0,J.jsx)(E,{htmlFor:`newsletter-sender-name`,children:`Sender name`}),(0,J.jsx)(H,{id:`newsletter-sender-name`,maxLength:191,placeholder:ge,value:e.sender_name||``,onChange:e=>n({sender_name:e.target.value})})]}),Ne(),(0,J.jsx)(ke,{clearError:s,errors:o,newsletter:e,updateNewsletter:n,validate:a})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Member settings`}),(0,J.jsx)(S,{children:(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-subscribe-on-signup`,children:`Subscribe new members on signup`}),(0,J.jsx)(m,{checked:!!e.subscribe_on_signup,id:`newsletter-subscribe-on-signup`,onCheckedChange:e=>n({subscribe_on_signup:e})})]})})]}),(0,J.jsx)(`div`,{className:`mt-10 mb-5`,children:e.status===`active`?!t&&(0,J.jsx)(L,{className:`text-destructive hover:text-destructive`,disabled:Ae.length===1,type:`button`,variant:`ghost`,onClick:Me,children:`Archive newsletter`}):(0,J.jsx)(L,{className:`text-green hover:text-green`,type:`button`,variant:`ghost`,onClick:Me,children:`Reactivate newsletter`})})]})},{id:`content`,title:`Content`,contents:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Header`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(Ce,{inputId:`newsletter-header-image`,value:e.header_image||``,onChange:e=>n({header_image:e||null}),onUploadError:Se}),(0,J.jsxs)(l,{gap:`md`,children:[re&&(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-header-icon`,children:`Publication icon`}),(0,J.jsx)(m,{checked:!!e.show_header_icon,id:`newsletter-show-header-icon`,onCheckedChange:e=>n({show_header_icon:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-header-title`,children:`Publication title`}),(0,J.jsx)(m,{checked:!!e.show_header_title,id:`newsletter-show-header-title`,onCheckedChange:e=>n({show_header_title:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-header-name`,children:`Newsletter name`}),(0,J.jsx)(m,{checked:!!e.show_header_name,id:`newsletter-show-header-name`,onCheckedChange:e=>n({show_header_name:e})})]})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Title section`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-post-title`,children:`Post title`}),(0,J.jsx)(m,{checked:!!e.show_post_title_section,id:`newsletter-show-post-title`,onCheckedChange:e=>n({show_post_title_section:e})})]}),e.show_post_title_section&&(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-excerpt`,children:`Post excerpt`}),(0,J.jsx)(m,{checked:!!e.show_excerpt,id:`newsletter-show-excerpt`,onCheckedChange:e=>n({show_excerpt:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-feature-image`,children:`Feature image`}),(0,J.jsx)(m,{checked:!!e.show_feature_image,id:`newsletter-show-feature-image`,onCheckedChange:e=>n({show_feature_image:e})})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Footer`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(l,{gap:`lg`,children:[(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-feedback-enabled`,children:`Ask your readers for feedback`}),(0,J.jsx)(m,{checked:!!e.feedback_enabled,id:`newsletter-feedback-enabled`,onCheckedChange:e=>n({feedback_enabled:e})})]}),Ee&&(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-comment-cta`,children:`Add a link to your comments`}),(0,J.jsx)(m,{checked:!!e.show_comment_cta,id:`newsletter-show-comment-cta`,onCheckedChange:e=>n({show_comment_cta:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-share-button`,children:`Show share button`}),(0,J.jsx)(m,{checked:!!e.show_share_button,id:`newsletter-show-share-button`,onCheckedChange:e=>n({show_share_button:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-latest-posts`,children:`Share your latest posts`}),(0,J.jsx)(m,{checked:!!e.show_latest_posts,id:`newsletter-show-latest-posts`,onCheckedChange:e=>n({show_latest_posts:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-subscription-details`,children:`Show subscription details`}),(0,J.jsx)(m,{checked:!!e.show_subscription_details,id:`newsletter-show-subscription-details`,onCheckedChange:e=>n({show_subscription_details:e})})]})]}),(0,J.jsx)(Te,{hint:`Any extra information or legal text`,nodes:`MINIMAL_NODES`,placeholder:` `,title:`Email footer`,value:e.footer_content||``,onChange:e=>n({footer_content:e})})]})]}),(0,J.jsx)(V,{className:`mt-8`}),(0,J.jsxs)(`div`,{className:`my-5 flex w-full items-start`,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(ie,{className:`mt-[-1px] mr-2 size-5 text-red`})}),(0,J.jsx)(S,{className:`gap-8`,children:(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsxs)(T,{children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-badge`,children:`Promote independent publishing`}),(0,J.jsx)(D,{children:`Show you're a part of the indie publishing movement with a small badge in the footer`})]}),(0,J.jsx)(m,{checked:!!e.show_badge,id:`newsletter-show-badge`,onCheckedChange:e=>n({show_badge:e})})]})})]})]})},{id:`design`,title:`Design`,contents:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Global`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{hex:`#ffffff`,value:`light`,title:`White`}],title:`Background color`,value:e.background_color||`light`,onChange:e=>n({background_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:`Heading font`}),(0,J.jsxs)(k,{className:`max-w-[200px]`,children:[(0,J.jsx)(E,{className:`sr-only`,children:`Heading font`}),(0,J.jsxs)(y,{value:e.title_font_category,onValueChange:t=>{let r=e.title_font_weight,i=r;return Q[t].options.find(e=>e.value===r)||(i=Q[t].map?.[r]||`bold`),n({title_font_category:t,title_font_weight:i})},children:[(0,J.jsx)(_,{"aria-label":`Heading font`,children:(0,J.jsx)(v,{})}),(0,J.jsx)(g,{children:je.map(e=>(0,J.jsx)(h,{value:e.value,children:(0,J.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:`Heading weight`}),(0,J.jsxs)(k,{className:`max-w-[200px]`,children:[(0,J.jsx)(E,{className:`sr-only`,children:`Heading weight`}),(0,J.jsxs)(y,{value:(()=>{let t=e.title_font_category||`sans_serif`,n=e.title_font_weight,r=Q[t].map,i=r&&r[n]||n;return Pe.find(e=>e.value===i)||Pe[0]})().value,onValueChange:e=>n({title_font_weight:e}),children:[(0,J.jsx)(_,{"aria-label":`Heading weight`,children:(0,J.jsx)(v,{})}),(0,J.jsx)(g,{children:Pe.map(e=>(0,J.jsx)(h,{value:e.value,children:(0,J.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:`Body font`}),(0,J.jsxs)(k,{className:`max-w-[200px]`,children:[(0,J.jsx)(E,{className:`sr-only`,children:`Body font`}),(0,J.jsxs)(y,{value:e.body_font_category,onValueChange:e=>n({body_font_category:e}),children:[(0,J.jsx)(_,{"aria-label":`Body font`,"data-testid":`body-font-select`,children:(0,J.jsx)(v,{})}),(0,J.jsx)(g,{children:je.map(e=>(0,J.jsx)(h,{value:e.value,children:(0,J.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Header`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`transparent`,title:`Transparent`,hex:`#00000000`}],title:`Header background color`,value:e.header_background_color||`transparent`,onChange:e=>n({header_background_color:e})})}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:R.accent_color}],title:`Post title color`,value:e.post_title_color,onChange:e=>n({post_title_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Title alignment`}),(0,J.jsx)(Z,{label:`Title alignment`,options:[{value:`left`,label:`Left`,icon:(0,J.jsx)(de,{className:`size-3.5!`}),disabled:!e.show_post_title_section},{value:`center`,label:`Center`,icon:(0,J.jsx)(ce,{className:`size-3.5!`}),disabled:!e.show_post_title_section}],value:e.title_alignment,onValueChange:e=>n({title_alignment:e})})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Body`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:R.accent_color}],title:`Section title color`,value:e.section_title_color,onChange:e=>n({section_title_color:e})})}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:R.accent_color},{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`}],title:`Button color`,value:e.button_color,onChange:e=>n({button_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Button style`}),(0,J.jsx)(Z,{label:`Button style`,options:[{value:`fill`,label:`Fill`,icon:(0,J.jsx)(U,{className:`size-3.5!`,fill:`currentColor`})},{value:`outline`,label:`Outline`,icon:(0,J.jsx)(U,{className:`size-3.5!`})}],value:e.button_style||`fill`,onValueChange:e=>n({button_style:e})})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Button corners`}),(0,J.jsx)(Z,{label:`Button corners`,options:[{value:`square`,label:`Squared`,icon:(0,J.jsx)(ae,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,J.jsx)(U,{className:`size-3.5!`})},{value:`pill`,label:`Pill`,icon:(0,J.jsx)(ue,{className:`size-3.5!`})}],value:e.button_corners||`rounded`,onValueChange:e=>n({button_corners:e})})]}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:R.accent_color},{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`}],title:`Link color`,value:e.link_color,onChange:e=>n({link_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Link style`}),(0,J.jsx)(Z,{label:`Link style`,options:[{value:`underline`,label:`Underline`,icon:(0,J.jsx)(z,{className:`size-3.5!`})},{value:`regular`,label:`Regular`,icon:(0,J.jsx)(B,{className:`size-3.5!`})},{value:`bold`,label:`Bold`,icon:(0,J.jsx)(oe,{className:`size-3.5!`})}],value:e.link_style||`underline`,onValueChange:e=>n({link_style:e})})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Image corners`}),(0,J.jsx)(Z,{label:`Image corners`,options:[{value:`square`,label:`Squared`,icon:(0,J.jsx)(ae,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,J.jsx)(U,{className:`size-3.5!`})}],value:e.image_corners||`square`,onValueChange:e=>n({image_corners:e})})]}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`light`,title:`Light`,hex:`#e0e7eb`},{value:`accent`,title:`Accent`,hex:R.accent_color}],title:`Divider color`,value:e.divider_color||`light`,onChange:e=>n({divider_color:e})})})]})]})]})}];return(0,J.jsx)(`div`,{className:`flex flex-col`,children:(0,J.jsx)(`div`,{className:`px-7 pt-0 pb-7`,children:(0,J.jsxs)(p,{value:le,variant:`underline`,onValueChange:e=>{fe(e)},children:[(0,J.jsx)(f,{className:`sticky top-0 z-50 bg-surface-elevated-2`,children:Fe.map(e=>(0,J.jsx)(u,{value:e.id,children:e.title},e.id))}),Fe.map(e=>(0,J.jsx)(d,{value:e.id,children:e.contents},e.id))]})})})},je=({newsletter:e,onlyOne:t})=>{let{config:n}=W(),{mutateAsync:o}=me(),{updateRoute:s}=x(),c=Se(`automations`)?`emails`:`newsletters`,{formState:l,saveState:u,updateForm:d,setFormState:f,handleSave:p,validate:m,errors:h,clearError:g,okProps:_}=a({initialState:e,savingDelay:500,onSave:async()=>{let{meta:{sent_email_verification:[e]=[]}={}}=await o(l),t;(e&&e===`sender_email`||e&&e===`sender_reply_to`)&&(t=(0,J.jsx)(`div`,{children:`We‘ve sent a confirmation email to the new address.`})),t&&i.info(t)},onSaveError:r(),onValidate:()=>{let e={};return l.name||(e.name=`A name is required for your newsletter`),l.sender_email&&!X.default.isEmail(l.sender_email)?e.sender_email=`Enter a valid email address`:l.sender_email&&F(n)&&l.sender_email.split(`@`)[1]!==pe(n)&&(e.sender_email=`Email address must end with @${pe(n)}`),l.sender_reply_to&&!X.default.isEmail(l.sender_reply_to)&&![`newsletter`,`support`].includes(l.sender_reply_to)&&(e.sender_reply_to=`Enter a valid email address`),e}}),v=e=>{d(t=>({...t,...e}))};(0,Y.useEffect)(()=>{f(()=>e)},[f,e]);let y=(0,J.jsx)(Oe,{newsletter:l}),b=(0,J.jsx)(Ae,{clearError:g,errors:h,newsletter:l,onlyOne:t,updateNewsletter:v,validate:m});return(0,J.jsx)(Ee,{buttonsDisabled:_.disabled,cancelLabel:`Close`,dirty:u===`unsaved`,okLabel:_.label||`Save`,okVariant:_.variant,preview:y,previewBgColor:`grey`,previewToolbar:!1,sidebar:b,sidebarPadding:!1,testId:`newsletter-modal`,title:`Newsletter`,onClose:()=>s(c),onOk:async()=>{await p({fakeWhenUnchanged:!0})}})},Q=()=>{let{newsletterId:e}=o(),{data:{newsletters:t,isEnd:n}={},fetchNextPage:r}=he(),i=t?.find(({id:t})=>t===e);return(0,Y.useEffect)(()=>{!i&&!n&&r()},[r,n,i]),i?(0,J.jsx)(je,{newsletter:i,onlyOne:t.length===1}):null};export{Q as default};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-DAXXjFlN.js";import{t as e}from"./react-Bb3IsNbi.js";import{t}from"./jsx-runtime-DX3WBWVO.js";import{f as n}from"./dist-Cb5RSHSg.js";import{o as r,r as i,t as a}from"./field-Dh_lwk13.js";import{Ls as o,Rs as s,Yi as c}from"./index-BHy2DZX-.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./images-CrQKVc9Q.js";e();var _=t(),v=({inputId:e=`welcome-email-header-image`,onUploadError:t,value:o,onChange:s})=>{let{mutateAsync:v}=f(),y=async e=>{try{s(g(await v({file:e})))}catch(e){if(t){t(e);return}throw e}};return(0,_.jsxs)(a,{"data-testid":`header-image-field`,children:[(0,_.jsx)(r,{htmlFor:e,children:`Header image`}),(0,_.jsx)(m,{className:`aspect-[2/1] w-full`,children:o?(0,_.jsxs)(u,{children:[(0,_.jsx)(h,{alt:`Header`,src:o}),(0,_.jsx)(l,{children:(0,_.jsx)(d,{"aria-label":`Remove header image`,type:`button`,onClick:()=>s(``),children:(0,_.jsx)(c,{})})})]}):(0,_.jsx)(p,{accept:{"image/*":[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.svg`]},inputId:e,onDropAccepted:e=>e[0]&&y(e[0]),children:(0,_.jsx)(`span`,{className:`text-control font-medium`,children:`Upload header image`})})}),(0,_.jsxs)(i,{children:[n(1200),`×`,n(600),` recommended. Use a transparent PNG for best results on any background.`]})]})},y=(e,t,n)=>s(t)&&!o(t)&&n?n:e.sender_email||n||``,b=(e,t,n,r)=>e.sender_reply_to===`newsletter`?s(t)?``:y(e,t,r):e.sender_reply_to===`support`?n||r||``:e.sender_reply_to,x=(e,t,n,r)=>b(e,t,n,r)||(e.sender_reply_to===`newsletter`?y(e,t,r)||n||r||``:n||r||``);export{v as i,x as n,y as r,b as t};
@@ -0,0 +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{c as r,g as i,i as a,r as o}from"./stats-D8nZCTy5.js";import{g as s}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as c,t as l}from"./router-provider-DSQfprxH.js";import{f as u,l as d,p as f}from"./dist-Cb5RSHSg.js";import{g as p,n as m,o as h,r as g}from"./chart-BnXyfH11.js";import{a as _,c as v,i as y,l as b,n as x,t as ee,u as te}from"./chart-helpers-CZElTGYL.js";import{n as ne,t as S}from"./sort-button-CdBsm40v.js";import{r as re,t as ie}from"./tabs-Dd6oOKbv.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./select-D9oU1IoM.js";import{a as A,n as j,o as M,r as N,t as P}from"./card-aUHX0hyR.js";import{t as F}from"./empty-indicator-WB1WgT9h.js";import{a as I,c as L,n as R,r as z,s as B,t as V}from"./table-TMCgCQK7.js";import{$a as H,$r as U,Br as ae,Kr as W,Pr as G,Qa as oe,Vs as K,Wr as q,Yr as se,Zr as ce,ai as le,ir as J,p as Y,sr as ue}from"./index-BHy2DZX-.js";import{i as de,n as fe,r as pe,t as me}from"./stats-view-CugFVf0g.js";import{n as X,r as Z,t as he}from"./kpi-tabs-X3DkOYbI.js";import{t as ge}from"./use-analytics-data-B-b4wNSC.js";import{r as _e}from"./newsletters-Du0lzskS.js";var Q=e(t(),1),$=n(),ve=({active:e,payload:t})=>{if(!e||!t?.length)return null;let n=t[0].payload,r=typeof n.send_date==`string`?n.send_date:n.send_date.toISOString().split(`T`)[0];return(0,$.jsxs)(`div`,{className:`max-w-[240px] min-w-[220px] rounded-lg border bg-background px-3 py-2 shadow-lg`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex w-full flex-col border-b pb-2`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-tight font-semibold`,children:n.post_title}),(0,$.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Sent on `,d(r)]})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Sent`}),(0,$.jsx)(`div`,{className:`ml-2 w-full text-right font-mono`,children:u(n.sent_to)})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Opens`}),(0,$.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(n.total_opens),` / `]}),f(n.open_rate)]})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Clicks`}),(0,$.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(n.total_clicks),` / `]}),f(n.click_rate)]})]})]})},ye=({subscribersData:e,avgsData:t,totals:n,isLoading:r,isAvgsLoading:i,initialTab:a=`total-subscribers`})=>{let[o,l]=(0,Q.useState)(a),[d,S]=(0,Q.useState)(!1),{range:C}=Y(),w=c(),[T]=s(),{appSettings:E}=K(),{emailTrackClicks:D,emailTrackOpens:O}=E?.analytics||{},{totalSubscribers:k,avgOpenRate:A,avgClickRate:j}=n,M=(0,Q.useMemo)(()=>{if(!e||e.length===0)return[];let t=[];return t=y(e,C,`value`,`exact`),t.map(e=>({...e,formattedValue:u(e.value),label:`Total Subscribers`}))},[e,C]),N=(0,Q.useMemo)(()=>ee(C,e||[]),[e,C]),P=(0,Q.useMemo)(()=>{if(!M||M.length<=1)return{direction:`same`,value:`0%`};let e=M[0]?.value??0,t=M[M.length-1]?.value??0,n=`same`;t>e?n=`up`:t<e&&(n=`down`);let r;if(e===0)r=t===0?`0%`:`+100%`;else{let n=(t-e)/e*100,i=Math.round(n*10)/10;r=`${n>=0?`+`:``}${i}%`}return{direction:n,value:r}},[M]);(0,Q.useEffect)(()=>{l(a)},[a]);let I=e=>{l(e);let t=new URLSearchParams(T);t.set(`tab`,e),w(`?${t.toString()}`,{replace:!0})},L={open_rate:{label:`Open rate`}},R=(0,Q.useMemo)(()=>({"total-subscribers":{color:`var(--chart-darkblue)`,datakey:`value`},"avg-open-rate":{color:`var(--chart-blue)`,datakey:`open_rate`},"avg-click-rate":{color:`var(--chart-teal)`,datakey:`click_rate`}}),[]),{barDomain:z,barTicks:B}=(0,Q.useMemo)(()=>{if(!t||t.length===0||o===`total-subscribers`)return{barDomain:[0,1],barTicks:[0,1]};let e=R[o]?.datakey;if(!e)return{barDomain:[0,1],barTicks:[0,1]};let n=t.map(t=>t[e]).filter(e=>typeof e==`number`);if(n.length===0)return{barDomain:[0,1],barTicks:[0,1]};let r=o===`avg-open-rate`?A:j,i=Math.max(Math.max(...n),r),a;return a=i<.01?.01:i<.1?(Math.floor(i*100)+1)/100:(Math.floor(i*10)+1)/10,{barDomain:[0,a],barTicks:[0,a]}},[t,o,R,A,j]);if(r)return(0,$.jsx)(`div`,{className:`-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center`,children:(0,$.jsx)(J,{})});let V=`grid-cols-3`;(!D||!O)&&(V=`grid-cols-2`),!D&&!O&&(V=`grid-cols-1`);let W=o===`avg-open-rate`&&A>z[0]&&A<z[1]||o===`avg-click-rate`&&j>z[0]&&j<z[1],G=o===`avg-open-rate`?A:j;return(0,$.jsxs)(ie,{defaultValue:a,variant:`kpis`,children:[(0,$.jsxs)(re,{className:`-mx-6 hidden grid-cols-3 md:visible! md:grid! ${V}`,children:[(0,$.jsx)(X,{className:`${!O&&!D&&`cursor-auto after:hidden`}`,value:`total-subscribers`,onClick:()=>{I(`total-subscribers`)},children:(0,$.jsx)(Z,{color:R[`total-subscribers`].color,"data-testid":`total-subscribers-value`,diffDirection:P.direction,diffValue:P.value,label:`Total subscribers`,value:u(k)})}),O&&(0,$.jsx)(X,{value:`avg-open-rate`,onClick:()=>{I(`avg-open-rate`)},children:(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-open-rate`].color,label:`Avg. open rate`,value:f(A)})}),D&&(0,$.jsx)(X,{value:`avg-click-rate`,onClick:()=>{I(`avg-click-rate`)},children:(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-click-rate`].color,label:`Avg. click rate`,value:f(j)})})]}),(0,$.jsxs)(se,{children:[(0,$.jsx)(le,{className:`md:hidden`,asChild:!0,children:(0,$.jsxs)(he,{children:[o===`total-subscribers`&&(0,$.jsx)(Z,{color:R[`total-subscribers`].color,label:`Total subscribers`,value:u(k)}),o===`avg-open-rate`&&O&&(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-open-rate`].color,label:`Avg. open rate`,value:f(A)}),o===`avg-click-rate`&&D&&(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-click-rate`].color,label:`Avg. click rate`,value:f(j)})]})}),(0,$.jsxs)(ce,{align:`end`,className:`w-56`,children:[(0,$.jsx)(U,{onClick:()=>I(`total-subscribers`),children:`Total subscribers`}),O&&(0,$.jsx)(U,{onClick:()=>I(`avg-open-rate`),children:`Avg. open rate`}),D&&(0,$.jsx)(U,{onClick:()=>I(`avg-click-rate`),children:`Avg. click rate`})]})]}),(0,$.jsxs)(`div`,{className:`my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:[o===`total-subscribers`&&(0,$.jsx)(_,{className:`-mb-3 h-[16vw] max-h-[320px] min-h-[180px] w-full`,color:R[`total-subscribers`].color,data:M,id:`mrr`,range:N}),(o===`avg-open-rate`&&O||o===`avg-click-rate`&&D)&&(0,$.jsx)($.Fragment,{children:i?(0,$.jsx)(`div`,{className:`h-[320px] w-full items-center justify-center`,children:(0,$.jsx)(J,{})}):t&&t.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{className:`aspect-auto h-[200px] w-full md:h-[220px] xl:h-[320px]`,config:L,children:(0,$.jsxs)(ne,{className:d?`cursor-pointer!`:``,data:t,margin:{top:20},onClick:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;t&&w(`/posts/analytics/${t}`,{crossApp:!0})},onMouseLeave:()=>S(!1),onMouseMove:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;S(!!t)},children:[(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:R[o].color,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:R[o].color,stopOpacity:.6})]})}),(0,$.jsx)(te,{horizontal:!0,stroke:`var(--border)`,vertical:!1}),(0,$.jsx)(b,{axisLine:{stroke:`var(--border)`,strokeWidth:1},dataKey:`post_id`,interval:0,stroke:`var(--border)`,tickFormatter:()=>``,tickLine:!1,tickMargin:10}),(0,$.jsx)(v,{axisLine:!1,domain:z,tickFormatter:e=>f(e),tickLine:!1,ticks:B,width:ae(B,e=>f(e))}),(0,$.jsx)(g,{content:(0,$.jsx)(ve,{}),cursor:!1,isAnimationActive:!1,position:{y:10}}),W&&(0,$.jsx)(h,{label:{value:`${f(G)}`,position:`left`,offset:8,fill:`var(--muted-foreground)`},opacity:.5,stroke:`var(--muted-foreground)`,strokeDasharray:`4 4`,y:G}),(0,$.jsx)(p,{activeBar:{fillOpacity:1},dataKey:R[o].datakey,fill:`url(#barGradient)`,fillOpacity:.6,isAnimationActive:!1,maxBarSize:32,minPointSize:3,radius:4})]})}),(0,$.jsxs)(`div`,{className:`-mt-4 text-center text-sm text-muted-foreground`,children:[`Newsletters `,o===`avg-open-rate`?`opens`:`clicks`,` in this period`]})]}):(0,$.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${x(C)}`,children:(0,$.jsx)(H,{strokeWidth:1.5})})})]})]})},be=({newsletters:e})=>{let{selectedNewsletterId:t,setSelectedNewsletterId:n}=Y(),r=(0,Q.useMemo)(()=>e?.filter(e=>e.status===`active`)||[],[e]);return(0,Q.useEffect)(()=>{if(r.length>0&&!t){let e=r.find(e=>e.sort_order===0);n(e?e.id:r[0].id)}},[r,t,n]),r.length<=1?null:(0,$.jsxs)(k,{value:t||``,onValueChange:e=>{n(e)},children:[(0,$.jsxs)(E,{className:`w-auto`,children:[(0,$.jsx)(oe,{className:`mr-2`,size:16,strokeWidth:1.5}),(0,$.jsx)(O,{placeholder:`Select a newsletter`})]}),(0,$.jsx)(T,{align:`end`,children:(0,$.jsxs)(D,{children:[(0,$.jsx)(C,{children:`Newsletters`}),r.map(e=>(0,$.jsx)(w,{value:e.id,children:e.name},e.id))]})})]})},xe=(e,t,n=!0)=>{let i=e??30,{startDate:a,endDate:o}=(0,Q.useMemo)(()=>W(i),[i]),s=r({searchParams:(0,Q.useMemo)(()=>{let e={date_from:q(a),date_to:q(o)};return t&&(e.newsletter_id=t),e},[a,o,t]),enabled:n});return n?s:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:s.refetch}},Se=(e,t,n,r=!0)=>{let i=e??30,a=t??`date desc`,{startDate:s,endDate:c}=(0,Q.useMemo)(()=>W(i),[i]),l=o({searchParams:(0,Q.useMemo)(()=>{let e={date_from:q(s),date_to:q(c),order:a};return n&&(e.newsletter_id=n),e},[s,c,a,n]),enabled:r});return r?l:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:l.refetch}},Ce=(e,t=[],n=!0)=>{let r=a({searchParams:(0,Q.useMemo)(()=>{let n={};return e&&(n.newsletter_id=e),t.length>0&&(n.post_ids=t.join(`,`)),n},[e,t]),enabled:n});return n?r:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:r.refetch}},we=(e,t,n,r=!0)=>{let i=Se(e,t,n,r),a=(0,Q.useMemo)(()=>i.data?.stats?i.data.stats.map(e=>e.post_id):[],[i.data]),o=Ce(n,a,r&&a.length>0);return{data:(0,Q.useMemo)(()=>{if(!i.data?.stats)return;let e=i.data.stats,t=o.data?.stats||[],n=new Map;t.forEach(e=>{n.set(e.post_id,e)});let r=e.map(e=>{let t=n.get(e.post_id);return{...e,total_clicks:t?.total_clicks||0,click_rate:t?.click_rate||0}});return{...i.data,stats:r}},[i.data,o.data]),isLoading:i.isLoading,isClicksLoading:o.isLoading,error:i.error||o.error,isError:i.isError||o.isError,refetch:()=>{i.refetch(),o.refetch()}}},Te=Q.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})=>{let i=c(),{settings:a}=ge(),o=String(a.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),{data:s,isLoading:l,isClicksLoading:p}=we(e,r,t||void 0,!!n),{appSettings:m}=K(),{emailTrackClicks:h,emailTrackOpens:g}=m?.analytics||{},_=(0,Q.useMemo)(()=>s?.stats||[],[s]),v=g&&h?5:g||h?4:3,y=(0,Q.useMemo)(()=>(0,$.jsx)($.Fragment,{children:(0,$.jsx)(L,{className:`last:border-none [&>td]:py-2.5`,children:(0,$.jsx)(z,{className:`font-medium`,colSpan:v,children:(0,$.jsx)(ue,{className:`mt-5`})})})}),[v]),b=(0,Q.useMemo)(()=>_.length>0?(0,$.jsx)($.Fragment,{children:_.map(e=>(0,$.jsxs)(L,{className:`last:border-none [&>td]:py-2.5`,children:[(0,$.jsx)(z,{className:`font-medium`,children:(0,$.jsx)(`div`,{className:`group/link inline-flex items-center gap-2`,children:e.post_id?(0,$.jsx)(G,{className:`h-auto p-0 text-left whitespace-normal hover:underline!`,title:`View post analytics`,variant:`link`,onClick:()=>{i(`/posts/analytics/${e.post_id}/`,{crossApp:!0})},children:e.post_title}):(0,$.jsx)($.Fragment,{children:e.post_title})})}),(0,$.jsx)(z,{className:`text-sm whitespace-nowrap`,children:d(e.send_date,o)}),(0,$.jsx)(z,{className:`text-right font-mono text-sm`,children:u(e.sent_to)}),g&&(0,$.jsxs)(z,{className:`text-right font-mono text-sm`,children:[(0,$.jsx)(`span`,{className:`group-hover:hidden`,children:f(e.open_rate)}),(0,$.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:u(e.total_opens)})]}),h&&(0,$.jsx)(z,{className:`text-right font-mono text-sm`,children:p?(0,$.jsx)(`span`,{className:`inline-block h-4 w-8 animate-pulse rounded bg-gray-200`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`group-hover:hidden`,children:f(e.click_rate)}),(0,$.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:u(e.total_clicks)})]})})]},e.post_id))}):(0,$.jsx)(L,{className:`border-none hover:bg-transparent`,children:(0,$.jsx)(z,{className:`text-center group-hover:bg-transparent!`,colSpan:v,children:(0,$.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${x(e)}`,children:(0,$.jsx)(H,{strokeWidth:1.5})})})}),[_,p,i,h,g,e]);return l||!s?y:b});Te.displayName=`NewsletterTableRows`;var Ee=Q.memo(({sortBy:e,setSortBy:t,range:n})=>{let r=(0,Q.useMemo)(()=>(0,$.jsxs)(A,{children:[(0,$.jsx)(M,{children:`Top newsletters`}),(0,$.jsxs)(N,{children:[` Your best performing newsletters `,x(n)]})]}),[n]),{appSettings:i}=K(),{emailTrackClicks:a,emailTrackOpens:o}=i?.analytics||{};return(0,$.jsx)(B,{children:(0,$.jsxs)(L,{children:[(0,$.jsx)(I,{className:`min-w-[320px]`,variant:`cardhead`,children:r}),(0,$.jsx)(I,{className:`w-[65px]`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`date desc`,children:`Date`})}),(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`sent_to desc`,children:`Sent`})}),o&&(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`open_rate desc`,children:`Opens`})}),a&&(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`click_rate desc`,children:`Clicks`})})]})})});Ee.displayName=`NewsletterTableHeader`;var De=Q.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n})=>{let[r,i]=(0,Q.useState)(`open_rate desc`);return(0,$.jsx)(P,{className:`w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]`,"data-testid":`top-newsletters-card`,children:(0,$.jsx)(j,{children:(0,$.jsxs)(V,{children:[(0,$.jsx)(Ee,{range:e,setSortBy:i,sortBy:r}),(0,$.jsx)(R,{children:(0,$.jsx)(Te,{range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})})]})})})});De.displayName=`TopNewslettersTable`;var Oe=()=>{let{range:e,selectedNewsletterId:t}=Y(),[n]=s(),{appSettings:r}=K(),a=n.get(`tab`)||`total-subscribers`,{data:o,isLoading:c}=_e({searchParams:{limit:`50`}}),u=!c&&o&&o.newsletters.length>0&&!!t,{data:d,isLoading:f}=xe(e,t||void 0,u||!1),{data:p,isLoading:m,isClicksLoading:h}=we(e,`date asc`,t||void 0,u||!1),g=(0,Q.useMemo)(()=>!o?.newsletters||!t?null:o.newsletters.find(e=>e.id===t)||null,[o,t]),_=(0,Q.useMemo)(()=>{let e=g?.count?.active_members||d?.stats?.[0]?.total||0,t=0,n=0;if(p?.stats&&p.stats.length>0){let e=p.stats,r=e.reduce((e,t)=>e+(t.open_rate||0),0),i=e.reduce((e,t)=>e+(t.click_rate||0),0);t=r/e.length,n=i/e.length}return{totalSubscribers:e,avgOpenRate:t,avgClickRate:n}},[g,d,p]),v=(0,Q.useMemo)(()=>{if(!d?.stats?.[0]?.values||d.stats[0].values.length===0){let{startDate:t,endDate:n}=W(e),r=[],i=t.clone().toDate(),a=n.toDate();for(;i<=a;)r.push({date:i.toISOString().split(`T`)[0],value:0}),i.setDate(i.getDate()+1);return r}let t=d.stats[0].values;if(t.length===1){let n=t[0],r=new Date,i=e,a=new Date(r.getTime()-i*24*60*60*1e3);return[{...n,date:a.toISOString().split(`T`)[0]},{...n,date:r.toISOString().split(`T`)[0]}]}return t},[d,e]),y=(0,Q.useMemo)(()=>p?.stats?p.stats.map(e=>({post_id:e.post_id,post_title:e.post_title,send_date:e.send_date,sent_to:e.sent_to,total_opens:e.total_opens,open_rate:e.open_rate,total_clicks:e.total_clicks||0,click_rate:e.click_rate||0})):[],[p]),b=f||h||m;return r&&!r.newslettersEnabled?(0,$.jsx)(l,{to:`/analytics`}):(0,$.jsxs)(fe,{children:[(0,$.jsx)(pe,{children:(0,$.jsxs)(i,{children:[(0,$.jsx)(be,{newsletters:o?.newsletters}),(0,$.jsx)(de,{})]})}),(0,$.jsx)(me,{isLoading:!1,loadingComponent:(0,$.jsx)($.Fragment,{}),children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{"data-testid":`newsletters-card`,children:(0,$.jsx)(j,{children:(0,$.jsx)(ye,{avgsData:y,initialTab:a,isAvgsLoading:!1,isLoading:b,subscribersData:v,totals:_})})}),(0,$.jsx)(De,{range:e,selectedNewsletterId:t,shouldFetchStats:!!u})]})})]})};export{Oe as default};
@@ -1 +1 @@
1
- import{i as e,n as t,t as n}from"./hooks-CixO01lL.js";import{n as r,r as i}from"./update-queries-C4CnvJaW.js";var a=`NewslettersResponseType`,o=a,s=n({dataType:a,path:`/newsletters/`,defaultSearchParams:{include:`count.active_members,count.posts`,limit:`50`},defaultNextPageParams:(e,t)=>({...t,page:(e.meta?.pagination.next||1).toString()}),returnData:e=>{let{pages:t}=e,n=t.flatMap(e=>e.newsletters),r=t[t.length-1].meta;return{newsletters:n,meta:r,isEnd:r?r.pagination.pages===r.pagination.page:!0}}});e({dataType:a,path:e=>`/newsletters/${e}/`});var c=t({method:`POST`,path:()=>`/newsletters/`,body:({opt_in_existing:e,...t})=>({newsletters:[t]}),searchParams:e=>({opt_in_existing:e.opt_in_existing.toString(),include:`count.active_members,count.posts`}),updateQueries:{dataType:a,emberUpdateType:`createOrUpdate`,update:r(`newsletters`)}}),l=t({method:`PUT`,path:e=>`/newsletters/${e.id}/`,body:e=>({newsletters:[e]}),defaultSearchParams:{include:`count.active_members,count.posts`},updateQueries:{dataType:a,emberUpdateType:`createOrUpdate`,update:i(`newsletters`)}}),u=t({method:`PUT`,path:()=>`/newsletters/verifications/`,body:({token:e})=>({token:e}),defaultSearchParams:{include:`count.active_members,count.posts`},updateQueries:{dataType:a,emberUpdateType:`createOrUpdate`,update:i(`newsletters`)}});export{u as a,l as i,c as n,s as r,o as t};
1
+ import{i as e,n as t,t as n}from"./hooks-D6EE7BIt.js";import{n as r,r as i}from"./update-queries-C4CnvJaW.js";var a=`NewslettersResponseType`,o=a,s=n({dataType:a,path:`/newsletters/`,defaultSearchParams:{include:`count.active_members,count.posts`,limit:`50`},defaultNextPageParams:(e,t)=>({...t,page:(e.meta?.pagination.next||1).toString()}),returnData:e=>{let{pages:t}=e,n=t.flatMap(e=>e.newsletters),r=t[t.length-1].meta;return{newsletters:n,meta:r,isEnd:r?r.pagination.pages===r.pagination.page:!0}}});e({dataType:a,path:e=>`/newsletters/${e}/`});var c=t({method:`POST`,path:()=>`/newsletters/`,body:({opt_in_existing:e,...t})=>({newsletters:[t]}),searchParams:e=>({opt_in_existing:e.opt_in_existing.toString(),include:`count.active_members,count.posts`}),updateQueries:{dataType:a,emberUpdateType:`createOrUpdate`,update:r(`newsletters`)}}),l=t({method:`PUT`,path:e=>`/newsletters/${e.id}/`,body:e=>({newsletters:[e]}),defaultSearchParams:{include:`count.active_members,count.posts`},updateQueries:{dataType:a,emberUpdateType:`createOrUpdate`,update:i(`newsletters`)}}),u=t({method:`PUT`,path:()=>`/newsletters/verifications/`,body:({token:e})=>({token:e}),defaultSearchParams:{include:`count.active_members,count.posts`},updateQueries:{dataType:a,emberUpdateType:`createOrUpdate`,update:i(`newsletters`)}});export{u as a,l as i,c as n,s as r,o 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{m as r}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as i}from"./router-provider-C1R4AZ2o.js";import{$ as a,B as o,Jt as s,Kt as c,R as l,Wt as u,Z as d,et as f,ft as p,ir as m,rr as h,rt as g,xo as _,z as v}from"./index-BGG7NckO.js";import{i as y,n as b,r as x,t as S}from"./use-reply-chain-data-DBDRtGu-.js";var C=e(t(),1),w=n(),T=()=>(0,w.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`}),E=()=>{let{postId:e}=r(),{canGoBack:t}=i(),[n,E]=(0,C.useState)(new Set),[D,O]=(0,C.useState)(new Set),[k,A]=(0,C.useState)(new Set),[j,M]=(0,C.useState)(!1),N=(0,C.useRef)(null),P=(0,C.useRef)(null),F=(0,C.useRef)(null),I=(0,C.useRef)(null),L=s(),{threadParents:R,post:z,processedReplies:B,isLoading:V,loadMoreChildren:H,loadMoreChildReplies:U,hasMoreChildren:W,hasMoreChildReplies:G}=S(decodeURIComponent(e??``),{includeAncestors:!0}),K=z?.object,q=K?.replyCount??0,[J,Y]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{P.current&&R.length>0&&!J&&(P.current.scrollIntoView({behavior:`instant`,block:`start`}),Y(!0))},[R,J]),(0,C.useEffect)(()=>{F.current&&F.current.disconnect();let e=document.querySelector(`[data-scrollable-container]`);if(e)return F.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&W&&!j){M(!0);try{await H()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{M(!1)}}},{root:e,rootMargin:`200px`}),I.current&&F.current.observe(I.current),()=>{F.current&&F.current.disconnect()}},[W,j,H]),V)return(0,w.jsx)(o,{children:(0,w.jsxs)(`div`,{className:`mx-auto flex max-w-[620px] flex-col items-center gap-3 pt-9 lg:px-8`,children:[(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[(0,w.jsx)(m,{className:`size-10 rounded-full`}),(0,w.jsxs)(`div`,{className:`grow pt-1`,children:[(0,w.jsx)(m,{className:`w-24`}),(0,w.jsx)(m,{className:`w-3/5`})]})]}),(0,w.jsxs)(`div`,{className:`mb-7 w-full`,children:[(0,w.jsx)(m,{}),(0,w.jsx)(m,{className:`w-4/5`}),(0,w.jsx)(m,{})]}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3 py-3`,children:[(0,w.jsx)(m,{className:`block size-full`,containerClassName:`size-10 rounded-full overflow-hidden`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(m,{className:`w-52`}),(0,w.jsx)(m,{className:`w-28`})]})]}),(0,w.jsx)(T,{})]})});if(!z)return(0,w.jsx)(o,{children:(0,w.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center`,children:(0,w.jsxs)(v,{children:[(0,w.jsx)(l,{children:(0,w.jsx)(_,{})}),(0,w.jsx)(`div`,{children:`Error loading note.`})]})})});function X(){}function Z(e){E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),O(t=>{let n=new Set(t);return n.add(e),n})),n})}async function Q(e,t){if(!k.has(e)){A(t=>new Set(t).add(e));try{U&&await U(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{A(t=>{let n=new Set(t);return n.delete(e),n})}}}return(0,w.jsx)(o,{children:(0,w.jsx)(`div`,{className:`mx-auto flex h-full max-w-[620px] flex-col`,children:(0,w.jsx)(`div`,{className:`relative flex-1`,children:(0,w.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,w.jsxs)(`div`,{className:`mx-auto px-8 pt-5 pb-10 max-lg:px-0`,children:[!R.length&&(0,w.jsx)(g,{actor:z.actor,isCurrentUser:z.object.authored,children:(0,w.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full cursor-pointer items-center gap-3 ${t?`pt-10 max-md:pt-5`:`pt-5`}`,children:[(0,w.jsx)(`div`,{className:`relative z-10`,children:(0,w.jsx)(p,{author:z.actor,showFollowButton:!z.object.authored&&!z.actor.followedByMe})}),(0,w.jsxs)(`div`,{className:`relative z-10 flex w-full min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>{f(z.actor,L,e)},children:[(0,w.jsx)(`div`,{className:`flex w-full`,children:(0,w.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap hover:underline`,children:z.actor.name})}),(0,w.jsxs)(`div`,{className:`flex w-full`,children:[(0,w.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:c(z.actor)}),(0,w.jsx)(`span`,{className:`text-gray-700`,children:a(K,!K.authored)})]})]})]})}),R.map(e=>e.object.type===`Tombstone`?(0,w.jsx)(x,{last:!1}):(0,w.jsx)(d,{actor:e.actor,allowDelete:!1,commentCount:e.object.replyCount??0,last:!1,layout:`reply`,likeCount:e.object.likeCount??0,object:e.object,repostCount:e.object.repostCount??0,type:`Note`,onClick:()=>{L(`/${e.object.type===`Article`?`reader`:`notes`}/${encodeURIComponent(e.object.id)}`)}})),(0,w.jsx)(`div`,{ref:P,className:`${t?`scroll-mt-[12px]`:`scroll-mt-[124px]`}`,children:(0,w.jsxs)(`div`,{className:`${R.length>0&&`min-h-[calc(100vh-52px)]`}`,children:[(0,w.jsx)(d,{actor:z.actor,allowDelete:!1,commentCount:q,last:!0,layout:`modal`,likeCount:K.likeCount??0,object:K,repostCount:K.repostCount,showHeader:R.length>0,showStats:!0,type:`Note`}),(0,w.jsx)(y,{object:K}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{ref:N,children:[B.map((e,t)=>{let r=t===B.length-1,i=e.mainReply.id,a=n.has(i),o=D.has(i),s=k.has(i),c=e.chain.length>0;return(0,w.jsxs)(C.Fragment,{children:[(0,w.jsx)(d,{actor:e.mainReply.actor,allowDelete:e.mainReply.object.authored,commentCount:e.mainReply.object.replyCount??0,isChainParent:c,isPending:u(e.mainReply.id),last:!c,layout:`reply`,likeCount:e.mainReply.object.likeCount??0,object:e.mainReply.object,parentId:K.id,repostCount:e.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.mainReply.id)}`)},onDelete:X}),c&&e.chain[0]&&(0,w.jsx)(d,{actor:e.chain[0].actor,allowDelete:e.chain[0].object.authored,commentCount:e.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:u(e.chain[0].id),last:e.chain.length===1,layout:`reply`,likeCount:e.chain[0].object.likeCount??0,object:e.chain[0].object,parentId:K.id,repostCount:e.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.chain[0].id)}`)},onDelete:X},e.chain[0].id),c&&a&&e.chain.slice(1).map((n,r)=>{let i=r===e.chain.slice(1).length-1,a=G&&G(t),o=i&&a;return(0,w.jsx)(d,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isChainContinuation:!0,isPending:u(n.id),last:i&&!o,layout:`reply`,likeCount:n.object.likeCount??0,object:n.object,parentId:K.id,repostCount:n.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(n.id)}`)},onDelete:X},n.id)}),c&&e.chain.length>1&&!a&&(0,w.jsx)(b,{variant:`expand`,onClick:()=>Z(i)}),c&&a&&o&&G&&G(t)&&(0,w.jsx)(b,{loading:s,variant:`loadMore`,onClick:()=>Q(i,t)}),!r&&(0,w.jsx)(T,{})]},e.mainReply.id)}),j&&(0,w.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,w.jsx)(h,{size:`md`})})]}),W&&(0,w.jsx)(`div`,{ref:I,className:`h-1`})]})})]})})})})})};export{E as default};
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{m as r}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as i}from"./router-provider-DSQfprxH.js";import{$ as a,B as o,Jt as s,Kt as c,R as l,Wt as u,Z as d,ar as f,et as p,ft as m,or as h,rt as g,xo as _,z as v}from"./index-BHy2DZX-.js";import{i as y,n as b,r as x,t as S}from"./use-reply-chain-data-DaK8q2qQ.js";var C=e(t(),1),w=n(),T=()=>(0,w.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`}),E=()=>{let{postId:e}=r(),{canGoBack:t}=i(),[n,E]=(0,C.useState)(new Set),[D,O]=(0,C.useState)(new Set),[k,A]=(0,C.useState)(new Set),[j,M]=(0,C.useState)(!1),N=(0,C.useRef)(null),P=(0,C.useRef)(null),F=(0,C.useRef)(null),I=(0,C.useRef)(null),L=s(),{threadParents:R,post:z,processedReplies:B,isLoading:V,loadMoreChildren:H,loadMoreChildReplies:U,hasMoreChildren:W,hasMoreChildReplies:G}=S(decodeURIComponent(e??``),{includeAncestors:!0}),K=z?.object,q=K?.replyCount??0,[J,Y]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{P.current&&R.length>0&&!J&&(P.current.scrollIntoView({behavior:`instant`,block:`start`}),Y(!0))},[R,J]),(0,C.useEffect)(()=>{F.current&&F.current.disconnect();let e=document.querySelector(`[data-scrollable-container]`);if(e)return F.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&W&&!j){M(!0);try{await H()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{M(!1)}}},{root:e,rootMargin:`200px`}),I.current&&F.current.observe(I.current),()=>{F.current&&F.current.disconnect()}},[W,j,H]),V)return(0,w.jsx)(o,{children:(0,w.jsxs)(`div`,{className:`mx-auto flex max-w-[620px] flex-col items-center gap-3 pt-9 lg:px-8`,children:[(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[(0,w.jsx)(h,{className:`size-10 rounded-full`}),(0,w.jsxs)(`div`,{className:`grow pt-1`,children:[(0,w.jsx)(h,{className:`w-24`}),(0,w.jsx)(h,{className:`w-3/5`})]})]}),(0,w.jsxs)(`div`,{className:`mb-7 w-full`,children:[(0,w.jsx)(h,{}),(0,w.jsx)(h,{className:`w-4/5`}),(0,w.jsx)(h,{})]}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3 py-3`,children:[(0,w.jsx)(h,{className:`block size-full`,containerClassName:`size-10 rounded-full overflow-hidden`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(h,{className:`w-52`}),(0,w.jsx)(h,{className:`w-28`})]})]}),(0,w.jsx)(T,{})]})});if(!z)return(0,w.jsx)(o,{children:(0,w.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center`,children:(0,w.jsxs)(v,{children:[(0,w.jsx)(l,{children:(0,w.jsx)(_,{})}),(0,w.jsx)(`div`,{children:`Error loading note.`})]})})});function X(){}function Z(e){E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),O(t=>{let n=new Set(t);return n.add(e),n})),n})}async function Q(e,t){if(!k.has(e)){A(t=>new Set(t).add(e));try{U&&await U(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{A(t=>{let n=new Set(t);return n.delete(e),n})}}}return(0,w.jsx)(o,{children:(0,w.jsx)(`div`,{className:`mx-auto flex h-full max-w-[620px] flex-col`,children:(0,w.jsx)(`div`,{className:`relative flex-1`,children:(0,w.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,w.jsxs)(`div`,{className:`mx-auto px-8 pt-5 pb-10 max-lg:px-0`,children:[!R.length&&(0,w.jsx)(g,{actor:z.actor,isCurrentUser:z.object.authored,children:(0,w.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full cursor-pointer items-center gap-3 ${t?`pt-10 max-md:pt-5`:`pt-5`}`,children:[(0,w.jsx)(`div`,{className:`relative z-10`,children:(0,w.jsx)(m,{author:z.actor,showFollowButton:!z.object.authored&&!z.actor.followedByMe})}),(0,w.jsxs)(`div`,{className:`relative z-10 flex w-full min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>{p(z.actor,L,e)},children:[(0,w.jsx)(`div`,{className:`flex w-full`,children:(0,w.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap hover:underline`,children:z.actor.name})}),(0,w.jsxs)(`div`,{className:`flex w-full`,children:[(0,w.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:c(z.actor)}),(0,w.jsx)(`span`,{className:`text-gray-700`,children:a(K,!K.authored)})]})]})]})}),R.map(e=>e.object.type===`Tombstone`?(0,w.jsx)(x,{last:!1}):(0,w.jsx)(d,{actor:e.actor,allowDelete:!1,commentCount:e.object.replyCount??0,last:!1,layout:`reply`,likeCount:e.object.likeCount??0,object:e.object,repostCount:e.object.repostCount??0,type:`Note`,onClick:()=>{L(`/${e.object.type===`Article`?`reader`:`notes`}/${encodeURIComponent(e.object.id)}`)}})),(0,w.jsx)(`div`,{ref:P,className:`${t?`scroll-mt-[12px]`:`scroll-mt-[124px]`}`,children:(0,w.jsxs)(`div`,{className:`${R.length>0&&`min-h-[calc(100vh-52px)]`}`,children:[(0,w.jsx)(d,{actor:z.actor,allowDelete:!1,commentCount:q,last:!0,layout:`modal`,likeCount:K.likeCount??0,object:K,repostCount:K.repostCount,showHeader:R.length>0,showStats:!0,type:`Note`}),(0,w.jsx)(y,{object:K}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{ref:N,children:[B.map((e,t)=>{let r=t===B.length-1,i=e.mainReply.id,a=n.has(i),o=D.has(i),s=k.has(i),c=e.chain.length>0;return(0,w.jsxs)(C.Fragment,{children:[(0,w.jsx)(d,{actor:e.mainReply.actor,allowDelete:e.mainReply.object.authored,commentCount:e.mainReply.object.replyCount??0,isChainParent:c,isPending:u(e.mainReply.id),last:!c,layout:`reply`,likeCount:e.mainReply.object.likeCount??0,object:e.mainReply.object,parentId:K.id,repostCount:e.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.mainReply.id)}`)},onDelete:X}),c&&e.chain[0]&&(0,w.jsx)(d,{actor:e.chain[0].actor,allowDelete:e.chain[0].object.authored,commentCount:e.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:u(e.chain[0].id),last:e.chain.length===1,layout:`reply`,likeCount:e.chain[0].object.likeCount??0,object:e.chain[0].object,parentId:K.id,repostCount:e.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.chain[0].id)}`)},onDelete:X},e.chain[0].id),c&&a&&e.chain.slice(1).map((n,r)=>{let i=r===e.chain.slice(1).length-1,a=G&&G(t),o=i&&a;return(0,w.jsx)(d,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isChainContinuation:!0,isPending:u(n.id),last:i&&!o,layout:`reply`,likeCount:n.object.likeCount??0,object:n.object,parentId:K.id,repostCount:n.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(n.id)}`)},onDelete:X},n.id)}),c&&e.chain.length>1&&!a&&(0,w.jsx)(b,{variant:`expand`,onClick:()=>Z(i)}),c&&a&&o&&G&&G(t)&&(0,w.jsx)(b,{loading:s,variant:`loadMore`,onClick:()=>Q(i,t)}),!r&&(0,w.jsx)(T,{})]},e.mainReply.id)}),j&&(0,w.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,w.jsx)(f,{size:`md`})})]}),W&&(0,w.jsx)(`div`,{ref:I,className:`h-1`})]})})]})})})})})};export{E as default};
@@ -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{f as r}from"./dist-DGzPJ_bO.js";import{$ as i,At as a,B as o,Ca as s,Gt as c,Ir as l,Jt as u,L as d,Li as f,Q as p,R as m,_s as h,bo as g,dt as _,et as v,ft as y,ir as b,lt as x,ns as S,nt as C,rr as w,rt as T,ut as E,xa as D,xs as O,z as k}from"./index-BGG7NckO.js";import"./layout-yQEi2qDM.js";var A=e(t(),1),j=n(),M=({notificationType:e,size:t=`lg`,className:n})=>{let r,i=``,a=`white`,o=t===`sm`?13:20,c=t===`sm`?2:1.5;switch(e){case`follow`:r=(0,j.jsx)(f,{className:`-mt-0.5 -mr-0.5 ${t===`sm`&&`size-[11px]`}`,color:a,size:o,strokeWidth:c}),i=`bg-blue-600`;break;case`like`:r=(0,j.jsx)(g,{className:`${t===`sm`?`size-[11px]`:`mt-px size-5`}`,color:a,strokeWidth:c}),i=`bg-pink-600`;break;case`reply`:r=(0,j.jsx)(D,{className:`mr-px mb-px`,color:a,size:o,strokeWidth:c}),i=`bg-purple-600`;break;case`repost`:r=(0,j.jsx)(s,{color:a,size:o,strokeWidth:c}),i=`bg-green-500`;break;case`mention`:r=(0,j.jsx)(O,{className:`${t===`sm`?`size-[12px]`:`size-5`}`,color:a,size:o,strokeWidth:c}),i=`bg-orange-500`;break}return(0,j.jsx)(`div`,{className:`flex ${t===`sm`?`size-5`:`size-9`} items-center justify-center rounded-full ${i} ${n&&n}`,children:r})},N=A.createContext(void 0),P=({isGrouped:e,centerAlign:t,children:n,onClick:r,url:i,className:a})=>(0,j.jsx)(N.Provider,{value:{onClick:r,url:i},children:(0,j.jsx)(`div`,{className:`group relative -mx-4 -my-px ${e?`grid`:`flex`} ${t?`items-center`:`items-start`} break-anywhere cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left hover:bg-gray-100 ${a}`,role:`button`,onClick:r,children:n})});P.Icon=({size:e=`lg`,type:t})=>(0,j.jsx)(`div`,{className:`col-start-1 row-start-1`,children:(0,j.jsx)(M,{notificationType:t,size:e})}),P.Avatars=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-1 flex gap-2`,children:e}),P.Content=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-2 -mt-0.5 grow overflow-hidden`,children:e});var F=()=>(0,j.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`});function I(e){let t=1440*60*1e3,n=new Date(e).getTime();return(Math.floor(n/t)*t).toString()}function L(e){let t={},n=null,r=0;return e.forEach(e=>{e.type!==n&&(r+=1,n=e.type);let i=``,a=`_${I(e.createdAt)}`,o=`_seq${r}`;switch(e.type){case`like`:e.post?.id&&(i=`like_${e.post.id}${a}${o}`);break;case`reply`:i=`reply_${e.id}`;break;case`repost`:e.post?.id&&(i=`repost_${e.post.id}${a}${o}`);break;case`follow`:i=`follow_${a}${o}`;break;case`mention`:i=`mention_${e.id}`;break}t[i]||(t[i]={id:e.id,type:e.type,actors:[],post:e.post,inReplyTo:e.inReplyTo,createdAt:e.createdAt}),t[i].actors.find(t=>t.id===e.actor.id)||t[i].actors.push(e.actor)}),Object.values(t)}var R=({group:e})=>{let[t,...n]=e.actors,i=n.length>0,a=n.length,o=u(),s=(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{actor:t,align:`center`,isCurrentUser:!1,children:(0,j.jsx)(`span`,{className:`cursor-pointer font-semibold hover:underline text-black dark:text-white`,onClick:e=>{e?.stopPropagation(),t.handle&&v(t.handle,o)},children:t.name})}),i&&` and ${r(a)} ${a>1?`others`:`other`}`]});switch(e.type){case`follow`:return(0,j.jsxs)(j.Fragment,{children:[s,` followed you`]});case`like`:return(0,j.jsxs)(j.Fragment,{children:[s,` liked your `,e.post?.type===`article`?`post`:`note`]});case`repost`:return(0,j.jsxs)(j.Fragment,{children:[s,` reposted your `,e.post?.type===`article`?`post`:`note`]});case`reply`:if(e.inReplyTo&&typeof e.inReplyTo!=`string`)return s;break;case`mention`:return s}return(0,j.jsx)(j.Fragment,{})},z=({content:e,className:t,stripTags:n=[]})=>{let r=(0,A.useRef)(null),i=u();return(0,A.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{let t=e.target.closest(`a[data-profile]`);if(t){let n=t.getAttribute(`data-profile`)?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(n||``)&&n&&(e.preventDefault(),e.stopPropagation(),v(n,i))}};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}},[i,e]),(0,j.jsx)(`div`,{dangerouslySetInnerHTML:{__html:x(E(e||``,n))},ref:r,className:t})},B=()=>{let[e,t]=A.useState({}),n=u(),s=e=>{t(t=>({...t,[e]:!t[e]}))},f=()=>{},{data:g,error:T,fetchNextPage:D,hasNextPage:O,isFetchingNextPage:N,isLoading:I}=a(`index`),B=g?.pages.flatMap(e=>L(e.notifications))??Array(10).fill({actors:[{}]}),V=(0,A.useRef)(null),H=(0,A.useRef)(null);(0,A.useEffect)(()=>(V.current&&V.current.disconnect(),V.current=new IntersectionObserver(e=>{e[0].isIntersecting&&O&&!N&&D()}),H.current&&V.current.observe(H.current),()=>{V.current&&V.current.disconnect()}),[O,N,D]);let U=(e,t)=>{switch(e.type){case`like`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`reply`:e.post&&e.inReplyTo&&n(`/notes/${encodeURIComponent(e.post.id)}`);break;case`repost`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`follow`:e.actors.length>1?s(e.id||`${e.type}_${t}`):e.actors[0]?.handle&&v(e.actors[0].handle,n);break;case`mention`:e.post&&n(`/notes/${encodeURIComponent(e.post.id)}`);break}};return T&&c(T)?(0,j.jsx)(d,{errorCode:T.code,statusCode:T.statusCode}):(0,j.jsx)(o,{children:(0,j.jsxs)(`div`,{className:`z-0 flex w-full flex-col items-center`,children:[I===!1&&B.length===0&&(0,j.jsxs)(k,{children:[(0,j.jsx)(m,{children:(0,j.jsx)(h,{})}),`Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here.`]}),B.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`my-8 flex w-full max-w-[620px] flex-col max-md:mt-5`,children:B.map((t,a)=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsxs)(P,{centerAlign:t.actors.length<2&&t.type===`follow`,className:`hover:bg-gray-100 dark:hover:bg-gray-950`,isGrouped:t.actors.length>1,onClick:()=>U(t,a),children:[I?(0,j.jsx)(b,{className:`rounded-full`,containerClassName:`flex h-10 w-10`}):t.actors.length>1?(0,j.jsx)(P.Icon,{type:t.type}):(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(y,{author:{icon:{url:t.actors[0].avatarUrl||``},name:t.actors[0].name,handle:t.actors[0].handle},size:`notification`},t.actors[0].id),(0,j.jsx)(M,{className:`absolute -right-1 -bottom-1 z-10 border-2 border-white dark:border-black`,notificationType:t.type,size:`sm`})]}),t.actors.length>1&&(0,j.jsx)(P.Avatars,{children:(0,j.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,j.jsxs)(`div`,{className:`relative flex w-fit items-center pl-2`,children:[!e[t.id||`${t.type}_${a}`]&&t.actors.slice(0,5).map(e=>(0,j.jsx)(y,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},className:`-ml-2 bg-[#F3F3F3]! outline-2 outline-white group-hover:bg-[#EDEEF0]! group-hover:outline-gray-100 dark:outline-black group-hover:dark:outline-gray-950`,size:`notification`},e.id)),t.actors.length>5&&!e[t.id||`${t.type}_${a}`]&&(0,j.jsx)(`div`,{className:`absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white`,children:`+${r(t.actors.length-5)}`}),t.actors.length>1&&(0,j.jsxs)(l,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${e[t.id||`${t.type}_${a}`]?`ml-[-20px]`:`ml-0 w-[28px]`}`,variant:`ghost`,onClick:e=>{e?.stopPropagation(),s(t.id||`${t.type}_${a}`)},children:[(0,j.jsx)(S,{className:`${e[t.id||`${t.type}_${a}`]?`rotate-180`:``}`,size:20,strokeWidth:1.5}),e[t.id||`${t.type}_${a}`]?`Hide`:(0,j.jsx)(`span`,{className:`sr-only`,children:`Show all`})]})]}),(0,j.jsx)(`div`,{className:`overflow-hidden transition-all duration-300 ease-in-out ${e[t.id||`${t.type}_${a}`]?`mb-2 max-h-[1384px] opacity-100`:`max-h-0 opacity-0`}`,children:e[t.id||`${t.type}_${a}`]&&t.actors.length>1&&(0,j.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t.actors.map(e=>(0,j.jsxs)(`div`,{className:`group/item break-anywhere flex items-center justify-between gap-4`,onClick:t=>{t?.stopPropagation(),e.handle&&v(e.handle,n)},children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,j.jsx)(y,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},size:`xs`}),(0,j.jsx)(`span`,{className:`ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white`,children:e.name}),(0,j.jsx)(`span`,{className:`ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600`,children:e.handle})]}),t.type===`follow`&&!e.followedByMe&&e.handle&&(0,j.jsx)(_,{following:!1,handle:e.handle,variant:`link`})]},e.id))})})]})}),(0,j.jsxs)(P.Content,{children:[(0,j.jsx)(`div`,{children:I?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(b,{}),(0,j.jsx)(b,{className:`w-full max-w-60`})]}):(0,j.jsxs)(`div`,{className:`flex justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:(0,j.jsx)(R,{group:t})}),t.actors.length<2&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`mt-px text-[8px] text-gray-700 dark:text-gray-600`,children:`•`}),(0,j.jsx)(`span`,{className:`mt-0.5 text-sm text-gray-700 dark:text-gray-600`,children:i(t,!1)})]})]}),t.actors.length===1&&(t.type===`follow`||t.type===`reply`||t.type===`mention`)&&!t.actors[0].followedByMe&&t.actors[0].handle&&(0,j.jsx)(_,{following:!1,handle:t.actors[0].handle,variant:`link`})]})}),(t.type===`reply`&&t.inReplyTo||t.type===`mention`||t.type===`like`&&!t.post?.name&&t.post?.content||t.type===`repost`&&!t.post?.name&&t.post?.content)&&(t.type!==`reply`&&t.type!==`mention`?(0,j.jsxs)(`div`,{className:`ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600`,children:[t.post?.type===`article`&&t.post?.title&&(0,j.jsxs)(j.Fragment,{children:[t.post.title,` — `]}),(0,j.jsx)(`span`,{dangerouslySetInnerHTML:{__html:x(E(t.post?.content||``))}})]}):(0,j.jsx)(j.Fragment,{children:(0,j.jsxs)(`div`,{className:`mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-950/30 group-hover:dark:bg-black/40`,children:[(0,j.jsx)(z,{className:`ap-note-content text-pretty`,content:t.post?.content||``,stripTags:[`a`]}),t.post&&t.post.attachments&&t.post.attachments.length>0&&(0,j.jsx)(`div`,{className:`notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]`,children:p({...t.post,type:`Note`,attachment:t.post.attachments})})]})})),(t.type===`reply`&&t.post||t.type===`mention`)&&(0,j.jsx)(`div`,{className:`mt-1.5`,children:(0,j.jsx)(C,{actor:{...t.actors[0],icon:{url:t.actors[0].avatarUrl||``},id:t.actors[0].url,preferredUsername:t.actors[0].handle?.replace(/^@([^@]+)@.*$/,`$1`)||`unknown`},buttonClassName:`hover:bg-gray-200`,commentCount:t.post.replyCount||0,layout:`notification`,likeCount:t.post.likeCount||0,object:{...t.post,liked:t.post.likedByMe,reposted:t.post.repostedByMe},repostCount:t.post.repostCount||0,onLikeClick:f})})]})]}),a<B.length-1&&(0,j.jsx)(`div`,{className:`pl-[52px]`,children:(0,j.jsx)(F,{})})]},t.id||`${t.type}_${a}`))}),(0,j.jsx)(`div`,{ref:H,className:`h-1`}),N&&(0,j.jsx)(`div`,{className:`-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center`,children:(0,j.jsx)(w,{size:`md`})})]})]})})};export{B as default};
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{f as r}from"./dist-Cb5RSHSg.js";import{$ as i,At as a,B as o,Ca as s,Gt as c,Jt as l,L as u,Li as d,Pr as f,Q as p,R as m,_s as h,ar as g,bo as _,dt as v,et as y,ft as b,lt as x,ns as S,nt as C,or as w,rt as T,ut as E,xa as D,xs as O,z as k}from"./index-BHy2DZX-.js";import"./layout-TMj4P-vv.js";var A=e(t(),1),j=n(),M=({notificationType:e,size:t=`lg`,className:n})=>{let r,i=``,a=`white`,o=t===`sm`?13:20,c=t===`sm`?2:1.5;switch(e){case`follow`:r=(0,j.jsx)(d,{className:`-mt-0.5 -mr-0.5 ${t===`sm`&&`size-[11px]`}`,color:a,size:o,strokeWidth:c}),i=`bg-blue-600`;break;case`like`:r=(0,j.jsx)(_,{className:`${t===`sm`?`size-[11px]`:`mt-px size-5`}`,color:a,strokeWidth:c}),i=`bg-pink-600`;break;case`reply`:r=(0,j.jsx)(D,{className:`mr-px mb-px`,color:a,size:o,strokeWidth:c}),i=`bg-purple-600`;break;case`repost`:r=(0,j.jsx)(s,{color:a,size:o,strokeWidth:c}),i=`bg-green-500`;break;case`mention`:r=(0,j.jsx)(O,{className:`${t===`sm`?`size-[12px]`:`size-5`}`,color:a,size:o,strokeWidth:c}),i=`bg-orange-500`;break}return(0,j.jsx)(`div`,{className:`flex ${t===`sm`?`size-5`:`size-9`} items-center justify-center rounded-full ${i} ${n&&n}`,children:r})},N=A.createContext(void 0),P=({isGrouped:e,centerAlign:t,children:n,onClick:r,url:i,className:a})=>(0,j.jsx)(N.Provider,{value:{onClick:r,url:i},children:(0,j.jsx)(`div`,{className:`group relative -mx-4 -my-px ${e?`grid`:`flex`} ${t?`items-center`:`items-start`} break-anywhere cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left hover:bg-gray-100 ${a}`,role:`button`,onClick:r,children:n})});P.Icon=({size:e=`lg`,type:t})=>(0,j.jsx)(`div`,{className:`col-start-1 row-start-1`,children:(0,j.jsx)(M,{notificationType:t,size:e})}),P.Avatars=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-1 flex gap-2`,children:e}),P.Content=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-2 -mt-0.5 grow overflow-hidden`,children:e});var F=()=>(0,j.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`});function I(e){let t=1440*60*1e3,n=new Date(e).getTime();return(Math.floor(n/t)*t).toString()}function L(e){let t={},n=null,r=0;return e.forEach(e=>{e.type!==n&&(r+=1,n=e.type);let i=``,a=`_${I(e.createdAt)}`,o=`_seq${r}`;switch(e.type){case`like`:e.post?.id&&(i=`like_${e.post.id}${a}${o}`);break;case`reply`:i=`reply_${e.id}`;break;case`repost`:e.post?.id&&(i=`repost_${e.post.id}${a}${o}`);break;case`follow`:i=`follow_${a}${o}`;break;case`mention`:i=`mention_${e.id}`;break}t[i]||(t[i]={id:e.id,type:e.type,actors:[],post:e.post,inReplyTo:e.inReplyTo,createdAt:e.createdAt}),t[i].actors.find(t=>t.id===e.actor.id)||t[i].actors.push(e.actor)}),Object.values(t)}var R=({group:e})=>{let[t,...n]=e.actors,i=n.length>0,a=n.length,o=l(),s=(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{actor:t,align:`center`,isCurrentUser:!1,children:(0,j.jsx)(`span`,{className:`cursor-pointer font-semibold hover:underline text-black dark:text-white`,onClick:e=>{e?.stopPropagation(),t.handle&&y(t.handle,o)},children:t.name})}),i&&` and ${r(a)} ${a>1?`others`:`other`}`]});switch(e.type){case`follow`:return(0,j.jsxs)(j.Fragment,{children:[s,` followed you`]});case`like`:return(0,j.jsxs)(j.Fragment,{children:[s,` liked your `,e.post?.type===`article`?`post`:`note`]});case`repost`:return(0,j.jsxs)(j.Fragment,{children:[s,` reposted your `,e.post?.type===`article`?`post`:`note`]});case`reply`:if(e.inReplyTo&&typeof e.inReplyTo!=`string`)return s;break;case`mention`:return s}return(0,j.jsx)(j.Fragment,{})},z=({content:e,className:t,stripTags:n=[]})=>{let r=(0,A.useRef)(null),i=l();return(0,A.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{let t=e.target.closest(`a[data-profile]`);if(t){let n=t.getAttribute(`data-profile`)?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(n||``)&&n&&(e.preventDefault(),e.stopPropagation(),y(n,i))}};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}},[i,e]),(0,j.jsx)(`div`,{dangerouslySetInnerHTML:{__html:x(E(e||``,n))},ref:r,className:t})},B=()=>{let[e,t]=A.useState({}),n=l(),s=e=>{t(t=>({...t,[e]:!t[e]}))},d=()=>{},{data:_,error:T,fetchNextPage:D,hasNextPage:O,isFetchingNextPage:N,isLoading:I}=a(`index`),B=_?.pages.flatMap(e=>L(e.notifications))??Array(10).fill({actors:[{}]}),V=(0,A.useRef)(null),H=(0,A.useRef)(null);(0,A.useEffect)(()=>(V.current&&V.current.disconnect(),V.current=new IntersectionObserver(e=>{e[0].isIntersecting&&O&&!N&&D()}),H.current&&V.current.observe(H.current),()=>{V.current&&V.current.disconnect()}),[O,N,D]);let U=(e,t)=>{switch(e.type){case`like`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`reply`:e.post&&e.inReplyTo&&n(`/notes/${encodeURIComponent(e.post.id)}`);break;case`repost`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`follow`:e.actors.length>1?s(e.id||`${e.type}_${t}`):e.actors[0]?.handle&&y(e.actors[0].handle,n);break;case`mention`:e.post&&n(`/notes/${encodeURIComponent(e.post.id)}`);break}};return T&&c(T)?(0,j.jsx)(u,{errorCode:T.code,statusCode:T.statusCode}):(0,j.jsx)(o,{children:(0,j.jsxs)(`div`,{className:`z-0 flex w-full flex-col items-center`,children:[I===!1&&B.length===0&&(0,j.jsxs)(k,{children:[(0,j.jsx)(m,{children:(0,j.jsx)(h,{})}),`Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here.`]}),B.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`my-8 flex w-full max-w-[620px] flex-col max-md:mt-5`,children:B.map((t,a)=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsxs)(P,{centerAlign:t.actors.length<2&&t.type===`follow`,className:`hover:bg-gray-100 dark:hover:bg-gray-950`,isGrouped:t.actors.length>1,onClick:()=>U(t,a),children:[I?(0,j.jsx)(w,{className:`rounded-full`,containerClassName:`flex h-10 w-10`}):t.actors.length>1?(0,j.jsx)(P.Icon,{type:t.type}):(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(b,{author:{icon:{url:t.actors[0].avatarUrl||``},name:t.actors[0].name,handle:t.actors[0].handle},size:`notification`},t.actors[0].id),(0,j.jsx)(M,{className:`absolute -right-1 -bottom-1 z-10 border-2 border-white dark:border-black`,notificationType:t.type,size:`sm`})]}),t.actors.length>1&&(0,j.jsx)(P.Avatars,{children:(0,j.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,j.jsxs)(`div`,{className:`relative flex w-fit items-center pl-2`,children:[!e[t.id||`${t.type}_${a}`]&&t.actors.slice(0,5).map(e=>(0,j.jsx)(b,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},className:`-ml-2 bg-[#F3F3F3]! outline-2 outline-white group-hover:bg-[#EDEEF0]! group-hover:outline-gray-100 dark:outline-black group-hover:dark:outline-gray-950`,size:`notification`},e.id)),t.actors.length>5&&!e[t.id||`${t.type}_${a}`]&&(0,j.jsx)(`div`,{className:`absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white`,children:`+${r(t.actors.length-5)}`}),t.actors.length>1&&(0,j.jsxs)(f,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${e[t.id||`${t.type}_${a}`]?`ml-[-20px]`:`ml-0 w-[28px]`}`,variant:`ghost`,onClick:e=>{e?.stopPropagation(),s(t.id||`${t.type}_${a}`)},children:[(0,j.jsx)(S,{className:`${e[t.id||`${t.type}_${a}`]?`rotate-180`:``}`,size:20,strokeWidth:1.5}),e[t.id||`${t.type}_${a}`]?`Hide`:(0,j.jsx)(`span`,{className:`sr-only`,children:`Show all`})]})]}),(0,j.jsx)(`div`,{className:`overflow-hidden transition-all duration-300 ease-in-out ${e[t.id||`${t.type}_${a}`]?`mb-2 max-h-[1384px] opacity-100`:`max-h-0 opacity-0`}`,children:e[t.id||`${t.type}_${a}`]&&t.actors.length>1&&(0,j.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t.actors.map(e=>(0,j.jsxs)(`div`,{className:`group/item break-anywhere flex items-center justify-between gap-4`,onClick:t=>{t?.stopPropagation(),e.handle&&y(e.handle,n)},children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,j.jsx)(b,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},size:`xs`}),(0,j.jsx)(`span`,{className:`ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white`,children:e.name}),(0,j.jsx)(`span`,{className:`ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600`,children:e.handle})]}),t.type===`follow`&&!e.followedByMe&&e.handle&&(0,j.jsx)(v,{following:!1,handle:e.handle,variant:`link`})]},e.id))})})]})}),(0,j.jsxs)(P.Content,{children:[(0,j.jsx)(`div`,{children:I?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(w,{}),(0,j.jsx)(w,{className:`w-full max-w-60`})]}):(0,j.jsxs)(`div`,{className:`flex justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:(0,j.jsx)(R,{group:t})}),t.actors.length<2&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`mt-px text-[8px] text-gray-700 dark:text-gray-600`,children:`•`}),(0,j.jsx)(`span`,{className:`mt-0.5 text-sm text-gray-700 dark:text-gray-600`,children:i(t,!1)})]})]}),t.actors.length===1&&(t.type===`follow`||t.type===`reply`||t.type===`mention`)&&!t.actors[0].followedByMe&&t.actors[0].handle&&(0,j.jsx)(v,{following:!1,handle:t.actors[0].handle,variant:`link`})]})}),(t.type===`reply`&&t.inReplyTo||t.type===`mention`||t.type===`like`&&!t.post?.name&&t.post?.content||t.type===`repost`&&!t.post?.name&&t.post?.content)&&(t.type!==`reply`&&t.type!==`mention`?(0,j.jsxs)(`div`,{className:`ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600`,children:[t.post?.type===`article`&&t.post?.title&&(0,j.jsxs)(j.Fragment,{children:[t.post.title,` — `]}),(0,j.jsx)(`span`,{dangerouslySetInnerHTML:{__html:x(E(t.post?.content||``))}})]}):(0,j.jsx)(j.Fragment,{children:(0,j.jsxs)(`div`,{className:`mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-950/30 group-hover:dark:bg-black/40`,children:[(0,j.jsx)(z,{className:`ap-note-content text-pretty`,content:t.post?.content||``,stripTags:[`a`]}),t.post&&t.post.attachments&&t.post.attachments.length>0&&(0,j.jsx)(`div`,{className:`notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]`,children:p({...t.post,type:`Note`,attachment:t.post.attachments})})]})})),(t.type===`reply`&&t.post||t.type===`mention`)&&(0,j.jsx)(`div`,{className:`mt-1.5`,children:(0,j.jsx)(C,{actor:{...t.actors[0],icon:{url:t.actors[0].avatarUrl||``},id:t.actors[0].url,preferredUsername:t.actors[0].handle?.replace(/^@([^@]+)@.*$/,`$1`)||`unknown`},buttonClassName:`hover:bg-gray-200`,commentCount:t.post.replyCount||0,layout:`notification`,likeCount:t.post.likeCount||0,object:{...t.post,liked:t.post.likedByMe,reposted:t.post.repostedByMe},repostCount:t.post.repostCount||0,onLikeClick:d})})]})]}),a<B.length-1&&(0,j.jsx)(`div`,{className:`pl-[52px]`,children:(0,j.jsx)(F,{})})]},t.id||`${t.type}_${a}`))}),(0,j.jsx)(`div`,{ref:H,className:`h-1`}),N&&(0,j.jsx)(`div`,{className:`-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center`,children:(0,j.jsx)(g,{size:`md`})})]})]})})};export{B as default};
@@ -1 +1 @@
1
- import{o as e}from"./framework-provider-CmtnPXIT.js";import{i as t,n,r}from"./hooks-CixO01lL.js";import{n as i,r as a}from"./update-queries-C4CnvJaW.js";var o=`OffersResponseType`,s=()=>{let t=e();return()=>t.invalidateQueries({queryKey:[o]})},c=r({dataType:o,path:`/offers/`,defaultSearchParams:{}}),l=t({dataType:o,path:e=>`/offers/${e}/`}),u=n({method:`PUT`,path:e=>`/offers/${e.id}/`,body:e=>({offers:[e]}),updateQueries:{dataType:o,emberUpdateType:`createOrUpdate`,update:a(`offers`)}}),d=n({method:`POST`,path:()=>`/offers/`,body:e=>({offers:[e]}),updateQueries:{dataType:o,emberUpdateType:`createOrUpdate`,update:i(`offers`)}});export{s as a,u as i,c as n,l as r,d as t};
1
+ import{o as e}from"./framework-provider-CmtnPXIT.js";import{i as t,n,r}from"./hooks-D6EE7BIt.js";import{n as i,r as a}from"./update-queries-C4CnvJaW.js";var o=`OffersResponseType`,s=()=>{let t=e();return()=>t.invalidateQueries({queryKey:[o]})},c=r({dataType:o,path:`/offers/`,defaultSearchParams:{}}),l=t({dataType:o,path:e=>`/offers/${e}/`}),u=n({method:`PUT`,path:e=>`/offers/${e.id}/`,body:e=>({offers:[e]}),updateQueries:{dataType:o,emberUpdateType:`createOrUpdate`,update:a(`offers`)}}),d=n({method:`POST`,path:()=>`/offers/`,body:e=>({offers:[e]}),updateQueries:{dataType:o,emberUpdateType:`createOrUpdate`,update:i(`offers`)}});export{s as a,u as i,c as n,l as r,d as t};
@@ -0,0 +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{m as r,p as i,v as a}from"./hooks-D6EE7BIt.js";import{n as o}from"./dist-Ndy-PuGN.js";import{t as s}from"./use-form-vRjI0Kwk.js";import{a as c,i as l,n as u,r as d,t as f}from"./offers-Um6ab71O.js";import{f as p}from"./dist-Cb5RSHSg.js";import{t as m}from"./inline-Cw-gigDW.js";import{t as h}from"./stack-CIfOAAVf.js";import{t as g}from"./switch-CE2NuMn-.js";import{i as _,n as v,o as y,s as b,t as x}from"./select-D9oU1IoM.js";import{o as S,s as C,t as w}from"./use-settings-navigation-Bf1g1rEh.js";import{a as T,i as E,n as D,o as O,r as k,t as A}from"./field-Dh_lwk13.js";import{a as j,i as M,n as N,r as P,t as F}from"./input-group-6vEPvX9S.js";import{n as I,t as L}from"./radio-group-I7ou7PoJ.js";import{a as R,c as z,n as B,r as V,s as H,t as U}from"./table-TMCgCQK7.js";import{t as W}from"./textarea-d9qEkMOP.js";import{$n as G,$r as K,Ds as q,Pr as J,Ss as ee,Xr as te,Yr as ne,Zr as re,ai as ie,bs as ae,co as oe,cr as Y,ei as se,ni as ce,ri as le,ti as ue,wn as de}from"./index-BHy2DZX-.js";import{a as fe,r as pe}from"./tiers-Da6kxHQP.js";import{n as me}from"./confirmation-modal-B6D6mk6R.js";import{n as X}from"./global-data-provider-B949LDXJ.js";import{t as he}from"./brand-icon-09YqFZjV.js";import{o as ge,r as _e}from"./zapier-modal-BP2f4-vY.js";import{t as ve}from"./preview-modal-Dw_HtD6S.js";import{t as ye}from"./portal-frame-BF0NBIji.js";import{t as be}from"./settings-breadcrumbs-K0USP2nw.js";import{i as xe,r as Se}from"./currency-Dy4Tc2R2.js";var Ce=(e,t)=>{let{disableBackground:n=!1,name:r,code:i,displayTitle:a=``,displayDescription:o=``,type:s,cadence:c,amount:l=0,duration:u,durationInMonths:d,currency:f=`usd`,status:p,tierId:m,redemptionType:h=`signup`}=e;t=t.replace(/\/$/,``);let g=new URLSearchParams;return g.append(`disableBackground`,`false`),g.append(`name`,encodeURIComponent(r)),g.append(`code`,encodeURIComponent(i)),g.append(`display_title`,encodeURIComponent(a)),g.append(`display_description`,encodeURIComponent(o)),g.append(`type`,encodeURIComponent(s)),g.append(`cadence`,encodeURIComponent(c)),g.append(`amount`,encodeURIComponent(l)),g.append(`duration`,encodeURIComponent(u)),g.append(`duration_in_months`,encodeURIComponent(d)),g.append(`currency`,encodeURIComponent(f)),g.append(`status`,encodeURIComponent(p)),g.append(`tier_id`,encodeURIComponent(m)),g.append(`redemption_type`,encodeURIComponent(h)),n&&g.append(`disableBackground`,`true`),g.append(`admin_toolbar`,`0`),`${t}/?v=modal-portal-offer#/portal/preview/offer?${g.toString()}`},we=e=>{let t=[];return e.forEach(e=>{t.push({label:`${e.name} - Monthly`,value:`${e.id}-month-${e.currency}`}),t.push({label:`${e.name} - Yearly`,value:`${e.id}-year-${e.currency}`})}),t},Z=e(t(),1),Q=n();function Te(e){return e.toString().toLowerCase().trim().replace(/\s+/g,`-`).replace(/[^\w-]+/g,``).replace(/--+/g,`-`)}var Ee=191,De=e=>{let{fixedAmount:t=0,percentAmount:n=0,trialAmount:r=0,amount:i=0}=e;switch(e.type){case`fixed`:return t*100;case`percent`:return n;case`trial`:return r;default:return i}},Oe=({tierOptions:e,handleTierChange:t,selectedTier:n,typeOptions:r,durationOptions:i,handleTypeChange:a,handleDurationChange:o,overrides:s,handleAmountTypeChange:c,handleNameInput:l,handleTextAreaInput:u,handleDisplayTitleInput:d,handleDurationInMonthsInput:f,handleAmountInput:m,handleCodeInput:h,clearError:g,errors:S,testId:C,handleTrialAmountInput:w,amountOptions:P})=>{let R=s.cadence===`year`,z=R?i.filter(e=>e.value!==`repeating`):i,[B,V]=(0,Z.useState)(0),H=B>40?`text-red`:`text-green`,{siteData:U}=X(),[G,K]=(0,Z.useState)(!1),q=de(U),ee=`${q}${s.code.value}`;return(0,Q.jsx)(`div`,{className:`pt-7`,"data-testid":C,children:(0,Q.jsxs)(T,{className:`mb-10 gap-8`,children:[(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(A,{"data-invalid":!!S.name||void 0,children:[(0,Q.jsx)(O,{htmlFor:`offer-name`,children:`Offer name`}),(0,Q.jsx)(Y,{"aria-invalid":!!S.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,onChange:e=>{l(e),V(e.target.value.length)},onKeyDown:()=>g(`name`)}),S.name?(0,Q.jsx)(E,{children:S.name}):(0,Q.jsx)(k,{children:(0,Q.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Q.jsx)(`span`,{children:`Visible to members on Stripe Checkout page`}),(0,Q.jsxs)(`strong`,{children:[(0,Q.jsx)(`span`,{className:H,children:p(B)}),` / `,p(40)]})]})})]}),(0,Q.jsxs)(A,{"data-invalid":!!S.displayTitle||void 0,children:[(0,Q.jsx)(O,{htmlFor:`offer-display-title`,children:`Display title`}),(0,Q.jsx)(Y,{"aria-invalid":!!S.displayTitle||void 0,id:`offer-display-title`,maxLength:Ee,placeholder:`Black Friday Special`,value:s.displayTitle.value,onChange:e=>{d(e)},onKeyDown:()=>g(`displayTitle`)}),S.displayTitle&&(0,Q.jsx)(E,{children:S.displayTitle})]}),(0,Q.jsxs)(A,{children:[(0,Q.jsx)(O,{htmlFor:`offer-display-description`,children:`Display description`}),(0,Q.jsx)(W,{id:`offer-display-description`,maxLength:Ee,placeholder:`Take advantage of this limited-time offer.`,value:s.displayDescription,onChange:e=>{u(e)}})]})]})]}),(0,Q.jsxs)(`section`,{className:`mt-4`,children:[(0,Q.jsx)(`h2`,{className:`mb-4 text-lg`,children:`Details`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsx)(L,{"aria-label":`Offer type`,className:`rounded-md border border-border-default p-4`,value:s.type===`trial`?`trial`:`percent`,onValueChange:a,children:r.map(e=>{let t=`offer-type-${e.value}`;return(0,Q.jsxs)(A,{orientation:`horizontal`,children:[(0,Q.jsx)(I,{id:t,value:e.value}),(0,Q.jsxs)(D,{children:[(0,Q.jsx)(O,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,Q.jsx)(k,{children:e.description})]})]},e.value)})}),(0,Q.jsxs)(A,{children:[(0,Q.jsx)(O,{children:`Tier — Cadence`}),(0,Q.jsxs)(x,{value:n.value,onValueChange:n=>{let r=e.find(e=>e.value===n);r&&t(r)},children:[(0,Q.jsx)(y,{"aria-label":`Tier — Cadence`,"data-testid":`tier-cadence-select-offers`,children:(0,Q.jsx)(b,{})}),(0,Q.jsx)(v,{children:e.map(e=>(0,Q.jsx)(_,{value:e.value,children:e.label},e.value))})]})]}),s.type!==`trial`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(A,{"data-invalid":!!S.amount||void 0,children:[(0,Q.jsx)(O,{htmlFor:`offer-amount`,children:`Amount off`}),(0,Q.jsxs)(F,{"data-invalid":!!S.amount||void 0,children:[(0,Q.jsx)(M,{id:`offer-amount`,type:`number`,value:s.type===`fixed`?s.fixedAmount===0?``:s.fixedAmount?.toString():s.percentAmount===0?``:s.percentAmount?.toString(),onChange:e=>{m(e)},onKeyDown:()=>g(`amount`)}),(0,Q.jsx)(N,{align:`inline-end`,children:(0,Q.jsxs)(x,{value:s.type===`percent`?P[0].value:P[1].value,onValueChange:c,children:[(0,Q.jsx)(y,{"aria-label":`Amount type`,className:`h-7 w-20 border-0 bg-transparent px-2 shadow-none focus-visible:ring-0`,"data-testid":`amount-type-select-offers`,children:(0,Q.jsx)(b,{})}),(0,Q.jsx)(v,{align:`end`,children:P.map(e=>(0,Q.jsx)(_,{value:e.value,children:e.label},e.value))})]})})]}),S.amount&&(0,Q.jsx)(E,{children:S.amount})]}),(0,Q.jsxs)(A,{children:[(0,Q.jsx)(O,{children:`Duration`}),(0,Q.jsxs)(x,{value:s.duration,onValueChange:e=>{g(`durationInMonths`),o(e)},children:[(0,Q.jsx)(y,{"aria-label":`Duration`,"data-testid":`duration-select-offers`,children:(0,Q.jsx)(b,{})}),(0,Q.jsx)(v,{children:z.map(e=>(0,Q.jsx)(_,{value:e.value,children:e.label},e.value))})]})]}),s.duration===`repeating`&&!R&&(0,Q.jsx)(`div`,{className:`-mt-4`,children:(0,Q.jsxs)(A,{"data-invalid":!!S.durationInMonths||void 0,children:[(0,Q.jsxs)(F,{"data-invalid":!!S.durationInMonths||void 0,children:[(0,Q.jsx)(M,{"aria-invalid":!!S.durationInMonths||void 0,"data-testid":`duration-months-input`,type:`number`,value:s.durationInMonths===0?``:String(s.durationInMonths),onChange:e=>{f(e)},onKeyDown:()=>g(`durationInMonths`)}),(0,Q.jsx)(N,{align:`inline-end`,children:(0,Q.jsx)(j,{children:s.durationInMonths===1?`month`:`months`})})]}),S.durationInMonths&&(0,Q.jsx)(E,{children:S.durationInMonths})]})})]}),s.type===`trial`&&(0,Q.jsxs)(A,{"data-invalid":!!S.amount||void 0,children:[(0,Q.jsx)(O,{htmlFor:`trial-duration`,children:`Trial duration`}),(0,Q.jsx)(Y,{"aria-invalid":!!S.amount||void 0,id:`trial-duration`,type:`number`,value:s.trialAmount?.toString(),onChange:e=>{w(e)},onKeyDown:()=>g(`amount`)}),S.amount&&(0,Q.jsx)(E,{children:S.amount})]}),(0,Q.jsxs)(A,{"data-invalid":!!S.code||void 0,children:[(0,Q.jsx)(O,{htmlFor:`offer-code`,children:`Offer code`}),(0,Q.jsx)(Y,{"aria-invalid":!!S.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:s.code.value,onChange:e=>{h(e)},onKeyDown:()=>g(`code`)}),S.code?(0,Q.jsx)(E,{children:S.code}):s.code.value!==``&&(0,Q.jsx)(k,{children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[q,(0,Q.jsx)(`span`,{className:`font-bold`,children:s.code.value})]}),(0,Q.jsx)(J,{className:`h-auto p-0 text-sm text-green hover:text-green`,size:`sm`,type:`button`,variant:`link`,onClick:async()=>{await navigator.clipboard.writeText(ee),K(!0),setTimeout(()=>K(!1),2e3)},children:G?`Copied`:`Copy`})]})})]})]})]})]})})},$=e=>{let[t,n,r]=e.split(`-`);if(!t||!n||!r)throw Error(`Invalid input format. Expected format is: id-period-currency`);return{id:t,period:n,currency:r}},ke=()=>{let{siteData:e}=X(),t=[{title:`Discount`,description:`Offer a special reduced price`,value:`percent`},{title:`Free trial`,description:`Give free access for a limited time`,value:`trial`}],n=[{value:`once`,label:`First-payment`},{value:`repeating`,label:`Multiple-months`},{value:`forever`,label:`Forever`}],[r,i]=(0,Z.useState)(``),{updateRoute:c}=w(),{data:{tiers:l}={}}=fe(),d=pe(l||[]),p=we(d),{mutateAsync:m}=f(),[h,g]=(0,Z.useState)({tier:p[0]||{},dataset:{id:p[0]?.value?$(p[0]?.value).id:``,period:p[0]?.value?$(p[0]?.value).period:``,currency:p[0]?.value?$(p[0]?.value).currency:``}}),{data:{offers:_=[]}={}}=u(),{formState:v,updateForm:y,handleSave:b,saveState:x,okProps:S,validate:C,errors:T,clearError:E}=s({initialState:{disableBackground:!1,name:``,code:{isDirty:!1,value:``},displayTitle:{isDirty:!1,value:``},displayDescription:``,type:`percent`,cadence:h?.dataset?.period||``,amount:0,duration:`once`,durationInMonths:1,currency:h?.dataset?.currency||`USD`,status:`active`,tierId:h?.dataset?.id||``,trialAmount:7,fixedAmount:0,percentAmount:0},onSave:async()=>{let e=v.type===`trial`?`trial`:v.duration,t={name:v.name,code:v.code.value,display_title:v.displayTitle.value,display_description:v.displayDescription,cadence:v.cadence,amount:De(v)||0,duration:e,...e===`repeating`?{duration_in_months:v.durationInMonths}:{},currency:v.currency,status:v.status,redemption_type:`signup`,tier:{id:v.tierId},type:v.type,currency_restriction:!1},n=await m(t);n&&n.offers&&n.offers.length>0&&c(`offers/success/${n.offers[0].id}`)},onSaveError:()=>{},onValidate:()=>{let e={};return!v.name&&v.name.length===0&&(e.name=`Name is required`),!v.code.value&&v.code.value.length===0&&(e.code=`Code is required`),!v.displayTitle.value&&v.displayTitle.value.length===0&&(e.displayTitle=`Display title is required`),v.type===`percent`&&v.percentAmount===0&&(e.amount=`Enter an amount greater than 0.`),v.type===`percent`&&(v.percentAmount<1||v.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),(v.type===`fixed`&&v.fixedAmount===0||v.type===`fixed`&&v.fixedAmount<1)&&(e.amount=`Enter an amount greater than 0.`),v.type===`trial`&&v.trialAmount===0&&(e.amount=`Enter an amount greater than 0.`),v.type===`trial`&&v.trialAmount<1&&(e.amount=`Free trial must be at least 1 day.`),v.type!==`trial`&&v.duration===`repeating`&&(!Number.isInteger(v.durationInMonths)||v.durationInMonths<1)&&(e.durationInMonths=`Enter a whole number of months (1 or more).`),e},savingDelay:500}),D=[{value:`percent`,label:`%`},{value:`fixed`,label:v.currency}],O=e=>{let t=$(e.value),n=t.period===`year`;g({tier:e,dataset:t}),y(e=>({...e,cadence:t.period,currency:t.currency,tierId:t.id,duration:n&&e.duration===`repeating`?`once`:e.duration})),n&&E(`durationInMonths`)},k=e=>{e===`trial`&&(E(`amount`),E(`durationInMonths`)),y(t=>({...t,type:e}))},A=e=>{y(t=>({...t,type:e===`percent`?`percent`:`fixed`}))},j=e=>{let t=e.target;v.type===`fixed`?y(e=>({...e,fixedAmount:Number(t.value)})):v.type===`percent`?y(e=>({...e,percentAmount:Number(t.value)})):y(e=>({...e,amount:Number(t.value)}))},M=e=>{let t=e.target,n=Number(t.value);y(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},N=e=>{let t=e.target.value;y(e=>{let n={...e};return n.name=t,e.code.isDirty||(E(`code`),n.code={...e.code,value:Te(t)}),e.displayTitle.isDirty||(E(`displayTitle`),n.displayTitle={...e.displayTitle,value:t}),n})},P=e=>{let t=e.target;y(e=>({...e,displayTitle:{...e.displayTitle,isDirty:!0,value:t.value}}))},F=e=>{let t=e.target;y(e=>({...e,displayDescription:t.value}))},I=e=>{let t=e.target;y(e=>({...e,trialAmount:Number(t.value)}))},L=e=>{y(t=>({...t,duration:e}))},R=e=>{let t=e.target;y(e=>({...e,code:{...e.code,isDirty:!0,value:t.value}}))},z=()=>{_.length>0?c(`offers/edit`):c(`offers`)},B=(0,Z.useMemo)(()=>({name:v.name||``,code:v.code.value||``,displayTitle:v.displayTitle.value||``,displayDescription:v.displayDescription||``,type:v.type||`percent`,cadence:v.cadence||`month`,amount:De(v)||0,duration:v.type===`trial`?`trial`:v.duration||`once`,durationInMonths:v.durationInMonths||0,currency:v.currency||`USD`,status:v.status||`active`,tierId:v.tierId||d[0]?.id,redemptionType:`signup`}),[v,d]);(0,Z.useEffect)(()=>{let t=Ce(B,e.url);i(t)},[v,e.url,v.type,B]);let V=(0,Q.jsx)(Oe,{amountOptions:D,clearError:E,durationOptions:n,errors:T,handleAmountInput:j,handleAmountTypeChange:A,handleCodeInput:R,handleDisplayTitleInput:P,handleDurationChange:L,handleDurationInMonthsInput:M,handleNameInput:N,handleTextAreaInput:F,handleTierChange:O,handleTrialAmountInput:I,handleTypeChange:k,overrides:v,selectedTier:h.tier,testId:`add-offer-sidebar`,tierOptions:p,typeOptions:t,validate:C}),H=(0,Q.jsx)(ye,{href:r||``,portalParent:`offers`});return(0,Q.jsx)(ve,{backDropClick:!1,cancelLabel:`Cancel`,dirty:x===`unsaved`,height:`full`,okLabel:`Publish`,okVariant:S.variant,preview:H,previewToolbar:!1,sidebar:V,size:`lg`,testId:`add-offer-modal`,title:`Offer`,width:1140,onCancel:z,onClose:()=>{c(`offers`)},onOk:async()=>{if(C(),!Object.values(T).every(e=>!e)){o.dismiss(),o.info(`Can't save offer`,{description:`Make sure you filled all required fields`});return}try{if(await b({force:!0}))return}catch(e){let t;e instanceof a&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message),o.dismiss(),t&&o.error(`Can't save offer`,{description:t||`Please try again later`})}}})},Ae=e=>new Date(e).toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`2-digit`}),je=e=>{let t=`${i().adminRoot}#/members`,n=`offer_redemptions:[${e.join(`,`)}]`;return`${t}?filter=${encodeURIComponent(n)}`},Me=e=>je([e]),Ne=({amount:e,duration:t})=>e===100&&t===`repeating`,Pe=(e,t)=>`Retention ${e} (${t})`,Fe=({amount:e,duration:t,durationInMonths:n})=>Ne({amount:e,duration:t})?`${n} ${n===1?`month`:`months`} free`:t===`once`?`${e}% off once`:t===`repeating`?`${e}% off for ${n} mo`:`${e}% off forever`,Ie=(e,t)=>{let n=t.trim(),r=Fe(e),i=Pe(r,n);if(i.length<=40)return i;let a=i.length-40,o=Math.max(3,n.length-a);return Pe(r,n.slice(0,o))};function Le(e){return new Date(e).toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`2-digit`})}var Re=({clearError:e,errors:t,offer:n,updateOffer:i})=>{let{siteData:a}=X(),[s,c]=(0,Z.useState)(!1),u=r(),{mutateAsync:d}=l(),[f,m]=(0,Z.useState)(n?.name.length||0),h=f>40?`text-red`:`text-green`,{updateRoute:g}=w();(0,Z.useEffect)(()=>{n?.name&&m(n?.name.length)},[n?.name]);let _=de(a),v=`${_}${n?.code}`,y=async()=>{await navigator.clipboard.writeText(v),c(!0),setTimeout(()=>c(!1),2e3)},b=async()=>{n?.status===`active`?C.show(me,{title:`Archive offer`,prompt:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`New members will no longer be able to subscribe using this offer.`}),(0,Q.jsxs)(`p`,{children:[`All members that previously redeemed `,(0,Q.jsx)(`strong`,{children:n?.name}),` will remain unchanged.`]})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async e=>{try{await d({...n,status:`archived`}),e?.remove(),o.success(`Offer archived`),g(`offers/edit`)}catch(e){u(e)}}}):C.show(me,{title:`Reactivate offer`,prompt:(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsxs)(`p`,{children:[`Reactivating `,(0,Q.jsx)(`strong`,{children:n?.name}),` will allow new members to subscribe using this offer. Existing members will remain unchanged.`]})}),okLabel:`Reactivate`,onOk:async e=>{try{await d({...n,status:`active`}),e?.remove(),o.success(`Offer reactivated`),g(`offers/edit`)}catch(e){u(e)}}})};return(0,Q.jsxs)(`div`,{className:`flex grow flex-col pt-2`,children:[(0,Q.jsxs)(T,{className:`mb-10 grow gap-8`,children:[(0,Q.jsx)(`section`,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5 rounded-md border border-grey-300 p-4 pb-3.5 dark:border-grey-800`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Created on`}),(0,Q.jsx)(`span`,{children:Le(n?.created_at?n.created_at:``)})]}),(0,Q.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Performance`}),(0,Q.jsxs)(`span`,{children:[p(n?.redemption_count||0),` `,n?.redemption_count===1?`redemption`:`redemptions`]})]}),n?.redemption_count>0&&n?.last_redeemed?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Last redemption`}),(0,Q.jsx)(`span`,{children:Le(n?.last_redeemed)})]}):null]}),n?.redemption_count>0?(0,Q.jsx)(`a`,{className:`font-semibold text-green`,href:Me(n?.id),children:`See members →`}):null]})]})}),(0,Q.jsxs)(`section`,{className:`mt-2`,children:[(0,Q.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(A,{"data-invalid":!!t.name||void 0,children:[(0,Q.jsx)(O,{htmlFor:`offer-name`,children:`Offer name`}),(0,Q.jsx)(Y,{"aria-invalid":!!t.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,value:n?.name??``,onChange:e=>{m(e.target.value.length),i({name:e.target.value})},onKeyDown:()=>e(`name`)}),t.name?(0,Q.jsx)(E,{children:t.name}):(0,Q.jsx)(k,{children:(0,Q.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Q.jsx)(`span`,{children:`Visible to members on Stripe Checkout page`}),(0,Q.jsxs)(`strong`,{children:[(0,Q.jsx)(`span`,{className:h,children:p(f)}),` / `,p(40)]})]})})]}),(0,Q.jsxs)(A,{className:`group`,"data-invalid":!!t.code||void 0,children:[(0,Q.jsx)(O,{htmlFor:`offer-code`,children:`Offer code`}),(0,Q.jsxs)(F,{"data-invalid":!!t.code||void 0,children:[(0,Q.jsx)(M,{"aria-invalid":!!t.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:n?.code??``,onChange:e=>i({code:e.target.value}),onKeyDown:()=>e(`code`)}),n?.code!==``&&(0,Q.jsx)(N,{align:`inline-end`,children:(0,Q.jsx)(P,{onClick:y,children:s?`Copied!`:`Copy link`})})]}),t.code?(0,Q.jsx)(E,{children:t.code}):n?.code!==``&&(0,Q.jsxs)(k,{className:`truncate`,children:[_,(0,Q.jsx)(`span`,{className:`font-bold text-foreground`,children:n?.code})]})]}),(0,Q.jsxs)(A,{"data-invalid":!!t.displayTitle||void 0,children:[(0,Q.jsx)(O,{htmlFor:`offer-display-title`,children:`Display title`}),(0,Q.jsx)(Y,{"aria-invalid":!!t.displayTitle||void 0,id:`offer-display-title`,placeholder:`Black Friday Special`,value:n?.display_title??``,onChange:e=>i({display_title:e.target.value}),onKeyDown:()=>e(`displayTitle`)}),t.displayTitle&&(0,Q.jsx)(E,{children:t.displayTitle})]}),(0,Q.jsxs)(A,{children:[(0,Q.jsx)(O,{htmlFor:`offer-display-description`,children:`Display description`}),(0,Q.jsx)(W,{id:`offer-display-description`,placeholder:`Take advantage of this limited-time offer.`,value:n?.display_description??``,onChange:e=>i({display_description:e.target.value})})]})]})]})]}),(0,Q.jsx)(`div`,{className:`mb-2`,children:n?.status===`active`?(0,Q.jsx)(J,{className:`h-auto p-0 text-destructive hover:text-destructive`,type:`button`,variant:`link`,onClick:b,children:`Archive offer`}):(0,Q.jsx)(J,{className:`h-auto p-0 text-green hover:text-green`,type:`button`,variant:`link`,onClick:b,children:`Reactivate offer`})})]})},ze=({id:e})=>{let{siteData:t}=X(),{updateRoute:n}=w(),i=r(),{mutateAsync:c}=l(),[u,f]=(0,Z.useState)(``),{data:{offers:p=[]}={}}=d(e||``),{formState:m,saveState:h,updateForm:g,setFormState:_,handleSave:v,validate:y,errors:b,clearError:x,okProps:S}=s({initialState:p[0],savingDelay:500,onSave:async()=>{await c(m)},onSaveError:i,onValidate:()=>{let e={};return m?.name||(e.name=`Name is required`),m?.display_title||(e.displayTitle=`Display title is required`),m?.code||(e.code=`Please enter a code`),e}});(0,Z.useEffect)(()=>{_(()=>p[0])},[_,p]);let C=(0,Q.jsx)(Re,{clearError:x,errors:b,offer:m,updateOffer:e=>{g(t=>({...t,...e}))},validate:y});(0,Z.useEffect)(()=>{let e=Ce({name:m?.name||``,code:m?.code||``,displayTitle:m?.display_title||``,displayDescription:m?.display_description||``,type:m?.type||``,cadence:m?.cadence||``,amount:m?.amount,duration:m?.duration||``,durationInMonths:m?.duration_in_months||0,currency:m?.currency||``,status:m?.status||``,tierId:m?.tier?.id||``,redemptionType:`signup`},t.url);f(e)},[m,t]);let T=(0,Q.jsx)(ye,{href:u||``,portalParent:`offers`}),E=()=>{n(`offers/edit`)};return p?(0,Q.jsx)(ve,{backDropClick:!1,cancelLabel:`Cancel`,dirty:h===`unsaved`,height:`full`,okLabel:S.label||`Save`,okVariant:S.variant,preview:T,previewToolbarBreadcrumbs:(0,Q.jsx)(be,{current:m?.name||`Offer`,label:`Offers`,onBack:E}),sidebar:C,size:`lg`,testId:`offer-update-modal`,title:`Offer`,width:1140,onCancel:E,onClose:()=>{n(`offers`)},onOk:async()=>{try{if(await v({force:!0}))return}catch(e){let t;e instanceof a&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message),o.dismiss(),t&&o.error(`Can't save offer`,{description:`Please try again later`})}}}):null},Be=[{title:`Percentage discount`,description:`Offer a special reduced price`,value:`percent`},{title:`Free month(s)`,description:`Give free access for a limited time`,value:`free_months`}],Ve=[{value:`once`,label:`First-payment`},{value:`repeating`,label:`Multiple-months`},{value:`forever`,label:`Forever`}],He=191,Ue=99,We=`Enter a whole number of months between 1 and ${Ue}.`,Ge=e=>Math.max(1,Number.isFinite(e)?Math.trunc(e):0),Ke=({type:e,percentAmount:t,freeMonths:n,lastPercentAmount:r,lastFreeMonths:i})=>e===`free_months`?n>0?n:i:t>0?t:r,qe=(e=`monthly`)=>({enabled:!1,displayTitle:``,displayDescription:``,type:e===`yearly`?`percent`:`free_months`,percentAmount:20,duration:`once`,durationInMonths:1,freeMonths:1}),Je=e=>e.type===`percent`&&e.amount===100&&e.duration===`repeating`,Ye=(e,t=`monthly`)=>{let n=qe(t);if(!e)return n;let r=Je(e),i=e.type===`percent`&&!r,a=e.duration===`repeating`&&e.duration_in_months?e.duration_in_months:n.durationInMonths;return{enabled:e.status===`active`,displayTitle:e.display_title||``,displayDescription:e.display_description||``,type:r?`free_months`:`percent`,percentAmount:i?e.amount:n.percentAmount,duration:i?e.duration:n.duration,durationInMonths:a,freeMonths:r&&e.duration_in_months||n.freeMonths}},Xe=({formState:e,lastPercentAmount:t,lastFreeMonths:n})=>{let r=Ke({type:e.type,percentAmount:e.percentAmount,freeMonths:e.freeMonths,lastPercentAmount:t,lastFreeMonths:n});if(e.type===`free_months`)return{type:`percent`,amount:100,duration:`repeating`,durationInMonths:Ge(r)};let i=e.duration;return{type:`percent`,amount:r,duration:i,durationInMonths:i===`repeating`?Ge(e.durationInMonths):0}},Ze=e=>{if(!e)return null;let t=e.duration_in_months??0;return{type:`percent`,amount:e.amount,duration:e.duration,durationInMonths:t}},Qe=e=>e?`${e.type}:${e.amount}:${e.duration}:${e.durationInMonths}`:``,$e=e=>Number.isInteger(e)&&e>0&&e<=Ue,et=(e,t)=>e.displayTitle!==t.displayTitle||e.displayDescription!==t.displayDescription||e.type!==t.type||e.percentAmount!==t.percentAmount||e.duration!==t.duration||e.durationInMonths!==t.durationInMonths||e.freeMonths!==t.freeMonths,tt=({formState:e,updateForm:t,clearError:n,errors:r,cadence:i,lastRedeemed:a,membersFilterUrl:o,redemptions:s})=>{let c=i===`yearly`?Ve.filter(e=>e.value!==`repeating`):Ve;return(0,Q.jsx)(`div`,{className:`flex grow flex-col pt-2`,children:(0,Q.jsxs)(T,{className:`mb-10 grow gap-8`,children:[(0,Q.jsx)(`section`,{children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-5 rounded-md border border-grey-300 p-4 pb-3.5 dark:border-grey-800`,children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,Q.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Performance`}),(0,Q.jsxs)(`span`,{children:[p(s),` `,s===1?`redemption`:`redemptions`]})]}),s>0&&a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Last redemption`}),(0,Q.jsx)(`span`,{children:Ae(a)})]}):null]}),s>0&&o?(0,Q.jsx)(`a`,{className:`font-semibold text-green`,href:o,children:`See members →`}):null]})})})}),(0,Q.jsx)(`section`,{className:`mt-2`,children:(0,Q.jsxs)(A,{orientation:`horizontal`,children:[(0,Q.jsxs)(D,{children:[(0,Q.jsxs)(O,{htmlFor:`${i}-retention-enabled`,children:[`Enable `,i,` retention`]}),(0,Q.jsx)(k,{children:i===`monthly`?`Applied to monthly plans`:`Applied to annual plans`})]}),(0,Q.jsx)(g,{checked:e.enabled,id:`${i}-retention-enabled`,onCheckedChange:e=>t(t=>({...t,enabled:e}))})]})}),e.enabled&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`section`,{className:`mt-2`,children:[(0,Q.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(A,{children:[(0,Q.jsx)(O,{htmlFor:`retention-display-title`,children:`Display title`}),(0,Q.jsx)(Y,{id:`retention-display-title`,maxLength:He,placeholder:`Before you go`,value:e.displayTitle,onChange:e=>{t(t=>({...t,displayTitle:e.target.value}))}})]}),(0,Q.jsxs)(A,{children:[(0,Q.jsx)(O,{htmlFor:`retention-display-description`,children:`Display description`}),(0,Q.jsx)(W,{id:`retention-display-description`,maxLength:He,placeholder:`We'd hate to see you leave. How about a special offer to stay?`,value:e.displayDescription,onChange:e=>{t(t=>({...t,displayDescription:e.target.value}))}})]})]})]}),(0,Q.jsxs)(`section`,{className:`mt-4`,children:[(0,Q.jsx)(`h2`,{className:`mb-4 text-lg`,children:`Details`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[i===`monthly`&&(0,Q.jsx)(L,{"aria-label":`${i} retention offer type`,className:`rounded-md border border-border-default p-4`,value:e.type,onValueChange:e=>{n(`amount`),n(`durationInMonths`),t(t=>({...t,type:e}))},children:Be.map(e=>{let t=`${i}-retention-type-${e.value}`;return(0,Q.jsxs)(A,{orientation:`horizontal`,children:[(0,Q.jsx)(I,{id:t,value:e.value}),(0,Q.jsxs)(D,{children:[(0,Q.jsx)(O,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,Q.jsx)(k,{children:e.description})]})]},e.value)})}),e.type===`percent`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(A,{"data-invalid":!!r.amount||void 0,children:[(0,Q.jsx)(O,{htmlFor:`retention-amount`,children:`Amount off`}),(0,Q.jsxs)(F,{"data-invalid":!!r.amount||void 0,children:[(0,Q.jsx)(M,{"aria-invalid":!!r.amount||void 0,id:`retention-amount`,type:`number`,value:e.percentAmount===0?``:String(e.percentAmount),onChange:e=>{let n=Number(e.target.value),r=Number.isNaN(n)?0:n;t(e=>({...e,percentAmount:r}))},onKeyDown:()=>n(`amount`)}),(0,Q.jsx)(N,{align:`inline-end`,children:(0,Q.jsx)(j,{children:`%`})})]}),r.amount&&(0,Q.jsx)(E,{children:r.amount})]}),(0,Q.jsxs)(A,{children:[(0,Q.jsx)(O,{children:`Duration`}),(0,Q.jsxs)(x,{value:e.duration,onValueChange:e=>{n(`durationInMonths`),t(t=>({...t,duration:e}))},children:[(0,Q.jsx)(y,{"aria-label":`Duration`,children:(0,Q.jsx)(b,{})}),(0,Q.jsx)(v,{children:c.map(e=>(0,Q.jsx)(_,{value:e.value,children:e.label},e.value))})]})]}),e.duration===`repeating`&&(0,Q.jsx)(`div`,{className:`-mt-4`,children:(0,Q.jsxs)(A,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,Q.jsxs)(F,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,Q.jsx)(M,{"aria-invalid":!!r.durationInMonths||void 0,"data-testid":`duration-months-input`,type:`number`,value:e.durationInMonths===0?``:String(e.durationInMonths),onChange:e=>{let n=Number(e.target.value);t(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},onKeyDown:()=>n(`durationInMonths`)}),(0,Q.jsx)(N,{align:`inline-end`,children:(0,Q.jsx)(j,{children:e.durationInMonths===1?`month`:`months`})})]}),r.durationInMonths&&(0,Q.jsx)(E,{children:r.durationInMonths})]})})]}),e.type===`free_months`&&(0,Q.jsxs)(A,{"data-invalid":!!r.amount||void 0,children:[(0,Q.jsx)(O,{htmlFor:`retention-free-months`,children:`Free months`}),(0,Q.jsxs)(F,{"data-invalid":!!r.amount||void 0,children:[(0,Q.jsx)(M,{"aria-invalid":!!r.amount||void 0,id:`retention-free-months`,type:`number`,value:e.freeMonths===0?``:String(e.freeMonths),onChange:e=>{let n=Number(e.target.value);t(e=>({...e,freeMonths:Number.isNaN(n)?0:n}))},onKeyDown:()=>n(`amount`)}),(0,Q.jsx)(N,{align:`inline-end`,children:(0,Q.jsx)(j,{children:e.freeMonths===1?`month`:`months`})})]}),r.amount&&(0,Q.jsx)(E,{children:r.amount})]})]})]})]})]})})},nt=({id:e})=>{let{updateRoute:t}=w(),{siteData:n}=X(),{data:{tiers:r=[]}={}}=fe(),{data:{offers:i=[]}={},isFetched:d,isFetching:p}=u(),{mutateAsync:m}=f(),{mutateAsync:h}=l(),g=c(),[_,v]=(0,Z.useState)(``),y=e===`monthly`?`monthly`:`yearly`,b=y===`monthly`?`Monthly retention`:`Yearly retention`,x=y===`monthly`?`month`:`year`,S=pe(r||[]),C=(0,Z.useMemo)(()=>i.filter(e=>e.redemption_type===`retention`&&e.cadence===x).sort((e,t)=>{let n=e.created_at?new Date(e.created_at).getTime():0;return(t.created_at?new Date(t.created_at).getTime():0)-n}),[i,x]),T=(0,Z.useMemo)(()=>C.find(e=>e.status===`active`)||null,[C]),E=C[0]||null,D=T||E,O=(0,Z.useMemo)(()=>C.reduce((e,t)=>e+(t.redemption_count||0),0),[C]),k=(0,Z.useMemo)(()=>C.map(e=>e.id),[C]),A=(0,Z.useMemo)(()=>C.map(e=>e.last_redeemed).filter(e=>!!e).sort((e,t)=>new Date(t).getTime()-new Date(e).getTime())[0]||null,[C]),j=(0,Z.useMemo)(()=>O===0||k.length===0?null:je(k),[k,O]),[M,N]=(0,Z.useState)(20),[P,F]=(0,Z.useState)(1),[I,L]=(0,Z.useState)(null),{formState:R,setFormState:z,updateForm:B,handleSave:V,saveState:H,okProps:U,errors:W,clearError:G}=s({initialState:qe(y),savingDelay:500,onSave:async()=>{let e=!1,t=Xe({formState:R,lastPercentAmount:M,lastFreeMonths:P}),n=Qe(Ze(D))!==Qe(t),r=R.enabled?`active`:`archived`,i=R.displayTitle||``,a=R.displayDescription||``,o=D?i!==(D.display_title||``)||a!==(D.display_description||``):i!==``||a!==``,s=qe(y),c=!R.enabled&&!D&&et(R,s),l=async n=>{let r=crypto.getRandomValues(new Uint32Array(1))[0].toString(16).padStart(8,`0`),o=Ie(t,r);await m({name:o,code:r,display_title:i,display_description:a,cadence:x,amount:t.amount,duration:t.duration,duration_in_months:t.duration===`repeating`?t.durationInMonths:null,currency:null,status:n,redemption_type:`retention`,tier:null,type:t.type,currency_restriction:!1}),e=!0},u=async()=>{e&&await g()};if(!(!D&&!R.enabled&&!c)){if(n){!R.enabled&&T&&(await h({...T,status:`archived`}),e=!0),await l(r),await u();return}if(D){let t=D.status!==r;(o||t)&&(await h({...D,display_title:i,display_description:a,status:r}),e=!0),await u();return}(R.enabled||c)&&await l(r),await u()}},onSaveError:e=>{let t=`Please try again later`;e instanceof a&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message||t),o.dismiss(),o.error(`Failed to save offer`,{description:t})},onValidate:()=>{let e={};return R.enabled?(R.type===`percent`&&((R.percentAmount<1||R.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),R.duration===`repeating`&&!$e(R.durationInMonths)&&(e.durationInMonths=We)),R.type===`free_months`&&($e(R.freeMonths)||(e.amount=We)),e):e}}),K=`${e}:${D?.id||`none`}`;(0,Z.useEffect)(()=>{!d||p||H===`unsaved`||I===K||(z(()=>Ye(D,y)),L(K))},[y,K,D,d,I,p,H,z]),(0,Z.useEffect)(()=>{R.percentAmount>0&&N(R.percentAmount)},[R.percentAmount]),(0,Z.useEffect)(()=>{R.freeMonths>0&&F(R.freeMonths)},[R.freeMonths]);let q=()=>{t(`offers/edit`)},J=(0,Q.jsx)(tt,{cadence:y,clearError:G,errors:W,formState:R,lastRedeemed:A,membersFilterUrl:j,redemptions:O,updateForm:B}),ee=async()=>{try{await V({force:!0})&&q()}catch{}},te=(0,Z.useMemo)(()=>{let e=Xe({formState:R,lastPercentAmount:M,lastFreeMonths:P}),t=S.find(e=>x===`month`?e.monthly_price:e.yearly_price);return{enabled:R.enabled,name:`${y} retention`,code:`${y}-retention`,displayTitle:R.displayTitle||``,displayDescription:R.displayDescription||``,type:e.type,cadence:x,amount:e.amount,duration:e.duration,durationInMonths:e.durationInMonths,currency:``,status:`active`,tierId:t?.id||``,redemptionType:`retention`}},[S,y,R,P,M,x]);(0,Z.useEffect)(()=>{if(!n.url){v(``);return}let e=Ce(te,n.url);v(e)},[te,n.url]);let ne=(0,Q.jsx)(ye,{href:_||``,portalParent:`offers`});return(0,Q.jsx)(ve,{backDropClick:!1,cancelLabel:`Cancel`,dirty:H===`unsaved`,height:`full`,okLabel:U.label||`Save`,okVariant:U.variant,preview:ne,previewToolbarBreadcrumbs:(0,Q.jsx)(be,{current:b,label:`Offers`,onBack:q}),sidebar:J,size:`lg`,testId:`retention-offer-modal`,title:`Offer`,width:1140,onCancel:q,onClose:()=>t(`offers`),onOk:ee})},rt=({id:e})=>{let{updateRoute:t}=w(),{data:{offers:n=[]}={}}=d(e||``),[r,i]=(0,Z.useState)(),[a,o]=(0,Z.useState)(``),{siteData:s}=X();(0,Z.useEffect)(()=>{if(n.length>0){let e=n[0],t=`${de(s)}${e?.code}`;o(t),i(e)}},[n,s]);let[c,l]=(0,Z.useState)(!1),u=()=>{let e=``;switch(r?.type){case`percent`:e=r?.amount+`% discount`;break;case`fixed`:e=p(Se(r?.amount),{maximumFractionDigits:2})+` `+r?.currency+` discount`;break;case`trial`:e=r?.amount+` days free trial`;break;default:break}return`${encodeURIComponent(r?.name||``)} — Check out ${encodeURIComponent(e)} on:`};return(0,Q.jsx)(S,{animate:!1,backDropClick:!1,footer:!1,height:`full`,size:`lg`,testId:`offer-success-modal`,topRightContent:`close`,width:1140,onClose:()=>{t(`offers`)},children:(0,Q.jsxs)(`div`,{className:`-mt-6 flex h-full flex-col items-center justify-center text-center`,children:[(0,Q.jsx)(be,{className:`absolute top-5 left-6`,current:r?.name||``,label:`Offers`,onBack:()=>t(`offers/edit`)}),(0,Q.jsx)(ae,{className:`-mt-4 size-10 text-grey-700`}),(0,Q.jsx)(`h1`,{className:`mt-6 text-4xl`,children:`Your new offer is live!`}),(0,Q.jsx)(`p`,{className:`mt-3 max-w-[510px] text-[1.6rem]`,children:`You can share the link anywhere. In your newsletter, social media, a podcast, or in-person. It all just works.`}),(0,Q.jsxs)(`div`,{className:`mt-8 flex w-full max-w-md flex-col gap-8`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse gap-2`,children:[(0,Q.jsx)(Y,{name:`offer-url`,type:`url`,value:a,disabled:!0}),(0,Q.jsx)(J,{className:`w-full`,type:`button`,onClick:async()=>{await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3)},children:c?`Copied!`:`Copy link`})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-4 text-sm font-medium before:h-px before:grow before:bg-grey-300 before:content-[""] after:h-px after:grow after:bg-grey-300 after:content-[""] dark:before:bg-grey-800 dark:after:bg-grey-800`,children:`OR`}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(J,{"aria-label":`Share on X`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`https://twitter.com/intent/tweet?url=${encodeURI(a)}&text=${u()}`,`_blank`)},children:(0,Q.jsx)(he,{className:`size-3.5!`,name:`twitter-x`})}),(0,Q.jsx)(J,{"aria-label":`Share on Facebook`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(a)}`,`_blank`)},children:(0,Q.jsx)(he,{className:`size-3.5!`,name:`facebook`})}),(0,Q.jsx)(J,{"aria-label":`Share on LinkedIn`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`http://www.linkedin.com/shareArticle?mini=true&url=${encodeURI(a)}&title=${u()}`,`_blank`)},children:(0,Q.jsx)(he,{className:`size-3.5!`,name:`linkedin`})})]})]})]})})},it=(e,t)=>e.find(e=>e.redemption_type===`retention`&&e.cadence===t&&e.status===`active`)||null,at=(e,t)=>e.reduce((e,n)=>n.redemption_type!==`retention`||n.cadence!==t?e:e+(n.redemption_count||0),0),ot=(e,t)=>e.filter(e=>e.redemption_type===`retention`&&e.cadence===t).map(e=>e.id),st=(e,t)=>{let n=e.filter(e=>e.redemption_type===`retention`&&e.cadence===t&&e.created_at).map(e=>new Date(e.created_at).getTime()).filter(e=>!Number.isNaN(e));return n.length===0?null:new Date(Math.max(...n)).toISOString()},ct=e=>e.type===`percent`&&e.amount===100&&e.duration===`repeating`,lt=e=>{if(!e)return null;if(ct(e)){let t=e.duration_in_months||0,n=t===1?`month`:`months`;return`${p(t)} ${n} free`}return e.type===`percent`?`${p(e.amount)}% OFF`:null},ut=e=>{if(!e)return null;if(ct(e))return``;if(e.duration===`once`)return`First payment`;if(e.duration===`repeating`&&e.duration_in_months){let t=e.duration_in_months===1?`month`:`months`;return`For ${p(e.duration_in_months)} ${t}`}return e.duration===`forever`?`Forever`:null},dt=e=>{let t=it(e,`month`),n=it(e,`year`),r=ot(e,`month`),i=ot(e,`year`),a=at(e,`month`),o=at(e,`year`);return[{id:`monthly`,name:`Monthly retention`,description:`Applied to monthly plans`,terms:lt(t),termsDetail:ut(t),redemptionOfferIds:r,redemptions:a,status:t?`active`:`inactive`,createdAt:st(e,`month`)},{id:`yearly`,name:`Yearly retention`,description:`Applied to annual plans`,terms:lt(n),termsDetail:ut(n),redemptionOfferIds:i,redemptions:o,status:n?`active`:`inactive`,createdAt:st(e,`year`)}]},ft=e=>e===`month`?`monthly`:`yearly`,pt=e=>e===`once`?`First payment`:e===`repeating`?`Repeating`:`Forever`,mt=(e,t,n,r,i)=>{let a=``,o=n===`month`?i?.monthly_price??0:i?.yearly_price??0,s=o,c=e=>parseFloat(e.toFixed(2)),l=e=>p(c(Se(e)),{maximumFractionDigits:2}),u=xe(r)+l(o);switch(e){case`percent`:a=`${p(t)}% off`,s=o-o*t/100;break;case`fixed`:a=`${l(t)} ${r} off`,s=o-t;break;case`trial`:a=`${p(t)} days free`,u=``;break;default:break}s<0&&(s=0);let d=xe(r)+l(s);return{discountOffer:a,originalPriceWithCurrency:u,updatedPriceWithCurrency:d}},ht=({showArchived:e,setShowArchived:t,sortOption:n,sortDirection:r,onSortChange:i,onDirectionChange:a})=>(0,Q.jsxs)(ne,{children:[(0,Q.jsx)(ie,{asChild:!0,children:(0,Q.jsx)(J,{"aria-label":`Filter options`,className:`text-muted-foreground hover:text-foreground`,size:`icon`,type:`button`,variant:`ghost`,children:(0,Q.jsx)(oe,{size:16,strokeWidth:1.5})})}),(0,Q.jsxs)(re,{align:`end`,className:`z-[9999] min-w-[200px] normal-case`,children:[(0,Q.jsx)(se,{className:`text-xs tracking-wide text-muted-foreground uppercase`,children:`Sort by`}),(0,Q.jsxs)(ue,{value:n,onValueChange:i,children:[(0,Q.jsx)(ce,{value:`date-added`,children:`Date added`}),(0,Q.jsx)(ce,{value:`name`,children:`Name`}),(0,Q.jsx)(ce,{value:`redemptions`,children:`Redemptions`})]}),(0,Q.jsxs)(K,{onSelect:a,children:[r===`asc`?(0,Q.jsx)(ee,{className:`size-3`}):(0,Q.jsx)(q,{className:`size-3`}),r===`asc`?`Ascending`:`Descending`]}),(0,Q.jsx)(le,{}),(0,Q.jsx)(te,{checked:e,onCheckedChange:e=>t(!!e),children:`Show archived`})]})]}),gt=({offer:e,onClick:t})=>{let n=e.redemptions>0&&e.redemptionOfferIds.length>0?je(e.redemptionOfferIds):void 0;return(0,Q.jsxs)(z,{"data-testid":`retention-offer-item`,children:[(0,Q.jsx)(V,{className:`sticky left-0 z-10 bg-background p-0`,children:(0,Q.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:(0,Q.jsxs)(h,{gap:`none`,children:[(0,Q.jsx)(`span`,{className:`font-semibold`,children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.description})]})})}),(0,Q.jsx)(V,{className:`p-0 whitespace-nowrap`,children:(0,Q.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:e.terms?(0,Q.jsxs)(h,{gap:`none`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium uppercase`,children:e.terms}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.termsDetail})]}):(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`–`})})}),(0,Q.jsx)(V,{className:`p-0 whitespace-nowrap`,children:(0,Q.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`–`})})}),(0,Q.jsx)(V,{className:`p-0 whitespace-nowrap`,children:n?(0,Q.jsx)(`a`,{className:`block cursor-pointer p-5 hover:underline`,"data-testid":`retention-redemptions-link-${e.id}`,href:n,children:p(e.redemptions)}):(0,Q.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,"data-testid":`retention-redemptions-link-${e.id}`,type:`button`,onClick:t,children:p(e.redemptions)})}),(0,Q.jsx)(V,{className:`p-0 whitespace-nowrap`,children:(0,Q.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:e.status===`active`?(0,Q.jsx)(G,{className:`rounded-full uppercase`,variant:`success`,children:`Active`}):(0,Q.jsx)(G,{className:`rounded-full uppercase`,variant:`secondary`,children:`Inactive`})})})]})},_t=({archived:e,offer:t,tier:n,onClick:r})=>{let{discountOffer:i,originalPriceWithCurrency:a,updatedPriceWithCurrency:o}=mt(t.type,t.amount,t.cadence,t.currency||`USD`,n);return(0,Q.jsxs)(z,{className:e?`opacity-60`:void 0,"data-testid":`offer-item`,children:[(0,Q.jsx)(V,{className:`sticky left-0 z-10 bg-background p-0`,children:(0,Q.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:(0,Q.jsxs)(h,{gap:`none`,children:[(0,Q.jsx)(`span`,{className:`font-semibold`,children:t.name}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[n.name,` `,ft(t.cadence)]})]})})}),(0,Q.jsx)(V,{className:`p-0 whitespace-nowrap`,children:(0,Q.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:(0,Q.jsxs)(h,{gap:`none`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium uppercase`,children:i}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:t.type===`trial`?`Trial period`:pt(t.duration)})]})})}),(0,Q.jsx)(V,{className:`p-0 whitespace-nowrap`,children:(0,Q.jsxs)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:o}),` `,t.type===`trial`?null:(0,Q.jsx)(`span`,{className:`relative text-sm text-muted-foreground before:absolute before:-inset-x-0.5 before:top-1/2 before:rotate-[-20deg] before:border-t before:content-[""]`,children:a})]})}),(0,Q.jsx)(V,{className:`p-0 whitespace-nowrap`,children:t.redemption_count>0&&t.id?(0,Q.jsx)(`a`,{className:`block cursor-pointer p-5 hover:underline`,href:Me(t.id),children:p(t.redemption_count)}):(0,Q.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:p(t.redemption_count)})}),(0,Q.jsx)(V,{className:`p-0 whitespace-nowrap`,children:(0,Q.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:e?(0,Q.jsx)(G,{className:`rounded-full uppercase`,variant:`secondary`,children:`Archived`}):(0,Q.jsx)(G,{className:`rounded-full uppercase`,variant:`success`,children:`Active`})})})]})},vt=e=>e.offer.name,yt=e=>e.kind===`retention`?e.offer.redemptions:e.offer.redemption_count,bt=e=>e.kind===`retention`?e.offer.createdAt:e.offer.created_at||null,xt=(e,t,n)=>{let r=n===`desc`?-1:1;return[...e].sort((e,n)=>{let i;switch(t){case`name`:i=vt(e).localeCompare(vt(n));break;case`redemptions`:i=yt(e)-yt(n);break;default:{let t=bt(e),r=bt(n);if(!t&&!r)i=0;else if(!t)return 1;else if(r)i=new Date(t).getTime()-new Date(r).getTime();else return-1;break}}return(i||vt(e).localeCompare(vt(n)))*r})},St=()=>{let{updateRoute:e}=w(),{data:{offers:t=[]}={}}=u(),{data:{tiers:n}={}}=fe(),r=t.filter(e=>e.redemption_type===`signup`),i=dt(t),{sortingState:a,setSortingState:s}=ge(),c=a?.find(e=>e.type===`offers`),{offersShowArchived:l,setOffersShowArchived:d}=_e(),f=c?.option||`date-added`,p=c?.direction||`desc`,g=t=>{t&&e(`offers/edit/${t}`)},_=t=>{e(`offers/edit/retention/${t}`)},v=pe(n||[]),y=r.filter(e=>{let t=n?.find(t=>t.id===e?.tier?.id),r=e.status===`active`&&t&&t.active===!0,i=e.status===`archived`||t&&t.active===!1;return!!(r||l&&i)}),b=xt([...i.map(e=>({kind:`retention`,offer:e})),...y.map(e=>({kind:`signup`,offer:e}))],f,p),x=e=>{s?.([{type:`offers`,option:e,direction:p}])},C=()=>{s?.([{type:`offers`,option:f,direction:p===`asc`?`desc`:`asc`}])},T=e=>{let t=n?.find(t=>t.id===e?.tier?.id);return e.status===`archived`||t?.active===!1};return(0,Q.jsx)(S,{animate:!1,backDropClick:!1,cancelLabel:``,footer:!1,height:`full`,size:`lg`,testId:`offers-modal`,title:`Offers`,topRightContent:(0,Q.jsxs)(m,{gap:`md`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>{e(`offers`)},children:`Close`}),(0,Q.jsx)(J,{type:`button`,onClick:()=>{v.length===0?o.info(`You must have an active tier to create an offer.`):e(`offers/new`)},children:`New offer`})]}),width:1140,onClose:()=>{e(`offers`)},children:(0,Q.jsx)(h,{className:`h-full pt-8`,children:(0,Q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Q.jsxs)(U,{className:`m-0 min-w-[900px]`,children:[(0,Q.jsxs)(`colgroup`,{children:[(0,Q.jsx)(`col`,{className:`w-[25%]`}),(0,Q.jsx)(`col`,{className:`w-[200px]`}),(0,Q.jsx)(`col`,{className:`w-[200px]`}),(0,Q.jsx)(`col`,{className:`w-[200px]`}),(0,Q.jsx)(`col`,{className:`w-[220px]`})]}),(0,Q.jsx)(H,{children:(0,Q.jsxs)(z,{children:[(0,Q.jsx)(R,{className:`sticky left-0 z-10 h-auto bg-background p-0 pb-2.5 pl-5 uppercase`,children:`Name`}),(0,Q.jsx)(R,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Terms`}),(0,Q.jsx)(R,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Price`}),(0,Q.jsx)(R,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Redemptions`}),(0,Q.jsx)(R,{className:`h-auto p-0 px-5 pb-2.5 uppercase`,children:(0,Q.jsxs)(m,{align:`center`,justify:`between`,children:[`Status`,(0,Q.jsx)(ht,{setShowArchived:d,showArchived:l,sortDirection:p,sortOption:f,onDirectionChange:C,onSortChange:x})]})})]})}),(0,Q.jsx)(B,{"data-testid":`offers-table-body`,children:b.map(e=>{if(e.kind===`retention`)return(0,Q.jsx)(gt,{offer:e.offer,onClick:()=>_(e.offer.id)},`retention-${e.offer.id}`);let t=e.offer,r=n?.find(e=>e.id===t?.tier?.id);if(!r)return null;let i=T(t);return(0,Q.jsx)(_t,{archived:i,offer:t,tier:r,onClick:()=>g(t.id)},`signup-${t.id}`)})})]})})})})},Ct=({route:e})=>{if(e===`offers/new`)return(0,Q.jsx)(ke,{});if(e.startsWith(`offers/edit/retention/`)&&e.length>22){let t=e.split(`/`).pop();return(0,Q.jsx)(nt,{id:t||``})}else if(e===`offers/edit/retention/`||e===`offers/edit/retention`)return(0,Q.jsx)(St,{});else if(e.startsWith(`offers/edit/`)&&e.length>12){let t=e.split(`/`).pop();return(0,Q.jsx)(ze,{id:t||``})}else if(e.startsWith(`offers/success/`)&&e.length>15){let t=e.split(`/`).pop();return(0,Q.jsx)(rt,{id:t||``})}else if(e===`offers/edit`||e===`offers/edit/`)return(0,Q.jsx)(St,{})},wt=()=>{let{route:e}=w();return(0,Q.jsx)(Ct,{route:e})};export{wt as default};
@@ -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{g as r}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as i,t as a}from"./router-provider-C1R4AZ2o.js";import{Cn as o,Ir as s,Tn as c,ba as l,kn as u,n as d,r as f,rs as p,vo as m,ws as h}from"./index-BGG7NckO.js";import{t as g}from"./share-modal-DsgW3wbg.js";var _=e(t(),1),v=``+new URL(`logo-loader-dark-CuSPz-zc.mp4`,import.meta.url).href,y=``+new URL(`logo-loader-88VPEpXE.mp4`,import.meta.url).href,b=n();function x(){return(0,b.jsxs)(`div`,{className:`relative mb-6 size-20`,children:[(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`size-20 dark:hidden`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:y,type:`video/mp4`})}),(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`hidden size-20 dark:block`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:v,type:`video/mp4`})}),(0,b.jsx)(`div`,{className:`pointer-events-none absolute inset-0 hidden bg-[hsl(216deg_11%_70%/1%)] dark:block`})]})}function S({complete:e,id:t,isBeforeNext:n,isLast:r,isNext:i,onClick:a,step:o}){let s=o.icon;return(0,b.jsxs)(`button`,{className:`group ${i?`relative z-10 -mx-8 flex w-[calc(100%+64px)] items-center justify-between rounded-md bg-background px-8 py-6 text-left shadow-[0_1px_0_rgba(17,17,26,0.05),0_0_8px_rgba(17,17,26,0.10)] transition-none dark:ring-1 dark:ring-border ${r?`-mb-[18px]`:`mb-1.5`}`:`relative flex w-full items-center justify-between bg-transparent py-6 text-left ${r||n||i?``:`after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border after:content-['']`}`}`,"data-testid":`onboarding-step-${o.id}`,id:t,type:`button`,onClick:a,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center ${e?`opacity-20 group-hover:opacity-25`:`group-hover:opacity-90`}`,children:[(0,b.jsx)(s,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsxs)(`span`,{className:`min-w-0 text-left`,children:[(0,b.jsx)(`span`,{className:`block truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:o.title}),i&&(0,b.jsx)(`span`,{className:`mt-1 block pr-8 text-[15px] leading-[1.4] text-muted-foreground`,children:o.description})]})]}),(0,b.jsx)(`span`,{className:`flex shrink-0 items-center transition-transform group-hover:translate-x-[5px] ${e?`text-green`:`text-purple`}`,children:e?(0,b.jsx)(p,{className:`size-5`}):(0,b.jsx)(h,{className:`size-3.5`})})]})}function C({allStepsCompleted:e,completedSteps:t,nextStep:n,onComplete:r,onDismiss:i,onStepClick:a,siteTitle:o}){let c=new Set(t);return(0,b.jsx)(`main`,{className:`relative flex min-h-screen flex-col items-center justify-center px-6 py-8`,children:(0,b.jsxs)(`section`,{className:`mt-[-48px] flex w-full flex-col items-center`,"data-test-dashboard":`onboarding-checklist`,"data-testid":`onboarding-checklist`,children:[(0,b.jsxs)(`div`,{className:`mb-8 flex flex-col items-center text-center`,children:[(0,b.jsx)(x,{}),e?(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`You're all set.`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`Let's get started!`}),(0,b.jsxs)(`p`,{className:`mt-2 mb-0 text-[15px] text-muted-foreground max-[480px]:m-0 max-[480px]:text-[14px]`,children:[`Welcome! It's time to set up `,o,`.`]})]})]}),(0,b.jsxs)(`div`,{className:`w-full max-w-[540px] rounded-md border border-border bg-background px-6 pt-4 pb-1`,children:[(0,b.jsxs)(`div`,{className:`mt-[-12px] flex items-center justify-between py-6 ${n===`customize-design`?`border-b-0`:`border-b border-border`}`,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center opacity-20`,children:[(0,b.jsx)(l,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsx)(`span`,{className:`truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:`Start a new Ghost publication`})]}),(0,b.jsx)(`span`,{className:`shrink-0 text-green`,children:(0,b.jsx)(p,{className:`size-5`})})]}),f.map((e,t)=>(0,b.jsx)(S,{complete:c.has(e.id),id:`ob-${e.id}`,isBeforeNext:f[t+1]?.id===n,isLast:t===f.length-1,isNext:n===e.id,step:e,onClick:()=>a(e.id)},e.id))]}),e&&(0,b.jsx)(s,{className:`mt-6 h-auto w-full max-w-[540px] p-3 text-[16px] max-[480px]:text-[15px]`,"data-testid":`onboarding-complete`,id:`ob-completed`,type:`button`,onClick:r,children:`Explore your dashboard`}),(0,b.jsxs)(`p`,{className:`mt-8 mb-0 text-[15px] text-muted-foreground max-[480px]:text-[14px]`,children:[`More questions? Check out our`,` `,(0,b.jsx)(s,{className:`h-auto p-0 align-baseline text-[15px] text-green hover:text-green/90 max-[480px]:text-[14px]`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`https://ghost.org/help?utm_source=admin&utm_campaign=onboarding`,id:`ob-help-center`,rel:`noreferrer`,target:`_blank`,children:`Help Center`})}),`.`]}),!e&&(0,b.jsx)(s,{className:`mt-6 h-[38px] overflow-hidden px-3.5 py-px text-[15px] font-normal whitespace-nowrap text-muted-foreground hover:border-gray-300 hover:text-foreground`,"data-testid":`onboarding-skip`,id:`ob-skip`,type:`button`,variant:`outline`,onClick:i,children:`Skip onboarding`})]})})}function w({description:e,imageUrl:t,onOpenChange:n,open:r,siteTitle:i,siteUrl:a}){let o=encodeURIComponent(a),c=[{href:`https://twitter.com/intent/tweet?url=${o}`,id:`ob-share-on-x`,label:`Share your publication on X`,service:`x`},{href:`https://threads.net/intent/post?text=${o}`,id:`ob-share-on-threads`,label:`Share your publication on Threads`,service:`threads`},{href:`https://www.facebook.com/sharer/sharer.php?u=${o}`,id:`ob-share-on-fb`,label:`Share your publication on Facebook`,service:`facebook`},{href:`https://www.linkedin.com/feed/?shareActive=true&text=${o}`,id:`ob-share-on-li`,label:`Share your publication on LinkedIn`,service:`linkedin`}];return(0,b.jsx)(g.Root,{open:r,onOpenChange:n,children:(0,b.jsxs)(g.Content,{className:`dark:bg-surface-elevated`,"data-test-modal":`onboarding-share`,"data-testid":`onboarding-share-modal`,children:[(0,b.jsxs)(g.Header,{className:`flex-row items-center justify-between gap-4 space-y-0 text-left`,children:[(0,b.jsx)(g.Title,{className:`text-2xl`,children:`Share your publication`}),(0,b.jsx)(g.CloseButton,{id:`ob-close-share-modal`,onClick:()=>n(!1)})]}),(0,b.jsxs)(g.Preview,{className:`rounded-lg bg-card`,href:a,children:[t?(0,b.jsx)(`div`,{className:`aspect-video bg-cover bg-center`,style:{backgroundImage:`url(${t})`}}):(0,b.jsx)(`div`,{className:`flex aspect-video items-center justify-center bg-muted text-muted-foreground`,children:(0,b.jsx)(m,{className:`size-8`})}),(0,b.jsxs)(`div`,{className:`p-5`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:i}),e&&(0,b.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e})]})]}),(0,b.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Set your publication's cover image and description in`,` `,(0,b.jsx)(s,{className:`h-auto p-0 align-baseline text-sm text-green hover:text-green/90`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`#/settings/design/edit?ref=setup`,id:`ob-share-modal-design-settings`,children:`Design settings`})}),`.`]}),(0,b.jsxs)(g.Footer,{children:[(0,b.jsx)(g.SocialLinks,{links:c}),(0,b.jsx)(g.CopyButton,{className:`ml-0! grow cursor-pointer`,copyURL:a,"data-testid":`onboarding-copy-link`,icon:`link`,id:`ob-copy-publication-link`,label:`Copy link`})]})]})})}function T(e){return e&&/^\/analytics(?:\/|\?|$)/.test(e)?e:`/analytics`}function E(){let e=i(),[t]=r(),n=T(t.get(`returnTo`)),s=d(),l=u(),p=o(),m=(0,_.useRef)(!1),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(!1),x=String(c(l.data?.settings,`title`)||p.data?.site.title||`your publication`),S=String(c(l.data?.settings,`description`)||p.data?.site.description||``),E=String(c(l.data?.settings,`cover_image`)||``),D=p.data?.site.url||`/`,{allStepsCompleted:O,completeChecklist:k,completedSteps:A,dismissChecklist:j,shouldShowChecklist:M,isLoading:N,markStepCompleted:P,nextStep:F}=s;if(N||p.isLoading||h||m.current)return null;if(!M)return(0,b.jsx)(a,{to:n,replace:!0});let I=async t=>{m.current=!0,g(!0);try{await t(),e(n,{replace:!0})}catch(e){m.current=!1,g(!1),console.error(e)}},L=async t=>{if(t===`share-publication`){await P(t),y(!0);return}await P(t);let n=f.find(({id:e})=>e===t);n?.route&&e(n.route)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(C,{allStepsCompleted:O,completedSteps:A,nextStep:F,siteTitle:x,onComplete:()=>{I(k)},onDismiss:()=>{I(j)},onStepClick:e=>{L(e)}}),(0,b.jsx)(w,{description:S,imageUrl:E,open:v,siteTitle:x,siteUrl:D,onOpenChange:y})]})}export{E as default};
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{g as r}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as i,t as a}from"./router-provider-DSQfprxH.js";import{Dn as o,Pr as s,Tn as c,ba as l,jn as u,n as d,r as f,rs as p,vo as m,ws as h}from"./index-BHy2DZX-.js";import{t as g}from"./share-modal-ClIyPzc5.js";var _=e(t(),1),v=``+new URL(`logo-loader-dark-CuSPz-zc.mp4`,import.meta.url).href,y=``+new URL(`logo-loader-88VPEpXE.mp4`,import.meta.url).href,b=n();function x(){return(0,b.jsxs)(`div`,{className:`relative mb-6 size-20`,children:[(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`size-20 dark:hidden`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:y,type:`video/mp4`})}),(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`hidden size-20 dark:block`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:v,type:`video/mp4`})}),(0,b.jsx)(`div`,{className:`pointer-events-none absolute inset-0 hidden bg-[hsl(216deg_11%_70%/1%)] dark:block`})]})}function S({complete:e,id:t,isBeforeNext:n,isLast:r,isNext:i,onClick:a,step:o}){let s=o.icon;return(0,b.jsxs)(`button`,{className:`group ${i?`relative z-10 -mx-8 flex w-[calc(100%+64px)] items-center justify-between rounded-md bg-background px-8 py-6 text-left shadow-[0_1px_0_rgba(17,17,26,0.05),0_0_8px_rgba(17,17,26,0.10)] transition-none dark:ring-1 dark:ring-border ${r?`-mb-[18px]`:`mb-1.5`}`:`relative flex w-full items-center justify-between bg-transparent py-6 text-left ${r||n||i?``:`after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border after:content-['']`}`}`,"data-testid":`onboarding-step-${o.id}`,id:t,type:`button`,onClick:a,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center ${e?`opacity-20 group-hover:opacity-25`:`group-hover:opacity-90`}`,children:[(0,b.jsx)(s,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsxs)(`span`,{className:`min-w-0 text-left`,children:[(0,b.jsx)(`span`,{className:`block truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:o.title}),i&&(0,b.jsx)(`span`,{className:`mt-1 block pr-8 text-[15px] leading-[1.4] text-muted-foreground`,children:o.description})]})]}),(0,b.jsx)(`span`,{className:`flex shrink-0 items-center transition-transform group-hover:translate-x-[5px] ${e?`text-green`:`text-purple`}`,children:e?(0,b.jsx)(p,{className:`size-5`}):(0,b.jsx)(h,{className:`size-3.5`})})]})}function C({allStepsCompleted:e,completedSteps:t,nextStep:n,onComplete:r,onDismiss:i,onStepClick:a,siteTitle:o}){let c=new Set(t);return(0,b.jsx)(`main`,{className:`relative flex min-h-screen flex-col items-center justify-center px-6 py-8`,children:(0,b.jsxs)(`section`,{className:`mt-[-48px] flex w-full flex-col items-center`,"data-test-dashboard":`onboarding-checklist`,"data-testid":`onboarding-checklist`,children:[(0,b.jsxs)(`div`,{className:`mb-8 flex flex-col items-center text-center`,children:[(0,b.jsx)(x,{}),e?(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`You're all set.`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`Let's get started!`}),(0,b.jsxs)(`p`,{className:`mt-2 mb-0 text-[15px] text-muted-foreground max-[480px]:m-0 max-[480px]:text-[14px]`,children:[`Welcome! It's time to set up `,o,`.`]})]})]}),(0,b.jsxs)(`div`,{className:`w-full max-w-[540px] rounded-md border border-border bg-background px-6 pt-4 pb-1`,children:[(0,b.jsxs)(`div`,{className:`mt-[-12px] flex items-center justify-between py-6 ${n===`customize-design`?`border-b-0`:`border-b border-border`}`,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center opacity-20`,children:[(0,b.jsx)(l,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsx)(`span`,{className:`truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:`Start a new Ghost publication`})]}),(0,b.jsx)(`span`,{className:`shrink-0 text-green`,children:(0,b.jsx)(p,{className:`size-5`})})]}),f.map((e,t)=>(0,b.jsx)(S,{complete:c.has(e.id),id:`ob-${e.id}`,isBeforeNext:f[t+1]?.id===n,isLast:t===f.length-1,isNext:n===e.id,step:e,onClick:()=>a(e.id)},e.id))]}),e&&(0,b.jsx)(s,{className:`mt-6 h-auto w-full max-w-[540px] p-3 text-[16px] max-[480px]:text-[15px]`,"data-testid":`onboarding-complete`,id:`ob-completed`,type:`button`,onClick:r,children:`Explore your dashboard`}),(0,b.jsxs)(`p`,{className:`mt-8 mb-0 text-[15px] text-muted-foreground max-[480px]:text-[14px]`,children:[`More questions? Check out our`,` `,(0,b.jsx)(s,{className:`h-auto p-0 align-baseline text-[15px] text-green hover:text-green/90 max-[480px]:text-[14px]`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`https://ghost.org/help?utm_source=admin&utm_campaign=onboarding`,id:`ob-help-center`,rel:`noreferrer`,target:`_blank`,children:`Help Center`})}),`.`]}),!e&&(0,b.jsx)(s,{className:`mt-6 h-[38px] overflow-hidden px-3.5 py-px text-[15px] font-normal whitespace-nowrap text-muted-foreground hover:border-gray-300 hover:text-foreground`,"data-testid":`onboarding-skip`,id:`ob-skip`,type:`button`,variant:`outline`,onClick:i,children:`Skip onboarding`})]})})}function w({description:e,imageUrl:t,onOpenChange:n,open:r,siteTitle:i,siteUrl:a}){let o=encodeURIComponent(a),c=[{href:`https://twitter.com/intent/tweet?url=${o}`,id:`ob-share-on-x`,label:`Share your publication on X`,service:`x`},{href:`https://threads.net/intent/post?text=${o}`,id:`ob-share-on-threads`,label:`Share your publication on Threads`,service:`threads`},{href:`https://www.facebook.com/sharer/sharer.php?u=${o}`,id:`ob-share-on-fb`,label:`Share your publication on Facebook`,service:`facebook`},{href:`https://www.linkedin.com/feed/?shareActive=true&text=${o}`,id:`ob-share-on-li`,label:`Share your publication on LinkedIn`,service:`linkedin`}];return(0,b.jsx)(g.Root,{open:r,onOpenChange:n,children:(0,b.jsxs)(g.Content,{className:`dark:bg-surface-elevated`,"data-test-modal":`onboarding-share`,"data-testid":`onboarding-share-modal`,children:[(0,b.jsxs)(g.Header,{className:`flex-row items-center justify-between gap-4 space-y-0 text-left`,children:[(0,b.jsx)(g.Title,{className:`text-2xl`,children:`Share your publication`}),(0,b.jsx)(g.CloseButton,{id:`ob-close-share-modal`,onClick:()=>n(!1)})]}),(0,b.jsxs)(g.Preview,{className:`rounded-lg bg-card`,href:a,children:[t?(0,b.jsx)(`div`,{className:`aspect-video bg-cover bg-center`,style:{backgroundImage:`url(${t})`}}):(0,b.jsx)(`div`,{className:`flex aspect-video items-center justify-center bg-muted text-muted-foreground`,children:(0,b.jsx)(m,{className:`size-8`})}),(0,b.jsxs)(`div`,{className:`p-5`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:i}),e&&(0,b.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e})]})]}),(0,b.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Set your publication's cover image and description in`,` `,(0,b.jsx)(s,{className:`h-auto p-0 align-baseline text-sm text-green hover:text-green/90`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`#/settings/design/edit?ref=setup`,id:`ob-share-modal-design-settings`,children:`Design settings`})}),`.`]}),(0,b.jsxs)(g.Footer,{children:[(0,b.jsx)(g.SocialLinks,{links:c}),(0,b.jsx)(g.CopyButton,{className:`ml-0! grow cursor-pointer`,copyURL:a,"data-testid":`onboarding-copy-link`,icon:`link`,id:`ob-copy-publication-link`,label:`Copy link`})]})]})})}function T(e){return e&&/^\/analytics(?:\/|\?|$)/.test(e)?e:`/analytics`}function E(){let e=i(),[t]=r(),n=T(t.get(`returnTo`)),s=d(),l=u(),p=c(),m=(0,_.useRef)(!1),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(!1),x=String(o(l.data?.settings,`title`)||p.data?.site.title||`your publication`),S=String(o(l.data?.settings,`description`)||p.data?.site.description||``),E=String(o(l.data?.settings,`cover_image`)||``),D=p.data?.site.url||`/`,{allStepsCompleted:O,completeChecklist:k,completedSteps:A,dismissChecklist:j,shouldShowChecklist:M,isLoading:N,markStepCompleted:P,nextStep:F}=s;if(N||p.isLoading||h||m.current)return null;if(!M)return(0,b.jsx)(a,{to:n,replace:!0});let I=async t=>{m.current=!0,g(!0);try{await t(),e(n,{replace:!0})}catch(e){m.current=!1,g(!1),console.error(e)}},L=async t=>{if(t===`share-publication`){await P(t),y(!0);return}await P(t);let n=f.find(({id:e})=>e===t);n?.route&&e(n.route)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(C,{allStepsCompleted:O,completedSteps:A,nextStep:F,siteTitle:x,onComplete:()=>{I(k)},onDismiss:()=>{I(j)},onStepClick:e=>{L(e)}}),(0,b.jsx)(w,{description:S,imageUrl:E,open:v,siteTitle:x,siteUrl:D,onOpenChange:y})]})}export{E as default};
@@ -0,0 +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{t as r}from"./use-tinybird-query-GSa32hVw.js";import{f as i,g as a,s as o}from"./stats-D8nZCTy5.js";import{n as s}from"./posts-CxG7v0-M.js";import{t as c}from"./analytics-53FOa2wq.js";import{a as l,t as u}from"./post-helpers-C5OQMBoi.js";import{a as d}from"./router-provider-DSQfprxH.js";import{c as f,f as p,l as m,p as h,s as g}from"./dist-Cb5RSHSg.js";import{a as _,i as v,n as y,t as b}from"./chart-helpers-CZElTGYL.js";import{a as x,n as S,o as C,r as w,s as T,t as E}from"./card-aUHX0hyR.js";import{t as D}from"./empty-indicator-WB1WgT9h.js";import{Ba as O,Bo as k,Ei as A,Fa as ee,Kr as j,Ms as M,Ni as te,Pr as N,Ri as P,So as F,Vr as I,Vs as L,Wr as R,ga as z,i as ne,ir as re,is as ie,jo as B,ls as ae,or as V,p as H,pa as oe,ro as U,sr as se,ss as ce,u as W,vo as G,za as K}from"./index-BHy2DZX-.js";import{i as le,n as ue,r as de,t as fe}from"./stats-view-CugFVf0g.js";import{t as pe}from"./use-growth-stats-DPU5rt3W.js";import{n as me,r as he,t as ge}from"./kpi-card-DOUnkZcN.js";import{t as q}from"./use-analytics-data-B-b4wNSC.js";import{n as _e}from"./audience-DTJtXXWY.js";import{n as J}from"./url-helpers-CCyfRrKj.js";import{t as ve}from"./post-share-modal-B9Vmk_XM.js";var Y=e(t(),1),ye=()=>{let{data:{posts:[e]}={posts:[]},isLoading:t}=s({searchParams:{filter:`status:[published,sent]`,order:`published_at DESC`,limit:`1`,include:`authors,email,count.clicks`}}),n=e,{data:r,isLoading:i}=o(n?.id||``,{enabled:!!n?.id});return{data:(0,Y.useMemo)(()=>{if(!n)return null;let e=r?.stats?.[0]||{id:n.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:n.id,uuid:n.uuid,title:n.title||``,slug:n.slug||``,feature_image:n.feature_image||null,published_at:n.published_at||``,url:n.url||``,excerpt:n.excerpt||``,email_only:n.email_only||!1,status:n.status,email:n.email,count:n.count,authors:n.authors||[],recipient_count:e.recipient_count,opened_count:e.opened_count,open_rate:e.open_rate,member_delta:e.member_delta,free_members:e.free_members,paid_members:e.paid_members,visitors:e.visitors,click_rate:null}},[n,r]),isLoading:t||!!n?.id&&i}},X=n(),be=e=>e.email_only?`Sent`:e.email?`Published and sent`:`Published`,xe=({latestPostStats:e,isLoading:t})=>{let n=d(),[r,i]=(0,Y.useState)(!1),{site:a,settings:o}=q(),{appSettings:s}=L(),{emailTrackClicks:l,emailTrackOpens:g,webAnalytics:_=!1,membersTrackSources:v=!1}=s?.analytics||{};(0,Y.useEffect)(()=>{r&&c(`Share Modal Opened`,{giftLinkShown:!1,source:`stats-overview`})},[r]);let y=a.title||String(o.find(e=>e.key===`title`)?.value||`Ghost Site`),b=String(o.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),T=e?u(e,{membersTrackSources:v}):null,k=`group mr-2 flex flex-col gap-1.5 hover:cursor-pointer`,A=!!e?.email,j=J({postId:e?.id,hasEmailData:A,analytics:{webAnalytics:_,membersTrackSources:v}}),M=j.startsWith(`/editor/`);return(0,X.jsxs)(E,{className:`group/card`,"data-testid":`latest-post`,children:[(0,X.jsxs)(x,{children:[(0,X.jsx)(C,{className:`flex items-baseline justify-between leading-snug font-medium text-muted-foreground`,children:`Latest post performance`}),(0,X.jsx)(w,{className:`hidden`,children:`How your last post did`})]}),(0,X.jsxs)(S,{className:`flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3`,children:[t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-6 px-6 xl:col-span-2`,children:[(0,X.jsx)(`div`,{className:`w-full max-w-[232px] grow`,children:(0,X.jsx)(V,{className:`aspect-[16/10] rounded-md`})}),(0,X.jsxs)(`div`,{className:`w-full grow`,children:[(0,X.jsx)(V,{className:`w-full max-w-[420px]`}),(0,X.jsx)(V,{className:`w-1/2`})]})]}),(0,X.jsx)(`div`,{className:`flex flex-col items-stretch gap-2 px-6`,children:(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(V,{className:`w-3/4`}),(0,X.jsx)(V,{className:`h-10 w-1/3`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(V,{className:`w-3/4`}),(0,X.jsx)(V,{className:`h-10 w-1/3`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(V,{className:`w-3/4`}),(0,X.jsx)(V,{className:`h-10 w-1/3`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(V,{className:`w-3/4`}),(0,X.jsx)(V,{className:`h-10 w-1/3`})]})]})})]}),!t&&e&&T?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2`,children:[e.feature_image&&(0,X.jsx)(`div`,{className:`aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]`,style:{backgroundImage:`url(${e.feature_image})`}}),(0,X.jsxs)(`div`,{className:`flex grow flex-col items-start justify-center self-stretch`,children:[(0,X.jsx)(`div`,{className:`text-md leading-tighter font-semibold tracking-tight hover:cursor-pointer hover:opacity-75`,onClick:()=>{!t&&e&&n(j,{crossApp:!0})},children:e.title}),(0,X.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[e.authors&&e.authors.length>0&&(0,X.jsxs)(`div`,{children:[`By `,e.authors.map(e=>e.name).join(`, `),` – `,m(e.published_at,b)]}),(0,X.jsx)(`div`,{className:`mt-0.5`,children:be(e)})]}),(0,X.jsxs)(`div`,{className:`mt-6 flex items-center gap-2`,children:[!e.email_only&&(0,X.jsx)(ve,{author:e.authors?.map(e=>e.name).join(`, `)||``,description:``,faviconURL:a.icon||``,featureImageURL:e.feature_image||``,open:r,postExcerpt:e.excerpt||``,postTitle:e.title,postURL:e.url||``,siteTitle:y,onClose:()=>i(!1),onOpenChange:i,children:(0,X.jsxs)(N,{onClick:()=>i(!0),children:[(0,X.jsx)(oe,{}),` Share post`]})}),(0,X.jsx)(N,{className:e.email_only?`w-full`:``,variant:`outline`,onClick:()=>{n(j,{crossApp:!0})},children:M?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ee,{}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Edit post`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ce,{}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:e.email_only?`Post analytics`:`Analytics`})]})})]})]})]}),(0,X.jsx)(`div`,{className:`-ml-4 flex w-full flex-col items-stretch gap-2 pr-6 xl:h-full xl:max-w-none`,children:(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-6 pl-10 lg:border-l xl:h-full`,children:[T.showWebMetrics&&_&&(0,X.jsxs)(`div`,{className:k,"data-testid":`latest-post-visitors`,onClick:()=>{n(`/posts/analytics/${e.id}/web`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(F,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Visitors`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:p(e.visitors)})]}),T.showMemberGrowth&&(0,X.jsxs)(`div`,{className:f(k,T.showEmailMetrics&&(!T.showWebMetrics||!_)&&`col-[1/2] row-[2/3]`),"data-testid":`latest-post-members`,onClick:()=>{n(`/posts/analytics/${e.id}/growth`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(P,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Members`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.member_delta?(0,X.jsxs)(X.Fragment,{children:[`+`,p(e.member_delta)]}):0})]}),T.showEmailMetrics&&e.email&&(0,X.jsxs)(X.Fragment,{children:[g&&(0,X.jsxs)(`div`,{className:k,onClick:()=>{n(`/posts/analytics/${e.id}/newsletter`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(U,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap md:visible! md:block!`,children:`Opens`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.email.email_count?h((e.email.opened_count||0)/e.email.email_count):`0%`})]}),l&&(0,X.jsxs)(`div`,{className:k,onClick:()=>{n(`/posts/analytics/${e.id}/newsletter`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(O,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap md:visible! md:block!`,children:`Clicks`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.email.email_count&&e.count?.clicks?h((e.count.clicks||0)/e.email.email_count):`0%`})]})]})]})})]}):!t&&(0,X.jsx)(D,{actions:(0,X.jsx)(N,{variant:`secondary`,onClick:()=>{n(`/editor/post`,{crossApp:!0})},children:`New post`}),className:`w-full pb-10 xl:col-span-3`,description:`Once it's live, you can track performance here`,title:`Publish your first post`,children:(0,X.jsx)(B,{strokeWidth:1.5})})]})]})},Se=()=>{let{config:e}=q();return{isLimited:t=>e?.hostSettings?.limits&&t===`limitAnalytics`?e.hostSettings.limits.limitAnalytics?.disabled===!0:!1}},Z=({title:e,iconName:t,description:n,color:r,diffDirection:i,diffValue:a,formattedValue:o,trendingFromValue:s,children:c,onClick:l})=>{let{range:u}=H(),d=t&&A[t],f=Y.useMemo(()=>{if(!i||i===`empty`||u===W.allTime.value||!a)return``;let e=i===`up`?`up`:i===`down`?`down`:`at`,t=y(u).replace(`in the `,``).replace(/^\(|\)$/g,``);return i===`same`?(0,X.jsxs)(`span`,{children:[`You're trending at the same level as `,(0,X.jsx)(`span`,{className:`font-semibold`,children:o}),` compared to the `,(0,X.jsx)(`span`,{className:`font-semibold`,children:t})]}):(0,X.jsxs)(`span`,{children:[`You're trending `,(0,X.jsxs)(`span`,{className:`font-semibold`,children:[e,` `,a]}),` from `,(0,X.jsx)(`span`,{className:`font-semibold`,children:s}),` compared to the `,t]})},[i,a,s,o,u]);return(0,X.jsxs)(E,{className:`group`,"data-testid":e,children:[(0,X.jsxs)(x,{className:`hidden`,children:[(0,X.jsx)(C,{children:e}),(0,X.jsx)(w,{children:n})]}),(0,X.jsxs)(ge,{className:`relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4`,children:[(0,X.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,X.jsxs)(me,{className:l&&`transition-all group-hover:text-foreground`,children:[r&&(0,X.jsx)(`span`,{className:`inline-block size-2 rounded-full opacity-50`,style:{backgroundColor:r}}),d&&(0,X.jsx)(d,{size:16,strokeWidth:1.5}),e]}),(0,X.jsx)(he,{diffDirection:u===W.allTime.value?`hidden`:i,diffTooltip:f,diffValue:a,value:o})]}),l&&(0,X.jsx)(N,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:l,children:`View more`})]}),(0,X.jsx)(S,{children:c})]})},Ce=({kpiValues:e,visitorsChartData:t,visitorsChartRange:n,visitorsYRange:r,growthTotals:i,membersChartData:a,mrrChartData:o,growthChartRange:s,currencySymbol:c,isLoading:l})=>{let u=d(),{appSettings:f}=L(),m=Se().isLimited(`limitAnalytics`),h=`-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:cursor-pointer!`;if(l)return(0,X.jsx)(T,{className:`flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:cursor-pointer!`,children:(0,X.jsx)(re,{})});let g=f?.analytics.webAnalytics,v=m&&!g,y=f?.paidMembersEnabled,b=[g,v,!0,y].filter(Boolean).length,O=`lg:grid-cols-3`;return b===2?O=`lg:grid-cols-2`:b===1&&(O=`lg:grid-cols-1`),(0,X.jsxs)(`div`,{className:`flex flex-col lg:grid ${O} gap-6`,children:[g&&!v&&(0,X.jsx)(Z,{description:`Number of individual people who visited your website`,diffDirection:`empty`,formattedValue:e.visits,iconName:`Globe`,linkto:`/analytics/web/`,title:`Unique visitors`,onClick:()=>{u(`/analytics/web/`)},children:(0,X.jsx)(_,{className:h,color:`var(--chart-blue)`,data:t,id:`visitors`,range:n,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`,yAxisRange:r})}),v&&(0,X.jsxs)(E,{children:[(0,X.jsxs)(x,{className:`hidden`,children:[(0,X.jsx)(C,{children:`Unlock web analytics`}),(0,X.jsx)(w,{children:`Get the full picture of what's working with detailed, cookie-free traffic analytics.`})]}),(0,X.jsx)(S,{className:`flex h-full items-center justify-center p-6`,children:(0,X.jsx)(D,{actions:(0,X.jsx)(N,{variant:`outline`,onClick:()=>u(`/pro`,{crossApp:!0}),children:`Upgrade now`}),className:`py-10`,description:`Get the full picture of what's working with detailed, cookie-free traffic analytics.`,title:`Unlock web analytics`,children:(0,X.jsx)(ie,{})})})]}),(0,X.jsx)(Z,{description:`How number of members of your publication changed over time`,diffDirection:i.directions.total,diffValue:i.percentChanges.total,formattedValue:p(i.totalMembers),iconName:`User`,linkto:`/analytics/growth/`,title:`Members`,trendingFromValue:`${p(a[0]?.value??0)}`,onClick:()=>{u(`/analytics/growth/?tab=total-members`)},children:(0,X.jsx)(_,{className:h,color:`var(--chart-darkblue)`,data:a,id:`members`,range:s,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`})}),y&&(0,X.jsx)(Z,{description:`Monthly recurring revenue changes over time`,diffDirection:i.directions.mrr,diffValue:i.percentChanges.mrr,formattedValue:`${c}${p(I(i.mrr))}`,iconName:`Coins`,linkto:`/analytics/growth/`,title:`MRR`,trendingFromValue:`${c}${p(o[0]?.value??0)}`,onClick:()=>{u(`/analytics/growth/?tab=mrr`)},children:(0,X.jsx)(_,{className:h,color:`var(--chart-teal)`,data:o,id:`mrr`,range:s,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`})})]})},we=({className:e})=>(0,X.jsx)(`div`,{className:f(`flex flex-col items-center justify-center gap-1 rounded-sm bg-muted p-6 dark:bg-surface-elevated-2`,e),children:(0,X.jsx)(G,{className:`text-muted-foreground/50`,size:18,strokeWidth:1.5})}),Q=({className:e,metrics:t,title:n})=>(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:f(`pointer-events-none absolute bottom-[calc(100%+2px)] left-1/2 z-50 min-w-[160px] -translate-x-1/2 rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100`,e),children:[(0,X.jsx)(`div`,{className:`mb-1.5 border-b pr-10 pb-1.5 font-medium whitespace-nowrap text-muted-foreground`,children:n}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t?.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 whitespace-nowrap`,children:[e.icon,e.label]}),(0,X.jsx)(`span`,{className:`font-mono`,children:e.metric})]},e.label))})]})}),Te=({topPostsData:e,isLoading:t})=>{let n=d(),{range:r}=H(),{settings:i}=q(),{appSettings:a}=L(),o=String(i.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),{webAnalytics:s=!1,membersTrackSources:c=!1,emailTrackClicks:u=!1,emailTrackOpens:f=!1}=a?.analytics||{},h=`flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground`;return(0,X.jsxs)(E,{className:`group/card w-full lg:col-span-2`,"data-testid":`top-posts-card`,children:[(0,X.jsxs)(x,{children:[(0,X.jsxs)(C,{className:`flex items-baseline justify-between leading-snug font-medium text-muted-foreground`,children:[`Top posts `,y(r)]}),(0,X.jsx)(w,{className:`hidden`,children:`Most viewed posts in this period`})]}),(0,X.jsx)(S,{children:t?(0,X.jsx)(se,{className:`mt-6`}):(0,X.jsxs)(X.Fragment,{children:[e?.stats?.map(e=>(0,X.jsxs)(`div`,{className:`group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-table-row-hover before:content-[""] first:border-border! hover:cursor-pointer hover:border-transparent hover:before:block md:items-center [&+div]:hover:border-transparent`,children:[(0,X.jsxs)(`div`,{className:`z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]`,onClick:()=>{n(J({postId:e.post_id,hasEmailData:e.sent_count!==null,analytics:{webAnalytics:s,membersTrackSources:c}}),{crossApp:!0})},children:[e.feature_image?(0,X.jsx)(`div`,{className:`hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:visible! sm:block! lg:w-[100px]`,style:{backgroundImage:`url(${e.feature_image})`}}):(0,X.jsx)(we,{className:`hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:visible! sm:flex! lg:w-[100px]`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`line-clamp-2 text-md font-semibold`,children:e.title}),(0,X.jsxs)(`span`,{className:`text text-muted-foreground`,children:[`By `,e.authors,` – `,m(e.published_at,o)]}),(0,X.jsx)(`span`,{className:`text text-muted-foreground`,children:l(e)})]})]}),(0,X.jsxs)(`div`,{className:`z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3`,children:[s&&(0,X.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,"data-testid":`statistics-visitors`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/web`,{crossApp:!0})},children:[(0,X.jsx)(Q,{metrics:[{icon:(0,X.jsx)(F,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Unique visitors`,metric:p(e.views)}],title:`Web traffic`}),(0,X.jsxs)(`div`,{className:h,children:[(0,X.jsx)(F,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),g(e.views)]})]}),e.sent_count!==null&&(0,X.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/newsletter`,{crossApp:!0})},children:[(0,X.jsx)(Q,{className:`${c?``:`right-0 left-auto translate-x-0`}`,metrics:[{icon:(0,X.jsx)(z,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Sent`,metric:p(e.sent_count||0)},...f?[{icon:(0,X.jsx)(U,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Opens`,metric:p(e.opened_count||0)}]:[],...u?[{icon:(0,X.jsx)(K,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Clicks`,metric:p(e.clicked_count||0)}]:[]],title:`Newsletter performance`}),(0,X.jsx)(`div`,{className:h,children:f?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.open_rate?`${Math.round(e.open_rate)}%`:`0%`]}):u?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.click_rate?`${Math.round(e.click_rate)}%`:`0%`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),g(e.sent_count||0)]})})]}),c&&(0,X.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,"data-testid":`statistics-members`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/growth`,{crossApp:!0})},children:[(0,X.jsx)(Q,{className:`right-0 left-auto translate-x-0`,metrics:[{icon:(0,X.jsx)(te,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Free`,metric:e.free_members>0?`+${p(e.free_members)}`:`0`},...a?.paidMembersEnabled?[{icon:(0,X.jsx)(k,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Paid`,metric:e.paid_members>0?`+${p(e.paid_members)}`:`0`}]:[]],title:`New members`}),(0,X.jsxs)(`div`,{className:h,children:[(0,X.jsx)(P,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.members>0?`+${p(e.members)}`:`0`]})]})]})]},e.post_id)),(!e?.stats||e.stats.length===0)&&(0,X.jsx)(D,{className:`w-full pb-10`,title:`No posts ${y(r)}`,children:(0,X.jsx)(B,{strokeWidth:1.5})})]})})]})},$=({className:e,title:t,description:n,url:r,children:i})=>(0,X.jsx)(`a`,{className:f(`group/card block rounded-xl border bg-card p-6 transition-all hover:bg-table-row-hover hover:shadow-xs`,e),href:r,rel:`noreferrer`,target:`_blank`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-6`,children:[i,(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 leading-tight`,children:[(0,X.jsx)(`span`,{className:`text-base font-semibold`,children:t}),(0,X.jsx)(`span`,{className:`text-sm font-normal text-gray-700`,children:n})]})]})}),Ee=()=>{let{appSettings:e}=L(),{range:t}=H(),{statsConfig:n,isLoading:o}=q(),{startDate:s,endDate:c,timezone:l}=j(t),{isLoading:u,chartData:d,totals:f,currencySymbol:m}=pe(t),{data:h,isLoading:g}=ye(),{data:_,isLoading:y}=i({searchParams:{date_from:R(s),date_to:R(c),limit:`5`,timezone:l}}),{data:x,loading:S}=r({endpoint:`api_kpis`,statsConfig:n,params:{site_uuid:n?.id||``,date_from:R(s),date_to:R(c),timezone:l,member_status:_e(ne)}}),C=(0,Y.useMemo)(()=>v(x||[],t,`visits`,`sum`)?.map(e=>{let t=Number(e.visits),n=isNaN(t)?0:t;return{date:String(e.date),value:n,formattedValue:p(n),label:`Visitors`}}),[x,t]),w=(0,Y.useMemo)(()=>b(t,x||[],{fieldName:`visits`}),[x,t]),T=(0,Y.useMemo)(()=>{let e=[0,1];if(!C||C.length===0)return e;let t=C.map(e=>e.value).filter(e=>e>=0);return t.length===0?e:[0,Math.max(...t)||e[1]]},[C]),E=(0,Y.useMemo)(()=>b(t,d||[]),[d,t]),D=(0,Y.useMemo)(()=>{if(!d||d.length===0)return[];let e=[];return e=v(d,t,`value`,`exact`),e.map(e=>({date:e.date,value:e.free+e.paid,formattedValue:p(e.free+e.paid),label:`Members`}))},[d,t]),O=(0,Y.useMemo)(()=>{if(!e?.paidMembersEnabled||!d||d.length===0)return[];let n=[];return n=v(d,t,`mrr`,`exact`),n.map(e=>({date:e.date,value:I(e.mrr),formattedValue:`${m}${p(I(e.mrr))}`,label:`MRR`}))},[d,t,m,e]),k=(0,Y.useMemo)(()=>x?.length?{visits:p(x.reduce((e,t)=>{let n=Number(t.visits);return e+(isNaN(n)?0:n)},0))}:{visits:`0`},[x]);return(0,X.jsxs)(ue,{children:[(0,X.jsx)(de,{children:(0,X.jsx)(a,{children:(0,X.jsx)(le,{excludeRanges:[`today`]})})}),(0,X.jsxs)(fe,{isLoading:o,loadingComponent:(0,X.jsx)(X.Fragment,{}),children:[(0,X.jsx)(Ce,{currencySymbol:m,growthChartRange:E,growthTotals:f,isLoading:S||u,kpiValues:k,membersChartData:D,mrrChartData:O,visitorsChartData:C,visitorsChartRange:w,visitorsYRange:T}),(0,X.jsx)(xe,{isLoading:g,latestPostStats:h}),(0,X.jsx)(Te,{isLoading:y,topPostsData:_}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,X.jsx)(M,{className:`mt-4 -mb-4 lg:col-span-2`,children:`Grow your audience`}),(0,X.jsx)($,{description:`Find out how to review the performance of your content and get the most out of post analytics in Ghost.`,title:`Understanding analytics in Ghost`,url:`https://ghost.org/help/native-analytics`,children:(0,X.jsx)(`div`,{className:`flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100`,children:(0,X.jsx)(ae,{className:`text-[#00BBA7]`,size:20,strokeWidth:1.5})})}),(0,X.jsx)($,{description:`Use these content distribution tactics to get more people to discover your work and increase engagement.`,title:`How to get your content seen online`,url:`https://ghost.org/resources/content-distribution/`,children:(0,X.jsx)(`div`,{className:`flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100`,children:(0,X.jsx)(F,{className:`text-[#FE9A00]`,size:20,strokeWidth:1.5})})})]})]})]})};export{Ee as default};
@@ -0,0 +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{t as r}from"./use-tinybird-query-GSa32hVw.js";import{i,o as a}from"./post-helpers-C5OQMBoi.js";import{m as o}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as s}from"./router-provider-DSQfprxH.js";import{f as c,p as l}from"./dist-Cb5RSHSg.js";import{a as u,i as d,t as f}from"./chart-helpers-CZElTGYL.js";import{a as p,n as m,o as h,t as g}from"./card-aUHX0hyR.js";import{c as _,l as v,n as y,o as b,r as ee,s as x,t as S,u as C}from"./data-list-CupF7bjM.js";import{t as w}from"./empty-indicator-WB1WgT9h.js";import{$a as te,Co as T,Kr as ne,Pr as E,Ps as D,So as O,Vs as re,Wr as ie,Xn as k,da as ae,ir as A,lo as j,or as M,qr as oe,u as se}from"./index-BHy2DZX-.js";import{t as ce}from"./disabled-sources-indicator-iMHrkyV3.js";import{n as N,r as P,t as F}from"./kpi-card-DOUnkZcN.js";import{t as I}from"./use-analytics-data-B-b4wNSC.js";import{a as L,n as R,r as z,t as B}from"./kpi-card-IHDo8Q56.js";import{n as le,r as ue,t as de}from"./post-analytics-header-ChzjXVPt.js";import{t as fe}from"./gift-links-CVuqLhsZ.js";import{r as pe,t as me}from"./gift-link-modal-zMtlJhLQ.js";import{n as he}from"./post-analytics-context-D0Mw-Pmv.js";import{n as ge,t as _e}from"./use-post-referrers-C2mXyrp-.js";import{a as V,o as H,r as U,t as W}from"./link-helpers-Bzkk68GD.js";import{n as ve,r as G}from"./kpi-helpers-CjUdECAK.js";var K=e(t(),1),q=n(),ye=({post:e,isNewsletterStatsLoading:t,isWebShown:n})=>{let{postId:r}=o(),i=s(),a=(0,K.useMemo)(()=>{let t=e.email?.opened_count||0,n=e.email?.email_count||0,r=e.count?.clicks||0;return{opened:t,clicked:r,openedRate:n>0?t/n:0,clickedRate:n>0?r/n:0,sent:n}},[e]),{data:u}=V({searchParams:{filter:`post_id:'${r}'`}}),d=(0,K.useMemo)(()=>U(u),[u]),f=[{datatype:`Clicked`,value:a.clickedRate,fill:`url(#gradientTeal)`,color:`var(--chart-teal)`},{datatype:`Opened`,value:a.openedRate,fill:`url(#gradientBlue)`,color:`var(--chart-blue)`}],w={percentage:{label:`Opened`},Average:{label:`Clicked`},"This newsletter":{label:`Opened`}},T=e.email_only||!n;return(0,q.jsxs)(g,{className:`group/datalist overflow-hidden ${T&&`col-span-2`}`,children:[(0,q.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,q.jsx)(p,{children:(0,q.jsxs)(h,{className:`flex items-center gap-1.5 text-lg`,children:[(0,q.jsx)(te,{size:16,strokeWidth:1.5}),`Newsletter performance`]})}),(0,q.jsx)(E,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:()=>{i(`/posts/analytics/${r}/newsletter`)},children:`View more`})]}),t?(0,q.jsx)(m,{children:(0,q.jsx)(`div`,{className:`mx-auto flex min-h-[250px] items-center justify-center xl:size-full`,children:(0,q.jsx)(A,{})})}):(0,q.jsxs)(m,{className:`${T&&`grid grid-cols-2`}`,children:[(0,q.jsxs)(`div`,{className:`${T&&`border-r pr-6`}`,children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,q.jsx)(F,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,children:(0,q.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,q.jsx)(N,{color:`var(--chart-blue)`,children:`Open rate`}),(0,q.jsx)(P,{value:l(a.openedRate)})]})}),(0,q.jsx)(F,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,children:(0,q.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,q.jsx)(N,{color:`var(--chart-teal)`,children:`Click rate`}),(0,q.jsx)(P,{value:l(a.clickedRate)})]})})]}),!T&&(0,q.jsx)(k,{}),(0,q.jsx)(`div`,{className:`mx-auto my-6 h-[240px]`,children:(0,q.jsx)(H,{className:`pointer-events-none aspect-square h-[240px]`,config:w,data:f,tooltip:!1})})]}),(0,q.jsxs)(`div`,{className:`${T&&`pl-6`}`,children:[!T&&(0,q.jsx)(k,{}),(0,q.jsxs)(`div`,{className:T?``:`pt-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 ${T?`pb-3`:`py-3`}`,children:[(0,q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Top clicked links in this email`}),(0,q.jsx)(D,{children:`Members`})]}),d.length>0?(0,q.jsx)(S,{className:``,children:(0,q.jsx)(ee,{children:d.slice(0,T?10:5).map(e=>{let t=a.clicked>0?e.count/a.clicked:0;return(0,q.jsxs)(C,{children:[(0,q.jsx)(y,{style:{width:`${t?Math.round(t*100):0}%`}}),(0,q.jsx)(b,{children:(0,q.jsxs)(`div`,{className:`flex items-center space-x-2 overflow-hidden`,children:[(0,q.jsx)(j,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),(0,q.jsx)(`a`,{className:`block truncate font-medium hover:underline`,href:e.link.to,rel:`noreferrer`,target:`_blank`,title:e.link.to,children:W(e.link.to,!0)})]})}),(0,q.jsxs)(x,{children:[(0,q.jsx)(_,{children:c(e.count||0)}),(0,q.jsx)(v,{children:l(t)})]})]},e.link.link_id)})})}):(0,q.jsx)(`div`,{className:`py-20 text-center text-sm text-gray-700`,children:`You have no links in your post.`})]})]})]})]})},be=({chartData:e,range:t,isLoading:n,visitors:r,sourcesData:i,isNewsletterShown:a=!0})=>{let{postId:l}=o(),d=s(),{site:f}=I(),_=f.url,v=f.icon,y=(0,K.useMemo)(()=>i?i.reduce((e,t)=>e+Number(t.visits||0),0):0,[i]);return(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(g,{className:`group/datalist overflow-hidden ${!a&&`col-span-2`}`,"data-testid":`web-performance`,children:[(0,q.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,q.jsx)(p,{children:(0,q.jsxs)(h,{className:`flex items-center gap-1.5 text-lg`,children:[(0,q.jsx)(O,{size:16,strokeWidth:1.5}),`Web performance`]})}),(0,q.jsx)(E,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:()=>{d(`/posts/analytics/${l}/web`)},children:`View more`})]}),(0,q.jsxs)(m,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(F,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,"data-testid":`unique-visitors`,children:(0,q.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,q.jsx)(N,{color:`var(--chart-blue)`,children:`Unique visitors`}),(0,q.jsx)(P,{value:c(r)})]})}),(0,q.jsx)(k,{}),(0,q.jsx)(`div`,{className:`max-h-[288px] py-6 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:n?(0,q.jsx)(`div`,{className:`flex h-[16vw] min-h-[240px] items-center justify-center`,children:(0,q.jsx)(A,{})}):(0,q.jsx)(u,{className:`aspect-auto h-[240px] w-full`,color:`var(--chart-blue)`,data:e||[],id:`visitors`,range:t,syncId:`overview-charts`})})]}),a&&(0,q.jsxs)(`div`,{className:a?`border-t pt-3`:`-mt-3`,children:[(0,q.jsx)(`div`,{children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`How readers found this post`}),(0,q.jsx)(D,{children:`Visitors`})]})}),i&&i.length>0?(0,q.jsx)(G,{data:i,range:t,siteIcon:v,siteUrl:_,tableOnly:!0,topSourcesLimit:5,totalVisitors:y}):(0,q.jsx)(w,{className:`h-full py-10`,description:`Once someone visits this post, sources will show here`,title:`No visitors since you published this post`,children:(0,q.jsx)(O,{strokeWidth:1.5})})]})]})]})})},J=()=>{let e=s(),{statsConfig:t,isLoading:n}=I(),{post:o,isPostLoading:l,postId:u}=he(),{totals:_,isLoading:v,currencySymbol:y}=_e(u),{appSettings:b}=re(),{emailTrackClicks:ee,emailTrackOpens:x}=b?.analytics||{},S=b?.analytics?.webAnalytics===!0,C=le(o),{token:w,isLoading:te,error:D}=fe(u,{enabled:C}),{usage:O,loading:k,error:j}=pe({postUuid:o?.uuid,token:w,tokenLoading:te,tokenError:D,enabled:C}),[N,P]=(0,K.useState)(!1),F=(0,K.useMemo)(()=>o?.published_at?oe(o.published_at):se.allTime.value,[o?.published_at]),{startDate:V,endDate:H,timezone:U}=ne(F),W=(0,K.useMemo)(()=>{let e={site_uuid:t?.id||``,date_from:ie(V),date_to:ie(H),timezone:U,post_uuid:``};return!l&&o?.uuid?{...e,post_uuid:o.uuid}:e},[l,o,t?.id,V,H,U]),{data:G,loading:J}=r({endpoint:`api_kpis`,statsConfig:t,params:W}),xe=(0,K.useMemo)(()=>G?.length?G.reduce((e,t)=>{let n=Number(t.visits);return e+(isNaN(n)?0:n)},0):0,[G]),Y=ve.visits,Se=f(F,G||[],{fieldName:Y.dataKey}),Ce=d(G||[],F,Y.dataKey,`sum`)?.map(e=>{let t=Number(e[Y.dataKey]);return{date:String(e.date),value:t,formattedValue:Y.formatter(t),label:Y.label}}),{data:we,loading:Te}=r({endpoint:`api_top_sources`,statsConfig:t,params:W}),Ee=n||v||l||J,De=l||n||J,X=a(o)&&x&&ee,Z=!o?.email_only&&S,Q=b?.analytics.membersTrackSources,$=!!(C&&o&&b?.analytics.webAnalytics);return(0,K.useEffect)(()=>{!l&&o&&i(o)&&!S&&Q&&e(`/posts/analytics/${u}/growth`,{replace:!0})},[l,o,S,e,u,Q]),l?(0,q.jsx)(A,{}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(de,{currentTab:`Overview`}),(0,q.jsx)(ue,{children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 lg:grid lg:grid-cols-2`,children:[Z&&(0,q.jsx)(be,{chartData:Ce,isLoading:De||Ee||Te,isNewsletterShown:X,range:Se,sourcesData:we,visitors:xe}),X&&(0,q.jsx)(ye,{isNewsletterStatsLoading:l,isWebShown:Z,post:o}),(Q||$)&&(0,q.jsxs)(`div`,{className:`col-span-2 flex flex-col gap-6 lg:grid lg:grid-cols-3`,children:[Q&&(0,q.jsxs)(g,{className:`group overflow-hidden p-0 ${$?`lg:col-span-2`:`lg:col-span-3`}`,"data-testid":`growth`,children:[(0,q.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,q.jsx)(p,{children:(0,q.jsxs)(h,{className:`flex items-center gap-1.5 text-lg`,children:[(0,q.jsx)(ae,{size:16,strokeWidth:1.5}),`Growth`]})}),(0,q.jsx)(E,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:()=>{e(`/posts/analytics/${u}/growth`)},children:`View more`})]}),(0,q.jsx)(m,{className:`flex flex-col gap-6 px-0 md:grid md:grid-cols-3 md:items-stretch md:gap-0`,children:Ee?Array.from({length:3},(e,t)=>(0,q.jsxs)(`div`,{className:`h-[98px] gap-1 border-r px-6 py-5 last:border-r-0`,children:[(0,q.jsx)(M,{className:`w-2/3`}),(0,q.jsx)(M,{className:`h-7 w-12`})]},t)):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(B,{className:`grow gap-1 py-0`,children:[(0,q.jsx)(z,{children:`Free members`}),(0,q.jsx)(R,{children:(0,q.jsx)(L,{className:`text-[2.2rem]`,children:c(_?.free_members||0)})})]}),b?.paidMembersEnabled&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(B,{className:`grow gap-1 py-0`,children:[(0,q.jsx)(z,{children:`Paid members`}),(0,q.jsx)(R,{children:(0,q.jsx)(L,{className:`text-[2.2rem]`,children:c(_?.paid_members||0)})})]}),(0,q.jsxs)(B,{className:`grow gap-1 py-0`,children:[(0,q.jsx)(z,{children:`MRR impact`}),(0,q.jsx)(R,{children:(0,q.jsxs)(L,{className:`text-[2.2rem]`,children:[y,c(ge(_?.mrr||0))]})})]})]})]})})]}),$&&(0,q.jsxs)(g,{className:`group/datalist overflow-hidden ${Q?`lg:col-span-1`:`lg:col-span-3`}`,"data-testid":`gift-link-card`,children:[(0,q.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,q.jsx)(p,{children:(0,q.jsxs)(h,{className:`flex items-center gap-1.5 text-lg`,children:[(0,q.jsx)(T,{size:16,strokeWidth:1.5}),`Gift link`]})}),(0,q.jsx)(E,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:()=>P(!0),children:`Share`})]}),!k&&!j&&(0,q.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Visitors`}),(0,q.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold`,"data-testid":`gift-link-card-visitors`,children:c(O?.visits??0)})]})]})]}),!Z&&!X&&!Q&&!$&&(0,q.jsx)(ce,{className:`col-span-2 py-20`})]})}),$&&(0,q.jsx)(me,{open:N,postId:u,source:`gift-link-card`,onOpenChange:P},u)]})};export{J as default};