ghost 6.17.2 → 6.18.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 (213) hide show
  1. package/components/tryghost-i18n-6.18.0.tgz +0 -0
  2. package/components/{tryghost-parse-email-address-6.17.2.tgz → tryghost-parse-email-address-6.18.0.tgz} +0 -0
  3. package/content/themes/source/package.json +1 -1
  4. package/core/built/admin/assets/{PolarAngleAxis-B8JrAxf_.js → PolarAngleAxis-Dod0DwfL.js} +1 -1
  5. package/core/built/admin/assets/{_baseAssignValue-Bbalamaq.js → _baseAssignValue-DnkbkowM.js} +1 -1
  6. package/core/built/admin/assets/{a-large-small-CgWPeKpi.js → a-large-small-C5mgFBRg.js} +1 -1
  7. package/core/built/admin/assets/activitypub/activitypub.js +1 -1
  8. package/core/built/admin/assets/activitypub/{at-sign-Fsk3x72r.mjs → at-sign-BR2C2gdz.mjs} +2 -2
  9. package/core/built/admin/assets/activitypub/{avatar-flipboard-C10JfFS_.mjs → avatar-flipboard-CJV3KhLU.mjs} +2 -2
  10. package/core/built/admin/assets/activitypub/{bluesky-sharing-C1xeGSL6.mjs → bluesky-sharing-DY4KCGPZ.mjs} +4 -4
  11. package/core/built/admin/assets/activitypub/{copy-C1fElSkQ.mjs → copy-CBFwbAdE.mjs} +2 -2
  12. package/core/built/admin/assets/activitypub/{deleted-feed-item-Bun4tY2_.mjs → deleted-feed-item-DOm9GxTQ.mjs} +2 -2
  13. package/core/built/admin/assets/activitypub/{edit-profile-CYh00FZ7.mjs → edit-profile-CcbnZWkM.mjs} +3 -3
  14. package/core/built/admin/assets/activitypub/{feed-BxUqmcN9.mjs → feed-BHiZU0Q_.mjs} +4 -4
  15. package/core/built/admin/assets/activitypub/{hash-CNgwAx-U.mjs → hash-Csjloy5t.mjs} +2 -2
  16. package/core/built/admin/assets/activitypub/{inbox-DqNqII4a.mjs → inbox-DGKbBux9.mjs} +2 -2
  17. package/core/built/admin/assets/activitypub/{index-CONoLlDU.mjs → index-Bt_qFJNY.mjs} +2 -2
  18. package/core/built/admin/assets/activitypub/{index--Q6orQkb.mjs → index-CCYuVHjm.mjs} +21 -21
  19. package/core/built/admin/assets/activitypub/{index-jhjmoHwu.mjs → index-CTV39jCH.mjs} +2 -2
  20. package/core/built/admin/assets/activitypub/{index-Dvh9q3jy.mjs → index-ClNx7qzi.mjs} +4 -4
  21. package/core/built/admin/assets/activitypub/{index-C9pnotJK.mjs → index-D6Y6ywyl.mjs} +6 -6
  22. package/core/built/admin/assets/activitypub/{index-BueIufRq.mjs → index-YLvIz6pJ.mjs} +5 -5
  23. package/core/built/admin/assets/activitypub/{index-C3KJXzZE.mjs → index-tWANcGjH.mjs} +7 -7
  24. package/core/built/admin/assets/activitypub/{index-CJJXnqq1.mjs → index-vVqFEPIX.mjs} +3 -3
  25. package/core/built/admin/assets/activitypub/{moderation-CYhwUFi2.mjs → moderation-CUGqRfT1.mjs} +3 -3
  26. package/core/built/admin/assets/activitypub/{note-COVa8CMw.mjs → note-DMy39JHG.mjs} +4 -4
  27. package/core/built/admin/assets/activitypub/{reply-BHpKVBxx.mjs → reply-BboFcDsv.mjs} +2 -2
  28. package/core/built/admin/assets/activitypub/{separator-DP7q5sFH.mjs → separator-DBvIXQnV.mjs} +2 -2
  29. package/core/built/admin/assets/activitypub/{settings-3n7zo_3K.mjs → settings-D4qRhs9E.mjs} +3 -3
  30. package/core/built/admin/assets/activitypub/{step-1-BmUukywZ.mjs → step-1-C-ubwwIT.mjs} +3 -3
  31. package/core/built/admin/assets/activitypub/{step-2-C--I3xxp.mjs → step-2-Dsd2XY1_.mjs} +5 -5
  32. package/core/built/admin/assets/activitypub/{step-3-0Deh5N9c.mjs → step-3-BHz3ow0t.mjs} +7 -7
  33. package/core/built/admin/assets/activitypub/{tabs-D_vmoLBo.mjs → tabs-s_P4XeyF.mjs} +3 -3
  34. package/core/built/admin/assets/activitypub/{topic-filter-DJMrhH-c.mjs → topic-filter-CCf15CR-.mjs} +2 -2
  35. package/core/built/admin/assets/admin-x-settings/admin-x-settings.js +1 -1
  36. package/core/built/admin/assets/admin-x-settings/{code-editor-view-BzvYs1fs.mjs → code-editor-view-C9yQgDwn.mjs} +2 -2
  37. package/core/built/admin/assets/admin-x-settings/{index-BXChUyr6.mjs → index-Cb0MgPGv.mjs} +30 -19
  38. package/core/built/admin/assets/admin-x-settings/{index-DYEF3NiM.mjs → index-DGoxlHIt.mjs} +2 -2
  39. package/core/built/admin/assets/admin-x-settings/{index-DdMo_pvD.mjs → index-jzFpi950.mjs} +2 -2
  40. package/core/built/admin/assets/admin-x-settings/{modals-Ck3AHDx3.mjs → modals-CCI0FGRh.mjs} +13 -12
  41. package/core/built/admin/assets/{at-sign-BottTo2X.js → at-sign-Bz-SU-S_.js} +1 -1
  42. package/core/built/admin/assets/{audience-CcGOt5Fb.js → audience-DmVdEmIe.js} +1 -1
  43. package/core/built/admin/assets/{avatar-flipboard-MxW2k124.js → avatar-flipboard-C7sxDVEM.js} +1 -1
  44. package/core/built/admin/assets/{bluesky-sharing-BBmDBlxr.js → bluesky-sharing-DJniSF6N.js} +1 -1
  45. package/core/built/admin/assets/{chart-pimL5Chk.js → chart-mYz3IJwm.js} +1 -1
  46. package/core/built/admin/assets/{chunk.524.9a8f5123fd3ecf3e4451.js → chunk.524.d2c4d1c78e72685d04c9.js} +7 -7
  47. package/core/built/admin/assets/{chunk.582.41886d06af2895d571bd.js → chunk.582.a3333324fa5a373a6148.js} +8 -8
  48. package/core/built/admin/assets/{code-editor-view-tCZOpc_h.js → code-editor-view-BIQWFJ01.js} +1 -1
  49. package/core/built/admin/assets/comments-B_-hdjc6.js +1 -0
  50. package/core/built/admin/assets/{copy-aC0WUVtq.js → copy-Bpq3uhnh.js} +1 -1
  51. package/core/built/admin/assets/{data-list-BOdyZGWI.js → data-list-BYNMbRIq.js} +1 -1
  52. package/core/built/admin/assets/{deleted-feed-item-BnUJ8bWP.js → deleted-feed-item-B_AwUKZy.js} +1 -1
  53. package/core/built/admin/assets/{edit-profile-CEgPhWMJ.js → edit-profile-DZo2ZcOu.js} +1 -1
  54. package/core/built/admin/assets/{empty-indicator-CR_9BHAH.js → empty-indicator-Bn5wG9-T.js} +1 -1
  55. package/core/built/admin/assets/{en-ajofhc7o.js → en-D4zIrMLN.js} +1 -1
  56. package/core/built/admin/assets/{feed-Ci-ODCHE.js → feed-Bgq4RarU.js} +1 -1
  57. package/core/built/admin/assets/{filters-CmJJOv3I.js → filters-CpVwu1Gk.js} +1 -1
  58. package/core/built/admin/assets/{gh-chart-hn7wEnik.js → gh-chart-Br7NXn_b.js} +1 -1
  59. package/core/built/admin/assets/{ghost-78b420974adc056bf1c9570275a46535.css → ghost-3c48d37b32f4fcd7eb15cfd739905a03.css} +1 -1
  60. package/core/built/admin/assets/{ghost-a9268074d0a9b02198594a05ecd7a626.js → ghost-98a3c5fd6235ebd344594f491cb6d17b.js} +241 -246
  61. package/core/built/admin/assets/{ghost-dark-12abca67e79c76fe6bfed6cb81ba2a53.css → ghost-dark-0100fe3ec7b4c3f6d8d043c904254a63.css} +1 -1
  62. package/core/built/admin/assets/{growth-CQceZQ1g.js → growth-CiPDnWxJ.js} +1 -1
  63. package/core/built/admin/assets/{hash-BcaWmkw5.js → hash-Bc1e38oH.js} +1 -1
  64. package/core/built/admin/assets/{inbox-D9hID-rO.js → inbox-BcZNBNhk.js} +1 -1
  65. package/core/built/admin/assets/{index-d_UH71zm.js → index-BFEx_ouC.js} +1 -1
  66. package/core/built/admin/assets/{index-kXF42nga.js → index-B_7QsC5T.js} +1 -1
  67. package/core/built/admin/assets/{index-CZ3lARQ2.js → index-Bm5ZeLtt.js} +1 -1
  68. package/core/built/admin/assets/{index-DJDgMk-T.js → index-BpcL7RmI.js} +2 -2
  69. package/core/built/admin/assets/{index-g4BWcHhl.js → index-Brg4tecQ.js} +1 -1
  70. package/core/built/admin/assets/{index-f5Lv9kLb.js → index-CMTzNTew.js} +29 -29
  71. package/core/built/admin/assets/{index-Cl2eSBwg.js → index-CTfJflJ2.js} +1 -1
  72. package/core/built/admin/assets/{index-BJS8H75W.js → index-Cn32t_gv.js} +1 -1
  73. package/core/built/admin/assets/{index-D8syEvSm.js → index-CsidX7Si.js} +1 -1
  74. package/core/built/admin/assets/{index-DO76vL0R.js → index-D212VvOz.js} +1 -1
  75. package/core/built/admin/assets/{index-B1rKIiOr.js → index-D67LJ_H4.js} +1 -1
  76. package/core/built/admin/assets/{index-BmK6ThYl.js → index-DU3bv9jz.js} +1 -1
  77. package/core/built/admin/assets/{index-DYM1MbXR.js → index-Dv13wKfX.js} +1 -1
  78. package/core/built/admin/assets/{index-Do091GLu.js → index-ETsoQLbU.js} +1 -1
  79. package/core/built/admin/assets/{index-rluYcfd-.js → index-ZYDRMgcT.js} +1 -1
  80. package/core/built/admin/assets/{koenig-lexical-D2XHvS2J.js → koenig-lexical-DZUWzN0P.js} +1 -1
  81. package/core/built/admin/assets/{kpi-card-Dga9rFZ5.js → kpi-card-DENsK2xK.js} +1 -1
  82. package/core/built/admin/assets/{kpis-BbnqD1za.js → kpis-CDrs2iS1.js} +1 -1
  83. package/core/built/admin/assets/{label-D8WHEOe0.js → label-BznQtEEo.js} +1 -1
  84. package/core/built/admin/assets/{links-dgwx7ko1.js → links-lpAC3T1p.js} +1 -1
  85. package/core/built/admin/assets/{lucide-react-BARFK2PZ.js → lucide-react-CBigk-fq.js} +1 -1
  86. package/core/built/admin/assets/{main-layout-CcjtCuF_.js → main-layout-_SYQRjIl.js} +1 -1
  87. package/core/built/admin/assets/{message-square-text-BxquqPhA.js → message-square-text-cV8O_qKq.js} +1 -1
  88. package/core/built/admin/assets/{minus-Ziy4LSYD.js → minus-NvnQTlW7.js} +1 -1
  89. package/core/built/admin/assets/{modals-fMQzR7L6.js → modals-XRSkribf.js} +3 -3
  90. package/core/built/admin/assets/{moderation-Ci9UNwiZ.js → moderation-BQp1GEWG.js} +1 -1
  91. package/core/built/admin/assets/{newsletter-DnrS7Fvi.js → newsletter-foM6KNNV.js} +1 -1
  92. package/core/built/admin/assets/{newsletters-D78pgnas.js → newsletters-BexdXUhn.js} +1 -1
  93. package/core/built/admin/assets/{note-BAfNweZN.js → note-DuaUGOeZ.js} +1 -1
  94. package/core/built/admin/assets/{overview-CWQPNOF0.js → overview-DgKBNqyc.js} +1 -1
  95. package/core/built/admin/assets/{pagemenu-DjSqq3Wu.js → pagemenu-CZyroidv.js} +1 -1
  96. package/core/built/admin/assets/{post-analytics-c8kRV0YB.js → post-analytics-DLK2SOSQ.js} +1 -1
  97. package/core/built/admin/assets/{post-analytics-context-CEqWyqgm.js → post-analytics-context-CF7C67-0.js} +1 -1
  98. package/core/built/admin/assets/{post-analytics-header-CpPPBAz4.js → post-analytics-header-7GtJCx0W.js} +1 -1
  99. package/core/built/admin/assets/{post-share-modal-Dln0kZhn.js → post-share-modal-D8R7DUZP.js} +1 -1
  100. package/core/built/admin/assets/posts/{comments-CHEqbZPq.mjs → comments-Bn_vn_sb.mjs} +434 -407
  101. package/core/built/admin/assets/posts/{dialog-VFomJYla.mjs → dialog-CKPcMrj7.mjs} +3 -3
  102. package/core/built/admin/assets/posts/{empty-indicator-CT9qQsMO.mjs → empty-indicator-kkrhP6K_.mjs} +2 -2
  103. package/core/built/admin/assets/posts/{filters-BXCfSKKS.mjs → filters-DHsxxy0F.mjs} +6 -6
  104. package/core/built/admin/assets/posts/{growth-xMitvyvt.mjs → growth-D7ACh-oR.mjs} +12 -12
  105. package/core/built/admin/assets/posts/{heading-DIulQwgD.mjs → heading-BrKVbOxA.mjs} +2 -2
  106. package/core/built/admin/assets/posts/{hooks-BiBMDYOA.mjs → hooks-BBEMuLiW.mjs} +3 -3
  107. package/core/built/admin/assets/posts/{index-uYyMBANY.mjs → index-C0rRguZx.mjs} +9 -9
  108. package/core/built/admin/assets/posts/{kpis-DK6j0CJA.mjs → kpis-1o524OIK.mjs} +10 -10
  109. package/core/built/admin/assets/posts/{links-CBiYZsyk.mjs → links-JpeATx1f.mjs} +4 -4
  110. package/core/built/admin/assets/posts/{loading-indicator-BPPeKpVb.mjs → loading-indicator-BHAmSf8j.mjs} +3 -3
  111. package/core/built/admin/assets/posts/{main-layout-f-PcNn-6.mjs → main-layout-BTItAOQE.mjs} +2 -2
  112. package/core/built/admin/assets/posts/{newsletter-CSOyAfvO.mjs → newsletter-CQdsCEHv.mjs} +13 -13
  113. package/core/built/admin/assets/posts/{overview-Dve3Uxt4.mjs → overview-sYh4JN1D.mjs} +15 -15
  114. package/core/built/admin/assets/posts/{post-analytics-CPKxH7yg.mjs → post-analytics-DtLt2SWx.mjs} +6 -6
  115. package/core/built/admin/assets/posts/{post-analytics-context-B5zQoflZ.mjs → post-analytics-context-CB1yM9fk.mjs} +4 -4
  116. package/core/built/admin/assets/posts/{post-analytics-header-BBxuaptK.mjs → post-analytics-header-BYaWuL9W.mjs} +9 -9
  117. package/core/built/admin/assets/posts/{post-share-modal-D_iMXvnI.mjs → post-share-modal-V0HTOBaf.mjs} +4 -4
  118. package/core/built/admin/assets/posts/{posts-DW6ne0od.mjs → posts-DeQT3knv.mjs} +2 -2
  119. package/core/built/admin/assets/posts/posts.js +1 -1
  120. package/core/built/admin/assets/posts/{search-CVlPqGMA.mjs → search-CLjC37AT.mjs} +2 -2
  121. package/core/built/admin/assets/posts/{separator-YrJkDGVP.mjs → separator-KNoTIaJx.mjs} +5 -5
  122. package/core/built/admin/assets/posts/{sheet-T5GWxxrn.mjs → sheet-DBg_SCDt.mjs} +3 -3
  123. package/core/built/admin/assets/posts/{skeleton-qnvlkDy-.mjs → skeleton-DvsoolWu.mjs} +3 -3
  124. package/core/built/admin/assets/posts/{source-icon-DBU0eZwS.mjs → source-icon-OmRaTU2G.mjs} +3 -3
  125. package/core/built/admin/assets/posts/{stats-udwJVZP8.mjs → stats-BC2DzntY.mjs} +4 -4
  126. package/core/built/admin/assets/posts/{table-Cu0BZfBU.mjs → table-CxX9OKAj.mjs} +2 -2
  127. package/core/built/admin/assets/posts/{tabs-B-RaoD3I.mjs → tabs-B1jw7cBi.mjs} +10 -10
  128. package/core/built/admin/assets/posts/{tags-DSDGzArh.mjs → tags-BBilTo1a.mjs} +11 -11
  129. package/core/built/admin/assets/posts/{tags-DByfrDKO.mjs → tags-BitrLT_j.mjs} +2 -2
  130. package/core/built/admin/assets/posts/{use-infinite-virtual-scroll-B7dD2nWW.mjs → use-infinite-virtual-scroll-DaijA1ao.mjs} +3 -3
  131. package/core/built/admin/assets/posts/{web-B9wvEtJ_.mjs → web-CKmyC4Xj.mjs} +15 -15
  132. package/core/built/admin/assets/{posts-C1Eh5Ypq.js → posts-CL9UDYoW.js} +1 -1
  133. package/core/built/admin/assets/{repeat-CN4fiG5H.js → repeat-DgH39UKE.js} +1 -1
  134. package/core/built/admin/assets/{reply-BfWgvH7y.js → reply-DAaNxiy8.js} +1 -1
  135. package/core/built/admin/assets/{select-B_0NBkLz.js → select-Cor2wFXT.js} +1 -1
  136. package/core/built/admin/assets/{settings-BqaVcJee.js → settings-BeumESEN.js} +5 -5
  137. package/core/built/admin/assets/{settings-Dk9E7Fqv.js → settings-xRx917Gj.js} +1 -1
  138. package/core/built/admin/assets/{sort-button-C2M35dLh.js → sort-button-BNW3i4Lb.js} +1 -1
  139. package/core/built/admin/assets/{source-icon-DkGi13e_.js → source-icon-DvDuzw73.js} +1 -1
  140. package/core/built/admin/assets/{sprout-BKiwQsGn.js → sprout-C3cc0c-K.js} +1 -1
  141. package/core/built/admin/assets/{square-BEpRc_fY.js → square-tZp0_n7e.js} +1 -1
  142. package/core/built/admin/assets/stats/{audience-Dfo7BmNu.mjs → audience-BWqU7WWT.mjs} +3 -3
  143. package/core/built/admin/assets/stats/{index-DUWoiDE_.mjs → index-CUuQaROI.mjs} +5 -5
  144. package/core/built/admin/assets/stats/{index-Yo58temM.mjs → index-CcCyLMxL.mjs} +7 -7
  145. package/core/built/admin/assets/stats/{index-h0rsyxDz.mjs → index-D5mlMG4l.mjs} +8 -8
  146. package/core/built/admin/assets/stats/{index-_vL3Zubi.mjs → index-DXU2rE9t.mjs} +5 -5
  147. package/core/built/admin/assets/stats/{index-Banm1wtA.mjs → index-K7ASx7EG.mjs} +6 -6
  148. package/core/built/admin/assets/stats/{sort-button-i6PS-TUn.mjs → sort-button-CELUx6Zp.mjs} +3 -3
  149. package/core/built/admin/assets/stats/{stats-CjepXEWS.mjs → stats-d_u_in4l.mjs} +2 -2
  150. package/core/built/admin/assets/stats/stats.js +2 -2
  151. package/core/built/admin/assets/stats/{tabs-Q20S1oup.mjs → tabs-3wLZsy0v.mjs} +3 -3
  152. package/core/built/admin/assets/stats/{url-helpers-DrGoeEH1.mjs → url-helpers-Drq3xg0l.mjs} +4 -4
  153. package/core/built/admin/assets/stats/{use-growth-stats-BnffY2W3.mjs → use-growth-stats-28Sr42va.mjs} +3 -3
  154. package/core/built/admin/assets/{stats-CRgy_cWm.js → stats-2Jelnn-Q.js} +1 -1
  155. package/core/built/admin/assets/{stats-view-CTQ4qO3S.js → stats-view-CESy8ELH.js} +1 -1
  156. package/core/built/admin/assets/{step-1-CNbdmB8C.js → step-1-DrqdolAh.js} +1 -1
  157. package/core/built/admin/assets/{step-2-Ddrl2uae.js → step-2-DmEpKck5.js} +1 -1
  158. package/core/built/admin/assets/{step-3-CbqkEtwh.js → step-3-Bus-0o0n.js} +1 -1
  159. package/core/built/admin/assets/{table-Dw9xFlFd.js → table-BQUcKHfm.js} +1 -1
  160. package/core/built/admin/assets/{tabs-DCHagOip.js → tabs-BmdL0X4U.js} +1 -1
  161. package/core/built/admin/assets/{tags-DV2SSdMK.js → tags-CLxXZlOO.js} +1 -1
  162. package/core/built/admin/assets/{tags-BsDlfsPN.js → tags-EchqlZUJ.js} +1 -1
  163. package/core/built/admin/assets/{tiers-tc5tafWV.js → tiers-nCGyTly9.js} +1 -1
  164. package/core/built/admin/assets/{toggle-group-DS-ZVhCr.js → toggle-group-CM5uf7J1.js} +1 -1
  165. package/core/built/admin/assets/{topic-filter-BfoEqHRD.js → topic-filter-LTRvZ8aU.js} +1 -1
  166. package/core/built/admin/assets/{trash-CpnxYen-.js → trash-u5BxolyH.js} +1 -1
  167. package/core/built/admin/assets/{url-helpers-wKPPeCtD.js → url-helpers-D41fEt51.js} +1 -1
  168. package/core/built/admin/assets/{use-growth-stats-CbHIETF_.js → use-growth-stats-BJ0O9ewi.js} +1 -1
  169. package/core/built/admin/assets/{use-infinite-virtual-scroll-DU1EUhyj.js → use-infinite-virtual-scroll-APZWciOk.js} +1 -1
  170. package/core/built/admin/assets/{use-simple-pagination-X6kmRz2u.js → use-simple-pagination-DVRHeaAR.js} +1 -1
  171. package/core/built/admin/assets/{user-round-check-DYkrjHxF.js → user-round-check-B6j98D6d.js} +1 -1
  172. package/core/built/admin/assets/{wallet-cards-CSdWOmJE.js → wallet-cards-KmOh29LP.js} +1 -1
  173. package/core/built/admin/assets/{web-C39IKnvl.js → web-Cclotbnz.js} +1 -1
  174. package/core/built/admin/index.html +5 -5
  175. package/core/frontend/meta/asset-url.js +126 -15
  176. package/core/frontend/services/asset-hash/index.js +73 -0
  177. package/core/frontend/services/theme-engine/active.js +4 -2
  178. package/core/server/api/endpoints/utils/serializers/output/utils/post-gating.js +6 -0
  179. package/core/server/data/migrations/versions/6.17/2026-02-04-10-42-20-offers-nullable-product-id.js +11 -0
  180. package/core/server/data/migrations/versions/6.18/2026-02-04-10-42-20-offers-nullable-product-id.js +4 -0
  181. package/core/server/data/schema/schema.js +1 -1
  182. package/core/server/data/tinybird/datasources/_mv_daily_pages.datasource +13 -0
  183. package/core/server/data/tinybird/endpoints/api_top_pages_v3.pipe +113 -0
  184. package/core/server/data/tinybird/pipes/mv_daily_pages.pipe +23 -0
  185. package/core/server/data/tinybird/scripts/benchmark-top-pages.sh +186 -0
  186. package/core/server/data/tinybird/scripts/compare-top-pages.sh +262 -0
  187. package/core/server/data/tinybird/tests/api_top_pages_v3.yaml +112 -0
  188. package/core/server/models/automated-email.js +34 -0
  189. package/core/server/services/koenig/node-renderers/transistor-renderer.js +3 -8
  190. package/core/server/services/lib/member-signup-contexts.js +23 -0
  191. package/core/server/services/lib/member-signup-contexts.ts +22 -0
  192. package/core/server/services/member-welcome-emails/member-welcome-email-renderer.js +13 -7
  193. package/core/server/services/member-welcome-emails/service.js +8 -12
  194. package/core/server/services/members/members-api/controllers/router-controller.js +14 -0
  195. package/core/server/services/members/members-api/repositories/member-repository.js +1 -1
  196. package/core/server/services/members/members-api/services/payments-service.js +5 -0
  197. package/core/server/services/oembed/oembed-service.js +1 -1
  198. package/core/server/services/offers/application/offer-mapper.js +6 -7
  199. package/core/server/services/offers/application/offers-api.js +3 -3
  200. package/core/server/services/offers/domain/errors/index.js +2 -0
  201. package/core/server/services/offers/domain/models/offer.js +15 -3
  202. package/core/server/services/offers/offer-bookshelf-repository.js +4 -5
  203. package/core/server/services/stats/utils/tinybird.js +5 -3
  204. package/core/server/services/stripe/services/webhook/checkout-session-event-service.js +17 -1
  205. package/core/server/services/stripe/stripe-service.js +8 -0
  206. package/core/shared/config/defaults.json +6 -0
  207. package/core/shared/labs.js +3 -3
  208. package/core/shared/url-utils.js +2 -1
  209. package/package.json +6 -6
  210. package/tsconfig.tsbuildinfo +1 -1
  211. package/yarn.lock +23 -2
  212. package/components/tryghost-i18n-6.17.2.tgz +0 -0
  213. package/core/built/admin/assets/comments-OXqhcC0t.js +0 -1
@@ -1,6 +1,6 @@
1
- import{j as s,r as D,aH as we,e as at,d7 as i_,av as $g,aq as l_,ar as c_,as as Lg,aw as u_,au as Vi,aE as Kf,ax as f_,ay as Sf,az as d_,aF as p_,aG as h_,d8 as ut,ad as ns,bM as ot,d9 as no,da as Rn,db as gt,dc as xt,cF as Pg,cW as Fg,dd as Ug,de as ah,df as m_,dg as ln,dh as g_,di as ts,aB as x_,dj as b_,d6 as Zf,d5 as Hs,dk as Ha,ak as v_,aN as w_,dl as y_,dm as Qi,dn as Vf,dp as oh,dq as dr,dr as Za,ds as Nf,dt as __,du as Ws,dv as k_,dw as M_,dx as j_,dy as Hi,dz as E_,dA as T_,dB as Af,ac as S_,dC as N_,dD as A_,dE as I_,dF as C_,dG as Nn,dH as ih,dI as lh,dJ as D_}from"./index-f5Lv9kLb.js";import{H as bt,a as Gr,S as Va,B as Ue,x as Ji,K as R_,y as Zt,z as O_,A as Lt,M as yt,C as an,F as $_,G as Dn,J as zg,O as L_,Q as el,U as ye,V as Qe,W as P_,X as Qf,Y as Je,Z as cn,_ as On,$ as Et,a0 as Nt,a1 as ss,a2 as kr,a3 as F_,a4 as ch,a5 as tt,a6 as Ae,a7 as uh,a8 as fh,a9 as st,aa as Hg,ab as Bg,ac as U_,ad as z_,ae as H_,af as B_,ag as Ys,ah as Gs,ai as Xr,aj as $n,ak as Wg,al as W_,am as q_,an as Y_,ao as G_,ap as X_,aq as Bi,ar as Wi,as as K_,at as dh,au as ph,av as Z_,aw as Xs,ax as un,ay as on,az as qg,aA as V_,aB as Q_,aC as J_,aD as Yg,aE as Jf,aF as e2,aG as t2,aH as r2,aI as qi,aJ as ed,aK as n2,aL as td,aM as s2,aN as a2,aO as Gg,aP as Xg,aQ as rd,aR as o2,aS as i2,aT as l2,aU as Kg,aV as Zg,aW as c2,aX as u2,aY as hh,aZ as Vg,a_ as Qg,a$ as Jg,b0 as If,b1 as f2,b2 as d2,b3 as p2,b4 as e0,b5 as h2,b6 as m2,b7 as g2,b8 as t0,b9 as x2,ba as b2,bb as v2,bc as r0,bd as nd,be as w2,bf as sd,bg as y2,bh as _2,bi as n0,bj as k2,bk as s0,bl as M2,bm as j2,bn as E2}from"./settings-BqaVcJee.js";import{a as T2,u as a0,b as o0}from"./newsletters-D78pgnas.js";import{C as S2,a as N2}from"./index-g4BWcHhl.js";import{u as i0}from"./posts-C1Eh5Ypq.js";import{a as so,b as ad,c as A2,g as od}from"./tiers-tc5tafWV.js";import"./index-DO76vL0R.js";function I2(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const l0=({children:e,...n})=>s.jsx("div",{className:"flex h-full w-full flex-col px-8",...n,children:s.jsx("div",{className:"h-full w-full overflow-hidden rounded-t-[4px] shadow-sm",children:e})}),c0=({children:e,...n})=>s.jsx("div",{className:"flex h-[775px] w-[380px] flex-col rounded-3xl bg-white p-2 shadow-xl dark:bg-grey-900",...n,children:s.jsx("div",{className:"w-100 h-100 grow overflow-auto rounded-2xl border border-grey-100 dark:border-grey-950",children:e})}),C2=({title:e,label:n,value:a,onChange:o,disabled:c,error:m,hint:y,checked:h,separator:l,testId:f})=>{const u=D.useId(),p=x=>{o(x===!0)};return s.jsxs("div",{children:[s.jsxs("div",{className:`flex flex-col gap-1 ${l&&"pb-2"}`,children:[e&&s.jsx(bt,{grey:!0,level:6,children:e}),s.jsxs("label",{className:`flex cursor-pointer items-start ${e&&"-mb-1 mt-1"}`,htmlFor:u,children:[s.jsx(S2,{className:"mt-0.5 flex size-4 cursor-pointer appearance-none items-center justify-center rounded-[3px] border border-solid border-grey-500 bg-white outline-none data-[state=checked]:border-black data-[state=indeterminate]:border-black data-[state=checked]:bg-black data-[state=indeterminate]:bg-black","data-testid":f,defaultChecked:h,disabled:c,id:u,value:a,onCheckedChange:p,children:s.jsx(N2,{children:s.jsx("svg",{fill:"none",height:"11",viewBox:"0 0 10 11",width:"10",children:s.jsx("path",{d:"M1 5.88889L4.6 9L9 1",stroke:"white",strokeLinecap:"round",strokeWidth:"2"})})})}),s.jsxs("div",{className:`ml-2 flex flex-col ${y&&"mb-2"}`,children:[s.jsx("span",{className:`inline-block text-[1.425rem] dark:text-white ${y&&"-mb-1"}`,children:n}),y&&s.jsx(Gr,{color:m?"red":"",children:y})]})]})]}),(l||m)&&s.jsx(Va,{className:m?"border-red":""})]})},Cf=({title:e,checkboxes:n,hint:a,error:o})=>s.jsxs("div",{children:[e&&s.jsx(bt,{grey:!0,level:6,children:e}),s.jsx("div",{className:"mt-2 flex flex-col gap-1",children:n?.map(({key:c,...m})=>s.jsx(C2,{...m},c))}),s.jsx("div",{className:`flex flex-col ${a&&"mb-2"}`,children:a&&s.jsx(Gr,{color:o?"red":"",children:a})})]}),D2=({hex:e,value:n,title:a,size:o="md",isSelected:c,onSelect:m})=>{const y=D.useRef(null),h=u=>{u.preventDefault(),m(n!==void 0?n:e)},l=e.length===4&&e[3]==="0"||e.length===8&&e.slice(6)==="00";let f="h-5 w-5";switch(o){case"lg":f="w-6 h-6";break}return s.jsx("button",{ref:y,className:we("relative flex shrink-0 cursor-pointer items-center rounded-full border border-grey-300 dark:border-grey-800",f,c&&"outline outline-2 outline-green"),style:{backgroundColor:e},title:a,type:"button",onClick:h,children:l&&s.jsx("div",{className:"absolute left-0 top-0 z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})})},u0=({title:e,value:n,swatches:a,swatchSize:o="md",onSwatchChange:c,onTogglePicker:m,isExpanded:y,picker:h=!0,containerClassName:l})=>{const f=a.find(p=>p.value===n||p.hex===n);l=we("flex flex-col gap-3");const u=y||!h;return s.jsxs("div",{className:l,children:[e&&s.jsx(bt,{useLabelTag:!0,children:e}),s.jsxs("div",{className:"flex gap-1",children:[u&&s.jsx("div",{className:"flex items-center gap-1",children:a.map(({customContent:p,...x})=>p?s.jsx(D.Fragment,{children:p},x.title):s.jsx(D2,{isSelected:f?.title===x.title,size:o,onSelect:c,...x},x.title))}),h&&s.jsxs("button",{"aria-label":"Pick color",className:"relative size-6 cursor-pointer rounded-full border border-grey-250 dark:border-grey-800",type:"button",onClick:m,children:[s.jsx("div",{className:"absolute inset-0 rounded-full bg-[conic-gradient(hsl(360,100%,50%),hsl(315,100%,50%),hsl(270,100%,50%),hsl(225,100%,50%),hsl(180,100%,50%),hsl(135,100%,50%),hsl(90,100%,50%),hsl(45,100%,50%),hsl(0,100%,50%))]"}),f&&s.jsx("div",{className:"absolute inset-[3px] overflow-hidden rounded-full border border-white dark:border-grey-950",style:{backgroundColor:f.hex},children:f.hex==="transparent"&&s.jsx("div",{className:"absolute left-[3px] top-[3px] z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})}),!f&&n&&s.jsx("div",{className:"absolute inset-[3px] overflow-hidden rounded-full border border-white dark:border-grey-950",style:{backgroundColor:n},children:n==="transparent"&&s.jsx("div",{className:"absolute left-[3px] top-[3px] z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})})]})]})]})};function Ks(){return(Ks=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o])}return e}).apply(this,arguments)}function tl(e,n){if(e==null)return{};var a,o,c={},m=Object.keys(e);for(o=0;o<m.length;o++)n.indexOf(a=m[o])>=0||(c[a]=e[a]);return c}function Qa(e){var n=D.useRef(e),a=D.useRef(function(o){n.current&&n.current(o)});return n.current=e,a.current}var Ja=function(e,n,a){return n===void 0&&(n=0),a===void 0&&(a=1),e>a?a:e<n?n:e},Xa=function(e){return"touches"in e},Df=function(e){return e&&e.ownerDocument.defaultView||self},mh=function(e,n,a){var o=e.getBoundingClientRect(),c=Xa(n)?(function(m,y){for(var h=0;h<m.length;h++)if(m[h].identifier===y)return m[h];return m[0]})(n.touches,a):n;return{left:Ja((c.pageX-(o.left+Df(e).pageXOffset))/o.width),top:Ja((c.pageY-(o.top+Df(e).pageYOffset))/o.height)}},gh=function(e){!Xa(e)&&e.preventDefault()},f0=at.memo(function(e){var n=e.onMove,a=e.onKey,o=tl(e,["onMove","onKey"]),c=D.useRef(null),m=Qa(n),y=Qa(a),h=D.useRef(null),l=D.useRef(!1),f=D.useMemo(function(){var v=function(M){gh(M),(Xa(M)?M.touches.length>0:M.buttons>0)&&c.current?m(mh(c.current,M,h.current)):k(!1)},_=function(){return k(!1)};function k(M){var T=l.current,A=Df(c.current),C=M?A.addEventListener:A.removeEventListener;C(T?"touchmove":"mousemove",v),C(T?"touchend":"mouseup",_)}return[function(M){var T=M.nativeEvent,A=c.current;if(A&&(gh(T),!(function(O,$){return $&&!Xa(O)})(T,l.current)&&A)){if(Xa(T)){l.current=!0;var C=T.changedTouches||[];C.length&&(h.current=C[0].identifier)}A.focus(),m(mh(A,T,h.current)),k(!0)}},function(M){var T=M.which||M.keyCode;T<37||T>40||(M.preventDefault(),y({left:T===39?.05:T===37?-.05:0,top:T===40?.05:T===38?-.05:0}))},k]},[y,m]),u=f[0],p=f[1],x=f[2];return D.useEffect(function(){return x},[x]),at.createElement("div",Ks({},o,{onTouchStart:u,onMouseDown:u,className:"react-colorful__interactive",ref:c,onKeyDown:p,tabIndex:0,role:"slider"}))}),id=function(e){return e.filter(Boolean).join(" ")},d0=function(e){var n=e.color,a=e.left,o=e.top,c=o===void 0?.5:o,m=id(["react-colorful__pointer",e.className]);return at.createElement("div",{className:m,style:{top:100*c+"%",left:100*a+"%"}},at.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:n}}))},Yt=function(e,n,a){return n===void 0&&(n=0),a===void 0&&(a=Math.pow(10,n)),Math.round(a*e)/a},R2=function(e){return F2(Rf(e))},Rf=function(e){return e[0]==="#"&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?Yt(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?Yt(parseInt(e.substring(6,8),16)/255,2):1}},O2=function(e){return P2(L2(e))},$2=function(e){var n=e.s,a=e.v,o=e.a,c=(200-n)*a/100;return{h:Yt(e.h),s:Yt(c>0&&c<200?n*a/100/(c<=100?c:200-c)*100:0),l:Yt(c/2),a:Yt(o,2)}},Of=function(e){var n=$2(e);return"hsl("+n.h+", "+n.s+"%, "+n.l+"%)"},L2=function(e){var n=e.h,a=e.s,o=e.v,c=e.a;n=n/360*6,a/=100,o/=100;var m=Math.floor(n),y=o*(1-a),h=o*(1-(n-m)*a),l=o*(1-(1-n+m)*a),f=m%6;return{r:Yt(255*[o,h,y,y,l,o][f]),g:Yt(255*[l,o,o,h,y,y][f]),b:Yt(255*[y,y,l,o,o,h][f]),a:Yt(c,2)}},Di=function(e){var n=e.toString(16);return n.length<2?"0"+n:n},P2=function(e){var n=e.r,a=e.g,o=e.b,c=e.a,m=c<1?Di(Yt(255*c)):"";return"#"+Di(n)+Di(a)+Di(o)+m},F2=function(e){var n=e.r,a=e.g,o=e.b,c=e.a,m=Math.max(n,a,o),y=m-Math.min(n,a,o),h=y?m===n?(a-o)/y:m===a?2+(o-n)/y:4+(n-a)/y:0;return{h:Yt(60*(h<0?h+6:h)),s:Yt(m?y/m*100:0),v:Yt(m/255*100),a:c}},U2=at.memo(function(e){var n=e.hue,a=e.onChange,o=id(["react-colorful__hue",e.className]);return at.createElement("div",{className:o},at.createElement(f0,{onMove:function(c){a({h:360*c.left})},onKey:function(c){a({h:Ja(n+360*c.left,0,360)})},"aria-label":"Hue","aria-valuenow":Yt(n),"aria-valuemax":"360","aria-valuemin":"0"},at.createElement(d0,{className:"react-colorful__hue-pointer",left:n/360,color:Of({h:n,s:100,v:100,a:1})})))}),z2=at.memo(function(e){var n=e.hsva,a=e.onChange,o={backgroundColor:Of({h:n.h,s:100,v:100,a:1})};return at.createElement("div",{className:"react-colorful__saturation",style:o},at.createElement(f0,{onMove:function(c){a({s:100*c.left,v:100-100*c.top})},onKey:function(c){a({s:Ja(n.s+100*c.left,0,100),v:Ja(n.v-100*c.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+Yt(n.s)+"%, Brightness "+Yt(n.v)+"%"},at.createElement(d0,{className:"react-colorful__saturation-pointer",top:1-n.v/100,left:n.s/100,color:Of(n)})))}),p0=function(e,n){if(e===n)return!0;for(var a in e)if(e[a]!==n[a])return!1;return!0},H2=function(e,n){return e.toLowerCase()===n.toLowerCase()||p0(Rf(e),Rf(n))};function B2(e,n,a){var o=Qa(a),c=D.useState(function(){return e.toHsva(n)}),m=c[0],y=c[1],h=D.useRef({color:n,hsva:m});D.useEffect(function(){if(!e.equal(n,h.current.color)){var f=e.toHsva(n);h.current={hsva:f,color:n},y(f)}},[n,e]),D.useEffect(function(){var f;p0(m,h.current.hsva)||e.equal(f=e.fromHsva(m),h.current.color)||(h.current={hsva:m,color:f},o(f))},[m,e,o]);var l=D.useCallback(function(f){y(function(u){return Object.assign({},u,f)})},[]);return[m,l]}var W2=typeof window<"u"?D.useLayoutEffect:D.useEffect,q2=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},xh=new Map,Y2=function(e){W2(function(){var n=e.current?e.current.ownerDocument:document;if(n!==void 0&&!xh.has(n)){var a=n.createElement("style");a.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,xh.set(n,a);var o=q2();o&&a.setAttribute("nonce",o),n.head.appendChild(a)}},[])},G2=function(e){var n=e.className,a=e.colorModel,o=e.color,c=o===void 0?a.defaultColor:o,m=e.onChange,y=tl(e,["className","colorModel","color","onChange"]),h=D.useRef(null);Y2(h);var l=B2(a,c,m),f=l[0],u=l[1],p=id(["react-colorful",n]);return at.createElement("div",Ks({},y,{ref:h,className:p}),at.createElement(z2,{hsva:f,onChange:u}),at.createElement(U2,{hue:f.h,onChange:u,className:"react-colorful__last-control"}))},X2={defaultColor:"000",toHsva:R2,fromHsva:function(e){return O2({h:e.h,s:e.s,v:e.v,a:1})},equal:H2},K2=function(e){return at.createElement(G2,Ks({},e,{colorModel:X2}))},Z2=/^#?([0-9A-F]{3,8})$/i,V2=function(e){var n=e.color,a=n===void 0?"":n,o=e.onChange,c=e.onBlur,m=e.escape,y=e.validate,h=e.format,l=e.process,f=tl(e,["color","onChange","onBlur","escape","validate","format","process"]),u=D.useState(function(){return m(a)}),p=u[0],x=u[1],v=Qa(o),_=Qa(c),k=D.useCallback(function(T){var A=m(T.target.value);x(A),y(A)&&v(l?l(A):A)},[m,l,y,v]),M=D.useCallback(function(T){y(T.target.value)||x(m(a)),_(T)},[a,m,y,_]);return D.useEffect(function(){x(m(a))},[a,m]),at.createElement("input",Ks({},f,{value:h?h(p):p,spellCheck:"false",onChange:k,onBlur:M}))},bh=function(e){return"#"+e},Q2=function(e){var n=e.prefixed,a=e.alpha,o=tl(e,["prefixed","alpha"]),c=D.useCallback(function(y){return y.replace(/([^0-9A-F]+)/gi,"").substring(0,a?8:6)},[a]),m=D.useCallback(function(y){return(function(h,l){var f=Z2.exec(h),u=f?f[1].length:0;return u===3||u===6||!!l&&u===4||!!l&&u===8})(y,a)},[a]);return at.createElement(V2,Ks({},o,{escape:c,format:n?bh:void 0,process:bh,validate:m}))};const J2=({hexValue:e,eyedropper:n,clearButtonValue:a,containerClassName:o,onChange:c})=>{const m=D.useRef(null),y=D.useCallback(x=>{var v,_,k;x.stopPropagation();const M=(v=m.current)==null?void 0:v.querySelector("input");x.target!==M&&((k=(_=m.current)==null?void 0:_.querySelector("input"))==null||k.focus(),x.preventDefault())},[]),h=D.useRef(!1),l=D.useCallback(()=>{var x,v;h.current=!1,(v=(x=m.current)==null?void 0:x.querySelector("input"))==null||v.focus(),document.removeEventListener("mouseup",l),document.removeEventListener("touchend",l)},[]),f=D.useCallback(()=>{h.current=!0,document.addEventListener("mouseup",l),document.addEventListener("touchend",l)},[l]),u=D.useCallback(x=>{if(x.preventDefault(),!window.EyeDropper)return;h.current=!0,document.body.style.setProperty("pointer-events","none"),new window.EyeDropper().open().then(_=>c?.(_.sRGBHex)).finally(()=>{var _,k;h.current=!1,document.body.style.removeProperty("pointer-events"),(k=(_=m.current)==null?void 0:_.querySelector("input"))==null||k.focus()})},[c]);D.useEffect(()=>{var x,v;(v=(x=m.current)==null?void 0:x.querySelector("input"))==null||v.focus()},[]);const p=D.useCallback(()=>{var x,v;(v=(x=m.current)==null?void 0:x.querySelector("input"))==null||v.focus()},[]);return o=we("mt-2",o),s.jsxs("div",{className:o,onMouseDown:y,onTouchStart:y,children:[s.jsx(K2,{className:"w-full",color:e||"#ffffff",onChange:c,onMouseDown:f,onTouchStart:f}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsxs("div",{ref:m,className:"peer relative order-2 flex h-10 w-full items-center",onClick:p,children:[s.jsx("span",{className:"absolute left-2 top-[9px] z-10 ml-1 mr-2 text-grey-700",children:"#"}),s.jsx(Q2,{"aria-label":"Color value",className:"z-[1] w-full rounded-md border border-transparent bg-grey-150 p-2 pl-6 transition-all hover:bg-grey-100 focus:border-green focus:bg-white focus:shadow-[0_0_0_1px_rgba(48,207,67,1)] dark:bg-grey-900 dark:text-white dark:focus:bg-grey-925",color:e,onChange:c}),n&&!!window.EyeDropper&&s.jsx("button",{className:"absolute inset-y-0 right-3 z-50 my-auto h-4 w-4 p-[1px]",type:"button",onClick:u,children:s.jsx(i_,{className:"h-full w-full"})})]}),a!==void 0&&s.jsx(Ue,{color:"grey",value:"Clear",onClick:()=>c?.(a)})]})]})},e3=D.createContext({colorPickers:[]}),vh=e=>e.length===4?e.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"):e,Yr=({testId:e,title:n,direction:a,value:o,hint:c,error:m,eyedropper:y,clearButtonValue:h,onChange:l,swatches:f=[],alwaysOpen:u=!1,debounceMs:p})=>{const[x,v]=D.useState(!1),[_,k]=D.useState(o),M=D.useContext(e3),T=D.useId();D.useEffect(()=>{k(W=>vh(W||"")===o?W:o)},[o]),D.useEffect(()=>(M.colorPickers.push({id:T,setExpanded:v}),()=>{M.colorPickers=M.colorPickers.filter(W=>W.id!==T)}),[M,T]),D.useEffect(()=>{if(x){M.colorPickers.filter(R=>R.id!==T).forEach(R=>R.setExpanded(!1));const W=()=>{v(!1)};return document.addEventListener("click",W),()=>{document.removeEventListener("click",W)}}},[M,T,x]);const A=D.useMemo(()=>l&&p?Ji(l,p):l,[p,l]),C=W=>{k(W),A?.(W?vh(W):null)};let O=s.jsx(u0,{isExpanded:x,swatches:f,value:_,onSwatchChange:W=>{C(W),v(!1)},onTogglePicker:()=>!u&&v(!x)});n&&(O=s.jsxs("div",{className:we("flex w-full cursor-pointer items-start first:mt-0 dark:text-white",a==="rtl"&&"flex-row-reverse"),children:[s.jsx("div",{className:"shrink-0",children:O}),s.jsxs("div",{className:we("flex-1",a==="rtl"?"pr-2":"pl-2",c?"mt-[-2px]":"mt-[1px]"),onClick:()=>!u&&v(!x),children:[n,c&&s.jsx("div",{className:`text-xs ${m?"text-red":"text-grey-700"}`,children:c})]})]}));const $=f.find(W=>W.value===_);return s.jsxs("div",{className:"flex-col","data-testid":e,onClick:W=>W.stopPropagation(),children:[O,(u||x)&&s.jsx(J2,{clearButtonValue:h,eyedropper:y,hexValue:$?.hex||_||void 0,onChange:C})]})},t3=({value:e,onChange:n,singleParagraph:a=!0,...o})=>{const c=D.useCallback(m=>{const h=new DOMParser().parseFromString(m,"text/html");h.querySelectorAll("*").forEach(f=>{f.style.removeProperty("white-space"),f.getAttribute("style")||f.removeAttribute("style")}),h.body.innerHTML!==e&&n?.(h.body.innerHTML)},[e,n]);return s.jsx(R_,{...o,singleParagraph:a,children:m=>s.jsx(m.HtmlOutputPlugin,{html:e,setHtml:c})})},ld=({title:e,hideTitle:n,error:a,hint:o,value:c,clearBg:m=!1,className:y="",containerClassName:h="",hintClassName:l="",unstyled:f=!1,...u})=>{const p=f?"":we("flex min-h-[32px] items-center rounded-md border border-transparent py-1.5 md:min-h-[36px]",m?"bg-transparent":"bg-grey-150 px-3 dark:bg-grey-900",a?"border-red":"transition-all hover:bg-grey-100 has-[:focus]:border-green has-[:focus]:bg-white has-[:focus]:shadow-[0_0_0_1px_rgba(48,207,67,1)] dark:selection:bg-[rgba(88,101,116,0.99)] dark:hover:bg-grey-925 dark:has-[:focus]:bg-grey-950",e&&!n&&!m&&"mt-2",y);return s.jsxs("div",{className:`flex flex-col ${h}`,children:[e&&s.jsx(bt,{className:n?"sr-only":"",grey:!0,useLabelTag:!0,children:e}),s.jsx("div",{className:p,children:s.jsx(t3,{...u,value:c})}),o&&s.jsx(Gr,{className:l,color:a?"red":"",children:o})]})};var cd="Radio",[r3,h0]=Lg(cd),[n3,s3]=r3(cd),m0=D.forwardRef((e,n)=>{const{__scopeRadio:a,name:o,checked:c=!1,required:m,disabled:y,value:h="on",onCheck:l,form:f,...u}=e,[p,x]=D.useState(null),v=Kf(n,M=>x(M)),_=D.useRef(!1),k=p?f||!!p.closest("form"):!0;return s.jsxs(n3,{scope:a,checked:c,disabled:y,children:[s.jsx(Vi.button,{type:"button",role:"radio","aria-checked":c,"data-state":v0(c),"data-disabled":y?"":void 0,disabled:y,value:h,...u,ref:v,onClick:Sf(e.onClick,M=>{c||l?.(),k&&(_.current=M.isPropagationStopped(),_.current||M.stopPropagation())})}),k&&s.jsx(b0,{control:p,bubbles:!_.current,name:o,value:h,checked:c,required:m,disabled:y,form:f,style:{transform:"translateX(-100%)"}})]})});m0.displayName=cd;var g0="RadioIndicator",x0=D.forwardRef((e,n)=>{const{__scopeRadio:a,forceMount:o,...c}=e,m=s3(g0,a);return s.jsx(d_,{present:o||m.checked,children:s.jsx(Vi.span,{"data-state":v0(m.checked),"data-disabled":m.disabled?"":void 0,...c,ref:n})})});x0.displayName=g0;var a3="RadioBubbleInput",b0=D.forwardRef(({__scopeRadio:e,control:n,checked:a,bubbles:o=!0,...c},m)=>{const y=D.useRef(null),h=Kf(y,m),l=p_(a),f=h_(n);return D.useEffect(()=>{const u=y.current;if(!u)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==a&&v){const _=new Event("click",{bubbles:o});v.call(u,a),u.dispatchEvent(_)}},[l,a,o]),s.jsx(Vi.input,{type:"radio","aria-hidden":!0,defaultChecked:a,...c,tabIndex:-1,ref:h,style:{...c.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});b0.displayName=a3;function v0(e){return e?"checked":"unchecked"}var o3=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],rl="RadioGroup",[i3]=Lg(rl,[$g,h0]),w0=$g(),y0=h0(),[l3,c3]=i3(rl),_0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:a,name:o,defaultValue:c,value:m,required:y=!1,disabled:h=!1,orientation:l,dir:f,loop:u=!0,onValueChange:p,...x}=e,v=w0(a),_=l_(f),[k,M]=c_({prop:m,defaultProp:c??null,onChange:p,caller:rl});return s.jsx(l3,{scope:a,name:o,required:y,disabled:h,value:k,onValueChange:M,children:s.jsx(u_,{asChild:!0,...v,orientation:l,dir:_,loop:u,children:s.jsx(Vi.div,{role:"radiogroup","aria-required":y,"aria-orientation":l,"data-disabled":h?"":void 0,dir:_,...x,ref:n})})})});_0.displayName=rl;var k0="RadioGroupItem",M0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:a,disabled:o,...c}=e,m=c3(k0,a),y=m.disabled||o,h=w0(a),l=y0(a),f=D.useRef(null),u=Kf(n,f),p=m.value===c.value,x=D.useRef(!1);return D.useEffect(()=>{const v=k=>{o3.includes(k.key)&&(x.current=!0)},_=()=>x.current=!1;return document.addEventListener("keydown",v),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",v),document.removeEventListener("keyup",_)}},[]),s.jsx(f_,{asChild:!0,...h,focusable:!y,active:p,children:s.jsx(m0,{disabled:y,required:m.required,checked:p,...l,...c,name:m.name,ref:u,onCheck:()=>m.onValueChange(c.value),onKeyDown:Sf(v=>{v.key==="Enter"&&v.preventDefault()}),onFocus:Sf(c.onFocus,()=>{x.current&&f.current?.click()})})})});M0.displayName=k0;var u3="RadioGroupIndicator",j0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:a,...o}=e,c=y0(a);return s.jsx(x0,{...c,...o,ref:n})});j0.displayName=u3;var f3=_0,d3=M0,p3=j0;const h3=({id:e,title:n,options:a,onSelect:o,error:c,hint:m,selectedOption:y,separator:h})=>s.jsxs(f3,{defaultValue:y,name:e,onValueChange:o,children:[s.jsxs("div",{className:`flex flex-col gap-2 ${h&&"pb-2"}`,children:[n&&s.jsx(bt,{level:6,children:n}),a.map(l=>s.jsxs("label",{className:`flex cursor-pointer items-start ${n&&"-mb-1 mt-1"}`,htmlFor:l.value,children:[s.jsx(d3,{className:"relative float-left mt-[3px] size-4 min-w-[16px] appearance-none rounded-full border-2 border-solid border-grey-300 hover:cursor-pointer focus:shadow-none focus:outline-none focus:ring-0 data-[state=checked]:border-green data-[state=checked]:focus:border-green dark:border-grey-800 dark:text-white dark:data-[state=checked]:border-green dark:data-[state=checked]:focus:border-green",id:l.value,value:l.value,children:s.jsx(p3,{className:"flex size-full items-center justify-center after:block after:size-[6px] after:rounded-full after:border-green after:bg-green after:content-[''] dark:after:border-green dark:after:bg-green"})}),s.jsxs("div",{className:`ml-2 flex flex-col ${l.hint&&"mb-2"}`,children:[s.jsx("span",{className:`inline-block text-md dark:text-white ${l.hint&&"-mb-1"}`,children:l.label}),l.hint&&s.jsx(Gr,{children:l.hint})]})]},l.value)),m&&s.jsx(Gr,{color:c?"red":"",children:m})]}),(h||c)&&s.jsx(Va,{className:c?"border-red":""})]}),Yi=({children:e,gap:n="md",className:a})=>{let o="gap-3";switch(n){case"sm":o="gap-2";break;case"md":o="gap-3";break;case"lg":o="gap-4";break}return a=we("flex flex-col",o,a),s.jsx("div",{className:a,children:e})},ud=({heading:e,children:n,className:a})=>(a=we("w-full p-[8vmin] pt-5",a),s.jsxs("div",{className:a,children:[e&&s.jsx(bt,{className:"mb-8",children:e}),n]})),fd=({items:e,backIcon:n=!1,snapBackIcon:a=!0,onBack:o,containerClassName:c,itemClassName:m,activeItemClassName:y,separatorClassName:h})=>{const l=e.length;let f=0;return c=we("flex items-center gap-2 text-sm",c),y=we("font-bold",y),m=we("text-sm",m),s.jsxs("div",{className:c,children:[n&&s.jsx(Ue,{className:a?"mr-1":"mr-6",icon:"arrow-left",iconColorClass:"dark:text-white",size:"sm",link:!0,onClick:o}),e.map(u=>{const p=f===l-1?s.jsx("span",{className:y,children:u.label}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:`${m} ${u.onClick&&"-mx-1 cursor-pointer rounded-sm px-1 py-px hover:bg-grey-100 dark:hover:bg-grey-900"}`,type:"button",onClick:u.onClick,children:u.label},`bc-${f}`),s.jsx("span",{className:h,children:"/"})]});return f=f+1,p})]})},Zs=({testId:e,title:n,titleHeadingLevel:a=4,size:o="full",width:c,height:m,sidebar:y="",preview:h,dirty:l=!1,cancelLabel:f="Cancel",okLabel:u="OK",okColor:p="black",previewToolbar:x=!0,leftToolbar:v=!0,rightToolbar:_=!0,deviceSelector:k=!0,siteLink:M,previewToolbarURLs:T,previewBgColor:A="grey",selectedURL:C,previewToolbarTabs:O,previewToolbarBreadcrumbs:$,buttonsDisabled:W,sidebarButtons:R,sidebarHeader:Z,sidebarPadding:X=!0,sidebarContentClasses:q,enableCMDS:B=!0,backDropClick:Y,onCancel:ae,onOk:ee,afterClose:re,onSelectURL:Q,onSelectDesktopView:ne,onSelectMobileView:be,onBreadcrumbsBack:je})=>{const H=Zt(),{setGlobalDirtyState:he}=O_();D.useEffect(()=>{he(l)},[l,he]),D.useEffect(()=>{if(ee){const J=xe=>{(xe.metaKey||xe.ctrlKey)&&xe.key==="s"&&(xe.preventDefault(),ee())};if(B)return window.addEventListener("keydown",J),()=>{window.removeEventListener("keydown",J)}}});const[ge,F]=D.useState("desktop");if(ge==="mobile"&&k?h=s.jsx(c0,{"data-testid":"preview-mobile",children:h}):ge==="desktop"&&k&&(h=s.jsx(l0,{"data-testid":"preview-desktop",children:h})),x){let J=s.jsx(s.Fragment,{});T?J=s.jsx(Lt,{options:T,selectedOption:T.find(Ie=>Ie.value===C),onSelect:Ie=>Ie&&Q?.(Ie.value)}):O?J=s.jsx(Dn,{border:!1,selectedTab:C,tabs:O,width:"wide",onTabChange:Q}):$&&(J=s.jsx(fd,{activeItemClassName:"hidden md:!block md:!visible",containerClassName:"whitespace-nowrap",itemClassName:"hidden md:!block md:!visible",items:$,separatorClassName:"hidden md:!block md:!visible",backIcon:!0,onBack:je}));const xe="text-black dark:text-green",Te="text-grey-500 dark:text-grey-600",De=[{icon:"laptop",label:"Desktop",hideLabel:!0,link:!0,size:"sm",iconColorClass:ge==="desktop"?xe:Te,onClick:ne||(()=>{F("desktop")})},{icon:"mobile",label:"Mobile",hideLabel:!0,link:!0,size:"sm",iconColorClass:ge==="mobile"?xe:Te,onClick:be||(()=>{F("mobile")})}],Me=k&&s.jsx(an,{buttons:De});let oe="";A==="grey"?oe="bg-grey-50 dark:bg-black":A==="greygradient"&&(oe="bg-gradient-to-tr from-white to-[#f9f9fa] dark:from-grey-950 dark:to-black");const Ee=we("min-w-100 absolute inset-y-0 left-0 right-[400px] flex w-full grow flex-col overflow-y-auto",oe);let Ne;M&&(Ne=s.jsx("div",{className:"ml-3 border-l border-grey-400 dark:border-grey-800",children:s.jsxs("a",{className:"ml-3 flex items-center gap-1 text-sm",href:M,rel:"noopener noreferrer",target:"_blank",children:["View site ",s.jsx(ut,{name:"arrow-top-right",size:"xs"})]})})),h=s.jsxs("div",{className:Ee,children:[x&&s.jsxs("header",{className:"relative flex h-[80px] shrink-0 items-center justify-center px-8 py-5","data-testid":"design-toolbar",children:[v&&s.jsx("div",{className:"absolute left-8 flex h-full items-center",children:J}),_&&s.jsxs("div",{className:"absolute right-8 flex h-full items-center",children:[Me,Ne]})]}),s.jsx("div",{className:"flex grow items-center justify-center text-sm text-grey-400",children:h})]})}const L=[];return R||(L.push({key:"cancel-modal",label:f,onClick:ae||(()=>{$_(l,()=>{H.remove(),re?.()})}),disabled:W}),L.push({key:"ok-modal",label:u,color:p,onClick:ee,disabled:W})),s.jsx(yt,{afterClose:re,animate:!1,backDropClick:Y,dirty:l,footer:!1,height:m,padding:!1,size:o,testId:e,title:"",width:c,hideXOnMobile:!0,children:s.jsxs("div",{className:"flex h-full grow",children:[s.jsx("div",{className:`relative hidden grow flex-col [@media(min-width:801px)]:!visible [@media(min-width:801px)]:!flex ${A==="grey"?"bg-grey-50":"bg-white dark:bg-black"}`,children:h}),y&&s.jsxs("div",{className:"relative flex size-full flex-col border-l border-grey-100 dark:border-grey-900 [@media(min-width:801px)]:w-auto [@media(min-width:801px)]:basis-[400px]",children:[Z||s.jsxs("div",{className:"flex max-h-[82px] items-center justify-between gap-3 px-7 py-6",children:[s.jsx(bt,{level:a,children:n}),R||s.jsx(an,{buttons:L})]}),s.jsx("div",{className:`${Z?"":"absolute inset-x-0 bottom-0 top-[80px] grow"} ${X&&"p-7 pt-0"} flex flex-col justify-between overflow-y-auto ${q&&q}`,children:y})]})]})})},m3=({offset:e,onTrigger:n})=>{const a=D.useRef(null);return D.useEffect(()=>{const o=new IntersectionObserver(c=>{c[0].intersectionRatio<=0||n()});return a.current&&o.observe(a.current),()=>o.disconnect()},[n]),s.jsx("div",{ref:a,className:"absolute w-full",style:{bottom:e}})},E0=({trigger:e,triggerButtonProps:n,items:a,position:o="start",open:c,setOpen:m})=>(e||(e=s.jsx(Ue,{icon:"ellipsis",label:"Menu",hideLabel:!0,...n})),s.jsx(zg,{open:c,position:o,setOpen:m,trigger:e,closeOnItemClick:!0,children:s.jsx("div",{className:"flex min-w-[160px] flex-col justify-stretch py-1",role:"none",children:a.map(y=>s.jsx("button",{className:`mx-1 block cursor-pointer rounded-[2.5px] px-4 py-1.5 text-left text-sm hover:bg-grey-100 dark:hover:bg-grey-925 ${y.destructive&&" text-red-500"}`,type:"button",onClick:h=>{y.onClick&&y.onClick(h)},children:y.label},y.id))})}));var T0=typeof global=="object"&&global&&global.Object===Object&&global,g3=typeof self=="object"&&self&&self.Object===Object&&self,fn=T0||g3||Function("return this")(),qs=fn.Symbol,S0=Object.prototype,x3=S0.hasOwnProperty,b3=S0.toString,Ba=qs?qs.toStringTag:void 0;function v3(e){var n=x3.call(e,Ba),a=e[Ba];try{e[Ba]=void 0;var o=!0}catch{}var c=b3.call(e);return o&&(n?e[Ba]=a:delete e[Ba]),c}var w3=Object.prototype,y3=w3.toString;function _3(e){return y3.call(e)}var k3="[object Null]",M3="[object Undefined]",wh=qs?qs.toStringTag:void 0;function ao(e){return e==null?e===void 0?M3:k3:wh&&wh in Object(e)?v3(e):_3(e)}function eo(e){return e!=null&&typeof e=="object"}var Gi=Array.isArray;function N0(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}var j3="[object AsyncFunction]",E3="[object Function]",T3="[object GeneratorFunction]",S3="[object Proxy]";function A0(e){if(!N0(e))return!1;var n=ao(e);return n==E3||n==T3||n==j3||n==S3}var ru=fn["__core-js_shared__"],yh=(function(){var e=/[^.]+$/.exec(ru&&ru.keys&&ru.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function N3(e){return!!yh&&yh in e}var A3=Function.prototype,I3=A3.toString;function as(e){if(e!=null){try{return I3.call(e)}catch{}try{return e+""}catch{}}return""}var C3=/[\\^$.*+?()[\]{}|]/g,D3=/^\[object .+?Constructor\]$/,R3=Function.prototype,O3=Object.prototype,$3=R3.toString,L3=O3.hasOwnProperty,P3=RegExp("^"+$3.call(L3).replace(C3,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function F3(e){if(!N0(e)||N3(e))return!1;var n=A0(e)?P3:D3;return n.test(as(e))}function U3(e,n){return e?.[n]}function Vs(e,n){var a=U3(e,n);return F3(a)?a:void 0}var $f=Vs(fn,"WeakMap"),z3=9007199254740991,H3=/^(?:0|[1-9]\d*)$/;function B3(e,n){var a=typeof e;return n=n??z3,!!n&&(a=="number"||a!="symbol"&&H3.test(e))&&e>-1&&e%1==0&&e<n}function I0(e,n){return e===n||e!==e&&n!==n}var W3=9007199254740991;function C0(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=W3}function q3(e){return e!=null&&C0(e.length)&&!A0(e)}var Y3=Object.prototype;function G3(e){var n=e&&e.constructor,a=typeof n=="function"&&n.prototype||Y3;return e===a}function X3(e,n){for(var a=-1,o=Array(e);++a<e;)o[a]=n(a);return o}var K3="[object Arguments]";function _h(e){return eo(e)&&ao(e)==K3}var D0=Object.prototype,Z3=D0.hasOwnProperty,V3=D0.propertyIsEnumerable,Q3=_h((function(){return arguments})())?_h:function(e){return eo(e)&&Z3.call(e,"callee")&&!V3.call(e,"callee")};function J3(){return!1}var R0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,kh=R0&&typeof module=="object"&&module&&!module.nodeType&&module,e8=kh&&kh.exports===R0,Mh=e8?fn.Buffer:void 0,t8=Mh?Mh.isBuffer:void 0,Lf=t8||J3,r8="[object Arguments]",n8="[object Array]",s8="[object Boolean]",a8="[object Date]",o8="[object Error]",i8="[object Function]",l8="[object Map]",c8="[object Number]",u8="[object Object]",f8="[object RegExp]",d8="[object Set]",p8="[object String]",h8="[object WeakMap]",m8="[object ArrayBuffer]",g8="[object DataView]",x8="[object Float32Array]",b8="[object Float64Array]",v8="[object Int8Array]",w8="[object Int16Array]",y8="[object Int32Array]",_8="[object Uint8Array]",k8="[object Uint8ClampedArray]",M8="[object Uint16Array]",j8="[object Uint32Array]",wt={};wt[x8]=wt[b8]=wt[v8]=wt[w8]=wt[y8]=wt[_8]=wt[k8]=wt[M8]=wt[j8]=!0;wt[r8]=wt[n8]=wt[m8]=wt[s8]=wt[g8]=wt[a8]=wt[o8]=wt[i8]=wt[l8]=wt[c8]=wt[u8]=wt[f8]=wt[d8]=wt[p8]=wt[h8]=!1;function E8(e){return eo(e)&&C0(e.length)&&!!wt[ao(e)]}function T8(e){return function(n){return e(n)}}var O0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ka=O0&&typeof module=="object"&&module&&!module.nodeType&&module,S8=Ka&&Ka.exports===O0,nu=S8&&T0.process,jh=(function(){try{var e=Ka&&Ka.require&&Ka.require("util").types;return e||nu&&nu.binding&&nu.binding("util")}catch{}})(),Eh=jh&&jh.isTypedArray,$0=Eh?T8(Eh):E8,N8=Object.prototype,A8=N8.hasOwnProperty;function I8(e,n){var a=Gi(e),o=!a&&Q3(e),c=!a&&!o&&Lf(e),m=!a&&!o&&!c&&$0(e),y=a||o||c||m,h=y?X3(e.length,String):[],l=h.length;for(var f in e)A8.call(e,f)&&!(y&&(f=="length"||c&&(f=="offset"||f=="parent")||m&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||B3(f,l)))&&h.push(f);return h}function C8(e,n){return function(a){return e(n(a))}}var D8=C8(Object.keys,Object),R8=Object.prototype,O8=R8.hasOwnProperty;function $8(e){if(!G3(e))return D8(e);var n=[];for(var a in Object(e))O8.call(e,a)&&a!="constructor"&&n.push(a);return n}function L8(e){return q3(e)?I8(e):$8(e)}var to=Vs(Object,"create");function P8(){this.__data__=to?to(null):{},this.size=0}function F8(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}var U8="__lodash_hash_undefined__",z8=Object.prototype,H8=z8.hasOwnProperty;function B8(e){var n=this.__data__;if(to){var a=n[e];return a===U8?void 0:a}return H8.call(n,e)?n[e]:void 0}var W8=Object.prototype,q8=W8.hasOwnProperty;function Y8(e){var n=this.__data__;return to?n[e]!==void 0:q8.call(n,e)}var G8="__lodash_hash_undefined__";function X8(e,n){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=to&&n===void 0?G8:n,this}function rs(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var o=e[n];this.set(o[0],o[1])}}rs.prototype.clear=P8;rs.prototype.delete=F8;rs.prototype.get=B8;rs.prototype.has=Y8;rs.prototype.set=X8;function K8(){this.__data__=[],this.size=0}function nl(e,n){for(var a=e.length;a--;)if(I0(e[a][0],n))return a;return-1}var Z8=Array.prototype,V8=Z8.splice;function Q8(e){var n=this.__data__,a=nl(n,e);if(a<0)return!1;var o=n.length-1;return a==o?n.pop():V8.call(n,a,1),--this.size,!0}function J8(e){var n=this.__data__,a=nl(n,e);return a<0?void 0:n[a][1]}function ek(e){return nl(this.__data__,e)>-1}function tk(e,n){var a=this.__data__,o=nl(a,e);return o<0?(++this.size,a.push([e,n])):a[o][1]=n,this}function dn(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var o=e[n];this.set(o[0],o[1])}}dn.prototype.clear=K8;dn.prototype.delete=Q8;dn.prototype.get=J8;dn.prototype.has=ek;dn.prototype.set=tk;var ro=Vs(fn,"Map");function rk(){this.size=0,this.__data__={hash:new rs,map:new(ro||dn),string:new rs}}function nk(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function sl(e,n){var a=e.__data__;return nk(n)?a[typeof n=="string"?"string":"hash"]:a.map}function sk(e){var n=sl(this,e).delete(e);return this.size-=n?1:0,n}function ak(e){return sl(this,e).get(e)}function ok(e){return sl(this,e).has(e)}function ik(e,n){var a=sl(this,e),o=a.size;return a.set(e,n),this.size+=a.size==o?0:1,this}function os(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var o=e[n];this.set(o[0],o[1])}}os.prototype.clear=rk;os.prototype.delete=sk;os.prototype.get=ak;os.prototype.has=ok;os.prototype.set=ik;function lk(e,n){for(var a=-1,o=n.length,c=e.length;++a<o;)e[c+a]=n[a];return e}function ck(){this.__data__=new dn,this.size=0}function uk(e){var n=this.__data__,a=n.delete(e);return this.size=n.size,a}function fk(e){return this.__data__.get(e)}function dk(e){return this.__data__.has(e)}var pk=200;function hk(e,n){var a=this.__data__;if(a instanceof dn){var o=a.__data__;if(!ro||o.length<pk-1)return o.push([e,n]),this.size=++a.size,this;a=this.__data__=new os(o)}return a.set(e,n),this.size=a.size,this}function Cn(e){var n=this.__data__=new dn(e);this.size=n.size}Cn.prototype.clear=ck;Cn.prototype.delete=uk;Cn.prototype.get=fk;Cn.prototype.has=dk;Cn.prototype.set=hk;function mk(e,n){for(var a=-1,o=e==null?0:e.length,c=0,m=[];++a<o;){var y=e[a];n(y,a,e)&&(m[c++]=y)}return m}function gk(){return[]}var xk=Object.prototype,bk=xk.propertyIsEnumerable,Th=Object.getOwnPropertySymbols,vk=Th?function(e){return e==null?[]:(e=Object(e),mk(Th(e),function(n){return bk.call(e,n)}))}:gk;function wk(e,n,a){var o=n(e);return Gi(e)?o:lk(o,a(e))}function Sh(e){return wk(e,L8,vk)}var Pf=Vs(fn,"DataView"),Ff=Vs(fn,"Promise"),Uf=Vs(fn,"Set"),Nh="[object Map]",yk="[object Object]",Ah="[object Promise]",Ih="[object Set]",Ch="[object WeakMap]",Dh="[object DataView]",_k=as(Pf),kk=as(ro),Mk=as(Ff),jk=as(Uf),Ek=as($f),In=ao;(Pf&&In(new Pf(new ArrayBuffer(1)))!=Dh||ro&&In(new ro)!=Nh||Ff&&In(Ff.resolve())!=Ah||Uf&&In(new Uf)!=Ih||$f&&In(new $f)!=Ch)&&(In=function(e){var n=ao(e),a=n==yk?e.constructor:void 0,o=a?as(a):"";if(o)switch(o){case _k:return Dh;case kk:return Nh;case Mk:return Ah;case jk:return Ih;case Ek:return Ch}return n});var Rh=fn.Uint8Array,Tk="__lodash_hash_undefined__";function Sk(e){return this.__data__.set(e,Tk),this}function Nk(e){return this.__data__.has(e)}function Xi(e){var n=-1,a=e==null?0:e.length;for(this.__data__=new os;++n<a;)this.add(e[n])}Xi.prototype.add=Xi.prototype.push=Sk;Xi.prototype.has=Nk;function Ak(e,n){for(var a=-1,o=e==null?0:e.length;++a<o;)if(n(e[a],a,e))return!0;return!1}function Ik(e,n){return e.has(n)}var Ck=1,Dk=2;function L0(e,n,a,o,c,m){var y=a&Ck,h=e.length,l=n.length;if(h!=l&&!(y&&l>h))return!1;var f=m.get(e),u=m.get(n);if(f&&u)return f==n&&u==e;var p=-1,x=!0,v=a&Dk?new Xi:void 0;for(m.set(e,n),m.set(n,e);++p<h;){var _=e[p],k=n[p];if(o)var M=y?o(k,_,p,n,e,m):o(_,k,p,e,n,m);if(M!==void 0){if(M)continue;x=!1;break}if(v){if(!Ak(n,function(T,A){if(!Ik(v,A)&&(_===T||c(_,T,a,o,m)))return v.push(A)})){x=!1;break}}else if(!(_===k||c(_,k,a,o,m))){x=!1;break}}return m.delete(e),m.delete(n),x}function Rk(e){var n=-1,a=Array(e.size);return e.forEach(function(o,c){a[++n]=[c,o]}),a}function Ok(e){var n=-1,a=Array(e.size);return e.forEach(function(o){a[++n]=o}),a}var $k=1,Lk=2,Pk="[object Boolean]",Fk="[object Date]",Uk="[object Error]",zk="[object Map]",Hk="[object Number]",Bk="[object RegExp]",Wk="[object Set]",qk="[object String]",Yk="[object Symbol]",Gk="[object ArrayBuffer]",Xk="[object DataView]",Oh=qs?qs.prototype:void 0,su=Oh?Oh.valueOf:void 0;function Kk(e,n,a,o,c,m,y){switch(a){case Xk:if(e.byteLength!=n.byteLength||e.byteOffset!=n.byteOffset)return!1;e=e.buffer,n=n.buffer;case Gk:return!(e.byteLength!=n.byteLength||!m(new Rh(e),new Rh(n)));case Pk:case Fk:case Hk:return I0(+e,+n);case Uk:return e.name==n.name&&e.message==n.message;case Bk:case qk:return e==n+"";case zk:var h=Rk;case Wk:var l=o&$k;if(h||(h=Ok),e.size!=n.size&&!l)return!1;var f=y.get(e);if(f)return f==n;o|=Lk,y.set(e,n);var u=L0(h(e),h(n),o,c,m,y);return y.delete(e),u;case Yk:if(su)return su.call(e)==su.call(n)}return!1}var Zk=1,Vk=Object.prototype,Qk=Vk.hasOwnProperty;function Jk(e,n,a,o,c,m){var y=a&Zk,h=Sh(e),l=h.length,f=Sh(n),u=f.length;if(l!=u&&!y)return!1;for(var p=l;p--;){var x=h[p];if(!(y?x in n:Qk.call(n,x)))return!1}var v=m.get(e),_=m.get(n);if(v&&_)return v==n&&_==e;var k=!0;m.set(e,n),m.set(n,e);for(var M=y;++p<l;){x=h[p];var T=e[x],A=n[x];if(o)var C=y?o(A,T,x,n,e,m):o(T,A,x,e,n,m);if(!(C===void 0?T===A||c(T,A,a,o,m):C)){k=!1;break}M||(M=x=="constructor")}if(k&&!M){var O=e.constructor,$=n.constructor;O!=$&&"constructor"in e&&"constructor"in n&&!(typeof O=="function"&&O instanceof O&&typeof $=="function"&&$ instanceof $)&&(k=!1)}return m.delete(e),m.delete(n),k}var eM=1,$h="[object Arguments]",Lh="[object Array]",Ri="[object Object]",tM=Object.prototype,Ph=tM.hasOwnProperty;function rM(e,n,a,o,c,m){var y=Gi(e),h=Gi(n),l=y?Lh:In(e),f=h?Lh:In(n);l=l==$h?Ri:l,f=f==$h?Ri:f;var u=l==Ri,p=f==Ri,x=l==f;if(x&&Lf(e)){if(!Lf(n))return!1;y=!0,u=!1}if(x&&!u)return m||(m=new Cn),y||$0(e)?L0(e,n,a,o,c,m):Kk(e,n,l,a,o,c,m);if(!(a&eM)){var v=u&&Ph.call(e,"__wrapped__"),_=p&&Ph.call(n,"__wrapped__");if(v||_){var k=v?e.value():e,M=_?n.value():n;return m||(m=new Cn),c(k,M,a,o,m)}}return x?(m||(m=new Cn),Jk(e,n,a,o,c,m)):!1}function P0(e,n,a,o,c){return e===n?!0:e==null||n==null||!eo(e)&&!eo(n)?e!==e&&n!==n:rM(e,n,a,o,P0,c)}function nM(e,n){return P0(e,n)}const Fh=({className:e,children:n,colSpan:a,sticky:o=!1,...c})=>{const m=we("!py-2 !pl-0 !pr-6 text-left align-top",o&&"sticky top-0 bg-white",c.onClick&&"hover:cursor-pointer",e);return s.jsx("th",{className:m,colSpan:a,...c,children:s.jsx(bt,{className:"whitespace-nowrap",level:6,children:n})})},F0=({left:e,center:n,right:a,sticky:o=!0,containerClassName:c,children:m})=>{const y=we("z-50 h-22 min-h-[92px] p-8",!m&&"flex items-center justify-between gap-3",o&&"sticky top-0",c);if(!m){if(e){const h=we("flex flex-auto items-center",a&&n&&"basis-1/3",!a&&n&&"basis-1/2");e=s.jsx("div",{className:h,children:e})}if(n){const h=we("flex flex-auto items-center justify-center",e&&a&&"basis-1/3",(e&&!a||!e&&a)&&"basis-1/2");n=s.jsx("div",{className:h,children:n})}if(a){const h=we("flex flex-auto items-center justify-end",e&&n&&"basis-1/3",!e&&n&&"basis-1/2");a=s.jsx("div",{className:h,children:a})}}return s.jsx("div",{className:y,children:m||s.jsxs(s.Fragment,{children:[e,n,a]})})},U0=({items:e,setItems:n,blank:a,canAddNewItem:o})=>{const[c,m]=D.useState(e.map((x,v)=>({item:x,id:v.toString()}))),[y,h]=D.useState(a);return D.useEffect(()=>{const x=c.map(({item:v})=>v);o(y)&&x.push(y),nM(JSON.parse(JSON.stringify(x)),JSON.parse(JSON.stringify(e)))||n(x)},[c,y,e,n,o]),{items:c,updateItem:(x,v)=>{const _=c.map(k=>k.id===x?{...k,item:v}:k);m(_),n(_.map(k=>k.item))},addItem:()=>{if(o(y)){const x=c.reduce((_,k)=>Math.max(_,parseInt(k.id)),0),v=c.concat({item:y,id:(x+1).toString()});m(v),n(v.map(_=>_.item)),h(a)}},removeItem:x=>{const v=c.filter(_=>_.id!==x);m(v),n(v.map(_=>_.item))},moveItem:(x,v)=>{if(x!==v){const _=c.findIndex(T=>T.id===x),k=v?c.findIndex(T=>T.id===v):0,M=L_(c,_,k);m(M),n(M.map(T=>T.item))}},newItem:y,setNewItem:h}},sM=({label:e,text:n="",hint:a,onRegenerate:o})=>{const[c,m]=D.useState(!1),y=()=>{navigator.clipboard.writeText(n),m(!0),setTimeout(()=>m(!1),2e3)},h=we("group/api-keys relative -mt-1 mb-1 w-full overflow-hidden border-b border-transparent py-2 hover:border-grey-300 dark:hover:border-grey-600");return s.jsxs("div",{className:"mb-3 grid grid-cols-1",children:[e&&s.jsx(bt,{level:6,grey:!0,children:e}),s.jsxs("div",{className:h,children:[s.jsx("span",{children:n}),a,s.jsxs("div",{className:"visible absolute right-0 top-1/2 flex translate-y-[-50%] gap-1 bg-white pl-1 text-sm group-hover/api-keys:visible md:invisible dark:bg-black",children:[o&&s.jsx(Ue,{color:"outline",label:"Regenerate",size:"sm",onClick:o}),s.jsx(Ue,{color:"outline",label:c?"Copied":"Copy",size:"sm",onClick:y})]})]})]})},al=({keys:e})=>s.jsx("div",{"data-testid":"api-keys",children:e.map(n=>s.jsx(sM,{...n},n.label))}),Qs=({icon:e,title:n,detail:a,extra:o})=>s.jsxs("div",{className:"-mx-8 -mt-8 flex flex-col gap-4 bg-grey-75 p-8 md:flex-row dark:bg-grey-950",children:[s.jsx("div",{className:"size-14",children:e}),s.jsxs("div",{className:"mt-1.5 flex min-w-0 flex-1 flex-col",children:[s.jsx("h3",{children:n}),s.jsx("div",{children:a}),o&&s.jsx("div",{className:"mt-4",children:o})]})]}),dd=ns({method:"POST",path:({integrationId:e,apiKeyId:n})=>`/integrations/${e}/api_key/${n}/refresh/`,body:({integrationId:e})=>({integrations:[{id:e}]}),updateQueries:{emberUpdateType:"createOrUpdate",dataType:el,update:(e,n)=>n&&{...n,integrations:n.integrations.map(a=>e.integrations.find(({id:c})=>c===a.id)||a)}}}),aM=ye.create(()=>{const e=ye.useModal(),{updateRoute:n}=Qe(),{zapierTemplates:a}=P_(),{data:{integrations:o}={integrations:[]}}=Qf(),{config:c}=Je(),{mutateAsync:m}=dd(),y=ot(),[h,l]=D.useState(!1),f=c.hostSettings?.limits?.customIntegrations?.disabled,u=o.find(({slug:v})=>v==="zapier"),p=u?.api_keys?.find(v=>v.type==="admin");D.useEffect(()=>{f&&n("integrations")},[f,n]);const x=()=>{!u||!p||(l(!1),ye.show(Et,{title:"Regenerate Admin API Key",prompt:'You will need to locate the Ghost App within your Zapier account and click on "Reconnect" to enter the new Admin API Key.',okLabel:"Regenerate Admin API Key",onOk:async v=>{try{await m({integrationId:u.id,apiKeyId:p.id}),l(!0),v?.remove()}catch(_){y(_)}}}))};return s.jsxs(yt,{afterClose:()=>{n("integrations")},cancelLabel:"",footer:s.jsxs("div",{className:"mx-8 flex w-full items-center justify-between",children:[s.jsxs("a",{className:"mt-1 self-baseline text-sm font-bold",href:"https://zapier.com/apps/ghost/integrations?utm_medium=partner_api&utm_source=widget&utm_campaign=Widget",rel:"noopener noreferrer",target:"_blank",children:["View more Ghost integrations powered by ",s.jsx("span",{children:s.jsx(ut,{className:"relative top-[-2px] inline-block",name:"zapier-logo",size:24})})]}),s.jsx(Ue,{color:"black",label:"Close",onClick:()=>{e.remove()}})]}),okColor:"black",okLabel:"Close",testId:"zapier-modal",title:"",stickyFooter:!0,onOk:()=>{n("integrations"),e.remove()},children:[s.jsx(Qs,{detail:"Automation for your favorite apps",extra:s.jsx("div",{className:"-mb-4 mt-1",children:s.jsx(al,{keys:[{label:"Admin API key",text:p?.secret,hint:h?s.jsx("div",{className:"text-green",children:"Admin API Key was successfully regenerated"}):void 0,onRegenerate:x},{label:"API URL",text:window.location.origin+no().subdir}]})}),icon:s.jsx(ut,{name:"zapier",size:56}),title:"Zapier"}),s.jsx(cn,{children:a.map(v=>s.jsx(On,{action:s.jsx(Ue,{className:"whitespace-nowrap text-sm font-semibold text-[#FF4A00]",href:v.url,label:"Use this Zap",tag:"a",target:"_blank",link:!0,unstyled:!0}),bgOnHover:!1,className:"flex items-center gap-3 py-2 pl-3",title:s.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center",children:[s.jsxs("div",{className:"flex shrink-0 flex-nowrap items-center gap-2",children:[s.jsx("img",{className:"size-8 object-contain dark:invert",role:"presentation",src:v.ghostImage}),s.jsx(ut,{name:"arrow-right",size:"xs"}),s.jsx("img",{className:"size-8 object-contain",role:"presentation",src:v.appImage})]}),s.jsx("span",{className:"text-sm",children:v.title})]}),hideActions:!0}))})]})});function z0(e){const n="The URL must be in a format like https://www.threads.net/@yourUsername";if(!e)return"";if(e.startsWith("http")){if(!e.includes("threads.net")&&!e.includes("threads.com"))throw new Error(n);if(e=e.replace("threads.com","threads.net"),e.includes("www.")||(e=e.replace("https://","https://www.")),!Nt.isURL(e))throw new Error(n);if(!e.match(/^https:\/\/www\.threads\.net\/@?[a-zA-Z0-9._]+$/))throw new Error(n);return e}if(!e.includes("/")){if(e.startsWith("@")&&(e=e.slice(1)),!e.match(/^[a-zA-Z0-9._]+$/))throw new Error(n);return`https://www.threads.net/@${e}`}throw new Error(n)}const oM=e=>`https://www.threads.net/${e}`,iM=e=>{const n=e.match(/(?:https:\/\/)(?:www\.)?(?:threads\.(?:com|net))(?:\/)?(?:#!\/)?@?([^/]*)/)?.[1];return n?`@${n}`:null},Bs={INVALID_USERNAME:"Your Username is not a valid Bluesky Username",INVALID_URL:"The URL must be in a format like https://bsky.app/profile/yourUsername"};function H0(e){return[/^did:plc:[a-z2-7]{24}$/,/^[a-zA-Z0-9._]{1,15}$/,/^(?=.{1,191}$)[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$/].some(a=>a.test(e))}function zf(e){let n=e.trim();return n.startsWith("@")&&(n=n.slice(1)),n.startsWith("did:plc:")?n.toLowerCase():n}function B0(e){if(!e)return"";let n;if(e.startsWith("http")||e.startsWith("www.")||e.includes("bsky.app")){if(!e.includes("bsky.app"))throw new Error(Bs.INVALID_URL);const o=e.match(/bsky\.app\/profile\/@?([^/]+)/);if(!o)throw new Error(Bs.INVALID_URL);n=zf(o[1])}else n=zf(e);if(!H0(n))throw new Error(Bs.INVALID_USERNAME);const a=`https://bsky.app/profile/${n}`;if(!Nt.isURL(a))throw new Error(Bs.INVALID_URL);return a}const lM=e=>{if(!e)throw new Error(Bs.INVALID_USERNAME);let n=zf(e);if(!H0(n))throw new Error(Bs.INVALID_USERNAME);return`https://bsky.app/profile/${n}`},cM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?bsky\.app\/profile\/@?([^/]*)/);return n?`${n[1]}`:null},es={INVALID_URL:"The URL must be in a format like https://www.linkedin.com/in/yourUsername",INVALID_USERNAME:"Your Username is not a valid LinkedIn Username"},uM=["in","pub","company","school"],fM=/^[a-zA-Z0-9-]{3,100}$/,dM=/^[a-zA-Z0-9-]{3,100}(?:\/[a-zA-Z0-9-]*)*$/,W0=/^(?:https?:\/\/)?(?:www\.)?(?:([a-z]{2})\.)?linkedin\.com\/(in|pub|company|school)\/([^?#]+)/i,Hf=e=>e.trim().replace(/^@/,""),q0=e=>{if(/^(https?:\/\/|www\.)/.test(e)||e.includes("linkedin.com")){const o=e.match(W0);if(!o)throw new Error(es.INVALID_URL);if(o[0].length!==e.length)throw new Error(es.INVALID_USERNAME);const[,c,m,y]=o,h=Hf(y);if(c&&!/^[A-Z]{2}$/.test(c.toUpperCase()))throw new Error(es.INVALID_URL);return{regional:c,pathType:m,username:h}}const n=Hf(e),a=n.indexOf("/");if(a!==-1){const o=n.substring(0,a);if(uM.includes(o))return{pathType:o,username:n.substring(a+1)}}return{username:n}},Y0=(e,n)=>(e==="pub"?dM:fM).test(n),G0=({regional:e,pathType:n,username:a})=>{const c=`https://${e?`${e.toLowerCase()}.`:"www."}linkedin.com/${n}/${a}`;if(!Nt.isURL(c))throw new Error(es.INVALID_URL);return c};function X0(e){if(!e)return"";const{regional:n,pathType:a="in",username:o}=q0(e);if(!Y0(a,o))throw new Error(es.INVALID_USERNAME);return G0({regional:n,pathType:a,username:o})}const pM=e=>{if(!e)throw new Error(es.INVALID_USERNAME);const{regional:n,pathType:a="in",username:o}=q0(e);if(!Y0(a,o))throw new Error(es.INVALID_USERNAME);return G0({regional:n,pathType:a,username:o})},hM=e=>{const n=e.match(W0);if(!n)return null;const[,,a,o]=n,c=Hf(o);return a==="in"?c:`${a}/${c}`};function K0(e){const n="The URL must be in a format like https://www.instagram.com/yourUsername",a="Your Username is not a valid Instagram Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("instagram.com")){if(!e.includes("instagram.com"))throw new Error(n);const m=e.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]+)/);if(!m)throw new Error(n);o=m[1]}else o=e.startsWith("@")?e.slice(1):e;if(!o.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||o.includes("..")||o.length>30)throw new Error(a);const c=`https://www.instagram.com/${o}`;if(!Nt.isURL(c))throw new Error(n);return c}const mM=e=>{const n="Your Username is not a valid Instagram Username";if(!e)throw new Error(n);let a=e;if(a.startsWith("@")&&(a=a.slice(1)),!a.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||a.includes("..")||a.length>30)throw new Error(n);return`https://www.instagram.com/${a}`},gM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]*)/);return n?`${n[1]}`:null};function Z0(e){const n="The URL must be in a format like https://www.youtube.com/@yourUsername, https://www.youtube.com/user/yourUsername, or https://www.youtube.com/channel/yourChannelId",a="Your Username is not a valid YouTube Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("youtube.com")){if(!e.includes("youtube.com"))throw new Error(n);const m=e.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]+)/);if(!m)throw new Error(n);o=m[1]}else o=e;if(o.startsWith("@")){const m=o.slice(1);if(!m.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||m.includes("..")||m.length>30)throw new Error(a)}else if(o.startsWith("user/")){if(!o.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(a)}else if(o.startsWith("channel/")){if(!o.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(a)}else throw new Error(n);const c=`https://www.youtube.com/${o}`;if(!Nt.isURL(c))throw new Error(n);return c}const xM=e=>{const n="Your Username is not a valid YouTube Username";if(!e)throw new Error(n);if(e.startsWith("@")){const a=e.slice(1);if(!a.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||a.includes("..")||a.length>30)throw new Error(n)}else if(e.startsWith("user/")){if(!e.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(n)}else if(e.startsWith("channel/")){if(!e.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(n)}else throw new Error("The handle must be in a format like @yourUsername, user/yourUsername, or channel/yourChannelId");return`https://www.youtube.com/${e}`},bM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]*)/);return n?n[1]:null};function V0(e){const n="The URL must be in a format like https://www.tiktok.com/@yourUsername",a="Your Username is not a valid TikTok Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("tiktok.com")){if(!e.includes("tiktok.com"))throw new Error(n);const y=e.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]+)/);if(!y)throw new Error(n);o=y[1]}else o=e.startsWith("@")?e:`@${e}`;const c=o.slice(1);if(!c.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||c.includes("..")||c.length<2||c.length>24)throw new Error(a);const m=`https://www.tiktok.com/${o}`;if(!Nt.isURL(m))throw new Error(n);return m}const vM=e=>{const n="Your Username is not a valid TikTok Username";if(!e)throw new Error(n);const a=e.startsWith("@")?e:`@${e}`,o=a.slice(1);if(!o.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||o.includes("..")||o.length<2||o.length>24)throw new Error(n);return`https://www.tiktok.com/${a}`},wM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]*)/);return n?n[1]:null};function Q0(e){const n="The URL must be in a format like @username@instance.tld or https://instance.tld/@username or https://website.com/@username@instance.tld";if(!e)return"";let a=e;if(a=a.replace(/^https?:\/\//,""),a.match(/^@[^@]+@[^/]+$/)){const[o,c]=a.split("@").slice(1);if(!Nt.isFQDN(c))throw new Error(n);return`https://${c}/@${o}`}if(a.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[o,c]=a.split("/@");if(!Nt.isFQDN(o))throw new Error(n);if(c.includes("@")){const[,m]=c.split("@");if(!Nt.isFQDN(m))throw new Error(n)}return`https://${a}`}throw new Error(n)}const yM=e=>{const n="Your Username is not a valid Mastodon Username";if(!e)throw new Error(n);if(e.match(/^@[^@]+@[^/]+$/)){const[a,o]=e.split("@").slice(1);if(!Nt.isFQDN(o))throw new Error(n);return`https://${o}/@${a}`}if(e.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[a,o]=e.split("/@");if(!Nt.isFQDN(a))throw new Error(n);if(o.includes("@")){const[,c]=o.split("@");if(!Nt.isFQDN(c))throw new Error(n)}return`https://${e}`}throw new Error(n)},_M=e=>e.replace(/^https?:\/\//,""),kM=({tier:e})=>{const n=e?.type==="free",{updateRoute:a}=Qe(),{mutateAsync:o}=ad(),{mutateAsync:c}=A2(),{mutateAsync:m}=Rn(),[y,h]=at.useState(!!e?.trial_days),l=ot(),{localSettings:f,siteData:u}=ss(),[p]=gt(f,["portal_plans"]),x=JSON.parse(p?.toString()||"[]"),v={name:()=>_.name?void 0:"Enter a name for the tier",monthly_price:()=>_.type!=="free"?ch(_.monthly_price||0,_.currency,{allowZero:!1}):void 0,yearly_price:()=>_.type!=="free"?ch(_.yearly_price||0,_.currency,{allowZero:!1}):void 0},{formState:_,saveState:k,updateForm:M,handleSave:T,errors:A,clearError:C,okProps:O}=kr({initialState:{...e||{},trial_days:e?.trial_days?.toString()||"",currency:e?.currency||F_[0].isoCode,visibility:e?.visibility||"none",welcome_page_url:e?.welcome_page_url||null},savingDelay:500,savedDelay:500,onValidate:()=>{const q={};return Object.entries(v).forEach(([B,Y])=>{q[B]=Y?.()}),q},onSave:async()=>{const{trial_days:q,currency:B,...Y}=_,ae=Y;if(ae.benefits=ae.benefits?.filter(ee=>ee),n||(ae.currency=B,ae.trial_days=parseInt(q)),e?.id?await o({...e,...ae}):await c(ae),n){const ee=_.visibility==="public";let re=!1;x.includes("free")&&!ee&&(x.splice(x.indexOf("free"),1),re=!0),!x.includes("free")&&ee&&(x.push("free"),re=!0),re&&await m([{key:"portal_plans",value:JSON.stringify(x)}])}},onSaveError:l}),$=U0({items:_.benefits||[],setItems:q=>M(B=>({...B,benefits:q})),blank:"",canAddNewItem:q=>!!q}),W=q=>{q.target.checked?(h(!0),M(B=>({...B,trial_days:e?.trial_days?e?.trial_days.toString():"7"}))):(h(!1),M(B=>({...B,trial_days:"0"})))},R=D.useRef(!1);D.useEffect(()=>{R.current&&(v.monthly_price?.(),v.yearly_price?.()),R.current=!0},[_.currency]);const Z=()=>{if(e){const q=e.active?"Archive tier":"Reactivate tier",B=e.active?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:["Members will no longer be able to subscribe to ",s.jsx("strong",{children:e.name})," and it will be removed from the list of available tiers in portal."]}),s.jsx("div",{children:"Existing members on this tier will remain unchanged. Offers using this tier will be disabled."})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:["Reactivating ",s.jsx("strong",{children:e.name})," will re-enable it as an option in portal and allow new members to subscribe to this tier."]}),s.jsx("div",{children:"Existing members will remain unchanged."})]}),Y=e.active?"Archive":"Reactivate";ye.show(Et,{title:q,prompt:B,okLabel:Y,cancelLabel:"Cancel",okColor:e.active?"red":"black",onOk:ae=>{o({...e,active:!e.active}),ae?.remove(),xt({type:"success",title:`Tier ${e.active?"archived":"reactivated"}`})}})}};let X={};return e&&(e.active&&e.type!=="free"?X={label:"Archive tier",color:"red",link:!0,onClick:Z}:e.active||(X={label:"Reactivate tier",color:"green",link:!0,onClick:Z})),s.jsx(yt,{afterClose:()=>{a("tiers")},buttonsDisabled:O.disabled,cancelLabel:"Close",dirty:k==="unsaved",leftButtonProps:X,okColor:O.color,okLabel:O.label||"Save",size:"lg",testId:"tier-detail-modal",title:e?e.active?"Edit tier":"Edit archived tier":"New tier",stickyFooter:!0,onOk:async()=>{await T({fakeWhenUnchanged:!0})},children:s.jsxs("div",{className:"-mb-8 mt-8 flex items-start gap-8",children:[s.jsxs("div",{className:"flex grow flex-col gap-8",children:[s.jsxs(tt,{marginBottom:!1,title:"Basic",grouped:!0,children:[s.jsx(Ae,{autoComplete:"off",error:!!A.name,hint:A.name,maxLength:191,placeholder:n?"Free":"Bronze",title:"Name",value:_.name||"",autoFocus:!0,onChange:q=>M(B=>({...B,name:q.target.value})),onKeyDown:()=>C("name")}),s.jsx(Ae,{autoComplete:"off",autoFocus:n,maxLength:191,placeholder:n?"Free preview":"Full access to premium content",title:"Description",value:_.description||"",onChange:q=>M(B=>({...B,description:q.target.value}))}),!n&&s.jsx(s.Fragment,{children:s.jsxs("div",{className:"flex flex-col gap-10 md:flex-row",children:[s.jsxs("div",{className:"basis-1/2",children:[s.jsxs("div",{className:"mb-1 flex h-6 items-center justify-between",children:[s.jsx(bt,{level:6,children:"Prices"}),s.jsx("div",{className:"-mr-2 w-[50px]",children:s.jsx(Lt,{border:!1,containerClassName:"font-medium",controlClasses:{menu:"w-18"},options:uh(),selectedOption:uh().flatMap(q=>q.options).find(q=>q.value===_.currency),size:"xs",clearBg:!0,isSearchable:!0,onSelect:q=>M(B=>({...B,currency:q?.value}))})})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(fh,{error:!!A.monthly_price,hint:A.monthly_price,placeholder:"5",rightPlaceholder:`${_.currency}/month`,title:"Monthly price",valueInCents:_.monthly_price||"",hideTitle:!0,onBlur:q=>q.target.value===""?M(B=>({...B,monthly_price:0})):null,onChange:q=>M(B=>({...B,monthly_price:q})),onKeyDown:()=>C("monthly_price")}),s.jsx(fh,{error:!!A.yearly_price,hint:A.yearly_price,placeholder:"50",rightPlaceholder:`${_.currency}/year`,title:"Yearly price",valueInCents:_.yearly_price||"",hideTitle:!0,onBlur:q=>q.target.value===""?M(B=>({...B,yearly_price:0})):null,onChange:q=>M(B=>({...B,yearly_price:q})),onKeyDown:()=>C("yearly_price")})]})]}),s.jsxs("div",{className:"basis-1/2",children:[s.jsx("div",{className:"mb-1 flex h-6 flex-col justify-center",children:s.jsx(st,{checked:y,label:"Add a free trial",labelStyle:"heading",onChange:W})}),s.jsx(Ae,{disabled:!y,hint:s.jsxs("div",{className:"mt-1",children:["Members will be subscribed at full price once the trial ends. ",s.jsx("a",{className:"text-green",href:"https://ghost.org/help/free-trials/",rel:"noreferrer",target:"_blank",children:"Learn more"})]}),placeholder:"0",rightPlaceholder:"days",title:"Trial days",value:_.trial_days,hideTitle:!0,onChange:q=>M(B=>({...B,trial_days:q.target.value.replace(/[^\d]/,"")}))})]})]})}),s.jsx(Hg,{baseUrl:u?.url,hint:`Redirect to this URL after signup ${n?"":" for premium membership"}`,maxLength:2e3,placeholder:u?.url,title:"Welcome page",value:_.welcome_page_url||null,nullable:!0,transformPathWithoutSlash:!0,onChange:q=>M(B=>({...B,welcome_page_url:q||null}))})]}),s.jsxs(tt,{gap:"none",title:"Benefits",grouped:!0,children:[s.jsx("div",{className:"-mt-3",children:s.jsx(Bg,{items:$.items,itemSeparator:!1,renderItem:({id:q,item:B})=>s.jsxs("div",{className:"relative flex w-full items-center gap-5",children:[s.jsx("div",{className:"absolute left-[-32px] top-[7px] flex size-6 items-center justify-center bg-white group-hover:hidden dark:bg-black",children:s.jsx(ut,{name:"check",size:"sm"})}),s.jsx(Ae,{maxLength:191,value:B,onChange:Y=>$.updateItem(q,Y.target.value)}),s.jsx(Ue,{className:"absolute right-1 top-1 z-10 opacity-0 group-hover:opacity-100",color:"grey",icon:"trash",size:"sm",onClick:()=>$.removeItem(q)})]}),onMove:$.moveItem})}),s.jsxs("div",{className:"relative mt-1 flex items-center gap-3",children:[s.jsx(ut,{className:"dark:text-white",name:"check",size:"sm"}),s.jsx(Ae,{className:"grow",containerClassName:"w-100",maxLength:191,placeholder:"Expert analysis",title:"New benefit",value:$.newItem,hideTitle:!0,onChange:q=>$.setNewItem(q.target.value),onKeyDown:q=>{q.key==="Enter"&&$.addItem()}}),s.jsx(Ue,{className:"absolute right-[5px] top-[5px] z-10",color:"green",icon:"add",iconColorClass:"text-white",label:"Add",size:"sm",hideLabel:!0,onClick:()=>$.addItem()})]})]})]}),s.jsx("div",{className:"sticky top-[96px] hidden shrink-0 basis-[380px] min-[920px]:!visible min-[920px]:!block",children:s.jsx(U_,{isFreeTier:n,tier:_})})]})})},MM=({params:e})=>{const{data:{tiers:n,isEnd:a}={},fetchNextPage:o}=so();let c;return D.useEffect(()=>{e?.id&&!c&&!a&&o()},[o,a,e?.id,c]),e?.id&&(c=n?.find(({id:m})=>m===e?.id),!c)?null:s.jsx(kM,{tier:c})},jM=ye.create(MM);var au,Uh;function J0(){if(Uh)return au;Uh=1;var e={};return au=typeof process=="object"&&e&&e.NODE_DEBUG&&/\bsemver\b/i.test(e.NODE_DEBUG)?(...a)=>console.error("SEMVER",...a):()=>{},au}var ou,zh;function ex(){if(zh)return ou;zh=1;const e="2.0.0",n=256,a=Number.MAX_SAFE_INTEGER||9007199254740991,o=16,c=n-6;return ou={MAX_LENGTH:n,MAX_SAFE_COMPONENT_LENGTH:o,MAX_SAFE_BUILD_LENGTH:c,MAX_SAFE_INTEGER:a,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:e,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},ou}var Oi={exports:{}},Hh;function EM(){return Hh||(Hh=1,(function(e,n){const{MAX_SAFE_COMPONENT_LENGTH:a,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:c}=ex(),m=J0();n=e.exports={};const y=n.re=[],h=n.safeRe=[],l=n.src=[],f=n.safeSrc=[],u=n.t={};let p=0;const x="[a-zA-Z0-9-]",v=[["\\s",1],["\\d",c],[x,o]],_=M=>{for(const[T,A]of v)M=M.split(`${T}*`).join(`${T}{0,${A}}`).split(`${T}+`).join(`${T}{1,${A}}`);return M},k=(M,T,A)=>{const C=_(T),O=p++;m(M,O,T),u[M]=O,l[O]=T,f[O]=C,y[O]=new RegExp(T,A?"g":void 0),h[O]=new RegExp(C,A?"g":void 0)};k("NUMERICIDENTIFIER","0|[1-9]\\d*"),k("NUMERICIDENTIFIERLOOSE","\\d+"),k("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${x}*`),k("MAINVERSION",`(${l[u.NUMERICIDENTIFIER]})\\.(${l[u.NUMERICIDENTIFIER]})\\.(${l[u.NUMERICIDENTIFIER]})`),k("MAINVERSIONLOOSE",`(${l[u.NUMERICIDENTIFIERLOOSE]})\\.(${l[u.NUMERICIDENTIFIERLOOSE]})\\.(${l[u.NUMERICIDENTIFIERLOOSE]})`),k("PRERELEASEIDENTIFIER",`(?:${l[u.NONNUMERICIDENTIFIER]}|${l[u.NUMERICIDENTIFIER]})`),k("PRERELEASEIDENTIFIERLOOSE",`(?:${l[u.NONNUMERICIDENTIFIER]}|${l[u.NUMERICIDENTIFIERLOOSE]})`),k("PRERELEASE",`(?:-(${l[u.PRERELEASEIDENTIFIER]}(?:\\.${l[u.PRERELEASEIDENTIFIER]})*))`),k("PRERELEASELOOSE",`(?:-?(${l[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[u.PRERELEASEIDENTIFIERLOOSE]})*))`),k("BUILDIDENTIFIER",`${x}+`),k("BUILD",`(?:\\+(${l[u.BUILDIDENTIFIER]}(?:\\.${l[u.BUILDIDENTIFIER]})*))`),k("FULLPLAIN",`v?${l[u.MAINVERSION]}${l[u.PRERELEASE]}?${l[u.BUILD]}?`),k("FULL",`^${l[u.FULLPLAIN]}$`),k("LOOSEPLAIN",`[v=\\s]*${l[u.MAINVERSIONLOOSE]}${l[u.PRERELEASELOOSE]}?${l[u.BUILD]}?`),k("LOOSE",`^${l[u.LOOSEPLAIN]}$`),k("GTLT","((?:<|>)?=?)"),k("XRANGEIDENTIFIERLOOSE",`${l[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),k("XRANGEIDENTIFIER",`${l[u.NUMERICIDENTIFIER]}|x|X|\\*`),k("XRANGEPLAIN",`[v=\\s]*(${l[u.XRANGEIDENTIFIER]})(?:\\.(${l[u.XRANGEIDENTIFIER]})(?:\\.(${l[u.XRANGEIDENTIFIER]})(?:${l[u.PRERELEASE]})?${l[u.BUILD]}?)?)?`),k("XRANGEPLAINLOOSE",`[v=\\s]*(${l[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[u.XRANGEIDENTIFIERLOOSE]})(?:${l[u.PRERELEASELOOSE]})?${l[u.BUILD]}?)?)?`),k("XRANGE",`^${l[u.GTLT]}\\s*${l[u.XRANGEPLAIN]}$`),k("XRANGELOOSE",`^${l[u.GTLT]}\\s*${l[u.XRANGEPLAINLOOSE]}$`),k("COERCEPLAIN",`(^|[^\\d])(\\d{1,${a}})(?:\\.(\\d{1,${a}}))?(?:\\.(\\d{1,${a}}))?`),k("COERCE",`${l[u.COERCEPLAIN]}(?:$|[^\\d])`),k("COERCEFULL",l[u.COERCEPLAIN]+`(?:${l[u.PRERELEASE]})?(?:${l[u.BUILD]})?(?:$|[^\\d])`),k("COERCERTL",l[u.COERCE],!0),k("COERCERTLFULL",l[u.COERCEFULL],!0),k("LONETILDE","(?:~>?)"),k("TILDETRIM",`(\\s*)${l[u.LONETILDE]}\\s+`,!0),n.tildeTrimReplace="$1~",k("TILDE",`^${l[u.LONETILDE]}${l[u.XRANGEPLAIN]}$`),k("TILDELOOSE",`^${l[u.LONETILDE]}${l[u.XRANGEPLAINLOOSE]}$`),k("LONECARET","(?:\\^)"),k("CARETTRIM",`(\\s*)${l[u.LONECARET]}\\s+`,!0),n.caretTrimReplace="$1^",k("CARET",`^${l[u.LONECARET]}${l[u.XRANGEPLAIN]}$`),k("CARETLOOSE",`^${l[u.LONECARET]}${l[u.XRANGEPLAINLOOSE]}$`),k("COMPARATORLOOSE",`^${l[u.GTLT]}\\s*(${l[u.LOOSEPLAIN]})$|^$`),k("COMPARATOR",`^${l[u.GTLT]}\\s*(${l[u.FULLPLAIN]})$|^$`),k("COMPARATORTRIM",`(\\s*)${l[u.GTLT]}\\s*(${l[u.LOOSEPLAIN]}|${l[u.XRANGEPLAIN]})`,!0),n.comparatorTrimReplace="$1$2$3",k("HYPHENRANGE",`^\\s*(${l[u.XRANGEPLAIN]})\\s+-\\s+(${l[u.XRANGEPLAIN]})\\s*$`),k("HYPHENRANGELOOSE",`^\\s*(${l[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[u.XRANGEPLAINLOOSE]})\\s*$`),k("STAR","(<|>)?=?\\s*\\*"),k("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),k("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Oi,Oi.exports)),Oi.exports}var iu,Bh;function TM(){if(Bh)return iu;Bh=1;const e=Object.freeze({loose:!0}),n=Object.freeze({});return iu=o=>o?typeof o!="object"?e:o:n,iu}var lu,Wh;function SM(){if(Wh)return lu;Wh=1;const e=/^[0-9]+$/,n=(o,c)=>{if(typeof o=="number"&&typeof c=="number")return o===c?0:o<c?-1:1;const m=e.test(o),y=e.test(c);return m&&y&&(o=+o,c=+c),o===c?0:m&&!y?-1:y&&!m?1:o<c?-1:1};return lu={compareIdentifiers:n,rcompareIdentifiers:(o,c)=>n(c,o)},lu}var cu,qh;function NM(){if(qh)return cu;qh=1;const e=J0(),{MAX_LENGTH:n,MAX_SAFE_INTEGER:a}=ex(),{safeRe:o,t:c}=EM(),m=TM(),{compareIdentifiers:y}=SM();class h{constructor(f,u){if(u=m(u),f instanceof h){if(f.loose===!!u.loose&&f.includePrerelease===!!u.includePrerelease)return f;f=f.version}else if(typeof f!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof f}".`);if(f.length>n)throw new TypeError(`version is longer than ${n} characters`);e("SemVer",f,u),this.options=u,this.loose=!!u.loose,this.includePrerelease=!!u.includePrerelease;const p=f.trim().match(u.loose?o[c.LOOSE]:o[c.FULL]);if(!p)throw new TypeError(`Invalid Version: ${f}`);if(this.raw=f,this.major=+p[1],this.minor=+p[2],this.patch=+p[3],this.major>a||this.major<0)throw new TypeError("Invalid major version");if(this.minor>a||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>a||this.patch<0)throw new TypeError("Invalid patch version");p[4]?this.prerelease=p[4].split(".").map(x=>{if(/^[0-9]+$/.test(x)){const v=+x;if(v>=0&&v<a)return v}return x}):this.prerelease=[],this.build=p[5]?p[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(f){if(e("SemVer.compare",this.version,this.options,f),!(f instanceof h)){if(typeof f=="string"&&f===this.version)return 0;f=new h(f,this.options)}return f.version===this.version?0:this.compareMain(f)||this.comparePre(f)}compareMain(f){return f instanceof h||(f=new h(f,this.options)),this.major<f.major?-1:this.major>f.major?1:this.minor<f.minor?-1:this.minor>f.minor?1:this.patch<f.patch?-1:this.patch>f.patch?1:0}comparePre(f){if(f instanceof h||(f=new h(f,this.options)),this.prerelease.length&&!f.prerelease.length)return-1;if(!this.prerelease.length&&f.prerelease.length)return 1;if(!this.prerelease.length&&!f.prerelease.length)return 0;let u=0;do{const p=this.prerelease[u],x=f.prerelease[u];if(e("prerelease compare",u,p,x),p===void 0&&x===void 0)return 0;if(x===void 0)return 1;if(p===void 0)return-1;if(p===x)continue;return y(p,x)}while(++u)}compareBuild(f){f instanceof h||(f=new h(f,this.options));let u=0;do{const p=this.build[u],x=f.build[u];if(e("build compare",u,p,x),p===void 0&&x===void 0)return 0;if(x===void 0)return 1;if(p===void 0)return-1;if(p===x)continue;return y(p,x)}while(++u)}inc(f,u,p){if(f.startsWith("pre")){if(!u&&p===!1)throw new Error("invalid increment argument: identifier is empty");if(u){const x=`-${u}`.match(this.options.loose?o[c.PRERELEASELOOSE]:o[c.PRERELEASE]);if(!x||x[1]!==u)throw new Error(`invalid identifier: ${u}`)}}switch(f){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",u,p);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",u,p);break;case"prepatch":this.prerelease.length=0,this.inc("patch",u,p),this.inc("pre",u,p);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",u,p),this.inc("pre",u,p);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const x=Number(p)?1:0;if(this.prerelease.length===0)this.prerelease=[x];else{let v=this.prerelease.length;for(;--v>=0;)typeof this.prerelease[v]=="number"&&(this.prerelease[v]++,v=-2);if(v===-1){if(u===this.prerelease.join(".")&&p===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(x)}}if(u){let v=[u,x];p===!1&&(v=[u]),y(this.prerelease[0],u)===0?isNaN(this.prerelease[1])&&(this.prerelease=v):this.prerelease=v}break}default:throw new Error(`invalid increment argument: ${f}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return cu=h,cu}var uu,Yh;function AM(){if(Yh)return uu;Yh=1;const e=NM();return uu=(a,o,c=!1)=>{if(a instanceof e)return a;try{return new e(a,o)}catch(m){if(!c)return null;throw m}},uu}var IM=AM();const CM=Pg(IM);function Gh(e){if(!e)return"";const n=e.replace("+moya","");try{const o=CM(n,{includePrerelease:!0})?.prerelease;if(o&&o?.length>0){const m=String(o[0]).split("-")[1];return!m||!m.startsWith("g")?"":`https://github.com/TryGhost/Ghost/commit/${m.slice(1)}`}return`https://github.com/TryGhost/Ghost/releases/tag/v${n}`}catch{return""}}function DM(e,n){const a=!!e.match?.(/production/i);return!!(a&&n!=="mysql8"||!a&&n==="mysql5")}const RM=ye.create(({})=>{const{updateRoute:e}=Qe();let a=Je().config;const o=z_();function c(){return new Date().getFullYear()}function m(){return!!a.enableDeveloperExperiments}function y(){return!a.hostSettings?.siteId}return s.jsx(yt,{afterClose:()=>{e("")},cancelLabel:"",footer:s.jsx(s.Fragment,{}),topRightContent:"close",width:540,children:s.jsxs("div",{className:"flex flex-col gap-4 pb-7 text-sm",children:[s.jsx(H_,{className:"h-auto w-[120px] dark:invert"}),s.jsxs("div",{className:"mt-3 flex flex-col gap-1.5",children:[o?.message&&s.jsxs("div",{className:"gh-prose-links mb-4 rounded-sm border border-green p-5",children:[s.jsx("strong",{children:"Update available!"}),s.jsx("div",{dangerouslySetInnerHTML:{__html:o.message}})]}),Gh(a.version)&&s.jsxs("div",{children:[s.jsx("strong",{children:"Version:"})," ",s.jsx("a",{className:"text-green",href:Gh(a.version),rel:"noopener noreferrer",target:"_blank",children:a.version})]})||s.jsxs("div",{children:[s.jsx("strong",{children:"Version:"})," ",a.version]}),y()&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Environment:"})," ",a.environment]}),s.jsxs("div",{children:[s.jsx("strong",{children:"Database:"})," ",a.database]}),s.jsxs("div",{children:[s.jsx("strong",{children:"Mail:"})," ",a.mail?a.mail:"Native"]})]}),m()&&s.jsxs("div",{children:[s.jsx("strong",{children:"Developer experiments:"})," Enabled"]}),y()&&DM(a.environment,a.database)&&s.jsxs("div",{className:"text-red-500 dark:text-red-400",children:["You are running an unsupported database in production. Please ",s.jsx("a",{href:"https://ghost.org/docs/faq/supported-databases/",rel:"noopener noreferrer",target:"_blank",children:"upgrade to MySQL 8"}),"."]})]}),s.jsx(Va,{}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://ghost.org/docs/",rel:"noopener noreferrer",target:"_blank",children:[s.jsx(ut,{name:"book-open",size:"sm"})," User documentation"]}),s.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://forum.ghost.org/",rel:"noopener noreferrer",target:"_blank",children:[s.jsx(ut,{name:"question-circle",size:"sm"})," Get help with Ghost"]}),s.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://ghost.org/docs/contributing/",rel:"noopener noreferrer",target:"_blank",children:[s.jsx(ut,{name:"angle-brackets",size:"sm"})," Get involved"]})]}),s.jsx(Va,{}),s.jsxs("p",{className:"max-w-[460px] text-xs",children:["Copyright © 2013 – ",c()," Ghost Foundation, released under the ",s.jsx("a",{className:"text-green",href:"https://github.com/TryGhost/Ghost/blob/main/LICENSE",rel:"noopener noreferrer",target:"_blank",children:"MIT license"}),". ",s.jsx("a",{className:"text-green",href:"https://ghost.org/",rel:"noopener noreferrer",target:"_blank",children:"Ghost"})," is a registered trademark of ",s.jsx("a",{className:"text-green",href:"https://ghost.org/trademark/",rel:"noopener noreferrer",target:"_blank",children:"Ghost Foundation Ltd"}),"."]})]})})}),OM=()=>{const e=Zt(),{updateRoute:n}=Qe(),[a,o]=D.useState(""),[c,m]=D.useState({name:""}),{mutateAsync:y}=B_(),h=Ys(),l=ot();return D.useEffect(()=>{h?.isLimited("customIntegrations")&&h.errorIfWouldGoOverLimit("customIntegrations").catch(f=>{f instanceof Gs&&(ye.show(Xr,{prompt:f.message||"Your current plan doesn't support more custom integrations.",onOk:()=>n({route:"/pro",isExternal:!0})}),e.remove(),n("integrations"))})},[h,e,n]),s.jsx(yt,{afterClose:()=>{n("integrations")},okColor:"black",okLabel:"Add",size:"sm",testId:"add-integration-modal",title:"Add integration",onOk:async()=>{if(!a){m({name:"Name is required"});return}try{const f=await y({name:a});e.remove(),n({route:`integrations/${f.integrations[0].id}`})}catch(f){l(f)}},children:s.jsx("div",{className:"mt-5",children:s.jsx(tt,{marginBottom:!1,marginTop:!1,children:s.jsx(Ae,{autoFocus:!0,error:!!c.name,hint:c.name,maxLength:191,placeholder:"Custom integration",title:"Name",value:a,onChange:f=>o(f.target.value),onInput:()=>{c.name&&m({name:""})}})})})})},$M=ye.create(OM),LM=()=>{const e=Zt(),{updateRoute:n}=Qe(),a=ot(),[o,c]=D.useState(!0),[m,y]=D.useState(null),{data:h}=Fg({searchParams:{filter:"newsletters.status:active+email_disabled:0",limit:"1",page:"1",include:"newsletters,labels"}}),{mutateAsync:l}=T2(),{formState:f,updateForm:u,saveState:p,handleSave:x,errors:v,clearError:_}=kr({initialState:{name:"",description:"",optInExistingSubscribers:!0},onSave:async()=>{const T=await l({name:f.name,description:f.description,opt_in_existing:f.optInExistingSubscribers,feedback_enabled:!0});n({route:`newsletters/${T.newsletters[0].id}`})},onSaveError:a,onValidate:()=>{const T={};return f.name||(T.name="A name is required for your newsletter"),T}}),k=Ys();D.useEffect(()=>{if(!k){c(!1);return}k.errorIfWouldGoOverLimit("newsletters").catch(T=>{if(T instanceof Gs)y(T);else throw T}).finally(()=>{c(!1)})},[k]);const M=h?.meta?.pagination.total;return D.useEffect(()=>{m&&(ye.show(Xr,{prompt:m.message||"Your current plan doesn't support more newsletters.",onOk:()=>n({route:"/pro",isExternal:!0})}),e.remove(),n("newsletters"))},[m,e,n]),o||m?null:s.jsx(yt,{afterClose:()=>{n("newsletters")},backDropClick:!1,okColor:"black",okDisabled:p==="saving",okLabel:"Create",okLoading:p==="saving",size:"sm",testId:"add-newsletter-modal",title:"Create newsletter",onOk:async()=>{await x()&&e.remove()},children:s.jsxs(tt,{marginBottom:!1,marginTop:!0,children:[s.jsx(Ae,{autoFocus:!0,error:!!v.name,hint:v.name,maxLength:191,placeholder:"Weekly roundup",title:"Name",value:f.name,onChange:T=>u(A=>({...A,name:T.target.value})),onKeyDown:()=>_("name")}),s.jsx($n,{maxLength:2e3,title:"Description",value:f.description,onChange:T=>u(A=>({...A,description:T.target.value}))}),s.jsx(st,{checked:f.optInExistingSubscribers,direction:"rtl",hint:f.optInExistingSubscribers?`This newsletter will be available to all members. Your ${M===void 0?"":Wg(M)} existing subscriber${h?.meta?.pagination.total===1?"":"s"} will also be opted-in to receive it.`:"The newsletter will be available to all new members. Existing members won’t be subscribed, but may visit their account area to opt-in to future emails.",label:"Opt-in existing subscribers",labelStyle:"heading",onChange:T=>u(A=>({...A,optInExistingSubscribers:T.target.checked}))})]})})},PM=ye.create(LM),FM=({recommendation:e,animate:n})=>{const a=Zt(),{updateRoute:o,route:c}=Qe(),{mutateAsync:m}=W_(),y=ot(),{formState:h,updateForm:l,handleSave:f,saveState:u,errors:p,clearError:x,setErrors:v}=kr({initialState:{...e},onSave:async T=>{await m(T),a.remove(),xt({title:"Recommendation added",type:"success"}),Y_("Recommendation Added",{oneClickSubscribe:T.one_click_subscribe}),o("recommendations")},onSaveError:y,onValidate:T=>q_(T)});let _="Add",k=!1;u==="saving"?k=!0:u==="saved"&&(_="Added");let M={label:"Back",icon:"arrow-left",iconColorClass:"text-black dark:text-white",link:!0,size:"sm",onClick:()=>{u!=="saving"&&(a.remove(),ye.show(tx,{pathName:c,animate:!1,recommendation:{...h}}))}};return s.jsx(yt,{afterClose:()=>{o("recommendations")},animate:n??!0,backDropClick:!1,cancelLabel:"Cancel",dirty:!0,leftButtonProps:M,okColor:"black",okLabel:_,okLoading:k,size:"sm",testId:"add-recommendation-modal",title:"Add recommendation",stickyFooter:!0,onCancel:()=>{u!=="saving"&&(a.remove(),o("recommendations"))},onOk:async()=>{if(u!=="saving"){Ug();try{await f({force:!0})}catch{xt({type:"error",title:"Something went wrong when adding this recommendation, please try again."})}}},children:s.jsx(G_,{clearError:x,errors:p,formState:h,setErrors:v,showURL:!1,updateForm:l})})},UM=ye.create(FM),Xh=e=>Bi(e).save||"",zM=function(e,n){try{new URL(n).hostname.includes(".")?delete e.url:e.url="Enter a valid URL"}catch{e.url="Enter a valid URL"}return e},HM=({searchParams:e,recommendation:n,animate:a})=>{const[o,c]=D.useState(!1),m=Zt(),{updateRoute:y}=Qe(),{mutateAsync:h}=X_(),l=n?"":e?.get("url")??"",{save:f}=l?Bi(l):{save:""},u=at.useRef(!1),[p,x]=at.useState(!!f),{formState:v,updateForm:_,handleSave:k,errors:M,saveState:T,clearError:A}=kr({initialState:n??{title:"",url:f||"",description:"",excerpt:null,featured_image:null,favicon:null,one_click_subscribe:!1},onSave:async()=>{let O;O=new URL(v.url);const $=O.hostname.replace("www.",""),W={...v,url:O.toString()},{recommendations:R=[]}=await h(O);if(!R||R.length===0)return;const Z=R[0];if(Z.id)throw new ah("A recommendation with this URL already exists.");W.title=Z.title??$,W.excerpt=Z.excerpt??W.excerpt,W.featured_image=Z.featured_image??W.featured_image??null,W.favicon=Z.favicon??W.favicon??null,W.one_click_subscribe=Z.one_click_subscribe??W.one_click_subscribe??!1,W.description=W.excerpt||null,m.remove(),ye.show(UM,{animate:!1,recommendation:W})},onValidate:()=>{const O={};return zM(O,v.url),p&&x(Object.keys(O).length===0),O}}),C=at.useCallback(async()=>{if(T!=="saving"){Ug();try{if(await k({force:!0}))return}catch(O){const $=O instanceof ah?O.message:"Something went wrong while checking this URL, please try again.";xt({type:"error",title:$})}p&&x(!1)}},[k,T,p,x]);return at.useEffect(()=>{p&&!u.current&&(u.current=!0,C())},[p,C]),D.useEffect(()=>{o&&(C(),c(!1))},[v]),p?s.jsx(yt,{afterClose:()=>{y("recommendations")},animate:a??!0,backDropClick:!1,footer:!1,header:!1,size:"sm",children:s.jsx("div",{className:"flex flex-col items-center justify-center p-8",children:s.jsx(Wi,{})})}):s.jsxs(yt,{afterClose:()=>{y("recommendations")},animate:a??!0,backDropClick:!1,okColor:"black",okLabel:"Next",okLoading:T==="saving",size:"sm",testId:"add-recommendation-modal",title:"Add recommendation",onOk:C,children:[s.jsxs("p",{className:"mt-4",children:["You can recommend ",s.jsx("strong",{children:"any site"})," your audience will find valuable, not just those published on Ghost."]}),s.jsx(tt,{marginBottom:!1,marginTop:!0,children:s.jsx(Ae,{autoFocus:!0,error:!!M.url,hint:M.url||s.jsxs(s.Fragment,{children:["Need inspiration? ",s.jsx("a",{className:"text-green",href:"https://www.ghost.org/explore",rel:"noopener noreferrer",target:"_blank",children:"Explore thousands of sites"})," to recommend"]}),maxLength:2e3,placeholder:"https://www.example.com",title:"URL",value:v.url,onBlur:()=>{const O=Xh(v.url);_($=>({...$,url:O}))},onChange:O=>{A?.("url"),_($=>({...$,url:O.target.value}))},onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),_($=>({...$,url:Xh(v.url)})),c(!0))}})})]})},tx=ye.create(HM);function BM(e,n){let a;return function(...c){const m=()=>{clearTimeout(a),e(...c)};clearTimeout(a),a=setTimeout(m,n)}}const pd=({generateContent:e,className:n,height:a,width:o,parentClassName:c,testId:m,addDelay:y=!1})=>{const[h,l]=D.useState(0),f=[D.useRef(null),D.useRef(null)],[u,p]=D.useState(0);return D.useEffect(()=>{const x=h===0?1:0,v=f[x].current;if(v){e(v);const _=()=>{y?setTimeout(()=>{l(x)},500):l(x)};return v.addEventListener("load",_),()=>{v.removeEventListener("load",_)}}},[e]),D.useEffect(()=>{const x=f[h].current,v=BM(()=>{p(x?.contentWindow?.scrollY||0)},250);return x?.contentWindow?.addEventListener("scroll",v),()=>{x?.contentWindow?.removeEventListener("scroll",v)}},[h,f]),D.useEffect(()=>{const x=f[h].current;if(x)try{x.contentWindow?.scrollTo(0,u)}catch(v){m_(v)}},[u,h,f]),s.jsxs("div",{className:c,"data-testid":m,children:[s.jsx("iframe",{ref:f[0],className:`${n} ${h!==0?"z-10 opacity-0":"z-20 opacity-100"}`,"data-visible":h===0,frameBorder:"0",height:a,title:"Buffered Preview 1",width:o}),s.jsx("iframe",{ref:f[1],className:`${n} ${h!==1?"z-10 opacity-0":"z-20 opacity-100"}`,"data-visible":h===1,frameBorder:"0",height:a,title:"Buffered Preview 2",width:o})]})},WM=(e,n,a)=>{const o=new URLSearchParams;return o.append("announcement_bg",e||"accent"),o.append("announcement",n||""),a&&a.length>0&&o.append("announcement_vis",a?.join(",")||""),o.toString()},qM=({announcementBackgroundColor:e,announcementContent:n,url:a,visibility:o})=>{const c=D.useMemo(()=>o,[o?.join(",")]),m=D.useCallback(y=>{a&&fetch(a,{method:"POST",headers:{"Content-Type":"text/html;charset=utf-8","x-ghost-preview":WM(e,n,c),Accept:"text/plain"},mode:"cors",credentials:"include"}).then(h=>h.text()).then(h=>{const l="html { pointer-events: none; }",u=new DOMParser().parseFromString(h,"text/html"),p=u.querySelector("style"),x=p.innerHTML;p.innerHTML=`${x}
1
+ import{j as s,r as D,aH as we,e as at,d7 as i_,av as $g,aq as l_,ar as c_,as as Lg,aw as u_,au as Vi,aE as Kf,ax as f_,ay as Sf,az as d_,aF as p_,aG as h_,d8 as ut,ad as ns,bM as ot,d9 as no,da as Rn,db as gt,dc as xt,cF as Pg,cW as Fg,dd as Ug,de as ah,df as m_,dg as ln,dh as g_,di as ts,aB as x_,dj as b_,d6 as Zf,d5 as Hs,dk as Ha,ak as v_,aN as w_,dl as y_,dm as Qi,dn as Vf,dp as oh,dq as dr,dr as Za,ds as Nf,dt as __,du as Ws,dv as k_,dw as M_,dx as j_,dy as Hi,dz as E_,dA as T_,dB as Af,ac as S_,dC as N_,dD as A_,dE as I_,dF as C_,dG as Nn,dH as ih,dI as lh,dJ as D_}from"./index-CMTzNTew.js";import{H as bt,a as Gr,S as Va,B as Ue,x as Ji,K as R_,y as Zt,z as O_,A as Lt,M as yt,C as an,F as $_,G as Dn,J as zg,O as L_,Q as el,U as ye,V as Qe,W as P_,X as Qf,Y as Je,Z as cn,_ as On,$ as Et,a0 as Nt,a1 as ss,a2 as kr,a3 as F_,a4 as ch,a5 as tt,a6 as Ae,a7 as uh,a8 as fh,a9 as st,aa as Hg,ab as Bg,ac as U_,ad as z_,ae as H_,af as B_,ag as Ys,ah as Gs,ai as Xr,aj as $n,ak as Wg,al as W_,am as q_,an as Y_,ao as G_,ap as X_,aq as Bi,ar as Wi,as as K_,at as dh,au as ph,av as Z_,aw as Xs,ax as un,ay as on,az as qg,aA as V_,aB as Q_,aC as J_,aD as Yg,aE as Jf,aF as e2,aG as t2,aH as r2,aI as qi,aJ as ed,aK as n2,aL as td,aM as s2,aN as a2,aO as Gg,aP as Xg,aQ as rd,aR as o2,aS as i2,aT as l2,aU as Kg,aV as Zg,aW as c2,aX as u2,aY as hh,aZ as Vg,a_ as Qg,a$ as Jg,b0 as If,b1 as f2,b2 as d2,b3 as p2,b4 as e0,b5 as h2,b6 as m2,b7 as g2,b8 as t0,b9 as x2,ba as b2,bb as v2,bc as r0,bd as nd,be as w2,bf as sd,bg as y2,bh as _2,bi as n0,bj as k2,bk as s0,bl as M2,bm as j2,bn as E2}from"./settings-BeumESEN.js";import{a as T2,u as a0,b as o0}from"./newsletters-BexdXUhn.js";import{C as S2,a as N2}from"./index-Brg4tecQ.js";import{u as i0}from"./posts-CL9UDYoW.js";import{a as so,b as ad,c as A2,g as od}from"./tiers-nCGyTly9.js";import"./index-D212VvOz.js";function I2(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const l0=({children:e,...n})=>s.jsx("div",{className:"flex h-full w-full flex-col px-8",...n,children:s.jsx("div",{className:"h-full w-full overflow-hidden rounded-t-[4px] shadow-sm",children:e})}),c0=({children:e,...n})=>s.jsx("div",{className:"flex h-[775px] w-[380px] flex-col rounded-3xl bg-white p-2 shadow-xl dark:bg-grey-900",...n,children:s.jsx("div",{className:"w-100 h-100 grow overflow-auto rounded-2xl border border-grey-100 dark:border-grey-950",children:e})}),C2=({title:e,label:n,value:a,onChange:o,disabled:c,error:m,hint:y,checked:h,separator:l,testId:f})=>{const u=D.useId(),p=x=>{o(x===!0)};return s.jsxs("div",{children:[s.jsxs("div",{className:`flex flex-col gap-1 ${l&&"pb-2"}`,children:[e&&s.jsx(bt,{grey:!0,level:6,children:e}),s.jsxs("label",{className:`flex cursor-pointer items-start ${e&&"-mb-1 mt-1"}`,htmlFor:u,children:[s.jsx(S2,{className:"mt-0.5 flex size-4 cursor-pointer appearance-none items-center justify-center rounded-[3px] border border-solid border-grey-500 bg-white outline-none data-[state=checked]:border-black data-[state=indeterminate]:border-black data-[state=checked]:bg-black data-[state=indeterminate]:bg-black","data-testid":f,defaultChecked:h,disabled:c,id:u,value:a,onCheckedChange:p,children:s.jsx(N2,{children:s.jsx("svg",{fill:"none",height:"11",viewBox:"0 0 10 11",width:"10",children:s.jsx("path",{d:"M1 5.88889L4.6 9L9 1",stroke:"white",strokeLinecap:"round",strokeWidth:"2"})})})}),s.jsxs("div",{className:`ml-2 flex flex-col ${y&&"mb-2"}`,children:[s.jsx("span",{className:`inline-block text-[1.425rem] dark:text-white ${y&&"-mb-1"}`,children:n}),y&&s.jsx(Gr,{color:m?"red":"",children:y})]})]})]}),(l||m)&&s.jsx(Va,{className:m?"border-red":""})]})},Cf=({title:e,checkboxes:n,hint:a,error:o})=>s.jsxs("div",{children:[e&&s.jsx(bt,{grey:!0,level:6,children:e}),s.jsx("div",{className:"mt-2 flex flex-col gap-1",children:n?.map(({key:c,...m})=>s.jsx(C2,{...m},c))}),s.jsx("div",{className:`flex flex-col ${a&&"mb-2"}`,children:a&&s.jsx(Gr,{color:o?"red":"",children:a})})]}),D2=({hex:e,value:n,title:a,size:o="md",isSelected:c,onSelect:m})=>{const y=D.useRef(null),h=u=>{u.preventDefault(),m(n!==void 0?n:e)},l=e.length===4&&e[3]==="0"||e.length===8&&e.slice(6)==="00";let f="h-5 w-5";switch(o){case"lg":f="w-6 h-6";break}return s.jsx("button",{ref:y,className:we("relative flex shrink-0 cursor-pointer items-center rounded-full border border-grey-300 dark:border-grey-800",f,c&&"outline outline-2 outline-green"),style:{backgroundColor:e},title:a,type:"button",onClick:h,children:l&&s.jsx("div",{className:"absolute left-0 top-0 z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})})},u0=({title:e,value:n,swatches:a,swatchSize:o="md",onSwatchChange:c,onTogglePicker:m,isExpanded:y,picker:h=!0,containerClassName:l})=>{const f=a.find(p=>p.value===n||p.hex===n);l=we("flex flex-col gap-3");const u=y||!h;return s.jsxs("div",{className:l,children:[e&&s.jsx(bt,{useLabelTag:!0,children:e}),s.jsxs("div",{className:"flex gap-1",children:[u&&s.jsx("div",{className:"flex items-center gap-1",children:a.map(({customContent:p,...x})=>p?s.jsx(D.Fragment,{children:p},x.title):s.jsx(D2,{isSelected:f?.title===x.title,size:o,onSelect:c,...x},x.title))}),h&&s.jsxs("button",{"aria-label":"Pick color",className:"relative size-6 cursor-pointer rounded-full border border-grey-250 dark:border-grey-800",type:"button",onClick:m,children:[s.jsx("div",{className:"absolute inset-0 rounded-full bg-[conic-gradient(hsl(360,100%,50%),hsl(315,100%,50%),hsl(270,100%,50%),hsl(225,100%,50%),hsl(180,100%,50%),hsl(135,100%,50%),hsl(90,100%,50%),hsl(45,100%,50%),hsl(0,100%,50%))]"}),f&&s.jsx("div",{className:"absolute inset-[3px] overflow-hidden rounded-full border border-white dark:border-grey-950",style:{backgroundColor:f.hex},children:f.hex==="transparent"&&s.jsx("div",{className:"absolute left-[3px] top-[3px] z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})}),!f&&n&&s.jsx("div",{className:"absolute inset-[3px] overflow-hidden rounded-full border border-white dark:border-grey-950",style:{backgroundColor:n},children:n==="transparent"&&s.jsx("div",{className:"absolute left-[3px] top-[3px] z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})})]})]})]})};function Ks(){return(Ks=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o])}return e}).apply(this,arguments)}function tl(e,n){if(e==null)return{};var a,o,c={},m=Object.keys(e);for(o=0;o<m.length;o++)n.indexOf(a=m[o])>=0||(c[a]=e[a]);return c}function Qa(e){var n=D.useRef(e),a=D.useRef(function(o){n.current&&n.current(o)});return n.current=e,a.current}var Ja=function(e,n,a){return n===void 0&&(n=0),a===void 0&&(a=1),e>a?a:e<n?n:e},Xa=function(e){return"touches"in e},Df=function(e){return e&&e.ownerDocument.defaultView||self},mh=function(e,n,a){var o=e.getBoundingClientRect(),c=Xa(n)?(function(m,y){for(var h=0;h<m.length;h++)if(m[h].identifier===y)return m[h];return m[0]})(n.touches,a):n;return{left:Ja((c.pageX-(o.left+Df(e).pageXOffset))/o.width),top:Ja((c.pageY-(o.top+Df(e).pageYOffset))/o.height)}},gh=function(e){!Xa(e)&&e.preventDefault()},f0=at.memo(function(e){var n=e.onMove,a=e.onKey,o=tl(e,["onMove","onKey"]),c=D.useRef(null),m=Qa(n),y=Qa(a),h=D.useRef(null),l=D.useRef(!1),f=D.useMemo(function(){var v=function(M){gh(M),(Xa(M)?M.touches.length>0:M.buttons>0)&&c.current?m(mh(c.current,M,h.current)):k(!1)},_=function(){return k(!1)};function k(M){var T=l.current,A=Df(c.current),C=M?A.addEventListener:A.removeEventListener;C(T?"touchmove":"mousemove",v),C(T?"touchend":"mouseup",_)}return[function(M){var T=M.nativeEvent,A=c.current;if(A&&(gh(T),!(function(O,$){return $&&!Xa(O)})(T,l.current)&&A)){if(Xa(T)){l.current=!0;var C=T.changedTouches||[];C.length&&(h.current=C[0].identifier)}A.focus(),m(mh(A,T,h.current)),k(!0)}},function(M){var T=M.which||M.keyCode;T<37||T>40||(M.preventDefault(),y({left:T===39?.05:T===37?-.05:0,top:T===40?.05:T===38?-.05:0}))},k]},[y,m]),u=f[0],p=f[1],x=f[2];return D.useEffect(function(){return x},[x]),at.createElement("div",Ks({},o,{onTouchStart:u,onMouseDown:u,className:"react-colorful__interactive",ref:c,onKeyDown:p,tabIndex:0,role:"slider"}))}),id=function(e){return e.filter(Boolean).join(" ")},d0=function(e){var n=e.color,a=e.left,o=e.top,c=o===void 0?.5:o,m=id(["react-colorful__pointer",e.className]);return at.createElement("div",{className:m,style:{top:100*c+"%",left:100*a+"%"}},at.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:n}}))},Yt=function(e,n,a){return n===void 0&&(n=0),a===void 0&&(a=Math.pow(10,n)),Math.round(a*e)/a},R2=function(e){return F2(Rf(e))},Rf=function(e){return e[0]==="#"&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?Yt(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?Yt(parseInt(e.substring(6,8),16)/255,2):1}},O2=function(e){return P2(L2(e))},$2=function(e){var n=e.s,a=e.v,o=e.a,c=(200-n)*a/100;return{h:Yt(e.h),s:Yt(c>0&&c<200?n*a/100/(c<=100?c:200-c)*100:0),l:Yt(c/2),a:Yt(o,2)}},Of=function(e){var n=$2(e);return"hsl("+n.h+", "+n.s+"%, "+n.l+"%)"},L2=function(e){var n=e.h,a=e.s,o=e.v,c=e.a;n=n/360*6,a/=100,o/=100;var m=Math.floor(n),y=o*(1-a),h=o*(1-(n-m)*a),l=o*(1-(1-n+m)*a),f=m%6;return{r:Yt(255*[o,h,y,y,l,o][f]),g:Yt(255*[l,o,o,h,y,y][f]),b:Yt(255*[y,y,l,o,o,h][f]),a:Yt(c,2)}},Di=function(e){var n=e.toString(16);return n.length<2?"0"+n:n},P2=function(e){var n=e.r,a=e.g,o=e.b,c=e.a,m=c<1?Di(Yt(255*c)):"";return"#"+Di(n)+Di(a)+Di(o)+m},F2=function(e){var n=e.r,a=e.g,o=e.b,c=e.a,m=Math.max(n,a,o),y=m-Math.min(n,a,o),h=y?m===n?(a-o)/y:m===a?2+(o-n)/y:4+(n-a)/y:0;return{h:Yt(60*(h<0?h+6:h)),s:Yt(m?y/m*100:0),v:Yt(m/255*100),a:c}},U2=at.memo(function(e){var n=e.hue,a=e.onChange,o=id(["react-colorful__hue",e.className]);return at.createElement("div",{className:o},at.createElement(f0,{onMove:function(c){a({h:360*c.left})},onKey:function(c){a({h:Ja(n+360*c.left,0,360)})},"aria-label":"Hue","aria-valuenow":Yt(n),"aria-valuemax":"360","aria-valuemin":"0"},at.createElement(d0,{className:"react-colorful__hue-pointer",left:n/360,color:Of({h:n,s:100,v:100,a:1})})))}),z2=at.memo(function(e){var n=e.hsva,a=e.onChange,o={backgroundColor:Of({h:n.h,s:100,v:100,a:1})};return at.createElement("div",{className:"react-colorful__saturation",style:o},at.createElement(f0,{onMove:function(c){a({s:100*c.left,v:100-100*c.top})},onKey:function(c){a({s:Ja(n.s+100*c.left,0,100),v:Ja(n.v-100*c.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+Yt(n.s)+"%, Brightness "+Yt(n.v)+"%"},at.createElement(d0,{className:"react-colorful__saturation-pointer",top:1-n.v/100,left:n.s/100,color:Of(n)})))}),p0=function(e,n){if(e===n)return!0;for(var a in e)if(e[a]!==n[a])return!1;return!0},H2=function(e,n){return e.toLowerCase()===n.toLowerCase()||p0(Rf(e),Rf(n))};function B2(e,n,a){var o=Qa(a),c=D.useState(function(){return e.toHsva(n)}),m=c[0],y=c[1],h=D.useRef({color:n,hsva:m});D.useEffect(function(){if(!e.equal(n,h.current.color)){var f=e.toHsva(n);h.current={hsva:f,color:n},y(f)}},[n,e]),D.useEffect(function(){var f;p0(m,h.current.hsva)||e.equal(f=e.fromHsva(m),h.current.color)||(h.current={hsva:m,color:f},o(f))},[m,e,o]);var l=D.useCallback(function(f){y(function(u){return Object.assign({},u,f)})},[]);return[m,l]}var W2=typeof window<"u"?D.useLayoutEffect:D.useEffect,q2=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},xh=new Map,Y2=function(e){W2(function(){var n=e.current?e.current.ownerDocument:document;if(n!==void 0&&!xh.has(n)){var a=n.createElement("style");a.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,xh.set(n,a);var o=q2();o&&a.setAttribute("nonce",o),n.head.appendChild(a)}},[])},G2=function(e){var n=e.className,a=e.colorModel,o=e.color,c=o===void 0?a.defaultColor:o,m=e.onChange,y=tl(e,["className","colorModel","color","onChange"]),h=D.useRef(null);Y2(h);var l=B2(a,c,m),f=l[0],u=l[1],p=id(["react-colorful",n]);return at.createElement("div",Ks({},y,{ref:h,className:p}),at.createElement(z2,{hsva:f,onChange:u}),at.createElement(U2,{hue:f.h,onChange:u,className:"react-colorful__last-control"}))},X2={defaultColor:"000",toHsva:R2,fromHsva:function(e){return O2({h:e.h,s:e.s,v:e.v,a:1})},equal:H2},K2=function(e){return at.createElement(G2,Ks({},e,{colorModel:X2}))},Z2=/^#?([0-9A-F]{3,8})$/i,V2=function(e){var n=e.color,a=n===void 0?"":n,o=e.onChange,c=e.onBlur,m=e.escape,y=e.validate,h=e.format,l=e.process,f=tl(e,["color","onChange","onBlur","escape","validate","format","process"]),u=D.useState(function(){return m(a)}),p=u[0],x=u[1],v=Qa(o),_=Qa(c),k=D.useCallback(function(T){var A=m(T.target.value);x(A),y(A)&&v(l?l(A):A)},[m,l,y,v]),M=D.useCallback(function(T){y(T.target.value)||x(m(a)),_(T)},[a,m,y,_]);return D.useEffect(function(){x(m(a))},[a,m]),at.createElement("input",Ks({},f,{value:h?h(p):p,spellCheck:"false",onChange:k,onBlur:M}))},bh=function(e){return"#"+e},Q2=function(e){var n=e.prefixed,a=e.alpha,o=tl(e,["prefixed","alpha"]),c=D.useCallback(function(y){return y.replace(/([^0-9A-F]+)/gi,"").substring(0,a?8:6)},[a]),m=D.useCallback(function(y){return(function(h,l){var f=Z2.exec(h),u=f?f[1].length:0;return u===3||u===6||!!l&&u===4||!!l&&u===8})(y,a)},[a]);return at.createElement(V2,Ks({},o,{escape:c,format:n?bh:void 0,process:bh,validate:m}))};const J2=({hexValue:e,eyedropper:n,clearButtonValue:a,containerClassName:o,onChange:c})=>{const m=D.useRef(null),y=D.useCallback(x=>{var v,_,k;x.stopPropagation();const M=(v=m.current)==null?void 0:v.querySelector("input");x.target!==M&&((k=(_=m.current)==null?void 0:_.querySelector("input"))==null||k.focus(),x.preventDefault())},[]),h=D.useRef(!1),l=D.useCallback(()=>{var x,v;h.current=!1,(v=(x=m.current)==null?void 0:x.querySelector("input"))==null||v.focus(),document.removeEventListener("mouseup",l),document.removeEventListener("touchend",l)},[]),f=D.useCallback(()=>{h.current=!0,document.addEventListener("mouseup",l),document.addEventListener("touchend",l)},[l]),u=D.useCallback(x=>{if(x.preventDefault(),!window.EyeDropper)return;h.current=!0,document.body.style.setProperty("pointer-events","none"),new window.EyeDropper().open().then(_=>c?.(_.sRGBHex)).finally(()=>{var _,k;h.current=!1,document.body.style.removeProperty("pointer-events"),(k=(_=m.current)==null?void 0:_.querySelector("input"))==null||k.focus()})},[c]);D.useEffect(()=>{var x,v;(v=(x=m.current)==null?void 0:x.querySelector("input"))==null||v.focus()},[]);const p=D.useCallback(()=>{var x,v;(v=(x=m.current)==null?void 0:x.querySelector("input"))==null||v.focus()},[]);return o=we("mt-2",o),s.jsxs("div",{className:o,onMouseDown:y,onTouchStart:y,children:[s.jsx(K2,{className:"w-full",color:e||"#ffffff",onChange:c,onMouseDown:f,onTouchStart:f}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsxs("div",{ref:m,className:"peer relative order-2 flex h-10 w-full items-center",onClick:p,children:[s.jsx("span",{className:"absolute left-2 top-[9px] z-10 ml-1 mr-2 text-grey-700",children:"#"}),s.jsx(Q2,{"aria-label":"Color value",className:"z-[1] w-full rounded-md border border-transparent bg-grey-150 p-2 pl-6 transition-all hover:bg-grey-100 focus:border-green focus:bg-white focus:shadow-[0_0_0_1px_rgba(48,207,67,1)] dark:bg-grey-900 dark:text-white dark:focus:bg-grey-925",color:e,onChange:c}),n&&!!window.EyeDropper&&s.jsx("button",{className:"absolute inset-y-0 right-3 z-50 my-auto h-4 w-4 p-[1px]",type:"button",onClick:u,children:s.jsx(i_,{className:"h-full w-full"})})]}),a!==void 0&&s.jsx(Ue,{color:"grey",value:"Clear",onClick:()=>c?.(a)})]})]})},e3=D.createContext({colorPickers:[]}),vh=e=>e.length===4?e.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"):e,Yr=({testId:e,title:n,direction:a,value:o,hint:c,error:m,eyedropper:y,clearButtonValue:h,onChange:l,swatches:f=[],alwaysOpen:u=!1,debounceMs:p})=>{const[x,v]=D.useState(!1),[_,k]=D.useState(o),M=D.useContext(e3),T=D.useId();D.useEffect(()=>{k(W=>vh(W||"")===o?W:o)},[o]),D.useEffect(()=>(M.colorPickers.push({id:T,setExpanded:v}),()=>{M.colorPickers=M.colorPickers.filter(W=>W.id!==T)}),[M,T]),D.useEffect(()=>{if(x){M.colorPickers.filter(R=>R.id!==T).forEach(R=>R.setExpanded(!1));const W=()=>{v(!1)};return document.addEventListener("click",W),()=>{document.removeEventListener("click",W)}}},[M,T,x]);const A=D.useMemo(()=>l&&p?Ji(l,p):l,[p,l]),C=W=>{k(W),A?.(W?vh(W):null)};let O=s.jsx(u0,{isExpanded:x,swatches:f,value:_,onSwatchChange:W=>{C(W),v(!1)},onTogglePicker:()=>!u&&v(!x)});n&&(O=s.jsxs("div",{className:we("flex w-full cursor-pointer items-start first:mt-0 dark:text-white",a==="rtl"&&"flex-row-reverse"),children:[s.jsx("div",{className:"shrink-0",children:O}),s.jsxs("div",{className:we("flex-1",a==="rtl"?"pr-2":"pl-2",c?"mt-[-2px]":"mt-[1px]"),onClick:()=>!u&&v(!x),children:[n,c&&s.jsx("div",{className:`text-xs ${m?"text-red":"text-grey-700"}`,children:c})]})]}));const $=f.find(W=>W.value===_);return s.jsxs("div",{className:"flex-col","data-testid":e,onClick:W=>W.stopPropagation(),children:[O,(u||x)&&s.jsx(J2,{clearButtonValue:h,eyedropper:y,hexValue:$?.hex||_||void 0,onChange:C})]})},t3=({value:e,onChange:n,singleParagraph:a=!0,...o})=>{const c=D.useCallback(m=>{const h=new DOMParser().parseFromString(m,"text/html");h.querySelectorAll("*").forEach(f=>{f.style.removeProperty("white-space"),f.getAttribute("style")||f.removeAttribute("style")}),h.body.innerHTML!==e&&n?.(h.body.innerHTML)},[e,n]);return s.jsx(R_,{...o,singleParagraph:a,children:m=>s.jsx(m.HtmlOutputPlugin,{html:e,setHtml:c})})},ld=({title:e,hideTitle:n,error:a,hint:o,value:c,clearBg:m=!1,className:y="",containerClassName:h="",hintClassName:l="",unstyled:f=!1,...u})=>{const p=f?"":we("flex min-h-[32px] items-center rounded-md border border-transparent py-1.5 md:min-h-[36px]",m?"bg-transparent":"bg-grey-150 px-3 dark:bg-grey-900",a?"border-red":"transition-all hover:bg-grey-100 has-[:focus]:border-green has-[:focus]:bg-white has-[:focus]:shadow-[0_0_0_1px_rgba(48,207,67,1)] dark:selection:bg-[rgba(88,101,116,0.99)] dark:hover:bg-grey-925 dark:has-[:focus]:bg-grey-950",e&&!n&&!m&&"mt-2",y);return s.jsxs("div",{className:`flex flex-col ${h}`,children:[e&&s.jsx(bt,{className:n?"sr-only":"",grey:!0,useLabelTag:!0,children:e}),s.jsx("div",{className:p,children:s.jsx(t3,{...u,value:c})}),o&&s.jsx(Gr,{className:l,color:a?"red":"",children:o})]})};var cd="Radio",[r3,h0]=Lg(cd),[n3,s3]=r3(cd),m0=D.forwardRef((e,n)=>{const{__scopeRadio:a,name:o,checked:c=!1,required:m,disabled:y,value:h="on",onCheck:l,form:f,...u}=e,[p,x]=D.useState(null),v=Kf(n,M=>x(M)),_=D.useRef(!1),k=p?f||!!p.closest("form"):!0;return s.jsxs(n3,{scope:a,checked:c,disabled:y,children:[s.jsx(Vi.button,{type:"button",role:"radio","aria-checked":c,"data-state":v0(c),"data-disabled":y?"":void 0,disabled:y,value:h,...u,ref:v,onClick:Sf(e.onClick,M=>{c||l?.(),k&&(_.current=M.isPropagationStopped(),_.current||M.stopPropagation())})}),k&&s.jsx(b0,{control:p,bubbles:!_.current,name:o,value:h,checked:c,required:m,disabled:y,form:f,style:{transform:"translateX(-100%)"}})]})});m0.displayName=cd;var g0="RadioIndicator",x0=D.forwardRef((e,n)=>{const{__scopeRadio:a,forceMount:o,...c}=e,m=s3(g0,a);return s.jsx(d_,{present:o||m.checked,children:s.jsx(Vi.span,{"data-state":v0(m.checked),"data-disabled":m.disabled?"":void 0,...c,ref:n})})});x0.displayName=g0;var a3="RadioBubbleInput",b0=D.forwardRef(({__scopeRadio:e,control:n,checked:a,bubbles:o=!0,...c},m)=>{const y=D.useRef(null),h=Kf(y,m),l=p_(a),f=h_(n);return D.useEffect(()=>{const u=y.current;if(!u)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==a&&v){const _=new Event("click",{bubbles:o});v.call(u,a),u.dispatchEvent(_)}},[l,a,o]),s.jsx(Vi.input,{type:"radio","aria-hidden":!0,defaultChecked:a,...c,tabIndex:-1,ref:h,style:{...c.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});b0.displayName=a3;function v0(e){return e?"checked":"unchecked"}var o3=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],rl="RadioGroup",[i3]=Lg(rl,[$g,h0]),w0=$g(),y0=h0(),[l3,c3]=i3(rl),_0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:a,name:o,defaultValue:c,value:m,required:y=!1,disabled:h=!1,orientation:l,dir:f,loop:u=!0,onValueChange:p,...x}=e,v=w0(a),_=l_(f),[k,M]=c_({prop:m,defaultProp:c??null,onChange:p,caller:rl});return s.jsx(l3,{scope:a,name:o,required:y,disabled:h,value:k,onValueChange:M,children:s.jsx(u_,{asChild:!0,...v,orientation:l,dir:_,loop:u,children:s.jsx(Vi.div,{role:"radiogroup","aria-required":y,"aria-orientation":l,"data-disabled":h?"":void 0,dir:_,...x,ref:n})})})});_0.displayName=rl;var k0="RadioGroupItem",M0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:a,disabled:o,...c}=e,m=c3(k0,a),y=m.disabled||o,h=w0(a),l=y0(a),f=D.useRef(null),u=Kf(n,f),p=m.value===c.value,x=D.useRef(!1);return D.useEffect(()=>{const v=k=>{o3.includes(k.key)&&(x.current=!0)},_=()=>x.current=!1;return document.addEventListener("keydown",v),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",v),document.removeEventListener("keyup",_)}},[]),s.jsx(f_,{asChild:!0,...h,focusable:!y,active:p,children:s.jsx(m0,{disabled:y,required:m.required,checked:p,...l,...c,name:m.name,ref:u,onCheck:()=>m.onValueChange(c.value),onKeyDown:Sf(v=>{v.key==="Enter"&&v.preventDefault()}),onFocus:Sf(c.onFocus,()=>{x.current&&f.current?.click()})})})});M0.displayName=k0;var u3="RadioGroupIndicator",j0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:a,...o}=e,c=y0(a);return s.jsx(x0,{...c,...o,ref:n})});j0.displayName=u3;var f3=_0,d3=M0,p3=j0;const h3=({id:e,title:n,options:a,onSelect:o,error:c,hint:m,selectedOption:y,separator:h})=>s.jsxs(f3,{defaultValue:y,name:e,onValueChange:o,children:[s.jsxs("div",{className:`flex flex-col gap-2 ${h&&"pb-2"}`,children:[n&&s.jsx(bt,{level:6,children:n}),a.map(l=>s.jsxs("label",{className:`flex cursor-pointer items-start ${n&&"-mb-1 mt-1"}`,htmlFor:l.value,children:[s.jsx(d3,{className:"relative float-left mt-[3px] size-4 min-w-[16px] appearance-none rounded-full border-2 border-solid border-grey-300 hover:cursor-pointer focus:shadow-none focus:outline-none focus:ring-0 data-[state=checked]:border-green data-[state=checked]:focus:border-green dark:border-grey-800 dark:text-white dark:data-[state=checked]:border-green dark:data-[state=checked]:focus:border-green",id:l.value,value:l.value,children:s.jsx(p3,{className:"flex size-full items-center justify-center after:block after:size-[6px] after:rounded-full after:border-green after:bg-green after:content-[''] dark:after:border-green dark:after:bg-green"})}),s.jsxs("div",{className:`ml-2 flex flex-col ${l.hint&&"mb-2"}`,children:[s.jsx("span",{className:`inline-block text-md dark:text-white ${l.hint&&"-mb-1"}`,children:l.label}),l.hint&&s.jsx(Gr,{children:l.hint})]})]},l.value)),m&&s.jsx(Gr,{color:c?"red":"",children:m})]}),(h||c)&&s.jsx(Va,{className:c?"border-red":""})]}),Yi=({children:e,gap:n="md",className:a})=>{let o="gap-3";switch(n){case"sm":o="gap-2";break;case"md":o="gap-3";break;case"lg":o="gap-4";break}return a=we("flex flex-col",o,a),s.jsx("div",{className:a,children:e})},ud=({heading:e,children:n,className:a})=>(a=we("w-full p-[8vmin] pt-5",a),s.jsxs("div",{className:a,children:[e&&s.jsx(bt,{className:"mb-8",children:e}),n]})),fd=({items:e,backIcon:n=!1,snapBackIcon:a=!0,onBack:o,containerClassName:c,itemClassName:m,activeItemClassName:y,separatorClassName:h})=>{const l=e.length;let f=0;return c=we("flex items-center gap-2 text-sm",c),y=we("font-bold",y),m=we("text-sm",m),s.jsxs("div",{className:c,children:[n&&s.jsx(Ue,{className:a?"mr-1":"mr-6",icon:"arrow-left",iconColorClass:"dark:text-white",size:"sm",link:!0,onClick:o}),e.map(u=>{const p=f===l-1?s.jsx("span",{className:y,children:u.label}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:`${m} ${u.onClick&&"-mx-1 cursor-pointer rounded-sm px-1 py-px hover:bg-grey-100 dark:hover:bg-grey-900"}`,type:"button",onClick:u.onClick,children:u.label},`bc-${f}`),s.jsx("span",{className:h,children:"/"})]});return f=f+1,p})]})},Zs=({testId:e,title:n,titleHeadingLevel:a=4,size:o="full",width:c,height:m,sidebar:y="",preview:h,dirty:l=!1,cancelLabel:f="Cancel",okLabel:u="OK",okColor:p="black",previewToolbar:x=!0,leftToolbar:v=!0,rightToolbar:_=!0,deviceSelector:k=!0,siteLink:M,previewToolbarURLs:T,previewBgColor:A="grey",selectedURL:C,previewToolbarTabs:O,previewToolbarBreadcrumbs:$,buttonsDisabled:W,sidebarButtons:R,sidebarHeader:Z,sidebarPadding:X=!0,sidebarContentClasses:q,enableCMDS:B=!0,backDropClick:Y,onCancel:ae,onOk:ee,afterClose:re,onSelectURL:Q,onSelectDesktopView:ne,onSelectMobileView:be,onBreadcrumbsBack:je})=>{const H=Zt(),{setGlobalDirtyState:he}=O_();D.useEffect(()=>{he(l)},[l,he]),D.useEffect(()=>{if(ee){const J=xe=>{(xe.metaKey||xe.ctrlKey)&&xe.key==="s"&&(xe.preventDefault(),ee())};if(B)return window.addEventListener("keydown",J),()=>{window.removeEventListener("keydown",J)}}});const[ge,F]=D.useState("desktop");if(ge==="mobile"&&k?h=s.jsx(c0,{"data-testid":"preview-mobile",children:h}):ge==="desktop"&&k&&(h=s.jsx(l0,{"data-testid":"preview-desktop",children:h})),x){let J=s.jsx(s.Fragment,{});T?J=s.jsx(Lt,{options:T,selectedOption:T.find(Ie=>Ie.value===C),onSelect:Ie=>Ie&&Q?.(Ie.value)}):O?J=s.jsx(Dn,{border:!1,selectedTab:C,tabs:O,width:"wide",onTabChange:Q}):$&&(J=s.jsx(fd,{activeItemClassName:"hidden md:!block md:!visible",containerClassName:"whitespace-nowrap",itemClassName:"hidden md:!block md:!visible",items:$,separatorClassName:"hidden md:!block md:!visible",backIcon:!0,onBack:je}));const xe="text-black dark:text-green",Te="text-grey-500 dark:text-grey-600",De=[{icon:"laptop",label:"Desktop",hideLabel:!0,link:!0,size:"sm",iconColorClass:ge==="desktop"?xe:Te,onClick:ne||(()=>{F("desktop")})},{icon:"mobile",label:"Mobile",hideLabel:!0,link:!0,size:"sm",iconColorClass:ge==="mobile"?xe:Te,onClick:be||(()=>{F("mobile")})}],Me=k&&s.jsx(an,{buttons:De});let oe="";A==="grey"?oe="bg-grey-50 dark:bg-black":A==="greygradient"&&(oe="bg-gradient-to-tr from-white to-[#f9f9fa] dark:from-grey-950 dark:to-black");const Ee=we("min-w-100 absolute inset-y-0 left-0 right-[400px] flex w-full grow flex-col overflow-y-auto",oe);let Ne;M&&(Ne=s.jsx("div",{className:"ml-3 border-l border-grey-400 dark:border-grey-800",children:s.jsxs("a",{className:"ml-3 flex items-center gap-1 text-sm",href:M,rel:"noopener noreferrer",target:"_blank",children:["View site ",s.jsx(ut,{name:"arrow-top-right",size:"xs"})]})})),h=s.jsxs("div",{className:Ee,children:[x&&s.jsxs("header",{className:"relative flex h-[80px] shrink-0 items-center justify-center px-8 py-5","data-testid":"design-toolbar",children:[v&&s.jsx("div",{className:"absolute left-8 flex h-full items-center",children:J}),_&&s.jsxs("div",{className:"absolute right-8 flex h-full items-center",children:[Me,Ne]})]}),s.jsx("div",{className:"flex grow items-center justify-center text-sm text-grey-400",children:h})]})}const L=[];return R||(L.push({key:"cancel-modal",label:f,onClick:ae||(()=>{$_(l,()=>{H.remove(),re?.()})}),disabled:W}),L.push({key:"ok-modal",label:u,color:p,onClick:ee,disabled:W})),s.jsx(yt,{afterClose:re,animate:!1,backDropClick:Y,dirty:l,footer:!1,height:m,padding:!1,size:o,testId:e,title:"",width:c,hideXOnMobile:!0,children:s.jsxs("div",{className:"flex h-full grow",children:[s.jsx("div",{className:`relative hidden grow flex-col [@media(min-width:801px)]:!visible [@media(min-width:801px)]:!flex ${A==="grey"?"bg-grey-50":"bg-white dark:bg-black"}`,children:h}),y&&s.jsxs("div",{className:"relative flex size-full flex-col border-l border-grey-100 dark:border-grey-900 [@media(min-width:801px)]:w-auto [@media(min-width:801px)]:basis-[400px]",children:[Z||s.jsxs("div",{className:"flex max-h-[82px] items-center justify-between gap-3 px-7 py-6",children:[s.jsx(bt,{level:a,children:n}),R||s.jsx(an,{buttons:L})]}),s.jsx("div",{className:`${Z?"":"absolute inset-x-0 bottom-0 top-[80px] grow"} ${X&&"p-7 pt-0"} flex flex-col justify-between overflow-y-auto ${q&&q}`,children:y})]})]})})},m3=({offset:e,onTrigger:n})=>{const a=D.useRef(null);return D.useEffect(()=>{const o=new IntersectionObserver(c=>{c[0].intersectionRatio<=0||n()});return a.current&&o.observe(a.current),()=>o.disconnect()},[n]),s.jsx("div",{ref:a,className:"absolute w-full",style:{bottom:e}})},E0=({trigger:e,triggerButtonProps:n,items:a,position:o="start",open:c,setOpen:m})=>(e||(e=s.jsx(Ue,{icon:"ellipsis",label:"Menu",hideLabel:!0,...n})),s.jsx(zg,{open:c,position:o,setOpen:m,trigger:e,closeOnItemClick:!0,children:s.jsx("div",{className:"flex min-w-[160px] flex-col justify-stretch py-1",role:"none",children:a.map(y=>s.jsx("button",{className:`mx-1 block cursor-pointer rounded-[2.5px] px-4 py-1.5 text-left text-sm hover:bg-grey-100 dark:hover:bg-grey-925 ${y.destructive&&" text-red-500"}`,type:"button",onClick:h=>{y.onClick&&y.onClick(h)},children:y.label},y.id))})}));var T0=typeof global=="object"&&global&&global.Object===Object&&global,g3=typeof self=="object"&&self&&self.Object===Object&&self,fn=T0||g3||Function("return this")(),qs=fn.Symbol,S0=Object.prototype,x3=S0.hasOwnProperty,b3=S0.toString,Ba=qs?qs.toStringTag:void 0;function v3(e){var n=x3.call(e,Ba),a=e[Ba];try{e[Ba]=void 0;var o=!0}catch{}var c=b3.call(e);return o&&(n?e[Ba]=a:delete e[Ba]),c}var w3=Object.prototype,y3=w3.toString;function _3(e){return y3.call(e)}var k3="[object Null]",M3="[object Undefined]",wh=qs?qs.toStringTag:void 0;function ao(e){return e==null?e===void 0?M3:k3:wh&&wh in Object(e)?v3(e):_3(e)}function eo(e){return e!=null&&typeof e=="object"}var Gi=Array.isArray;function N0(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}var j3="[object AsyncFunction]",E3="[object Function]",T3="[object GeneratorFunction]",S3="[object Proxy]";function A0(e){if(!N0(e))return!1;var n=ao(e);return n==E3||n==T3||n==j3||n==S3}var ru=fn["__core-js_shared__"],yh=(function(){var e=/[^.]+$/.exec(ru&&ru.keys&&ru.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function N3(e){return!!yh&&yh in e}var A3=Function.prototype,I3=A3.toString;function as(e){if(e!=null){try{return I3.call(e)}catch{}try{return e+""}catch{}}return""}var C3=/[\\^$.*+?()[\]{}|]/g,D3=/^\[object .+?Constructor\]$/,R3=Function.prototype,O3=Object.prototype,$3=R3.toString,L3=O3.hasOwnProperty,P3=RegExp("^"+$3.call(L3).replace(C3,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function F3(e){if(!N0(e)||N3(e))return!1;var n=A0(e)?P3:D3;return n.test(as(e))}function U3(e,n){return e?.[n]}function Vs(e,n){var a=U3(e,n);return F3(a)?a:void 0}var $f=Vs(fn,"WeakMap"),z3=9007199254740991,H3=/^(?:0|[1-9]\d*)$/;function B3(e,n){var a=typeof e;return n=n??z3,!!n&&(a=="number"||a!="symbol"&&H3.test(e))&&e>-1&&e%1==0&&e<n}function I0(e,n){return e===n||e!==e&&n!==n}var W3=9007199254740991;function C0(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=W3}function q3(e){return e!=null&&C0(e.length)&&!A0(e)}var Y3=Object.prototype;function G3(e){var n=e&&e.constructor,a=typeof n=="function"&&n.prototype||Y3;return e===a}function X3(e,n){for(var a=-1,o=Array(e);++a<e;)o[a]=n(a);return o}var K3="[object Arguments]";function _h(e){return eo(e)&&ao(e)==K3}var D0=Object.prototype,Z3=D0.hasOwnProperty,V3=D0.propertyIsEnumerable,Q3=_h((function(){return arguments})())?_h:function(e){return eo(e)&&Z3.call(e,"callee")&&!V3.call(e,"callee")};function J3(){return!1}var R0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,kh=R0&&typeof module=="object"&&module&&!module.nodeType&&module,e8=kh&&kh.exports===R0,Mh=e8?fn.Buffer:void 0,t8=Mh?Mh.isBuffer:void 0,Lf=t8||J3,r8="[object Arguments]",n8="[object Array]",s8="[object Boolean]",a8="[object Date]",o8="[object Error]",i8="[object Function]",l8="[object Map]",c8="[object Number]",u8="[object Object]",f8="[object RegExp]",d8="[object Set]",p8="[object String]",h8="[object WeakMap]",m8="[object ArrayBuffer]",g8="[object DataView]",x8="[object Float32Array]",b8="[object Float64Array]",v8="[object Int8Array]",w8="[object Int16Array]",y8="[object Int32Array]",_8="[object Uint8Array]",k8="[object Uint8ClampedArray]",M8="[object Uint16Array]",j8="[object Uint32Array]",wt={};wt[x8]=wt[b8]=wt[v8]=wt[w8]=wt[y8]=wt[_8]=wt[k8]=wt[M8]=wt[j8]=!0;wt[r8]=wt[n8]=wt[m8]=wt[s8]=wt[g8]=wt[a8]=wt[o8]=wt[i8]=wt[l8]=wt[c8]=wt[u8]=wt[f8]=wt[d8]=wt[p8]=wt[h8]=!1;function E8(e){return eo(e)&&C0(e.length)&&!!wt[ao(e)]}function T8(e){return function(n){return e(n)}}var O0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ka=O0&&typeof module=="object"&&module&&!module.nodeType&&module,S8=Ka&&Ka.exports===O0,nu=S8&&T0.process,jh=(function(){try{var e=Ka&&Ka.require&&Ka.require("util").types;return e||nu&&nu.binding&&nu.binding("util")}catch{}})(),Eh=jh&&jh.isTypedArray,$0=Eh?T8(Eh):E8,N8=Object.prototype,A8=N8.hasOwnProperty;function I8(e,n){var a=Gi(e),o=!a&&Q3(e),c=!a&&!o&&Lf(e),m=!a&&!o&&!c&&$0(e),y=a||o||c||m,h=y?X3(e.length,String):[],l=h.length;for(var f in e)A8.call(e,f)&&!(y&&(f=="length"||c&&(f=="offset"||f=="parent")||m&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||B3(f,l)))&&h.push(f);return h}function C8(e,n){return function(a){return e(n(a))}}var D8=C8(Object.keys,Object),R8=Object.prototype,O8=R8.hasOwnProperty;function $8(e){if(!G3(e))return D8(e);var n=[];for(var a in Object(e))O8.call(e,a)&&a!="constructor"&&n.push(a);return n}function L8(e){return q3(e)?I8(e):$8(e)}var to=Vs(Object,"create");function P8(){this.__data__=to?to(null):{},this.size=0}function F8(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}var U8="__lodash_hash_undefined__",z8=Object.prototype,H8=z8.hasOwnProperty;function B8(e){var n=this.__data__;if(to){var a=n[e];return a===U8?void 0:a}return H8.call(n,e)?n[e]:void 0}var W8=Object.prototype,q8=W8.hasOwnProperty;function Y8(e){var n=this.__data__;return to?n[e]!==void 0:q8.call(n,e)}var G8="__lodash_hash_undefined__";function X8(e,n){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=to&&n===void 0?G8:n,this}function rs(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var o=e[n];this.set(o[0],o[1])}}rs.prototype.clear=P8;rs.prototype.delete=F8;rs.prototype.get=B8;rs.prototype.has=Y8;rs.prototype.set=X8;function K8(){this.__data__=[],this.size=0}function nl(e,n){for(var a=e.length;a--;)if(I0(e[a][0],n))return a;return-1}var Z8=Array.prototype,V8=Z8.splice;function Q8(e){var n=this.__data__,a=nl(n,e);if(a<0)return!1;var o=n.length-1;return a==o?n.pop():V8.call(n,a,1),--this.size,!0}function J8(e){var n=this.__data__,a=nl(n,e);return a<0?void 0:n[a][1]}function ek(e){return nl(this.__data__,e)>-1}function tk(e,n){var a=this.__data__,o=nl(a,e);return o<0?(++this.size,a.push([e,n])):a[o][1]=n,this}function dn(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var o=e[n];this.set(o[0],o[1])}}dn.prototype.clear=K8;dn.prototype.delete=Q8;dn.prototype.get=J8;dn.prototype.has=ek;dn.prototype.set=tk;var ro=Vs(fn,"Map");function rk(){this.size=0,this.__data__={hash:new rs,map:new(ro||dn),string:new rs}}function nk(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function sl(e,n){var a=e.__data__;return nk(n)?a[typeof n=="string"?"string":"hash"]:a.map}function sk(e){var n=sl(this,e).delete(e);return this.size-=n?1:0,n}function ak(e){return sl(this,e).get(e)}function ok(e){return sl(this,e).has(e)}function ik(e,n){var a=sl(this,e),o=a.size;return a.set(e,n),this.size+=a.size==o?0:1,this}function os(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var o=e[n];this.set(o[0],o[1])}}os.prototype.clear=rk;os.prototype.delete=sk;os.prototype.get=ak;os.prototype.has=ok;os.prototype.set=ik;function lk(e,n){for(var a=-1,o=n.length,c=e.length;++a<o;)e[c+a]=n[a];return e}function ck(){this.__data__=new dn,this.size=0}function uk(e){var n=this.__data__,a=n.delete(e);return this.size=n.size,a}function fk(e){return this.__data__.get(e)}function dk(e){return this.__data__.has(e)}var pk=200;function hk(e,n){var a=this.__data__;if(a instanceof dn){var o=a.__data__;if(!ro||o.length<pk-1)return o.push([e,n]),this.size=++a.size,this;a=this.__data__=new os(o)}return a.set(e,n),this.size=a.size,this}function Cn(e){var n=this.__data__=new dn(e);this.size=n.size}Cn.prototype.clear=ck;Cn.prototype.delete=uk;Cn.prototype.get=fk;Cn.prototype.has=dk;Cn.prototype.set=hk;function mk(e,n){for(var a=-1,o=e==null?0:e.length,c=0,m=[];++a<o;){var y=e[a];n(y,a,e)&&(m[c++]=y)}return m}function gk(){return[]}var xk=Object.prototype,bk=xk.propertyIsEnumerable,Th=Object.getOwnPropertySymbols,vk=Th?function(e){return e==null?[]:(e=Object(e),mk(Th(e),function(n){return bk.call(e,n)}))}:gk;function wk(e,n,a){var o=n(e);return Gi(e)?o:lk(o,a(e))}function Sh(e){return wk(e,L8,vk)}var Pf=Vs(fn,"DataView"),Ff=Vs(fn,"Promise"),Uf=Vs(fn,"Set"),Nh="[object Map]",yk="[object Object]",Ah="[object Promise]",Ih="[object Set]",Ch="[object WeakMap]",Dh="[object DataView]",_k=as(Pf),kk=as(ro),Mk=as(Ff),jk=as(Uf),Ek=as($f),In=ao;(Pf&&In(new Pf(new ArrayBuffer(1)))!=Dh||ro&&In(new ro)!=Nh||Ff&&In(Ff.resolve())!=Ah||Uf&&In(new Uf)!=Ih||$f&&In(new $f)!=Ch)&&(In=function(e){var n=ao(e),a=n==yk?e.constructor:void 0,o=a?as(a):"";if(o)switch(o){case _k:return Dh;case kk:return Nh;case Mk:return Ah;case jk:return Ih;case Ek:return Ch}return n});var Rh=fn.Uint8Array,Tk="__lodash_hash_undefined__";function Sk(e){return this.__data__.set(e,Tk),this}function Nk(e){return this.__data__.has(e)}function Xi(e){var n=-1,a=e==null?0:e.length;for(this.__data__=new os;++n<a;)this.add(e[n])}Xi.prototype.add=Xi.prototype.push=Sk;Xi.prototype.has=Nk;function Ak(e,n){for(var a=-1,o=e==null?0:e.length;++a<o;)if(n(e[a],a,e))return!0;return!1}function Ik(e,n){return e.has(n)}var Ck=1,Dk=2;function L0(e,n,a,o,c,m){var y=a&Ck,h=e.length,l=n.length;if(h!=l&&!(y&&l>h))return!1;var f=m.get(e),u=m.get(n);if(f&&u)return f==n&&u==e;var p=-1,x=!0,v=a&Dk?new Xi:void 0;for(m.set(e,n),m.set(n,e);++p<h;){var _=e[p],k=n[p];if(o)var M=y?o(k,_,p,n,e,m):o(_,k,p,e,n,m);if(M!==void 0){if(M)continue;x=!1;break}if(v){if(!Ak(n,function(T,A){if(!Ik(v,A)&&(_===T||c(_,T,a,o,m)))return v.push(A)})){x=!1;break}}else if(!(_===k||c(_,k,a,o,m))){x=!1;break}}return m.delete(e),m.delete(n),x}function Rk(e){var n=-1,a=Array(e.size);return e.forEach(function(o,c){a[++n]=[c,o]}),a}function Ok(e){var n=-1,a=Array(e.size);return e.forEach(function(o){a[++n]=o}),a}var $k=1,Lk=2,Pk="[object Boolean]",Fk="[object Date]",Uk="[object Error]",zk="[object Map]",Hk="[object Number]",Bk="[object RegExp]",Wk="[object Set]",qk="[object String]",Yk="[object Symbol]",Gk="[object ArrayBuffer]",Xk="[object DataView]",Oh=qs?qs.prototype:void 0,su=Oh?Oh.valueOf:void 0;function Kk(e,n,a,o,c,m,y){switch(a){case Xk:if(e.byteLength!=n.byteLength||e.byteOffset!=n.byteOffset)return!1;e=e.buffer,n=n.buffer;case Gk:return!(e.byteLength!=n.byteLength||!m(new Rh(e),new Rh(n)));case Pk:case Fk:case Hk:return I0(+e,+n);case Uk:return e.name==n.name&&e.message==n.message;case Bk:case qk:return e==n+"";case zk:var h=Rk;case Wk:var l=o&$k;if(h||(h=Ok),e.size!=n.size&&!l)return!1;var f=y.get(e);if(f)return f==n;o|=Lk,y.set(e,n);var u=L0(h(e),h(n),o,c,m,y);return y.delete(e),u;case Yk:if(su)return su.call(e)==su.call(n)}return!1}var Zk=1,Vk=Object.prototype,Qk=Vk.hasOwnProperty;function Jk(e,n,a,o,c,m){var y=a&Zk,h=Sh(e),l=h.length,f=Sh(n),u=f.length;if(l!=u&&!y)return!1;for(var p=l;p--;){var x=h[p];if(!(y?x in n:Qk.call(n,x)))return!1}var v=m.get(e),_=m.get(n);if(v&&_)return v==n&&_==e;var k=!0;m.set(e,n),m.set(n,e);for(var M=y;++p<l;){x=h[p];var T=e[x],A=n[x];if(o)var C=y?o(A,T,x,n,e,m):o(T,A,x,e,n,m);if(!(C===void 0?T===A||c(T,A,a,o,m):C)){k=!1;break}M||(M=x=="constructor")}if(k&&!M){var O=e.constructor,$=n.constructor;O!=$&&"constructor"in e&&"constructor"in n&&!(typeof O=="function"&&O instanceof O&&typeof $=="function"&&$ instanceof $)&&(k=!1)}return m.delete(e),m.delete(n),k}var eM=1,$h="[object Arguments]",Lh="[object Array]",Ri="[object Object]",tM=Object.prototype,Ph=tM.hasOwnProperty;function rM(e,n,a,o,c,m){var y=Gi(e),h=Gi(n),l=y?Lh:In(e),f=h?Lh:In(n);l=l==$h?Ri:l,f=f==$h?Ri:f;var u=l==Ri,p=f==Ri,x=l==f;if(x&&Lf(e)){if(!Lf(n))return!1;y=!0,u=!1}if(x&&!u)return m||(m=new Cn),y||$0(e)?L0(e,n,a,o,c,m):Kk(e,n,l,a,o,c,m);if(!(a&eM)){var v=u&&Ph.call(e,"__wrapped__"),_=p&&Ph.call(n,"__wrapped__");if(v||_){var k=v?e.value():e,M=_?n.value():n;return m||(m=new Cn),c(k,M,a,o,m)}}return x?(m||(m=new Cn),Jk(e,n,a,o,c,m)):!1}function P0(e,n,a,o,c){return e===n?!0:e==null||n==null||!eo(e)&&!eo(n)?e!==e&&n!==n:rM(e,n,a,o,P0,c)}function nM(e,n){return P0(e,n)}const Fh=({className:e,children:n,colSpan:a,sticky:o=!1,...c})=>{const m=we("!py-2 !pl-0 !pr-6 text-left align-top",o&&"sticky top-0 bg-white",c.onClick&&"hover:cursor-pointer",e);return s.jsx("th",{className:m,colSpan:a,...c,children:s.jsx(bt,{className:"whitespace-nowrap",level:6,children:n})})},F0=({left:e,center:n,right:a,sticky:o=!0,containerClassName:c,children:m})=>{const y=we("z-50 h-22 min-h-[92px] p-8",!m&&"flex items-center justify-between gap-3",o&&"sticky top-0",c);if(!m){if(e){const h=we("flex flex-auto items-center",a&&n&&"basis-1/3",!a&&n&&"basis-1/2");e=s.jsx("div",{className:h,children:e})}if(n){const h=we("flex flex-auto items-center justify-center",e&&a&&"basis-1/3",(e&&!a||!e&&a)&&"basis-1/2");n=s.jsx("div",{className:h,children:n})}if(a){const h=we("flex flex-auto items-center justify-end",e&&n&&"basis-1/3",!e&&n&&"basis-1/2");a=s.jsx("div",{className:h,children:a})}}return s.jsx("div",{className:y,children:m||s.jsxs(s.Fragment,{children:[e,n,a]})})},U0=({items:e,setItems:n,blank:a,canAddNewItem:o})=>{const[c,m]=D.useState(e.map((x,v)=>({item:x,id:v.toString()}))),[y,h]=D.useState(a);return D.useEffect(()=>{const x=c.map(({item:v})=>v);o(y)&&x.push(y),nM(JSON.parse(JSON.stringify(x)),JSON.parse(JSON.stringify(e)))||n(x)},[c,y,e,n,o]),{items:c,updateItem:(x,v)=>{const _=c.map(k=>k.id===x?{...k,item:v}:k);m(_),n(_.map(k=>k.item))},addItem:()=>{if(o(y)){const x=c.reduce((_,k)=>Math.max(_,parseInt(k.id)),0),v=c.concat({item:y,id:(x+1).toString()});m(v),n(v.map(_=>_.item)),h(a)}},removeItem:x=>{const v=c.filter(_=>_.id!==x);m(v),n(v.map(_=>_.item))},moveItem:(x,v)=>{if(x!==v){const _=c.findIndex(T=>T.id===x),k=v?c.findIndex(T=>T.id===v):0,M=L_(c,_,k);m(M),n(M.map(T=>T.item))}},newItem:y,setNewItem:h}},sM=({label:e,text:n="",hint:a,onRegenerate:o})=>{const[c,m]=D.useState(!1),y=()=>{navigator.clipboard.writeText(n),m(!0),setTimeout(()=>m(!1),2e3)},h=we("group/api-keys relative -mt-1 mb-1 w-full overflow-hidden border-b border-transparent py-2 hover:border-grey-300 dark:hover:border-grey-600");return s.jsxs("div",{className:"mb-3 grid grid-cols-1",children:[e&&s.jsx(bt,{level:6,grey:!0,children:e}),s.jsxs("div",{className:h,children:[s.jsx("span",{children:n}),a,s.jsxs("div",{className:"visible absolute right-0 top-1/2 flex translate-y-[-50%] gap-1 bg-white pl-1 text-sm group-hover/api-keys:visible md:invisible dark:bg-black",children:[o&&s.jsx(Ue,{color:"outline",label:"Regenerate",size:"sm",onClick:o}),s.jsx(Ue,{color:"outline",label:c?"Copied":"Copy",size:"sm",onClick:y})]})]})]})},al=({keys:e})=>s.jsx("div",{"data-testid":"api-keys",children:e.map(n=>s.jsx(sM,{...n},n.label))}),Qs=({icon:e,title:n,detail:a,extra:o})=>s.jsxs("div",{className:"-mx-8 -mt-8 flex flex-col gap-4 bg-grey-75 p-8 md:flex-row dark:bg-grey-950",children:[s.jsx("div",{className:"size-14",children:e}),s.jsxs("div",{className:"mt-1.5 flex min-w-0 flex-1 flex-col",children:[s.jsx("h3",{children:n}),s.jsx("div",{children:a}),o&&s.jsx("div",{className:"mt-4",children:o})]})]}),dd=ns({method:"POST",path:({integrationId:e,apiKeyId:n})=>`/integrations/${e}/api_key/${n}/refresh/`,body:({integrationId:e})=>({integrations:[{id:e}]}),updateQueries:{emberUpdateType:"createOrUpdate",dataType:el,update:(e,n)=>n&&{...n,integrations:n.integrations.map(a=>e.integrations.find(({id:c})=>c===a.id)||a)}}}),aM=ye.create(()=>{const e=ye.useModal(),{updateRoute:n}=Qe(),{zapierTemplates:a}=P_(),{data:{integrations:o}={integrations:[]}}=Qf(),{config:c}=Je(),{mutateAsync:m}=dd(),y=ot(),[h,l]=D.useState(!1),f=c.hostSettings?.limits?.customIntegrations?.disabled,u=o.find(({slug:v})=>v==="zapier"),p=u?.api_keys?.find(v=>v.type==="admin");D.useEffect(()=>{f&&n("integrations")},[f,n]);const x=()=>{!u||!p||(l(!1),ye.show(Et,{title:"Regenerate Admin API Key",prompt:'You will need to locate the Ghost App within your Zapier account and click on "Reconnect" to enter the new Admin API Key.',okLabel:"Regenerate Admin API Key",onOk:async v=>{try{await m({integrationId:u.id,apiKeyId:p.id}),l(!0),v?.remove()}catch(_){y(_)}}}))};return s.jsxs(yt,{afterClose:()=>{n("integrations")},cancelLabel:"",footer:s.jsxs("div",{className:"mx-8 flex w-full items-center justify-between",children:[s.jsxs("a",{className:"mt-1 self-baseline text-sm font-bold",href:"https://zapier.com/apps/ghost/integrations?utm_medium=partner_api&utm_source=widget&utm_campaign=Widget",rel:"noopener noreferrer",target:"_blank",children:["View more Ghost integrations powered by ",s.jsx("span",{children:s.jsx(ut,{className:"relative top-[-2px] inline-block",name:"zapier-logo",size:24})})]}),s.jsx(Ue,{color:"black",label:"Close",onClick:()=>{e.remove()}})]}),okColor:"black",okLabel:"Close",testId:"zapier-modal",title:"",stickyFooter:!0,onOk:()=>{n("integrations"),e.remove()},children:[s.jsx(Qs,{detail:"Automation for your favorite apps",extra:s.jsx("div",{className:"-mb-4 mt-1",children:s.jsx(al,{keys:[{label:"Admin API key",text:p?.secret,hint:h?s.jsx("div",{className:"text-green",children:"Admin API Key was successfully regenerated"}):void 0,onRegenerate:x},{label:"API URL",text:window.location.origin+no().subdir}]})}),icon:s.jsx(ut,{name:"zapier",size:56}),title:"Zapier"}),s.jsx(cn,{children:a.map(v=>s.jsx(On,{action:s.jsx(Ue,{className:"whitespace-nowrap text-sm font-semibold text-[#FF4A00]",href:v.url,label:"Use this Zap",tag:"a",target:"_blank",link:!0,unstyled:!0}),bgOnHover:!1,className:"flex items-center gap-3 py-2 pl-3",title:s.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center",children:[s.jsxs("div",{className:"flex shrink-0 flex-nowrap items-center gap-2",children:[s.jsx("img",{className:"size-8 object-contain dark:invert",role:"presentation",src:v.ghostImage}),s.jsx(ut,{name:"arrow-right",size:"xs"}),s.jsx("img",{className:"size-8 object-contain",role:"presentation",src:v.appImage})]}),s.jsx("span",{className:"text-sm",children:v.title})]}),hideActions:!0}))})]})});function z0(e){const n="The URL must be in a format like https://www.threads.net/@yourUsername";if(!e)return"";if(e.startsWith("http")){if(!e.includes("threads.net")&&!e.includes("threads.com"))throw new Error(n);if(e=e.replace("threads.com","threads.net"),e.includes("www.")||(e=e.replace("https://","https://www.")),!Nt.isURL(e))throw new Error(n);if(!e.match(/^https:\/\/www\.threads\.net\/@?[a-zA-Z0-9._]+$/))throw new Error(n);return e}if(!e.includes("/")){if(e.startsWith("@")&&(e=e.slice(1)),!e.match(/^[a-zA-Z0-9._]+$/))throw new Error(n);return`https://www.threads.net/@${e}`}throw new Error(n)}const oM=e=>`https://www.threads.net/${e}`,iM=e=>{const n=e.match(/(?:https:\/\/)(?:www\.)?(?:threads\.(?:com|net))(?:\/)?(?:#!\/)?@?([^/]*)/)?.[1];return n?`@${n}`:null},Bs={INVALID_USERNAME:"Your Username is not a valid Bluesky Username",INVALID_URL:"The URL must be in a format like https://bsky.app/profile/yourUsername"};function H0(e){return[/^did:plc:[a-z2-7]{24}$/,/^[a-zA-Z0-9._]{1,15}$/,/^(?=.{1,191}$)[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$/].some(a=>a.test(e))}function zf(e){let n=e.trim();return n.startsWith("@")&&(n=n.slice(1)),n.startsWith("did:plc:")?n.toLowerCase():n}function B0(e){if(!e)return"";let n;if(e.startsWith("http")||e.startsWith("www.")||e.includes("bsky.app")){if(!e.includes("bsky.app"))throw new Error(Bs.INVALID_URL);const o=e.match(/bsky\.app\/profile\/@?([^/]+)/);if(!o)throw new Error(Bs.INVALID_URL);n=zf(o[1])}else n=zf(e);if(!H0(n))throw new Error(Bs.INVALID_USERNAME);const a=`https://bsky.app/profile/${n}`;if(!Nt.isURL(a))throw new Error(Bs.INVALID_URL);return a}const lM=e=>{if(!e)throw new Error(Bs.INVALID_USERNAME);let n=zf(e);if(!H0(n))throw new Error(Bs.INVALID_USERNAME);return`https://bsky.app/profile/${n}`},cM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?bsky\.app\/profile\/@?([^/]*)/);return n?`${n[1]}`:null},es={INVALID_URL:"The URL must be in a format like https://www.linkedin.com/in/yourUsername",INVALID_USERNAME:"Your Username is not a valid LinkedIn Username"},uM=["in","pub","company","school"],fM=/^[a-zA-Z0-9-]{3,100}$/,dM=/^[a-zA-Z0-9-]{3,100}(?:\/[a-zA-Z0-9-]*)*$/,W0=/^(?:https?:\/\/)?(?:www\.)?(?:([a-z]{2})\.)?linkedin\.com\/(in|pub|company|school)\/([^?#]+)/i,Hf=e=>e.trim().replace(/^@/,""),q0=e=>{if(/^(https?:\/\/|www\.)/.test(e)||e.includes("linkedin.com")){const o=e.match(W0);if(!o)throw new Error(es.INVALID_URL);if(o[0].length!==e.length)throw new Error(es.INVALID_USERNAME);const[,c,m,y]=o,h=Hf(y);if(c&&!/^[A-Z]{2}$/.test(c.toUpperCase()))throw new Error(es.INVALID_URL);return{regional:c,pathType:m,username:h}}const n=Hf(e),a=n.indexOf("/");if(a!==-1){const o=n.substring(0,a);if(uM.includes(o))return{pathType:o,username:n.substring(a+1)}}return{username:n}},Y0=(e,n)=>(e==="pub"?dM:fM).test(n),G0=({regional:e,pathType:n,username:a})=>{const c=`https://${e?`${e.toLowerCase()}.`:"www."}linkedin.com/${n}/${a}`;if(!Nt.isURL(c))throw new Error(es.INVALID_URL);return c};function X0(e){if(!e)return"";const{regional:n,pathType:a="in",username:o}=q0(e);if(!Y0(a,o))throw new Error(es.INVALID_USERNAME);return G0({regional:n,pathType:a,username:o})}const pM=e=>{if(!e)throw new Error(es.INVALID_USERNAME);const{regional:n,pathType:a="in",username:o}=q0(e);if(!Y0(a,o))throw new Error(es.INVALID_USERNAME);return G0({regional:n,pathType:a,username:o})},hM=e=>{const n=e.match(W0);if(!n)return null;const[,,a,o]=n,c=Hf(o);return a==="in"?c:`${a}/${c}`};function K0(e){const n="The URL must be in a format like https://www.instagram.com/yourUsername",a="Your Username is not a valid Instagram Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("instagram.com")){if(!e.includes("instagram.com"))throw new Error(n);const m=e.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]+)/);if(!m)throw new Error(n);o=m[1]}else o=e.startsWith("@")?e.slice(1):e;if(!o.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||o.includes("..")||o.length>30)throw new Error(a);const c=`https://www.instagram.com/${o}`;if(!Nt.isURL(c))throw new Error(n);return c}const mM=e=>{const n="Your Username is not a valid Instagram Username";if(!e)throw new Error(n);let a=e;if(a.startsWith("@")&&(a=a.slice(1)),!a.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||a.includes("..")||a.length>30)throw new Error(n);return`https://www.instagram.com/${a}`},gM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]*)/);return n?`${n[1]}`:null};function Z0(e){const n="The URL must be in a format like https://www.youtube.com/@yourUsername, https://www.youtube.com/user/yourUsername, or https://www.youtube.com/channel/yourChannelId",a="Your Username is not a valid YouTube Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("youtube.com")){if(!e.includes("youtube.com"))throw new Error(n);const m=e.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]+)/);if(!m)throw new Error(n);o=m[1]}else o=e;if(o.startsWith("@")){const m=o.slice(1);if(!m.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||m.includes("..")||m.length>30)throw new Error(a)}else if(o.startsWith("user/")){if(!o.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(a)}else if(o.startsWith("channel/")){if(!o.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(a)}else throw new Error(n);const c=`https://www.youtube.com/${o}`;if(!Nt.isURL(c))throw new Error(n);return c}const xM=e=>{const n="Your Username is not a valid YouTube Username";if(!e)throw new Error(n);if(e.startsWith("@")){const a=e.slice(1);if(!a.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||a.includes("..")||a.length>30)throw new Error(n)}else if(e.startsWith("user/")){if(!e.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(n)}else if(e.startsWith("channel/")){if(!e.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(n)}else throw new Error("The handle must be in a format like @yourUsername, user/yourUsername, or channel/yourChannelId");return`https://www.youtube.com/${e}`},bM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]*)/);return n?n[1]:null};function V0(e){const n="The URL must be in a format like https://www.tiktok.com/@yourUsername",a="Your Username is not a valid TikTok Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("tiktok.com")){if(!e.includes("tiktok.com"))throw new Error(n);const y=e.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]+)/);if(!y)throw new Error(n);o=y[1]}else o=e.startsWith("@")?e:`@${e}`;const c=o.slice(1);if(!c.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||c.includes("..")||c.length<2||c.length>24)throw new Error(a);const m=`https://www.tiktok.com/${o}`;if(!Nt.isURL(m))throw new Error(n);return m}const vM=e=>{const n="Your Username is not a valid TikTok Username";if(!e)throw new Error(n);const a=e.startsWith("@")?e:`@${e}`,o=a.slice(1);if(!o.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||o.includes("..")||o.length<2||o.length>24)throw new Error(n);return`https://www.tiktok.com/${a}`},wM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]*)/);return n?n[1]:null};function Q0(e){const n="The URL must be in a format like @username@instance.tld or https://instance.tld/@username or https://website.com/@username@instance.tld";if(!e)return"";let a=e;if(a=a.replace(/^https?:\/\//,""),a.match(/^@[^@]+@[^/]+$/)){const[o,c]=a.split("@").slice(1);if(!Nt.isFQDN(c))throw new Error(n);return`https://${c}/@${o}`}if(a.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[o,c]=a.split("/@");if(!Nt.isFQDN(o))throw new Error(n);if(c.includes("@")){const[,m]=c.split("@");if(!Nt.isFQDN(m))throw new Error(n)}return`https://${a}`}throw new Error(n)}const yM=e=>{const n="Your Username is not a valid Mastodon Username";if(!e)throw new Error(n);if(e.match(/^@[^@]+@[^/]+$/)){const[a,o]=e.split("@").slice(1);if(!Nt.isFQDN(o))throw new Error(n);return`https://${o}/@${a}`}if(e.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[a,o]=e.split("/@");if(!Nt.isFQDN(a))throw new Error(n);if(o.includes("@")){const[,c]=o.split("@");if(!Nt.isFQDN(c))throw new Error(n)}return`https://${e}`}throw new Error(n)},_M=e=>e.replace(/^https?:\/\//,""),kM=({tier:e})=>{const n=e?.type==="free",{updateRoute:a}=Qe(),{mutateAsync:o}=ad(),{mutateAsync:c}=A2(),{mutateAsync:m}=Rn(),[y,h]=at.useState(!!e?.trial_days),l=ot(),{localSettings:f,siteData:u}=ss(),[p]=gt(f,["portal_plans"]),x=JSON.parse(p?.toString()||"[]"),v={name:()=>_.name?void 0:"Enter a name for the tier",monthly_price:()=>_.type!=="free"?ch(_.monthly_price||0,_.currency,{allowZero:!1}):void 0,yearly_price:()=>_.type!=="free"?ch(_.yearly_price||0,_.currency,{allowZero:!1}):void 0},{formState:_,saveState:k,updateForm:M,handleSave:T,errors:A,clearError:C,okProps:O}=kr({initialState:{...e||{},trial_days:e?.trial_days?.toString()||"",currency:e?.currency||F_[0].isoCode,visibility:e?.visibility||"none",welcome_page_url:e?.welcome_page_url||null},savingDelay:500,savedDelay:500,onValidate:()=>{const q={};return Object.entries(v).forEach(([B,Y])=>{q[B]=Y?.()}),q},onSave:async()=>{const{trial_days:q,currency:B,...Y}=_,ae=Y;if(ae.benefits=ae.benefits?.filter(ee=>ee),n||(ae.currency=B,ae.trial_days=parseInt(q)),e?.id?await o({...e,...ae}):await c(ae),n){const ee=_.visibility==="public";let re=!1;x.includes("free")&&!ee&&(x.splice(x.indexOf("free"),1),re=!0),!x.includes("free")&&ee&&(x.push("free"),re=!0),re&&await m([{key:"portal_plans",value:JSON.stringify(x)}])}},onSaveError:l}),$=U0({items:_.benefits||[],setItems:q=>M(B=>({...B,benefits:q})),blank:"",canAddNewItem:q=>!!q}),W=q=>{q.target.checked?(h(!0),M(B=>({...B,trial_days:e?.trial_days?e?.trial_days.toString():"7"}))):(h(!1),M(B=>({...B,trial_days:"0"})))},R=D.useRef(!1);D.useEffect(()=>{R.current&&(v.monthly_price?.(),v.yearly_price?.()),R.current=!0},[_.currency]);const Z=()=>{if(e){const q=e.active?"Archive tier":"Reactivate tier",B=e.active?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:["Members will no longer be able to subscribe to ",s.jsx("strong",{children:e.name})," and it will be removed from the list of available tiers in portal."]}),s.jsx("div",{children:"Existing members on this tier will remain unchanged. Offers using this tier will be disabled."})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:["Reactivating ",s.jsx("strong",{children:e.name})," will re-enable it as an option in portal and allow new members to subscribe to this tier."]}),s.jsx("div",{children:"Existing members will remain unchanged."})]}),Y=e.active?"Archive":"Reactivate";ye.show(Et,{title:q,prompt:B,okLabel:Y,cancelLabel:"Cancel",okColor:e.active?"red":"black",onOk:ae=>{o({...e,active:!e.active}),ae?.remove(),xt({type:"success",title:`Tier ${e.active?"archived":"reactivated"}`})}})}};let X={};return e&&(e.active&&e.type!=="free"?X={label:"Archive tier",color:"red",link:!0,onClick:Z}:e.active||(X={label:"Reactivate tier",color:"green",link:!0,onClick:Z})),s.jsx(yt,{afterClose:()=>{a("tiers")},buttonsDisabled:O.disabled,cancelLabel:"Close",dirty:k==="unsaved",leftButtonProps:X,okColor:O.color,okLabel:O.label||"Save",size:"lg",testId:"tier-detail-modal",title:e?e.active?"Edit tier":"Edit archived tier":"New tier",stickyFooter:!0,onOk:async()=>{await T({fakeWhenUnchanged:!0})},children:s.jsxs("div",{className:"-mb-8 mt-8 flex items-start gap-8",children:[s.jsxs("div",{className:"flex grow flex-col gap-8",children:[s.jsxs(tt,{marginBottom:!1,title:"Basic",grouped:!0,children:[s.jsx(Ae,{autoComplete:"off",error:!!A.name,hint:A.name,maxLength:191,placeholder:n?"Free":"Bronze",title:"Name",value:_.name||"",autoFocus:!0,onChange:q=>M(B=>({...B,name:q.target.value})),onKeyDown:()=>C("name")}),s.jsx(Ae,{autoComplete:"off",autoFocus:n,maxLength:191,placeholder:n?"Free preview":"Full access to premium content",title:"Description",value:_.description||"",onChange:q=>M(B=>({...B,description:q.target.value}))}),!n&&s.jsx(s.Fragment,{children:s.jsxs("div",{className:"flex flex-col gap-10 md:flex-row",children:[s.jsxs("div",{className:"basis-1/2",children:[s.jsxs("div",{className:"mb-1 flex h-6 items-center justify-between",children:[s.jsx(bt,{level:6,children:"Prices"}),s.jsx("div",{className:"-mr-2 w-[50px]",children:s.jsx(Lt,{border:!1,containerClassName:"font-medium",controlClasses:{menu:"w-18"},options:uh(),selectedOption:uh().flatMap(q=>q.options).find(q=>q.value===_.currency),size:"xs",clearBg:!0,isSearchable:!0,onSelect:q=>M(B=>({...B,currency:q?.value}))})})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(fh,{error:!!A.monthly_price,hint:A.monthly_price,placeholder:"5",rightPlaceholder:`${_.currency}/month`,title:"Monthly price",valueInCents:_.monthly_price||"",hideTitle:!0,onBlur:q=>q.target.value===""?M(B=>({...B,monthly_price:0})):null,onChange:q=>M(B=>({...B,monthly_price:q})),onKeyDown:()=>C("monthly_price")}),s.jsx(fh,{error:!!A.yearly_price,hint:A.yearly_price,placeholder:"50",rightPlaceholder:`${_.currency}/year`,title:"Yearly price",valueInCents:_.yearly_price||"",hideTitle:!0,onBlur:q=>q.target.value===""?M(B=>({...B,yearly_price:0})):null,onChange:q=>M(B=>({...B,yearly_price:q})),onKeyDown:()=>C("yearly_price")})]})]}),s.jsxs("div",{className:"basis-1/2",children:[s.jsx("div",{className:"mb-1 flex h-6 flex-col justify-center",children:s.jsx(st,{checked:y,label:"Add a free trial",labelStyle:"heading",onChange:W})}),s.jsx(Ae,{disabled:!y,hint:s.jsxs("div",{className:"mt-1",children:["Members will be subscribed at full price once the trial ends. ",s.jsx("a",{className:"text-green",href:"https://ghost.org/help/free-trials/",rel:"noreferrer",target:"_blank",children:"Learn more"})]}),placeholder:"0",rightPlaceholder:"days",title:"Trial days",value:_.trial_days,hideTitle:!0,onChange:q=>M(B=>({...B,trial_days:q.target.value.replace(/[^\d]/,"")}))})]})]})}),s.jsx(Hg,{baseUrl:u?.url,hint:`Redirect to this URL after signup ${n?"":" for premium membership"}`,maxLength:2e3,placeholder:u?.url,title:"Welcome page",value:_.welcome_page_url||null,nullable:!0,transformPathWithoutSlash:!0,onChange:q=>M(B=>({...B,welcome_page_url:q||null}))})]}),s.jsxs(tt,{gap:"none",title:"Benefits",grouped:!0,children:[s.jsx("div",{className:"-mt-3",children:s.jsx(Bg,{items:$.items,itemSeparator:!1,renderItem:({id:q,item:B})=>s.jsxs("div",{className:"relative flex w-full items-center gap-5",children:[s.jsx("div",{className:"absolute left-[-32px] top-[7px] flex size-6 items-center justify-center bg-white group-hover:hidden dark:bg-black",children:s.jsx(ut,{name:"check",size:"sm"})}),s.jsx(Ae,{maxLength:191,value:B,onChange:Y=>$.updateItem(q,Y.target.value)}),s.jsx(Ue,{className:"absolute right-1 top-1 z-10 opacity-0 group-hover:opacity-100",color:"grey",icon:"trash",size:"sm",onClick:()=>$.removeItem(q)})]}),onMove:$.moveItem})}),s.jsxs("div",{className:"relative mt-1 flex items-center gap-3",children:[s.jsx(ut,{className:"dark:text-white",name:"check",size:"sm"}),s.jsx(Ae,{className:"grow",containerClassName:"w-100",maxLength:191,placeholder:"Expert analysis",title:"New benefit",value:$.newItem,hideTitle:!0,onChange:q=>$.setNewItem(q.target.value),onKeyDown:q=>{q.key==="Enter"&&$.addItem()}}),s.jsx(Ue,{className:"absolute right-[5px] top-[5px] z-10",color:"green",icon:"add",iconColorClass:"text-white",label:"Add",size:"sm",hideLabel:!0,onClick:()=>$.addItem()})]})]})]}),s.jsx("div",{className:"sticky top-[96px] hidden shrink-0 basis-[380px] min-[920px]:!visible min-[920px]:!block",children:s.jsx(U_,{isFreeTier:n,tier:_})})]})})},MM=({params:e})=>{const{data:{tiers:n,isEnd:a}={},fetchNextPage:o}=so();let c;return D.useEffect(()=>{e?.id&&!c&&!a&&o()},[o,a,e?.id,c]),e?.id&&(c=n?.find(({id:m})=>m===e?.id),!c)?null:s.jsx(kM,{tier:c})},jM=ye.create(MM);var au,Uh;function J0(){if(Uh)return au;Uh=1;var e={};return au=typeof process=="object"&&e&&e.NODE_DEBUG&&/\bsemver\b/i.test(e.NODE_DEBUG)?(...a)=>console.error("SEMVER",...a):()=>{},au}var ou,zh;function ex(){if(zh)return ou;zh=1;const e="2.0.0",n=256,a=Number.MAX_SAFE_INTEGER||9007199254740991,o=16,c=n-6;return ou={MAX_LENGTH:n,MAX_SAFE_COMPONENT_LENGTH:o,MAX_SAFE_BUILD_LENGTH:c,MAX_SAFE_INTEGER:a,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:e,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},ou}var Oi={exports:{}},Hh;function EM(){return Hh||(Hh=1,(function(e,n){const{MAX_SAFE_COMPONENT_LENGTH:a,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:c}=ex(),m=J0();n=e.exports={};const y=n.re=[],h=n.safeRe=[],l=n.src=[],f=n.safeSrc=[],u=n.t={};let p=0;const x="[a-zA-Z0-9-]",v=[["\\s",1],["\\d",c],[x,o]],_=M=>{for(const[T,A]of v)M=M.split(`${T}*`).join(`${T}{0,${A}}`).split(`${T}+`).join(`${T}{1,${A}}`);return M},k=(M,T,A)=>{const C=_(T),O=p++;m(M,O,T),u[M]=O,l[O]=T,f[O]=C,y[O]=new RegExp(T,A?"g":void 0),h[O]=new RegExp(C,A?"g":void 0)};k("NUMERICIDENTIFIER","0|[1-9]\\d*"),k("NUMERICIDENTIFIERLOOSE","\\d+"),k("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${x}*`),k("MAINVERSION",`(${l[u.NUMERICIDENTIFIER]})\\.(${l[u.NUMERICIDENTIFIER]})\\.(${l[u.NUMERICIDENTIFIER]})`),k("MAINVERSIONLOOSE",`(${l[u.NUMERICIDENTIFIERLOOSE]})\\.(${l[u.NUMERICIDENTIFIERLOOSE]})\\.(${l[u.NUMERICIDENTIFIERLOOSE]})`),k("PRERELEASEIDENTIFIER",`(?:${l[u.NONNUMERICIDENTIFIER]}|${l[u.NUMERICIDENTIFIER]})`),k("PRERELEASEIDENTIFIERLOOSE",`(?:${l[u.NONNUMERICIDENTIFIER]}|${l[u.NUMERICIDENTIFIERLOOSE]})`),k("PRERELEASE",`(?:-(${l[u.PRERELEASEIDENTIFIER]}(?:\\.${l[u.PRERELEASEIDENTIFIER]})*))`),k("PRERELEASELOOSE",`(?:-?(${l[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[u.PRERELEASEIDENTIFIERLOOSE]})*))`),k("BUILDIDENTIFIER",`${x}+`),k("BUILD",`(?:\\+(${l[u.BUILDIDENTIFIER]}(?:\\.${l[u.BUILDIDENTIFIER]})*))`),k("FULLPLAIN",`v?${l[u.MAINVERSION]}${l[u.PRERELEASE]}?${l[u.BUILD]}?`),k("FULL",`^${l[u.FULLPLAIN]}$`),k("LOOSEPLAIN",`[v=\\s]*${l[u.MAINVERSIONLOOSE]}${l[u.PRERELEASELOOSE]}?${l[u.BUILD]}?`),k("LOOSE",`^${l[u.LOOSEPLAIN]}$`),k("GTLT","((?:<|>)?=?)"),k("XRANGEIDENTIFIERLOOSE",`${l[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),k("XRANGEIDENTIFIER",`${l[u.NUMERICIDENTIFIER]}|x|X|\\*`),k("XRANGEPLAIN",`[v=\\s]*(${l[u.XRANGEIDENTIFIER]})(?:\\.(${l[u.XRANGEIDENTIFIER]})(?:\\.(${l[u.XRANGEIDENTIFIER]})(?:${l[u.PRERELEASE]})?${l[u.BUILD]}?)?)?`),k("XRANGEPLAINLOOSE",`[v=\\s]*(${l[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[u.XRANGEIDENTIFIERLOOSE]})(?:${l[u.PRERELEASELOOSE]})?${l[u.BUILD]}?)?)?`),k("XRANGE",`^${l[u.GTLT]}\\s*${l[u.XRANGEPLAIN]}$`),k("XRANGELOOSE",`^${l[u.GTLT]}\\s*${l[u.XRANGEPLAINLOOSE]}$`),k("COERCEPLAIN",`(^|[^\\d])(\\d{1,${a}})(?:\\.(\\d{1,${a}}))?(?:\\.(\\d{1,${a}}))?`),k("COERCE",`${l[u.COERCEPLAIN]}(?:$|[^\\d])`),k("COERCEFULL",l[u.COERCEPLAIN]+`(?:${l[u.PRERELEASE]})?(?:${l[u.BUILD]})?(?:$|[^\\d])`),k("COERCERTL",l[u.COERCE],!0),k("COERCERTLFULL",l[u.COERCEFULL],!0),k("LONETILDE","(?:~>?)"),k("TILDETRIM",`(\\s*)${l[u.LONETILDE]}\\s+`,!0),n.tildeTrimReplace="$1~",k("TILDE",`^${l[u.LONETILDE]}${l[u.XRANGEPLAIN]}$`),k("TILDELOOSE",`^${l[u.LONETILDE]}${l[u.XRANGEPLAINLOOSE]}$`),k("LONECARET","(?:\\^)"),k("CARETTRIM",`(\\s*)${l[u.LONECARET]}\\s+`,!0),n.caretTrimReplace="$1^",k("CARET",`^${l[u.LONECARET]}${l[u.XRANGEPLAIN]}$`),k("CARETLOOSE",`^${l[u.LONECARET]}${l[u.XRANGEPLAINLOOSE]}$`),k("COMPARATORLOOSE",`^${l[u.GTLT]}\\s*(${l[u.LOOSEPLAIN]})$|^$`),k("COMPARATOR",`^${l[u.GTLT]}\\s*(${l[u.FULLPLAIN]})$|^$`),k("COMPARATORTRIM",`(\\s*)${l[u.GTLT]}\\s*(${l[u.LOOSEPLAIN]}|${l[u.XRANGEPLAIN]})`,!0),n.comparatorTrimReplace="$1$2$3",k("HYPHENRANGE",`^\\s*(${l[u.XRANGEPLAIN]})\\s+-\\s+(${l[u.XRANGEPLAIN]})\\s*$`),k("HYPHENRANGELOOSE",`^\\s*(${l[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[u.XRANGEPLAINLOOSE]})\\s*$`),k("STAR","(<|>)?=?\\s*\\*"),k("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),k("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Oi,Oi.exports)),Oi.exports}var iu,Bh;function TM(){if(Bh)return iu;Bh=1;const e=Object.freeze({loose:!0}),n=Object.freeze({});return iu=o=>o?typeof o!="object"?e:o:n,iu}var lu,Wh;function SM(){if(Wh)return lu;Wh=1;const e=/^[0-9]+$/,n=(o,c)=>{if(typeof o=="number"&&typeof c=="number")return o===c?0:o<c?-1:1;const m=e.test(o),y=e.test(c);return m&&y&&(o=+o,c=+c),o===c?0:m&&!y?-1:y&&!m?1:o<c?-1:1};return lu={compareIdentifiers:n,rcompareIdentifiers:(o,c)=>n(c,o)},lu}var cu,qh;function NM(){if(qh)return cu;qh=1;const e=J0(),{MAX_LENGTH:n,MAX_SAFE_INTEGER:a}=ex(),{safeRe:o,t:c}=EM(),m=TM(),{compareIdentifiers:y}=SM();class h{constructor(f,u){if(u=m(u),f instanceof h){if(f.loose===!!u.loose&&f.includePrerelease===!!u.includePrerelease)return f;f=f.version}else if(typeof f!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof f}".`);if(f.length>n)throw new TypeError(`version is longer than ${n} characters`);e("SemVer",f,u),this.options=u,this.loose=!!u.loose,this.includePrerelease=!!u.includePrerelease;const p=f.trim().match(u.loose?o[c.LOOSE]:o[c.FULL]);if(!p)throw new TypeError(`Invalid Version: ${f}`);if(this.raw=f,this.major=+p[1],this.minor=+p[2],this.patch=+p[3],this.major>a||this.major<0)throw new TypeError("Invalid major version");if(this.minor>a||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>a||this.patch<0)throw new TypeError("Invalid patch version");p[4]?this.prerelease=p[4].split(".").map(x=>{if(/^[0-9]+$/.test(x)){const v=+x;if(v>=0&&v<a)return v}return x}):this.prerelease=[],this.build=p[5]?p[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(f){if(e("SemVer.compare",this.version,this.options,f),!(f instanceof h)){if(typeof f=="string"&&f===this.version)return 0;f=new h(f,this.options)}return f.version===this.version?0:this.compareMain(f)||this.comparePre(f)}compareMain(f){return f instanceof h||(f=new h(f,this.options)),this.major<f.major?-1:this.major>f.major?1:this.minor<f.minor?-1:this.minor>f.minor?1:this.patch<f.patch?-1:this.patch>f.patch?1:0}comparePre(f){if(f instanceof h||(f=new h(f,this.options)),this.prerelease.length&&!f.prerelease.length)return-1;if(!this.prerelease.length&&f.prerelease.length)return 1;if(!this.prerelease.length&&!f.prerelease.length)return 0;let u=0;do{const p=this.prerelease[u],x=f.prerelease[u];if(e("prerelease compare",u,p,x),p===void 0&&x===void 0)return 0;if(x===void 0)return 1;if(p===void 0)return-1;if(p===x)continue;return y(p,x)}while(++u)}compareBuild(f){f instanceof h||(f=new h(f,this.options));let u=0;do{const p=this.build[u],x=f.build[u];if(e("build compare",u,p,x),p===void 0&&x===void 0)return 0;if(x===void 0)return 1;if(p===void 0)return-1;if(p===x)continue;return y(p,x)}while(++u)}inc(f,u,p){if(f.startsWith("pre")){if(!u&&p===!1)throw new Error("invalid increment argument: identifier is empty");if(u){const x=`-${u}`.match(this.options.loose?o[c.PRERELEASELOOSE]:o[c.PRERELEASE]);if(!x||x[1]!==u)throw new Error(`invalid identifier: ${u}`)}}switch(f){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",u,p);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",u,p);break;case"prepatch":this.prerelease.length=0,this.inc("patch",u,p),this.inc("pre",u,p);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",u,p),this.inc("pre",u,p);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const x=Number(p)?1:0;if(this.prerelease.length===0)this.prerelease=[x];else{let v=this.prerelease.length;for(;--v>=0;)typeof this.prerelease[v]=="number"&&(this.prerelease[v]++,v=-2);if(v===-1){if(u===this.prerelease.join(".")&&p===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(x)}}if(u){let v=[u,x];p===!1&&(v=[u]),y(this.prerelease[0],u)===0?isNaN(this.prerelease[1])&&(this.prerelease=v):this.prerelease=v}break}default:throw new Error(`invalid increment argument: ${f}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return cu=h,cu}var uu,Yh;function AM(){if(Yh)return uu;Yh=1;const e=NM();return uu=(a,o,c=!1)=>{if(a instanceof e)return a;try{return new e(a,o)}catch(m){if(!c)return null;throw m}},uu}var IM=AM();const CM=Pg(IM);function Gh(e){if(!e)return"";const n=e.replace("+moya","");try{const o=CM(n,{includePrerelease:!0})?.prerelease;if(o&&o?.length>0){const m=String(o[0]).split("-")[1];return!m||!m.startsWith("g")?"":`https://github.com/TryGhost/Ghost/commit/${m.slice(1)}`}return`https://github.com/TryGhost/Ghost/releases/tag/v${n}`}catch{return""}}function DM(e,n){const a=!!e.match?.(/production/i);return!!(a&&n!=="mysql8"||!a&&n==="mysql5")}const RM=ye.create(({})=>{const{updateRoute:e}=Qe();let a=Je().config;const o=z_();function c(){return new Date().getFullYear()}function m(){return!!a.enableDeveloperExperiments}function y(){return!a.hostSettings?.siteId}return s.jsx(yt,{afterClose:()=>{e("")},cancelLabel:"",footer:s.jsx(s.Fragment,{}),topRightContent:"close",width:540,children:s.jsxs("div",{className:"flex flex-col gap-4 pb-7 text-sm",children:[s.jsx(H_,{className:"h-auto w-[120px] dark:invert"}),s.jsxs("div",{className:"mt-3 flex flex-col gap-1.5",children:[o?.message&&s.jsxs("div",{className:"gh-prose-links mb-4 rounded-sm border border-green p-5",children:[s.jsx("strong",{children:"Update available!"}),s.jsx("div",{dangerouslySetInnerHTML:{__html:o.message}})]}),Gh(a.version)&&s.jsxs("div",{children:[s.jsx("strong",{children:"Version:"})," ",s.jsx("a",{className:"text-green",href:Gh(a.version),rel:"noopener noreferrer",target:"_blank",children:a.version})]})||s.jsxs("div",{children:[s.jsx("strong",{children:"Version:"})," ",a.version]}),y()&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Environment:"})," ",a.environment]}),s.jsxs("div",{children:[s.jsx("strong",{children:"Database:"})," ",a.database]}),s.jsxs("div",{children:[s.jsx("strong",{children:"Mail:"})," ",a.mail?a.mail:"Native"]})]}),m()&&s.jsxs("div",{children:[s.jsx("strong",{children:"Developer experiments:"})," Enabled"]}),y()&&DM(a.environment,a.database)&&s.jsxs("div",{className:"text-red-500 dark:text-red-400",children:["You are running an unsupported database in production. Please ",s.jsx("a",{href:"https://ghost.org/docs/faq/supported-databases/",rel:"noopener noreferrer",target:"_blank",children:"upgrade to MySQL 8"}),"."]})]}),s.jsx(Va,{}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://ghost.org/docs/",rel:"noopener noreferrer",target:"_blank",children:[s.jsx(ut,{name:"book-open",size:"sm"})," User documentation"]}),s.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://forum.ghost.org/",rel:"noopener noreferrer",target:"_blank",children:[s.jsx(ut,{name:"question-circle",size:"sm"})," Get help with Ghost"]}),s.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://ghost.org/docs/contributing/",rel:"noopener noreferrer",target:"_blank",children:[s.jsx(ut,{name:"angle-brackets",size:"sm"})," Get involved"]})]}),s.jsx(Va,{}),s.jsxs("p",{className:"max-w-[460px] text-xs",children:["Copyright © 2013 – ",c()," Ghost Foundation, released under the ",s.jsx("a",{className:"text-green",href:"https://github.com/TryGhost/Ghost/blob/main/LICENSE",rel:"noopener noreferrer",target:"_blank",children:"MIT license"}),". ",s.jsx("a",{className:"text-green",href:"https://ghost.org/",rel:"noopener noreferrer",target:"_blank",children:"Ghost"})," is a registered trademark of ",s.jsx("a",{className:"text-green",href:"https://ghost.org/trademark/",rel:"noopener noreferrer",target:"_blank",children:"Ghost Foundation Ltd"}),"."]})]})})}),OM=()=>{const e=Zt(),{updateRoute:n}=Qe(),[a,o]=D.useState(""),[c,m]=D.useState({name:""}),{mutateAsync:y}=B_(),h=Ys(),l=ot();return D.useEffect(()=>{h?.isLimited("customIntegrations")&&h.errorIfWouldGoOverLimit("customIntegrations").catch(f=>{f instanceof Gs&&(ye.show(Xr,{prompt:f.message||"Your current plan doesn't support more custom integrations.",onOk:()=>n({route:"/pro",isExternal:!0})}),e.remove(),n("integrations"))})},[h,e,n]),s.jsx(yt,{afterClose:()=>{n("integrations")},okColor:"black",okLabel:"Add",size:"sm",testId:"add-integration-modal",title:"Add integration",onOk:async()=>{if(!a){m({name:"Name is required"});return}try{const f=await y({name:a});e.remove(),n({route:`integrations/${f.integrations[0].id}`})}catch(f){l(f)}},children:s.jsx("div",{className:"mt-5",children:s.jsx(tt,{marginBottom:!1,marginTop:!1,children:s.jsx(Ae,{autoFocus:!0,error:!!c.name,hint:c.name,maxLength:191,placeholder:"Custom integration",title:"Name",value:a,onChange:f=>o(f.target.value),onInput:()=>{c.name&&m({name:""})}})})})})},$M=ye.create(OM),LM=()=>{const e=Zt(),{updateRoute:n}=Qe(),a=ot(),[o,c]=D.useState(!0),[m,y]=D.useState(null),{data:h}=Fg({searchParams:{filter:"newsletters.status:active+email_disabled:0",limit:"1",page:"1",include:"newsletters,labels"}}),{mutateAsync:l}=T2(),{formState:f,updateForm:u,saveState:p,handleSave:x,errors:v,clearError:_}=kr({initialState:{name:"",description:"",optInExistingSubscribers:!0},onSave:async()=>{const T=await l({name:f.name,description:f.description,opt_in_existing:f.optInExistingSubscribers,feedback_enabled:!0});n({route:`newsletters/${T.newsletters[0].id}`})},onSaveError:a,onValidate:()=>{const T={};return f.name||(T.name="A name is required for your newsletter"),T}}),k=Ys();D.useEffect(()=>{if(!k){c(!1);return}k.errorIfWouldGoOverLimit("newsletters").catch(T=>{if(T instanceof Gs)y(T);else throw T}).finally(()=>{c(!1)})},[k]);const M=h?.meta?.pagination.total;return D.useEffect(()=>{m&&(ye.show(Xr,{prompt:m.message||"Your current plan doesn't support more newsletters.",onOk:()=>n({route:"/pro",isExternal:!0})}),e.remove(),n("newsletters"))},[m,e,n]),o||m?null:s.jsx(yt,{afterClose:()=>{n("newsletters")},backDropClick:!1,okColor:"black",okDisabled:p==="saving",okLabel:"Create",okLoading:p==="saving",size:"sm",testId:"add-newsletter-modal",title:"Create newsletter",onOk:async()=>{await x()&&e.remove()},children:s.jsxs(tt,{marginBottom:!1,marginTop:!0,children:[s.jsx(Ae,{autoFocus:!0,error:!!v.name,hint:v.name,maxLength:191,placeholder:"Weekly roundup",title:"Name",value:f.name,onChange:T=>u(A=>({...A,name:T.target.value})),onKeyDown:()=>_("name")}),s.jsx($n,{maxLength:2e3,title:"Description",value:f.description,onChange:T=>u(A=>({...A,description:T.target.value}))}),s.jsx(st,{checked:f.optInExistingSubscribers,direction:"rtl",hint:f.optInExistingSubscribers?`This newsletter will be available to all members. Your ${M===void 0?"":Wg(M)} existing subscriber${h?.meta?.pagination.total===1?"":"s"} will also be opted-in to receive it.`:"The newsletter will be available to all new members. Existing members won’t be subscribed, but may visit their account area to opt-in to future emails.",label:"Opt-in existing subscribers",labelStyle:"heading",onChange:T=>u(A=>({...A,optInExistingSubscribers:T.target.checked}))})]})})},PM=ye.create(LM),FM=({recommendation:e,animate:n})=>{const a=Zt(),{updateRoute:o,route:c}=Qe(),{mutateAsync:m}=W_(),y=ot(),{formState:h,updateForm:l,handleSave:f,saveState:u,errors:p,clearError:x,setErrors:v}=kr({initialState:{...e},onSave:async T=>{await m(T),a.remove(),xt({title:"Recommendation added",type:"success"}),Y_("Recommendation Added",{oneClickSubscribe:T.one_click_subscribe}),o("recommendations")},onSaveError:y,onValidate:T=>q_(T)});let _="Add",k=!1;u==="saving"?k=!0:u==="saved"&&(_="Added");let M={label:"Back",icon:"arrow-left",iconColorClass:"text-black dark:text-white",link:!0,size:"sm",onClick:()=>{u!=="saving"&&(a.remove(),ye.show(tx,{pathName:c,animate:!1,recommendation:{...h}}))}};return s.jsx(yt,{afterClose:()=>{o("recommendations")},animate:n??!0,backDropClick:!1,cancelLabel:"Cancel",dirty:!0,leftButtonProps:M,okColor:"black",okLabel:_,okLoading:k,size:"sm",testId:"add-recommendation-modal",title:"Add recommendation",stickyFooter:!0,onCancel:()=>{u!=="saving"&&(a.remove(),o("recommendations"))},onOk:async()=>{if(u!=="saving"){Ug();try{await f({force:!0})}catch{xt({type:"error",title:"Something went wrong when adding this recommendation, please try again."})}}},children:s.jsx(G_,{clearError:x,errors:p,formState:h,setErrors:v,showURL:!1,updateForm:l})})},UM=ye.create(FM),Xh=e=>Bi(e).save||"",zM=function(e,n){try{new URL(n).hostname.includes(".")?delete e.url:e.url="Enter a valid URL"}catch{e.url="Enter a valid URL"}return e},HM=({searchParams:e,recommendation:n,animate:a})=>{const[o,c]=D.useState(!1),m=Zt(),{updateRoute:y}=Qe(),{mutateAsync:h}=X_(),l=n?"":e?.get("url")??"",{save:f}=l?Bi(l):{save:""},u=at.useRef(!1),[p,x]=at.useState(!!f),{formState:v,updateForm:_,handleSave:k,errors:M,saveState:T,clearError:A}=kr({initialState:n??{title:"",url:f||"",description:"",excerpt:null,featured_image:null,favicon:null,one_click_subscribe:!1},onSave:async()=>{let O;O=new URL(v.url);const $=O.hostname.replace("www.",""),W={...v,url:O.toString()},{recommendations:R=[]}=await h(O);if(!R||R.length===0)return;const Z=R[0];if(Z.id)throw new ah("A recommendation with this URL already exists.");W.title=Z.title??$,W.excerpt=Z.excerpt??W.excerpt,W.featured_image=Z.featured_image??W.featured_image??null,W.favicon=Z.favicon??W.favicon??null,W.one_click_subscribe=Z.one_click_subscribe??W.one_click_subscribe??!1,W.description=W.excerpt||null,m.remove(),ye.show(UM,{animate:!1,recommendation:W})},onValidate:()=>{const O={};return zM(O,v.url),p&&x(Object.keys(O).length===0),O}}),C=at.useCallback(async()=>{if(T!=="saving"){Ug();try{if(await k({force:!0}))return}catch(O){const $=O instanceof ah?O.message:"Something went wrong while checking this URL, please try again.";xt({type:"error",title:$})}p&&x(!1)}},[k,T,p,x]);return at.useEffect(()=>{p&&!u.current&&(u.current=!0,C())},[p,C]),D.useEffect(()=>{o&&(C(),c(!1))},[v]),p?s.jsx(yt,{afterClose:()=>{y("recommendations")},animate:a??!0,backDropClick:!1,footer:!1,header:!1,size:"sm",children:s.jsx("div",{className:"flex flex-col items-center justify-center p-8",children:s.jsx(Wi,{})})}):s.jsxs(yt,{afterClose:()=>{y("recommendations")},animate:a??!0,backDropClick:!1,okColor:"black",okLabel:"Next",okLoading:T==="saving",size:"sm",testId:"add-recommendation-modal",title:"Add recommendation",onOk:C,children:[s.jsxs("p",{className:"mt-4",children:["You can recommend ",s.jsx("strong",{children:"any site"})," your audience will find valuable, not just those published on Ghost."]}),s.jsx(tt,{marginBottom:!1,marginTop:!0,children:s.jsx(Ae,{autoFocus:!0,error:!!M.url,hint:M.url||s.jsxs(s.Fragment,{children:["Need inspiration? ",s.jsx("a",{className:"text-green",href:"https://www.ghost.org/explore",rel:"noopener noreferrer",target:"_blank",children:"Explore thousands of sites"})," to recommend"]}),maxLength:2e3,placeholder:"https://www.example.com",title:"URL",value:v.url,onBlur:()=>{const O=Xh(v.url);_($=>({...$,url:O}))},onChange:O=>{A?.("url"),_($=>({...$,url:O.target.value}))},onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),_($=>({...$,url:Xh(v.url)})),c(!0))}})})]})},tx=ye.create(HM);function BM(e,n){let a;return function(...c){const m=()=>{clearTimeout(a),e(...c)};clearTimeout(a),a=setTimeout(m,n)}}const pd=({generateContent:e,className:n,height:a,width:o,parentClassName:c,testId:m,addDelay:y=!1})=>{const[h,l]=D.useState(0),f=[D.useRef(null),D.useRef(null)],[u,p]=D.useState(0);return D.useEffect(()=>{const x=h===0?1:0,v=f[x].current;if(v){e(v);const _=()=>{y?setTimeout(()=>{l(x)},500):l(x)};return v.addEventListener("load",_),()=>{v.removeEventListener("load",_)}}},[e]),D.useEffect(()=>{const x=f[h].current,v=BM(()=>{p(x?.contentWindow?.scrollY||0)},250);return x?.contentWindow?.addEventListener("scroll",v),()=>{x?.contentWindow?.removeEventListener("scroll",v)}},[h,f]),D.useEffect(()=>{const x=f[h].current;if(x)try{x.contentWindow?.scrollTo(0,u)}catch(v){m_(v)}},[u,h,f]),s.jsxs("div",{className:c,"data-testid":m,children:[s.jsx("iframe",{ref:f[0],className:`${n} ${h!==0?"z-10 opacity-0":"z-20 opacity-100"}`,"data-visible":h===0,frameBorder:"0",height:a,title:"Buffered Preview 1",width:o}),s.jsx("iframe",{ref:f[1],className:`${n} ${h!==1?"z-10 opacity-0":"z-20 opacity-100"}`,"data-visible":h===1,frameBorder:"0",height:a,title:"Buffered Preview 2",width:o})]})},WM=(e,n,a)=>{const o=new URLSearchParams;return o.append("announcement_bg",e||"accent"),o.append("announcement",n||""),a&&a.length>0&&o.append("announcement_vis",a?.join(",")||""),o.toString()},qM=({announcementBackgroundColor:e,announcementContent:n,url:a,visibility:o})=>{const c=D.useMemo(()=>o,[o?.join(",")]),m=D.useCallback(y=>{a&&fetch(a,{method:"POST",headers:{"Content-Type":"text/html;charset=utf-8","x-ghost-preview":WM(e,n,c),Accept:"text/plain"},mode:"cors",credentials:"include"}).then(h=>h.text()).then(h=>{const l="html { pointer-events: none; }",u=new DOMParser().parseFromString(h,"text/html"),p=u.querySelector("style"),x=p.innerHTML;p.innerHTML=`${x}
2
2
 
3
- ${l}`;let _=(u.doctype?new XMLSerializer().serializeToString(u.doctype):"")+u.documentElement.outerHTML;y.contentDocument?.open(),y.contentDocument?.write(_),y.contentDocument?.close()}).catch(()=>{})},[e,n,a,c]);return s.jsx(pd,{addDelay:!0,className:"absolute size-[110%] origin-top-left scale-[.90909] bg-white max-[1600px]:size-[130%] max-[1600px]:scale-[.76923]",generateContent:m,height:"100%",parentClassName:"relative h-full w-full",testId:"announcement-bar-preview-iframe",width:"100%"})},YM=({announcementContent:e,announcementTextHandler:n,accentColor:a,announcementBackgroundColor:o,toggleColorSwatch:c,toggleVisibility:m,visibility:y=[],paidMembersEnabled:h,onBlur:l})=>{const f=[{label:"Public visitors",onChange:u=>{m("visitors",u)},value:"visitors",checked:y.includes("visitors")},{label:"Free members",onChange:u=>{m("free_members",u)},value:"free_members",checked:y.includes("free_members")},...h?[{label:"Paid members",onChange:u=>{m("paid_members",u)},value:"paid_members",checked:y.includes("paid_members")}]:[]];return s.jsxs(tt,{children:[s.jsx(ld,{nodes:"MINIMAL_NODES",placeholder:"Highlight breaking news, offers or updates",title:"Announcement",value:e,onBlur:l,onChange:n}),s.jsx(u0,{isExpanded:!1,picker:!1,swatches:[{hex:"#08090c",title:"Dark",value:"dark"},{hex:"#ffffff",title:"Light",value:"light"},{hex:a||"#ffdd00",title:"Accent",value:"accent"}],swatchSize:"lg",title:"Background color",value:o,onSwatchChange:u=>{u!==null&&c(u)},onTogglePicker:()=>{}}),s.jsx(Cf,{checkboxes:f,title:"Visibility"})]})},GM=()=>{const{siteData:e}=Je(),{localSettings:n,updateSetting:a,handleSave:o,okProps:c}=ss({savingDelay:500}),[m]=gt(n,["announcement_content"]),[y]=gt(n,["accent_color"]),[h]=gt(n,["announcement_background"]),[l]=gt(n,["announcement_visibility"]),[f]=gt(n,["paid_members_enabled"]),u=JSON.parse(l?.toString()||"[]"),{updateRoute:p}=Qe(),[x,v]=D.useState("homepage"),_=R=>{a("announcement_background",R)},k=(R,Z)=>{const X=u.indexOf(R);X===-1&&Z?u.push(R):u.splice(X,1),a("announcement_visibility",JSON.stringify(u))},M=D.useRef(Ji(R=>{a("announcement_content",R)},500)),T=s.jsx(YM,{accentColor:y,announcementBackgroundColor:h,announcementContent:m,announcementTextHandler:R=>{M.current(R)},paidMembersEnabled:f,toggleColorSwatch:_,toggleVisibility:k,visibility:l,onBlur:()=>{}}),{data:{posts:[A]}={posts:[]}}=i0({searchParams:{filter:"status:published",order:"published_at DESC",limit:"1",fields:"id,url"}});let C=[];A&&(C=[{id:"homepage",title:"Homepage"},{id:"post",title:"Post"}]);const O=R=>{C.length&&v(R)};let $=ln(e);switch(x){case"homepage":$=ln(e);break;case"post":$=A.url;break}const W=s.jsx(qM,{announcementBackgroundColor:h,announcementContent:m,url:$,visibility:u});return s.jsx(Zs,{afterClose:()=>{p("announcement-bar")},buttonsDisabled:c.disabled,cancelLabel:"Close",deviceSelector:!0,dirty:!1,okColor:c.color,okLabel:c.label||"Save",preview:W,previewBgColor:"greygradient",previewToolbarTabs:C,selectedURL:x,sidebar:T,testId:"announcement-bar-modal",title:"Announcement",titleHeadingLevel:5,onOk:async()=>{await o({fakeWhenUnchanged:!0})||xt({type:"error",message:"An error occurred while saving your changes. Please try again."})},onSelectURL:O})},XM=ye.create(GM),Bf=[{label:"Global",options:[{value:"site.changed",label:"Site changed (rebuild)"}]},{label:"Posts",options:[{value:"post.added",label:"Post created"},{value:"post.deleted",label:"Post deleted"},{value:"post.edited",label:"Post updated"},{value:"post.published",label:"Post published"},{value:"post.published.edited",label:"Published post updated"},{value:"post.unpublished",label:"Post unpublished"},{value:"post.scheduled",label:"Post scheduled"},{value:"post.unscheduled",label:"Post unscheduled"},{value:"post.tag.attached",label:"Tag added to post"},{value:"post.tag.detached",label:"Tag removed from post"}]},{label:"Pages",options:[{value:"page.added",label:"Page created"},{value:"page.deleted",label:"Page deleted"},{value:"page.edited",label:"Page updated"},{value:"page.published",label:"Page published"},{value:"page.published.edited",label:"Published page updated"},{value:"page.unpublished",label:"Page unpublished"},{value:"page.tag.attached",label:"Tag added to page"},{value:"page.tag.detached",label:"Tag removed from page"}]},{label:"Tags",options:[{value:"tag.added",label:"Tag created"},{value:"tag.edited",label:"Tag updated"},{value:"tag.deleted",label:"Tag deleted"}]},{label:"Members",options:[{value:"member.added",label:"Member added"},{value:"member.edited",label:"Member updated"},{value:"member.deleted",label:"Member deleted"}]}],KM=e=>Bf.flatMap(({options:a})=>a).find(a=>a.value===e)?.label,ZM=ns({method:"POST",path:()=>"/webhooks/",body:e=>({webhooks:[e]}),updateQueries:{dataType:el,emberUpdateType:"createOrUpdate",update:(e,n)=>n&&{...n,integrations:n.integrations.map(a=>{const o=e.webhooks[0];return o.integration_id===a.id?{...a,webhooks:[...a.webhooks||[],o]}:a})}}}),VM=ns({method:"PUT",path:e=>`/webhooks/${e.id}/`,body:e=>({webhooks:[e]}),updateQueries:{dataType:el,emberUpdateType:"createOrUpdate",update:(e,n)=>n&&{...n,integrations:n.integrations.map(a=>{var o;return{...a,webhooks:(o=a.webhooks)==null?void 0:o.map(c=>c.id===e.webhooks[0].id?e.webhooks[0]:c)}})}}}),QM=ns({method:"DELETE",path:e=>`/webhooks/${e}/`,updateQueries:{dataType:el,emberUpdateType:"createOrUpdate",update:(e,n,a)=>({...n,integrations:n.integrations.map(o=>{var c;return{...o,webhooks:(c=o.webhooks)==null?void 0:c.filter(m=>m.id!==a)}})})}}),JM=({webhook:e,integrationId:n})=>{const a=Zt(),{mutateAsync:o}=ZM(),{mutateAsync:c}=VM(),m=ot(),{formState:y,updateForm:h,handleSave:l,errors:f,clearError:u}=kr({initialState:e||{},onSave:async()=>{y.id?await c(y):await o({...y,integration_id:n})},onSaveError:m,onValidate:()=>{const p={};return y.name||(p.name="Enter a name"),y.event||(p.event="Select an event"),y.target_url||(p.target_url="Enter a target URL"),y.target_url&&!Nt.isURL(y.target_url,{require_tld:!1})&&(p.target_url="Enter a valid URL"),p}});return s.jsx(yt,{okColor:"black",okLabel:e?"Update":"Add",size:"sm",testId:"webhook-modal",title:"Add webhook",formSheet:!0,onOk:async()=>{await l()&&a.remove()},children:s.jsx("div",{className:"mt-5",children:s.jsxs(tt,{marginBottom:!1,marginTop:!1,children:[s.jsx(Ae,{error:!!f.name,hint:f.name,maxLength:191,placeholder:"Custom webhook",title:"Name",value:y.name,onChange:p=>h(x=>({...x,name:p.target.value})),onKeyDown:()=>u("name")}),s.jsx(Lt,{error:!!f.event,hint:f.event,options:Bf,prompt:"Select an event",selectedOption:Bf.flatMap(p=>p.options).find(p=>p.value===y.event),testId:"event-select",title:"Event",hideTitle:!0,onSelect:p=>{h(x=>({...x,event:p?.value})),u("event")}}),s.jsx(Ae,{error:!!f.target_url,hint:f.target_url,maxLength:2e3,placeholder:"https://example.com",title:"Target URL",type:"url",value:y.target_url,onChange:p=>h(x=>({...x,target_url:p.target.value})),onKeyDown:()=>u("target_url")}),s.jsx(Ae,{maxLength:191,placeholder:"https://example.com",title:"Secret",value:y.secret||void 0,onChange:p=>h(x=>({...x,secret:p.target.value}))})]})})})},Kh=ye.create(JM),ej=({integration:e})=>{const{mutateAsync:n}=QM(),a=ot(),o=c=>{ye.show(Et,{title:"Are you sure?",prompt:"Deleting this webhook may prevent the integration from functioning.",okColor:"red",okLabel:"Delete Webhook",onOk:async m=>{try{await n(c),m?.remove(),xt({message:"Webhook deleted",type:"info"})}catch(y){a(y)}}})};return s.jsxs("div",{children:[s.jsxs(K_,{children:[s.jsxs(dh,{bgOnHover:!1,children:[s.jsxs(Fh,{children:[e.webhooks?.length||0," ",e.webhooks?.length===1?"webhook":"webhooks"]}),s.jsx(Fh,{children:"Last triggered"})]}),e.webhooks?.map(c=>s.jsxs(dh,{action:s.jsx(Ue,{color:"red",label:"Delete",link:!0,onClick:m=>{m?.stopPropagation(),o(c.id)}}),bgOnHover:!1,hideActions:!0,onClick:()=>{ye.show(Kh,{webhook:c,integrationId:e.id})},children:[s.jsxs(ph,{className:"w-3/4",children:[s.jsx("div",{className:"text-sm font-semibold",children:c.name}),s.jsxs("div",{className:"grid grid-cols-[max-content_1fr] gap-x-1 text-xs leading-snug",children:[s.jsx("span",{className:"text-grey-600",children:"Event:"}),s.jsx("span",{children:KM(c.event)}),s.jsx("span",{className:"text-grey-600",children:"URL:"}),s.jsx("span",{className:"line-clamp-3 break-all",title:c.target_url,children:c.target_url})]})]}),s.jsx(ph,{className:"w-1/4 text-sm",children:c.last_triggered_at&&new Date(c.last_triggered_at).toLocaleString("default",{weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})})]}))]}),s.jsx("div",{className:"mt-5",children:s.jsx(Ue,{color:"green",icon:"add",iconColorClass:"text-green",label:"Add webhook",size:"sm",link:!0,onClick:()=>{ye.show(Kh,{integrationId:e.id})}})})]})},tj=({integration:e})=>{const n=Zt(),{updateRoute:a}=Qe(),{mutateAsync:o}=Z_(),{mutateAsync:c}=dd(),{mutateAsync:m}=Xs(),y=ot(),{formState:h,updateForm:l,handleSave:f,saveState:u,errors:p,clearError:x,okProps:v}=kr({initialState:e,savingDelay:500,savedDelay:500,onSave:async()=>{await o(h)},onSavedStateReset:()=>{a("integrations")},onSaveError:y,onValidate:()=>{const $={};return h.name||($.name="Enter integration title"),$}}),_=e.api_keys?.find($=>$.type==="admin"),k=e.api_keys?.find($=>$.type==="content"),[M,T]=D.useState(!1),[A,C]=D.useState(!1);D.useEffect(()=>{e.type!=="custom"&&(n.remove(),a("integrations"))},[e.type,n,a]);const O=($,W)=>{W(!1);const R=$.type==="content"?"Content":"Admin";ye.show(Et,{title:`Regenerate ${R} API Key`,prompt:`You can regenerate ${R} API Key any time, but any scripts or applications using it will need to be updated.`,okLabel:`Regenerate ${R} API Key`,onOk:async Z=>{try{await c({integrationId:e.id,apiKeyId:$.id}),W(!0),Z?.remove()}catch(X){y(X)}}})};return s.jsxs(yt,{afterClose:()=>{a("integrations")},buttonsDisabled:v.disabled,cancelLabel:"Close",dirty:u==="unsaved",okColor:v.color,okLabel:v.label||"Save",size:"md",testId:"custom-integration-modal",title:h.name||"Custom integration",stickyFooter:!0,onOk:async()=>{await f({fakeWhenUnchanged:!0})},children:[s.jsxs("div",{className:"mt-7 flex w-full flex-col gap-7 md:flex-row",children:[s.jsx("div",{children:s.jsx(un,{height:"100px",id:"custom-integration-icon",imageURL:h.icon_image||void 0,width:"100px",onDelete:()=>l($=>({...$,icon_image:null})),onUpload:async $=>{try{const W=on(await m({file:$}));l(R=>({...R,icon_image:W}))}catch(W){const R=W;R.response.status===415&&(R.message="Unsupported file type"),y(R)}},children:"Upload icon"})}),s.jsx("div",{className:"flex grow flex-col",children:s.jsxs(tt,{children:[s.jsx(Ae,{error:!!p.name,hint:p.name,maxLength:191,title:"Title",value:h.name,onChange:$=>l(W=>({...W,name:$.target.value})),onKeyDown:()=>x("name")}),s.jsx(Ae,{maxLength:2e3,title:"Description",value:h.description||"",onChange:$=>l(W=>({...W,description:$.target.value}))}),s.jsx(al,{keys:[{label:"Content API key",text:k?.secret,hint:A?s.jsx("div",{className:"text-green",children:"Content API Key was successfully regenerated"}):void 0,onRegenerate:()=>k&&O(k,C)},{label:"Admin API key",text:_?.secret,hint:M?s.jsx("div",{className:"text-green",children:"Admin API Key was successfully regenerated"}):void 0,onRegenerate:()=>_&&O(_,T)},{label:"API URL",text:window.location.origin+no().subdir}]})]})})]}),s.jsx("div",{children:s.jsx(ej,{integration:e})})]})},rj=({params:e})=>{const{data:{integrations:n}={}}=Qf(),a=n?.find(({id:o})=>o===e?.id);return a?s.jsx(tj,{integration:a}):null},nj=ye.create(rj),sj=({problem:e})=>{const[n,a]=D.useState(!1),o=()=>{a(!n)};return s.jsx(On,{title:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`${e.level==="error"?"before:bg-red":"before:bg-yellow"} relative px-4 text-sm before:absolute before:left-0 before:top-1.5 before:block before:size-2 before:rounded-full before:content-['']`,children:[e?.fatal?s.jsx("strong",{children:"Fatal: "}):s.jsx("strong",{children:e.level==="error"?"Error: ":"Warning: "}),s.jsx("span",{dangerouslySetInnerHTML:{__html:e.rule}}),s.jsx("div",{className:"absolute -right-4 top-1",children:s.jsx(Ue,{color:"green",icon:n?"chevron-down":"chevron-right",iconColorClass:"text-grey-700",size:"sm",link:!0,onClick:()=>o()})})]}),n?s.jsxs("div",{className:"mt-2 px-4 text-[13px] leading-8",children:[s.jsx("div",{dangerouslySetInnerHTML:{__html:e.details},className:"mb-4"}),s.jsx(bt,{level:6,children:"Affected files:"}),s.jsx("ul",{className:"mt-1",children:e.failures.map(c=>s.jsxs("li",{children:[s.jsx("code",{children:c.ref}),c.message?`: ${c.message}`:""]}))})]}):null]}),hideActions:!0,separator:!0})},aj=({title:e,prompt:n,fatalErrors:a,onRetry:o})=>{let c=null;return a&&(c=s.jsx("div",{className:"mt-10",children:s.jsx(cn,{title:"Errors",children:a.map(m=>typeof m.details=="object"&&m.details.errors&&m.details.errors.length>0?m.details.errors.map(y=>s.jsx(sj,{problem:y})):typeof m.details=="string"?s.jsx(On,{title:m.details}):null)})})),s.jsx(qg,{cancelLabel:"Close",okColor:"black",okLabel:"Retry",prompt:s.jsxs(s.Fragment,{children:[n,c]}),title:e,onOk:o})},rx=ye.create(aj),hd=()=>{const e=V_(),a=!e.data?.themes[0]?.warnings?.some(c=>c.code==="GS051-CUSTOM-FONTS"),o=D.useCallback(()=>{e.refetch()},[e]);return{supportsCustomFonts:a,refreshActiveThemeData:o}};function oj(e){let n=e.package?.name||e.name;return Q_(e)?n+=" (default)":J_(e)?n+=" (legacy)":e.package?.name!==e.name&&(n=s.jsxs("span",{className:"text-sm md:text-base",children:[n," ",s.jsxs("span",{className:"text-grey-600",children:["(",e.name,")"]})]})),Yg(e)&&(n=s.jsxs("span",{className:"text-sm font-bold md:text-base",children:[n," — ",s.jsx("span",{className:"text-green",children:" Active"})]})),n}function ij(e){return e.package?.version||"1.0"}const lj=({theme:e})=>{const{mutateAsync:n}=Jf(),{mutateAsync:a}=e2(),{refreshActiveThemeData:o}=hd(),c=ot(),m=async()=>{try{await n(e.name),o(),xt({title:"Theme activated",type:"success",message:s.jsxs("div",{children:[s.jsx("span",{className:"capitalize",children:e.name})," is now your active theme"]})})}catch(p){let x=null;p instanceof ts&&p.response?.status===422&&p.data?.errors?x=p.data.errors:c(p);let v="Invalid Theme",_=s.jsx(s.Fragment,{children:"This theme is invalid and cannot be activated. Fix the following errors and re-upload the theme"});x&&ye.show(rx,{title:v,prompt:_,fatalErrors:x,onRetry:async k=>{k?.remove(),m()}})}},y=async()=>{const{apiRoot:p}=no();g_(`${p}/themes/${e.name}/download`)},h=async()=>{ye.show(Et,{title:"Are you sure you want to delete this?",prompt:s.jsxs(s.Fragment,{children:["You are about to delete ",s.jsxs("strong",{children:['"',e.name,'".']})," This is permanent! We warned you, k? Maybe download"," ",s.jsx("span",{className:"cursor-pointer text-green-500",onClick:()=>{y()},children:"your theme before continuing"})]}),okLabel:"Delete",okRunningLabel:"Deleting",okColor:"red",onOk:async p=>{try{await a(e.name),p?.remove()}catch(x){c(x)}}})};let l=[];Yg(e)||l.push(s.jsx(Ue,{className:"ml-2",color:"green",label:"Activate",link:!0,onClick:m},"activate"));let f=[{id:"download",label:"Download",onClick:y}];t2(e)&&f.push({id:"delete",label:"Delete",onClick:h});const u={iconColorClass:"text-base",size:"sm"};return s.jsxs("div",{className:"-mr-3 flex items-center gap-4",children:[l,s.jsx(E0,{items:f,position:"end",triggerButtonProps:u})]})},cj=({themes:e})=>(e.sort((n,a)=>n.active&&!a.active?-1:!n.active&&a.active?1:n.package?.name&&a.package?.name?n.package.name.localeCompare(a.package.name):n.name.localeCompare(a.name)),s.jsx(cn,{pageTitle:"Installed themes",children:e.map(n=>{const a=oj(n),o=ij(n);return s.jsx(On,{action:s.jsx(lj,{theme:n}),detail:o,id:`theme-${n.name}`,separator:!1,testId:"theme-list-item",title:a},n.name)})})),uj=({themes:e})=>s.jsx(ud,{children:s.jsx(cj,{themes:e})}),fj=""+new URL("footer-marketplace-bg-BpIYEF6z.png",import.meta.url).href,dj=3e3,Zh=e=>e.variants&&e.variants.length>0,fu=e=>{const n=[{category:e.category,previewUrl:e.previewUrl,image:e.image}];return e.variants&&e.variants.length>0&&n.push(...e.variants),n},pj=({onSelectTheme:e})=>{const n=r2(),[a,o]=D.useState(null),[c,m]=D.useState(0),y=h=>{o(h),m(h!==null&&Zh(h)&&fu(h).length>1?1:0)};return D.useEffect(()=>{if(a===null)return;const h=setInterval(()=>{m((c+1)%(fu(a).length||0))},dj);return()=>clearInterval(h)},[a,c]),s.jsxs(ud,{heading:"Themes",children:[s.jsx("div",{className:"mt-[6vmin] grid grid-cols-1 gap-[6vmin] sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4",children:n.map(h=>{const l=Zh(h),f=fu(h),u=a===h;return s.jsxs("button",{className:"flex cursor-pointer flex-col gap-3 text-left",type:"button",onClick:()=>{e?.(h)},children:[s.jsx("div",{className:"relative w-full bg-grey-100 shadow-md transition-all duration-500 hover:scale-[1.05]",onMouseEnter:()=>y(h),onMouseLeave:()=>y(null),children:l?s.jsx(s.Fragment,{children:f.map((p,x)=>s.jsx("img",{alt:`${h.name} Theme - ${p.category}`,className:we("size-full object-contain opacity-0 transition-opacity duration-500",{"opacity-100":x===c&&u||!u&&x===0,relative:x===c,absolute:x!==c,"left-0":x!==c,"top-0":x!==c}),src:p.image},`theme-variant-${p.category.toLowerCase()}`))}):s.jsx("img",{alt:`${h.name} Theme`,className:"size-full object-contain",src:h.image})}),s.jsxs("div",{className:"relative mt-3",children:[s.jsx(bt,{level:4,children:h.name}),l?f.map((p,x)=>s.jsx("span",{className:we("absolute left-0 translate-y-px text-sm text-grey-700 opacity-0",{"opacity-100":x===c&&u||!u&&x===0}),children:p.category})):s.jsx("span",{className:"text-sm text-grey-700",children:h.category})]})]},h.name)})}),s.jsxs("div",{className:"mx-[-8vmin] mb-[-8vmin] mt-[8vmin] bg-black px-[8vmin] py-16 text-center text-lg text-white",style:{background:`#15171a url(${fj}) 100% 100% / 35vw no-repeat`},children:["Find and buy third-party, premium themes from independent developers in the ",s.jsx("a",{className:"inline-block font-semibold text-lime",href:"https://ghost.org/themes/",rel:"noopener noreferrer",target:"_blank",children:"Ghost Marketplace →"})]})]})},Vh=({problem:e})=>{const[n,a]=D.useState(!1);return s.jsx(On,{title:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`${e.level==="error"?"before:bg-red":"before:bg-yellow"} relative px-4 text-sm before:absolute before:left-0 before:top-1.5 before:block before:size-2 before:rounded-full before:content-['']`,children:[s.jsx("strong",{children:e.level==="error"?"Error: ":"Warning: "}),s.jsx("span",{dangerouslySetInnerHTML:{__html:e.rule}}),s.jsx("div",{className:"absolute -right-4 top-1",children:s.jsx(Ue,{color:"green",icon:n?"chevron-down":"chevron-right",iconColorClass:"text-grey-700",size:"sm",link:!0,onClick:()=>a(!n)})})]}),n?s.jsxs("div",{className:"mt-2 px-4 text-[13px] leading-8",children:[s.jsx("div",{dangerouslySetInnerHTML:{__html:e.details},className:"mb-4"}),s.jsx(bt,{level:6,children:"Affected files:"}),s.jsx("ul",{className:"mt-1",children:e.failures.map(o=>s.jsxs("li",{children:[s.jsx("code",{children:o.ref}),o.message?`: ${o.message}`:""]}))})]}):null]}),hideActions:!0,separator:!0})},hj=({title:e,prompt:n,installedTheme:a,onActivate:o})=>{const{mutateAsync:c}=Jf(),{refreshActiveThemeData:m}=hd(),y=ot();let h=null;a&&a.gscan_errors&&(h=s.jsx("div",{className:"mt-6",children:s.jsx(cn,{hint:s.jsxs(s.Fragment,{children:["Highly recommended to fix, functionality ",s.jsx("strong",{children:"could"})," be restricted"]}),title:"Errors",children:a.gscan_errors?.map(u=>s.jsx(Vh,{problem:u}))})}));let l=null;a&&a.warnings&&(l=s.jsx("div",{className:"mt-10",children:s.jsx(cn,{title:"Warnings",children:a.warnings?.map(u=>s.jsx(Vh,{problem:u}))})}));let f=`Activate${a.gscan_errors?.length?" with errors":""}`;return a.active&&(f="OK"),s.jsx(qg,{cancelLabel:"Close",okColor:"black",okLabel:f,okRunningLabel:"Activating...",prompt:s.jsxs(s.Fragment,{children:[n,h,l]}),title:e,onOk:async u=>{if(!a.active)try{const x=(await c(a.name)).themes[0];m(),xt({title:"Theme activated",type:"success",message:s.jsxs("div",{children:[s.jsx("span",{className:"capitalize",children:x.name})," is now your active theme."]})})}catch(p){y(p)}o?.(),u?.remove()}})},nx=ye.create(hj),Qh=e=>e.variants&&e.variants.length>0,Jh=e=>{const n=[{image:e.image,category:e.category,previewUrl:e.previewUrl}];return e.variants&&e.variants.length>0&&n.push(...e.variants),n},em=e=>e.category.toLowerCase(),mj=({selectedTheme:e,isInstalling:n,installedTheme:a,onBack:o,onInstall:c})=>{const[m,y]=D.useState("desktop"),[h,l]=D.useState(void 0);if(!e)return null;let f=e.previewUrl;const u=Jh(e).map(k=>({label:k.category,value:em(k)}));Qh(e)&&(h===void 0&&l(u[0]),f=Jh(e).find(k=>em(k)===h?.value)?.previewUrl||f);let p=`Install ${e.name}`;n?p="Installing...":qi(e)&&!a?.active?p=`Activate ${e.name}`:a&&(p=`Update ${e.name}`);const x=()=>{c?.()},v=s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fd,{activeItemClassName:"hidden md:!block md:!visible",containerClassName:"whitespace-nowrap",itemClassName:"hidden md:!block md:!visible",items:[{label:"Change theme",onClick:o},{label:e.name}],separatorClassName:"hidden md:!block md:!visible",backIcon:!0,onBack:o}),Qh(e)?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hidden md:!visible md:!block",children:"–"}),s.jsx(Lt,{border:!1,containerClassName:"text-sm font-bold",controlClasses:{menu:"w-24"},fullWidth:!1,options:u,selectedOption:h,clearBg:!0,onSelect:k=>{l(k||void 0)}})]}):null]}),_=s.jsxs("div",{className:"flex justify-end gap-8",children:[s.jsx(an,{buttons:[{icon:"laptop",iconColorClass:m==="desktop"?"text-black dark:text-green":"text-grey-500 dark:text-grey-600",link:!0,size:"sm",onClick:()=>{y("desktop")}},{icon:"mobile",iconColorClass:m==="mobile"?"text-black dark:text-green":"text-grey-500 dark:text-grey-600",link:!0,size:"sm",onClick:()=>{y("mobile")}}]}),s.jsx(Ue,{color:"green",disabled:n,label:n?"Installing...":p,onClick:x})]});return s.jsxs("div",{className:"absolute inset-0 z-[100]",children:[s.jsx(F0,{containerClassName:"bg-grey-50 dark:bg-black z-[100]",left:v,right:_,sticky:!1}),s.jsx("div",{className:"flex h-[calc(100%-92px)] grow flex-col items-center justify-center bg-grey-50 dark:bg-black",children:m==="desktop"?s.jsx(l0,{children:s.jsx("iframe",{className:"size-full",src:f,title:"Theme preview"})}):s.jsx(c0,{children:s.jsx("iframe",{className:"size-full",src:f,title:"Theme preview"})})})]})},gj=({onUpload:e})=>{const n=Zt();return s.jsx("div",{className:"-mb-6",children:s.jsx(a2,{id:"theme-upload",onUpload:a=>{n.remove(),e(a)},children:s.jsx("div",{className:"cursor-pointer bg-grey-75 p-10 text-center dark:bg-grey-950",children:"Click to select or drag & drop zip file"})})})},xj=({currentTab:e,setCurrentTab:n,themes:a})=>{const o=Zt(),{updateRoute:c}=Qe(),{mutateAsync:m}=s2(),{checkThemeLimitError:y,isThemeLimited:h}=td(),l=ot(),[f,u]=D.useState(),[p,x]=D.useState(!1);D.useEffect(()=>{(async()=>{if(h){const O=await y(".");u({enabled:!1,error:O||"Your current plan doesn't support uploading custom themes."})}else u({enabled:!0})})()},[y,h]);const v=()=>{c("/")},_=async C=>{const O=C?.name.replace(/\.zip$/,""),$=a.map(W=>W.name);qi({name:O})?ye.show(Et,{title:"Upload failed",cancelLabel:"Cancel",okLabel:"",prompt:s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["The default ",s.jsx("strong",{children:O})," theme cannot be overwritten."]}),s.jsx("p",{children:"Rename your zip file and try again."})]}),onOk:async W=>{W?.remove()}}):$.includes(O)?ye.show(Et,{title:"Overwrite theme",prompt:s.jsxs(s.Fragment,{children:["The theme ",s.jsx("strong",{children:O})," already exists. Do you want to overwrite it?"]}),okLabel:"Overwrite",cancelLabel:"Cancel",okRunningLabel:"Overwriting...",okColor:"red",onOk:async W=>{x(!0);const R=$.indexOf(O);a.splice(R,1),await k({file:C,onActivate:v}),x(!1),n("installed"),W?.remove()}}):(n("installed"),k({file:C,onActivate:v}))},k=async({file:C,onActivate:O})=>{let $,W=null;try{x(!0),$=await m({file:C}),x(!1)}catch(q){x(!1),q instanceof ts&&q.response?.status===422&&q.data?.errors?W=q.data.errors:l(q)}if(W&&!$){let q="Invalid Theme",B=s.jsx(s.Fragment,{children:"This theme is invalid and cannot be activated. Fix the following errors and re-upload the theme"});ye.show(rx,{title:q,prompt:B,fatalErrors:W,onRetry:async()=>{o?.remove(),T()}})}if(!$)return;const R=$.themes[0];let Z="Upload successful",X=s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:R.name})," uploaded"]});if(R.active||(X=s.jsxs(s.Fragment,{children:[X," ","Do you want to activate it now?"]})),R?.gscan_errors?.length||R.warnings?.length){const q=R?.gscan_errors?.length;Z=`Upload successful with ${q?"errors":"warnings"}`,X=s.jsxs(s.Fragment,{children:["The theme ",s.jsxs("strong",{children:['"',R.name,'"']})," was installed but we detected some ",q?"errors":"warnings","."]}),R.active||(X=s.jsxs(s.Fragment,{children:[X,"You are still able to activate and use the theme but it is recommended to fix these ",q?"errors":"warnings"," before you do so."]}))}ye.show(nx,{title:Z,prompt:X,installedTheme:R,onActivate:O})},M=s.jsx("div",{className:"hidden md:!visible md:!block",children:s.jsx(Dn,{border:!1,selectedTab:e,tabs:[{id:"official",title:"Official themes"},{id:"installed",title:"Installed"}],onTabChange:C=>{n(C)}})}),T=()=>{f&&(f.enabled?ye.show(Et,{title:"Upload theme",prompt:s.jsx(gj,{onUpload:_}),okLabel:"",formSheet:!1}):ye.show(Xr,{title:"Upgrade to enable custom themes",prompt:f.error||s.jsxs(s.Fragment,{children:["Your current plan only supports official themes. You can install them from the ",s.jsx("a",{href:"https://ghost.org/marketplace/",children:"Ghost theme marketplace"}),"."]}),onOk:()=>c({route:"/pro",isExternal:!0})}))},A=s.jsx("div",{className:"flex items-center gap-14",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ue,{label:"Close",onClick:()=>{o.remove(),v()}}),s.jsx(Ue,{color:"black",label:"Upload theme",loading:p,onClick:T})]})});return s.jsxs(s.Fragment,{children:[s.jsx(F0,{containerClassName:"bg-white dark:bg-black",left:M,right:A}),s.jsx("div",{className:"px-[8vmin] md:hidden",children:s.jsx(Dn,{border:!1,selectedTab:e,tabs:[{id:"official",title:"Official themes"},{id:"installed",title:"Installed"}],onTabChange:C=>{n(C)}})})]})},bj=({currentTab:e,onSelectTheme:n,themes:a})=>{switch(e){case"official":return s.jsx(pj,{onSelectTheme:n});case"installed":return s.jsx(uj,{themes:a})}return null},tm=({source:e,themeRef:n})=>{const[a,o]=D.useState("official"),[c,m]=D.useState(null),[y,h]=D.useState("desktop"),[l,f]=D.useState(!1),[u,p]=D.useState(!1),[x,v]=D.useState(!1),{updateRoute:_}=Qe(),k=Zt(),{data:{themes:M}={}}=ed(),{mutateAsync:T}=n2(),{mutateAsync:A}=Jf(),{checkThemeLimitError:C}=td(),O=ot(),$=Z=>{m(Z)};if(D.useEffect(()=>{v(!0)},[]),D.useEffect(()=>{(async()=>{if(e&&n&&!u&&x){const X=n.split("/")[1];if(await C(X)){k.remove();return}let B="Install Theme";const Y=M?.map(ne=>ne.name)||[];let ae=Y.includes(X.toLowerCase());const ee=Y.indexOf(X.toLowerCase()),re=M?.[ee];let Q=s.jsxs(s.Fragment,{children:["By clicking below, ",s.jsx("strong",{children:X})," will automatically be activated as the theme for your site.",ae&&s.jsxs(s.Fragment,{children:[s.jsx("br",{}),s.jsx("br",{}),"This will overwrite your existing version of ",s.jsx("strong",{children:X}),re?.active?" which is your active theme":"",". All custom changes will be lost."]})]});ye.show(Et,{title:B,prompt:Q,okLabel:"Install",cancelLabel:"Cancel",okRunningLabel:"Installing...",okColor:"black",onOk:async ne=>{let be;p(!0);try{ae&&M&&M.splice(ee,1),be=await T(n),be?.themes[0]&&(await A(be.themes[0].name),xt({title:"Theme activated",type:"success",message:s.jsxs("div",{children:[s.jsx("span",{className:"capitalize",children:be.themes[0].name})," is now your active theme"]})})),ne?.remove(),_("")}catch(je){O(je)}}})}})()},[n,e,T,O,A,_,M,u,C,k,x]),!M)return;let W,R;if(c){W=M.find(X=>X.name.toLowerCase()===c.name.toLowerCase()),R=async()=>{const X=await C(c.name);if(X){ye.show(Xr,{prompt:X,onOk:()=>_({route:"/pro",isExternal:!0})});return}return W&&!qi(c)?new Promise(q=>{ye.show(Et,{title:"Overwrite theme",prompt:s.jsxs(s.Fragment,{children:["This will overwrite your existing version of ",c.name,W?.active?", which is your active theme":"",". All custom changes will be lost."]}),okLabel:"Overwrite",okRunningLabel:"Installing...",cancelLabel:"Cancel",okColor:"red",onOk:async B=>{B?.remove(),await Z(),q()}})}):Z()};const Z=async()=>{let X="Success",q=s.jsx(s.Fragment,{});if(qi(c))X="Activate theme",q=s.jsxs(s.Fragment,{children:["By clicking below, ",s.jsx("strong",{children:c.name})," will automatically be activated as the theme for your site."]});else{f(!0);let B;try{B=await T(c.ref)}catch(ae){O(ae)}finally{f(!1)}if(!B)return;const Y=B.themes[0];if(X="Success",q=s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:Y.name})," has been successfully installed."]}),Y.active||(q=s.jsxs(s.Fragment,{children:[q," ","Do you want to activate it now?"]})),Y.gscan_errors?.length||Y.warnings?.length){const ae=Y.gscan_errors?.length;X=`Installed with ${ae?"errors":"warnings"}`,q=s.jsxs(s.Fragment,{children:["The theme ",s.jsxs("strong",{children:['"',Y.name,'"']})," was installed successfully but we detected some ",ae?"errors":"warnings","."]}),Y.active||(q=s.jsxs(s.Fragment,{children:[q,"You are still able to activate and use the theme but it is recommended to contact the theme developer fix these ",ae?"errors":"warnings"," before you do so."]}))}W=Y}ye.show(nx,{title:X,prompt:q,installedTheme:W,onActivate:()=>{_("")}})}}return s.jsx(yt,{afterClose:()=>{_("")},animate:!1,cancelLabel:"",footer:!1,padding:!1,size:"full",testId:"theme-modal",title:"",scrolling:!0,onCancel:()=>{k.remove(),_("")},children:s.jsx("div",{className:"flex h-full justify-between",children:s.jsxs("div",{className:"grow",children:[c&&s.jsx(mj,{installedTheme:W,isInstalling:l,selectedTheme:c,onBack:()=>{m(null)},onClose:()=>{_("")},onInstall:R}),s.jsx(xj,{currentTab:a,modal:k,previewMode:y,selectedTheme:c,setCurrentTab:o,setPreviewMode:h,setSelectedTheme:m,themes:M}),!c&&s.jsx(bj,{currentTab:a,themes:M,onSelectTheme:$})]})})})},vj=({children:e,to:n,classNames:a})=>{const o=n||document.body;if(!o)return s.jsx(s.Fragment,{children:e});const c=m=>{m.stopPropagation()};return x_.createPortal(s.jsx("div",{className:a,onMouseDown:c,children:s.jsx("div",{children:e})}),o)};var wj=Object.defineProperty,yj=(e,n,a)=>n in e?wj(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a,jt=(e,n,a)=>yj(e,typeof n!="symbol"?n+"":n,a),sx={exports:{}},Wa={};/**
3
+ ${l}`;let _=(u.doctype?new XMLSerializer().serializeToString(u.doctype):"")+u.documentElement.outerHTML;y.contentDocument?.open(),y.contentDocument?.write(_),y.contentDocument?.close()}).catch(()=>{})},[e,n,a,c]);return s.jsx(pd,{addDelay:!0,className:"absolute size-[110%] origin-top-left scale-[.90909] bg-white max-[1600px]:size-[130%] max-[1600px]:scale-[.76923]",generateContent:m,height:"100%",parentClassName:"relative h-full w-full",testId:"announcement-bar-preview-iframe",width:"100%"})},YM=({announcementContent:e,announcementTextHandler:n,accentColor:a,announcementBackgroundColor:o,toggleColorSwatch:c,toggleVisibility:m,visibility:y=[],paidMembersEnabled:h,onBlur:l})=>{const f=[{label:"Public visitors",onChange:u=>{m("visitors",u)},value:"visitors",checked:y.includes("visitors")},{label:"Free members",onChange:u=>{m("free_members",u)},value:"free_members",checked:y.includes("free_members")},...h?[{label:"Paid members",onChange:u=>{m("paid_members",u)},value:"paid_members",checked:y.includes("paid_members")}]:[]];return s.jsxs(tt,{children:[s.jsx(ld,{nodes:"MINIMAL_NODES",placeholder:"Highlight breaking news, offers or updates",title:"Announcement",value:e,onBlur:l,onChange:n}),s.jsx(u0,{isExpanded:!1,picker:!1,swatches:[{hex:"#08090c",title:"Dark",value:"dark"},{hex:"#ffffff",title:"Light",value:"light"},{hex:a||"#ffdd00",title:"Accent",value:"accent"}],swatchSize:"lg",title:"Background color",value:o,onSwatchChange:u=>{u!==null&&c(u)},onTogglePicker:()=>{}}),s.jsx(Cf,{checkboxes:f,title:"Visibility"})]})},GM=()=>{const{siteData:e}=Je(),{localSettings:n,updateSetting:a,handleSave:o,okProps:c}=ss({savingDelay:500}),[m]=gt(n,["announcement_content"]),[y]=gt(n,["accent_color"]),[h]=gt(n,["announcement_background"]),[l]=gt(n,["announcement_visibility"]),[f]=gt(n,["paid_members_enabled"]),u=JSON.parse(l?.toString()||"[]"),{updateRoute:p}=Qe(),[x,v]=D.useState("homepage"),_=R=>{a("announcement_background",R)},k=(R,Z)=>{const X=u.indexOf(R);X===-1&&Z?u.push(R):u.splice(X,1),a("announcement_visibility",JSON.stringify(u))},M=D.useRef(Ji(R=>{a("announcement_content",R)},500)),T=s.jsx(YM,{accentColor:y,announcementBackgroundColor:h,announcementContent:m,announcementTextHandler:R=>{M.current(R)},paidMembersEnabled:f,toggleColorSwatch:_,toggleVisibility:k,visibility:l,onBlur:()=>{}}),{data:{posts:[A]}={posts:[]}}=i0({searchParams:{filter:"status:published",order:"published_at DESC",limit:"1",fields:"id,url"}});let C=[];A&&(C=[{id:"homepage",title:"Homepage"},{id:"post",title:"Post"}]);const O=R=>{C.length&&v(R)};let $=ln(e);switch(x){case"homepage":$=ln(e);break;case"post":$=A.url;break}const W=s.jsx(qM,{announcementBackgroundColor:h,announcementContent:m,url:$,visibility:u});return s.jsx(Zs,{afterClose:()=>{p("announcement-bar")},buttonsDisabled:c.disabled,cancelLabel:"Close",deviceSelector:!0,dirty:!1,okColor:c.color,okLabel:c.label||"Save",preview:W,previewBgColor:"greygradient",previewToolbarTabs:C,selectedURL:x,sidebar:T,testId:"announcement-bar-modal",title:"Announcement",titleHeadingLevel:5,onOk:async()=>{await o({fakeWhenUnchanged:!0})||xt({type:"error",message:"An error occurred while saving your changes. Please try again."})},onSelectURL:O})},XM=ye.create(GM),Bf=[{label:"Global",options:[{value:"site.changed",label:"Site changed (rebuild)"}]},{label:"Posts",options:[{value:"post.added",label:"Post created"},{value:"post.deleted",label:"Post deleted"},{value:"post.edited",label:"Post updated"},{value:"post.published",label:"Post published"},{value:"post.published.edited",label:"Published post updated"},{value:"post.unpublished",label:"Post unpublished"},{value:"post.scheduled",label:"Post scheduled"},{value:"post.unscheduled",label:"Post unscheduled"},{value:"post.tag.attached",label:"Tag added to post"},{value:"post.tag.detached",label:"Tag removed from post"}]},{label:"Pages",options:[{value:"page.added",label:"Page created"},{value:"page.deleted",label:"Page deleted"},{value:"page.edited",label:"Page updated"},{value:"page.published",label:"Page published"},{value:"page.published.edited",label:"Published page updated"},{value:"page.unpublished",label:"Page unpublished"},{value:"page.tag.attached",label:"Tag added to page"},{value:"page.tag.detached",label:"Tag removed from page"}]},{label:"Tags",options:[{value:"tag.added",label:"Tag created"},{value:"tag.edited",label:"Tag updated"},{value:"tag.deleted",label:"Tag deleted"}]},{label:"Members",options:[{value:"member.added",label:"Member added"},{value:"member.edited",label:"Member updated"},{value:"member.deleted",label:"Member deleted"}]}],KM=e=>Bf.flatMap(({options:a})=>a).find(a=>a.value===e)?.label,ZM=ns({method:"POST",path:()=>"/webhooks/",body:e=>({webhooks:[e]}),updateQueries:{dataType:el,emberUpdateType:"createOrUpdate",update:(e,n)=>n&&{...n,integrations:n.integrations.map(a=>{const o=e.webhooks[0];return o.integration_id===a.id?{...a,webhooks:[...a.webhooks||[],o]}:a})}}}),VM=ns({method:"PUT",path:e=>`/webhooks/${e.id}/`,body:e=>({webhooks:[e]}),updateQueries:{dataType:el,emberUpdateType:"createOrUpdate",update:(e,n)=>n&&{...n,integrations:n.integrations.map(a=>{var o;return{...a,webhooks:(o=a.webhooks)==null?void 0:o.map(c=>c.id===e.webhooks[0].id?e.webhooks[0]:c)}})}}}),QM=ns({method:"DELETE",path:e=>`/webhooks/${e}/`,updateQueries:{dataType:el,emberUpdateType:"createOrUpdate",update:(e,n,a)=>({...n,integrations:n.integrations.map(o=>{var c;return{...o,webhooks:(c=o.webhooks)==null?void 0:c.filter(m=>m.id!==a)}})})}}),JM=({webhook:e,integrationId:n})=>{const a=Zt(),{mutateAsync:o}=ZM(),{mutateAsync:c}=VM(),m=ot(),{formState:y,updateForm:h,handleSave:l,errors:f,clearError:u}=kr({initialState:e||{},onSave:async()=>{y.id?await c(y):await o({...y,integration_id:n})},onSaveError:m,onValidate:()=>{const p={};return y.name||(p.name="Enter a name"),y.event||(p.event="Select an event"),y.target_url||(p.target_url="Enter a target URL"),y.target_url&&!Nt.isURL(y.target_url,{require_tld:!1})&&(p.target_url="Enter a valid URL"),p}});return s.jsx(yt,{okColor:"black",okLabel:e?"Update":"Add",size:"sm",testId:"webhook-modal",title:"Add webhook",formSheet:!0,onOk:async()=>{await l()&&a.remove()},children:s.jsx("div",{className:"mt-5",children:s.jsxs(tt,{marginBottom:!1,marginTop:!1,children:[s.jsx(Ae,{error:!!f.name,hint:f.name,maxLength:191,placeholder:"Custom webhook",title:"Name",value:y.name,onChange:p=>h(x=>({...x,name:p.target.value})),onKeyDown:()=>u("name")}),s.jsx(Lt,{error:!!f.event,hint:f.event,options:Bf,prompt:"Select an event",selectedOption:Bf.flatMap(p=>p.options).find(p=>p.value===y.event),testId:"event-select",title:"Event",hideTitle:!0,onSelect:p=>{h(x=>({...x,event:p?.value})),u("event")}}),s.jsx(Ae,{error:!!f.target_url,hint:f.target_url,maxLength:2e3,placeholder:"https://example.com",title:"Target URL",type:"url",value:y.target_url,onChange:p=>h(x=>({...x,target_url:p.target.value})),onKeyDown:()=>u("target_url")}),s.jsx(Ae,{maxLength:191,placeholder:"https://example.com",title:"Secret",value:y.secret||void 0,onChange:p=>h(x=>({...x,secret:p.target.value}))})]})})})},Kh=ye.create(JM),ej=({integration:e})=>{const{mutateAsync:n}=QM(),a=ot(),o=c=>{ye.show(Et,{title:"Are you sure?",prompt:"Deleting this webhook may prevent the integration from functioning.",okColor:"red",okLabel:"Delete Webhook",onOk:async m=>{try{await n(c),m?.remove(),xt({message:"Webhook deleted",type:"info"})}catch(y){a(y)}}})};return s.jsxs("div",{children:[s.jsxs(K_,{children:[s.jsxs(dh,{bgOnHover:!1,children:[s.jsxs(Fh,{children:[e.webhooks?.length||0," ",e.webhooks?.length===1?"webhook":"webhooks"]}),s.jsx(Fh,{children:"Last triggered"})]}),e.webhooks?.map(c=>s.jsxs(dh,{action:s.jsx(Ue,{color:"red",label:"Delete",link:!0,onClick:m=>{m?.stopPropagation(),o(c.id)}}),bgOnHover:!1,hideActions:!0,onClick:()=>{ye.show(Kh,{webhook:c,integrationId:e.id})},children:[s.jsxs(ph,{className:"w-3/4",children:[s.jsx("div",{className:"text-sm font-semibold",children:c.name}),s.jsxs("div",{className:"grid grid-cols-[max-content_1fr] gap-x-1 text-xs leading-snug",children:[s.jsx("span",{className:"text-grey-600",children:"Event:"}),s.jsx("span",{children:KM(c.event)}),s.jsx("span",{className:"text-grey-600",children:"URL:"}),s.jsx("span",{className:"line-clamp-3 break-all",title:c.target_url,children:c.target_url})]})]}),s.jsx(ph,{className:"w-1/4 text-sm",children:c.last_triggered_at&&new Date(c.last_triggered_at).toLocaleString("default",{weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})})]}))]}),s.jsx("div",{className:"mt-5",children:s.jsx(Ue,{color:"green",icon:"add",iconColorClass:"text-green",label:"Add webhook",size:"sm",link:!0,onClick:()=>{ye.show(Kh,{integrationId:e.id})}})})]})},tj=({integration:e})=>{const n=Zt(),{updateRoute:a}=Qe(),{mutateAsync:o}=Z_(),{mutateAsync:c}=dd(),{mutateAsync:m}=Xs(),y=ot(),{formState:h,updateForm:l,handleSave:f,saveState:u,errors:p,clearError:x,okProps:v}=kr({initialState:e,savingDelay:500,savedDelay:500,onSave:async()=>{await o(h)},onSavedStateReset:()=>{a("integrations")},onSaveError:y,onValidate:()=>{const $={};return h.name||($.name="Enter integration title"),$}}),_=e.api_keys?.find($=>$.type==="admin"),k=e.api_keys?.find($=>$.type==="content"),[M,T]=D.useState(!1),[A,C]=D.useState(!1);D.useEffect(()=>{e.type!=="custom"&&(n.remove(),a("integrations"))},[e.type,n,a]);const O=($,W)=>{W(!1);const R=$.type==="content"?"Content":"Admin";ye.show(Et,{title:`Regenerate ${R} API Key`,prompt:`You can regenerate ${R} API Key any time, but any scripts or applications using it will need to be updated.`,okLabel:`Regenerate ${R} API Key`,onOk:async Z=>{try{await c({integrationId:e.id,apiKeyId:$.id}),W(!0),Z?.remove()}catch(X){y(X)}}})};return s.jsxs(yt,{afterClose:()=>{a("integrations")},buttonsDisabled:v.disabled,cancelLabel:"Close",dirty:u==="unsaved",okColor:v.color,okLabel:v.label||"Save",size:"md",testId:"custom-integration-modal",title:h.name||"Custom integration",stickyFooter:!0,onOk:async()=>{await f({fakeWhenUnchanged:!0})},children:[s.jsxs("div",{className:"mt-7 flex w-full flex-col gap-7 md:flex-row",children:[s.jsx("div",{children:s.jsx(un,{height:"100px",id:"custom-integration-icon",imageURL:h.icon_image||void 0,width:"100px",onDelete:()=>l($=>({...$,icon_image:null})),onUpload:async $=>{try{const W=on(await m({file:$}));l(R=>({...R,icon_image:W}))}catch(W){const R=W;R.response.status===415&&(R.message="Unsupported file type"),y(R)}},children:"Upload icon"})}),s.jsx("div",{className:"flex grow flex-col",children:s.jsxs(tt,{children:[s.jsx(Ae,{error:!!p.name,hint:p.name,maxLength:191,title:"Title",value:h.name,onChange:$=>l(W=>({...W,name:$.target.value})),onKeyDown:()=>x("name")}),s.jsx(Ae,{maxLength:2e3,title:"Description",value:h.description||"",onChange:$=>l(W=>({...W,description:$.target.value}))}),s.jsx(al,{keys:[{label:"Content API key",text:k?.secret,hint:A?s.jsx("div",{className:"text-green",children:"Content API Key was successfully regenerated"}):void 0,onRegenerate:()=>k&&O(k,C)},{label:"Admin API key",text:_?.secret,hint:M?s.jsx("div",{className:"text-green",children:"Admin API Key was successfully regenerated"}):void 0,onRegenerate:()=>_&&O(_,T)},{label:"API URL",text:window.location.origin+no().subdir}]})]})})]}),s.jsx("div",{children:s.jsx(ej,{integration:e})})]})},rj=({params:e})=>{const{data:{integrations:n}={}}=Qf(),a=n?.find(({id:o})=>o===e?.id);return a?s.jsx(tj,{integration:a}):null},nj=ye.create(rj),sj=({problem:e})=>{const[n,a]=D.useState(!1),o=()=>{a(!n)};return s.jsx(On,{title:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`${e.level==="error"?"before:bg-red":"before:bg-yellow"} relative px-4 text-sm before:absolute before:left-0 before:top-1.5 before:block before:size-2 before:rounded-full before:content-['']`,children:[e?.fatal?s.jsx("strong",{children:"Fatal: "}):s.jsx("strong",{children:e.level==="error"?"Error: ":"Warning: "}),s.jsx("span",{dangerouslySetInnerHTML:{__html:e.rule}}),s.jsx("div",{className:"absolute -right-4 top-1",children:s.jsx(Ue,{color:"green",icon:n?"chevron-down":"chevron-right",iconColorClass:"text-grey-700",size:"sm",link:!0,onClick:()=>o()})})]}),n?s.jsxs("div",{className:"mt-2 px-4 text-[13px] leading-8",children:[s.jsx("div",{dangerouslySetInnerHTML:{__html:e.details},className:"mb-4"}),s.jsx(bt,{level:6,children:"Affected files:"}),s.jsx("ul",{className:"mt-1",children:e.failures.map(c=>s.jsxs("li",{children:[s.jsx("code",{children:c.ref}),c.message?`: ${c.message}`:""]}))})]}):null]}),hideActions:!0,separator:!0})},aj=({title:e,prompt:n,fatalErrors:a,onRetry:o})=>{let c=null;return a&&(c=s.jsx("div",{className:"mt-10",children:s.jsx(cn,{title:"Errors",children:a.map(m=>typeof m.details=="object"&&m.details.errors&&m.details.errors.length>0?m.details.errors.map(y=>s.jsx(sj,{problem:y})):typeof m.details=="string"?s.jsx(On,{title:m.details}):null)})})),s.jsx(qg,{cancelLabel:"Close",okColor:"black",okLabel:"Retry",prompt:s.jsxs(s.Fragment,{children:[n,c]}),title:e,onOk:o})},rx=ye.create(aj),hd=()=>{const e=V_(),a=!e.data?.themes[0]?.warnings?.some(c=>c.code==="GS051-CUSTOM-FONTS"),o=D.useCallback(()=>{e.refetch()},[e]);return{supportsCustomFonts:a,refreshActiveThemeData:o}};function oj(e){let n=e.package?.name||e.name;return Q_(e)?n+=" (default)":J_(e)?n+=" (legacy)":e.package?.name!==e.name&&(n=s.jsxs("span",{className:"text-sm md:text-base",children:[n," ",s.jsxs("span",{className:"text-grey-600",children:["(",e.name,")"]})]})),Yg(e)&&(n=s.jsxs("span",{className:"text-sm font-bold md:text-base",children:[n," — ",s.jsx("span",{className:"text-green",children:" Active"})]})),n}function ij(e){return e.package?.version||"1.0"}const lj=({theme:e})=>{const{mutateAsync:n}=Jf(),{mutateAsync:a}=e2(),{refreshActiveThemeData:o}=hd(),c=ot(),m=async()=>{try{await n(e.name),o(),xt({title:"Theme activated",type:"success",message:s.jsxs("div",{children:[s.jsx("span",{className:"capitalize",children:e.name})," is now your active theme"]})})}catch(p){let x=null;p instanceof ts&&p.response?.status===422&&p.data?.errors?x=p.data.errors:c(p);let v="Invalid Theme",_=s.jsx(s.Fragment,{children:"This theme is invalid and cannot be activated. Fix the following errors and re-upload the theme"});x&&ye.show(rx,{title:v,prompt:_,fatalErrors:x,onRetry:async k=>{k?.remove(),m()}})}},y=async()=>{const{apiRoot:p}=no();g_(`${p}/themes/${e.name}/download`)},h=async()=>{ye.show(Et,{title:"Are you sure you want to delete this?",prompt:s.jsxs(s.Fragment,{children:["You are about to delete ",s.jsxs("strong",{children:['"',e.name,'".']})," This is permanent! We warned you, k? Maybe download"," ",s.jsx("span",{className:"cursor-pointer text-green-500",onClick:()=>{y()},children:"your theme before continuing"})]}),okLabel:"Delete",okRunningLabel:"Deleting",okColor:"red",onOk:async p=>{try{await a(e.name),p?.remove()}catch(x){c(x)}}})};let l=[];Yg(e)||l.push(s.jsx(Ue,{className:"ml-2",color:"green",label:"Activate",link:!0,onClick:m},"activate"));let f=[{id:"download",label:"Download",onClick:y}];t2(e)&&f.push({id:"delete",label:"Delete",onClick:h});const u={iconColorClass:"text-base",size:"sm"};return s.jsxs("div",{className:"-mr-3 flex items-center gap-4",children:[l,s.jsx(E0,{items:f,position:"end",triggerButtonProps:u})]})},cj=({themes:e})=>(e.sort((n,a)=>n.active&&!a.active?-1:!n.active&&a.active?1:n.package?.name&&a.package?.name?n.package.name.localeCompare(a.package.name):n.name.localeCompare(a.name)),s.jsx(cn,{pageTitle:"Installed themes",children:e.map(n=>{const a=oj(n),o=ij(n);return s.jsx(On,{action:s.jsx(lj,{theme:n}),detail:o,id:`theme-${n.name}`,separator:!1,testId:"theme-list-item",title:a},n.name)})})),uj=({themes:e})=>s.jsx(ud,{children:s.jsx(cj,{themes:e})}),fj=""+new URL("footer-marketplace-bg-BpIYEF6z.png",import.meta.url).href,dj=3e3,Zh=e=>e.variants&&e.variants.length>0,fu=e=>{const n=[{category:e.category,previewUrl:e.previewUrl,image:e.image}];return e.variants&&e.variants.length>0&&n.push(...e.variants),n},pj=({onSelectTheme:e})=>{const n=r2(),[a,o]=D.useState(null),[c,m]=D.useState(0),y=h=>{o(h),m(h!==null&&Zh(h)&&fu(h).length>1?1:0)};return D.useEffect(()=>{if(a===null)return;const h=setInterval(()=>{m((c+1)%(fu(a).length||0))},dj);return()=>clearInterval(h)},[a,c]),s.jsxs(ud,{heading:"Themes",children:[s.jsx("div",{className:"mt-[6vmin] grid grid-cols-1 gap-[6vmin] sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4",children:n.map(h=>{const l=Zh(h),f=fu(h),u=a===h;return s.jsxs("button",{className:"flex cursor-pointer flex-col gap-3 text-left",type:"button",onClick:()=>{e?.(h)},children:[s.jsx("div",{className:"relative w-full bg-grey-100 shadow-md transition-all duration-500 hover:scale-[1.05]",onMouseEnter:()=>y(h),onMouseLeave:()=>y(null),children:l?s.jsx(s.Fragment,{children:f.map((p,x)=>s.jsx("img",{alt:`${h.name} Theme - ${p.category}`,className:we("size-full object-contain opacity-0 transition-opacity duration-500",{"opacity-100":x===c&&u||!u&&x===0,relative:x===c,absolute:x!==c,"left-0":x!==c,"top-0":x!==c}),src:p.image},`theme-variant-${p.category.toLowerCase()}`))}):s.jsx("img",{alt:`${h.name} Theme`,className:"size-full object-contain",src:h.image})}),s.jsxs("div",{className:"relative mt-3",children:[s.jsx(bt,{level:4,children:h.name}),l?f.map((p,x)=>s.jsx("span",{className:we("absolute left-0 translate-y-px text-sm text-grey-700 opacity-0",{"opacity-100":x===c&&u||!u&&x===0}),children:p.category})):s.jsx("span",{className:"text-sm text-grey-700",children:h.category})]})]},h.name)})}),s.jsxs("div",{className:"mx-[-8vmin] mb-[-8vmin] mt-[8vmin] bg-black px-[8vmin] py-16 text-center text-lg text-white",style:{background:`#15171a url(${fj}) 100% 100% / 35vw no-repeat`},children:["Find and buy third-party, premium themes from independent developers in the ",s.jsx("a",{className:"inline-block font-semibold text-lime",href:"https://ghost.org/themes/",rel:"noopener noreferrer",target:"_blank",children:"Ghost Marketplace →"})]})]})},Vh=({problem:e})=>{const[n,a]=D.useState(!1);return s.jsx(On,{title:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`${e.level==="error"?"before:bg-red":"before:bg-yellow"} relative px-4 text-sm before:absolute before:left-0 before:top-1.5 before:block before:size-2 before:rounded-full before:content-['']`,children:[s.jsx("strong",{children:e.level==="error"?"Error: ":"Warning: "}),s.jsx("span",{dangerouslySetInnerHTML:{__html:e.rule}}),s.jsx("div",{className:"absolute -right-4 top-1",children:s.jsx(Ue,{color:"green",icon:n?"chevron-down":"chevron-right",iconColorClass:"text-grey-700",size:"sm",link:!0,onClick:()=>a(!n)})})]}),n?s.jsxs("div",{className:"mt-2 px-4 text-[13px] leading-8",children:[s.jsx("div",{dangerouslySetInnerHTML:{__html:e.details},className:"mb-4"}),s.jsx(bt,{level:6,children:"Affected files:"}),s.jsx("ul",{className:"mt-1",children:e.failures.map(o=>s.jsxs("li",{children:[s.jsx("code",{children:o.ref}),o.message?`: ${o.message}`:""]},o.ref))})]}):null]}),hideActions:!0,separator:!0})},hj=({title:e,prompt:n,installedTheme:a,onActivate:o})=>{const{mutateAsync:c}=Jf(),{refreshActiveThemeData:m}=hd(),y=ot();let h=null;a&&a.errors&&(h=s.jsx("div",{className:"mt-6",children:s.jsx(cn,{hint:s.jsxs(s.Fragment,{children:["Highly recommended to fix, functionality ",s.jsx("strong",{children:"could"})," be restricted"]}),title:"Errors",children:a.errors?.map((u,p)=>s.jsx(Vh,{problem:u},p))})}));let l=null;a&&a.warnings&&(l=s.jsx("div",{className:"mt-10",children:s.jsx(cn,{title:"Warnings",children:a.warnings?.map((u,p)=>s.jsx(Vh,{problem:u},p))})}));let f=`Activate${a.errors?.length?" with errors":""}`;return a.active&&(f="OK"),s.jsx(qg,{cancelLabel:"Close",okColor:"black",okLabel:f,okRunningLabel:"Activating...",prompt:s.jsxs(s.Fragment,{children:[n,h,l]}),title:e,onOk:async u=>{if(!a.active)try{const x=(await c(a.name)).themes[0];m(),xt({title:"Theme activated",type:"success",message:s.jsxs("div",{children:[s.jsx("span",{className:"capitalize",children:x.name})," is now your active theme."]})})}catch(p){y(p)}o?.(),u?.remove()}})},nx=ye.create(hj),Qh=e=>e.variants&&e.variants.length>0,Jh=e=>{const n=[{image:e.image,category:e.category,previewUrl:e.previewUrl}];return e.variants&&e.variants.length>0&&n.push(...e.variants),n},em=e=>e.category.toLowerCase(),mj=({selectedTheme:e,isInstalling:n,installedTheme:a,onBack:o,onInstall:c})=>{const[m,y]=D.useState("desktop"),[h,l]=D.useState(void 0);if(!e)return null;let f=e.previewUrl;const u=Jh(e).map(k=>({label:k.category,value:em(k)}));Qh(e)&&(h===void 0&&l(u[0]),f=Jh(e).find(k=>em(k)===h?.value)?.previewUrl||f);let p=`Install ${e.name}`;n?p="Installing...":qi(e)&&!a?.active?p=`Activate ${e.name}`:a&&(p=`Update ${e.name}`);const x=()=>{c?.()},v=s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fd,{activeItemClassName:"hidden md:!block md:!visible",containerClassName:"whitespace-nowrap",itemClassName:"hidden md:!block md:!visible",items:[{label:"Change theme",onClick:o},{label:e.name}],separatorClassName:"hidden md:!block md:!visible",backIcon:!0,onBack:o}),Qh(e)?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hidden md:!visible md:!block",children:"–"}),s.jsx(Lt,{border:!1,containerClassName:"text-sm font-bold",controlClasses:{menu:"w-24"},fullWidth:!1,options:u,selectedOption:h,clearBg:!0,onSelect:k=>{l(k||void 0)}})]}):null]}),_=s.jsxs("div",{className:"flex justify-end gap-8",children:[s.jsx(an,{buttons:[{icon:"laptop",iconColorClass:m==="desktop"?"text-black dark:text-green":"text-grey-500 dark:text-grey-600",link:!0,size:"sm",onClick:()=>{y("desktop")}},{icon:"mobile",iconColorClass:m==="mobile"?"text-black dark:text-green":"text-grey-500 dark:text-grey-600",link:!0,size:"sm",onClick:()=>{y("mobile")}}]}),s.jsx(Ue,{color:"green",disabled:n,label:n?"Installing...":p,onClick:x})]});return s.jsxs("div",{className:"absolute inset-0 z-[100]",children:[s.jsx(F0,{containerClassName:"bg-grey-50 dark:bg-black z-[100]",left:v,right:_,sticky:!1}),s.jsx("div",{className:"flex h-[calc(100%-92px)] grow flex-col items-center justify-center bg-grey-50 dark:bg-black",children:m==="desktop"?s.jsx(l0,{children:s.jsx("iframe",{className:"size-full",src:f,title:"Theme preview"})}):s.jsx(c0,{children:s.jsx("iframe",{className:"size-full",src:f,title:"Theme preview"})})})]})},gj=({onUpload:e})=>{const n=Zt();return s.jsx("div",{className:"-mb-6",children:s.jsx(a2,{id:"theme-upload",onUpload:a=>{n.remove(),e(a)},children:s.jsx("div",{className:"cursor-pointer bg-grey-75 p-10 text-center dark:bg-grey-950",children:"Click to select or drag & drop zip file"})})})},xj=({currentTab:e,setCurrentTab:n,themes:a})=>{const o=Zt(),{updateRoute:c}=Qe(),{mutateAsync:m}=s2(),{checkThemeLimitError:y,isThemeLimited:h}=td(),l=ot(),[f,u]=D.useState(),[p,x]=D.useState(!1);D.useEffect(()=>{(async()=>{if(h){const O=await y(".");u({enabled:!1,error:O||"Your current plan doesn't support uploading custom themes."})}else u({enabled:!0})})()},[y,h]);const v=()=>{c("/")},_=async C=>{const O=C?.name.replace(/\.zip$/,""),$=a.map(W=>W.name);qi({name:O})?ye.show(Et,{title:"Upload failed",cancelLabel:"Cancel",okLabel:"",prompt:s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["The default ",s.jsx("strong",{children:O})," theme cannot be overwritten."]}),s.jsx("p",{children:"Rename your zip file and try again."})]}),onOk:async W=>{W?.remove()}}):$.includes(O)?ye.show(Et,{title:"Overwrite theme",prompt:s.jsxs(s.Fragment,{children:["The theme ",s.jsx("strong",{children:O})," already exists. Do you want to overwrite it?"]}),okLabel:"Overwrite",cancelLabel:"Cancel",okRunningLabel:"Overwriting...",okColor:"red",onOk:async W=>{x(!0);const R=$.indexOf(O);a.splice(R,1),await k({file:C,onActivate:v}),x(!1),n("installed"),W?.remove()}}):(n("installed"),k({file:C,onActivate:v}))},k=async({file:C,onActivate:O})=>{let $,W=null;try{x(!0),$=await m({file:C}),x(!1)}catch(q){x(!1),q instanceof ts&&q.response?.status===422&&q.data?.errors?W=q.data.errors:l(q)}if(W&&!$){let q="Invalid Theme",B=s.jsx(s.Fragment,{children:"This theme is invalid and cannot be activated. Fix the following errors and re-upload the theme"});ye.show(rx,{title:q,prompt:B,fatalErrors:W,onRetry:async()=>{o?.remove(),T()}})}if(!$)return;const R=$.themes[0];let Z="Upload successful",X=s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:R.name})," uploaded"]});if(R.active||(X=s.jsxs(s.Fragment,{children:[X," ","Do you want to activate it now?"]})),R?.errors?.length||R.warnings?.length){const q=R?.errors?.length;Z=`Upload successful with ${q?"errors":"warnings"}`,X=s.jsxs(s.Fragment,{children:["The theme ",s.jsxs("strong",{children:['"',R.name,'"']})," was installed but we detected some ",q?"errors":"warnings","."]}),R.active||(X=s.jsxs(s.Fragment,{children:[X,"You are still able to activate and use the theme but it is recommended to fix these ",q?"errors":"warnings"," before you do so."]}))}ye.show(nx,{title:Z,prompt:X,installedTheme:R,onActivate:O})},M=s.jsx("div",{className:"hidden md:!visible md:!block",children:s.jsx(Dn,{border:!1,selectedTab:e,tabs:[{id:"official",title:"Official themes"},{id:"installed",title:"Installed"}],onTabChange:C=>{n(C)}})}),T=()=>{f&&(f.enabled?ye.show(Et,{title:"Upload theme",prompt:s.jsx(gj,{onUpload:_}),okLabel:"",formSheet:!1}):ye.show(Xr,{title:"Upgrade to enable custom themes",prompt:f.error||s.jsxs(s.Fragment,{children:["Your current plan only supports official themes. You can install them from the ",s.jsx("a",{href:"https://ghost.org/marketplace/",children:"Ghost theme marketplace"}),"."]}),onOk:()=>c({route:"/pro",isExternal:!0})}))},A=s.jsx("div",{className:"flex items-center gap-14",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ue,{label:"Close",onClick:()=>{o.remove(),v()}}),s.jsx(Ue,{color:"black",label:"Upload theme",loading:p,onClick:T})]})});return s.jsxs(s.Fragment,{children:[s.jsx(F0,{containerClassName:"bg-white dark:bg-black",left:M,right:A}),s.jsx("div",{className:"px-[8vmin] md:hidden",children:s.jsx(Dn,{border:!1,selectedTab:e,tabs:[{id:"official",title:"Official themes"},{id:"installed",title:"Installed"}],onTabChange:C=>{n(C)}})})]})},bj=({currentTab:e,onSelectTheme:n,themes:a})=>{switch(e){case"official":return s.jsx(pj,{onSelectTheme:n});case"installed":return s.jsx(uj,{themes:a})}return null},tm=({source:e,themeRef:n})=>{const[a,o]=D.useState("official"),[c,m]=D.useState(null),[y,h]=D.useState("desktop"),[l,f]=D.useState(!1),[u,p]=D.useState(!1),[x,v]=D.useState(!1),{updateRoute:_}=Qe(),k=Zt(),{data:{themes:M}={}}=ed(),{mutateAsync:T}=n2(),{mutateAsync:A}=Jf(),{checkThemeLimitError:C}=td(),O=ot(),$=Z=>{m(Z)};if(D.useEffect(()=>{v(!0)},[]),D.useEffect(()=>{(async()=>{if(e&&n&&!u&&x){const X=n.split("/")[1];if(await C(X)){k.remove();return}let B="Install Theme";const Y=M?.map(ne=>ne.name)||[];let ae=Y.includes(X.toLowerCase());const ee=Y.indexOf(X.toLowerCase()),re=M?.[ee];let Q=s.jsxs(s.Fragment,{children:["By clicking below, ",s.jsx("strong",{children:X})," will automatically be activated as the theme for your site.",ae&&s.jsxs(s.Fragment,{children:[s.jsx("br",{}),s.jsx("br",{}),"This will overwrite your existing version of ",s.jsx("strong",{children:X}),re?.active?" which is your active theme":"",". All custom changes will be lost."]})]});ye.show(Et,{title:B,prompt:Q,okLabel:"Install",cancelLabel:"Cancel",okRunningLabel:"Installing...",okColor:"black",onOk:async ne=>{let be;p(!0);try{ae&&M&&M.splice(ee,1),be=await T(n),be?.themes[0]&&(await A(be.themes[0].name),xt({title:"Theme activated",type:"success",message:s.jsxs("div",{children:[s.jsx("span",{className:"capitalize",children:be.themes[0].name})," is now your active theme"]})})),ne?.remove(),_("")}catch(je){O(je)}}})}})()},[n,e,T,O,A,_,M,u,C,k,x]),!M)return;let W,R;if(c){W=M.find(X=>X.name.toLowerCase()===c.name.toLowerCase()),R=async()=>{const X=await C(c.name);if(X){ye.show(Xr,{prompt:X,onOk:()=>_({route:"/pro",isExternal:!0})});return}return W&&!qi(c)?new Promise(q=>{ye.show(Et,{title:"Overwrite theme",prompt:s.jsxs(s.Fragment,{children:["This will overwrite your existing version of ",c.name,W?.active?", which is your active theme":"",". All custom changes will be lost."]}),okLabel:"Overwrite",okRunningLabel:"Installing...",cancelLabel:"Cancel",okColor:"red",onOk:async B=>{B?.remove(),await Z(),q()}})}):Z()};const Z=async()=>{let X="Success",q=s.jsx(s.Fragment,{});if(qi(c))X="Activate theme",q=s.jsxs(s.Fragment,{children:["By clicking below, ",s.jsx("strong",{children:c.name})," will automatically be activated as the theme for your site."]});else{f(!0);let B;try{B=await T(c.ref)}catch(ae){O(ae)}finally{f(!1)}if(!B)return;const Y=B.themes[0];if(X="Success",q=s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:Y.name})," has been successfully installed."]}),Y.active||(q=s.jsxs(s.Fragment,{children:[q," ","Do you want to activate it now?"]})),Y.errors?.length||Y.warnings?.length){const ae=Y.errors?.length;X=`Installed with ${ae?"errors":"warnings"}`,q=s.jsxs(s.Fragment,{children:["The theme ",s.jsxs("strong",{children:['"',Y.name,'"']})," was installed successfully but we detected some ",ae?"errors":"warnings","."]}),Y.active||(q=s.jsxs(s.Fragment,{children:[q,"You are still able to activate and use the theme but it is recommended to contact the theme developer fix these ",ae?"errors":"warnings"," before you do so."]}))}W=Y}ye.show(nx,{title:X,prompt:q,installedTheme:W,onActivate:()=>{_("")}})}}return s.jsx(yt,{afterClose:()=>{_("")},animate:!1,cancelLabel:"",footer:!1,padding:!1,size:"full",testId:"theme-modal",title:"",scrolling:!0,onCancel:()=>{k.remove(),_("")},children:s.jsx("div",{className:"flex h-full justify-between",children:s.jsxs("div",{className:"grow",children:[c&&s.jsx(mj,{installedTheme:W,isInstalling:l,selectedTheme:c,onBack:()=>{m(null)},onClose:()=>{_("")},onInstall:R}),s.jsx(xj,{currentTab:a,modal:k,previewMode:y,selectedTheme:c,setCurrentTab:o,setPreviewMode:h,setSelectedTheme:m,themes:M}),!c&&s.jsx(bj,{currentTab:a,themes:M,onSelectTheme:$})]})})})},vj=({children:e,to:n,classNames:a})=>{const o=n||document.body;if(!o)return s.jsx(s.Fragment,{children:e});const c=m=>{m.stopPropagation()};return x_.createPortal(s.jsx("div",{className:a,onMouseDown:c,children:s.jsx("div",{children:e})}),o)};var wj=Object.defineProperty,yj=(e,n,a)=>n in e?wj(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a,jt=(e,n,a)=>yj(e,typeof n!="symbol"?n+"":n,a),sx={exports:{}},Wa={};/**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.min.js
6
6
  *
@@ -74,4 +74,4 @@ ${y}`:l.head.innerHTML+=`<style>${y}</style>`;let x=(l.doctype?new XMLSerializer
74
74
  </head>
75
75
  <body>${e}</body>
76
76
  </html>
77
- `;c.open(),c.write(m),c.close()};return s.jsx(pd,{className:"absolute size-full overflow-hidden transition-opacity duration-500",generateContent:a,height:"100%",parentClassName:"relative h-full w-full",width:"100%"})},cE=({selectedLayout:e,accentColor:n,handleColorToggle:a,selectedColor:o,selectedLabels:c,handleLabelClick:m,embedScript:y,handleLayoutSelect:h,handleCopyClick:l,isCopied:f})=>{const{loadData:u}=Zg({path:"/labels/",filterKey:"name",responseKey:"labels"}),p=async(x,v)=>{const _=await u(x);v(_.map(k=>({label:k.name,value:k.name})))};return s.jsxs("div",{className:"flex h-[calc(100vh-16vmin)] max-h-[645px] flex-col justify-between overflow-y-scroll border-l border-grey-200 p-6 pb-0 dark:border-grey-900",children:[s.jsxs("div",{children:[s.jsx(bt,{className:"mb-8",level:4,children:"Embed signup form"}),s.jsxs(tt,{gap:"sm",children:[s.jsxs("div",{className:"flex w-full items-center justify-between",children:[s.jsx("div",{children:"Layout"}),s.jsx(an,{activeKey:e,buttons:[{key:"all-in-one",label:"Branded",size:"md",className:"w-auto !px-3",onClick:()=>h("all-in-one")},{key:"minimal",label:"Minimal",size:"md",className:"w-auto !px-3",onClick:()=>h("minimal")}],clearBg:!1})]}),e==="all-in-one"&&s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{hex:"#08090c",title:"Dark",value:"#08090c"},{hex:"#ffffff",title:"Light",value:"#ffffff"},{hex:n||"#d74780",title:"Accent",value:n||"#d74780"}],title:"Background color",value:o,onChange:x=>{x&&a(x)}}),s.jsx(c2,{hint:"Will be applied to all members signing up via this form",loadOptions:Ji(p,500),placeholder:"Pick one or more labels (optional)",title:"Labels at signup",values:c||[],async:!0,canCreate:!0,defaultOptions:!0,onChange:m}),s.jsx($n,{className:"text-grey-800",fontStyle:"mono",hint:"Paste this code onto any website where you'd like your signup to appear.",title:"Embed code",value:`${y}`,onChange:()=>{}})]})]}),s.jsx(u2,{height:74,children:s.jsx("div",{className:"flex w-full justify-end",children:s.jsx(Ue,{color:f?"green":"black",label:f?"Copied!":"Copy code",onClick:l})})})]})};function Eg(e){return e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""}function _d(e,n){return n={exports:{}},e(n,n.exports),n.exports}var qa={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},uE=function(n){return!n||typeof n=="string"?!1:n instanceof Array||Array.isArray(n)||n.length>=0&&(n.splice instanceof Function||Object.getOwnPropertyDescriptor(n,n.length-1)&&n.constructor.name!=="String")},Ya=_d(function(e){var n=Array.prototype.concat,a=Array.prototype.slice,o=e.exports=function(m){for(var y=[],h=0,l=m.length;h<l;h++){var f=m[h];uE(f)?y=n.call(y,a.call(f)):y.push(f)}return y};o.wrap=function(c){return function(){return c(o(arguments))}}}),Jn=_d(function(e){var n=Object.hasOwnProperty,a=Object.create(null);for(var o in qa)n.call(qa,o)&&(a[qa[o]]=o);var c=e.exports={to:{},get:{}};c.get=function(h){var l=h.substring(0,3).toLowerCase(),f,u;switch(l){case"hsl":f=c.get.hsl(h),u="hsl";break;case"hwb":f=c.get.hwb(h),u="hwb";break;default:f=c.get.rgb(h),u="rgb";break}return f?{model:u,value:f}:null},c.get.rgb=function(h){if(!h)return null;var l=/^#([a-f0-9]{3,4})$/i,f=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,u=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,p=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,x=/^(\w+)$/,v=[0,0,0,1],_,k,M;if(_=h.match(f)){for(M=_[2],_=_[1],k=0;k<3;k++){var T=k*2;v[k]=parseInt(_.slice(T,T+2),16)}M&&(v[3]=parseInt(M,16)/255)}else if(_=h.match(l)){for(_=_[1],M=_[3],k=0;k<3;k++)v[k]=parseInt(_[k]+_[k],16);M&&(v[3]=parseInt(M+M,16)/255)}else if(_=h.match(u)){for(k=0;k<3;k++)v[k]=parseInt(_[k+1],0);_[4]&&(_[5]?v[3]=parseFloat(_[4])*.01:v[3]=parseFloat(_[4]))}else if(_=h.match(p)){for(k=0;k<3;k++)v[k]=Math.round(parseFloat(_[k+1])*2.55);_[4]&&(_[5]?v[3]=parseFloat(_[4])*.01:v[3]=parseFloat(_[4]))}else return(_=h.match(x))?_[1]==="transparent"?[0,0,0,0]:n.call(qa,_[1])?(v=qa[_[1]],v[3]=1,v):null:null;for(k=0;k<3;k++)v[k]=m(v[k],0,255);return v[3]=m(v[3],0,1),v},c.get.hsl=function(h){if(!h)return null;var l=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,f=h.match(l);if(f){var u=parseFloat(f[4]),p=(parseFloat(f[1])%360+360)%360,x=m(parseFloat(f[2]),0,100),v=m(parseFloat(f[3]),0,100),_=m(isNaN(u)?1:u,0,1);return[p,x,v,_]}return null},c.get.hwb=function(h){if(!h)return null;var l=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,f=h.match(l);if(f){var u=parseFloat(f[4]),p=(parseFloat(f[1])%360+360)%360,x=m(parseFloat(f[2]),0,100),v=m(parseFloat(f[3]),0,100),_=m(isNaN(u)?1:u,0,1);return[p,x,v,_]}return null},c.to.hex=function(){var h=Ya(arguments);return"#"+y(h[0])+y(h[1])+y(h[2])+(h[3]<1?y(Math.round(h[3]*255)):"")},c.to.rgb=function(){var h=Ya(arguments);return h.length<4||h[3]===1?"rgb("+Math.round(h[0])+", "+Math.round(h[1])+", "+Math.round(h[2])+")":"rgba("+Math.round(h[0])+", "+Math.round(h[1])+", "+Math.round(h[2])+", "+h[3]+")"},c.to.rgb.percent=function(){var h=Ya(arguments),l=Math.round(h[0]/255*100),f=Math.round(h[1]/255*100),u=Math.round(h[2]/255*100);return h.length<4||h[3]===1?"rgb("+l+"%, "+f+"%, "+u+"%)":"rgba("+l+"%, "+f+"%, "+u+"%, "+h[3]+")"},c.to.hsl=function(){var h=Ya(arguments);return h.length<4||h[3]===1?"hsl("+h[0]+", "+h[1]+"%, "+h[2]+"%)":"hsla("+h[0]+", "+h[1]+"%, "+h[2]+"%, "+h[3]+")"},c.to.hwb=function(){var h=Ya(arguments),l="";return h.length>=4&&h[3]!==1&&(l=", "+h[3]),"hwb("+h[0]+", "+h[1]+"%, "+h[2]+"%"+l+")"},c.to.keyword=function(h){return a[h.slice(0,3)]};function m(h,l,f){return Math.min(Math.max(l,h),f)}function y(h){var l=Math.round(h).toString(16).toUpperCase();return l.length<2?"0"+l:l}});Jn.to;Jn.get;var Vn={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},At=_d(function(e){var n={};for(var a in Vn)Vn.hasOwnProperty(a)&&(n[Vn[a]]=a);var o=e.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var c in o)if(o.hasOwnProperty(c)){if(!("channels"in o[c]))throw new Error("missing channels property: "+c);if(!("labels"in o[c]))throw new Error("missing channel labels property: "+c);if(o[c].labels.length!==o[c].channels)throw new Error("channel and label counts mismatch: "+c);var m=o[c].channels,y=o[c].labels;delete o[c].channels,delete o[c].labels,Object.defineProperty(o[c],"channels",{value:m}),Object.defineProperty(o[c],"labels",{value:y})}o.rgb.hsl=function(l){var f=l[0]/255,u=l[1]/255,p=l[2]/255,x=Math.min(f,u,p),v=Math.max(f,u,p),_=v-x,k,M,T;return v===x?k=0:f===v?k=(u-p)/_:u===v?k=2+(p-f)/_:p===v&&(k=4+(f-u)/_),k=Math.min(k*60,360),k<0&&(k+=360),T=(x+v)/2,v===x?M=0:T<=.5?M=_/(v+x):M=_/(2-v-x),[k,M*100,T*100]},o.rgb.hsv=function(l){var f,u,p,x,v,_=l[0]/255,k=l[1]/255,M=l[2]/255,T=Math.max(_,k,M),A=T-Math.min(_,k,M),C=function(O){return(T-O)/6/A+1/2};return A===0?x=v=0:(v=A/T,f=C(_),u=C(k),p=C(M),_===T?x=p-u:k===T?x=1/3+f-p:M===T&&(x=2/3+u-f),x<0?x+=1:x>1&&(x-=1)),[x*360,v*100,T*100]},o.rgb.hwb=function(l){var f=l[0],u=l[1],p=l[2],x=o.rgb.hsl(l)[0],v=1/255*Math.min(f,Math.min(u,p));return p=1-1/255*Math.max(f,Math.max(u,p)),[x,v*100,p*100]},o.rgb.cmyk=function(l){var f=l[0]/255,u=l[1]/255,p=l[2]/255,x,v,_,k;return k=Math.min(1-f,1-u,1-p),x=(1-f-k)/(1-k)||0,v=(1-u-k)/(1-k)||0,_=(1-p-k)/(1-k)||0,[x*100,v*100,_*100,k*100]};function h(l,f){return Math.pow(l[0]-f[0],2)+Math.pow(l[1]-f[1],2)+Math.pow(l[2]-f[2],2)}o.rgb.keyword=function(l){var f=n[l];if(f)return f;var u=1/0,p;for(var x in Vn)if(Vn.hasOwnProperty(x)){var v=Vn[x],_=h(l,v);_<u&&(u=_,p=x)}return p},o.keyword.rgb=function(l){return Vn[l]},o.rgb.xyz=function(l){var f=l[0]/255,u=l[1]/255,p=l[2]/255;f=f>.04045?Math.pow((f+.055)/1.055,2.4):f/12.92,u=u>.04045?Math.pow((u+.055)/1.055,2.4):u/12.92,p=p>.04045?Math.pow((p+.055)/1.055,2.4):p/12.92;var x=f*.4124+u*.3576+p*.1805,v=f*.2126+u*.7152+p*.0722,_=f*.0193+u*.1192+p*.9505;return[x*100,v*100,_*100]},o.rgb.lab=function(l){var f=o.rgb.xyz(l),u=f[0],p=f[1],x=f[2],v,_,k;return u/=95.047,p/=100,x/=108.883,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,p=p>.008856?Math.pow(p,1/3):7.787*p+16/116,x=x>.008856?Math.pow(x,1/3):7.787*x+16/116,v=116*p-16,_=500*(u-p),k=200*(p-x),[v,_,k]},o.hsl.rgb=function(l){var f=l[0]/360,u=l[1]/100,p=l[2]/100,x,v,_,k,M;if(u===0)return M=p*255,[M,M,M];p<.5?v=p*(1+u):v=p+u-p*u,x=2*p-v,k=[0,0,0];for(var T=0;T<3;T++)_=f+1/3*-(T-1),_<0&&_++,_>1&&_--,6*_<1?M=x+(v-x)*6*_:2*_<1?M=v:3*_<2?M=x+(v-x)*(2/3-_)*6:M=x,k[T]=M*255;return k},o.hsl.hsv=function(l){var f=l[0],u=l[1]/100,p=l[2]/100,x=u,v=Math.max(p,.01),_,k;return p*=2,u*=p<=1?p:2-p,x*=v<=1?v:2-v,k=(p+u)/2,_=p===0?2*x/(v+x):2*u/(p+u),[f,_*100,k*100]},o.hsv.rgb=function(l){var f=l[0]/60,u=l[1]/100,p=l[2]/100,x=Math.floor(f)%6,v=f-Math.floor(f),_=255*p*(1-u),k=255*p*(1-u*v),M=255*p*(1-u*(1-v));switch(p*=255,x){case 0:return[p,M,_];case 1:return[k,p,_];case 2:return[_,p,M];case 3:return[_,k,p];case 4:return[M,_,p];case 5:return[p,_,k]}},o.hsv.hsl=function(l){var f=l[0],u=l[1]/100,p=l[2]/100,x=Math.max(p,.01),v,_,k;return k=(2-u)*p,v=(2-u)*x,_=u*x,_/=v<=1?v:2-v,_=_||0,k/=2,[f,_*100,k*100]},o.hwb.rgb=function(l){var f=l[0]/360,u=l[1]/100,p=l[2]/100,x=u+p,v,_,k,M;x>1&&(u/=x,p/=x),v=Math.floor(6*f),_=1-p,k=6*f-v,(v&1)!==0&&(k=1-k),M=u+k*(_-u);var T,A,C;switch(v){default:case 6:case 0:T=_,A=M,C=u;break;case 1:T=M,A=_,C=u;break;case 2:T=u,A=_,C=M;break;case 3:T=u,A=M,C=_;break;case 4:T=M,A=u,C=_;break;case 5:T=_,A=u,C=M;break}return[T*255,A*255,C*255]},o.cmyk.rgb=function(l){var f=l[0]/100,u=l[1]/100,p=l[2]/100,x=l[3]/100,v,_,k;return v=1-Math.min(1,f*(1-x)+x),_=1-Math.min(1,u*(1-x)+x),k=1-Math.min(1,p*(1-x)+x),[v*255,_*255,k*255]},o.xyz.rgb=function(l){var f=l[0]/100,u=l[1]/100,p=l[2]/100,x,v,_;return x=f*3.2406+u*-1.5372+p*-.4986,v=f*-.9689+u*1.8758+p*.0415,_=f*.0557+u*-.204+p*1.057,x=x>.0031308?1.055*Math.pow(x,1/2.4)-.055:x*12.92,v=v>.0031308?1.055*Math.pow(v,1/2.4)-.055:v*12.92,_=_>.0031308?1.055*Math.pow(_,1/2.4)-.055:_*12.92,x=Math.min(Math.max(0,x),1),v=Math.min(Math.max(0,v),1),_=Math.min(Math.max(0,_),1),[x*255,v*255,_*255]},o.xyz.lab=function(l){var f=l[0],u=l[1],p=l[2],x,v,_;return f/=95.047,u/=100,p/=108.883,f=f>.008856?Math.pow(f,1/3):7.787*f+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,p=p>.008856?Math.pow(p,1/3):7.787*p+16/116,x=116*u-16,v=500*(f-u),_=200*(u-p),[x,v,_]},o.lab.xyz=function(l){var f=l[0],u=l[1],p=l[2],x,v,_;v=(f+16)/116,x=u/500+v,_=v-p/200;var k=Math.pow(v,3),M=Math.pow(x,3),T=Math.pow(_,3);return v=k>.008856?k:(v-16/116)/7.787,x=M>.008856?M:(x-16/116)/7.787,_=T>.008856?T:(_-16/116)/7.787,x*=95.047,v*=100,_*=108.883,[x,v,_]},o.lab.lch=function(l){var f=l[0],u=l[1],p=l[2],x,v,_;return x=Math.atan2(p,u),v=x*360/2/Math.PI,v<0&&(v+=360),_=Math.sqrt(u*u+p*p),[f,_,v]},o.lch.lab=function(l){var f=l[0],u=l[1],p=l[2],x,v,_;return _=p/360*2*Math.PI,x=u*Math.cos(_),v=u*Math.sin(_),[f,x,v]},o.rgb.ansi16=function(l){var f=l[0],u=l[1],p=l[2],x=1 in arguments?arguments[1]:o.rgb.hsv(l)[2];if(x=Math.round(x/50),x===0)return 30;var v=30+(Math.round(p/255)<<2|Math.round(u/255)<<1|Math.round(f/255));return x===2&&(v+=60),v},o.hsv.ansi16=function(l){return o.rgb.ansi16(o.hsv.rgb(l),l[2])},o.rgb.ansi256=function(l){var f=l[0],u=l[1],p=l[2];if(f===u&&u===p)return f<8?16:f>248?231:Math.round((f-8)/247*24)+232;var x=16+36*Math.round(f/255*5)+6*Math.round(u/255*5)+Math.round(p/255*5);return x},o.ansi16.rgb=function(l){var f=l%10;if(f===0||f===7)return l>50&&(f+=3.5),f=f/10.5*255,[f,f,f];var u=(~~(l>50)+1)*.5,p=(f&1)*u*255,x=(f>>1&1)*u*255,v=(f>>2&1)*u*255;return[p,x,v]},o.ansi256.rgb=function(l){if(l>=232){var f=(l-232)*10+8;return[f,f,f]}l-=16;var u,p=Math.floor(l/36)/5*255,x=Math.floor((u=l%36)/6)/5*255,v=u%6/5*255;return[p,x,v]},o.rgb.hex=function(l){var f=((Math.round(l[0])&255)<<16)+((Math.round(l[1])&255)<<8)+(Math.round(l[2])&255),u=f.toString(16).toUpperCase();return"000000".substring(u.length)+u},o.hex.rgb=function(l){var f=l.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!f)return[0,0,0];var u=f[0];f[0].length===3&&(u=u.split("").map(function(k){return k+k}).join(""));var p=parseInt(u,16),x=p>>16&255,v=p>>8&255,_=p&255;return[x,v,_]},o.rgb.hcg=function(l){var f=l[0]/255,u=l[1]/255,p=l[2]/255,x=Math.max(Math.max(f,u),p),v=Math.min(Math.min(f,u),p),_=x-v,k,M;return _<1?k=v/(1-_):k=0,_<=0?M=0:x===f?M=(u-p)/_%6:x===u?M=2+(p-f)/_:M=4+(f-u)/_+4,M/=6,M%=1,[M*360,_*100,k*100]},o.hsl.hcg=function(l){var f=l[1]/100,u=l[2]/100,p=1,x=0;return u<.5?p=2*f*u:p=2*f*(1-u),p<1&&(x=(u-.5*p)/(1-p)),[l[0],p*100,x*100]},o.hsv.hcg=function(l){var f=l[1]/100,u=l[2]/100,p=f*u,x=0;return p<1&&(x=(u-p)/(1-p)),[l[0],p*100,x*100]},o.hcg.rgb=function(l){var f=l[0]/360,u=l[1]/100,p=l[2]/100;if(u===0)return[p*255,p*255,p*255];var x=[0,0,0],v=f%1*6,_=v%1,k=1-_,M=0;switch(Math.floor(v)){case 0:x[0]=1,x[1]=_,x[2]=0;break;case 1:x[0]=k,x[1]=1,x[2]=0;break;case 2:x[0]=0,x[1]=1,x[2]=_;break;case 3:x[0]=0,x[1]=k,x[2]=1;break;case 4:x[0]=_,x[1]=0,x[2]=1;break;default:x[0]=1,x[1]=0,x[2]=k}return M=(1-u)*p,[(u*x[0]+M)*255,(u*x[1]+M)*255,(u*x[2]+M)*255]},o.hcg.hsv=function(l){var f=l[1]/100,u=l[2]/100,p=f+u*(1-f),x=0;return p>0&&(x=f/p),[l[0],x*100,p*100]},o.hcg.hsl=function(l){var f=l[1]/100,u=l[2]/100,p=u*(1-f)+.5*f,x=0;return p>0&&p<.5?x=f/(2*p):p>=.5&&p<1&&(x=f/(2*(1-p))),[l[0],x*100,p*100]},o.hcg.hwb=function(l){var f=l[1]/100,u=l[2]/100,p=f+u*(1-f);return[l[0],(p-f)*100,(1-p)*100]},o.hwb.hcg=function(l){var f=l[1]/100,u=l[2]/100,p=1-u,x=p-f,v=0;return x<1&&(v=(p-x)/(1-x)),[l[0],x*100,v*100]},o.apple.rgb=function(l){return[l[0]/65535*255,l[1]/65535*255,l[2]/65535*255]},o.rgb.apple=function(l){return[l[0]/255*65535,l[1]/255*65535,l[2]/255*65535]},o.gray.rgb=function(l){return[l[0]/100*255,l[0]/100*255,l[0]/100*255]},o.gray.hsl=o.gray.hsv=function(l){return[0,0,l[0]]},o.gray.hwb=function(l){return[0,100,l[0]]},o.gray.cmyk=function(l){return[0,0,0,l[0]]},o.gray.lab=function(l){return[l[0],0,0]},o.gray.hex=function(l){var f=Math.round(l[0]/100*255)&255,u=(f<<16)+(f<<8)+f,p=u.toString(16).toUpperCase();return"000000".substring(p.length)+p},o.rgb.gray=function(l){var f=(l[0]+l[1]+l[2])/3;return[f/255*100]}});At.rgb;At.hsl;At.hsv;At.hwb;At.cmyk;At.xyz;At.lab;At.lch;At.hex;At.keyword;At.ansi16;At.ansi256;At.hcg;At.apple;At.gray;function fE(){for(var e={},n=Object.keys(At),a=n.length,o=0;o<a;o++)e[n[o]]={distance:-1,parent:null};return e}function dE(e){var n=fE(),a=[e];for(n[e].distance=0;a.length;)for(var o=a.pop(),c=Object.keys(At[o]),m=c.length,y=0;y<m;y++){var h=c[y],l=n[h];l.distance===-1&&(l.distance=n[o].distance+1,l.parent=o,a.unshift(h))}return n}function pE(e,n){return function(a){return n(e(a))}}function hE(e,n){for(var a=[n[e].parent,e],o=At[n[e].parent][e],c=n[e].parent;n[c].parent;)a.unshift(n[c].parent),o=pE(At[n[c].parent][c],o),c=n[c].parent;return o.conversion=a,o}var mE=function(e){for(var n=dE(e),a={},o=Object.keys(n),c=o.length,m=0;m<c;m++){var y=o[m],h=n[y];h.parent!==null&&(a[y]=hE(y,n))}return a},zs={},gE=Object.keys(At);function xE(e){var n=function(a){return a==null?a:(arguments.length>1&&(a=Array.prototype.slice.call(arguments)),e(a))};return"conversion"in e&&(n.conversion=e.conversion),n}function bE(e){var n=function(a){if(a==null)return a;arguments.length>1&&(a=Array.prototype.slice.call(arguments));var o=e(a);if(typeof o=="object")for(var c=o.length,m=0;m<c;m++)o[m]=Math.round(o[m]);return o};return"conversion"in e&&(n.conversion=e.conversion),n}gE.forEach(function(e){zs[e]={},Object.defineProperty(zs[e],"channels",{value:At[e].channels}),Object.defineProperty(zs[e],"labels",{value:At[e].labels});var n=mE(e),a=Object.keys(n);a.forEach(function(o){var c=n[o];zs[e][o]=bE(c),zs[e][o].raw=xE(c)})});var _r=zs,kd=[].slice,vx=["keyword","gray","hex"],qf={};Object.keys(_r).forEach(function(e){qf[kd.call(_r[e].labels).sort().join("")]=e});var Ki={};function qt(e,n){if(!(this instanceof qt))return new qt(e,n);if(n&&n in vx&&(n=null),n&&!(n in _r))throw new Error("Unknown model: "+n);var a,o;if(e==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof qt)this.model=e.model,this.color=e.color.slice(),this.valpha=e.valpha;else if(typeof e=="string"){var c=Jn.get(e);if(c===null)throw new Error("Unable to parse color from string: "+e);this.model=c.model,o=_r[this.model].channels,this.color=c.value.slice(0,o),this.valpha=typeof c.value[o]=="number"?c.value[o]:1}else if(e.length){this.model=n||"rgb",o=_r[this.model].channels;var m=kd.call(e,0,o);this.color=Yf(m,o),this.valpha=typeof e[o]=="number"?e[o]:1}else if(typeof e=="number")e&=16777215,this.model="rgb",this.color=[e>>16&255,e>>8&255,e&255],this.valpha=1;else{this.valpha=1;var y=Object.keys(e);"alpha"in e&&(y.splice(y.indexOf("alpha"),1),this.valpha=typeof e.alpha=="number"?e.alpha:0);var h=y.sort().join("");if(!(h in qf))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=qf[h];var l=_r[this.model].labels,f=[];for(a=0;a<l.length;a++)f.push(e[l[a]]);this.color=Yf(f)}if(Ki[this.model])for(o=_r[this.model].channels,a=0;a<o;a++){var u=Ki[this.model][a];u&&(this.color[a]=u(this.color[a]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}qt.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(e){var n=this.model in Jn.to?this:this.rgb();n=n.round(typeof e=="number"?e:1);var a=n.valpha===1?n.color:n.color.concat(this.valpha);return Jn.to[n.model](a)},percentString:function(e){var n=this.rgb().round(typeof e=="number"?e:1),a=n.valpha===1?n.color:n.color.concat(this.valpha);return Jn.to.rgb.percent(a)},array:function(){return this.valpha===1?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var e={},n=_r[this.model].channels,a=_r[this.model].labels,o=0;o<n;o++)e[a[o]]=this.color[o];return this.valpha!==1&&(e.alpha=this.valpha),e},unitArray:function(){var e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,this.valpha!==1&&e.push(this.valpha),e},unitObject:function(){var e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,this.valpha!==1&&(e.alpha=this.valpha),e},round:function(e){return e=Math.max(e||0,0),new qt(this.color.map(wE(e)).concat(this.valpha),this.model)},alpha:function(e){return arguments.length?new qt(this.color.concat(Math.max(0,Math.min(1,e))),this.model):this.valpha},red:St("rgb",0,Ft(255)),green:St("rgb",1,Ft(255)),blue:St("rgb",2,Ft(255)),hue:St(["hsl","hsv","hsl","hwb","hcg"],0,function(e){return(e%360+360)%360}),saturationl:St("hsl",1,Ft(100)),lightness:St("hsl",2,Ft(100)),saturationv:St("hsv",1,Ft(100)),value:St("hsv",2,Ft(100)),chroma:St("hcg",1,Ft(100)),gray:St("hcg",2,Ft(100)),white:St("hwb",1,Ft(100)),wblack:St("hwb",2,Ft(100)),cyan:St("cmyk",0,Ft(100)),magenta:St("cmyk",1,Ft(100)),yellow:St("cmyk",2,Ft(100)),black:St("cmyk",3,Ft(100)),x:St("xyz",0,Ft(100)),y:St("xyz",1,Ft(100)),z:St("xyz",2,Ft(100)),l:St("lab",0,Ft(100)),a:St("lab",1),b:St("lab",2),keyword:function(e){return arguments.length?new qt(e):_r[this.model].keyword(this.color)},hex:function(e){return arguments.length?new qt(e):Jn.to.hex(this.rgb().round().color)},rgbNumber:function(){var e=this.rgb().color;return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255},luminosity:function(){for(var e=this.rgb().color,n=[],a=0;a<e.length;a++){var o=e[a]/255;n[a]=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)}return .2126*n[0]+.7152*n[1]+.0722*n[2]},contrast:function(e){var n=this.luminosity(),a=e.luminosity();return n>a?(n+.05)/(a+.05):(a+.05)/(n+.05)},level:function(e){var n=this.contrast(e);return n>=7.1?"AAA":n>=4.5?"AA":""},isDark:function(){var e=this.rgb().color,n=(e[0]*299+e[1]*587+e[2]*114)/1e3;return n<128},isLight:function(){return!this.isDark()},negate:function(){for(var e=this.rgb(),n=0;n<3;n++)e.color[n]=255-e.color[n];return e},lighten:function(e){var n=this.hsl();return n.color[2]+=n.color[2]*e,n},darken:function(e){var n=this.hsl();return n.color[2]-=n.color[2]*e,n},saturate:function(e){var n=this.hsl();return n.color[1]+=n.color[1]*e,n},desaturate:function(e){var n=this.hsl();return n.color[1]-=n.color[1]*e,n},whiten:function(e){var n=this.hwb();return n.color[1]+=n.color[1]*e,n},blacken:function(e){var n=this.hwb();return n.color[2]+=n.color[2]*e,n},grayscale:function(){var e=this.rgb().color,n=e[0]*.3+e[1]*.59+e[2]*.11;return qt.rgb(n,n,n)},fade:function(e){return this.alpha(this.valpha-this.valpha*e)},opaquer:function(e){return this.alpha(this.valpha+this.valpha*e)},rotate:function(e){var n=this.hsl(),a=n.color[0];return a=(a+e)%360,a=a<0?360+a:a,n.color[0]=a,n},mix:function(e,n){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);var a=e.rgb(),o=this.rgb(),c=n===void 0?.5:n,m=2*c-1,y=a.alpha()-o.alpha(),h=((m*y===-1?m:(m+y)/(1+m*y))+1)/2,l=1-h;return qt.rgb(h*a.red()+l*o.red(),h*a.green()+l*o.green(),h*a.blue()+l*o.blue(),a.alpha()*c+o.alpha()*(1-c))}};Object.keys(_r).forEach(function(e){if(vx.indexOf(e)===-1){var n=_r[e].channels;qt.prototype[e]=function(){if(this.model===e)return new qt(this);if(arguments.length)return new qt(arguments,e);var a=typeof arguments[n]=="number"?n:this.valpha;return new qt(yE(_r[this.model][e].raw(this.color)).concat(a),e)},qt[e]=function(a){return typeof a=="number"&&(a=Yf(kd.call(arguments),n)),new qt(a,e)}}});function vE(e,n){return Number(e.toFixed(n))}function wE(e){return function(n){return vE(n,e)}}function St(e,n,a){return e=Array.isArray(e)?e:[e],e.forEach(function(o){(Ki[o]||(Ki[o]=[]))[n]=a}),e=e[0],function(o){var c;return arguments.length?(a&&(o=a(o)),c=this[e](),c.color[n]=o,c):(c=this[e]().color[n],a&&(c=a(c)),c)}}function Ft(e){return function(n){return Math.max(0,Math.min(e,n))}}function yE(e){return Array.isArray(e)?e:[e]}function Yf(e,n){for(var a=0;a<n;a++)typeof e[a]!="number"&&(e[a]=0);return e}var Ef=qt;function Nr(e){const n=Ef(e),a=Ef({r:255,g:255,b:255}),o=Ef({r:0,g:0,b:0});return n.red()*.299+n.green()*.587+n.b()*.114>=186?o:a}const Tg=({preview:e,config:n,settings:a,labels:o,backgroundColor:c,layout:m})=>{const y=n.blogUrl,h=n.signupForm.url.replace("{version}",n.signupForm.version);let l={site:y,locale:a.locale,"button-color":a.accentColor,"button-text-color":Nr(a.accentColor).hex()};for(const[_,k]of o.entries())l[`label-${_+1}`]=k.name;let f="min-height: 58px;max-width: 440px;margin: 0 auto;width: 100%";m==="all-in-one"&&(a.icon&&a.icon!==""&&(l.icon=a.icon.replace(/\/content\/images\//,"/content/images/size/w192h192/")),l.title=a.title,l.description=a.description,l["background-color"]=c,l["text-color"]=Nr(c).hex(),f="height: 40vmin;min-height: 360px"),e&&(m==="minimal"?f="min-height: 58px; max-width: 440px;width: 100%;position: absolute; left: 50%; top:50%; transform: translate(-50%, -50%);":f="height: 100vh");let u="";const p=["background-color","text-color","button-color","button-text-color","title","description","icon","site","locale"],x=Object.keys(l).sort((_,k)=>p.indexOf(_)-p.indexOf(k));for(const _ of x){const k=l[_];u+=` data-${_}="${Eg(k)}"`}const v=`<div style="${Eg(f)}"><script src="${encodeURI(h)}"${u} async><\/script></div>`;return e&&m==="minimal"?`<div style="position: absolute; z-index: -1; top: 0; left: 0; width: 100%; height: 100%; background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%), linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%);background-size: 16px 16px;background-position: 0 0, 8px 8px;;"></div>${v}`:v},_E=ye.create(()=>{const[e,n]=D.useState("#08090c"),[a,o]=D.useState([]),[c,m]=D.useState("all-in-one"),[y,h]=D.useState(""),[l,f]=D.useState(""),[u,p]=D.useState(!1),{updateRoute:x}=Qe(),{config:v}=Je(),{localSettings:_,siteData:k}=ss(),[M,T,A,C,O]=gt(_,["accent_color","title","description","locale","icon"]),[$,W]=D.useState({active:!1});D.useEffect(()=>{if(!k)return;const q={config:{blogUrl:k.url,signupForm:{url:v?.signupForm?.url,version:v?.signupForm?.version}},settings:{accentColor:M||"#d74780",title:T||"",locale:C||"en",icon:O||"",description:A||""},labels:a.map(({label:ae})=>({name:ae})),backgroundColor:e||"#08090c",layout:c},B=Tg({preview:!0,...q});h(B);const Y=Tg({preview:!1,...q});f(Y)},[k,M,a,v,T,e,c,C,O,A]);const R=async()=>{try{await navigator.clipboard.writeText(l),p(!0),setTimeout(()=>p(!1),2e3)}catch(q){console.error("Failed to copy text: ",q)}},Z=q=>{n(q)},X=q=>{if(q?.length){const B=q?.map(({value:Y})=>({label:Y,value:Y}));o(B)}else o([])};return s.jsx(yt,{afterClose:()=>{x("embed-signup-form")},cancelLabel:"",footer:!1,height:645,padding:!1,testId:"embed-signup-form",title:"",topRightContent:"close",width:1120,children:s.jsxs("div",{className:"grid grid-cols-[5.2fr_2.8fr]",children:[s.jsx(lE,{html:y,style:c}),s.jsx(cE,{accentColor:M,customColor:$,embedScript:l,handleColorToggle:Z,handleCopyClick:R,handleLabelClick:X,handleLayoutSelect:m,isCopied:u,selectedColor:e,selectedLabels:a,selectedLayout:c,setCustomColor:W})]})})}),kE=ye.create(()=>{const{updateRoute:e}=Qe(),{settings:n}=Je(),{mutateAsync:a}=Rn(),o=ot(),[c,m]=D.useState(""),[y]=gt(n,["firstpromoter"]),[h]=gt(n,["firstpromoter_id"]),[l,f]=D.useState("Save"),[u,p]=D.useState(!!y);D.useEffect(()=>{p(y||!1),m(h||null)},[y,h]);const x=async()=>{const v=[{key:"firstpromoter",value:u},{key:"firstpromoter_id",value:c}];try{f("Saving..."),await Promise.all([a(v),new Promise(_=>{setTimeout(_,1e3)})]),f("Saved")}catch(_){o(_)}finally{setTimeout(()=>f("Save"),1e3)}};return s.jsxs(yt,{afterClose:()=>{e("integrations")},cancelLabel:"Close",dirty:u!==y||c!==h,okColor:l==="Saved"?"green":"black",okLabel:l,testId:"firstpromoter-modal",title:"",onOk:async()=>{try{await x()}catch(v){o(v)}},children:[s.jsx(Qs,{detail:"Launch your own member referral program",icon:s.jsx(ut,{className:"-mt-2",name:"firstpromoter",size:56}),title:"FirstPromoter"}),s.jsx("div",{className:"mt-7",children:s.jsxs(tt,{marginBottom:!1,title:"FirstPromoter configuration",grouped:!0,children:[s.jsx(st,{checked:u,direction:"rtl",hint:s.jsxs(s.Fragment,{children:["Enable ",s.jsx("a",{className:"text-green",href:"https://firstpromoter.com/?fpr=ghost&fp_sid=admin",rel:"noopener noreferrer",target:"_blank",children:"FirstPromoter"})," for tracking referrals"]}),label:"Enable FirstPromoter",onChange:v=>{p(v.target.checked)}}),u&&s.jsx(Ae,{hint:s.jsxs(s.Fragment,{children:["Affiliate and referral tracking, find your ID ",s.jsx("a",{className:"text-green",href:"https://ghost.org/help/firstpromoter-id/",rel:"noopener noreferrer",target:"_blank",children:"here"})]}),placeholder:"XXXXXXXX",title:"FirstPromoter account ID",value:c||"",onChange:v=>{m(v.target.value)}})]})})]})}),ME="ActionsResponseType",jE=v_({dataType:ME,path:"/actions/",returnData:e=>{const{pages:n}=e;let a=n.flatMap(m=>m.actions.map(({context:y,...h})=>({...h,context:JSON.parse(y)})));a=a.reverse();let o=1;a.forEach((m,y)=>{const h=a[y+1];h&&m.resource_id===h.resource_id&&m.event===h.event?(m.skip=!0,o+=1):o>1&&(m.count=o,o=1)});const c=n[n.length-1].meta;return{actions:a.reverse(),meta:c,isEnd:c?c.pagination.pages===c.pagination.page:!0}}}),EE=e=>{var n,a;let o=e.resource_type;if(e.event!=="deleted")switch(e.resource_type){case"page":case"post":return!e.resource||!e.resource.id?void 0:(o==="post"&&(n=e.context)!=null&&n.type&&(o=(a=e.context)==null?void 0:a.type),{isExternal:!0,route:`editor/${o}/${e.resource.id}`,models:[o,e.resource.id]});case"integration":return!e.resource||!e.resource.id?void 0:{route:`integrations/${e.resource.id}`};case"offer":return!e.resource||!e.resource.id?void 0:{isExternal:!0,route:`offers/${e.resource.id}`,models:[e.resource.id]};case"tag":return!e.resource||!e.resource.slug?void 0:{isExternal:!0,route:"tag",models:[e.resource.slug]};case"product":return{route:"tiers"};case"user":return!e.resource||!e.resource.slug?void 0:{route:`staff/${e.resource.slug}`}}},TE=e=>{var n,a,o,c,m,y,h;let l=e.resource_type;l==="api_key"?l="API key":l==="setting"?l="settings":l==="product"&&(l="tier"),l==="post"&&(n=e.context)!=null&&n.type&&(l=(a=e.context)==null?void 0:a.type);let f=e.event;return e.event==="edited"&&(o=e.context)!=null&&o.action_name&&(f=(c=e.context)==null?void 0:c.action_name),(m=e.context)!=null&&m.count&&((y=e.context)==null?void 0:y.count)>1?`${(h=e.context)==null?void 0:h.count} ${l}s ${f}`:`${l.slice(0,1).toUpperCase()}${l.slice(1)} ${f}`},SE=e=>{var n,a,o,c;if(e.resource_type==="setting"&&(n=e.context)!=null&&n.group&&(a=e.context)!=null&&a.key)return{group:(o=e.context)==null?void 0:o.group,key:(c=e.context)==null?void 0:c.key}},Sg=e=>{var n,a;return typeof((n=e.context)==null?void 0:n.count)=="number"&&((a=e.context)==null?void 0:a.count)>1},NE=({action:e})=>{let n="pen";switch(e.event){case"added":n="add";break;case"deleted":n="trash";break}return s.jsx(ut,{name:n,size:"xs"})},AE=({action:e})=>s.jsxs("div",{className:"relative shrink-0",children:[s.jsx(Vg,{bgColor:Jg(e.actor?.name||e.actor?.slug||""),image:e.actor?.image??void 0,label:Qg(e.actor?.name||e.actor?.slug),labelColor:"white",size:"md"}),s.jsx("div",{className:"absolute -bottom-1 -right-1 z-30 flex items-center justify-center rounded-full border border-grey-100 bg-white p-1 shadow-sm dark:border-grey-900 dark:bg-black",children:s.jsx(NE,{action:e})})]}),An=({label:e,item:n,excludedItems:a,toggleItem:o})=>s.jsx(st,{checked:!a.includes(n),direction:"rtl",label:e,labelClasses:"text-sm",onChange:c=>o(n,c.target.checked)}),IE=({excludedEvents:e,excludedResources:n,toggleEventType:a,toggleResourceType:o})=>{const{updateRoute:c}=Qe(),m=Zg({path:"/users/",filterKey:"name",responseKey:"users"}),y=async(u,p)=>{const x=await m.loadData(u);p(x.map(v=>({label:v.name,value:v.id})))},[h,l]=D.useState(),f=()=>{l(null)};return s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(zg,{position:"end",trigger:s.jsx(Ue,{color:"outline",label:"Filter"}),children:s.jsxs("div",{className:"flex w-[220px] flex-col gap-8 p-5",children:[s.jsxs(Yi,{children:[s.jsx(An,{excludedItems:e,item:"added",label:"Added",toggleItem:a}),s.jsx(An,{excludedItems:e,item:"edited",label:"Edited",toggleItem:a}),s.jsx(An,{excludedItems:e,item:"deleted",label:"Deleted",toggleItem:a})]}),s.jsxs(Yi,{children:[s.jsx(An,{excludedItems:n,item:"post",label:"Posts",toggleItem:o}),s.jsx(An,{excludedItems:n,item:"page",label:"Pages",toggleItem:o}),s.jsx(An,{excludedItems:n,item:"tag",label:"Tags",toggleItem:o}),s.jsx(An,{excludedItems:n,item:"offer,product",label:"Tiers & offers",toggleItem:o}),s.jsx(An,{excludedItems:n,item:"api_key,integration,setting,user,webhook",label:"Settings & staff",toggleItem:o})]})]})}),s.jsx("div",{className:"w-[200px]",children:s.jsx(Lt,{loadOptions:Ji(y,500),placeholder:"Search staff",value:h,async:!0,defaultOptions:!0,isClearable:!0,onSelect:u=>{u?(l(u),c(`history/view/${u.value}`)):(f(),c("history/view"))}})})]})},CE=({action:e})=>{const{updateRoute:n}=Qe(),a=SE(e);if(a){const{group:o,key:c}=a;return s.jsxs(s.Fragment,{children:[o.slice(0,1).toUpperCase(),o.slice(1),o!==c&&s.jsxs("span",{className:"text-xs",children:[" ",s.jsxs("code",{className:"mb-1 bg-white text-grey-800 dark:bg-grey-900 dark:text-white",children:["(",c,")"]})]})]})}else if(e.resource?.title||e.resource?.name||e.context?.primary_name){const o=EE(e);return o?s.jsx("a",{className:"cursor-pointer font-bold",onClick:c=>{c.preventDefault(),n(o)},children:e.resource?.title||e.resource?.name}):s.jsx(s.Fragment,{children:e.resource?.title||e.resource?.name||e.context?.primary_name})}else return s.jsx("span",{className:"text-grey-500",children:"(unknown)"})},DE=e=>{const a=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(e).reduce((o,{type:c,value:m})=>({...o,[c]:m}),{});return`${a.year}-${a.month}-${a.day} ${a.hour}:${a.minute}:${a.second}`},RE=200,OE=ye.create(({params:e})=>{const n=Zt(),{updateRoute:a}=Qe(),[o,c]=D.useState([]),[m,y]=D.useState(["label"]),{data:h,fetchNextPage:l,isFetchingNextPage:f}=jE({searchParams:{include:"actor,resource",limit:RE.toString(),filter:[o.length&&`event:-[${o.join(",")}]`,m.length&&`resource_type:-[${m.join(",")}]`,e?.user&&`actor_id:'${e.user}'`].filter(Boolean).join("+")},getNextPageParams:(v,_)=>({..._,filter:[_.filter,v.actions.length&&`created_at:<'${DE(new Date(v.actions[v.actions.length-1].created_at))}'`].join("+")}),keepPreviousData:!0}),u=D.useCallback(()=>{h?.isEnd||l()},[h?.isEnd,l]),p=(v,_,k)=>{v(M=>k?M.concat(_):M.filter(T=>T!==_))},x=o.length>0||m.length>0||e?.user;return s.jsx(yt,{afterClose:()=>{a("history")},cancelLabel:"",okLabel:"Close",scrolling:!0,size:"md",stickyFooter:!0,stickyHeader:!0,testId:"history-modal",title:"History",topRightContent:s.jsx(IE,{excludedEvents:o,excludedResources:m,toggleEventType:(v,_)=>p(c,v,!_),toggleResourceType:(v,_)=>p(y,v,!_),userId:e?.user}),onOk:()=>{n.remove(),a("history")},children:s.jsx("div",{className:"relative mt-6",children:s.jsx(cn,{hint:h?.isEnd&&h.actions.length>0?"End of history log":void 0,children:h?.actions?h.actions.length>0?s.jsxs(s.Fragment,{children:[s.jsx(m3,{offset:250,onTrigger:u}),h.actions.map(v=>!v.skip&&s.jsx(On,{avatar:s.jsx(AE,{action:v}),detail:[new Date(v.created_at).toLocaleDateString("default",{year:"numeric",month:"short",day:"2-digit"}),new Date(v.created_at).toLocaleTimeString("default",{hour:"2-digit",minute:"2-digit",second:"2-digit"})].join(" | "),title:s.jsxs("div",{className:"text-sm",children:[TE(v),Sg(v)?"":": ",!Sg(v)&&s.jsx(CE,{action:v}),v.count?s.jsxs(s.Fragment,{children:[" ",v.count," times"]}):null,s.jsxs("span",{children:[" — by ",v.actor?.name||v.actor?.slug]})]}),separator:!0})),f&&s.jsx("div",{className:"flex items-center justify-center p-5",children:s.jsx(Wi,{size:"md"})})]}):s.jsx(hh,{icon:"time-back",children:x?"No entries match your current filters.":"No history entries found."}):h===void 0?s.jsx("div",{className:"flex items-center justify-center px-5 pb-10 pt-12",children:s.jsx(Wi,{})}):s.jsx(hh,{children:"No entries found."})})})})}),$E=ye.create(()=>{const e=ye.useModal(),n=If(),a=If({searchParams:{limit:"100",permissions:"assign"}}),o=Ys(),{updateRoute:c}=Qe(),{config:m}=Je(),y=m.labs.superEditors,h=D.useRef(null),[l,f]=D.useState(""),[u,p]=D.useState(""),[x,v]=D.useState("contributor"),[_,k]=D.useState({}),{data:{users:M}={}}=w_(),{data:{invites:T}={}}=f2(),{mutateAsync:A}=d2(),C=ot();if(D.useEffect(()=>{h.current&&h.current.focus()},[]),D.useEffect(()=>{u==="saved"&&setTimeout(()=>{p("")},2e3)},[u]),D.useEffect(()=>{x!=="contributor"&&o?.isLimited("staff")?o.errorIfWouldGoOverLimit("staff").then(()=>{k(q=>({...q,role:void 0}))}).catch(q=>{if(q instanceof Gs){k(B=>({...B,role:q.message}));return}else throw q}):k(q=>({...q,role:void 0}))},[o,x]),!n.data?.roles||!a.data?.roles)return null;const O=n.data.roles,$=a.data.roles;let W="Send invitation";u==="saving"?W="Sending...":u==="saved"?W="Invite sent!":u==="error"&&(W="Retry");const R=async()=>{if(u!=="saving"){if(!Nt.isEmail(l)){k({email:"Please enter a valid email address."});return}if(M?.some(({email:q})=>q===l)){k({email:"A user with that email address already exists."});return}if(T?.some(({email:q})=>q===l)){k({email:"A user with that email address was already invited."});return}if(!_.role){p("saving");try{await A({email:l,roleId:O.find(({name:q})=>q.toLowerCase()===x.toLowerCase()).id}),p("saved"),xt({title:"Invitation sent",message:`${l}`,type:"success"}),e.remove(),c("staff?tab=invited")}catch(q){p("error");let B="Failed to send invitation",Y=s.jsxs("span",{children:["If the problem persists, ",s.jsxs("a",{href:"https://ghost.org/contact",children:[s.jsx("u",{children:"contact support"}),"."]}),"."]});q instanceof y_&&q.data?.errors?.[0]?.type==="EmailError"&&(Y=s.jsx("span",{children:"Check your Mailgun configuration."})),xt({title:B,message:Y,type:"error"}),C(q,{withToast:!1});return}}}},Z=[{hint:"Can create and edit their own posts, but cannot publish. An Editor needs to approve and publish for them.",label:"Contributor",value:"contributor"},{hint:"A trusted user who can create, edit and publish their own posts, but can’t modify others.",label:"Author",value:"author"},{hint:"Can invite and manage other Authors and Contributors, as well as edit and publish any posts on the site.",label:"Editor",value:"editor"},{hint:"Trusted staff user who should be able to manage all content and users, as well as site settings and options.",label:"Administrator",value:"administrator"}];y&&(Z[2]={hint:"Can invite and manage other Authors and Contributors, as well as edit and publish any posts on the site. Can manage members and moderate comments.",label:"Editor (beta mode)",value:"super editor"});const X=Z.filter(q=>$.some(B=>B.name===q.label||B.name==="Super Editor"&&q.label==="Editor (beta mode)"));return _.email&&(W="Retry"),s.jsx(yt,{afterClose:()=>{c("staff")},cancelLabel:"",okColor:u==="error"||_.email?"red":"black",okLabel:W,testId:"invite-user-modal",title:"Invite a new staff user",width:540,onOk:R,children:s.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[s.jsx("p",{children:"Send an invitation for a new person to create a staff account on your site, and select a role that matches what you’d like them to be able to do."}),s.jsx(Ae,{error:!!_.email,hint:_.email,inputRef:h,placeholder:"jamie@example.com",title:"Email address",value:l,onChange:q=>{f(q.target.value)},onKeyDown:()=>k(q=>({...q,email:void 0}))}),s.jsx("div",{children:s.jsx(h3,{error:!!_.role,hint:_.role,id:"role",options:X,selectedOption:x,separator:!0,title:"Role",onSelect:q=>{v(q)}})})]})})}),Ng=({items:e,setItems:n})=>{const a=x=>!!(x.label&&!x.label.match(/^\s*$/)||x.url!=="/"),o=U0({items:e.map(x=>({...x,errors:{}})),setItems:x=>n(x.map(({url:v,label:_})=>({url:v,label:_}))),blank:{url:"/",label:"",errors:{}},canAddNewItem:a}),c=new RegExp(/^(\/|#|[a-zA-Z0-9-]+:)/),m=x=>{const v={};return(!x.label||x.label.match(/^\s*$/))&&(v.label="You must specify a label"),(!x.url||x.url.match(/\s/)||!Nt.isURL(x.url,{require_protocol:!0})&&!x.url.match(c))&&(v.url="You must specify a valid URL or relative path"),v},y=(x,v)=>{const _=o.items.find(k=>k.id===x);o.updateItem(x,{..._.item,...v})},h=()=>{const x=m(o.newItem);Object.values(x).some(v=>v)?o.setNewItem({...o.newItem,errors:x}):o.addItem()},l=x=>{o.removeItem(x)},f=(x,v)=>{o.moveItem(x,v)},u="new",p=(x,v)=>{if(x===u)o.setNewItem({...o.newItem,errors:{...o.newItem.errors,[v]:void 0}});else{const _=o.items.find(k=>k.id===x).item;o.updateItem(x,{..._,errors:{..._.errors,[v]:void 0}})}};return{items:o.items.map(({item:x,id:v})=>({...x,id:v})),updateItem:y,addItem:h,removeItem:l,moveItem:f,newItem:{...o.newItem,id:u},setNewItem:x=>o.setNewItem({...o.newItem,...x}),clearError:p,validate:()=>{let x=!0;if(o.items.forEach(({item:v,id:_})=>{let k=m(v);Object.values(k).some(M=>M)&&(x=!1,o.updateItem(_,{...v,errors:k}))}),a(o.newItem)){const v=m(o.newItem);Object.values(v).some(_=>_)&&(x=!1,o.setNewItem({...o.newItem,errors:v}))}return x}}},Ag=({baseUrl:e,item:n,updateItem:a,addItem:o,clearError:c,labelPlaceholder:m,unstyled:y,textFieldClasses:h,action:l,className:f,...u})=>s.jsxs("div",{className:we("flex w-full items-start gap-3",f),"data-testid":"navigation-item-editor",...u,children:[s.jsx("div",{className:"flex flex-1 pt-1",children:s.jsx(Ae,{className:h,containerClassName:"grow",error:!!n.errors.label,hint:n.errors.label,placeholder:m,title:"Label",unstyled:y,value:n.label,hideTitle:!0,onChange:p=>a?.({label:p.target.value}),onKeyDown:p=>{a?.({label:p.target.value}),p.key==="Enter"&&(p.preventDefault(),o?.()),n.errors.label&&c?.("label")}})}),s.jsx("div",{className:"flex flex-1 pt-1",children:s.jsx(Hg,{baseUrl:e,className:h,containerClassName:"grow",error:!!n.errors.url,hint:n.errors.url,title:"URL",unstyled:y,value:n.url,hideTitle:!0,onChange:p=>a?.({url:p||""}),onKeyDown:p=>{const x=Bi(p.target.value,e,!0);a?.({url:x.save||""})},onKeyUp:p=>{if(p.key==="Enter"){p.preventDefault();const x=Bi(p.target.value,e,!0);a?.({url:x.save||""}),o?.()}n.errors.url&&c?.("url")}})}),l]}),Ig=({baseUrl:e,navigation:n})=>s.jsxs("div",{className:"w-full pt-2",children:[s.jsx(Bg,{items:n.items,itemSeparator:!1,renderItem:a=>s.jsx(Ag,{action:s.jsx(Ue,{className:"mt-1 self-center",icon:"trash",iconColorClass:"dark:text-white",size:"sm",onClick:()=>n.removeItem(a.id)}),baseUrl:e,clearError:o=>n.clearError(a.id,o),item:a,updateItem:o=>n.updateItem(a.id,o)}),onMove:n.moveItem}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ut,{colorClass:"text-grey-300 dark:text-grey-900 mt-1",name:"add",size:"sm"}),s.jsx(Ag,{action:s.jsx(Ue,{className:"mx-2 mt-1 self-center rounded bg-green p-1","data-testid":"add-button",icon:"add",iconColorClass:"text-white",size:"sm",unstyled:!0,onClick:n.addItem}),addItem:n.addItem,baseUrl:e,className:"mt-1",clearError:a=>n.clearError(n.newItem.id,a),"data-testid":"new-navigation-item",item:n.newItem,labelPlaceholder:"New item label",updateItem:n.setNewItem})]})]}),LE=ye.create(()=>{const e=Zt(),{updateRoute:n}=Qe(),{localSettings:a,updateSetting:o,saveState:c,handleSave:m,siteData:y}=ss(),[h,l]=gt(a,["navigation","secondary_navigation"]).map(v=>JSON.parse(v||"[]")),f=Ng({items:h,setItems:v=>{o("navigation",JSON.stringify(v))}}),u=Ng({items:l,setItems:v=>o("secondary_navigation",JSON.stringify(v))}),[p,x]=D.useState("primary-nav");return s.jsx(yt,{afterClose:()=>{n("navigation")},buttonsDisabled:c==="saving",cancelLabel:"Close",dirty:a.some(v=>v.dirty),okLabel:c==="saving"?"Saving...":"Save",scrolling:!0,size:"lg",stickyFooter:!0,testId:"navigation-modal",title:"Navigation",onOk:async()=>{f.validate()&&u.validate()&&(await m(),e.remove(),n("navigation"))},children:s.jsx("div",{className:"mb-1 mt-6",children:s.jsx(Dn,{selectedTab:p,tabs:[{id:"primary-nav",title:"Primary",contents:s.jsx(Ig,{baseUrl:y.url,navigation:f})},{id:"secondary-nav",title:"Secondary",contents:s.jsx(Ig,{baseUrl:y.url,navigation:u})}],onTabChange:x})})})}),PE=""+new URL("user-cover-yM4cP_Mo.jpg",import.meta.url).href,FE=""+new URL("latest-posts-1-D7-ilqhR.jpg",import.meta.url).href,UE=""+new URL("latest-posts-2-BPfbGB8B.jpg",import.meta.url).href,zE=""+new URL("latest-posts-3-D72O3dn8.jpg",import.meta.url).href,HE=({senderName:e,senderEmail:n,senderReplyTo:a,headerImage:o,headerIcon:c,headerTitle:m,headerSubtitle:y,showPostTitleSection:h,showExcerpt:l,titleAlignment:f,titleFontCategory:u,titleFontWeight:p,bodyFontCategory:x,authorPlaceholder:v,showCommentCta:_,showFeatureImage:k,showFeedback:M,showLatestPosts:T,showSubscriptionDetails:A,siteTitle:C,footerContent:O,showBadge:$,backgroundColor:W,headerBackgroundColor:R,accentColor:Z,textColor:X,secondaryTextColor:q,headerTextColor:B,secondaryHeaderTextColor:Y,postTitleColor:ae,sectionTitleColor:ee,dividerColor:re,buttonColor:Q,buttonTextColor:ne,linkColor:be,buttonCorners:je,buttonStyle:H,imageCorners:he,linkStyle:ge,dividerStyle:F})=>{const L=c||m,{config:J}=Je(),xe=new Date().toLocaleDateString("default",{year:"numeric",month:"short",day:"numeric"}),Te=new Date().getFullYear(),De=O?O.replace(/<a/g,'<a target="_blank" rel="noopener noreferrer"'):"";let Me;Qi(J)?Me=s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"leading-normal",children:[s.jsx("span",{className:"font-semibold text-grey-900",children:"From: "}),s.jsxs("span",{children:[e," (",n,")"]})]}),s.jsxs("p",{className:"leading-normal",children:[s.jsx("span",{className:"font-semibold text-grey-900",children:"Reply-to: "}),a||n]})]}):Me=s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"leading-normal",children:[s.jsx("span",{className:"font-semibold text-grey-900",children:e}),s.jsxs("span",{children:[" ",n]})]}),s.jsxs("p",{className:"leading-normal",children:[s.jsx("span",{className:"font-semibold text-grey-900",children:"To:"})," Jamie Larson jamie@example.com"]})]});let oe="mb-5 text-pretty leading-[1.7] text-black";return u==="serif"&&x==="serif"?oe=we(oe,"mb-8 font-serif text-[2.0rem] leading-tight"):u!=="serif"&&x==="serif"?oe=we(oe,"mb-8 text-[1.7rem] leading-tight tracking-tight"):u==="serif"&&x!=="serif"?oe=we(oe,"mb-8 font-serif text-[2.0rem] leading-tight"):oe=we(oe,"mb-8 text-[1.9rem] leading-tight tracking-tight"),f==="center"&&(oe=we(oe,"text-center")),s.jsx("div",{className:"relative flex grow flex-col",children:s.jsx("div",{className:"absolute inset-0 m-5 flex items-center justify-center",children:s.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:[s.jsx("div",{className:"flex-column flex min-h-[77px] justify-center rounded-t-sm border-b border-grey-200 bg-white px-6 text-sm text-grey-700",children:Me}),s.jsxs("div",{className:"overflow-y-auto text-sm",style:{backgroundColor:W},children:[s.jsxs("div",{className:"px-[7rem]",style:{backgroundColor:R},children:[o&&s.jsx("div",{children:s.jsx("img",{alt:"",className:"mb-4 block pt-6",src:o})}),L&&s.jsxs("div",{className:"py-3",children:[c&&s.jsx("img",{alt:"",className:"mx-auto mb-2 size-10",role:"presentation",src:c}),m&&s.jsx("h4",{className:"mb-1 text-center text-[1.6rem] font-bold uppercase leading-tight tracking-tight text-grey-900",style:{color:B},children:m}),y&&s.jsx("h5",{className:"mb-1 text-center text-[1.3rem] font-normal text-grey-700",style:{color:Y},children:y})]}),h&&s.jsxs("div",{className:we("flex flex-col py-8",f==="center"?"items-center":"items-start"),children:[s.jsx("h2",{className:we("text-4xl font-bold leading-supertight text-black",u==="serif"&&"font-serif",p==="normal"&&"font-normal",p==="medium"&&"font-medium",p==="semibold"&&"font-semibold",p==="bold"&&"font-bold",f==="center"?"text-center":"text-left",l?"mb-2":"mb-8"),style:{color:ae},children:"Your email newsletter"}),l&&s.jsx("p",{className:oe,style:{color:B},children:"A subtitle to highlight key points and engage your readers."}),s.jsxs("div",{className:we("flex w-full justify-between text-center text-md leading-none text-grey-700",f==="center"?"flex-col gap-1":"flex-row"),children:[s.jsxs("p",{className:"pb-1 text-[1.3rem]",style:{color:Y},children:["By ",v,s.jsx("span",{className:"before:pl-0.5 before:pr-1 before:content-['•']",children:xe})]}),s.jsx("p",{className:"pb-1 text-[1.3rem] underline",style:{color:Y},children:s.jsx("span",{children:"View in browser"})})]})]}),k&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:we("h-[unset] w-full max-w-[600px] bg-cover bg-no-repeat",h?"":"pt-6"),children:s.jsx("img",{alt:"Feature",className:we("min-h-full min-w-full shrink-0",he==="square"&&"rounded-none",he==="rounded"&&"rounded-md"),src:PE})}),s.jsx("div",{className:"mt-1 w-full max-w-[600px] pb-8 text-center text-[1.3rem] text-grey-700",style:{color:Y},children:"Feature image caption"})]})]}),s.jsxs("div",{className:we("px-[7rem]",R!=="transparent"&&"pt-10"),children:[s.jsxs("div",{className:we("max-w-[600px] border-b border-grey-200 pb-[52px] leading-[27.2px] text-black",F==="dashed"&&"border-dashed",F==="dotted"&&"border-b-2 border-dotted",x==="serif"?"font-serif text-[1.8rem]":"text-[1.7rem] tracking-tight",k||h?"":"pt-8"),style:{borderColor:re},children:[s.jsx("p",{className:"mb-6",style:{color:X},children:"This is what your content will look like when you send one of your posts as an email newsletter to your subscribers."}),s.jsx("p",{className:"mb-6",style:{color:X},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."}),s.jsx("p",{className:"mb-[52px]",style:{color:X},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."}),s.jsx("hr",{className:we("my-[52px] border-[#e0e7eb]",F==="dashed"&&"border-dashed",F==="dotted"&&"border-b-2 border-t-0 border-dotted"),style:{borderColor:re}}),s.jsx("h3",{className:we("mb-[13px] text-[2.6rem] leading-supertight",u==="serif"&&"font-serif",u==="sans_serif"&&"font-sans",p==="normal"&&"font-normal",p==="medium"&&"font-medium",p==="semibold"&&"font-semibold",p==="bold"&&"font-bold"),style:{color:ee},children:"Need inspiration?"}),s.jsxs("p",{className:"mb-[27px]",style:{color:X},children:["We've put together a ",s.jsx("a",{className:we(ge==="underline"&&"underline",ge==="bold"&&"font-bold"),href:"https://ghost.org/help/email-design/",rel:"noopener noreferrer",style:{color:be||Z},target:"_blank",children:"quick guide"})," that walks through all of the available settings, along with a few examples of what's possible."]}),s.jsx("a",{className:we("inline-block border px-[18px] py-2 font-sans text-[15px]",je==="rounded"&&"rounded-[6px]",je==="pill"&&"rounded-full",je==="square"&&"rounded-none",H==="outline"?"bg-transparent":"border-transparent text-white",ge==="bold"?"font-bold":"font-semibold"),href:"https://ghost.org/help/email-design/",rel:"noopener noreferrer",style:H==="outline"?{borderColor:Q||Z,color:Q||Z}:{backgroundColor:Q||Z,color:ne},target:"_blank",children:"Learn more"})]}),(M||_)&&s.jsx("div",{className:we("grid gap-5 border-b border-grey-200 px-6 py-5",F==="dashed"&&"border-dashed",F==="dotted"&&"border-b-2 border-dotted"),style:{borderColor:re},children:s.jsxs("div",{className:"flex justify-center gap-3",children:[M&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"pointer-events-none cursor-default whitespace-nowrap rounded-[2.2rem] bg-transparent font-semibold",type:"button",children:s.jsxs("span",{className:"inline-flex items-center gap-2 px-[18px] py-[7px]",style:{color:X},children:[s.jsx(ut,{colorClass:"",name:"thumbs-up",size:"md"}),s.jsx("span",{children:"More like this"})]})}),s.jsx("button",{className:"pointer-events-none cursor-default whitespace-nowrap rounded-[2.2rem] bg-transparent font-semibold",type:"button",children:s.jsxs("span",{className:"inline-flex items-center gap-2 px-[18px] py-[7px]",style:{color:X},children:[s.jsx(ut,{colorClass:"",name:"thumbs-down"}),s.jsx("span",{children:"Less like this"})]})})]}),_&&s.jsx("button",{className:"pointer-events-none cursor-default whitespace-nowrap rounded-[2.2rem] bg-transparent font-semibold",type:"button",children:s.jsxs("span",{className:"inline-flex items-center gap-2 px-[18px] py-[7px]",style:{color:X},children:[s.jsx(ut,{colorClass:"",name:"comment"}),s.jsx("span",{children:"Comment"})]})})]})}),T&&s.jsxs("div",{className:we("border-b border-grey-200 py-6",F==="dashed"&&"border-dashed",F==="dotted"&&"border-b-2 border-dotted"),style:{borderColor:re},children:[s.jsx("h3",{className:"mb-4 mt-2 pb-1 text-[1.2rem] font-semibold uppercase tracking-wide text-black",style:{color:X},children:"Keep reading"}),s.jsxs("div",{className:"flex justify-between gap-4 py-2",children:[s.jsxs("div",{children:[s.jsx("h4",{className:we("mt-0.5 text-[1.9rem] text-black",u==="serif"&&"font-serif",p==="normal"&&"font-normal",p==="medium"&&"font-medium",p==="semibold"&&"font-semibold",p==="bold"&&"font-bold"),style:{color:ee},children:"The three latest posts published on your site"}),s.jsx("p",{className:"m-0 text-base text-grey-700",style:{color:q},children:"Posts sent as an email only will never be shown here."})]}),s.jsx("div",{className:"aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat",children:s.jsx("img",{alt:"Latest post",className:we(he==="square"&&"rounded-none",he==="rounded"&&"rounded-md"),src:FE})})]}),s.jsxs("div",{className:"flex justify-between gap-4 py-2",children:[s.jsxs("div",{children:[s.jsx("h4",{className:we("mt-0.5 text-[1.9rem] text-black",u==="serif"&&"font-serif",p==="normal"&&"font-normal",p==="medium"&&"font-medium",p==="semibold"&&"font-semibold",p==="bold"&&"font-bold"),style:{color:ee},children:"Displayed at the bottom of each newsletter"}),s.jsx("p",{className:"m-0 text-base text-grey-700",style:{color:q},children:"Giving your readers one more place to discover your stories."})]}),s.jsx("div",{className:"aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat",children:s.jsx("img",{alt:"Latest post",className:we(he==="square"&&"rounded-none",he==="rounded"&&"rounded-md"),src:UE})})]}),s.jsxs("div",{className:"flex justify-between gap-4 py-2",children:[s.jsxs("div",{children:[s.jsx("h4",{className:we("mt-0.5 text-[1.9rem] text-black",u==="serif"&&"font-serif",p==="normal"&&"font-normal",p==="medium"&&"font-medium",p==="semibold"&&"font-semibold",p==="bold"&&"font-bold"),style:{color:ee},children:"To keep your work front and center"}),s.jsx("p",{className:"m-0 text-base text-grey-700",style:{color:q},children:"Making sure that your audience stays engaged."})]}),s.jsx("div",{className:"aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat",children:s.jsx("img",{alt:"Latest post",className:we(he==="square"&&"rounded-none",he==="rounded"&&"rounded-md"),src:zE})})]})]}),A&&s.jsxs("div",{className:we("border-b border-grey-200 py-8",F==="dashed"&&"border-dashed",F==="dotted"&&"border-b-2 border-dotted"),style:{borderColor:re},children:[s.jsx("h4",{className:"mb-3 text-[1.2rem] uppercase tracking-wide text-black",style:{color:X},children:"Subscription details"}),s.jsxs("p",{className:"m-0 mb-4 text-base",style:{color:X},children:["You are receiving this because you are a paid subscriber to ",C,". Your subscription will renew on 17 Jul 2024."]}),s.jsxs("div",{className:"flex",children:[s.jsxs("div",{className:"shrink-0 text-base",children:[s.jsx("p",{style:{color:X},children:"Name: Jamie Larson"}),s.jsx("p",{style:{color:X},children:"Email: jamie@example.com"}),s.jsx("p",{style:{color:X},children:"Member since: 17 July 2023"})]}),s.jsx("span",{className:we("w-full self-end whitespace-nowrap text-right text-base",ge==="underline"&&"underline",ge==="bold"&&"font-bold"),style:{color:be||Z},children:"Manage subscription"})]})]}),s.jsxs("div",{className:"flex flex-col items-center pt-10",children:[s.jsx("div",{dangerouslySetInnerHTML:{__html:De||""},className:"text break-words px-8 py-3 text-center text-[1.3rem] leading-base text-grey-700 [&_a]:underline",style:{color:q}}),s.jsxs("div",{className:"px-8 pb-14 pt-3 text-center text-[1.3rem] text-grey-700",children:[s.jsxs("span",{style:{color:q},children:[C," © ",Te," — "]}),s.jsx("span",{className:"pointer-events-none cursor-auto underline",style:{color:q},children:"Unsubscribe"})]}),$&&s.jsx("div",{className:"flex flex-col items-center pb-[40px] pt-[10px]",children:s.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:X},children:[s.jsx(p2,{className:"mr-[6px] size-4"}),s.jsx("span",{children:"Powered by Ghost"})]})})]})]})]})]})})})},cl=(e,n,a)=>Qi(n)&&!Vf(n)&&a?a:e.sender_email||a||"",Gf=(e,n,a,o)=>e.sender_reply_to==="newsletter"?Qi(n)?"":cl(e,n,o):e.sender_reply_to==="support"?a||o||"":e.sender_reply_to,BE=({newsletter:e})=>{const{currentUser:n,settings:a,siteData:o,config:c}=Je(),[m,y,h,l,f]=gt(a,["title","icon","comments_enabled","support_email_address","default_email_address"]);let u=null;e.show_header_title?u=m||null:e.show_header_name&&(u=e.name);const p=e.show_header_title&&e.show_header_name?e.name:void 0,x=e.show_comment_cta&&h!=="off",v=e.feedback_enabled&&c.labs.audienceFeedback,_=()=>{const B=e.background_color;return/#([0-9a-f]{3}){1,2}$/i.test(B)?B:"#ffffff"},k=()=>{const B=e.header_background_color;return!B||B==="transparent"?"transparent":/#([0-9a-f]{3}){1,2}$/i.test(B)?B:"transparent"},M=()=>{const B=e.button_color;if(/#([0-9a-f]{3}){1,2}$/i.test(B||""))return B;if(B===null){const ae=_();return Nr(ae).hex()}return o.accent_color},T=()=>{const B=e.button_style,Y=M();if(Y&&B==="fill")return Nr(Y).hex()},A=()=>{const B=e.link_color===void 0?"accent":e.link_color,Y=/#([0-9a-f]{3}){1,2}$/i;return B==="accent"?o.accent_color:Y.test(B||"")?B:Nr(_()).hex()},C=()=>{const B=e.post_title_color;if(/#([0-9a-f]{3}){1,2}$/i.test(B||""))return B;if(B==="accent")return o.accent_color;const ae=k(),ee=ae==="transparent"?_():ae;return Nr(ee).hex()},O=()=>{const B=e.section_title_color;return/#([0-9a-f]{3}){1,2}$/i.test(B||"")?B:B==="accent"?o.accent_color:Nr(_()).hex()},$=()=>{const B=e.divider_color;return/#([0-9a-f]{3}){1,2}$/i.test(B||"")?B:B==="accent"?o.accent_color:"#e0e7eb"},W=Nr(_()).hex(),R=Nr(_()).alpha(.5).toString(),Z=k()==="transparent"?W:Nr(k()).hex(),X=k()==="transparent"?R:Nr(k()).alpha(.5).toString(),q={backgroundColor:_(),headerBackgroundColor:k(),postTitleColor:C()||void 0,sectionTitleColor:O()||void 0,buttonColor:M()||void 0,buttonTextColor:T()||void 0,linkColor:A()||void 0,dividerColor:$()||void 0,textColor:W,secondaryTextColor:R,headerTextColor:Z,secondaryHeaderTextColor:X};return s.jsx(HE,{accentColor:o.accent_color,authorPlaceholder:n.name||n.email,backgroundColor:q.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:q.headerBackgroundColor||"transparent",headerIcon:e.show_header_icon?y:void 0,headerImage:e.header_image,headerSubtitle:p,headerTitle:u,imageCorners:e.image_corners||"square",linkStyle:e.link_style||"underline",senderEmail:cl(e,c,f),senderName:e.sender_name||m,senderReplyTo:Gf(e,c,l,f),showBadge:e.show_badge,showCommentCta:x,showExcerpt:e.show_excerpt,showFeatureImage:e.show_feature_image,showFeedback:v,showLatestPosts:e.show_latest_posts,showPostTitleSection:e.show_post_title_section,showSubscriptionDetails:e.show_subscription_details,siteTitle:m,titleAlignment:e.title_alignment,titleFontCategory:e.title_font_category,titleFontWeight:e.title_font_weight||"bold",...q})},WE=({newsletter:e,updateNewsletter:n,errors:a,clearError:o})=>{const{settings:c,config:m}=Je(),[y,h]=gt(c,["default_email_address","support_email_address"]),[l,f]=D.useState(Gf(e,m,h,y)||"");let u=cl(e,m,y);const p=D.useCallback(v=>{f(v.target.value),n({sender_reply_to:v.target.value||"newsletter"})},[n,f]),x=()=>{const v=Gf(e,m,h,y)||"";f(v)};return s.jsx(Ae,{error:!!a.sender_reply_to,hint:a.sender_reply_to,maxLength:191,placeholder:u||"",title:"Reply-to email",value:l,onBlur:x,onChange:p,onKeyDown:()=>o("sender_reply_to")})},qE=({newsletter:e,onlyOne:n,updateNewsletter:a,validate:o,errors:c,clearError:m})=>{const{updateRoute:y}=Qe(),{mutateAsync:h}=o0(),l=Ys(),{settings:f,config:u,siteData:p}=Je(),[x,v]=gt(f,["icon","default_email_address"]),{mutateAsync:_}=Xs(),[k,M]=D.useState("generalSettings"),{localSettings:T}=ss(),[A]=gt(T,["title"]),C=ot(),{data:{newsletters:O}={}}=a0(),$=["all","paid"].includes(dr(f,"comments_enabled")||"");let W=cl(e,u,v);const[R,Z]=D.useState(O||[]),X=R.filter(H=>H.status==="active");D.useEffect(()=>{Z(O||[])},[O]);const q=[{value:"serif",label:"Elegant serif",className:"font-serif"},{value:"sans_serif",label:"Clean sans-serif"}],B={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"}}},Y=()=>e.background_color==="light"?!1:Nr(e.background_color).hex().toLowerCase()==="#ffffff",ae=async()=>{if(e.status==="active")ye.show(Et,{title:"Archive newsletter",prompt:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:["Your newsletter ",s.jsx("strong",{children:e.name})," will no longer be visible to members or available as an option when publishing new posts."]}),s.jsx("div",{children:"Existing posts previously sent as this newsletter will remain unchanged."})]}),okLabel:"Archive",okColor:"red",onOk:async H=>{try{await h({...e,status:"archived"}),H?.remove(),xt({type:"success",message:"Newsletter archived"})}catch(he){C(he)}}});else{try{await l?.errorIfWouldGoOverLimit("newsletters")}catch(H){if(H instanceof Gs){ye.show(Xr,{prompt:H.message||"Your current plan doesn't support more newsletters.",onOk:()=>y({route:"/pro",isExternal:!0})});return}else throw H}ye.show(Et,{title:"Reactivate newsletter",prompt:s.jsxs(s.Fragment,{children:["Reactivating ",s.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 H=>{await h({...e,status:"active"}),H?.remove(),xt({type:"success",message:"Newsletter reactivated"})}})}},ee=()=>{if(!Qi(u))return s.jsx(Ae,{error:!!c.sender_email,hint:c.sender_email,placeholder:W||"",title:"Sender email address",value:e.sender_email||"",onChange:H=>a({sender_email:H.target.value}),onKeyDown:()=>m("sender_email")});if(Vf(u))return s.jsx(Ae,{error:!!c.sender_email,hint:c.sender_email,maxLength:191,placeholder:v,title:"Sender email address",value:e.sender_email||"",onChange:H=>{a({sender_email:H.target.value})},onKeyDown:()=>m("sender_email")})},re=B[e.title_font_category||"sans_serif"].options,Q=()=>{const H=e.title_font_category||"sans_serif",he=e.title_font_weight,ge=B[H].map,F=ge&&ge[he]||he;return re.find(J=>J.value===F)||re[0]},ne=H=>{const he=H?.value||"sans_serif",ge=e.title_font_weight;let F=ge;return B[he].options.find(L=>L.value===ge)||(F=B[he].map?.[ge]||"bold"),a({title_font_category:he,title_font_weight:F})},be=[{id:"generalSettings",title:"General",contents:s.jsxs(s.Fragment,{children:[s.jsxs(tt,{className:"mt-6",gap:"sm",margins:"lg",title:"Name and description",children:[s.jsx(Ae,{error:!!c.name,hint:c.name,maxLength:191,placeholder:"Weekly Roundup",title:"Name",value:e.name||"",onChange:H=>a({name:H.target.value}),onKeyDown:()=>m("name")}),s.jsx($n,{maxLength:2e3,rows:2,title:"Description",value:e.description||"",onChange:H=>a({description:H.target.value})})]}),s.jsxs(tt,{className:"mt-6",gap:"sm",margins:"lg",title:"Email info",children:[s.jsx(Ae,{maxLength:191,placeholder:A,title:"Sender name",value:e.sender_name||"",onChange:H=>a({sender_name:H.target.value})}),ee(),s.jsx(WE,{clearError:m,errors:c,newsletter:e,updateNewsletter:a,validate:o})]}),s.jsx(tt,{className:"mt-6",gap:"sm",margins:"lg",title:"Member settings",children:s.jsx(st,{checked:e.subscribe_on_signup,direction:"rtl",label:"Subscribe new members on signup",labelStyle:"value",onChange:H=>a({subscribe_on_signup:H.target.checked})})}),s.jsx("div",{className:"mb-5 mt-10",children:e.status==="active"?!n&&s.jsx(Ue,{color:"red",disabled:X.length===1,label:"Archive newsletter",link:!0,onClick:ae}):s.jsx(Ue,{color:"green",label:"Reactivate newsletter",link:!0,onClick:ae})})]})},{id:"content",title:"Content",contents:s.jsxs(s.Fragment,{children:[s.jsxs(tt,{className:"mt-6",gap:"sm",margins:"lg",title:"Header",children:[s.jsxs("div",{children:[s.jsx("div",{children:s.jsx(bt,{className:"mb-2",level:6,children:"Header image"})}),s.jsxs("div",{className:"flex-column flex gap-1",children:[s.jsx(un,{deleteButtonClassName:"!top-1 !right-1",height:e.header_image?"66px":"64px",id:"logo",imageURL:e.header_image||void 0,onDelete:()=>{a({header_image:null})},onUpload:async H=>{try{const he=on(await _({file:H}));a({header_image:he})}catch(he){C(he)}},children:s.jsx(ut,{colorClass:"text-grey-700 dark:text-grey-300",name:"picture"})}),s.jsx(Gr,{children:"1200×600 recommended. Use a transparent PNG for best results on any background."})]})]}),s.jsxs(Yi,{children:[x&&s.jsx(st,{checked:e.show_header_icon,direction:"rtl",label:"Publication icon",onChange:H=>a({show_header_icon:H.target.checked})}),s.jsx(st,{checked:e.show_header_title,direction:"rtl",label:"Publication title",onChange:H=>a({show_header_title:H.target.checked})}),s.jsx(st,{checked:e.show_header_name,direction:"rtl",label:"Newsletter name",onChange:H=>a({show_header_name:H.target.checked})})]})]}),s.jsxs(tt,{className:"mt-6",gap:"xs",margins:"lg",title:"Title section",children:[s.jsx(st,{checked:e.show_post_title_section,direction:"rtl",label:"Post title",onChange:H=>a({show_post_title_section:H.target.checked})}),e.show_post_title_section&&s.jsx(st,{checked:e.show_excerpt,direction:"rtl",label:"Post excerpt",onChange:H=>a({show_excerpt:H.target.checked})}),s.jsx(st,{checked:e.show_feature_image,direction:"rtl",label:"Feature image",onChange:H=>a({show_feature_image:H.target.checked})})]}),s.jsxs(tt,{className:"mt-6",gap:"sm",margins:"lg",title:"Footer",children:[s.jsxs(Yi,{gap:"lg",children:[s.jsx(st,{checked:e.feedback_enabled,direction:"rtl",label:"Ask your readers for feedback",onChange:H=>a({feedback_enabled:H.target.checked})}),$&&s.jsx(st,{checked:e.show_comment_cta,direction:"rtl",label:"Add a link to your comments",onChange:H=>a({show_comment_cta:H.target.checked})}),s.jsx(st,{checked:e.show_latest_posts,direction:"rtl",label:"Share your latest posts",onChange:H=>a({show_latest_posts:H.target.checked})}),s.jsx(st,{checked:e.show_subscription_details,direction:"rtl",label:"Show subscription details",onChange:H=>a({show_subscription_details:H.target.checked})})]}),s.jsx(ld,{hint:"Any extra information or legal text",nodes:"MINIMAL_NODES",placeholder:" ",title:"Email footer",value:e.footer_content||"",onChange:H=>a({footer_content:H})})]}),s.jsx(Va,{}),s.jsxs("div",{className:"my-5 flex w-full items-start",children:[s.jsx("span",{children:s.jsx(ut,{className:"mr-2 mt-[-1px]",colorClass:"text-red",name:"heart"})}),s.jsx(tt,{marginBottom:!1,children:s.jsx(st,{checked:e.show_badge,direction:"rtl",label:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx("span",{className:"text-sm md:text-base",children:"Promote independent publishing"}),s.jsx("span",{className:"text-[11px] leading-tight text-grey-700 md:text-xs md:leading-tight",children:"Show you're a part of the indie publishing movement with a small badge in the footer"})]}),labelStyle:"value",onChange:H=>a({show_badge:H.target.checked})})})]})]})},{id:"design",title:"Design",contents:s.jsxs(s.Fragment,{children:[s.jsxs(tt,{className:"mt-6",gap:"xs",margins:"lg",title:"Global",children:[s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{hex:"#ffffff",value:"light",title:"White"}],title:"Background color",value:e.background_color||"light",onChange:H=>a({background_color:H})})}),s.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[s.jsx("div",{className:"shrink-0",children:"Heading font"}),s.jsx(Lt,{containerClassName:"max-w-[200px]",options:q,selectedOption:q.find(H=>H.value===e.title_font_category),onSelect:ne})]}),s.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[s.jsx("div",{className:"shrink-0",children:"Heading weight"}),s.jsx(Lt,{containerClassName:"max-w-[200px]",options:re,selectedOption:Q(),onSelect:H=>a({title_font_weight:H?.value})})]}),s.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[s.jsx("div",{className:"shrink-0",children:"Body font"}),s.jsx(Lt,{containerClassName:"max-w-[200px]",options:q,selectedOption:q.find(H=>H.value===e.body_font_category),testId:"body-font-select",onSelect:H=>a({body_font_category:H?.value})})]})]}),s.jsxs(tt,{className:"mt-6",gap:"xs",margins:"lg",title:"Header",children:[s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:"transparent",title:"Transparent",hex:"#00000000"}],title:"Header background color",value:e.header_background_color||"transparent",onChange:H=>a({header_background_color:H})})}),s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:null,title:"Auto",hex:Y()?"#ffffff":"#000000"},{value:"accent",title:"Accent",hex:p.accent_color}],title:"Post title color",value:e.post_title_color,onChange:H=>a({post_title_color:H})})}),s.jsxs("div",{className:"flex w-full justify-between",children:[s.jsx("div",{children:"Title alignment"}),s.jsx(an,{activeKey:e.title_alignment,buttons:[{key:"left",icon:"align-left",iconSize:14,label:"Align left",tooltip:"Left",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({title_alignment:"left"}),disabled:!e.show_post_title_section},{key:"center",icon:"align-center",iconSize:14,label:"Align center",tooltip:"Center",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({title_alignment:"center"}),disabled:!e.show_post_title_section}],clearBg:!1})]})]}),s.jsxs(tt,{className:"mt-6",gap:"xs",margins:"lg",title:"Body",children:[s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:null,title:"Auto",hex:Y()?"#ffffff":"#000000"},{value:"accent",title:"Accent",hex:p.accent_color}],title:"Section title color",value:e.section_title_color,onChange:H=>a({section_title_color:H})})}),s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:"accent",title:"Accent",hex:p.accent_color},{value:null,title:"Auto",hex:Y()?"#ffffff":"#000000"}],title:"Button color",value:e.button_color,onChange:H=>a({button_color:H})})}),s.jsxs("div",{className:"flex w-full justify-between",children:[s.jsx("div",{children:"Button style"}),s.jsx(an,{activeKey:e.button_style||"fill",buttons:[{key:"fill",icon:"squircle-fill",iconSize:14,label:"Fill",tooltip:"Fill",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({button_style:"fill"})},{key:"outline",icon:"squircle",iconSize:14,label:"Outline",tooltip:"Outline",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({button_style:"outline"})}],clearBg:!1})]}),s.jsxs("div",{className:"flex w-full justify-between",children:[s.jsx("div",{children:"Button corners"}),s.jsx(an,{activeKey:e.button_corners||"rounded",buttons:[{key:"square",icon:"square",iconSize:14,label:"Square",tooltip:"Squared",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({button_corners:"square"})},{key:"rounded",icon:"squircle",iconSize:14,label:"Rounded",tooltip:"Rounded",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({button_corners:"rounded"})},{key:"pill",icon:"circle",iconSize:14,label:"Pill",tooltip:"Pill",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({button_corners:"pill"})}],clearBg:!1})]}),s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:"accent",title:"Accent",hex:p.accent_color},{value:null,title:"Auto",hex:Y()?"#ffffff":"#000000"}],title:"Link color",value:e.link_color,onChange:H=>a({link_color:H})})}),s.jsxs("div",{className:"flex w-full justify-between",children:[s.jsx("div",{children:"Link style"}),s.jsx(an,{activeKey:e.link_style||"underline",buttons:[{key:"underline",icon:"text-underline",iconSize:14,label:"Underline",tooltip:"Underline",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({link_style:"underline"})},{key:"regular",icon:"text-regular",iconSize:14,label:"Regular",tooltip:"Regular",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({link_style:"regular"})},{key:"bold",icon:"text-bold",iconSize:14,label:"Bold",tooltip:"Bold",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({link_style:"bold"})}],clearBg:!1})]}),s.jsxs("div",{className:"flex w-full justify-between",children:[s.jsx("div",{children:"Image corners"}),s.jsx(an,{activeKey:e.image_corners||"square",buttons:[{key:"square",icon:"square",iconSize:14,label:"Square",tooltip:"Squared",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({image_corners:"square"})},{key:"rounded",icon:"squircle",iconSize:14,label:"Rounded",tooltip:"Rounded",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({image_corners:"rounded"})}],clearBg:!1})]}),s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:"light",title:"Light",hex:"#e0e7eb"},{value:"accent",title:"Accent",hex:p.accent_color}],title:"Divider color",value:e.divider_color||"light",onChange:H=>a({divider_color:H})})})]})]})}],je=H=>{M(H)};return s.jsx("div",{className:"flex flex-col",children:s.jsx("div",{className:"px-7 pb-7 pt-0",children:s.jsx(Dn,{selectedTab:k,stickyHeader:!0,tabs:be,onTabChange:je})})})},YE=({newsletter:e,onlyOne:n})=>{const{config:a}=Je(),{mutateAsync:o}=o0(),{updateRoute:c}=Qe(),m=ot(),{formState:y,saveState:h,updateForm:l,setFormState:f,handleSave:u,validate:p,errors:x,clearError:v,okProps:_}=kr({initialState:e,savingDelay:500,onSave:async()=>{const{meta:{sent_email_verification:[A]=[]}={}}=await o(y);let C;A&&A==="sender_email"?C=s.jsx("div",{children:"We‘ve sent a confirmation email to the new address."}):A&&A==="sender_reply_to"&&(C=s.jsx("div",{children:"We‘ve sent a confirmation email to the new address."})),C&&xt({icon:"email",message:C,type:"info"})},onSaveError:m,onValidate:()=>{const A={};return y.name||(A.name="A name is required for your newsletter"),y.sender_email&&!Nt.isEmail(y.sender_email)?A.sender_email="Enter a valid email address":y.sender_email&&Vf(a)&&y.sender_email.split("@")[1]!==oh(a)&&(A.sender_email=`Email address must end with @${oh(a)}`),y.sender_reply_to&&!Nt.isEmail(y.sender_reply_to)&&!["newsletter","support"].includes(y.sender_reply_to)&&(A.sender_reply_to="Enter a valid email address"),A}}),k=A=>{l(C=>({...C,...A}))};D.useEffect(()=>{f(()=>e)},[f,e]);const M=s.jsx(BE,{newsletter:y}),T=s.jsx(qE,{clearError:v,errors:x,newsletter:y,onlyOne:n,updateNewsletter:k,validate:p});return s.jsx(Zs,{afterClose:()=>c("newsletters"),buttonsDisabled:_.disabled,cancelLabel:"Close",deviceSelector:!1,dirty:h==="unsaved",okColor:_.color,okLabel:_.label||"Save",preview:M,previewBgColor:"grey",previewToolbar:!1,sidebar:T,sidebarPadding:!1,testId:"newsletter-modal",title:"Newsletter",onOk:async()=>{await u({fakeWhenUnchanged:!0})}})},GE=({params:e})=>{const{data:{newsletters:n,isEnd:a}={},fetchNextPage:o}=a0(),c=n?.find(({id:m})=>m===e?.id);return D.useEffect(()=>{!c&&!a&&o()},[o,a,c]),c?s.jsx(YE,{newsletter:c,onlyOne:n.length===1}):null},XE=ye.create(GE),wx=({id:e})=>{const{updateRoute:n}=Qe(),{data:{offers:a=[]}={}}=e0(e||""),[o,c]=D.useState(),[m,y]=D.useState(""),{siteData:h}=Je();D.useEffect(()=>{if(a.length>0){const k=a[0],M=`${ln(h)}${k?.code}`;y(M),c(k)}},[a,h]);const[l,f]=D.useState(!1),u=()=>{let k="";switch(o?.type){case"percent":k=o?.amount+"% discount";break;case"fixed":k=Wg(h2(o?.amount))+" "+o?.currency+" discount";break;case"trial":k=o?.amount+" days free trial";break}return`${encodeURIComponent(o?.name||"")} — Check out ${encodeURIComponent(k)} on:`},p=async()=>{await navigator.clipboard.writeText(m),f(!0),setTimeout(()=>f(!1),2e3)},x=()=>{window.open(`https://twitter.com/intent/tweet?url=${encodeURI(m)}&text=${u()}`,"_blank")},v=()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(m)}`,"_blank")},_=()=>{window.open(`http://www.linkedin.com/shareArticle?mini=true&url=${encodeURI(m)}&title=${u()}`,"_blank")};return s.jsx(yt,{afterClose:()=>{n("offers")},animate:!1,backDropClick:!1,footer:!1,height:"full",size:"lg",testId:"offer-success-modal",topRightContent:"close",width:1140,children:s.jsxs("div",{className:"-mt-6 flex h-full flex-col items-center justify-center text-center",children:[s.jsx("div",{className:"absolute left-6 top-5",children:s.jsx(fd,{activeItemClassName:"hidden md:!block md:!visible",containerClassName:"whitespace-nowrap",itemClassName:"hidden md:!block md:!visible",items:[{label:"Offers",onClick:()=>{n("offers/edit")}},{label:o?.name||""}],separatorClassName:"hidden md:!block md:!visible",backIcon:!0,onBack:()=>{n("offers/edit")}})}),s.jsx(ut,{colorClass:"text-grey-700 -mt-4",name:"tags-check",size:"xl"}),s.jsx("h1",{className:"mt-6 text-4xl",children:"Your new offer is live!"}),s.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."}),s.jsxs("div",{className:"mt-8 flex w-full max-w-md flex-col gap-8",children:[s.jsxs("div",{className:"flex flex-col-reverse gap-2",children:[s.jsx(Ae,{name:"offer-url",type:"url",value:m,disabled:!0}),s.jsx(Ue,{color:"green",label:l?"Copied!":"Copy link",fullWidth:!0,onClick:p})]}),s.jsx("div",{className:'flex items-center gap-4 text-xs 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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ue,{className:"h-8 border border-grey-300 dark:border-grey-800",icon:"twitter-x",iconColorClass:"w-[14px] h-[14px]",size:"sm",fullWidth:!0,onClick:x}),s.jsx(Ue,{className:"h-8 border border-grey-300 dark:border-grey-800",icon:"facebook",size:"sm",fullWidth:!0,onClick:v}),s.jsx(Ue,{className:"h-8 border border-grey-300 dark:border-grey-800",icon:"linkedin",size:"sm",fullWidth:!0,onClick:_})]})]})]})})},Zi=({href:e,onDestroyed:n,selectedTab:a,portalParent:o})=>{a||(a="signup");const c=D.useRef(null),[m,y]=D.useState(!1),[h,l]=D.useState(!0),f=D.useCallback(()=>{setTimeout(()=>{c.current&&l(!1)},300)},[c]);if(D.useEffect(()=>{const x=v=>{if(!e)return;new URL(v.origin).origin===new URL(e).origin&&v?.data?.type==="portal-preview-ready"&&f()};return window.addEventListener("message",x,!0),()=>{window.removeEventListener("message",x,!0),n?.()}},[e,n,f,m]),!e)return null;let u="mt-[-7%] flex h-screen items-center justify-center",p="hidden";return o==="preview"?(u="absolute z-50 mt-[-7%] flex h-screen items-center justify-center",p="invisible"):o==="offers"&&(u="absolute z-50 flex w-full h-full items-center justify-center",p="invisible"),s.jsxs(s.Fragment,{children:[h&&s.jsx("div",{className:u,children:s.jsx("span",{children:s.jsx(Wi,{})})}),s.jsx("iframe",{ref:c,className:!h&&m?"":p,"data-testid":"portal-preview",height:"100%",src:e,title:"Portal Preview",width:"100%",onLoad:()=>{y(!0)}})]})},yx=(e,n)=>{const{disableBackground:a=!1,name:o,code:c,displayTitle:m="",displayDescription:y="",type:h,cadence:l,amount:f=0,duration:u,durationInMonths:p,currency:x="usd",status:v,tierId:_}=e;n=n.replace(/\/$/,"");const k="/?v=modal-portal-offer#/portal/preview/offer",M=new URLSearchParams;return M.append("disableBackground","false"),M.append("name",encodeURIComponent(o)),M.append("code",encodeURIComponent(c)),M.append("display_title",encodeURIComponent(m)),M.append("display_description",encodeURIComponent(y)),M.append("type",encodeURIComponent(h)),M.append("cadence",encodeURIComponent(l)),M.append("amount",encodeURIComponent(f)),M.append("duration",encodeURIComponent(u)),M.append("duration_in_months",encodeURIComponent(p)),M.append("currency",encodeURIComponent(x)),M.append("status",encodeURIComponent(v)),M.append("tier_id",encodeURIComponent(_)),a&&M.append("disableBackground","true"),`${n}${k}?${M.toString()}`},KE=e=>{const n=[];return e.forEach(a=>{n.push({label:`${a.name} - Monthly`,value:`${a.id}-month-${a.currency}`}),n.push({label:`${a.name} - Yearly`,value:`${a.id}-year-${a.currency}`})}),n};function ZE(e){return e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-")}const Cg=({type:e,checked:n,onClick:a})=>{const o=n?"bg-black text-white dark:bg-white dark:text-black":"border border-grey-300 dark:border-grey-800";return s.jsx("button",{className:"text-left",type:"button",onClick:a,children:s.jsxs("div",{className:"flex gap-3",children:[s.jsx("div",{className:`mt-0.5 flex size-4 items-center justify-center rounded-full ${o}`,children:n?s.jsx(ut,{className:"w-[7px] stroke-[4]",name:"check",size:"custom"}):null}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{children:e.title}),s.jsx("span",{className:"text-sm",children:e.description})]})]})})},Dg=e=>{const{fixedAmount:n=0,percentAmount:a=0,trialAmount:o=0,amount:c=0}=e;switch(e.type){case"fixed":return n*100;case"percent":return a;case"trial":return o;default:return c}},VE=({tierOptions:e,handleTierChange:n,selectedTier:a,typeOptions:o,durationOptions:c,handleTypeChange:m,handleDurationChange:y,overrides:h,handleAmountTypeChange:l,handleNameInput:f,handleTextAreaInput:u,handleDisplayTitleInput:p,handleDurationInMonthsInput:x,handleAmountInput:v,handleCodeInput:_,clearError:k,errors:M,testId:T,handleTrialAmountInput:A,amountOptions:C})=>{const $=a?.label?.includes("Yearly")?c.filter(re=>re.value!=="repeating"):c,[W,R]=D.useState(0),Z=W>40?"text-red":"text-green",{siteData:X}=Je(),[q,B]=D.useState(!1),Y=ln(X),ae=`${Y}${h.code.value}`,ee=async()=>{await navigator.clipboard.writeText(ae),B(!0),setTimeout(()=>B(!1),2e3)};return s.jsx("div",{className:"pt-7","data-testId":T,children:s.jsxs(tt,{children:[s.jsxs("section",{children:[s.jsx("h2",{className:"mb-4 text-lg",children:"General"}),s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(Ae,{error:!!M.name,hint:M.name||s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{children:"Visible to members on Stripe Checkout page"}),s.jsxs("strong",{children:[s.jsx("span",{className:`${Z}`,children:W})," / 40"]})]}),maxLength:40,placeholder:"Black Friday",title:"Offer name",onChange:re=>{f(re),R(re.target.value.length)},onKeyDown:()=>k("name")}),s.jsx(Ae,{error:!!M.displayTitle,hint:M.displayTitle,placeholder:"Black Friday Special",title:"Display title",value:h.displayTitle.value,onChange:re=>{p(re)},onKeyDown:()=>k("displayTitle")}),s.jsx($n,{placeholder:"Take advantage of this limited-time offer.",title:"Display description",value:h.displayDescription,onChange:re=>{u(re)}})]})]}),s.jsxs("section",{className:"mt-4",children:[s.jsx("h2",{className:"mb-4 text-lg",children:"Details"}),s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-col gap-4 rounded-md border border-grey-200 p-4 dark:border-grey-800",children:[s.jsx(Cg,{checked:h.type!=="trial",type:o[0],onClick:()=>{m("percent")}}),s.jsx(Cg,{checked:h.type==="trial",type:o[1],onClick:()=>{m("trial")}})]}),s.jsx(Lt,{options:e,selectedOption:a,testId:"tier-cadence-select-offers",title:"Tier — Cadence",onSelect:re=>{re&&n(re)}}),h.type!=="trial"&&s.jsxs(s.Fragment,{children:[" ",s.jsxs("div",{className:"relative",children:[s.jsx(Ae,{error:!!M.amount,hint:M.amount,title:"Amount off",type:"number",value:h.type==="fixed"?h.fixedAmount===0?"":h.fixedAmount?.toString():h.percentAmount===0?"":h.percentAmount?.toString(),onChange:re=>{v(re)},onKeyDown:()=>k("amount")}),s.jsx("div",{className:"absolute right-1.5 top-6 z-10",children:s.jsx(Lt,{clearBg:!0,controlClasses:{menu:"w-20 right-0"},options:C,selectedOption:h.type==="percent"?C[0]:C[1],testId:"amount-type-select-offers",onSelect:re=>{l(re?.value||"")}})})]}),s.jsx(Lt,{options:$,selectedOption:$.find(re=>re.value===h.duration),testId:"duration-select-offers",title:"Duration",onSelect:re=>y(re?.value||"")}),h.duration==="repeating"&&s.jsx(Ae,{title:"Duration in months",type:"number",onChange:re=>{x(re)}})]}),h.type==="trial"&&s.jsx(Ae,{error:!!M.amount,hint:M.amount,title:"Trial duration",type:"number",value:h.trialAmount?.toString(),onChange:re=>{A(re)},onKeyDown:()=>k("amount")}),s.jsx(Ae,{error:!!M.code,hint:M.code||(h.code.value!==""?s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[Y,s.jsx("span",{className:"font-bold",children:h.code.value})]}),s.jsx("span",{}),s.jsx(Ue,{className:"text-xs",color:"green",label:`${q?"Copied":"Copy"}`,size:"sm",link:!0,onClick:ee})]}):null),placeholder:"black-friday",title:"Offer code",value:h.code.value,onChange:re=>{_(re)},onKeyDown:()=>k("code")})]})]})]})})},Qn=e=>{const[n,a,o]=e.split("-");if(!n||!a||!o)throw new Error("Invalid input format. Expected format is: id-period-currency");return{id:n,period:a,currency:o}},QE=()=>{const{siteData:e}=Je(),n=[{title:"Discount",description:"Offer a special reduced price",value:"percent"},{title:"Free trial",description:"Give free access for a limited time",value:"trial"}],a=[{value:"once",label:"First-payment"},{value:"repeating",label:"Multiple-months"},{value:"forever",label:"Forever"}],[o,c]=D.useState(""),{updateRoute:m}=Qe(),{data:{tiers:y}={}}=so(),h=od(y||[]),l=KE(h),{mutateAsync:f}=m2(),[u,p]=D.useState({tier:l[0]||{},dataset:{id:l[0]?.value?Qn(l[0]?.value).id:"",period:l[0]?.value?Qn(l[0]?.value).period:"",currency:l[0]?.value?Qn(l[0]?.value).currency:""}}),{data:{offers:x=[]}={}}=g2(),{formState:v,updateForm:_,handleSave:k,saveState:M,okProps:T,validate:A,errors:C,clearError:O}=kr({initialState:{disableBackground:!1,name:"",code:{isDirty:!1,value:""},displayTitle:{isDirty:!1,value:""},displayDescription:"",type:"percent",cadence:u?.dataset?.period||"",amount:0,duration:"once",durationInMonths:0,currency:u?.dataset?.currency||"USD",status:"active",tierId:u?.dataset?.id||"",trialAmount:7,fixedAmount:0,percentAmount:0},onSave:async()=>{const he={name:v.name,code:v.code.value,display_title:v.displayTitle.value,display_description:v.displayDescription,cadence:v.cadence,amount:Dg(v)||0,duration:v.type==="trial"?"trial":v.duration,duration_in_months:Number(v.durationInMonths),currency:v.currency,status:v.status,redemption_type:"signup",tier:{id:v.tierId},type:v.type,currency_restriction:!1},ge=await f(he);ge&&ge.offers&&ge.offers.length>0&&m(`offers/success/${ge.offers[0].id}`)},onSaveError:()=>{},onValidate:()=>{const he={};return!v.name&&v.name.length===0&&(he.name="Name is required"),!v.code.value&&v.code.value.length===0&&(he.code="Code is required"),!v.displayTitle.value&&v.displayTitle.value.length===0&&(he.displayTitle="Display title is required"),v.type==="percent"&&v.percentAmount===0&&(he.amount="Enter an amount greater than 0."),v.type==="percent"&&(v.percentAmount<0||v.percentAmount>100)&&(he.amount="Amount must be between 0 and 100%."),(v.type==="fixed"&&v.fixedAmount===0||v.type==="fixed"&&v.fixedAmount<1)&&(he.amount="Enter an amount greater than 0."),v.type==="trial"&&v.trialAmount===0&&(he.amount="Enter an amount greater than 0."),v.type==="trial"&&v.trialAmount<1&&(he.amount="Free trial must be at least 1 day."),he},savingDelay:500}),$=[{value:"percent",label:"%"},{value:"fixed",label:v.currency}],W=he=>{p({tier:he,dataset:Qn(he.value)}),_(ge=>({...ge,cadence:Qn(he.value).period,currency:Qn(he.value).currency,tierId:Qn(he.value).id}))},R=he=>{_(ge=>({...ge,type:he}))},Z=he=>{_(ge=>({...ge,type:he==="percent"?"percent":"fixed"}))},X=he=>{const ge=he.target;v.type==="fixed"?_(F=>({...F,fixedAmount:Number(ge.value)})):v.type==="percent"?_(F=>({...F,percentAmount:Number(ge.value)})):_(F=>({...F,amount:Number(ge.value)}))},q=he=>{const ge=he.target;_(F=>({...F,durationInMonths:Number(ge.value)}))},B=he=>{const ge=he.target.value;_(F=>{let L={...F};return L.name=ge,F.code.isDirty||(O("code"),L.code={...F.code,value:ZE(ge)}),F.displayTitle.isDirty||(O("displayTitle"),L.displayTitle={...F.displayTitle,value:ge}),L})},Y=he=>{const ge=he.target;_(F=>({...F,displayTitle:{...F.displayTitle,isDirty:!0,value:ge.value}}))},ae=he=>{const ge=he.target;_(F=>({...F,displayDescription:ge.value}))},ee=he=>{const ge=he.target;_(F=>({...F,trialAmount:Number(ge.value)}))},re=he=>{_(ge=>({...ge,duration:he}))},Q=he=>{const ge=he.target;_(F=>({...F,code:{...F.code,isDirty:!0,value:ge.value}}))},ne=()=>{x.length>0?m("offers/edit"):m("offers")},be=D.useMemo(()=>({name:v.name||"",code:v.code.value||"",displayTitle:v.displayTitle.value||"",displayDescription:v.displayDescription||"",type:v.type||"percent",cadence:v.cadence||"month",amount:Dg(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||h[0]?.id}),[v,h]);D.useEffect(()=>{const he=yx(be,e.url);c(he)},[v,e.url,v.type,be]);const je=s.jsx(VE,{amountOptions:$,clearError:O,durationOptions:a,errors:C,handleAmountInput:X,handleAmountTypeChange:Z,handleCodeInput:Q,handleDisplayTitleInput:Y,handleDurationChange:re,handleDurationInMonthsInput:q,handleNameInput:B,handleTextAreaInput:ae,handleTierChange:W,handleTrialAmountInput:ee,handleTypeChange:R,overrides:v,selectedTier:u.tier,testId:"add-offer-sidebar",tierOptions:l,typeOptions:n,validate:A}),H=s.jsx(Zi,{href:o||"",portalParent:"offers"});return s.jsx(Zs,{afterClose:()=>{m("offers")},backDropClick:!1,cancelLabel:"Close",deviceSelector:!1,dirty:M==="unsaved",height:"full",okColor:T.color,okLabel:"Publish",preview:H,previewToolbar:!1,sidebar:je,size:"lg",testId:"add-offer-modal",title:"Offer",width:1140,onCancel:ne,onOk:async()=>{if(A(),!Object.values(C).every(ge=>!ge)){Za.remove(),xt({title:"Can't save offer",type:"info",message:"Make sure you filled all required fields"});return}try{if(await k({force:!0}))return}catch(ge){let F;ge instanceof ts&&ge.data&&ge.data.errors[0]&&(F=ge.data.errors[0].context||ge.data.errors[0].message),Za.remove(),F&&xt({title:"Can't save offer",type:"error",message:F||"Please try again later"})}}})};function Rg(e){return new Date(e).toLocaleDateString("default",{year:"numeric",month:"short",day:"2-digit"})}const JE=({clearError:e,errors:n,offer:a,updateOffer:o})=>{const{siteData:c}=Je(),[m,y]=D.useState(!1),h=ot(),{mutateAsync:l}=t0(),[f,u]=D.useState(a?.name.length||0),p=f>40?"text-red":"text-green",{updateRoute:x}=Qe();D.useEffect(()=>{a?.name&&u(a?.name.length)},[a?.name]);const v=ln(c),_=`${v}${a?.code}`,k=async()=>{await navigator.clipboard.writeText(_),y(!0),setTimeout(()=>y(!1),2e3)},M=async()=>{a?.status==="active"?ye.show(Et,{title:"Archive offer",prompt:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"New members will no longer be able to subscribe using this offer."}),s.jsxs("p",{children:["All members that previously redeemed ",s.jsx("strong",{children:a?.name})," will remain unchanged."]})]}),okLabel:"Archive",okColor:"red",onOk:async T=>{try{await l({...a,status:"archived"}),T?.remove(),xt({type:"success",title:"Offer archived"}),x("offers/edit")}catch(A){h(A)}}}):ye.show(Et,{title:"Reactivate offer",prompt:s.jsx(s.Fragment,{children:s.jsxs("p",{children:["Reactivating ",s.jsx("strong",{children:a?.name})," will allow new members to subscribe using this offer. Existing members will remain unchanged."]})}),okLabel:"Reactivate",onOk:async T=>{try{await l({...a,status:"active"}),T?.remove(),xt({type:"success",title:"Offer reactivated"}),x("offers/edit")}catch(A){h(A)}}})};return s.jsxs("div",{className:"flex grow flex-col pt-2",children:[s.jsxs(tt,{className:" grow",children:[s.jsx("section",{children:s.jsxs("div",{className:"flex flex-col gap-5 rounded-md border border-grey-300 p-4 pb-3.5 dark:border-grey-800",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-semibold leading-none text-grey-700",children:"Created on"}),s.jsx("span",{children:Rg(a?.created_at?a.created_at:"")})]}),s.jsxs("div",{className:"flex items-end justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-semibold leading-none text-grey-700",children:"Performance"}),s.jsxs("span",{children:[a?.redemption_count," ",a?.redemption_count===1?"redemption":"redemptions"]})]}),a?.redemption_count>0&&a?.last_redeemed?s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-semibold leading-none text-grey-700",children:"Last redemption"}),s.jsx("span",{children:Rg(a?.last_redeemed)})]}):null]}),a?.redemption_count>0?s.jsx("a",{className:"font-semibold text-green",href:x2(a?.id),children:"See members →"}):null]})]})}),s.jsxs("section",{className:"mt-4",children:[s.jsx("h2",{className:"mb-4 text-lg",children:"General"}),s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(Ae,{error:!!n.name,hint:n.name||s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{children:"Visible to members on Stripe Checkout page"}),s.jsxs("strong",{children:[s.jsx("span",{className:`${p}`,children:f})," / 40"]})]}),maxLength:40,placeholder:"Black Friday",title:"Offer name",value:a?.name,onChange:T=>{u(T.target.value.length),o({name:T.target.value})},onKeyDown:()=>e("name")}),s.jsx(Ae,{error:!!n.displayTitle,hint:n.displayTitle,placeholder:"Black Friday Special",title:"Display title",value:a?.display_title,onChange:T=>o({display_title:T.target.value}),onKeyDown:()=>e("displayTitle")}),s.jsx($n,{placeholder:"Take advantage of this limited-time offer.",title:"Display description",value:a?.display_description,onChange:T=>o({display_description:T.target.value})}),s.jsx(Ae,{error:!!n.code,hint:n.code||(a?.code!==""?s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[v,s.jsx("span",{className:"font-bold",children:a?.code})]}),s.jsx("span",{}),s.jsx(Ue,{className:"text-xs",color:"green",label:`${m?"Copied":"Copy"}`,size:"sm",link:!0,onClick:k})]}):null),placeholder:"black-friday",title:"Offer code",value:a?.code,onChange:T=>o({code:T.target.value}),onKeyDown:()=>e("code")})]})]})]}),s.jsx("div",{className:"mb-2",children:a?.status==="active"?s.jsx(Ue,{color:"red",label:"Archive offer",link:!0,onClick:M}):s.jsx(Ue,{color:"green",label:"Reactivate offer",link:!0,onClick:M})})]})},e4=({id:e})=>{const{siteData:n}=Je(),{updateRoute:a}=Qe(),o=ot(),{mutateAsync:c}=t0(),[m,y]=D.useState(""),{data:{offers:h=[]}={}}=e0(e||""),{formState:l,saveState:f,updateForm:u,setFormState:p,handleSave:x,validate:v,errors:_,clearError:k,okProps:M}=kr({initialState:h[0],savingDelay:500,onSave:async()=>{await c(l)},onSaveError:o,onValidate:()=>{const O={};return l?.name||(O.name="Name is required"),l?.display_title||(O.displayTitle="Display title is required"),l?.code||(O.code="Please enter a code"),O}});D.useEffect(()=>{p(()=>h[0])},[p,h]);const T=O=>{u($=>({...$,...O}))},A=s.jsx(JE,{clearError:k,errors:_,offer:l,updateOffer:T,validate:v});D.useEffect(()=>{const O={name:l?.name||"",code:l?.code||"",displayTitle:l?.display_title||"",displayDescription:l?.display_description||"",type:l?.type||"",cadence:l?.cadence||"",amount:l?.amount,duration:l?.duration||"",durationInMonths:l?.duration_in_months||0,currency:l?.currency||"",status:l?.status||"",tierId:l?.tier.id||""},$=yx(O,n.url);y($)},[l,n]);const C=s.jsx(Zi,{href:m||"",portalParent:"offers"});return h?s.jsx(Zs,{afterClose:()=>{a("offers")},backDropClick:!1,cancelLabel:"Close",deviceSelector:!1,dirty:f==="unsaved",height:"full",okColor:M.color,okLabel:M.label||"Save",preview:C,previewToolbar:!1,sidebar:A,size:"lg",testId:"offer-update-modal",title:"Offer",width:1140,onCancel:()=>{sessionStorage.getItem("editOfferPageSource")==="offers"?(sessionStorage.removeItem("editOfferPageSource"),a("offers")):(sessionStorage.removeItem("editOfferPageSource"),a("offers/edit"))},onOk:async()=>{try{if(await x({force:!0}))return}catch(O){let $;O instanceof ts&&O.data&&O.data.errors[0]&&($=O.data.errors[0].context||O.data.errors[0].message),Za.remove(),$&&xt({title:"Can't save offer",type:"error",message:"Please try again later"})}}}):null},t4=({route:e})=>{if(e==="offers/new")return s.jsx(QE,{});if(e.startsWith("offers/edit/")&&e.length>12){const n=e.split("/").pop();return s.jsx(e4,{id:n||""})}else if(e.startsWith("offers/success/")&&e.length>15){const n=e.split("/").pop();return s.jsx(wx,{id:n||""})}else if(e==="offers/edit")return s.jsx(b2,{})},r4=()=>{const{route:e}=Qe();return s.jsx(t4,{route:e})},n4=ye.create(r4),s4=""+new URL("pintura-screenshot-1gRQGS4m.png",import.meta.url).href,a4=ns({method:"POST",path:()=>"/files/upload/",body:({file:e})=>{const n=new FormData;return n.append("file",e),n}}),o4=ye.create(()=>{const{updateRoute:e}=Qe(),[n,a]=D.useState({js:!1,css:!1}),{settings:o,config:c}=Je(),[m]=gt(o,["pintura"]),{mutateAsync:y}=Rn(),{mutateAsync:h}=a4(),l=ot();D.useEffect(()=>{x(m||!1)},[m]);const[f,u]=D.useState("Save"),[p,x]=D.useState(!!m),v=async()=>{const C=[{key:"pintura",value:p}];try{u("Saving..."),await Promise.all([y(C),new Promise(O=>{setTimeout(O,1e3)})]),u("Saved")}catch(O){l(O)}finally{setTimeout(()=>u("Save"),1e3)}},_=D.useRef(null),k=D.useRef(null),M=C=>{C==="js"&&_.current?.click(),C==="css"&&k.current?.click()},T=async(C,O)=>{try{a(X=>({...X,[O]:!0}));const $=C.target?.files?.[0];if(!$)return;const{files:W}=await h({file:$}),R=W[0].url,Z=[{key:`pintura_${O}_url`,value:R}];await y(Z),a(X=>({...X,[O]:!1})),xt({type:"success",title:`Pintura ${O} uploaded`})}catch($){a({js:!1,css:!1}),l($)}},A=p!==m;return s.jsxs(yt,{afterClose:()=>{e("integrations")},cancelLabel:"Close",dirty:A,okColor:f==="Saved"?"green":"black",okLabel:f,testId:"pintura-modal",title:"",onOk:v,children:[s.jsx(Qs,{detail:"Advanced image editing",icon:s.jsx(ut,{name:"pintura",size:48}),title:"Pintura"}),s.jsxs("div",{className:"mt-7",children:[!c.pintura&&s.jsxs("div",{className:"mb-7 flex flex-col items-stretch justify-between gap-4 rounded-sm bg-grey-75 p-4 md:flex-row md:p-7 dark:bg-grey-950",children:[s.jsxs("div",{className:"md:basis-1/2",children:[s.jsx("p",{className:"mb-4 font-bold",children:"Add advanced image editing to Ghost, with Pintura"}),s.jsx("p",{className:"mb-4 text-sm",children:"Pintura is a powerful JavaScript image editor that allows you to crop, rotate, annotate and modify images directly inside Ghost."}),s.jsx("p",{className:"text-sm",children:"Try a demo, purchase a license, and download the required CSS/JS files from pqina.nl/pintura/ to activate this feature."})]}),s.jsxs("div",{className:"flex grow flex-col items-end justify-between gap-2 md:basis-1/2 md:gap-0",children:[s.jsx("img",{alt:"Pintura screenshot",src:s4}),s.jsx("a",{className:"-mb-1 text-sm font-bold text-green",href:"https://pqina.nl/pintura/ghost/?ref=ghost.org",rel:"noopener noreferrer",target:"_blank",children:"Find out more →"})]})]}),s.jsxs(tt,{marginBottom:!1,title:"Pintura configuration",grouped:!0,children:[s.jsx(st,{checked:p,direction:"rtl",hint:s.jsxs(s.Fragment,{children:["Enable ",s.jsx("a",{className:"text-green",href:"https://pqina.nl/pintura/ghost/?ref=ghost.org",rel:"noopener noreferrer",target:"_blank",children:"Pintura"})," for editing your images in Ghost"]}),label:"Enable Pintura",onChange:C=>{x(C.target.checked)}}),p&&!c.pintura&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col justify-between gap-1 md:flex-row md:items-center",children:[s.jsxs("div",{children:[s.jsx("div",{children:"Upload Pintura script"}),s.jsxs("div",{className:"text-xs text-grey-600",children:["Upload the ",s.jsx("code",{children:"pintura-umd.js"})," file from the Pintura package"]})]}),s.jsx("input",{ref:_,accept:".js",type:"file",hidden:!0,onChange:async C=>{await T(C,"js")}}),s.jsx(Ue,{color:"outline",disabled:n.js,label:"Upload",onClick:()=>{M("js")}})]}),s.jsxs("div",{className:"flex flex-col justify-between gap-1 md:flex-row md:items-center",children:[s.jsxs("div",{children:[s.jsx("div",{children:"Upload Pintura styles"}),s.jsxs("div",{className:"text-xs text-grey-600",children:["Upload the ",s.jsx("code",{children:"pintura.css"})," file from the Pintura package"]})]}),s.jsx("input",{ref:k,accept:".css",type:"file",hidden:!0,onChange:async C=>{await T(C,"css")}}),s.jsx(Ue,{color:"outline",disabled:n.css,label:"Upload",onClick:()=>{M("css")}})]})]})]})]})]})}),i4=({updateSetting:e,errors:n,setError:a})=>{const{siteData:o,settings:c,config:m}=Je(),[y,h]=gt(c,["members_support_address","support_email_address"]),l=h?.toString()||Nf(y?.toString()||"",o,m),f=__(o,m),[u,p]=D.useState(l),x=v=>{let _=v.target.value;_?Nt.isEmail(_)?a("members_support_address",""):a("members_support_address","Enter a valid email address"):a("members_support_address","Enter an email address");let k=f&&_===`noreply@${f}`?"noreply":_;e("members_support_address",k),p(Nf(k,o,m))};return D.useEffect(()=>{p(l)},[l]),s.jsx("div",{className:"mt-7",children:s.jsx(tt,{children:s.jsx(Ae,{error:!!n.members_support_address,hint:n.members_support_address,title:"Support email address",value:u,onBlur:x,onChange:v=>p(v.target.value)})})})},Tf=[{icon:"portal-icon-1",value:"icon-1"},{icon:"portal-icon-2",value:"icon-2"},{icon:"portal-icon-3",value:"icon-3"},{icon:"portal-icon-4",value:"icon-4"},{icon:"portal-icon-5",value:"icon-5"}],l4=({localSettings:e,updateSetting:n})=>{const{mutateAsync:a}=Xs(),o=ot(),[c,m,y,h]=gt(e,["portal_button","portal_button_style","portal_button_icon","portal_button_signup_text"]),l=y||Tf[0].value,f=Tf.map(({value:k})=>k).includes(l),[u,p]=D.useState(f?void 0:l),x=async k=>{try{const M=on(await a({file:k}));n("portal_button_icon",M),p(M)}catch(M){const T=M;T.response.status===415&&(T.message="Unsupported file type"),o(T)}},v=()=>{n("portal_button_icon",null),p(void 0)},_=[{value:"icon-and-text",label:"Icon and text"},{value:"icon-only",label:"Icon only"},{value:"text-only",label:"Text only"}];return s.jsx("div",{className:"mt-7",children:s.jsxs(tt,{children:[s.jsx(st,{checked:!!c,direction:"rtl",label:"Show portal button",onChange:k=>n("portal_button",k.target.checked)}),c&&s.jsxs(s.Fragment,{children:[s.jsx(Lt,{options:_,selectedOption:_.find(k=>k.value===m),title:"Button style",onSelect:k=>n("portal_button_style",k?.value||null)}),m?.toString()?.includes("icon")&&s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(bt,{level:6,grey:!0,children:"Icon"}),s.jsxs("div",{className:"flex justify-between",children:[Tf.map(k=>s.jsx("button",{className:we("border p-3",l===k.value?"border-green":"border-transparent"),type:"button",onClick:()=>n("portal_button_icon",k.value),children:s.jsx(ut,{className:`size-5 ${l===k.value?"text-green":"text-black opacity-70 transition-all hover:opacity-100 dark:text-white"}`,name:k.icon})},k.value)),s.jsx("div",{className:we("relative w-[46px] border",l===u?"border-green":"border-transparent"),children:s.jsx(un,{deleteButtonClassName:"invisible absolute -right-2 -top-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-full bg-[rgba(0,0,0,0.75)] text-white hover:bg-black group-hover:!visible",deleteButtonContent:s.jsx(ut,{colorClass:"text-white",name:"trash",size:"sm"}),height:"46px",id:"test",imageClassName:"cursor-pointer",imageURL:u,width:"46px",deleteButtonUnstyled:!0,onDelete:v,onImageClick:()=>u&&n("portal_button_icon",u),onUpload:x,children:s.jsx(ut,{className:"dark:text-white",name:"upload",size:"md"})})})]})]}),m?.toString()?.includes("text")&&s.jsx(Ae,{title:"Signup button text",value:h,onChange:k=>n("portal_button_signup_text",k.target.value)})]})]})})},Lr=({name:e,value:n})=>{const a=D.useId();return s.jsx(On,{action:s.jsx(Ue,{color:"black",label:"Copy",link:!0,onClick:o=>{navigator.clipboard.writeText(n);const c=o?.target;c.innerText="Copied",setTimeout(()=>{c.innerText="Copy"},1e3)}}),separator:!0,children:s.jsxs("div",{className:"flex w-full grow flex-col py-3 lg:flex-row lg:items-center lg:gap-5",children:[s.jsxs("label",{className:"inline-block whitespace-nowrap lg:w-[180px] lg:min-w-[180px]",htmlFor:a,children:[e,":"]}),s.jsx(Ae,{className:"border-b-500 grow bg-transparent py-1 text-grey-700 lg:p-1",id:a,value:n,disabled:!0,unstyled:!0})]})})},c4=()=>{const[e,n]=D.useState(!1),[a,o]=D.useState(""),{siteData:c}=Je(),{data:{tiers:m}={}}=so(),y=od(m||[]),h=()=>{n(!e)};D.useEffect(()=>{y?.length&&!a&&o(y[0].id)},[y,a]);const l=y?.map(u=>({label:u.name,value:u.id})),f=ln(c);return s.jsxs(ud,{className:"max-w-[920px] text-base text-black dark:text-white",heading:"Links",children:[s.jsxs("p",{className:"-mt-6 mb-16",children:["Use these ",e?"data attributes":"links"," in your theme to show pages of Portal."]}),s.jsxs(cn,{actions:s.jsx(Ue,{color:"green",label:e?"Links":"Data attributes",link:!0,onClick:h}),title:"Generic",titleSize:"lg",children:[s.jsx(Lr,{name:"Default",value:e?"data-portal":`${f}#/portal`}),s.jsx(Lr,{name:"Sign in",value:e?'data-portal="signin"':`${f}#/portal/signin`}),s.jsx(Lr,{name:"Sign up",value:e?'data-portal="signup"':`${f}#/portal/signup`})]}),s.jsxs(cn,{className:"mt-14",title:"Tiers",titleSize:"lg",children:[s.jsx(On,{hideActions:!0,separator:!0,children:s.jsxs("div",{className:"flex w-full items-center gap-2 py-2",children:[s.jsx("span",{className:"inline-block w-[180px] min-w-[180px] shrink-0",children:"Tier:"}),s.jsx(Lt,{options:l,selectedOption:l.find(u=>u.value===a),onSelect:u=>{u&&o(u?.value)}})]})}),s.jsx(Lr,{name:"Signup / Monthly",value:e?`data-portal="signup/${a}/monthly"`:`${f}#/portal/signup/${a}/monthly`}),s.jsx(Lr,{name:"Signup / Yearly",value:e?`data-portal="signup/${a}/yearly"`:`${f}#/portal/signup/${a}/yearly`}),s.jsx(Lr,{name:"Signup / Free",value:e?'data-portal="signup/free"':`${f}#/portal/signup/free`})]}),s.jsxs(cn,{className:"mt-14",title:"Account",titleSize:"lg",children:[s.jsx(Lr,{name:"Account",value:e?'data-portal="account"':`${f}#/portal/account`}),s.jsx(Lr,{name:"Account / Plans",value:e?'data-portal="account/plans"':`${f}#/portal/account/plans`}),s.jsx(Lr,{name:"Account / Profile",value:e?'data-portal="account/profile"':`${f}#/portal/account/profile`}),s.jsx(Lr,{name:"Account / Newsletters",value:e?'data-portal="account/newsletters"':`${f}#/portal/account/newsletters`}),s.jsx(Lr,{name:"Account / Newsletter help",value:e?'data-portal="account/newsletters/help"':`${f}#/portal/account/newsletters/help`})]})]})},u4=({settings:e,config:n,tiers:a,siteData:o,selectedTab:c})=>{if(!o?.url)return null;let m=a.filter(v=>v.visibility==="public"&&v.type==="paid").map(v=>v.id);const y=o.url.replace(/\/$/,""),h="/?v=modal-portal-settings#/portal/preview",l=JSON.parse(dr(e,"portal_plans")||""),f=new URLSearchParams;f.append("button",dr(e,"portal_button")?"true":"false"),f.append("name",dr(e,"portal_name")?"true":"false"),f.append("isFree",l.includes("free")?"true":"false"),f.append("isMonthly",Ws(e,n)&&l.includes("monthly")?"true":"false"),f.append("isYearly",Ws(e,n)&&l.includes("yearly")?"true":"false"),f.append("page",c==="account"?"accountHome":"signup"),f.append("buttonIcon",encodeURIComponent(dr(e,"portal_button_icon")||"icon-1")),f.append("signupButtonText",encodeURIComponent(dr(e,"portal_button_signup_text")||"")),f.append("membersSignupAccess",dr(e,"members_signup_access")||"all"),f.append("allowSelfSignup",dr(e,"allow_self_signup")||"false"),f.append("signupTermsHtml",dr(e,"portal_signup_terms_html")||""),f.append("signupCheckboxRequired",dr(e,"portal_signup_checkbox_required")?"true":"false"),f.append("portalProducts",m.join(","));const u=dr(e,"portal_default_plan");u&&f.append("portalDefaultPlan",u),l&&l.length&&f.append("portalPrices",encodeURIComponent(l.join(",")));const p=dr(e,"accent_color");p!=null&&f.append("accentColor",encodeURIComponent(p));const x=dr(e,"portal_button_style");return x&&f.append("buttonStyle",encodeURIComponent(x)),f.append("disableBackground","false"),`${y}${h}?${f.toString()}`},f4=({selectedTab:e="signup",localSettings:n,localTiers:a})=>{const{siteData:o,config:c}=Je(),m=u4({settings:n,tiers:a,selectedTab:e,siteData:o,config:c});let y=s.jsx(s.Fragment,{});switch(e){case"account":y=s.jsx(s.Fragment,{children:s.jsx(Zi,{href:m||"",portalParent:"preview",selectedTab:e})});break;case"links":y=s.jsx(c4,{});break;default:y=s.jsx(s.Fragment,{children:s.jsx(Zi,{href:m||"",portalParent:"preview",selectedTab:e})});break}return y},d4=({localSettings:e,updateSetting:n,localTiers:a,updateTier:o,errors:c,setError:m})=>{const{config:y}=Je(),[h,l,f,u,p,x]=gt(e,["members_signup_access","portal_name","portal_signup_terms_html","portal_signup_checkbox_required","portal_plans","portal_default_plan"]),v=JSON.parse(p?.toString()||"[]"),_=115,k=D.useMemo(()=>{const X=document.createElement("div");return X.innerHTML=f?.toString()||"",X.innerText.length},[f]),M=D.useCallback((X,q)=>{m(X,q)},[]);D.useEffect(()=>{k>_?M("portal_signup_terms_html","Signup notice is too long"):M("portal_signup_terms_html",void 0)},[k,M]);const T=X=>{const q=v.indexOf(X);q===-1?v.push(X):v.splice(q,1),n("portal_plans",JSON.stringify(v)),x==="yearly"?!v.includes("yearly")&&v.includes("monthly")&&n("portal_default_plan","monthly"):x==="monthly"&&(v.includes("monthly")||n("portal_default_plan","yearly"))},A=h==="all"||h==="paid",C=h==="all",O=Ws(e,y);let $=[];a&&a.forEach(X=>{X.type==="free"&&C&&$.push({checked:v.includes("free"),disabled:!A,label:X.name,value:"free",testId:"free-tier-checkbox",onChange:q=>{v.includes("free")&&!q&&v.splice(v.indexOf("free"),1),!v.includes("free")&&q&&v.push("free"),n("portal_plans",JSON.stringify(v)),o({...X,visibility:q?"public":"none"})}})});const W=od(a)||[],R=[{value:"yearly",label:"Yearly"},{value:"monthly",label:"Monthly"}];O&&W.length>0&&W.forEach(X=>{$.push({checked:X.visibility==="public",label:X.name,value:X.id,onChange:(q=>o({...X,visibility:q?"public":"none"}))})});const Z=O&&W.length>0&&W.some(X=>X.visibility==="public");return s.jsx("div",{className:"mt-7",children:s.jsxs(tt,{children:[s.jsx(st,{checked:!!l,direction:"rtl",disabled:!A,label:"Display name in signup form",onChange:X=>n("portal_name",X.target.checked)}),s.jsx(Cf,{checkboxes:$,title:"Available tiers"}),Z&&s.jsxs(s.Fragment,{children:[s.jsx(Cf,{checkboxes:[{checked:v.includes("monthly"),disabled:!A,label:"Monthly",value:"monthly",onChange:()=>{T("monthly")}},{checked:v.includes("yearly"),disabled:!A,label:"Yearly",value:"yearly",onChange:()=>{T("yearly")}}],title:"Available prices"}),v.includes("yearly")&&v.includes("monthly")&&s.jsx(Lt,{options:R,selectedOption:R.find(X=>X.value===x),title:"Default price at signup",onSelect:X=>{n("portal_default_plan",X?.value??"yearly")}})]}),s.jsx(ld,{error:!!c.portal_signup_terms_html,hint:c.portal_signup_terms_html||s.jsxs(s.Fragment,{children:["Recommended: ",s.jsx("strong",{children:"115"})," characters. You've used ",s.jsx("strong",{className:"text-green",children:k})]}),nodes:"MINIMAL_NODES",placeholder:"By signing up, I agree to receive emails from ...",title:"Display notice at signup",value:f?.toString(),onChange:X=>n("portal_signup_terms_html",X)}),f?.toString()&&s.jsx(st,{checked:!!u,disabled:!A,label:"Require agreement",labelStyle:"heading",onChange:X=>n("portal_signup_checkbox_required",X.target.checked)})]})})},p4="SettingsResponseType",h4=ns({path:()=>"/settings/verifications",method:"PUT",body:({token:e})=>({token:e}),updateQueries:{dataType:p4,emberUpdateType:"createOrUpdate",update:e=>({...e,settings:e.settings})}}),m4=({localSettings:e,updateSetting:n,localTiers:a,updateTier:o,errors:c,setError:m})=>{const[y,h]=D.useState("signupOptions"),l=[{id:"signupOptions",title:"Signup options",contents:s.jsx(d4,{errors:c,localSettings:e,localTiers:a,setError:m,updateSetting:n,updateTier:o})},{id:"lookAndFeel",title:"Look & feel",contents:s.jsx(l4,{localSettings:e,updateSetting:n})},{id:"accountPage",title:"Account page",contents:s.jsx(i4,{errors:c,setError:m,updateSetting:n})}],f=u=>{h(u)};return s.jsx("div",{className:"pt-4",children:s.jsx(Dn,{selectedTab:y,tabs:l,onTabChange:f})})},g4=()=>{const{updateRoute:e}=Qe(),[n,a]=D.useState("signup"),o=ot(),{settings:c,siteData:m,config:y}=Je(),{mutateAsync:h}=Rn(),{data:{tiers:l}={}}=so(),{mutateAsync:f}=ad(),{mutateAsync:u}=h4(),{getParam:p}=Kg(),x=p("verifyEmail");D.useEffect(()=>{x&&(async({token:ae})=>{try{let{settings:ee}=await u({token:ae});const[re]=gt(ee,["members_support_address"]);ye.show(Et,{title:"Support address verified",prompt:s.jsxs(s.Fragment,{children:["Your support email address has been changed to ",s.jsx("strong",{children:re}),"."]}),okLabel:"Close",cancelLabel:"",onOk:Q=>Q?.remove()})}catch(ee){let re="There was an error verifying your email address. Please try again.";ee?.message==="Token expired"&&(re="Verification link has expired."),ye.show(Et,{title:"Error verifying support address",prompt:re,okLabel:"Close",cancelLabel:"",onOk:Q=>Q?.remove()}),o(ee,{withToast:!1})}})({token:x})},[o,x,u]);const{formState:v,setFormState:_,saveState:k,handleSave:M,updateForm:T,okProps:A}=kr({initialState:{settings:c,tiers:l||[]},savingDelay:500,onSave:async()=>{await Promise.all(v.tiers.filter(({dirty:re})=>re).map(re=>f(re))),_(re=>({...re,tiers:v.tiers.map(Q=>({...Q,dirty:!1}))}));const Y=v.settings.filter(re=>re.dirty);if(!Y.length)return;const{meta:ae,settings:ee}=await h(Y);if(_(re=>({...re,settings:v.settings.map(Q=>({...Q,dirty:!1}))})),ae?.sent_email_verification){const re=v.settings.find(ne=>ne.key==="members_support_address")?.value,Q=ee.find(ne=>ne.key==="support_email_address")?.value||Nf(ee.find(ne=>ne.key==="members_support_address")?.value?.toString()||"noreply",m,y);ye.show(Et,{title:"Confirm email address",prompt:s.jsxs(s.Fragment,{children:["We've sent a confirmation email to ",s.jsx("strong",{children:re}),". Until verified, your support email address will remain ",Q,"."]}),okLabel:"Close",cancelLabel:"",onOk:ne=>ne?.remove()})}},onSaveError:o});D.useEffect(()=>{!v.tiers.length&&l?.length&&_(Y=>({...Y,tiers:l}))},[l,v.tiers,_]);const[C,O]=D.useState({}),$=(Y,ae)=>{T(ee=>({...ee,settings:ee.settings.map(re=>re.key===Y?{...re,value:ae,dirty:!0}:re)}))},W=(Y,ae)=>{O(ee=>({...ee,[Y]:ae}))},R=Y=>{T(ae=>({...ae,tiers:ae.tiers.map(ee=>ee.id===Y.id?{...Y,dirty:!0}:ee)}))},Z=Y=>{a(Y)},X=s.jsx(m4,{errors:C,localSettings:v.settings,localTiers:v.tiers,setError:W,updateSetting:$,updateTier:R}),q=s.jsx(f4,{localSettings:v.settings,localTiers:v.tiers,selectedTab:n});let B=[{id:"signup",title:"Signup"},{id:"account",title:"Account page"},{id:"links",title:"Links"}];return s.jsx(Zs,{afterClose:()=>{e("portal")},buttonsDisabled:A.disabled,cancelLabel:"Close",deviceSelector:!1,dirty:k==="unsaved",okColor:A.color,okLabel:A.label||"Save",preview:q,previewBgColor:n==="links"?"white":"greygradient",previewToolbarTabs:B,selectedURL:n,sidebar:X,testId:"portal-modal",title:"Portal",onOk:async()=>{Object.values(C).filter(Boolean).length||await M({force:!0})},onSelectURL:Z})},x4=ye.create(g4),b4=ye.create(()=>{const{updateRoute:e}=Qe(),{localSettings:n,updateSetting:a,handleSave:o,validate:c,errors:m,clearError:y,okProps:h}=ss({onValidate:()=>{const v={};return l&&!Nt.isURL(l,{require_protocol:!0})&&(v.slackUrl="The URL must be in a format like https://hooks.slack.com/services/<your personal key>"),v},savingDelay:500}),[l,f]=gt(n,["slack_url","slack_username"]),{mutateAsync:u}=k_(),p=async()=>{Za.remove(),await o()&&(await u(null),xt({title:"Check your Slack channel for the test message",type:"info"}))},x=n.some(v=>v.dirty);return s.jsxs(yt,{afterClose:()=>{e("integrations")},cancelLabel:"Close",dirty:x,okColor:h.color,okLabel:h.label||"Save",testId:"slack-modal",title:"",onOk:async()=>{Za.remove(),await o()},children:[s.jsx(Qs,{detail:"A messaging app for teams",icon:s.jsx(ut,{name:"slack",size:56}),title:"Slack"}),s.jsx("div",{className:"mt-7",children:s.jsxs(tt,{marginBottom:!1,title:"Slack configuration",grouped:!0,children:[s.jsx(Ae,{error:!!m.slackUrl,hint:m.slackUrl||s.jsxs(s.Fragment,{children:["Automatically send newly published posts to a channel in Slack or any Slack-compatible service like Discord or Mattermost. Set up a new incoming webhook ",s.jsx("a",{href:"https://my.slack.com/apps/new/A0F7XDUAZ-incoming-webhooks",children:"here"}),", and grab the URL."]}),placeholder:"https://hooks.slack.com/services/...",title:"Webhook URL",value:l,onBlur:c,onChange:v=>a("slack_url",v.target.value),onKeyDown:()=>y("slackUrl")}),s.jsxs("div",{className:"flex w-full flex-col gap-2 md:flex-row md:items-center",children:[s.jsx(Ae,{containerClassName:"flex-grow",hint:"The username to display messages from",title:"Username",value:f,onChange:v=>a("slack_username",v.target.value)}),s.jsx(Ue,{color:"outline",label:"Send test notification",onClick:p})]})]})})]})}),v4=""+new URL("stripe-thumb-Cu2h4McY.jpg",import.meta.url).href,w4=""+new URL("orb-squircle-e1heFqOI.png",import.meta.url).href,y4="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20400%20400'%20style='enable-background:new%200%200%20400%20400'%20xml:space='preserve'%3e%3cpath%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%23635bff'%20d='M0%200h400v400H0z'/%3e%3cpath%20d='M184.4%20155.5c0-9.4%207.7-13.1%2020.5-13.1%2018.4%200%2041.6%205.6%2060%2015.5v-56.8C244.8%2093.1%20225%2090%20205%2090c-49.1%200-81.7%2025.6-81.7%2068.4%200%2066.7%2091.9%2056.1%2091.9%2084.9%200%2011.1-9.7%2014.7-23.2%2014.7-20.1%200-45.7-8.2-66-19.3v57.5c22.5%209.7%2045.2%2013.8%2066%2013.8%2050.3%200%2084.9-24.9%2084.9-68.2-.4-72-92.5-59.2-92.5-86.3z'%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%23fff'/%3e%3c/svg%3e",_4=""+new URL("stripe-verified-DM7Q8nrY.svg",import.meta.url).href,Xf=1e3,k4=15*Xf,M4=({onNext:e})=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(bt,{level:3,children:"Getting paid"}),s.jsx("img",{alt:"Stripe Verified Partner Badge",src:_4})]}),s.jsxs("div",{className:"mb-7 mt-6",children:["Stripe is our exclusive direct payments partner. Ghost collects ",s.jsx("strong",{children:"no fees"})," on any payments! If you don’t have a Stripe account yet, you can ",s.jsx("a",{className:"underline",href:"https://stripe.com",rel:"noopener noreferrer",target:"_blank",children:"sign up here"}),"."]}),s.jsx(r0,{label:s.jsx(s.Fragment,{children:"I have a Stripe account, let's go →"}),onClick:e})]}),j4=()=>{const[e,n]=D.useState(!1),[a,o]=D.useState(""),[c,m]=D.useState(!1),[y,h]=D.useState(""),{refetch:l}=so({searchParams:{filter:"type:paid+active:true"},enabled:!1}),{mutateAsync:f}=ad(),{mutateAsync:u}=Rn(),p=ot(),x=T=>{o(T.target.value),n(!!T.target.value)},v=async()=>{const{data:T}=await l(),A=T?.pages[0].tiers[0];if(A){A.monthly_price=500,A.yearly_price=5e3,A.currency="USD";let C=0;for(;C<k4;){await new Promise(O=>{setTimeout(O,Xf)});try{await f(A);break}catch(O){if(O instanceof ts&&O.data?.errors?.[0].code==="STRIPE_NOT_CONFIGURED"){C+=Xf;continue}else{p(O);return}}}}},_=async()=>{if(h(""),a)try{await u([{key:"stripe_connect_integration_token",value:a}]),await v(),await u([{key:"portal_plans",value:JSON.stringify(["free","monthly","yearly"])}])}catch(T){if(T instanceof ts&&T.data?.errors){h("Invalid secure key");return}else{p(T);return}}else h("Please enter a secure key")},{apiRoot:k}=no(),M=`${k}/members/stripe_connect?mode=${c?"test":"live"}`;return s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx(bt,{level:3,children:"Connect with Stripe"}),s.jsx(st,{direction:"rtl",label:"Test mode",labelClasses:`text-sm translate-y-[1px] ${c?"text-[#EC6803]":"text-grey-800"}`,toggleBg:"stripetest",onChange:T=>m(T.target.checked)})]}),s.jsxs(bt,{level:6,grey:!0,children:["Step 1 — ",s.jsx("span",{className:"text-black dark:text-white",children:"Generate secure key"})]}),s.jsxs("div",{className:"mb-4 mt-2",children:["Click on the ",s.jsx("strong",{children:"“Connect with Stripe”"})," button to generate a secure key that connects your Ghost site with Stripe."]}),s.jsx(r0,{href:M,tag:"a",target:"_blank"}),s.jsxs(bt,{className:"mb-2 mt-8",level:6,grey:!0,children:["Step 2 — ",s.jsx("span",{className:"text-black dark:text-white",children:"Paste secure key"})]}),s.jsx($n,{error:!!y,hint:y||void 0,placeholder:"Paste your secure key here",onChange:x}),e&&s.jsx(Ue,{className:"mt-5",color:"green",label:"Save Stripe settings",onClick:_})]})},E4=({onClose:e})=>{const{settings:n}=Je(),[a,o]=gt(n,["stripe_connect_display_name","stripe_connect_livemode"]),{refetch:c,isFetching:m}=Fg({searchParams:{filter:"status:paid",limit:"0"},enabled:!1}),{mutateAsync:y}=M_(),h=ot(),l=async()=>{const{data:f}=await c(),u=!!f?.meta?.pagination.total;ye.show(Et,{title:"Disconnect Stripe",prompt:u?"Cannot disconnect while there are members with active Stripe subscriptions.":s.jsxs(s.Fragment,{children:["You‘re about to disconnect your Stripe account ",a," from this site. This will automatically turn off paid memberships on this site."]}),okLabel:u?"":"Disconnect",onOk:async p=>{try{await y(null),p?.remove(),e?.()}catch(x){h(x)}}})};return s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Ue,{color:"red",disabled:m,icon:"link-broken",iconColorClass:"text-red",label:"Disconnect",link:!0,onClick:l}),s.jsx(Ue,{icon:"close",iconColorClass:"dark:text-white",label:"Close",size:"sm",hideLabel:!0,link:!0,onClick:e})]}),s.jsxs("div",{className:"my-20 flex flex-col items-center",children:[s.jsxs("div",{className:"relative h-20 w-[200px]",children:[s.jsx("img",{alt:"Ghost Logo",className:"absolute left-10 size-16",src:w4}),s.jsx("img",{alt:"Stripe Logo",className:"absolute right-10 size-16 rounded-2xl shadow-[-1.5px_0_0_1.5px_#fff] dark:shadow-[-1.5px_0_0_1.5px_black]",src:y4})]}),s.jsxs(bt,{className:"text-center",level:3,children:["You are connected with Stripe!",o?null:" (Test mode)"]}),s.jsxs("div",{className:"mt-1",children:["Connected to ",s.jsx("strong",{children:a||"Test mode"})]})]}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx(bt,{level:6,children:"Read next"}),s.jsxs("a",{className:"w-100 mt-5 flex flex-col items-stretch justify-between rounded-sm border border-grey-200 transition-all hover:border-grey-400 md:flex-row dark:border-grey-900",href:"https://ghost.org/resources/managing-your-stripe-account/?ref=admin",rel:"noopener noreferrer",target:"_blank",children:[s.jsxs("div",{className:"order-2 p-4 md:order-1",children:[s.jsx("div",{className:"font-bold",children:"How to setup and manage your Stripe account"}),s.jsx("div",{className:"mt-1 text-sm text-grey-800 dark:text-grey-500",children:"Learn how to configure your Stripe account to work with Ghost, from custom branding to payment receipt emails."}),s.jsxs("div",{className:"mt-3 flex items-center gap-1 text-sm text-grey-800 dark:text-grey-500",children:[s.jsx("img",{alt:"Ghost Logo",className:"size-4",src:v2}),s.jsx("strong",{children:"Ghost Resources"}),s.jsx("span",{children:"·"}),s.jsx("span",{children:"by Kym Ellis"})]})]}),s.jsx("div",{className:"order-1 hidden w-[200px] shrink-0 items-center justify-center overflow-hidden md:!visible md:order-2 md:!flex",children:s.jsx("img",{alt:"Bookmark Thumb",className:"min-h-full min-w-full shrink-0",src:v4})})]})]})]})},T4=({onClose:e})=>{const{localSettings:n,updateSetting:a,handleSave:o,saveState:c}=ss(),[m,y]=gt(n,["stripe_publishable_key","stripe_secret_key"]),h=async()=>{try{j_.remove(),await o(),e()}catch(l){if(l instanceof ts){xt({title:"Failed to save settings",type:"error",message:"Check you copied both keys correctly"});return}throw l}};return s.jsxs("div",{children:[s.jsx(bt,{level:3,children:"Connect Stripe"}),s.jsxs(tt,{marginBottom:!1,marginTop:!0,children:[s.jsx(Ae,{title:"Publishable key",value:m?.toString(),onChange:l=>a("stripe_publishable_key",l.target.value)}),s.jsx(Ae,{title:"Secure key",value:y?.toString(),onChange:l=>a("stripe_secret_key",l.target.value)}),s.jsx(Ue,{className:"mt-5",color:"green",disabled:c==="saving",label:"Save Stripe settings",onClick:h})]})]})},S4=()=>{const{config:e,settings:n}=Je(),a=dr(n,"stripe_connect_account_id"),{updateRoute:o}=Qe(),[c,m]=D.useState("start"),y=Zt(),h=Ys(),l=Ws(n,e),f=h?.isDisabled("limitStripeConnect");D.useEffect(()=>{(async()=>{if(f&&!l)try{await h?.errorIfWouldGoOverLimit("limitStripeConnect")}catch(_){_ instanceof Gs&&(y.remove(),ye.show(Xr,{prompt:_.message||"Your current plan doesn't support Stripe Connect.",onOk:()=>o({route:"/pro",isExternal:!0})}))}})()},[h,y,o,l,f]);const u=()=>{m("connect")},p=()=>{y.remove(),o("tiers")};let x;return e?.stripeDirect||Ws(n||[],e||{})&&!a?x=s.jsx(T4,{onClose:p}):a?x=s.jsx(E4,{onClose:p}):c==="start"?x=s.jsx(M4,{onNext:u}):x=s.jsx(j4,{}),s.jsx(yt,{afterClose:()=>{o("tiers")},cancelLabel:"",footer:s.jsx("div",{className:"mt-8"}),testId:"stripe-modal",title:"",width:a?740:520,hideXOnMobile:!0,children:x})},N4=ye.create(S4),A4=""+new URL("ali-abdaal-C_tOLbSs.png",import.meta.url).href,I4=""+new URL("isaac-saul-DhERrV-4.png",import.meta.url).href,C4=""+new URL("joel-warner-CHe_ZipQ.png",import.meta.url).href,D4=ye.create(()=>{const{updateRoute:e}=Qe(),n=ot(),a=Zt(),{settings:o,currentUser:c,siteData:m,config:y}=Je(),h=y.exploreTestimonialsUrl,l=m.site_uuid,[f]=gt(o,["title"]),u=c.name,p=c.email,x=c.roles[0].name,v=c.profile_image,{formState:_,updateForm:k,saveState:M,handleSave:T,errors:A,clearError:C}=kr({initialState:{content:"",prev_platform:""},onSave:async()=>{const $=["none","other",""].includes(_.prev_platform)?void 0:_.prev_platform,W={ghost_uuid:l,staff_user_email:p,content:_.content,prev_platform:$};if(!h)throw new Error("Something went wrong, please try again later.");if(!(await fetch(h,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(W)})).ok)throw new Error("Something went wrong, please try again later.");xt({message:"Thank you for your testimonial!",type:"success"}),e("explore"),a.remove()},onSaveError:n,onValidate:()=>{const $={};return _.content.trim()||($.content="This field is required"),$}}),O=[{value:"none",label:"None - This is a new site"},{value:"substack",label:"Substack"},{value:"beehiiv",label:"BeeHiiv"},{value:"wordpress",label:"WordPress"},{value:"newspack",label:"Newspack"},{value:"medium",label:"Medium"},{value:"squarespace",label:"Squarespace"},{value:"wix",label:"Wix"},{value:"patreon",label:"Patreon"},{value:"memberful",label:"Memberful"},{value:"other",label:"Other"}];return s.jsx(yt,{afterClose:()=>{e("explore")},cancelLabel:"",footer:!1,padding:!1,testId:"explore-testimonials-modal",title:"",topRightContent:"close",width:920,children:s.jsx(tt,{className:"!mb-0",children:s.jsxs("div",{className:"flex items-stretch",children:[s.jsxs("div",{className:"hidden w-full flex-col justify-between bg-gradient-to-tl from-grey-100/50 to-grey-100/80 p-8 dark:from-grey-900/40 dark:to-grey-900/60 [@media(min-width:905px)]:!visible [@media(min-width:905px)]:!flex",children:[s.jsxs("div",{className:"pr-6",children:[s.jsx("div",{className:"relative rounded-xl bg-white px-3 py-2.5 italic text-grey-700 shadow-lg before:absolute before:-bottom-1.5 before:left-5 before:block before:size-3 before:rotate-45 before:bg-white dark:bg-black dark:text-grey-300 before:dark:bg-black",children:"Moving to Ghost has proven to be one of the best business decisions we’ve made as an independent media outlet."}),s.jsxs("div",{className:"ml-2 mt-[14px] flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"size-9 rounded-full bg-white bg-cover bg-center opacity-90 grayscale",style:{backgroundImage:`url(${C4})`}}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-black dark:text-white",children:"Joel Warner"}),s.jsx("div",{className:"-mt-0.5 text-grey-700",children:"Lever News"})]})]})]}),s.jsxs("div",{className:"ml-6 mt-8",children:[s.jsx("div",{className:"relative rounded-xl bg-white px-3 py-2.5 italic text-grey-700 shadow-lg before:absolute before:-bottom-1.5 before:right-5 before:block before:size-3 before:rotate-45 before:bg-white dark:bg-black dark:text-grey-300 before:dark:bg-black",children:"It has now been one year since I quit my full-time job to go all in on Tangle. Today, we have 50,000+ paying subscribers. That’s roughly $5M in gross yearly revenue ... it’s the best paying job I’ve ever had."}),s.jsxs("div",{className:"mr-2 mt-[14px] flex items-center justify-end gap-2 text-sm",children:[s.jsxs("div",{className:"flex flex-col items-end",children:[s.jsx("div",{className:"font-medium text-black dark:text-white",children:"Isaac Saul"}),s.jsx("div",{className:"-mt-0.5 text-grey-700",children:"Tangle"})]}),s.jsx("div",{className:"size-9 rounded-full bg-white bg-cover bg-center opacity-90 grayscale",style:{backgroundImage:`url(${I4})`}})]})]}),s.jsxs("div",{className:"mt-8 hidden pr-6 [@media(min-width:940px)]:!visible [@media(min-width:940px)]:!block",children:[s.jsx("div",{className:"relative rounded-xl bg-white px-3 py-2.5 italic text-grey-700 shadow-lg before:absolute before:-bottom-1.5 before:left-5 before:block before:size-3 before:rotate-45 before:bg-white dark:bg-black dark:text-grey-300 before:dark:bg-black",children:"You should be using Ghost because it’s absolutely amazing and I love it. It’s what I’ve been using for all my sites since 2016."}),s.jsxs("div",{className:"ml-2 mt-[14px] flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"size-9 rounded-full bg-white bg-cover bg-center opacity-90 grayscale",style:{backgroundImage:`url(${A4})`}}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-black dark:text-white",children:"Ali Abdaal"}),s.jsx("div",{className:"-mt-0.5 text-grey-700",children:"YouTuber"})]})]})]})]}),s.jsxs("div",{className:"flex grow flex-col justify-between gap-6 p-8 [@media(min-width:905px)]:min-w-[520px] [@media(min-width:940px)]:min-w-[460px]",children:[s.jsxs("div",{children:[s.jsx("div",{className:"flex size-[60px] items-center justify-center rounded-full bg-gradient-to-t from-[#CFB0FF] to-[#B27EFF]",children:s.jsx("svg",{fill:"none",height:"26",viewBox:"0 0 32 26",width:"32",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M19.9967 26L18.1562 21.4542C23.4268 19.1176 25.7693 16.5261 26.2712 11.7255C25.5183 12.3627 24.5562 12.7026 23.3431 12.7026C20.1641 12.7026 17.4869 10.1536 17.4869 6.41503C17.4869 2.80392 20.3732 9.72736e-07 24.2634 6.32644e-07C28.2791 2.81581e-07 31.5 3.10131 31.5 8.96405C31.5 17.5458 27.4425 23.0261 19.9967 26ZM3.0098 26L1.12745 21.4543C6.43987 19.1176 8.78235 16.5261 9.24248 11.7255C8.53137 12.3627 7.56928 12.7026 6.35621 12.7026C3.17712 12.7026 0.499999 10.1536 0.499998 6.41504C0.499998 2.80393 3.38627 2.45778e-06 7.23464 2.12135e-06C11.2503 1.77028e-06 14.5131 3.10131 14.5131 8.96405C14.5131 17.5458 10.4556 23.0261 3.0098 26Z",fill:"white"})})}),s.jsxs("div",{className:"mt-6",children:[s.jsx("div",{className:"text-2xl font-semibold tracking-tight",children:"A quote about Ghost"}),s.jsx("div",{className:"mt-2 text-pretty",children:"We feature quotes from publishers to showcase their work, including a logo and a link! If you'd like to be included, share a quote we can use to highlight you."})]}),s.jsx("div",{className:"mt-8",children:s.jsx($n,{error:!!A.content,hint:A.content,placeholder:"What changed for the better since you switched to Ghost?",rows:7,value:_.content,autoFocus:!0,onChange:$=>k(W=>({...W,content:$.target.value})),onKeyDown:()=>C("content")})}),s.jsx("div",{className:"ml-0.5 mt-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Vg,{bgColor:Jg(u||p),image:v??void 0,label:Qg(u),labelColor:"white",size:"md"}),s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("span",{className:"text-sm font-medium",children:["By ",u||p]}),s.jsxs("span",{className:"text-xs text-grey-700",children:[x," — ",f]})]})]})})]}),s.jsx("div",{children:s.jsxs("div",{className:"mt-2 flex items-center gap-4",children:[s.jsx("div",{className:"grow",children:s.jsx(Lt,{error:!!A.prev_platform,hint:A.prev_platform,options:O,placeholder:"Previous platform",selectedOption:O.find($=>$.value===_.prev_platform),testId:"migrated-from",onSelect:$=>{k(W=>({...W,prev_platform:$?.value||""})),C("prev_platform")}})}),s.jsx(Ue,{className:"!h-[38px] rounded-lg",color:"black",disabled:M==="saving",label:"Send testimonial",loading:M==="saving",onClick:async()=>{await T()}})]})})]})]})})})}),R4=ye.create(()=>{const{updateRoute:e}=Qe(),{settings:n}=Je(),{mutateAsync:a}=Rn(),{data:{integrations:o}={integrations:[]}}=Qf(),{mutateAsync:c}=dd(),m=ot(),[y,h]=D.useState(!1),[l]=gt(n,["transistor"]),[f,u]=D.useState(!!l),[p,x]=D.useState("Save");D.useEffect(()=>{u(l||!1)},[l]);const v=o.find(({slug:T})=>T==="transistor"),_=v?.api_keys?.find(T=>T.type==="admin"),k=()=>{if(!v||!_)throw new Error("Transistor integration or Admin API key not found");h(!1),ye.show(Et,{title:"Regenerate Admin API Key",prompt:"You will need to update the API key in your Transistor account settings after regenerating.",okLabel:"Regenerate Admin API Key",onOk:async T=>{try{await c({integrationId:v.id,apiKeyId:_.id}),h(!0),T?.remove()}catch(A){m(A)}}})},M=async()=>{const T=[{key:"transistor",value:f}];try{x("Saving..."),await Promise.all([a(T),new Promise(A=>{setTimeout(A,1e3)})]),x("Saved")}catch(A){m(A)}finally{setTimeout(()=>x("Save"),1e3)}};return s.jsxs(yt,{afterClose:()=>{e("integrations")},cancelLabel:"Close",dirty:f!==l,okColor:p==="Saved"?"green":"black",okLabel:p,testId:"transistor-modal",title:"",onOk:M,children:[s.jsx(Qs,{detail:"Podcast hosting platform",icon:s.jsx(ut,{name:"transistor",size:56}),title:"Transistor"}),s.jsx("div",{className:"mt-7",children:s.jsxs(tt,{marginBottom:!1,title:"Transistor configuration",grouped:!0,children:[s.jsx(st,{checked:f,direction:"rtl",hint:s.jsxs(s.Fragment,{children:["Connect your Ghost site with ",s.jsx("a",{className:"text-green",href:"https://transistor.fm",rel:"noopener noreferrer",target:"_blank",children:"Transistor.fm"})," to start offering members private podcasts."]}),label:"Enable Transistor",onChange:T=>{u(T.target.checked)}}),f&&s.jsx(al,{keys:[{label:"Admin API key",text:_?.secret,hint:y?s.jsx("div",{className:"text-green",children:"Admin API Key was successfully regenerated"}):void 0,onRegenerate:k},{label:"API URL",text:window.location.origin+no().subdir}]})]})})]})}),O4=ye.create(()=>{const{updateRoute:e}=Qe(),{settings:n}=Je(),[a]=gt(n,["unsplash"]),{mutateAsync:o}=Rn(),c=ot(),[m,y]=D.useState("Save"),[h,l]=D.useState(!!a);D.useEffect(()=>{l(a||!1)},[a]);const f=async()=>{const p=[{key:"unsplash",value:h}];try{y("Saving..."),await Promise.all([o(p),new Promise(x=>{setTimeout(x,1e3)})]),y("Saved")}catch(x){c(x)}finally{setTimeout(()=>y("Save"),1e3)}},u=h!==a;return s.jsxs(yt,{afterClose:()=>{e("integrations")},cancelLabel:"Close",dirty:u,okColor:m==="Saved"?"green":"black",okLabel:m,testId:"unsplash-modal",title:"",onOk:f,children:[s.jsx(Qs,{detail:"Beautiful, free photos",icon:s.jsx(ut,{name:"unsplash",size:48}),title:"Unsplash"}),s.jsx("div",{className:"mt-7",children:s.jsx(tt,{marginBottom:!1,grouped:!0,children:s.jsx(st,{checked:h,direction:"rtl",hint:s.jsxs(s.Fragment,{children:["Enable ",s.jsx("a",{className:"text-green",href:"https://unsplash.com",rel:"noopener noreferrer",target:"_blank",children:"Unsplash"})," image integration for your posts"]}),label:"Enable Unsplash",onChange:p=>{l(p.target.checked)}})})})]})}),$4=({user:e,setUserData:n})=>{const{config:a,settings:o}=Je(),c=w2("webmentions"),m=Ws(o||[],a||{});return s.jsxs(sd,{children:[s.jsx(st,{checked:e.comment_notifications,direction:"rtl",hint:"Every time a member comments on one of your posts",label:"Comments",onChange:y=>{n?.({...e,comment_notifications:y.target.checked})}}),Hi(e)&&s.jsxs(s.Fragment,{children:[c&&s.jsx(st,{checked:e.mention_notifications,direction:"rtl",hint:"Every time another site links to your work",label:"Mentions",onChange:y=>{n?.({...e,mention_notifications:y.target.checked})}}),s.jsx(st,{checked:e.recommendation_notifications,direction:"rtl",hint:"Every time another publisher recommends you to their audience",label:"Recommendations",onChange:y=>{n?.({...e,recommendation_notifications:y.target.checked})}}),s.jsx(st,{checked:e.free_member_signup_notification,direction:"rtl",hint:"Every time a new free member signs up",label:"New signups",onChange:y=>{n?.({...e,free_member_signup_notification:y.target.checked})}}),m&&s.jsxs(s.Fragment,{children:[s.jsx(st,{checked:e.paid_subscription_started_notification,direction:"rtl",hint:"Every time a member starts a new paid subscription",label:"New paid members",onChange:y=>{n?.({...e,paid_subscription_started_notification:y.target.checked})}}),s.jsx(st,{checked:e.paid_subscription_canceled_notification,direction:"rtl",hint:"Every time a member cancels their paid subscription",label:"Paid member cancellations",onChange:y=>{n?.({...e,paid_subscription_canceled_notification:y.target.checked})}})]}),s.jsx(st,{checked:e.milestone_notifications,direction:"rtl",hint:m?"Occasional summaries of your audience & revenue growth":"Occasional summaries of your audience growth",label:"Milestones",onChange:y=>{n?.({...e,milestone_notifications:y.target.checked})}}),m&&s.jsx(st,{checked:e.donation_notifications,direction:"rtl",hint:"Every time you receive a one-time payment",label:"Tips & donations",onChange:y=>{n?.({...e,donation_notifications:y.target.checked})}})]})]})},L4=({user:e,setUserData:n})=>s.jsx(nd,{border:!1,children:s.jsx($4,{setUserData:n,user:e})}),P4=["1234567890","qwertyuiop","qwertzuiop","asdfghjkl;","abcdefghij","0987654321","1q2w3e4r5t","12345asdfg"],F4=["ghost","password","passw0rd"],U4=e=>{let n={},a,o=!0;a=e.length/2;for(let c=0;c<e.length;c+=1)n[e[c]]?n[e[c]]+=1:n[e[c]]=1;for(let c in n)if(n[c]>=a)return o=!1,o;return o},z4=({user:e})=>{const{currentUser:n,config:a,siteData:o}=Je(),[c,m]=D.useState(!1),[y,h]=D.useState(""),[l,f]=D.useState(""),[u,p]=D.useState(""),[x,v]=D.useState(""),[_,k]=D.useState({}),M=D.useRef(null),T=D.useRef(null),A=D.useRef(null),{mutateAsync:C}=E_(),O=ot(),$=e.id===n.id,W=({password:B,confirmPassword:Y})=>{if($&&!y)return{oldPassword:"Your current password is required to set a new one"};if(B!==Y)return{newPassword:"Your new passwords do not match",confirmNewPassword:"Your new passwords do not match"};let ae=a.blogUrl||window.location.host,ee=o.title,re;if(ae=ae.replace(/^http(s?):\/\//,""),re=ae.match(/\/$/)?ae:`${ae}/`,ee=ee&&ee.trim().toLowerCase(),B.length<10)return{newPassword:"Password must be at least 10 characters long."};B=B.toString();for(const Q of P4)if(Q===B)return{newPassword:"Sorry, you cannot use an insecure password."};if(B.toLowerCase()===e.email.toLowerCase())return{newPassword:"Sorry, you cannot use an insecure password."};for(const Q of F4)if(B.toLowerCase().indexOf(Q)>=0)return{newPassword:"Sorry, you cannot use an insecure password."};return B.toLowerCase()===ee?{newPassword:"Sorry, you cannot use an insecure password."}:B.toLowerCase()===ae||B.toLowerCase()===re?{newPassword:"Sorry, you cannot use an insecure password."}:U4(B)?{}:{newPassword:"Sorry, you cannot use an insecure password."}};D.useEffect(()=>{x==="saved"&&setTimeout(()=>{v(""),m(!1)},2500)},[x]),D.useEffect(()=>{c&&setTimeout(()=>{$?A.current?.focus():M.current?.focus()},100)},[c,$]);const R=()=>{m(!0)};let Z="Save password";x==="saving"?Z="Saving...":x==="saved"&&(Z="Saved");const X=s.jsxs(s.Fragment,{children:[$&&s.jsx(Ae,{"data-testid":"old-password",error:!!_.oldPassword,hint:_.oldPassword,inputRef:A,title:"Old password",type:"password",value:y,onChange:B=>{h(B.target.value)}}),s.jsx(Ae,{"data-testid":"new-password",error:!!_.newPassword,hint:_.newPassword,inputRef:M,title:"New password",type:"password",value:l,onChange:B=>{f(B.target.value)}}),s.jsx(Ae,{"data-testid":"confirm-password",error:!!_.confirmNewPassword,hint:_.confirmNewPassword,inputRef:T,title:"Confirm new password",type:"password",value:u,onChange:B=>{p(B.target.value)}}),s.jsxs("div",{className:"mt-1 flex items-center justify-end gap-3",children:[s.jsx(Ue,{color:"outline",label:"Cancel",onClick:()=>{m(!1),h(""),f(""),p(""),k({})}}),s.jsx(Ue,{color:"green","data-testid":"save-password-button",label:Z,onClick:async()=>{v("saving");const B=W({password:l,confirmPassword:u});if(k(B),Object.keys(B).length>0){v("");return}try{await C({newPassword:l,confirmNewPassword:u,oldPassword:y,userId:e?.id}),v("saved")}catch(Y){v(""),xt({type:"error",title:Y instanceof T_?Y.message:"Couldn't update password. Please try again."}),O(Y,{withToast:!1})}}})]})]}),q=s.jsxs("div",{className:"relative flex flex-col",children:[s.jsx(Ae,{containerClassName:"grow",disabled:!0,title:"Password",type:"password",value:"••••••••••••"}),s.jsx(Ue,{className:"absolute right-0 top-0",color:"green","data-testid":"change-password-button",label:"Change",link:!0,onClick:R})]});return s.jsx(s.Fragment,{children:c?X:q})},H4=({user:e,setUserData:n})=>{const{data:{roles:a}={}}=If(),{config:o}=Je(),c=o.labs.superEditors;let m=[{hint:"Can write and edit their own posts, but cannot publish them.",label:"Contributor",value:"contributor"},{hint:"Can create, edit and publish their own posts, but can’t modify others.",label:"Author",value:"author"},{hint:"Can edit and publish any posts, and manage Authors and Contributors.",label:"Editor",value:"editor"},{hint:"Trusted user who has full access to all content, settings, and user management.",label:"Administrator",value:"administrator"}];if(c&&(m=m.map(y=>y.value==="editor"?{...y,label:"Editor (beta mode)",value:"super editor",hint:"Can invite and manage other Authors and Contributors, as well as edit and publish any posts on the site. Can manage members and moderate comments."}:y)),Af(e)){const y={label:"Owner",value:"owner"};return s.jsx("div",{children:s.jsx(Lt,{disabled:!0,hint:s.jsxs(s.Fragment,{children:["This user is the owner of the site. ",s.jsx("a",{className:"font-medium text-grey-800 transition-colors hover:text-grey-900 dark:text-grey-500 dark:hover:text-grey-400",href:"https://ghost.org/help/transfer-publication-ownership/",rel:"noopener noreferrer",target:"_blank",children:"Transfer ownership"})," first to change their role."]}),options:[y],selectedOption:y,title:"Role",onSelect:()=>{}})})}return s.jsx(Lt,{options:m,selectedOption:m.find(y=>y.value===e.roles[0].name.toLowerCase()),testId:"role-select",title:"Role",onSelect:y=>{if(y){const h=a?.find(l=>l.name.toLowerCase()===y.value.toLowerCase());h&&n?.({...e,roles:[h]})}}})},B4="StaffTokenResponseType",W4=S_({dataType:B4,path:"/users/me/token/"}),q4=ns({path:()=>"/users/me/token/",method:"PUT"}),Y4=()=>{const{refetch:e}=W4({enabled:!1}),n=ot(),[a,o]=D.useState(""),{mutateAsync:c}=q4();D.useEffect(()=>{(async()=>{const h=await e();h?.data?.apiKey&&o(`${h.data.apiKey.id}:${h.data.apiKey.secret}`)})()},[e]);const m=()=>{ye.show(Et,{title:"Regenerate your Staff Access Token",prompt:"You can regenerate your Staff Access Token any time, but any scripts or applications using it will need to be updated.",okLabel:"Regenerate your Staff Access Token",okColor:"red",onOk:async y=>{try{const h=await c([]);o(`${h.apiKey.id}:${h.apiKey.secret}`),y?.remove()}catch(h){n(h)}}})};return s.jsxs("div",{children:[s.jsx(bt,{className:"mb-2",level:6,grey:!0,children:"Staff access token"}),s.jsx(al,{hasLabel:!1,keys:[{text:a||"",onRegenerate:m}]})]})},G4=({errors:e,clearError:n,user:a,setUserData:o})=>{const{currentUser:c}=Je();return s.jsxs(sd,{children:[s.jsx(Ae,{error:!!e?.email,hint:e?.email||"Used for notifications",maxLength:191,title:"Email",value:a.email,onChange:m=>{o({...a,email:m.target.value})},onKeyDown:()=>n("email")}),s.jsx(z4,{user:a}),Hi(c)&&s.jsx(H4,{setUserData:o,user:a}),s.jsx(Ae,{error:!!e?.name,hint:e?.name||"Use your real name so people can recognize you",maxLength:191,title:"Full name",value:a.name,onChange:m=>{o({...a,name:m.target.value})},onKeyDown:()=>n("name")}),s.jsx(Ae,{hint:`https://example.com/author/${a.slug}`,maxLength:191,title:"Slug",value:a.slug,onChange:m=>{o({...a,slug:m.target.value})}}),s.jsx(Ae,{error:!!e?.location,hint:e?.location||"Where in the world do you live?",maxLength:65535,title:"Location",value:a.location||"",onChange:m=>{o({...a,location:m.target.value})},onKeyDown:()=>n("location")}),s.jsx($n,{error:!!e?.bio,hint:e?.bio||s.jsxs(s.Fragment,{children:["Recommended: 250 characters. You‘ve used ",s.jsx("span",{className:"font-bold",children:a.bio?.length||0})]}),maxLength:65535,title:"Bio",value:a.bio||"",onChange:m=>{o({...a,bio:m.target.value})},onKeyDown:()=>n("bio")}),a.id===c.id&&s.jsx(Y4,{})]})},X4=e=>s.jsx(nd,{border:!1,children:s.jsx(G4,{...e})}),K4=({errors:e,clearError:n,validateField:a,user:o,setUserData:c})=>{const[m,y]=D.useState(o.facebook?y2(o.facebook):""),[h,l]=D.useState(o.twitter?_2(o.twitter):""),[f,u]=D.useState(o.threads?oM(o.threads):""),[p,x]=D.useState(o.bluesky?lM(o.bluesky):""),[v,_]=D.useState(o.linkedin?pM(o.linkedin):""),[k,M]=D.useState(o.instagram?mM(o.instagram):""),[T,A]=D.useState(o.youtube?xM(o.youtube):""),[C,O]=D.useState(o.tiktok?vM(o.tiktok):""),[$,W]=D.useState(o.mastodon?yM(o.mastodon):"");return s.jsxs(sd,{children:[s.jsx(Ae,{"data-testid":"website-input",error:!!e?.website,hint:e?.website,maxLength:2e3,placeholder:"https://example.com",title:"Website",value:o.website||"",onChange:R=>{c({...o,website:R.target.value})},onKeyDown:()=>n("url")}),s.jsx(Ae,{"data-testid":"x-input",error:!!e?.twitter,hint:e?.twitter,maxLength:2e3,placeholder:"https://x.com/username",title:"X",value:h,onBlur:R=>{if(a("twitter",R.target.value)){const Z=n0(R.target.value);l(Z),c({...o,twitter:k2(Z)})}},onChange:R=>{l(R.target.value)},onKeyDown:()=>n("twitter")}),s.jsx(Ae,{"data-testid":"facebook-input",error:!!e?.facebook,hint:e?.facebook,maxLength:2e3,placeholder:"https://www.facebook.com/username",title:"Facebook",value:m,onBlur:R=>{if(a("facebook",R.target.value)){const Z=s0(R.target.value);y(Z),c({...o,facebook:M2(Z)})}},onChange:R=>{y(R.target.value)},onKeyDown:()=>n("facebook")}),s.jsx(Ae,{"data-testid":"linkedin-input",error:!!e?.linkedin,hint:e?.linkedin,maxLength:2e3,placeholder:"https://www.linkedin.com/in/username",title:"LinkedIn",value:v,onBlur:R=>{if(a("linkedin",R.target.value)){const Z=X0(R.target.value);_(Z),c({...o,linkedin:hM(Z)})}},onChange:R=>{_(R.target.value)},onKeyDown:()=>n("linkedin")}),s.jsx(Ae,{"data-testid":"bluesky-input",error:!!e?.bluesky,hint:e?.bluesky,maxLength:2e3,placeholder:"https://bsky.app/profile/username",title:"Bluesky",value:p,onBlur:R=>{if(a("bluesky",R.target.value)){const Z=B0(R.target.value);x(Z),c({...o,bluesky:cM(Z)})}},onChange:R=>{x(R.target.value)},onKeyDown:()=>n("bluesky")}),s.jsx(Ae,{"data-testid":"threads-input",error:!!e?.threads,hint:e?.threads,maxLength:2e3,placeholder:"https://threads.net/@username",title:"Threads",value:f,onBlur:R=>{if(a("threads",R.target.value)){const Z=z0(R.target.value);u(Z),c({...o,threads:iM(Z)})}},onChange:R=>{u(R.target.value)},onKeyDown:()=>n("threads")}),s.jsx(Ae,{"data-testid":"mastodon-input",error:!!e?.mastodon,hint:e?.mastodon,maxLength:2e3,placeholder:"https://mastodon.social/@username",title:"Mastodon",value:$,onBlur:R=>{if(a("mastodon",R.target.value)){const Z=Q0(R.target.value);W(Z),c({...o,mastodon:_M(Z)})}},onChange:R=>{W(R.target.value)},onKeyDown:()=>n("mastodon")}),s.jsx(Ae,{"data-testid":"tiktok-input",error:!!e?.tiktok,hint:e?.tiktok,maxLength:2e3,placeholder:"https://www.tiktok.com/@username",title:"TikTok",value:C,onBlur:R=>{if(a("tiktok",R.target.value)){const Z=V0(R.target.value);O(Z),c({...o,tiktok:wM(Z)})}},onChange:R=>{O(R.target.value)},onKeyDown:()=>n("tiktok")}),s.jsx(Ae,{"data-testid":"youtube-input",error:!!e?.youtube,hint:e?.youtube,maxLength:2e3,placeholder:"https://www.youtube.com/@channel",title:"YouTube",value:T,onBlur:R=>{if(a("youtube",R.target.value)){const Z=Z0(R.target.value);A(Z),c({...o,youtube:bM(Z)})}},onChange:R=>{A(R.target.value)},onKeyDown:()=>n("youtube")}),s.jsx(Ae,{"data-testid":"instagram-input",error:!!e?.instagram,hint:e?.instagram,maxLength:2e3,placeholder:"https://www.instagram.com/username",title:"Instagram",value:k,onBlur:R=>{if(a("instagram",R.target.value)){const Z=K0(R.target.value);M(Z),c({...o,instagram:gM(Z)})}},onChange:R=>{M(R.target.value)},onKeyDown:()=>n("instagram")})]})},Z4=e=>s.jsx(nd,{border:!1,children:s.jsx(K4,{...e})}),Og={name:({name:e})=>{let n="";return e||(n="Name is required"),e&&e.length>191&&(n="Name is too long"),n},email:({email:e})=>Nt.isEmail(e||"")?"":"Enter a valid email address",url:({url:e})=>!e||Nt.isURL(e,{require_tld:!1})?"":"Enter a valid URL",bio:({bio:e})=>!e||e.length<=250?"":"Bio is too long",location:({location:e})=>!e||e.length<=150?"":"Location is too long",website:({website:e})=>!e||Nt.isURL(e)&&e.length<=2e3?"":"Enter a valid URL",facebook:({facebook:e})=>{try{return s0(e||""),""}catch(n){return n instanceof Error?n.message:""}},twitter:({twitter:e})=>{try{return n0(e||""),""}catch(n){return n instanceof Error?n.message:""}},threads:({threads:e})=>{try{return z0(e||""),""}catch(n){return n instanceof Error?n.message:""}},bluesky:({bluesky:e})=>{try{return B0(e||""),""}catch(n){return n instanceof Error?n.message:""}},linkedin:({linkedin:e})=>{try{return X0(e||""),""}catch(n){return n instanceof Error?n.message:""}},instagram:({instagram:e})=>{try{return K0(e||""),""}catch(n){return n instanceof Error?n.message:""}},youtube:({youtube:e})=>{try{return Z0(e||""),""}catch(n){return n instanceof Error?n.message:""}},tiktok:({tiktok:e})=>{try{return V0(e||""),""}catch(n){return n instanceof Error?n.message:""}},mastodon:({mastodon:e})=>{try{return Q0(e||""),""}catch(n){return n instanceof Error?n.message:""}}},V4=({user:e})=>{const{updateRoute:n,route:a}=Qe(),o=L=>{const J=L.split("/").pop()||"";return J==="social-links"||J==="email-notifications"?J:"profile"},{ownerUser:c}=j2(),{currentUser:m}=Je(),y=ot(),{formState:h,setFormState:l,saveState:f,handleSave:u,updateForm:p,errors:x,setErrors:v,clearError:_,okProps:k}=kr({initialState:e,savingDelay:500,savedDelay:500,onValidate:L=>Object.entries(Og).reduce((J,[xe,Te])=>{const De=Te(L);return De&&(J[xe]=De),J},{}),onSave:async L=>{await O?.(L)},onSaveError:y}),M=L=>p(()=>L),T=(L,J)=>{const xe=Og[L]?.({[L]:J});return xe?(v({...x,[L]:xe}),!1):(_(L),!0)},A=Zt(),{mutateAsync:C}=Xs(),{mutateAsync:O}=A_(),{mutateAsync:$}=I_(),{mutateAsync:W}=C_(),R=Ys(),Z=Gg(),X=D.useCallback(()=>{Nn(m)?n("staff"):n({isExternal:!0,route:""})},[m,n]),q=async L=>{if(L.status==="inactive"&&L.roles[0].name!=="Contributor")try{await R?.errorIfWouldGoOverLimit("staff")}catch(xe){if(xe instanceof Gs){ye.show(Xr,{formSheet:!0,prompt:xe.message||"Your current plan doesn't support more users.",onOk:()=>n({route:"/pro",isExternal:!0})});return}else throw xe}let J="This user will no longer be able to log in but their posts will be kept.";L.status==="inactive"&&(J="This user will be able to log in again and will have the same permissions they had previously."),ye.show(Et,{title:"Are you sure you want to suspend this user?",prompt:s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"WARNING:"})," ",J]}),okLabel:L.status==="inactive"?"Un-suspend":"Suspend",okRunningLabel:L.status==="inactive"?"Un-suspending...":"Suspending...",okColor:"red",onOk:async xe=>{const Te={...L,status:L.status==="inactive"?"active":"inactive"};try{await O(Te),l(()=>Te),xe?.remove(),xt({title:L.status==="inactive"?"User un-suspended":"User suspended",type:"success"})}catch(De){y(De)}}})},B=(L,{owner:J})=>{ye.show(Et,{title:"Are you sure you want to delete this user?",prompt:s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"mb-3",children:[s.jsx("span",{className:"font-bold",children:L.name||L.email})," will be permanently deleted and all their posts will be automatically assigned to the ",s.jsx("span",{className:"font-bold",children:J.name}),"."]}),s.jsxs("p",{children:["To make these easy to find in the future, each post will be given an internal tag of ",s.jsxs("span",{className:"font-bold",children:["#",e.slug]})]})]}),okLabel:"Delete user",okColor:"red",onOk:async xe=>{try{await $(L?.id),xe?.remove(),A?.remove(),X(),xt({title:"User deleted",type:"success"})}catch(Te){y(Te)}}})},Y=()=>{ye.show(Et,{title:"Transfer Ownership",prompt:"Are you sure you want to transfer the ownership of this blog? You will not be able to undo this action.",okLabel:"Yep — I'm sure",okColor:"red",onOk:async L=>{try{await W(e.id),L?.remove(),xt({title:"Ownership transferred",type:"success"})}catch(J){y(J)}}})},ae=async(L,J)=>{try{const xe=on(await C({file:J}));switch(L){case"cover_image":p(Te=>({...Te,cover_image:xe}));break;case"profile_image":p(Te=>({...Te,profile_image:xe}));break}}catch(xe){const Te=xe;Te.response.status===415&&(Te.message="Unsupported file type"),y(Te)}},ee=L=>{switch(L){case"cover_image":p(J=>({...J,cover_image:""}));break;case"profile_image":p(J=>({...J,profile_image:""}));break}},re=Hi(m)||ih(m)&&lh(e);let Q=[];if(Af(m)&&D_(h)&&h.status!=="inactive"&&Q.push({id:"make-owner",label:"Make owner",onClick:Y}),h.id!==m.id&&(Hi(m)&&!Af(e)||ih(m)&&lh(e))){let L=h.status==="inactive"?"Un-suspend user":"Suspend user";Q.push({id:"delete-user",label:"Delete user",onClick:()=>{B(e,{owner:c})}},{id:"suspend-user",label:L,onClick:()=>{q(h)}})}Q.push({id:"view-user-activity",label:"View user activity",onClick:()=>{A.remove(),n(`history/view/${h.id}`)}});const ne="rounded text-sm flex flex-nowrap items-center justify-center px-3 h-8 transition-all cursor-pointer font-medium border border-grey-300 bg-transparent text-black dark:border-grey-800 dark:text-white",be="flex flex-nowrap items-center justify-center px-3 h-8 opacity-80 hover:opacity-100 bg-[rgba(0,0,0,0.75)] rounded text-sm text-white transition-all cursor-pointer font-medium nowrap",je=h.status==="inactive"?" (Suspended)":"",H=o(a),[he,ge]=D.useState(H),F=L=>{const J=L==="profile"?"":`/${L}`;n(`staff/${e.slug}${J}`),ge(L)};return s.jsx(yt,{afterClose:X,animate:Nn(m),backDrop:Nn(m),buttonsDisabled:k.disabled,cancelLabel:"Close",dirty:f==="unsaved",okColor:k.color,okLabel:k.label||"Save",size:Nn(m)?"md":"bleed",stickyFooter:!0,testId:"user-detail-modal",width:Nn(m)?600:"full",onOk:async()=>{await u({fakeWhenUnchanged:!0})},children:s.jsxs("div",{children:[s.jsx("div",{className:`relative ${Nn(m)?"-mx-8 -mt-8 rounded-t":"-mx-10 -mt-10"}`,children:s.jsx("div",{className:`flex flex-wrap items-end justify-between gap-8 p-8 ${h.cover_image?"bg-cover bg-center":""} ${!Nn(m)&&"min-h-[30vmin]"}`,style:{backgroundImage:h.cover_image?`url(${h.cover_image})`:"none"},children:s.jsxs("div",{className:"flex w-full flex-col gap-2",children:[s.jsxs("div",{className:"flex flex-nowrap items-start justify-between gap-3",children:[s.jsx("div",{children:s.jsx(un,{deleteButtonClassName:"md:invisible absolute pr-3 -right-2 -top-2 flex h-8 w-10 cursor-pointer items-center justify-end rounded-full bg-[rgba(0,0,0,0.75)] text-white group-hover:!visible",deleteButtonContent:s.jsx(ut,{colorClass:"text-white",name:"trash",size:"sm"}),editButtonClassName:"md:invisible absolute right-[22px] -top-2 flex h-8 w-8 cursor-pointer items-center justify-center text-white group-hover:!visible z-20",fileUploadClassName:"rounded-full bg-black flex items-center justify-center opacity-80 transition hover:opacity-100 -ml-2 cursor-pointer h-[80px] w-[80px]",fileUploadProps:{dragIndicatorClassName:"rounded-full"},id:"avatar",imageClassName:"w-full h-full object-cover rounded-full shrink-0",imageContainerClassName:"relative group bg-cover bg-center -ml-1 h-16 w-16 md:h-18 md:w-18 shrink-0",imageURL:h.profile_image??void 0,pintura:{isEnabled:Z.isEnabled,openEditor:async()=>Z.openEditor({image:h.profile_image||"",handleSave:async L=>{ae("profile_image",L)}})},unstyled:!0,width:"80px",onDelete:()=>{ee("profile_image")},onUpload:L=>{ae("profile_image",L)},children:s.jsx(ut,{colorClass:"black",name:"user-add",size:"lg"})})}),s.jsxs("div",{className:"flex flex-nowrap items-start gap-3",children:[s.jsx(un,{buttonContainerClassName:"flex items-end gap-4 justify-end flex-nowrap",deleteButtonClassName:be,deleteButtonContent:"Delete cover image",editButtonClassName:be,fileUploadClassName:ne,id:"cover-image",imageClassName:"hidden",imageURL:h.cover_image||"",pintura:{isEnabled:Z.isEnabled,openEditor:async()=>Z.openEditor({image:h.cover_image||"",handleSave:async L=>{ae("cover_image",L)}})},unstyled:!0,onDelete:()=>{ee("cover_image")},onUpload:L=>{ae("cover_image",L)},children:"Upload cover image"}),re&&s.jsx("div",{className:"z-10",children:s.jsx(E0,{items:Q,position:"end",trigger:s.jsxs("button",{className:we("flex h-8 cursor-pointer items-center justify-center rounded px-3",h.cover_image?"bg-[rgba(0,0,0,0.75)] opacity-80 hover:opacity-100":"border border-grey-300 bg-transparent text-black dark:border-grey-800 dark:text-white"),type:"button",children:[s.jsx("span",{className:"sr-only",children:"Actions"}),s.jsx(ut,{colorClass:h.cover_image?"text-white":void 0,name:"ellipsis",size:"md"})]})})})]})]}),s.jsxs("div",{children:[s.jsxs(bt,{level:3,styles:we("break-words md:break-normal",h.cover_image?"text-white":"text-black dark:text-white"),children:[e.name,je]}),s.jsx("span",{className:we("text-md font-medium capitalize",h.cover_image?"text-white":"text-black dark:text-white"),children:e.roles[0].name.toLowerCase()})]})]})})}),s.jsx("div",{className:`${!Nn(m)&&"mx-auto max-w-[536px]"} mt-6 flex flex-col`,children:s.jsx(Dn,{selectedTab:he,tabs:[{id:"profile",title:"Profile",contents:s.jsx(X4,{clearError:_,errors:x,setUserData:M,user:h,validateField:T})},{id:"social-links",title:"Social Links",contents:s.jsx(Z4,{clearError:_,errors:x,setUserData:M,user:h,validateField:T})},{id:"email-notifications",title:"Email Notifications",contents:s.jsx(L4,{setUserData:M,user:h})}],onTabChange:F})})]})})},Q4=({params:e})=>{const{currentUser:n}=Je(),a=n.slug===e?.slug,{data:o}=N_(e?.slug||"",{enabled:!a&&!!e?.slug}),c=a?n:o?.users?.[0];return c?s.jsx(V4,{user:c}):null},J4=ye.create(Q4),iT={AddIntegrationModal:$M,AddNewsletterModal:PM,AddRecommendationModal:tx,CustomIntegrationModal:nj,DesignAndThemeModal:iE,EditRecommendationModal:E2,FirstPromoterModal:kE,HistoryModal:OE,InviteUserModal:$E,NavigationModal:LE,NewsletterDetailModal:XE,PinturaModal:o4,PortalModal:x4,SlackModal:b4,StripeConnectModal:N4,TestimonialsModal:D4,TierDetailModal:jM,TransistorModal:R4,UnsplashModal:O4,UserDetailModal:J4,ZapierModal:aM,AnnouncementBarModal:XM,EmbedSignupFormModal:_E,OffersContainerModal:n4,AboutModal:RM,OfferSuccess:wx};export{iT as default};
77
+ `;c.open(),c.write(m),c.close()};return s.jsx(pd,{className:"absolute size-full overflow-hidden transition-opacity duration-500",generateContent:a,height:"100%",parentClassName:"relative h-full w-full",width:"100%"})},cE=({selectedLayout:e,accentColor:n,handleColorToggle:a,selectedColor:o,selectedLabels:c,handleLabelClick:m,embedScript:y,handleLayoutSelect:h,handleCopyClick:l,isCopied:f})=>{const{loadData:u}=Zg({path:"/labels/",filterKey:"name",responseKey:"labels"}),p=async(x,v)=>{const _=await u(x);v(_.map(k=>({label:k.name,value:k.name})))};return s.jsxs("div",{className:"flex h-[calc(100vh-16vmin)] max-h-[645px] flex-col justify-between overflow-y-scroll border-l border-grey-200 p-6 pb-0 dark:border-grey-900",children:[s.jsxs("div",{children:[s.jsx(bt,{className:"mb-8",level:4,children:"Embed signup form"}),s.jsxs(tt,{gap:"sm",children:[s.jsxs("div",{className:"flex w-full items-center justify-between",children:[s.jsx("div",{children:"Layout"}),s.jsx(an,{activeKey:e,buttons:[{key:"all-in-one",label:"Branded",size:"md",className:"w-auto !px-3",onClick:()=>h("all-in-one")},{key:"minimal",label:"Minimal",size:"md",className:"w-auto !px-3",onClick:()=>h("minimal")}],clearBg:!1})]}),e==="all-in-one"&&s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{hex:"#08090c",title:"Dark",value:"#08090c"},{hex:"#ffffff",title:"Light",value:"#ffffff"},{hex:n||"#d74780",title:"Accent",value:n||"#d74780"}],title:"Background color",value:o,onChange:x=>{x&&a(x)}}),s.jsx(c2,{hint:"Will be applied to all members signing up via this form",loadOptions:Ji(p,500),placeholder:"Pick one or more labels (optional)",title:"Labels at signup",values:c||[],async:!0,canCreate:!0,defaultOptions:!0,onChange:m}),s.jsx($n,{className:"text-grey-800",fontStyle:"mono",hint:"Paste this code onto any website where you'd like your signup to appear.",title:"Embed code",value:`${y}`,onChange:()=>{}})]})]}),s.jsx(u2,{height:74,children:s.jsx("div",{className:"flex w-full justify-end",children:s.jsx(Ue,{color:f?"green":"black",label:f?"Copied!":"Copy code",onClick:l})})})]})};function Eg(e){return e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""}function _d(e,n){return n={exports:{}},e(n,n.exports),n.exports}var qa={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},uE=function(n){return!n||typeof n=="string"?!1:n instanceof Array||Array.isArray(n)||n.length>=0&&(n.splice instanceof Function||Object.getOwnPropertyDescriptor(n,n.length-1)&&n.constructor.name!=="String")},Ya=_d(function(e){var n=Array.prototype.concat,a=Array.prototype.slice,o=e.exports=function(m){for(var y=[],h=0,l=m.length;h<l;h++){var f=m[h];uE(f)?y=n.call(y,a.call(f)):y.push(f)}return y};o.wrap=function(c){return function(){return c(o(arguments))}}}),Jn=_d(function(e){var n=Object.hasOwnProperty,a=Object.create(null);for(var o in qa)n.call(qa,o)&&(a[qa[o]]=o);var c=e.exports={to:{},get:{}};c.get=function(h){var l=h.substring(0,3).toLowerCase(),f,u;switch(l){case"hsl":f=c.get.hsl(h),u="hsl";break;case"hwb":f=c.get.hwb(h),u="hwb";break;default:f=c.get.rgb(h),u="rgb";break}return f?{model:u,value:f}:null},c.get.rgb=function(h){if(!h)return null;var l=/^#([a-f0-9]{3,4})$/i,f=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,u=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,p=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,x=/^(\w+)$/,v=[0,0,0,1],_,k,M;if(_=h.match(f)){for(M=_[2],_=_[1],k=0;k<3;k++){var T=k*2;v[k]=parseInt(_.slice(T,T+2),16)}M&&(v[3]=parseInt(M,16)/255)}else if(_=h.match(l)){for(_=_[1],M=_[3],k=0;k<3;k++)v[k]=parseInt(_[k]+_[k],16);M&&(v[3]=parseInt(M+M,16)/255)}else if(_=h.match(u)){for(k=0;k<3;k++)v[k]=parseInt(_[k+1],0);_[4]&&(_[5]?v[3]=parseFloat(_[4])*.01:v[3]=parseFloat(_[4]))}else if(_=h.match(p)){for(k=0;k<3;k++)v[k]=Math.round(parseFloat(_[k+1])*2.55);_[4]&&(_[5]?v[3]=parseFloat(_[4])*.01:v[3]=parseFloat(_[4]))}else return(_=h.match(x))?_[1]==="transparent"?[0,0,0,0]:n.call(qa,_[1])?(v=qa[_[1]],v[3]=1,v):null:null;for(k=0;k<3;k++)v[k]=m(v[k],0,255);return v[3]=m(v[3],0,1),v},c.get.hsl=function(h){if(!h)return null;var l=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,f=h.match(l);if(f){var u=parseFloat(f[4]),p=(parseFloat(f[1])%360+360)%360,x=m(parseFloat(f[2]),0,100),v=m(parseFloat(f[3]),0,100),_=m(isNaN(u)?1:u,0,1);return[p,x,v,_]}return null},c.get.hwb=function(h){if(!h)return null;var l=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,f=h.match(l);if(f){var u=parseFloat(f[4]),p=(parseFloat(f[1])%360+360)%360,x=m(parseFloat(f[2]),0,100),v=m(parseFloat(f[3]),0,100),_=m(isNaN(u)?1:u,0,1);return[p,x,v,_]}return null},c.to.hex=function(){var h=Ya(arguments);return"#"+y(h[0])+y(h[1])+y(h[2])+(h[3]<1?y(Math.round(h[3]*255)):"")},c.to.rgb=function(){var h=Ya(arguments);return h.length<4||h[3]===1?"rgb("+Math.round(h[0])+", "+Math.round(h[1])+", "+Math.round(h[2])+")":"rgba("+Math.round(h[0])+", "+Math.round(h[1])+", "+Math.round(h[2])+", "+h[3]+")"},c.to.rgb.percent=function(){var h=Ya(arguments),l=Math.round(h[0]/255*100),f=Math.round(h[1]/255*100),u=Math.round(h[2]/255*100);return h.length<4||h[3]===1?"rgb("+l+"%, "+f+"%, "+u+"%)":"rgba("+l+"%, "+f+"%, "+u+"%, "+h[3]+")"},c.to.hsl=function(){var h=Ya(arguments);return h.length<4||h[3]===1?"hsl("+h[0]+", "+h[1]+"%, "+h[2]+"%)":"hsla("+h[0]+", "+h[1]+"%, "+h[2]+"%, "+h[3]+")"},c.to.hwb=function(){var h=Ya(arguments),l="";return h.length>=4&&h[3]!==1&&(l=", "+h[3]),"hwb("+h[0]+", "+h[1]+"%, "+h[2]+"%"+l+")"},c.to.keyword=function(h){return a[h.slice(0,3)]};function m(h,l,f){return Math.min(Math.max(l,h),f)}function y(h){var l=Math.round(h).toString(16).toUpperCase();return l.length<2?"0"+l:l}});Jn.to;Jn.get;var Vn={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},At=_d(function(e){var n={};for(var a in Vn)Vn.hasOwnProperty(a)&&(n[Vn[a]]=a);var o=e.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var c in o)if(o.hasOwnProperty(c)){if(!("channels"in o[c]))throw new Error("missing channels property: "+c);if(!("labels"in o[c]))throw new Error("missing channel labels property: "+c);if(o[c].labels.length!==o[c].channels)throw new Error("channel and label counts mismatch: "+c);var m=o[c].channels,y=o[c].labels;delete o[c].channels,delete o[c].labels,Object.defineProperty(o[c],"channels",{value:m}),Object.defineProperty(o[c],"labels",{value:y})}o.rgb.hsl=function(l){var f=l[0]/255,u=l[1]/255,p=l[2]/255,x=Math.min(f,u,p),v=Math.max(f,u,p),_=v-x,k,M,T;return v===x?k=0:f===v?k=(u-p)/_:u===v?k=2+(p-f)/_:p===v&&(k=4+(f-u)/_),k=Math.min(k*60,360),k<0&&(k+=360),T=(x+v)/2,v===x?M=0:T<=.5?M=_/(v+x):M=_/(2-v-x),[k,M*100,T*100]},o.rgb.hsv=function(l){var f,u,p,x,v,_=l[0]/255,k=l[1]/255,M=l[2]/255,T=Math.max(_,k,M),A=T-Math.min(_,k,M),C=function(O){return(T-O)/6/A+1/2};return A===0?x=v=0:(v=A/T,f=C(_),u=C(k),p=C(M),_===T?x=p-u:k===T?x=1/3+f-p:M===T&&(x=2/3+u-f),x<0?x+=1:x>1&&(x-=1)),[x*360,v*100,T*100]},o.rgb.hwb=function(l){var f=l[0],u=l[1],p=l[2],x=o.rgb.hsl(l)[0],v=1/255*Math.min(f,Math.min(u,p));return p=1-1/255*Math.max(f,Math.max(u,p)),[x,v*100,p*100]},o.rgb.cmyk=function(l){var f=l[0]/255,u=l[1]/255,p=l[2]/255,x,v,_,k;return k=Math.min(1-f,1-u,1-p),x=(1-f-k)/(1-k)||0,v=(1-u-k)/(1-k)||0,_=(1-p-k)/(1-k)||0,[x*100,v*100,_*100,k*100]};function h(l,f){return Math.pow(l[0]-f[0],2)+Math.pow(l[1]-f[1],2)+Math.pow(l[2]-f[2],2)}o.rgb.keyword=function(l){var f=n[l];if(f)return f;var u=1/0,p;for(var x in Vn)if(Vn.hasOwnProperty(x)){var v=Vn[x],_=h(l,v);_<u&&(u=_,p=x)}return p},o.keyword.rgb=function(l){return Vn[l]},o.rgb.xyz=function(l){var f=l[0]/255,u=l[1]/255,p=l[2]/255;f=f>.04045?Math.pow((f+.055)/1.055,2.4):f/12.92,u=u>.04045?Math.pow((u+.055)/1.055,2.4):u/12.92,p=p>.04045?Math.pow((p+.055)/1.055,2.4):p/12.92;var x=f*.4124+u*.3576+p*.1805,v=f*.2126+u*.7152+p*.0722,_=f*.0193+u*.1192+p*.9505;return[x*100,v*100,_*100]},o.rgb.lab=function(l){var f=o.rgb.xyz(l),u=f[0],p=f[1],x=f[2],v,_,k;return u/=95.047,p/=100,x/=108.883,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,p=p>.008856?Math.pow(p,1/3):7.787*p+16/116,x=x>.008856?Math.pow(x,1/3):7.787*x+16/116,v=116*p-16,_=500*(u-p),k=200*(p-x),[v,_,k]},o.hsl.rgb=function(l){var f=l[0]/360,u=l[1]/100,p=l[2]/100,x,v,_,k,M;if(u===0)return M=p*255,[M,M,M];p<.5?v=p*(1+u):v=p+u-p*u,x=2*p-v,k=[0,0,0];for(var T=0;T<3;T++)_=f+1/3*-(T-1),_<0&&_++,_>1&&_--,6*_<1?M=x+(v-x)*6*_:2*_<1?M=v:3*_<2?M=x+(v-x)*(2/3-_)*6:M=x,k[T]=M*255;return k},o.hsl.hsv=function(l){var f=l[0],u=l[1]/100,p=l[2]/100,x=u,v=Math.max(p,.01),_,k;return p*=2,u*=p<=1?p:2-p,x*=v<=1?v:2-v,k=(p+u)/2,_=p===0?2*x/(v+x):2*u/(p+u),[f,_*100,k*100]},o.hsv.rgb=function(l){var f=l[0]/60,u=l[1]/100,p=l[2]/100,x=Math.floor(f)%6,v=f-Math.floor(f),_=255*p*(1-u),k=255*p*(1-u*v),M=255*p*(1-u*(1-v));switch(p*=255,x){case 0:return[p,M,_];case 1:return[k,p,_];case 2:return[_,p,M];case 3:return[_,k,p];case 4:return[M,_,p];case 5:return[p,_,k]}},o.hsv.hsl=function(l){var f=l[0],u=l[1]/100,p=l[2]/100,x=Math.max(p,.01),v,_,k;return k=(2-u)*p,v=(2-u)*x,_=u*x,_/=v<=1?v:2-v,_=_||0,k/=2,[f,_*100,k*100]},o.hwb.rgb=function(l){var f=l[0]/360,u=l[1]/100,p=l[2]/100,x=u+p,v,_,k,M;x>1&&(u/=x,p/=x),v=Math.floor(6*f),_=1-p,k=6*f-v,(v&1)!==0&&(k=1-k),M=u+k*(_-u);var T,A,C;switch(v){default:case 6:case 0:T=_,A=M,C=u;break;case 1:T=M,A=_,C=u;break;case 2:T=u,A=_,C=M;break;case 3:T=u,A=M,C=_;break;case 4:T=M,A=u,C=_;break;case 5:T=_,A=u,C=M;break}return[T*255,A*255,C*255]},o.cmyk.rgb=function(l){var f=l[0]/100,u=l[1]/100,p=l[2]/100,x=l[3]/100,v,_,k;return v=1-Math.min(1,f*(1-x)+x),_=1-Math.min(1,u*(1-x)+x),k=1-Math.min(1,p*(1-x)+x),[v*255,_*255,k*255]},o.xyz.rgb=function(l){var f=l[0]/100,u=l[1]/100,p=l[2]/100,x,v,_;return x=f*3.2406+u*-1.5372+p*-.4986,v=f*-.9689+u*1.8758+p*.0415,_=f*.0557+u*-.204+p*1.057,x=x>.0031308?1.055*Math.pow(x,1/2.4)-.055:x*12.92,v=v>.0031308?1.055*Math.pow(v,1/2.4)-.055:v*12.92,_=_>.0031308?1.055*Math.pow(_,1/2.4)-.055:_*12.92,x=Math.min(Math.max(0,x),1),v=Math.min(Math.max(0,v),1),_=Math.min(Math.max(0,_),1),[x*255,v*255,_*255]},o.xyz.lab=function(l){var f=l[0],u=l[1],p=l[2],x,v,_;return f/=95.047,u/=100,p/=108.883,f=f>.008856?Math.pow(f,1/3):7.787*f+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,p=p>.008856?Math.pow(p,1/3):7.787*p+16/116,x=116*u-16,v=500*(f-u),_=200*(u-p),[x,v,_]},o.lab.xyz=function(l){var f=l[0],u=l[1],p=l[2],x,v,_;v=(f+16)/116,x=u/500+v,_=v-p/200;var k=Math.pow(v,3),M=Math.pow(x,3),T=Math.pow(_,3);return v=k>.008856?k:(v-16/116)/7.787,x=M>.008856?M:(x-16/116)/7.787,_=T>.008856?T:(_-16/116)/7.787,x*=95.047,v*=100,_*=108.883,[x,v,_]},o.lab.lch=function(l){var f=l[0],u=l[1],p=l[2],x,v,_;return x=Math.atan2(p,u),v=x*360/2/Math.PI,v<0&&(v+=360),_=Math.sqrt(u*u+p*p),[f,_,v]},o.lch.lab=function(l){var f=l[0],u=l[1],p=l[2],x,v,_;return _=p/360*2*Math.PI,x=u*Math.cos(_),v=u*Math.sin(_),[f,x,v]},o.rgb.ansi16=function(l){var f=l[0],u=l[1],p=l[2],x=1 in arguments?arguments[1]:o.rgb.hsv(l)[2];if(x=Math.round(x/50),x===0)return 30;var v=30+(Math.round(p/255)<<2|Math.round(u/255)<<1|Math.round(f/255));return x===2&&(v+=60),v},o.hsv.ansi16=function(l){return o.rgb.ansi16(o.hsv.rgb(l),l[2])},o.rgb.ansi256=function(l){var f=l[0],u=l[1],p=l[2];if(f===u&&u===p)return f<8?16:f>248?231:Math.round((f-8)/247*24)+232;var x=16+36*Math.round(f/255*5)+6*Math.round(u/255*5)+Math.round(p/255*5);return x},o.ansi16.rgb=function(l){var f=l%10;if(f===0||f===7)return l>50&&(f+=3.5),f=f/10.5*255,[f,f,f];var u=(~~(l>50)+1)*.5,p=(f&1)*u*255,x=(f>>1&1)*u*255,v=(f>>2&1)*u*255;return[p,x,v]},o.ansi256.rgb=function(l){if(l>=232){var f=(l-232)*10+8;return[f,f,f]}l-=16;var u,p=Math.floor(l/36)/5*255,x=Math.floor((u=l%36)/6)/5*255,v=u%6/5*255;return[p,x,v]},o.rgb.hex=function(l){var f=((Math.round(l[0])&255)<<16)+((Math.round(l[1])&255)<<8)+(Math.round(l[2])&255),u=f.toString(16).toUpperCase();return"000000".substring(u.length)+u},o.hex.rgb=function(l){var f=l.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!f)return[0,0,0];var u=f[0];f[0].length===3&&(u=u.split("").map(function(k){return k+k}).join(""));var p=parseInt(u,16),x=p>>16&255,v=p>>8&255,_=p&255;return[x,v,_]},o.rgb.hcg=function(l){var f=l[0]/255,u=l[1]/255,p=l[2]/255,x=Math.max(Math.max(f,u),p),v=Math.min(Math.min(f,u),p),_=x-v,k,M;return _<1?k=v/(1-_):k=0,_<=0?M=0:x===f?M=(u-p)/_%6:x===u?M=2+(p-f)/_:M=4+(f-u)/_+4,M/=6,M%=1,[M*360,_*100,k*100]},o.hsl.hcg=function(l){var f=l[1]/100,u=l[2]/100,p=1,x=0;return u<.5?p=2*f*u:p=2*f*(1-u),p<1&&(x=(u-.5*p)/(1-p)),[l[0],p*100,x*100]},o.hsv.hcg=function(l){var f=l[1]/100,u=l[2]/100,p=f*u,x=0;return p<1&&(x=(u-p)/(1-p)),[l[0],p*100,x*100]},o.hcg.rgb=function(l){var f=l[0]/360,u=l[1]/100,p=l[2]/100;if(u===0)return[p*255,p*255,p*255];var x=[0,0,0],v=f%1*6,_=v%1,k=1-_,M=0;switch(Math.floor(v)){case 0:x[0]=1,x[1]=_,x[2]=0;break;case 1:x[0]=k,x[1]=1,x[2]=0;break;case 2:x[0]=0,x[1]=1,x[2]=_;break;case 3:x[0]=0,x[1]=k,x[2]=1;break;case 4:x[0]=_,x[1]=0,x[2]=1;break;default:x[0]=1,x[1]=0,x[2]=k}return M=(1-u)*p,[(u*x[0]+M)*255,(u*x[1]+M)*255,(u*x[2]+M)*255]},o.hcg.hsv=function(l){var f=l[1]/100,u=l[2]/100,p=f+u*(1-f),x=0;return p>0&&(x=f/p),[l[0],x*100,p*100]},o.hcg.hsl=function(l){var f=l[1]/100,u=l[2]/100,p=u*(1-f)+.5*f,x=0;return p>0&&p<.5?x=f/(2*p):p>=.5&&p<1&&(x=f/(2*(1-p))),[l[0],x*100,p*100]},o.hcg.hwb=function(l){var f=l[1]/100,u=l[2]/100,p=f+u*(1-f);return[l[0],(p-f)*100,(1-p)*100]},o.hwb.hcg=function(l){var f=l[1]/100,u=l[2]/100,p=1-u,x=p-f,v=0;return x<1&&(v=(p-x)/(1-x)),[l[0],x*100,v*100]},o.apple.rgb=function(l){return[l[0]/65535*255,l[1]/65535*255,l[2]/65535*255]},o.rgb.apple=function(l){return[l[0]/255*65535,l[1]/255*65535,l[2]/255*65535]},o.gray.rgb=function(l){return[l[0]/100*255,l[0]/100*255,l[0]/100*255]},o.gray.hsl=o.gray.hsv=function(l){return[0,0,l[0]]},o.gray.hwb=function(l){return[0,100,l[0]]},o.gray.cmyk=function(l){return[0,0,0,l[0]]},o.gray.lab=function(l){return[l[0],0,0]},o.gray.hex=function(l){var f=Math.round(l[0]/100*255)&255,u=(f<<16)+(f<<8)+f,p=u.toString(16).toUpperCase();return"000000".substring(p.length)+p},o.rgb.gray=function(l){var f=(l[0]+l[1]+l[2])/3;return[f/255*100]}});At.rgb;At.hsl;At.hsv;At.hwb;At.cmyk;At.xyz;At.lab;At.lch;At.hex;At.keyword;At.ansi16;At.ansi256;At.hcg;At.apple;At.gray;function fE(){for(var e={},n=Object.keys(At),a=n.length,o=0;o<a;o++)e[n[o]]={distance:-1,parent:null};return e}function dE(e){var n=fE(),a=[e];for(n[e].distance=0;a.length;)for(var o=a.pop(),c=Object.keys(At[o]),m=c.length,y=0;y<m;y++){var h=c[y],l=n[h];l.distance===-1&&(l.distance=n[o].distance+1,l.parent=o,a.unshift(h))}return n}function pE(e,n){return function(a){return n(e(a))}}function hE(e,n){for(var a=[n[e].parent,e],o=At[n[e].parent][e],c=n[e].parent;n[c].parent;)a.unshift(n[c].parent),o=pE(At[n[c].parent][c],o),c=n[c].parent;return o.conversion=a,o}var mE=function(e){for(var n=dE(e),a={},o=Object.keys(n),c=o.length,m=0;m<c;m++){var y=o[m],h=n[y];h.parent!==null&&(a[y]=hE(y,n))}return a},zs={},gE=Object.keys(At);function xE(e){var n=function(a){return a==null?a:(arguments.length>1&&(a=Array.prototype.slice.call(arguments)),e(a))};return"conversion"in e&&(n.conversion=e.conversion),n}function bE(e){var n=function(a){if(a==null)return a;arguments.length>1&&(a=Array.prototype.slice.call(arguments));var o=e(a);if(typeof o=="object")for(var c=o.length,m=0;m<c;m++)o[m]=Math.round(o[m]);return o};return"conversion"in e&&(n.conversion=e.conversion),n}gE.forEach(function(e){zs[e]={},Object.defineProperty(zs[e],"channels",{value:At[e].channels}),Object.defineProperty(zs[e],"labels",{value:At[e].labels});var n=mE(e),a=Object.keys(n);a.forEach(function(o){var c=n[o];zs[e][o]=bE(c),zs[e][o].raw=xE(c)})});var _r=zs,kd=[].slice,vx=["keyword","gray","hex"],qf={};Object.keys(_r).forEach(function(e){qf[kd.call(_r[e].labels).sort().join("")]=e});var Ki={};function qt(e,n){if(!(this instanceof qt))return new qt(e,n);if(n&&n in vx&&(n=null),n&&!(n in _r))throw new Error("Unknown model: "+n);var a,o;if(e==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof qt)this.model=e.model,this.color=e.color.slice(),this.valpha=e.valpha;else if(typeof e=="string"){var c=Jn.get(e);if(c===null)throw new Error("Unable to parse color from string: "+e);this.model=c.model,o=_r[this.model].channels,this.color=c.value.slice(0,o),this.valpha=typeof c.value[o]=="number"?c.value[o]:1}else if(e.length){this.model=n||"rgb",o=_r[this.model].channels;var m=kd.call(e,0,o);this.color=Yf(m,o),this.valpha=typeof e[o]=="number"?e[o]:1}else if(typeof e=="number")e&=16777215,this.model="rgb",this.color=[e>>16&255,e>>8&255,e&255],this.valpha=1;else{this.valpha=1;var y=Object.keys(e);"alpha"in e&&(y.splice(y.indexOf("alpha"),1),this.valpha=typeof e.alpha=="number"?e.alpha:0);var h=y.sort().join("");if(!(h in qf))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=qf[h];var l=_r[this.model].labels,f=[];for(a=0;a<l.length;a++)f.push(e[l[a]]);this.color=Yf(f)}if(Ki[this.model])for(o=_r[this.model].channels,a=0;a<o;a++){var u=Ki[this.model][a];u&&(this.color[a]=u(this.color[a]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}qt.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(e){var n=this.model in Jn.to?this:this.rgb();n=n.round(typeof e=="number"?e:1);var a=n.valpha===1?n.color:n.color.concat(this.valpha);return Jn.to[n.model](a)},percentString:function(e){var n=this.rgb().round(typeof e=="number"?e:1),a=n.valpha===1?n.color:n.color.concat(this.valpha);return Jn.to.rgb.percent(a)},array:function(){return this.valpha===1?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var e={},n=_r[this.model].channels,a=_r[this.model].labels,o=0;o<n;o++)e[a[o]]=this.color[o];return this.valpha!==1&&(e.alpha=this.valpha),e},unitArray:function(){var e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,this.valpha!==1&&e.push(this.valpha),e},unitObject:function(){var e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,this.valpha!==1&&(e.alpha=this.valpha),e},round:function(e){return e=Math.max(e||0,0),new qt(this.color.map(wE(e)).concat(this.valpha),this.model)},alpha:function(e){return arguments.length?new qt(this.color.concat(Math.max(0,Math.min(1,e))),this.model):this.valpha},red:St("rgb",0,Ft(255)),green:St("rgb",1,Ft(255)),blue:St("rgb",2,Ft(255)),hue:St(["hsl","hsv","hsl","hwb","hcg"],0,function(e){return(e%360+360)%360}),saturationl:St("hsl",1,Ft(100)),lightness:St("hsl",2,Ft(100)),saturationv:St("hsv",1,Ft(100)),value:St("hsv",2,Ft(100)),chroma:St("hcg",1,Ft(100)),gray:St("hcg",2,Ft(100)),white:St("hwb",1,Ft(100)),wblack:St("hwb",2,Ft(100)),cyan:St("cmyk",0,Ft(100)),magenta:St("cmyk",1,Ft(100)),yellow:St("cmyk",2,Ft(100)),black:St("cmyk",3,Ft(100)),x:St("xyz",0,Ft(100)),y:St("xyz",1,Ft(100)),z:St("xyz",2,Ft(100)),l:St("lab",0,Ft(100)),a:St("lab",1),b:St("lab",2),keyword:function(e){return arguments.length?new qt(e):_r[this.model].keyword(this.color)},hex:function(e){return arguments.length?new qt(e):Jn.to.hex(this.rgb().round().color)},rgbNumber:function(){var e=this.rgb().color;return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255},luminosity:function(){for(var e=this.rgb().color,n=[],a=0;a<e.length;a++){var o=e[a]/255;n[a]=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)}return .2126*n[0]+.7152*n[1]+.0722*n[2]},contrast:function(e){var n=this.luminosity(),a=e.luminosity();return n>a?(n+.05)/(a+.05):(a+.05)/(n+.05)},level:function(e){var n=this.contrast(e);return n>=7.1?"AAA":n>=4.5?"AA":""},isDark:function(){var e=this.rgb().color,n=(e[0]*299+e[1]*587+e[2]*114)/1e3;return n<128},isLight:function(){return!this.isDark()},negate:function(){for(var e=this.rgb(),n=0;n<3;n++)e.color[n]=255-e.color[n];return e},lighten:function(e){var n=this.hsl();return n.color[2]+=n.color[2]*e,n},darken:function(e){var n=this.hsl();return n.color[2]-=n.color[2]*e,n},saturate:function(e){var n=this.hsl();return n.color[1]+=n.color[1]*e,n},desaturate:function(e){var n=this.hsl();return n.color[1]-=n.color[1]*e,n},whiten:function(e){var n=this.hwb();return n.color[1]+=n.color[1]*e,n},blacken:function(e){var n=this.hwb();return n.color[2]+=n.color[2]*e,n},grayscale:function(){var e=this.rgb().color,n=e[0]*.3+e[1]*.59+e[2]*.11;return qt.rgb(n,n,n)},fade:function(e){return this.alpha(this.valpha-this.valpha*e)},opaquer:function(e){return this.alpha(this.valpha+this.valpha*e)},rotate:function(e){var n=this.hsl(),a=n.color[0];return a=(a+e)%360,a=a<0?360+a:a,n.color[0]=a,n},mix:function(e,n){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);var a=e.rgb(),o=this.rgb(),c=n===void 0?.5:n,m=2*c-1,y=a.alpha()-o.alpha(),h=((m*y===-1?m:(m+y)/(1+m*y))+1)/2,l=1-h;return qt.rgb(h*a.red()+l*o.red(),h*a.green()+l*o.green(),h*a.blue()+l*o.blue(),a.alpha()*c+o.alpha()*(1-c))}};Object.keys(_r).forEach(function(e){if(vx.indexOf(e)===-1){var n=_r[e].channels;qt.prototype[e]=function(){if(this.model===e)return new qt(this);if(arguments.length)return new qt(arguments,e);var a=typeof arguments[n]=="number"?n:this.valpha;return new qt(yE(_r[this.model][e].raw(this.color)).concat(a),e)},qt[e]=function(a){return typeof a=="number"&&(a=Yf(kd.call(arguments),n)),new qt(a,e)}}});function vE(e,n){return Number(e.toFixed(n))}function wE(e){return function(n){return vE(n,e)}}function St(e,n,a){return e=Array.isArray(e)?e:[e],e.forEach(function(o){(Ki[o]||(Ki[o]=[]))[n]=a}),e=e[0],function(o){var c;return arguments.length?(a&&(o=a(o)),c=this[e](),c.color[n]=o,c):(c=this[e]().color[n],a&&(c=a(c)),c)}}function Ft(e){return function(n){return Math.max(0,Math.min(e,n))}}function yE(e){return Array.isArray(e)?e:[e]}function Yf(e,n){for(var a=0;a<n;a++)typeof e[a]!="number"&&(e[a]=0);return e}var Ef=qt;function Nr(e){const n=Ef(e),a=Ef({r:255,g:255,b:255}),o=Ef({r:0,g:0,b:0});return n.red()*.299+n.green()*.587+n.b()*.114>=186?o:a}const Tg=({preview:e,config:n,settings:a,labels:o,backgroundColor:c,layout:m})=>{const y=n.blogUrl,h=n.signupForm.url.replace("{version}",n.signupForm.version);let l={site:y,locale:a.locale,"button-color":a.accentColor,"button-text-color":Nr(a.accentColor).hex()};for(const[_,k]of o.entries())l[`label-${_+1}`]=k.name;let f="min-height: 58px;max-width: 440px;margin: 0 auto;width: 100%";m==="all-in-one"&&(a.icon&&a.icon!==""&&(l.icon=a.icon.replace(/\/content\/images\//,"/content/images/size/w192h192/")),l.title=a.title,l.description=a.description,l["background-color"]=c,l["text-color"]=Nr(c).hex(),f="height: 40vmin;min-height: 360px"),e&&(m==="minimal"?f="min-height: 58px; max-width: 440px;width: 100%;position: absolute; left: 50%; top:50%; transform: translate(-50%, -50%);":f="height: 100vh");let u="";const p=["background-color","text-color","button-color","button-text-color","title","description","icon","site","locale"],x=Object.keys(l).sort((_,k)=>p.indexOf(_)-p.indexOf(k));for(const _ of x){const k=l[_];u+=` data-${_}="${Eg(k)}"`}const v=`<div style="${Eg(f)}"><script src="${encodeURI(h)}"${u} async><\/script></div>`;return e&&m==="minimal"?`<div style="position: absolute; z-index: -1; top: 0; left: 0; width: 100%; height: 100%; background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%), linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%);background-size: 16px 16px;background-position: 0 0, 8px 8px;;"></div>${v}`:v},_E=ye.create(()=>{const[e,n]=D.useState("#08090c"),[a,o]=D.useState([]),[c,m]=D.useState("all-in-one"),[y,h]=D.useState(""),[l,f]=D.useState(""),[u,p]=D.useState(!1),{updateRoute:x}=Qe(),{config:v}=Je(),{localSettings:_,siteData:k}=ss(),[M,T,A,C,O]=gt(_,["accent_color","title","description","locale","icon"]),[$,W]=D.useState({active:!1});D.useEffect(()=>{if(!k)return;const q={config:{blogUrl:k.url,signupForm:{url:v?.signupForm?.url,version:v?.signupForm?.version}},settings:{accentColor:M||"#d74780",title:T||"",locale:C||"en",icon:O||"",description:A||""},labels:a.map(({label:ae})=>({name:ae})),backgroundColor:e||"#08090c",layout:c},B=Tg({preview:!0,...q});h(B);const Y=Tg({preview:!1,...q});f(Y)},[k,M,a,v,T,e,c,C,O,A]);const R=async()=>{try{await navigator.clipboard.writeText(l),p(!0),setTimeout(()=>p(!1),2e3)}catch(q){console.error("Failed to copy text: ",q)}},Z=q=>{n(q)},X=q=>{if(q?.length){const B=q?.map(({value:Y})=>({label:Y,value:Y}));o(B)}else o([])};return s.jsx(yt,{afterClose:()=>{x("embed-signup-form")},cancelLabel:"",footer:!1,height:645,padding:!1,testId:"embed-signup-form",title:"",topRightContent:"close",width:1120,children:s.jsxs("div",{className:"grid grid-cols-[5.2fr_2.8fr]",children:[s.jsx(lE,{html:y,style:c}),s.jsx(cE,{accentColor:M,customColor:$,embedScript:l,handleColorToggle:Z,handleCopyClick:R,handleLabelClick:X,handleLayoutSelect:m,isCopied:u,selectedColor:e,selectedLabels:a,selectedLayout:c,setCustomColor:W})]})})}),kE=ye.create(()=>{const{updateRoute:e}=Qe(),{settings:n}=Je(),{mutateAsync:a}=Rn(),o=ot(),[c,m]=D.useState(""),[y]=gt(n,["firstpromoter"]),[h]=gt(n,["firstpromoter_id"]),[l,f]=D.useState("Save"),[u,p]=D.useState(!!y);D.useEffect(()=>{p(y||!1),m(h||null)},[y,h]);const x=async()=>{const v=[{key:"firstpromoter",value:u},{key:"firstpromoter_id",value:c}];try{f("Saving..."),await Promise.all([a(v),new Promise(_=>{setTimeout(_,1e3)})]),f("Saved")}catch(_){o(_)}finally{setTimeout(()=>f("Save"),1e3)}};return s.jsxs(yt,{afterClose:()=>{e("integrations")},cancelLabel:"Close",dirty:u!==y||c!==h,okColor:l==="Saved"?"green":"black",okLabel:l,testId:"firstpromoter-modal",title:"",onOk:async()=>{try{await x()}catch(v){o(v)}},children:[s.jsx(Qs,{detail:"Launch your own member referral program",icon:s.jsx(ut,{className:"-mt-2",name:"firstpromoter",size:56}),title:"FirstPromoter"}),s.jsx("div",{className:"mt-7",children:s.jsxs(tt,{marginBottom:!1,title:"FirstPromoter configuration",grouped:!0,children:[s.jsx(st,{checked:u,direction:"rtl",hint:s.jsxs(s.Fragment,{children:["Enable ",s.jsx("a",{className:"text-green",href:"https://firstpromoter.com/?fpr=ghost&fp_sid=admin",rel:"noopener noreferrer",target:"_blank",children:"FirstPromoter"})," for tracking referrals"]}),label:"Enable FirstPromoter",onChange:v=>{p(v.target.checked)}}),u&&s.jsx(Ae,{hint:s.jsxs(s.Fragment,{children:["Affiliate and referral tracking, find your ID ",s.jsx("a",{className:"text-green",href:"https://ghost.org/help/firstpromoter-id/",rel:"noopener noreferrer",target:"_blank",children:"here"})]}),placeholder:"XXXXXXXX",title:"FirstPromoter account ID",value:c||"",onChange:v=>{m(v.target.value)}})]})})]})}),ME="ActionsResponseType",jE=v_({dataType:ME,path:"/actions/",returnData:e=>{const{pages:n}=e;let a=n.flatMap(m=>m.actions.map(({context:y,...h})=>({...h,context:JSON.parse(y)})));a=a.reverse();let o=1;a.forEach((m,y)=>{const h=a[y+1];h&&m.resource_id===h.resource_id&&m.event===h.event?(m.skip=!0,o+=1):o>1&&(m.count=o,o=1)});const c=n[n.length-1].meta;return{actions:a.reverse(),meta:c,isEnd:c?c.pagination.pages===c.pagination.page:!0}}}),EE=e=>{var n,a;let o=e.resource_type;if(e.event!=="deleted")switch(e.resource_type){case"page":case"post":return!e.resource||!e.resource.id?void 0:(o==="post"&&(n=e.context)!=null&&n.type&&(o=(a=e.context)==null?void 0:a.type),{isExternal:!0,route:`editor/${o}/${e.resource.id}`,models:[o,e.resource.id]});case"integration":return!e.resource||!e.resource.id?void 0:{route:`integrations/${e.resource.id}`};case"offer":return!e.resource||!e.resource.id?void 0:{isExternal:!0,route:`offers/${e.resource.id}`,models:[e.resource.id]};case"tag":return!e.resource||!e.resource.slug?void 0:{isExternal:!0,route:"tag",models:[e.resource.slug]};case"product":return{route:"tiers"};case"user":return!e.resource||!e.resource.slug?void 0:{route:`staff/${e.resource.slug}`}}},TE=e=>{var n,a,o,c,m,y,h;let l=e.resource_type;l==="api_key"?l="API key":l==="setting"?l="settings":l==="product"&&(l="tier"),l==="post"&&(n=e.context)!=null&&n.type&&(l=(a=e.context)==null?void 0:a.type);let f=e.event;return e.event==="edited"&&(o=e.context)!=null&&o.action_name&&(f=(c=e.context)==null?void 0:c.action_name),(m=e.context)!=null&&m.count&&((y=e.context)==null?void 0:y.count)>1?`${(h=e.context)==null?void 0:h.count} ${l}s ${f}`:`${l.slice(0,1).toUpperCase()}${l.slice(1)} ${f}`},SE=e=>{var n,a,o,c;if(e.resource_type==="setting"&&(n=e.context)!=null&&n.group&&(a=e.context)!=null&&a.key)return{group:(o=e.context)==null?void 0:o.group,key:(c=e.context)==null?void 0:c.key}},Sg=e=>{var n,a;return typeof((n=e.context)==null?void 0:n.count)=="number"&&((a=e.context)==null?void 0:a.count)>1},NE=({action:e})=>{let n="pen";switch(e.event){case"added":n="add";break;case"deleted":n="trash";break}return s.jsx(ut,{name:n,size:"xs"})},AE=({action:e})=>s.jsxs("div",{className:"relative shrink-0",children:[s.jsx(Vg,{bgColor:Jg(e.actor?.name||e.actor?.slug||""),image:e.actor?.image??void 0,label:Qg(e.actor?.name||e.actor?.slug),labelColor:"white",size:"md"}),s.jsx("div",{className:"absolute -bottom-1 -right-1 z-30 flex items-center justify-center rounded-full border border-grey-100 bg-white p-1 shadow-sm dark:border-grey-900 dark:bg-black",children:s.jsx(NE,{action:e})})]}),An=({label:e,item:n,excludedItems:a,toggleItem:o})=>s.jsx(st,{checked:!a.includes(n),direction:"rtl",label:e,labelClasses:"text-sm",onChange:c=>o(n,c.target.checked)}),IE=({excludedEvents:e,excludedResources:n,toggleEventType:a,toggleResourceType:o})=>{const{updateRoute:c}=Qe(),m=Zg({path:"/users/",filterKey:"name",responseKey:"users"}),y=async(u,p)=>{const x=await m.loadData(u);p(x.map(v=>({label:v.name,value:v.id})))},[h,l]=D.useState(),f=()=>{l(null)};return s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(zg,{position:"end",trigger:s.jsx(Ue,{color:"outline",label:"Filter"}),children:s.jsxs("div",{className:"flex w-[220px] flex-col gap-8 p-5",children:[s.jsxs(Yi,{children:[s.jsx(An,{excludedItems:e,item:"added",label:"Added",toggleItem:a}),s.jsx(An,{excludedItems:e,item:"edited",label:"Edited",toggleItem:a}),s.jsx(An,{excludedItems:e,item:"deleted",label:"Deleted",toggleItem:a})]}),s.jsxs(Yi,{children:[s.jsx(An,{excludedItems:n,item:"post",label:"Posts",toggleItem:o}),s.jsx(An,{excludedItems:n,item:"page",label:"Pages",toggleItem:o}),s.jsx(An,{excludedItems:n,item:"tag",label:"Tags",toggleItem:o}),s.jsx(An,{excludedItems:n,item:"offer,product",label:"Tiers & offers",toggleItem:o}),s.jsx(An,{excludedItems:n,item:"api_key,integration,setting,user,webhook",label:"Settings & staff",toggleItem:o})]})]})}),s.jsx("div",{className:"w-[200px]",children:s.jsx(Lt,{loadOptions:Ji(y,500),placeholder:"Search staff",value:h,async:!0,defaultOptions:!0,isClearable:!0,onSelect:u=>{u?(l(u),c(`history/view/${u.value}`)):(f(),c("history/view"))}})})]})},CE=({action:e})=>{const{updateRoute:n}=Qe(),a=SE(e);if(a){const{group:o,key:c}=a;return s.jsxs(s.Fragment,{children:[o.slice(0,1).toUpperCase(),o.slice(1),o!==c&&s.jsxs("span",{className:"text-xs",children:[" ",s.jsxs("code",{className:"mb-1 bg-white text-grey-800 dark:bg-grey-900 dark:text-white",children:["(",c,")"]})]})]})}else if(e.resource?.title||e.resource?.name||e.context?.primary_name){const o=EE(e);return o?s.jsx("a",{className:"cursor-pointer font-bold",onClick:c=>{c.preventDefault(),n(o)},children:e.resource?.title||e.resource?.name}):s.jsx(s.Fragment,{children:e.resource?.title||e.resource?.name||e.context?.primary_name})}else return s.jsx("span",{className:"text-grey-500",children:"(unknown)"})},DE=e=>{const a=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(e).reduce((o,{type:c,value:m})=>({...o,[c]:m}),{});return`${a.year}-${a.month}-${a.day} ${a.hour}:${a.minute}:${a.second}`},RE=200,OE=ye.create(({params:e})=>{const n=Zt(),{updateRoute:a}=Qe(),[o,c]=D.useState([]),[m,y]=D.useState(["label"]),{data:h,fetchNextPage:l,isFetchingNextPage:f}=jE({searchParams:{include:"actor,resource",limit:RE.toString(),filter:[o.length&&`event:-[${o.join(",")}]`,m.length&&`resource_type:-[${m.join(",")}]`,e?.user&&`actor_id:'${e.user}'`].filter(Boolean).join("+")},getNextPageParams:(v,_)=>({..._,filter:[_.filter,v.actions.length&&`created_at:<'${DE(new Date(v.actions[v.actions.length-1].created_at))}'`].join("+")}),keepPreviousData:!0}),u=D.useCallback(()=>{h?.isEnd||l()},[h?.isEnd,l]),p=(v,_,k)=>{v(M=>k?M.concat(_):M.filter(T=>T!==_))},x=o.length>0||m.length>0||e?.user;return s.jsx(yt,{afterClose:()=>{a("history")},cancelLabel:"",okLabel:"Close",scrolling:!0,size:"md",stickyFooter:!0,stickyHeader:!0,testId:"history-modal",title:"History",topRightContent:s.jsx(IE,{excludedEvents:o,excludedResources:m,toggleEventType:(v,_)=>p(c,v,!_),toggleResourceType:(v,_)=>p(y,v,!_),userId:e?.user}),onOk:()=>{n.remove(),a("history")},children:s.jsx("div",{className:"relative mt-6",children:s.jsx(cn,{hint:h?.isEnd&&h.actions.length>0?"End of history log":void 0,children:h?.actions?h.actions.length>0?s.jsxs(s.Fragment,{children:[s.jsx(m3,{offset:250,onTrigger:u}),h.actions.map(v=>!v.skip&&s.jsx(On,{avatar:s.jsx(AE,{action:v}),detail:[new Date(v.created_at).toLocaleDateString("default",{year:"numeric",month:"short",day:"2-digit"}),new Date(v.created_at).toLocaleTimeString("default",{hour:"2-digit",minute:"2-digit",second:"2-digit"})].join(" | "),title:s.jsxs("div",{className:"text-sm",children:[TE(v),Sg(v)?"":": ",!Sg(v)&&s.jsx(CE,{action:v}),v.count?s.jsxs(s.Fragment,{children:[" ",v.count," times"]}):null,s.jsxs("span",{children:[" — by ",v.actor?.name||v.actor?.slug]})]}),separator:!0})),f&&s.jsx("div",{className:"flex items-center justify-center p-5",children:s.jsx(Wi,{size:"md"})})]}):s.jsx(hh,{icon:"time-back",children:x?"No entries match your current filters.":"No history entries found."}):h===void 0?s.jsx("div",{className:"flex items-center justify-center px-5 pb-10 pt-12",children:s.jsx(Wi,{})}):s.jsx(hh,{children:"No entries found."})})})})}),$E=ye.create(()=>{const e=ye.useModal(),n=If(),a=If({searchParams:{limit:"100",permissions:"assign"}}),o=Ys(),{updateRoute:c}=Qe(),{config:m}=Je(),y=m.labs.superEditors,h=D.useRef(null),[l,f]=D.useState(""),[u,p]=D.useState(""),[x,v]=D.useState("contributor"),[_,k]=D.useState({}),{data:{users:M}={}}=w_(),{data:{invites:T}={}}=f2(),{mutateAsync:A}=d2(),C=ot();if(D.useEffect(()=>{h.current&&h.current.focus()},[]),D.useEffect(()=>{u==="saved"&&setTimeout(()=>{p("")},2e3)},[u]),D.useEffect(()=>{x!=="contributor"&&o?.isLimited("staff")?o.errorIfWouldGoOverLimit("staff").then(()=>{k(q=>({...q,role:void 0}))}).catch(q=>{if(q instanceof Gs){k(B=>({...B,role:q.message}));return}else throw q}):k(q=>({...q,role:void 0}))},[o,x]),!n.data?.roles||!a.data?.roles)return null;const O=n.data.roles,$=a.data.roles;let W="Send invitation";u==="saving"?W="Sending...":u==="saved"?W="Invite sent!":u==="error"&&(W="Retry");const R=async()=>{if(u!=="saving"){if(!Nt.isEmail(l)){k({email:"Please enter a valid email address."});return}if(M?.some(({email:q})=>q===l)){k({email:"A user with that email address already exists."});return}if(T?.some(({email:q})=>q===l)){k({email:"A user with that email address was already invited."});return}if(!_.role){p("saving");try{await A({email:l,roleId:O.find(({name:q})=>q.toLowerCase()===x.toLowerCase()).id}),p("saved"),xt({title:"Invitation sent",message:`${l}`,type:"success"}),e.remove(),c("staff?tab=invited")}catch(q){p("error");let B="Failed to send invitation",Y=s.jsxs("span",{children:["If the problem persists, ",s.jsxs("a",{href:"https://ghost.org/contact",children:[s.jsx("u",{children:"contact support"}),"."]}),"."]});q instanceof y_&&q.data?.errors?.[0]?.type==="EmailError"&&(Y=s.jsx("span",{children:"Check your Mailgun configuration."})),xt({title:B,message:Y,type:"error"}),C(q,{withToast:!1});return}}}},Z=[{hint:"Can create and edit their own posts, but cannot publish. An Editor needs to approve and publish for them.",label:"Contributor",value:"contributor"},{hint:"A trusted user who can create, edit and publish their own posts, but can’t modify others.",label:"Author",value:"author"},{hint:"Can invite and manage other Authors and Contributors, as well as edit and publish any posts on the site.",label:"Editor",value:"editor"},{hint:"Trusted staff user who should be able to manage all content and users, as well as site settings and options.",label:"Administrator",value:"administrator"}];y&&(Z[2]={hint:"Can invite and manage other Authors and Contributors, as well as edit and publish any posts on the site. Can manage members and moderate comments.",label:"Editor (beta mode)",value:"super editor"});const X=Z.filter(q=>$.some(B=>B.name===q.label||B.name==="Super Editor"&&q.label==="Editor (beta mode)"));return _.email&&(W="Retry"),s.jsx(yt,{afterClose:()=>{c("staff")},cancelLabel:"",okColor:u==="error"||_.email?"red":"black",okLabel:W,testId:"invite-user-modal",title:"Invite a new staff user",width:540,onOk:R,children:s.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[s.jsx("p",{children:"Send an invitation for a new person to create a staff account on your site, and select a role that matches what you’d like them to be able to do."}),s.jsx(Ae,{error:!!_.email,hint:_.email,inputRef:h,placeholder:"jamie@example.com",title:"Email address",value:l,onChange:q=>{f(q.target.value)},onKeyDown:()=>k(q=>({...q,email:void 0}))}),s.jsx("div",{children:s.jsx(h3,{error:!!_.role,hint:_.role,id:"role",options:X,selectedOption:x,separator:!0,title:"Role",onSelect:q=>{v(q)}})})]})})}),Ng=({items:e,setItems:n})=>{const a=x=>!!(x.label&&!x.label.match(/^\s*$/)||x.url!=="/"),o=U0({items:e.map(x=>({...x,errors:{}})),setItems:x=>n(x.map(({url:v,label:_})=>({url:v,label:_}))),blank:{url:"/",label:"",errors:{}},canAddNewItem:a}),c=new RegExp(/^(\/|#|[a-zA-Z0-9-]+:)/),m=x=>{const v={};return(!x.label||x.label.match(/^\s*$/))&&(v.label="You must specify a label"),(!x.url||x.url.match(/\s/)||!Nt.isURL(x.url,{require_protocol:!0})&&!x.url.match(c))&&(v.url="You must specify a valid URL or relative path"),v},y=(x,v)=>{const _=o.items.find(k=>k.id===x);o.updateItem(x,{..._.item,...v})},h=()=>{const x=m(o.newItem);Object.values(x).some(v=>v)?o.setNewItem({...o.newItem,errors:x}):o.addItem()},l=x=>{o.removeItem(x)},f=(x,v)=>{o.moveItem(x,v)},u="new",p=(x,v)=>{if(x===u)o.setNewItem({...o.newItem,errors:{...o.newItem.errors,[v]:void 0}});else{const _=o.items.find(k=>k.id===x).item;o.updateItem(x,{..._,errors:{..._.errors,[v]:void 0}})}};return{items:o.items.map(({item:x,id:v})=>({...x,id:v})),updateItem:y,addItem:h,removeItem:l,moveItem:f,newItem:{...o.newItem,id:u},setNewItem:x=>o.setNewItem({...o.newItem,...x}),clearError:p,validate:()=>{let x=!0;if(o.items.forEach(({item:v,id:_})=>{let k=m(v);Object.values(k).some(M=>M)&&(x=!1,o.updateItem(_,{...v,errors:k}))}),a(o.newItem)){const v=m(o.newItem);Object.values(v).some(_=>_)&&(x=!1,o.setNewItem({...o.newItem,errors:v}))}return x}}},Ag=({baseUrl:e,item:n,updateItem:a,addItem:o,clearError:c,labelPlaceholder:m,unstyled:y,textFieldClasses:h,action:l,className:f,...u})=>s.jsxs("div",{className:we("flex w-full items-start gap-3",f),"data-testid":"navigation-item-editor",...u,children:[s.jsx("div",{className:"flex flex-1 pt-1",children:s.jsx(Ae,{className:h,containerClassName:"grow",error:!!n.errors.label,hint:n.errors.label,placeholder:m,title:"Label",unstyled:y,value:n.label,hideTitle:!0,onChange:p=>a?.({label:p.target.value}),onKeyDown:p=>{a?.({label:p.target.value}),p.key==="Enter"&&(p.preventDefault(),o?.()),n.errors.label&&c?.("label")}})}),s.jsx("div",{className:"flex flex-1 pt-1",children:s.jsx(Hg,{baseUrl:e,className:h,containerClassName:"grow",error:!!n.errors.url,hint:n.errors.url,title:"URL",unstyled:y,value:n.url,hideTitle:!0,onChange:p=>a?.({url:p||""}),onKeyDown:p=>{const x=Bi(p.target.value,e,!0);a?.({url:x.save||""})},onKeyUp:p=>{if(p.key==="Enter"){p.preventDefault();const x=Bi(p.target.value,e,!0);a?.({url:x.save||""}),o?.()}n.errors.url&&c?.("url")}})}),l]}),Ig=({baseUrl:e,navigation:n})=>s.jsxs("div",{className:"w-full pt-2",children:[s.jsx(Bg,{items:n.items,itemSeparator:!1,renderItem:a=>s.jsx(Ag,{action:s.jsx(Ue,{className:"mt-1 self-center",icon:"trash",iconColorClass:"dark:text-white",size:"sm",onClick:()=>n.removeItem(a.id)}),baseUrl:e,clearError:o=>n.clearError(a.id,o),item:a,updateItem:o=>n.updateItem(a.id,o)}),onMove:n.moveItem}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ut,{colorClass:"text-grey-300 dark:text-grey-900 mt-1",name:"add",size:"sm"}),s.jsx(Ag,{action:s.jsx(Ue,{className:"mx-2 mt-1 self-center rounded bg-green p-1","data-testid":"add-button",icon:"add",iconColorClass:"text-white",size:"sm",unstyled:!0,onClick:n.addItem}),addItem:n.addItem,baseUrl:e,className:"mt-1",clearError:a=>n.clearError(n.newItem.id,a),"data-testid":"new-navigation-item",item:n.newItem,labelPlaceholder:"New item label",updateItem:n.setNewItem})]})]}),LE=ye.create(()=>{const e=Zt(),{updateRoute:n}=Qe(),{localSettings:a,updateSetting:o,saveState:c,handleSave:m,siteData:y}=ss(),[h,l]=gt(a,["navigation","secondary_navigation"]).map(v=>JSON.parse(v||"[]")),f=Ng({items:h,setItems:v=>{o("navigation",JSON.stringify(v))}}),u=Ng({items:l,setItems:v=>o("secondary_navigation",JSON.stringify(v))}),[p,x]=D.useState("primary-nav");return s.jsx(yt,{afterClose:()=>{n("navigation")},buttonsDisabled:c==="saving",cancelLabel:"Close",dirty:a.some(v=>v.dirty),okLabel:c==="saving"?"Saving...":"Save",scrolling:!0,size:"lg",stickyFooter:!0,testId:"navigation-modal",title:"Navigation",onOk:async()=>{f.validate()&&u.validate()&&(await m(),e.remove(),n("navigation"))},children:s.jsx("div",{className:"mb-1 mt-6",children:s.jsx(Dn,{selectedTab:p,tabs:[{id:"primary-nav",title:"Primary",contents:s.jsx(Ig,{baseUrl:y.url,navigation:f})},{id:"secondary-nav",title:"Secondary",contents:s.jsx(Ig,{baseUrl:y.url,navigation:u})}],onTabChange:x})})})}),PE=""+new URL("user-cover-yM4cP_Mo.jpg",import.meta.url).href,FE=""+new URL("latest-posts-1-D7-ilqhR.jpg",import.meta.url).href,UE=""+new URL("latest-posts-2-BPfbGB8B.jpg",import.meta.url).href,zE=""+new URL("latest-posts-3-D72O3dn8.jpg",import.meta.url).href,HE=({senderName:e,senderEmail:n,senderReplyTo:a,headerImage:o,headerIcon:c,headerTitle:m,headerSubtitle:y,showPostTitleSection:h,showExcerpt:l,titleAlignment:f,titleFontCategory:u,titleFontWeight:p,bodyFontCategory:x,authorPlaceholder:v,showCommentCta:_,showFeatureImage:k,showFeedback:M,showLatestPosts:T,showSubscriptionDetails:A,siteTitle:C,footerContent:O,showBadge:$,backgroundColor:W,headerBackgroundColor:R,accentColor:Z,textColor:X,secondaryTextColor:q,headerTextColor:B,secondaryHeaderTextColor:Y,postTitleColor:ae,sectionTitleColor:ee,dividerColor:re,buttonColor:Q,buttonTextColor:ne,linkColor:be,buttonCorners:je,buttonStyle:H,imageCorners:he,linkStyle:ge,dividerStyle:F})=>{const L=c||m,{config:J}=Je(),xe=new Date().toLocaleDateString("default",{year:"numeric",month:"short",day:"numeric"}),Te=new Date().getFullYear(),De=O?O.replace(/<a/g,'<a target="_blank" rel="noopener noreferrer"'):"";let Me;Qi(J)?Me=s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"leading-normal",children:[s.jsx("span",{className:"font-semibold text-grey-900",children:"From: "}),s.jsxs("span",{children:[e," (",n,")"]})]}),s.jsxs("p",{className:"leading-normal",children:[s.jsx("span",{className:"font-semibold text-grey-900",children:"Reply-to: "}),a||n]})]}):Me=s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"leading-normal",children:[s.jsx("span",{className:"font-semibold text-grey-900",children:e}),s.jsxs("span",{children:[" ",n]})]}),s.jsxs("p",{className:"leading-normal",children:[s.jsx("span",{className:"font-semibold text-grey-900",children:"To:"})," Jamie Larson jamie@example.com"]})]});let oe="mb-5 text-pretty leading-[1.7] text-black";return u==="serif"&&x==="serif"?oe=we(oe,"mb-8 font-serif text-[2.0rem] leading-tight"):u!=="serif"&&x==="serif"?oe=we(oe,"mb-8 text-[1.7rem] leading-tight tracking-tight"):u==="serif"&&x!=="serif"?oe=we(oe,"mb-8 font-serif text-[2.0rem] leading-tight"):oe=we(oe,"mb-8 text-[1.9rem] leading-tight tracking-tight"),f==="center"&&(oe=we(oe,"text-center")),s.jsx("div",{className:"relative flex grow flex-col",children:s.jsx("div",{className:"absolute inset-0 m-5 flex items-center justify-center",children:s.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:[s.jsx("div",{className:"flex-column flex min-h-[77px] justify-center rounded-t-sm border-b border-grey-200 bg-white px-6 text-sm text-grey-700",children:Me}),s.jsxs("div",{className:"overflow-y-auto text-sm",style:{backgroundColor:W},children:[s.jsxs("div",{className:"px-[7rem]",style:{backgroundColor:R},children:[o&&s.jsx("div",{children:s.jsx("img",{alt:"",className:"mb-4 block pt-6",src:o})}),L&&s.jsxs("div",{className:"py-3",children:[c&&s.jsx("img",{alt:"",className:"mx-auto mb-2 size-10",role:"presentation",src:c}),m&&s.jsx("h4",{className:"mb-1 text-center text-[1.6rem] font-bold uppercase leading-tight tracking-tight text-grey-900",style:{color:B},children:m}),y&&s.jsx("h5",{className:"mb-1 text-center text-[1.3rem] font-normal text-grey-700",style:{color:Y},children:y})]}),h&&s.jsxs("div",{className:we("flex flex-col py-8",f==="center"?"items-center":"items-start"),children:[s.jsx("h2",{className:we("text-4xl font-bold leading-supertight text-black",u==="serif"&&"font-serif",p==="normal"&&"font-normal",p==="medium"&&"font-medium",p==="semibold"&&"font-semibold",p==="bold"&&"font-bold",f==="center"?"text-center":"text-left",l?"mb-2":"mb-8"),style:{color:ae},children:"Your email newsletter"}),l&&s.jsx("p",{className:oe,style:{color:B},children:"A subtitle to highlight key points and engage your readers."}),s.jsxs("div",{className:we("flex w-full justify-between text-center text-md leading-none text-grey-700",f==="center"?"flex-col gap-1":"flex-row"),children:[s.jsxs("p",{className:"pb-1 text-[1.3rem]",style:{color:Y},children:["By ",v,s.jsx("span",{className:"before:pl-0.5 before:pr-1 before:content-['•']",children:xe})]}),s.jsx("p",{className:"pb-1 text-[1.3rem] underline",style:{color:Y},children:s.jsx("span",{children:"View in browser"})})]})]}),k&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:we("h-[unset] w-full max-w-[600px] bg-cover bg-no-repeat",h?"":"pt-6"),children:s.jsx("img",{alt:"Feature",className:we("min-h-full min-w-full shrink-0",he==="square"&&"rounded-none",he==="rounded"&&"rounded-md"),src:PE})}),s.jsx("div",{className:"mt-1 w-full max-w-[600px] pb-8 text-center text-[1.3rem] text-grey-700",style:{color:Y},children:"Feature image caption"})]})]}),s.jsxs("div",{className:we("px-[7rem]",R!=="transparent"&&"pt-10"),children:[s.jsxs("div",{className:we("max-w-[600px] border-b border-grey-200 pb-[52px] leading-[27.2px] text-black",F==="dashed"&&"border-dashed",F==="dotted"&&"border-b-2 border-dotted",x==="serif"?"font-serif text-[1.8rem]":"text-[1.7rem] tracking-tight",k||h?"":"pt-8"),style:{borderColor:re},children:[s.jsx("p",{className:"mb-6",style:{color:X},children:"This is what your content will look like when you send one of your posts as an email newsletter to your subscribers."}),s.jsx("p",{className:"mb-6",style:{color:X},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."}),s.jsx("p",{className:"mb-[52px]",style:{color:X},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."}),s.jsx("hr",{className:we("my-[52px] border-[#e0e7eb]",F==="dashed"&&"border-dashed",F==="dotted"&&"border-b-2 border-t-0 border-dotted"),style:{borderColor:re}}),s.jsx("h3",{className:we("mb-[13px] text-[2.6rem] leading-supertight",u==="serif"&&"font-serif",u==="sans_serif"&&"font-sans",p==="normal"&&"font-normal",p==="medium"&&"font-medium",p==="semibold"&&"font-semibold",p==="bold"&&"font-bold"),style:{color:ee},children:"Need inspiration?"}),s.jsxs("p",{className:"mb-[27px]",style:{color:X},children:["We've put together a ",s.jsx("a",{className:we(ge==="underline"&&"underline",ge==="bold"&&"font-bold"),href:"https://ghost.org/help/email-design/",rel:"noopener noreferrer",style:{color:be||Z},target:"_blank",children:"quick guide"})," that walks through all of the available settings, along with a few examples of what's possible."]}),s.jsx("a",{className:we("inline-block border px-[18px] py-2 font-sans text-[15px]",je==="rounded"&&"rounded-[6px]",je==="pill"&&"rounded-full",je==="square"&&"rounded-none",H==="outline"?"bg-transparent":"border-transparent text-white",ge==="bold"?"font-bold":"font-semibold"),href:"https://ghost.org/help/email-design/",rel:"noopener noreferrer",style:H==="outline"?{borderColor:Q||Z,color:Q||Z}:{backgroundColor:Q||Z,color:ne},target:"_blank",children:"Learn more"})]}),(M||_)&&s.jsx("div",{className:we("grid gap-5 border-b border-grey-200 px-6 py-5",F==="dashed"&&"border-dashed",F==="dotted"&&"border-b-2 border-dotted"),style:{borderColor:re},children:s.jsxs("div",{className:"flex justify-center gap-3",children:[M&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"pointer-events-none cursor-default whitespace-nowrap rounded-[2.2rem] bg-transparent font-semibold",type:"button",children:s.jsxs("span",{className:"inline-flex items-center gap-2 px-[18px] py-[7px]",style:{color:X},children:[s.jsx(ut,{colorClass:"",name:"thumbs-up",size:"md"}),s.jsx("span",{children:"More like this"})]})}),s.jsx("button",{className:"pointer-events-none cursor-default whitespace-nowrap rounded-[2.2rem] bg-transparent font-semibold",type:"button",children:s.jsxs("span",{className:"inline-flex items-center gap-2 px-[18px] py-[7px]",style:{color:X},children:[s.jsx(ut,{colorClass:"",name:"thumbs-down"}),s.jsx("span",{children:"Less like this"})]})})]}),_&&s.jsx("button",{className:"pointer-events-none cursor-default whitespace-nowrap rounded-[2.2rem] bg-transparent font-semibold",type:"button",children:s.jsxs("span",{className:"inline-flex items-center gap-2 px-[18px] py-[7px]",style:{color:X},children:[s.jsx(ut,{colorClass:"",name:"comment"}),s.jsx("span",{children:"Comment"})]})})]})}),T&&s.jsxs("div",{className:we("border-b border-grey-200 py-6",F==="dashed"&&"border-dashed",F==="dotted"&&"border-b-2 border-dotted"),style:{borderColor:re},children:[s.jsx("h3",{className:"mb-4 mt-2 pb-1 text-[1.2rem] font-semibold uppercase tracking-wide text-black",style:{color:X},children:"Keep reading"}),s.jsxs("div",{className:"flex justify-between gap-4 py-2",children:[s.jsxs("div",{children:[s.jsx("h4",{className:we("mt-0.5 text-[1.9rem] text-black",u==="serif"&&"font-serif",p==="normal"&&"font-normal",p==="medium"&&"font-medium",p==="semibold"&&"font-semibold",p==="bold"&&"font-bold"),style:{color:ee},children:"The three latest posts published on your site"}),s.jsx("p",{className:"m-0 text-base text-grey-700",style:{color:q},children:"Posts sent as an email only will never be shown here."})]}),s.jsx("div",{className:"aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat",children:s.jsx("img",{alt:"Latest post",className:we(he==="square"&&"rounded-none",he==="rounded"&&"rounded-md"),src:FE})})]}),s.jsxs("div",{className:"flex justify-between gap-4 py-2",children:[s.jsxs("div",{children:[s.jsx("h4",{className:we("mt-0.5 text-[1.9rem] text-black",u==="serif"&&"font-serif",p==="normal"&&"font-normal",p==="medium"&&"font-medium",p==="semibold"&&"font-semibold",p==="bold"&&"font-bold"),style:{color:ee},children:"Displayed at the bottom of each newsletter"}),s.jsx("p",{className:"m-0 text-base text-grey-700",style:{color:q},children:"Giving your readers one more place to discover your stories."})]}),s.jsx("div",{className:"aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat",children:s.jsx("img",{alt:"Latest post",className:we(he==="square"&&"rounded-none",he==="rounded"&&"rounded-md"),src:UE})})]}),s.jsxs("div",{className:"flex justify-between gap-4 py-2",children:[s.jsxs("div",{children:[s.jsx("h4",{className:we("mt-0.5 text-[1.9rem] text-black",u==="serif"&&"font-serif",p==="normal"&&"font-normal",p==="medium"&&"font-medium",p==="semibold"&&"font-semibold",p==="bold"&&"font-bold"),style:{color:ee},children:"To keep your work front and center"}),s.jsx("p",{className:"m-0 text-base text-grey-700",style:{color:q},children:"Making sure that your audience stays engaged."})]}),s.jsx("div",{className:"aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat",children:s.jsx("img",{alt:"Latest post",className:we(he==="square"&&"rounded-none",he==="rounded"&&"rounded-md"),src:zE})})]})]}),A&&s.jsxs("div",{className:we("border-b border-grey-200 py-8",F==="dashed"&&"border-dashed",F==="dotted"&&"border-b-2 border-dotted"),style:{borderColor:re},children:[s.jsx("h4",{className:"mb-3 text-[1.2rem] uppercase tracking-wide text-black",style:{color:X},children:"Subscription details"}),s.jsxs("p",{className:"m-0 mb-4 text-base",style:{color:X},children:["You are receiving this because you are a paid subscriber to ",C,". Your subscription will renew on 17 Jul 2024."]}),s.jsxs("div",{className:"flex",children:[s.jsxs("div",{className:"shrink-0 text-base",children:[s.jsx("p",{style:{color:X},children:"Name: Jamie Larson"}),s.jsx("p",{style:{color:X},children:"Email: jamie@example.com"}),s.jsx("p",{style:{color:X},children:"Member since: 17 July 2023"})]}),s.jsx("span",{className:we("w-full self-end whitespace-nowrap text-right text-base",ge==="underline"&&"underline",ge==="bold"&&"font-bold"),style:{color:be||Z},children:"Manage subscription"})]})]}),s.jsxs("div",{className:"flex flex-col items-center pt-10",children:[s.jsx("div",{dangerouslySetInnerHTML:{__html:De||""},className:"text break-words px-8 py-3 text-center text-[1.3rem] leading-base text-grey-700 [&_a]:underline",style:{color:q}}),s.jsxs("div",{className:"px-8 pb-14 pt-3 text-center text-[1.3rem] text-grey-700",children:[s.jsxs("span",{style:{color:q},children:[C," © ",Te," — "]}),s.jsx("span",{className:"pointer-events-none cursor-auto underline",style:{color:q},children:"Unsubscribe"})]}),$&&s.jsx("div",{className:"flex flex-col items-center pb-[40px] pt-[10px]",children:s.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:X},children:[s.jsx(p2,{className:"mr-[6px] size-4"}),s.jsx("span",{children:"Powered by Ghost"})]})})]})]})]})]})})})},cl=(e,n,a)=>Qi(n)&&!Vf(n)&&a?a:e.sender_email||a||"",Gf=(e,n,a,o)=>e.sender_reply_to==="newsletter"?Qi(n)?"":cl(e,n,o):e.sender_reply_to==="support"?a||o||"":e.sender_reply_to,BE=({newsletter:e})=>{const{currentUser:n,settings:a,siteData:o,config:c}=Je(),[m,y,h,l,f]=gt(a,["title","icon","comments_enabled","support_email_address","default_email_address"]);let u=null;e.show_header_title?u=m||null:e.show_header_name&&(u=e.name);const p=e.show_header_title&&e.show_header_name?e.name:void 0,x=e.show_comment_cta&&h!=="off",v=e.feedback_enabled&&c.labs.audienceFeedback,_=()=>{const B=e.background_color;return/#([0-9a-f]{3}){1,2}$/i.test(B)?B:"#ffffff"},k=()=>{const B=e.header_background_color;return!B||B==="transparent"?"transparent":/#([0-9a-f]{3}){1,2}$/i.test(B)?B:"transparent"},M=()=>{const B=e.button_color;if(/#([0-9a-f]{3}){1,2}$/i.test(B||""))return B;if(B===null){const ae=_();return Nr(ae).hex()}return o.accent_color},T=()=>{const B=e.button_style,Y=M();if(Y&&B==="fill")return Nr(Y).hex()},A=()=>{const B=e.link_color===void 0?"accent":e.link_color,Y=/#([0-9a-f]{3}){1,2}$/i;return B==="accent"?o.accent_color:Y.test(B||"")?B:Nr(_()).hex()},C=()=>{const B=e.post_title_color;if(/#([0-9a-f]{3}){1,2}$/i.test(B||""))return B;if(B==="accent")return o.accent_color;const ae=k(),ee=ae==="transparent"?_():ae;return Nr(ee).hex()},O=()=>{const B=e.section_title_color;return/#([0-9a-f]{3}){1,2}$/i.test(B||"")?B:B==="accent"?o.accent_color:Nr(_()).hex()},$=()=>{const B=e.divider_color;return/#([0-9a-f]{3}){1,2}$/i.test(B||"")?B:B==="accent"?o.accent_color:"#e0e7eb"},W=Nr(_()).hex(),R=Nr(_()).alpha(.5).toString(),Z=k()==="transparent"?W:Nr(k()).hex(),X=k()==="transparent"?R:Nr(k()).alpha(.5).toString(),q={backgroundColor:_(),headerBackgroundColor:k(),postTitleColor:C()||void 0,sectionTitleColor:O()||void 0,buttonColor:M()||void 0,buttonTextColor:T()||void 0,linkColor:A()||void 0,dividerColor:$()||void 0,textColor:W,secondaryTextColor:R,headerTextColor:Z,secondaryHeaderTextColor:X};return s.jsx(HE,{accentColor:o.accent_color,authorPlaceholder:n.name||n.email,backgroundColor:q.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:q.headerBackgroundColor||"transparent",headerIcon:e.show_header_icon?y:void 0,headerImage:e.header_image,headerSubtitle:p,headerTitle:u,imageCorners:e.image_corners||"square",linkStyle:e.link_style||"underline",senderEmail:cl(e,c,f),senderName:e.sender_name||m,senderReplyTo:Gf(e,c,l,f),showBadge:e.show_badge,showCommentCta:x,showExcerpt:e.show_excerpt,showFeatureImage:e.show_feature_image,showFeedback:v,showLatestPosts:e.show_latest_posts,showPostTitleSection:e.show_post_title_section,showSubscriptionDetails:e.show_subscription_details,siteTitle:m,titleAlignment:e.title_alignment,titleFontCategory:e.title_font_category,titleFontWeight:e.title_font_weight||"bold",...q})},WE=({newsletter:e,updateNewsletter:n,errors:a,clearError:o})=>{const{settings:c,config:m}=Je(),[y,h]=gt(c,["default_email_address","support_email_address"]),[l,f]=D.useState(Gf(e,m,h,y)||"");let u=cl(e,m,y);const p=D.useCallback(v=>{f(v.target.value),n({sender_reply_to:v.target.value||"newsletter"})},[n,f]),x=()=>{const v=Gf(e,m,h,y)||"";f(v)};return s.jsx(Ae,{error:!!a.sender_reply_to,hint:a.sender_reply_to,maxLength:191,placeholder:u||"",title:"Reply-to email",value:l,onBlur:x,onChange:p,onKeyDown:()=>o("sender_reply_to")})},qE=({newsletter:e,onlyOne:n,updateNewsletter:a,validate:o,errors:c,clearError:m})=>{const{updateRoute:y}=Qe(),{mutateAsync:h}=o0(),l=Ys(),{settings:f,config:u,siteData:p}=Je(),[x,v]=gt(f,["icon","default_email_address"]),{mutateAsync:_}=Xs(),[k,M]=D.useState("generalSettings"),{localSettings:T}=ss(),[A]=gt(T,["title"]),C=ot(),{data:{newsletters:O}={}}=a0(),$=["all","paid"].includes(dr(f,"comments_enabled")||"");let W=cl(e,u,v);const[R,Z]=D.useState(O||[]),X=R.filter(H=>H.status==="active");D.useEffect(()=>{Z(O||[])},[O]);const q=[{value:"serif",label:"Elegant serif",className:"font-serif"},{value:"sans_serif",label:"Clean sans-serif"}],B={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"}}},Y=()=>e.background_color==="light"?!1:Nr(e.background_color).hex().toLowerCase()==="#ffffff",ae=async()=>{if(e.status==="active")ye.show(Et,{title:"Archive newsletter",prompt:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:["Your newsletter ",s.jsx("strong",{children:e.name})," will no longer be visible to members or available as an option when publishing new posts."]}),s.jsx("div",{children:"Existing posts previously sent as this newsletter will remain unchanged."})]}),okLabel:"Archive",okColor:"red",onOk:async H=>{try{await h({...e,status:"archived"}),H?.remove(),xt({type:"success",message:"Newsletter archived"})}catch(he){C(he)}}});else{try{await l?.errorIfWouldGoOverLimit("newsletters")}catch(H){if(H instanceof Gs){ye.show(Xr,{prompt:H.message||"Your current plan doesn't support more newsletters.",onOk:()=>y({route:"/pro",isExternal:!0})});return}else throw H}ye.show(Et,{title:"Reactivate newsletter",prompt:s.jsxs(s.Fragment,{children:["Reactivating ",s.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 H=>{await h({...e,status:"active"}),H?.remove(),xt({type:"success",message:"Newsletter reactivated"})}})}},ee=()=>{if(!Qi(u))return s.jsx(Ae,{error:!!c.sender_email,hint:c.sender_email,placeholder:W||"",title:"Sender email address",value:e.sender_email||"",onChange:H=>a({sender_email:H.target.value}),onKeyDown:()=>m("sender_email")});if(Vf(u))return s.jsx(Ae,{error:!!c.sender_email,hint:c.sender_email,maxLength:191,placeholder:v,title:"Sender email address",value:e.sender_email||"",onChange:H=>{a({sender_email:H.target.value})},onKeyDown:()=>m("sender_email")})},re=B[e.title_font_category||"sans_serif"].options,Q=()=>{const H=e.title_font_category||"sans_serif",he=e.title_font_weight,ge=B[H].map,F=ge&&ge[he]||he;return re.find(J=>J.value===F)||re[0]},ne=H=>{const he=H?.value||"sans_serif",ge=e.title_font_weight;let F=ge;return B[he].options.find(L=>L.value===ge)||(F=B[he].map?.[ge]||"bold"),a({title_font_category:he,title_font_weight:F})},be=[{id:"generalSettings",title:"General",contents:s.jsxs(s.Fragment,{children:[s.jsxs(tt,{className:"mt-6",gap:"sm",margins:"lg",title:"Name and description",children:[s.jsx(Ae,{error:!!c.name,hint:c.name,maxLength:191,placeholder:"Weekly Roundup",title:"Name",value:e.name||"",onChange:H=>a({name:H.target.value}),onKeyDown:()=>m("name")}),s.jsx($n,{maxLength:2e3,rows:2,title:"Description",value:e.description||"",onChange:H=>a({description:H.target.value})})]}),s.jsxs(tt,{className:"mt-6",gap:"sm",margins:"lg",title:"Email info",children:[s.jsx(Ae,{maxLength:191,placeholder:A,title:"Sender name",value:e.sender_name||"",onChange:H=>a({sender_name:H.target.value})}),ee(),s.jsx(WE,{clearError:m,errors:c,newsletter:e,updateNewsletter:a,validate:o})]}),s.jsx(tt,{className:"mt-6",gap:"sm",margins:"lg",title:"Member settings",children:s.jsx(st,{checked:e.subscribe_on_signup,direction:"rtl",label:"Subscribe new members on signup",labelStyle:"value",onChange:H=>a({subscribe_on_signup:H.target.checked})})}),s.jsx("div",{className:"mb-5 mt-10",children:e.status==="active"?!n&&s.jsx(Ue,{color:"red",disabled:X.length===1,label:"Archive newsletter",link:!0,onClick:ae}):s.jsx(Ue,{color:"green",label:"Reactivate newsletter",link:!0,onClick:ae})})]})},{id:"content",title:"Content",contents:s.jsxs(s.Fragment,{children:[s.jsxs(tt,{className:"mt-6",gap:"sm",margins:"lg",title:"Header",children:[s.jsxs("div",{children:[s.jsx("div",{children:s.jsx(bt,{className:"mb-2",level:6,children:"Header image"})}),s.jsxs("div",{className:"flex-column flex gap-1",children:[s.jsx(un,{deleteButtonClassName:"!top-1 !right-1",height:e.header_image?"66px":"64px",id:"logo",imageURL:e.header_image||void 0,onDelete:()=>{a({header_image:null})},onUpload:async H=>{try{const he=on(await _({file:H}));a({header_image:he})}catch(he){C(he)}},children:s.jsx(ut,{colorClass:"text-grey-700 dark:text-grey-300",name:"picture"})}),s.jsx(Gr,{children:"1200×600 recommended. Use a transparent PNG for best results on any background."})]})]}),s.jsxs(Yi,{children:[x&&s.jsx(st,{checked:e.show_header_icon,direction:"rtl",label:"Publication icon",onChange:H=>a({show_header_icon:H.target.checked})}),s.jsx(st,{checked:e.show_header_title,direction:"rtl",label:"Publication title",onChange:H=>a({show_header_title:H.target.checked})}),s.jsx(st,{checked:e.show_header_name,direction:"rtl",label:"Newsletter name",onChange:H=>a({show_header_name:H.target.checked})})]})]}),s.jsxs(tt,{className:"mt-6",gap:"xs",margins:"lg",title:"Title section",children:[s.jsx(st,{checked:e.show_post_title_section,direction:"rtl",label:"Post title",onChange:H=>a({show_post_title_section:H.target.checked})}),e.show_post_title_section&&s.jsx(st,{checked:e.show_excerpt,direction:"rtl",label:"Post excerpt",onChange:H=>a({show_excerpt:H.target.checked})}),s.jsx(st,{checked:e.show_feature_image,direction:"rtl",label:"Feature image",onChange:H=>a({show_feature_image:H.target.checked})})]}),s.jsxs(tt,{className:"mt-6",gap:"sm",margins:"lg",title:"Footer",children:[s.jsxs(Yi,{gap:"lg",children:[s.jsx(st,{checked:e.feedback_enabled,direction:"rtl",label:"Ask your readers for feedback",onChange:H=>a({feedback_enabled:H.target.checked})}),$&&s.jsx(st,{checked:e.show_comment_cta,direction:"rtl",label:"Add a link to your comments",onChange:H=>a({show_comment_cta:H.target.checked})}),s.jsx(st,{checked:e.show_latest_posts,direction:"rtl",label:"Share your latest posts",onChange:H=>a({show_latest_posts:H.target.checked})}),s.jsx(st,{checked:e.show_subscription_details,direction:"rtl",label:"Show subscription details",onChange:H=>a({show_subscription_details:H.target.checked})})]}),s.jsx(ld,{hint:"Any extra information or legal text",nodes:"MINIMAL_NODES",placeholder:" ",title:"Email footer",value:e.footer_content||"",onChange:H=>a({footer_content:H})})]}),s.jsx(Va,{}),s.jsxs("div",{className:"my-5 flex w-full items-start",children:[s.jsx("span",{children:s.jsx(ut,{className:"mr-2 mt-[-1px]",colorClass:"text-red",name:"heart"})}),s.jsx(tt,{marginBottom:!1,children:s.jsx(st,{checked:e.show_badge,direction:"rtl",label:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx("span",{className:"text-sm md:text-base",children:"Promote independent publishing"}),s.jsx("span",{className:"text-[11px] leading-tight text-grey-700 md:text-xs md:leading-tight",children:"Show you're a part of the indie publishing movement with a small badge in the footer"})]}),labelStyle:"value",onChange:H=>a({show_badge:H.target.checked})})})]})]})},{id:"design",title:"Design",contents:s.jsxs(s.Fragment,{children:[s.jsxs(tt,{className:"mt-6",gap:"xs",margins:"lg",title:"Global",children:[s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{hex:"#ffffff",value:"light",title:"White"}],title:"Background color",value:e.background_color||"light",onChange:H=>a({background_color:H})})}),s.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[s.jsx("div",{className:"shrink-0",children:"Heading font"}),s.jsx(Lt,{containerClassName:"max-w-[200px]",options:q,selectedOption:q.find(H=>H.value===e.title_font_category),onSelect:ne})]}),s.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[s.jsx("div",{className:"shrink-0",children:"Heading weight"}),s.jsx(Lt,{containerClassName:"max-w-[200px]",options:re,selectedOption:Q(),onSelect:H=>a({title_font_weight:H?.value})})]}),s.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[s.jsx("div",{className:"shrink-0",children:"Body font"}),s.jsx(Lt,{containerClassName:"max-w-[200px]",options:q,selectedOption:q.find(H=>H.value===e.body_font_category),testId:"body-font-select",onSelect:H=>a({body_font_category:H?.value})})]})]}),s.jsxs(tt,{className:"mt-6",gap:"xs",margins:"lg",title:"Header",children:[s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:"transparent",title:"Transparent",hex:"#00000000"}],title:"Header background color",value:e.header_background_color||"transparent",onChange:H=>a({header_background_color:H})})}),s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:null,title:"Auto",hex:Y()?"#ffffff":"#000000"},{value:"accent",title:"Accent",hex:p.accent_color}],title:"Post title color",value:e.post_title_color,onChange:H=>a({post_title_color:H})})}),s.jsxs("div",{className:"flex w-full justify-between",children:[s.jsx("div",{children:"Title alignment"}),s.jsx(an,{activeKey:e.title_alignment,buttons:[{key:"left",icon:"align-left",iconSize:14,label:"Align left",tooltip:"Left",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({title_alignment:"left"}),disabled:!e.show_post_title_section},{key:"center",icon:"align-center",iconSize:14,label:"Align center",tooltip:"Center",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({title_alignment:"center"}),disabled:!e.show_post_title_section}],clearBg:!1})]})]}),s.jsxs(tt,{className:"mt-6",gap:"xs",margins:"lg",title:"Body",children:[s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:null,title:"Auto",hex:Y()?"#ffffff":"#000000"},{value:"accent",title:"Accent",hex:p.accent_color}],title:"Section title color",value:e.section_title_color,onChange:H=>a({section_title_color:H})})}),s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:"accent",title:"Accent",hex:p.accent_color},{value:null,title:"Auto",hex:Y()?"#ffffff":"#000000"}],title:"Button color",value:e.button_color,onChange:H=>a({button_color:H})})}),s.jsxs("div",{className:"flex w-full justify-between",children:[s.jsx("div",{children:"Button style"}),s.jsx(an,{activeKey:e.button_style||"fill",buttons:[{key:"fill",icon:"squircle-fill",iconSize:14,label:"Fill",tooltip:"Fill",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({button_style:"fill"})},{key:"outline",icon:"squircle",iconSize:14,label:"Outline",tooltip:"Outline",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({button_style:"outline"})}],clearBg:!1})]}),s.jsxs("div",{className:"flex w-full justify-between",children:[s.jsx("div",{children:"Button corners"}),s.jsx(an,{activeKey:e.button_corners||"rounded",buttons:[{key:"square",icon:"square",iconSize:14,label:"Square",tooltip:"Squared",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({button_corners:"square"})},{key:"rounded",icon:"squircle",iconSize:14,label:"Rounded",tooltip:"Rounded",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({button_corners:"rounded"})},{key:"pill",icon:"circle",iconSize:14,label:"Pill",tooltip:"Pill",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({button_corners:"pill"})}],clearBg:!1})]}),s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:"accent",title:"Accent",hex:p.accent_color},{value:null,title:"Auto",hex:Y()?"#ffffff":"#000000"}],title:"Link color",value:e.link_color,onChange:H=>a({link_color:H})})}),s.jsxs("div",{className:"flex w-full justify-between",children:[s.jsx("div",{children:"Link style"}),s.jsx(an,{activeKey:e.link_style||"underline",buttons:[{key:"underline",icon:"text-underline",iconSize:14,label:"Underline",tooltip:"Underline",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({link_style:"underline"})},{key:"regular",icon:"text-regular",iconSize:14,label:"Regular",tooltip:"Regular",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({link_style:"regular"})},{key:"bold",icon:"text-bold",iconSize:14,label:"Bold",tooltip:"Bold",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({link_style:"bold"})}],clearBg:!1})]}),s.jsxs("div",{className:"flex w-full justify-between",children:[s.jsx("div",{children:"Image corners"}),s.jsx(an,{activeKey:e.image_corners||"square",buttons:[{key:"square",icon:"square",iconSize:14,label:"Square",tooltip:"Squared",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({image_corners:"square"})},{key:"rounded",icon:"squircle",iconSize:14,label:"Rounded",tooltip:"Rounded",hideLabel:!0,link:!1,size:"sm",onClick:()=>a({image_corners:"rounded"})}],clearBg:!1})]}),s.jsx("div",{className:"mb-1",children:s.jsx(Yr,{direction:"rtl",eyedropper:!0,swatches:[{value:"light",title:"Light",hex:"#e0e7eb"},{value:"accent",title:"Accent",hex:p.accent_color}],title:"Divider color",value:e.divider_color||"light",onChange:H=>a({divider_color:H})})})]})]})}],je=H=>{M(H)};return s.jsx("div",{className:"flex flex-col",children:s.jsx("div",{className:"px-7 pb-7 pt-0",children:s.jsx(Dn,{selectedTab:k,stickyHeader:!0,tabs:be,onTabChange:je})})})},YE=({newsletter:e,onlyOne:n})=>{const{config:a}=Je(),{mutateAsync:o}=o0(),{updateRoute:c}=Qe(),m=ot(),{formState:y,saveState:h,updateForm:l,setFormState:f,handleSave:u,validate:p,errors:x,clearError:v,okProps:_}=kr({initialState:e,savingDelay:500,onSave:async()=>{const{meta:{sent_email_verification:[A]=[]}={}}=await o(y);let C;A&&A==="sender_email"?C=s.jsx("div",{children:"We‘ve sent a confirmation email to the new address."}):A&&A==="sender_reply_to"&&(C=s.jsx("div",{children:"We‘ve sent a confirmation email to the new address."})),C&&xt({icon:"email",message:C,type:"info"})},onSaveError:m,onValidate:()=>{const A={};return y.name||(A.name="A name is required for your newsletter"),y.sender_email&&!Nt.isEmail(y.sender_email)?A.sender_email="Enter a valid email address":y.sender_email&&Vf(a)&&y.sender_email.split("@")[1]!==oh(a)&&(A.sender_email=`Email address must end with @${oh(a)}`),y.sender_reply_to&&!Nt.isEmail(y.sender_reply_to)&&!["newsletter","support"].includes(y.sender_reply_to)&&(A.sender_reply_to="Enter a valid email address"),A}}),k=A=>{l(C=>({...C,...A}))};D.useEffect(()=>{f(()=>e)},[f,e]);const M=s.jsx(BE,{newsletter:y}),T=s.jsx(qE,{clearError:v,errors:x,newsletter:y,onlyOne:n,updateNewsletter:k,validate:p});return s.jsx(Zs,{afterClose:()=>c("newsletters"),buttonsDisabled:_.disabled,cancelLabel:"Close",deviceSelector:!1,dirty:h==="unsaved",okColor:_.color,okLabel:_.label||"Save",preview:M,previewBgColor:"grey",previewToolbar:!1,sidebar:T,sidebarPadding:!1,testId:"newsletter-modal",title:"Newsletter",onOk:async()=>{await u({fakeWhenUnchanged:!0})}})},GE=({params:e})=>{const{data:{newsletters:n,isEnd:a}={},fetchNextPage:o}=a0(),c=n?.find(({id:m})=>m===e?.id);return D.useEffect(()=>{!c&&!a&&o()},[o,a,c]),c?s.jsx(YE,{newsletter:c,onlyOne:n.length===1}):null},XE=ye.create(GE),wx=({id:e})=>{const{updateRoute:n}=Qe(),{data:{offers:a=[]}={}}=e0(e||""),[o,c]=D.useState(),[m,y]=D.useState(""),{siteData:h}=Je();D.useEffect(()=>{if(a.length>0){const k=a[0],M=`${ln(h)}${k?.code}`;y(M),c(k)}},[a,h]);const[l,f]=D.useState(!1),u=()=>{let k="";switch(o?.type){case"percent":k=o?.amount+"% discount";break;case"fixed":k=Wg(h2(o?.amount))+" "+o?.currency+" discount";break;case"trial":k=o?.amount+" days free trial";break}return`${encodeURIComponent(o?.name||"")} — Check out ${encodeURIComponent(k)} on:`},p=async()=>{await navigator.clipboard.writeText(m),f(!0),setTimeout(()=>f(!1),2e3)},x=()=>{window.open(`https://twitter.com/intent/tweet?url=${encodeURI(m)}&text=${u()}`,"_blank")},v=()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(m)}`,"_blank")},_=()=>{window.open(`http://www.linkedin.com/shareArticle?mini=true&url=${encodeURI(m)}&title=${u()}`,"_blank")};return s.jsx(yt,{afterClose:()=>{n("offers")},animate:!1,backDropClick:!1,footer:!1,height:"full",size:"lg",testId:"offer-success-modal",topRightContent:"close",width:1140,children:s.jsxs("div",{className:"-mt-6 flex h-full flex-col items-center justify-center text-center",children:[s.jsx("div",{className:"absolute left-6 top-5",children:s.jsx(fd,{activeItemClassName:"hidden md:!block md:!visible",containerClassName:"whitespace-nowrap",itemClassName:"hidden md:!block md:!visible",items:[{label:"Offers",onClick:()=>{n("offers/edit")}},{label:o?.name||""}],separatorClassName:"hidden md:!block md:!visible",backIcon:!0,onBack:()=>{n("offers/edit")}})}),s.jsx(ut,{colorClass:"text-grey-700 -mt-4",name:"tags-check",size:"xl"}),s.jsx("h1",{className:"mt-6 text-4xl",children:"Your new offer is live!"}),s.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."}),s.jsxs("div",{className:"mt-8 flex w-full max-w-md flex-col gap-8",children:[s.jsxs("div",{className:"flex flex-col-reverse gap-2",children:[s.jsx(Ae,{name:"offer-url",type:"url",value:m,disabled:!0}),s.jsx(Ue,{color:"green",label:l?"Copied!":"Copy link",fullWidth:!0,onClick:p})]}),s.jsx("div",{className:'flex items-center gap-4 text-xs 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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ue,{className:"h-8 border border-grey-300 dark:border-grey-800",icon:"twitter-x",iconColorClass:"w-[14px] h-[14px]",size:"sm",fullWidth:!0,onClick:x}),s.jsx(Ue,{className:"h-8 border border-grey-300 dark:border-grey-800",icon:"facebook",size:"sm",fullWidth:!0,onClick:v}),s.jsx(Ue,{className:"h-8 border border-grey-300 dark:border-grey-800",icon:"linkedin",size:"sm",fullWidth:!0,onClick:_})]})]})]})})},Zi=({href:e,onDestroyed:n,selectedTab:a,portalParent:o})=>{a||(a="signup");const c=D.useRef(null),[m,y]=D.useState(!1),[h,l]=D.useState(!0),f=D.useCallback(()=>{setTimeout(()=>{c.current&&l(!1)},300)},[c]);if(D.useEffect(()=>{const x=v=>{if(!e)return;new URL(v.origin).origin===new URL(e).origin&&v?.data?.type==="portal-preview-ready"&&f()};return window.addEventListener("message",x,!0),()=>{window.removeEventListener("message",x,!0),n?.()}},[e,n,f,m]),!e)return null;let u="mt-[-7%] flex h-screen items-center justify-center",p="hidden";return o==="preview"?(u="absolute z-50 mt-[-7%] flex h-screen items-center justify-center",p="invisible"):o==="offers"&&(u="absolute z-50 flex w-full h-full items-center justify-center",p="invisible"),s.jsxs(s.Fragment,{children:[h&&s.jsx("div",{className:u,children:s.jsx("span",{children:s.jsx(Wi,{})})}),s.jsx("iframe",{ref:c,className:!h&&m?"":p,"data-testid":"portal-preview",height:"100%",src:e,title:"Portal Preview",width:"100%",onLoad:()=>{y(!0)}})]})},yx=(e,n)=>{const{disableBackground:a=!1,name:o,code:c,displayTitle:m="",displayDescription:y="",type:h,cadence:l,amount:f=0,duration:u,durationInMonths:p,currency:x="usd",status:v,tierId:_}=e;n=n.replace(/\/$/,"");const k="/?v=modal-portal-offer#/portal/preview/offer",M=new URLSearchParams;return M.append("disableBackground","false"),M.append("name",encodeURIComponent(o)),M.append("code",encodeURIComponent(c)),M.append("display_title",encodeURIComponent(m)),M.append("display_description",encodeURIComponent(y)),M.append("type",encodeURIComponent(h)),M.append("cadence",encodeURIComponent(l)),M.append("amount",encodeURIComponent(f)),M.append("duration",encodeURIComponent(u)),M.append("duration_in_months",encodeURIComponent(p)),M.append("currency",encodeURIComponent(x)),M.append("status",encodeURIComponent(v)),M.append("tier_id",encodeURIComponent(_)),a&&M.append("disableBackground","true"),`${n}${k}?${M.toString()}`},KE=e=>{const n=[];return e.forEach(a=>{n.push({label:`${a.name} - Monthly`,value:`${a.id}-month-${a.currency}`}),n.push({label:`${a.name} - Yearly`,value:`${a.id}-year-${a.currency}`})}),n};function ZE(e){return e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-")}const Cg=({type:e,checked:n,onClick:a})=>{const o=n?"bg-black text-white dark:bg-white dark:text-black":"border border-grey-300 dark:border-grey-800";return s.jsx("button",{className:"text-left",type:"button",onClick:a,children:s.jsxs("div",{className:"flex gap-3",children:[s.jsx("div",{className:`mt-0.5 flex size-4 items-center justify-center rounded-full ${o}`,children:n?s.jsx(ut,{className:"w-[7px] stroke-[4]",name:"check",size:"custom"}):null}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{children:e.title}),s.jsx("span",{className:"text-sm",children:e.description})]})]})})},Dg=e=>{const{fixedAmount:n=0,percentAmount:a=0,trialAmount:o=0,amount:c=0}=e;switch(e.type){case"fixed":return n*100;case"percent":return a;case"trial":return o;default:return c}},VE=({tierOptions:e,handleTierChange:n,selectedTier:a,typeOptions:o,durationOptions:c,handleTypeChange:m,handleDurationChange:y,overrides:h,handleAmountTypeChange:l,handleNameInput:f,handleTextAreaInput:u,handleDisplayTitleInput:p,handleDurationInMonthsInput:x,handleAmountInput:v,handleCodeInput:_,clearError:k,errors:M,testId:T,handleTrialAmountInput:A,amountOptions:C})=>{const $=a?.label?.includes("Yearly")?c.filter(re=>re.value!=="repeating"):c,[W,R]=D.useState(0),Z=W>40?"text-red":"text-green",{siteData:X}=Je(),[q,B]=D.useState(!1),Y=ln(X),ae=`${Y}${h.code.value}`,ee=async()=>{await navigator.clipboard.writeText(ae),B(!0),setTimeout(()=>B(!1),2e3)};return s.jsx("div",{className:"pt-7","data-testId":T,children:s.jsxs(tt,{children:[s.jsxs("section",{children:[s.jsx("h2",{className:"mb-4 text-lg",children:"General"}),s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(Ae,{error:!!M.name,hint:M.name||s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{children:"Visible to members on Stripe Checkout page"}),s.jsxs("strong",{children:[s.jsx("span",{className:`${Z}`,children:W})," / 40"]})]}),maxLength:40,placeholder:"Black Friday",title:"Offer name",onChange:re=>{f(re),R(re.target.value.length)},onKeyDown:()=>k("name")}),s.jsx(Ae,{error:!!M.displayTitle,hint:M.displayTitle,placeholder:"Black Friday Special",title:"Display title",value:h.displayTitle.value,onChange:re=>{p(re)},onKeyDown:()=>k("displayTitle")}),s.jsx($n,{placeholder:"Take advantage of this limited-time offer.",title:"Display description",value:h.displayDescription,onChange:re=>{u(re)}})]})]}),s.jsxs("section",{className:"mt-4",children:[s.jsx("h2",{className:"mb-4 text-lg",children:"Details"}),s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-col gap-4 rounded-md border border-grey-200 p-4 dark:border-grey-800",children:[s.jsx(Cg,{checked:h.type!=="trial",type:o[0],onClick:()=>{m("percent")}}),s.jsx(Cg,{checked:h.type==="trial",type:o[1],onClick:()=>{m("trial")}})]}),s.jsx(Lt,{options:e,selectedOption:a,testId:"tier-cadence-select-offers",title:"Tier — Cadence",onSelect:re=>{re&&n(re)}}),h.type!=="trial"&&s.jsxs(s.Fragment,{children:[" ",s.jsxs("div",{className:"relative",children:[s.jsx(Ae,{error:!!M.amount,hint:M.amount,title:"Amount off",type:"number",value:h.type==="fixed"?h.fixedAmount===0?"":h.fixedAmount?.toString():h.percentAmount===0?"":h.percentAmount?.toString(),onChange:re=>{v(re)},onKeyDown:()=>k("amount")}),s.jsx("div",{className:"absolute right-1.5 top-6 z-10",children:s.jsx(Lt,{clearBg:!0,controlClasses:{menu:"w-20 right-0"},options:C,selectedOption:h.type==="percent"?C[0]:C[1],testId:"amount-type-select-offers",onSelect:re=>{l(re?.value||"")}})})]}),s.jsx(Lt,{options:$,selectedOption:$.find(re=>re.value===h.duration),testId:"duration-select-offers",title:"Duration",onSelect:re=>y(re?.value||"")}),h.duration==="repeating"&&s.jsx(Ae,{title:"Duration in months",type:"number",onChange:re=>{x(re)}})]}),h.type==="trial"&&s.jsx(Ae,{error:!!M.amount,hint:M.amount,title:"Trial duration",type:"number",value:h.trialAmount?.toString(),onChange:re=>{A(re)},onKeyDown:()=>k("amount")}),s.jsx(Ae,{error:!!M.code,hint:M.code||(h.code.value!==""?s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[Y,s.jsx("span",{className:"font-bold",children:h.code.value})]}),s.jsx("span",{}),s.jsx(Ue,{className:"text-xs",color:"green",label:`${q?"Copied":"Copy"}`,size:"sm",link:!0,onClick:ee})]}):null),placeholder:"black-friday",title:"Offer code",value:h.code.value,onChange:re=>{_(re)},onKeyDown:()=>k("code")})]})]})]})})},Qn=e=>{const[n,a,o]=e.split("-");if(!n||!a||!o)throw new Error("Invalid input format. Expected format is: id-period-currency");return{id:n,period:a,currency:o}},QE=()=>{const{siteData:e}=Je(),n=[{title:"Discount",description:"Offer a special reduced price",value:"percent"},{title:"Free trial",description:"Give free access for a limited time",value:"trial"}],a=[{value:"once",label:"First-payment"},{value:"repeating",label:"Multiple-months"},{value:"forever",label:"Forever"}],[o,c]=D.useState(""),{updateRoute:m}=Qe(),{data:{tiers:y}={}}=so(),h=od(y||[]),l=KE(h),{mutateAsync:f}=m2(),[u,p]=D.useState({tier:l[0]||{},dataset:{id:l[0]?.value?Qn(l[0]?.value).id:"",period:l[0]?.value?Qn(l[0]?.value).period:"",currency:l[0]?.value?Qn(l[0]?.value).currency:""}}),{data:{offers:x=[]}={}}=g2(),{formState:v,updateForm:_,handleSave:k,saveState:M,okProps:T,validate:A,errors:C,clearError:O}=kr({initialState:{disableBackground:!1,name:"",code:{isDirty:!1,value:""},displayTitle:{isDirty:!1,value:""},displayDescription:"",type:"percent",cadence:u?.dataset?.period||"",amount:0,duration:"once",durationInMonths:0,currency:u?.dataset?.currency||"USD",status:"active",tierId:u?.dataset?.id||"",trialAmount:7,fixedAmount:0,percentAmount:0},onSave:async()=>{const he={name:v.name,code:v.code.value,display_title:v.displayTitle.value,display_description:v.displayDescription,cadence:v.cadence,amount:Dg(v)||0,duration:v.type==="trial"?"trial":v.duration,duration_in_months:Number(v.durationInMonths),currency:v.currency,status:v.status,redemption_type:"signup",tier:{id:v.tierId},type:v.type,currency_restriction:!1},ge=await f(he);ge&&ge.offers&&ge.offers.length>0&&m(`offers/success/${ge.offers[0].id}`)},onSaveError:()=>{},onValidate:()=>{const he={};return!v.name&&v.name.length===0&&(he.name="Name is required"),!v.code.value&&v.code.value.length===0&&(he.code="Code is required"),!v.displayTitle.value&&v.displayTitle.value.length===0&&(he.displayTitle="Display title is required"),v.type==="percent"&&v.percentAmount===0&&(he.amount="Enter an amount greater than 0."),v.type==="percent"&&(v.percentAmount<0||v.percentAmount>100)&&(he.amount="Amount must be between 0 and 100%."),(v.type==="fixed"&&v.fixedAmount===0||v.type==="fixed"&&v.fixedAmount<1)&&(he.amount="Enter an amount greater than 0."),v.type==="trial"&&v.trialAmount===0&&(he.amount="Enter an amount greater than 0."),v.type==="trial"&&v.trialAmount<1&&(he.amount="Free trial must be at least 1 day."),he},savingDelay:500}),$=[{value:"percent",label:"%"},{value:"fixed",label:v.currency}],W=he=>{p({tier:he,dataset:Qn(he.value)}),_(ge=>({...ge,cadence:Qn(he.value).period,currency:Qn(he.value).currency,tierId:Qn(he.value).id}))},R=he=>{_(ge=>({...ge,type:he}))},Z=he=>{_(ge=>({...ge,type:he==="percent"?"percent":"fixed"}))},X=he=>{const ge=he.target;v.type==="fixed"?_(F=>({...F,fixedAmount:Number(ge.value)})):v.type==="percent"?_(F=>({...F,percentAmount:Number(ge.value)})):_(F=>({...F,amount:Number(ge.value)}))},q=he=>{const ge=he.target;_(F=>({...F,durationInMonths:Number(ge.value)}))},B=he=>{const ge=he.target.value;_(F=>{let L={...F};return L.name=ge,F.code.isDirty||(O("code"),L.code={...F.code,value:ZE(ge)}),F.displayTitle.isDirty||(O("displayTitle"),L.displayTitle={...F.displayTitle,value:ge}),L})},Y=he=>{const ge=he.target;_(F=>({...F,displayTitle:{...F.displayTitle,isDirty:!0,value:ge.value}}))},ae=he=>{const ge=he.target;_(F=>({...F,displayDescription:ge.value}))},ee=he=>{const ge=he.target;_(F=>({...F,trialAmount:Number(ge.value)}))},re=he=>{_(ge=>({...ge,duration:he}))},Q=he=>{const ge=he.target;_(F=>({...F,code:{...F.code,isDirty:!0,value:ge.value}}))},ne=()=>{x.length>0?m("offers/edit"):m("offers")},be=D.useMemo(()=>({name:v.name||"",code:v.code.value||"",displayTitle:v.displayTitle.value||"",displayDescription:v.displayDescription||"",type:v.type||"percent",cadence:v.cadence||"month",amount:Dg(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||h[0]?.id}),[v,h]);D.useEffect(()=>{const he=yx(be,e.url);c(he)},[v,e.url,v.type,be]);const je=s.jsx(VE,{amountOptions:$,clearError:O,durationOptions:a,errors:C,handleAmountInput:X,handleAmountTypeChange:Z,handleCodeInput:Q,handleDisplayTitleInput:Y,handleDurationChange:re,handleDurationInMonthsInput:q,handleNameInput:B,handleTextAreaInput:ae,handleTierChange:W,handleTrialAmountInput:ee,handleTypeChange:R,overrides:v,selectedTier:u.tier,testId:"add-offer-sidebar",tierOptions:l,typeOptions:n,validate:A}),H=s.jsx(Zi,{href:o||"",portalParent:"offers"});return s.jsx(Zs,{afterClose:()=>{m("offers")},backDropClick:!1,cancelLabel:"Close",deviceSelector:!1,dirty:M==="unsaved",height:"full",okColor:T.color,okLabel:"Publish",preview:H,previewToolbar:!1,sidebar:je,size:"lg",testId:"add-offer-modal",title:"Offer",width:1140,onCancel:ne,onOk:async()=>{if(A(),!Object.values(C).every(ge=>!ge)){Za.remove(),xt({title:"Can't save offer",type:"info",message:"Make sure you filled all required fields"});return}try{if(await k({force:!0}))return}catch(ge){let F;ge instanceof ts&&ge.data&&ge.data.errors[0]&&(F=ge.data.errors[0].context||ge.data.errors[0].message),Za.remove(),F&&xt({title:"Can't save offer",type:"error",message:F||"Please try again later"})}}})};function Rg(e){return new Date(e).toLocaleDateString("default",{year:"numeric",month:"short",day:"2-digit"})}const JE=({clearError:e,errors:n,offer:a,updateOffer:o})=>{const{siteData:c}=Je(),[m,y]=D.useState(!1),h=ot(),{mutateAsync:l}=t0(),[f,u]=D.useState(a?.name.length||0),p=f>40?"text-red":"text-green",{updateRoute:x}=Qe();D.useEffect(()=>{a?.name&&u(a?.name.length)},[a?.name]);const v=ln(c),_=`${v}${a?.code}`,k=async()=>{await navigator.clipboard.writeText(_),y(!0),setTimeout(()=>y(!1),2e3)},M=async()=>{a?.status==="active"?ye.show(Et,{title:"Archive offer",prompt:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"New members will no longer be able to subscribe using this offer."}),s.jsxs("p",{children:["All members that previously redeemed ",s.jsx("strong",{children:a?.name})," will remain unchanged."]})]}),okLabel:"Archive",okColor:"red",onOk:async T=>{try{await l({...a,status:"archived"}),T?.remove(),xt({type:"success",title:"Offer archived"}),x("offers/edit")}catch(A){h(A)}}}):ye.show(Et,{title:"Reactivate offer",prompt:s.jsx(s.Fragment,{children:s.jsxs("p",{children:["Reactivating ",s.jsx("strong",{children:a?.name})," will allow new members to subscribe using this offer. Existing members will remain unchanged."]})}),okLabel:"Reactivate",onOk:async T=>{try{await l({...a,status:"active"}),T?.remove(),xt({type:"success",title:"Offer reactivated"}),x("offers/edit")}catch(A){h(A)}}})};return s.jsxs("div",{className:"flex grow flex-col pt-2",children:[s.jsxs(tt,{className:" grow",children:[s.jsx("section",{children:s.jsxs("div",{className:"flex flex-col gap-5 rounded-md border border-grey-300 p-4 pb-3.5 dark:border-grey-800",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-semibold leading-none text-grey-700",children:"Created on"}),s.jsx("span",{children:Rg(a?.created_at?a.created_at:"")})]}),s.jsxs("div",{className:"flex items-end justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-semibold leading-none text-grey-700",children:"Performance"}),s.jsxs("span",{children:[a?.redemption_count," ",a?.redemption_count===1?"redemption":"redemptions"]})]}),a?.redemption_count>0&&a?.last_redeemed?s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-semibold leading-none text-grey-700",children:"Last redemption"}),s.jsx("span",{children:Rg(a?.last_redeemed)})]}):null]}),a?.redemption_count>0?s.jsx("a",{className:"font-semibold text-green",href:x2(a?.id),children:"See members →"}):null]})]})}),s.jsxs("section",{className:"mt-4",children:[s.jsx("h2",{className:"mb-4 text-lg",children:"General"}),s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(Ae,{error:!!n.name,hint:n.name||s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{children:"Visible to members on Stripe Checkout page"}),s.jsxs("strong",{children:[s.jsx("span",{className:`${p}`,children:f})," / 40"]})]}),maxLength:40,placeholder:"Black Friday",title:"Offer name",value:a?.name,onChange:T=>{u(T.target.value.length),o({name:T.target.value})},onKeyDown:()=>e("name")}),s.jsx(Ae,{error:!!n.displayTitle,hint:n.displayTitle,placeholder:"Black Friday Special",title:"Display title",value:a?.display_title,onChange:T=>o({display_title:T.target.value}),onKeyDown:()=>e("displayTitle")}),s.jsx($n,{placeholder:"Take advantage of this limited-time offer.",title:"Display description",value:a?.display_description,onChange:T=>o({display_description:T.target.value})}),s.jsx(Ae,{error:!!n.code,hint:n.code||(a?.code!==""?s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[v,s.jsx("span",{className:"font-bold",children:a?.code})]}),s.jsx("span",{}),s.jsx(Ue,{className:"text-xs",color:"green",label:`${m?"Copied":"Copy"}`,size:"sm",link:!0,onClick:k})]}):null),placeholder:"black-friday",title:"Offer code",value:a?.code,onChange:T=>o({code:T.target.value}),onKeyDown:()=>e("code")})]})]})]}),s.jsx("div",{className:"mb-2",children:a?.status==="active"?s.jsx(Ue,{color:"red",label:"Archive offer",link:!0,onClick:M}):s.jsx(Ue,{color:"green",label:"Reactivate offer",link:!0,onClick:M})})]})},e4=({id:e})=>{const{siteData:n}=Je(),{updateRoute:a}=Qe(),o=ot(),{mutateAsync:c}=t0(),[m,y]=D.useState(""),{data:{offers:h=[]}={}}=e0(e||""),{formState:l,saveState:f,updateForm:u,setFormState:p,handleSave:x,validate:v,errors:_,clearError:k,okProps:M}=kr({initialState:h[0],savingDelay:500,onSave:async()=>{await c(l)},onSaveError:o,onValidate:()=>{const O={};return l?.name||(O.name="Name is required"),l?.display_title||(O.displayTitle="Display title is required"),l?.code||(O.code="Please enter a code"),O}});D.useEffect(()=>{p(()=>h[0])},[p,h]);const T=O=>{u($=>({...$,...O}))},A=s.jsx(JE,{clearError:k,errors:_,offer:l,updateOffer:T,validate:v});D.useEffect(()=>{const O={name:l?.name||"",code:l?.code||"",displayTitle:l?.display_title||"",displayDescription:l?.display_description||"",type:l?.type||"",cadence:l?.cadence||"",amount:l?.amount,duration:l?.duration||"",durationInMonths:l?.duration_in_months||0,currency:l?.currency||"",status:l?.status||"",tierId:l?.tier?.id||""},$=yx(O,n.url);y($)},[l,n]);const C=s.jsx(Zi,{href:m||"",portalParent:"offers"});return h?s.jsx(Zs,{afterClose:()=>{a("offers")},backDropClick:!1,cancelLabel:"Close",deviceSelector:!1,dirty:f==="unsaved",height:"full",okColor:M.color,okLabel:M.label||"Save",preview:C,previewToolbar:!1,sidebar:A,size:"lg",testId:"offer-update-modal",title:"Offer",width:1140,onCancel:()=>{sessionStorage.getItem("editOfferPageSource")==="offers"?(sessionStorage.removeItem("editOfferPageSource"),a("offers")):(sessionStorage.removeItem("editOfferPageSource"),a("offers/edit"))},onOk:async()=>{try{if(await x({force:!0}))return}catch(O){let $;O instanceof ts&&O.data&&O.data.errors[0]&&($=O.data.errors[0].context||O.data.errors[0].message),Za.remove(),$&&xt({title:"Can't save offer",type:"error",message:"Please try again later"})}}}):null},t4=({route:e})=>{if(e==="offers/new")return s.jsx(QE,{});if(e.startsWith("offers/edit/")&&e.length>12){const n=e.split("/").pop();return s.jsx(e4,{id:n||""})}else if(e.startsWith("offers/success/")&&e.length>15){const n=e.split("/").pop();return s.jsx(wx,{id:n||""})}else if(e==="offers/edit")return s.jsx(b2,{})},r4=()=>{const{route:e}=Qe();return s.jsx(t4,{route:e})},n4=ye.create(r4),s4=""+new URL("pintura-screenshot-1gRQGS4m.png",import.meta.url).href,a4=ns({method:"POST",path:()=>"/files/upload/",body:({file:e})=>{const n=new FormData;return n.append("file",e),n}}),o4=ye.create(()=>{const{updateRoute:e}=Qe(),[n,a]=D.useState({js:!1,css:!1}),{settings:o,config:c}=Je(),[m]=gt(o,["pintura"]),{mutateAsync:y}=Rn(),{mutateAsync:h}=a4(),l=ot();D.useEffect(()=>{x(m||!1)},[m]);const[f,u]=D.useState("Save"),[p,x]=D.useState(!!m),v=async()=>{const C=[{key:"pintura",value:p}];try{u("Saving..."),await Promise.all([y(C),new Promise(O=>{setTimeout(O,1e3)})]),u("Saved")}catch(O){l(O)}finally{setTimeout(()=>u("Save"),1e3)}},_=D.useRef(null),k=D.useRef(null),M=C=>{C==="js"&&_.current?.click(),C==="css"&&k.current?.click()},T=async(C,O)=>{try{a(X=>({...X,[O]:!0}));const $=C.target?.files?.[0];if(!$)return;const{files:W}=await h({file:$}),R=W[0].url,Z=[{key:`pintura_${O}_url`,value:R}];await y(Z),a(X=>({...X,[O]:!1})),xt({type:"success",title:`Pintura ${O} uploaded`})}catch($){a({js:!1,css:!1}),l($)}},A=p!==m;return s.jsxs(yt,{afterClose:()=>{e("integrations")},cancelLabel:"Close",dirty:A,okColor:f==="Saved"?"green":"black",okLabel:f,testId:"pintura-modal",title:"",onOk:v,children:[s.jsx(Qs,{detail:"Advanced image editing",icon:s.jsx(ut,{name:"pintura",size:48}),title:"Pintura"}),s.jsxs("div",{className:"mt-7",children:[!c.pintura&&s.jsxs("div",{className:"mb-7 flex flex-col items-stretch justify-between gap-4 rounded-sm bg-grey-75 p-4 md:flex-row md:p-7 dark:bg-grey-950",children:[s.jsxs("div",{className:"md:basis-1/2",children:[s.jsx("p",{className:"mb-4 font-bold",children:"Add advanced image editing to Ghost, with Pintura"}),s.jsx("p",{className:"mb-4 text-sm",children:"Pintura is a powerful JavaScript image editor that allows you to crop, rotate, annotate and modify images directly inside Ghost."}),s.jsx("p",{className:"text-sm",children:"Try a demo, purchase a license, and download the required CSS/JS files from pqina.nl/pintura/ to activate this feature."})]}),s.jsxs("div",{className:"flex grow flex-col items-end justify-between gap-2 md:basis-1/2 md:gap-0",children:[s.jsx("img",{alt:"Pintura screenshot",src:s4}),s.jsx("a",{className:"-mb-1 text-sm font-bold text-green",href:"https://pqina.nl/pintura/ghost/?ref=ghost.org",rel:"noopener noreferrer",target:"_blank",children:"Find out more →"})]})]}),s.jsxs(tt,{marginBottom:!1,title:"Pintura configuration",grouped:!0,children:[s.jsx(st,{checked:p,direction:"rtl",hint:s.jsxs(s.Fragment,{children:["Enable ",s.jsx("a",{className:"text-green",href:"https://pqina.nl/pintura/ghost/?ref=ghost.org",rel:"noopener noreferrer",target:"_blank",children:"Pintura"})," for editing your images in Ghost"]}),label:"Enable Pintura",onChange:C=>{x(C.target.checked)}}),p&&!c.pintura&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col justify-between gap-1 md:flex-row md:items-center",children:[s.jsxs("div",{children:[s.jsx("div",{children:"Upload Pintura script"}),s.jsxs("div",{className:"text-xs text-grey-600",children:["Upload the ",s.jsx("code",{children:"pintura-umd.js"})," file from the Pintura package"]})]}),s.jsx("input",{ref:_,accept:".js",type:"file",hidden:!0,onChange:async C=>{await T(C,"js")}}),s.jsx(Ue,{color:"outline",disabled:n.js,label:"Upload",onClick:()=>{M("js")}})]}),s.jsxs("div",{className:"flex flex-col justify-between gap-1 md:flex-row md:items-center",children:[s.jsxs("div",{children:[s.jsx("div",{children:"Upload Pintura styles"}),s.jsxs("div",{className:"text-xs text-grey-600",children:["Upload the ",s.jsx("code",{children:"pintura.css"})," file from the Pintura package"]})]}),s.jsx("input",{ref:k,accept:".css",type:"file",hidden:!0,onChange:async C=>{await T(C,"css")}}),s.jsx(Ue,{color:"outline",disabled:n.css,label:"Upload",onClick:()=>{M("css")}})]})]})]})]})]})}),i4=({updateSetting:e,errors:n,setError:a})=>{const{siteData:o,settings:c,config:m}=Je(),[y,h]=gt(c,["members_support_address","support_email_address"]),l=h?.toString()||Nf(y?.toString()||"",o,m),f=__(o,m),[u,p]=D.useState(l),x=v=>{let _=v.target.value;_?Nt.isEmail(_)?a("members_support_address",""):a("members_support_address","Enter a valid email address"):a("members_support_address","Enter an email address");let k=f&&_===`noreply@${f}`?"noreply":_;e("members_support_address",k),p(Nf(k,o,m))};return D.useEffect(()=>{p(l)},[l]),s.jsx("div",{className:"mt-7",children:s.jsx(tt,{children:s.jsx(Ae,{error:!!n.members_support_address,hint:n.members_support_address,title:"Support email address",value:u,onBlur:x,onChange:v=>p(v.target.value)})})})},Tf=[{icon:"portal-icon-1",value:"icon-1"},{icon:"portal-icon-2",value:"icon-2"},{icon:"portal-icon-3",value:"icon-3"},{icon:"portal-icon-4",value:"icon-4"},{icon:"portal-icon-5",value:"icon-5"}],l4=({localSettings:e,updateSetting:n})=>{const{mutateAsync:a}=Xs(),o=ot(),[c,m,y,h]=gt(e,["portal_button","portal_button_style","portal_button_icon","portal_button_signup_text"]),l=y||Tf[0].value,f=Tf.map(({value:k})=>k).includes(l),[u,p]=D.useState(f?void 0:l),x=async k=>{try{const M=on(await a({file:k}));n("portal_button_icon",M),p(M)}catch(M){const T=M;T.response.status===415&&(T.message="Unsupported file type"),o(T)}},v=()=>{n("portal_button_icon",null),p(void 0)},_=[{value:"icon-and-text",label:"Icon and text"},{value:"icon-only",label:"Icon only"},{value:"text-only",label:"Text only"}];return s.jsx("div",{className:"mt-7",children:s.jsxs(tt,{children:[s.jsx(st,{checked:!!c,direction:"rtl",label:"Show portal button",onChange:k=>n("portal_button",k.target.checked)}),c&&s.jsxs(s.Fragment,{children:[s.jsx(Lt,{options:_,selectedOption:_.find(k=>k.value===m),title:"Button style",onSelect:k=>n("portal_button_style",k?.value||null)}),m?.toString()?.includes("icon")&&s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(bt,{level:6,grey:!0,children:"Icon"}),s.jsxs("div",{className:"flex justify-between",children:[Tf.map(k=>s.jsx("button",{className:we("border p-3",l===k.value?"border-green":"border-transparent"),type:"button",onClick:()=>n("portal_button_icon",k.value),children:s.jsx(ut,{className:`size-5 ${l===k.value?"text-green":"text-black opacity-70 transition-all hover:opacity-100 dark:text-white"}`,name:k.icon})},k.value)),s.jsx("div",{className:we("relative w-[46px] border",l===u?"border-green":"border-transparent"),children:s.jsx(un,{deleteButtonClassName:"invisible absolute -right-2 -top-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-full bg-[rgba(0,0,0,0.75)] text-white hover:bg-black group-hover:!visible",deleteButtonContent:s.jsx(ut,{colorClass:"text-white",name:"trash",size:"sm"}),height:"46px",id:"test",imageClassName:"cursor-pointer",imageURL:u,width:"46px",deleteButtonUnstyled:!0,onDelete:v,onImageClick:()=>u&&n("portal_button_icon",u),onUpload:x,children:s.jsx(ut,{className:"dark:text-white",name:"upload",size:"md"})})})]})]}),m?.toString()?.includes("text")&&s.jsx(Ae,{title:"Signup button text",value:h,onChange:k=>n("portal_button_signup_text",k.target.value)})]})]})})},Lr=({name:e,value:n})=>{const a=D.useId();return s.jsx(On,{action:s.jsx(Ue,{color:"black",label:"Copy",link:!0,onClick:o=>{navigator.clipboard.writeText(n);const c=o?.target;c.innerText="Copied",setTimeout(()=>{c.innerText="Copy"},1e3)}}),separator:!0,children:s.jsxs("div",{className:"flex w-full grow flex-col py-3 lg:flex-row lg:items-center lg:gap-5",children:[s.jsxs("label",{className:"inline-block whitespace-nowrap lg:w-[180px] lg:min-w-[180px]",htmlFor:a,children:[e,":"]}),s.jsx(Ae,{className:"border-b-500 grow bg-transparent py-1 text-grey-700 lg:p-1",id:a,value:n,disabled:!0,unstyled:!0})]})})},c4=()=>{const[e,n]=D.useState(!1),[a,o]=D.useState(""),{siteData:c}=Je(),{data:{tiers:m}={}}=so(),y=od(m||[]),h=()=>{n(!e)};D.useEffect(()=>{y?.length&&!a&&o(y[0].id)},[y,a]);const l=y?.map(u=>({label:u.name,value:u.id})),f=ln(c);return s.jsxs(ud,{className:"max-w-[920px] text-base text-black dark:text-white",heading:"Links",children:[s.jsxs("p",{className:"-mt-6 mb-16",children:["Use these ",e?"data attributes":"links"," in your theme to show pages of Portal."]}),s.jsxs(cn,{actions:s.jsx(Ue,{color:"green",label:e?"Links":"Data attributes",link:!0,onClick:h}),title:"Generic",titleSize:"lg",children:[s.jsx(Lr,{name:"Default",value:e?"data-portal":`${f}#/portal`}),s.jsx(Lr,{name:"Sign in",value:e?'data-portal="signin"':`${f}#/portal/signin`}),s.jsx(Lr,{name:"Sign up",value:e?'data-portal="signup"':`${f}#/portal/signup`})]}),s.jsxs(cn,{className:"mt-14",title:"Tiers",titleSize:"lg",children:[s.jsx(On,{hideActions:!0,separator:!0,children:s.jsxs("div",{className:"flex w-full items-center gap-2 py-2",children:[s.jsx("span",{className:"inline-block w-[180px] min-w-[180px] shrink-0",children:"Tier:"}),s.jsx(Lt,{options:l,selectedOption:l.find(u=>u.value===a),onSelect:u=>{u&&o(u?.value)}})]})}),s.jsx(Lr,{name:"Signup / Monthly",value:e?`data-portal="signup/${a}/monthly"`:`${f}#/portal/signup/${a}/monthly`}),s.jsx(Lr,{name:"Signup / Yearly",value:e?`data-portal="signup/${a}/yearly"`:`${f}#/portal/signup/${a}/yearly`}),s.jsx(Lr,{name:"Signup / Free",value:e?'data-portal="signup/free"':`${f}#/portal/signup/free`})]}),s.jsxs(cn,{className:"mt-14",title:"Account",titleSize:"lg",children:[s.jsx(Lr,{name:"Account",value:e?'data-portal="account"':`${f}#/portal/account`}),s.jsx(Lr,{name:"Account / Plans",value:e?'data-portal="account/plans"':`${f}#/portal/account/plans`}),s.jsx(Lr,{name:"Account / Profile",value:e?'data-portal="account/profile"':`${f}#/portal/account/profile`}),s.jsx(Lr,{name:"Account / Newsletters",value:e?'data-portal="account/newsletters"':`${f}#/portal/account/newsletters`}),s.jsx(Lr,{name:"Account / Newsletter help",value:e?'data-portal="account/newsletters/help"':`${f}#/portal/account/newsletters/help`})]})]})},u4=({settings:e,config:n,tiers:a,siteData:o,selectedTab:c})=>{if(!o?.url)return null;let m=a.filter(v=>v.visibility==="public"&&v.type==="paid").map(v=>v.id);const y=o.url.replace(/\/$/,""),h="/?v=modal-portal-settings#/portal/preview",l=JSON.parse(dr(e,"portal_plans")||""),f=new URLSearchParams;f.append("button",dr(e,"portal_button")?"true":"false"),f.append("name",dr(e,"portal_name")?"true":"false"),f.append("isFree",l.includes("free")?"true":"false"),f.append("isMonthly",Ws(e,n)&&l.includes("monthly")?"true":"false"),f.append("isYearly",Ws(e,n)&&l.includes("yearly")?"true":"false"),f.append("page",c==="account"?"accountHome":"signup"),f.append("buttonIcon",encodeURIComponent(dr(e,"portal_button_icon")||"icon-1")),f.append("signupButtonText",encodeURIComponent(dr(e,"portal_button_signup_text")||"")),f.append("membersSignupAccess",dr(e,"members_signup_access")||"all"),f.append("allowSelfSignup",dr(e,"allow_self_signup")||"false"),f.append("signupTermsHtml",dr(e,"portal_signup_terms_html")||""),f.append("signupCheckboxRequired",dr(e,"portal_signup_checkbox_required")?"true":"false"),f.append("portalProducts",m.join(","));const u=dr(e,"portal_default_plan");u&&f.append("portalDefaultPlan",u),l&&l.length&&f.append("portalPrices",encodeURIComponent(l.join(",")));const p=dr(e,"accent_color");p!=null&&f.append("accentColor",encodeURIComponent(p));const x=dr(e,"portal_button_style");return x&&f.append("buttonStyle",encodeURIComponent(x)),f.append("disableBackground","false"),`${y}${h}?${f.toString()}`},f4=({selectedTab:e="signup",localSettings:n,localTiers:a})=>{const{siteData:o,config:c}=Je(),m=u4({settings:n,tiers:a,selectedTab:e,siteData:o,config:c});let y=s.jsx(s.Fragment,{});switch(e){case"account":y=s.jsx(s.Fragment,{children:s.jsx(Zi,{href:m||"",portalParent:"preview",selectedTab:e})});break;case"links":y=s.jsx(c4,{});break;default:y=s.jsx(s.Fragment,{children:s.jsx(Zi,{href:m||"",portalParent:"preview",selectedTab:e})});break}return y},d4=({localSettings:e,updateSetting:n,localTiers:a,updateTier:o,errors:c,setError:m})=>{const{config:y}=Je(),[h,l,f,u,p,x]=gt(e,["members_signup_access","portal_name","portal_signup_terms_html","portal_signup_checkbox_required","portal_plans","portal_default_plan"]),v=JSON.parse(p?.toString()||"[]"),_=115,k=D.useMemo(()=>{const X=document.createElement("div");return X.innerHTML=f?.toString()||"",X.innerText.length},[f]),M=D.useCallback((X,q)=>{m(X,q)},[]);D.useEffect(()=>{k>_?M("portal_signup_terms_html","Signup notice is too long"):M("portal_signup_terms_html",void 0)},[k,M]);const T=X=>{const q=v.indexOf(X);q===-1?v.push(X):v.splice(q,1),n("portal_plans",JSON.stringify(v)),x==="yearly"?!v.includes("yearly")&&v.includes("monthly")&&n("portal_default_plan","monthly"):x==="monthly"&&(v.includes("monthly")||n("portal_default_plan","yearly"))},A=h==="all"||h==="paid",C=h==="all",O=Ws(e,y);let $=[];a&&a.forEach(X=>{X.type==="free"&&C&&$.push({checked:v.includes("free"),disabled:!A,label:X.name,value:"free",testId:"free-tier-checkbox",onChange:q=>{v.includes("free")&&!q&&v.splice(v.indexOf("free"),1),!v.includes("free")&&q&&v.push("free"),n("portal_plans",JSON.stringify(v)),o({...X,visibility:q?"public":"none"})}})});const W=od(a)||[],R=[{value:"yearly",label:"Yearly"},{value:"monthly",label:"Monthly"}];O&&W.length>0&&W.forEach(X=>{$.push({checked:X.visibility==="public",label:X.name,value:X.id,onChange:(q=>o({...X,visibility:q?"public":"none"}))})});const Z=O&&W.length>0&&W.some(X=>X.visibility==="public");return s.jsx("div",{className:"mt-7",children:s.jsxs(tt,{children:[s.jsx(st,{checked:!!l,direction:"rtl",disabled:!A,label:"Display name in signup form",onChange:X=>n("portal_name",X.target.checked)}),s.jsx(Cf,{checkboxes:$,title:"Available tiers"}),Z&&s.jsxs(s.Fragment,{children:[s.jsx(Cf,{checkboxes:[{checked:v.includes("monthly"),disabled:!A,label:"Monthly",value:"monthly",onChange:()=>{T("monthly")}},{checked:v.includes("yearly"),disabled:!A,label:"Yearly",value:"yearly",onChange:()=>{T("yearly")}}],title:"Available prices"}),v.includes("yearly")&&v.includes("monthly")&&s.jsx(Lt,{options:R,selectedOption:R.find(X=>X.value===x),title:"Default price at signup",onSelect:X=>{n("portal_default_plan",X?.value??"yearly")}})]}),s.jsx(ld,{error:!!c.portal_signup_terms_html,hint:c.portal_signup_terms_html||s.jsxs(s.Fragment,{children:["Recommended: ",s.jsx("strong",{children:"115"})," characters. You've used ",s.jsx("strong",{className:"text-green",children:k})]}),nodes:"MINIMAL_NODES",placeholder:"By signing up, I agree to receive emails from ...",title:"Display notice at signup",value:f?.toString(),onChange:X=>n("portal_signup_terms_html",X)}),f?.toString()&&s.jsx(st,{checked:!!u,disabled:!A,label:"Require agreement",labelStyle:"heading",onChange:X=>n("portal_signup_checkbox_required",X.target.checked)})]})})},p4="SettingsResponseType",h4=ns({path:()=>"/settings/verifications",method:"PUT",body:({token:e})=>({token:e}),updateQueries:{dataType:p4,emberUpdateType:"createOrUpdate",update:e=>({...e,settings:e.settings})}}),m4=({localSettings:e,updateSetting:n,localTiers:a,updateTier:o,errors:c,setError:m})=>{const[y,h]=D.useState("signupOptions"),l=[{id:"signupOptions",title:"Signup options",contents:s.jsx(d4,{errors:c,localSettings:e,localTiers:a,setError:m,updateSetting:n,updateTier:o})},{id:"lookAndFeel",title:"Look & feel",contents:s.jsx(l4,{localSettings:e,updateSetting:n})},{id:"accountPage",title:"Account page",contents:s.jsx(i4,{errors:c,setError:m,updateSetting:n})}],f=u=>{h(u)};return s.jsx("div",{className:"pt-4",children:s.jsx(Dn,{selectedTab:y,tabs:l,onTabChange:f})})},g4=()=>{const{updateRoute:e}=Qe(),[n,a]=D.useState("signup"),o=ot(),{settings:c,siteData:m,config:y}=Je(),{mutateAsync:h}=Rn(),{data:{tiers:l}={}}=so(),{mutateAsync:f}=ad(),{mutateAsync:u}=h4(),{getParam:p}=Kg(),x=p("verifyEmail");D.useEffect(()=>{x&&(async({token:ae})=>{try{let{settings:ee}=await u({token:ae});const[re]=gt(ee,["members_support_address"]);ye.show(Et,{title:"Support address verified",prompt:s.jsxs(s.Fragment,{children:["Your support email address has been changed to ",s.jsx("strong",{children:re}),"."]}),okLabel:"Close",cancelLabel:"",onOk:Q=>Q?.remove()})}catch(ee){let re="There was an error verifying your email address. Please try again.";ee?.message==="Token expired"&&(re="Verification link has expired."),ye.show(Et,{title:"Error verifying support address",prompt:re,okLabel:"Close",cancelLabel:"",onOk:Q=>Q?.remove()}),o(ee,{withToast:!1})}})({token:x})},[o,x,u]);const{formState:v,setFormState:_,saveState:k,handleSave:M,updateForm:T,okProps:A}=kr({initialState:{settings:c,tiers:l||[]},savingDelay:500,onSave:async()=>{await Promise.all(v.tiers.filter(({dirty:re})=>re).map(re=>f(re))),_(re=>({...re,tiers:v.tiers.map(Q=>({...Q,dirty:!1}))}));const Y=v.settings.filter(re=>re.dirty);if(!Y.length)return;const{meta:ae,settings:ee}=await h(Y);if(_(re=>({...re,settings:v.settings.map(Q=>({...Q,dirty:!1}))})),ae?.sent_email_verification){const re=v.settings.find(ne=>ne.key==="members_support_address")?.value,Q=ee.find(ne=>ne.key==="support_email_address")?.value||Nf(ee.find(ne=>ne.key==="members_support_address")?.value?.toString()||"noreply",m,y);ye.show(Et,{title:"Confirm email address",prompt:s.jsxs(s.Fragment,{children:["We've sent a confirmation email to ",s.jsx("strong",{children:re}),". Until verified, your support email address will remain ",Q,"."]}),okLabel:"Close",cancelLabel:"",onOk:ne=>ne?.remove()})}},onSaveError:o});D.useEffect(()=>{!v.tiers.length&&l?.length&&_(Y=>({...Y,tiers:l}))},[l,v.tiers,_]);const[C,O]=D.useState({}),$=(Y,ae)=>{T(ee=>({...ee,settings:ee.settings.map(re=>re.key===Y?{...re,value:ae,dirty:!0}:re)}))},W=(Y,ae)=>{O(ee=>({...ee,[Y]:ae}))},R=Y=>{T(ae=>({...ae,tiers:ae.tiers.map(ee=>ee.id===Y.id?{...Y,dirty:!0}:ee)}))},Z=Y=>{a(Y)},X=s.jsx(m4,{errors:C,localSettings:v.settings,localTiers:v.tiers,setError:W,updateSetting:$,updateTier:R}),q=s.jsx(f4,{localSettings:v.settings,localTiers:v.tiers,selectedTab:n});let B=[{id:"signup",title:"Signup"},{id:"account",title:"Account page"},{id:"links",title:"Links"}];return s.jsx(Zs,{afterClose:()=>{e("portal")},buttonsDisabled:A.disabled,cancelLabel:"Close",deviceSelector:!1,dirty:k==="unsaved",okColor:A.color,okLabel:A.label||"Save",preview:q,previewBgColor:n==="links"?"white":"greygradient",previewToolbarTabs:B,selectedURL:n,sidebar:X,testId:"portal-modal",title:"Portal",onOk:async()=>{Object.values(C).filter(Boolean).length||await M({force:!0})},onSelectURL:Z})},x4=ye.create(g4),b4=ye.create(()=>{const{updateRoute:e}=Qe(),{localSettings:n,updateSetting:a,handleSave:o,validate:c,errors:m,clearError:y,okProps:h}=ss({onValidate:()=>{const v={};return l&&!Nt.isURL(l,{require_protocol:!0})&&(v.slackUrl="The URL must be in a format like https://hooks.slack.com/services/<your personal key>"),v},savingDelay:500}),[l,f]=gt(n,["slack_url","slack_username"]),{mutateAsync:u}=k_(),p=async()=>{Za.remove(),await o()&&(await u(null),xt({title:"Check your Slack channel for the test message",type:"info"}))},x=n.some(v=>v.dirty);return s.jsxs(yt,{afterClose:()=>{e("integrations")},cancelLabel:"Close",dirty:x,okColor:h.color,okLabel:h.label||"Save",testId:"slack-modal",title:"",onOk:async()=>{Za.remove(),await o()},children:[s.jsx(Qs,{detail:"A messaging app for teams",icon:s.jsx(ut,{name:"slack",size:56}),title:"Slack"}),s.jsx("div",{className:"mt-7",children:s.jsxs(tt,{marginBottom:!1,title:"Slack configuration",grouped:!0,children:[s.jsx(Ae,{error:!!m.slackUrl,hint:m.slackUrl||s.jsxs(s.Fragment,{children:["Automatically send newly published posts to a channel in Slack or any Slack-compatible service like Discord or Mattermost. Set up a new incoming webhook ",s.jsx("a",{href:"https://my.slack.com/apps/new/A0F7XDUAZ-incoming-webhooks",children:"here"}),", and grab the URL."]}),placeholder:"https://hooks.slack.com/services/...",title:"Webhook URL",value:l,onBlur:c,onChange:v=>a("slack_url",v.target.value),onKeyDown:()=>y("slackUrl")}),s.jsxs("div",{className:"flex w-full flex-col gap-2 md:flex-row md:items-center",children:[s.jsx(Ae,{containerClassName:"flex-grow",hint:"The username to display messages from",title:"Username",value:f,onChange:v=>a("slack_username",v.target.value)}),s.jsx(Ue,{color:"outline",label:"Send test notification",onClick:p})]})]})})]})}),v4=""+new URL("stripe-thumb-Cu2h4McY.jpg",import.meta.url).href,w4=""+new URL("orb-squircle-e1heFqOI.png",import.meta.url).href,y4="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20400%20400'%20style='enable-background:new%200%200%20400%20400'%20xml:space='preserve'%3e%3cpath%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%23635bff'%20d='M0%200h400v400H0z'/%3e%3cpath%20d='M184.4%20155.5c0-9.4%207.7-13.1%2020.5-13.1%2018.4%200%2041.6%205.6%2060%2015.5v-56.8C244.8%2093.1%20225%2090%20205%2090c-49.1%200-81.7%2025.6-81.7%2068.4%200%2066.7%2091.9%2056.1%2091.9%2084.9%200%2011.1-9.7%2014.7-23.2%2014.7-20.1%200-45.7-8.2-66-19.3v57.5c22.5%209.7%2045.2%2013.8%2066%2013.8%2050.3%200%2084.9-24.9%2084.9-68.2-.4-72-92.5-59.2-92.5-86.3z'%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%23fff'/%3e%3c/svg%3e",_4=""+new URL("stripe-verified-DM7Q8nrY.svg",import.meta.url).href,Xf=1e3,k4=15*Xf,M4=({onNext:e})=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(bt,{level:3,children:"Getting paid"}),s.jsx("img",{alt:"Stripe Verified Partner Badge",src:_4})]}),s.jsxs("div",{className:"mb-7 mt-6",children:["Stripe is our exclusive direct payments partner. Ghost collects ",s.jsx("strong",{children:"no fees"})," on any payments! If you don’t have a Stripe account yet, you can ",s.jsx("a",{className:"underline",href:"https://stripe.com",rel:"noopener noreferrer",target:"_blank",children:"sign up here"}),"."]}),s.jsx(r0,{label:s.jsx(s.Fragment,{children:"I have a Stripe account, let's go →"}),onClick:e})]}),j4=()=>{const[e,n]=D.useState(!1),[a,o]=D.useState(""),[c,m]=D.useState(!1),[y,h]=D.useState(""),{refetch:l}=so({searchParams:{filter:"type:paid+active:true"},enabled:!1}),{mutateAsync:f}=ad(),{mutateAsync:u}=Rn(),p=ot(),x=T=>{o(T.target.value),n(!!T.target.value)},v=async()=>{const{data:T}=await l(),A=T?.pages[0].tiers[0];if(A){A.monthly_price=500,A.yearly_price=5e3,A.currency="USD";let C=0;for(;C<k4;){await new Promise(O=>{setTimeout(O,Xf)});try{await f(A);break}catch(O){if(O instanceof ts&&O.data?.errors?.[0].code==="STRIPE_NOT_CONFIGURED"){C+=Xf;continue}else{p(O);return}}}}},_=async()=>{if(h(""),a)try{await u([{key:"stripe_connect_integration_token",value:a}]),await v(),await u([{key:"portal_plans",value:JSON.stringify(["free","monthly","yearly"])}])}catch(T){if(T instanceof ts&&T.data?.errors){h("Invalid secure key");return}else{p(T);return}}else h("Please enter a secure key")},{apiRoot:k}=no(),M=`${k}/members/stripe_connect?mode=${c?"test":"live"}`;return s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx(bt,{level:3,children:"Connect with Stripe"}),s.jsx(st,{direction:"rtl",label:"Test mode",labelClasses:`text-sm translate-y-[1px] ${c?"text-[#EC6803]":"text-grey-800"}`,toggleBg:"stripetest",onChange:T=>m(T.target.checked)})]}),s.jsxs(bt,{level:6,grey:!0,children:["Step 1 — ",s.jsx("span",{className:"text-black dark:text-white",children:"Generate secure key"})]}),s.jsxs("div",{className:"mb-4 mt-2",children:["Click on the ",s.jsx("strong",{children:"“Connect with Stripe”"})," button to generate a secure key that connects your Ghost site with Stripe."]}),s.jsx(r0,{href:M,tag:"a",target:"_blank"}),s.jsxs(bt,{className:"mb-2 mt-8",level:6,grey:!0,children:["Step 2 — ",s.jsx("span",{className:"text-black dark:text-white",children:"Paste secure key"})]}),s.jsx($n,{error:!!y,hint:y||void 0,placeholder:"Paste your secure key here",onChange:x}),e&&s.jsx(Ue,{className:"mt-5",color:"green",label:"Save Stripe settings",onClick:_})]})},E4=({onClose:e})=>{const{settings:n}=Je(),[a,o]=gt(n,["stripe_connect_display_name","stripe_connect_livemode"]),{refetch:c,isFetching:m}=Fg({searchParams:{filter:"status:paid",limit:"0"},enabled:!1}),{mutateAsync:y}=M_(),h=ot(),l=async()=>{const{data:f}=await c(),u=!!f?.meta?.pagination.total;ye.show(Et,{title:"Disconnect Stripe",prompt:u?"Cannot disconnect while there are members with active Stripe subscriptions.":s.jsxs(s.Fragment,{children:["You‘re about to disconnect your Stripe account ",a," from this site. This will automatically turn off paid memberships on this site."]}),okLabel:u?"":"Disconnect",onOk:async p=>{try{await y(null),p?.remove(),e?.()}catch(x){h(x)}}})};return s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Ue,{color:"red",disabled:m,icon:"link-broken",iconColorClass:"text-red",label:"Disconnect",link:!0,onClick:l}),s.jsx(Ue,{icon:"close",iconColorClass:"dark:text-white",label:"Close",size:"sm",hideLabel:!0,link:!0,onClick:e})]}),s.jsxs("div",{className:"my-20 flex flex-col items-center",children:[s.jsxs("div",{className:"relative h-20 w-[200px]",children:[s.jsx("img",{alt:"Ghost Logo",className:"absolute left-10 size-16",src:w4}),s.jsx("img",{alt:"Stripe Logo",className:"absolute right-10 size-16 rounded-2xl shadow-[-1.5px_0_0_1.5px_#fff] dark:shadow-[-1.5px_0_0_1.5px_black]",src:y4})]}),s.jsxs(bt,{className:"text-center",level:3,children:["You are connected with Stripe!",o?null:" (Test mode)"]}),s.jsxs("div",{className:"mt-1",children:["Connected to ",s.jsx("strong",{children:a||"Test mode"})]})]}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx(bt,{level:6,children:"Read next"}),s.jsxs("a",{className:"w-100 mt-5 flex flex-col items-stretch justify-between rounded-sm border border-grey-200 transition-all hover:border-grey-400 md:flex-row dark:border-grey-900",href:"https://ghost.org/resources/managing-your-stripe-account/?ref=admin",rel:"noopener noreferrer",target:"_blank",children:[s.jsxs("div",{className:"order-2 p-4 md:order-1",children:[s.jsx("div",{className:"font-bold",children:"How to setup and manage your Stripe account"}),s.jsx("div",{className:"mt-1 text-sm text-grey-800 dark:text-grey-500",children:"Learn how to configure your Stripe account to work with Ghost, from custom branding to payment receipt emails."}),s.jsxs("div",{className:"mt-3 flex items-center gap-1 text-sm text-grey-800 dark:text-grey-500",children:[s.jsx("img",{alt:"Ghost Logo",className:"size-4",src:v2}),s.jsx("strong",{children:"Ghost Resources"}),s.jsx("span",{children:"·"}),s.jsx("span",{children:"by Kym Ellis"})]})]}),s.jsx("div",{className:"order-1 hidden w-[200px] shrink-0 items-center justify-center overflow-hidden md:!visible md:order-2 md:!flex",children:s.jsx("img",{alt:"Bookmark Thumb",className:"min-h-full min-w-full shrink-0",src:v4})})]})]})]})},T4=({onClose:e})=>{const{localSettings:n,updateSetting:a,handleSave:o,saveState:c}=ss(),[m,y]=gt(n,["stripe_publishable_key","stripe_secret_key"]),h=async()=>{try{j_.remove(),await o(),e()}catch(l){if(l instanceof ts){xt({title:"Failed to save settings",type:"error",message:"Check you copied both keys correctly"});return}throw l}};return s.jsxs("div",{children:[s.jsx(bt,{level:3,children:"Connect Stripe"}),s.jsxs(tt,{marginBottom:!1,marginTop:!0,children:[s.jsx(Ae,{title:"Publishable key",value:m?.toString(),onChange:l=>a("stripe_publishable_key",l.target.value)}),s.jsx(Ae,{title:"Secure key",value:y?.toString(),onChange:l=>a("stripe_secret_key",l.target.value)}),s.jsx(Ue,{className:"mt-5",color:"green",disabled:c==="saving",label:"Save Stripe settings",onClick:h})]})]})},S4=()=>{const{config:e,settings:n}=Je(),a=dr(n,"stripe_connect_account_id"),{updateRoute:o}=Qe(),[c,m]=D.useState("start"),y=Zt(),h=Ys(),l=Ws(n,e),f=h?.isDisabled("limitStripeConnect");D.useEffect(()=>{(async()=>{if(f&&!l)try{await h?.errorIfWouldGoOverLimit("limitStripeConnect")}catch(_){_ instanceof Gs&&(y.remove(),ye.show(Xr,{prompt:_.message||"Your current plan doesn't support Stripe Connect.",onOk:()=>o({route:"/pro",isExternal:!0})}))}})()},[h,y,o,l,f]);const u=()=>{m("connect")},p=()=>{y.remove(),o("tiers")};let x;return e?.stripeDirect||Ws(n||[],e||{})&&!a?x=s.jsx(T4,{onClose:p}):a?x=s.jsx(E4,{onClose:p}):c==="start"?x=s.jsx(M4,{onNext:u}):x=s.jsx(j4,{}),s.jsx(yt,{afterClose:()=>{o("tiers")},cancelLabel:"",footer:s.jsx("div",{className:"mt-8"}),testId:"stripe-modal",title:"",width:a?740:520,hideXOnMobile:!0,children:x})},N4=ye.create(S4),A4=""+new URL("ali-abdaal-C_tOLbSs.png",import.meta.url).href,I4=""+new URL("isaac-saul-DhERrV-4.png",import.meta.url).href,C4=""+new URL("joel-warner-CHe_ZipQ.png",import.meta.url).href,D4=ye.create(()=>{const{updateRoute:e}=Qe(),n=ot(),a=Zt(),{settings:o,currentUser:c,siteData:m,config:y}=Je(),h=y.exploreTestimonialsUrl,l=m.site_uuid,[f]=gt(o,["title"]),u=c.name,p=c.email,x=c.roles[0].name,v=c.profile_image,{formState:_,updateForm:k,saveState:M,handleSave:T,errors:A,clearError:C}=kr({initialState:{content:"",prev_platform:""},onSave:async()=>{const $=["none","other",""].includes(_.prev_platform)?void 0:_.prev_platform,W={ghost_uuid:l,staff_user_email:p,content:_.content,prev_platform:$};if(!h)throw new Error("Something went wrong, please try again later.");if(!(await fetch(h,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(W)})).ok)throw new Error("Something went wrong, please try again later.");xt({message:"Thank you for your testimonial!",type:"success"}),e("explore"),a.remove()},onSaveError:n,onValidate:()=>{const $={};return _.content.trim()||($.content="This field is required"),$}}),O=[{value:"none",label:"None - This is a new site"},{value:"substack",label:"Substack"},{value:"beehiiv",label:"BeeHiiv"},{value:"wordpress",label:"WordPress"},{value:"newspack",label:"Newspack"},{value:"medium",label:"Medium"},{value:"squarespace",label:"Squarespace"},{value:"wix",label:"Wix"},{value:"patreon",label:"Patreon"},{value:"memberful",label:"Memberful"},{value:"other",label:"Other"}];return s.jsx(yt,{afterClose:()=>{e("explore")},cancelLabel:"",footer:!1,padding:!1,testId:"explore-testimonials-modal",title:"",topRightContent:"close",width:920,children:s.jsx(tt,{className:"!mb-0",children:s.jsxs("div",{className:"flex items-stretch",children:[s.jsxs("div",{className:"hidden w-full flex-col justify-between bg-gradient-to-tl from-grey-100/50 to-grey-100/80 p-8 dark:from-grey-900/40 dark:to-grey-900/60 [@media(min-width:905px)]:!visible [@media(min-width:905px)]:!flex",children:[s.jsxs("div",{className:"pr-6",children:[s.jsx("div",{className:"relative rounded-xl bg-white px-3 py-2.5 italic text-grey-700 shadow-lg before:absolute before:-bottom-1.5 before:left-5 before:block before:size-3 before:rotate-45 before:bg-white dark:bg-black dark:text-grey-300 before:dark:bg-black",children:"Moving to Ghost has proven to be one of the best business decisions we’ve made as an independent media outlet."}),s.jsxs("div",{className:"ml-2 mt-[14px] flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"size-9 rounded-full bg-white bg-cover bg-center opacity-90 grayscale",style:{backgroundImage:`url(${C4})`}}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-black dark:text-white",children:"Joel Warner"}),s.jsx("div",{className:"-mt-0.5 text-grey-700",children:"Lever News"})]})]})]}),s.jsxs("div",{className:"ml-6 mt-8",children:[s.jsx("div",{className:"relative rounded-xl bg-white px-3 py-2.5 italic text-grey-700 shadow-lg before:absolute before:-bottom-1.5 before:right-5 before:block before:size-3 before:rotate-45 before:bg-white dark:bg-black dark:text-grey-300 before:dark:bg-black",children:"It has now been one year since I quit my full-time job to go all in on Tangle. Today, we have 50,000+ paying subscribers. That’s roughly $5M in gross yearly revenue ... it’s the best paying job I’ve ever had."}),s.jsxs("div",{className:"mr-2 mt-[14px] flex items-center justify-end gap-2 text-sm",children:[s.jsxs("div",{className:"flex flex-col items-end",children:[s.jsx("div",{className:"font-medium text-black dark:text-white",children:"Isaac Saul"}),s.jsx("div",{className:"-mt-0.5 text-grey-700",children:"Tangle"})]}),s.jsx("div",{className:"size-9 rounded-full bg-white bg-cover bg-center opacity-90 grayscale",style:{backgroundImage:`url(${I4})`}})]})]}),s.jsxs("div",{className:"mt-8 hidden pr-6 [@media(min-width:940px)]:!visible [@media(min-width:940px)]:!block",children:[s.jsx("div",{className:"relative rounded-xl bg-white px-3 py-2.5 italic text-grey-700 shadow-lg before:absolute before:-bottom-1.5 before:left-5 before:block before:size-3 before:rotate-45 before:bg-white dark:bg-black dark:text-grey-300 before:dark:bg-black",children:"You should be using Ghost because it’s absolutely amazing and I love it. It’s what I’ve been using for all my sites since 2016."}),s.jsxs("div",{className:"ml-2 mt-[14px] flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"size-9 rounded-full bg-white bg-cover bg-center opacity-90 grayscale",style:{backgroundImage:`url(${A4})`}}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-black dark:text-white",children:"Ali Abdaal"}),s.jsx("div",{className:"-mt-0.5 text-grey-700",children:"YouTuber"})]})]})]})]}),s.jsxs("div",{className:"flex grow flex-col justify-between gap-6 p-8 [@media(min-width:905px)]:min-w-[520px] [@media(min-width:940px)]:min-w-[460px]",children:[s.jsxs("div",{children:[s.jsx("div",{className:"flex size-[60px] items-center justify-center rounded-full bg-gradient-to-t from-[#CFB0FF] to-[#B27EFF]",children:s.jsx("svg",{fill:"none",height:"26",viewBox:"0 0 32 26",width:"32",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M19.9967 26L18.1562 21.4542C23.4268 19.1176 25.7693 16.5261 26.2712 11.7255C25.5183 12.3627 24.5562 12.7026 23.3431 12.7026C20.1641 12.7026 17.4869 10.1536 17.4869 6.41503C17.4869 2.80392 20.3732 9.72736e-07 24.2634 6.32644e-07C28.2791 2.81581e-07 31.5 3.10131 31.5 8.96405C31.5 17.5458 27.4425 23.0261 19.9967 26ZM3.0098 26L1.12745 21.4543C6.43987 19.1176 8.78235 16.5261 9.24248 11.7255C8.53137 12.3627 7.56928 12.7026 6.35621 12.7026C3.17712 12.7026 0.499999 10.1536 0.499998 6.41504C0.499998 2.80393 3.38627 2.45778e-06 7.23464 2.12135e-06C11.2503 1.77028e-06 14.5131 3.10131 14.5131 8.96405C14.5131 17.5458 10.4556 23.0261 3.0098 26Z",fill:"white"})})}),s.jsxs("div",{className:"mt-6",children:[s.jsx("div",{className:"text-2xl font-semibold tracking-tight",children:"A quote about Ghost"}),s.jsx("div",{className:"mt-2 text-pretty",children:"We feature quotes from publishers to showcase their work, including a logo and a link! If you'd like to be included, share a quote we can use to highlight you."})]}),s.jsx("div",{className:"mt-8",children:s.jsx($n,{error:!!A.content,hint:A.content,placeholder:"What changed for the better since you switched to Ghost?",rows:7,value:_.content,autoFocus:!0,onChange:$=>k(W=>({...W,content:$.target.value})),onKeyDown:()=>C("content")})}),s.jsx("div",{className:"ml-0.5 mt-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Vg,{bgColor:Jg(u||p),image:v??void 0,label:Qg(u),labelColor:"white",size:"md"}),s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("span",{className:"text-sm font-medium",children:["By ",u||p]}),s.jsxs("span",{className:"text-xs text-grey-700",children:[x," — ",f]})]})]})})]}),s.jsx("div",{children:s.jsxs("div",{className:"mt-2 flex items-center gap-4",children:[s.jsx("div",{className:"grow",children:s.jsx(Lt,{error:!!A.prev_platform,hint:A.prev_platform,options:O,placeholder:"Previous platform",selectedOption:O.find($=>$.value===_.prev_platform),testId:"migrated-from",onSelect:$=>{k(W=>({...W,prev_platform:$?.value||""})),C("prev_platform")}})}),s.jsx(Ue,{className:"!h-[38px] rounded-lg",color:"black",disabled:M==="saving",label:"Send testimonial",loading:M==="saving",onClick:async()=>{await T()}})]})})]})]})})})}),R4=ye.create(()=>{const{updateRoute:e}=Qe(),{settings:n}=Je(),{mutateAsync:a}=Rn(),{data:{integrations:o}={integrations:[]}}=Qf(),{mutateAsync:c}=dd(),m=ot(),[y,h]=D.useState(!1),[l]=gt(n,["transistor"]),[f,u]=D.useState(!!l),[p,x]=D.useState("Save");D.useEffect(()=>{u(l||!1)},[l]);const v=o.find(({slug:T})=>T==="transistor"),_=v?.api_keys?.find(T=>T.type==="admin"),k=()=>{if(!v||!_)throw new Error("Transistor integration or Admin API key not found");h(!1),ye.show(Et,{title:"Regenerate Admin API Key",prompt:"You will need to update the API key in your Transistor account settings after regenerating.",okLabel:"Regenerate Admin API Key",onOk:async T=>{try{await c({integrationId:v.id,apiKeyId:_.id}),h(!0),T?.remove()}catch(A){m(A)}}})},M=async()=>{const T=[{key:"transistor",value:f}];try{x("Saving..."),await Promise.all([a(T),new Promise(A=>{setTimeout(A,1e3)})]),x("Saved")}catch(A){m(A)}finally{setTimeout(()=>x("Save"),1e3)}};return s.jsxs(yt,{afterClose:()=>{e("integrations")},cancelLabel:"Close",dirty:f!==l,okColor:p==="Saved"?"green":"black",okLabel:p,testId:"transistor-modal",title:"",onOk:M,children:[s.jsx(Qs,{detail:"Podcast hosting platform",icon:s.jsx(ut,{name:"transistor",size:56}),title:"Transistor"}),s.jsx("div",{className:"mt-7",children:s.jsxs(tt,{marginBottom:!1,title:"Transistor configuration",grouped:!0,children:[s.jsx(st,{checked:f,direction:"rtl",hint:s.jsxs(s.Fragment,{children:["Connect your Ghost site with ",s.jsx("a",{className:"text-green",href:"https://transistor.fm",rel:"noopener noreferrer",target:"_blank",children:"Transistor.fm"})," to start offering members private podcasts."]}),label:"Enable Transistor",onChange:T=>{u(T.target.checked)}}),f&&s.jsx(al,{keys:[{label:"Admin API key",text:_?.secret,hint:y?s.jsx("div",{className:"text-green",children:"Admin API Key was successfully regenerated"}):void 0,onRegenerate:k},{label:"API URL",text:window.location.origin+no().subdir}]})]})})]})}),O4=ye.create(()=>{const{updateRoute:e}=Qe(),{settings:n}=Je(),[a]=gt(n,["unsplash"]),{mutateAsync:o}=Rn(),c=ot(),[m,y]=D.useState("Save"),[h,l]=D.useState(!!a);D.useEffect(()=>{l(a||!1)},[a]);const f=async()=>{const p=[{key:"unsplash",value:h}];try{y("Saving..."),await Promise.all([o(p),new Promise(x=>{setTimeout(x,1e3)})]),y("Saved")}catch(x){c(x)}finally{setTimeout(()=>y("Save"),1e3)}},u=h!==a;return s.jsxs(yt,{afterClose:()=>{e("integrations")},cancelLabel:"Close",dirty:u,okColor:m==="Saved"?"green":"black",okLabel:m,testId:"unsplash-modal",title:"",onOk:f,children:[s.jsx(Qs,{detail:"Beautiful, free photos",icon:s.jsx(ut,{name:"unsplash",size:48}),title:"Unsplash"}),s.jsx("div",{className:"mt-7",children:s.jsx(tt,{marginBottom:!1,grouped:!0,children:s.jsx(st,{checked:h,direction:"rtl",hint:s.jsxs(s.Fragment,{children:["Enable ",s.jsx("a",{className:"text-green",href:"https://unsplash.com",rel:"noopener noreferrer",target:"_blank",children:"Unsplash"})," image integration for your posts"]}),label:"Enable Unsplash",onChange:p=>{l(p.target.checked)}})})})]})}),$4=({user:e,setUserData:n})=>{const{config:a,settings:o}=Je(),c=w2("webmentions"),m=Ws(o||[],a||{});return s.jsxs(sd,{children:[s.jsx(st,{checked:e.comment_notifications,direction:"rtl",hint:"Every time a member comments on one of your posts",label:"Comments",onChange:y=>{n?.({...e,comment_notifications:y.target.checked})}}),Hi(e)&&s.jsxs(s.Fragment,{children:[c&&s.jsx(st,{checked:e.mention_notifications,direction:"rtl",hint:"Every time another site links to your work",label:"Mentions",onChange:y=>{n?.({...e,mention_notifications:y.target.checked})}}),s.jsx(st,{checked:e.recommendation_notifications,direction:"rtl",hint:"Every time another publisher recommends you to their audience",label:"Recommendations",onChange:y=>{n?.({...e,recommendation_notifications:y.target.checked})}}),s.jsx(st,{checked:e.free_member_signup_notification,direction:"rtl",hint:"Every time a new free member signs up",label:"New signups",onChange:y=>{n?.({...e,free_member_signup_notification:y.target.checked})}}),m&&s.jsxs(s.Fragment,{children:[s.jsx(st,{checked:e.paid_subscription_started_notification,direction:"rtl",hint:"Every time a member starts a new paid subscription",label:"New paid members",onChange:y=>{n?.({...e,paid_subscription_started_notification:y.target.checked})}}),s.jsx(st,{checked:e.paid_subscription_canceled_notification,direction:"rtl",hint:"Every time a member cancels their paid subscription",label:"Paid member cancellations",onChange:y=>{n?.({...e,paid_subscription_canceled_notification:y.target.checked})}})]}),s.jsx(st,{checked:e.milestone_notifications,direction:"rtl",hint:m?"Occasional summaries of your audience & revenue growth":"Occasional summaries of your audience growth",label:"Milestones",onChange:y=>{n?.({...e,milestone_notifications:y.target.checked})}}),m&&s.jsx(st,{checked:e.donation_notifications,direction:"rtl",hint:"Every time you receive a one-time payment",label:"Tips & donations",onChange:y=>{n?.({...e,donation_notifications:y.target.checked})}})]})]})},L4=({user:e,setUserData:n})=>s.jsx(nd,{border:!1,children:s.jsx($4,{setUserData:n,user:e})}),P4=["1234567890","qwertyuiop","qwertzuiop","asdfghjkl;","abcdefghij","0987654321","1q2w3e4r5t","12345asdfg"],F4=["ghost","password","passw0rd"],U4=e=>{let n={},a,o=!0;a=e.length/2;for(let c=0;c<e.length;c+=1)n[e[c]]?n[e[c]]+=1:n[e[c]]=1;for(let c in n)if(n[c]>=a)return o=!1,o;return o},z4=({user:e})=>{const{currentUser:n,config:a,siteData:o}=Je(),[c,m]=D.useState(!1),[y,h]=D.useState(""),[l,f]=D.useState(""),[u,p]=D.useState(""),[x,v]=D.useState(""),[_,k]=D.useState({}),M=D.useRef(null),T=D.useRef(null),A=D.useRef(null),{mutateAsync:C}=E_(),O=ot(),$=e.id===n.id,W=({password:B,confirmPassword:Y})=>{if($&&!y)return{oldPassword:"Your current password is required to set a new one"};if(B!==Y)return{newPassword:"Your new passwords do not match",confirmNewPassword:"Your new passwords do not match"};let ae=a.blogUrl||window.location.host,ee=o.title,re;if(ae=ae.replace(/^http(s?):\/\//,""),re=ae.match(/\/$/)?ae:`${ae}/`,ee=ee&&ee.trim().toLowerCase(),B.length<10)return{newPassword:"Password must be at least 10 characters long."};B=B.toString();for(const Q of P4)if(Q===B)return{newPassword:"Sorry, you cannot use an insecure password."};if(B.toLowerCase()===e.email.toLowerCase())return{newPassword:"Sorry, you cannot use an insecure password."};for(const Q of F4)if(B.toLowerCase().indexOf(Q)>=0)return{newPassword:"Sorry, you cannot use an insecure password."};return B.toLowerCase()===ee?{newPassword:"Sorry, you cannot use an insecure password."}:B.toLowerCase()===ae||B.toLowerCase()===re?{newPassword:"Sorry, you cannot use an insecure password."}:U4(B)?{}:{newPassword:"Sorry, you cannot use an insecure password."}};D.useEffect(()=>{x==="saved"&&setTimeout(()=>{v(""),m(!1)},2500)},[x]),D.useEffect(()=>{c&&setTimeout(()=>{$?A.current?.focus():M.current?.focus()},100)},[c,$]);const R=()=>{m(!0)};let Z="Save password";x==="saving"?Z="Saving...":x==="saved"&&(Z="Saved");const X=s.jsxs(s.Fragment,{children:[$&&s.jsx(Ae,{"data-testid":"old-password",error:!!_.oldPassword,hint:_.oldPassword,inputRef:A,title:"Old password",type:"password",value:y,onChange:B=>{h(B.target.value)}}),s.jsx(Ae,{"data-testid":"new-password",error:!!_.newPassword,hint:_.newPassword,inputRef:M,title:"New password",type:"password",value:l,onChange:B=>{f(B.target.value)}}),s.jsx(Ae,{"data-testid":"confirm-password",error:!!_.confirmNewPassword,hint:_.confirmNewPassword,inputRef:T,title:"Confirm new password",type:"password",value:u,onChange:B=>{p(B.target.value)}}),s.jsxs("div",{className:"mt-1 flex items-center justify-end gap-3",children:[s.jsx(Ue,{color:"outline",label:"Cancel",onClick:()=>{m(!1),h(""),f(""),p(""),k({})}}),s.jsx(Ue,{color:"green","data-testid":"save-password-button",label:Z,onClick:async()=>{v("saving");const B=W({password:l,confirmPassword:u});if(k(B),Object.keys(B).length>0){v("");return}try{await C({newPassword:l,confirmNewPassword:u,oldPassword:y,userId:e?.id}),v("saved")}catch(Y){v(""),xt({type:"error",title:Y instanceof T_?Y.message:"Couldn't update password. Please try again."}),O(Y,{withToast:!1})}}})]})]}),q=s.jsxs("div",{className:"relative flex flex-col",children:[s.jsx(Ae,{containerClassName:"grow",disabled:!0,title:"Password",type:"password",value:"••••••••••••"}),s.jsx(Ue,{className:"absolute right-0 top-0",color:"green","data-testid":"change-password-button",label:"Change",link:!0,onClick:R})]});return s.jsx(s.Fragment,{children:c?X:q})},H4=({user:e,setUserData:n})=>{const{data:{roles:a}={}}=If(),{config:o}=Je(),c=o.labs.superEditors;let m=[{hint:"Can write and edit their own posts, but cannot publish them.",label:"Contributor",value:"contributor"},{hint:"Can create, edit and publish their own posts, but can’t modify others.",label:"Author",value:"author"},{hint:"Can edit and publish any posts, and manage Authors and Contributors.",label:"Editor",value:"editor"},{hint:"Trusted user who has full access to all content, settings, and user management.",label:"Administrator",value:"administrator"}];if(c&&(m=m.map(y=>y.value==="editor"?{...y,label:"Editor (beta mode)",value:"super editor",hint:"Can invite and manage other Authors and Contributors, as well as edit and publish any posts on the site. Can manage members and moderate comments."}:y)),Af(e)){const y={label:"Owner",value:"owner"};return s.jsx("div",{children:s.jsx(Lt,{disabled:!0,hint:s.jsxs(s.Fragment,{children:["This user is the owner of the site. ",s.jsx("a",{className:"font-medium text-grey-800 transition-colors hover:text-grey-900 dark:text-grey-500 dark:hover:text-grey-400",href:"https://ghost.org/help/transfer-publication-ownership/",rel:"noopener noreferrer",target:"_blank",children:"Transfer ownership"})," first to change their role."]}),options:[y],selectedOption:y,title:"Role",onSelect:()=>{}})})}return s.jsx(Lt,{options:m,selectedOption:m.find(y=>y.value===e.roles[0].name.toLowerCase()),testId:"role-select",title:"Role",onSelect:y=>{if(y){const h=a?.find(l=>l.name.toLowerCase()===y.value.toLowerCase());h&&n?.({...e,roles:[h]})}}})},B4="StaffTokenResponseType",W4=S_({dataType:B4,path:"/users/me/token/"}),q4=ns({path:()=>"/users/me/token/",method:"PUT"}),Y4=()=>{const{refetch:e}=W4({enabled:!1}),n=ot(),[a,o]=D.useState(""),{mutateAsync:c}=q4();D.useEffect(()=>{(async()=>{const h=await e();h?.data?.apiKey&&o(`${h.data.apiKey.id}:${h.data.apiKey.secret}`)})()},[e]);const m=()=>{ye.show(Et,{title:"Regenerate your Staff Access Token",prompt:"You can regenerate your Staff Access Token any time, but any scripts or applications using it will need to be updated.",okLabel:"Regenerate your Staff Access Token",okColor:"red",onOk:async y=>{try{const h=await c([]);o(`${h.apiKey.id}:${h.apiKey.secret}`),y?.remove()}catch(h){n(h)}}})};return s.jsxs("div",{children:[s.jsx(bt,{className:"mb-2",level:6,grey:!0,children:"Staff access token"}),s.jsx(al,{hasLabel:!1,keys:[{text:a||"",onRegenerate:m}]})]})},G4=({errors:e,clearError:n,user:a,setUserData:o})=>{const{currentUser:c}=Je();return s.jsxs(sd,{children:[s.jsx(Ae,{error:!!e?.email,hint:e?.email||"Used for notifications",maxLength:191,title:"Email",value:a.email,onChange:m=>{o({...a,email:m.target.value})},onKeyDown:()=>n("email")}),s.jsx(z4,{user:a}),Hi(c)&&s.jsx(H4,{setUserData:o,user:a}),s.jsx(Ae,{error:!!e?.name,hint:e?.name||"Use your real name so people can recognize you",maxLength:191,title:"Full name",value:a.name,onChange:m=>{o({...a,name:m.target.value})},onKeyDown:()=>n("name")}),s.jsx(Ae,{hint:`https://example.com/author/${a.slug}`,maxLength:191,title:"Slug",value:a.slug,onChange:m=>{o({...a,slug:m.target.value})}}),s.jsx(Ae,{error:!!e?.location,hint:e?.location||"Where in the world do you live?",maxLength:65535,title:"Location",value:a.location||"",onChange:m=>{o({...a,location:m.target.value})},onKeyDown:()=>n("location")}),s.jsx($n,{error:!!e?.bio,hint:e?.bio||s.jsxs(s.Fragment,{children:["Recommended: 250 characters. You‘ve used ",s.jsx("span",{className:"font-bold",children:a.bio?.length||0})]}),maxLength:65535,title:"Bio",value:a.bio||"",onChange:m=>{o({...a,bio:m.target.value})},onKeyDown:()=>n("bio")}),a.id===c.id&&s.jsx(Y4,{})]})},X4=e=>s.jsx(nd,{border:!1,children:s.jsx(G4,{...e})}),K4=({errors:e,clearError:n,validateField:a,user:o,setUserData:c})=>{const[m,y]=D.useState(o.facebook?y2(o.facebook):""),[h,l]=D.useState(o.twitter?_2(o.twitter):""),[f,u]=D.useState(o.threads?oM(o.threads):""),[p,x]=D.useState(o.bluesky?lM(o.bluesky):""),[v,_]=D.useState(o.linkedin?pM(o.linkedin):""),[k,M]=D.useState(o.instagram?mM(o.instagram):""),[T,A]=D.useState(o.youtube?xM(o.youtube):""),[C,O]=D.useState(o.tiktok?vM(o.tiktok):""),[$,W]=D.useState(o.mastodon?yM(o.mastodon):"");return s.jsxs(sd,{children:[s.jsx(Ae,{"data-testid":"website-input",error:!!e?.website,hint:e?.website,maxLength:2e3,placeholder:"https://example.com",title:"Website",value:o.website||"",onChange:R=>{c({...o,website:R.target.value})},onKeyDown:()=>n("url")}),s.jsx(Ae,{"data-testid":"x-input",error:!!e?.twitter,hint:e?.twitter,maxLength:2e3,placeholder:"https://x.com/username",title:"X",value:h,onBlur:R=>{if(a("twitter",R.target.value)){const Z=n0(R.target.value);l(Z),c({...o,twitter:k2(Z)})}},onChange:R=>{l(R.target.value)},onKeyDown:()=>n("twitter")}),s.jsx(Ae,{"data-testid":"facebook-input",error:!!e?.facebook,hint:e?.facebook,maxLength:2e3,placeholder:"https://www.facebook.com/username",title:"Facebook",value:m,onBlur:R=>{if(a("facebook",R.target.value)){const Z=s0(R.target.value);y(Z),c({...o,facebook:M2(Z)})}},onChange:R=>{y(R.target.value)},onKeyDown:()=>n("facebook")}),s.jsx(Ae,{"data-testid":"linkedin-input",error:!!e?.linkedin,hint:e?.linkedin,maxLength:2e3,placeholder:"https://www.linkedin.com/in/username",title:"LinkedIn",value:v,onBlur:R=>{if(a("linkedin",R.target.value)){const Z=X0(R.target.value);_(Z),c({...o,linkedin:hM(Z)})}},onChange:R=>{_(R.target.value)},onKeyDown:()=>n("linkedin")}),s.jsx(Ae,{"data-testid":"bluesky-input",error:!!e?.bluesky,hint:e?.bluesky,maxLength:2e3,placeholder:"https://bsky.app/profile/username",title:"Bluesky",value:p,onBlur:R=>{if(a("bluesky",R.target.value)){const Z=B0(R.target.value);x(Z),c({...o,bluesky:cM(Z)})}},onChange:R=>{x(R.target.value)},onKeyDown:()=>n("bluesky")}),s.jsx(Ae,{"data-testid":"threads-input",error:!!e?.threads,hint:e?.threads,maxLength:2e3,placeholder:"https://threads.net/@username",title:"Threads",value:f,onBlur:R=>{if(a("threads",R.target.value)){const Z=z0(R.target.value);u(Z),c({...o,threads:iM(Z)})}},onChange:R=>{u(R.target.value)},onKeyDown:()=>n("threads")}),s.jsx(Ae,{"data-testid":"mastodon-input",error:!!e?.mastodon,hint:e?.mastodon,maxLength:2e3,placeholder:"https://mastodon.social/@username",title:"Mastodon",value:$,onBlur:R=>{if(a("mastodon",R.target.value)){const Z=Q0(R.target.value);W(Z),c({...o,mastodon:_M(Z)})}},onChange:R=>{W(R.target.value)},onKeyDown:()=>n("mastodon")}),s.jsx(Ae,{"data-testid":"tiktok-input",error:!!e?.tiktok,hint:e?.tiktok,maxLength:2e3,placeholder:"https://www.tiktok.com/@username",title:"TikTok",value:C,onBlur:R=>{if(a("tiktok",R.target.value)){const Z=V0(R.target.value);O(Z),c({...o,tiktok:wM(Z)})}},onChange:R=>{O(R.target.value)},onKeyDown:()=>n("tiktok")}),s.jsx(Ae,{"data-testid":"youtube-input",error:!!e?.youtube,hint:e?.youtube,maxLength:2e3,placeholder:"https://www.youtube.com/@channel",title:"YouTube",value:T,onBlur:R=>{if(a("youtube",R.target.value)){const Z=Z0(R.target.value);A(Z),c({...o,youtube:bM(Z)})}},onChange:R=>{A(R.target.value)},onKeyDown:()=>n("youtube")}),s.jsx(Ae,{"data-testid":"instagram-input",error:!!e?.instagram,hint:e?.instagram,maxLength:2e3,placeholder:"https://www.instagram.com/username",title:"Instagram",value:k,onBlur:R=>{if(a("instagram",R.target.value)){const Z=K0(R.target.value);M(Z),c({...o,instagram:gM(Z)})}},onChange:R=>{M(R.target.value)},onKeyDown:()=>n("instagram")})]})},Z4=e=>s.jsx(nd,{border:!1,children:s.jsx(K4,{...e})}),Og={name:({name:e})=>{let n="";return e||(n="Name is required"),e&&e.length>191&&(n="Name is too long"),n},email:({email:e})=>Nt.isEmail(e||"")?"":"Enter a valid email address",url:({url:e})=>!e||Nt.isURL(e,{require_tld:!1})?"":"Enter a valid URL",bio:({bio:e})=>!e||e.length<=250?"":"Bio is too long",location:({location:e})=>!e||e.length<=150?"":"Location is too long",website:({website:e})=>!e||Nt.isURL(e)&&e.length<=2e3?"":"Enter a valid URL",facebook:({facebook:e})=>{try{return s0(e||""),""}catch(n){return n instanceof Error?n.message:""}},twitter:({twitter:e})=>{try{return n0(e||""),""}catch(n){return n instanceof Error?n.message:""}},threads:({threads:e})=>{try{return z0(e||""),""}catch(n){return n instanceof Error?n.message:""}},bluesky:({bluesky:e})=>{try{return B0(e||""),""}catch(n){return n instanceof Error?n.message:""}},linkedin:({linkedin:e})=>{try{return X0(e||""),""}catch(n){return n instanceof Error?n.message:""}},instagram:({instagram:e})=>{try{return K0(e||""),""}catch(n){return n instanceof Error?n.message:""}},youtube:({youtube:e})=>{try{return Z0(e||""),""}catch(n){return n instanceof Error?n.message:""}},tiktok:({tiktok:e})=>{try{return V0(e||""),""}catch(n){return n instanceof Error?n.message:""}},mastodon:({mastodon:e})=>{try{return Q0(e||""),""}catch(n){return n instanceof Error?n.message:""}}},V4=({user:e})=>{const{updateRoute:n,route:a}=Qe(),o=L=>{const J=L.split("/").pop()||"";return J==="social-links"||J==="email-notifications"?J:"profile"},{ownerUser:c}=j2(),{currentUser:m}=Je(),y=ot(),{formState:h,setFormState:l,saveState:f,handleSave:u,updateForm:p,errors:x,setErrors:v,clearError:_,okProps:k}=kr({initialState:e,savingDelay:500,savedDelay:500,onValidate:L=>Object.entries(Og).reduce((J,[xe,Te])=>{const De=Te(L);return De&&(J[xe]=De),J},{}),onSave:async L=>{await O?.(L)},onSaveError:y}),M=L=>p(()=>L),T=(L,J)=>{const xe=Og[L]?.({[L]:J});return xe?(v({...x,[L]:xe}),!1):(_(L),!0)},A=Zt(),{mutateAsync:C}=Xs(),{mutateAsync:O}=A_(),{mutateAsync:$}=I_(),{mutateAsync:W}=C_(),R=Ys(),Z=Gg(),X=D.useCallback(()=>{Nn(m)?n("staff"):n({isExternal:!0,route:""})},[m,n]),q=async L=>{if(L.status==="inactive"&&L.roles[0].name!=="Contributor")try{await R?.errorIfWouldGoOverLimit("staff")}catch(xe){if(xe instanceof Gs){ye.show(Xr,{formSheet:!0,prompt:xe.message||"Your current plan doesn't support more users.",onOk:()=>n({route:"/pro",isExternal:!0})});return}else throw xe}let J="This user will no longer be able to log in but their posts will be kept.";L.status==="inactive"&&(J="This user will be able to log in again and will have the same permissions they had previously."),ye.show(Et,{title:"Are you sure you want to suspend this user?",prompt:s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"WARNING:"})," ",J]}),okLabel:L.status==="inactive"?"Un-suspend":"Suspend",okRunningLabel:L.status==="inactive"?"Un-suspending...":"Suspending...",okColor:"red",onOk:async xe=>{const Te={...L,status:L.status==="inactive"?"active":"inactive"};try{await O(Te),l(()=>Te),xe?.remove(),xt({title:L.status==="inactive"?"User un-suspended":"User suspended",type:"success"})}catch(De){y(De)}}})},B=(L,{owner:J})=>{ye.show(Et,{title:"Are you sure you want to delete this user?",prompt:s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"mb-3",children:[s.jsx("span",{className:"font-bold",children:L.name||L.email})," will be permanently deleted and all their posts will be automatically assigned to the ",s.jsx("span",{className:"font-bold",children:J.name}),"."]}),s.jsxs("p",{children:["To make these easy to find in the future, each post will be given an internal tag of ",s.jsxs("span",{className:"font-bold",children:["#",e.slug]})]})]}),okLabel:"Delete user",okColor:"red",onOk:async xe=>{try{await $(L?.id),xe?.remove(),A?.remove(),X(),xt({title:"User deleted",type:"success"})}catch(Te){y(Te)}}})},Y=()=>{ye.show(Et,{title:"Transfer Ownership",prompt:"Are you sure you want to transfer the ownership of this blog? You will not be able to undo this action.",okLabel:"Yep — I'm sure",okColor:"red",onOk:async L=>{try{await W(e.id),L?.remove(),xt({title:"Ownership transferred",type:"success"})}catch(J){y(J)}}})},ae=async(L,J)=>{try{const xe=on(await C({file:J}));switch(L){case"cover_image":p(Te=>({...Te,cover_image:xe}));break;case"profile_image":p(Te=>({...Te,profile_image:xe}));break}}catch(xe){const Te=xe;Te.response.status===415&&(Te.message="Unsupported file type"),y(Te)}},ee=L=>{switch(L){case"cover_image":p(J=>({...J,cover_image:""}));break;case"profile_image":p(J=>({...J,profile_image:""}));break}},re=Hi(m)||ih(m)&&lh(e);let Q=[];if(Af(m)&&D_(h)&&h.status!=="inactive"&&Q.push({id:"make-owner",label:"Make owner",onClick:Y}),h.id!==m.id&&(Hi(m)&&!Af(e)||ih(m)&&lh(e))){let L=h.status==="inactive"?"Un-suspend user":"Suspend user";Q.push({id:"delete-user",label:"Delete user",onClick:()=>{B(e,{owner:c})}},{id:"suspend-user",label:L,onClick:()=>{q(h)}})}Q.push({id:"view-user-activity",label:"View user activity",onClick:()=>{A.remove(),n(`history/view/${h.id}`)}});const ne="rounded text-sm flex flex-nowrap items-center justify-center px-3 h-8 transition-all cursor-pointer font-medium border border-grey-300 bg-transparent text-black dark:border-grey-800 dark:text-white",be="flex flex-nowrap items-center justify-center px-3 h-8 opacity-80 hover:opacity-100 bg-[rgba(0,0,0,0.75)] rounded text-sm text-white transition-all cursor-pointer font-medium nowrap",je=h.status==="inactive"?" (Suspended)":"",H=o(a),[he,ge]=D.useState(H),F=L=>{const J=L==="profile"?"":`/${L}`;n(`staff/${e.slug}${J}`),ge(L)};return s.jsx(yt,{afterClose:X,animate:Nn(m),backDrop:Nn(m),buttonsDisabled:k.disabled,cancelLabel:"Close",dirty:f==="unsaved",okColor:k.color,okLabel:k.label||"Save",size:Nn(m)?"md":"bleed",stickyFooter:!0,testId:"user-detail-modal",width:Nn(m)?600:"full",onOk:async()=>{await u({fakeWhenUnchanged:!0})},children:s.jsxs("div",{children:[s.jsx("div",{className:`relative ${Nn(m)?"-mx-8 -mt-8 rounded-t":"-mx-10 -mt-10"}`,children:s.jsx("div",{className:`flex flex-wrap items-end justify-between gap-8 p-8 ${h.cover_image?"bg-cover bg-center":""} ${!Nn(m)&&"min-h-[30vmin]"}`,style:{backgroundImage:h.cover_image?`url(${h.cover_image})`:"none"},children:s.jsxs("div",{className:"flex w-full flex-col gap-2",children:[s.jsxs("div",{className:"flex flex-nowrap items-start justify-between gap-3",children:[s.jsx("div",{children:s.jsx(un,{deleteButtonClassName:"md:invisible absolute pr-3 -right-2 -top-2 flex h-8 w-10 cursor-pointer items-center justify-end rounded-full bg-[rgba(0,0,0,0.75)] text-white group-hover:!visible",deleteButtonContent:s.jsx(ut,{colorClass:"text-white",name:"trash",size:"sm"}),editButtonClassName:"md:invisible absolute right-[22px] -top-2 flex h-8 w-8 cursor-pointer items-center justify-center text-white group-hover:!visible z-20",fileUploadClassName:"rounded-full bg-black flex items-center justify-center opacity-80 transition hover:opacity-100 -ml-2 cursor-pointer h-[80px] w-[80px]",fileUploadProps:{dragIndicatorClassName:"rounded-full"},id:"avatar",imageClassName:"w-full h-full object-cover rounded-full shrink-0",imageContainerClassName:"relative group bg-cover bg-center -ml-1 h-16 w-16 md:h-18 md:w-18 shrink-0",imageURL:h.profile_image??void 0,pintura:{isEnabled:Z.isEnabled,openEditor:async()=>Z.openEditor({image:h.profile_image||"",handleSave:async L=>{ae("profile_image",L)}})},unstyled:!0,width:"80px",onDelete:()=>{ee("profile_image")},onUpload:L=>{ae("profile_image",L)},children:s.jsx(ut,{colorClass:"black",name:"user-add",size:"lg"})})}),s.jsxs("div",{className:"flex flex-nowrap items-start gap-3",children:[s.jsx(un,{buttonContainerClassName:"flex items-end gap-4 justify-end flex-nowrap",deleteButtonClassName:be,deleteButtonContent:"Delete cover image",editButtonClassName:be,fileUploadClassName:ne,id:"cover-image",imageClassName:"hidden",imageURL:h.cover_image||"",pintura:{isEnabled:Z.isEnabled,openEditor:async()=>Z.openEditor({image:h.cover_image||"",handleSave:async L=>{ae("cover_image",L)}})},unstyled:!0,onDelete:()=>{ee("cover_image")},onUpload:L=>{ae("cover_image",L)},children:"Upload cover image"}),re&&s.jsx("div",{className:"z-10",children:s.jsx(E0,{items:Q,position:"end",trigger:s.jsxs("button",{className:we("flex h-8 cursor-pointer items-center justify-center rounded px-3",h.cover_image?"bg-[rgba(0,0,0,0.75)] opacity-80 hover:opacity-100":"border border-grey-300 bg-transparent text-black dark:border-grey-800 dark:text-white"),type:"button",children:[s.jsx("span",{className:"sr-only",children:"Actions"}),s.jsx(ut,{colorClass:h.cover_image?"text-white":void 0,name:"ellipsis",size:"md"})]})})})]})]}),s.jsxs("div",{children:[s.jsxs(bt,{level:3,styles:we("break-words md:break-normal",h.cover_image?"text-white":"text-black dark:text-white"),children:[e.name,je]}),s.jsx("span",{className:we("text-md font-medium capitalize",h.cover_image?"text-white":"text-black dark:text-white"),children:e.roles[0].name.toLowerCase()})]})]})})}),s.jsx("div",{className:`${!Nn(m)&&"mx-auto max-w-[536px]"} mt-6 flex flex-col`,children:s.jsx(Dn,{selectedTab:he,tabs:[{id:"profile",title:"Profile",contents:s.jsx(X4,{clearError:_,errors:x,setUserData:M,user:h,validateField:T})},{id:"social-links",title:"Social Links",contents:s.jsx(Z4,{clearError:_,errors:x,setUserData:M,user:h,validateField:T})},{id:"email-notifications",title:"Email Notifications",contents:s.jsx(L4,{setUserData:M,user:h})}],onTabChange:F})})]})})},Q4=({params:e})=>{const{currentUser:n}=Je(),a=n.slug===e?.slug,{data:o}=N_(e?.slug||"",{enabled:!a&&!!e?.slug}),c=a?n:o?.users?.[0];return c?s.jsx(V4,{user:c}):null},J4=ye.create(Q4),iT={AddIntegrationModal:$M,AddNewsletterModal:PM,AddRecommendationModal:tx,CustomIntegrationModal:nj,DesignAndThemeModal:iE,EditRecommendationModal:E2,FirstPromoterModal:kE,HistoryModal:OE,InviteUserModal:$E,NavigationModal:LE,NewsletterDetailModal:XE,PinturaModal:o4,PortalModal:x4,SlackModal:b4,StripeConnectModal:N4,TestimonialsModal:D4,TierDetailModal:jM,TransistorModal:R4,UnsplashModal:O4,UserDetailModal:J4,ZapierModal:aM,AnnouncementBarModal:XM,EmbedSignupFormModal:_E,OffersContainerModal:n4,AboutModal:RM,OfferSuccess:wx};export{iT as default};