ghost 6.47.0 → 6.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MigratorConfig.js +0 -1
- package/bin/create-migration.js +1 -1
- package/bin/generate-golden-email.js +0 -1
- package/components/tryghost-i18n-0.0.0.tgz +0 -0
- package/core/boot.js +13 -7
- package/core/built/admin/assets/{PolarAngleAxis-CLluELUg.js → PolarAngleAxis-DufzOBEz.js} +1 -1
- package/core/built/admin/assets/{_baseAssignValue-Dz1iqdwD.js → _baseAssignValue-BjUm4QeA.js} +1 -1
- package/core/built/admin/assets/{a-large-small-BA74vHPp.js → a-large-small-D0RF_WS9.js} +1 -1
- package/core/built/admin/assets/{account-migration-B-NqdKuN.js → account-migration-B7n6ezrZ.js} +1 -1
- package/core/built/admin/assets/activitypub/{account-migration-ClmVrAXr.js → account-migration-BJeRnMCl.js} +3 -3
- package/core/built/admin/assets/activitypub/activitypub.js +1 -1
- package/core/built/admin/assets/activitypub/{at-sign-9F3qd4Nn.js → at-sign-BygVOKdj.js} +2 -2
- package/core/built/admin/assets/activitypub/{avatar-flipboard-jBHA13Ej.js → avatar-flipboard-CNcjI8lK.js} +2 -2
- package/core/built/admin/assets/activitypub/{bluesky-sharing-1irhvVtF.js → bluesky-sharing-mgBNeRfA.js} +4 -4
- package/core/built/admin/assets/activitypub/{copy-DXRvsGiK.js → copy-BMChXIQc.js} +2 -2
- package/core/built/admin/assets/activitypub/{deleted-feed-item-67VQJde4.js → deleted-feed-item-D-spb6V1.js} +2 -2
- package/core/built/admin/assets/activitypub/{edit-profile-BfpbEj98.js → edit-profile-CDQ3V8-c.js} +4 -4
- package/core/built/admin/assets/activitypub/{feed-DUrI7SPC.js → feed-Vqr3WU-V.js} +4 -4
- package/core/built/admin/assets/activitypub/{hash-CMtB10PN.js → hash-D7SSXVOg.js} +2 -2
- package/core/built/admin/assets/activitypub/{inbox-2xq8SJ7A.js → inbox-BHk5Dw27.js} +2 -2
- package/core/built/admin/assets/activitypub/{index-BT97xLpd.js → index-BejkeH-m.js} +2 -2
- package/core/built/admin/assets/activitypub/{index-DssHQAjK.js → index-BqL23J-m.js} +32 -32
- package/core/built/admin/assets/activitypub/{index-Ba6FXt8y.js → index-CHhvjNuG.js} +6 -6
- package/core/built/admin/assets/activitypub/{index-ERtz4Bvy.js → index-CZsNO9hA.js} +5 -5
- package/core/built/admin/assets/activitypub/{index-sgY7lLrg.js → index-CaIhRYzz.js} +3 -3
- package/core/built/admin/assets/activitypub/{index-D1EWoXrK.js → index-DA2MkQVu.js} +2 -2
- package/core/built/admin/assets/activitypub/{index-sudOvKcY.js → index-DHhFcmfu.js} +21 -21
- package/core/built/admin/assets/activitypub/{index-Ccighz1t.js → index-sh2bDSls.js} +4 -4
- package/core/built/admin/assets/activitypub/{label-KQSsSjmN.js → label-D80yhOIm.js} +2 -2
- package/core/built/admin/assets/activitypub/{moderation-B78if-r0.js → moderation-LJNmKBCi.js} +3 -3
- package/core/built/admin/assets/activitypub/{note-Bfr7ovn7.js → note-CyjKLcQ-.js} +4 -4
- package/core/built/admin/assets/activitypub/{reply-CehesW8Z.js → reply-BiiCFx7G.js} +2 -2
- package/core/built/admin/assets/activitypub/{separator-B_Ly_Qq8.js → separator-CY3PMmtI.js} +2 -2
- package/core/built/admin/assets/activitypub/{settings-D6R97p7v.js → settings-BQy6Gr7R.js} +3 -3
- package/core/built/admin/assets/activitypub/{step-1-Cl1YxgZ1.js → step-1-DCqRwgf3.js} +3 -3
- package/core/built/admin/assets/activitypub/{step-2-DDyR--Qe.js → step-2-DQlhehTO.js} +5 -5
- package/core/built/admin/assets/activitypub/{step-3-Don8gv0n.js → step-3-DAUCAcxW.js} +7 -7
- package/core/built/admin/assets/activitypub/{tabs-DTpfm-wu.js → tabs-B_6UuI7r.js} +3 -3
- package/core/built/admin/assets/activitypub/{topic-filter-Oee10885.js → topic-filter--FT1A_dc.js} +2 -2
- package/core/built/admin/assets/admin-x-settings/admin-x-settings.js +1 -1
- package/core/built/admin/assets/admin-x-settings/{code-editor-view-CGZuiDGx.js → code-editor-view-Bp_sCJR0.js} +2 -2
- package/core/built/admin/assets/admin-x-settings/{index-CwEblQZC.js → index-BPXA3pTW.js} +5 -5
- package/core/built/admin/assets/admin-x-settings/{index-rr_UntGE.js → index-BS375mg1.js} +3 -3
- package/core/built/admin/assets/admin-x-settings/{index-BpM6W2br.js → index-B_PlQoEG.js} +3 -3
- package/core/built/admin/assets/admin-x-settings/{index-BGdS5xw4.js → index-BflhAbu2.js} +3 -3
- package/core/built/admin/assets/admin-x-settings/{index-DtWUeJhp.js → index-CftMe8fe.js} +3 -3
- package/core/built/admin/assets/admin-x-settings/{index-B65inCwj.js → index-DRB7FH6y.js} +2 -2
- package/core/built/admin/assets/admin-x-settings/{index-DSX261S9.js → index-DijZ3oAM.js} +2 -2
- package/core/built/admin/assets/admin-x-settings/{index-DF6YEs01.js → index-cV0Lof9H.js} +1526 -1500
- package/core/built/admin/assets/admin-x-settings/{index-CluZYkUC.js → index-qc4x3vZj.js} +3 -3
- package/core/built/admin/assets/admin-x-settings/{modals-Bf4KOU31.js → modals-CkjuEByw.js} +55 -67
- package/core/built/admin/assets/{arrow-right-BxP3aeA5.js → arrow-right-BF77Yx73.js} +1 -1
- package/core/built/admin/assets/{at-sign-Bf0y-jim.js → at-sign-DhJF3n_V.js} +1 -1
- package/core/built/admin/assets/{audience-DHR1WgFK.js → audience-DHPKKayV.js} +1 -1
- package/core/built/admin/assets/{automated-emails-DbJbDLib.js → automated-emails-DInKYTEC.js} +1 -1
- package/core/built/admin/assets/{automations-aLgTzSsZ.js → automations-DJpeZw9T.js} +1 -1
- package/core/built/admin/assets/automations-DpQKN9j0.js +1 -0
- package/core/built/admin/assets/{avatar-flipboard-B0F2LMW5.js → avatar-flipboard-yRdmFC6R.js} +1 -1
- package/core/built/admin/assets/{bluesky-sharing-DjhtIuyr.js → bluesky-sharing-qSiCERoR.js} +1 -1
- package/core/built/admin/assets/{chart-BGwxlD0z.js → chart-CP2N9ZC-.js} +1 -1
- package/core/built/admin/assets/{chevron-up-C2FeVzre.js → chevron-up-BQ6fOpFR.js} +1 -1
- package/core/built/admin/assets/{chunk.524.31b31f7958dfae110016.js → chunk.524.ad4560630d4d62fbceb5.js} +4 -4
- package/core/built/admin/assets/{chunk.582.a855020953886af6e83b.js → chunk.582.fd4878e4e0af31ef86c0.js} +6 -6
- package/core/built/admin/assets/{chunk.972.258e6b1dab79b2189f1c.js → chunk.98.69968e0f393d82c2949c.js} +4 -4
- package/core/built/admin/assets/{code-editor-view-DzPkm_nJ.js → code-editor-view-CVODiRVJ.js} +1 -1
- package/core/built/admin/assets/{comments-DgItXUWN.js → comments-CP-NxopD.js} +1 -1
- package/core/built/admin/assets/{content-helpers-BNefU_PE.js → content-helpers-Crzkusiq.js} +1 -1
- package/core/built/admin/assets/{copy-DoNNUZlb.js → copy-r1LFsU75.js} +1 -1
- package/core/built/admin/assets/{data-list-CO1cZQRU.js → data-list-CzSc7z-2.js} +1 -1
- package/core/built/admin/assets/{deleted-feed-item-DC2wSAhv.js → deleted-feed-item-PyEM8FiX.js} +1 -1
- package/core/built/admin/assets/{dropzone-BTODLafn.js → dropzone-DI8A9qO6.js} +1 -1
- package/core/built/admin/assets/{edit-profile-BMMpmWIZ.js → edit-profile-DlJ64lV7.js} +1 -1
- package/core/built/admin/assets/editor-CevNZicQ.js +8 -0
- package/core/built/admin/assets/{empty-indicator-Dza0FQlj.js → empty-indicator-Dxg05yWg.js} +1 -1
- package/core/built/admin/assets/{en-yf9qAqTu.js → en-D93GVp3o.js} +1 -1
- package/core/built/admin/assets/{eye-CAqnnfQF.js → eye-6POPPpTw.js} +1 -1
- package/core/built/admin/assets/{feed-BkNsbWiF.js → feed-P_RMYb5x.js} +1 -1
- package/core/built/admin/assets/{field-Ddb1ZOqM.js → field-DeNjwWrL.js} +1 -1
- package/core/built/admin/assets/{filter-query-core-5Mac92kh.js → filter-query-core-DFs5WSmA.js} +1 -1
- package/core/built/admin/assets/{filters-BCb4bgtg.js → filters-C_BSQgb7.js} +1 -1
- package/core/built/admin/assets/{gh-chart-C6zkIg8k.js → gh-chart-pNHAbeQn.js} +1 -1
- package/core/built/admin/assets/{ghost-5313258fd425ced5db6516acde01ba36.js → ghost-3f5b3569e0beec61266cb74077677fbc.js} +3 -3
- package/core/built/admin/assets/{growth-ezUlN8OE.js → growth-B83tVOYO.js} +1 -1
- package/core/built/admin/assets/{hash-DE2OmChI.js → hash-BCTATV5W.js} +1 -1
- package/core/built/admin/assets/{inbox-OthiHvlV.js → inbox-rE3c5suT.js} +1 -1
- package/core/built/admin/assets/{index-BLyzLfyx.js → index-7EiRc5Ay.js} +1 -1
- package/core/built/admin/assets/{index-CV5v0eFE.js → index-B5bpZGTI.js} +1 -1
- package/core/built/admin/assets/index-BNtzAd7H.css +1 -0
- package/core/built/admin/assets/{index-BC1yWeaJ.js → index-BT33w2Io.js} +1 -1
- package/core/built/admin/assets/{index-DjffQ3VJ.js → index-BbkXWdhb.js} +1 -1
- package/core/built/admin/assets/{index-DH6PA3W6.js → index-BfhSrnrJ.js} +1 -1
- package/core/built/admin/assets/{index-CRvK0Iac.js → index-BmR_OUpb.js} +1 -1
- package/core/built/admin/assets/{index-CNV7fxKZ.js → index-BuhMgn5c.js} +1 -1
- package/core/built/admin/assets/{index-pkixJbdq.js → index-C-075SzJ.js} +34 -34
- package/core/built/admin/assets/{index-DJoByVS8.js → index-CB3hJd9E.js} +1 -1
- package/core/built/admin/assets/{index-D3bb-MEJ.js → index-CCISLIQd.js} +1 -1
- package/core/built/admin/assets/{index-BIEhcKiV.js → index-Cnptpx11.js} +1 -1
- package/core/built/admin/assets/{index-DK1cu59e.js → index-CrBRU81r.js} +1 -1
- package/core/built/admin/assets/{index-B0_p1-R0.js → index-CscUHFJp.js} +1 -1
- package/core/built/admin/assets/{index-Bi5qzf86.js → index-D3ZzfuJt.js} +1 -1
- package/core/built/admin/assets/{index-CKPny_6u.js → index-D4wn-U0V.js} +1 -1
- package/core/built/admin/assets/{index-YzcsD17L.js → index-DNRlkUeu.js} +1 -1
- package/core/built/admin/assets/{index-BoMsDCxD.js → index-D_G6negZ.js} +1 -1
- package/core/built/admin/assets/{index-CwsmINtV.js → index-DfxHSK1s.js} +1 -1
- package/core/built/admin/assets/{index-X91I8PcS.js → index-Dpc3COTl.js} +1 -1
- package/core/built/admin/assets/{index-c1h-EQpd.js → index-UsbnU2jy.js} +1 -1
- package/core/built/admin/assets/{index-oKgNVmwC.js → index-VfrJzh5m.js} +1 -1
- package/core/built/admin/assets/{index-D5MrQBSe.js → index-fbxc8Dpt.js} +1 -1
- package/core/built/admin/assets/{input-group-BOLMrDfJ.js → input-group-BLygwiDK.js} +1 -1
- package/core/built/admin/assets/{koenig-lexical-DlzcWUPw.js → koenig-lexical-B9U3sBS5.js} +1 -1
- package/core/built/admin/assets/{kpi-card-BlF7JKRC.js → kpi-card-Bmnvvp4X.js} +1 -1
- package/core/built/admin/assets/{kpi-card-HDshm3lO.js → kpi-card-CGVtzdgJ.js} +1 -1
- package/core/built/admin/assets/{kpi-tabs-Dty6zMSP.js → kpi-tabs-DxbvMkIU.js} +1 -1
- package/core/built/admin/assets/{kpis-CFz4r5wW.js → kpis-CQBAGVjP.js} +1 -1
- package/core/built/admin/assets/{label-CVzNcbjb.js → label-DpTwHQi_.js} +1 -1
- package/core/built/admin/assets/{links-D9dHwDlP.js → links-Bdw25FJF.js} +1 -1
- package/core/built/admin/assets/{list-page-shoQED7N.js → list-page-BvTQwP5F.js} +1 -1
- package/core/built/admin/assets/{loader-circle-cad701gH.js → loader-circle-3HJkQKWf.js} +1 -1
- package/core/built/admin/assets/{mail-DG4PKpZy.js → mail-DvrqP73n.js} +1 -1
- package/core/built/admin/assets/{main-layout-BmFla3Se.js → main-layout-BAPpm0bz.js} +1 -1
- package/core/built/admin/assets/{members-d19Z6k1C.js → members-CF4CzJSf.js} +1 -1
- package/core/built/admin/assets/minus-DJIePlnU.js +1 -0
- package/core/built/admin/assets/modals-CVsVi0zu.js +35 -0
- package/core/built/admin/assets/{moderation-BWBLnh4h.js → moderation-BX1KH5QL.js} +1 -1
- package/core/built/admin/assets/{newsletter-DNY4MroI.js → newsletter-BlKeb58e.js} +1 -1
- package/core/built/admin/assets/{newsletters-B10iBPP-.js → newsletters-3In8H0Z5.js} +1 -1
- package/core/built/admin/assets/{note-S0b6wjRR.js → note-ybwJCAxm.js} +1 -1
- package/core/built/admin/assets/{offers-B-9mZqKd.js → offers-Cl0ZNEMr.js} +1 -1
- package/core/built/admin/assets/{onboarding-route-AMFn0X5G.js → onboarding-route-A3ECeMAi.js} +1 -1
- package/core/built/admin/assets/{overview-WKadyZRW.js → overview-DrMrfsk-.js} +1 -1
- package/core/built/admin/assets/{pagemenu-BofQcFaF.js → pagemenu-O7HbsehH.js} +1 -1
- package/core/built/admin/assets/{pencil-LfMcD0vS.js → pencil-CknTbJeE.js} +1 -1
- package/core/built/admin/assets/{pin-CayUjL8e.js → pin-BNs-JdQ3.js} +1 -1
- package/core/built/admin/assets/{post-analytics-DMHvt3Jl.js → post-analytics-Dk1VloZp.js} +1 -1
- package/core/built/admin/assets/{post-analytics-context-10cqioP1.js → post-analytics-context-kPL94Ivz.js} +1 -1
- package/core/built/admin/assets/{post-analytics-header-DlICE18K.js → post-analytics-header-CpMOozq-.js} +1 -1
- package/core/built/admin/assets/{post-share-modal-Cfwy2UwD.js → post-share-modal-F0dobdhF.js} +1 -1
- package/core/built/admin/assets/posts/{alert-dialog-cQK32v9G.js → alert-dialog-NoPLULhG.js} +5 -5
- package/core/built/admin/assets/posts/{app-utils-DQ2hixop.js → app-utils-BiM9QO4L.js} +3 -3
- package/core/built/admin/assets/posts/{automations-BqkU9-zY.js → automations-BgIAmq9f.js} +3 -3
- package/core/built/admin/assets/posts/{automations-CoilKpVH.js → automations-D_XwO405.js} +30 -30
- package/core/built/admin/assets/posts/{avatar-BejAO6Rj.js → avatar-BYsYOpmq.js} +5 -5
- package/core/built/admin/assets/posts/{badge-BYGRyd2f.js → badge-B54vLono.js} +2 -2
- package/core/built/admin/assets/posts/{button-CG2Dpjqy.js → button-DMLfwOQt.js} +3 -3
- package/core/built/admin/assets/posts/{check-fsC5BvGC.js → check-D6qDi62T.js} +2 -2
- package/core/built/admin/assets/posts/{comments-CsyF5C1S.js → comments-CyYCbvUG.js} +26 -26
- package/core/built/admin/assets/posts/{data-list-JslRF2F5.js → data-list-B0DrMm-x.js} +4 -4
- package/core/built/admin/assets/posts/{dialog-3KY3A8t5.js → dialog-DtEZpY1q.js} +3 -3
- package/core/built/admin/assets/posts/{editor-3HPW_xW4.js → editor-LJHLmUoW.js} +1943 -1943
- package/core/built/admin/assets/posts/{ellipsis-BhK5S70U.js → ellipsis-JeIF0Biz.js} +2 -2
- package/core/built/admin/assets/posts/{empty-indicator-C9DbE9wZ.js → empty-indicator-dktzN32y.js} +2 -2
- package/core/built/admin/assets/posts/{filters-BCBDCnQF.js → filters-D1L-LU_m.js} +10 -10
- package/core/built/admin/assets/posts/{get-site-timezone-83C41MGz.js → get-site-timezone-dsyl8nlB.js} +3 -3
- package/core/built/admin/assets/posts/{growth-COoL1kMe.js → growth-yX8UB_ce.js} +12 -12
- package/core/built/admin/assets/posts/{heading-D3VqNO3z.js → heading-CNte43wH.js} +2 -2
- package/core/built/admin/assets/posts/{hooks-5YpJYWOw.js → hooks-BIgv7QBp.js} +2 -2
- package/core/built/admin/assets/posts/{index-Dqn5WIFh.js → index-2FO6Vy0r.js} +11 -11
- package/core/built/admin/assets/posts/{input-C1qcZBGw.js → input-BycmlCp8.js} +3 -3
- package/core/built/admin/assets/posts/{input-surface-C4vUAdbV.js → input-surface-vY3ACaso.js} +2 -2
- package/core/built/admin/assets/posts/{koenig-lexical-NZjxFY0X.js → koenig-lexical-Cq8SUcZC.js} +2 -2
- package/core/built/admin/assets/posts/{kpis-C2FEXoUT.js → kpis-CAJcU1w0.js} +27 -27
- package/core/built/admin/assets/posts/{label-CmJzmJY7.js → label-BmLTflMF.js} +3 -3
- package/core/built/admin/assets/posts/{links-nzud7t_t.js → links-BVcmMZmF.js} +4 -4
- package/core/built/admin/assets/posts/{list-page-D_rv4TgN.js → list-page-DX2WRn5T.js} +4 -4
- package/core/built/admin/assets/posts/{loading-indicator-DAOD6O2b.js → loading-indicator-C6FD4nS6.js} +3 -3
- package/core/built/admin/assets/posts/{mail-CtH0gTpq.js → mail-BMyoNUVM.js} +2 -2
- package/core/built/admin/assets/posts/{main-layout-VqvCxOXQ.js → main-layout-ClnxdW1Y.js} +2 -2
- package/core/built/admin/assets/posts/{message-circle-D4bCjxKS.js → message-circle-DwfHX-p1.js} +2 -2
- package/core/built/admin/assets/posts/{newsletter-BfwFyv6d.js → newsletter-Bid5_Bim.js} +19 -19
- package/core/built/admin/assets/posts/{overview-DKGum6ro.js → overview-BXti6Wg_.js} +18 -18
- package/core/built/admin/assets/posts/{pencil-Cffx-vm3.js → pencil-ChTk8IpW.js} +2 -2
- package/core/built/admin/assets/posts/{plus-D2ekwsq0.js → plus-DIKls8C6.js} +2 -2
- package/core/built/admin/assets/posts/{popover-DdbdKflP.js → popover-DVZsAT5u.js} +4 -4
- package/core/built/admin/assets/posts/{post-analytics-BleJYoNZ.js → post-analytics-DBL_kS0g.js} +6 -6
- package/core/built/admin/assets/posts/{post-analytics-context-DT3Avn9Q.js → post-analytics-context-Dr5y5nxd.js} +6 -6
- package/core/built/admin/assets/posts/{post-analytics-header-BktlrM_v.js → post-analytics-header-LH2-Jzgp.js} +13 -13
- package/core/built/admin/assets/posts/{post-share-modal-G8v3ZuSg.js → post-share-modal-D4DrfNfJ.js} +6 -6
- package/core/built/admin/assets/posts/{posts-CdWV_nlm.js → posts-ByxhcCrn.js} +2 -2
- package/core/built/admin/assets/posts/posts.js +1 -1
- package/core/built/admin/assets/posts/{search-CXP00fG8.js → search-DZR23LP-.js} +2 -2
- package/core/built/admin/assets/posts/{settings-DEXxDYc2.js → settings-CWyOKKnK.js} +2 -2
- package/core/built/admin/assets/posts/{sheet-CXHmD_eT.js → sheet-CNe7II5c.js} +3 -3
- package/core/built/admin/assets/posts/{site-C6DajagV.js → site-H9RAiQVv.js} +2 -2
- package/core/built/admin/assets/posts/{skeleton-Bihnkn8q.js → skeleton-Cn6x1x_C.js} +3 -3
- package/core/built/admin/assets/posts/{source-icon-C3oQy3UI.js → source-icon-BZOYujd1.js} +4 -4
- package/core/built/admin/assets/posts/{stats-DFicPtCX.js → stats-ugHCg8Oe.js} +4 -4
- package/core/built/admin/assets/posts/{table-DSJmeU5t.js → table-dG3Q5X95.js} +2 -2
- package/core/built/admin/assets/posts/{tabs-oRdVpN8P.js → tabs--EW8uL5B.js} +4 -4
- package/core/built/admin/assets/posts/{tags-6v5Qt_05.js → tags-DVdOfiSf.js} +2 -2
- package/core/built/admin/assets/posts/{tags-Upnkm0CF.js → tags-i0HJqNYU.js} +16 -16
- package/core/built/admin/assets/posts/{tooltip-Ci7pesWi.js → tooltip-ZvsT1Fs9.js} +4 -4
- package/core/built/admin/assets/posts/{trash-2-NCYWjRlg.js → trash-2-BT9fEHUL.js} +2 -2
- package/core/built/admin/assets/posts/{value-CcwzOh2_.js → value-DoFcsWDk.js} +2 -2
- package/core/built/admin/assets/posts/{virtual-list-window-CNahQBXY.js → virtual-list-window-Bt47XODn.js} +3 -3
- package/core/built/admin/assets/posts/{web-C3KrPq0T.js → web-BMTRLT-h.js} +20 -20
- package/core/built/admin/assets/posts/{zap-k30mZEuO.js → zap-DcIfEzKX.js} +2 -2
- package/core/built/admin/assets/{posts-DAfLuxAA.js → posts-DODOCB1E.js} +1 -1
- package/core/built/admin/assets/{power-Drkzg1xX.js → power-BZ7BM82m.js} +1 -1
- package/core/built/admin/assets/{referrers-TYxTJ2On.js → referrers-xwNb6L-8.js} +1 -1
- package/core/built/admin/assets/{repeat-CTM1qAzl.js → repeat-DHMCQMCA.js} +1 -1
- package/core/built/admin/assets/{reply-DXN16g7W.js → reply-DoLURZi2.js} +1 -1
- package/core/built/admin/assets/{rocket-DLixlWs0.js → rocket-BDH89dZr.js} +1 -1
- package/core/built/admin/assets/{select-DbiLEqYb.js → select-oE39QRll.js} +1 -1
- package/core/built/admin/assets/{send-B71C_46D.js → send-QgRN_yRy.js} +1 -1
- package/core/built/admin/assets/{settings-BBMPA3MP.js → settings-CF4NLxuS.js} +4 -4
- package/core/built/admin/assets/{settings-lSFHFrsJ.js → settings-D7e6KLAi.js} +1 -1
- package/core/built/admin/assets/{share-modal-CXrYja6o.js → share-modal-BxIh7i7o.js} +1 -1
- package/core/built/admin/assets/{sort-button-WYo-9Kge.js → sort-button-CEe_40Pi.js} +1 -1
- package/core/built/admin/assets/{source-icon-D6BzjYPP.js → source-icon-CzTNLO6j.js} +1 -1
- package/core/built/admin/assets/{sprout-DVfG_qhy.js → sprout-B2fN41p-.js} +1 -1
- package/core/built/admin/assets/{square-BbUJwQJi.js → square-CJZsjE-3.js} +1 -1
- package/core/built/admin/assets/{stats-CnXALQ4j.js → stats-jTxCK1CB.js} +1 -1
- package/core/built/admin/assets/{stats-view-B-yeMUkl.js → stats-view-B4jz69N8.js} +1 -1
- package/core/built/admin/assets/{step-1-DUl_hlpV.js → step-1-BovjhDNc.js} +1 -1
- package/core/built/admin/assets/{step-2-DjX_A4Ke.js → step-2-ClG40BfX.js} +1 -1
- package/core/built/admin/assets/{step-3-CnDCCA8T.js → step-3-ZMSyEHZI.js} +1 -1
- package/core/built/admin/assets/{table-AagTvMa9.js → table-B8Pj96or.js} +1 -1
- package/core/built/admin/assets/{tabs-IDJWnQD-.js → tabs-BZosOk0o.js} +1 -1
- package/core/built/admin/assets/{tags-CXAcIDw-.js → tags-BpWoYBfB.js} +1 -1
- package/core/built/admin/assets/{tags-C3lykbgu.js → tags-DZukMyuU.js} +1 -1
- package/core/built/admin/assets/{textarea-Cc3nUXep.js → textarea-BtnzsOk7.js} +1 -1
- package/core/built/admin/assets/{thumbs-down-SsjC2lMD.js → thumbs-down-CZTzyz7D.js} +1 -1
- package/core/built/admin/assets/{tiers-J8AeZmRd.js → tiers-Do7zBqAk.js} +1 -1
- package/core/built/admin/assets/{toggle-group-BzD8yimX.js → toggle-group-abk9FYXi.js} +1 -1
- package/core/built/admin/assets/{topic-filter-CA_L6ehz.js → topic-filter-CdMvjkmc.js} +1 -1
- package/core/built/admin/assets/{trash-BKhRqxsX.js → trash-DNXRsBf0.js} +1 -1
- package/core/built/admin/assets/{underline-_HIgX6e1.js → underline-HXWuVCAi.js} +1 -1
- package/core/built/admin/assets/{undo-2-ClkkOS0O.js → undo-2-C2ntNJKC.js} +1 -1
- package/core/built/admin/assets/{upload-DEPHbyvo.js → upload-D52l7HIb.js} +1 -1
- package/core/built/admin/assets/{use-growth-stats-BM2qWt0C.js → use-growth-stats-Dgs0UxDT.js} +1 -1
- package/core/built/admin/assets/{use-simple-pagination-zyklfekn.js → use-simple-pagination-Cj2rVggA.js} +1 -1
- package/core/built/admin/assets/{user-round-check-DoaGU2hC.js → user-round-check-C0GdT99c.js} +1 -1
- package/core/built/admin/assets/{user-round-x-CwEKNuU6.js → user-round-x-CVCvxuUG.js} +1 -1
- package/core/built/admin/assets/{virtual-list-window-C0Cv0gUC.js → virtual-list-window-mdQS2bt_.js} +1 -1
- package/core/built/admin/assets/{wallet-cards-BjdG5glh.js → wallet-cards-CtLF01jQ.js} +1 -1
- package/core/built/admin/assets/{web-BZNnanCT.js → web-DTib8_n8.js} +1 -1
- package/core/built/admin/index.html +6 -6
- package/core/frontend/helpers/ghost_foot.js +12 -2
- package/core/frontend/helpers/prev_post.js +1 -1
- package/core/frontend/helpers/tpl/gift-toast.hbs +130 -0
- package/core/frontend/services/proxy.js +9 -0
- package/core/frontend/services/routing/controllers/entry/canonical-url.js +15 -0
- package/core/frontend/services/routing/controllers/entry/canonical-url.ts +14 -0
- package/core/frontend/services/routing/controllers/entry/gift-links.js +82 -0
- package/core/frontend/services/routing/controllers/entry/gift-links.ts +92 -0
- package/core/frontend/services/routing/controllers/entry/markdown.js +62 -0
- package/core/frontend/services/routing/controllers/entry/markdown.ts +66 -0
- package/core/frontend/services/routing/controllers/entry.js +96 -105
- package/core/frontend/services/routing/controllers/entry.ts +97 -0
- package/core/frontend/services/routing/controllers/index.js +1 -1
- package/core/frontend/web/middleware/frontend-caching.js +9 -0
- package/core/server/adapters/cache/Redis.js +0 -1
- package/core/server/adapters/redirects/RedirectsStoreBase.d.ts +0 -4
- package/core/server/adapters/scheduling/scheduling-default.js +8 -1
- package/core/server/api/endpoints/gift-links.js +23 -16
- package/core/server/api/endpoints/gift-links.ts +25 -17
- package/core/server/api/endpoints/index.js +0 -1
- package/core/server/api/endpoints/previews.js +3 -24
- package/core/server/api/endpoints/utils/serializers/output/gift-links.js +4 -4
- package/core/server/api/endpoints/utils/serializers/output/gift-links.ts +4 -4
- package/core/server/api/endpoints/utils/serializers/output/index.js +0 -1
- package/core/server/api/endpoints/utils/validators/input/automation_email_previews.js +8 -9
- package/core/server/api/endpoints/utils/validators/input/index.js +0 -1
- package/core/server/data/migrations/versions/6.48/2026-06-23-00-00-00-drop-gift-links-revoked-at.js +6 -0
- package/core/server/data/migrations/versions/6.48/2026-06-23-00-00-01-rename-gift-links-revoke-all-permission-to-remove-all.js +37 -0
- package/core/server/data/migrations/versions/6.48/2026-06-24-00-00-00-drop-gift-links-redemption-columns.js +10 -0
- package/core/server/data/schema/fixtures/fixtures.json +2 -2
- package/core/server/data/schema/schema.js +1 -4
- package/core/server/data/seeders/data-generator.js +4 -1
- package/core/server/data/seeders/importers/members-login-events-importer.js +0 -1
- package/core/server/data/seeders/importers/members-newsletters-importer.js +0 -1
- package/core/server/data/seeders/importers/members-paid-subscription-events-importer.js +0 -1
- package/core/server/data/seeders/importers/members-status-events-importer.js +0 -1
- package/core/server/data/seeders/importers/members-stripe-customers-importer.js +0 -1
- package/core/server/data/seeders/importers/members-stripe-customers-subscriptions-importer.js +0 -1
- package/core/server/data/seeders/importers/members-subscribe-events-importer.js +0 -1
- package/core/server/data/seeders/importers/members-subscription-created-events-importer.js +0 -1
- package/core/server/lib/lexical.js +62 -36
- package/core/server/lib/post-revisions.js +0 -2
- package/core/server/lib/post-revisions.ts +0 -3
- package/core/server/models/index.js +0 -3
- package/core/server/services/auth/reset-authentication.js +0 -2
- package/core/server/services/auth/reset-authentication.ts +0 -3
- package/core/server/services/auth/session/index.js +0 -1
- package/core/server/services/automations/automations-api.js +59 -17
- package/core/server/services/automations/automations-api.ts +69 -16
- package/core/server/services/automations/database-automations-repository.js +58 -3
- package/core/server/services/automations/database-automations-repository.ts +70 -3
- package/core/server/services/automations/stale-lock-cutoff.js +7 -0
- package/core/server/services/automations/stale-lock-cutoff.ts +5 -0
- package/core/server/services/email-address/email-address-parser.js.d.ts +0 -1
- package/core/server/services/email-service/batch-sending-service.js +99 -26
- package/core/server/services/email-service/email-service-wrapper.js +7 -2
- package/core/server/services/email-service/email-service.js +146 -4
- package/core/server/services/gift-links/database.js +0 -3
- package/core/server/services/gift-links/database.ts +1 -4
- package/core/server/services/gift-links/index.js +2 -2
- package/core/server/services/gift-links/index.ts +4 -2
- package/core/server/services/gift-links/models.js +0 -2
- package/core/server/services/gift-links/models.ts +0 -2
- package/core/server/services/gift-links/queries.js +2 -2
- package/core/server/services/gift-links/queries.ts +2 -2
- package/core/server/services/gift-links/serializers.js +0 -2
- package/core/server/services/gift-links/serializers.ts +0 -2
- package/core/server/services/gift-links/service.js +54 -35
- package/core/server/services/gift-links/service.ts +70 -35
- package/core/server/services/gifts/gift-reminder-scheduler.js +0 -2
- package/core/server/services/gifts/gift-reminder-scheduler.ts +0 -2
- package/core/server/services/indexnow.js +8 -1
- package/core/server/services/internal-keys/index.js +0 -1
- package/core/server/services/internal-keys/index.ts +0 -2
- package/core/server/services/lib/dynamic-redirect-manager.d.ts +0 -1
- package/core/server/services/lib/in-memory-repository.js +0 -1
- package/core/server/services/lib/in-memory-repository.ts +0 -2
- package/core/server/services/members/api.js +0 -3
- package/core/server/services/members/create-paid-member-shim.js +31 -0
- package/core/server/services/members/create-paid-member-shim.ts +31 -0
- package/core/server/services/members/emails/signin.js +0 -1
- package/core/server/services/members/members-api/members-api.js +0 -2
- package/core/server/services/members/members-api/repositories/member-repository.js +0 -3
- package/core/server/services/members/service.js +4 -0
- package/core/server/services/post-scheduling/index.js +0 -2
- package/core/server/services/post-scheduling/index.ts +0 -2
- package/core/server/services/post-scheduling/post-scheduling.js +0 -5
- package/core/server/services/post-scheduling/post-scheduling.ts +0 -5
- package/core/server/services/recommendations/service/bookshelf-repository.js +0 -1
- package/core/server/services/recommendations/service/bookshelf-repository.ts +0 -4
- package/core/server/services/recommendations/service/incoming-recommendation-service.js +0 -1
- package/core/server/services/recommendations/service/incoming-recommendation-service.ts +0 -1
- package/core/server/services/recommendations/service/recommendation-controller.js +0 -1
- package/core/server/services/recommendations/service/recommendation-controller.ts +0 -1
- package/core/server/services/recommendations/service/recommendation-metadata-service.js +0 -1
- package/core/server/services/recommendations/service/recommendation-metadata-service.ts +0 -1
- package/core/server/services/recommendations/service/recommendation.js +0 -1
- package/core/server/services/recommendations/service/recommendation.ts +0 -1
- package/core/server/services/remote-flags/index.js +0 -1
- package/core/server/services/remote-flags/index.ts +0 -1
- package/core/server/services/slack.js +5 -1
- package/core/server/services/update-check/index.js +0 -1
- package/core/server/services/url/lazy-find-resource.js +0 -1
- package/core/server/services/url/lazy-find-resource.ts +0 -2
- package/core/server/services/url/lazy-url-service.js +0 -1
- package/core/server/services/url/lazy-url-service.ts +0 -2
- package/core/server/services/url/permalink-matcher.js +0 -1
- package/core/server/services/url/permalink-matcher.ts +0 -2
- package/core/server/services/url/router-filter.js +0 -2
- package/core/server/services/url/router-filter.ts +0 -2
- package/core/server/services/url/url-service-facade.js +0 -1
- package/core/server/services/url/url-service-facade.ts +0 -2
- package/core/server/services/verification/verification-webhook-service.js +0 -1
- package/core/server/services/verification/verification-webhook-service.ts +0 -1
- package/core/server/web/api/endpoints/admin/routes.js +7 -7
- package/core/shared/events-ts/post-deleted-event.js +0 -2
- package/core/shared/events-ts/post-deleted-event.ts +0 -2
- package/core/shared/labs.js +0 -1
- package/package.json +8 -16
- package/pnpm-lock.yaml +162 -113
- package/core/built/admin/assets/automations-BthXBzzq.js +0 -1
- package/core/built/admin/assets/editor-91xrI2A3.js +0 -8
- package/core/built/admin/assets/index-BYb09f-7.css +0 -1
- package/core/built/admin/assets/minus-DmrVsJ-z.js +0 -1
- package/core/built/admin/assets/modals-dnqxCS3l.js +0 -35
- package/core/server/models/outbox.js +0 -24
- package/core/server/services/outbox/events/start-outbox-processing-event.js +0 -22
- package/core/server/services/outbox/handlers/member-created.js +0 -85
- package/core/server/services/outbox/index.js +0 -49
- package/core/server/services/outbox/jobs/index.js +0 -30
- package/core/server/services/outbox/jobs/lib/constants.js +0 -17
- package/core/server/services/outbox/jobs/lib/process-entries.js +0 -117
- package/core/server/services/outbox/jobs/lib/process-outbox.js +0 -96
- package/core/server/services/outbox/jobs/outbox-job.js +0 -36
- package/types/ghost-storage-base.d.ts +0 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./code-editor-view-
|
|
2
|
-
import{d$ as u,bx as Ky,cI as R,d2 as W,ed as v,ct as Co,aF as me,an as Gy,by as Eu,aq as zg,Y as $g,fR as qy,cD as Ls,d3 as Nf,cw as Yy,ec as qr,c3 as Xy,c4 as Jy,bo as Zy,bD as Qy,ce as ew,W as tw,bz as nw,aJ as rw,am as iw,c1 as sw,bB as ow,r as aw,cf as lw,X as cw,eX as uw,cL as wi,bm as Ao,eV as Mo,cO as dw,f0 as hw,fG as fw,fA as mw,cP as pw,cJ as Le,J as Nr,aL as _s,eO as gw,eP as bw,eK as vw,eY as Hg,f5 as ai,fh as Ye,dv as we,fe as Ug,cV as Xd,cT as Ot,cQ as Jd,dJ as xw,c_ as yw,eR as ww,d1 as Zd,fB as Bl,eo as rn,dl as Ys,cE as kw,du as Xs,cN as Sw,eM as Wg,cy as Cw,dc as Tf,b as Vl,f as Aw,i as Mw,l as Ew,m as jw,j as Nw,k as Tw,h as Dw,g as Ow,_ as Iw,a1 as Pw,a5 as Rw,aD as Lw,c2 as ju,be as _w,bh as Fw,bg as Bw,dV as Qd,dA as Kg,el as Vw,es as pi,aU as zw,bM as Nu,dZ as Tu,dz as Fs,dS as Gg,dO as $w,cu as Hw,cG as nr,c$ as Uw,fC as Ww,D as Kw,bs as Gw,aP as qg,eQ as qw,d0 as Yw,z as Xw,aV as Jw,e5 as Zw,cC as Qw}from"./index-pkixJbdq.js";import{e as zl,d as Sc,a as eh,u as Yg,c as e2,v as wt,n as Xg,i as t2,j as n2,g as r2,f as i2,k as s2,h as o2,m as a2,b as Jg,l as l2}from"./automated-emails-DbJbDLib.js";import{R as c2,C as u2,L as d2,e as h2,T as th,b as nh,c as zi,a as qa}from"./tabs-IDJWnQD-.js";import{a as $l,b as Zg,c as Qg,n as e0}from"./newsletters-B10iBPP-.js";import{_ as Js}from"./typeof-QjJsDpFa.js";import{D as f2}from"./dropzone-BTODLafn.js";import{g as t0,S as Eo,e as jo,f as No,a as To,c as $i}from"./select-DbiLEqYb.js";import{P as m2,U as p2,T as g2,B as b2}from"./underline-_HIgX6e1.js";import{T as Hl,a as Gn}from"./toggle-group-BzD8yimX.js";import{T as v2}from"./textarea-Cc3nUXep.js";import{c as rh,b as x2,g as y2,a as w2}from"./tiers-J8AeZmRd.js";import{a as k2}from"./offers-B-9mZqKd.js";import{u as S2}from"./referrers-TYxTJ2On.js";const Tt=({className:t})=>(t||(t="border-grey-200 dark:border-grey-800"),u.jsx(Ky,{asChild:!0,decorative:!0,children:u.jsx("hr",{className:t})})),n0=R("text-base font-semibold tracking-normal"),r0=R(n0,"text-base font-semibold text-grey-900 dark:text-grey-500"),qe=({level:t=1,children:e,styles:n="",grey:r=!0,separator:i,useLabelTag:s,className:o="",...a})=>{const l=`${s?"label":`h${t}`}`;if(n+=t===6||s?` block ${r?r0:n0}`:" ",!s)switch(t){case 1:n+=" md:text-4xl leading-tighter";break;case 2:n+=" md:text-3xl";break;case 3:n+=" md:text-2xl";break;case 4:n+=" md:text-xl";break;case 5:n+=" md:text-lg";break}o=R(n,!r&&"dark:text-white",o);const c=W.createElement(l,{className:o,key:"heading-elem",...a},e);if(i){const d=!t||t===1?2:1,h=t===6?2:3;return u.jsxs("div",{className:`gap-${d} mb-${h} flex flex-col`,children:[c,u.jsx(Tt,{})]})}else return c},on=({children:t,color:e,className:n,...r})=>{if(!t)return null;let i="text-grey-700 dark:text-grey-600";switch(e){case"red":i="text-red dark:text-red-500";break;case"green":i="text-green dark:text-green-500";break}return n=R("mt-1 inline-block leading-snug",i,n),u.jsx("span",{className:n,...r,children:t})},C2=W.lazy(()=>Co(()=>import("./code-editor-view-DzPkm_nJ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]),import.meta.url)),Df=v.forwardRef(function(e,n){return u.jsx(v.Suspense,{fallback:null,children:u.jsx(C2,{...e,ref:n})})}),Ul=({size:t,color:e,delay:n,style:r})=>{const[i,s]=W.useState(!n);W.useEffect(()=>{if(n){const a=setTimeout(()=>{s(!0)},n);return()=>{clearTimeout(a)}}},[n]);let o="relative mx-0 my-[-0.5] box-border inline-block animate-spin rounded-full before:z-10 before:block before:rounded-full before:content-[''] ";switch(t){case"sm":o+=" h-[16px] w-[16px] border-2 before:mt-[10px] before:h-[3px] before:w-[3px] ";break;case"md":o+=" h-[20px] w-[20px] border-2 before:mt-[13px] before:h-[3px] before:w-[3px] ";break;default:o+=" h-[50px] w-[50px] border before:mt-[7px] before:h-[7px] before:w-[7px] ";break}return e==="light"?o+=" border-white/20 before:bg-white dark:border-black/10 dark:before:bg-black ":o+=" border-black/10 before:bg-black dark:border-white/20 dark:before:bg-white ",t==="lg"?u.jsx("div",{className:`flex h-64 items-center justify-center transition-opacity ${i?"opacity-100":"opacity-0"}`,style:r,children:u.jsx("div",{className:o})}):u.jsx("div",{className:o})},J=W.forwardRef(({testId:t,size:e="md",label:n="",hideLabel:r=!1,icon:i="",iconSize:s,iconColorClass:o,color:a="clear",fullWidth:l,link:c,linkWithPadding:d=!1,disabled:h,unstyled:f=!1,className:m="",tag:p="button",loading:g=!1,loadingIndicatorColor:b,outlineOnMobile:x=!1,onClick:y,...w},k)=>{if(a||(a="clear"),!f){switch(m=R("text inline-flex items-center justify-center rounded-md whitespace-nowrap transition",c&&a!=="clear"&&a!=="black"||!c&&a!=="clear"?"font-bold":"font-semibold",c?"":`${e==="sm"?"h-7":"h-[34px]"}`,c?"":`${e==="sm"||n&&i?"px-3":"px-4"}`,c&&d&&"-m-1 p-1",m),a){case"black":m=R(c?"text-black hover:text-grey-800 dark:text-white":`bg-black text-white dark:bg-white dark:text-black ${!h&&"hover:bg-grey-900"}`,m),b="light",o=o||"text-white";break;case"light-grey":m=R(c?"text-grey-800 hover:text-green-400 dark:text-white":`bg-grey-200 text-black dark:bg-grey-900 dark:text-white ${!h&&"hover:bg-grey-300! dark:hover:bg-grey-800!"}`,m),b="dark";break;case"grey":m=R(c?"text-black hover:text-grey-800 dark:text-white":`bg-grey-100 text-black dark:bg-grey-900 dark:text-white ${!h&&"hover:bg-grey-300! dark:hover:bg-grey-800!"}`,m),b="dark";break;case"green":m=R(c?" text-green hover:text-green-400":` bg-green text-white ${!h&&"hover:bg-green-400"}`,m),b="light",o=o||"text-white";break;case"red":m=R(c?"text-red hover:text-red-400":`bg-red text-white ${!h&&"hover:bg-red-400"}`,m),b="light",o=o||"text-white";break;case"white":m=R(c?"text-white hover:text-white dark:text-black dark:hover:text-grey-800":"bg-white text-black dark:bg-black dark:text-white",m),b="dark";break;case"outline":m=R(c?"text-black hover:text-grey-800 dark:text-white":`border border-grey-300 bg-transparent text-black dark:border-grey-800 dark:text-white ${!h&&"hover:border-black! dark:hover:border-white!"}`,m),b="dark";break;default:m=R(c?" text-black hover:text-grey-800 dark:text-white":`text-grey-900 dark:text-white dark:hover:bg-grey-900 ${!h&&"hover:bg-grey-200 hover:text-black"}`,x&&!c&&"border border-grey-300 hover:border-transparent md:border-transparent",m),b="dark";break}m=R(l&&!c&&" w-full",h?"opacity-40":"cursor-pointer",m)}const C=n&&i&&!r?"mr-1.5":"";let S="";S+=n&&r?"sr-only":"",S+=g?"invisible":"",s=s||(e==="sm"||n&&i?"sm":"md");const A=u.jsxs(u.Fragment,{children:[i&&u.jsx(me,{className:C,colorClass:o,name:i,size:s}),u.jsx("span",{className:S,children:n}),g&&u.jsxs("div",{className:"absolute flex",children:[u.jsx(Ul,{color:b,size:e}),u.jsx("span",{className:"sr-only",children:"Loading..."})]})]});return W.createElement(p,{className:m,"data-testid":t,disabled:h,type:"button",onClick:y,ref:k,...w},A)});J.displayName="Button";function A2(t,e,n=!1){let r;return function(...i){const s=()=>{r=null,n||t.apply(this,i)},o=n&&!r;r&&clearTimeout(r),r=setTimeout(s,e),o&&t.apply(this,i)}}var it=function(){return it=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},it.apply(this,arguments)},i0=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n},Cc=Symbol("NiceModalId"),ih={},Qi=W.createContext(ih),s0=W.createContext(null),yn={},Zs={},M2=0,es=function(){throw new Error("No dispatch method detected, did you embed your app with NiceModal.Provider?")},o0=function(){return"_nice_modal_"+M2++},a0=function(t,e){var n,r,i;switch(t===void 0&&(t=ih),e.type){case"nice-modal/show":{var s=e.payload,o=s.modalId,a=s.args;return it(it({},t),(n={},n[o]=it(it({},t[o]),{id:o,args:a,visible:!!Zs[o],delayVisible:!Zs[o]}),n))}case"nice-modal/hide":{var o=e.payload.modalId;return t[o]?it(it({},t),(r={},r[o]=it(it({},t[o]),{visible:!1}),r)):t}case"nice-modal/remove":{var o=e.payload.modalId,l=it({},t);return delete l[o],l}case"nice-modal/set-flags":{var c=e.payload,o=c.modalId,d=c.flags;return it(it({},t),(i={},i[o]=it(it({},t[o]),d),i))}default:return t}};function E2(t){var e;return(e=yn[t])===null||e===void 0?void 0:e.comp}function j2(t,e){return{type:"nice-modal/show",payload:{modalId:t,args:e}}}function N2(t,e){return{type:"nice-modal/set-flags",payload:{modalId:t,flags:e}}}function T2(t){return{type:"nice-modal/hide",payload:{modalId:t}}}function D2(t){return{type:"nice-modal/remove",payload:{modalId:t}}}var rr={},ji={},Wl=function(t){return typeof t=="string"?t:(t[Cc]||(t[Cc]=o0()),t[Cc])};function sh(t,e){var n=Wl(t);if(typeof t!="string"&&!yn[n]&&Kl(n,t),es(j2(n,e)),!rr[n]){var r,i,s=new Promise(function(o,a){r=o,i=a});rr[n]={resolve:r,reject:i,promise:s}}return rr[n].promise}function oh(t){var e=Wl(t);if(es(T2(e)),delete rr[e],!ji[e]){var n,r,i=new Promise(function(s,o){n=s,r=o});ji[e]={resolve:n,reject:r,promise:i}}return ji[e].promise}var l0=function(t){var e=Wl(t);es(D2(e)),delete rr[e],delete ji[e]},O2=function(t,e){es(N2(t,e))};function an(t,e){var n=v.useContext(Qi),r=v.useContext(s0),i=null,s=t&&typeof t!="string";if(t?i=Wl(t):i=r,!i)throw new Error("No modal id found in NiceModal.useModal.");var o=i;v.useEffect(function(){s&&!yn[o]&&Kl(o,t,e)},[s,o,t,e]);var a=n[o],l=v.useCallback(function(p){return sh(o,p)},[o]),c=v.useCallback(function(){return oh(o)},[o]),d=v.useCallback(function(){return l0(o)},[o]),h=v.useCallback(function(p){var g;(g=rr[o])===null||g===void 0||g.resolve(p),delete rr[o]},[o]),f=v.useCallback(function(p){var g;(g=rr[o])===null||g===void 0||g.reject(p),delete rr[o]},[o]),m=v.useCallback(function(p){var g;(g=ji[o])===null||g===void 0||g.resolve(p),delete ji[o]},[o]);return v.useMemo(function(){return{id:o,args:a?.args,visible:!!a?.visible,keepMounted:!!a?.keepMounted,show:l,hide:c,remove:d,resolve:h,reject:f,resolveHide:m}},[o,a?.args,a?.visible,a?.keepMounted,l,c,d,h,f,m])}var I2=function(t){return function(e){var n,r=e.defaultVisible,i=e.keepMounted,s=e.id,o=i0(e,["defaultVisible","keepMounted","id"]),a=an(s),l=a.args,c=a.show,d=v.useContext(Qi),h=!!d[s];v.useEffect(function(){return r&&c(),Zs[s]=!0,function(){delete Zs[s]}},[s,c,r]),v.useEffect(function(){i&&O2(s,{keepMounted:!0})},[s,i]);var f=(n=d[s])===null||n===void 0?void 0:n.delayVisible;return v.useEffect(function(){f&&c(l)},[f,l,c]),h?W.createElement(s0.Provider,{value:s},W.createElement(t,it({},o,l))):null}},Kl=function(t,e,n){yn[t]?yn[t].props=n:yn[t]={comp:e,props:n}},P2=function(t){delete yn[t]},c0=function(){var t=v.useContext(Qi),e=Object.keys(t).filter(function(r){return!!t[r]});e.forEach(function(r){if(!yn[r]&&!Zs[r]){console.warn("No modal found for id: "+r+". Please check the id or if it is registered or declared via JSX.");return}});var n=e.filter(function(r){return yn[r]}).map(function(r){return it({id:r},yn[r])});return W.createElement(W.Fragment,null,n.map(function(r){return W.createElement(r.comp,it({key:r.id,id:r.id},r.props))}))},R2=function(t){var e=t.children,n=v.useReducer(a0,ih),r=n[0];return es=n[1],W.createElement(Qi.Provider,{value:r},e,W.createElement(c0,null))},L2=function(t){var e=t.children,n=t.dispatch,r=t.modals;return!n||!r?W.createElement(R2,null,e):(es=n,W.createElement(Qi.Provider,{value:r},e,W.createElement(c0,null)))},_2=function(t){var e=t.id,n=t.component;return v.useEffect(function(){return Kl(e,n),function(){P2(e)}},[e,n]),null},F2=function(t){var e,n=t.modal,r=t.handler,i=r===void 0?{}:r,s=i0(t,["modal","handler"]),o=v.useMemo(function(){return o0()},[]),a=typeof n=="string"?(e=yn[n])===null||e===void 0?void 0:e.comp:n;if(!i)throw new Error("No handler found in NiceModal.ModalHolder.");if(!a)throw new Error("No modal found for id: "+n+" in NiceModal.ModalHolder.");return i.show=v.useCallback(function(l){return sh(o,l)},[o]),i.hide=v.useCallback(function(){return oh(o)},[o]),W.createElement(a,it({id:o},s))},B2=function(t){return{visible:t.visible,onOk:function(){return t.hide()},onCancel:function(){return t.hide()},afterClose:function(){t.resolveHide(),t.keepMounted||t.remove()}}},V2=function(t){return{visible:t.visible,onClose:function(){return t.hide()},afterVisibleChange:function(e){e||t.resolveHide(),!e&&!t.keepMounted&&t.remove()}}},z2=function(t){return{open:t.visible,onClose:function(){return t.hide()},onExited:function(){t.resolveHide(),!t.keepMounted&&t.remove()}}},$2=function(t){return{show:t.visible,onHide:function(){return t.hide()},onExited:function(){t.resolveHide(),!t.keepMounted&&t.remove()}}},pe={Provider:L2,ModalDef:_2,ModalHolder:F2,NiceModalContext:Qi,create:I2,register:Kl,getModal:E2,show:sh,hide:oh,remove:l0,useModal:an,reducer:a0,antdModal:B2,antdDrawer:V2,muiDialog:z2,bootstrapDialog:$2};const u0=W.createContext({isDirty:!1,setGlobalDirtyState:()=>{}}),H2=({children:t})=>{const[e,n]=v.useState([]),r=v.useCallback((i,s)=>{n(o=>s&&!o.includes(i)?[...o,i]:!s&&o.includes(i)?o.filter(a=>a!==i):o)},[]);return u.jsx(u0.Provider,{value:{isDirty:e.length>0,setGlobalDirtyState:r},children:t})},Gl=()=>{const t=v.useId(),{isDirty:e,setGlobalDirtyState:n}=v.useContext(u0);v.useEffect(()=>()=>n(t,!1),[t,n]);const r=v.useCallback(i=>n(t,i),[t,n]);return{isDirty:e,setGlobalDirtyState:r}},d0=v.createContext({isAnyTextFieldFocused:!1,setFocusState:()=>{},fetchKoenigLexical:async()=>{},darkMode:!1}),ah=()=>v.useContext(d0),ts=()=>{const t=ah();if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t},U2=({fetchKoenigLexical:t,darkMode:e,children:n})=>{const[r,i]=v.useState(!1),s=o=>{i(o)};return u.jsx(d0.Provider,{value:{isAnyTextFieldFocused:r,setFocusState:s,fetchKoenigLexical:t,darkMode:e},children:u.jsxs(H2,{children:[u.jsx(Gy,{}),u.jsx(pe.Provider,{children:n})]})})},at=({type:t="text",inputRef:e,title:n,hideTitle:r,value:i,error:s,placeholder:o,rightPlaceholder:a,hint:l,onChange:c,onFocus:d,onBlur:h,clearBg:f=!1,className:m="",maxLength:p,containerClassName:g="",hintClassName:b="",unstyled:x=!1,disabled:y,...w})=>{const k=v.useId(),{setFocusState:C}=ts(),S=O=>{d?.(O),C(!0)},A=O=>{h?.(O),C(!1)},M=R("relative order-2 flex w-full items-center",n&&!r&&"mt-1.5"),E=!x&&R("absolute inset-0 rounded-lg border text-grey-300 transition-colors peer-hover:bg-grey-100 peer-focus:border-green peer-focus:bg-white peer-focus:shadow-[0_0_0_2px_rgba(48,207,67,.25)] dark:peer-hover:bg-grey-900 dark:peer-focus:bg-grey-950",s?"border-red bg-white dark:bg-grey-900":"border-transparent bg-grey-100 dark:bg-grey-900",y&&"bg-grey-50 shadow-[0_0_0_1px_rgba(255,255,255,0.45)] peer-hover:bg-grey-50 dark:bg-grey-950 dark:shadow-[0_0_0_1px_rgba(255,255,255,0.18)] dark:peer-hover:bg-grey-950"),j=!x&&R("peer z-[1] order-2 h-[var(--control-height)] w-full bg-transparent px-3 py-1.5 placeholder:text-grey-500 md:h-[var(--control-height)] md:py-2 dark:placeholder:text-grey-700",y?"cursor-not-allowed text-grey-600 dark:text-grey-800":"dark:text-white",a?"w-0 grow rounded-l-lg":"rounded-lg",m),T=!x&&R("z-[1] order-3 rounded-r-lg",a?typeof a=="string"?"flex h-[var(--control-height)] items-center py-1 pr-3 text-right text-grey-500":"pr-1":"pr-2");let N=u.jsx(u.Fragment,{});const D=u.jsx("input",{ref:e,className:j||m,disabled:y,id:k,maxLength:p,placeholder:o,type:t,value:i,onBlur:A,onChange:c,onFocus:S,...w});return N=u.jsx(zg,{name:k,asChild:!0,children:u.jsxs("div",{className:M,children:[u.jsx($g,{asChild:!0,children:D}),!x&&!f&&u.jsx("div",{className:E||""}),a&&u.jsx("span",{className:T||"",children:a})]})}),b=R("order-3",b),g=R("flex flex-col",g),n||l?u.jsx(Eu,{asChild:!0,children:u.jsxs("div",{className:g,children:[N,n&&u.jsx(qe,{className:r?"sr-only":"order-1",htmlFor:k,useLabelTag:!0,children:n}),l&&u.jsx(on,{className:b,color:s?"red":"default",children:l})]})}):u.jsx(Eu,{asChild:!0,children:N})},W2=({valueInCents:t,onChange:e,...n})=>{const[r,i]=v.useState(t===""?"":((t||0)/100).toString()),s=a=>a.replace(/[^\d.]+/g,""),o=a=>Math.round(parseFloat(a.match(/[\d]+\.?[\d]{0,2}/)?.[0]||"0")*100);return u.jsx(at,{...n,value:r,onBlur:a=>{i((o(a.target.value)/100).toString()),n.onBlur?.(a)},onChange:a=>{i(s(a.target.value)),e?.(o(a.target.value))}})},Ya=({id:t,onUpload:e,children:n,style:r,unstyled:i=!1,inputRef:s,className:o,dragIndicatorClassName:a,accept:l,...c})=>{const[d,h]=v.useState(Date.now()),[f,m]=v.useState(!1),p=y=>{const w=y.target.files?.[0];w&&e?.(w),h(Date.now())},g=y=>{x(y);const w=y.dataTransfer.files?.[0];w&&e?.(w),h(Date.now())},b=y=>{y.preventDefault(),m(!0)},x=y=>{y.preventDefault(),m(!1)};return u.jsxs("label",{className:R("relative",o),htmlFor:t,style:r,onDragEnter:b,onDragLeave:x,onDragOver:b,onDrop:g,...c,children:[u.jsx("div",{className:R({"absolute inset-1 rounded":!0,"border-2 border-dashed border-grey-400/25":f},f&&[a])}),u.jsx("input",{ref:s||null,accept:l,id:t,type:"file",hidden:!0,onChange:p},d),typeof n=="string"?u.jsx("div",{className:i?"":"inline-flex h-[34px] cursor-pointer items-center justify-center rounded px-4 font-medium hover:bg-grey-100 dark:text-white dark:hover:bg-grey-900",children:n}):n]})},K2=({title:t,grouped:e=!1,gap:n="md",margins:r="md",marginTop:i=!1,marginBottom:s=!0,className:o="",children:a})=>{let l=R("flex flex-col",n==="xs"&&"gap-4",n==="sm"&&"gap-6",n==="md"&&"gap-8",n==="lg"&&"gap-11");r||(r=n),s&&(l=R(l,r==="sm"&&"mb-7",r==="md"&&"mb-10",r==="lg"&&"mb-12")),i&&(l=R(l,r==="sm"&&"mt-7",r==="md"&&"mt-10",r==="lg"&&"mt-12")),e&&(l=R(l,"rounded-sm border border-grey-200 p-4 md:p-7 dark:border-grey-900"));const c=R(e?"mb-3":"mb-4");return e||t?u.jsxs("div",{className:o,children:[t&&u.jsx(qe,{className:c,level:5,children:t}),u.jsx("div",{className:l,children:a})]}):u.jsx("div",{className:R(l,o),children:a})},h0=({color:t="grey",children:e,className:n})=>{const r=R("relative overflow-hidden rounded-sm p-2",t==="grey"&&"text-black",t==="blue"&&"text-blue",t==="green"&&"text-green",t==="yellow"&&"text-yellow-600",t==="red"&&"text-red","after:pointer-events-none after:absolute after:inset-0 after:block after:opacity-10 after:content-['']",t==="grey"&&"after:bg-grey-500",t==="blue"&&"after:bg-blue",t==="green"&&"after:bg-green",t==="yellow"&&"after:bg-yellow",t==="red"&&"after:bg-red",n);return u.jsx("div",{className:r,children:e})};class lh extends W.Component{state={hasError:!1};constructor(e){super(e)}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,n){qy(r=>{r.setTag("adminx_settings_component",n.componentStack),Ls(e)}),console.error(e),console.error("In component:",n.componentStack)}render(){return this.state.hasError?u.jsxs(h0,{color:"red",children:["An error occurred loading ",this.props.name,". Please refresh and try again."]}):this.props.children}}const Ce=(t,e)=>function(r){return u.jsx(lh,{name:e,children:u.jsx(t,{...r})})},f0=function(t){let e="pending",n;const r=t().then(s=>{e="success",n=s},s=>{e="error",n=s});return{read:()=>{switch(e){case"pending":throw r;case"error":throw n;default:return n}}}},G2=({editor:t,onBlur:e,placeholder:n,nodes:r,emojiPicker:i=!0,darkMode:s=!1,singleParagraph:o=!1,children:a,initialEditorState:l,onChange:c,fileUploader:d,cardConfig:h,registerAPI:f})=>{const m=v.useCallback(k=>{try{Ls({error:k,tags:{lexical:!0},contexts:{koenig:{version:window["@tryghost/koenig-lexical"]?.version}}})}catch(C){console.error(C)}console.error(k)},[]),{setFocusState:p}=ts(),g=()=>{e&&e(),p(!1)},b=()=>{p(!0)},x=v.useMemo(()=>new Proxy({},{get:(k,C)=>t.read()[C]}),[t]),y={DEFAULT_NODES:x.DEFAULT_TRANSFORMERS,BASIC_NODES:x.BASIC_TRANSFORMERS,MINIMAL_NODES:x.MINIMAL_TRANSFORMERS,EMAIL_NODES:x.EMAIL_TRANSFORMERS,EMAIL_EDITOR_NODES:x.EMAIL_TRANSFORMERS},w=r||"DEFAULT_NODES";return u.jsx(x.KoenigComposer,{cardConfig:h,darkMode:s,fileUploader:d,initialEditorState:l,nodes:x[w],onError:m,children:u.jsxs(x.KoenigComposableEditor,{className:"koenig-lexical koenig-lexical-editor-input",isSnippetsEnabled:!1,markdownTransformers:y[w],placeholderClassName:"koenig-lexical-editor-input-placeholder line-clamp-1",placeholderText:n,registerAPI:f,singleParagraph:o,onBlur:g,onChange:c,onFocus:b,children:[a(x),i?u.jsx(x.EmojiPickerPlugin,{}):null]})})},U_=({className:t,children:e,initialEditorState:n,onChange:r,inheritFontStyles:i=!0,loadingFallback:s,...o})=>{const{fetchKoenigLexical:a,darkMode:l}=ah(),c=v.useMemo(()=>f0(a),[a]),d=i?"[&_*]:font-inherit! [&_*]:[font-size:inherit]!":"";return u.jsx("div",{className:t||"w-full",children:u.jsx("div",{className:`koenig-react-editor w-full ${d}`,children:u.jsx(lh,{name:"editor",children:u.jsx(v.Suspense,{fallback:s||u.jsx("p",{className:"koenig-react-editor-loading",children:"Loading editor..."}),children:u.jsx(G2,{...o,darkMode:l,editor:c,initialEditorState:n,onChange:r,children:e})})})})})},Of=({id:t,children:e,width:n="100%",height:r="120px",imageURL:i,imageFit:s="cover",imageContainerClassName:o,imageClassName:a,fileUploadClassName:l,fileUploadProps:c,deleteButtonClassName:d,deleteButtonContent:h,deleteButtonUnstyled:f=!1,imageBWCheckedBg:m=!1,unstyled:p=!1,onUpload:g,onDelete:b,onImageClick:x,pintura:y,editButtonClassName:w,editButtonContent:k,editButtonUnstyled:C=!1,buttonContainerClassName:S,unsplashButtonClassName:A,unsplashButtonUnstyled:M=!1,unsplashButtonContent:E,unsplashEnabled:j,openUnsplash:T})=>{if(p||(o=R("group relative flex justify-center",o),a=R(s==="cover"&&"object-cover",s==="contain"&&"object-contain",s==="fill"&&"object-fill",s==="scale-down"&&"object-scale-down",s==="none"&&"object-scale-down",a),l=R("flex cursor-pointer items-center justify-center rounded border border-grey-100 bg-grey-50 p-3 font-medium text-grey-800 hover:text-black dark:border-grey-900 dark:bg-grey-900 dark:text-grey-400",l),f||(d=R("absolute top-4 right-4 flex size-8 cursor-pointer items-center justify-center rounded bg-[rgba(0,0,0,0.75)] text-white group-hover:visible! hover:bg-black md:invisible [@media(hover:none)]:visible!",d)),C||(w=R("absolute top-4 right-16 flex size-8 cursor-pointer items-center justify-center rounded bg-[rgba(0,0,0,0.75)] text-white group-hover:visible! hover:bg-black md:invisible [@media(hover:none)]:visible!",w)),M||(A=R("absolute top-4 right-16 flex size-8 cursor-pointer items-center justify-center rounded bg-[rgba(255,255,255)] text-white",A))),h=h||u.jsx(me,{colorClass:"text-white",name:"trash",size:"sm"}),k=k||u.jsx(me,{colorClass:"text-white",name:"pen",size:"sm"}),E=E||u.jsx(me,{colorClass:"text-black",name:"unsplash-logo",size:"sm"}),i){let N=u.jsxs("div",{className:o,"data-testid":"image-upload-container",style:{width:p?"":n,height:p?"":r},children:[u.jsx("img",{alt:"",className:a,id:t,src:i,style:{width:p?"":n||"100%",height:p?"":r||"auto"},onClick:x}),u.jsxs("div",{className:S,children:[y?.isEnabled&&y?.openEditor&&u.jsx("button",{className:w,type:"button",onClick:y.openEditor,children:k}),u.jsx("button",{className:d,"data-testid":"image-delete-button",type:"button",onClick:b,children:h})]})]});if(m){const D="#d9d9d9";N=u.jsx("div",{style:{backgroundImage:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./code-editor-view-CVODiRVJ.js","./index-C-075SzJ.js","./index-BNtzAd7H.css","./automated-emails-DInKYTEC.js","./offers-Cl0ZNEMr.js","./posts-DODOCB1E.js","./nql-X2E2VBtR.js","./tabs-BZosOk0o.js","./newsletters-3In8H0Z5.js","./typeof-QjJsDpFa.js","./dropzone-DI8A9qO6.js","./index-BuhMgn5c.js","./select-oE39QRll.js","./chevron-up-BQ6fOpFR.js","./underline-HXWuVCAi.js","./toggle-group-abk9FYXi.js","./textarea-BtnzsOk7.js","./tiers-Do7zBqAk.js","./referrers-xwNb6L-8.js","./index-DNRlkUeu.js","./index-BT33w2Io.js","./index-CscUHFJp.js","./index-D3ZzfuJt.js","./index-fbxc8Dpt.js","./_baseAssignValue-BjUm4QeA.js","./modals-CVsVi0zu.js","./index-BfhSrnrJ.js","./undo-2-C2ntNJKC.js","./index-Dpc3COTl.js","./pencil-CknTbJeE.js","./koenig-lexical-B9U3sBS5.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{d$ as u,bx as Ky,cI as R,d2 as W,ed as v,ct as Co,aF as me,an as Gy,by as Eu,aq as zg,Y as $g,fR as qy,cD as Ls,d3 as Nf,cw as Yy,ec as qr,c3 as Xy,c4 as Jy,bo as Zy,bD as Qy,ce as ew,W as tw,bz as nw,aJ as rw,am as iw,c1 as sw,bB as ow,r as aw,cf as lw,X as cw,eX as uw,cL as wi,bm as Ao,eV as Mo,cO as dw,f0 as hw,fG as fw,fA as mw,cP as pw,cJ as Le,J as Nr,aL as _s,eO as gw,eP as bw,eK as vw,eY as Hg,f5 as ai,fh as Ye,dv as we,fe as Ug,cV as Xd,cT as Ot,cQ as Jd,dJ as xw,c_ as yw,eR as ww,d1 as Zd,fB as Bl,eo as rn,dl as Ys,cE as kw,du as Xs,cN as Sw,eM as Wg,cy as Cw,dc as Tf,b as Vl,f as Aw,i as Mw,l as Ew,m as jw,j as Nw,k as Tw,h as Dw,g as Ow,_ as Iw,a1 as Pw,a5 as Rw,aD as Lw,c2 as ju,be as _w,bh as Fw,bg as Bw,dV as Qd,dA as Kg,el as Vw,es as pi,aU as zw,bM as Nu,dZ as Tu,dz as Fs,dS as Gg,dO as $w,cu as Hw,cG as nr,c$ as Uw,fC as Ww,D as Kw,bs as Gw,aP as qg,eQ as qw,d0 as Yw,z as Xw,aV as Jw,e5 as Zw,cC as Qw}from"./index-C-075SzJ.js";import{e as zl,d as Sc,a as eh,u as Yg,c as e2,v as wt,n as Xg,i as t2,j as n2,g as r2,f as i2,k as s2,h as o2,m as a2,b as Jg,l as l2}from"./automated-emails-DInKYTEC.js";import{R as c2,C as u2,L as d2,e as h2,T as th,b as nh,c as zi,a as qa}from"./tabs-BZosOk0o.js";import{a as $l,b as Zg,c as Qg,n as e0}from"./newsletters-3In8H0Z5.js";import{_ as Js}from"./typeof-QjJsDpFa.js";import{D as f2}from"./dropzone-DI8A9qO6.js";import{g as t0,S as Eo,e as jo,f as No,a as To,c as $i}from"./select-oE39QRll.js";import{P as m2,U as p2,T as g2,B as b2}from"./underline-HXWuVCAi.js";import{T as Hl,a as Gn}from"./toggle-group-abk9FYXi.js";import{T as v2}from"./textarea-BtnzsOk7.js";import{c as rh,b as x2,g as y2,a as w2}from"./tiers-Do7zBqAk.js";import{a as k2}from"./offers-Cl0ZNEMr.js";import{u as S2}from"./referrers-xwNb6L-8.js";const Tt=({className:t})=>(t||(t="border-grey-200 dark:border-grey-800"),u.jsx(Ky,{asChild:!0,decorative:!0,children:u.jsx("hr",{className:t})})),n0=R("text-base font-semibold tracking-normal"),r0=R(n0,"text-base font-semibold text-grey-900 dark:text-grey-500"),qe=({level:t=1,children:e,styles:n="",grey:r=!0,separator:i,useLabelTag:s,className:o="",...a})=>{const l=`${s?"label":`h${t}`}`;if(n+=t===6||s?` block ${r?r0:n0}`:" ",!s)switch(t){case 1:n+=" md:text-4xl leading-tighter";break;case 2:n+=" md:text-3xl";break;case 3:n+=" md:text-2xl";break;case 4:n+=" md:text-xl";break;case 5:n+=" md:text-lg";break}o=R(n,!r&&"dark:text-white",o);const c=W.createElement(l,{className:o,key:"heading-elem",...a},e);if(i){const d=!t||t===1?2:1,h=t===6?2:3;return u.jsxs("div",{className:`gap-${d} mb-${h} flex flex-col`,children:[c,u.jsx(Tt,{})]})}else return c},on=({children:t,color:e,className:n,...r})=>{if(!t)return null;let i="text-grey-700 dark:text-grey-600";switch(e){case"red":i="text-red dark:text-red-500";break;case"green":i="text-green dark:text-green-500";break}return n=R("mt-1 inline-block leading-snug",i,n),u.jsx("span",{className:n,...r,children:t})},C2=W.lazy(()=>Co(()=>import("./code-editor-view-CVODiRVJ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]),import.meta.url)),Df=v.forwardRef(function(e,n){return u.jsx(v.Suspense,{fallback:null,children:u.jsx(C2,{...e,ref:n})})}),Ul=({size:t,color:e,delay:n,style:r})=>{const[i,s]=W.useState(!n);W.useEffect(()=>{if(n){const a=setTimeout(()=>{s(!0)},n);return()=>{clearTimeout(a)}}},[n]);let o="relative mx-0 my-[-0.5] box-border inline-block animate-spin rounded-full before:z-10 before:block before:rounded-full before:content-[''] ";switch(t){case"sm":o+=" h-[16px] w-[16px] border-2 before:mt-[10px] before:h-[3px] before:w-[3px] ";break;case"md":o+=" h-[20px] w-[20px] border-2 before:mt-[13px] before:h-[3px] before:w-[3px] ";break;default:o+=" h-[50px] w-[50px] border before:mt-[7px] before:h-[7px] before:w-[7px] ";break}return e==="light"?o+=" border-white/20 before:bg-white dark:border-black/10 dark:before:bg-black ":o+=" border-black/10 before:bg-black dark:border-white/20 dark:before:bg-white ",t==="lg"?u.jsx("div",{className:`flex h-64 items-center justify-center transition-opacity ${i?"opacity-100":"opacity-0"}`,style:r,children:u.jsx("div",{className:o})}):u.jsx("div",{className:o})},J=W.forwardRef(({testId:t,size:e="md",label:n="",hideLabel:r=!1,icon:i="",iconSize:s,iconColorClass:o,color:a="clear",fullWidth:l,link:c,linkWithPadding:d=!1,disabled:h,unstyled:f=!1,className:m="",tag:p="button",loading:g=!1,loadingIndicatorColor:b,outlineOnMobile:x=!1,onClick:y,...w},k)=>{if(a||(a="clear"),!f){switch(m=R("text inline-flex items-center justify-center rounded-md whitespace-nowrap transition",c&&a!=="clear"&&a!=="black"||!c&&a!=="clear"?"font-bold":"font-semibold",c?"":`${e==="sm"?"h-7":"h-[34px]"}`,c?"":`${e==="sm"||n&&i?"px-3":"px-4"}`,c&&d&&"-m-1 p-1",m),a){case"black":m=R(c?"text-black hover:text-grey-800 dark:text-white":`bg-black text-white dark:bg-white dark:text-black ${!h&&"hover:bg-grey-900"}`,m),b="light",o=o||"text-white";break;case"light-grey":m=R(c?"text-grey-800 hover:text-green-400 dark:text-white":`bg-grey-200 text-black dark:bg-grey-900 dark:text-white ${!h&&"hover:bg-grey-300! dark:hover:bg-grey-800!"}`,m),b="dark";break;case"grey":m=R(c?"text-black hover:text-grey-800 dark:text-white":`bg-grey-100 text-black dark:bg-grey-900 dark:text-white ${!h&&"hover:bg-grey-300! dark:hover:bg-grey-800!"}`,m),b="dark";break;case"green":m=R(c?" text-green hover:text-green-400":` bg-green text-white ${!h&&"hover:bg-green-400"}`,m),b="light",o=o||"text-white";break;case"red":m=R(c?"text-red hover:text-red-400":`bg-red text-white ${!h&&"hover:bg-red-400"}`,m),b="light",o=o||"text-white";break;case"white":m=R(c?"text-white hover:text-white dark:text-black dark:hover:text-grey-800":"bg-white text-black dark:bg-black dark:text-white",m),b="dark";break;case"outline":m=R(c?"text-black hover:text-grey-800 dark:text-white":`border border-grey-300 bg-transparent text-black dark:border-grey-800 dark:text-white ${!h&&"hover:border-black! dark:hover:border-white!"}`,m),b="dark";break;default:m=R(c?" text-black hover:text-grey-800 dark:text-white":`text-grey-900 dark:text-white dark:hover:bg-grey-900 ${!h&&"hover:bg-grey-200 hover:text-black"}`,x&&!c&&"border border-grey-300 hover:border-transparent md:border-transparent",m),b="dark";break}m=R(l&&!c&&" w-full",h?"opacity-40":"cursor-pointer",m)}const C=n&&i&&!r?"mr-1.5":"";let S="";S+=n&&r?"sr-only":"",S+=g?"invisible":"",s=s||(e==="sm"||n&&i?"sm":"md");const A=u.jsxs(u.Fragment,{children:[i&&u.jsx(me,{className:C,colorClass:o,name:i,size:s}),u.jsx("span",{className:S,children:n}),g&&u.jsxs("div",{className:"absolute flex",children:[u.jsx(Ul,{color:b,size:e}),u.jsx("span",{className:"sr-only",children:"Loading..."})]})]});return W.createElement(p,{className:m,"data-testid":t,disabled:h,type:"button",onClick:y,ref:k,...w},A)});J.displayName="Button";function A2(t,e,n=!1){let r;return function(...i){const s=()=>{r=null,n||t.apply(this,i)},o=n&&!r;r&&clearTimeout(r),r=setTimeout(s,e),o&&t.apply(this,i)}}var it=function(){return it=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},it.apply(this,arguments)},i0=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n},Cc=Symbol("NiceModalId"),ih={},Qi=W.createContext(ih),s0=W.createContext(null),yn={},Zs={},M2=0,es=function(){throw new Error("No dispatch method detected, did you embed your app with NiceModal.Provider?")},o0=function(){return"_nice_modal_"+M2++},a0=function(t,e){var n,r,i;switch(t===void 0&&(t=ih),e.type){case"nice-modal/show":{var s=e.payload,o=s.modalId,a=s.args;return it(it({},t),(n={},n[o]=it(it({},t[o]),{id:o,args:a,visible:!!Zs[o],delayVisible:!Zs[o]}),n))}case"nice-modal/hide":{var o=e.payload.modalId;return t[o]?it(it({},t),(r={},r[o]=it(it({},t[o]),{visible:!1}),r)):t}case"nice-modal/remove":{var o=e.payload.modalId,l=it({},t);return delete l[o],l}case"nice-modal/set-flags":{var c=e.payload,o=c.modalId,d=c.flags;return it(it({},t),(i={},i[o]=it(it({},t[o]),d),i))}default:return t}};function E2(t){var e;return(e=yn[t])===null||e===void 0?void 0:e.comp}function j2(t,e){return{type:"nice-modal/show",payload:{modalId:t,args:e}}}function N2(t,e){return{type:"nice-modal/set-flags",payload:{modalId:t,flags:e}}}function T2(t){return{type:"nice-modal/hide",payload:{modalId:t}}}function D2(t){return{type:"nice-modal/remove",payload:{modalId:t}}}var rr={},ji={},Wl=function(t){return typeof t=="string"?t:(t[Cc]||(t[Cc]=o0()),t[Cc])};function sh(t,e){var n=Wl(t);if(typeof t!="string"&&!yn[n]&&Kl(n,t),es(j2(n,e)),!rr[n]){var r,i,s=new Promise(function(o,a){r=o,i=a});rr[n]={resolve:r,reject:i,promise:s}}return rr[n].promise}function oh(t){var e=Wl(t);if(es(T2(e)),delete rr[e],!ji[e]){var n,r,i=new Promise(function(s,o){n=s,r=o});ji[e]={resolve:n,reject:r,promise:i}}return ji[e].promise}var l0=function(t){var e=Wl(t);es(D2(e)),delete rr[e],delete ji[e]},O2=function(t,e){es(N2(t,e))};function an(t,e){var n=v.useContext(Qi),r=v.useContext(s0),i=null,s=t&&typeof t!="string";if(t?i=Wl(t):i=r,!i)throw new Error("No modal id found in NiceModal.useModal.");var o=i;v.useEffect(function(){s&&!yn[o]&&Kl(o,t,e)},[s,o,t,e]);var a=n[o],l=v.useCallback(function(p){return sh(o,p)},[o]),c=v.useCallback(function(){return oh(o)},[o]),d=v.useCallback(function(){return l0(o)},[o]),h=v.useCallback(function(p){var g;(g=rr[o])===null||g===void 0||g.resolve(p),delete rr[o]},[o]),f=v.useCallback(function(p){var g;(g=rr[o])===null||g===void 0||g.reject(p),delete rr[o]},[o]),m=v.useCallback(function(p){var g;(g=ji[o])===null||g===void 0||g.resolve(p),delete ji[o]},[o]);return v.useMemo(function(){return{id:o,args:a?.args,visible:!!a?.visible,keepMounted:!!a?.keepMounted,show:l,hide:c,remove:d,resolve:h,reject:f,resolveHide:m}},[o,a?.args,a?.visible,a?.keepMounted,l,c,d,h,f,m])}var I2=function(t){return function(e){var n,r=e.defaultVisible,i=e.keepMounted,s=e.id,o=i0(e,["defaultVisible","keepMounted","id"]),a=an(s),l=a.args,c=a.show,d=v.useContext(Qi),h=!!d[s];v.useEffect(function(){return r&&c(),Zs[s]=!0,function(){delete Zs[s]}},[s,c,r]),v.useEffect(function(){i&&O2(s,{keepMounted:!0})},[s,i]);var f=(n=d[s])===null||n===void 0?void 0:n.delayVisible;return v.useEffect(function(){f&&c(l)},[f,l,c]),h?W.createElement(s0.Provider,{value:s},W.createElement(t,it({},o,l))):null}},Kl=function(t,e,n){yn[t]?yn[t].props=n:yn[t]={comp:e,props:n}},P2=function(t){delete yn[t]},c0=function(){var t=v.useContext(Qi),e=Object.keys(t).filter(function(r){return!!t[r]});e.forEach(function(r){if(!yn[r]&&!Zs[r]){console.warn("No modal found for id: "+r+". Please check the id or if it is registered or declared via JSX.");return}});var n=e.filter(function(r){return yn[r]}).map(function(r){return it({id:r},yn[r])});return W.createElement(W.Fragment,null,n.map(function(r){return W.createElement(r.comp,it({key:r.id,id:r.id},r.props))}))},R2=function(t){var e=t.children,n=v.useReducer(a0,ih),r=n[0];return es=n[1],W.createElement(Qi.Provider,{value:r},e,W.createElement(c0,null))},L2=function(t){var e=t.children,n=t.dispatch,r=t.modals;return!n||!r?W.createElement(R2,null,e):(es=n,W.createElement(Qi.Provider,{value:r},e,W.createElement(c0,null)))},_2=function(t){var e=t.id,n=t.component;return v.useEffect(function(){return Kl(e,n),function(){P2(e)}},[e,n]),null},F2=function(t){var e,n=t.modal,r=t.handler,i=r===void 0?{}:r,s=i0(t,["modal","handler"]),o=v.useMemo(function(){return o0()},[]),a=typeof n=="string"?(e=yn[n])===null||e===void 0?void 0:e.comp:n;if(!i)throw new Error("No handler found in NiceModal.ModalHolder.");if(!a)throw new Error("No modal found for id: "+n+" in NiceModal.ModalHolder.");return i.show=v.useCallback(function(l){return sh(o,l)},[o]),i.hide=v.useCallback(function(){return oh(o)},[o]),W.createElement(a,it({id:o},s))},B2=function(t){return{visible:t.visible,onOk:function(){return t.hide()},onCancel:function(){return t.hide()},afterClose:function(){t.resolveHide(),t.keepMounted||t.remove()}}},V2=function(t){return{visible:t.visible,onClose:function(){return t.hide()},afterVisibleChange:function(e){e||t.resolveHide(),!e&&!t.keepMounted&&t.remove()}}},z2=function(t){return{open:t.visible,onClose:function(){return t.hide()},onExited:function(){t.resolveHide(),!t.keepMounted&&t.remove()}}},$2=function(t){return{show:t.visible,onHide:function(){return t.hide()},onExited:function(){t.resolveHide(),!t.keepMounted&&t.remove()}}},pe={Provider:L2,ModalDef:_2,ModalHolder:F2,NiceModalContext:Qi,create:I2,register:Kl,getModal:E2,show:sh,hide:oh,remove:l0,useModal:an,reducer:a0,antdModal:B2,antdDrawer:V2,muiDialog:z2,bootstrapDialog:$2};const u0=W.createContext({isDirty:!1,setGlobalDirtyState:()=>{}}),H2=({children:t})=>{const[e,n]=v.useState([]),r=v.useCallback((i,s)=>{n(o=>s&&!o.includes(i)?[...o,i]:!s&&o.includes(i)?o.filter(a=>a!==i):o)},[]);return u.jsx(u0.Provider,{value:{isDirty:e.length>0,setGlobalDirtyState:r},children:t})},Gl=()=>{const t=v.useId(),{isDirty:e,setGlobalDirtyState:n}=v.useContext(u0);v.useEffect(()=>()=>n(t,!1),[t,n]);const r=v.useCallback(i=>n(t,i),[t,n]);return{isDirty:e,setGlobalDirtyState:r}},d0=v.createContext({isAnyTextFieldFocused:!1,setFocusState:()=>{},fetchKoenigLexical:async()=>{},darkMode:!1}),ah=()=>v.useContext(d0),ts=()=>{const t=ah();if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t},U2=({fetchKoenigLexical:t,darkMode:e,children:n})=>{const[r,i]=v.useState(!1),s=o=>{i(o)};return u.jsx(d0.Provider,{value:{isAnyTextFieldFocused:r,setFocusState:s,fetchKoenigLexical:t,darkMode:e},children:u.jsxs(H2,{children:[u.jsx(Gy,{}),u.jsx(pe.Provider,{children:n})]})})},at=({type:t="text",inputRef:e,title:n,hideTitle:r,value:i,error:s,placeholder:o,rightPlaceholder:a,hint:l,onChange:c,onFocus:d,onBlur:h,clearBg:f=!1,className:m="",maxLength:p,containerClassName:g="",hintClassName:b="",unstyled:x=!1,disabled:y,...w})=>{const k=v.useId(),{setFocusState:C}=ts(),S=O=>{d?.(O),C(!0)},A=O=>{h?.(O),C(!1)},M=R("relative order-2 flex w-full items-center",n&&!r&&"mt-1.5"),E=!x&&R("absolute inset-0 rounded-lg border text-grey-300 transition-colors peer-hover:bg-grey-100 peer-focus:border-green peer-focus:bg-white peer-focus:shadow-[0_0_0_2px_rgba(48,207,67,.25)] dark:peer-hover:bg-grey-900 dark:peer-focus:bg-grey-950",s?"border-red bg-white dark:bg-grey-900":"border-transparent bg-grey-100 dark:bg-grey-900",y&&"bg-grey-50 shadow-[0_0_0_1px_rgba(255,255,255,0.45)] peer-hover:bg-grey-50 dark:bg-grey-950 dark:shadow-[0_0_0_1px_rgba(255,255,255,0.18)] dark:peer-hover:bg-grey-950"),j=!x&&R("peer z-[1] order-2 h-[var(--control-height)] w-full bg-transparent px-3 py-1.5 placeholder:text-grey-500 md:h-[var(--control-height)] md:py-2 dark:placeholder:text-grey-700",y?"cursor-not-allowed text-grey-600 dark:text-grey-800":"dark:text-white",a?"w-0 grow rounded-l-lg":"rounded-lg",m),T=!x&&R("z-[1] order-3 rounded-r-lg",a?typeof a=="string"?"flex h-[var(--control-height)] items-center py-1 pr-3 text-right text-grey-500":"pr-1":"pr-2");let N=u.jsx(u.Fragment,{});const D=u.jsx("input",{ref:e,className:j||m,disabled:y,id:k,maxLength:p,placeholder:o,type:t,value:i,onBlur:A,onChange:c,onFocus:S,...w});return N=u.jsx(zg,{name:k,asChild:!0,children:u.jsxs("div",{className:M,children:[u.jsx($g,{asChild:!0,children:D}),!x&&!f&&u.jsx("div",{className:E||""}),a&&u.jsx("span",{className:T||"",children:a})]})}),b=R("order-3",b),g=R("flex flex-col",g),n||l?u.jsx(Eu,{asChild:!0,children:u.jsxs("div",{className:g,children:[N,n&&u.jsx(qe,{className:r?"sr-only":"order-1",htmlFor:k,useLabelTag:!0,children:n}),l&&u.jsx(on,{className:b,color:s?"red":"default",children:l})]})}):u.jsx(Eu,{asChild:!0,children:N})},W2=({valueInCents:t,onChange:e,...n})=>{const[r,i]=v.useState(t===""?"":((t||0)/100).toString()),s=a=>a.replace(/[^\d.]+/g,""),o=a=>Math.round(parseFloat(a.match(/[\d]+\.?[\d]{0,2}/)?.[0]||"0")*100);return u.jsx(at,{...n,value:r,onBlur:a=>{i((o(a.target.value)/100).toString()),n.onBlur?.(a)},onChange:a=>{i(s(a.target.value)),e?.(o(a.target.value))}})},Ya=({id:t,onUpload:e,children:n,style:r,unstyled:i=!1,inputRef:s,className:o,dragIndicatorClassName:a,accept:l,...c})=>{const[d,h]=v.useState(Date.now()),[f,m]=v.useState(!1),p=y=>{const w=y.target.files?.[0];w&&e?.(w),h(Date.now())},g=y=>{x(y);const w=y.dataTransfer.files?.[0];w&&e?.(w),h(Date.now())},b=y=>{y.preventDefault(),m(!0)},x=y=>{y.preventDefault(),m(!1)};return u.jsxs("label",{className:R("relative",o),htmlFor:t,style:r,onDragEnter:b,onDragLeave:x,onDragOver:b,onDrop:g,...c,children:[u.jsx("div",{className:R({"absolute inset-1 rounded":!0,"border-2 border-dashed border-grey-400/25":f},f&&[a])}),u.jsx("input",{ref:s||null,accept:l,id:t,type:"file",hidden:!0,onChange:p},d),typeof n=="string"?u.jsx("div",{className:i?"":"inline-flex h-[34px] cursor-pointer items-center justify-center rounded px-4 font-medium hover:bg-grey-100 dark:text-white dark:hover:bg-grey-900",children:n}):n]})},K2=({title:t,grouped:e=!1,gap:n="md",margins:r="md",marginTop:i=!1,marginBottom:s=!0,className:o="",children:a})=>{let l=R("flex flex-col",n==="xs"&&"gap-4",n==="sm"&&"gap-6",n==="md"&&"gap-8",n==="lg"&&"gap-11");r||(r=n),s&&(l=R(l,r==="sm"&&"mb-7",r==="md"&&"mb-10",r==="lg"&&"mb-12")),i&&(l=R(l,r==="sm"&&"mt-7",r==="md"&&"mt-10",r==="lg"&&"mt-12")),e&&(l=R(l,"rounded-sm border border-grey-200 p-4 md:p-7 dark:border-grey-900"));const c=R(e?"mb-3":"mb-4");return e||t?u.jsxs("div",{className:o,children:[t&&u.jsx(qe,{className:c,level:5,children:t}),u.jsx("div",{className:l,children:a})]}):u.jsx("div",{className:R(l,o),children:a})},h0=({color:t="grey",children:e,className:n})=>{const r=R("relative overflow-hidden rounded-sm p-2",t==="grey"&&"text-black",t==="blue"&&"text-blue",t==="green"&&"text-green",t==="yellow"&&"text-yellow-600",t==="red"&&"text-red","after:pointer-events-none after:absolute after:inset-0 after:block after:opacity-10 after:content-['']",t==="grey"&&"after:bg-grey-500",t==="blue"&&"after:bg-blue",t==="green"&&"after:bg-green",t==="yellow"&&"after:bg-yellow",t==="red"&&"after:bg-red",n);return u.jsx("div",{className:r,children:e})};class lh extends W.Component{state={hasError:!1};constructor(e){super(e)}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,n){qy(r=>{r.setTag("adminx_settings_component",n.componentStack),Ls(e)}),console.error(e),console.error("In component:",n.componentStack)}render(){return this.state.hasError?u.jsxs(h0,{color:"red",children:["An error occurred loading ",this.props.name,". Please refresh and try again."]}):this.props.children}}const Ce=(t,e)=>function(r){return u.jsx(lh,{name:e,children:u.jsx(t,{...r})})},f0=function(t){let e="pending",n;const r=t().then(s=>{e="success",n=s},s=>{e="error",n=s});return{read:()=>{switch(e){case"pending":throw r;case"error":throw n;default:return n}}}},G2=({editor:t,onBlur:e,placeholder:n,nodes:r,emojiPicker:i=!0,darkMode:s=!1,singleParagraph:o=!1,children:a,initialEditorState:l,onChange:c,fileUploader:d,cardConfig:h,registerAPI:f})=>{const m=v.useCallback(k=>{try{Ls({error:k,tags:{lexical:!0},contexts:{koenig:{version:window["@tryghost/koenig-lexical"]?.version}}})}catch(C){console.error(C)}console.error(k)},[]),{setFocusState:p}=ts(),g=()=>{e&&e(),p(!1)},b=()=>{p(!0)},x=v.useMemo(()=>new Proxy({},{get:(k,C)=>t.read()[C]}),[t]),y={DEFAULT_NODES:x.DEFAULT_TRANSFORMERS,BASIC_NODES:x.BASIC_TRANSFORMERS,MINIMAL_NODES:x.MINIMAL_TRANSFORMERS,EMAIL_NODES:x.EMAIL_TRANSFORMERS,EMAIL_EDITOR_NODES:x.EMAIL_TRANSFORMERS},w=r||"DEFAULT_NODES";return u.jsx(x.KoenigComposer,{cardConfig:h,darkMode:s,fileUploader:d,initialEditorState:l,nodes:x[w],onError:m,children:u.jsxs(x.KoenigComposableEditor,{className:"koenig-lexical koenig-lexical-editor-input",isSnippetsEnabled:!1,markdownTransformers:y[w],placeholderClassName:"koenig-lexical-editor-input-placeholder line-clamp-1",placeholderText:n,registerAPI:f,singleParagraph:o,onBlur:g,onChange:c,onFocus:b,children:[a(x),i?u.jsx(x.EmojiPickerPlugin,{}):null]})})},U_=({className:t,children:e,initialEditorState:n,onChange:r,inheritFontStyles:i=!0,loadingFallback:s,...o})=>{const{fetchKoenigLexical:a,darkMode:l}=ah(),c=v.useMemo(()=>f0(a),[a]),d=i?"[&_*]:font-inherit! [&_*]:[font-size:inherit]!":"";return u.jsx("div",{className:t||"w-full",children:u.jsx("div",{className:`koenig-react-editor w-full ${d}`,children:u.jsx(lh,{name:"editor",children:u.jsx(v.Suspense,{fallback:s||u.jsx("p",{className:"koenig-react-editor-loading",children:"Loading editor..."}),children:u.jsx(G2,{...o,darkMode:l,editor:c,initialEditorState:n,onChange:r,children:e})})})})})},Of=({id:t,children:e,width:n="100%",height:r="120px",imageURL:i,imageFit:s="cover",imageContainerClassName:o,imageClassName:a,fileUploadClassName:l,fileUploadProps:c,deleteButtonClassName:d,deleteButtonContent:h,deleteButtonUnstyled:f=!1,imageBWCheckedBg:m=!1,unstyled:p=!1,onUpload:g,onDelete:b,onImageClick:x,pintura:y,editButtonClassName:w,editButtonContent:k,editButtonUnstyled:C=!1,buttonContainerClassName:S,unsplashButtonClassName:A,unsplashButtonUnstyled:M=!1,unsplashButtonContent:E,unsplashEnabled:j,openUnsplash:T})=>{if(p||(o=R("group relative flex justify-center",o),a=R(s==="cover"&&"object-cover",s==="contain"&&"object-contain",s==="fill"&&"object-fill",s==="scale-down"&&"object-scale-down",s==="none"&&"object-scale-down",a),l=R("flex cursor-pointer items-center justify-center rounded border border-grey-100 bg-grey-50 p-3 font-medium text-grey-800 hover:text-black dark:border-grey-900 dark:bg-grey-900 dark:text-grey-400",l),f||(d=R("absolute top-4 right-4 flex size-8 cursor-pointer items-center justify-center rounded bg-[rgba(0,0,0,0.75)] text-white group-hover:visible! hover:bg-black md:invisible [@media(hover:none)]:visible!",d)),C||(w=R("absolute top-4 right-16 flex size-8 cursor-pointer items-center justify-center rounded bg-[rgba(0,0,0,0.75)] text-white group-hover:visible! hover:bg-black md:invisible [@media(hover:none)]:visible!",w)),M||(A=R("absolute top-4 right-16 flex size-8 cursor-pointer items-center justify-center rounded bg-[rgba(255,255,255)] text-white",A))),h=h||u.jsx(me,{colorClass:"text-white",name:"trash",size:"sm"}),k=k||u.jsx(me,{colorClass:"text-white",name:"pen",size:"sm"}),E=E||u.jsx(me,{colorClass:"text-black",name:"unsplash-logo",size:"sm"}),i){let N=u.jsxs("div",{className:o,"data-testid":"image-upload-container",style:{width:p?"":n,height:p?"":r},children:[u.jsx("img",{alt:"",className:a,id:t,src:i,style:{width:p?"":n||"100%",height:p?"":r||"auto"},onClick:x}),u.jsxs("div",{className:S,children:[y?.isEnabled&&y?.openEditor&&u.jsx("button",{className:w,type:"button",onClick:y.openEditor,children:k}),u.jsx("button",{className:d,"data-testid":"image-delete-button",type:"button",onClick:b,children:h})]})]});if(m){const D="#d9d9d9";N=u.jsx("div",{style:{backgroundImage:`
|
|
3
3
|
linear-gradient(45deg, ${D} 25%, transparent 25%),
|
|
4
4
|
linear-gradient(45deg, transparent 75%, ${D} 75%),
|
|
5
5
|
linear-gradient(45deg, transparent 75%, ${D} 75%),
|
|
@@ -26,6 +26,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
26
26
|
--\u2028\u2029\uFEFF-]`,kd),O3={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Xc=null;function I3(){var t;if(Xc==null&&typeof document<"u"&&document.body){let e=document.body.style;Xc=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return Xc||!1}const za=H.define({combine(t){let e=Zn(t,{render:null,specialChars:D3,addSpecialChars:null});return(e.replaceTabs=!I3())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,kd)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,kd)),e}});function P3(t={}){return[za.of(t),R3()]}let cp=null;function R3(){return cp||(cp=We.fromClass(class{constructor(t){this.view=t,this.decorations=Q.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(za)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new T3({regexp:t.specialChars,decoration:(e,n,r)=>{let{doc:i}=n.state,s=Bt(e[0],0);if(s==9){let o=i.lineAt(r),a=n.state.tabSize,l=cs(o.text,a,r-o.from);return Q.replace({widget:new B3((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Q.replace({widget:new F3(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(za);t.startState.facet(za)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const L3="•";function _3(t){return t>=32?L3:t==10?"":String.fromCharCode(9216+t)}class F3 extends An{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=_3(this.code),r=e.state.phrase("Control character")+" "+(O3[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let s=document.createElement("span");return s.textContent=n,s.title=r,s.setAttribute("aria-label",r),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class B3 extends An{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function V3(){return $3}const z3=Q.line({class:"cm-activeLine"}),$3=We.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let i=t.lineBlockAt(r.head);i.from>e&&(n.push(z3.range(i.from)),e=i.from)}return Q.set(n)}},{decorations:t=>t.decorations});class H3 extends An{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?Ws(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=uo(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function U3(t){let e=We.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Q.set([Q.widget({widget:new H3(t),side:1}).range(0)]):Q.none}get decorations(){return this.view.state.doc.length?Q.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,V.contentAttributes.of({"aria-placeholder":t})]:e}const Sd=2e3;function W3(t,e,n){let r=Math.min(e.line,n.line),i=Math.max(e.line,n.line),s=[];if(e.off>Sd||n.off>Sd||e.col<0||n.col<0){let o=Math.min(e.off,n.off),a=Math.max(e.off,n.off);for(let l=r;l<=i;l++){let c=t.doc.line(l);c.length<=a&&s.push(P.range(c.from+o,c.to+a))}}else{let o=Math.min(e.col,n.col),a=Math.max(e.col,n.col);for(let l=r;l<=i;l++){let c=t.doc.line(l),d=nd(c.text,o,t.tabSize,!0);if(d<0)s.push(P.cursor(c.to));else{let h=nd(c.text,a,t.tabSize);s.push(P.range(c.from+d,c.from+h))}}}return s}function K3(t,e){let n=t.coordsAtPos(t.viewport.from);return n?Math.round(Math.abs((n.left-e)/t.defaultCharacterWidth)):-1}function up(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),r=t.state.doc.lineAt(n),i=n-r.from,s=i>Sd?-1:i==r.length?K3(t,e.clientX):cs(r.text,t.state.tabSize,n-r.from);return{line:r.number,col:s,off:i}}function G3(t,e){let n=up(t,e),r=t.state.selection;return n?{update(i){if(i.docChanged){let s=i.changes.mapPos(i.startState.doc.line(n.line).from),o=i.state.doc.lineAt(s);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},r=r.map(i.changes)}},get(i,s,o){let a=up(t,i);if(!a)return r;let l=W3(t.state,n,a);return l.length?o?P.create(l.concat(r.ranges)):P.create(l):r}}:null}function q3(t){let e=(n=>n.altKey&&n.button==0);return V.mouseSelectionStyle.of((n,r)=>e(r)?G3(n,r):null)}const Y3={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},X3={style:"cursor: crosshair"};function J3(t={}){let[e,n]=Y3[t.key||"Alt"],r=We.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==e||n(i))},keyup(i){(i.keyCode==e||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,V.contentAttributes.of(i=>{var s;return!((s=i.plugin(r))===null||s===void 0)&&s.isDown?X3:null})]}const va="-10000px";class Xv{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=n?[]:null;for(let l=0;l<s.length;l++){let c=s[l],d=-1;if(c){for(let h=0;h<this.tooltips.length;h++){let f=this.tooltips[h];f&&f.create==c.create&&(d=h)}if(d<0)o[l]=this.createTooltipView(c,l?o[l-1]:null),a&&(a[l]=!!c.above);else{let h=o[l]=this.tooltipViews[d];a&&(a[l]=n[d]),h.update&&h.update(e)}}}for(let l of this.tooltipViews)o.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(a.forEach((l,c)=>n[c]=l),n.length=a.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function Z3(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Jc=H.define({combine:t=>{var e,n,r;return{position:K.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||Z3}}}),dp=new WeakMap,Bh=We.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Jc);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Xv(t,Vh,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(Jc);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=va,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(K.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Rh(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let a=this.manager.tooltipViews[o];return a.getCoords?a.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Jc).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:d}=c,h=t.pos[a],f=t.size[a];if(!h||l.clip!==!1&&(h.bottom<=Math.max(n.top,r.top)||h.top>=Math.min(n.bottom,r.bottom)||h.right<Math.max(n.left,r.left)-.1||h.left>Math.min(n.right,r.right)+.1)){d.style.top=va;continue}let m=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=m?7:0,g=f.right-f.left,b=(e=dp.get(c))!==null&&e!==void 0?e:f.bottom-f.top,x=c.offset||eN,y=this.view.textDirection==Ie.LTR,w=f.width>r.right-r.left?y?r.left:r.right-f.width:y?Math.max(r.left,Math.min(h.left-(m?14:0)+x.x,r.right-g)):Math.min(Math.max(r.left,h.left-g+(m?14:0)-x.x),r.right-g),k=this.above[a];!l.strictSide&&(k?h.top-b-p-x.y<r.top:h.bottom+b+p+x.y>r.bottom)&&k==r.bottom-h.bottom>h.top-r.top&&(k=this.above[a]=!k);let C=(k?h.top-r.top:r.bottom-h.bottom)-p;if(C<b&&c.resize!==!1){if(C<this.view.defaultLineHeight){d.style.top=va;continue}dp.set(c,b),d.style.height=(b=C)/s+"px"}else d.style.height&&(d.style.height="");let S=k?h.top-b-p-x.y:h.bottom+p+x.y,A=w+g;if(c.overlap!==!0)for(let M of o)M.left<A&&M.right>w&&M.top<S+b&&M.bottom>S&&(S=k?M.top-b-2-p:M.bottom+p+2);if(this.position=="absolute"?(d.style.top=(S-t.parent.top)/s+"px",hp(d,(w-t.parent.left)/i)):(d.style.top=S/s+"px",hp(d,w/i)),m){let M=h.left+(y?x.x:-x.x)-(w+14-7);m.style.left=M/i+"px"}c.overlap!==!0&&o.push({left:w,top:S,right:A,bottom:S+b}),d.classList.toggle("cm-tooltip-above",k),d.classList.toggle("cm-tooltip-below",!k),c.positioned&&c.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=va}},{eventObservers:{scroll(){this.maybeMeasure()}}});function hp(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const Q3=V.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),eN={x:0,y:0},Vh=H.define({enables:[Bh,Q3]}),yl=H.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class hc{static create(e){return new hc(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Xv(e,yl,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const tN=Vh.compute([yl],t=>{let e=t.facet(yl);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:hc.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),Jv=H.define();class nN{constructor(e,n,r,i,s,o){this.view=e,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:n}=this,r=e.docView.tile.nearest(n.target);if(!r)return;let i,s=1;if(r.isWidget())i=r.posAtStart;else{if(i=e.posAtCoords(n),i==null)return;let o=e.coordsAtPos(i);if(!o||n.y<o.top||n.y>o.bottom||n.x<o.left-e.defaultCharacterWidth||n.x>o.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(i)).find(c=>c.from<=i&&c.to>=i),l=a&&a.dir==Ie.RTL?-1:1;s=n.x<o.left?-l:l}this.activateHover(e,i,s)}activateHover(e,n,r,i){let s=this.source(e,n,r),o=a=>{if(a&&!(Array.isArray(a)&&!a.length)){let l=Array.isArray(a)?a:[a];i&&this.locked.set(l,i),e.dispatch({effects:this.setHover.of(l)})}};if(s&&"then"in s){let a=this.pending={pos:n};s.then(l=>{this.pending==a&&(this.pending=null,o(l))},l=>$t(e.state,l,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(Bh),n=e?e.manager.tooltips.findIndex(r=>r.create==hc.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&!this.locked.has(i)&&s&&!rN(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,a=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!iN(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const xa=4;function rN(t,e){let{left:n,right:r,top:i,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let a=o.getBoundingClientRect();i=Math.min(a.top,i),s=Math.max(a.bottom,s)}return e.clientX>=n-xa&&e.clientX<=r+xa&&e.clientY>=i-xa&&e.clientY<=s+xa}function iN(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),a=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,a)<i)return!1;let l=t.posAtCoords({x:r,y:i},!1);return l>=e&&l<=n}function sN(t,e={}){let n=le.define(),r=new WeakMap,i=Ct.define({create(){return[]},update(o,a){let l=r.get(o);if(o.length&&(e.hideOnChange&&(a.docChanged||a.selection)?o=[]:l&&l(a)?o=[]:e.hideOn&&(o=o.filter(c=>!e.hideOn(a,c)))),a.docChanged&&o.length){let c=[];for(let d of o){let h=a.changes.mapPos(d.pos,-1,yt.TrackDel);if(h!=null){let f=Object.assign(Object.create(null),d);f.pos=h,f.end!=null&&(f.end=a.changes.mapPos(f.end)),c.push(f)}}o=c}for(let c of a.effects)c.is(n)&&(o=c.value,l=void 0),(c.is(aN)&&!c.value||c.value==i)&&(o=[]);return o.length&&l&&r.set(o,l),o},provide:o=>yl.from(o)});const s=We.define(o=>new nN(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,Jv.of(s),tN]}}function oN(t,e,n,r={}){var i;let s=t.state.facet(Jv).map(o=>t.plugin(o)).filter(o=>!!o);if(r.tooltip&&r.tooltip.active){let o=s.find(a=>a.field==r.tooltip.active);o&&(s=[o])}for(let o of s)o.activateHover(t,e,n,(i=r.until)!==null&&i!==void 0?i:(()=>!1))}function Zv(t,e){let n=t.plugin(Bh);if(!n)return null;let r=n.manager.tooltips.indexOf(e);return r<0?null:n.manager.tooltipViews[r]}const aN=le.define(),fp=H.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}});function zh(t,e){let n=t.plugin(Qv),r=n?n.specs.indexOf(e):-1;return r>-1?n.panels[r]:null}const Qv=We.fromClass(class{constructor(t){this.input=t.state.facet(fo),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(fp);this.top=new ya(t,!0,e.topContainer),this.bottom=new ya(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(fp);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ya(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ya(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(fo);if(n!=this.input){let r=n.filter(l=>l),i=[],s=[],o=[],a=[];for(let l of r){let c=this.specs.indexOf(l),d;c<0?(d=l(t.view),a.push(d)):(d=this.panels[c],d.update&&d.update(t)),i.push(d),(d.top?s:o).push(d)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>V.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class ya{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=mp(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=mp(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function mp(t){let e=t.nextSibling;return t.remove(),e}const fo=H.define({enables:Qv});function lN(t,e){let n,r=new Promise(o=>n=o),i=o=>cN(o,e,n);t.state.field(Zc,!1)?t.dispatch({effects:ex.of(i)}):t.dispatch({effects:le.appendConfig.of(Zc.init(()=>[i]))});let s=tx.of(i);return{close:s,result:r.then(o=>((t.win.queueMicrotask||(l=>t.win.setTimeout(l,10)))(()=>{t.state.field(Zc).indexOf(i)>-1&&t.dispatch({effects:s})}),o))}}const Zc=Ct.define({create(){return[]},update(t,e){for(let n of e.effects)n.is(ex)?t=[n.value].concat(t):n.is(tx)&&(t=t.filter(r=>r!=n.value));return t},provide:t=>fo.computeN([t],e=>e.field(t))}),ex=le.define(),tx=le.define();function cN(t,e,n){let r=e.content?e.content(t,()=>o(null)):null;if(!r){if(r=Te("form"),e.input){let a=Te("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),r.appendChild(Te("label",(e.label||"")+": ",a))}else r.appendChild(document.createTextNode(e.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(Te("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let i=r.nodeName=="FORM"?[r]:r.querySelectorAll("form");for(let a=0;a<i.length;a++){let l=i[a];l.addEventListener("keydown",c=>{c.keyCode==27?(c.preventDefault(),o(null)):c.keyCode==13&&(c.preventDefault(),o(l))}),l.addEventListener("submit",c=>{c.preventDefault(),o(l)})}let s=Te("div",r,Te("button",{onclick:()=>o(null),"aria-label":t.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(s.className=e.class),s.classList.add("cm-dialog");function o(a){s.contains(s.ownerDocument.activeElement)&&t.focus(),n(a)}return{dom:s,top:e.top,mount:()=>{if(e.focus){let a;typeof e.focus=="string"?a=r.querySelector(e.focus):a=r.querySelector("input")||r.querySelector("button"),a&&"select"in a?a.select():a&&"focus"in a&&a.focus()}}}}class dr extends Dr{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}dr.prototype.elementClass="";dr.prototype.toDOM=void 0;dr.prototype.mapMode=yt.TrackBefore;dr.prototype.startSide=dr.prototype.endSide=-1;dr.prototype.point=!0;const $a=H.define(),uN=H.define(),dN={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ge.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},qs=H.define();function hN(t){return[nx(),qs.of({...dN,...t})]}const pp=H.define({combine:t=>t.some(e=>e)});function nx(t){return[fN]}const fN=We.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(qs).map(e=>new bp(t,e)),this.fixed=!t.state.facet(pp);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(pp)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=ge.iter(this.view.state.facet($a),this.view.viewport.from),r=[],i=this.gutters.map(s=>new mN(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==kt.Text&&o){Cd(n,r,a.from);for(let l of i)l.line(this.view,a,r);o=!1}else if(a.widget)for(let l of i)l.widget(this.view,a)}else if(s.type==kt.Text){Cd(n,r,s.from);for(let o of i)o.line(this.view,s,r)}else if(s.widget)for(let o of i)o.widget(this.view,s);for(let s of i)s.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(qs),n=t.state.facet(qs),r=t.docChanged||t.heightChanged||t.viewportChanged||!ge.eq(t.startState.facet($a),t.state.facet($a),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let i of this.gutters)i.update(t)&&(r=!0);else{r=!0;let i=[];for(let s of n){let o=e.indexOf(s);o<0?i.push(new bp(this.view,s)):(this.gutters[o].update(t),i.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),i.indexOf(s)<0&&s.destroy();for(let s of i)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=i}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>V.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,i=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Ie.LTR?{left:r,right:i}:{right:r,left:i}})});function gp(t){return Array.isArray(t)?t:[t]}function Cd(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class mN{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=ge.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:i}=this,s=(n.top-this.height)/e.scaleY,o=n.height/e.scaleY;if(this.i==i.elements.length){let a=new rx(e,o,s,r);i.elements.push(a),i.dom.appendChild(a.dom)}else i.elements[this.i].update(e,o,s,r);this.height=n.bottom,this.i++}line(e,n,r){let i=[];Cd(this.cursor,i,n.from),r.length&&(i=i.concat(r));let s=this.gutter.config.lineMarker(e,n,i);s&&i.unshift(s);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(e,n,i)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),i=r?[r]:null;for(let s of e.state.facet(uN)){let o=s(e,n.widget,n);o&&(i||(i=[])).push(o)}i&&this.addElement(e,n,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class bp{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let s=i.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=i.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);n.domEventHandlers[r](e,a,i)&&i.preventDefault()});this.markers=gp(n.markers(e)),n.initialSpacer&&(this.spacer=new rx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=gp(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let r=e.view.viewport;return!ge.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class rx{constructor(e,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,i)}update(e,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),pN(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let s=0,o=0;;){let a=o,l=s<n.length?n[s++]:null,c=!1;if(l){let d=l.elementClass;d&&(r+=" "+d);for(let h=o;h<this.markers.length;h++)if(this.markers[h].compare(l)){a=h,c=!0;break}}else a=this.markers.length;for(;o<a;){let d=this.markers[o++];if(d.toDOM){d.destroy(i);let h=i.nextSibling;i.remove(),i=h}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(e),i)),c&&o++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function pN(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].compare(e[n]))return!1;return!0}const gN=H.define(),bN=H.define(),Ci=H.define({combine(t){return Zn(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,n){let r=Object.assign({},e);for(let i in n){let s=r[i],o=n[i];r[i]=s?(a,l,c)=>s(a,l,c)||o(a,l,c):o}return r}})}});class Qc extends dr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function eu(t,e){return t.state.facet(Ci).formatNumber(e,t.state)}const vN=qs.compute([Ci],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(gN)},lineMarker(e,n,r){return r.some(i=>i.toDOM)?null:new Qc(eu(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let i of e.state.facet(bN)){let s=i(e,n,r);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Ci)!=e.state.facet(Ci),initialSpacer(e){return new Qc(eu(e,vp(e.state.doc.lines)))},updateSpacer(e,n){let r=eu(n.view,vp(n.view.state.doc.lines));return r==e.number?e:new Qc(r)},domEventHandlers:t.facet(Ci).domEventHandlers,side:"before"}));function xN(t={}){return[Ci.of(t),nx(),vN]}function vp(t){let e=9;for(;e<t;)e=e*10+9;return e}const yN=new class extends dr{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},wN=$a.compute(["selection"],t=>{let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.head).from;i>n&&(n=i,e.push(yN.range(i)))}return ge.of(e)});function kN(){return wN}const SN=1024;let CN=0;class hn{constructor(e,n){this.from=e,this.to=n}}class be{constructor(e={}){this.id=CN++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Gt.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}be.closedBy=new be({deserialize:t=>t.split(" ")});be.openedBy=new be({deserialize:t=>t.split(" ")});be.group=new be({deserialize:t=>t.split(" ")});be.isolate=new be({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});be.contextHash=new be({perNode:!0});be.lookAhead=new be({perNode:!0});be.mounted=new be({perNode:!0});class Li{constructor(e,n,r,i=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[be.mounted.id]}}const AN=Object.create(null);class Gt{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):AN,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Gt(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(be.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(be.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}Gt.none=new Gt("",Object.create(null),0,8);class ix{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let i=null;for(let s of e){let o=s(r);if(o){i||(i=Object.assign({},r.props));let a=o[1],l=o[0];l.combine&&l.id in i&&(a=l.combine(i[l.id],a)),i[l.id]=a}}n.push(i?new Gt(r.name,i,r.id,r.flags):r)}return new ix(n)}}const wa=new WeakMap,xp=new WeakMap;var Oe;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Oe||(Oe={}));class et{constructor(e,n,r,i,s){if(this.type=e,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=Li.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new wl(this.topNode,e)}cursorAt(e,n=0,r=0){let i=wa.get(this)||this.topNode,s=new wl(i);return s.moveTo(e,n),wa.set(this,s._tree),s}get topNode(){return new Dt(this,0,0,null)}resolve(e,n=0){let r=mo(wa.get(this)||this.topNode,e,n,!1);return wa.set(this,r),r}resolveInner(e,n=0){let r=mo(xp.get(this)||this.topNode,e,n,!0);return xp.set(this,r),r}resolveStack(e,n=0){return jN(this,e,n)}iterate(e){let{enter:n,leave:r,from:i=0,to:s=this.length}=e,o=e.mode||0,a=(o&Oe.IncludeAnonymous)>0;for(let l=this.cursor(o|Oe.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=i&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Uh(Gt.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new et(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new et(Gt.none,n,r,i)))}static build(e){return NN(e)}}et.empty=new et(Gt.none,[],[],0);class $h{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new $h(this.buffer,this.index)}}class Rr{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Gt.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),e+=4,r==e)return s;let o=[];for(;e<r;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,r,i,s){let{buffer:o}=this,a=-1;for(let l=e;l!=n&&!(sx(s,i,o[l+1],o[l+2])&&(a=l,r>0));l=o[l+3]);return a}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let a=e,l=0;a<n;){s[l++]=i[a++],s[l++]=i[a++]-r;let c=s[l++]=i[a++]-r;s[l++]=i[a++]-e,o=Math.max(o,c)}return new Rr(s,o,this.set)}}function sx(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function mo(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!r&&t instanceof Dt&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=r?0:Oe.IgnoreOverlays;if(r)for(let o=t,a=o.parent;a;o=a,a=o.parent)o instanceof Dt&&o.index<0&&((i=a.enter(e,n,s))===null||i===void 0?void 0:i.from)!=o.from&&(t=a);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class ox{cursor(e=0){return new wl(this,e)}getChild(e,n=null,r=null){let i=yp(this,e,n,r);return i.length?i[0]:null}getChildren(e,n=null,r=null){return yp(this,e,n,r)}resolve(e,n=0){return mo(this,e,n,!1)}resolveInner(e,n=0){return mo(this,e,n,!0)}matchContext(e){return Ad(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class Dt extends ox{constructor(e,n,r,i){super(),this._tree=e,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,i,s=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,c=n>0?a.length:-1;e!=c;e+=n){let d=a[e],h=l[e]+o.from,f;if(!(!(s&Oe.EnterBracketed&&d instanceof et&&(f=Li.get(d))&&!f.overlay&&f.bracketed&&r>=h&&r<=h+d.length)&&!sx(i,r,h,h+d.length))){if(d instanceof Rr){if(s&Oe.ExcludeBuffers)continue;let m=d.findChild(0,d.buffer.length,n,r-h,i);if(m>-1)return new Un(new MN(o,d,e,h),null,m)}else if(s&Oe.IncludeAnonymous||!d.type.isAnonymous||Hh(d)){let m;if(!(s&Oe.IgnoreMounts)&&(m=Li.get(d))&&!m.overlay)return new Dt(m.tree,h,e,o);let p=new Dt(d,h,e,o);return s&Oe.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?d.children.length-1:0,n,r,i,s)}}}if(s&Oe.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let i;if(!(r&Oe.IgnoreOverlays)&&(i=Li.get(this._tree))&&i.overlay){let s=e-this.from,o=r&Oe.EnterBracketed&&i.bracketed;for(let{from:a,to:l}of i.overlay)if((n>0||o?a<=s:a<s)&&(n<0||o?l>=s:l>s))return new Dt(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function yp(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function Ad(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class MN{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class Un extends ox{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new Un(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Oe.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new Un(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Un(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Un(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new et(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function ax(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let r=n instanceof Dt&&n.index<0?null:n.parent,i=t.slice();return r?i[e]=r:i.splice(e,1),new EN(i,n)}class EN{constructor(e,n){this.heads=e,this.node=n}get next(){return ax(this.heads)}}function jN(t,e,n){let r=t.resolveInner(e,n),i=null;for(let s=r instanceof Dt?r:r.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(i||(i=[r])).push(o.resolve(e,n)),s=o}else{let o=Li.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new Dt(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(mo(a,e,n,!1))}}return i?ax(i):r}class wl{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Oe.EnterBracketed,e instanceof Dt)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof Dt?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Oe.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Oe.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Oe.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let a=r._tree.children[s];if(this.mode&Oe.IncludeAnonymous||a instanceof Rr||!a.type.isAnonymous||Hh(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new Un(this.buffer,n,this.stack[i]);return this.bufferNode=new Un(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return Ad(this.node.parent,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return Ad(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Hh(t){return t.children.some(e=>e instanceof Rr||!e.type.isAnonymous||Hh(e))}function NN(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=SN,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new $h(n,n.length):n,l=r.types,c=0,d=0;function h(C,S,A,M,E,j){let{id:T,start:N,end:D,size:O}=a,L=d,$=c;if(O<0)if(a.next(),O==-1){let ce=s[T];A.push(ce),M.push(N-C);return}else if(O==-3){c=T;return}else if(O==-4){d=T;return}else throw new RangeError(`Unrecognized record size: ${O}`);let U=l[T],q,_,te=N-C;if(D-N<=i&&(_=b(a.pos-S,E))){let ce=new Uint16Array(_.size-_.skip),G=a.pos-_.size,oe=ce.length;for(;a.pos>G;)oe=x(_.start,ce,oe);q=new Rr(ce,D-_.start,r),te=_.start-C}else{let ce=a.pos-O;a.next();let G=[],oe=[],B=T>=o?T:-1,Y=0,ee=D;for(;a.pos>ce;)B>=0&&a.id==B&&a.size>=0?(a.end<=ee-i&&(p(G,oe,N,Y,a.end,ee,B,L,$),Y=G.length,ee=a.end),a.next()):j>2500?f(N,ce,G,oe):h(N,ce,G,oe,B,j+1);if(B>=0&&Y>0&&Y<G.length&&p(G,oe,N,Y,N,ee,B,L,$),G.reverse(),oe.reverse(),B>-1&&Y>0){let ae=m(U,$);q=Uh(U,G,oe,0,G.length,0,D-N,ae,ae)}else q=g(U,G,oe,D-N,L-D,$)}A.push(q),M.push(te)}function f(C,S,A,M){let E=[],j=0,T=-1;for(;a.pos>S;){let{id:N,start:D,end:O,size:L}=a;if(L>4)a.next();else{if(T>-1&&D<T)break;T<0&&(T=O-i),E.push(N,D,O),j++,a.next()}}if(j){let N=new Uint16Array(j*4),D=E[E.length-2];for(let O=E.length-3,L=0;O>=0;O-=3)N[L++]=E[O],N[L++]=E[O+1]-D,N[L++]=E[O+2]-D,N[L++]=L;A.push(new Rr(N,E[2]-D,r)),M.push(D-C)}}function m(C,S){return(A,M,E)=>{let j=0,T=A.length-1,N,D;if(T>=0&&(N=A[T])instanceof et){if(!T&&N.type==C&&N.length==E)return N;(D=N.prop(be.lookAhead))&&(j=M[T]+N.length+D)}return g(C,A,M,E,j,S)}}function p(C,S,A,M,E,j,T,N,D){let O=[],L=[];for(;C.length>M;)O.push(C.pop()),L.push(S.pop()+A-E);C.push(g(r.types[T],O,L,j-E,N-j,D)),S.push(E-A)}function g(C,S,A,M,E,j,T){if(j){let N=[be.contextHash,j];T=T?[N].concat(T):[N]}if(E>25){let N=[be.lookAhead,E];T=T?[N].concat(T):[N]}return new et(C,S,A,M,T)}function b(C,S){let A=a.fork(),M=0,E=0,j=0,T=A.end-i,N={size:0,start:0,skip:0};e:for(let D=A.pos-C;A.pos>D;){let O=A.size;if(A.id==S&&O>=0){N.size=M,N.start=E,N.skip=j,j+=4,M+=4,A.next();continue}let L=A.pos-O;if(O<0||L<D||A.start<T)break;let $=A.id>=o?4:0,U=A.start;for(A.next();A.pos>L;){if(A.size<0)if(A.size==-3||A.size==-4)$+=4;else break e;else A.id>=o&&($+=4);A.next()}E=U,M+=O,j+=$}return(S<0||M==C)&&(N.size=M,N.start=E,N.skip=j),N.size>4?N:void 0}function x(C,S,A){let{id:M,start:E,end:j,size:T}=a;if(a.next(),T>=0&&M<o){let N=A;if(T>4){let D=a.pos-(T-4);for(;a.pos>D;)A=x(C,S,A)}S[--A]=N,S[--A]=j-C,S[--A]=E-C,S[--A]=M}else T==-3?c=M:T==-4&&(d=M);return A}let y=[],w=[];for(;a.pos>0;)h(t.start||0,t.bufferStart||0,y,w,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:y.length?w[0]+y[0].length:0;return new et(l[t.topID],y.reverse(),w.reverse(),k)}const wp=new WeakMap;function Ha(t,e){if(!t.isAnonymous||e instanceof Rr||e.type!=t)return 1;let n=wp.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof et)){n=1;break}n+=Ha(t,r)}wp.set(e,n)}return n}function Uh(t,e,n,r,i,s,o,a,l){let c=0;for(let p=r;p<i;p++)c+=Ha(t,e[p]);let d=Math.ceil(c*1.5/8),h=[],f=[];function m(p,g,b,x,y){for(let w=b;w<x;){let k=w,C=g[w],S=Ha(t,p[w]);for(w++;w<x;w++){let A=Ha(t,p[w]);if(S+A>=d)break;S+=A}if(w==k+1){if(S>d){let A=p[k];m(A.children,A.positions,0,A.children.length,g[k]+y);continue}h.push(p[k])}else{let A=g[w-1]+p[w-1].length-C;h.push(Uh(t,p,g,k,w,C,A,null,l))}f.push(C+y-s)}}return m(e,n,r,i,0),(a||l)(h,f,o)}class q_{constructor(){this.map=new WeakMap}setBuffer(e,n,r){let i=this.map.get(e);i||this.map.set(e,i=new Map),i.set(n,r)}getBuffer(e,n){let r=this.map.get(e);return r&&r.get(n)}set(e,n){e instanceof Un?this.setBuffer(e.context.buffer,e.index,n):e instanceof Dt&&this.map.set(e.tree,n)}get(e){return e instanceof Un?this.getBuffer(e.context.buffer,e.index):e instanceof Dt?this.map.get(e.tree):void 0}cursorSet(e,n){e.buffer?this.setBuffer(e.buffer.buffer,e.index,n):this.map.set(e.tree,n)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class ar{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new ar(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let d=a<n.length?n[a]:null,h=d?d.fromA:1e9;if(h-l>=r)for(;o&&o.from<h;){let f=o;if(l>=f.from||h<=f.to||c){let m=Math.max(f.from,l)-c,p=Math.min(f.to,h)-c;f=m>=p?null:new ar(m,p,f.tree,f.offset+c,a>0,!!d)}if(f&&i.push(f),o.to>h)break;o=s<e.length?e[s++]:null}if(!d)break;l=d.toA,c=d.toA-d.toB}return i}}class TN{startParse(e,n,r){return typeof e=="string"&&(e=new DN(e)),r=r?r.length?r.map(i=>new hn(i.from,i.to)):[new hn(0,0)]:[new hn(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class DN{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}function Y_(t){return(e,n,r,i)=>new IN(e,t,n,r,i)}class kp{constructor(e,n,r,i,s,o){this.parser=e,this.parse=n,this.overlay=r,this.bracketed=i,this.target=s,this.from=o}}function Sp(t){if(!t.length||t.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(t))}class ON{constructor(e,n,r,i,s,o,a,l){this.parser=e,this.predicate=n,this.mounts=r,this.index=i,this.start=s,this.bracketed=o,this.target=a,this.prev=l,this.depth=0,this.ranges=[]}}const Md=new be({perNode:!0});class IN{constructor(e,n,r,i,s){this.nest=n,this.input=r,this.fragments=i,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new et(r.type,r.children,r.positions,r.length,r.propValues.concat([[Md,this.stoppedAt]]))),r}let e=this.inner[this.innerDone],n=e.parse.advance();if(n){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[be.mounted.id]=new Li(n,e.overlay,e.parser,e.bracketed),e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].from<e&&(e=Math.min(e,this.inner[n].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].parse.stopAt(e)}startInner(){let e=new LN(this.fragments),n=null,r=null,i=new wl(new Dt(this.baseTree,this.ranges[0].from,0,null),Oe.IncludeAnonymous|Oe.IgnoreMounts);e:for(let s,o;;){let a=!0,l;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)a=!1;else if(e.hasNode(i)){if(n){let c=n.mounts.find(d=>d.frag.from<=i.from&&d.frag.to>=i.to&&d.mount.overlay);if(c)for(let d of c.mount.overlay){let h=d.from+c.pos,f=d.to+c.pos;h>=i.from&&f<=i.to&&!n.ranges.some(m=>m.from<f&&m.to>h)&&n.ranges.push({from:h,to:f})}}a=!1}else if(r&&(o=PN(r.ranges,i.from,i.to)))a=o!=2;else if(!i.type.isAnonymous&&(s=this.nest(i,this.input))&&(i.from<i.to||!s.overlay)){i.tree||(RN(i),n&&n.depth++,r&&r.depth++);let c=e.findMounts(i.from,s.parser);if(typeof s.overlay=="function")n=new ON(s.parser,s.overlay,c,this.inner.length,i.from,!!s.bracketed,i.tree,n);else{let d=Mp(this.ranges,s.overlay||(i.from<i.to?[new hn(i.from,i.to)]:[]));d.length&&Sp(d),(d.length||!s.overlay)&&this.inner.push(new kp(s.parser,d.length?s.parser.startParse(this.input,Ep(c,d),d):s.parser.startParse(""),s.overlay?s.overlay.map(h=>new hn(h.from-i.from,h.to-i.from)):null,!!s.bracketed,i.tree,d.length?d[0].from:i.from)),s.overlay?d.length&&(r={ranges:d,depth:0,prev:r}):a=!1}}else if(n&&(l=n.predicate(i))&&(l===!0&&(l=new hn(i.from,i.to)),l.from<l.to)){let c=n.ranges.length-1;c>=0&&n.ranges[c].to==l.from?n.ranges[c]={from:n.ranges[c].from,to:l.to}:n.ranges.push(l)}if(a&&i.firstChild())n&&n.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(n&&!--n.depth){let c=Mp(this.ranges,n.ranges);c.length&&(Sp(c),this.inner.splice(n.index,0,new kp(n.parser,n.parser.startParse(this.input,Ep(n.mounts,c),c),n.ranges.map(d=>new hn(d.from-n.start,d.to-n.start)),n.bracketed,n.target,c[0].from))),n=n.prev}r&&!--r.depth&&(r=r.prev)}}}}function PN(t,e,n){for(let r of t){if(r.from>=n)break;if(r.to>e)return r.from<=e&&r.to>=n?2:1}return 0}function Cp(t,e,n,r,i,s){if(e<n){let o=t.buffer[e+1];r.push(t.slice(e,n,o)),i.push(o-s)}}function RN(t){let{node:e}=t,n=[],r=e.context.buffer;do n.push(t.index),t.parent();while(!t.tree);let i=t.tree,s=i.children.indexOf(r),o=i.children[s],a=o.buffer,l=[s];function c(d,h,f,m,p,g){let b=n[g],x=[],y=[];Cp(o,d,b,x,y,m);let w=a[b+1],k=a[b+2];l.push(x.length);let C=g?c(b+4,a[b+3],o.set.types[a[b]],w,k-w,g-1):e.toTree();return x.push(C),y.push(w-m),Cp(o,a[b+3],h,x,y,m),new et(f,x,y,p)}i.children[s]=c(0,a.length,Gt.none,0,o.length,n.length-1);for(let d of l){let h=t.tree.children[d],f=t.tree.positions[d];t.yield(new Dt(h,f+t.from,d,t._tree))}}class Ap{constructor(e,n){this.offset=n,this.done=!1,this.cursor=e.cursor(Oe.IncludeAnonymous|Oe.IgnoreMounts)}moveTo(e){let{cursor:n}=this,r=e-this.offset;for(;!this.done&&n.from<r;)if(!(n.to>=e&&n.enter(r,1,Oe.IgnoreOverlays|Oe.ExcludeBuffers)))if(n.to<=e)n.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==e.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof et)n=n.children[0];else break}return!1}}class LN{constructor(e){var n;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let r=this.curFrag=e[0];this.curTo=(n=r.tree.prop(Md))!==null&&n!==void 0?n:r.to,this.inner=new Ap(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(e=n.tree.prop(Md))!==null&&e!==void 0?e:n.to,this.inner=new Ap(n.tree,-n.offset)}}findMounts(e,n){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(r=s.tree)===null||r===void 0?void 0:r.prop(be.mounted);if(o&&o.parser==n)for(let a=this.fragI;a<this.fragments.length;a++){let l=this.fragments[a];if(l.from>=s.to)break;l.tree==this.curFrag.tree&&i.push({frag:l,pos:s.from-l.offset,mount:o})}}}return i}}function Mp(t,e){let n=null,r=e;for(let i=1,s=0;i<t.length;i++){let o=t[i-1].to,a=t[i].from;for(;s<r.length;s++){let l=r[s];if(l.from>=a)break;l.to<=o||(n||(r=n=e.slice()),l.from<o?(n[s]=new hn(l.from,o),l.to>a&&n.splice(s+1,0,new hn(a,l.to))):l.to>a?n[s--]=new hn(a,l.to):n.splice(s--,1))}}return r}function _N(t,e,n,r){let i=0,s=0,o=!1,a=!1,l=-1e9,c=[];for(;;){let d=i==t.length?1e9:o?t[i].to:t[i].from,h=s==e.length?1e9:a?e[s].to:e[s].from;if(o!=a){let f=Math.max(l,n),m=Math.min(d,h,r);f<m&&c.push(new hn(f,m))}if(l=Math.min(d,h),l==1e9)break;d==l&&(o?(o=!1,i++):o=!0),h==l&&(a?(a=!1,s++):a=!0)}return c}function Ep(t,e){let n=[];for(let{pos:r,mount:i,frag:s}of t){let o=r+(i.overlay?i.overlay[0].from:0),a=o+i.tree.length,l=Math.max(s.from,o),c=Math.min(s.to,a);if(i.overlay){let d=i.overlay.map(f=>new hn(f.from+r,f.to+r)),h=_N(e,d,l,c);for(let f=0,m=l;;f++){let p=f==h.length,g=p?c:h[f].from;if(g>m&&n.push(new ar(m,g,i.tree,-o,s.from>=m||s.openStart,s.to<=g||s.openEnd)),p)break;m=h[f].to}}else n.push(new ar(l,c,i.tree,-o,s.from>=o||s.openStart,s.to<=a||s.openEnd))}return n}let FN=0;class un{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=FN++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof un&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let i=new un(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new kl(e);return r=>r.modified.indexOf(n)>-1?r:kl.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let BN=0;class kl{constructor(e){this.name=e,this.instances=[],this.id=BN++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&VN(n,a.modified));if(r)return r;let i=[],s=new un(e.name,i,e,n);for(let a of n)a.instances.push(s);let o=zN(n);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(kl.get(a,l));return s}}function VN(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function zN(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function $N(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,a=i;for(let h=0;;){if(a=="..."&&h>0&&h+3==i.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+i);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),h+=f[0].length,h==i.length)break;let m=i[h++];if(h==i.length&&m=="!"){o=0;break}if(m!="/")throw new RangeError("Invalid path: "+i);a=i.slice(h)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+i);let d=new po(r,o,l>0?s.slice(0,l):null);e[c]=d.sort(e[c])}}return lx.add(e)}const lx=new be({combine(t,e){let n,r,i;for(;t||e;){if(!t||e&&t.depth>=e.depth?(i=e,e=e.next):(i=t,t=t.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new po(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class po{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}po.empty=new po([],2,null);function cx(t,e){let n=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:r,all:i=null}=e||{};return{style:s=>{let o=i;for(let a of s)for(let l of a.set){let c=n[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function HN(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function UN(t,e,n,r=0,i=t.length){let s=new WN(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class WN{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:a,to:l}=e;if(a>=r||l<=n)return;o.isTop&&(s=this.highlighters.filter(m=>!m.scope||m.scope(o)));let c=i,d=KN(e)||po.empty,h=HN(s,d.tags);if(h&&(c&&(c+=" "),c+=h,d.mode==1&&(i+=(i?" ":"")+h)),this.startSpan(Math.max(n,a),c),d.opaque)return;let f=e.tree&&e.tree.prop(be.mounted);if(f&&f.overlay){let m=e.node.enter(f.overlay[0].from+a,1),p=this.highlighters.filter(b=>!b.scope||b.scope(f.tree.type)),g=e.firstChild();for(let b=0,x=a;;b++){let y=b<f.overlay.length?f.overlay[b]:null,w=y?y.from+a:l,k=Math.max(n,x),C=Math.min(r,w);if(k<C&&g)for(;e.from<C&&(this.highlightRange(e,k,C,i,s),this.startSpan(Math.min(C,e.to),c),!(e.to>=w||!e.nextSibling())););if(!y||w>r)break;x=y.to+a,x>n&&(this.highlightRange(m.cursor(),Math.max(n,y.from+a),Math.min(r,x),"",p),this.startSpan(Math.min(r,x),c))}g&&e.parent()}else if(e.firstChild()){f&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}}function KN(t){let e=t.type.prop(lx);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const F=un.define,ka=F(),wr=F(),jp=F(wr),Np=F(wr),kr=F(),Sa=F(kr),tu=F(kr),Pn=F(),zr=F(Pn),On=F(),In=F(),Ed=F(),As=F(Ed),Ca=F(),I={comment:ka,lineComment:F(ka),blockComment:F(ka),docComment:F(ka),name:wr,variableName:F(wr),typeName:jp,tagName:F(jp),propertyName:Np,attributeName:F(Np),className:F(wr),labelName:F(wr),namespace:F(wr),macroName:F(wr),literal:kr,string:Sa,docString:F(Sa),character:F(Sa),attributeValue:F(Sa),number:tu,integer:F(tu),float:F(tu),bool:F(kr),regexp:F(kr),escape:F(kr),color:F(kr),url:F(kr),keyword:On,self:F(On),null:F(On),atom:F(On),unit:F(On),modifier:F(On),operatorKeyword:F(On),controlKeyword:F(On),definitionKeyword:F(On),moduleKeyword:F(On),operator:In,derefOperator:F(In),arithmeticOperator:F(In),logicOperator:F(In),bitwiseOperator:F(In),compareOperator:F(In),updateOperator:F(In),definitionOperator:F(In),typeOperator:F(In),controlOperator:F(In),punctuation:Ed,separator:F(Ed),bracket:As,angleBracket:F(As),squareBracket:F(As),paren:F(As),brace:F(As),content:Pn,heading:zr,heading1:F(zr),heading2:F(zr),heading3:F(zr),heading4:F(zr),heading5:F(zr),heading6:F(zr),contentSeparator:F(Pn),list:F(Pn),quote:F(Pn),emphasis:F(Pn),strong:F(Pn),link:F(Pn),monospace:F(Pn),strikethrough:F(Pn),inserted:F(),deleted:F(),changed:F(),invalid:F(),meta:Ca,documentMeta:F(Ca),annotation:F(Ca),processingInstruction:F(Ca),definition:un.defineModifier("definition"),constant:un.defineModifier("constant"),function:un.defineModifier("function"),standard:un.defineModifier("standard"),local:un.defineModifier("local"),special:un.defineModifier("special")};for(let t in I){let e=I[t];e instanceof un&&(e.name=t)}cx([{tag:I.link,class:"tok-link"},{tag:I.heading,class:"tok-heading"},{tag:I.emphasis,class:"tok-emphasis"},{tag:I.strong,class:"tok-strong"},{tag:I.keyword,class:"tok-keyword"},{tag:I.atom,class:"tok-atom"},{tag:I.bool,class:"tok-bool"},{tag:I.url,class:"tok-url"},{tag:I.labelName,class:"tok-labelName"},{tag:I.inserted,class:"tok-inserted"},{tag:I.deleted,class:"tok-deleted"},{tag:I.literal,class:"tok-literal"},{tag:I.string,class:"tok-string"},{tag:I.number,class:"tok-number"},{tag:[I.regexp,I.escape,I.special(I.string)],class:"tok-string2"},{tag:I.variableName,class:"tok-variableName"},{tag:I.local(I.variableName),class:"tok-variableName tok-local"},{tag:I.definition(I.variableName),class:"tok-variableName tok-definition"},{tag:I.special(I.variableName),class:"tok-variableName2"},{tag:I.definition(I.propertyName),class:"tok-propertyName tok-definition"},{tag:I.typeName,class:"tok-typeName"},{tag:I.namespace,class:"tok-namespace"},{tag:I.className,class:"tok-className"},{tag:I.macroName,class:"tok-macroName"},{tag:I.propertyName,class:"tok-propertyName"},{tag:I.operator,class:"tok-operator"},{tag:I.comment,class:"tok-comment"},{tag:I.meta,class:"tok-meta"},{tag:I.invalid,class:"tok-invalid"},{tag:I.punctuation,class:"tok-punctuation"}]);var nu;const Ai=new be;function GN(t){return H.define({combine:t?e=>e.concat(t):void 0})}const qN=new be;class xn{constructor(e,n,r=[],i=""){this.data=e,this.name=i,xe.prototype.hasOwnProperty("tree")||Object.defineProperty(xe.prototype,"tree",{get(){return St(this)}}),this.parser=n,this.extension=[Lr.of(this),xe.languageData.of((s,o,a)=>{let l=Tp(s,o,a),c=l.type.prop(Ai);if(!c)return[];let d=s.facet(c),h=l.type.prop(qN);if(h){let f=l.resolve(o-l.from,a);for(let m of h)if(m.test(f,s)){let p=s.facet(m.facet);return m.type=="replace"?p:p.concat(d)}}return d})].concat(r)}isActiveAt(e,n,r=-1){return Tp(e,n,r).type.prop(Ai)==this.data}findRegions(e){let n=e.facet(Lr);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(Ai)==this.data){r.push({from:o,to:o+s.length});return}let a=s.prop(be.mounted);if(a){if(a.tree.prop(Ai)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+s.length});return}else if(a.overlay){let l=r.length;if(i(a.tree,a.overlay[0].from+o),r.length>l)return}}for(let l=0;l<s.children.length;l++){let c=s.children[l];c instanceof et&&i(c,s.positions[l]+o)}};return i(St(e),0),r}get allowsNesting(){return!0}}xn.setState=le.define();function Tp(t,e,n){let r=t.facet(Lr),i=St(t).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(e,n,Oe.ExcludeBuffers|Oe.EnterBracketed))s.type.isTop&&(i=s);return i}class jd extends xn{constructor(e,n,r){super(e,n,[],r),this.parser=n}static define(e){let n=GN(e.languageData);return new jd(n,e.parser.configure({props:[Ai.add(r=>r.isTop?n:void 0)]}),e.name)}configure(e,n){return new jd(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function St(t){let e=t.field(xn.state,!1);return e?e.tree:et.empty}class YN{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e<r||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ms=null;class Sl{constructor(e,n,r=[],i,s,o,a,l){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Sl(e,n,[],et.empty,0,r,[],null)}startParse(){return this.parser.startParse(new YN(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=et.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(ar.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(ar.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ms;Ms=this;try{return e()}finally{Ms=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Dp(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,d,h,f)=>l.push({fromA:c,toA:d,fromB:h,toB:f})),r=ar.applyChanges(r,l),i=et.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let d=e.mapPos(c.from,1),h=e.mapPos(c.to,-1);d<h&&a.push({from:d,to:h})}}}return new Sl(this.parser,n,r,i,s,o,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:s}=this.skipped[r];i<e.to&&s>e.from&&(this.fragments=Dp(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends TN{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let l=Ms;if(l){for(let c of i)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new et(Gt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ms}}function Dp(t,e,n){return ar.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Ji{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new Ji(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Sl.create(e.facet(Lr).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Ji(r)}}xn.state=Ct.define({create:Ji.init,update(t,e){for(let n of e.effects)if(n.is(xn.setState))return n.value;return e.startState.facet(Lr)!=e.state.facet(Lr)?Ji.init(e.state):t.apply(e)}});let ux=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(ux=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const ru=typeof navigator<"u"&&(!((nu=navigator.scheduling)===null||nu===void 0)&&nu.isInputPending)?()=>navigator.scheduling.isInputPending():null,XN=We.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(xn.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(xn.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=ux(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,s=r.field(xn.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!ru?Math.max(25,e.timeRemaining()-5):1e9),a=s.context.treeLen<i&&r.doc.length>i+1e3,l=s.context.work(()=>ru&&ru()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:xn.setState.of(new Ji(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>$t(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Lr=H.define({combine(t){return t.length?t[0]:null},enables:t=>[xn.state,XN,V.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class J_{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}class dx{constructor(e,n,r,i,s,o=void 0){this.name=e,this.alias=n,this.extensions=r,this.filename=i,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:n,support:r}=e;if(!n){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(r)}return new dx(e.name,(e.alias||[]).concat(e.name).map(i=>i.toLowerCase()),e.extensions||[],e.filename,n,r)}static matchFilename(e,n){for(let i of e)if(i.filename&&i.filename.test(n))return i;let r=/\.([^.]+)$/.exec(n);if(r){for(let i of e)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(e,n,r=!0){n=n.toLowerCase();for(let i of e)if(i.alias.some(s=>s==n))return i;if(r)for(let i of e)for(let s of i.alias){let o=n.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(n[o-1])&&!/\w/.test(n[o+s.length])))return i}return null}}const JN=H.define(),zo=H.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Cl(t){let e=t.facet(zo);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function go(t,e){let n="",r=t.tabSize,i=t.facet(zo)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s<e;s++)n+=i;return n}function Wh(t,e){t instanceof xe&&(t=new fc(t));for(let r of t.state.facet(JN)){let i=r(t,e);if(i!==void 0)return i}let n=St(t.state);return n.length>=e?QN(t,n,e):null}class fc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Cl(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(n<0?i<e:i<=e)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(e,n);return r.slice(e-i,Math.min(r.length,e+100-i))}column(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.countColumn(r,e-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return cs(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ZN=new be;function QN(t,e,n){let r=e.resolveStack(n),i=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return hx(r,t,n)}function hx(t,e,n){for(let r=t;r;r=r.next){let i=tT(r.node);if(i)return i(Kh.create(e,n,r))}return 0}function eT(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function tT(t){let e=t.type.prop(ZN);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(be.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>fx(o,!0,1,void 0,s&&!eT(o)?i.from:void 0)}return t.parent==null?nT:null}function nT(){return 0}class Kh extends fc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Kh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(rT(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return hx(this.context.next,this.base,this.pos)}}function rT(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function iT(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let a=n.to;;){let l=e.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+c}}a=l.to}}function Z_({closing:t,align:e=!0,units:n=1}){return r=>fx(r,e,n,t)}function fx(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,a=r&&s.slice(o,o+r.length)==r||i==t.pos+o,l=e?iT(t):null;return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*n)}const Q_=t=>t.baseIndent;function e9({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const sT=200;function oT(){return xe.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:r}=t.newSelection.main,i=n.lineAt(r);if(r>i.from+sT)return t;let s=n.sliceString(i.from,r);if(!e.some(c=>c.test(s)))return t;let{state:o}=t,a=-1,l=[];for(let{head:c}of o.selection.ranges){let d=o.doc.lineAt(c);if(d.from==a)continue;a=d.from;let h=Wh(o,d.from);if(h==null)continue;let f=/^\s*/.exec(d.text)[0],m=go(o,h);f!=m&&l.push({from:d.from,to:d.from+f.length,insert:m})}return l.length?[t,{changes:l,sequential:!0}]:t})}const aT=H.define(),lT=new be;function t9(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function cT(t,e,n){let r=St(t);if(r.length<n)return null;let i=r.resolveStack(n,1),s=null;for(let o=i;o;o=o.next){let a=o.node;if(a.to<=n||a.from>n)continue;if(s&&a.from<e)break;let l=a.type.prop(lT);if(l&&(a.to<r.length-50||r.length==t.doc.length||!uT(a))){let c=l(a,t);c&&c.from<=n&&c.from>=e&&c.to>n&&(s=c)}}return s}function uT(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Al(t,e,n){for(let r of t.facet(aT)){let i=r(t,e,n);if(i)return i}return cT(t,e,n)}function mx(t,e){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);return n>=r?void 0:{from:n,to:r}}const mc=le.define({map:mx}),$o=le.define({map:mx});function px(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(r=>r.from<=n&&r.to>=n)||e.push(t.lineBlockAt(n));return e}const oi=Ct.define({create(){return Q.none},update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((n,r)=>t=Op(t,n,r)),t=t.map(e.changes);for(let n of e.effects)if(n.is(mc)&&!dT(t,n.value.from,n.value.to)){let{preparePlaceholder:r}=e.state.facet(vx),i=r?Q.replace({widget:new vT(r(e.state,n.value))}):Ip;t=t.update({add:[i.range(n.value.from,n.value.to)]})}else n.is($o)&&(t=t.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=Op(t,e.selection.main.head)),t},provide:t=>V.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let r=t[n++],i=t[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(Ip.range(r,i))}return Q.set(e,!0)}});function Op(t,e,n=e){let r=!1;return t.between(e,n,(i,s)=>{i<n&&s>e&&(r=!0)}),r?t.update({filterFrom:e,filterTo:n,filter:(i,s)=>i>=n||s<=e}):t}function Ml(t,e,n){var r;let i=null;return(r=t.field(oi,!1))===null||r===void 0||r.between(e,n,(s,o)=>{(!i||i.from>s)&&(i={from:s,to:o})}),i}function dT(t,e,n){let r=!1;return t.between(e,e,(i,s)=>{i==e&&s==n&&(r=!0)}),r}function gx(t,e){return t.field(oi,!1)?e:e.concat(le.appendConfig.of(xx()))}const hT=t=>{for(let e of px(t)){let n=Al(t.state,e.from,e.to);if(n)return t.dispatch({effects:gx(t.state,[mc.of(n),bx(t,n)])}),!0}return!1},fT=t=>{if(!t.state.field(oi,!1))return!1;let e=[];for(let n of px(t)){let r=Ml(t.state,n.from,n.to);r&&e.push($o.of(r),bx(t,r,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function bx(t,e,n=!0){let r=t.state.doc.lineAt(e.from).number,i=t.state.doc.lineAt(e.to).number;return V.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${t.state.phrase("to")} ${i}.`)}const mT=t=>{let{state:e}=t,n=[];for(let r=0;r<e.doc.length;){let i=t.lineBlockAt(r),s=Al(e,i.from,i.to);s&&n.push(mc.of(s)),r=(s?t.lineBlockAt(s.to):i).to+1}return n.length&&t.dispatch({effects:gx(t.state,n)}),!!n.length},pT=t=>{let e=t.state.field(oi,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(r,i)=>{n.push($o.of({from:r,to:i}))}),t.dispatch({effects:n}),!0},gT=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:hT},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:fT},{key:"Ctrl-Alt-[",run:mT},{key:"Ctrl-Alt-]",run:pT}],bT={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},vx=H.define({combine(t){return Zn(t,bT)}});function xx(t){return[oi,wT]}function yx(t,e){let{state:n}=t,r=n.facet(vx),i=o=>{let a=t.lineBlockAt(t.posAtDOM(o.target)),l=Ml(t.state,a.from,a.to);l&&t.dispatch({effects:$o.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(t,i,e);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const Ip=Q.replace({widget:new class extends An{toDOM(t){return yx(t,null)}}});class vT extends An{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return yx(e,this.value)}}const xT={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class iu extends dr{constructor(e,n){super(),this.config=e,this.open=n}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=e.state.phrase(this.open?"Fold line":"Unfold line"),n}}function yT(t={}){let e={...xT,...t},n=new iu(e,!0),r=new iu(e,!1),i=We.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Lr)!=o.state.facet(Lr)||o.startState.field(oi,!1)!=o.state.field(oi,!1)||St(o.startState)!=St(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new cr;for(let l of o.viewportLineBlocks){let c=Ml(o.state,l.from,l.to)?r:Al(o.state,l.from,l.to)?n:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:s}=e;return[i,hN({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(i))===null||a===void 0?void 0:a.markers)||ge.empty},initialSpacer(){return new iu(e,!1)},domEventHandlers:{...s,click:(o,a,l)=>{if(s.click&&s.click(o,a,l))return!0;let c=Ml(o.state,a.from,a.to);if(c)return o.dispatch({effects:$o.of(c)}),!0;let d=Al(o.state,a.from,a.to);return d?(o.dispatch({effects:mc.of(d)}),!0):!1}}}),xx()]}const wT=V.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Ho{constructor(e,n){this.specs=e;let r;function i(a){let l=Or.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const s=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof xn?a=>a.prop(Ai)==o.data:o?a=>a==o:void 0,this.style=cx(e.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=r?new Or(r):null,this.themeType=n.themeType}static define(e,n){return new Ho(e,n||{})}}const Nd=H.define(),wx=H.define({combine(t){return t.length?[t[0]]:null}});function su(t){let e=t.facet(Nd);return e.length?e:t.facet(wx)}function kx(t,e){let n=[ST],r;return t instanceof Ho&&(t.module&&n.push(V.styleModule.of(t.module)),r=t.themeType),e?.fallback?n.push(wx.of(t)):r?n.push(Nd.computeN([V.darkTheme],i=>i.facet(V.darkTheme)==(r=="dark")?[t]:[])):n.push(Nd.of(t)),n}class kT{constructor(e){this.markCache=Object.create(null),this.tree=St(e.state),this.decorations=this.buildDeco(e,su(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=St(e.state),r=su(e.state),i=r!=su(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length<s.to&&!i&&n.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Q.none;let r=new cr;for(let{from:i,to:s}of e.visibleRanges)UN(this.tree,n,(o,a,l)=>{r.add(o,a,this.markCache[l]||(this.markCache[l]=Q.mark({class:l})))},i,s);return r.finish()}}const ST=Br.high(We.fromClass(kT,{decorations:t=>t.decorations})),CT=Ho.define([{tag:I.meta,color:"#404740"},{tag:I.link,textDecoration:"underline"},{tag:I.heading,textDecoration:"underline",fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.strong,fontWeight:"bold"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.keyword,color:"#708"},{tag:[I.atom,I.bool,I.url,I.contentSeparator,I.labelName],color:"#219"},{tag:[I.literal,I.inserted],color:"#164"},{tag:[I.string,I.deleted],color:"#a11"},{tag:[I.regexp,I.escape,I.special(I.string)],color:"#e40"},{tag:I.definition(I.variableName),color:"#00f"},{tag:I.local(I.variableName),color:"#30a"},{tag:[I.typeName,I.namespace],color:"#085"},{tag:I.className,color:"#167"},{tag:[I.special(I.variableName),I.macroName],color:"#256"},{tag:I.definition(I.propertyName),color:"#00c"},{tag:I.comment,color:"#940"},{tag:I.invalid,color:"#f00"}]),AT=V.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Sx=1e4,Cx="()[]{}",Ax=H.define({combine(t){return Zn(t,{afterCursor:!0,brackets:Cx,maxScanDistance:Sx,renderMatch:jT})}}),MT=Q.mark({class:"cm-matchingBracket"}),ET=Q.mark({class:"cm-nonmatchingBracket"});function jT(t){let e=[],n=t.matched?MT:ET;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}function Pp(t){let e=[],n=t.facet(Ax);for(let r of t.selection.ranges){if(!r.empty)continue;let i=Wn(t,r.head,-1,n)||r.head>0&&Wn(t,r.head-1,1,n)||n.afterCursor&&(Wn(t,r.head,1,n)||r.head<t.doc.length&&Wn(t,r.head+1,-1,n));i&&(e=e.concat(n.renderMatch(i,t)))}return Q.set(e,!0)}const NT=We.fromClass(class{constructor(t){this.paused=!1,this.decorations=Pp(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=Pp(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),TT=[NT,AT];function DT(t={}){return[Ax.of(t),TT]}const OT=new be;function Td(t,e,n){let r=t.prop(e<0?be.openedBy:be.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function Dd(t){let e=t.type.prop(OT);return e?e(t.node):t}function Wn(t,e,n,r={}){let i=r.maxScanDistance||Sx,s=r.brackets||Cx,o=St(t),a=o.resolveInner(e,n);for(let l=a;l;l=l.parent){let c=Td(l.type,n,s);if(c&&l.from<l.to){let d=Dd(l);if(d&&(n>0?e>=d.from&&e<d.to:e>d.from&&e<=d.to))return IT(t,e,n,l,d,c,s)}}return PT(t,e,n,o,a.type,i,s)}function IT(t,e,n,r,i,s,o){let a=r.parent,l={from:i.from,to:i.to},c=0,d=a?.cursor();if(d&&(n<0?d.childBefore(r.from):d.childAfter(r.to)))do if(n<0?d.to<=r.from:d.from>=r.to){if(c==0&&s.indexOf(d.type.name)>-1&&d.from<d.to){let h=Dd(d);return{start:l,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Td(d.type,n,o))c++;else if(Td(d.type,-n,o)){if(c==0){let h=Dd(d);return{start:l,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}c--}}while(n<0?d.prevSibling():d.nextSibling());return{start:l,matched:!1}}function PT(t,e,n,r,i,s,o){if(n<0?!e:e==t.doc.length)return null;let a=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=o.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?e-1:e,to:n>0?e+1:e},d=t.doc.iterRange(e,n>0?t.doc.length:0),h=0;for(let f=0;!d.next().done&&f<=s;){let m=d.value;n<0&&(f+=m.length);let p=e+f*n;for(let g=n>0?0:m.length-1,b=n>0?m.length:-1;g!=b;g+=n){let x=o.indexOf(m[g]);if(!(x<0||r.resolveInner(p+g,1).type!=i))if(x%2==0==n>0)h++;else{if(h==1)return{start:c,end:{from:p+g,to:p+g+1},matched:x>>1==l>>1};h--}}n>0&&(f+=m.length)}return d.done?{start:c,matched:!1}:null}const RT=Object.create(null),Rp=[Gt.none],Lp=[],_p=Object.create(null),LT=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])LT[t]=_T(RT,e);function ou(t,e){Lp.indexOf(t)>-1||(Lp.push(t),console.warn(e))}function _T(t,e){let n=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let d=t[c]||I[c];d?typeof d=="function"?l.length?l=l.map(d):ou(c,`Modifier ${c} used at start of tag`):l.length?ou(c,`Tag ${c} used as modifier`):l=Array.isArray(d)?d:[d]:ou(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(a=>a.id),s=_p[i];if(s)return s.id;let o=_p[i]=Gt.define({id:Rp.length,name:r,props:[$N({[r]:n})]});return Rp.push(o),o.id}Ie.RTL,Ie.LTR;const FT=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=qh(t.state,n.from);return r.line?BT(t):r.block?zT(t):!1};function Gh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const BT=Gh(UT,0),VT=Gh(Mx,0),zT=Gh((t,e)=>Mx(t,e,HT(e)),0);function qh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Es=50;function $T(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Es,r),o=t.sliceDoc(i,i+Es),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,c=s.length-a;if(s.slice(c-e.length,c)==e&&o.slice(l,l+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let d,h;i-r<=2*Es?d=h=t.sliceDoc(r,i):(d=t.sliceDoc(r,r+Es),h=t.sliceDoc(i-Es,i));let f=/^\s*/.exec(d)[0].length,m=/\s*$/.exec(h)[0].length,p=h.length-m-n.length;return d.slice(f,f+e.length)==e&&h.slice(p,p+n.length)==n?{open:{pos:r+f+e.length,margin:/\s/.test(d.charAt(f+e.length))?1:0},close:{pos:i-m-n.length,margin:/\s/.test(h.charAt(p-1))?1:0}}:null}function HT(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function Mx(t,e,n=e.selection.ranges){let r=n.map(s=>qh(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>$T(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,a;o<i.length;o++)if(a=i[o]){let l=r[o],{open:c,close:d}=a;s.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:d.pos-d.margin,to:d.pos+l.close.length})}return{changes:s}}return null}function UT(t,e,n=e.selection.ranges){let r=[],i=-1;e:for(let{from:s,to:o}of n){let a=r.length,l=1e9,c;for(let d=s;d<=o;){let h=e.doc.lineAt(d);if(c==null&&(c=qh(e,h.from).line,!c))continue e;if(h.from>i&&(s==o||o>h.from)){i=h.from;let f=/^\s*/.exec(h.text)[0].length,m=f==h.length,p=h.text.slice(f,f+c.length)==c?f:-1;f<h.text.length&&f<l&&(l=f),r.push({line:h,comment:p,token:c,indent:f,empty:m,single:!1})}d=h.to+1}if(l<1e9)for(let d=a;d<r.length;d++)r[d].indent<r[d].line.text.length&&(r[d].indent=l);r.length==a+1&&(r[a].single=!0)}if(t!=2&&r.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:c,empty:d,single:h}of r)(h||!d)&&s.push({from:a.from+c,insert:l+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:l}of r)if(a>=0){let c=o.from+a,d=c+l.length;o.text[d-o.from]==" "&&d++,s.push({from:c,to:d})}return{changes:s}}return null}const Od=Jn.define(),WT=Jn.define(),KT=H.define(),Ex=H.define({combine(t){return Zn(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),jx=Ct.define({create(){return Kn.empty},update(t,e){let n=e.state.facet(Ex),r=e.annotation(Od);if(r){let l=Ht.fromTransaction(e,r.selection),c=r.side,d=c==0?t.undone:t.done;return l?d=El(d,d.length,n.minDepth,l):d=Dx(d,e.startState.selection),new Kn(c==0?r.rest:d,c==0?d:r.rest)}let i=e.annotation(WT);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(Qe.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Ht.fromTransaction(e),o=e.annotation(Qe.time),a=e.annotation(Qe.userEvent);return s?t=t.addChanges(s,o,a,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,a,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Kn(t.done.map(Ht.fromJSON),t.undone.map(Ht.fromJSON))}});function GT(t={}){return[jx,Ex.of(t),V.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?Nx:e.inputType=="historyRedo"?Id:null;return r?(e.preventDefault(),r(n)):!1}})]}function pc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(jx,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const Nx=pc(0,!1),Id=pc(1,!1),qT=pc(0,!0),YT=pc(1,!0);class Ht{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Ht(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Ht(e.changes&&ot.fromJSON(e.changes),[],e.mapped&&Yn.fromJSON(e.mapped),e.startSelection&&P.fromJSON(e.startSelection),e.selectionsAfter.map(P.fromJSON))}static fromTransaction(e,n){let r=fn;for(let i of e.startState.facet(KT)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new Ht(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,fn)}static selection(e){return new Ht(void 0,fn,void 0,void 0,e)}}function El(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function XT(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,a)=>{for(let l=0;l<n.length;){let c=n[l++],d=n[l++];a>=c&&o<=d&&(r=!0)}}),r}function JT(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function Tx(t,e){return t.length?e.length?t.concat(e):t:e}const fn=[],ZT=200;function Dx(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-ZT));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),El(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Ht.selection([e])]}function QT(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function au(t,e){if(!t.length)return t;let n=t.length,r=fn;for(;n;){let i=eD(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[Ht.selection(r)]:fn}function eD(t,e,n){let r=Tx(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):fn,n);if(!t.changes)return Ht.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Ht(i,le.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const tD=/^(input\.type|delete)($|\.)/;class Kn{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new Kn(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||tD.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,XT(a.changes,e.changes))||r=="input.type.compose")?o=El(o,o.length-1,i.minDepth,new Ht(e.changes.compose(a.changes),Tx(le.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,fn)):o=El(o,o.length,i.minDepth,e),new Kn(o,fn,n,r)}addSelection(e,n,r,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:fn;return s.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&JT(s[s.length-1],e)?this:new Kn(Dx(this.done,e),this.undone,n,r)}addMapping(e){return new Kn(au(this.done,e),au(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,r){let i=e==0?this.done:this.undone;if(i.length==0)return null;let s=i[i.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):n.selection);if(r&&s.selectionsAfter.length)return n.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Od.of({side:e,rest:QT(i),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=i.length==1?fn:i.slice(0,i.length-1);return s.mapped&&(a=au(a,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Od.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Kn.empty=new Kn(fn,fn);const nD=[{key:"Mod-z",run:Nx,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Id,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Id,preventDefault:!0},{key:"Mod-u",run:qT,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:YT,preventDefault:!0}];function us(t,e){return P.create(t.ranges.map(e),t.mainIndex)}function Mn(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function En({state:t,dispatch:e},n){let r=us(t.selection,n);return r.eq(t.selection,!0)?!1:(e(Mn(t,r)),!0)}function gc(t,e){return P.cursor(e?t.to:t.from)}function Ox(t,e){return En(t,n=>n.empty?t.moveByChar(n,e):gc(n,e))}function It(t){return t.textDirectionAt(t.state.selection.main.head)==Ie.LTR}const Ix=t=>Ox(t,!It(t)),Px=t=>Ox(t,It(t));function Rx(t,e){return En(t,n=>n.empty?t.moveByGroup(n,e):gc(n,e))}const rD=t=>Rx(t,!It(t)),iD=t=>Rx(t,It(t));function sD(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function bc(t,e,n){let r=St(t).resolveInner(e.head),i=n?be.closedBy:be.openedBy;for(let l=e.head;;){let c=n?r.childAfter(l):r.childBefore(l);if(!c)break;sD(t,c,i)?r=c:l=n?c.to:c.from}let s=r.type.prop(i),o,a;return s&&(o=n?Wn(t,r.from,1):Wn(t,r.to,-1))&&o.matched?a=n?o.end.to:o.end.from:a=n?r.to:r.from,P.cursor(a,n?-1:1)}const oD=t=>En(t,e=>bc(t.state,e,!It(t))),aD=t=>En(t,e=>bc(t.state,e,It(t)));function Lx(t,e){return En(t,n=>{if(!n.empty)return gc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const _x=t=>Lx(t,!1),Fx=t=>Lx(t,!0);function Bx(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,r=0,i;if(e){for(let s of t.state.facet(V.scrollMargins)){let o=s(t);o?.top&&(n=Math.max(o?.top,n)),o?.bottom&&(r=Math.max(o?.bottom,r))}i=t.scrollDOM.clientHeight-n-r}else i=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:e,height:Math.max(t.defaultLineHeight,i-5)}}function Vx(t,e){let n=Bx(t),{state:r}=t,i=us(r.selection,o=>o.empty?t.moveVertically(o,e,n.height):gc(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+n.marginTop,c=a.bottom-n.marginBottom;o&&o.top>l&&o.bottom<c&&(s=V.scrollIntoView(i.main.head,{y:"start",yMargin:o.top-l}))}return t.dispatch(Mn(r,i),{effects:s}),!0}const Fp=t=>Vx(t,!1),Pd=t=>Vx(t,!0);function Vr(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=P.cursor(r.from+s))}return i}const lD=t=>En(t,e=>Vr(t,e,!0)),cD=t=>En(t,e=>Vr(t,e,!1)),uD=t=>En(t,e=>Vr(t,e,!It(t))),dD=t=>En(t,e=>Vr(t,e,It(t))),hD=t=>En(t,e=>P.cursor(t.lineBlockAt(e.head).from,1)),fD=t=>En(t,e=>P.cursor(t.lineBlockAt(e.head).to,-1));function mD(t,e,n){let r=!1,i=us(t.selection,s=>{let o=Wn(t,s.head,-1)||Wn(t,s.head,1)||s.head>0&&Wn(t,s.head-1,1)||s.head<t.doc.length&&Wn(t,s.head+1,-1);if(!o||!o.end)return s;r=!0;let a=o.start.from==s.head?o.end.to:o.end.from;return P.cursor(a)});return r?(e(Mn(t,i)),!0):!1}const pD=({state:t,dispatch:e})=>mD(t,e);function pn(t,e){let n=us(t.state.selection,r=>{let i=e(r);return P.range(r.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return n.eq(t.state.selection)?!1:(t.dispatch(Mn(t.state,n)),!0)}function zx(t,e){return pn(t,n=>t.moveByChar(n,e))}const $x=t=>zx(t,!It(t)),Hx=t=>zx(t,It(t));function Ux(t,e){return pn(t,n=>t.moveByGroup(n,e))}const gD=t=>Ux(t,!It(t)),bD=t=>Ux(t,It(t)),vD=t=>pn(t,e=>bc(t.state,e,!It(t))),xD=t=>pn(t,e=>bc(t.state,e,It(t)));function Wx(t,e){return pn(t,n=>t.moveVertically(n,e))}const Kx=t=>Wx(t,!1),Gx=t=>Wx(t,!0);function qx(t,e){return pn(t,n=>t.moveVertically(n,e,Bx(t).height))}const Bp=t=>qx(t,!1),Vp=t=>qx(t,!0),yD=t=>pn(t,e=>Vr(t,e,!0)),wD=t=>pn(t,e=>Vr(t,e,!1)),kD=t=>pn(t,e=>Vr(t,e,!It(t))),SD=t=>pn(t,e=>Vr(t,e,It(t))),CD=t=>pn(t,e=>P.cursor(t.lineBlockAt(e.head).from)),AD=t=>pn(t,e=>P.cursor(t.lineBlockAt(e.head).to)),zp=({state:t,dispatch:e})=>(e(Mn(t,{anchor:0})),!0),$p=({state:t,dispatch:e})=>(e(Mn(t,{anchor:t.doc.length})),!0),Hp=({state:t,dispatch:e})=>(e(Mn(t,{anchor:t.selection.main.anchor,head:0})),!0),Up=({state:t,dispatch:e})=>(e(Mn(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),MD=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),ED=({state:t,dispatch:e})=>{let n=vc(t).map(({from:r,to:i})=>P.range(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:P.create(n),userEvent:"select"})),!0},jD=({state:t,dispatch:e})=>{let n=us(t.selection,r=>{let i=St(t),s=i.resolveStack(r.from,1);if(r.empty){let o=i.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:a}=o;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&o.next)return P.range(a.to,a.from)}return r});return n.eq(t.selection)?!1:(e(Mn(t,n)),!0)};function Yx(t,e){let{state:n}=t,r=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to<t.state.doc.length:o.from>0)for(let a=s;;){let l=t.moveVertically(a,e);if(l.head<o.from||l.head>o.to){i.some(c=>c.head==l.head)||i.push(l);break}else{if(l.head==a.head)break;a=l}}}return i.length==r.ranges.length?!1:(t.dispatch(Mn(n,P.create(i,i.length-1))),!0)}const ND=t=>Yx(t,!1),TD=t=>Yx(t,!0),DD=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=P.create([n.main]):n.main.empty||(r=P.create([P.cursor(n.main.head)])),r?(e(Mn(t,r)),!0):!1};function Uo(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=e(s);l<o?(n="delete.backward",l=Aa(t,l,!1)):l>o&&(n="delete.forward",l=Aa(t,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=Aa(t,o,!1),a=Aa(t,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:P.cursor(o,o<s.head?-1:1)}});return i.changes.empty?!1:(t.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?V.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function Aa(t,e,n){if(t instanceof V)for(let r of t.state.facet(V.atomicRanges).map(i=>i(t)))r.between(e,e,(i,s)=>{i<e&&s>e&&(e=n?s:i)});return e}const Xx=(t,e,n)=>Uo(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),a,l;if(n&&!e&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,i-o.from))){if(a[a.length-1]==" ")return i-1;let c=cs(a,s.tabSize),d=c%Cl(s)||Cl(s);for(let h=0;h<d&&a[a.length-1-h]==" ";h++)i--;l=i}else l=ft(o.text,i-o.from,e,e)+o.from,l==i&&o.number!=(e?s.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,i-o.from))&&(l=ft(o.text,l-o.from,!1,!1)+o.from);return l}),Rd=t=>Xx(t,!1,!0),Jx=t=>Xx(t,!0,!1),Zx=(t,e)=>Uo(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let a=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let l=ft(s.text,r-s.from,e)+s.from,c=s.text.slice(Math.min(r,l)-s.from,Math.max(r,l)-s.from),d=o(c);if(a!=null&&d!=a)break;(c!=" "||r!=n.head)&&(a=d),r=l}return r}),Qx=t=>Zx(t,!1),OD=t=>Zx(t,!0),ID=t=>Uo(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),PD=t=>Uo(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),RD=t=>Uo(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),LD=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ye.of(["",""])},range:P.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},_D=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:ft(s.text,i-s.from,!1)+s.from,a=i==s.to?i+1:ft(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:t.doc.slice(i,a).append(t.doc.slice(o,i))},range:P.cursor(a)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function vc(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return e}function e1(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of vc(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),a=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let l of s.ranges)i.push(P.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let l of s.ranges)i.push(P.range(l.anchor-a,l.head-a))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:P.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const FD=({state:t,dispatch:e})=>e1(t,e,!1),BD=({state:t,dispatch:e})=>e1(t,e,!0);function t1(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of vc(t))n?r.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):r.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let i=t.changes(r);return e(t.update({changes:i,selection:t.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const VD=({state:t,dispatch:e})=>t1(t,e,!1),zD=({state:t,dispatch:e})=>t1(t,e,!0),$D=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(vc(e).map(({from:i,to:s})=>(i>0?i--:s<e.doc.length&&s++,{from:i,to:s}))),r=us(e.selection,i=>{let s;if(t.lineWrapping){let o=t.lineBlockAt(i.head),a=t.coordsAtPos(i.head,i.assoc||1);a&&(s=o.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,s)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function HD(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=St(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(be.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const Wp=n1(!1),UD=n1(!0);function n1(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,a=e.doc.lineAt(s),l=!t&&s==o&&HD(e,s);t&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new fc(e,{simulateBreak:s,simulateDoubleBreak:!!l}),d=Wh(c,s);for(d==null&&(d=cs(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:s,to:o}=l:s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let h=["",go(e,d)];return l&&h.push(go(e,c.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:ye.of(h)},range:P.cursor(s+1+h[1].length)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Yh(t,e){let n=-1;return t.changeByRange(r=>{let i=[];for(let o=r.from;o<=r.to;){let a=t.doc.lineAt(o);a.number>n&&(r.empty||r.to>a.from)&&(e(a,i,r),n=a.number),o=a.to+1}let s=t.changes(i);return{changes:i,range:P.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const WD=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new fc(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=Yh(t,(s,o,a)=>{let l=Wh(r,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],d=go(t,l);(c!=d||a.from<s.from+c.length)&&(n[s.from]=l,o.push({from:s.from,to:s.from+c.length,insert:d}))});return i.changes.empty||e(t.update(i,{userEvent:"indent"})),!0},r1=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Yh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(zo)})}),{userEvent:"input.indent"})),!0),i1=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Yh(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=cs(i,t.tabSize),o=0,a=go(t,Math.max(0,s-Cl(t)));for(;o<i.length&&o<a.length&&i.charCodeAt(o)==a.charCodeAt(o);)o++;r.push({from:n.from+o,to:n.from+i.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),KD=t=>(t.setTabFocusMode(),!0),GD=[{key:"Ctrl-b",run:Ix,shift:$x,preventDefault:!0},{key:"Ctrl-f",run:Px,shift:Hx},{key:"Ctrl-p",run:_x,shift:Kx},{key:"Ctrl-n",run:Fx,shift:Gx},{key:"Ctrl-a",run:hD,shift:CD},{key:"Ctrl-e",run:fD,shift:AD},{key:"Ctrl-d",run:Jx},{key:"Ctrl-h",run:Rd},{key:"Ctrl-k",run:ID},{key:"Ctrl-Alt-h",run:Qx},{key:"Ctrl-o",run:LD},{key:"Ctrl-t",run:_D},{key:"Ctrl-v",run:Pd}],qD=[{key:"ArrowLeft",run:Ix,shift:$x,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:rD,shift:gD,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:uD,shift:kD,preventDefault:!0},{key:"ArrowRight",run:Px,shift:Hx,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:iD,shift:bD,preventDefault:!0},{mac:"Cmd-ArrowRight",run:dD,shift:SD,preventDefault:!0},{key:"ArrowUp",run:_x,shift:Kx,preventDefault:!0},{mac:"Cmd-ArrowUp",run:zp,shift:Hp},{mac:"Ctrl-ArrowUp",run:Fp,shift:Bp},{key:"ArrowDown",run:Fx,shift:Gx,preventDefault:!0},{mac:"Cmd-ArrowDown",run:$p,shift:Up},{mac:"Ctrl-ArrowDown",run:Pd,shift:Vp},{key:"PageUp",run:Fp,shift:Bp},{key:"PageDown",run:Pd,shift:Vp},{key:"Home",run:cD,shift:wD,preventDefault:!0},{key:"Mod-Home",run:zp,shift:Hp},{key:"End",run:lD,shift:yD,preventDefault:!0},{key:"Mod-End",run:$p,shift:Up},{key:"Enter",run:Wp,shift:Wp},{key:"Mod-a",run:MD},{key:"Backspace",run:Rd,shift:Rd,preventDefault:!0},{key:"Delete",run:Jx,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Qx,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:OD,preventDefault:!0},{mac:"Mod-Backspace",run:PD,preventDefault:!0},{mac:"Mod-Delete",run:RD,preventDefault:!0}].concat(GD.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),YD=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:oD,shift:vD},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:aD,shift:xD},{key:"Alt-ArrowUp",run:FD},{key:"Shift-Alt-ArrowUp",run:VD},{key:"Alt-ArrowDown",run:BD},{key:"Shift-Alt-ArrowDown",run:zD},{key:"Mod-Alt-ArrowUp",run:ND},{key:"Mod-Alt-ArrowDown",run:TD},{key:"Escape",run:DD},{key:"Mod-Enter",run:UD},{key:"Alt-l",mac:"Ctrl-l",run:ED},{key:"Mod-i",run:jD,preventDefault:!0},{key:"Mod-[",run:i1},{key:"Mod-]",run:r1},{key:"Mod-Alt-\\",run:WD},{key:"Shift-Mod-k",run:$D},{key:"Shift-Mod-\\",run:pD},{key:"Mod-/",run:FT},{key:"Alt-A",run:VT},{key:"Ctrl-m",mac:"Shift-Alt-m",run:KD}].concat(qD),XD={key:"Tab",run:r1,shift:i1},Kp=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class Zi{constructor(e,n,r=0,i=e.length,s,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,i),this.bufferStart=r,this.normalize=s?a=>s(Kp(a)):Kp,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Bt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let n=Sh(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=Vn(e);let i=this.normalize(n);if(i.length)for(let s=0,o=r,a=!0;;s++){let l=i.charCodeAt(s),c=this.match(l,o,a,this.bufferPos+this.bufferStart,s==i.length-1);if(c)return this.value=c,this;if(s==i.length-1)break;a&&s<n.length&&n.charCodeAt(s)==l?o++:a=!1}}}match(e,n,r,i,s){let o=null;for(let a=0;a<this.matches.length;){let l=this.matches[a],c=!1;this.query.charCodeAt(l.index)==e&&(l.index==this.query.length-1?o={from:l.from,to:i,precise:s&&l.precise}:(l.index++,c=!0)),c?a++:this.matches.splice(a,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:n,to:i,precise:r&&s}:this.matches.push({from:n,index:1,precise:r})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(Zi.prototype[Symbol.iterator]=function(){return this});const s1={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Xh="gm"+(/x/.unicode==null?"":"u");class o1{constructor(e,n,r,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=s1,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new a1(e,n,r,i,s);this.re=new RegExp(n,Xh+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=e.iter();let o=e.lineAt(i);this.curLineStart=o.from,this.matchPos=jl(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,i=r+n[0].length;if(this.matchPos=jl(this.text,i+(r==i?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<i||r>this.value.to)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,precise:!0,match:n},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const lu=new WeakMap;class _i{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,r){let i=lu.get(e);if(!i||i.from>=r||i.to<=n){let a=new _i(n,e.sliceString(n,r));return lu.set(e,a),a}if(i.from==n&&i.to==r)return i;let{text:s,from:o}=i;return o>n&&(s=e.sliceString(n,o)+s,o=n),i.to<r&&(s+=e.sliceString(i.to,r)),lu.set(e,new _i(o,s)),new _i(n,s.slice(n-o,r-o))}}class a1{constructor(e,n,r,i,s){this.text=e,this.to=s,this.done=!1,this.value=s1,this.matchPos=jl(e,i),this.re=new RegExp(n,Xh+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=_i.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,i=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,precise:!0,match:n},this.matchPos=jl(this.text,i+(r==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=_i.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(o1.prototype[Symbol.iterator]=a1.prototype[Symbol.iterator]=function(){return this});function JD(t){try{return new RegExp(t,Xh),!0}catch{return!1}}function jl(t,e){if(e>=t.length)return e;let n=t.lineAt(e),r;for(;e<n.to&&(r=n.text.charCodeAt(e-n.from))>=56320&&r<57344;)e++;return e}const ZD=t=>{let{state:e}=t,n=String(e.doc.lineAt(t.state.selection.main.head).number),{close:r,result:i}=lN(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:e.phrase("go")});return i.then(s=>{let o=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!o){t.dispatch({effects:r});return}let a=e.doc.lineAt(e.selection.main.head),[,l,c,d,h]=o,f=d?+d.slice(1):0,m=c?+c:a.number;if(c&&h){let b=m/100;l&&(b=b*(l=="-"?-1:1)+a.number/e.doc.lines),m=Math.round(e.doc.lines*b)}else c&&l&&(m=m*(l=="-"?-1:1)+a.number);let p=e.doc.line(Math.max(1,Math.min(e.doc.lines,m))),g=P.cursor(p.from+Math.max(0,Math.min(f,p.length)));t.dispatch({effects:[r,V.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},QD={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},eO=H.define({combine(t){return Zn(t,QD,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function tO(t){return[oO,sO]}const nO=Q.mark({class:"cm-selectionMatch"}),rO=Q.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Gp(t,e,n,r){return(n==0||t(e.sliceDoc(n-1,n))!=Be.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=Be.Word)}function iO(t,e,n,r){return t(e.sliceDoc(n,n+1))==Be.Word&&t(e.sliceDoc(r-1,r))==Be.Word}const sO=We.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(eO),{state:n}=t,r=n.selection;if(r.ranges.length>1)return Q.none;let i=r.main,s,o=null;if(i.empty){if(!e.highlightWordAroundCursor)return Q.none;let l=n.wordAt(i.head);if(!l)return Q.none;o=n.charCategorizer(i.head),s=n.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l<e.minSelectionLength||l>200)return Q.none;if(e.wholeWords){if(s=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Gp(o,n,i.from,i.to)&&iO(o,n,i.from,i.to)))return Q.none}else if(s=n.sliceDoc(i.from,i.to),!s)return Q.none}let a=[];for(let l of t.visibleRanges){let c=new Zi(n.doc,s,l.from,l.to);for(;!c.next().done;){let{from:d,to:h}=c.value;if((!o||Gp(o,n,d,h))&&(i.empty&&d<=i.from&&h>=i.to?a.push(rO.range(d,h)):(d>=i.to||h<=i.from)&&a.push(nO.range(d,h)),a.length>e.maxMatches))return Q.none}}return Q.set(a)}},{decorations:t=>t.decorations}),oO=V.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),aO=({state:t,dispatch:e})=>{let{selection:n}=t,r=P.create(n.ranges.map(i=>t.wordAt(i.head)||P.cursor(i.head)),n.mainIndex);return r.eq(n)?!1:(e(t.update({selection:r})),!0)};function lO(t,e){let{main:n,ranges:r}=t.selection,i=t.wordAt(n.head),s=i&&i.from==n.from&&i.to==n.to;for(let o=!1,a=new Zi(t.doc,e,r[r.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new Zi(t.doc,e,0,Math.max(0,r[r.length-1].from-1)),o=!0}else{if(o&&r.some(l=>l.from==a.value.from))continue;if(s){let l=t.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const cO=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(s=>s.from===s.to))return aO({state:t,dispatch:e});let r=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(s=>t.sliceDoc(s.from,s.to)!=r))return!1;let i=lO(t,r);return i?(e(t.update({selection:t.selection.addRange(P.range(i.from,i.to),!1),effects:V.scrollIntoView(i.to)})),!0):!1},ci=H.define({combine(t){return Zn(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new SO(e),scrollToMatch:e=>V.scrollIntoView(e)})}});function n9(t){return t?[ci.of(t),_d]:_d}class l1{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||JD(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
|
|
27
27
|
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new pO(this):new hO(this)}getCursor(e,n=0,r){let i=e.doc?e:xe.create({doc:e});return r==null&&(r=i.doc.length),this.regexp?xi(this,i,n,r):vi(this,i,n,r)}}class c1{constructor(e){this.spec=e}}function uO(t,e,n){return(r,i,s,o)=>{if(n&&!n(r,i,s,o))return!1;let a=r>=o&&i<=o+s.length?s.slice(r-o,i-o):e.doc.sliceString(r,i);return t(a,e,r,i)}}function vi(t,e,n,r){let i;return t.wholeWord&&(i=dO(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(i=uO(t.test,e,i)),new Zi(e.doc,t.unquoted,n,r,t.caseSensitive?void 0:s=>s.toLowerCase(),i)}function dO(t,e){return(n,r,i,s)=>((s>n||s+i.length<r)&&(s=Math.max(0,n-2),i=t.sliceString(s,Math.min(t.length,r+2))),(e(Nl(i,n-s))!=Be.Word||e(Tl(i,n-s))!=Be.Word)&&(e(Tl(i,r-s))!=Be.Word||e(Nl(i,r-s))!=Be.Word))}class hO extends c1{constructor(e){super(e)}nextMatch(e,n,r){let i=vi(this.spec,e,r,e.doc.length).nextOverlapping();if(i.done){let s=Math.min(e.doc.length,n+this.spec.unquoted.length);i=vi(this.spec,e,0,s).nextOverlapping()}return i.done||i.value.from==n&&i.value.to==r?null:i.value}prevMatchInRange(e,n,r){for(let i=r;;){let s=Math.max(n,i-1e4-this.spec.unquoted.length),o=vi(this.spec,e,s,i),a=null;for(;!o.nextOverlapping().done;)a=o.value;if(a)return a;if(s==n)return null;i-=1e4}}prevMatch(e,n,r){let i=this.prevMatchInRange(e,0,n);return i||(i=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=n||i.to!=r)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let r=vi(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(e,n,r,i){let s=vi(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}function fO(t,e,n){return(r,i,s)=>(!n||n(r,i,s))&&t(s[0],e,r,i)}function xi(t,e,n,r){let i;return t.wholeWord&&(i=mO(e.charCategorizer(e.selection.main.head))),t.test&&(i=fO(t.test,e,i)),new o1(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:i},n,r)}function Nl(t,e){return t.slice(ft(t,e,!1),e)}function Tl(t,e){return t.slice(e,ft(t,e))}function mO(t){return(e,n,r)=>!r[0].length||(t(Nl(r.input,r.index))!=Be.Word||t(Tl(r.input,r.index))!=Be.Word)&&(t(Tl(r.input,r.index+r[0].length))!=Be.Word||t(Nl(r.input,r.index+r[0].length))!=Be.Word)}class pO extends c1{nextMatch(e,n,r){let i=xi(this.spec,e,r,e.doc.length).next();return i.done&&(i=xi(this.spec,e,0,n).next()),i.done?null:i.value}prevMatchInRange(e,n,r){for(let i=1;;i++){let s=Math.max(n,r-i*1e4),o=xi(this.spec,e,s,r),a=null;for(;!o.next().done;)a=o.value;if(a&&(s==n||a.from>s+10))return a;if(s==n)return null}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let i=r.length;i>0;i--){let s=+r.slice(0,i);if(s>0&&s<e.match.length)return e.match[s]+r.slice(i)}return n})}matchAll(e,n){let r=xi(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(e,n,r,i){let s=xi(this.spec,e,Math.max(0,n-250),Math.min(r+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}const bo=le.define(),Jh=le.define(),Er=Ct.define({create(t){return new cu(Ld(t).create(),null)},update(t,e){for(let n of e.effects)n.is(bo)?t=new cu(n.value.create(),t.panel):n.is(Jh)&&(t=new cu(t.query,n.value?Zh:null));return t},provide:t=>fo.from(t,e=>e.panel)});class cu{constructor(e,n){this.query=e,this.panel=n}}const gO=Q.mark({class:"cm-searchMatch"}),bO=Q.mark({class:"cm-searchMatch cm-searchMatch-selected"}),vO=We.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Er))}update(t){let e=t.state.field(Er);(e!=t.startState.field(Er)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Q.none;let{view:n}=this,r=new cr;for(let i=0,s=n.visibleRanges,o=s.length;i<o;i++){let{from:a,to:l}=s[i];for(;i<o-1&&l>s[i+1].from-500;)l=s[++i].to;t.highlight(n.state,a,l,(c,d)=>{let h=n.state.selection.ranges.some(f=>f.from==c&&f.to==d);r.add(c,d,h?bO:gO)})}return r.finish()}},{decorations:t=>t.decorations});function Wo(t){return e=>{let n=e.state.field(Er,!1);return n&&n.query.spec.valid?t(e,n):h1(e)}}const Dl=Wo((t,{query:e})=>{let{to:n}=t.state.selection.main,r=e.nextMatch(t.state,n,n);if(!r)return!1;let i=P.single(r.from,r.to),s=t.state.facet(ci);return t.dispatch({selection:i,effects:[Qh(t,r),s.scrollToMatch(i.main,t)],userEvent:"select.search"}),d1(t),!0}),Ol=Wo((t,{query:e})=>{let{state:n}=t,{from:r}=n.selection.main,i=e.prevMatch(n,r,r);if(!i)return!1;let s=P.single(i.from,i.to),o=t.state.facet(ci);return t.dispatch({selection:s,effects:[Qh(t,i),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),d1(t),!0}),xO=Wo((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:P.create(n.map(r=>P.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),yO=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,s=[],o=0;for(let a=new Zi(t.doc,t.sliceDoc(r,i));!a.next().done;){if(s.length>1e3)return!1;a.value.from==r&&(o=s.length),s.push(P.range(a.value.from,a.value.to))}return e(t.update({selection:P.create(s,o),userEvent:"select.search.matches"})),!0},qp=Wo((t,{query:e})=>{let{state:n}=t,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,r,r);if(!s)return!1;let o=s,a=[],l,c,d=[];o.precise?o.from==r&&o.to==i&&(c=n.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:c}),d.push(V.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):o=e.nextMatch(n,o.from,o.to);let h=t.state.changes(a);return o&&(l=P.single(o.from,o.to).map(h),d.push(Qh(t,o)),d.push(n.facet(ci).scrollToMatch(l.main,t))),t.dispatch({changes:h,selection:l,effects:d,userEvent:"input.replace"}),!0}),wO=Wo((t,{query:e})=>{if(t.state.readOnly)return!1;let n=[];for(let i of e.matchAll(t.state,1e9)){let{from:s,to:o,precise:a}=i;a&&n.push({from:s,to:o,insert:e.getReplacement(i)})}if(!n.length)return!1;let r=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:V.announce.of(r),userEvent:"input.replace.all"}),!0});function Zh(t){return t.state.facet(ci).createPanel(t)}function Ld(t,e){var n,r,i,s,o;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=t.facet(ci);return new l1({search:((n=e?.literal)!==null&&n!==void 0?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=e?.caseSensitive)!==null&&r!==void 0?r:c.caseSensitive,literal:(i=e?.literal)!==null&&i!==void 0?i:c.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function u1(t){let e=zh(t,Zh);return e&&e.dom.querySelector("[main-field]")}function d1(t){let e=u1(t);e&&e==t.root.activeElement&&e.select()}const h1=t=>{let e=t.state.field(Er,!1);if(e&&e.panel){let n=u1(t);if(n&&n!=t.root.activeElement){let r=Ld(t.state,e.query.spec);r.valid&&t.dispatch({effects:bo.of(r)}),n.focus(),n.select()}}else t.dispatch({effects:[Jh.of(!0),e?bo.of(Ld(t.state,e.query.spec)):le.appendConfig.of(_d)]});return!0},f1=t=>{let e=t.state.field(Er,!1);if(!e||!e.panel)return!1;let n=zh(t,Zh);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Jh.of(!1)}),!0},kO=[{key:"Mod-f",run:h1,scope:"editor search-panel"},{key:"F3",run:Dl,shift:Ol,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Dl,shift:Ol,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:f1,scope:"editor search-panel"},{key:"Mod-Shift-l",run:yO},{key:"Mod-Alt-g",run:ZD},{key:"Mod-d",run:cO,preventDefault:!0}];class SO{constructor(e){this.view=e;let n=this.query=e.state.field(Er).query.spec;this.commit=this.commit.bind(this),this.searchField=Te("input",{value:n.search,placeholder:Zt(e,"Find"),"aria-label":Zt(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Te("input",{value:n.replace,placeholder:Zt(e,"Replace"),"aria-label":Zt(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Te("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=Te("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=Te("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(i,s,o){return Te("button",{class:"cm-button",name:i,onclick:s,type:"button"},o)}this.dom=Te("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,r("next",()=>Dl(e),[Zt(e,"next")]),r("prev",()=>Ol(e),[Zt(e,"previous")]),r("select",()=>xO(e),[Zt(e,"all")]),Te("label",null,[this.caseField,Zt(e,"match case")]),Te("label",null,[this.reField,Zt(e,"regexp")]),Te("label",null,[this.wordField,Zt(e,"by word")]),...e.state.readOnly?[]:[Te("br"),this.replaceField,r("replace",()=>qp(e),[Zt(e,"replace")]),r("replaceAll",()=>wO(e),[Zt(e,"replace all")])],Te("button",{name:"close",onclick:()=>f1(e),"aria-label":Zt(e,"close"),type:"button"},["×"])])}commit(){let e=new l1({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:bo.of(e)}))}keydown(e){b3(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Ol:Dl)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),qp(this.view))}update(e){for(let n of e.transactions)for(let r of n.effects)r.is(bo)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ci).top}}function Zt(t,e){return t.state.phrase(e)}const Ma=30,Ea=/[\s\.,:;?!]/;function Qh(t,{from:e,to:n}){let r=t.state.doc.lineAt(e),i=t.state.doc.lineAt(n).to,s=Math.max(r.from,e-Ma),o=Math.min(i,n+Ma),a=t.state.sliceDoc(s,o);if(s!=r.from){for(let l=0;l<Ma;l++)if(!Ea.test(a[l+1])&&Ea.test(a[l])){a=a.slice(l);break}}if(o!=i){for(let l=a.length-1;l>a.length-Ma;l--)if(!Ea.test(a[l-1])&&Ea.test(a[l])){a=a.slice(0,l);break}}return V.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${r.number}.`)}const CO=V.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),_d=[Er,Br.low(vO),CO];class m1{constructor(e,n,r,i){this.state=e,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=St(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),s=i.search(p1(e,!1));return s<0?null:{from:r+s,to:this.pos,text:i.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,r){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function Yp(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function AO(t){let e=Object.create(null),n=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let s=1;s<i.length;s++)n[i[s]]=!0}let r=Yp(e)+Yp(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function MO(t){let e=t.map(i=>typeof i=="string"?{label:i}:i),[n,r]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:AO(e);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:e,validFor:n}:null}}function r9(t,e){return n=>{for(let r=St(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(t.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return e(n)}}class Xp{constructor(e,n,r,i){this.completion=e,this.source=n,this.match=r,this.score=i}}function ei(t){return t.selection.main.from}function p1(t,e){var n;let{source:r}=t,i=e&&r[0]!="^",s=r[r.length-1]!="$";return!i&&!s?t:new RegExp(`${i?"^":""}(?:${r})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const ef=Jn.define();function EO(t,e,n,r){let{main:i}=t.selection,s=n-i.from,o=r-i.from;return{...t.changeByRange(a=>{if(a!=i&&n!=r&&t.sliceDoc(a.from+s,a.from+o)!=t.sliceDoc(n,r))return{range:a};let l=t.toText(e);return{changes:{from:a.from+s,to:r==i.from?a.to:a.from+o,insert:l},range:P.cursor(a.from+s+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Jp=new WeakMap;function jO(t){if(!Array.isArray(t))return t;let e=Jp.get(t);return e||Jp.set(t,e=MO(t)),e}const Il=le.define(),vo=le.define();class NO{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let r=Bt(e,n),i=Vn(r);this.chars.push(r);let s=e.slice(n,n+i),o=s.toUpperCase();this.folded.push(Bt(o==s?s.toLowerCase():o,0)),n+=i}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:s,byWord:o}=this;if(n.length==1){let y=Bt(e,0),w=Vn(y),k=w==e.length?0:-100;if(y!=n[0])if(y==r[0])k+=-200;else return null;return this.ret(k,[0,w])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(a<0){for(let y=0,w=Math.min(e.length,200);y<w&&c<l;){let k=Bt(e,y);(k==n[c]||k==r[c])&&(i[c++]=y),y+=Vn(k)}if(c<l)return null}let d=0,h=0,f=!1,m=0,p=-1,g=-1,b=/[a-z]/.test(e),x=!0;for(let y=0,w=Math.min(e.length,200),k=0;y<w&&h<l;){let C=Bt(e,y);a<0&&(d<l&&C==n[d]&&(s[d++]=y),m<l&&(C==n[m]||C==r[m]?(m==0&&(p=y),g=y+1,m++):m=0));let S,A=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(S=Sh(C))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!y||A==1&&b||k==0&&A!=0)&&(n[h]==C||r[h]==C&&(f=!0)?o[h++]=y:o.length&&(x=!1)),k=A,y+=Vn(C)}return h==l&&o[0]==0&&x?this.result(-100+(f?-200:0),o,e):m==l&&p==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):m==l?this.ret(-900-e.length,[p,g]):h==l?this.result(-100+(f?-200:0)+-700+(x?0:-1100),o,e):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,n,r){let i=[],s=0;for(let o of n){let a=o+(this.astral?Vn(Bt(r,o)):1);s&&i[s-1]==o?i[s-1]=a:(i[s++]=o,i[s++]=a)}return this.ret(e-r.length,i)}}class TO{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(e.length==this.pattern.length?0:-100),this)}}const dt=H.define({combine(t){return Zn(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:DO,filterStrict:!1,compareCompletions:(e,n)=>(e.sortText||e.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>r=>Zp(e(r),n(r)),optionClass:(e,n)=>r=>Zp(e(r),n(r)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function Zp(t,e){return t?e?t+" "+e:t:e}function DO(t,e,n,r,i,s){let o=t.textDirection==Ie.RTL,a=o,l=!1,c="top",d,h,f=e.left-i.left,m=i.right-e.right,p=r.right-r.left,g=r.bottom-r.top;if(a&&f<Math.min(p,m)?a=!1:!a&&m<Math.min(p,f)&&(a=!0),p<=(a?f:m))d=Math.max(i.top,Math.min(n.top,i.bottom-g))-e.top,h=Math.min(400,a?f:m);else{l=!0,h=Math.min(400,(o?e.right:i.right-e.left)-30);let y=i.bottom-e.bottom;y>=g||y>e.top?d=n.bottom-e.top:(c="bottom",d=e.bottom-n.top)}let b=(e.bottom-e.top)/s.offsetHeight,x=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${d/b}px; max-width: ${h/x}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}const tf=le.define();function OO(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),e.push({render(n,r,i,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=n.displayLabel||n.label,l=0;for(let c=0;c<s.length;){let d=s[c++],h=s[c++];d>l&&o.appendChild(document.createTextNode(a.slice(l,d)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(a.slice(d,h))),f.className="cm-completionMatchedText",l=h}return l<a.length&&o.appendChild(document.createTextNode(a.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),e.sort((n,r)=>n.position-r.position).map(n=>n.render)}function uu(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let i=Math.floor(e/n);return{from:i*n,to:(i+1)*n}}let r=Math.ceil((t-e)/n);return{from:t-r*n,to:t-(r-1)*n}}class IO{constructor(e,n,r){this.view=e,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=e.state.field(n),{options:s,selected:o}=i.open,a=e.state.facet(dt);this.optionContent=OO(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=uu(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(n).open;for(let d=l.target,h;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(h=/-(\d+)$/.exec(d.id))&&+h[1]<c.length){this.applyCompletion(e,c[+h[1]]),l.preventDefault();return}if(l.target==this.list){let d=this.list.classList.contains("cm-completionListIncompleteTop")&&l.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&l.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(e.dispatch({effects:tf.of(d)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(dt).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:vo.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let r=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),r!=i){let{options:s,selected:o,disabled:a}=r.open;(!i.open||i.open.options!=s)&&(this.range=uu(s.length,o,e.state.facet(dt).maxRenderedOptions),this.showOptions(s,r.id)),this.updateSel(),a!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=uu(n.options.length,n.selected,this.view.state.facet(dt).maxRenderedOptions),this.showOptions(n.options,e.id));let r=this.updateSelectedOption(n.selected);if(r){this.destroyInfo();let{completion:i}=n.options[n.selected],{info:s}=i;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(i);if(!o)return;"then"in o?o.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,i)}).catch(a=>$t(this.view.state,a,"completion info")):(this.addInfoPane(o,i),r.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",r.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)r.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:s}=e;r.appendChild(i),this.infoDestroy=s||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==e?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&(r.removeAttribute("aria-selected"),r.removeAttribute("aria-describedby"));return n&&RO(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(s.bottom,n.bottom)-10||i.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(dt).positionInfo(this.view,n,i,r,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let s=null;for(let o=r.from;o<r.to;o++){let{completion:a,match:l}=e[o],{section:c}=a;if(c){let f=typeof c=="string"?c:c.name;if(f!=s&&(o>r.from||r.from==0))if(s=f,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let m=i.appendChild(document.createElement("completion-section"));m.textContent=f}}const d=i.appendChild(document.createElement("li"));d.id=n+"-"+o,d.setAttribute("role","option");let h=this.optionClass(a);h&&(d.className=h);for(let f of this.optionContent){let m=f(a,this.view.state,this.view,l);m&&d.appendChild(m)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function PO(t,e){return n=>new IO(n,t,e)}function RO(t,e){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=n.height/t.offsetHeight;r.top<n.top?t.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(t.scrollTop+=(r.bottom-n.bottom)/i)}function Qp(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function LO(t,e){let n=[],r=null,i=null,s=d=>{n.push(d);let{section:h}=d.completion;if(h){r||(r=[]);let f=typeof h=="string"?h:h.name;r.some(m=>m.name==f)||r.push(typeof h=="string"?{name:f}:h)}},o=e.facet(dt);for(let d of t)if(d.hasResult()){let h=d.result.getMatch;if(d.result.filter===!1)for(let f of d.result.options)s(new Xp(f,d.source,h?h(f):[],1e9-n.length));else{let f=e.sliceDoc(d.from,d.to),m,p=o.filterStrict?new TO(f):new NO(f);for(let g of d.result.options)if(m=p.match(g.label)){let b=g.displayLabel?h?h(g,m.matched):[]:m.matched,x=m.score+(g.boost||0);if(s(new Xp(g,d.source,b,x)),typeof g.section=="object"&&g.section.rank==="dynamic"){let{name:y}=g.section;i||(i=Object.create(null)),i[y]=Math.max(x,i[y]||-1e9)}}}}if(r){let d=Object.create(null),h=0,f=(m,p)=>(m.rank==="dynamic"&&p.rank==="dynamic"?i[p.name]-i[m.name]:0)||(typeof m.rank=="number"?m.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(m.name<p.name?-1:1);for(let m of r.sort(f))h-=1e5,d[m.name]=h;for(let m of n){let{section:p}=m.completion;p&&(m.score+=d[typeof p=="string"?p:p.name])}}let a=[],l=null,c=o.compareCompletions;for(let d of n.sort((h,f)=>f.score-h.score||c(h.completion,f.completion))){let h=d.completion;!l||l.label!=h.label||l.detail!=h.detail||l.type!=null&&h.type!=null&&l.type!=h.type||l.apply!=h.apply||l.boost!=h.boost?a.push(d):Qp(d.completion)>Qp(l)&&(a[a.length-1]=d),l=d.completion}return a}class Mi{constructor(e,n,r,i,s,o){this.options=e,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=s,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new Mi(this.options,eg(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,r,i,s,o){if(i&&!o&&e.some(c=>c.isPending))return i.setDisabled();let a=LO(e,n);if(!a.length)return i&&e.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(dt).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let d=0;d<a.length;d++)if(a[d].completion==c){l=d;break}}return new Mi(a,eg(r,l),{pos:e.reduce((c,d)=>d.hasResult()?Math.min(c,d.from):c,1e8),create:$O,above:s.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(e){return new Mi(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Mi(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Pl{constructor(e,n,r){this.active=e,this.id=n,this.open=r}static start(){return new Pl(VO,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,r=n.facet(dt),s=(r.override||n.languageDataAt("autocomplete",ei(n)).map(jO)).map(l=>(this.active.find(d=>d.source==l)||new mn(l,this.active.some(d=>d.state!=0)?1:0)).update(e,r));s.length==this.active.length&&s.every((l,c)=>l==this.active[c])&&(s=this.active);let o=this.open,a=e.effects.some(l=>l.is(nf));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!_O(s,this.active)||a?o=Mi.build(s,n,this.id,o,r,a):o&&o.disabled&&!s.some(l=>l.isPending)&&(o=null),!o&&s.every(l=>!l.isPending)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new mn(l.source,0):l));for(let l of e.effects)l.is(tf)&&(o=o&&o.setSelected(l.value,this.id));return s==this.active&&o==this.open?this:new Pl(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?FO:BO}}function _O(t,e){if(t==e)return!0;for(let n=0,r=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;r<e.length&&!e[r].hasResult();)r++;let i=n==t.length,s=r==e.length;if(i||s)return i==s;if(t[n++].result!=e[r++].result)return!1}}const FO={"aria-autocomplete":"list"},BO={};function eg(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const VO=[];function g1(t,e){if(t.isUserEvent("input.complete")){let r=t.annotation(ef);if(r&&e.activateOnCompletion(r))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class mn{constructor(e,n,r=!1){this.source=e,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let r=g1(e,n),i=this;(r&8||r&16&&this.touches(e))&&(i=new mn(i.source,0)),r&4&&i.state==0&&(i=new mn(this.source,1)),i=i.updateFor(e,r);for(let s of e.effects)if(s.is(Il))i=new mn(i.source,1,s.value);else if(s.is(vo))i=new mn(i.source,0);else if(s.is(nf))for(let o of s.value)o.source==i.source&&(i=o);return i}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(ei(e.state))}}class Fi extends mn{constructor(e,n,r,i,s,o){super(e,3,n),this.limit=r,this.result=i,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,n){var r;if(!(n&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=ei(e.state);if(a>o||!i||n&2&&(ei(e.startState)==this.from||a<this.limit))return new mn(this.source,n&4?1:0);let l=e.changes.mapPos(this.limit);return zO(i.validFor,e.state,s,o)?new Fi(this.source,this.explicit,l,i,s,o):i.update&&(i=i.update(i,s,o,new m1(e.state,a,!1)))?new Fi(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:ei(e.state)):new mn(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Fi(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new mn(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function zO(t,e,n,r){if(!t)return!1;let i=e.sliceDoc(n,r);return typeof t=="function"?t(i,n,r,e):p1(t,!0).test(i)}const nf=le.define({map(t,e){return t.map(n=>n.map(e))}}),Vt=Ct.define({create(){return Pl.start()},update(t,e){return t.update(e)},provide:t=>[Vh.from(t,e=>e.tooltip),V.contentAttributes.from(t,e=>e.attrs)]});function rf(t,e){const n=e.completion.apply||e.completion.label;let r=t.state.field(Vt).active.find(i=>i.source==e.source);return r instanceof Fi?(typeof n=="string"?t.dispatch({...EO(t.state,n,r.from,r.to),annotations:ef.of(e.completion)}):n(t,e.completion,r.from,r.to),!0):!1}const $O=PO(Vt,rf);function ja(t,e="option"){return n=>{let r=n.state.field(Vt,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(dt).interactionDelay)return!1;let i=1,s;e=="page"&&(s=Zv(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,a=r.open.selected>-1?r.open.selected+i*(t?1:-1):t?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),n.dispatch({effects:tf.of(a)}),!0}}const HO=t=>{let e=t.state.field(Vt,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(dt).interactionDelay?!1:rf(t,e.open.options[e.open.selected])},du=t=>t.state.field(Vt,!1)?(t.dispatch({effects:Il.of(!0)}),!0):!1,UO=t=>{let e=t.state.field(Vt,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:vo.of(null)}),!0)};class WO{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const KO=50,GO=1e3,qO=We.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Vt).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(Vt),n=t.state.facet(dt);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Vt)==e)return;let r=t.transactions.some(s=>{let o=g1(s,n);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(r||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>KO&&Date.now()-o.time>GO){for(let a of o.context.abortListeners)try{a()}catch(l){$t(this.view.state,l)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(o=>o.is(Il)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of t.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Vt);for(let n of e.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(dt).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=ei(e),r=new m1(e,n,t.explicit,this.view),i=new WO(t,r);this.running.push(i),Promise.resolve(t.source(r)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:vo.of(null)}),$t(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(dt).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(dt),r=this.view.state.field(Vt);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let a=ei(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(a,s.done.from+(s.active.explicit?0:1)),c=new Fi(s.active.source,s.active.explicit,l,s.done,s.done.from,(t=s.done.to)!==null&&t!==void 0?t:a);for(let d of s.updates)c=c.update(d,n);if(c.hasResult()){e.push(c);continue}}let o=r.active.find(a=>a.source==s.active.source);if(o&&o.isPending)if(s.done==null){let a=new mn(s.active.source,0);for(let l of s.updates)a=a.update(l,n);a.isPending||e.push(a)}else this.startQuery(o)}(e.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:nf.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Vt,!1);if(e&&e.tooltip&&this.view.state.facet(dt).closeOnBlur){let n=e.open&&Zv(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:vo.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Il.of(!1)}),20),this.composing=0}}}),YO=typeof navigator=="object"&&/Win/.test(navigator.platform),XO=Br.highest(V.domEventHandlers({keydown(t,e){let n=e.state.field(Vt,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(YO&&t.altKey)||t.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),s=r.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&rf(e,r),!1}})),b1=V.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class JO{constructor(e,n,r,i){this.field=e,this.line=n,this.from=r,this.to=i}}class sf{constructor(e,n,r){this.field=e,this.from=n,this.to=r}map(e){let n=e.mapPos(this.from,-1,yt.TrackDel),r=e.mapPos(this.to,1,yt.TrackDel);return n==null||r==null?null:new sf(this.field,n,r)}}class of{constructor(e,n){this.lines=e,this.fieldPositions=n}instantiate(e,n){let r=[],i=[n],s=e.doc.lineAt(n),o=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(r.length){let c=o,d=/^\t*/.exec(l)[0].length;for(let h=0;h<d;h++)c+=e.facet(zo);i.push(n+c.length-d),l=c+l.slice(d)}r.push(l),n+=l.length+1}let a=this.fieldPositions.map(l=>new sf(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:a}}static parse(e){let n=[],r=[],i=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let a=s[1]?+s[1]:null,l=s[2]||s[3]||"",c=-1,d=l.replace(/\\[{}]/g,h=>h[1]);for(let h=0;h<n.length;h++)(a!=null?n[h].seq==a:d&&n[h].name==d)&&(c=h);if(c<0){let h=0;for(;h<n.length&&(a==null||n[h].seq!=null&&n[h].seq<a);)h++;n.splice(h,0,{seq:a,name:d}),c=h;for(let f of i)f.field>=c&&f.field++}for(let h of i)if(h.line==r.length&&h.from>s.index){let f=s[2]?3+(s[1]||"").length:2;h.from-=f,h.to-=f}i.push(new JO(c,r.length,s.index,s.index+d.length)),o=o.slice(0,s.index)+l+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(a,l,c)=>{for(let d of i)d.line==r.length&&d.from>c&&(d.from--,d.to--);return l}),r.push(o)}return new of(r,i)}}let ZO=Q.widget({widget:new class extends An{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),QO=Q.mark({class:"cm-snippetField"});class ds{constructor(e,n){this.ranges=e,this.active=n,this.deco=Q.set(e.map(r=>(r.from==r.to?ZO:QO).range(r.from,r.to)),!0)}map(e){let n=[];for(let r of this.ranges){let i=r.map(e);if(!i)return null;n.push(i)}return new ds(n,this.active)}selectionInsideField(e){return e.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const Ko=le.define({map(t,e){return t&&t.map(e)}}),e4=le.define(),xo=Ct.define({create(){return null},update(t,e){for(let n of e.effects){if(n.is(Ko))return n.value;if(n.is(e4)&&t)return new ds(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>V.decorations.from(t,e=>e?e.deco:Q.none)});function af(t,e){return P.create(t.filter(n=>n.field==e).map(n=>P.range(n.from,n.to)))}function t4(t){let e=of.parse(t);return(n,r,i,s)=>{let{text:o,ranges:a}=e.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:s==l.from?l.to:s,insert:ye.of(o)},scrollIntoView:!0,annotations:r?[ef.of(r),Qe.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=af(a,0)),a.some(d=>d.field>0)){let d=new ds(a,0),h=c.effects=[Ko.of(d)];n.state.field(xo,!1)===void 0&&h.push(le.appendConfig.of([xo,o4,a4,b1]))}n.dispatch(n.state.update(c))}}function v1(t){return({state:e,dispatch:n})=>{let r=e.field(xo,!1);if(!r||t<0&&r.active==0)return!1;let i=r.active+t,s=t>0&&!r.ranges.some(o=>o.field==i+t);return n(e.update({selection:af(r.ranges,i),effects:Ko.of(s?null:new ds(r.ranges,i)),scrollIntoView:!0})),!0}}const n4=({state:t,dispatch:e})=>t.field(xo,!1)?(e(t.update({effects:Ko.of(null)})),!0):!1,r4=v1(1),i4=v1(-1),s4=[{key:"Tab",run:r4,shift:i4},{key:"Escape",run:n4}],tg=H.define({combine(t){return t.length?t[0]:s4}}),o4=Br.highest(Vo.compute([tg],t=>t.facet(tg)));function i9(t,e){return{...e,apply:t4(t)}}const a4=V.domEventHandlers({mousedown(t,e){let n=e.state.field(xo,!1),r;if(!n||(r=e.posAtCoords({x:t.clientX,y:t.clientY}))==null)return!1;let i=n.ranges.find(s=>s.from<=r&&s.to>=r);return!i||i.field==n.active?!1:(e.dispatch({selection:af(n.ranges,i.field),effects:Ko.of(n.ranges.some(s=>s.field>i.field)?new ds(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),yo={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Jr=le.define({map(t,e){let n=e.mapPos(t,-1,yt.TrackAfter);return n??void 0}}),lf=new class extends Dr{};lf.startSide=1;lf.endSide=-1;const x1=Ct.define({create(){return ge.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of e.effects)n.is(Jr)&&(t=t.update({add:[lf.range(n.value,n.value+1)]}));return t}});function l4(){return[u4,x1]}const hu="()[]{}<>«»»«[]{}";function y1(t){for(let e=0;e<hu.length;e+=2)if(hu.charCodeAt(e)==t)return hu.charAt(e+1);return Sh(t<128?t:t+1)}function w1(t,e){return t.languageDataAt("closeBrackets",e)[0]||yo}const c4=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),u4=V.inputHandler.of((t,e,n,r)=>{if((c4?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let i=t.state.selection.main;if(r.length>2||r.length==2&&Vn(Bt(r,0))==1||e!=i.from||n!=i.to)return!1;let s=f4(t.state,r);return s?(t.dispatch(s),!0):!1}),d4=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=w1(t,t.selection.main.head).brackets||yo.brackets,i=null,s=t.changeByRange(o=>{if(o.empty){let a=m4(t.doc,o.head);for(let l of r)if(l==a&&xc(t.doc,o.head)==y1(Bt(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:P.cursor(o.head-l.length)}}return{range:i=o}});return i||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},h4=[{key:"Backspace",run:d4}];function f4(t,e){let n=w1(t,t.selection.main.head),r=n.brackets||yo.brackets;for(let i of r){let s=y1(Bt(i,0));if(e==i)return s==i?b4(t,i,r.indexOf(i+i+i)>-1,n):p4(t,i,s,n.before||yo.before);if(e==s&&k1(t,t.selection.main.from))return g4(t,i,s)}return null}function k1(t,e){let n=!1;return t.field(x1).between(0,t.doc.length,r=>{r==e&&(n=!0)}),n}function xc(t,e){let n=t.sliceString(e,e+2);return n.slice(0,Vn(Bt(n,0)))}function m4(t,e){let n=t.sliceString(e-2,e);return Vn(Bt(n,0))==n.length?n:n.slice(1)}function p4(t,e,n,r){let i=null,s=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:Jr.of(o.to+e.length),range:P.range(o.anchor+e.length,o.head+e.length)};let a=xc(t.doc,o.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:e+n,from:o.head},effects:Jr.of(o.head+e.length),range:P.cursor(o.head+e.length)}:{range:i=o}});return i?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function g4(t,e,n){let r=null,i=t.changeByRange(s=>s.empty&&xc(t.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:P.cursor(s.head+n.length)}:r={range:s});return r?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function b4(t,e,n,r){let i=r.stringPrefixes||yo.stringPrefixes,s=null,o=t.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Jr.of(a.to+e.length),range:P.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=xc(t.doc,l),d;if(c==e){if(ng(t,l))return{changes:{insert:e+e,from:l},effects:Jr.of(l+e.length),range:P.cursor(l+e.length)};if(k1(t,l)){let f=n&&t.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+f.length,insert:f},range:P.cursor(l+f.length)}}}else{if(n&&t.sliceDoc(l-2*e.length,l)==e+e&&(d=rg(t,l-2*e.length,i))>-1&&ng(t,d))return{changes:{insert:e+e+e+e,from:l},effects:Jr.of(l+e.length),range:P.cursor(l+e.length)};if(t.charCategorizer(l)(c)!=Be.Word&&rg(t,l,i)>-1&&!v4(t,l,e,i))return{changes:{insert:e+e,from:l},effects:Jr.of(l+e.length),range:P.cursor(l+e.length)}}return{range:s=a}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ng(t,e){let n=St(t).resolveInner(e+1);return n.parent&&n.from==e}function v4(t,e,n,r){let i=St(t).resolveInner(e,-1),s=r.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=t.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),l=a.indexOf(n);if(!l||l>-1&&r.indexOf(a.slice(0,l))>-1){let d=i.firstChild;for(;d&&d.from==i.from&&d.to-d.from>n.length+l;){if(t.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let c=i.to==e&&i.parent;if(!c)break;i=c}return!1}function rg(t,e,n){let r=t.charCategorizer(e);if(r(t.sliceDoc(e-1,e))!=Be.Word)return e;for(let i of n){let s=e-i.length;if(t.sliceDoc(s,e)==i&&r(t.sliceDoc(s-1,s))!=Be.Word)return s}return-1}function x4(t={}){return[XO,Vt,dt.of(t),qO,y4,b1]}const S1=[{key:"Ctrl-Space",run:du},{mac:"Alt-`",run:du},{mac:"Alt-i",run:du},{key:"Escape",run:UO},{key:"ArrowDown",run:ja(!0)},{key:"ArrowUp",run:ja(!1)},{key:"PageDown",run:ja(!0,"page")},{key:"PageUp",run:ja(!1,"page")},{key:"Enter",run:HO}],y4=Br.highest(Vo.computeN([dt],t=>t.facet(dt).defaultKeymap?[S1]:[]));class ig{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class Gr{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(wo).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((m,p)=>m.from-p.from||m.to-p.to),o=new cr,a=[],l=0,c=r.doc.iter(),d=0,h=r.doc.length;for(let m=0;;){let p=m==s.length?null:s[m];if(!p&&!a.length)break;let g,b;if(a.length)g=l,b=a.reduce((w,k)=>Math.min(w,k.to),p&&p.from>g?p.from:1e8);else{if(g=p.from,g>h)break;b=p.to,a.push(p),m++}for(;m<s.length;){let w=s[m];if(w.from==g&&(w.to>w.from||w.to==g))a.push(w),m++,b=Math.min(w.to,b);else{b=Math.min(w.from,b);break}}b=Math.min(b,h);let x=!1;if(a.some(w=>w.from==g&&(w.to==b||b==h))&&(x=g==b,!x&&b-g<10)){let w=g-(d+c.value.length);w>0&&(c.next(w),d=g);for(let k=g;;){if(k>=b){x=!0;break}if(!c.lineBreak&&d+c.value.length>k)break;k=d+c.value.length,d+=c.value.length,c.next()}}let y=I4(a);if(x)o.add(g,g,Q.widget({widget:new N4(y),diagnostics:a.slice()}));else{let w=a.reduce((k,C)=>C.markClass?k+" "+C.markClass:k,"");o.add(g,b,Q.mark({class:"cm-lintRange cm-lintRange-"+y+w,diagnostics:a.slice(),inclusiveEnd:a.some(k=>k.to>b)}))}if(l=b,l==h)break;for(let w=0;w<a.length;w++)a[w].to<=l&&a.splice(w--,1)}let f=o.finish();return new Gr(f,n,_r(f))}}function _r(t,e=null,n=0){let r=null;return t.between(n,1e9,(i,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new ig(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new ig(r.from,s,r.diagnostic)}}),r}function w4(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(wo).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(C1))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function k4(t,e){return t.field(nn,!1)?e:e.concat(le.appendConfig.of(P4))}const C1=le.define(),cf=le.define(),A1=le.define(),nn=Ct.define({create(){return new Gr(Q.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=_r(n,t.selected.diagnostic,s)||_r(n,null,s)}!n.size&&i&&e.state.facet(wo).autoPanel&&(i=null),t=new Gr(n,i,r)}for(let n of e.effects)if(n.is(C1)){let r=e.state.facet(wo).autoPanel?n.value.length?ko.open:null:t.panel;t=Gr.init(n.value,r,e.state)}else n.is(cf)?t=new Gr(t.diagnostics,n.value?ko.open:null,t.selected):n.is(A1)&&(t=new Gr(t.diagnostics,t.panel,n.value));return t},provide:t=>[fo.from(t,e=>e.panel),V.decorations.from(t,e=>e.diagnostics)]}),S4=Q.mark({class:"cm-lintRange cm-lintRange-active"});function C4(t,e,n){let{diagnostics:r}=t.state.field(nn),i,s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(l,c,{spec:d})=>{if(e>=l&&e<=c&&(l==c||(e>l||n>0)&&(e<c||n<0)))return i=d.diagnostics,s=l,o=c,!1});let a=t.state.facet(wo).tooltipFilter;return i&&a&&(i=a(i,t.state)),i?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:A4(t,i)}}}:null}function A4(t,e){return Te("ul",{class:"cm-tooltip-lint"},e.map(n=>E1(t,n,!1)))}const M4=t=>{let e=t.state.field(nn,!1);(!e||!e.panel)&&t.dispatch({effects:k4(t.state,[cf.of(!0)])});let n=zh(t,ko.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},sg=t=>{let e=t.state.field(nn,!1);return!e||!e.panel?!1:(t.dispatch({effects:cf.of(!1)}),!0)},E4=t=>{let e=t.state.field(nn,!1);if(!e)return!1;let n=t.state.selection.main,r=_r(e.diagnostics,null,n.to+1);return!r&&(r=_r(e.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),oN(t,r.from,1,{tooltip:j1,until:i=>i.docChanged||i.newSelection.main.head<r.from||i.newSelection.main.head>r.to}),!0)},j4=[{key:"Mod-Shift-m",run:M4,preventDefault:!0},{key:"F8",run:E4}],wo=H.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...Zn(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:og,tooltipFilter:og,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,i,s)=>e(r,i,s)||n(r,i,s):e:n,autoPanel:(e,n)=>e||n})}}});function og(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function M1(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;r<n.length;r++){let i=n[r];if(/[a-zA-Z]/.test(i)&&!e.some(s=>s.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function E1(t,e,n){var r;let i=n?M1(e.actions):[];return Te("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Te("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let a=!1,l=m=>{if(m.preventDefault(),a)return;a=!0;let p=_r(t.state.field(nn).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:c}=s,d=i[o]?c.indexOf(i[o]):-1,h=d<0?c:[c.slice(0,d),Te("u",c.slice(d,d+1)),c.slice(d+1)],f=s.markClass?" "+s.markClass:"";return Te("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${d<0?"":` (access key "${i[o]})"`}.`},h)}),e.source&&Te("div",{class:"cm-diagnosticSource"},e.source))}class N4 extends An{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Te("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ag{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=E1(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ko{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)sg(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=M1(s.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==i.keyCode){let l=_r(this.view.state.field(nn).diagnostics,s);l&&s.actions[a].apply(e,l.from,l.to)}}else return;i.preventDefault()}},r=i=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(i.target)&&this.moveSelection(s)};this.list=Te("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=Te("div",{class:"cm-panel-lint"},this.list,Te("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>sg(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(nn).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(nn),r=0,i=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:c})=>{for(let d of c.diagnostics){if(o.has(d))continue;o.add(d);let h=-1,f;for(let m=r;m<this.items.length;m++)if(this.items[m].diagnostic==d){h=m;break}h<0?(f=new ag(this.view,d),this.items.splice(r,0,f),i=!0):(f=this.items[h],h>r&&(this.items.splice(r,h-r),i=!0)),n&&f.diagnostic==n.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),s=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new ag(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/c:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(nn),r=_r(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:A1.of(r)})}static open(e){return new ko(e)}}function T4(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Na(t){return T4(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const D4=V.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Na("#f11")},".cm-lintRange-warning":{backgroundImage:Na("orange")},".cm-lintRange-info":{backgroundImage:Na("#999")},".cm-lintRange-hint":{backgroundImage:Na("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function O4(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function I4(t){let e="hint",n=1;for(let r of t){let i=O4(r.severity);i>n&&(n=i,e=r.severity)}return e}const j1=sN(C4,{hideOn:w4}),P4=[nn,V.decorations.compute([nn],t=>{let{selected:e,panel:n}=t.field(nn);return!e||!n||e.from==e.to?Q.none:Q.set([S4.range(e.from,e.to)])}),j1,D4];var lg=function(e){e===void 0&&(e={});var n=e,r=n.crosshairCursor,i=r===void 0?!1:r,s=[];e.closeBracketsKeymap!==!1&&(s=s.concat(h4)),e.defaultKeymap!==!1&&(s=s.concat(YD)),e.searchKeymap!==!1&&(s=s.concat(kO)),e.historyKeymap!==!1&&(s=s.concat(nD)),e.foldKeymap!==!1&&(s=s.concat(gT)),e.completionKeymap!==!1&&(s=s.concat(S1)),e.lintKeymap!==!1&&(s=s.concat(j4));var o=[];return e.lineNumbers!==!1&&o.push(xN()),e.highlightActiveLineGutter!==!1&&o.push(kN()),e.highlightSpecialChars!==!1&&o.push(P3()),e.history!==!1&&o.push(GT()),e.foldGutter!==!1&&o.push(yT()),e.drawSelection!==!1&&o.push(S3()),e.dropCursor!==!1&&o.push(j3()),e.allowMultipleSelections!==!1&&o.push(xe.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&o.push(oT()),e.syntaxHighlighting!==!1&&o.push(kx(CT,{fallback:!0})),e.bracketMatching!==!1&&o.push(DT()),e.closeBrackets!==!1&&o.push(l4()),e.autocompletion!==!1&&o.push(x4()),e.rectangularSelection!==!1&&o.push(q3()),i!==!1&&o.push(J3()),e.highlightActiveLine!==!1&&o.push(V3()),e.highlightSelectionMatches!==!1&&o.push(tO()),e.tabSize&&typeof e.tabSize=="number"&&o.push(zo.of(" ".repeat(e.tabSize))),o.concat([Vo.of(s.flat())]).filter(Boolean)};const R4="#e5c07b",cg="#e06c75",L4="#56b6c2",_4="#ffffff",Ua="#abb2bf",Fd="#7d8799",F4="#61afef",B4="#98c379",ug="#d19a66",V4="#c678dd",z4="#21252b",dg="#2c313a",hg="#282c34",fu="#353a42",$4="#3E4451",fg="#528bff",H4=V.theme({"&":{color:Ua,backgroundColor:hg},".cm-content":{caretColor:fg},".cm-cursor, .cm-dropCursor":{borderLeftColor:fg},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:$4},".cm-panels":{backgroundColor:z4,color:Ua},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:hg,color:Fd,border:"none"},".cm-activeLineGutter":{backgroundColor:dg},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:fu},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:fu,borderBottomColor:fu},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:dg,color:Ua}}},{dark:!0}),U4=Ho.define([{tag:I.keyword,color:V4},{tag:[I.name,I.deleted,I.character,I.propertyName,I.macroName],color:cg},{tag:[I.function(I.variableName),I.labelName],color:F4},{tag:[I.color,I.constant(I.name),I.standard(I.name)],color:ug},{tag:[I.definition(I.name),I.separator],color:Ua},{tag:[I.typeName,I.className,I.number,I.changed,I.annotation,I.modifier,I.self,I.namespace],color:R4},{tag:[I.operator,I.operatorKeyword,I.url,I.escape,I.regexp,I.link,I.special(I.string)],color:L4},{tag:[I.meta,I.comment],color:Fd},{tag:I.strong,fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.link,color:Fd,textDecoration:"underline"},{tag:I.heading,fontWeight:"bold",color:cg},{tag:[I.atom,I.bool,I.special(I.variableName)],color:ug},{tag:[I.processingInstruction,I.string,I.inserted],color:B4},{tag:I.invalid,color:_4}]),W4=[H4,kx(U4)];var K4=V.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),G4=function(e){e===void 0&&(e={});var n=e,r=n.indentWithTab,i=r===void 0?!0:r,s=n.editable,o=s===void 0?!0:s,a=n.readOnly,l=a===void 0?!1:a,c=n.theme,d=c===void 0?"light":c,h=n.placeholder,f=h===void 0?"":h,m=n.basicSetup,p=m===void 0?!0:m,g=[];switch(i&&g.unshift(Vo.of([XD])),p&&(typeof p=="boolean"?g.unshift(lg()):g.unshift(lg(p))),f&&g.unshift(U3(f)),d){case"light":g.push(K4);break;case"dark":g.push(W4);break;case"none":break;default:g.push(d);break}return o===!1&&g.push(V.editable.of(!1)),l&&g.push(xe.readOnly.of(!0)),[...g]},q4=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Y4{constructor(e,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(n=>{try{n()}catch(r){console.error("TimeoutLatch callback error:",r)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class mg{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var mu=null,X4=()=>typeof window>"u"?new mg:(mu||(mu=new mg),mu),pg=Jn.define(),J4=200,Z4=[];function Q4(t){var e=t.value,n=t.selection,r=t.onChange,i=t.onStatistics,s=t.onCreateEditor,o=t.onUpdate,a=t.extensions,l=a===void 0?Z4:a,c=t.autoFocus,d=t.theme,h=d===void 0?"light":d,f=t.height,m=f===void 0?null:f,p=t.minHeight,g=p===void 0?null:p,b=t.maxHeight,x=b===void 0?null:b,y=t.width,w=y===void 0?null:y,k=t.minWidth,C=k===void 0?null:k,S=t.maxWidth,A=S===void 0?null:S,M=t.placeholder,E=M===void 0?"":M,j=t.editable,T=j===void 0?!0:j,N=t.readOnly,D=N===void 0?!1:N,O=t.indentWithTab,L=O===void 0?!0:O,$=t.basicSetup,U=$===void 0?!0:$,q=t.root,_=t.initialState,te=v.useState(),ce=te[0],G=te[1],oe=v.useState(),B=oe[0],Y=oe[1],ee=v.useState(),ae=ee[0],ue=ee[1],ve=v.useState(()=>({current:null}))[0],X=v.useState(()=>({current:null}))[0],se=V.theme({"&":{height:m,minHeight:g,maxHeight:x,width:w,minWidth:C,maxWidth:A},"& .cm-scroller":{height:"100% !important"}}),ie=V.updateListener.of(he=>{if(he.docChanged&&typeof r=="function"&&!he.transactions.some(Mt=>Mt.annotation(pg))){ve.current?ve.current.reset():(ve.current=new Y4(()=>{if(X.current){var Mt=X.current;X.current=null,Mt()}ve.current=null},J4),X4().add(ve.current));var _e=he.state.doc,At=_e.toString();r(At,he)}i&&i(q4(he))}),Ne=G4({theme:h,editable:T,readOnly:D,placeholder:E,indentWithTab:L,basicSetup:U}),de=[ie,se,...Ne];return o&&typeof o=="function"&&de.push(V.updateListener.of(o)),de=de.concat(l),v.useLayoutEffect(()=>{if(ce&&!ae){var he={doc:e,selection:n,extensions:de},_e=_?xe.fromJSON(_.json,he,_.fields):xe.create(he);if(ue(_e),!B){var At=new V({state:_e,parent:ce,root:q});Y(At),s&&s(At,_e)}}return()=>{B&&(ue(void 0),Y(void 0))}},[ce,ae]),v.useEffect(()=>{t.container&&G(t.container)},[t.container]),v.useEffect(()=>()=>{B&&(B.destroy(),Y(void 0)),ve.current&&(ve.current.cancel(),ve.current=null)},[B]),v.useEffect(()=>{c&&B&&B.focus()},[c,B]),v.useEffect(()=>{B&&B.dispatch({effects:le.reconfigure.of(de)})},[h,l,m,g,x,w,C,A,E,T,D,L,U,r,o]),v.useEffect(()=>{if(e!==void 0){var he=B?B.state.doc.toString():"";if(B&&e!==he){var _e=ve.current&&!ve.current.isDone,At=()=>{B&&e!==B.state.doc.toString()&&B.dispatch({changes:{from:0,to:B.state.doc.toString().length,insert:e||""},annotations:[pg.of(!0)]})};_e?X.current=At:At()}}},[e,B]),{state:ae,setState:ue,view:B,setView:Y,container:ce,setContainer:G}}var eI=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],tI=v.forwardRef((t,e)=>{var n=t.className,r=t.value,i=r===void 0?"":r,s=t.selection,o=t.extensions,a=o===void 0?[]:o,l=t.onChange,c=t.onStatistics,d=t.onCreateEditor,h=t.onUpdate,f=t.autoFocus,m=t.theme,p=m===void 0?"light":m,g=t.height,b=t.minHeight,x=t.maxHeight,y=t.width,w=t.minWidth,k=t.maxWidth,C=t.basicSetup,S=t.placeholder,A=t.indentWithTab,M=t.editable,E=t.readOnly,j=t.root,T=t.initialState,N=g0(t,eI),D=v.useRef(null),O=Q4({root:j,value:i,autoFocus:f,theme:p,height:g,minHeight:b,maxHeight:x,width:y,minWidth:w,maxWidth:k,basicSetup:C,placeholder:S,indentWithTab:A,editable:M,readOnly:E,selection:s,onChange:l,onStatistics:c,onCreateEditor:d,onUpdate:h,extensions:a,initialState:T}),L=O.state,$=O.view,U=O.container,q=O.setContainer;v.useImperativeHandle(e,()=>({editor:D.current,state:L,view:$}),[D,U,L,$]);var _=v.useCallback(ce=>{D.current=ce,q(ce)},[q]);if(typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var te=typeof p=="string"?"cm-theme-"+p:"cm-theme";return u.jsx("div",re({ref:_,className:""+te+(n?" "+n:"")},N))});tI.displayName="CodeMirror";const Bd={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]};for(const t in Bd)Object.freeze(Bd[t]);const Xn=Object.freeze(Bd),N1=Object.create(null);for(const t in Xn)Object.hasOwn(Xn,t)&&(N1[Xn[t]]=t);const lt={to:{},get:{}};lt.get=function(t){const e=t.slice(0,3).toLowerCase();let n,r;switch(e){case"hsl":{n=lt.get.hsl(t),r="hsl";break}case"hwb":{n=lt.get.hwb(t),r="hwb";break}default:{n=lt.get.rgb(t),r="rgb";break}}return n?{model:r,value:n}:null};lt.get.rgb=function(t){if(!t)return null;const e=/^#([a-f\d]{3,4})$/i,n=/^#([a-f\d]{6})([a-f\d]{2})?$/i,r=/^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i,i=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i,s=/^(\w+)$/;let o=[0,0,0,1],a,l,c;if(a=t.match(n)){for(c=a[2],a=a[1],l=0;l<3;l++){const d=l*2;o[l]=Number.parseInt(a.slice(d,d+2),16)}c&&(o[3]=Number.parseInt(c,16)/255)}else if(a=t.match(e)){for(a=a[1],c=a[3],l=0;l<3;l++)o[l]=Number.parseInt(a[l]+a[l],16);c&&(o[3]=Number.parseInt(c+c,16)/255)}else if(a=t.match(r)){for(l=0;l<3;l++)o[l]=Number.parseFloat(a[l+1]);a[4]&&(o[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else if(a=t.match(i)){for(l=0;l<3;l++)o[l]=Math.round(Number.parseFloat(a[l+1])*2.55);a[4]&&(o[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else return(a=t.toLowerCase().match(s))?a[1]==="transparent"?[0,0,0,0]:Object.hasOwn(Xn,a[1])?(o=Xn[a[1]].slice(),o[3]=1,o):null:null;for(l=0;l<3;l++)o[l]=jr(o[l],0,255);return o[3]=jr(o[3],0,1),o};lt.get.hsl=function(t){if(!t)return null;const e=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i,n=t.match(e);if(n){const r=Number.parseFloat(n[4]),i=(Number.parseFloat(n[1])%360+360)%360,s=jr(Number.parseFloat(n[2]),0,100),o=jr(Number.parseFloat(n[3]),0,100),a=jr(Number.isNaN(r)?1:r,0,1);return[i,s,o,a]}return null};lt.get.hwb=function(t){if(!t)return null;const e=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i,n=t.match(e);if(n){const r=Number.parseFloat(n[4]),i=(Number.parseFloat(n[1])%360+360)%360,s=jr(Number.parseFloat(n[2]),0,100),o=jr(Number.parseFloat(n[3]),0,100),a=jr(Number.isNaN(r)?1:r,0,1);return[i,s,o,a]}return null};lt.to.hex=function(...t){return"#"+Ta(t[0])+Ta(t[1])+Ta(t[2])+(t[3]<1?Ta(Math.round(t[3]*255)):"")};lt.to.rgb=function(...t){return t.length<4||t[3]===1?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"};lt.to.rgb.percent=function(...t){const e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||t[3]===1?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"};lt.to.hsl=function(...t){return t.length<4||t[3]===1?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"};lt.to.hwb=function(...t){let e="";return t.length>=4&&t[3]!==1&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"};lt.to.keyword=function(...t){return N1[t.slice(0,3)]};function jr(t,e,n){return Math.min(Math.max(e,t),n)}function Ta(t){const e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}const T1={};for(const t of Object.keys(Xn))T1[Xn[t]]=t;const z={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"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},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"]}},lr=(6/29)**3;function Bi(t){const e=t>.0031308?1.055*t**.4166666666666667-.055:t*12.92;return Math.min(Math.max(0,e),1)}function Vi(t){return t>.04045?((t+.055)/1.055)**2.4:t/12.92}for(const t of Object.keys(z)){if(!("channels"in z[t]))throw new Error("missing channels property: "+t);if(!("labels"in z[t]))throw new Error("missing channel labels property: "+t);if(z[t].labels.length!==z[t].channels)throw new Error("channel and label counts mismatch: "+t);const{channels:e,labels:n}=z[t];delete z[t].channels,delete z[t].labels,Object.defineProperty(z[t],"channels",{value:e}),Object.defineProperty(z[t],"labels",{value:n})}z.rgb.hsl=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.min(e,n,r),s=Math.max(e,n,r),o=s-i;let a,l;switch(s){case i:{a=0;break}case e:{a=(n-r)/o;break}case n:{a=2+(r-e)/o;break}case r:{a=4+(e-n)/o;break}}a=Math.min(a*60,360),a<0&&(a+=360);const c=(i+s)/2;return s===i?l=0:c<=.5?l=o/(s+i):l=o/(2-s-i),[a,l*100,c*100]};z.rgb.hsv=function(t){let e,n,r,i,s;const o=t[0]/255,a=t[1]/255,l=t[2]/255,c=Math.max(o,a,l),d=c-Math.min(o,a,l),h=function(f){return(c-f)/6/d+1/2};if(d===0)i=0,s=0;else{switch(s=d/c,e=h(o),n=h(a),r=h(l),c){case o:{i=r-n;break}case a:{i=1/3+e-r;break}case l:{i=2/3+n-e;break}}i<0?i+=1:i>1&&(i-=1)}return[i*360,s*100,c*100]};z.rgb.hwb=function(t){const e=t[0],n=t[1];let r=t[2];const i=z.rgb.hsl(t)[0],s=1/255*Math.min(e,Math.min(n,r));return r=1-1/255*Math.max(e,Math.max(n,r)),[i,s*100,r*100]};z.rgb.oklab=function(t){const e=Vi(t[0]/255),n=Vi(t[1]/255),r=Vi(t[2]/255),i=Math.cbrt(.4122214708*e+.5363325363*n+.0514459929*r),s=Math.cbrt(.2119034982*e+.6806995451*n+.1073969566*r),o=Math.cbrt(.0883024619*e+.2817188376*n+.6299787005*r),a=.2104542553*i+.793617785*s-.0040720468*o,l=1.9779984951*i-2.428592205*s+.4505937099*o,c=.0259040371*i+.7827717662*s-.808675766*o;return[a*100,l*100,c*100]};z.rgb.cmyk=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.min(1-e,1-n,1-r),s=(1-e-i)/(1-i)||0,o=(1-n-i)/(1-i)||0,a=(1-r-i)/(1-i)||0;return[s*100,o*100,a*100,i*100]};function nI(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2}z.rgb.keyword=function(t){const e=T1[t];if(e)return e;let n=Number.POSITIVE_INFINITY,r;for(const i of Object.keys(Xn)){const s=Xn[i],o=nI(t,s);o<n&&(n=o,r=i)}return r};z.keyword.rgb=function(t){return[...Xn[t]]};z.rgb.xyz=function(t){const e=Vi(t[0]/255),n=Vi(t[1]/255),r=Vi(t[2]/255),i=e*.4124564+n*.3575761+r*.1804375,s=e*.2126729+n*.7151522+r*.072175,o=e*.0193339+n*.119192+r*.9503041;return[i*100,s*100,o*100]};z.rgb.lab=function(t){const e=z.rgb.xyz(t);let n=e[0],r=e[1],i=e[2];n/=95.047,r/=100,i/=108.883,n=n>lr?n**(1/3):7.787*n+16/116,r=r>lr?r**(1/3):7.787*r+16/116,i=i>lr?i**(1/3):7.787*i+16/116;const s=116*r-16,o=500*(n-r),a=200*(r-i);return[s,o,a]};z.hsl.rgb=function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100;let i,s;if(n===0)return s=r*255,[s,s,s];const o=r<.5?r*(1+n):r+n-r*n,a=2*r-o,l=[0,0,0];for(let c=0;c<3;c++)i=e+1/3*-(c-1),i<0&&i++,i>1&&i--,6*i<1?s=a+(o-a)*6*i:2*i<1?s=o:3*i<2?s=a+(o-a)*(2/3-i)*6:s=a,l[c]=s*255;return l};z.hsl.hsv=function(t){const e=t[0];let n=t[1]/100,r=t[2]/100,i=n;const s=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,i*=s<=1?s:2-s;const o=(r+n)/2,a=r===0?2*i/(s+i):2*n/(r+n);return[e,a*100,o*100]};z.hsv.rgb=function(t){const e=t[0]/60,n=t[1]/100;let r=t[2]/100;const i=Math.floor(e)%6,s=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*s),l=255*r*(1-n*(1-s));switch(r*=255,i){case 0:return[r,l,o];case 1:return[a,r,o];case 2:return[o,r,l];case 3:return[o,a,r];case 4:return[l,o,r];case 5:return[r,o,a]}};z.hsv.hsl=function(t){const e=t[0],n=t[1]/100,r=t[2]/100,i=Math.max(r,.01);let s,o;o=(2-n)*r;const a=(2-n)*i;return s=n*i,s/=a<=1?a:2-a,s=s||0,o/=2,[e,s*100,o*100]};z.hwb.rgb=function(t){const e=t[0]/360;let n=t[1]/100,r=t[2]/100;const i=n+r;let s;i>1&&(n/=i,r/=i);const o=Math.floor(6*e),a=1-r;s=6*e-o,(o&1)!==0&&(s=1-s);const l=n+s*(a-n);let c,d,h;switch(o){default:case 6:case 0:{c=a,d=l,h=n;break}case 1:{c=l,d=a,h=n;break}case 2:{c=n,d=a,h=l;break}case 3:{c=n,d=l,h=a;break}case 4:{c=l,d=n,h=a;break}case 5:{c=a,d=n,h=l;break}}return[c*255,d*255,h*255]};z.cmyk.rgb=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100,s=1-Math.min(1,e*(1-i)+i),o=1-Math.min(1,n*(1-i)+i),a=1-Math.min(1,r*(1-i)+i);return[s*255,o*255,a*255]};z.xyz.rgb=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100;let i,s,o;return i=e*3.2404542+n*-1.5371385+r*-.4985314,s=e*-.969266+n*1.8760108+r*.041556,o=e*.0556434+n*-.2040259+r*1.0572252,i=Bi(i),s=Bi(s),o=Bi(o),[i*255,s*255,o*255]};z.xyz.lab=function(t){let e=t[0],n=t[1],r=t[2];e/=95.047,n/=100,r/=108.883,e=e>lr?e**(1/3):7.787*e+16/116,n=n>lr?n**(1/3):7.787*n+16/116,r=r>lr?r**(1/3):7.787*r+16/116;const i=116*n-16,s=500*(e-n),o=200*(n-r);return[i,s,o]};z.xyz.oklab=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100,i=Math.cbrt(.8189330101*e+.3618667424*n-.1288597137*r),s=Math.cbrt(.0329845436*e+.9293118715*n+.0361456387*r),o=Math.cbrt(.0482003018*e+.2643662691*n+.633851707*r),a=.2104542553*i+.793617785*s-.0040720468*o,l=1.9779984951*i-2.428592205*s+.4505937099*o,c=.0259040371*i+.7827717662*s-.808675766*o;return[a*100,l*100,c*100]};z.oklab.oklch=function(t){return z.lab.lch(t)};z.oklab.xyz=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100,i=(.999999998*e+.396337792*n+.215803758*r)**3,s=(1.000000008*e-.105561342*n-.063854175*r)**3,o=(1.000000055*e-.089484182*n-1.291485538*r)**3,a=1.227013851*i-.55779998*s+.281256149*o,l=-.040580178*i+1.11225687*s-.071676679*o,c=-.076381285*i-.421481978*s+1.58616322*o;return[a*100,l*100,c*100]};z.oklab.rgb=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100,i=(e+.3963377774*n+.2158037573*r)**3,s=(e-.1055613458*n-.0638541728*r)**3,o=(e-.0894841775*n-1.291485548*r)**3,a=Bi(4.0767416621*i-3.3077115913*s+.2309699292*o),l=Bi(-1.2684380046*i+2.6097574011*s-.3413193965*o),c=Bi(-.0041960863*i-.7034186147*s+1.707614701*o);return[a*255,l*255,c*255]};z.oklch.oklab=function(t){return z.lch.lab(t)};z.lab.xyz=function(t){const e=t[0],n=t[1],r=t[2];let i,s,o;s=(e+16)/116,i=n/500+s,o=s-r/200;const a=s**3,l=i**3,c=o**3;return s=a>lr?a:(s-16/116)/7.787,i=l>lr?l:(i-16/116)/7.787,o=c>lr?c:(o-16/116)/7.787,i*=95.047,s*=100,o*=108.883,[i,s,o]};z.lab.lch=function(t){const e=t[0],n=t[1],r=t[2];let i;i=Math.atan2(r,n)*360/2/Math.PI,i<0&&(i+=360);const o=Math.sqrt(n*n+r*r);return[e,o,i]};z.lch.lab=function(t){const e=t[0],n=t[1],i=t[2]/360*2*Math.PI,s=n*Math.cos(i),o=n*Math.sin(i);return[e,s,o]};z.rgb.ansi16=function(t,e=null){const[n,r,i]=t;let s=e===null?z.rgb.hsv(t)[2]:e;if(s=Math.round(s/50),s===0)return 30;let o=30+(Math.round(i/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return s===2&&(o+=60),o};z.hsv.ansi16=function(t){return z.rgb.ansi16(z.hsv.rgb(t),t[2])};z.rgb.ansi256=function(t){const e=t[0],n=t[1],r=t[2];return e>>4===n>>4&&n>>4===r>>4?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)};z.ansi16.rgb=function(t){t=t[0];let e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];const n=(Math.trunc(t>50)+1)*.5,r=(e&1)*n*255,i=(e>>1&1)*n*255,s=(e>>2&1)*n*255;return[r,i,s]};z.ansi256.rgb=function(t){if(t=t[0],t>=232){const s=(t-232)*10+8;return[s,s,s]}t-=16;let e;const n=Math.floor(t/36)/5*255,r=Math.floor((e=t%36)/6)/5*255,i=e%6/5*255;return[n,r,i]};z.rgb.hex=function(t){const n=(((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255)).toString(16).toUpperCase();return"000000".slice(n.length)+n};z.hex.rgb=function(t){const e=t.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!e)return[0,0,0];let n=e[0];e[0].length===3&&(n=[...n].map(a=>a+a).join(""));const r=Number.parseInt(n,16),i=r>>16&255,s=r>>8&255,o=r&255;return[i,s,o]};z.rgb.hcg=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.max(Math.max(e,n),r),s=Math.min(Math.min(e,n),r),o=i-s;let a;const l=o<1?s/(1-o):0;return o<=0?a=0:i===e?a=(n-r)/o%6:i===n?a=2+(r-e)/o:a=4+(e-n)/o,a/=6,a%=1,[a*360,o*100,l*100]};z.hsl.hcg=function(t){const e=t[1]/100,n=t[2]/100,r=n<.5?2*e*n:2*e*(1-n);let i=0;return r<1&&(i=(n-.5*r)/(1-r)),[t[0],r*100,i*100]};z.hsv.hcg=function(t){const e=t[1]/100,n=t[2]/100,r=e*n;let i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],r*100,i*100]};z.hcg.rgb=function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100;if(n===0)return[r*255,r*255,r*255];const i=[0,0,0],s=e%1*6,o=s%1,a=1-o;let l=0;switch(Math.floor(s)){case 0:{i[0]=1,i[1]=o,i[2]=0;break}case 1:{i[0]=a,i[1]=1,i[2]=0;break}case 2:{i[0]=0,i[1]=1,i[2]=o;break}case 3:{i[0]=0,i[1]=a,i[2]=1;break}case 4:{i[0]=o,i[1]=0,i[2]=1;break}default:i[0]=1,i[1]=0,i[2]=a}return l=(1-n)*r,[(n*i[0]+l)*255,(n*i[1]+l)*255,(n*i[2]+l)*255]};z.hcg.hsv=function(t){const e=t[1]/100,n=t[2]/100,r=e+n*(1-e);let i=0;return r>0&&(i=e/r),[t[0],i*100,r*100]};z.hcg.hsl=function(t){const e=t[1]/100,r=t[2]/100*(1-e)+.5*e;let i=0;return r>0&&r<.5?i=e/(2*r):r>=.5&&r<1&&(i=e/(2*(1-r))),[t[0],i*100,r*100]};z.hcg.hwb=function(t){const e=t[1]/100,n=t[2]/100,r=e+n*(1-e);return[t[0],(r-e)*100,(1-r)*100]};z.hwb.hcg=function(t){const e=t[1]/100,r=1-t[2]/100,i=r-e;let s=0;return i<1&&(s=(r-i)/(1-i)),[t[0],i*100,s*100]};z.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};z.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};z.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};z.gray.hsl=function(t){return[0,0,t[0]]};z.gray.hsv=z.gray.hsl;z.gray.hwb=function(t){return[0,100,t[0]]};z.gray.cmyk=function(t){return[0,0,0,t[0]]};z.gray.lab=function(t){return[t[0],0,0]};z.gray.hex=function(t){const e=Math.round(t[0]/100*255)&255,r=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".slice(r.length)+r};z.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};function rI(){const t={},e=Object.keys(z);for(let{length:n}=e,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}function iI(t){const e=rI(),n=[t];for(e[t].distance=0;n.length>0;){const r=n.pop(),i=Object.keys(z[r]);for(let{length:s}=i,o=0;o<s;o++){const a=i[o],l=e[a];l.distance===-1&&(l.distance=e[r].distance+1,l.parent=r,n.unshift(a))}}return e}function sI(t,e){return function(n){return e(t(n))}}function oI(t,e){const n=[e[t].parent,t];let r=z[e[t].parent][t],i=e[t].parent;for(;e[i].parent;)n.unshift(e[i].parent),r=sI(z[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}function aI(t){const e=iI(t),n={},r=Object.keys(e);for(let{length:i}=r,s=0;s<i;s++){const o=r[s];e[o].parent!==null&&(n[o]=oI(o,e))}return n}const ht={},lI=Object.keys(z);function cI(t){const e=function(...n){const r=n[0];return r==null?r:(r.length>1&&(n=r),t(n))};return"conversion"in t&&(e.conversion=t.conversion),e}function uI(t){const e=function(...n){const r=n[0];if(r==null)return r;r.length>1&&(n=r);const i=t(n);if(typeof i=="object")for(let{length:s}=i,o=0;o<s;o++)i[o]=Math.round(i[o]);return i};return"conversion"in t&&(e.conversion=t.conversion),e}for(const t of lI){ht[t]={},Object.defineProperty(ht[t],"channels",{value:z[t].channels}),Object.defineProperty(ht[t],"labels",{value:z[t].labels});const e=aI(t),n=Object.keys(e);for(const r of n){const i=e[r];ht[t][r]=uI(i),ht[t][r].raw=cI(i)}}const D1=["keyword","gray","hex"],Vd={};for(const t of Object.keys(ht))Vd[[...ht[t].labels].sort().join("")]=t;const zd={};function Fe(t,e){if(!(this instanceof Fe))return new Fe(t,e);if(e&&e in D1&&(e=null),e&&!(e in ht))throw new Error("Unknown model: "+e);let n,r;if(t==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof Fe)this.model=t.model,this.color=[...t.color],this.valpha=t.valpha;else if(typeof t=="string"){const i=lt.get(t);if(i===null)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=ht[this.model].channels,this.color=i.value.slice(0,r),this.valpha=typeof i.value[r]=="number"?i.value[r]:1}else if(t.length>0){this.model=e||"rgb",r=ht[this.model].channels;const i=Array.prototype.slice.call(t,0,r);this.color=$d(i,r),this.valpha=typeof t[r]=="number"?t[r]:1}else if(typeof t=="number")this.model="rgb",this.color=[t>>16&255,t>>8&255,t&255],this.valpha=1;else{this.valpha=1;const i=Object.keys(t);"alpha"in t&&(i.splice(i.indexOf("alpha"),1),this.valpha=typeof t.alpha=="number"?t.alpha:0);const s=i.sort().join("");if(!(s in Vd))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=Vd[s];const{labels:o}=ht[this.model],a=[];for(n=0;n<o.length;n++)a.push(t[o[n]]);this.color=$d(a)}if(zd[this.model])for(r=ht[this.model].channels,n=0;n<r;n++){const i=zd[this.model][n];i&&(this.color[n]=i(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}Fe.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(t){let e=this.model in lt.to?this:this.rgb();e=e.round(typeof t=="number"?t:1);const n=e.valpha===1?e.color:[...e.color,this.valpha];return lt.to[e.model](...n)},percentString(t){const e=this.rgb().round(typeof t=="number"?t:1),n=e.valpha===1?e.color:[...e.color,this.valpha];return lt.to.rgb.percent(...n)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const t={},{channels:e}=ht[this.model],{labels:n}=ht[this.model];for(let r=0;r<e;r++)t[n[r]]=this.color[r];return this.valpha!==1&&(t.alpha=this.valpha),t},unitArray(){const t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,this.valpha!==1&&t.push(this.valpha),t},unitObject(){const t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,this.valpha!==1&&(t.alpha=this.valpha),t},round(t){return t=Math.max(t||0,0),new Fe([...this.color.map(hI(t)),this.valpha],this.model)},alpha(t){return t!==void 0?new Fe([...this.color,Math.max(0,Math.min(1,t))],this.model):this.valpha},red:ze("rgb",0,nt(255)),green:ze("rgb",1,nt(255)),blue:ze("rgb",2,nt(255)),hue:ze(["hsl","hsv","hsl","hwb","hcg"],0,t=>(t%360+360)%360),saturationl:ze("hsl",1,nt(100)),lightness:ze("hsl",2,nt(100)),saturationv:ze("hsv",1,nt(100)),value:ze("hsv",2,nt(100)),chroma:ze("hcg",1,nt(100)),gray:ze("hcg",2,nt(100)),white:ze("hwb",1,nt(100)),wblack:ze("hwb",2,nt(100)),cyan:ze("cmyk",0,nt(100)),magenta:ze("cmyk",1,nt(100)),yellow:ze("cmyk",2,nt(100)),black:ze("cmyk",3,nt(100)),x:ze("xyz",0,nt(95.047)),y:ze("xyz",1,nt(100)),z:ze("xyz",2,nt(108.833)),l:ze("lab",0,nt(100)),a:ze("lab",1),b:ze("lab",2),keyword(t){return t!==void 0?new Fe(t):ht[this.model].keyword(this.color)},hex(t){return t!==void 0?new Fe(t):lt.to.hex(...this.rgb().round().color)},hexa(t){if(t!==void 0)return new Fe(t);const e=this.rgb().round().color;let n=Math.round(this.valpha*255).toString(16).toUpperCase();return n.length===1&&(n="0"+n),lt.to.hex(...e)+n},rgbNumber(){const t=this.rgb().color;return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255},luminosity(){const t=this.rgb().color,e=[];for(const[n,r]of t.entries()){const i=r/255;e[n]=i<=.04045?i/12.92:((i+.055)/1.055)**2.4}return .2126*e[0]+.7152*e[1]+.0722*e[2]},contrast(t){const e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level(t){const e=this.contrast(t);return e>=7?"AAA":e>=4.5?"AA":""},isDark(){const t=this.rgb().color;return(t[0]*2126+t[1]*7152+t[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const t=this.rgb();for(let e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten(t){const e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken(t){const e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate(t){const e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate(t){const e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten(t){const e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken(t){const e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale(){const t=this.rgb().color,e=t[0]*.3+t[1]*.59+t[2]*.11;return Fe.rgb(e,e,e)},fade(t){return this.alpha(this.valpha-this.valpha*t)},opaquer(t){return this.alpha(this.valpha+this.valpha*t)},rotate(t){const e=this.hsl();let n=e.color[0];return n=(n+t)%360,n=n<0?360+n:n,e.color[0]=n,e},mix(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);const n=t.rgb(),r=this.rgb(),i=e===void 0?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o===-1?s:(s+o)/(1+s*o))+1)/2,l=1-a;return Fe.rgb(a*n.red()+l*r.red(),a*n.green()+l*r.green(),a*n.blue()+l*r.blue(),n.alpha()*i+r.alpha()*(1-i))}};for(const t of Object.keys(ht)){if(D1.includes(t))continue;const{channels:e}=ht[t];Fe.prototype[t]=function(...n){return this.model===t?new Fe(this):n.length>0?new Fe(n,t):new Fe([...fI(ht[this.model][t].raw(this.color)),this.valpha],t)},Fe[t]=function(...n){let r=n[0];return typeof r=="number"&&(r=$d(n,e)),new Fe(r,t)}}function dI(t,e){return Number(t.toFixed(e))}function hI(t){return function(e){return dI(e,t)}}function ze(t,e,n){t=Array.isArray(t)?t:[t];for(const r of t)(zd[r]||=[])[e]=n;return t=t[0],function(r){let i;return r!==void 0?(n&&(r=n(r)),i=this[t](),i.color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function nt(t){return function(e){return Math.max(0,Math.min(t,e))}}function fI(t){return Array.isArray(t)?t:[t]}function $d(t,e){for(let n=0;n<e;n++)typeof t[n]!="number"&&(t[n]=0);return t}var O1=["PageUp","PageDown"],I1=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],P1={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},hs="Slider",[Hd,mI,pI]=dw(hs),[uf]=pw(hs,[pI]),[gI,Go]=uf(hs),R1=v.forwardRef((t,e)=>{const{name:n,min:r=0,max:i=100,step:s=1,orientation:o="horizontal",disabled:a=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[r],value:d,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:m=!1,form:p,...g}=t,b=v.useRef(new Set),x=v.useRef(0),y=v.useRef(!1),k=o==="horizontal"?bI:vI,[C=[],S]=uw({prop:d,defaultProp:c,onChange:N=>{[...b.current][x.current]?.focus({preventScroll:!0,focusVisible:y.current}),y.current=!1,h(N)}}),A=v.useRef(C);function M(N){const D=kI(C,N);T(N,D)}function E(N){T(N,x.current)}function j(){const N=A.current[x.current];C[x.current]!==N&&f(C)}function T(N,D,{commit:O}={commit:!1}){const L=MI(s),$=EI(Math.round((N-r)/s)*s+r,L),U=t0($,[r,i]);S((q=[])=>{const _=yI(q,U,D);if(AI(_,l*s)){x.current=_.indexOf(U);const te=String(_)!==String(q);return te&&O&&f(_),te?_:q}else return q})}return u.jsx(gI,{scope:t.__scopeSlider,name:n,disabled:a,min:r,max:i,valueIndexToChangeRef:x,thumbs:b.current,values:C,orientation:o,form:p,children:u.jsx(Hd.Provider,{scope:t.__scopeSlider,children:u.jsx(Hd.Slot,{scope:t.__scopeSlider,children:u.jsx(k,{"aria-disabled":a,"data-disabled":a?"":void 0,...g,ref:e,onPointerDown:wi(g.onPointerDown,()=>{a||(A.current=C,y.current=!1)}),min:r,max:i,inverted:m,onSlideStart:a?void 0:M,onSlideMove:a?void 0:E,onSlideEnd:a?void 0:j,onHomeKeyDown:()=>{a||(y.current=!0,T(r,0,{commit:!0}))},onEndKeyDown:()=>{a||(y.current=!0,T(i,C.length-1,{commit:!0}))},onStepKeyDown:({event:N,direction:D})=>{if(!a){y.current=!0;const $=O1.includes(N.key)||N.shiftKey&&I1.includes(N.key)?10:1,U=x.current,q=C[U],_=s*$*D;T(q+_,U,{commit:!0})}}})})})})});R1.displayName=hs;var[L1,_1]=uf(hs,{startEdge:"left",endEdge:"right",size:"width",direction:1}),bI=v.forwardRef((t,e)=>{const{min:n,max:r,dir:i,inverted:s,onSlideStart:o,onSlideMove:a,onSlideEnd:l,onStepKeyDown:c,...d}=t,[h,f]=v.useState(null),m=Mo(e,w=>f(w)),p=v.useRef(void 0),g=hw(i),b=g==="ltr",x=b&&!s||!b&&s;function y(w){const k=p.current||h.getBoundingClientRect(),C=[0,k.width],A=df(C,x?[n,r]:[r,n]);return p.current=k,A(w-k.left)}return u.jsx(L1,{scope:t.__scopeSlider,startEdge:x?"left":"right",endEdge:x?"right":"left",direction:x?1:-1,size:"width",children:u.jsx(F1,{dir:g,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const k=y(w.clientX);o?.(k)},onSlideMove:w=>{const k=y(w.clientX);a?.(k)},onSlideEnd:()=>{p.current=void 0,l?.()},onStepKeyDown:w=>{const C=P1[x?"from-left":"from-right"].includes(w.key);c?.({event:w,direction:C?-1:1})}})})}),vI=v.forwardRef((t,e)=>{const{min:n,max:r,inverted:i,onSlideStart:s,onSlideMove:o,onSlideEnd:a,onStepKeyDown:l,...c}=t,d=v.useRef(null),h=Mo(e,d),f=v.useRef(void 0),m=!i;function p(g){const b=f.current||d.current.getBoundingClientRect(),x=[0,b.height],w=df(x,m?[r,n]:[n,r]);return f.current=b,w(g-b.top)}return u.jsx(L1,{scope:t.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:u.jsx(F1,{"data-orientation":"vertical",...c,ref:h,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:g=>{const b=p(g.clientY);s?.(b)},onSlideMove:g=>{const b=p(g.clientY);o?.(b)},onSlideEnd:()=>{f.current=void 0,a?.()},onStepKeyDown:g=>{const x=P1[m?"from-bottom":"from-top"].includes(g.key);l?.({event:g,direction:x?-1:1})}})})}),F1=v.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:s,onHomeKeyDown:o,onEndKeyDown:a,onStepKeyDown:l,...c}=t,d=Go(hs,n);return u.jsx(Ao.span,{...c,ref:e,onKeyDown:wi(t.onKeyDown,h=>{h.key==="Home"?(o(h),h.preventDefault()):h.key==="End"?(a(h),h.preventDefault()):O1.concat(I1).includes(h.key)&&(l(h),h.preventDefault())}),onPointerDown:wi(t.onPointerDown,h=>{const f=h.target;f.setPointerCapture(h.pointerId),h.preventDefault(),d.thumbs.has(f)?f.focus({preventScroll:!0,focusVisible:!1}):r(h)}),onPointerMove:wi(t.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&i(h)}),onPointerUp:wi(t.onPointerUp,h=>{const f=h.target;f.hasPointerCapture(h.pointerId)&&(f.releasePointerCapture(h.pointerId),s(h))})})}),B1="SliderTrack",V1=v.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=Go(B1,n);return u.jsx(Ao.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:e})});V1.displayName=B1;var Ud="SliderRange",z1=v.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=Go(Ud,n),s=_1(Ud,n),o=v.useRef(null),a=Mo(e,o),l=i.values.length,c=i.values.map(f=>X1(f,i.min,i.max)),d=l>1?Math.min(...c):0,h=100-Math.max(...c);return u.jsx(Ao.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:a,style:{...t.style,[s.startEdge]:d+"%",[s.endEdge]:h+"%"}})});z1.displayName=Ud;var $1="SliderThumb",[xI,H1]=uf($1),U1="SliderThumbProvider";function W1(t){const{__scopeSlider:e,name:n,children:r,internal_do_not_use_render:i}=t,s=Go(U1,e),o=mI(e),[a,l]=v.useState(null),c=v.useMemo(()=>a?o().findIndex(b=>b.ref.current===a):-1,[o,a]),d=fw(a),h=a?!!s.form||!!a.closest("form"):!0,f=s.values[c],m=n??(s.name?s.name+(s.values.length>1?"[]":""):void 0),p=f===void 0?0:X1(f,s.min,s.max);v.useEffect(()=>{if(a)return s.thumbs.add(a),()=>{s.thumbs.delete(a)}},[a,s.thumbs]);const g={value:f,name:m,form:s.form,isFormControl:h,index:c,thumb:a,onThumbChange:l,percent:p,size:d};return u.jsx(xI,{scope:e,...g,children:jI(i)?i(g):r})}W1.displayName=U1;var Wa="SliderThumbTrigger",K1=v.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=Go(Wa,n),s=_1(Wa,n),{index:o,value:a,percent:l,size:c,onThumbChange:d}=H1(Wa,n),h=Mo(e,g=>d(g)),f=wI(o,i.values.length),m=c?.[s.size],p=m?SI(m,l,s.direction):0;return u.jsx("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${l}% + ${p}px)`},children:u.jsx(Hd.ItemSlot,{scope:n,children:u.jsx(Ao.span,{role:"slider","aria-label":t["aria-label"]||f,"aria-valuemin":i.min,"aria-valuenow":a,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...r,ref:h,style:a===void 0?{display:"none"}:t.style,onFocus:wi(t.onFocus,()=>{i.valueIndexToChangeRef.current=o})})})})});K1.displayName=Wa;var G1=v.forwardRef((t,e)=>{const{__scopeSlider:n,name:r,...i}=t;return u.jsx(W1,{__scopeSlider:n,name:r,internal_do_not_use_render:({index:s,isFormControl:o})=>u.jsxs(u.Fragment,{children:[u.jsx(K1,{...i,ref:e,__scopeSlider:n}),o?u.jsx(Y1,{__scopeSlider:n},s):null]})})});G1.displayName=$1;var q1="SliderBubbleInput",Y1=v.forwardRef(({__scopeSlider:t,...e},n)=>{const{value:r,name:i,form:s}=H1(q1,t),o=v.useRef(null),a=Mo(o,n),l=mw(r);return v.useEffect(()=>{const c=o.current;if(!c)return;const d=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==r&&f){const m=new Event("input",{bubbles:!0});f.call(c,r),c.dispatchEvent(m)}},[l,r]),u.jsx(Ao.input,{style:{display:"none"},name:i,form:s,...e,ref:a,defaultValue:r})});Y1.displayName=q1;function yI(t=[],e,n){const r=[...t];return r[n]=e,r.sort((i,s)=>i-s)}function X1(t,e,n){const s=100/(n-e)*(t-e);return t0(s,[0,100])}function wI(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function kI(t,e){if(t.length===1)return 0;const n=t.map(i=>Math.abs(i-e)),r=Math.min(...n);return n.indexOf(r)}function SI(t,e,n){const r=t/2,s=df([0,50],[0,r]);return(r-s(e)*n)*n}function CI(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function AI(t,e){if(e>0){const n=CI(t);return Math.min(...n)>=e}return!0}function df(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function MI(t){if(!Number.isFinite(t))return 0;const e=t.toString();if(e.includes("e")){const[r,i]=e.split("e"),s=r.split(".")[1]||"",o=Number(i);return Math.max(0,s.length-o)}const n=e.split(".")[1];return n?n.length:0}function EI(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}function jI(t){return typeof t=="function"}const J1=v.createContext(void 0),qo=()=>{const t=v.useContext(J1);if(!t)throw new Error("useColorPicker must be used within a ColorPickerProvider");return t},NI=({value:t,defaultValue:e="rgb(0 0 0)",onChange:n,className:r,...i})=>{const s=Fe(t??e),[o,a]=v.useState(s.hue()),[l,c]=v.useState(s.saturationl()),[d,h]=v.useState(s.lightness()),[f,m]=v.useState(s.alpha()*100),[p,g]=v.useState("hex");return v.useEffect(()=>{if(t){const b=Fe(t);a(b.hue()),c(b.saturationl()),h(b.lightness()),m(b.alpha()*100)}},[t]),v.useEffect(()=>{if(n){const x=Fe.hsl(o,l,d).alpha(f/100).hex();n(x)}},[o,l,d,f,n]),u.jsx(J1.Provider,{value:{hue:o,saturation:l,lightness:d,alpha:f,mode:p,setHue:a,setSaturation:c,setLightness:h,setAlpha:m,setMode:g},children:u.jsx("div",{className:Le("flex size-full flex-col gap-4",r),...i})})},Z1=v.memo(({className:t,...e})=>{const n=v.useRef(null),[r,i]=v.useState(!1),[s,o]=v.useState(0),[a,l]=v.useState(0),{hue:c,saturation:d,lightness:h,setSaturation:f,setLightness:m}=qo(),p=v.useMemo(()=>`linear-gradient(0deg, rgba(0,0,0,1), rgba(0,0,0,0)),
|
|
28
28
|
linear-gradient(90deg, rgba(255,255,255,1), rgba(255,255,255,0)),
|
|
29
|
-
hsl(${c}, 100%, 50%)`,[c]);v.useEffect(()=>{const x=d/100,y=x<.01?100:50+50*(1-x),w=Math.max(0,Math.min(1,1-h/y));o(x),l(w)},[d,h]);const g=v.useCallback(x=>{if(!n.current)return;const y=n.current.getBoundingClientRect(),w=Math.max(0,Math.min(1,(x.clientX-y.left)/y.width)),k=Math.max(0,Math.min(1,(x.clientY-y.top)/y.height));o(w),l(k),f(w*100);const S=(w<.01?100:50+50*(1-w))*(1-k);m(S)},[f,m]),b=v.useCallback(x=>{r&&g(x)},[r,g]);return v.useEffect(()=>{const x=()=>i(!1);return r&&(window.addEventListener("pointermove",b),window.addEventListener("pointerup",x)),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",x)}},[r,b]),u.jsx("div",{ref:n,className:Le("relative size-full cursor-crosshair rounded",t),style:{background:p},onPointerDown:x=>{x.preventDefault(),i(!0),g(x.nativeEvent)},...e,children:u.jsx("div",{className:"pointer-events-none absolute size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white",style:{left:`${s*100}%`,top:`${a*100}%`,boxShadow:"0 0 0 1px rgba(0,0,0,0.5)"}})})});Z1.displayName="ColorPickerSelection";const TI=({className:t,...e})=>{const{hue:n,setHue:r}=qo();return u.jsxs(R1,{className:Le("relative flex h-4 w-full touch-none",t),max:360,step:1,value:[n],onValueChange:([i])=>r(i),...e,children:[u.jsx(V1,{className:"relative my-0.5 h-3 w-full grow rounded-full bg-[linear-gradient(90deg,red,yellow,lime,aqua,blue,magenta,red)]",children:u.jsx(z1,{className:"absolute h-full"})}),u.jsx(G1,{className:"block size-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:ring-1 focus-visible:ring-focus-ring focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"})]})},DI=({className:t,...e})=>{const{setHue:n,setSaturation:r,setLightness:i,setAlpha:s}=qo();if(!(typeof window<"u"&&"EyeDropper"in window))return null;const a=async()=>{try{const c=await new EyeDropper().open(),d=Fe(c.sRGBHex),[h,f,m]=d.hsl().array();n(h),r(f),i(m),s(100)}catch(l){console.error("EyeDropper failed:",l)}};return u.jsx(Nr,{className:Le("shrink-0 text-muted-foreground size-8",t),size:"icon",type:"button",variant:"outline",onClick:a,...e,children:u.jsx(m2,{size:16})})},OI=["hex","rgb","hsl"],II=({...t})=>{const{mode:e,setMode:n}=qo();return u.jsxs(Eo,{value:e,onValueChange:n,children:[u.jsx(jo,{className:"h-8 w-20 shrink-0 text-xs",...t,children:u.jsx(No,{placeholder:"Mode"})}),u.jsx(To,{children:OI.map(r=>u.jsx($i,{className:"text-xs",value:r,children:r.toUpperCase()},r))})]})},PI=({className:t,...e})=>{const{hue:n,saturation:r,lightness:i,mode:s,setHue:o,setSaturation:a,setLightness:l,setAlpha:c}=qo(),d=Fe.hsl(n,r,i),[h,f]=v.useState(null),m=(p,g)=>{try{if(s==="hex"){const b=Fe(p);o(b.hue()),a(b.saturationl()),l(b.lightness()),c(b.alpha()*100)}else if((s==="rgb"||s==="hsl")&&g!==void 0){const b=d[s]().array().map(y=>Math.round(y));b[g]=parseInt(p,10)||0;const x=Fe[s](b[0],b[1],b[2]);o(x.hue()),a(x.saturationl()),l(x.lightness())}}catch{}};if(s==="hex"){const p=d.hex();return u.jsx("div",{className:Le("-space-x-px relative flex w-full items-center rounded-md",t),...e,children:u.jsx(_s,{className:"h-8 px-2 font-mono text-xs shadow-none",type:"text",value:h??p,onBlur:()=>{f(null)},onChange:g=>{f(g.target.value),m(g.target.value)}})})}if(s==="rgb"||s==="hsl"){const p=d[s]().array().map(g=>Math.round(g));return u.jsx("div",{className:Le("-space-x-px flex flex-1 items-stretch rounded-md",t),...e,children:p.map((g,b)=>u.jsx(_s,{className:Le("h-8 px-2 font-mono text-xs flex-1 shadow-none focus:z-10",b&&"rounded-l-none",b<p.length-1&&"rounded-r-none"),maxLength:3,size:4,type:"text",value:g,onChange:x=>{m(x.target.value,b)}},b))})}return null},RI=t=>u.jsxs(NI,{className:"w-auto min-w-80",...t,children:[u.jsx(Z1,{className:"aspect-square"}),u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx(DI,{}),u.jsx(TI,{})]}),u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx(II,{}),u.jsx(PI,{})]})]}),LI=()=>{const{isDirty:t}=Gl(),e=()=>{window.location.hash="/"};return u.jsx(J,{className:"text-grey-700 hover:text-grey-900!","data-testid":"exit-settings",icon:"close",id:"done-button",label:"",link:!0,title:"Close (ESC)",onClick:()=>Ui(t,e)})},_I=""+new URL("logo-loader-88VPEpXE.mp4",import.meta.url).href,FI=""+new URL("logo-loader-dark-CuSPz-zc.mp4",import.meta.url).href,Q1=v.createContext(void 0),BI=({children:t})=>{const e=gw(),n=bw(),r=vw(),i=Hg(),[s,o]=v.useState(!1);v.useEffect(()=>{o(document.documentElement.classList.contains("dark"))},[]);const a=[e,n,r,i],l=a.map(c=>c.error).find(Boolean);if(l)throw l;return a.some(c=>c.isLoading)?u.jsx("div",{className:"gh-loading-orb-container",style:{width:"100vw",height:"100vh",display:"flex",alignItems:"center",justifyContent:"center",paddingBottom:"8vh"},children:u.jsx("video",{autoPlay:!0,className:"gh-loading-orb",height:"100",preload:"metadata",style:{width:"100px",height:"100px"},width:"100",loop:!0,muted:!0,playsInline:!0,children:u.jsx("source",{src:s?FI:_I,type:"video/mp4"})})}):u.jsx(Q1.Provider,{value:{settings:e.data.settings,siteData:n.data.site,config:r.data.config,currentUser:i.data},children:t})},ke=()=>v.useContext(Q1),Ft=({savingDelay:t,onValidate:e}={})=>{const n=v.useRef(null),{siteData:r,settings:i}=ke(),{mutateAsync:s}=ai(),o=Ye(),[a,l]=v.useState(!1),{formState:c,saveState:d,handleSave:h,updateForm:f,setFormState:m,reset:p,validate:g,errors:b,clearError:x,okProps:y}=zl({initialState:i||[],savingDelay:t,onSave:async()=>{await s?.(k())},onSaveError:o,onValidate:e}),{setGlobalDirtyState:w}=Gl();v.useEffect(()=>{w(c.some(M=>M.dirty))},[c,w]),v.useEffect(()=>{a&&n.current&&n.current.focus()},[a]),v.useEffect(()=>{(!a||d==="saving")&&m(()=>i)},[i]);const k=()=>c?.filter(M=>M.dirty)?.map(M=>({key:M.key,value:M.value}));return{localSettings:c,isEditing:a,saveState:d,focusRef:n,siteData:r,handleSave:async()=>{const M=await h();return M&&l(!1),M},handleCancel:()=>{p(),l(!1)},updateSetting:(M,E)=>{f(j=>j.some(T=>T.key===M)?j.map(T=>T.key===M?{...T,value:E,dirty:!0}:T):[...j,{key:M,value:E,dirty:!0}])},handleEditingChange:M=>{l(M)},validate:g,errors:b,clearError:x,okProps:y}},VI=(t,e)=>{const[n,r]=v.useState("Save"),[i,s]=v.useState(!1);return{savingTitle:n,isSaving:i,onSaveClick:async()=>{s(!0),r("Saving"),await t({fakeWhenUnchanged:e}),setTimeout(()=>{r("Saved"),setTimeout(()=>{r("Save"),s(!1)},1e3)},1e3)}}},zI=({afterClose:t})=>{const{localSettings:e,handleSave:n,updateSetting:r}=Ft(),i=an(),[s,o]=we(e,["codeinjection_head","codeinjection_foot"]),[a,l]=v.useState("header"),c=v.useRef(null),d=v.useRef(null),h=v.useMemo(()=>Co(()=>import("./index-YzcsD17L.js"),__vite__mapDeps([19,20,21,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,22]),import.meta.url).then(y=>y.html()),[]),f={extensions:[h],hint:"Code here will be injected into the {{ghost_head}} tag on every page of the site",value:s||"",onChange:y=>r("codeinjection_head",y)},m={extensions:[h],hint:"Code here will be injected into the {{ghost_foot}} tag on every page of the site",value:o||"",onChange:y=>r("codeinjection_foot",y)},p=[{id:"header",title:"Site header",contents:u.jsx(Df,{height:"full",...f,ref:c,className:"mt-2","data-testid":"header-code",autoFocus:!0}),tabWrapperClassName:"flex-auto",containerClassName:"h-full"},{id:"footer",title:"Site footer",contents:u.jsx(Df,{height:"full",...m,ref:d,className:"mt-2","data-testid":"footer-code"}),tabWrapperClassName:"flex-auto",containerClassName:"h-full"}],{savingTitle:g,isSaving:b,onSaveClick:x}=VI(n,!0);return v.useEffect(()=>{const y=w=>{(w.metaKey||w.ctrlKey)&&w.key==="s"&&(w.preventDefault(),x())};return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}}),u.jsx(Fr,{afterClose:t,backDropClick:!1,cancelLabel:"Close",footer:u.jsx(u.Fragment,{}),height:"full",size:"full",testId:"modal-code-injection",children:u.jsxs("div",{className:"flex h-full flex-col",children:[u.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[u.jsx(qe,{level:2,children:"Code injection"}),u.jsx(rl,{buttons:[{label:"Close",color:"outline",onClick:()=>{i.remove(),t?.()}},{disabled:b,label:g,color:g==="Saved"?"green":"black",onClick:x}]})]}),u.jsx(hr,{containerClassName:"flex-auto flex flex-col mb-16",selectedTab:a,tabs:p,onTabChange:l})]})})},$I=pe.create(zI),HI=(t,e)=>`${t}-${e}`,UI=()=>{const[t,e]=v.useState(""),[n,r]=v.useState(!1),i=v.useRef(new Map),[s,o]=v.useState(new Set),a=m=>m.length?m.some(p=>p.toLowerCase().includes(t.toLowerCase())):!0,l=v.useCallback((m,p)=>{i.current.set(m,p),(!t||p.some(b=>b.toLowerCase().includes(t.toLowerCase())))&&o(b=>new Set(b).add(m))},[t]),c=v.useCallback(m=>{i.current.delete(m),o(p=>{const g=new Set(p);return g.delete(m),g})},[]);v.useEffect(()=>{const m=new Set;i.current.forEach((p,g)=>{(!t||p.some(x=>x.toLowerCase().includes(t.toLowerCase())))&&m.add(g)}),o(m)},[t]);const d=v.useCallback(m=>s.size===1&&s.has(m),[s]),h=v.useCallback(()=>s,[s]),f=m=>{if(!t)return m;if(typeof m=="string"){const p=t.split(/\s+/).map(x=>x.toLowerCase()),g=p.map(x=>x.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return m.split(new RegExp(`(${g})`,"gi")).map(x=>p.includes(x.toLowerCase())?u.jsx("span",{className:"bg-yellow-500/40",children:x}):x)}else return Array.isArray(m)?m.map(p=>f(p)):m&&typeof m=="object"&&m?W.Children.map(m,p=>p&&typeof p=="object"&&"props"in p?f(p.props.children):p):m};return{filter:t,setFilter:e,checkVisible:a,highlightKeywords:f,noResult:n,setNoResult:r,registerComponent:l,unregisterComponent:c,getVisibleComponents:h,isOnlyVisibleComponent:d}},ey=v.createContext({route:"",updateRoute:()=>{},loadingModal:!1,eventTarget:new EventTarget});function WI(t,e){if(!e)return null;const n=new RegExp(`/${t}/(.*)`),r=e?.match(n);return r?r[1]:null}const KI=(t,e,n,r)=>{let i=window.location.hash;i=i.substring(1);const s=`${window.location.protocol}//${window.location.hostname}`,o=new URL(i,s),a=WI(t,o.pathname);if(!r||!n)return{pathName:a||""};const l=o.searchParams;if(a&&r&&n){const[,c]=Object.entries(r).find(([f])=>pu(e||"",f))||[],[d,h]=Object.entries(r).find(([f])=>pu(a,f))||[];return{pathName:a,changingModal:h&&h!==c,modal:d&&h?n().then(({default:f})=>{pe.show(f[h],{pathName:a,params:pu(a,d),searchParams:l})}):void 0}}return{pathName:""}},pu=(t,e)=>{const n=new RegExp("^"+e.replace(/:(\w+)/g,"(?<$1>[^/]+)")+"/?$"),r=t.match(n);if(r)return r.groups||{}},GI=({basePath:t,modals:e,children:n})=>{const{externalNavigate:r}=Ug(),[i,s]=v.useState(void 0),[o,a]=v.useState(!1),[l]=v.useState(new EventTarget),c=v.useCallback(d=>{const h=typeof d=="string"?{route:d}:d;if(h.isExternal){r(h);return}const f=h.route.replace(/^\//,"");f===i||(f?window.location.hash=`/${t}/${f}`:window.location.hash=`/${t}`),l.dispatchEvent(new CustomEvent("routeChange",{detail:{newPath:f,oldPath:i}}))},[t,l,r,i]);return v.useEffect(()=>{setTimeout(()=>{e?.load()},1e3)},[]),v.useEffect(()=>{const d=()=>{s(h=>{const{pathName:f,modal:m,changingModal:p}=KI(t,h,e?.load,e?.paths);return m&&p&&(a(!0),m.then(()=>a(!1))),f})};return d(),window.addEventListener("hashchange",d),()=>{window.removeEventListener("hashchange",d)}},[]),i===void 0?null:u.jsx(ey.Provider,{value:{route:i,updateRoute:c,loadingModal:o,eventTarget:l},children:n})};function fe(){return v.useContext(ey)}function qI(t,e){const{eventTarget:n}=fe(),r=v.useCallback(t,e);v.useEffect(()=>{const i=s=>{const o=s;r(o.detail.newPath,o.detail.oldPath)};return n.addEventListener("routeChange",i),()=>n.removeEventListener("routeChange",i)},[n,r])}const ty=v.createContext({updateSection:()=>{},updateNav:()=>{},currentSection:null,updateNavigatedSection:()=>{},scrollToSection:()=>{}}),yc=()=>v.useContext(ty),ny=193,gu=(t,e)=>{const n=document.getElementById("admin-x-settings-scroller"),r=t.getBoundingClientRect().top+n.scrollTop;n.scrollTo({behavior:e?"smooth":"instant",top:r-ny})},YI=(t,e)=>{const n=document.getElementById("admin-x-settings-sidebar-scroller"),r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),s=i.top+40;if(r.top>=s&&r.left>=i.left&&r.right<=i.right&&r.bottom<=i.bottom||!["auto","scroll"].includes(getComputedStyle(n).overflowY))return;const o=e?"smooth":"instant";n.querySelector("[data-setting-nav-item]")===t?n.scrollTo({top:0,behavior:o}):r.top<s?n.scrollTo({top:n.scrollTop+r.top-s,behavior:o}):n.scrollTo({top:n.scrollTop+r.top-i.top-i.height+r.height+4,behavior:o})},XI=(t,e,n)=>{const r=e.map(({isIntersecting:a,target:l})=>({isIntersecting:a,id:Object.entries(n).find(([,c])=>c===l)?.[0]})).filter(a=>a.id),i=r.filter(a=>!t.includes(a.id)&&a.isIntersecting).map(a=>a.id),s=r.filter(a=>!a.isIntersecting).map(a=>a.id),o=t.filter(a=>!s.includes(a)).concat(i);return o.sort((a,l)=>{const c=n[a],d=n[l];return!c||!d?0:c.getBoundingClientRect().top-d.getBoundingClientRect().top}),o},JI=({children:t})=>{const[e,n]=v.useState(null),r=v.useRef({}),i=v.useRef(null),[s,o]=v.useState([]),[a,l]=v.useState(null),[c,d]=v.useState(!1),[h,f]=v.useState(!1),[,m]=v.useState(!1),p=v.useCallback(C=>{n(C),d(!0)},[]),g=v.useRef({}),b=v.useCallback(()=>{const C=new IntersectionObserver(S=>{o(A=>{const M=XI(A,S,r.current);return M.length&&l(M[0]),M})},{rootMargin:`-${ny-50}px 0px -40% 0px`});return Object.values(r.current).forEach(S=>C.observe(S)),C},[]),x=v.useCallback((C,S)=>{r.current[C]!==S&&(r.current[C]&&i.current?.unobserve(r.current[C]),r.current[C]=S,i.current?.observe(S),!h&&C===e&&(gu(S,!1),f(!0)))},[i,e,h]),y=v.useCallback((C,S)=>{g.current[C]=S},[]),w=v.useCallback(C=>{r.current[C]&&gu(r.current[C],!0)},[]),k=v.useMemo(()=>e&&s.includes(e)?e:s.length?s[0]:a,[s,a,e]);return v.useEffect(()=>{c&&(e&&r.current[e]?f(C=>(gu(r.current[e],C),!0)):f(!0),setTimeout(()=>b()))},[c,e,b]),v.useEffect(()=>{c&&k&&g.current[k]&&m(C=>(YI(g.current[k],C),!0))},[c,k]),u.jsx(ty.Provider,{value:{updateSection:x,updateNav:y,currentSection:k,updateNavigatedSection:p,scrollToSection:w},children:t})},ZI=t=>{const{updateSection:e}=yc(),n=v.useRef(null);return v.useEffect(()=>{t&&n.current&&e(t,n.current)},[t,e]),{ref:n}},QI=t=>{const{updateNav:e}=yc(),n=v.useRef(null);return v.useEffect(()=>{t&&n.current&&(Array.isArray(t)?t:[t]).forEach(i=>{e(i,n.current)})},[t,e]),{ref:n,props:{"data-setting-nav-item":!0}}},Yo="IntegrationsResponseType",s9=Yo,eP=Xd({dataType:Yo,path:"/integrations/",defaultSearchParams:{include:"api_keys,webhooks",limit:"50"}}),o9=Ot({method:"POST",path:()=>"/integrations/",body:t=>({integrations:[t]}),searchParams:()=>({include:"api_keys,webhooks"}),updateQueries:{dataType:Yo,emberUpdateType:"createOrUpdate",update:(t,e)=>e&&{...e,integrations:e.integrations.concat(t.integrations)}}}),a9=Ot({method:"PUT",path:t=>`/integrations/${t.id}/`,body:t=>({integrations:[t]}),searchParams:()=>({include:"api_keys,webhooks"}),updateQueries:{dataType:Yo,emberUpdateType:"createOrUpdate",update:(t,e)=>e&&{...e,integrations:e.integrations.map(n=>t.integrations.find(({id:i})=>i===n.id)||n)}}}),tP=Ot({method:"DELETE",path:t=>`/integrations/${t}/`,updateQueries:{dataType:Yo,emberUpdateType:"delete",update:(t,e,n)=>({...e,integrations:e.integrations.filter(r=>r.id!==n)})}}),nP=""+new URL("Alto-DoS3yH_j.png",import.meta.url).href,rP=""+new URL("Bulletin-BUpcurG5.png",import.meta.url).href,iP=""+new URL("Casper-ASA9Ix4v.png",import.meta.url).href,sP=""+new URL("Dawn-aeEVEPie.png",import.meta.url).href,oP=""+new URL("Digest-DJl0U_FG.png",import.meta.url).href,aP=""+new URL("Dope-D_CgP0p0.png",import.meta.url).href,lP=""+new URL("Ease-B4NuA7sj.png",import.meta.url).href,cP=""+new URL("Edge-BPZxvKka.png",import.meta.url).href,uP=""+new URL("Edition-cIDLjlhj.png",import.meta.url).href,dP=""+new URL("Episode-D7bgV2bY.png",import.meta.url).href,hP=""+new URL("Headline-BFXOunIb.png",import.meta.url).href,fP=""+new URL("Journal-D3UW9T2b.png",import.meta.url).href,mP=""+new URL("London-CSCVHwS0.png",import.meta.url).href,pP=""+new URL("Ruby-DVEXVMTx.png",import.meta.url).href,gP=""+new URL("Solo-c-yPo0gw.png",import.meta.url).href,bP=""+new URL("Source-V-WXZXnS.png",import.meta.url).href,vP=""+new URL("Source-Magazine-Czq1p0a_.png",import.meta.url).href,xP=""+new URL("Source-Newsletter-CwTcfhJ-.png",import.meta.url).href,yP=""+new URL("Taste-U2cRR2yO.png",import.meta.url).href,wP=""+new URL("Wave-DE2aI-FM.png",import.meta.url).href,ry=[{name:"Source",category:"News",previewUrl:"https://source.ghost.io/",ref:"default",image:bP,variants:[{category:"Magazine",previewUrl:"https://source-magazine.ghost.io/",image:vP},{category:"Newsletter",previewUrl:"https://source-newsletter.ghost.io/",image:xP}]},{name:"Casper",category:"Blog",previewUrl:"https://demo.ghost.io/",ref:"TryGhost/Casper",image:iP},{name:"Edition",category:"Newsletter",url:"https://github.com/TryGhost/Edition",previewUrl:"https://edition.ghost.io/",ref:"TryGhost/Edition",image:uP},{name:"Solo",category:"Blog",url:"https://github.com/TryGhost/Solo",previewUrl:"https://solo.ghost.io",ref:"TryGhost/Solo",image:gP},{name:"Taste",category:"Blog",url:"https://github.com/TryGhost/Taste",previewUrl:"https://taste.ghost.io",ref:"TryGhost/Taste",image:yP},{name:"Episode",category:"Podcast",url:"https://github.com/TryGhost/Episode",previewUrl:"https://episode.ghost.io",ref:"TryGhost/Episode",image:dP},{name:"Digest",category:"Newsletter",url:"https://github.com/TryGhost/Digest",previewUrl:"https://digest.ghost.io/",ref:"TryGhost/Digest",image:oP},{name:"Bulletin",category:"Newsletter",url:"https://github.com/TryGhost/Bulletin",previewUrl:"https://bulletin.ghost.io/",ref:"TryGhost/Bulletin",image:rP},{name:"Alto",category:"Blog",url:"https://github.com/TryGhost/Alto",previewUrl:"https://alto.ghost.io",ref:"TryGhost/Alto",image:nP},{name:"Dope",category:"Magazine",url:"https://github.com/TryGhost/Dope",previewUrl:"https://dope.ghost.io",ref:"TryGhost/Dope",image:aP},{name:"Wave",category:"Podcast",url:"https://github.com/TryGhost/Wave",previewUrl:"https://wave.ghost.io",ref:"TryGhost/Wave",image:wP},{name:"Edge",category:"Photography",url:"https://github.com/TryGhost/Edge",previewUrl:"https://edge.ghost.io",ref:"TryGhost/Edge",image:cP},{name:"Dawn",category:"Newsletter",url:"https://github.com/TryGhost/Dawn",previewUrl:"https://dawn.ghost.io/",ref:"TryGhost/Dawn",image:sP},{name:"Ease",category:"Documentation",url:"https://github.com/TryGhost/Ease",previewUrl:"https://ease.ghost.io",ref:"TryGhost/Ease",image:lP},{name:"Headline",category:"News",url:"https://github.com/TryGhost/Headline",previewUrl:"https://headline.ghost.io",ref:"TryGhost/Headline",image:hP},{name:"Ruby",category:"Magazine",url:"https://github.com/TryGhost/Ruby",previewUrl:"https://ruby.ghost.io",ref:"TryGhost/Ruby",image:pP},{name:"London",category:"Photography",url:"https://github.com/TryGhost/London",previewUrl:"https://london.ghost.io",ref:"TryGhost/London",image:mP},{name:"Journal",category:"Newsletter",url:"https://github.com/TryGhost/Journal",previewUrl:"https://journal.ghost.io/",ref:"TryGhost/Journal",image:fP}],gg=""+new URL("orb-black-1-bYPPSSAp.png",import.meta.url).href,kP=""+new URL("orb-black-2-C-rcujeh.png",import.meta.url).href,bg=""+new URL("orb-black-3-DTkwRv_1.png",import.meta.url).href,vg=""+new URL("orb-black-4-BXF3fMuE.png",import.meta.url).href,SP=""+new URL("orb-black-5-94Eda1ek.png",import.meta.url).href,CP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201818.2%202500'%20style='enable-background:new%200%200%201818.2%202500'%20xml:space='preserve'%3e%3ctitle%3egoogle-docs%3c/title%3e%3cpath%20d='M1136.4%200h-966C79.6%200%200%2079.5%200%20170.5v2159.1c0%2090.9%2079.5%20170.5%20170.5%20170.5h1477.3c90.9%200%20170.5-79.5%20170.5-170.5V681.8l-397.7-284.1L1136.4%200z'%20style='fill:%234285f4'/%3e%3cpath%20d='M454.5%201818.2h909.1v-113.6h-909l-.1%20113.6zm0%20227.3h681.8v-113.6H454.5v113.6zm0-795.5v113.6h909.1V1250H454.5zm0%20340.9h909.1v-113.6h-909l-.1%20113.6z'%20style='fill:%23f1f1f1'/%3e%3cpath%20d='M1136.4%200v511.4c0%2090.9%2079.5%20170.4%20170.4%20170.4h511.4L1136.4%200z'%20style='fill:%23a1c2fa'/%3e%3c/svg%3e",AP=""+new URL("mailchimp-DwTEN-tS.svg",import.meta.url).href,MP="data:image/svg+xml,%3csvg%20height='546'%20viewBox='0%200%20569%20546'%20width='569'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3epatreon%3c/title%3e%3cg%20fill='%23FF424D'%3e%3ccircle%20cx='362.59'%20cy='204.59'%20data-fill='1'%20r='204.59'/%3e%3cpath%20data-fill='1'%20d='M0%200h100v545.8H0z'/%3e%3c/g%3e%3c/svg%3e",xg="data:image/svg+xml,%3csvg%20width='152'%20height='179'%20viewBox='0%200%20152%20179'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3epaypal%3c/title%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M136.492%2045.453c2.179-13.894-.015-23.348-7.53-31.911C120.688%204.114%20105.741.075%2086.617.075H31.105a7.943%207.943%200%200%200-7.846%206.705L.144%20153.36a4.765%204.765%200%200%200%204.707%205.507h34.27l-2.365%2015a4.168%204.168%200%200%200%204.118%204.818H69.76a6.948%206.948%200%200%200%206.863-5.865l.283-1.468%205.442-34.507.351-1.907a6.947%206.947%200%200%201%206.862-5.865h4.322c27.984%200%2049.896-11.37%2056.299-44.25%202.675-13.74%201.292-25.208-5.783-33.27-2.14-2.439-4.802-4.455-7.907-6.1'%20fill='%23238EC2'/%3e%3cpath%20d='M136.492%2045.453c2.179-13.894-.015-23.348-7.53-31.911C120.688%204.114%20105.741.075%2086.617.075H31.105a7.943%207.943%200%200%200-7.846%206.705L.144%20153.36a4.765%204.765%200%200%200%204.707%205.507h34.27l8.609-54.588-.267%201.711c.609-3.86%203.909-6.704%207.817-6.704h16.288c31.989%200%2057.037-12.996%2064.356-50.582.217-1.113.402-2.191.568-3.251'%20fill='%2320274F'/%3e%3cpath%20d='M56.978%2045.638a6.945%206.945%200%200%201%206.863-5.866h43.514c5.155%200%209.961.337%2014.356%201.045%201.256.202%202.478.435%203.665.698a53.92%2053.92%200%200%201%203.455.885c.558.162%201.106.333%201.646.512%202.157.717%204.166%201.562%206.015%202.541%202.179-13.894-.015-23.348-7.53-31.911C120.688%204.114%20105.741.075%2086.617.075H31.105a7.943%207.943%200%200%200-7.846%206.705L.144%20153.36a4.765%204.765%200%200%200%204.707%205.507h34.27L56.978%2045.638'%20fill='%23253667'/%3e%3c/g%3e%3c/svg%3e",EP=""+new URL("slackicon-37ETtpm7.png",import.meta.url).href,jP="data:image/svg+xml,%3csvg%20width='86'%20height='89'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3etypeform%3c/title%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M40.28%2087.561c12.464.154%2021.16-3.994%2030.135-12.175%208.975-8.18%2014.306-16.867%2014.741-28.73.436-11.862-3.412-21.43-12.564-30.581C63.441%206.923%2051.64.9%2039.4.899%2027.158.898%2018.967%206.252%2011.385%2016.07c-7.581%209.818-9.237%2022.212-9.894%2033.921-.657%2011.71-1.15%2017.111%206.608%2024.625%207.758%207.514%2019.718%2012.791%2032.182%2012.945z'%20stroke='%23262627'/%3e%3cpath%20d='M29.136%2037.976v-4.885h25.918v4.885H44.679v27.998H39.51V37.976z'%20fill='%23262627'%20fill-rule='nonzero'/%3e%3c/g%3e%3c/svg%3e",NP=""+new URL("zero-bounce-lzY95s9E.png",import.meta.url).href,iy=[{ghostImage:kP,appImage:EP,title:"Share scheduled posts with your team in Slack",url:"https://zapier.com/webintent/create-zap?template=359499"},{ghostImage:bg,appImage:MP,title:"Connect Patreon to your Ghost membership site",url:"https://zapier.com/webintent/create-zap?template=75801"},{ghostImage:vg,appImage:NP,title:"Protect email delivery with email verification",url:"https://zapier.com/webintent/create-zap?template=359415"},{ghostImage:SP,appImage:xg,title:"Add members for successful sales in PayPal",url:"https://zapier.com/webintent/create-zap?template=184423"},{ghostImage:bg,appImage:xg,title:"Unsubscribe members who cancel a subscription in PayPal",url:"https://zapier.com/webintent/create-zap?template=359348"},{ghostImage:gg,appImage:CP,title:"Send new post drafts from Google Docs to Ghost",url:"https://zapier.com/webintent/create-zap?template=50924"},{ghostImage:vg,appImage:jP,title:"Survey new members using Typeform",url:"https://zapier.com/webintent/create-zap?template=359407"},{ghostImage:gg,appImage:AP,title:"Sync email subscribers in Ghost + Mailchimp",url:"https://zapier.com/webintent/create-zap?template=359342"}],sy=v.createContext({officialThemes:ry,zapierTemplates:iy,search:{filter:"",setFilter:()=>{},checkVisible:()=>!0,highlightKeywords:()=>"",noResult:!1,setNoResult:()=>{},registerComponent:()=>{},unregisterComponent:()=>{},getVisibleComponents:()=>new Set,isOnlyVisibleComponent:()=>!1},sortingState:[],offersShowArchived:!1,setOffersShowArchived:()=>{}}),TP=({children:t,...e})=>{const n=UI(),[r,i]=v.useState([{type:"offers",option:"date-added",direction:"desc"}]),[s,o]=v.useState(!1);return u.jsx(sy.Provider,{value:{officialThemes:ry,zapierTemplates:iy,...e,search:n,sortingState:r,setSortingState:i,offersShowArchived:s,setOffersShowArchived:o},children:u.jsx(BI,{children:u.jsx(JI,{children:t})})})},Xo=()=>v.useContext(sy),l9=()=>Xo().officialThemes,Jo=()=>Xo().search,c9=()=>Xo().upgradeStatus,u9=()=>{const{sortingState:t,setSortingState:e}=Xo();return{sortingState:t,setSortingState:e}},d9=()=>{const{offersShowArchived:t,setOffersShowArchived:e}=Xo();return{offersShowArchived:t,setOffersShowArchived:e}},Se=({keywords:t,navid:e,children:n,...r})=>{const{checkVisible:i,noResult:s,registerComponent:o,unregisterComponent:a}=Jo(),{route:l}=fe(),[c,d]=v.useState(!1),{ref:h}=ZI(e),f=v.useId(),m=HI(e||"component",f);v.useEffect(()=>(o(m,t),()=>{a(m)}),[m,t,o,a]),v.useEffect(()=>{if(d(l===e),l===e){const b=setTimeout(()=>d(!1),2e3);return()=>clearTimeout(b)}},[l,e]);const g=W.Children.toArray(n).some(b=>W.isValidElement(b)&&b.type==="img")?u.jsx("div",{className:"-mx-5 -mb-5 overflow-hidden rounded-b-xl bg-grey-50 md:-mx-7 md:-mb-7",children:W.Children.map(n,b=>W.isValidElement(b)&&b.type==="img"?W.cloneElement(b,{className:`${b.props.className||""} h-full w-full rounded-b-xl`.trim()}):b)}):n;return u.jsx(eE,{ref:h,highlight:c,isVisible:i(t)||s,navid:e,...r,children:g})},DP=({keywords:t})=>u.jsx(Se,{customHeader:u.jsxs("div",{className:"z-10 flex items-start justify-between",children:[u.jsx(ni,{description:"Add custom code to your publication.",title:"Code injection"}),u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Open",size:"sm",onClick:()=>{pe.show($I)}})]}),description:"Add custom code to your publication",keywords:t,navid:"code-injection",testId:"code-injection",title:"Code injection"}),OP=Ce(DP,"Code injection"),hf="InvitesResponseType",IP=Jd({dataType:hf,path:"/invites/",permissions:["Owner","Administrator"],defaultSearchParams:{limit:"100",include:"roles"},defaultNextPageParams:(t,e)=>({...e,page:(t.meta?.pagination.next||1).toString()}),returnData:t=>{const{pages:e}=t,n=e.flatMap(i=>i.invites),r=e[e.length-1].meta;return{invites:n,meta:r,isEnd:r?r.pagination.pages===r.pagination.page:!0}}}),PP=Ot({method:"POST",path:()=>"/invites/",body:({email:t,roleId:e})=>({invites:[{email:t,role_id:e,expires:null,status:null,token:null}]}),updateQueries:{dataType:hf,emberUpdateType:"createOrUpdate",update:xw("invites")}}),RP=Ot({path:t=>`/invites/${t}/`,method:"DELETE",updateQueries:{dataType:hf,emberUpdateType:"delete",update:yw("invites")}}),LP="RolesResponseType",_P=Xd({dataType:LP,path:"/roles/",defaultSearchParams:{limit:"100"}});function Ka(t,e){return t.filter(n=>n.roles.find(r=>r.name===e))}function FP(t,e){return t.filter(n=>n.roles.find(r=>e.includes(r.name)))}function BP(t){return Ka(t,"Owner")[0]}const ff=()=>{const{currentUser:t}=ke(),{data:{users:e,meta:n,isEnd:r}={users:[]},isLoading:i,fetchNextPage:s}=ww(),{data:{invites:o,meta:a,isEnd:l}={invites:[]},isLoading:c,fetchNextPage:d}=IP(),{data:{roles:h}={},isLoading:f}=_P(),m=v.useMemo(()=>BP(e),[e]),p=v.useMemo(()=>Ka(e,"Administrator"),[e]),g=v.useMemo(()=>FP(e,["Editor","Super Editor"]),[e]),b=v.useMemo(()=>Ka(e,"Author"),[e]),x=v.useMemo(()=>Ka(e,"Contributor"),[e]),y=v.useMemo(()=>o.map(w=>{let k=h?.find(C=>w.role_id===C.id);return{...w,role:k?.name}}),[o,h]);return{totalUsers:n?.pagination.total||0,totalInvites:a?.pagination.total||0,users:e,ownerUser:m,adminUsers:p,editorUsers:g,authorUsers:b,contributorUsers:x,currentUser:t,invites:y,isLoading:i||c||f,hasNextPage:r===!1,invitesHasNextPage:l===!1,fetchNextPage:s,fetchNextInvitePage:d}},VP=Ot({method:"POST",path:()=>"/db/",body:t=>{const e=new FormData;return e.append("importfile",t),e}}),zP=Ot({method:"DELETE",path:()=>"/db/"}),$P=()=>Zd("/db/"),HP=Ot({method:"POST",path:()=>"/authentication/reset/"}),UP=({keywords:t})=>{const{mutateAsync:e}=zP(),{mutateAsync:n}=HP(),r=Bl(),i=Ye(),{config:s}=ke(),{totalUsers:o}=ff(),a=!!s?.labs?.dangerZoneResetAuth,l=o===1?"You will be signed out and must reset your password before signing back in.":o>1?`All ${o} staff users, including you, will be signed out and must reset their password before signing back in.`:"All staff users, including you, will be signed out and must reset their password before signing back in.",c=()=>{pe.show(Wt,{title:"Would you really like to delete all content from your blog?",prompt:"This is permanent! No backups, no restores, no magic undo button. We warned you, k?",okColor:"red",okLabel:"Delete",onOk:async h=>{try{await e(null),rn({title:"All content deleted from database.",type:"success"}),h?.remove(),await r.refetchQueries()}catch(f){i(f)}}})},d=()=>{pe.show(Wt,{title:"Reset all authentication?",prompt:u.jsxs(u.Fragment,{children:[u.jsxs("p",{className:"mb-4",children:["This rotates every API key on your site. Any integration using one will stop working until you reconfigure it with the new key from ",u.jsx("strong",{children:"Settings → Advanced → Integrations"}),"."]}),u.jsxs("p",{children:[l," Your members aren't affected."]})]}),okLabel:"Reset all authentication",okRunningLabel:"Resetting...",okColor:"red",onOk:async h=>{try{const m=(await n(null))?.security_action?.[0],p=m?.api_keys_rotated??0,g=m?.users_locked??0;rn({title:`Rotated ${p} API ${p===1?"key":"keys"} and locked ${g} ${g===1?"user":"users"}. You will be signed out shortly.`,type:"success"}),h?.remove(),window.location.href=Ys().adminRoot}catch(f){i(f)}}})};return u.jsx(Se,{customHeader:u.jsx(ni,{description:"Destructive actions that affect your entire site.",title:"Danger zone"}),keywords:t,navid:"dangerzone",testId:"dangerzone",children:u.jsxs("div",{className:"flex flex-col",children:[u.jsx(Wi,{action:u.jsx(J,{"aria-label":"Delete all content",color:"red",label:"Delete",onClick:c}),bgOnHover:!1,detail:"Permanently delete all posts and tags from the database.",testId:"delete-all-content",title:"Delete all content"}),a&&u.jsx(Wi,{action:u.jsx(J,{"aria-label":"Reset all authentication",color:"red",label:"Reset",onClick:d}),bgOnHover:!1,detail:"Rotate every API key, sign out every staff user, and require a password reset. Use after a suspected credential compromise.",testId:"reset-all-authentication",title:"Reset all authentication"})]})})},WP=Ce(UP,"Danger zone"),KP=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("history/view")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"View history",size:"sm",onClick:n}),description:"View system event log",keywords:t,navid:"history",testId:"history",title:"History"})},GP=Ce(KP,"History"),qP=""+new URL("integrations-settings-Ba5Zx8yQ.png",import.meta.url).href;function oy(){const{config:t,settings:e}=ke(),[n]=we(e,["pintura"]),[r,i]=v.useState(!1),[s,o]=v.useState(!1),[a,l]=v.useState(!1),c=v.useRef(!1),[d]=we(e,["pintura_js_url"]),[h]=we(e,["pintura_css_url"]);let f=n&&r&&s||!1;const m=t?.pintura;v.useEffect(()=>{let b=m?.js?m?.js:d||null;if(b){if(b.startsWith("/")){const{adminRoot:x}=Ys();b=window.location.origin+x.replace(/\/$/,"")+b}if(window.pintura){i(!0);return}try{const x=new URL(b);import(`${x.protocol}//${x.host}${x.pathname}`).then(()=>{i(!0)}).catch(k=>{Ls(k)})}catch(x){Ls(x)}}},[d,m?.js]),v.useEffect(()=>{let b=m?.css?m?.css:h||null;if(b){if(b.startsWith("/")){const{adminRoot:x}=Ys();b=window.location.origin+x.replace(/\/$/,"")+b}try{if(document.querySelector(`link[href="${b}"]`))o(!0);else{let y=document.createElement("link");y.rel="stylesheet",y.type="text/css",y.href=b,y.onload=()=>{o(!0)},document.head.appendChild(y)}}catch(x){Ls(x)}}},[h,m?.css]);const p=v.useCallback(({image:g,handleSave:b})=>{if(g&&f){const x=new URL(g);x.searchParams.has("v")||x.searchParams.set("v",Date.now().toString());const y=x.href,w=window.pintura.openDefaultEditor({src:y,enableTransparencyGrid:!0,util:"crop",utils:["crop","filter","finetune","redact","annotate","trim","frame","resize"],frameOptions:[[void 0,k=>k.labelNone],["solidSharp",k=>k.frameLabelMatSharp],["solidRound",k=>k.frameLabelMatRound],["lineSingle",k=>k.frameLabelLineSingle],["hook",k=>k.frameLabelCornerHooks],["polaroid",k=>k.frameLabelPolaroid]],cropSelectPresetFilter:"landscape",cropSelectPresetOptions:[[void 0,"Custom"],[1,"Square"],[2/1,"2:1"],[3/2,"3:2"],[4/3,"4:3"],[16/10,"16:10"],[16/9,"16:9"],[1/2,"1:2"],[2/3,"2:3"],[3/4,"3:4"],[10/16,"10:16"],[9/16,"9:16"]],locale:{labelButtonExport:"Save and close"},previewPad:!0,willClose:()=>c.current?(l(!1),!0):!1});w.on("loaderror",()=>{kw("Pintura editor failed to load")}),w.on("process",k=>{b(k.dest)}),l(!0)}},[f]);return v.useEffect(()=>{const g=x=>{x.key==="Escape"&&x.stopPropagation()};if(!a)return;const b=x=>{x.target instanceof Element&&x.target.closest('.PinturaModal button[title="Close"]')&&(c.current=!0)};return window.addEventListener("click",b,{capture:!0}),window.addEventListener("keydown",g,{capture:!0}),()=>{window.removeEventListener("click",b,{capture:!0}),window.removeEventListener("keydown",g,{capture:!0})}},[a]),{isEnabled:f,openEditor:p}}const ay=({icon:t,title:e,detail:n,action:r,onDelete:i,active:s,disabled:o,testId:a,custom:l=!1})=>{const{updateRoute:c}=fe(),d=m=>{m?.stopPropagation(),o?c({route:"pro",isExternal:!0}):r()},h=m=>{m?.stopPropagation(),i?.()},f=l?u.jsx(J,{color:"red",label:"Delete",link:!0,onClick:h}):o?u.jsx(J,{icon:"lock-locked",label:"Upgrade",link:!0,onClick:d}):u.jsx(J,{color:"green",label:"Configure",link:!0,onClick:d});return u.jsx(Wi,{action:f,avatar:t,className:o?"opacity-50 saturate-0":"",detail:n,hideActions:!o,testId:a,title:s?u.jsxs("span",{className:"inline-flex items-center gap-1",children:[e," ",u.jsx("span",{className:"inline-flex items-center rounded-full bg-[rgba(48,207,67,0.15)] px-1.5 py-px text-xs font-semibold tracking-wide text-green uppercase",children:"Active"})]}):e,onClick:d})},YP=()=>{const{config:t}=ke(),{updateRoute:e}=fe(),n=m=>{e(m)},r=t.hostSettings?.limits?.customIntegrations?.disabled,i=oy(),{settings:s}=ke(),[o,a,l,c,d]=we(s,["unsplash","firstpromoter","slack_url","slack_username","transistor"]),h=[{detail:"Automation for your apps",disabled:r,icon:u.jsx(me,{name:"zapier",size:32}),modal:"integrations/zapier",testId:"zapier-integration",title:"Zapier"},{active:!!(l&&c),detail:"A messaging app for teams",icon:u.jsx(me,{name:"slack",size:32}),modal:"integrations/slack",testId:"slack-integration",title:"Slack"},{active:!!o,detail:"Beautiful, free photos",icon:u.jsx(me,{name:"unsplash",size:32}),modal:"integrations/unsplash",testId:"unsplash-integration",title:"Unsplash"},{active:!!a,detail:"Launch your member referral program",icon:u.jsx(me,{name:"firstpromoter",size:32}),modal:"integrations/firstpromoter",testId:"firstpromoter-integration",title:"FirstPromoter"},{active:i.isEnabled,detail:"Advanced image editing",icon:u.jsx(me,{name:"pintura",size:32}),modal:"integrations/pintura",testId:"pintura-integration",title:"Pintura"},{active:!!d,detail:"Give your members access to private podcasts",disabled:r,icon:u.jsx(me,{name:"transistor",size:32}),modal:"integrations/transistor",testId:"transistor-integration",title:"Transistor.fm"},{detail:"Access your content programmatically",icon:u.jsx(me,{name:"angle-brackets",size:32}),modal:"integrations/contentapi",testId:"content-api-integration",title:"Content API"}],f=[...h.filter(m=>!m.disabled),...h.filter(m=>m.disabled)];return u.jsx(is,{titleSeparator:!1,children:f.map(m=>u.jsx(ay,{action:()=>{n(m.modal)},active:m.active,detail:m.detail,disabled:m.disabled,icon:m.icon,testId:m.testId,title:m.title},m.testId))})},XP=({integrations:t})=>{const{updateRoute:e}=fe(),{mutateAsync:n}=tP(),r=Ye();return t.length?u.jsx(is,{borderTop:!1,children:t.map(i=>u.jsx(ay,{action:()=>e({route:`integrations/${i.id}`}),detail:u.jsx("div",{className:"line-clamp-2 break-words",children:u.jsx("span",{title:`${i.name}: ${i.description||"No description"}`,children:i.description||"No description"})}),icon:i.icon_image?u.jsx("img",{className:"size-8 shrink-0 object-cover",role:"presentation",src:i.icon_image}):u.jsx(me,{className:"w-8 shrink-0",name:"integration"}),title:i.name,custom:!0,onDelete:()=>{pe.show(Wt,{title:"Are you sure?",prompt:"Deleting this integration will remove all webhooks and api keys associated with it.",okColor:"red",okLabel:"Delete Integration",onOk:async s=>{try{await n(i.id),s?.remove(),rn({title:"Integration deleted",type:"info",options:{position:"bottom-left"}})}catch(o){r(o)}}})}}))}):u.jsx(li,{icon:"integration",children:"No custom integration."})},JP=({keywords:t})=>{const[e,n]=v.useState("built-in"),{data:{integrations:r}={integrations:[]}}=eP(),{updateRoute:i}=fe(),s=[{id:"built-in",title:"Built-in",contents:u.jsx(YP,{})},{id:"custom",title:"Custom",contents:u.jsx(XP,{integrations:r.filter(a=>a.type==="custom")})}],o=u.jsx(J,{className:"mt-[-5px] inline-flex h-7 cursor-pointer items-center justify-center rounded px-3 font-semibold whitespace-nowrap text-grey-900 transition hover:bg-grey-200 dark:text-white dark:hover:bg-grey-900 [&:hover]:text-black",color:"clear",label:"Add custom integration",link:!0,onClick:()=>{i("integrations/new"),n("custom")}});return u.jsx(Se,{customButtons:o,customHeader:u.jsxs("div",{className:"sm:-mt-5 md:-mt-7",children:[u.jsx("div",{className:"-mx-5 overflow-hidden rounded-t-xl border-b border-grey-200 md:-mx-7 dark:border-grey-800",children:u.jsx("img",{className:"size-full",src:qP})}),u.jsxs("div",{className:" z-10 mt-6 flex items-start justify-between",children:[u.jsx(ni,{description:"Make Ghost work with apps and tools.",title:"Integrations"}),u.jsx(J,{className:"mt-[-5px] inline-flex h-7 cursor-pointer items-center justify-center rounded px-3 font-semibold whitespace-nowrap text-grey-900 transition hover:bg-grey-200 dark:text-white dark:hover:bg-grey-900 [&:hover]:text-black",color:"clear",label:"Add custom integration",link:!0,onClick:()=>{i("integrations/new"),n("custom")}})]})]}),keywords:t,navid:"integrations",testId:"integrations",children:u.jsx(hr,{selectedTab:e,tabs:s,onTabChange:n})})},ZP=Ce(JP,"Integrations");function QP(t,e={}){window.plausible=window.plausible||function(){(window.plausible.q=window.plausible.q||[]).push(arguments)},window.plausible(t,{props:e})}const eR=pe.create(({title:t,prompt:e,okLabel:n,okRunningLabel:r="Enabling...",onConfirm:i})=>{const s=an(),[o,a]=W.useState(!1),l=()=>{s.remove()},c=async()=>{a(!0);try{await i()&&s.remove()}finally{a(!1)}};return u.jsx(Fr,{backDropClick:!1,buttonsDisabled:o,cancelLabel:"Cancel",okLabel:o?r:n,testId:"feature-toggle-confirmation-modal",title:t,width:540,onCancel:l,onOk:c,children:u.jsx("div",{className:"py-4",children:e})})}),Rs=({label:t,flag:e,disabled:n,confirmation:r})=>{const{settings:i}=ke(),s=JSON.parse(Xs(i,"labs")||"{}"),{mutateAsync:o}=ai(),a=Bl(),l=Ye(),c=!!s[e],d=async h=>{try{return await o([{key:"labs",value:JSON.stringify({...s,[e]:h})}]),QP("Feature Toggled",{state:h?"on":"off",feature:e}),a.setQueriesData([Sw],f=>({config:{...f.config,labs:{...f.config.labs,[e]:h}}})),!0}catch(f){return l(f),!1}};return u.jsx(en,{checked:c,disabled:n,label:t,labelClasses:"sr-only",name:`feature-${e}`,onChange:async()=>{const h=!c;if(r&&h){pe.show(eR,{...r,onConfirm:()=>d(h)});return}await d(h)}})},Wr=({title:t,detail:e,action:n})=>u.jsx(Wi,{action:n,bgOnHover:!1,detail:e,paddingRight:!1,title:t}),tR=Ot({method:"POST",path:()=>"/redirects/upload/",body:t=>{const e=new FormData;return e.append("redirects",t),e}}),nR=()=>Zd("/redirects/download/"),rR=Ot({method:"POST",path:()=>"/settings/routes/yaml/",body:t=>{const e=new FormData;return e.append("routes",t),e}}),iR=()=>Zd("/settings/routes/yaml/"),sR=()=>{const{settings:t}=ke(),{mutateAsync:e}=tR(),{mutateAsync:n}=rR(),r=Ye(),[i,s]=v.useState(!1),[o,a]=v.useState(!1),c=!!JSON.parse(Xs(t,"labs")||"{}").automations;return u.jsxs(is,{titleSeparator:!1,children:[u.jsx(Wr,{action:u.jsx(Rs,{confirmation:{title:"Automations (beta)",prompt:"This is a one-way street. Once enabled, the automations beta can't be turned off. Existing welcome emails will move into your automations automatically.",okLabel:"Enable",okRunningLabel:"Enabling..."},disabled:c,flag:"automations",label:"Automations (beta)"}),detail:u.jsxs(u.Fragment,{children:["Build automated email flows for your members, and get early access to new automation features as they ship. ",u.jsx("a",{className:"text-green",href:"https://ghost.org/help/automations-beta",rel:"noopener noreferrer",target:"_blank",children:"Learn more →"})]}),title:"Automations (beta)"}),u.jsx(Wr,{action:u.jsx(Rs,{flag:"superEditors"}),detail:u.jsx(u.Fragment,{children:"Allows newly-assigned editors to manage members and comments in addition to regular roles."}),title:"Enhanced Editor role (beta)"}),u.jsx(Wr,{action:u.jsx(Rs,{flag:"editorExcerpt"}),detail:u.jsx(u.Fragment,{children:"Adds the excerpt input below the post title in the editor"}),title:"Show post excerpt inline"}),u.jsx(Wr,{action:u.jsx(Rs,{flag:"additionalPaymentMethods"}),detail:u.jsxs(u.Fragment,{children:["Enable support for CashApp, iDEAL, Bancontact, and others. ",u.jsx("a",{className:"text-green",href:"https://ghost.org/help/payment-methods",rel:"noopener noreferrer",target:"_blank",children:"Learn more →"})]}),title:"Additional payment methods"}),u.jsx(Wr,{action:u.jsxs("div",{className:"flex flex-col items-end gap-1",children:[u.jsx(Ya,{id:"upload-redirects",onUpload:async d=>{try{s(!0),await e(d),rn({title:"Redirects uploaded",type:"success"})}catch(h){r(h)}finally{s(!1)}},children:u.jsx(J,{color:"grey",label:i?"Uploading ...":"Upload redirects file",size:"sm",tag:"div"})}),u.jsx(J,{color:"green",label:"Download current redirects",link:!0,onClick:()=>nR()})]}),detail:u.jsxs(u.Fragment,{children:["Configure redirects for old or moved content, ",u.jsx("br",{})," more info in the ",u.jsx("a",{className:"text-green",href:"https://ghost.org/tutorials/implementing-redirects/",rel:"noopener noreferrer",target:"_blank",children:"docs"})]}),title:"Redirects"}),u.jsx(Wr,{action:u.jsxs("div",{className:"flex flex-col items-end gap-1",children:[u.jsx(Ya,{id:"upload-routes",onUpload:async d=>{try{a(!0),await n(d),rn({type:"success",title:"Routes uploaded"})}catch(h){r(h)}finally{a(!1)}},children:u.jsx(J,{color:"grey",label:o?"Uploading ...":"Upload routes file",size:"sm",tag:"div"})}),u.jsx(J,{color:"green",label:"Download current routes",link:!0,onClick:()=>iR()})]}),detail:"Configure dynamic routing by modifying the routes.yaml file",title:"Routes"})]})},oR="data:image/svg+xml,%3csvg%20width='267'%20height='285'%20viewBox='0%200%20267%20285'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='165'%20cy='183'%20r='102'%20fill='%23F1F3F4'/%3e%3ccircle%20cx='68'%20cy='71'%20r='31'%20fill='%23F1F3F4'/%3e%3ccircle%20cx='99'%20cy='17'%20r='17'%20fill='%23F1F3F4'/%3e%3ccircle%20cx='118'%20cy='70'%20r='7'%20fill='%23F1F3F4'/%3e%3ccircle%20cx='45'%20cy='32'%20r='3'%20fill='%23F1F3F4'/%3e%3ccircle%20cx='12.5'%20cy='83.5'%20r='12.5'%20fill='%23F1F3F4'/%3e%3c/svg%3e",aR=Co(()=>import("./index-D5MrQBSe.js").then(t=>t.i),__vite__mapDeps([23,1,2,24]),import.meta.url);class ly extends Error{errorType;errorDetails;constructor({errorType:e,errorDetails:n,message:r}){super(r),this.errorType=e,this.errorDetails=n}}class lR extends ly{constructor(e){super(Object.assign({errorType:"IncorrectUsageError"},e))}}class Zo extends ly{constructor(e){super(Object.assign({errorType:"HostLimitError"},e))}}const fs=()=>{const{config:t}=ke(),[e,n]=v.useState(null);v.useEffect(()=>{aR.then(d=>n(()=>d.default))},[]);const{users:r,contributorUsers:i,invites:s,isLoading:o}=ff(),{refetch:a}=Wg({searchParams:{limit:"1"},enabled:!1}),{refetch:l}=$l({searchParams:{filter:"status:active",limit:"1"},enabled:!1}),c=v.useMemo(()=>t.hostSettings?.billing?.enabled===!0&&t.hostSettings?.billing?.url?t.hostSettings.billing.url:"https://ghost.org/help/",[t.hostSettings?.billing]);return v.useMemo(()=>{const d={isLimited:()=>!1,isDisabled:()=>!1,checkWouldGoOverLimit:()=>Promise.resolve(!1),errorIfWouldGoOverLimit:()=>Promise.resolve(),errorIfIsOverLimit:()=>Promise.resolve()};if(!e||!t.hostSettings?.limits||o)return d;const h={...t.hostSettings.limits},f=new e;return h.staff&&(h.staff.currentCountQuery=async()=>{const m=r.filter(g=>g.status!=="inactive"&&!i.includes(g)),p=s.filter(g=>g.role!=="Contributor");return m.length+p.length}),h.members&&(h.members.currentCountQuery=async()=>{const{data:m}=await a();return m?.meta?.pagination?.total||0}),h.newsletters&&(h.newsletters.currentCountQuery=async()=>{const{data:{pages:m}={pages:[]}}=await l();return m[0].meta?.pagination.total||0}),f.loadLimits({limits:h,helpLink:c,errors:{HostLimitError:Zo,IncorrectUsageError:lR}}),{isLimited:m=>f.isLimited(m),isDisabled:m=>f.isDisabled(m),checkWouldGoOverLimit:m=>f.checkWouldGoOverLimit(m),errorIfWouldGoOverLimit:(m,p={})=>f.errorIfWouldGoOverLimit(m,p),errorIfIsOverLimit:m=>f.errorIfIsOverLimit(m)}},[e,t,i,a,l,c,s,o,r])},cR=[{title:"Automations",description:"Enable automations management interface.",flag:"automations"},{title:"Stripe Automatic Tax (private beta)",description:"Use Stripe Automatic Tax at Stripe Checkout. Needs to be enabled in Stripe",flag:"stripeAutomaticTax"},{title:"Email customization (internal beta)",description:"Newsletter customization settings that have been released to Ghost's own production sites",flag:"emailCustomization"},{title:"Import Member Tier",description:"Enables tier to be specified when importing members",flag:"importMemberTier"},{title:"CSV Content Importer",description:"Enables importing posts from CSV files in the Universal Importer",flag:"csvContentImporter"},{title:"Admin UI Refresh",description:"Enable Admin UI refresh (exploration)",flag:"adminUIRefresh"},{title:"Explore",description:"Enables keeping in touch with the new Explore API",flag:"explore"},{title:"Tags X",description:"Enables the new Tags UI",flag:"tagsX"},{title:"Email Unique ID",description:"Enables {uniqueid} variable in emails for unique image URLs to bypass ESP image caching",flag:"emailUniqueid"},{title:"Updated theme translation (beta)",description:"Enable theme translation using i18next instead of the old translation package.",flag:"themeTranslation"},{title:"Featurebase Feedback",description:"Display a Feedback menu item in the admin sidebar. Requires the new admin experience.",flag:"featurebaseFeedback"},{title:"Picture Element",description:"Use the HTML picture element to serve modern image formats (AVIF, WebP) with automatic fallbacks",flag:"pictureImageFormats"},{title:"Smarter Counts",description:"Use optimized COUNT queries for API pagination when safe",flag:"smarterCounts"},{title:"LLMs.txt",description:"Serve llms.txt, per-entry markdown exports, and Accept: text/markdown content negotiation for AI and LLM tooling",flag:"llmsTxt"},{title:"Get helper deduplication",description:"Deduplicate identical {{#get}} helper queries within a single request to avoid redundant database calls",flag:"getHelperDeduplication"},{title:"Gift links",description:"Tokenized links that let anyone read a single gated post or page in full, no account required",flag:"giftLinks"}],uR=()=>{const t=fs(),[e,n]=v.useState([]);return v.useEffect(()=>{(async()=>{const i=[];for(const s of cR)if(s.limitName&&t?.isLimited(s.limitName))try{await t.errorIfWouldGoOverLimit(s.limitName),i.push(s)}catch(o){o instanceof Zo||i.push(s)}else i.push(s);n(i)})()},[t]),u.jsx(is,{titleSeparator:!1,children:e.map(r=>u.jsx(Wr,{action:u.jsx(Rs,{flag:r.flag,label:r.title}),detail:r.description,title:r.title},r.flag))})};function dR(t){const[e,n]=v.useState(!1),r=v.useRef(!1),{filter:i,getVisibleComponents:s,checkVisible:o}=Jo();return v.useEffect(()=>{i||(r.current=!1)},[i]),v.useEffect(()=>{if(r.current)return;const c=o(t),d=s(),h=!!i&&c&&d.size===1;n(h)},[i,t,o,s]),{isOpen:e,openManually:()=>{r.current=!0,n(!0)},closeManually:()=>{r.current=!0,n(!1)}}}const hR=({keywords:t})=>{const[e,n]=v.useState("labs-beta-features"),{config:r}=ke(),{isOpen:i,openManually:s,closeManually:o}=dR(t),a=[{id:"labs-beta-features",title:"Beta features",contents:u.jsx(sR,{})},r.enableDeveloperExperiments&&{id:"labs-private-features",title:"Private features",contents:u.jsx(uR,{})}].filter(Boolean);return u.jsx(Se,{customHeader:u.jsxs("div",{className:"z-10 flex items-start justify-between",children:[u.jsx(ni,{description:"This is a testing ground for new or experimental features. They may change, break or inexplicably disappear at any time.",title:"Labs"}),u.jsx(J,{className:"mt-[-5px]",color:i?"grey":"clear",label:i?"Close":"Open",size:"sm",onClick:i?o:s})]}),isEditing:i,keywords:t,navid:"labs",testId:"labs",children:i?u.jsx(hr,{selectedTab:e,tabs:a,onTabChange:n}):u.jsx("div",{className:"absolute inset-0 z-0 overflow-hidden opacity-70",children:u.jsx("img",{className:"absolute -top-6 -right-6 dark:opacity-10",src:oR})})})},fR=Ce(hR,"Labs"),mR=()=>{const[t,e]=W.useState(!1),n=Ye(),r=async()=>{if(!t){e(!0);try{await Cw("/posts/export/?limit=1000","posts.analytics.csv")}catch(i){n(i)}finally{e(!1)}}};return u.jsxs("div",{className:"grid grid-cols-1 gap-4 pt-4 md:grid-cols-2 lg:grid-cols-3",children:[u.jsx(J,{className:"h-9! font-semibold!",color:"grey",icon:"export",iconColorClass:"h-4! w-auto!",label:"Content & settings",onClick:()=>$P()}),u.jsx(J,{className:"h-9! font-semibold!",color:"grey",disabled:t,icon:"baseline-chart",iconColorClass:"h-4! w-auto!",label:"Post analytics",loading:t,testId:"post-analytics-export-button",onClick:r})]})},pR=()=>{const t=an(),{mutateAsync:e}=VP(),[n,r]=v.useState(!1),i=Ye();return u.jsx(Fr,{backDropClick:!1,footer:u.jsxs("div",{className:"flex w-full items-center justify-between p-8",children:[u.jsx(no,{href:"https://docs.ghost.org/migration/ghost",target:"_blank",children:"Learn about importing"}),u.jsx(J,{color:"outline",disabled:n,label:"Cancel",onClick:()=>t.remove()})]}),okLabel:"",size:"sm",testId:"universal-import-modal",title:"Universal import",children:u.jsx("div",{className:"py-4",children:u.jsx(Ya,{accept:"application/json, application/zip",id:"import-file",onUpload:async s=>{r(!0);try{await e(s),t.remove(),pe.show(Wt,{title:"Import in progress",prompt:"Your import is being processed, and you'll receive a confirmation email as soon as it’s complete. Usually this only takes a few minutes, but larger imports may take longer.",cancelLabel:"",okLabel:"Got it",onOk:o=>o?.remove(),formSheet:!1})}catch(o){i(o)}finally{r(!1)}},children:u.jsx("div",{className:"-mb-4 cursor-pointer bg-grey-50 p-10 text-center dark:bg-grey-950",children:n?"Uploading...":u.jsxs(u.Fragment,{children:["Select any JSON or zip file that contains ",u.jsx("br",{}),"posts and settings"]})})})})})},gR=pe.create(pR),$r=({icon:t,title:e,onClick:n})=>{const r=R("flex h-9 cursor-pointer items-center justify-center gap-2 rounded-md bg-grey-100 px-2 font-semibold transition-all hover:bg-grey-200 dark:bg-grey-900");return n?u.jsxs("button",{className:r,type:"button",onClick:n,children:[t,e]}):u.jsx(u.Fragment,{})},bR=()=>{const{updateRoute:t}=fe(),e=()=>{pe.show(gR)};return u.jsxs("div",{className:"grid grid-cols-1 gap-4 pt-4 md:grid-cols-2 lg:grid-cols-3",children:[u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"substack",size:18}),title:"Substack",onClick:()=>t({isExternal:!0,route:"/migrate/substack"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"beehiiv",size:18}),title:"beehiiv",onClick:()=>t({isExternal:!0,route:"/migrate/beehiiv"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"wordpress",size:18}),title:"WordPress",onClick:()=>t({isExternal:!0,route:"/migrate/wordpress"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"squarespace",size:18}),title:"Squarespace",onClick:()=>t({isExternal:!0,route:"/migrate/squarespace"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto dark:invert",name:"medium",size:18}),title:"Medium",onClick:()=>t({isExternal:!0,route:"/migrate/medium"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"mailchimp",size:20}),title:"Mailchimp",onClick:()=>t({isExternal:!0,route:"/migrate/mailchimp"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"import",size:16}),title:"Universal import",onClick:e})]})},vR=({keywords:t})=>{const[e,n]=v.useState("import"),r=[{id:"import",title:"Import",contents:u.jsx(bR,{})},{id:"export",title:"Export",contents:u.jsx(mR,{})}].filter(Boolean);return u.jsx(Se,{customHeader:u.jsx(ni,{description:"Import content, members and subscriptions from other platforms or export your Ghost data.",title:"Migration tools"}),keywords:t,navid:"migration",testId:"migrationtools",children:u.jsx(hr,{selectedTab:e,tabs:r,onTabChange:n})})},xR=Ce(vR,"Migration tools"),ui=({keywords:t,...e})=>{const{checkVisible:n,noResult:r}=Jo();return u.jsx(oE,{isVisible:n(t)||r,...e})},Pt={integrations:["advanced","integrations","zapier","slack","unsplash","first promoter","firstpromoter","pintura","disqus","analytics","ulysses","typeform","buffer","plausible","github","webhooks"],migrationtools:["import","export","migrate","substack","substack","migration","medium","wordpress","wp","squarespace","beehiiv"],codeInjection:["advanced","code injection","head","footer"],labs:["advanced","labs","alpha","private","beta","flag","routes","redirect","translation","editor","portal"],history:["advanced","history","log","events","user events","staff","audit","action"],dangerzone:["danger zone","delete all content","delete site","reset all authentication","reset api keys","reset password","compromised credentials","lock staff users","sign out all staff"]},yR=()=>u.jsxs(ui,{keywords:Object.values(Pt).flat(),title:"Advanced",children:[u.jsx(ZP,{keywords:Pt.integrations}),u.jsx(xR,{keywords:Pt.migrationtools}),u.jsx(OP,{keywords:Pt.codeInjection}),u.jsx(fR,{keywords:Pt.labs}),u.jsx(GP,{keywords:Pt.history}),u.jsx(WP,{keywords:Pt.dangerzone})]});function yg(t){const e=new Date,n={timeZone:t},r=navigator.language.startsWith("en")?navigator.language:"en-US";return e.toLocaleString(r,n)}function cy(t=""){let e=new RegExp(/([A-Za-z\u00C0-\u017F]{1})[A-Za-z\u00C0-\u017F]+/,"g"),n=[...t.matchAll(e)];return((n.shift()?.[1]||"")+(n.pop()?.[1]||"")).toUpperCase()}function mf(t){let r=0;for(let s=0;s<t.length;s++)r=t.charCodeAt(s)+((r<<5)-r);return"hsl("+r%360+", 70%, 40%)"}function So(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function wR(t){return/^[a-z0-9]{24}$/.test(t)}const kR=[{label:"Free members",value:"status:free",color:"green"},{label:"Paid members",value:"status:-free",color:"pink"}],SR=(t,e)=>{const n=Sc({path:"/tiers/",filterKey:"name",responseKey:"tiers"}),r=Sc({path:"/labels/",filterKey:"name",responseKey:"labels"}),i=Sc({path:"/offers/",filterKey:"name",responseKey:"offers"}),[s,o]=v.useState(null),a=f=>({value:f.id,label:f.name,color:"black"}),l=f=>({value:`label:${f.slug}`,label:f.name,color:"grey"}),c=f=>({value:`offer_redemptions:${f.id}`,label:f.name,color:"black"}),d=async(f,m)=>{const[p,g,b]=await Promise.all([n.loadData(f),r.loadData(f),i.loadData(f)]),x=[{options:kR.filter(({label:y})=>y.toLowerCase().includes(f.toLowerCase()))},{label:"Active Tiers",options:p.filter(({active:y,type:w})=>y&&w!=="free").map(a)||[]},{label:"Archived Tiers",options:p.filter(({active:y})=>!y).map(a)||[]},{label:"Labels",options:g.map(l)||[]},{label:"Offers",options:b.map(c)||[]}];s===null&&h(),m(x.filter(y=>y.options.length>0))},h=async()=>{const f=e?.split(",")||[],m=[],p=[],g=[];for(const x of f)x.startsWith("label:")?p.push(x.replace("label:","")):x.startsWith("offer_redemptions:")?g.push(x.replace("offer_redemptions:","")):wR(x)&&m.push(x);const b=await Promise.all([n.loadInitialValues(m,"id").then(x=>x.map(a)),r.loadInitialValues(p,"slug").then(x=>x.map(l)),i.loadInitialValues(g,"id").then(x=>x.map(c))]).then(x=>x.flat());o(f.map(x=>b.find(y=>y.value===x)))};return v.useEffect(()=>{t==="segment"&&d("",()=>{})},[t]),{loadOptions:A2(d,500),selectedSegments:s,setSelectedSegments:o}},wg=[{label:"Whoever has access to the post",hint:"Free posts to everyone, premium posts sent to paid members",value:"visibility"},{label:"All members",hint:"Everyone who is subscribed to newsletter updates, whether free or paid members",value:"all-members"},{label:"Paid-members only",hint:"People who have a premium subscription",value:"paid-only"},{label:"Specific people",hint:"Only people with any of the selected tiers or labels",value:"segment"},{label:"Usually nobody",hint:"Newsletters are off for new posts, but can be enabled when needed",value:"none"}];function kg({defaultEmailRecipients:t,defaultEmailRecipientsFilter:e}){return t==="filter"?e==="status:free,status:-free"?"all-members":e==="status:-free"?"paid-only":e===null?"none":"segment":t}const CR=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,handleEditingChange:a}=Ft(),[l,c]=we(e,["editor_default_email_recipients","editor_default_email_recipients_filter"]),[d,h]=v.useState(kg({defaultEmailRecipients:l,defaultEmailRecipientsFilter:c})),{loadOptions:f,selectedSegments:m,setSelectedSegments:p}=SR(d,c);v.useEffect(()=>{const x=kg({defaultEmailRecipients:l,defaultEmailRecipientsFilter:c});h(x)},[l,c]);const g=x=>{["visibility","disabled"].includes(x)?(o("editor_default_email_recipients",x),o("editor_default_email_recipients_filter",null)):o("editor_default_email_recipients","filter"),x==="all-members"&&o("editor_default_email_recipients_filter","status:free,status:-free"),x==="paid-only"&&o("editor_default_email_recipients_filter","status:-free"),x==="none"&&o("editor_default_email_recipients_filter",null),h(x),n||a(!0)},b=x=>{if(p(x),x.length){const y=x?.map(({value:w})=>w).join(",");o("editor_default_email_recipients_filter",y)}else o("editor_default_email_recipients_filter",null),h("none");n||a(!0)};return u.jsx(Se,{description:"When you publish new content, who do you usually want to send it to?",isEditing:n,keywords:t,navid:"default-recipients",saveState:r,testId:"default-recipients",title:"Default recipients",hideEditButton:!0,onCancel:s,onEditingChange:a,onSave:i,children:u.jsxs(tt,{columns:1,children:[u.jsx(ir,{hint:"Who should receive your posts by default?",options:wg,selectedOption:wg.find(x=>x.value===d),testId:"default-recipients-select",title:"Default Newsletter recipients",onSelect:x=>{x&&g(x.value)}}),d==="segment"&&m&&u.jsx(nb,{loadOptions:f,title:"Filter",values:m,async:!0,defaultOptions:!0,onChange:b})]})})},uy=Ce(CR,"Default recipients"),AR=({keywords:t})=>{const{settings:e}=ke(),{mutateAsync:n}=ai(),{updateRoute:r}=fe(),i=Ye(),[s,o]=we(e,["editor_default_email_recipients","members_signup_access"]),a=o==="none",l=async d=>{const h=[{key:"editor_default_email_recipients",value:d.target.checked?"visibility":"disabled"}];d.target.checked||h.push({key:"editor_default_email_recipients_filter",value:null});try{await n(h)}catch(f){i(f)}},c=u.jsx(u.Fragment,{children:u.jsx(en,{checked:s!=="disabled"&&!a,direction:"rtl",disabled:a,onChange:l})});return u.jsx(Se,{customButtons:c,description:"Newsletter features are active, posts can be sent by email",keywords:t,navid:"enable-newsletters",testId:"enable-newsletters",title:"Newsletter sending",children:u.jsx(tt,{columns:1,values:[{key:"private",value:s!=="disabled"&&!a?u.jsx("div",{className:"w-full",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(me,{colorClass:"text-green",name:"check",size:"sm"}),u.jsx("span",{children:"Enabled"})]})}):u.jsxs("div",{className:"w-full",children:[u.jsxs("div",{className:"flex items-center gap-2 text-grey-900",children:[u.jsx(me,{colorClass:"text-grey-600",name:"mail-block",size:"sm"}),u.jsx("span",{children:"Disabled"})]}),a&&u.jsxs(h0,{className:"mt-6",color:"grey",children:["Your ",u.jsx("button",{className:"underline!",type:"button",onClick:()=>{r("members")},children:"Subscription access"})," is set to ‘Nobody’, which disables all newsletter sending. Change to ‘Invite-only’ to send newsletters to existing members without allowing new signups."]})]})}]})})},dy=Ce(AR,"Newsletter sending"),bu=[{label:"🇺🇸 US",value:"https://api.mailgun.net/v3"},{label:"🇪🇺 EU",value:"https://api.eu.mailgun.net/v3"}],MR=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,handleEditingChange:a}=Ft(),{mutateAsync:l}=ai(),c=Ye(),[d,h,f]=we(e,["mailgun_base_url","mailgun_domain","mailgun_api_key"]),p=h&&f?[{key:"status",value:u.jsx(Z5,{icon:"check-circle",iconColorClass:"text-green",children:"Mailgun is set up"})}]:[{heading:"Status",key:"status",value:"Mailgun is not set up"}],g=u.jsx(tt,{columns:1,values:p}),b=u.jsxs(u.Fragment,{children:["Find your Mailgun API keys ",u.jsx(no,{href:"https://app.mailgun.com/settings/api_security",rel:"noopener noreferrer",target:"_blank",children:"here"})]}),x=u.jsx(tt,{children:u.jsxs("div",{className:"grid grid-cols-[120px_auto] gap-x-3 gap-y-6",children:[u.jsx(ir,{options:bu,selectedOption:bu.find(w=>w.value===d),title:"Mailgun region",onSelect:w=>{o("mailgun_base_url",w?.value||null)}}),u.jsx(at,{title:"Mailgun domain",value:h,onChange:w=>{o("mailgun_domain",w.target.value)}}),u.jsx("div",{className:"col-span-2",children:u.jsx(at,{hint:b,title:"Mailgun private API key",type:"password",value:f,onChange:w=>{o("mailgun_api_key",w.target.value)}})})]})}),y=u.jsxs(u.Fragment,{children:["The Mailgun API is used for bulk email newsletter delivery. ",u.jsx(no,{href:"https://ghost.org/docs/faq/mailgun-newsletters/",target:"_blank",children:"Why is this required?"})]});return u.jsx(Se,{description:y,isEditing:n,keywords:t,navid:"mailgun",saveState:r,testId:"mailgun",title:"Mailgun",onCancel:s,onEditingChange:a,onSave:async()=>{if(!d)try{await l([{key:"mailgun_base_url",value:bu[0].value}])}catch(w){c(w);return}i()},children:n?x:g})},hy=Ce(MR,"Mailgun"),Sg=({id:t,setRef:e,isDragging:n,style:r,children:i,separator:s,...o})=>{const{updateRoute:a}=fe(),l=()=>{a({route:`newsletters/${t}`})},c=u.jsxs(ls,{ref:e,action:u.jsx(J,{color:"green","data-testid":"edit-newsletter-button",label:"Edit",link:!0,onClick:l}),className:n?"opacity-75":"",hideActions:!1,style:r,onClick:l,children:[(o.dragHandleAttributes||n)&&u.jsx($n,{className:"w-10 align-middle!",children:u.jsx(Ob,{className:"h-10",isDragging:n||!1,...o})}),i]});return n?u.jsx(Mr,{children:c}):c},Cg=({newsletter:t})=>{const{updateRoute:e}=fe(),n=()=>{e({route:`newsletters/${t.id}`})};return u.jsxs(u.Fragment,{children:[u.jsx($n,{className:"w-full",onClick:n,children:u.jsxs("div",{className:"flex grow flex-col",children:[u.jsx("span",{className:"font-medium",children:t.name}),u.jsx("span",{className:"mt-0.5 text-sm leading-tight text-grey-700",children:t.description||"No description"})]})}),u.jsx($n,{className:"hidden md:visible! md:table-cell! md:min-w-[11rem]",onClick:n,children:u.jsxs("div",{className:"flex grow flex-col",children:[u.jsx("span",{children:Tf(t.count?.active_members||0)}),u.jsx("span",{className:"mt-0.5 text-sm leading-tight whitespace-nowrap text-grey-700",children:"Subscribers"})]})}),u.jsx($n,{className:"hidden md:visible! md:table-cell! md:min-w-[11rem]",onClick:n,children:u.jsxs("div",{className:"flex grow flex-col",children:[u.jsx("span",{children:Tf(t.count?.posts||0)}),u.jsx("span",{className:"mt-0.5 text-sm leading-tight whitespace-nowrap text-grey-700",children:"Delivered"})]})})]})},Rl=({newsletters:t,isLoading:e,isSortable:n,onSort:r})=>e?u.jsx(Mr,{isLoading:!0}):t.length&&n?u.jsx(ZM,{container:i=>u.jsx(Sg,{...i}),items:t,renderItem:i=>u.jsx(Cg,{newsletter:i}),wrapper:Mr,onMove:(i,s)=>r?.(i,s)}):t.length?u.jsx(Mr,{children:t.map(i=>u.jsx(Sg,{id:i.id,children:u.jsx(Cg,{newsletter:i})}))}):u.jsx(li,{icon:"mail-block",children:"No newsletters found."}),Qo=()=>{const[t,e]=v.useState(new URLSearchParams);return v.useEffect(()=>{const r=()=>{const s=window.location.hash.split("?")[1];e(s?new URLSearchParams(s):new URLSearchParams)};return r(),window.addEventListener("hashchange",r),()=>{window.removeEventListener("hashchange",r)}},[]),{getParam:r=>t.get(r)}},vu=({id:t,children:e})=>{const n=an(),{updateRoute:r}=fe();return u.jsx("button",{className:"text-green",type:"button",onClick:()=>{r(`newsletters/${t}`),n.remove()},children:e})},ER=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("newsletters/new")},[r,i]=v.useState("active-newsletters"),{data:{newsletters:s,meta:o,isEnd:a}={},isLoading:l,fetchNextPage:c}=$l(),{mutateAsync:d}=Zg(),h=Bl(),f=Qo().getParam("verifyEmail"),{mutateAsync:m}=Qg(),p=Ye(),[g,b]=v.useState(s||[]);v.useEffect(()=>{b(s||[])},[s]),v.useEffect(()=>{if(!f||!window.location.href.includes("newsletters"))return;(async()=>{try{const{newsletters:[A],meta:{email_verified:M}={}}=await m({token:f});let E,j;M&&M==="sender_email"?(E="Newsletter email verified",j=u.jsxs(u.Fragment,{children:["Newsletter ",u.jsx(vu,{id:A.id,children:A.name})," will now be sent from ",u.jsx("strong",{children:A.sender_email}),"."]})):M&&M==="sender_reply_to"?(E="Reply-to address verified",j=u.jsxs(u.Fragment,{children:["Newsletter ",u.jsx(vu,{id:A.id,children:A.name})," will now use ",u.jsx("strong",{children:A.sender_reply_to})," as the reply-to address."]})):(E="Email address verified",j=u.jsxs(u.Fragment,{children:["Email address for newsletter ",u.jsx(vu,{id:A.id,children:A.name})," has been changed."]})),pe.show(Wt,{title:E,prompt:j,okLabel:"Close",cancelLabel:"",onOk:T=>T?.remove()})}catch(A){let M="There was an error verifying your email address. Try again later.";A instanceof Vl&&A.message==="Token expired"&&(M="Verification link has expired."),pe.show(Wt,{title:"Error verifying email address",prompt:M,okLabel:"Close",cancelLabel:"",onOk:E=>E?.remove()}),p(A,{withToast:!1})}})()},[f,p,m]);const x=u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Add newsletter",size:"sm",onClick:()=>{n()}}),y=g.filter(S=>S.status==="active").sort((S,A)=>S.sort_order-A.sort_order)||[],w=g.filter(S=>S.status!=="active"),k=async(S,A)=>{const M=y.findIndex(O=>O.id===S),E=y.findIndex(O=>O.id===A)||0,T=sc(y,M,E).map((O,L)=>O.sort_order===L?null:{...O,sort_order:L}).filter(O=>!!O),N=w.map((O,L)=>O.sort_order===L+y.length?null:{...O,sort_order:L}).filter(O=>!!O),D=[...T,...N].sort((O,L)=>O.sort_order-L.sort_order);b(g.map(O=>D.find(L=>L.id===O.id)||O)),h.setQueriesData([e0],O=>{if(O)return{...O,pages:O.pages.map(L=>({...L,newsletters:L.newsletters.map($=>D.find(U=>U.id===$.id)||$)}))}});for(const O of D)await d(O)},C=[{id:"active-newsletters",title:"Active",contents:u.jsx(Rl,{isLoading:l,newsletters:y,isSortable:!0,onSort:k})},{id:"archived-newsletters",title:"Archived",contents:u.jsx(Rl,{isLoading:l,newsletters:w})}];return u.jsxs(Se,{customButtons:x,description:"Edit details and customize your design",keywords:t,navid:"newsletters",testId:"newsletters",title:"Newsletters",children:[u.jsx(hr,{selectedTab:r,tabs:C,onTabChange:i}),a===!1&&u.jsx(J,{label:`Load more (showing ${g?.length||0}/${o?.pagination.total||0} newsletters)`,link:!0,onClick:()=>c()})]})},jR=Ce(ER,"Newsletters"),Rn={enableNewsletters:["emails","newsletters","newsletter sending","enable","disable","turn on","turn off"],newsletters:["newsletters","emails","design","customization"],defaultRecipients:["newsletters","default recipients","emails"],mailgun:["mailgun","emails","newsletters"]},NR=()=>{const{settings:t,config:e}=ke(),[n]=we(t,["editor_default_email_recipients"]),r=n!=="disabled",i=r&&!e.mailgunIsConfigured,s=[Rn.enableNewsletters,...r?[Rn.defaultRecipients,Rn.newsletters]:[],...i?[Rn.mailgun]:[]].flat();return u.jsxs(ui,{keywords:s,title:"Newsletters",children:[u.jsx(dy,{keywords:Rn.enableNewsletters}),r&&u.jsxs(u.Fragment,{children:[u.jsx(uy,{keywords:Rn.defaultRecipients}),u.jsx(jR,{keywords:Rn.newsletters}),i&&u.jsx(hy,{keywords:Rn.mailgun})]})]})},xu=({id:t,children:e})=>{const n=an(),{updateRoute:r}=fe();return u.jsx("button",{className:"text-green",type:"button",onClick:()=>{r(`newsletters/${t}`),n.remove()},children:e})},TR=()=>{const t=window.location.hash.slice(1),e=new URL(t||"/",window.location.origin).pathname;return e.startsWith("/settings/emails")||e.startsWith("/settings/newsletters")},DR=({filter:t})=>{const{data:{newsletters:e,meta:n,isEnd:r}={},isLoading:i,fetchNextPage:s}=$l(),{mutateAsync:o}=Zg(),a=Bl(),l=Qo().getParam("verifyEmail"),{mutateAsync:c}=Qg(),d=Ye(),[h,f]=v.useState(e||[]);v.useEffect(()=>{f(e||[])},[e]),v.useEffect(()=>{if(!l||!TR())return;(async()=>{try{const{newsletters:[y],meta:{email_verified:w}={}}=await c({token:l});let k,C;w&&w==="sender_email"?(k="Newsletter email verified",C=u.jsxs(u.Fragment,{children:["Newsletter ",u.jsx(xu,{id:y.id,children:y.name})," will now be sent from ",u.jsx("strong",{children:y.sender_email}),"."]})):w&&w==="sender_reply_to"?(k="Reply-to address verified",C=u.jsxs(u.Fragment,{children:["Newsletter ",u.jsx(xu,{id:y.id,children:y.name})," will now use ",u.jsx("strong",{children:y.sender_reply_to})," as the reply-to address."]})):(k="Email address verified",C=u.jsxs(u.Fragment,{children:["Email address for newsletter ",u.jsx(xu,{id:y.id,children:y.name})," has been changed."]})),pe.show(Wt,{title:k,prompt:C,okLabel:"Close",cancelLabel:"",onOk:S=>S?.remove()})}catch(y){let w="There was an error verifying your email address. Try again later.";y instanceof Vl&&y.message==="Token expired"&&(w="Verification link has expired."),pe.show(Wt,{title:"Error verifying email address",prompt:w,okLabel:"Close",cancelLabel:"",onOk:k=>k?.remove()}),d(y,{withToast:!1})}})()},[l,d,c]);const m=h.filter(x=>x.status==="active").sort((x,y)=>x.sort_order-y.sort_order)||[],p=h.filter(x=>x.status!=="active"),g=async(x,y)=>{const w=m.findIndex(E=>E.id===x),k=m.findIndex(E=>E.id===y)||0,S=sc(m,w,k).map((E,j)=>E.sort_order===j?null:{...E,sort_order:j}).filter(E=>!!E),A=p.map((E,j)=>E.sort_order===j+m.length?null:{...E,sort_order:j}).filter(E=>!!E),M=[...S,...A].sort((E,j)=>E.sort_order-j.sort_order);f(h.map(E=>M.find(j=>j.id===E.id)||E)),a.setQueriesData([e0],E=>{if(E)return{...E,pages:E.pages.map(j=>({...j,newsletters:j.newsletters.map(T=>M.find(N=>N.id===T.id)||T)}))}});for(const E of M)await o(E)},b=t==="active";return u.jsxs(u.Fragment,{children:[b?u.jsx(Rl,{isLoading:i,isSortable:!0,newsletters:m,onSort:g}):u.jsx(Rl,{isLoading:i,newsletters:p}),r===!1&&u.jsx(J,{label:`Load more (showing ${h?.length||0}/${n?.pagination.total||0} newsletters)`,link:!0,onClick:()=>s()})]})},OR=Ce(DR,"Newsletters"),IR=({title:t="Are you sure you want to leave this page?",description:e=u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{children:"Hey there! It looks like you didn't save the changes you made."}),u.jsx("p",{children:"Save before you go!"})]})})=>{const n=an(),r=v.useRef(n.visible),i=v.useRef(!1);return v.useEffect(()=>{r.current&&!n.visible&&(n.resolveHide(),n.remove()),r.current=n.visible},[n]),u.jsx(Aw,{open:n.visible,onOpenChange:s=>{s||(n.resolve(i.current),i.current=!1,n.hide())},children:u.jsxs(Mw,{"data-testid":"welcome-email-dirty-confirm-modal",onEscapeKeyDown:s=>{s.stopPropagation()},children:[u.jsxs(Ew,{children:[u.jsx(jw,{children:t}),u.jsx(Nw,{asChild:!0,children:e})]}),u.jsxs(Tw,{children:[u.jsx(Dw,{asChild:!0,children:u.jsx(Nr,{variant:"outline",children:"Stay"})}),u.jsx(Ow,{asChild:!0,children:u.jsx(Nr,{variant:"destructive",onClick:()=>{i.current=!0},children:"Leave"})})]})]})})},PR=pe.create(IR),RR=({open:t,title:e,preview:n,sidebar:r,dirty:i=!1,isLoading:s=!1,okProps:o,onSave:a,onClose:l,afterClose:c,testId:d})=>{const h=v.useRef(a),f=v.useRef(t);v.useEffect(()=>{h.current=a},[a]),v.useEffect(()=>{f.current&&!t&&c?.(),f.current=t},[c,t]),v.useEffect(()=>{const p=g=>{(g.metaKey||g.ctrlKey)&&g.key==="s"&&(g.preventDefault(),h.current())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[]);const m=async()=>{if(!i){l();return}await pe.show(PR)&&l()};return u.jsx(Iw,{open:t,onOpenChange:p=>{p||m()},children:u.jsx(Pw,{className:Le("top-[50%] left-[50%] h-[calc(100vh-8vmin)] w-[calc(100vw-8vmin)] max-w-none translate-x-[-50%] translate-y-[-50%] gap-0 overflow-hidden p-0"),"data-testid":d,onEscapeKeyDown:p=>{p.preventDefault(),p.stopPropagation(),m()},children:u.jsxs("div",{className:"flex h-full min-h-0",children:[u.jsx("div",{className:"hidden min-h-0 flex-1 flex-col bg-gray-50 dark:bg-black [@media(min-width:801px)]:flex",children:u.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-8",children:n})}),u.jsxs("div",{className:"flex min-h-0 w-full flex-col border-l border-gray-200 dark:border-gray-900 [@media(min-width:801px)]:w-[400px] [@media(min-width:801px)]:shrink-0",children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-5",children:[u.jsx(Rw,{children:e}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Nr,{variant:"outline",onClick:()=>m(),children:"Close"}),u.jsx(Nr,{className:o?.color==="green"?"bg-green text-white hover:bg-green/90":void 0,disabled:s||o?.disabled,variant:o?.color==="red"?"destructive":"default",onClick:a,children:o?.label||"Save"})]})]}),r]})]})})})};function pf(t,e){return e={exports:{}},t(e,e.exports),e.exports}var js={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]},LR=function(e){return!e||typeof e=="string"?!1:e instanceof Array||Array.isArray(e)||e.length>=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&e.constructor.name!=="String")},Ns=pf(function(t){var e=Array.prototype.concat,n=Array.prototype.slice,r=t.exports=function(s){for(var o=[],a=0,l=s.length;a<l;a++){var c=s[a];LR(c)?o=e.call(o,n.call(c)):o.push(c)}return o};r.wrap=function(i){return function(){return i(r(arguments))}}}),Zr=pf(function(t){var e=Object.hasOwnProperty,n=Object.create(null);for(var r in js)e.call(js,r)&&(n[js[r]]=r);var i=t.exports={to:{},get:{}};i.get=function(a){var l=a.substring(0,3).toLowerCase(),c,d;switch(l){case"hsl":c=i.get.hsl(a),d="hsl";break;case"hwb":c=i.get.hwb(a),d="hwb";break;default:c=i.get.rgb(a),d="rgb";break}return c?{model:d,value:c}:null},i.get.rgb=function(a){if(!a)return null;var l=/^#([a-f0-9]{3,4})$/i,c=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,d=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,h=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,f=/^(\w+)$/,m=[0,0,0,1],p,g,b;if(p=a.match(c)){for(b=p[2],p=p[1],g=0;g<3;g++){var x=g*2;m[g]=parseInt(p.slice(x,x+2),16)}b&&(m[3]=parseInt(b,16)/255)}else if(p=a.match(l)){for(p=p[1],b=p[3],g=0;g<3;g++)m[g]=parseInt(p[g]+p[g],16);b&&(m[3]=parseInt(b+b,16)/255)}else if(p=a.match(d)){for(g=0;g<3;g++)m[g]=parseInt(p[g+1],0);p[4]&&(p[5]?m[3]=parseFloat(p[4])*.01:m[3]=parseFloat(p[4]))}else if(p=a.match(h)){for(g=0;g<3;g++)m[g]=Math.round(parseFloat(p[g+1])*2.55);p[4]&&(p[5]?m[3]=parseFloat(p[4])*.01:m[3]=parseFloat(p[4]))}else return(p=a.match(f))?p[1]==="transparent"?[0,0,0,0]:e.call(js,p[1])?(m=js[p[1]],m[3]=1,m):null:null;for(g=0;g<3;g++)m[g]=s(m[g],0,255);return m[3]=s(m[3],0,1),m},i.get.hsl=function(a){if(!a)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*)?\)$/,c=a.match(l);if(c){var d=parseFloat(c[4]),h=(parseFloat(c[1])%360+360)%360,f=s(parseFloat(c[2]),0,100),m=s(parseFloat(c[3]),0,100),p=s(isNaN(d)?1:d,0,1);return[h,f,m,p]}return null},i.get.hwb=function(a){if(!a)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*)?\)$/,c=a.match(l);if(c){var d=parseFloat(c[4]),h=(parseFloat(c[1])%360+360)%360,f=s(parseFloat(c[2]),0,100),m=s(parseFloat(c[3]),0,100),p=s(isNaN(d)?1:d,0,1);return[h,f,m,p]}return null},i.to.hex=function(){var a=Ns(arguments);return"#"+o(a[0])+o(a[1])+o(a[2])+(a[3]<1?o(Math.round(a[3]*255)):"")},i.to.rgb=function(){var a=Ns(arguments);return a.length<4||a[3]===1?"rgb("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+")":"rgba("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+", "+a[3]+")"},i.to.rgb.percent=function(){var a=Ns(arguments),l=Math.round(a[0]/255*100),c=Math.round(a[1]/255*100),d=Math.round(a[2]/255*100);return a.length<4||a[3]===1?"rgb("+l+"%, "+c+"%, "+d+"%)":"rgba("+l+"%, "+c+"%, "+d+"%, "+a[3]+")"},i.to.hsl=function(){var a=Ns(arguments);return a.length<4||a[3]===1?"hsl("+a[0]+", "+a[1]+"%, "+a[2]+"%)":"hsla("+a[0]+", "+a[1]+"%, "+a[2]+"%, "+a[3]+")"},i.to.hwb=function(){var a=Ns(arguments),l="";return a.length>=4&&a[3]!==1&&(l=", "+a[3]),"hwb("+a[0]+", "+a[1]+"%, "+a[2]+"%"+l+")"},i.to.keyword=function(a){return n[a.slice(0,3)]};function s(a,l,c){return Math.min(Math.max(l,a),c)}function o(a){var l=Math.round(a).toString(16).toUpperCase();return l.length<2?"0"+l:l}});Zr.to;Zr.get;var Hr={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]},Ke=pf(function(t){var e={};for(var n in Hr)Hr.hasOwnProperty(n)&&(e[Hr[n]]=n);var r=t.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 i in r)if(r.hasOwnProperty(i)){if(!("channels"in r[i]))throw new Error("missing channels property: "+i);if(!("labels"in r[i]))throw new Error("missing channel labels property: "+i);if(r[i].labels.length!==r[i].channels)throw new Error("channel and label counts mismatch: "+i);var s=r[i].channels,o=r[i].labels;delete r[i].channels,delete r[i].labels,Object.defineProperty(r[i],"channels",{value:s}),Object.defineProperty(r[i],"labels",{value:o})}r.rgb.hsl=function(l){var c=l[0]/255,d=l[1]/255,h=l[2]/255,f=Math.min(c,d,h),m=Math.max(c,d,h),p=m-f,g,b,x;return m===f?g=0:c===m?g=(d-h)/p:d===m?g=2+(h-c)/p:h===m&&(g=4+(c-d)/p),g=Math.min(g*60,360),g<0&&(g+=360),x=(f+m)/2,m===f?b=0:x<=.5?b=p/(m+f):b=p/(2-m-f),[g,b*100,x*100]},r.rgb.hsv=function(l){var c,d,h,f,m,p=l[0]/255,g=l[1]/255,b=l[2]/255,x=Math.max(p,g,b),y=x-Math.min(p,g,b),w=function(k){return(x-k)/6/y+1/2};return y===0?f=m=0:(m=y/x,c=w(p),d=w(g),h=w(b),p===x?f=h-d:g===x?f=1/3+c-h:b===x&&(f=2/3+d-c),f<0?f+=1:f>1&&(f-=1)),[f*360,m*100,x*100]},r.rgb.hwb=function(l){var c=l[0],d=l[1],h=l[2],f=r.rgb.hsl(l)[0],m=1/255*Math.min(c,Math.min(d,h));return h=1-1/255*Math.max(c,Math.max(d,h)),[f,m*100,h*100]},r.rgb.cmyk=function(l){var c=l[0]/255,d=l[1]/255,h=l[2]/255,f,m,p,g;return g=Math.min(1-c,1-d,1-h),f=(1-c-g)/(1-g)||0,m=(1-d-g)/(1-g)||0,p=(1-h-g)/(1-g)||0,[f*100,m*100,p*100,g*100]};function a(l,c){return Math.pow(l[0]-c[0],2)+Math.pow(l[1]-c[1],2)+Math.pow(l[2]-c[2],2)}r.rgb.keyword=function(l){var c=e[l];if(c)return c;var d=1/0,h;for(var f in Hr)if(Hr.hasOwnProperty(f)){var m=Hr[f],p=a(l,m);p<d&&(d=p,h=f)}return h},r.keyword.rgb=function(l){return Hr[l]},r.rgb.xyz=function(l){var c=l[0]/255,d=l[1]/255,h=l[2]/255;c=c>.04045?Math.pow((c+.055)/1.055,2.4):c/12.92,d=d>.04045?Math.pow((d+.055)/1.055,2.4):d/12.92,h=h>.04045?Math.pow((h+.055)/1.055,2.4):h/12.92;var f=c*.4124+d*.3576+h*.1805,m=c*.2126+d*.7152+h*.0722,p=c*.0193+d*.1192+h*.9505;return[f*100,m*100,p*100]},r.rgb.lab=function(l){var c=r.rgb.xyz(l),d=c[0],h=c[1],f=c[2],m,p,g;return d/=95.047,h/=100,f/=108.883,d=d>.008856?Math.pow(d,1/3):7.787*d+16/116,h=h>.008856?Math.pow(h,1/3):7.787*h+16/116,f=f>.008856?Math.pow(f,1/3):7.787*f+16/116,m=116*h-16,p=500*(d-h),g=200*(h-f),[m,p,g]},r.hsl.rgb=function(l){var c=l[0]/360,d=l[1]/100,h=l[2]/100,f,m,p,g,b;if(d===0)return b=h*255,[b,b,b];h<.5?m=h*(1+d):m=h+d-h*d,f=2*h-m,g=[0,0,0];for(var x=0;x<3;x++)p=c+1/3*-(x-1),p<0&&p++,p>1&&p--,6*p<1?b=f+(m-f)*6*p:2*p<1?b=m:3*p<2?b=f+(m-f)*(2/3-p)*6:b=f,g[x]=b*255;return g},r.hsl.hsv=function(l){var c=l[0],d=l[1]/100,h=l[2]/100,f=d,m=Math.max(h,.01),p,g;return h*=2,d*=h<=1?h:2-h,f*=m<=1?m:2-m,g=(h+d)/2,p=h===0?2*f/(m+f):2*d/(h+d),[c,p*100,g*100]},r.hsv.rgb=function(l){var c=l[0]/60,d=l[1]/100,h=l[2]/100,f=Math.floor(c)%6,m=c-Math.floor(c),p=255*h*(1-d),g=255*h*(1-d*m),b=255*h*(1-d*(1-m));switch(h*=255,f){case 0:return[h,b,p];case 1:return[g,h,p];case 2:return[p,h,b];case 3:return[p,g,h];case 4:return[b,p,h];case 5:return[h,p,g]}},r.hsv.hsl=function(l){var c=l[0],d=l[1]/100,h=l[2]/100,f=Math.max(h,.01),m,p,g;return g=(2-d)*h,m=(2-d)*f,p=d*f,p/=m<=1?m:2-m,p=p||0,g/=2,[c,p*100,g*100]},r.hwb.rgb=function(l){var c=l[0]/360,d=l[1]/100,h=l[2]/100,f=d+h,m,p,g,b;f>1&&(d/=f,h/=f),m=Math.floor(6*c),p=1-h,g=6*c-m,(m&1)!==0&&(g=1-g),b=d+g*(p-d);var x,y,w;switch(m){default:case 6:case 0:x=p,y=b,w=d;break;case 1:x=b,y=p,w=d;break;case 2:x=d,y=p,w=b;break;case 3:x=d,y=b,w=p;break;case 4:x=b,y=d,w=p;break;case 5:x=p,y=d,w=b;break}return[x*255,y*255,w*255]},r.cmyk.rgb=function(l){var c=l[0]/100,d=l[1]/100,h=l[2]/100,f=l[3]/100,m,p,g;return m=1-Math.min(1,c*(1-f)+f),p=1-Math.min(1,d*(1-f)+f),g=1-Math.min(1,h*(1-f)+f),[m*255,p*255,g*255]},r.xyz.rgb=function(l){var c=l[0]/100,d=l[1]/100,h=l[2]/100,f,m,p;return f=c*3.2406+d*-1.5372+h*-.4986,m=c*-.9689+d*1.8758+h*.0415,p=c*.0557+d*-.204+h*1.057,f=f>.0031308?1.055*Math.pow(f,1/2.4)-.055:f*12.92,m=m>.0031308?1.055*Math.pow(m,1/2.4)-.055:m*12.92,p=p>.0031308?1.055*Math.pow(p,1/2.4)-.055:p*12.92,f=Math.min(Math.max(0,f),1),m=Math.min(Math.max(0,m),1),p=Math.min(Math.max(0,p),1),[f*255,m*255,p*255]},r.xyz.lab=function(l){var c=l[0],d=l[1],h=l[2],f,m,p;return c/=95.047,d/=100,h/=108.883,c=c>.008856?Math.pow(c,1/3):7.787*c+16/116,d=d>.008856?Math.pow(d,1/3):7.787*d+16/116,h=h>.008856?Math.pow(h,1/3):7.787*h+16/116,f=116*d-16,m=500*(c-d),p=200*(d-h),[f,m,p]},r.lab.xyz=function(l){var c=l[0],d=l[1],h=l[2],f,m,p;m=(c+16)/116,f=d/500+m,p=m-h/200;var g=Math.pow(m,3),b=Math.pow(f,3),x=Math.pow(p,3);return m=g>.008856?g:(m-16/116)/7.787,f=b>.008856?b:(f-16/116)/7.787,p=x>.008856?x:(p-16/116)/7.787,f*=95.047,m*=100,p*=108.883,[f,m,p]},r.lab.lch=function(l){var c=l[0],d=l[1],h=l[2],f,m,p;return f=Math.atan2(h,d),m=f*360/2/Math.PI,m<0&&(m+=360),p=Math.sqrt(d*d+h*h),[c,p,m]},r.lch.lab=function(l){var c=l[0],d=l[1],h=l[2],f,m,p;return p=h/360*2*Math.PI,f=d*Math.cos(p),m=d*Math.sin(p),[c,f,m]},r.rgb.ansi16=function(l){var c=l[0],d=l[1],h=l[2],f=1 in arguments?arguments[1]:r.rgb.hsv(l)[2];if(f=Math.round(f/50),f===0)return 30;var m=30+(Math.round(h/255)<<2|Math.round(d/255)<<1|Math.round(c/255));return f===2&&(m+=60),m},r.hsv.ansi16=function(l){return r.rgb.ansi16(r.hsv.rgb(l),l[2])},r.rgb.ansi256=function(l){var c=l[0],d=l[1],h=l[2];if(c===d&&d===h)return c<8?16:c>248?231:Math.round((c-8)/247*24)+232;var f=16+36*Math.round(c/255*5)+6*Math.round(d/255*5)+Math.round(h/255*5);return f},r.ansi16.rgb=function(l){var c=l%10;if(c===0||c===7)return l>50&&(c+=3.5),c=c/10.5*255,[c,c,c];var d=(~~(l>50)+1)*.5,h=(c&1)*d*255,f=(c>>1&1)*d*255,m=(c>>2&1)*d*255;return[h,f,m]},r.ansi256.rgb=function(l){if(l>=232){var c=(l-232)*10+8;return[c,c,c]}l-=16;var d,h=Math.floor(l/36)/5*255,f=Math.floor((d=l%36)/6)/5*255,m=d%6/5*255;return[h,f,m]},r.rgb.hex=function(l){var c=((Math.round(l[0])&255)<<16)+((Math.round(l[1])&255)<<8)+(Math.round(l[2])&255),d=c.toString(16).toUpperCase();return"000000".substring(d.length)+d},r.hex.rgb=function(l){var c=l.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!c)return[0,0,0];var d=c[0];c[0].length===3&&(d=d.split("").map(function(g){return g+g}).join(""));var h=parseInt(d,16),f=h>>16&255,m=h>>8&255,p=h&255;return[f,m,p]},r.rgb.hcg=function(l){var c=l[0]/255,d=l[1]/255,h=l[2]/255,f=Math.max(Math.max(c,d),h),m=Math.min(Math.min(c,d),h),p=f-m,g,b;return p<1?g=m/(1-p):g=0,p<=0?b=0:f===c?b=(d-h)/p%6:f===d?b=2+(h-c)/p:b=4+(c-d)/p+4,b/=6,b%=1,[b*360,p*100,g*100]},r.hsl.hcg=function(l){var c=l[1]/100,d=l[2]/100,h=1,f=0;return d<.5?h=2*c*d:h=2*c*(1-d),h<1&&(f=(d-.5*h)/(1-h)),[l[0],h*100,f*100]},r.hsv.hcg=function(l){var c=l[1]/100,d=l[2]/100,h=c*d,f=0;return h<1&&(f=(d-h)/(1-h)),[l[0],h*100,f*100]},r.hcg.rgb=function(l){var c=l[0]/360,d=l[1]/100,h=l[2]/100;if(d===0)return[h*255,h*255,h*255];var f=[0,0,0],m=c%1*6,p=m%1,g=1-p,b=0;switch(Math.floor(m)){case 0:f[0]=1,f[1]=p,f[2]=0;break;case 1:f[0]=g,f[1]=1,f[2]=0;break;case 2:f[0]=0,f[1]=1,f[2]=p;break;case 3:f[0]=0,f[1]=g,f[2]=1;break;case 4:f[0]=p,f[1]=0,f[2]=1;break;default:f[0]=1,f[1]=0,f[2]=g}return b=(1-d)*h,[(d*f[0]+b)*255,(d*f[1]+b)*255,(d*f[2]+b)*255]},r.hcg.hsv=function(l){var c=l[1]/100,d=l[2]/100,h=c+d*(1-c),f=0;return h>0&&(f=c/h),[l[0],f*100,h*100]},r.hcg.hsl=function(l){var c=l[1]/100,d=l[2]/100,h=d*(1-c)+.5*c,f=0;return h>0&&h<.5?f=c/(2*h):h>=.5&&h<1&&(f=c/(2*(1-h))),[l[0],f*100,h*100]},r.hcg.hwb=function(l){var c=l[1]/100,d=l[2]/100,h=c+d*(1-c);return[l[0],(h-c)*100,(1-h)*100]},r.hwb.hcg=function(l){var c=l[1]/100,d=l[2]/100,h=1-d,f=h-c,m=0;return f<1&&(m=(h-f)/(1-f)),[l[0],f*100,m*100]},r.apple.rgb=function(l){return[l[0]/65535*255,l[1]/65535*255,l[2]/65535*255]},r.rgb.apple=function(l){return[l[0]/255*65535,l[1]/255*65535,l[2]/255*65535]},r.gray.rgb=function(l){return[l[0]/100*255,l[0]/100*255,l[0]/100*255]},r.gray.hsl=r.gray.hsv=function(l){return[0,0,l[0]]},r.gray.hwb=function(l){return[0,100,l[0]]},r.gray.cmyk=function(l){return[0,0,0,l[0]]},r.gray.lab=function(l){return[l[0],0,0]},r.gray.hex=function(l){var c=Math.round(l[0]/100*255)&255,d=(c<<16)+(c<<8)+c,h=d.toString(16).toUpperCase();return"000000".substring(h.length)+h},r.rgb.gray=function(l){var c=(l[0]+l[1]+l[2])/3;return[c/255*100]}});Ke.rgb;Ke.hsl;Ke.hsv;Ke.hwb;Ke.cmyk;Ke.xyz;Ke.lab;Ke.lch;Ke.hex;Ke.keyword;Ke.ansi16;Ke.ansi256;Ke.hcg;Ke.apple;Ke.gray;function _R(){for(var t={},e=Object.keys(Ke),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}function FR(t){var e=_R(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),i=Object.keys(Ke[r]),s=i.length,o=0;o<s;o++){var a=i[o],l=e[a];l.distance===-1&&(l.distance=e[r].distance+1,l.parent=r,n.unshift(a))}return e}function BR(t,e){return function(n){return e(t(n))}}function VR(t,e){for(var n=[e[t].parent,t],r=Ke[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=BR(Ke[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var zR=function(t){for(var e=FR(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s],a=e[o];a.parent!==null&&(n[o]=VR(o,e))}return n},yi={},$R=Object.keys(Ke);function HR(t){var e=function(n){return n==null?n:(arguments.length>1&&(n=Array.prototype.slice.call(arguments)),t(n))};return"conversion"in t&&(e.conversion=t.conversion),e}function UR(t){var e=function(n){if(n==null)return n;arguments.length>1&&(n=Array.prototype.slice.call(arguments));var r=t(n);if(typeof r=="object")for(var i=r.length,s=0;s<i;s++)r[s]=Math.round(r[s]);return r};return"conversion"in t&&(e.conversion=t.conversion),e}$R.forEach(function(t){yi[t]={},Object.defineProperty(yi[t],"channels",{value:Ke[t].channels}),Object.defineProperty(yi[t],"labels",{value:Ke[t].labels});var e=zR(t),n=Object.keys(e);n.forEach(function(r){var i=e[r];yi[t][r]=UR(i),yi[t][r].raw=HR(i)})});var tn=yi,gf=[].slice,fy=["keyword","gray","hex"],Wd={};Object.keys(tn).forEach(function(t){Wd[gf.call(tn[t].labels).sort().join("")]=t});var Ll={};function vt(t,e){if(!(this instanceof vt))return new vt(t,e);if(e&&e in fy&&(e=null),e&&!(e in tn))throw new Error("Unknown model: "+e);var n,r;if(t==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof vt)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if(typeof t=="string"){var i=Zr.get(t);if(i===null)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=tn[this.model].channels,this.color=i.value.slice(0,r),this.valpha=typeof i.value[r]=="number"?i.value[r]:1}else if(t.length){this.model=e||"rgb",r=tn[this.model].channels;var s=gf.call(t,0,r);this.color=Kd(s,r),this.valpha=typeof t[r]=="number"?t[r]:1}else if(typeof t=="number")t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,t&255],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha=typeof t.alpha=="number"?t.alpha:0);var a=o.sort().join("");if(!(a in Wd))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=Wd[a];var l=tn[this.model].labels,c=[];for(n=0;n<l.length;n++)c.push(t[l[n]]);this.color=Kd(c)}if(Ll[this.model])for(r=tn[this.model].channels,n=0;n<r;n++){var d=Ll[this.model][n];d&&(this.color[n]=d(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}vt.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in Zr.to?this:this.rgb();e=e.round(typeof t=="number"?t:1);var n=e.valpha===1?e.color:e.color.concat(this.valpha);return Zr.to[e.model](n)},percentString:function(t){var e=this.rgb().round(typeof t=="number"?t:1),n=e.valpha===1?e.color:e.color.concat(this.valpha);return Zr.to.rgb.percent(n)},array:function(){return this.valpha===1?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=tn[this.model].channels,n=tn[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return this.valpha!==1&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,this.valpha!==1&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,this.valpha!==1&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new vt(this.color.map(KR(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new vt(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:$e("rgb",0,rt(255)),green:$e("rgb",1,rt(255)),blue:$e("rgb",2,rt(255)),hue:$e(["hsl","hsv","hsl","hwb","hcg"],0,function(t){return(t%360+360)%360}),saturationl:$e("hsl",1,rt(100)),lightness:$e("hsl",2,rt(100)),saturationv:$e("hsv",1,rt(100)),value:$e("hsv",2,rt(100)),chroma:$e("hcg",1,rt(100)),gray:$e("hcg",2,rt(100)),white:$e("hwb",1,rt(100)),wblack:$e("hwb",2,rt(100)),cyan:$e("cmyk",0,rt(100)),magenta:$e("cmyk",1,rt(100)),yellow:$e("cmyk",2,rt(100)),black:$e("cmyk",3,rt(100)),x:$e("xyz",0,rt(100)),y:$e("xyz",1,rt(100)),z:$e("xyz",2,rt(100)),l:$e("lab",0,rt(100)),a:$e("lab",1),b:$e("lab",2),keyword:function(t){return arguments.length?new vt(t):tn[this.model].keyword(this.color)},hex:function(t){return arguments.length?new vt(t):Zr.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return .2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color,e=(t[0]*299+t[1]*587+t[2]*114)/1e3;return e<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=t[0]*.3+t[1]*.59+t[2]*.11;return vt.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n+t)%360,n=n<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),i=e===void 0?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o===-1?s:(s+o)/(1+s*o))+1)/2,l=1-a;return vt.rgb(a*n.red()+l*r.red(),a*n.green()+l*r.green(),a*n.blue()+l*r.blue(),n.alpha()*i+r.alpha()*(1-i))}};Object.keys(tn).forEach(function(t){if(fy.indexOf(t)===-1){var e=tn[t].channels;vt.prototype[t]=function(){if(this.model===t)return new vt(this);if(arguments.length)return new vt(arguments,t);var n=typeof arguments[e]=="number"?e:this.valpha;return new vt(GR(tn[this.model][t].raw(this.color)).concat(n),t)},vt[t]=function(n){return typeof n=="number"&&(n=Kd(gf.call(arguments),e)),new vt(n,t)}}});function WR(t,e){return Number(t.toFixed(e))}function KR(t){return function(e){return WR(e,t)}}function $e(t,e,n){return t=Array.isArray(t)?t:[t],t.forEach(function(r){(Ll[r]||(Ll[r]=[]))[e]=n}),t=t[0],function(r){var i;return arguments.length?(n&&(r=n(r)),i=this[t](),i.color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function rt(t){return function(e){return Math.max(0,Math.min(t,e))}}function GR(t){return Array.isArray(t)?t:[t]}function Kd(t,e){for(var n=0;n<e;n++)typeof t[n]!="number"&&(t[n]=0);return t}var yu=vt;function sr(t){const e=yu(t),n=yu({r:255,g:255,b:255}),r=yu({r:0,g:0,b:0});return e.red()*.299+e.green()*.587+e.b()*.114>=186?r:n}const ms=/^#(?:[0-9a-f]{3}){1,2}$/i;function qR(t){return ms.test(t)?t:"#ffffff"}function YR(t,e){return!t||t==="transparent"?"transparent":t==="accent"?e:ms.test(t)?t:"transparent"}function XR(t,e,n){return ms.test(t||"")?t:t===null?sr(n).hex():e}function JR(t,e){if(t==="fill")return sr(e).hex()}function ZR(t,e,n){const r=t===void 0?"accent":t;return r==="accent"?e:ms.test(r||"")?r:sr(n).hex()}function QR(t,e,n){return ms.test(t||"")?t:t==="accent"?e:sr(n).hex()}function eL(t,e){return ms.test(t||"")?t:t==="accent"?e:"#e0e7eb"}function my(t,e){const n=qR(t.background_color),r=YR(t.header_background_color,e),i=XR(t.button_color,e,n),s=sr(n).hex(),o=sr(n).alpha(.5).toString(),a=r==="transparent"?s:sr(r).hex(),l=r==="transparent"?o:sr(r).alpha(.5).toString();return{backgroundColor:n,headerBackgroundColor:r,sectionTitleColor:QR(t.section_title_color,e,n),buttonColor:i,buttonTextColor:JR(t.button_style,i),linkColor:ZR(t.link_color,e,n),dividerColor:eL(t.divider_color,e),textColor:s,secondaryTextColor:o,headerTextColor:a,secondaryHeaderTextColor:l}}function tL(t){return t==="serif"?"Georgia, serif":'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'}function nL(t){switch(t){case"square":return"rounded-none";case"pill":return"rounded-full";default:return"rounded-[6px]"}}function py(t){return t==="rounded"?"rounded-md":""}const rL=({senderName:t,senderEmail:e,replyToEmail:n,subject:r,showRecipientLine:i=!0,showSubjectLine:s=!0})=>{const o=n||e,a=t&&e?`${t} (${e})`:t||e;return!a&&!o&&(!s||!r)?null:u.jsxs("div",{className:"flex flex-col justify-center gap-1 border-b border-grey-200 bg-white p-6 text-grey-700",children:[a&&u.jsxs("div",{children:[u.jsx("span",{className:"font-semibold text-grey-900",children:"From:"})," ",a]}),i&&e&&u.jsxs("div",{children:[u.jsx("span",{className:"font-semibold text-grey-900",children:"To:"})," subscriber@example.com"]}),o&&u.jsxs("div",{children:[u.jsx("span",{className:"font-semibold text-grey-900",children:"Reply-to:"})," ",o]}),s&&r&&u.jsx("div",{className:"text-base font-medium text-grey-900",children:r})]})},iL=({iconUrl:t,showIcon:e,showTitle:n,siteTitle:r,backgroundColor:i,textColor:s})=>!e&&(!n||!r)?null:u.jsxs("div",{className:"px-[7rem] py-3 text-center",style:{backgroundColor:i==="transparent"?void 0:i},children:[e&&t&&u.jsx("img",{alt:r||"Publication icon",className:"mx-auto mb-3 h-12 w-12 rounded",src:t}),n&&r&&u.jsx("h4",{className:"mb-1 text-[1.6rem] leading-tight font-bold tracking-tight uppercase",style:{color:s},children:r})]}),sL=({siteTitle:t,footerLinkText:e="Unsubscribe",emailFooter:n,showBadge:r,color:i,textColor:s})=>u.jsxs("div",{className:"flex flex-col items-center pt-10",children:[n&&u.jsx("div",{className:"px-8 py-3 text-center text-[1.3rem] leading-base break-words whitespace-pre-line",style:{color:i},children:n}),u.jsxs("div",{className:"px-8 pt-3 pb-14 text-center text-[1.3rem]",children:[u.jsxs("span",{style:{color:i},children:[t||"Your publication"," © ",new Date().getFullYear()," — "]}),u.jsx("span",{className:"underline",style:{color:i},children:e})]}),r&&u.jsx("div",{className:"flex flex-col items-center pt-[10px] pb-[40px]",children:u.jsxs("span",{className:"inline-flex items-center px-2 py-1 text-[1.25rem] font-semibold tracking-tight",style:{color:s},children:[u.jsx(dE,{className:"mr-[6px] size-4"}),u.jsx("span",{children:"Powered by Ghost"})]})})]}),oL=({settings:t,accentColor:e,publicationIcon:n,siteTitle:r,senderName:i,senderEmail:s,replyToEmail:o,subject:a,showRecipientLine:l=!0,showSubjectLine:c=!0,headerImage:d,showPublicationIcon:h=!1,showPublicationTitle:f=!0,showBadge:m=!0,emailFooter:p,footerLinkText:g,children:b})=>{const x=my(t,e),y=py(t.image_corners),w=r||void 0;return u.jsxs("div",{className:"mx-auto flex max-h-full min-h-0 w-full max-w-[700px] flex-col overflow-hidden rounded-[4px] text-black shadow-sm",children:[u.jsx(rL,{replyToEmail:o,senderEmail:s,senderName:i,showRecipientLine:l,showSubjectLine:c,subject:a}),u.jsxs("div",{className:"min-h-0 w-full flex-1 overflow-y-auto",style:{backgroundColor:x.backgroundColor},children:[u.jsxs("div",{className:"px-[7rem]",style:{backgroundColor:x.headerBackgroundColor==="transparent"?void 0:x.headerBackgroundColor},children:[d&&u.jsx("div",{className:"pt-8",children:u.jsx("img",{alt:"Header",className:Le("h-auto w-full",y),src:d})}),u.jsx(iL,{backgroundColor:"transparent",iconUrl:n,showIcon:h&&!!n,showTitle:f,siteTitle:w,textColor:x.headerTextColor})]}),b,u.jsx(sL,{color:x.secondaryTextColor,emailFooter:p,footerLinkText:g,showBadge:m,siteTitle:w,textColor:x.textColor})]})]})},gy=Ot({method:"POST",path:()=>"/images/upload/",body:({file:t})=>{const e=new FormData;return e.append("file",t),e.append("purpose","image"),e}}),Ga=t=>t.images[0].url,aL=({value:t,onChange:e})=>{const{mutateAsync:n}=gy(),r=async i=>{const s=Ga(await n({file:i}));e(s)};return u.jsxs("div",{className:"flex flex-col gap-1.5","data-testid":"header-image-field",children:[u.jsx("label",{className:"font-medium",htmlFor:"welcome-email-header-image",children:"Header image"}),t?u.jsxs("div",{className:"relative overflow-hidden rounded-md border border-gray-200 dark:border-gray-800",children:[u.jsx("img",{alt:"Header",className:"h-auto w-full",src:t}),u.jsx("button",{className:"absolute top-2 right-2 rounded bg-black/50 px-2 py-1 text-sm text-white hover:bg-black/70",type:"button",onClick:()=>e(""),children:"Remove"})]}):u.jsxs(u.Fragment,{children:[u.jsx(f2,{accept:{"image/*":[".jpg",".jpeg",".png",".gif",".webp",".svg"]},className:"flex h-24 items-center justify-center p-0",id:"welcome-email-header-image",onDropAccepted:i=>i[0]&&r(i[0]),children:u.jsx("span",{className:"text-gray-700",children:"Upload header image"})}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"1200x600 recommended. Use a transparent PNG for best results on any background."})]})]})},lL=({value:t,onChange:e})=>u.jsxs("div",{className:"mt-6 flex items-start justify-between gap-4",children:[u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx(Lw,{className:"mt-0.5 size-4 shrink-0 text-red-500"}),u.jsxs("div",{className:"flex flex-col gap-0.5",children:[u.jsx("span",{children:"Promote independent publishing"}),u.jsx("span",{className:"text-sm leading-tight text-muted-foreground",children:"Show you're a part of the indie publishing movement with a small badge in the footer"})]})]}),u.jsx(ju,{checked:t,size:"sm",onCheckedChange:e})]}),cL=""+new URL("email-design-user-image-BWe5RYS0.jpg",import.meta.url).href,by=v.createContext(void 0),uL=({settings:t,onSettingsChange:e,accentColor:n,children:r})=>u.jsx(by.Provider,{value:{settings:t,onSettingsChange:e,accentColor:n},children:r}),qt=()=>{const t=v.useContext(by);if(!t)throw new Error("useEmailDesign must be used within an EmailDesignProvider");return t},dL=()=>{const{settings:t,accentColor:e}=qt(),n=my(t,e),r=tL(t.body_font_category),i=nL(t.button_corners),s=t.button_style==="outline",o=Le("no-underline",t.link_style==="underline"&&"underline",t.link_style==="bold"&&"font-bold"),a=Le("mb-5 text-[2.6rem] tracking-tighter",t.title_font_category==="serif"&&"font-serif",t.title_font_category==="sans_serif"&&"font-sans",t.title_font_weight==="normal"&&"font-normal",t.title_font_weight==="medium"&&"font-medium",t.title_font_weight==="semibold"&&"font-semibold",t.title_font_weight==="bold"&&"font-bold"),l=Le(t.body_font_category==="serif"?"font-serif text-[1.8rem]":"text-[1.7rem]");return u.jsxs("div",{className:"mx-auto w-full max-w-[600px] px-10 pt-16",children:[u.jsx("h3",{className:a,style:{color:n.sectionTitleColor},children:"Your welcome email"}),u.jsxs("div",{className:Le(l),style:{color:n.textColor,fontFamily:r},children:[u.jsx("p",{className:"mt-0 mb-6",children:"This is what your welcome email will look like when someone signs up to your site."}),u.jsx("p",{className:"mt-0 mb-8",children:"Use the settings on the right to shape the design — from colors and typography to layout and buttons — so it feels like a natural extension of your brand."}),u.jsx("div",{className:Le("h-[unset] w-full max-w-[600px] bg-cover bg-no-repeat"),children:u.jsx("img",{alt:"Example cover image",className:Le("min-h-full min-w-full shrink-0",py(t.image_corners)),src:cL})}),u.jsx("div",{className:"mt-1 w-full max-w-[600px] pb-8 text-center text-body-sm",style:{color:n.secondaryTextColor},children:"Image caption"}),u.jsx("p",{className:"mt-0 mb-6",children:"Welcome emails set the tone for your relationship with new members. We’ve optimized this template to look great across devices and inboxes, so your first impression lands exactly how you want it."})]}),u.jsx("div",{className:"my-5 py-4",children:u.jsx("hr",{className:"m-0 border-0 border-t",style:{borderColor:n.dividerColor}})}),u.jsx("h3",{className:a,style:{color:n.sectionTitleColor},children:"Need inspiration?"}),u.jsx("div",{className:Le(l),style:{color:n.textColor,fontFamily:r},children:u.jsxs("p",{className:"mt-0 mb-6",children:["We’ve put together a ",u.jsx("a",{className:o,href:"https://ghost.org/help/email-design/",rel:"noopener noreferrer",style:{color:n.linkColor},target:"_blank",children:"quick guide"})," that walks through all the available settings, along with a few examples of what’s possible."]})}),u.jsx("div",{className:"pb-6",children:u.jsx("a",{className:Le("inline-block border px-[18px] py-2.5 font-sans text-[15px] no-underline",i,s?"bg-transparent":"border-transparent",t.link_style==="bold"?"font-bold":"font-semibold"),href:"https://ghost.org/help/email-design/",rel:"noopener noreferrer",style:s?{borderColor:n.buttonColor,color:n.buttonColor}:{backgroundColor:n.buttonColor,color:n.buttonTextColor},target:"_blank",children:"Learn more"})}),u.jsx("div",{className:"py-4",children:u.jsx("hr",{className:"m-0 border-0 border-t",style:{borderColor:n.dividerColor}})})]})},ea=t=>{const{config:e}=ke();return e.labs[t]||!1},vy="AutomatedEmailDesignResponseType",hL=Xd({dataType:vy,path:"/automated_emails/design/"}),fL=Ot({method:"PUT",path:()=>"/automated_emails/design/",body:t=>({automated_email_design:[t]}),updateQueries:{emberUpdateType:"skip",dataType:vy,update:t=>t}}),Ag=/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i,mL=(t,e,n=[])=>{if(t&&Ag.test(t))return t;switch(t){case"accent":return e&&Ag.test(e)?e:"#ffffff";case"light":return"#ffffff";case"transparent":return"#00000000"}const r=n.find(i=>i.value===t);return r?r.hex:"#ffffff"},pL=t=>{const e=t.toLowerCase();return e.length===5&&e[4]==="0"||e.length===9&&e.slice(7)==="00"},gL=()=>u.jsx("span",{className:"pointer-events-none absolute inset-0 overflow-hidden rounded-full","data-testid":"transparent-indicator","aria-hidden":!0,children:u.jsx("span",{className:"absolute top-1/2 left-[-30%] block h-px w-[160%] -translate-y-1/2 -rotate-45 bg-red"})}),ps=({title:t,value:e,onChange:n,accentColor:r,swatches:i=[]})=>{const[s,o]=v.useState(!1),a=mL(e,r,i),l=v.useRef(!1),c=v.useRef(!1),d=v.useRef(null),h=i.find(b=>b.value===e||e&&b.hex.toLowerCase()===e.toLowerCase()),f=()=>{l.current=!1,c.current=!1},m=v.useCallback(()=>{d.current&&(window.removeEventListener("keydown",d.current,!0),d.current=null)},[]),p=()=>{m(),f(),o(!1)},g=()=>{if(d.current)return;const b=x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),p())};d.current=b,window.addEventListener("keydown",b,!0)};return v.useEffect(()=>()=>{m()},[m]),u.jsxs(_w,{open:s,onOpenChange:b=>{f(),b?g():m(),o(b)},children:[u.jsx(Fw,{asChild:!0,children:u.jsxs("div",{className:"flex w-full cursor-pointer items-start justify-between",children:[u.jsx("span",{className:"mt-px flex-1",children:t}),u.jsxs("div",{className:"flex shrink-0 gap-1",children:[s&&i.length>0&&u.jsx("div",{className:"flex items-center gap-1",children:i.map(b=>{const x=b.value===void 0?b.hex:b.value,y=h?.title===b.title;return u.jsx("button",{"aria-label":b.title,className:`relative flex h-5 w-5 shrink-0 cursor-pointer items-center overflow-hidden rounded-full border border-grey-300 dark:border-grey-800 ${y?"outline-2 outline-green":""}`,style:{backgroundColor:b.hex},title:b.title,type:"button",onClick:()=>{l.current=!1,c.current=!0,n(x),p()},children:pL(b.hex)&&u.jsx(gL,{})},b.title)})}),u.jsxs("button",{"aria-label":"Pick color",className:"relative size-6 cursor-pointer rounded-full border border-grey-200 dark:border-grey-800",type:"button",children:[u.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%))]"}),u.jsx("div",{className:"absolute inset-[3px] overflow-hidden rounded-full border border-white dark:border-grey-950",style:{backgroundColor:a}})]})]})]})}),u.jsx(Bw,{align:"end",className:"w-auto p-4",onEscapeKeyDown:b=>{b.stopPropagation()},children:u.jsx("div",{onInputCapture:()=>{l.current=!0},onKeyDownCapture:()=>{l.current=!0},onMouseDownCapture:()=>{l.current=!0},onPointerDownCapture:()=>{l.current=!0},onTouchStartCapture:()=>{l.current=!0},children:u.jsx(RI,{value:a,onChange:b=>{c.current||!l.current||n(b)}})})})]})},bL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsx(ps,{swatches:[{title:"White",value:"light",hex:"#ffffff"}],title:"Background color",value:t.background_color,onChange:n=>n&&e({background_color:n})})},xy=[{value:"serif",label:"Elegant serif"},{value:"sans_serif",label:"Clean sans-serif"}],_l={sans_serif:{options:[{value:"normal",label:"Regular"},{value:"medium",label:"Medium"},{value:"semibold",label:"Semi-bold"},{value:"bold",label:"Bold"}]},serif:{options:[{value:"normal",label:"Regular"},{value:"bold",label:"Bold"}],map:{medium:"normal",semibold:"bold"}}};function yy(t,e){const n=_l[t]||_l.sans_serif;return n.options.find(r=>r.value===e)?e:n.map?.[e]||"bold"}const vL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Body font"}),u.jsxs(Eo,{value:t.body_font_category||"sans_serif",onValueChange:n=>e({body_font_category:n}),children:[u.jsx(jo,{className:"w-[180px]",children:u.jsx(No,{})}),u.jsx(To,{onEscapeKeyDown:n=>{n.stopPropagation()},children:xy.map(n=>u.jsx($i,{value:n.value,children:n.label},n.value))})]})]})},xL=/^#(?:[0-9a-f]{3}){1,2}$/i,yL=t=>t==="light"?"#ffffff":xL.test(t)?t:"#ffffff",bf=t=>sr(yL(t)).hex(),wL=()=>{const{settings:t,onSettingsChange:e,accentColor:n}=qt(),r=bf(t.background_color);return u.jsx(ps,{accentColor:n,swatches:[{title:"Accent",value:"accent",hex:n},{title:"Auto",value:null,hex:r}],title:"Button color",value:t.button_color,onChange:i=>e({button_color:i})})},kL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Button corners"}),u.jsxs(Hl,{type:"single",value:t.button_corners||"rounded",onValueChange:n=>n&&e({button_corners:n}),children:[u.jsx(Gn,{"aria-label":"Square",value:"square",children:u.jsx("span",{className:"inline-block size-4 border-[1.5px] border-current"})}),u.jsx(Gn,{"aria-label":"Rounded",value:"rounded",children:u.jsx("span",{className:"inline-block size-4 rounded-sm border-[1.5px] border-current"})}),u.jsx(Gn,{"aria-label":"Pill",value:"pill",children:u.jsx("span",{className:"inline-block size-4 rounded-full border-[1.5px] border-current"})})]})]})},SL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Button style"}),u.jsxs(Hl,{type:"single",value:t.button_style||"fill",onValueChange:n=>n&&e({button_style:n}),children:[u.jsx(Gn,{"aria-label":"Fill",value:"fill",children:u.jsx("span",{className:"inline-block h-4 w-5 rounded-sm bg-current"})}),u.jsx(Gn,{"aria-label":"Outline",value:"outline",children:u.jsx("span",{className:"inline-block h-4 w-5 rounded-sm border-[1.5px] border-current"})})]})]})},CL=()=>{const{settings:t,onSettingsChange:e,accentColor:n}=qt();return u.jsx(ps,{accentColor:n,swatches:[{title:"Light",value:null,hex:"#e0e7eb"},{title:"Accent",value:"accent",hex:n}],title:"Divider color",value:t.divider_color,onChange:r=>e({divider_color:r})})},AL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsx(ps,{swatches:[{title:"Transparent",value:"transparent",hex:"#00000000"}],title:"Header background color",value:t.header_background_color,onChange:n=>n&&e({header_background_color:n})})},ML=()=>{const{settings:t,onSettingsChange:e}=qt(),n=r=>{const i=yy(r,t.title_font_weight);e({title_font_category:r,title_font_weight:i})};return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Heading font"}),u.jsxs(Eo,{value:t.title_font_category||"sans_serif",onValueChange:n,children:[u.jsx(jo,{className:"w-[180px]",children:u.jsx(No,{})}),u.jsx(To,{onEscapeKeyDown:r=>{r.stopPropagation()},children:xy.map(r=>u.jsx($i,{value:r.value,children:r.label},r.value))})]})]})},EL=()=>{const{settings:t,onSettingsChange:e}=qt(),n=t.title_font_category||"sans_serif",r=_l[n]?.options||_l.sans_serif.options,i=yy(n,t.title_font_weight);return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Heading weight"}),u.jsxs(Eo,{value:i,onValueChange:s=>e({title_font_weight:s}),children:[u.jsx(jo,{className:"w-[180px]",children:u.jsx(No,{})}),u.jsx(To,{onEscapeKeyDown:s=>{s.stopPropagation()},children:r.map(s=>u.jsx($i,{value:s.value,children:s.label},s.value))})]})]})},jL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Image corners"}),u.jsxs(Hl,{type:"single",value:t.image_corners||"square",onValueChange:n=>n&&e({image_corners:n}),children:[u.jsx(Gn,{"aria-label":"Square",value:"square",children:u.jsx("span",{className:"inline-block size-4 border-[1.5px] border-current"})}),u.jsx(Gn,{"aria-label":"Rounded",value:"rounded",children:u.jsx("span",{className:"inline-block size-4 rounded-sm border-[1.5px] border-current"})})]})]})},NL=()=>{const{settings:t,onSettingsChange:e,accentColor:n}=qt(),r=bf(t.background_color);return u.jsx(ps,{accentColor:n,swatches:[{title:"Accent",value:"accent",hex:n},{title:"Auto",value:null,hex:r}],title:"Link color",value:t.link_color,onChange:i=>e({link_color:i})})},TL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Link style"}),u.jsxs(Hl,{type:"single",value:t.link_style||"underline",onValueChange:n=>n&&e({link_style:n}),children:[u.jsx(Gn,{"aria-label":"Underline",value:"underline",children:u.jsx(p2,{className:"size-4"})}),u.jsx(Gn,{"aria-label":"Regular",value:"regular",children:u.jsx(g2,{className:"size-4"})}),u.jsx(Gn,{"aria-label":"Bold",value:"bold",children:u.jsx(b2,{className:"size-4"})})]})]})},DL=()=>{const{settings:t,onSettingsChange:e,accentColor:n}=qt(),r=bf(t.background_color);return u.jsx(ps,{accentColor:n,swatches:[{title:"Auto",value:null,hex:r},{title:"Accent",value:"accent",hex:n}],title:"Section title color",value:t.section_title_color,onChange:i=>e({section_title_color:i})})},wy={background_color:"light",title_font_category:"sans_serif",title_font_weight:"bold",body_font_category:"sans_serif",header_background_color:"transparent",section_title_color:null,button_color:"accent",button_style:"fill",button_corners:"rounded",link_color:"accent",link_style:"underline",image_corners:"square",divider_color:null},Ar={free:"member-welcome-email-free",paid:"member-welcome-email-paid"},OL=`{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Welcome! Thanks for subscribing — it's great to have you here.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"You'll now receive new posts straight to your inbox. You can also log in any time to read the ","type":"extended-text","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"full archive","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"link","version":1,"rel":"noreferrer","target":null,"title":null,"url":"__GHOST_URL__/"},{"detail":0,"format":0,"mode":"normal","style":"","text":" or catch up on new posts as they go live.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"A little housekeeping: If this email landed in spam or promotions, try moving it to your primary inbox and adding this address to your contacts. Small signals like that help your inbox recognize that these messages matter to you.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Have questions or just want to say hi? Feel free to reply directly to this email or any newsletter in the future.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}`,IL=`{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Welcome, and thank you for your support — it means a lot.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"As a paid member, you now have full access to everything: the complete archive, and any paid-only content going forward. New posts will land straight to your inbox, and you can log in any time to ","type":"extended-text","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"catch up","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"link","version":1,"rel":"noreferrer","target":null,"title":null,"url":"__GHOST_URL__/"},{"detail":0,"format":0,"mode":"normal","style":"","text":" on anything you've missed.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"A little housekeeping: If this email landed in spam or promotions, try moving it to your primary inbox and adding this address to your contacts. Small signals like that help your inbox recognize that these messages matter to you.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Have questions or just want to say hi? Feel free to reply directly to this email or any newsletter in the future.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}`,vf=(t,e)=>({name:t==="free"?"Free member welcome flow":"Paid member welcome flow",slug:Ar[t],subject:t==="free"?`Welcome to ${e||"our site"}`:"Welcome to your paid subscription",lexical:t==="free"?OL:IL}),Mg=(t,e)=>({id:"",status:"inactive",...vf(t,e),sender_name:null,sender_email:null,sender_reply_to:null,created_at:"",updated_at:null}),xf=(t,e,n)=>Qd(e)&&!Kg(e)&&n?n:t.sender_email||n||"",PL=(t,e,n,r)=>t.sender_reply_to==="newsletter"?Qd(e)?"":xf(t,e,r):t.sender_reply_to==="support"?n||r||"":t.sender_reply_to,RL=(t,e,n,r)=>{const i=PL(t,e,n,r);return i||(t.sender_reply_to==="newsletter"?xf(t,e,r)||n||r||"":n||r||"")},xr=t=>t?.trim()||"",wu=(...t)=>t.map(xr).find(Boolean)||"",LL=({automatedEmails:t=[],config:e,defaultEmailAddress:n,newsletter:r,siteTitle:i,supportEmailAddress:s})=>{const o=t.find(A=>A.slug===Ar.free),a=t.find(A=>A.slug===Ar.paid),l=wu(o?.sender_name,a?.sender_name),c=wu(o?.sender_email,a?.sender_email),d=wu(o?.sender_reply_to,a?.sender_reply_to),h=xr(r?.sender_name),f=r?xr(xf(r,e,n||void 0)):"",m=r?xr(RL(r,e,s||void 0,n||void 0)):"",p=h||xr(i)||"Your site name",g=f||xr(n),b=m||xr(s)||xr(n),x=l||p,y=c||g||"",w=d||b||"",k=w!==""&&w!==y,C=Qd(e),S=Kg(e);return{hasDistinctReplyTo:k,replyToEmailInput:d,replyToEmailPlaceholder:b,resolvedReplyToEmail:w,resolvedSenderEmail:y,resolvedSenderName:x,senderEmailDomain:S?Vw(e):null,senderEmailInput:c,senderEmailPlaceholder:g,senderNameInput:l,senderNamePlaceholder:p,showSenderEmailInput:!C||S}},ky=(t=[],{config:e,defaultEmailAddress:n,siteTitle:r,supportEmailAddress:i})=>{const{data:s}=$l({searchParams:{filter:"status:active",limit:"1"}}),o=s?.newsletters?.[0];return v.useMemo(()=>LL({automatedEmails:t,config:e,defaultEmailAddress:n,newsletter:o,siteTitle:r,supportEmailAddress:i}),[t,e,n,o,r,i])},Ts="welcome-email-design-save-error",_L=new Set(Object.keys(wy)),Sy=t=>_L.has(t),FL=({generalSettings:t,onGeneralChange:e,showPublicationIconToggle:n,senderNamePlaceholder:r,senderEmailPlaceholder:i,replyToEmailPlaceholder:s,showSenderEmailInput:o,senderNameError:a,senderEmailError:l,replyToEmailError:c})=>u.jsxs("div",{className:"flex flex-col gap-6 pt-6",children:[u.jsxs("section",{children:[u.jsx("h4",{className:"mb-4 font-semibold md:text-lg",children:"Email info"}),u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{className:"font-medium",htmlFor:"welcome-email-sender-name",children:"Sender name"}),u.jsx(_s,{id:"welcome-email-sender-name",placeholder:r,value:t.senderName,onChange:d=>e({senderName:d.target.value})}),a?u.jsx("p",{className:"text-sm text-red",children:a}):null]}),o?u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{className:"font-medium",htmlFor:"welcome-email-sender-email",children:"Sender email"}),u.jsx(_s,{id:"welcome-email-sender-email",placeholder:i,value:t.senderEmail,onChange:d=>e({senderEmail:d.target.value})}),l?u.jsx("p",{className:"text-sm text-red",children:l}):null]}):null,u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{className:"font-medium",htmlFor:"welcome-email-reply-to-email",children:"Reply-to email"}),u.jsx(_s,{id:"welcome-email-reply-to-email",placeholder:s,value:t.replyToEmail,onChange:d=>e({replyToEmail:d.target.value})}),c?u.jsx("p",{className:"text-sm text-red",children:c}):null]})]})]}),u.jsx(Nu,{}),u.jsxs("section",{children:[u.jsx("h4",{className:"mb-4 font-semibold md:text-lg",children:"Content"}),u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx(aL,{value:t.headerImage,onChange:d=>e({headerImage:d})}),n&&u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"font-medium",children:"Publication icon"}),u.jsx(ju,{checked:t.showPublicationIcon,size:"sm",onCheckedChange:d=>e({showPublicationIcon:d})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"font-medium",children:"Publication title"}),u.jsx(ju,{checked:t.showPublicationTitle,size:"sm",onCheckedChange:d=>e({showPublicationTitle:d})})]}),u.jsxs("div",{className:"mt-2 flex flex-col gap-1.5",children:[u.jsx("label",{className:"font-medium",htmlFor:"welcome-email-footer",children:"Email footer"}),u.jsx(v2,{id:"welcome-email-footer",placeholder:"Any extra information or legal text",rows:3,value:t.emailFooter,onChange:d=>e({emailFooter:d.target.value})})]}),u.jsx(lL,{value:t.showBadge,onChange:d=>e({showBadge:d})})]})]})]}),BL=()=>u.jsxs("div",{className:"flex flex-col gap-6 pt-6",children:[u.jsxs("section",{children:[u.jsx("h4",{className:"mb-4 font-semibold md:text-lg",children:"Global"}),u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx(bL,{}),u.jsx(ML,{}),u.jsx(EL,{}),u.jsx(vL,{})]})]}),u.jsx(Nu,{}),u.jsxs("section",{children:[u.jsx("h4",{className:"mb-4 font-semibold md:text-lg",children:"Header"}),u.jsx("div",{className:"flex flex-col gap-4",children:u.jsx(AL,{})})]}),u.jsx(Nu,{}),u.jsxs("section",{children:[u.jsx("h4",{className:"mb-4 font-semibold md:text-lg",children:"Body"}),u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx(DL,{}),u.jsx(wL,{}),u.jsx(SL,{}),u.jsx(kL,{}),u.jsx(NL,{}),u.jsx(TL,{}),u.jsx(jL,{}),u.jsx(CL,{})]})]})]}),VL=({generalSettings:t,onGeneralChange:e,showPublicationIconToggle:n,senderNamePlaceholder:r,senderEmailPlaceholder:i,replyToEmailPlaceholder:s,showSenderEmailInput:o,senderNameError:a,senderEmailError:l,replyToEmailError:c,isLoading:d,errorMessage:h})=>u.jsxs(th,{className:"flex min-h-0 flex-1 flex-col",defaultValue:"general",variant:"underline",children:[u.jsxs(nh,{className:"px-5",children:[u.jsx(zi,{value:"general",children:"General"}),u.jsx(zi,{value:"design",children:"Design"})]}),d?u.jsx("div",{className:"flex flex-1 items-center justify-center",children:u.jsx(zw,{size:"md"})}):h?u.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-center text-gray-700 dark:text-gray-300",children:h}):u.jsxs(u.Fragment,{children:[u.jsx(qa,{className:"min-h-0 flex-1 overflow-y-auto px-5 pb-5",value:"general",children:u.jsx(FL,{generalSettings:t,replyToEmailError:c,replyToEmailPlaceholder:s,senderEmailError:l,senderEmailPlaceholder:i,senderNameError:a,senderNamePlaceholder:r,showPublicationIconToggle:n,showSenderEmailInput:o,onGeneralChange:e})}),u.jsx(qa,{className:"min-h-0 flex-1 overflow-y-auto px-5 pb-5",value:"design",children:u.jsx(BL,{})})]})]});function zL(t,e){return{senderName:e.senderName,senderEmail:e.senderEmail,replyToEmail:e.replyToEmail,headerImage:t.header_image||"",showPublicationIcon:t.show_header_icon,showPublicationTitle:t.show_header_title,showBadge:t.show_badge,emailFooter:t.footer_content||""}}function $L(t){return Object.fromEntries(Object.entries(t).filter(([e])=>Sy(e)))}function HL(t){return{...Object.fromEntries(Object.entries(t.designSettings).filter(([n])=>Sy(n))),header_image:t.generalSettings.headerImage||null,show_header_icon:t.generalSettings.showPublicationIcon,show_header_title:t.generalSettings.showPublicationTitle,show_badge:t.generalSettings.showBadge,footer_content:t.generalSettings.emailFooter||null}}const UL=({message:t})=>u.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-gray-700 dark:text-gray-300",children:t}),ku=t=>t?.trim()||""||null,Cy=pe.create(()=>{const t=an(),{siteData:e,settings:n,config:r}=ke(),[i,s,o,a]=we(n,["title","default_email_address","icon","support_email_address"]),l=Ye(),{data:c,isLoading:d,isError:h}=hL(),{data:f}=eh(),{mutateAsync:m}=fL(),{mutateAsync:p}=Yg(),{mutateAsync:g}=e2(),b=ea("automations"),[x,y]=v.useState(!1),[w,k]=v.useState(!1),C=f?.automated_emails||[],{senderNameInput:S,senderEmailInput:A,replyToEmailInput:M,senderNamePlaceholder:E,senderEmailPlaceholder:j,replyToEmailPlaceholder:T,showSenderEmailInput:N,senderEmailDomain:D}=ky(C,{config:r,defaultEmailAddress:s,siteTitle:i,supportEmailAddress:a}),O=v.useMemo(()=>({senderName:S,senderEmail:A,replyToEmail:M,headerImage:"",showPublicationIcon:!0,showPublicationTitle:!0,showBadge:!0,emailFooter:""}),[M,A,S]),L=v.useCallback(async()=>{const de=new Map((f?.automated_emails||[]).map(he=>[he.slug,he]));for(const he of["free","paid"]){if(de.has(Ar[he]))continue;const _e=vf(he,i),Mt=(await p({..._e,status:"inactive"})).automated_emails?.[0];Mt&&de.set(Mt.slug,Mt)}},[p,f?.automated_emails,i]),{formState:$,saveState:U,updateForm:q,setFormState:_,handleSave:te,okProps:ce,errors:G}=zl({initialState:{designSettings:{...wy},generalSettings:O},savingDelay:500,onSave:async de=>{if(!Y)throw pi.error("Unable to load email design settings. Please try again.",{id:Ts}),y(!0),new Error("Unable to load email design settings");b||await L();const he={sender_name:ku(de.generalSettings.senderName),sender_reply_to:ku(de.generalSettings.replyToEmail),...N?{sender_email:ku(de.generalSettings.senderEmail)}:{}},{meta:{sent_email_verification:_e=[]}={}}=await g(he);await m(HL(de)),_e.length>0&&pi.info("We’ve sent a confirmation email to the new address."),y(!1),pi.dismiss(Ts)},onSaveError:de=>{l(de,{withToast:!1}),pi.error("Unable to save email design settings. Please try again.",{id:Ts}),y(!0)},onValidate:de=>{const he={},_e=de.generalSettings.senderEmail?.trim(),At=de.generalSettings.replyToEmail?.trim();return N&&_e&&(wt.isEmail(_e)?D&&_e.split("@")[1]?.toLowerCase()!==D.toLowerCase()&&(he.senderEmail=`Email address must end with @${D}`):he.senderEmail="Enter a valid email address"),At&&!wt.isEmail(At)&&(he.replyToEmail="Enter a valid email address"),he}}),[oe,B]=v.useState(null),Y=c?.automated_email_design?.[0],ee=Y?`${Y.id}:${Y.updated_at??"initial"}`:null,{designSettings:ae,generalSettings:ue}=$;v.useEffect(()=>{Y&&oe===null&&(_(de=>({designSettings:$L(Y),generalSettings:zL(Y,de.generalSettings)})),B(ee))},[Y,ee,oe,_]),v.useEffect(()=>{w||f===void 0||(_(de=>({...de,generalSettings:{...de.generalSettings,senderName:S,senderEmail:A,replyToEmail:M}})),k(!0))},[f,M,A,w,S,_]);const ve=v.useCallback(de=>{y(!1),pi.dismiss(Ts),q(he=>({...he,designSettings:{...he.designSettings,...de}}))},[q]),X=v.useCallback(de=>{y(!1),pi.dismiss(Ts),q(he=>({...he,generalSettings:{...he.generalSettings,...de}}))},[q]),se=v.useCallback(()=>{t.hide()},[t]),ie="Unable to load email design settings. Please try again.",Ne=x?{...ce,color:"red",label:"Retry"}:ce;return u.jsx(uL,{accentColor:e.accent_color,settings:ae,onSettingsChange:ve,children:u.jsx(RR,{afterClose:()=>{t.resolveHide(),t.remove()},dirty:U==="unsaved",isLoading:d||h,okProps:Ne,open:t.visible,preview:h?u.jsx(UL,{message:ie}):u.jsx(oL,{accentColor:e.accent_color,emailFooter:ue.emailFooter,footerLinkText:"Manage your preferences",headerImage:ue.headerImage,publicationIcon:o,replyToEmail:ue.replyToEmail||T||"",senderEmail:ue.senderEmail||j||s||"",senderName:ue.senderName||E||i||"Your site",settings:ae,showBadge:ue.showBadge,showPublicationIcon:ue.showPublicationIcon&&!!o,showPublicationTitle:ue.showPublicationTitle,showRecipientLine:!1,showSubjectLine:!1,siteTitle:i,subject:`Welcome to ${ue.senderName||E||i||"our publication"}`,children:u.jsx(dL,{})}),sidebar:u.jsx(VL,{errorMessage:h?ie:void 0,generalSettings:ue,isLoading:d,replyToEmailError:G.replyToEmail,replyToEmailPlaceholder:T,senderEmailError:G.senderEmail,senderEmailPlaceholder:j,senderNameError:G.senderName,senderNamePlaceholder:E,showPublicationIconToggle:!!o,showSenderEmailInput:N,onGeneralChange:X}),testId:"welcome-email-customize-modal",title:"Welcome emails",onClose:se,onSave:()=>te({fakeWhenUnchanged:!0})})})}),Ln={enableNewsletters:["emails","newsletters","newsletter sending","enable","disable","turn on","turn off"],emails:["emails","newsletters","automation emails","transactional","design","customization","automations","welcome"],defaultRecipients:["newsletters","default recipients","emails"],mailgun:["mailgun","emails","newsletters"]},WL=()=>{const t=()=>{pe.show(Cy)};return u.jsx(Mr,{children:u.jsx(ls,{action:u.jsx("button",{className:"font-semibold text-green hover:opacity-80",type:"button",onClick:t,children:"Edit"}),hideActions:!1,testId:"automations-transactional-row",children:u.jsxs("button",{className:"flex w-full min-w-0 items-center gap-3 py-3 text-left focus-visible:ring-2 focus-visible:ring-green focus-visible:ring-offset-2 focus-visible:outline-none dark:focus-visible:ring-offset-black",type:"button",onClick:t,children:[u.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-grey-100 dark:bg-grey-900",children:u.jsx(me,{colorClass:"text-grey-700 dark:text-grey-600",name:"mailplus",size:"md"})}),u.jsxs("div",{className:"min-w-0 grow",children:[u.jsx("div",{className:"leading-tight font-medium",children:"Email design"}),u.jsx("div",{className:"mt-1 text-sm leading-[1.35] text-grey-700 dark:text-grey-600",children:"Customize the appearance of automation emails"})]})]})})})},KL=()=>{const t=window.location.hash.slice(1);return new URL(t||"/",window.location.origin).pathname.startsWith("/settings/memberemails")},GL=({keywords:t,newslettersEnabled:e})=>{const{updateRoute:n}=fe(),r=Qo().getParam("verifyEmail"),{mutateAsync:i}=Xg(),s=Ye(),o=v.useRef(null),[a,l]=v.useState(e?"newsletters":"transactional"),[c,d]=v.useState("active");v.useEffect(()=>{!e&&a==="newsletters"&&l("transactional")},[e,a]),v.useEffect(()=>{if(!r||!KL()||o.current===r)return;o.current=r,l("transactional"),(async()=>{try{const{meta:{email_verified:p}={}}=await i({token:r});let g="Sender email verified",b=u.jsx(u.Fragment,{children:"Automation email sender settings have been updated."});p==="sender_reply_to"&&(g="Reply-to address verified",b=u.jsx(u.Fragment,{children:"Automation email reply-to address has been verified and updated."})),n("emails"),pe.show(Wt,{title:g,prompt:b,okLabel:"Close",cancelLabel:"",onOk:x=>x?.remove()})}catch(p){let g="There was an error verifying your email address. Try again later.";p instanceof Vl&&p.message==="Token expired"&&(g="Verification link has expired."),n("emails"),pe.show(Wt,{title:"Error verifying email address",prompt:g,okLabel:"Close",cancelLabel:"",onOk:b=>b?.remove()}),s(p,{withToast:!1})}})()},[s,n,r,i]);const h=()=>{n("newsletters/new")},f=e&&a==="newsletters"?u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Add newsletter",size:"sm",onClick:h}):void 0;return u.jsx(Se,{customButtons:f,description:"Manage newsletters and design automation emails.",keywords:t,navid:"emails",testId:"emails",title:"Newsletters & automation emails",children:u.jsxs(th,{value:a,variant:"underline",onValueChange:m=>l(m),children:[u.jsxs("div",{className:"flex items-center justify-between border-b border-grey-200 dark:border-grey-900",children:[u.jsxs(nh,{className:"border-b-0",children:[e&&u.jsx(zi,{value:"newsletters",children:"Newsletters"}),u.jsx(zi,{value:"transactional",children:"Automation emails"})]}),e&&a==="newsletters"&&u.jsxs(Eo,{value:c,onValueChange:m=>d(m),children:[u.jsx(jo,{className:"h-7 w-auto gap-1 border-0 bg-transparent px-2 text-sm shadow-none hover:bg-muted focus:ring-0 focus:ring-offset-0","data-testid":"newsletters-filter",children:u.jsx(No,{})}),u.jsxs(To,{children:[u.jsx($i,{value:"active",children:"Active"}),u.jsx($i,{value:"archived",children:"Archived"})]})]})]}),e&&u.jsx(qa,{value:"newsletters",children:u.jsx(OR,{filter:c})}),u.jsx(qa,{value:"transactional",children:u.jsx(WL,{})})]})})},qL=()=>{const{settings:t,config:e}=ke(),[n]=we(t,["editor_default_email_recipients"]),r=n!=="disabled",i=r&&!e.mailgunIsConfigured,s=[Ln.enableNewsletters,...r?[Ln.defaultRecipients]:[],Ln.emails,...i?[Ln.mailgun]:[]].flat();return u.jsxs(ui,{keywords:s,title:"Email",children:[u.jsx(dy,{keywords:Ln.enableNewsletters}),r&&u.jsx(uy,{keywords:Ln.defaultRecipients}),u.jsx(GL,{keywords:Ln.emails,newslettersEnabled:r}),i&&u.jsx(hy,{keywords:Ln.mailgun})]})},YL=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,handleEditingChange:a}=Ft(),[l,c,d,h,f,m]=we(e,["email_track_opens","email_track_clicks","members_track_sources","outbound_link_tagging","web_analytics","web_analytics_configured"]),p=Tu(e,"email_track_clicks"),[g,b]=v.useState(!1),x=fs(),{updateRoute:y}=fe();v.useEffect(()=>{x?.isLimited("limitAnalytics")?x.errorIfWouldGoOverLimit("limitAnalytics").catch(S=>{S instanceof Zo&&b(!0)}):b(!1)},[x]);const w=(S,A)=>{o(S,A.target.checked),a(!0)},k=m&&!g,C=u.jsxs(tt,{className:"analytics-settings gap-y-0!",columns:1,children:[u.jsx(en,{align:"center",checked:f&&k,containerClasses:"py-4",direction:"rtl",disabled:!k,gap:"gap-0",hint:m?u.jsxs(u.Fragment,{children:["Cookie-free, first party traffic analytics for your site, powered by ",u.jsx("a",{className:"text-green",href:"https://ghost.org/integrations/tinybird",rel:"noopener noreferrer",target:"_blank",children:"Tinybird"})]}):u.jsx(u.Fragment,{children:"Cookie-free, first party traffic analytics for your site"}),label:"Web analytics",onChange:S=>{w("web_analytics",S)}}),g?u.jsx("div",{className:"mb-5 rounded-md border border-grey-200 bg-grey-50 px-4 py-2.5 dark:border-grey-900 dark:bg-grey-900",children:u.jsx("span",{className:"flex items-start gap-2",children:u.jsxs("span",{children:["Web analytics is available on the Publisher plan and above. ",u.jsx("span",{className:"cursor-pointer text-green",onClick:()=>y({route:"/pro",isExternal:!0}),children:"Upgrade now →"})]})})}):m?u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}):u.jsx("div",{className:"mb-5 rounded-md border border-grey-200 bg-grey-50 px-4 py-2.5 dark:border-grey-900 dark:bg-grey-900",children:u.jsx("span",{className:"flex items-start gap-2",children:u.jsxs("span",{children:["Web analytics in Ghost is powered by ",u.jsx("a",{className:"font-medium text-green",href:"https://tbrd.co/ghost",rel:"noopener noreferrer",target:"_blank",children:"Tinybird"})," and requires configuration to start collecting data. ",u.jsx("a",{className:"font-medium text-green",href:"https://docs.ghost.org/install/docker#tinybird-integration",rel:"noopener noreferrer",target:"_blank",children:"Get started →"})]})})}),u.jsx(en,{align:"center",checked:l,containerClasses:"py-4",direction:"rtl",gap:"gap-0",hint:"Record when a member opens an email",label:"Newsletter opens",onChange:S=>{w("email_track_opens",S)}}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsx(en,{align:"center",checked:c,containerClasses:"py-4",direction:"rtl",disabled:p,gap:"gap-0",hint:"Record when a member clicks on any link in an email",label:"Newsletter clicks",onChange:S=>{w("email_track_clicks",S)}}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsx(en,{align:"center",checked:d,containerClasses:"py-4",direction:"rtl",gap:"gap-0",hint:"Track the traffic sources and posts that drive the most member growth",label:"Member sources",onChange:S=>{w("members_track_sources",S)}}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsx(en,{align:"center",checked:h,containerClasses:"py-4",direction:"rtl",gap:"gap-0",hint:"Make it easier for other sites to track the traffic you send them in their analytics",label:"Outbound link tagging",onChange:S=>{w("outbound_link_tagging",S)}})]});return u.jsxs(Se,{description:"Decide what data you collect across your publication",isEditing:n,keywords:t,navid:"analytics",saveState:r,testId:"analytics",title:"Analytics",hideEditButton:!0,onCancel:s,onEditingChange:a,onSave:i,children:[C,u.jsx("div",{className:"items-center-mt-1 flex justify-between",children:u.jsx("a",{className:"font-medium text-green",href:"https://ghost.org/help/post-analytics/",rel:"noopener noreferrer",target:"_blank",children:"Learn about analytics"})})]})},XL=Ce(YL,"Analytics"),JL=[{code:"af",label:"Afrikaans"},{code:"ar",label:"Arabic"},{code:"bg",label:"Bulgarian"},{code:"bn",label:"Bengali"},{code:"bs",label:"Bosnian"},{code:"ca",label:"Catalan"},{code:"cs",label:"Czech"},{code:"da",label:"Danish"},{code:"de",label:"German"},{code:"de-CH",label:"Swiss German"},{code:"el",label:"Greek"},{code:"en",label:"English"},{code:"eo",label:"Esperanto"},{code:"es",label:"Spanish"},{code:"et",label:"Estonian"},{code:"eu",label:"Basque"},{code:"fa",label:"Persian/Farsi"},{code:"fi",label:"Finnish"},{code:"fr",label:"French"},{code:"gd",label:"Gaelic (Scottish)"},{code:"he",label:"Hebrew"},{code:"hi",label:"Hindi"},{code:"hr",label:"Croatian"},{code:"hu",label:"Hungarian"},{code:"id",label:"Indonesian"},{code:"is",label:"Icelandic"},{code:"it",label:"Italian"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"kz",label:"Kazakh"},{code:"lt",label:"Lithuanian"},{code:"lv",label:"Latvian"},{code:"mk",label:"Macedonian"},{code:"mn",label:"Mongolian"},{code:"ms",label:"Malay"},{code:"nb",label:"Norwegian Bokmål"},{code:"ne",label:"Nepali"},{code:"nl",label:"Dutch"},{code:"nn",label:"Norwegian Nynorsk"},{code:"pa",label:"Punjabi"},{code:"pl",label:"Polish"},{code:"pt",label:"Portuguese"},{code:"pt-BR",label:"Portuguese (Brazil)"},{code:"ro",label:"Romanian"},{code:"ru",label:"Russian"},{code:"si",label:"Sinhala"},{code:"sk",label:"Slovak"},{code:"sl",label:"Slovenian"},{code:"sq",label:"Albanian"},{code:"sr",label:"Serbian"},{code:"sr-Cyrl",label:"Serbian (Cyrillic)"},{code:"sv",label:"Swedish"},{code:"sw",label:"Swahili"},{code:"ta",label:"Tamil"},{code:"th",label:"Thai"},{code:"tr",label:"Turkish"},{code:"uk",label:"Ukrainian"},{code:"ur",label:"Urdu"},{code:"uz",label:"Uzbek"},{code:"vi",label:"Vietnamese"},{code:"zh",label:"Chinese"},{code:"zh-Hant",label:"Traditional Chinese"}],ZL=new Set(["en-gb-oed","i-ami","i-bnn","i-default","i-enochian","i-hak","i-klingon","i-lux","i-mingo","i-navajo","i-pwn","i-tao","i-tay","i-tsu","sgn-be-fr","sgn-be-nl","sgn-ch-de","art-lojban","cel-gaulish","no-bok","no-nyn","zh-guoyu","zh-hakka","zh-min","zh-min-nan","zh-xiang"]),Eg=t=>{const e="Invalid locale format. Examples: en, pt-BR, zh-Hant, sr-Cyrl, x-private";if(!t)return"Enter a value";const n=t.trim();if(!n)return e;if(ZL.has(n.toLowerCase()))return null;if(!/^[a-z0-9]+(-[a-z0-9]+)*$/i.test(n))return e;const r=n.split("-");if(r[0].toLowerCase()==="x"){if(r.length<2)return e;for(let l=1;l<r.length;l++)if(r[l].length<1||r[l].length>8)return e;return null}let i=0;const s=r[i];if(!/^[a-z]{2,3}$/i.test(s))return e;for(i+=1,i<r.length&&/^[a-z]{4}$/i.test(r[i])&&(i+=1),i<r.length&&/^([a-z]{2}|[0-9]{3})$/i.test(r[i])&&(i+=1);i<r.length&&/^([a-z0-9]{5,8}|[0-9][a-z0-9]{3})$/i.test(r[i]);)i+=1;for(;i<r.length&&/^[0-9a-wy-z]$/i.test(r[i]);){if(i+=1,i>=r.length||!/^[a-z0-9]{2,8}$/i.test(r[i]))return e;for(i+=1;i<r.length&&/^[a-z0-9]{2,8}$/i.test(r[i]);)i+=1}if(i<r.length&&r[i].toLowerCase()==="x"){if(i+=1,i>=r.length)return e;for(;i<r.length;){if(!/^[a-z0-9]+$/i.test(r[i]))return e;i+=1}}if(i!==r.length)return e;const o=r.findIndex(l=>l.toLowerCase()==="x"),a=["english","french","spanish","german","italian","chinese","japanese","korean","russian","arabic","united","states","kingdom","traditional","simplified"];for(let l=0;l<r.length;l++){const c=r[l];if(!["i","x","sgn","art","cel","no","zh"].includes(c.toLowerCase())&&!(o!==-1&&l>o)&&(c.length>16||a.includes(c.toLowerCase())))return e}return null},QL=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,errors:a,handleEditingChange:l}=Ft({onValidate:()=>{const m=Eg(c);return m?{publicationLanguage:m}:{}}}),[c]=we(e,["locale"]),d=W.useMemo(()=>JL.map(p=>({value:p.code,label:`${p.label} (${p.code})`})),[]),h=m=>{o("locale",m),n||l(!0)},f=u.jsxs(u.Fragment,{children:["Default: English (",u.jsx("strong",{children:"en"}),"); find out more about",u.jsx("a",{className:"text-green-400",href:"https://ghost.org/docs/faq/translation/",rel:"noopener noreferrer",target:"_blank",children:" using Ghost in other languages"})]});return u.jsx(Se,{description:"Set the language/locale which is used on your site",isEditing:n,keywords:t,navid:"publication-language",saveState:r,testId:"publication-language",title:"Publication Language",hideEditButton:!0,onCancel:s,onEditingChange:l,onSave:i,children:u.jsx(tt,{columns:1,children:u.jsx(T5,{defaultListValue:"en",error:!!a.publicationLanguage,hint:a.publicationLanguage||f,options:d,otherHint:"Enter a custom locale code.",otherPlaceholder:"e.g. pt-BR, sr-Cyrl, en",selectedValue:c,testId:"locale-select",title:"Site language",validate:Eg,isSearchable:!0,onSelect:h})})})},e6=Ce(QL,"Publication language"),t6=({title:t,description:e,icon:n,url:r})=>{const i=r?.replace(/\/$/,""),s=i?.replace(/^https?:\/\//,"").replace(/\/?$/,"");return u.jsx("div",{children:u.jsxs("div",{className:"-mx-5 -mb-5 overflow-hidden rounded-b-xl bg-grey-50 px-5 pt-2 md:-mx-7 md:-mb-7 md:px-7 md:pt-7 dark:bg-grey-950",children:[u.jsx("div",{className:"-mt-4 mb-2 text-sm text-grey-500 uppercase dark:text-grey-800",children:"Preview"}),u.jsxs("div",{className:"rounded-t-sm bg-white px-5 py-3 shadow-lg dark:bg-grey-950",children:[u.jsxs("div",{className:"mt-3 flex items-center",children:[u.jsx("div",{children:u.jsx(cE,{className:"mr-7 h-7"})}),u.jsx("div",{className:"grow",children:u.jsx("div",{className:"flex w-full items-center justify-end rounded-full bg-white p-3 px-4 shadow dark:bg-grey-900",children:u.jsx(me,{className:"stroke-[2px] text-blue-600",name:"magnifying-glass",size:"sm"})})})]}),u.jsxs("div",{className:"mt-4 flex items-center gap-2 border-t border-grey-200 pt-4 dark:border-grey-900",children:[u.jsx("div",{className:"flex size-7 items-center justify-center rounded-full bg-grey-200 dark:bg-grey-700",style:{backgroundImage:n?`url(${n})`:"none",backgroundSize:"contain"}}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{children:s}),u.jsx("span",{className:"-mt-0.5 inline-block text-sm text-grey-600",children:i})]})]}),u.jsxs("div",{className:"mt-1 flex flex-col",children:[u.jsx("span",{className:"text-lg text-[#1a0dab] dark:text-blue",children:t}),u.jsx("span",{className:"text-grey-900 dark:text-grey-700",children:e})]})]})]})})},n6=({keywords:t})=>{const{localSettings:e,saveState:n,siteData:r,focusRef:i,isEditing:s,handleSave:o,handleCancel:a,handleEditingChange:l,updateSetting:c}=Ft(),d=Ye(),{mutateAsync:h}=gy(),f=oy(),m=ea("llmsTxt"),[p,g,b,x,y,w,k,C,S,A]=we(e,["meta_title","meta_description","title","description","og_title","og_description","og_image","twitter_title","twitter_description","twitter_image"]).map(X=>X||""),[M]=we(e,["llms_enabled"]),E=M!==!1,[j,T]=v.useState("metadata"),N=X=>se=>{c(X,se.target.value),s||l(!0)},D=X=>async se=>{try{const ie=Ga(await h({file:se}));c(X,ie),s||l(!0)}catch(ie){const Ne=ie;Ne.response.status===415&&(Ne.message="Unsupported file type"),d(Ne)}},O=X=>()=>{c(X,""),s||l(!0)},L=X=>{c("llms_enabled",X.target.checked),s||l(!0)},$=N("meta_title"),U=N("meta_description"),q=N("og_title"),_=N("og_description"),te=D("og_image"),ce=O("og_image"),G=N("twitter_title"),oe=N("twitter_description"),B=D("twitter_image"),Y=O("twitter_image"),ee=u.jsxs(u.Fragment,{children:[u.jsxs(tt,{className:"my-6 gap-3",children:[m&&u.jsx(en,{checked:E,direction:"rtl",label:"Enable structured data for LLMs and AI search engines",onChange:L}),u.jsx(at,{hint:"Recommended: 70 characters",inputRef:i,maxLength:300,placeholder:b,title:"Meta title",value:p,onChange:$}),u.jsx(at,{hint:"Recommended: 156 characters",maxLength:500,placeholder:x,title:"Meta description",value:g,onChange:U})]}),u.jsx(t6,{description:g||x,icon:r?.icon,title:p||b,url:r?.url})]}),ae=u.jsxs("div",{className:"mt-6 md:mx-[52px]",children:[u.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[u.jsx("div",{children:u.jsx(lE,{className:"size-10"})}),u.jsxs("div",{children:[u.jsx("div",{className:"mb-1 leading-none font-semibold text-grey-900 dark:text-grey-300",children:b}),u.jsx("div",{className:"leading-none text-grey-700",children:"2h"})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"mb-2 h-3 w-full rounded bg-grey-200 dark:bg-grey-900"}),u.jsx("div",{className:"mb-4 h-3 w-3/5 rounded bg-grey-200 dark:bg-grey-900"}),u.jsxs(tt,{className:"overflow-hidden rounded-md border border-grey-300 dark:border-grey-900",children:[u.jsx(Of,{fileUploadClassName:"flex cursor-pointer items-center justify-center rounded rounded-b-none border border-grey-100 border-b-0 bg-grey-50 p-3 font-semibold text-grey-800 hover:text-black dark:border-grey-900",height:"300px",id:"facebook-image",imageURL:k,pintura:{isEnabled:f.isEnabled,openEditor:async()=>f.openEditor({image:k||"",handleSave:async X=>{const se=Ga(await h({file:X}));c("og_image",se)}})},onDelete:ce,onUpload:te,children:"Upload Facebook image"}),u.jsxs("div",{className:"mt-5 flex flex-col gap-x-6 gap-y-7 px-4 pb-7",children:[u.jsx(at,{maxLength:300,placeholder:b,title:"Facebook title",value:y,onChange:q}),u.jsx(at,{maxLength:300,placeholder:x,title:"Facebook description",value:w,onChange:_})]})]})]})]}),ue=u.jsxs("div",{className:"mt-6 flex flex-col gap-3 md:flex-row",children:[u.jsx("div",{className:"pt-1",children:u.jsx(uE,{className:"-mb-1 size-10"})}),u.jsxs("div",{className:"w-full md:mr-[52px]",children:[u.jsxs("div",{className:"mb-2",children:[u.jsx("span",{className:"mr-1 font-semibold text-grey-900 dark:text-grey-300",children:b}),u.jsx("span",{className:"text-grey-700",children:"· 2h"})]}),u.jsx("div",{className:"mb-2 h-3 w-full rounded bg-grey-200 dark:bg-grey-900"}),u.jsx("div",{className:"mb-4 h-3 w-3/5 rounded bg-grey-200 dark:bg-grey-900"}),u.jsxs(tt,{className:"overflow-hidden rounded-md border border-grey-300 dark:border-grey-900",children:[u.jsx(Of,{fileUploadClassName:"flex cursor-pointer items-center justify-center rounded rounded-b-none border border-grey-100 border-b-0 bg-grey-50 p-3 font-semibold text-grey-800 hover:text-black dark:border-grey-900",height:"300px",id:"twitter-image",imageURL:A,pintura:{isEnabled:f.isEnabled,openEditor:async()=>f.openEditor({image:A||"",handleSave:async X=>{const se=Ga(await h({file:X}));c("twitter_image",se)}})},onDelete:Y,onUpload:B,children:"Upload X image"}),u.jsxs("div",{className:"mt-6 flex flex-col gap-x-6 gap-y-7 px-4 pb-7",children:[u.jsx(at,{maxLength:300,placeholder:b,title:"X title",value:C,onChange:G}),u.jsx(at,{maxLength:300,placeholder:x,title:"X description",value:S,onChange:oe})]})]})]})]}),ve=[{id:"metadata",title:"Search",contents:ee},{id:"twitter",title:"X card",contents:ue},{id:"facebook",title:"Facebook card",contents:ae}];return u.jsx(Se,{description:"Extra content for search engines and social accounts",isEditing:s,keywords:t,navid:"metadata",saveState:n,testId:"seometa",title:"Meta data",hideEditButton:!0,onCancel:a,onEditingChange:l,onSave:o,children:u.jsx(hr,{selectedTab:j,tabs:ve,testId:"seo-tabview",onTabChange:T})})},r6=Ce(n6,"SEO meta");function i6(t){const e="The URL must be in a format like https://www.facebook.com/yourPage";if(!t)return"";if(t=t.replace(/(https?:\/\/)?(www\.)?facebook\.com/i,""),t.match(/^(http|\/\/)/i))throw new Error(e);if(t=t.replace(/^\//,""),t=`https://www.facebook.com/${t}`,!wt.isURL(t))throw new Error(e);return t}const s6=t=>`https://www.facebook.com/${t}`,o6=t=>t.match(/(?:https:\/\/)(?:www\.)(?:facebook\.com)\/(?:#!\/)?(\w+\/?\S+)/i)?.[1]||null,Su=/^x\.com\/([a-zA-Z0-9_]{1,15})$/;function a6(t){if(!t)return"";if(t.match(Su)||t.match(/([a-z\d.]+)/i)){let e=[];if(t.match(Su)?[,e]=t.match(Su):[e]=t.match(/([^/]+)\/?$/i),e.startsWith("@")&&(e=e.slice(1)),!e.match(/^[a-z\d_]{1,15}$/i))throw new Error("Your Username is not a valid Twitter Username");return`https://x.com/${e}`}else{const e="The URL must be in a format like https://x.com/yourUsername";throw new Error(e)}}const l6=t=>`https://x.com/${t.replace("@","")}`,c6=t=>{const e=t.match(/(?:https:\/\/)(?:x\.com)\/(?:#!\/)?@?([^/]*)/)?.[1];return e?`@${e}`:null};function u6(t){const e="The URL must be in a format like https://www.threads.net/@yourUsername";if(!t)return"";if(t.startsWith("http")){if(!t.includes("threads.net")&&!t.includes("threads.com"))throw new Error(e);if(t=t.replace("threads.com","threads.net"),t.includes("www.")||(t=t.replace("https://","https://www.")),!wt.isURL(t))throw new Error(e);if(!t.match(/^https:\/\/www\.threads\.net\/@?[a-zA-Z0-9._]+$/))throw new Error(e);return t}if(!t.includes("/")){if(t.startsWith("@")&&(t=t.slice(1)),!t.match(/^[a-zA-Z0-9._]+$/))throw new Error(e);return`https://www.threads.net/@${t}`}throw new Error(e)}const d6=t=>`https://www.threads.net/${t}`,h6=t=>{const e=t.match(/(?:https:\/\/)(?:www\.)?(?:threads\.(?:com|net))(?:\/)?(?:#!\/)?@?([^/]*)/)?.[1];return e?`@${e}`:null},Ei={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 Ay(t){return[/^did:plc:[a-z2-7]{24}$/,/^[a-zA-Z0-9._]{1,15}$/,/^(?=.{1,191}$)[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$/].some(n=>n.test(t))}function Gd(t){let e=t.trim();return e.startsWith("@")&&(e=e.slice(1)),e.startsWith("did:plc:")?e.toLowerCase():e}function f6(t){if(!t)return"";let e;if(t.startsWith("http")||t.startsWith("www.")||t.includes("bsky.app")){if(!t.includes("bsky.app"))throw new Error(Ei.INVALID_URL);const r=t.match(/bsky\.app\/profile\/@?([^/]+)/);if(!r)throw new Error(Ei.INVALID_URL);e=Gd(r[1])}else e=Gd(t);if(!Ay(e))throw new Error(Ei.INVALID_USERNAME);const n=`https://bsky.app/profile/${e}`;if(!wt.isURL(n))throw new Error(Ei.INVALID_URL);return n}const m6=t=>{if(!t)throw new Error(Ei.INVALID_USERNAME);let e=Gd(t);if(!Ay(e))throw new Error(Ei.INVALID_USERNAME);return`https://bsky.app/profile/${e}`},p6=t=>{const e=t.match(/(?:https?:\/\/)?(?:www\.)?bsky\.app\/profile\/@?([^/]*)/);return e?`${e[1]}`:null},ti={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"},g6=["in","pub","company","school"],b6=/^[a-zA-Z0-9-]{3,100}$/,v6=/^[a-zA-Z0-9-]{3,100}(?:\/[a-zA-Z0-9-]*)*$/,My=/^(?:https?:\/\/)?(?:www\.)?(?:([a-z]{2})\.)?linkedin\.com\/(in|pub|company|school)\/([^?#]+)/i,qd=t=>t.trim().replace(/^@/,"").replace(/\/$/,""),Ey=t=>{if(/^(https?:\/\/|www\.)/.test(t)||t.includes("linkedin.com")){const r=t.match(My);if(!r)throw new Error(ti.INVALID_URL);if(r[0].length!==t.length)throw new Error(ti.INVALID_USERNAME);const[,i,s,o]=r,a=qd(o);if(i&&!/^[A-Z]{2}$/.test(i.toUpperCase()))throw new Error(ti.INVALID_URL);return{regional:i,pathType:s,username:a}}const e=qd(t),n=e.indexOf("/");if(n!==-1){const r=e.substring(0,n);if(g6.includes(r))return{pathType:r,username:e.substring(n+1)}}return{username:e}},jy=(t,e)=>(t==="pub"?v6:b6).test(e),Ny=({regional:t,pathType:e,username:n})=>{const i=`https://${t?`${t.toLowerCase()}.`:"www."}linkedin.com/${e}/${n}`;if(!wt.isURL(i))throw new Error(ti.INVALID_URL);return i};function x6(t){if(!t)return"";const{regional:e,pathType:n="in",username:r}=Ey(t);if(!jy(n,r))throw new Error(ti.INVALID_USERNAME);return Ny({regional:e,pathType:n,username:r})}const y6=t=>{if(!t)throw new Error(ti.INVALID_USERNAME);const{regional:e,pathType:n="in",username:r}=Ey(t);if(!jy(n,r))throw new Error(ti.INVALID_USERNAME);return Ny({regional:e,pathType:n,username:r})},w6=t=>{const e=t.match(My);if(!e)return null;const[,,n,r]=e,i=qd(r);return n==="in"?i:`${n}/${i}`};function k6(t){const e="The URL must be in a format like https://www.instagram.com/yourUsername",n="Your Username is not a valid Instagram Username";if(!t)return"";let r;if(t.startsWith("http")||t.startsWith("www.")||t.includes("instagram.com")){if(!t.includes("instagram.com"))throw new Error(e);const s=t.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]+)/);if(!s)throw new Error(e);r=s[1]}else r=t.startsWith("@")?t.slice(1):t;if(!r.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||r.includes("..")||r.length>30)throw new Error(n);const i=`https://www.instagram.com/${r}`;if(!wt.isURL(i))throw new Error(e);return i}const S6=t=>{const e="Your Username is not a valid Instagram Username";if(!t)throw new Error(e);let n=t;if(n.startsWith("@")&&(n=n.slice(1)),!n.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||n.includes("..")||n.length>30)throw new Error(e);return`https://www.instagram.com/${n}`},C6=t=>{const e=t.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]*)/);return e?`${e[1]}`:null};function A6(t){const e="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",n="Your Username is not a valid YouTube Username";if(!t)return"";let r;if(t.startsWith("http")||t.startsWith("www.")||t.includes("youtube.com")){if(!t.includes("youtube.com"))throw new Error(e);const s=t.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]+)/);if(!s)throw new Error(e);r=s[1]}else r=t;if(r.startsWith("@")){const s=r.slice(1);if(!s.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||s.includes("..")||s.length>30)throw new Error(n)}else if(r.startsWith("user/")){if(!r.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(n)}else if(r.startsWith("channel/")){if(!r.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(n)}else throw new Error(e);const i=`https://www.youtube.com/${r}`;if(!wt.isURL(i))throw new Error(e);return i}const M6=t=>{const e="Your Username is not a valid YouTube Username";if(!t)throw new Error(e);if(t.startsWith("@")){const n=t.slice(1);if(!n.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||n.includes("..")||n.length>30)throw new Error(e)}else if(t.startsWith("user/")){if(!t.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(e)}else if(t.startsWith("channel/")){if(!t.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(e)}else throw new Error("The handle must be in a format like @yourUsername, user/yourUsername, or channel/yourChannelId");return`https://www.youtube.com/${t}`},E6=t=>{const e=t.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]*)/);return e?e[1]:null};function j6(t){const e="The URL must be in a format like https://www.tiktok.com/@yourUsername",n="Your Username is not a valid TikTok Username";if(!t)return"";let r;if(t.startsWith("http")||t.startsWith("www.")||t.includes("tiktok.com")){if(!t.includes("tiktok.com"))throw new Error(e);const o=t.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]+)/);if(!o)throw new Error(e);r=o[1]}else r=t.startsWith("@")?t:`@${t}`;const i=r.slice(1);if(!i.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||i.includes("..")||i.length<2||i.length>24)throw new Error(n);const s=`https://www.tiktok.com/${r}`;if(!wt.isURL(s))throw new Error(e);return s}const N6=t=>{const e="Your Username is not a valid TikTok Username";if(!t)throw new Error(e);const n=t.startsWith("@")?t:`@${t}`,r=n.slice(1);if(!r.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||r.includes("..")||r.length<2||r.length>24)throw new Error(e);return`https://www.tiktok.com/${n}`},T6=t=>{const e=t.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]*)/);return e?e[1]:null};function D6(t){const e="The URL must be in a format like @username@instance.tld or https://instance.tld/@username or https://website.com/@username@instance.tld";if(!t)return"";let n=t;if(n=n.replace(/^https?:\/\//,""),n.match(/^@[^@]+@[^/]+$/)){const[r,i]=n.split("@").slice(1);if(!wt.isFQDN(i))throw new Error(e);return`https://${i}/@${r}`}if(n.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[r,i]=n.split("/@");if(!wt.isFQDN(r))throw new Error(e);if(i.includes("@")){const[,s]=i.split("@");if(!wt.isFQDN(s))throw new Error(e)}return`https://${n}`}throw new Error(e)}const O6=t=>{const e="Your Username is not a valid Mastodon Username";if(!t)throw new Error(e);if(t.match(/^@[^@]+@[^/]+$/)){const[n,r]=t.split("@").slice(1);if(!wt.isFQDN(r))throw new Error(e);return`https://${r}/@${n}`}if(t.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[n,r]=t.split("/@");if(!wt.isFQDN(n))throw new Error(e);if(r.includes("@")){const[,i]=r.split("@");if(!wt.isFQDN(i))throw new Error(e)}return`https://${t}`}throw new Error(e)},I6=t=>t.replace(/^https?:\/\//,""),yf=["twitter","facebook","linkedin","bluesky","threads","mastodon","tiktok","youtube","instagram"],er=(t,e)=>t?e(t):"",Fl=[{key:"twitter",staffTitle:"X",publicationTitle:"X",placeholder:"https://x.com/username",testId:"x-input",validate:a6,toDisplayValue:t=>er(t,l6),toStoredValue:t=>c6(t)},{key:"facebook",staffTitle:"Facebook",publicationTitle:"Facebook",placeholder:"https://www.facebook.com/username",testId:"facebook-input",validate:i6,toDisplayValue:t=>er(t,s6),toStoredValue:t=>o6(t)},{key:"linkedin",staffTitle:"LinkedIn",publicationTitle:"LinkedIn",placeholder:"https://www.linkedin.com/in/username",testId:"linkedin-input",validate:x6,toDisplayValue:t=>er(t,y6),toStoredValue:t=>w6(t)},{key:"bluesky",staffTitle:"Bluesky",publicationTitle:"Bluesky",placeholder:"https://bsky.app/profile/username",testId:"bluesky-input",validate:f6,toDisplayValue:t=>er(t,m6),toStoredValue:t=>p6(t)},{key:"threads",staffTitle:"Threads",publicationTitle:"Threads",placeholder:"https://threads.net/@username",testId:"threads-input",validate:u6,toDisplayValue:t=>er(t,d6),toStoredValue:t=>h6(t)},{key:"mastodon",staffTitle:"Mastodon",publicationTitle:"Mastodon",placeholder:"https://mastodon.social/@username",testId:"mastodon-input",validate:D6,toDisplayValue:t=>er(t,O6),toStoredValue:t=>t?I6(t):null},{key:"tiktok",staffTitle:"TikTok",publicationTitle:"TikTok",placeholder:"https://www.tiktok.com/@username",testId:"tiktok-input",validate:j6,toDisplayValue:t=>er(t,N6),toStoredValue:t=>T6(t)},{key:"youtube",staffTitle:"YouTube",publicationTitle:"YouTube",placeholder:"https://www.youtube.com/@channel",testId:"youtube-input",validate:A6,toDisplayValue:t=>er(t,M6),toStoredValue:t=>E6(t)},{key:"instagram",staffTitle:"Instagram",publicationTitle:"Instagram",placeholder:"https://www.instagram.com/username",testId:"instagram-input",validate:k6,toDisplayValue:t=>er(t,S6),toStoredValue:t=>C6(t)}],Ty=Object.fromEntries(Fl.map(t=>[t.key,t])),jg=(t,e)=>{const n=Ty[t],r=n.validate(e),i=r?n.toStoredValue(r):null;return{displayValue:n.toDisplayValue(i),storedValue:i}},Cu=(t,e)=>{try{return Ty[t].validate(e||""),""}catch(n){return n instanceof Error?n.message:""}},Dy=["facebook","twitter"],P6=yf.filter(t=>!Dy.includes(t)),Ng=t=>{const e=we(t,[...yf]);return Object.fromEntries(Fl.map((n,r)=>{const i=e[r];return[n.key,n.toDisplayValue(i)]}))},R6=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,handleEditingChange:a}=Ft(),[l,c]=v.useState({}),[d,h]=v.useState(()=>Ng(e)),[f,m]=v.useState(null),p=we(e,[...yf]),g=P6.some(k=>e?.some(C=>C.key===k)),b=v.useMemo(()=>g?Fl:Fl.filter(k=>Dy.includes(k.key)),[g]);v.useEffect(()=>{f||h(Ng(e))},[p.map(k=>k??"").join("|")]);const x=(k,C)=>{h(S=>({...S,[k]:C})),n||a(!0);try{const{storedValue:S}=jg(k,C);o(k,S),l[k]&&c(A=>({...A,[k]:""}))}catch{c(S=>({...S,[k]:Cu(k,C)}))}},y=k=>{if(m(S=>S===k?null:S),Cu(k,d[k]))return;const{displayValue:C}=jg(k,d[k]);h(S=>({...S,[k]:C}))},w=()=>{const k=b.reduce((C,S)=>{const A=Cu(S.key,d[S.key]);return A&&(C[S.key]=A),C},{});c(k),Object.keys(k).length===0&&i()};return u.jsx(Se,{description:"Link your social accounts for full structured data and rich card support",isEditing:n,keywords:t,navid:"social-accounts",saveState:r,testId:"social-accounts",title:"Social accounts",hideEditButton:!0,onCancel:s,onEditingChange:a,onSave:w,children:u.jsx(tt,{children:b.map(k=>u.jsx(at,{"data-testid":k.testId,error:!!l[k.key],hint:l[k.key],placeholder:k.placeholder,title:k.publicationTitle,value:d[k.key],onBlur:()=>y(k.key),onChange:C=>x(k.key,C.target.value),onFocus:()=>m(k.key)},k.key))})})},L6=Ce(R6,"Social accounts"),_6=[{name:"Pacific/Pago_Pago",label:"Midway Island, Samoa"},{name:"Pacific/Honolulu",label:"Hawaii"},{name:"America/Anchorage",label:"Alaska"},{name:"America/Tijuana",label:"Tijuana"},{name:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{name:"America/Mazatlan",label:"La Paz, Mazatlan"},{name:"America/Phoenix",label:"Arizona"},{name:"America/Denver",label:"Mountain Time (US & Canada)"},{name:"America/Chihuahua",label:"Chihuahua"},{name:"America/Costa_Rica",label:"Central America"},{name:"America/Chicago",label:"Central Time (US & Canada)"},{name:"America/Mexico_City",label:"Guadalajara, Mexico City, Monterrey"},{name:"America/Regina",label:"Saskatchewan"},{name:"America/Bogota",label:"Bogota, Lima, Quito"},{name:"America/New_York",label:"Eastern Time (US & Canada)"},{name:"America/Fort_Wayne",label:"Indiana (East)"},{name:"America/Caracas",label:"Caracas, La Paz, Georgetown"},{name:"America/Halifax",label:"Atlantic Time (Canada); Greenland"},{name:"America/Santiago",label:"Santiago"},{name:"America/St_Johns",label:"Newfoundland"},{name:"America/Argentina/Buenos_Aires",label:"Buenos Aires, Brasilia"},{name:"America/Noronha",label:"Fernando de Noronha"},{name:"Atlantic/Azores",label:"Azores"},{name:"Atlantic/Cape_Verde",label:"Cape Verde Is."},{name:"Etc/UTC",label:"UTC"},{name:"Africa/Casablanca",label:"Casablanca, Monrovia"},{name:"Europe/Dublin",label:"Dublin, Edinburgh, London"},{name:"Europe/Amsterdam",label:"Amsterdam, Berlin, Rome, Stockholm, Vienna"},{name:"Europe/Prague",label:"Belgrade, Bratislava, Budapest, Prague"},{name:"Europe/Paris",label:"Brussels, Copenhagen, Madrid, Paris"},{name:"Europe/Warsaw",label:"Sarajevo, Skopje, Warsaw, Zagreb"},{name:"Africa/Lagos",label:"West Central Africa"},{name:"Europe/Athens",label:"Athens, Beirut, Bucharest"},{name:"Africa/Cairo",label:"Cairo, Egypt"},{name:"Africa/Maputo",label:"Harare"},{name:"Europe/Kiev",label:"Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius"},{name:"Asia/Jerusalem",label:"Jerusalem"},{name:"Africa/Johannesburg",label:"Pretoria"},{name:"Asia/Baghdad",label:"Baghdad"},{name:"Asia/Riyadh",label:"Kuwait, Nairobi, Riyadh"},{name:"Europe/Istanbul",label:"Istanbul, Ankara"},{name:"Europe/Moscow",label:"Moscow, St. Petersburg, Volgograd"},{name:"Asia/Tehran",label:"Tehran"},{name:"Asia/Dubai",label:"Abu Dhabi, Muscat"},{name:"Asia/Baku",label:"Baku, Tbilisi, Yerevan"},{name:"Asia/Kabul",label:"Kabul"},{name:"Asia/Almaty",label:"Almaty, Astana"},{name:"Asia/Karachi",label:"Islamabad, Karachi, Tashkent"},{name:"Asia/Yekaterinburg",label:"Yekaterinburg"},{name:"Asia/Kolkata",label:"Chennai, Kolkata, Mumbai, New Delhi"},{name:"Asia/Colombo",label:"Colombo, Sri Jayawardenepura"},{name:"Asia/Kathmandu",label:"Kathmandu"},{name:"Asia/Dhaka",label:"Dhaka"},{name:"Asia/Rangoon",label:"Yangon (Rangoon)"},{name:"Asia/Bangkok",label:"Bangkok, Hanoi, Jakarta"},{name:"Asia/Krasnoyarsk",label:"Krasnoyarsk, Novosibirsk"},{name:"Asia/Hong_Kong",label:"Beijing, Chongqing, Hong Kong, Urumqi"},{name:"Asia/Irkutsk",label:"Irkutsk, Ulaanbaatar"},{name:"Asia/Singapore",label:"Kuala Lumpur, Perth, Singapore, Taipei"},{name:"Asia/Tokyo",label:"Osaka, Sapporo, Tokyo"},{name:"Asia/Seoul",label:"Seoul"},{name:"Asia/Yakutsk",label:"Yakutsk"},{name:"Australia/Adelaide",label:"Adelaide"},{name:"Australia/Darwin",label:"Darwin"},{name:"Australia/Brisbane",label:"Brisbane, Guam, Port Moresby"},{name:"Australia/Sydney",label:"Canberra, Hobart, Melbourne, Sydney, Vladivostok"},{name:"Asia/Magadan",label:"Magadan, Soloman Is., New Caledonia"},{name:"Pacific/Auckland",label:"Auckland, Wellington"},{name:"Pacific/Fiji",label:"Fiji, Kamchatka, Marshall Is."},{name:"Pacific/Kwajalein",label:"International Date Line West"}],F6=t=>{const e={timeZone:t,timeZoneName:"longOffset"};try{const i=new Intl.DateTimeFormat("en-GB",e).formatToParts(new Date).find(m=>m.type==="timeZoneName")?.value;if(!i)return{offsetString:null,offsetMinutes:0};const s=i.match(/^GMT([+-])(\d{2}):(\d{2})$/);if(!s)return{offsetString:i,offsetMinutes:0};const[,o,a,l]=s,c=parseInt(a,10),d=parseInt(l,10),h=o==="+"?c*60+d:-(c*60+d);return{offsetString:h===0?"GMT":`GMT ${o}${c}:${d.toString().padStart(2,"0")}`,offsetMinutes:h}}catch{return{offsetString:null,offsetMinutes:0}}},B6=(t,e)=>`(${e}) ${t}`,V6=()=>_6.map(({name:t,label:e})=>{const{offsetString:n,offsetMinutes:r}=F6(t);return{name:t,label:n?B6(e,n):e,offsetMinutes:r}}).sort((t,e)=>t.offsetMinutes-e.offsetMinutes),z6=({timezone:t})=>{const[e,n]=v.useState(yg(t));return v.useEffect(()=>{const r=setInterval(()=>{n(yg(t))},1e3);return()=>{clearInterval(r)}},[t]),u.jsxs(u.Fragment,{children:["The local time here is currently ",e]})},$6=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,handleEditingChange:a}=Ft(),[l]=we(e,["timezone"]),c=V6().map(h=>({value:h.name,label:h.label})),d=h=>{o("timezone",h||null),a(!0)};return u.jsx(Se,{description:"Set the time and date of your publication, used for all published posts",hideEditButton:!0,isEditing:n,keywords:t,navid:"timezone",saveState:r,testId:"timezone",title:"Site timezone",onCancel:s,onEditingChange:a,onSave:i,children:u.jsx(tt,{columns:1,children:u.jsx(ir,{hint:u.jsx(z6,{timezone:l}),options:c,selectedOption:c.find(h=>h.value===l),testId:"timezone-select",title:"Site timezone",isSearchable:!0,onSelect:h=>d(h?.value)})})})},H6=Ce($6,"Site timezone"),U6=({keywords:t})=>{const{errors:e,localSettings:n,isEditing:r,saveState:i,focusRef:s,clearError:o,handleSave:a,handleCancel:l,updateSetting:c,handleEditingChange:d}=Ft({onValidate:()=>h?h.length<4?{title:"Please use a site title longer than 3 characters."}:h.length>63?{title:"Please use a site title shorter than 63 characters."}:{}:{title:"Please enter a site title."}}),[h,f]=we(n,["title","description"]),m=x=>{c("title",x.target.value)},p=x=>{c("description",x.target.value)},g=u.jsx(tt,{columns:2,values:[{heading:"Site title",key:"site-title",value:h},{heading:"Site description",key:"site-description",value:f}]}),b=u.jsxs(tt,{children:[u.jsx(at,{error:!!e.title,hint:e.title||"The name of your site",inputRef:s,maxLength:63,placeholder:"Site title",title:"Site title",value:h,onChange:m,onKeyDown:()=>o("title")}),u.jsx(at,{hint:"A short description, used in your theme, meta data and search results",maxLength:200,placeholder:"Site description",title:"Site description",value:f,onChange:p})]});return u.jsx(Se,{description:"The details used to identify your publication around the web",isEditing:r,keywords:t,navid:"general",saveState:i,testId:"title-and-description",title:"Title & description",onCancel:l,onEditingChange:d,onSave:a,children:r?b:g})},W6=Ce(U6,"Title & description"),K6=({user:t})=>{const{updateRoute:e}=fe(),{currentUser:n}=ke(),r=()=>{Fs(n)&&e({route:`staff/${t.slug}`})};return t?u.jsxs("div",{className:R("group flex gap-3",Fs(n)&&"cursor-pointer"),"data-testid":"owner-user",onClick:r,children:[u.jsx(gh,{bgColor:mf(t.name?t.name:t.email),image:t.profile_image??void 0,label:cy(t.name),labelColor:"white",size:"lg"}),u.jsxs("div",{className:"flex flex-col",children:[u.jsxs("span",{children:[t.name," — ",u.jsx("strong",{children:"Owner"})," ",Fs(n)&&u.jsx("button",{className:"ml-2 inline-block font-semibold text-green group-hover:visible md:invisible",type:"button",children:"View profile"})]}),u.jsx("span",{className:"text-sm text-grey-700",children:t.email})]})]}):null},Da=({users:t,groupname:e})=>{const{updateRoute:n}=fe(),{currentUser:r}=ke(),i=s=>{n({route:`staff/${s.slug}`})};return!t||!t.length?u.jsxs(li,{icon:"single-user-block",children:["No ",e," found."]}):u.jsx(is,{titleSeparator:!1,children:t.map(s=>{let o=s.name||"";s.status==="inactive"&&(o=`${o} (Suspended)`);const a=Fs(r)||Gg(r)&&$w(s)||r.id===s.id;return u.jsx(Wi,{action:a&&u.jsx(J,{color:"green",label:"Edit",link:!0,onClick:()=>i(s)}),avatar:u.jsx(gh,{bgColor:mf(s.name?s.name:s.email),image:s.profile_image??void 0,label:cy(s.name),labelColor:"white"}),bgOnHover:a,className:"min-h-[64px]",detail:s.email,hideActions:!0,id:`list-item-${s.id}`,separator:!1,testId:"user-list-item",title:o,onClick:()=>a&&i(s)},s.id)})})},G6=({invite:t})=>{const[e,n]=v.useState(""),[r,i]=v.useState(""),{mutateAsync:s}=RP(),{mutateAsync:o}=PP(),a=Ye();let l="Revoke";e==="progress"&&(l="Revoking...");let c="Resend";return r==="progress"&&(c="Resending..."),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(J,{color:"red",label:l,link:!0,onClick:async()=>{try{n("progress"),await s(t.id),rn({title:"Invitation revoked",message:t.email,type:"success"})}catch(d){a(d)}finally{n("")}}}),u.jsx(J,{className:"ml-2",color:"green",label:c,link:!0,onClick:async()=>{try{i("progress"),await s(t.id),await o({email:t.email,roleId:t.role_id}),rn({title:"Invitation resent",message:t.email,type:"success"})}catch(d){a(d)}finally{i("")}}})]})},q6=({users:t})=>!t||!t.length?u.jsx(li,{icon:"single-user-block",children:"No invitations found."}):u.jsx(is,{children:t.map(e=>u.jsx(Wi,{action:u.jsx(G6,{invite:e}),avatar:u.jsx(gh,{bgColor:mf(e.email),image:"",label:e.email.charAt(0).toUpperCase(),labelColor:"white"}),className:"min-h-[64px]",detail:e.role,hideActions:!0,id:`list-item-${e.id}`,separator:!1,testId:"user-invite",title:e.email,onClick:()=>{}},e.id))}),Y6=({keywords:t,highlight:e=!0})=>{const{totalUsers:n,totalInvites:r,users:i,ownerUser:s,adminUsers:o,editorUsers:a,authorUsers:l,contributorUsers:c,invites:d,hasNextPage:h,fetchNextPage:f,invitesHasNextPage:m,fetchNextInvitePage:p}=ff(),{updateRoute:g}=fe(),{settings:b,config:x,currentUser:y}=ke(),w=()=>{g("staff/invite")},k=u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Invite people",size:"sm",linkWithPadding:!0,onClick:()=>{w()}}),C=Qo().getParam("tab"),S=C||"administrators",[A,M]=v.useState(S);v.useEffect(()=>{C&&M(C)},[C]);const E=O=>{g(`staff?tab=${O}`),M(O)},j=[{id:"administrators",title:"Administrators",contents:u.jsx(Da,{groupname:"administrators",users:o}),counter:o.length?o.length:void 0},{id:"editors",title:"Editors",contents:u.jsx(Da,{groupname:"editors",users:a}),counter:a.length?a.length:void 0},{id:"authors",title:"Authors",contents:u.jsx(Da,{groupname:"authors",users:l}),counter:l.length?l.length:void 0},{id:"contributors",title:"Contributors",contents:u.jsx(Da,{groupname:"contributors",users:c}),counter:c.length?c.length:void 0},{id:"invited",title:"Invited",contents:u.jsx(q6,{users:d}),counter:r||void 0}],T=Xs(b,"require_email_mfa")||!1,{mutateAsync:N}=ai(),D=Ye();return u.jsxs(Se,{customButtons:k,highlightOnModalClose:e,keywords:t,navid:"staff",testId:"users",title:"Staff",children:[u.jsx(K6,{user:s}),(i.length>1||d.length>0)&&u.jsx(hr,{selectedTab:A,tabs:j,testId:"user-tabview",onTabChange:E}),h&&A!=="invited"&&u.jsx(J,{label:`Load more (showing ${i.length}/${n} users)`,link:!0,onClick:()=>f()}),m&&A==="invited"&&u.jsx(J,{label:`Load more (showing ${d.length}/${r} invites)`,link:!0,onClick:()=>p()}),x?.security?.staffDeviceVerification&&Fs(y)&&u.jsxs("div",{className:`flex flex-col gap-6 ${i.length>1||d.length>0?"-mt-6":""}`,children:[u.jsx(Tt,{}),u.jsxs("div",{className:"flex items-baseline justify-between",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{className:"text-[1.5rem] font-semibold tracking-tight",children:"Security settings"}),u.jsx("span",{children:"Require email 2FA codes to be used on all staff logins"})]}),u.jsx(en,{checked:T,direction:"rtl",gap:"gap-0",onChange:async()=>{const O=!T;try{await N([{key:"require_email_mfa",value:O}])}catch(L){D(L)}}})]})]})]})},Oy=Ce(Y6,"Staff"),gt={titleAndDescription:["general","title and description","site title","site description","title & description"],timeZone:["general","time","date","site timezone","time zone"],publicationLanguage:["general","publication language","locale"],users:["general","users and permissions","roles","staff","invite people","contributors","editors","authors","administrators"],metadata:["general","metadata","title","description","search","engine","google","meta data","twitter card","structured data","rich cards","x card","social","facebook card","llms","ai","ai search engines","llm"],socialAccounts:["general","social accounts","facebook","twitter","threads","bluesky","mastodon","tiktok","youtube","instagram","linkedin","structured data","rich cards"],analytics:["general","analytics","tracking","privacy","membership"]},X6=()=>u.jsxs(ui,{keywords:Object.values(gt).flat(),title:"General settings",children:[u.jsx(W6,{keywords:gt.titleAndDescription}),u.jsx(H6,{keywords:gt.timeZone}),u.jsx(e6,{keywords:gt.publicationLanguage}),u.jsx(Oy,{keywords:gt.users}),u.jsx(r6,{keywords:gt.metadata}),u.jsx(L6,{keywords:gt.socialAccounts}),u.jsx(XL,{keywords:gt.analytics})]}),J6=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("embed-signup-form/show")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Embed",size:"sm",onClick:n}),description:"Grow your audience from anywhere on the web",keywords:t,navid:"embed-signup-form",testId:"embed-signup-form",title:"Signup forms"})},Z6=""+new URL("explore-default-logo-P7UjmPqe.png",import.meta.url).href,Q6=""+new URL("ghost-explore-BuZQ7HbF.png",import.meta.url).href,e8=({keywords:t})=>{const{settings:e}=ke(),{mutateAsync:n}=ai(),r=Ye(),{updateRoute:i}=fe(),{refetch:s}=Wg({searchParams:{limit:"1"}}),[o,a]=v.useState(0);v.useEffect(()=>{(async()=>{const{data:C}=await s(),S=C?.meta?.pagination?.total||0;a(S)})()},[s]);const[l,c]=we(e,["accent_color","icon"]),{localSettings:d,siteData:h}=Ft(),[f,m]=we(d,["title","description"]),p=!!Xs(e,"explore_ping"),g=!!Xs(e,"explore_ping_growth"),b=h?.url,x=b?.replace(/^https?:\/\//,"").replace(/\/?$/,""),y=l||"#F6414E",w=async(k,C)=>{const S=[{key:k,value:C.target.checked}];try{await n(S)}catch(A){r(A)}};return u.jsx(Se,{customButtons:u.jsx(en,{checked:p,direction:"rtl",testId:"explore-toggle",onChange:k=>w("explore_ping",k)}),description:"Promote your site across Ghost's website and publishing network",keywords:t,navid:"explore",testId:"explore",title:"Ghost Explore",children:p?u.jsxs(tt,{columns:1,children:[u.jsx(Tt,{}),u.jsx(en,{checked:g,containerClasses:"items-center!",direction:"rtl",gap:"gap-0",hint:"Enabling this will use your revenue/member growth data to rank your site more highly on Ghost Explore. Total member count will be displayed publicly, other data will be kept private.",label:"Share growth data to rank higher?",labelClasses:"w-full",testId:"explore-growth-toggle",onChange:k=>w("explore_ping_growth",k)}),u.jsx("div",{className:"-mx-5 -mb-5 flex flex-col items-center bg-grey-50 px-7 py-10 md:-mx-7 md:-mb-7","data-testid":"explore-preview",children:u.jsxs("div",{className:"relative w-full max-w-[320px] rounded-lg bg-white p-6 text-black shadow-lg",children:[u.jsx("div",{className:"absolute top-2.5 right-3 text-sm text-grey-300 uppercase",children:"Preview"}),c?u.jsx("div",{className:"size-9 rounded-sm bg-cover bg-center",style:{backgroundImage:`url(${c})`}}):u.jsx("div",{className:"flex aspect-square size-10 items-center justify-center overflow-hidden rounded-full p-1 text-white",style:{backgroundColor:y},children:u.jsx("img",{className:"h-auto w-8",src:Z6})}),u.jsx("div",{className:"mt-3 text-lg font-semibold tracking-tight",children:f}),m&&u.jsx("div",{className:"mt-0.5 leading-tight text-grey-700",children:m}),u.jsxs("a",{className:"group mt-8 flex h-6 w-full items-center justify-between gap-5 hover:cursor-pointer",href:b,rel:"noopener noreferrer",target:"_blank",children:[u.jsx("span",{className:"font-semibold",children:x}),g?u.jsxs("span",{className:"rounded-sm bg-black px-2 py-0.5 text-sm font-semibold text-white","data-testid":"explore-members-count",children:[Hw(o)," ",o===1?"member":"members"]}):u.jsx("span",{className:"flex size-5 items-center justify-center rounded-full border border-black text-black group-hover:bg-black group-hover:text-white",children:u.jsx(me,{name:"arrow-right",size:10})})]})]})}),u.jsxs("div",{className:"-mx-5 -mb-5 flex items-center justify-between gap-4 rounded-b-xl border-t border-[rgba(142,66,255,0.1)] bg-gradient-to-tr from-[rgba(142,66,255,0.07)] to-[rgba(142,66,255,0.02)] p-6 px-7 md:-mx-7 md:-mb-7",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:"Get featured on the Ghost.org homepage"}),u.jsx("span",{className:"text-pretty text-black/80 dark:text-white/80",children:"Send us a quote we can use to highlight your site"})]}),u.jsx(J,{className:"border border-purple bg-white text-purple hover:bg-purple/5 hover:text-purple dark:bg-transparent",icon:"send",label:"Send testimonial",onClick:()=>{i("explore/testimonial")}})]})]}):u.jsx("img",{src:Q6})})},t8=Ce(e8,"Ghost Explore"),n8=""+new URL("network-C2Wz-Sfw.png",import.meta.url).href,r8=({keywords:t})=>{const{settings:e}=ke(),{mutateAsync:n}=ai(),r=Ye(),{updateRoute:i}=fe(),o=fs()?.isDisabled("limitSocialWeb"),{subdir:a}=Ys(),[l]=we(e,["is_private"]),c=!!a,d=["localhost","127.0.0.1","::1"].includes(window.location.hostname),h=wt.isIP(window.location.hostname),f=o||c||d||h,m=!!l,p=f||m,[g]=we(e,["social_web"]),b=!!g&&!p,x=async y=>{const w=[{key:"social_web",value:y.target.checked}];try{await n(w)}catch(k){r(k)}};return u.jsx(Se,{customButtons:u.jsx(en,{checked:b,direction:"rtl",disabled:p,onChange:x},`${b}-${p}`),description:"Distribute posts to the social web, so people can discover and follow your content across BlueSky, Threads, Mastodon, Flipboard, WordPress, and more.",keywords:t,navid:"network",testId:"network",title:"Network",children:u.jsxs(u.Fragment,{children:[u.jsx(tt,{columns:1,values:[{key:"private",value:p&&u.jsxs("div",{className:"flex w-full gap-1.5 rounded-md border border-grey-200 bg-grey-50 p-3 dark:border-grey-900 dark:bg-grey-900",children:[u.jsx(me,{name:"info",size:16}),u.jsx("div",{className:"-mt-0.5",children:m?u.jsxs(u.Fragment,{children:["Network is automatically disabled while your site is in ",u.jsx("span",{className:"cursor-pointer text-green",onClick:()=>i("members"),children:"private mode"})]}):u.jsxs(u.Fragment,{children:["You need to configure a supported custom domain to use this feature. ",u.jsx("a",{className:"text-green",href:"https://ghost.org/help/social-web/#custom-domain-required",rel:"noopener noreferrer",target:"_blank",children:"Help →"})]})})]})}]}),u.jsx("div",{className:"-mx-5 -mb-5 overflow-hidden rounded-b-xl md:-mx-7 md:-mb-7",children:u.jsx("img",{className:"dark:opacity-90",src:n8})})]})})},i8=Ce(r8,"Network"),s8=({keywords:t})=>{const{updateRoute:e}=fe(),{settings:n,config:r}=ke(),{data:{offers:i=[]}={}}=k2(),{data:{tiers:s}={}}=rh(),o=x2(s||[]),a=i.filter(d=>d.redemption_type==="signup"),l=()=>{e("offers/edit")},c=()=>{e("/tiers")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",disabled:!nr(n,r),label:"Manage offers",size:"sm",onClick:l}),description:u.jsxs(u.Fragment,{children:["Create discounts & coupons to boost new subscriptions and retain existing members.",u.jsx("span",{children:" "}),u.jsx("a",{className:"text-green",href:"https://ghost.org/help/offers",rel:"noopener noreferrer",target:"_blank",children:"Learn more"})]}),keywords:t,navid:"offers",testId:"offers",title:"Offers",children:o.length===0&&a.length===0?u.jsxs("div",{children:[u.jsx("span",{children:"You must have an active tier to create an offer."})," ",u.jsx(J,{className:"font-normal",color:"green",label:"Manage tiers",link:!0,linkWithPadding:!0,onClick:c})]}):""})},o8=Ce(s8,"Portal settings"),a8="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAA81BMVEUAAAAQEBAVFRUVFRgVFxkVFhoVFxkWFxkVFhoVFxoVFxoWFxoVFxkUFBgVFRsQGBgVFxsVFxkVFxoyNDZPUVNtbnBeX2FBQkVBQ0WKi43Excb////FxcaKi4xQUVMUGBgVFhkyNDenqKnx8fHw8fGYmZt7fX7i4uIUFxkjJSgUFhrS09Th4uOZmZokJiji4uPw8PHh4uLT09QTFRsTFxtsbnAUFhp7fH4UFxkUFhoWFxoVFxpAQkXT09O2triZmpq1tri2t7iZmpsXFxd7fX8QECB8fX4VGBgVFRsYGBgUGBoVFhoVGBgTFhkTFhoVFxkUFxrWJPvbAAAAUXRSTlMAEDBgkJ+/3+//z69vQF8gj4/f////////////////QKD/////////cP+A//////////9gkP+v/7/P3+//////////T/8Q/18wIIDPYFCf36+gOKr5AAACJ0lEQVR4AY3U1WLrMAwGYJX7l5mSMo6ZmRne/2nOnFqOm+N5/a5CiiQT6ULhSDQWTySS8CQTqXg6msmSWSgTT8IsnstTUDYOq9hiSKiAPxXJl09hCSWVJFRCQLlSrVXqCEiFaG6xnkaz5Uhuu2yqKg9Nh7/mmAo0XRJ6UPr8uWagZYkHEtSGjjByx9VKuTKR0dMaFNHFDKwpi1hRCQeOpwm2SkTxhe/XKtD11/0IrknVI95sIGBznqTm15Tlf23x9wFexDZ3HvZa4Oc7MNjc9TrD3B7tw1MRTw8gGfqQvUXpEJ6WIQGraClicpD64lkbvzgSb+ddHNMJhAlnNWup35XoVD1xVgBLUa4MSELwlgBgS7EN4YwgnMu2LCm4CeJ7c89sc8QtagEVWFwYAlZg0eIA7oGbWjKgbxskLmlFC8DoJwIWfTWscuIu1bCZXTnONc+0WhoTS4ItXsopOuFxtk3cjbb4DlVO80Twbh/w8t6XSS0pbh2/w1W1Rds/D2+N9e/q6+aOupB2+ThZdD909M0Ypgd/6xoiOruOsMNDfqYfZI2RmO+y4WQeNSAdE9Fq4HhwqysQVh75ZN5pgD0R0fP/h/euO7jecpirJX0hrkk68JLoRhP4YiTwOJlCdtsrYJyAeO5YY9LyxmbrZhKY+1eae3jDUlLEXpaKSL2Q7xV/ioZI99KD1XGXgl7ej5MwO34Nk9nzx+rn8ckXB359nXxHM90Qaf4BNjt9poiwMVcAAAAASUVORK5CYII=",wf=({title:t,favicon:e,featured_image:n,isGhostSite:r})=>{const[i,s]=v.useState(e||n||null),o=()=>{s(null)};if(!i)return u.jsx("div",{className:"relative size-6 shrink-0 rounded-sm"});const a=r?"This is a Ghost site that supports one-click subscribe":"";return u.jsxs("div",{className:"relative size-6 shrink-0 rounded-sm dark:group-hover/table-row:bg-grey-950",title:a,children:[u.jsx("img",{alt:t,className:"size-6 rounded-sm",src:i,onError:o}),r&&u.jsx("img",{alt:"Ghost Logo",className:"absolute right-[-3px] bottom-[-3px] size-[14px]",src:a8})]})},ta="RecommendationResponseType",l8=Jd({dataType:ta,path:"/recommendations/",returnData:t=>{const{pages:e}=t;let n=e.flatMap(r=>r.recommendations);return n=n.filter((r,i)=>n.findIndex(({id:s})=>s===r.id)===i),{recommendations:n,meta:e[e.length-1].meta}}}),c8=Ot({method:"DELETE",path:t=>`/recommendations/${t.id}/`,invalidateQueries:{dataType:ta}}),u8=Ot({method:"PUT",path:t=>`/recommendations/${t.id}/`,body:t=>({recommendations:[t]}),invalidateQueries:{dataType:ta}}),h9=Ot({method:"POST",path:()=>"/recommendations/",body:({...t})=>({recommendations:[t]}),invalidateQueries:{dataType:ta}}),f9=Ot({method:"POST",path:()=>"/recommendations/check/",body:t=>({recommendations:[{url:t.toString()}]})}),d8=Jd({dataType:ta,path:"/incoming_recommendations/",returnData:t=>{const{pages:e}=t;let n=e.flatMap(r=>r.recommendations);return n=n.filter((r,i)=>n.findIndex(({id:s})=>s===r.id)===i),{recommendations:n,meta:e[e.length-1].meta}}}),h8=({incomingRecommendation:t,stats:e})=>{const{updateRoute:n}=fe(),r=v.useMemo(()=>{let a=t.url;try{a=new URL(t.url).hostname.replace(/^www\./,"")}catch{}return e.reduce((l,c)=>c.source===a?l+c.signups:l,0)},[e,t.url]),i=()=>{n({route:`recommendations/add?url=${t.url}`})},s=()=>{window.open(t.url,"_blank")},o=r===1?"free member":"free members";return u.jsxs(ls,{action:!t.recommending_back&&u.jsx("div",{className:"flex items-center justify-end",children:u.jsx(J,{color:"green",label:"Recommend back",size:"sm",link:!0,onClick:i})}),testId:"incoming-recommendation-list-item",hideActions:!0,children:[u.jsx($n,{className:"w-80",onClick:s,children:u.jsx("div",{className:"group flex items-center gap-3 hover:cursor-pointer",children:u.jsx("div",{className:"flex grow flex-col",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(wf,{favicon:t.favicon,featured_image:t.featured_image,title:t.title||t.url}),u.jsx("span",{className:"line-clamp-1 font-medium",children:t.title||t.url})]})})})}),u.jsx($n,{className:"hidden w-auto text-left whitespace-nowrap md:visible! md:table-cell!",padding:!1,valign:"middle",onClick:s,children:r===0?u.jsx("span",{className:"text-grey-500 dark:text-grey-900",children:"-"}):u.jsx("div",{className:"mr-2",children:u.jsx("span",{children:So(r)})})}),u.jsx($n,{className:"hidden w-[1%] whitespace-nowrap md:visible! md:table-cell!",valign:"middle",onClick:s,children:r===0?null:u.jsx("div",{className:"-mt-px text-left",children:u.jsx("span",{className:"-mb-px inline-block min-w-[60px] text-left whitespace-nowrap text-grey-700 lowercase",children:o})})}),t.recommending_back&&u.jsx($n,{className:"w-[1%] whitespace-nowrap group-hover/table-row:visible md:invisible",children:u.jsx("div",{className:"mt-1 text-right whitespace-nowrap text-grey-700",children:"Recommending"})})]})},f8=({incomingRecommendations:t,stats:e,pagination:n,showMore:r,isLoading:i})=>i||t.length?u.jsx(Mr,{isLoading:i,pagination:n,showMore:r,hintSeparator:!0,children:t.map(s=>u.jsx(h8,{incomingRecommendation:s,stats:e},s.id))}):u.jsx(li,{children:u.jsx("span",{className:"max-w-[40ch] text-center",children:"No one’s recommended you yet. Once they do, you’ll find them here along with how many memberships they’ve driven."})}),Tg=function(t,e,n){const r={...t};switch(e){case"title":n?delete r.title:r.title="Title is required";break;case"description":n&&n.length>200?r.description="Description cannot be longer than 200 characters":delete r.description;break;default:{const i=e;throw new Error(`Unknown field ${i}`)}}return r},Iy=function(t){let e={};return e=Tg(e,"title",t.title),e=Tg(e,"description",t.description),e};function m8({showURL:t,formState:e,updateForm:n,errors:r,clearError:i,setErrors:s}){const[o,a]=W.useState(e?.description?.length||0),l=o>200?"text-red":"text-green",c=W.useRef(!1);return W.useEffect(()=>{c.current||(c.current=!0,s(Iy(e)))},[e,s]),u.jsxs(K2,{marginBottom:!1,marginTop:!0,children:[u.jsxs("div",{children:[u.jsx(qe,{className:"mb-2 block text-xs font-semibold tracking-wider uppercase",grey:!0,level:6,children:"Preview"}),u.jsx("div",{className:"-mx-8 flex items-center justify-center overflow-hidden border-y border-grey-100 bg-grey-50 px-7 py-4 dark:border-grey-950 dark:bg-black",children:u.jsx("div",{className:"w-full rounded bg-white py-3 shadow",children:u.jsx("div",{className:"",children:u.jsxs("a",{className:"flex items-center justify-between bg-white px-5 py-3",href:e.url,rel:"noopener noreferrer",target:"_blank",children:[u.jsxs("div",{className:"flex flex-col gap-[2px]",children:[u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx(wf,{...e}),u.jsx("span",{className:"text-[1.6rem] font-semibold text-grey-900",children:e.title})]}),e.description&&u.jsx("span",{className:"pl-[31px] text-[1.35rem] leading-snug text-grey-700",children:e.description})]}),e.one_click_subscribe&&u.jsx("span",{className:"flex pl-6 text-md font-semibold whitespace-nowrap text-green",children:"Subscribe"})]})})})}),e.one_click_subscribe&&u.jsx(on,{children:"This is a Ghost site, so your readers can subscribe with just one click"})]}),t&&u.jsx(K5,{disabled:!0,title:"URL",value:e.url,onChange:d=>n(h=>({...h,url:d||""}))}),u.jsx(at,{autoFocus:!0,error:!!r.title,hint:r.title,maxLength:2e3,title:"Title",value:e.title??"",onChange:d=>{i?.("title"),n(h=>({...h,title:d.target.value}))}}),u.jsx(rb,{error:!!r.description,hint:u.jsxs(u.Fragment,{children:["Max: ",u.jsx("strong",{children:"200"})," characters. You’ve used ",u.jsx("strong",{className:l,children:o})]}),rows:4,title:"Short description",value:e.description??"",onChange:d=>{i?.("description"),a(d.target.value.length),n(h=>({...h,description:d.target.value}))}})]})}const p8=({recommendation:t,animate:e})=>{const n=an(),{updateRoute:r}=fe(),{mutateAsync:i}=u8(),{mutateAsync:s}=c8(),o=Ye(),{formState:a,updateForm:l,handleSave:c,errors:d,clearError:h,setErrors:f,okProps:m}=zl({initialState:{...t},savingDelay:500,savedDelay:500,onSave:async g=>{await i(g)},onSaveError:o,onValidate:g=>Iy(g)});let p={label:"Delete",link:!0,color:"red",size:"sm",onClick:()=>{n.remove(),pe.show(Wt,{title:"Delete recommendation",prompt:u.jsx(u.Fragment,{children:u.jsxs("p",{children:["Your recommendation ",u.jsx("strong",{children:t.title})," will no longer be visible to your audience."]})}),okLabel:"Delete",onOk:async g=>{try{await s(t),g?.remove()}catch(b){rn({title:"Failed to delete the recommendation",message:"Please try again later.",type:"error"}),o(b,{withToast:!1})}}})}};return u.jsx(Fr,{afterClose:()=>{r("recommendations")},animate:e??!0,backDropClick:!1,buttonsDisabled:m.disabled,cancelLabel:"Close",leftButtonProps:p,okColor:m.color,okLabel:m.label||"Save",size:"sm",testId:"edit-recommendation-modal",title:"Edit recommendation",stickyFooter:!0,onOk:async()=>{Uw();try{await c({force:!0})}catch{rn({title:"Something went wrong",type:"error",message:"Please try again later."})}},children:u.jsx(m8,{clearError:h,errors:d,formState:a,setErrors:f,showURL:!0,updateForm:l})})},g8=pe.create(p8),b8=({recommendation:t})=>{const{route:e}=fe(),n=()=>{pe.show(g8,{pathName:e,animate:!1,recommendation:t})},r=t.one_click_subscribe,i=r&&!!t.count?.subscribers,s=(i?t.count?.subscribers:t.count?.clicks)||0,o=s===1?"signup":"signups",a=s===1?"click":"clicks";return u.jsxs(ls,{className:"group hover:cursor-pointer",testId:"recommendation-list-item",onClick:n,children:[u.jsx($n,{className:"w-80",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(wf,{isGhostSite:r,...t}),u.jsx("span",{className:"line-clamp-1 font-medium",children:t.title})]})}),u.jsx($n,{className:"hidden w-auto text-left align-middle whitespace-nowrap md:visible! md:table-cell!",children:s===0?u.jsx("span",{className:"text-grey-500 dark:text-grey-900",children:"-"}):u.jsx(u.Fragment,{children:u.jsxs("div",{className:"flex items-center",children:[u.jsx("div",{className:"mr-2",children:u.jsx("span",{children:So(s)})}),u.jsxs("div",{className:"text-grey-700 lowercase",children:[u.jsx("span",{children:i?o:a}),u.jsx("span",{className:"invisible group-hover:visible",children:" from you"})]})]})})})]})},v8=({recommendations:t,pagination:e,showMore:n,isLoading:r})=>{const{siteData:i}=Ft(),s=`${i?.url.replace(/\/$/,"")}/#/portal/recommendations`,{updateRoute:o}=fe(),a=()=>{o("recommendations/add")},[l,c]=v.useState(!1),d=()=>{navigator.clipboard.writeText(s),c(!0),setTimeout(()=>c(!1),2e3)};return r||t.length?u.jsx(Mr,{hint:u.jsxs("span",{children:["Shared with new members after signup, or anytime using ",u.jsx(no,{href:s,target:"_blank",children:"this link"}),u.jsx(sb,{containerClassName:"ml-1 align-middle leading-none",content:l?"Copied":"Copy link",size:"sm",children:u.jsx(J,{color:"clear",hideLabel:!0,icon:l?"check-circle":"duplicate",iconColorClass:l?"text-green w-[14px] h-[14px]":"text-grey-600 hover:opacity-80 w-[14px] h-[14px]",label:l?"Copied":"Copy",unstyled:!0,onClick:d})})]}),isLoading:r,pagination:e,showMore:n,hintSeparator:!0,children:t&&t.map(h=>u.jsx(b8,{recommendation:h},h.id))}):u.jsxs(li,{children:[u.jsx(J,{color:"grey",label:"Add first recommendation",size:"sm",onClick:()=>{a()}}),u.jsxs("span",{className:"mt-2 max-w-[40ch] text-center text-sm",children:["Need inspiration? ",u.jsx(no,{href:"https://ghost.org/explore",target:"_blank",children:"Explore thousands of sites"})]})]})},x8=({keywords:t})=>{const{saveState:e,handleSave:n}=Ft(),{data:{meta:r,recommendations:i}={},isLoading:s,hasNextPage:o,fetchNextPage:a}=l8({searchParams:{include:"count.clicks,count.subscribers",order:"created_at desc",limit:"5"},getNextPageParams:(M,E)=>{if(!M.meta)return;const{limit:j,page:T,pages:N}=M.meta.pagination;if(T>=N)return;const D=typeof j=="number"&&j<100?1:T+1;return{...E,page:D.toString(),limit:"100"}},keepPreviousData:!0}),l={hasMore:!!o,loadMore:a},{data:{recommendations:c,meta:d}={},isLoading:h,hasNextPage:f,fetchNextPage:m}=d8({searchParams:{limit:"5",order:"created_at desc"},getNextPageParams:(M,E)=>{if(!M.meta)return;const{limit:j,page:T,pages:N}=M.meta.pagination;if(T>=N)return;const D=typeof j=="number"&&j<100?1:T+1;return{...E,page:D.toString(),limit:"100"}},keepPreviousData:!0}),{data:{stats:p}={},isLoading:g}=S2({}),b={hasMore:!!f,loadMore:m},[x,y]=v.useState("your-recommendations"),w=[{id:"your-recommendations",title:"Your recommendations",counter:r?.pagination?.total,contents:u.jsx(v8,{isLoading:s,recommendations:i??[],showMore:l})},{id:"recommending-you",title:"Recommending you",counter:d?.pagination?.total,contents:u.jsx(f8,{incomingRecommendations:c??[],isLoading:h||g,showMore:b,stats:p??[]})}],k=u.jsx(u.Fragment,{children:"Recommend any publication that your audience will find valuable, and find out when others are recommending you."}),{updateRoute:C}=fe(),S=()=>{C("recommendations/add")},A=u.jsx(J,{className:"mt-[-5px] hidden md:!visible md:!block",color:"clear",label:"Add recommendation",size:"sm",onClick:()=>{S()}});return u.jsxs(Se,{beta:!0,customButtons:A,description:k,keywords:t,navid:"recommendations",saveState:e,testId:"recommendations",title:"Recommendations",onSave:n,children:[u.jsx("div",{className:"flex justify-center rounded border border-green px-4 py-2 md:hidden",children:u.jsx(J,{color:"light-grey",label:"Add recommendation",link:!0,onClick:()=>{S()}})}),u.jsx(hr,{selectedTab:x,tabs:w,onTabChange:y})]})},y8=Ce(x8,"Recommendations"),Je={network:["growth","network","activitypub","blog","fediverse","sharing"],explore:["ghost explore","explore","growth","share","list","listing"],recommendations:["growth","recommendations","recommend","blogroll"],embedSignupForm:["growth","embeddable signup form","embeddable form","embeddable sign up form","embeddable sign up"],offers:["growth","offers","discounts","coupons","promotions"]},w8=()=>{const{config:t,settings:e}=ke(),n=nr(e||[],t||{}),r=[Je.network,Je.explore,Je.recommendations,Je.embedSignupForm,...n?[Je.offers]:[]].flat();return u.jsxs(ui,{keywords:r,title:"Growth",children:[u.jsx(i8,{keywords:Je.network}),u.jsx(t8,{keywords:Je.explore}),u.jsx(y8,{keywords:Je.recommendations}),u.jsx(J6,{keywords:Je.embedSignupForm}),n&&u.jsx(o8,{keywords:Je.offers})]})},Dg=[{value:"public",label:"Public",hint:"Anyone can visit and read the website"},{value:"private",label:"Private",hint:"Access code required"}],Og=[{value:"all",label:"Public",hint:"Anyone can sign up and log in"},{value:"paid",label:"Paid-members only",hint:"A paid Stripe subscription is required to sign up"},{value:"invite",label:"Invite-only",hint:"People can sign in but won't be able to sign up"},{value:"none",label:"Nobody",hint:"Disable all member features, including newsletters"}],Ig=[{value:"public",label:"Public",hint:"All site visitors to your site, no login required"},{value:"members",label:"Members only",hint:"All logged-in members"},{value:"paid",label:"Paid-members only",hint:"Only logged-in members with an active Stripe subscription"},{value:"tiers",label:"Specific tiers",hint:"Members with any of the selected tiers"}],Pg=[{value:"all",label:"All members",hint:"Logged-in members"},{value:"paid",label:"Paid-members only",hint:"Only logged-in members with an active Stripe subscription"},{value:"off",label:"Nobody",hint:"Disable commenting completely"}],k8=({keywords:t})=>{const{settings:e}=ke(),r=fs()?.isDisabled("publicSiteAccess"),i=Tu(e,"is_private")||Tu(e,"password"),{mutateAsync:s}=Ww(),[o,a]=W.useState(!1),{localSettings:l,isEditing:c,saveState:d,siteData:h,handleSave:f,handleCancel:m,updateSetting:p,handleEditingChange:g,errors:b,clearError:x}=Ft({onValidate:()=>y&&!w?{password:"Enter an access code"}:{}}),[y,w,k,C,S,A]=we(l,["is_private","password","members_signup_access","default_content_visibility","default_content_visibility_tiers","comments_enabled"]),[M,E]=we(e,["is_private","public_hash"]),j=i?!0:y,{data:{tiers:T}={}}=rh(),N=[{label:"Active Tiers",options:T?.filter(({active:_})=>_).map(_=>({value:_.id,label:_.name}))||[]},{label:"Archived Tiers",options:T?.filter(({active:_})=>!_).map(_=>({value:_.id,label:_.name}))||[]}],D=JSON.parse(S||"[]"),O=N.flatMap(_=>_.options).filter(_=>D.includes(_.value)),L=M&&j&&h?.url&&E?`${h.url.replace(/\/$/,"")}/${E}/rss`:null,$=_=>{const te=_.map(ce=>ce.value);p("default_content_visibility_tiers",JSON.stringify(te))},U=async()=>{a(!0);try{const te=(await s(null)).settings.find(ce=>ce.key==="password")?.value;typeof te=="string"&&(p("password",te),x("password"))}catch{rn({type:"error",title:"Could not regenerate access code"})}finally{a(!1)}},q=u.jsxs(tt,{className:"gap-y-4",columns:1,children:[r&&u.jsx("div",{className:"-m-5 overflow-hidden p-5",children:u.jsxs(Kw,{className:"mb-2 flex w-full cursor-default flex-col gap-4 border-0 p-6 pt-5 transition-none hover:translate-y-0 hover:scale-100 hover:shadow-[-7px_-6px_42px_8px_rgb(75_225_226_/_28%),7px_6px_42px_8px_rgb(202_103_255_/_32%)] md:flex-row md:items-center md:justify-between dark:hover:shadow-[-7px_-6px_42px_8px_rgb(75_225_226_/_36%),7px_6px_42px_8px_rgb(202_103_255_/_38%)]",size:"lg",variant:"gradient",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-base font-semibold",children:"Pre-launch mode"}),u.jsx("div",{className:"mt-2 text-gray-700",children:"During your free trial, a private access code is required to browse your site. When you're ready to launch, pick a plan to upgrade your account and make everything public."})]}),u.jsx(Nr,{className:"shrink-0 self-start md:self-center",asChild:!0,children:u.jsx("a",{href:"#/pro/billing/plans",children:"Upgrade now"})})]})}),u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px]",children:"Who should be able to browse your site?"}),u.jsx("div",{className:"w-full md:flex-1",children:u.jsx(ir,{containerClassName:i?"relative z-10":void 0,disabled:i,options:Dg,selectedOption:Dg.find(_=>_.value===(j?"private":"public")),testId:"site-visibility-select",onSelect:_=>{p("is_private",_?.value==="private"),g(!0)}})})]}),(j||i)&&u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row md:items-start",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px] md:pt-3",children:"What access code should visitors use?"}),u.jsxs("div",{className:"w-full md:flex-1",children:[u.jsx(at,{containerClassName:i?"relative z-10":void 0,"data-testid":"site-access-code",disabled:i,error:!!b.password,hint:b.password,placeholder:"Enter access code",rightPlaceholder:u.jsx("span",{className:"flex h-full items-center",children:u.jsx("button",{"aria-label":"Regenerate access code",className:"mr-[5px] flex size-5 cursor-pointer items-center justify-center p-0 text-grey-900 disabled:cursor-not-allowed disabled:opacity-40 dark:text-grey-400","data-testid":"regenerate-access-code",disabled:o,title:"Regenerate access code",type:"button",onClick:U,children:u.jsx(Gw,{"aria-hidden":!0,className:"size-3.5",strokeWidth:1.5})})}),title:"Access code",value:w||"",hideTitle:!0,onChange:_=>{p("password",_.target.value),g(!0)},onKeyDown:()=>x("password")}),L&&!i&&u.jsx(on,{className:"mt-2",children:u.jsxs(u.Fragment,{children:["A private RSS feed is available ",u.jsx("a",{className:"text-green",href:L,rel:"noopener noreferrer",target:"_blank",children:"here"})]})})]})]}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px]",children:"Who should be able to subscribe to your site?"}),u.jsx("div",{className:"w-full md:flex-1",children:u.jsx(ir,{options:Og,selectedOption:Og.find(_=>_.value===k),testId:"subscription-access-select",onSelect:_=>{p("members_signup_access",_?.value||null),g(!0)}})})]}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px]",children:"Who should have access to new posts?"}),u.jsx("div",{className:"w-full md:flex-1",children:u.jsx(ir,{options:Ig,selectedOption:Ig.find(_=>_.value===C),testId:"default-post-access-select",onSelect:_=>{p("default_content_visibility",_?.value||null),g(!0)}})})]}),C==="tiers"&&u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px]",children:"Select specific tiers"}),u.jsx("div",{className:"w-full md:flex-1",children:u.jsx(nb,{color:"black",options:N.filter(_=>_.options.length>0),testId:"tiers-select",values:O,onChange:_=>{$(_),g(!0)}})})]}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px]",children:"Who can comment on posts?"}),u.jsx("div",{className:"w-full md:flex-1",children:u.jsx(ir,{options:Pg,selectedOption:Pg.find(_=>_.value===A),testId:"commenting-select",title:"",onSelect:_=>{p("comments_enabled",_?.value||null),g(!0)}})})]})]});return u.jsx(Se,{description:"Set up who can browse your site, subscribe, read posts, and comment",isEditing:c,keywords:t,navid:"members",saveState:d,testId:"access",title:"Access",hideEditButton:!0,onCancel:m,onEditingChange:g,onSave:f,children:q})},S8=Ce(k8,"Access"),C8=({keywords:t})=>{const{siteData:e}=ke(),[n,r]=v.useState(!1),i=`${e?.url.replace(/\/$/,"")}/#/portal/gift`,s=()=>{navigator.clipboard.writeText(i),r(!0),setTimeout(()=>r(!1),2e3)},o=()=>{window.open(i,"_blank")};return u.jsx(Se,{description:u.jsxs(u.Fragment,{children:["Allow your readers to share your work by purchasing a gift subscription for a friend or colleague. ",u.jsx("a",{className:"text-green",href:"https://ghost.org/help/gift-subscriptions/",rel:"noopener noreferrer",target:"_blank",children:"Learn more"})]}),keywords:t,navid:"gift-subscriptions",testId:"gift-subscriptions",title:"Gift subscriptions",hideEditButton:!0,children:u.jsx(tt,{columns:1,children:u.jsxs("div",{className:"w-100",children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx(qe,{level:6,children:"Shareable link"})}),u.jsxs("div",{className:"group relative mt-0 flex w-100 items-center justify-between overflow-hidden border-b border-transparent pt-1 pb-2 hover:border-grey-300 dark:hover:border-grey-600",children:[u.jsx("span",{"data-testid":"gift-url",children:i}),u.jsxs("div",{className:"invisible flex gap-1 bg-white pl-1 group-hover:visible dark:bg-black",children:[u.jsx(J,{color:"clear","data-testid":"preview-shareable-link",label:"Preview",size:"sm",onClick:o}),u.jsx(J,{color:"light-grey","data-testid":"copy-shareable-link",label:n?"Copied":"Copy link",size:"sm",onClick:s})]})]})]})})})},A8=Ce(C8,"Gift subscriptions"),M8=()=>{const{settings:t,siteData:e}=ke(),[n,r=!1,i=!1]=we(t,["members_signup_access","donations_enabled","recommendations_enabled"]);if(typeof n!="string")throw new TypeError("members_signup_access should be a string");if(typeof r!="boolean")throw new TypeError("donations_enabled should be a boolean");if(typeof i!="boolean")throw new TypeError("recommendations_enabled should be a boolean");return t2({siteUrl:e.url,membersSignupAccess:n,donationsEnabled:r,recommendationsEnabled:i})},E8={useFileUpload:o2,fileTypes:s2},j8=Le("text-[1.6rem] leading-[1.6] tracking-[-0.01em] pb-10","dark:text-white dark:selection:bg-[rgba(88,101,116,0.99)]","[&_.koenig-lexical-editor-input-placeholder]:font-sans! [&_.koenig-lexical-editor-input-placeholder]:text-[1.6rem] [&_.koenig-lexical-editor-input-placeholder]:tracking-tight","[&_:is(h2,h3)]:dark:text-white","[&_.koenig-lexical_input]:text-[1.4rem]","[&_[data-kg-plus-button]]:top-[-4px]","[&_[data-kg-card-selected]]:isolate","[&_:is(p,blockquote,aside,ul,ol)]:tracking-tight","[&_figcaption_:is(p,blockquote,aside,ul,ol)]:text-[1.4rem] [&_figcaption_:is(p,blockquote,aside,ul,ol)]:tracking-[.025em]","[&_figcaption_p]:mb-0","[&_:is(h1)]:text-[36px] [&_:is(h2)]:text-[32px] [&_:is(h3)]:text-[26px] [&_:is(h4)]:text-[21px] [&_:is(h5)]:text-[19px] [&_:is(h6)]:text-[19px] [&_:is(h1,h2,h3,h4,h5,h6)]:mb-[0.5em]","[&_:is(hr)]:pt-0","[&_p]:mb-4 [&_strong]:font-semibold","[&_[data-kg-settings-panel]_p]:!mb-0","[&_.not-kg-prose>div]:font-sans! [&_.not-kg-prose>div]:tracking-tight! [&_.not-kg-prose>div]:text-[1.6rem]! [&_.not-kg-prose>div]:leading-[1.6]!","[&_.kg-inherit-styles_p]:mb-0!","[&_.kg-inherit-styles]:pt-[3px]!","[&_.koenig-lexical-cta-label_p]:!text-[12.5px]"),N8=({editor:t,darkMode:e,cardConfig:n,initialEditorState:r,placeholder:i,className:s,registerAPI:o,onChange:a})=>{const c=t.read().EmailEditor;return u.jsx("div",{className:Le("koenig-react-editor w-full",j8,s),children:u.jsx(c,{cardConfig:n,className:"koenig-lexical koenig-lexical-editor-input",darkMode:e,fileUploader:E8,initialEditorState:r,placeholderText:i,registerAPI:o,onChange:a})})},T8=({value:t,placeholder:e,className:n,onChange:r})=>{const i=v.useRef(null),s=v.useRef(t),{unsplashConfig:o}=Ug(),a=n2(),{config:l,settings:c}=ke(),{fetchAutocompleteLinks:d,searchLinks:h}=M8(),f=r2(),m=l.tenor?.googleApiKey?l.tenor:null,p=l.klipy?.apiKey?l.klipy:null,{fetchKoenigLexical:g,darkMode:b}=ah(),x=v.useMemo(()=>f0(g),[g]),[y]=we(c,["transistor"]),w=v.useMemo(()=>({unsplash:o,pinturaConfig:a,tenor:m,klipy:p,fetchEmbed:f,fetchAutocompleteLinks:d,searchLinks:h,feature:{transistor:y},visibilitySettings:"none"}),[o,a,m,p,f,d,h,y]),k=v.useCallback(M=>{i.current=M},[]),C=v.useCallback(M=>{r&&M&&typeof M=="object"&&r(JSON.stringify(M))},[r]),S=v.useCallback(M=>{(M.metaKey||M.ctrlKey)&&M.key==="k"&&M.stopPropagation()},[]),A=M=>{i.current&&i2(i.current,M)};return u.jsx("div",{className:"h-full",onKeyDown:S,onMouseDown:A,children:u.jsx(lh,{name:"email-editor",children:u.jsx(v.Suspense,{fallback:u.jsx(Ul,{delay:200,size:"lg"}),children:u.jsx(N8,{cardConfig:w,className:n,darkMode:b,editor:x,initialEditorState:s.current,placeholder:e,registerAPI:k,onChange:C})})})})},D8=W.memo(T8),O8=({previewState:t})=>{const[e,n]=v.useState(null),[r,i]=v.useState(!1),s=v.useRef(!1),o=v.useRef(null),a=v.useRef(null),l=v.useRef(null),c=v.useRef(null);function d(){a.current?.disconnect(),a.current=null,l.current!==null&&(window.cancelAnimationFrame(l.current),l.current=null),c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)}const h=t.status==="success"?t.html:"";v.useEffect(()=>(d(),s.current=!1,i(!1),n(null),()=>{d()}),[h,t.status]);function f(){const b=o.current,x=b?.contentDocument;if(!b||!x)return;x.documentElement.style.overflowY="hidden",x.body.style.overflowY="hidden";const y=Math.max(x.documentElement?.scrollHeight||0,x.body?.scrollHeight||0,x.documentElement?.offsetHeight||0,x.body?.offsetHeight||0);y>0&&(n(w=>w===y?w:y),!s.current&&c.current===null&&(c.current=window.requestAnimationFrame(()=>{c.current=window.requestAnimationFrame(()=>{c.current=null,s.current=!0,i(!0)})})))}function m(){l.current!==null&&window.cancelAnimationFrame(l.current),l.current=window.requestAnimationFrame(()=>{l.current=null,f()})}function p(){const b=o.current,x=b?.contentDocument;if(!(!b||!x)&&(d(),m(),typeof ResizeObserver<"u")){const y=new ResizeObserver(()=>{m()});y.observe(x.documentElement),y.observe(x.body),a.current=y}}const g=t.status==="loading"||t.status==="success"&&!r;return u.jsxs("div",{className:"relative w-full","data-testid":"welcome-email-preview",children:[g&&u.jsx("div",{className:"flex min-h-full items-start justify-center pt-24","data-testid":"welcome-email-preview-loading",style:e?{height:`${e}px`}:void 0,children:u.jsx(Ul,{})}),t.status==="success"&&u.jsx("div",{"aria-hidden":!r,className:Le("w-full",!r&&"pointer-events-none absolute left-0 top-0 opacity-0"),children:u.jsx("iframe",{ref:o,className:"w-full rounded bg-white","data-testid":"welcome-email-preview-iframe",sandbox:"allow-same-origin allow-popups allow-popups-to-escape-sandbox",srcDoc:t.html,style:{height:e?`${e}px`:"600px"},title:"Welcome email preview",onLoad:p})}),(t.status==="error"||t.status==="invalid")&&u.jsx("div",{className:"flex h-full items-center justify-center px-4","data-testid":"welcome-email-preview-error",children:u.jsx(on,{color:"red",children:t.message})})]})},I8=t=>{if(!t)return!0;try{const n=JSON.parse(t)?.root?.children;return!n||n.length===0||n.length===1&&n[0].type==="paragraph"&&(!n[0].children||n[0].children.length===0)}catch{return!0}},Py=t=>{const e={};return t.subject?.trim()||(e.subject="A subject is required"),I8(t.lexical)&&(e.lexical="Email content is required"),e},P8=t=>{if(typeof DOMParser>"u")return t;const n=new DOMParser().parseFromString(t,"text/html");return n.querySelectorAll("a[href]").forEach(r=>{r.target="_blank",r.rel="noopener noreferrer"}),`<!doctype html>${n.documentElement.outerHTML}`},R8=t=>{const e="Failed to render preview";return t instanceof qg&&t.data?.errors?.[0]?t.data.errors[0].context||t.data.errors[0].message||e:t instanceof Error&&t.message?t.message:e},L8=({automatedEmailId:t,previewWelcomeEmail:e,setErrors:n})=>{const[r,i]=v.useState({status:"idle"}),s=v.useRef(0),o=()=>{s.current+=1,i({status:"idle"})},a=async c=>{const d=s.current+1;s.current=d;const h=Py(c);if(n(h),!!(h.subject||h.lexical)){i({status:"invalid",message:h.subject||h.lexical});return}i({status:"loading"});try{const m=await e({id:t,subject:c.subject,lexical:c.lexical});if(s.current!==d)return;const p=m.automated_emails?.[0];if(!p?.html||!p?.plaintext||!p?.subject)throw new Error("Preview response was incomplete");i({status:"success",preview:{...p,html:P8(p.html)}})}catch(m){if(s.current!==d)return;i({status:"error",message:R8(m)})}};let l={status:"loading"};return r.status==="success"?l={status:"success",html:r.preview.html}:(r.status==="error"||r.status==="invalid")&&(l={status:r.status,message:r.message}),{previewFrameState:l,previewState:r,enterPreview:a,exitPreview:o}},_8=({automatedEmailId:t,subject:e,lexical:n,validateForm:r,onClose:i})=>{const{data:s}=Hg(),{mutateAsync:o}=a2(),[a,l]=v.useState(s?.email||""),[c,d]=v.useState(""),[h,f]=v.useState("idle"),m=v.useRef(null);v.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),v.useEffect(()=>{s?.email&&l(s.email)},[s?.email]),v.useEffect(()=>{const g=b=>{b.key==="Escape"&&(b.stopPropagation(),i())};return document.addEventListener("keydown",g,!0),()=>document.removeEventListener("keydown",g,!0)},[i]);const p=async()=>{if(d(""),!wt.isEmail(a)){d("Please enter a valid email address");return}if(!r()){d("Please complete the required fields");return}f("sending");try{await o({id:t,email:a,subject:e,lexical:n}),f("sent"),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>f("idle"),2e3)}catch(g){f("idle");let b;g instanceof qg&&g.data&&g.data.errors[0]?b=g.data.errors[0].context||g.data.errors[0].message:g instanceof Error&&(b=g.message),d(b||"Failed to send test email")}};return u.jsxs("div",{className:"absolute top-full right-0 z-10 mt-2 w-[260px] rounded border border-grey-200 bg-white p-4 shadow-lg dark:border-grey-900 dark:bg-grey-950","data-testid":"test-email-dropdown",children:[u.jsxs("div",{className:"mb-3",children:[u.jsx("label",{className:"mb-2 block font-semibold",htmlFor:"test-email-input",children:"Send test email"}),u.jsx(at,{className:"h-[36px]!",id:"test-email-input",placeholder:"you@yoursite.com",value:a,onChange:g=>{l(g.target.value)}})]}),u.jsx(J,{className:"w-full",color:h==="sent"?"green":"black",disabled:h==="sending",label:h==="sent"?"Sent":h==="sending"?"Sending...":"Send",onClick:p}),c&&u.jsx(on,{className:"mt-2",color:"red",children:c})]})},Ry=W.forwardRef(({title:t,centeredHeaderContent:e,headerActions:n,children:r,className:i,isEditMode:s=!1},o)=>u.jsxs("div",{ref:o,className:Le("flex h-full w-full flex-col gap-0 overflow-hidden rounded-xl p-0",s?"bg-white":"bg-gray-100","dark:bg-gray-950",i),children:[u.jsxs("div",{className:"sticky top-0 grid shrink-0 grid-cols-[1fr_auto_1fr] items-center border-b border-gray-200 bg-white px-5 py-3 dark:border-gray-900 dark:bg-gray-950",children:[u.jsx("h3",{className:"justify-self-start text-xl font-semibold",children:t}),u.jsx("div",{className:"justify-self-center",children:e}),u.jsx("div",{className:"flex items-center gap-2 justify-self-end",children:n})]}),u.jsx("div",{className:"flex h-[clamp(0px,calc(100dvh-320px),82vh)] min-h-0 grow flex-col overflow-y-auto [scrollbar-gutter:stable]",children:r})]}));Ry.displayName="EmailPreviewModalContent";const F8=({children:t,className:e})=>u.jsx("div",{className:Le("relative z-20 isolate mx-auto w-full max-w-[780px] rounded-t-lg border border-b-0 border-gray-200 bg-white px-6 py-4 transition-[max-width,padding] duration-300 ease-out motion-reduce:transition-none dark:border-grey-900 dark:bg-grey-950",e),children:t}),B8=({children:t,className:e})=>u.jsx("div",{className:Le("flex mx-auto w-full rounded-b-lg transition-[max-width,height,padding] duration-300 ease-out motion-reduce:transition-none dark:border-grey-900 dark:shadow-none grow max-w-[780px]",e),children:t}),Rg=pe.create(({emailType:t="free",automatedEmail:e})=>{const n=an(),{settings:r,config:i}=ke(),[s,o,a]=we(r,["title","default_email_address","support_email_address"]),{updateRoute:l}=fe(),{mutateAsync:c}=Jg(),{mutateAsync:d}=l2(),{data:h}=eh(),[f,m]=v.useState(!1),[p,g]=v.useState("edit"),[b,x]=v.useState(null),y=v.useRef(null),w=v.useRef(e?.lexical||""),k=v.useRef(!1),C=Ye(),S=h?.automated_emails||[],{resolvedSenderName:A,resolvedSenderEmail:M,resolvedReplyToEmail:E,hasDistinctReplyTo:j}=ky(S,{config:i,defaultEmailAddress:o,siteTitle:s,supportEmailAddress:a}),N=`${t==="paid"?"Paid":"Free"} members welcome email`,{formState:D,saveState:O,updateForm:L,setFormState:$,setErrors:U,handleSave:q,okProps:_,errors:te,validate:ce}=zl({initialState:{subject:e?.subject||"Welcome",lexical:e?.lexical||""},savingDelay:500,onSave:async se=>{await c({...e,...se})},onSaveError:C,onValidate:Py}),G=_.label||"Save",{previewFrameState:oe,enterPreview:B,exitPreview:Y}=L8({automatedEmailId:e.id,previewWelcomeEmail:d,setErrors:U}),ee=O==="unsaved",ae=v.useCallback(()=>{Ui(ee,()=>{n.remove()})},[n,ee]);v.useEffect(()=>{const se=ie=>{y.current&&!y.current.contains(ie.target)&&m(!1)};return f&&document.addEventListener("mousedown",se),()=>{document.removeEventListener("mousedown",se)}},[f]);const ue=v.useRef(q);v.useEffect(()=>{ue.current=q},[q]),v.useEffect(()=>{const se=ie=>{(ie.metaKey||ie.ctrlKey)&&ie.key==="s"&&(ie.preventDefault(),ue.current({fakeWhenUnchanged:!0}))};return window.addEventListener("keydown",se),()=>{window.removeEventListener("keydown",se)}},[]);const ve=v.useCallback(se=>{g(se),se==="preview"?(x(null),B(D)):(m(!1),x(null),Y())},[B,Y,D]),X=v.useCallback(se=>{if(!k.current){w.current=se,$(ie=>({...ie,lexical:se}));return}se!==w.current?L(ie=>({...ie,lexical:se})):$(ie=>({...ie,lexical:se}))},[$,L]);return u.jsx(Fr,{afterClose:()=>{l("memberemails")},backDropClick:!1,dirty:ee,footer:!1,header:!1,padding:!1,scrolling:!1,size:"full",testId:"welcome-email-modal",width:"full",children:u.jsx(Ry,{centeredHeaderContent:u.jsx(th,{"data-testid":"welcome-email-mode-toggle",value:p,variant:"segmented-sm",onValueChange:se=>se&&ve(se),children:u.jsxs(nh,{className:"grid w-[240px] grid-cols-2 bg-gray-100 shadow-[inset_0_0_0_1px_rgba(0,0,0,0.04)]",children:[u.jsx(zi,{className:"w-full justify-center data-[state=active]:bg-white dark:data-[state=active]:bg-white dark:data-[state=active]:text-black","data-testid":"welcome-email-mode-edit",value:"edit",children:"Email content"}),u.jsx(zi,{className:"w-full justify-center","data-testid":"welcome-email-mode-preview",value:"preview",children:"Preview"})]})}),className:"dark:bg-[#151719]",headerActions:u.jsxs(u.Fragment,{children:[u.jsx(Nr,{variant:"outline",onClick:ae,children:"Close"}),u.jsx(Nr,{disabled:_.disabled,onClick:async()=>await q({fakeWhenUnchanged:!0}),children:G})]}),isEditMode:p==="edit",title:N,children:u.jsxs("div",{className:"flex grow flex-col items-center p-6",children:[p==="preview"&&u.jsx(F8,{className:"border-x-0 border-t-0 border-b",children:u.jsxs("div",{className:"flex flex-col gap-2",children:[u.jsxs("div",{className:"flex items-center py-1",children:[u.jsx("div",{className:"w-20 shrink-0 font-semibold",children:"From:"}),u.jsx("div",{className:"min-w-0 grow pr-4",children:u.jsxs("span",{className:"flex gap-1 truncate whitespace-nowrap",children:[u.jsx("span",{children:A}),u.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:`<${M}>`})]})}),u.jsxs("div",{ref:y,className:"relative",children:[u.jsx(J,{className:"border border-grey-200 font-semibold hover:border-grey-300 hover:bg-white! dark:border-grey-900 dark:hover:border-grey-800 dark:hover:bg-grey-950!",color:"clear",icon:"send",label:"Test",onClick:()=>m(!f)}),f&&u.jsx(_8,{automatedEmailId:e.id,lexical:D.lexical,subject:D.subject,validateForm:ce,onClose:()=>m(!1)})]})]}),j&&u.jsxs("div",{className:"flex items-center",children:[u.jsx("div",{className:"w-20 shrink-0 font-semibold",children:"Reply-to:"}),u.jsx("div",{className:"grow text-gray-500 dark:text-gray-400",children:E})]}),u.jsxs("div",{className:"flex items-center",children:[u.jsx("div",{className:"w-20 shrink-0 font-semibold",children:"Subject:"}),u.jsxs("div",{className:"grow",children:[u.jsx(at,{className:"w-full","data-testid":"welcome-email-preview-subject",value:b??D.subject,onChange:se=>{const ie=se.target.value;x(ie),L(Ne=>({...Ne,subject:ie}))}}),te.subject&&u.jsx(on,{className:"mt-2",color:"red",children:te.subject})]})]})]})}),u.jsxs(B8,{className:Le(p==="preview"&&"shadow-sm bg-white dark:bg-grey-950",p==="edit"&&"px-6",p==="edit"&&"rounded-lg",p==="edit"&&te.lexical&&"border border-red-500"),children:[u.jsx("div",{className:Le("mx-auto w-full max-w-[600px] pt-10 pb-8 transition-[max-width,padding] duration-300 ease-out motion-reduce:transition-none",p==="preview"&&"hidden"),"data-testid":"welcome-email-editor",onFocus:()=>{k.current=!0},children:u.jsx(D8,{className:"welcome-email-editor",placeholder:"Begin writing your email...",value:D.lexical,onChange:X},e?.id||"new")}),p==="preview"&&u.jsx(O8,{previewState:oe})]}),p==="edit"&&te.lexical&&u.jsx(on,{className:"mt-2 max-w-[740px]",color:"red",children:te.lexical})]})})})}),Lg=({automatedEmail:t,emailType:e,icon:n,title:r,enabled:i,isBusy:s,isInitialLoading:o,onEdit:a,onToggle:l})=>u.jsx(ls,{action:u.jsxs("div",{className:`flex items-center gap-7 ${s&&!o?"pointer-events-none":""}`,children:[o?u.jsx("div",{className:"h-4 w-7 rounded-full bg-grey-300 dark:bg-grey-800"}):u.jsx(en,{checked:i,onChange:l}),u.jsx("button",{className:"font-semibold text-green hover:opacity-80",type:"button",onClick:a,children:"Edit"})]}),hideActions:!1,testId:`${e}-welcome-email-row`,children:u.jsx("div",{className:"w-full",children:u.jsxs("button",{className:"flex w-full min-w-0 items-center gap-3 py-3 text-left focus-visible:ring-2 focus-visible:ring-green focus-visible:ring-offset-2 focus-visible:outline-none dark:focus-visible:ring-offset-black","data-testid":`${e}-welcome-email-preview`,type:"button",onClick:a,children:[u.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-grey-100 dark:bg-grey-900",children:u.jsx(me,{colorClass:"text-grey-700 dark:text-grey-600",name:n,size:"md"})}),u.jsxs("div",{className:"min-w-0 grow",children:[u.jsx("div",{className:"leading-tight font-medium","data-testid":`${e}-welcome-email-title`,children:r}),u.jsx("div",{className:"mt-1 text-sm leading-[1.35] text-grey-700 dark:text-grey-600",children:t.subject})]})]})})}),V8=({settings:t,config:e,freeEmailForDisplay:n,paidEmailForDisplay:r,freeWelcomeEmailEnabled:i,paidWelcomeEmailEnabled:s,isBusy:o,isLoading:a,onFreeEdit:l,onFreeToggle:c,onPaidEdit:d,onPaidToggle:h})=>u.jsxs(Mr,{borderTop:!0,children:[u.jsx(Lg,{automatedEmail:n,emailType:"free",enabled:i,icon:"user-add",isBusy:o,isInitialLoading:a,title:"Free members welcome email",onEdit:l,onToggle:c}),nr(t,e)&&u.jsx(Lg,{automatedEmail:r,emailType:"paid",enabled:s,icon:"bills",isBusy:o,isInitialLoading:a,title:"Paid members welcome email",onEdit:d,onToggle:h})]}),z8=({keywords:t})=>{const{settings:e,config:n}=ke(),[r]=we(e,["title"]),i=Qo().getParam("verifyEmail"),{data:s,isLoading:o}=eh(),{mutateAsync:a,isLoading:l}=Yg(),{mutateAsync:c,isLoading:d}=Jg(),{mutateAsync:h}=Xg(),f=Ye(),m=s?.automated_emails||[],g=o||(l||d),b=m.find(j=>j.slug===Ar.free),x=m.find(j=>j.slug===Ar.paid),y=b?.status==="active",w=x?.status==="active",k=async(j,T)=>{const N=vf(j,r);return a({...N,status:T})},C=v.useRef(null);v.useEffect(()=>{if(!i||!window.location.href.includes("memberemails")||C.current===i)return;C.current=i;const j=()=>{const N=window.location.hash.slice(1),D=new URL(N||"/memberemails",window.location.origin);D.searchParams.delete("verifyEmail");const O=D.search?`#${D.pathname}${D.search}`:`#${D.pathname}`;window.history.replaceState(null,"",`${window.location.pathname}${O}`)};(async()=>{try{const{meta:{email_verified:N}={}}=await h({token:i});j();let D="Sender email verified",O=u.jsx(u.Fragment,{children:"Welcome email sender settings have been updated."});N==="sender_reply_to"&&(D="Reply-to address verified",O=u.jsx(u.Fragment,{children:"Welcome email reply-to address has been verified and updated."})),pe.show(Wt,{title:D,prompt:O,okLabel:"Close",cancelLabel:"",onOk:L=>L?.remove()})}catch(N){let D="There was an error verifying your email address. Try again later.";N instanceof Vl&&N.message==="Token expired"&&(D="Verification link has expired."),j(),pe.show(Wt,{title:"Error verifying email address",prompt:D,okLabel:"Close",cancelLabel:"",onOk:O=>O?.remove()}),f(N,{withToast:!1})}})()},[f,i,h]);const S=async j=>{const T=m.find(D=>D.slug===Ar[j]),N=j==="free"?"Free members":"Paid members";if(!g)try{T?T.status==="active"?(await c({...T,status:"inactive"}),rn({type:"success",title:`${N} welcome email disabled`})):(await c({...T,status:"active"}),rn({type:"success",title:`${N} welcome email enabled`})):(await k(j,"active"),rn({type:"success",title:`${N} welcome email enabled`}))}catch(D){f(D)}},A=async j=>{const T=m.find(N=>N.slug===Ar[j]);if(!g)if(T)pe.show(Rg,{emailType:j,automatedEmail:T});else try{const D=(await k(j,"inactive"))?.automated_emails?.[0];D&&pe.show(Rg,{emailType:j,automatedEmail:D})}catch(N){f(N)}},M=b||Mg("free",r),E=x||Mg("paid",r);return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Customize",size:"sm",onClick:()=>pe.show(Cy)}),description:"Create and manage automated emails for your members",keywords:t,navid:"memberemails",testId:"memberemails",title:"Welcome emails",children:u.jsx(V8,{config:n,freeEmailForDisplay:M,freeWelcomeEmailEnabled:y,isBusy:g,isLoading:o,paidEmailForDisplay:E,paidWelcomeEmailEnabled:w,settings:e,onFreeEdit:()=>A("free"),onFreeToggle:()=>S("free"),onPaidEdit:()=>A("paid"),onPaidToggle:()=>S("paid")})})},$8=Ce(z8,"MemberEmails"),H8="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAcCAQAAADc8cciAAADJ0lEQVR4AYyUA2DsaBCAZ3X2s23btm3btm3btm3btm2VqyT31W3K9DfGkkjNJGaRkeZW8dpl6Zwpz295Al5i2awiCwt5nOQeGxjJUNZ9Or2i5AoRS6xQfW78f1sbTk+6UJ+SpMdEU49HeX4TS8wSWLrEAbU5qZXCDGO0MtF9xHWVB+oGZSjuh0UeipijRe2Umif8Qhd13/kubZOWtAaBZvnpaHpasY2vH4d8DJAtKoHrpOMscTk2r/A8EZNOxMBzr19fTeaJ1wGvKLS3tIrHK6847EGi0c0s8nAIezgxJkMgOf0Hqj0pqxqn1msVGf3LWnU9qx7UfqBzn+neKNqojT/P/CwxdTHX/IcLbNAGnyuv480j/mPLvLSG4WBRq3BLW8C0Zr8HyzggB2MpzS7EuN+tSD1OaEOud7su1wOEXtKAcjTxXeYrxn1GTn5nMytZl8eWRySPvF9ELSozu0ycMmLUu6QgLRXYxMqemQKVdM9jLCXoMjDXQDHqhf4jB39ynHF7W+8V2SvKaBaQl6bdinUToy5WSvI3Sxj3bMKzAAu6WzCY8VTc0jw2yfexLKnoxHrvWd4i3uIowUBGMMo+3S7G/XJFslCc/fYpdhG7PC1FZsYylV2DExnnraMNecnCbu+R3iJiGpSeJMyggTLNfsUec9qbeyejKSUoybr7be+L3PfvvjVcmVlAL3dPLpWJEx16wLs2g9JkYhGLuiYOspC58b8U0LrSnqH+6Ic25tDljS4x89i+LKICBciu3Hzd67W8FglczNOSUc/Zmeb0V8az7Hbl23rxTSKVE55qwESlCAWIo1xWt6iizz9z+d99RzFKbUJHbbk24d2Ad/JOKv1cNcnYvGerO9pSm7z+vRxJOM3+qXHFHClf52dnpjaaHZxX9rpuOFpSjIJkJSNZSEMmGlOV1+5eL3O/lKAuL3VdzGI6V5qSSnFGsJWbXGAFA2lJA7qygItMJ+Hjco91IkfiXzj+0bquBtRSW9OYNgxmGetZSB/iU/pQxkPRoupKXvn4s/I8LO1ZicqUIAfZFb/ZHtY3ZoXIEQaMMNqBRYXdgcWBAVMjAKGlEzkN2rk9AAAAAElFTkSuQmCC",U8="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAQlBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////8IX9KGAAAAFnRSTlMAQI+v38+/cCD/n3/vkFAwYBCAoLBfxGozVwAAAT1JREFUeAHd1NEO2yAMheGTBhL/idtAu73/q67VFIkRAevVpH13KDkYkGX9C9NtDiEuq/3l7wunzTR2o7RrZAH8/jA70jxKnPvPWb9ZAFb1JOBZrF/AoY4Ad5UiLP0CIat0AKam+XrkpXsLh+Na9IdaMqCKQdBp/HEQyOCqHL2A/Pokj/pdR0+ywV1NK8TLFZjUlB3WukBQxxP4Wax34KGeWHZ0vtG5QdHRIZkk2x2IGrDIhwfn46WRvFPwpIHd+VNI4/P4lg4zm9Z5NDoOB2LKOlkKQLDO/75WNe/tOWAO4VAtuZve9ljlcmgUz1lv+dIjO7ipyeqAAUlfBDZY9EUgO0zfBB6dvt/DBxDezrfa2vMqUzr3jZ0TLRTOWQ1ktdjbBME+qok0uHRrOQ5o4fldQKZxQEODMwyY/h+/ADWjEK3gLf0/AAAAAElFTkSuQmCC",Au=({title:t,color:e,price:n})=>u.jsxs("div",{className:"rounded-lg bg-grey-100/70 px-3 pt-1.5 pb-3",children:[u.jsx("div",{className:"font-space-grotesk text-[1.5rem] font-bold",style:{color:e},children:t}),u.jsx("div",{className:"-mt-1 font-space-grotesk text-[1.7rem] font-bold",children:n}),u.jsxs("div",{className:"mt-5 flex flex-col gap-1.5",children:[u.jsx("div",{className:"h-1.5 w-[100%] bg-grey-300/60"}),u.jsx("div",{className:"h-1.5 w-[70%] bg-grey-300/60"}),u.jsx("div",{className:"h-1.5 w-[90%] bg-grey-300/60"})]})]}),W8=({keywords:t})=>{const{updateRoute:e}=fe(),{settings:n}=ke(),[r,i,s]=we(n,["accent_color","icon","members_signup_access"]),o=()=>{e("portal/edit")},a=r||"#F6414E";return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",disabled:s==="none",label:"Customize",size:"sm",onClick:o}),description:"Customize members modal signup flow",keywords:t,navid:"portal",testId:"portal",title:"Signup portal",children:u.jsxs("div",{className:"relative isolate -mx-5 -mb-5 hidden flex-col items-center justify-end overflow-hidden rounded-b-xl bg-grey-50 px-5 pt-6 text-black sm:visible! sm:flex! md:-mx-7 md:-mb-7",children:[u.jsx("div",{className:"absolute right-6 bottom-6 flex size-12 items-center justify-center rounded-full text-white shadow-lg",style:{backgroundColor:a},children:u.jsx("img",{className:"size-6",src:U8})}),u.jsxs("div",{className:"grid w-full max-w-[440px] grid-cols-3 gap-5 rounded-t-xl bg-white px-9 py-6 shadow-xl",children:[u.jsxs("div",{className:"col-span-3 mb-1 flex flex-col items-center justify-center",children:[i?u.jsx("div",{className:"size-6 rounded-sm bg-cover bg-center",style:{backgroundImage:`url(${i})`}}):u.jsx("div",{className:"flex aspect-square items-center justify-center overflow-hidden rounded-full p-1 text-white",style:{backgroundColor:a},children:u.jsx("img",{className:"h-auto w-5",src:H8})}),u.jsx("div",{className:"mt-1.5 font-space-grotesk text-lg font-bold",children:"Sign up"}),u.jsx("div",{className:"mt-1.5 flex h-6 w-1/2 items-center rounded border border-grey-200 p-2 text-sm text-grey-700",children:"jamie@example.com"})]}),u.jsx(Au,{color:a,price:"$0",title:"Free"}),u.jsx(Au,{color:a,price:"$5",title:"Silver"}),u.jsx(Au,{color:a,price:"$10",title:"Gold"})]})]})})},K8=Ce(W8,"Portal settings"),G8=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,errors:a,clearError:l,handleEditingChange:c}=Ft({onValidate:()=>({})}),[d]=we(e,["blocked_email_domains"]),h=JSON.parse(d||"[]"),[f,m]=W.useState(h.join(`
|
|
29
|
+
hsl(${c}, 100%, 50%)`,[c]);v.useEffect(()=>{const x=d/100,y=x<.01?100:50+50*(1-x),w=Math.max(0,Math.min(1,1-h/y));o(x),l(w)},[d,h]);const g=v.useCallback(x=>{if(!n.current)return;const y=n.current.getBoundingClientRect(),w=Math.max(0,Math.min(1,(x.clientX-y.left)/y.width)),k=Math.max(0,Math.min(1,(x.clientY-y.top)/y.height));o(w),l(k),f(w*100);const S=(w<.01?100:50+50*(1-w))*(1-k);m(S)},[f,m]),b=v.useCallback(x=>{r&&g(x)},[r,g]);return v.useEffect(()=>{const x=()=>i(!1);return r&&(window.addEventListener("pointermove",b),window.addEventListener("pointerup",x)),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",x)}},[r,b]),u.jsx("div",{ref:n,className:Le("relative size-full cursor-crosshair rounded",t),style:{background:p},onPointerDown:x=>{x.preventDefault(),i(!0),g(x.nativeEvent)},...e,children:u.jsx("div",{className:"pointer-events-none absolute size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white",style:{left:`${s*100}%`,top:`${a*100}%`,boxShadow:"0 0 0 1px rgba(0,0,0,0.5)"}})})});Z1.displayName="ColorPickerSelection";const TI=({className:t,...e})=>{const{hue:n,setHue:r}=qo();return u.jsxs(R1,{className:Le("relative flex h-4 w-full touch-none",t),max:360,step:1,value:[n],onValueChange:([i])=>r(i),...e,children:[u.jsx(V1,{className:"relative my-0.5 h-3 w-full grow rounded-full bg-[linear-gradient(90deg,red,yellow,lime,aqua,blue,magenta,red)]",children:u.jsx(z1,{className:"absolute h-full"})}),u.jsx(G1,{className:"block size-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:ring-1 focus-visible:ring-focus-ring focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"})]})},DI=({className:t,...e})=>{const{setHue:n,setSaturation:r,setLightness:i,setAlpha:s}=qo();if(!(typeof window<"u"&&"EyeDropper"in window))return null;const a=async()=>{try{const c=await new EyeDropper().open(),d=Fe(c.sRGBHex),[h,f,m]=d.hsl().array();n(h),r(f),i(m),s(100)}catch(l){console.error("EyeDropper failed:",l)}};return u.jsx(Nr,{className:Le("shrink-0 text-muted-foreground size-8",t),size:"icon",type:"button",variant:"outline",onClick:a,...e,children:u.jsx(m2,{size:16})})},OI=["hex","rgb","hsl"],II=({...t})=>{const{mode:e,setMode:n}=qo();return u.jsxs(Eo,{value:e,onValueChange:n,children:[u.jsx(jo,{className:"h-8 w-20 shrink-0 text-xs",...t,children:u.jsx(No,{placeholder:"Mode"})}),u.jsx(To,{children:OI.map(r=>u.jsx($i,{className:"text-xs",value:r,children:r.toUpperCase()},r))})]})},PI=({className:t,...e})=>{const{hue:n,saturation:r,lightness:i,mode:s,setHue:o,setSaturation:a,setLightness:l,setAlpha:c}=qo(),d=Fe.hsl(n,r,i),[h,f]=v.useState(null),m=(p,g)=>{try{if(s==="hex"){const b=Fe(p);o(b.hue()),a(b.saturationl()),l(b.lightness()),c(b.alpha()*100)}else if((s==="rgb"||s==="hsl")&&g!==void 0){const b=d[s]().array().map(y=>Math.round(y));b[g]=parseInt(p,10)||0;const x=Fe[s](b[0],b[1],b[2]);o(x.hue()),a(x.saturationl()),l(x.lightness())}}catch{}};if(s==="hex"){const p=d.hex();return u.jsx("div",{className:Le("-space-x-px relative flex w-full items-center rounded-md",t),...e,children:u.jsx(_s,{className:"h-8 px-2 font-mono text-xs shadow-none",type:"text",value:h??p,onBlur:()=>{f(null)},onChange:g=>{f(g.target.value),m(g.target.value)}})})}if(s==="rgb"||s==="hsl"){const p=d[s]().array().map(g=>Math.round(g));return u.jsx("div",{className:Le("-space-x-px flex flex-1 items-stretch rounded-md",t),...e,children:p.map((g,b)=>u.jsx(_s,{className:Le("h-8 px-2 font-mono text-xs flex-1 shadow-none focus:z-10",b&&"rounded-l-none",b<p.length-1&&"rounded-r-none"),maxLength:3,size:4,type:"text",value:g,onChange:x=>{m(x.target.value,b)}},b))})}return null},RI=t=>u.jsxs(NI,{className:"w-auto min-w-80",...t,children:[u.jsx(Z1,{className:"aspect-square"}),u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx(DI,{}),u.jsx(TI,{})]}),u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx(II,{}),u.jsx(PI,{})]})]}),LI=()=>{const{isDirty:t}=Gl(),e=()=>{window.location.hash="/"};return u.jsx(J,{className:"text-grey-700 hover:text-grey-900!","data-testid":"exit-settings",icon:"close",id:"done-button",label:"",link:!0,title:"Close (ESC)",onClick:()=>Ui(t,e)})},_I=""+new URL("logo-loader-88VPEpXE.mp4",import.meta.url).href,FI=""+new URL("logo-loader-dark-CuSPz-zc.mp4",import.meta.url).href,Q1=v.createContext(void 0),BI=({children:t})=>{const e=gw(),n=bw(),r=vw(),i=Hg(),[s,o]=v.useState(!1);v.useEffect(()=>{o(document.documentElement.classList.contains("dark"))},[]);const a=[e,n,r,i],l=a.map(c=>c.error).find(Boolean);if(l)throw l;return a.some(c=>c.isLoading)?u.jsx("div",{className:"gh-loading-orb-container",style:{width:"100vw",height:"100vh",display:"flex",alignItems:"center",justifyContent:"center",paddingBottom:"8vh"},children:u.jsx("video",{autoPlay:!0,className:"gh-loading-orb",height:"100",preload:"metadata",style:{width:"100px",height:"100px"},width:"100",loop:!0,muted:!0,playsInline:!0,children:u.jsx("source",{src:s?FI:_I,type:"video/mp4"})})}):u.jsx(Q1.Provider,{value:{settings:e.data.settings,siteData:n.data.site,config:r.data.config,currentUser:i.data},children:t})},ke=()=>v.useContext(Q1),Ft=({savingDelay:t,onValidate:e}={})=>{const n=v.useRef(null),{siteData:r,settings:i}=ke(),{mutateAsync:s}=ai(),o=Ye(),[a,l]=v.useState(!1),{formState:c,saveState:d,handleSave:h,updateForm:f,setFormState:m,reset:p,validate:g,errors:b,clearError:x,okProps:y}=zl({initialState:i||[],savingDelay:t,onSave:async()=>{await s?.(k())},onSaveError:o,onValidate:e}),{setGlobalDirtyState:w}=Gl();v.useEffect(()=>{w(c.some(M=>M.dirty))},[c,w]),v.useEffect(()=>{a&&n.current&&n.current.focus()},[a]),v.useEffect(()=>{(!a||d==="saving")&&m(()=>i)},[i]);const k=()=>c?.filter(M=>M.dirty)?.map(M=>({key:M.key,value:M.value}));return{localSettings:c,isEditing:a,saveState:d,focusRef:n,siteData:r,handleSave:async()=>{const M=await h();return M&&l(!1),M},handleCancel:()=>{p(),l(!1)},updateSetting:(M,E)=>{f(j=>j.some(T=>T.key===M)?j.map(T=>T.key===M?{...T,value:E,dirty:!0}:T):[...j,{key:M,value:E,dirty:!0}])},handleEditingChange:M=>{l(M)},validate:g,errors:b,clearError:x,okProps:y}},VI=(t,e)=>{const[n,r]=v.useState("Save"),[i,s]=v.useState(!1);return{savingTitle:n,isSaving:i,onSaveClick:async()=>{s(!0),r("Saving"),await t({fakeWhenUnchanged:e}),setTimeout(()=>{r("Saved"),setTimeout(()=>{r("Save"),s(!1)},1e3)},1e3)}}},zI=({afterClose:t})=>{const{localSettings:e,handleSave:n,updateSetting:r}=Ft(),i=an(),[s,o]=we(e,["codeinjection_head","codeinjection_foot"]),[a,l]=v.useState("header"),c=v.useRef(null),d=v.useRef(null),h=v.useMemo(()=>Co(()=>import("./index-DNRlkUeu.js"),__vite__mapDeps([19,20,21,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,22]),import.meta.url).then(y=>y.html()),[]),f={extensions:[h],hint:"Code here will be injected into the {{ghost_head}} tag on every page of the site",value:s||"",onChange:y=>r("codeinjection_head",y)},m={extensions:[h],hint:"Code here will be injected into the {{ghost_foot}} tag on every page of the site",value:o||"",onChange:y=>r("codeinjection_foot",y)},p=[{id:"header",title:"Site header",contents:u.jsx(Df,{height:"full",...f,ref:c,className:"mt-2","data-testid":"header-code",autoFocus:!0}),tabWrapperClassName:"flex-auto",containerClassName:"h-full"},{id:"footer",title:"Site footer",contents:u.jsx(Df,{height:"full",...m,ref:d,className:"mt-2","data-testid":"footer-code"}),tabWrapperClassName:"flex-auto",containerClassName:"h-full"}],{savingTitle:g,isSaving:b,onSaveClick:x}=VI(n,!0);return v.useEffect(()=>{const y=w=>{(w.metaKey||w.ctrlKey)&&w.key==="s"&&(w.preventDefault(),x())};return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}}),u.jsx(Fr,{afterClose:t,backDropClick:!1,cancelLabel:"Close",footer:u.jsx(u.Fragment,{}),height:"full",size:"full",testId:"modal-code-injection",children:u.jsxs("div",{className:"flex h-full flex-col",children:[u.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[u.jsx(qe,{level:2,children:"Code injection"}),u.jsx(rl,{buttons:[{label:"Close",color:"outline",onClick:()=>{i.remove(),t?.()}},{disabled:b,label:g,color:g==="Saved"?"green":"black",onClick:x}]})]}),u.jsx(hr,{containerClassName:"flex-auto flex flex-col mb-16",selectedTab:a,tabs:p,onTabChange:l})]})})},$I=pe.create(zI),HI=(t,e)=>`${t}-${e}`,UI=()=>{const[t,e]=v.useState(""),[n,r]=v.useState(!1),i=v.useRef(new Map),[s,o]=v.useState(new Set),a=m=>m.length?m.some(p=>p.toLowerCase().includes(t.toLowerCase())):!0,l=v.useCallback((m,p)=>{i.current.set(m,p),(!t||p.some(b=>b.toLowerCase().includes(t.toLowerCase())))&&o(b=>new Set(b).add(m))},[t]),c=v.useCallback(m=>{i.current.delete(m),o(p=>{const g=new Set(p);return g.delete(m),g})},[]);v.useEffect(()=>{const m=new Set;i.current.forEach((p,g)=>{(!t||p.some(x=>x.toLowerCase().includes(t.toLowerCase())))&&m.add(g)}),o(m)},[t]);const d=v.useCallback(m=>s.size===1&&s.has(m),[s]),h=v.useCallback(()=>s,[s]),f=m=>{if(!t)return m;if(typeof m=="string"){const p=t.split(/\s+/).map(y=>y.toLowerCase()),g=p.map(y=>y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),b=m.split(new RegExp(`(${g})`,"gi")),x=new Map;return b.map(y=>{if(!p.includes(y.toLowerCase()))return y;const w=(x.get(y)??0)+1;return x.set(y,w),u.jsx("span",{className:"bg-yellow-500/40",children:y},`${y}-${w}`)})}else return Array.isArray(m)?m.map(p=>f(p)):m&&typeof m=="object"&&m?W.Children.map(m,p=>p&&typeof p=="object"&&"props"in p?f(p.props.children):p):m};return{filter:t,setFilter:e,checkVisible:a,highlightKeywords:f,noResult:n,setNoResult:r,registerComponent:l,unregisterComponent:c,getVisibleComponents:h,isOnlyVisibleComponent:d}},ey=v.createContext({route:"",updateRoute:()=>{},loadingModal:!1,eventTarget:new EventTarget});function WI(t,e){if(!e)return null;const n=new RegExp(`/${t}/(.*)`),r=e?.match(n);return r?r[1]:null}const KI=(t,e,n,r)=>{let i=window.location.hash;i=i.substring(1);const s=`${window.location.protocol}//${window.location.hostname}`,o=new URL(i,s),a=WI(t,o.pathname);if(!r||!n)return{pathName:a||""};const l=o.searchParams;if(a&&r&&n){const[,c]=Object.entries(r).find(([f])=>pu(e||"",f))||[],[d,h]=Object.entries(r).find(([f])=>pu(a,f))||[];return{pathName:a,changingModal:h&&h!==c,modal:d&&h?n().then(({default:f})=>{pe.show(f[h],{pathName:a,params:pu(a,d),searchParams:l})}):void 0}}return{pathName:""}},pu=(t,e)=>{const n=new RegExp("^"+e.replace(/:(\w+)/g,"(?<$1>[^/]+)")+"/?$"),r=t.match(n);if(r)return r.groups||{}},GI=({basePath:t,modals:e,children:n})=>{const{externalNavigate:r}=Ug(),[i,s]=v.useState(void 0),[o,a]=v.useState(!1),[l]=v.useState(new EventTarget),c=v.useCallback(d=>{const h=typeof d=="string"?{route:d}:d;if(h.isExternal){r(h);return}const f=h.route.replace(/^\//,"");f===i||(f?window.location.hash=`/${t}/${f}`:window.location.hash=`/${t}`),l.dispatchEvent(new CustomEvent("routeChange",{detail:{newPath:f,oldPath:i}}))},[t,l,r,i]);return v.useEffect(()=>{setTimeout(()=>{e?.load()},1e3)},[]),v.useEffect(()=>{const d=()=>{s(h=>{const{pathName:f,modal:m,changingModal:p}=KI(t,h,e?.load,e?.paths);return m&&p&&(a(!0),m.then(()=>a(!1))),f})};return d(),window.addEventListener("hashchange",d),()=>{window.removeEventListener("hashchange",d)}},[]),i===void 0?null:u.jsx(ey.Provider,{value:{route:i,updateRoute:c,loadingModal:o,eventTarget:l},children:n})};function fe(){return v.useContext(ey)}function qI(t,e){const{eventTarget:n}=fe(),r=v.useCallback(t,e);v.useEffect(()=>{const i=s=>{const o=s;r(o.detail.newPath,o.detail.oldPath)};return n.addEventListener("routeChange",i),()=>n.removeEventListener("routeChange",i)},[n,r])}const ty=v.createContext({updateSection:()=>{},updateNav:()=>{},currentSection:null,updateNavigatedSection:()=>{},scrollToSection:()=>{}}),yc=()=>v.useContext(ty),ny=193,gu=(t,e)=>{const n=document.getElementById("admin-x-settings-scroller"),r=t.getBoundingClientRect().top+n.scrollTop;n.scrollTo({behavior:e?"smooth":"instant",top:r-ny})},YI=(t,e)=>{const n=document.getElementById("admin-x-settings-sidebar-scroller"),r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),s=i.top+40;if(r.top>=s&&r.left>=i.left&&r.right<=i.right&&r.bottom<=i.bottom||!["auto","scroll"].includes(getComputedStyle(n).overflowY))return;const o=e?"smooth":"instant";n.querySelector("[data-setting-nav-item]")===t?n.scrollTo({top:0,behavior:o}):r.top<s?n.scrollTo({top:n.scrollTop+r.top-s,behavior:o}):n.scrollTo({top:n.scrollTop+r.top-i.top-i.height+r.height+4,behavior:o})},XI=(t,e,n)=>{const r=e.map(({isIntersecting:a,target:l})=>({isIntersecting:a,id:Object.entries(n).find(([,c])=>c===l)?.[0]})).filter(a=>a.id),i=r.filter(a=>!t.includes(a.id)&&a.isIntersecting).map(a=>a.id),s=r.filter(a=>!a.isIntersecting).map(a=>a.id),o=t.filter(a=>!s.includes(a)).concat(i);return o.sort((a,l)=>{const c=n[a],d=n[l];return!c||!d?0:c.getBoundingClientRect().top-d.getBoundingClientRect().top}),o},JI=({children:t})=>{const[e,n]=v.useState(null),r=v.useRef({}),i=v.useRef(null),[s,o]=v.useState([]),[a,l]=v.useState(null),[c,d]=v.useState(!1),[h,f]=v.useState(!1),[,m]=v.useState(!1),p=v.useCallback(C=>{n(C),d(!0)},[]),g=v.useRef({}),b=v.useCallback(()=>{const C=new IntersectionObserver(S=>{o(A=>{const M=XI(A,S,r.current);return M.length&&l(M[0]),M})},{rootMargin:`-${ny-50}px 0px -40% 0px`});return Object.values(r.current).forEach(S=>C.observe(S)),C},[]),x=v.useCallback((C,S)=>{r.current[C]!==S&&(r.current[C]&&i.current?.unobserve(r.current[C]),r.current[C]=S,i.current?.observe(S),!h&&C===e&&(gu(S,!1),f(!0)))},[i,e,h]),y=v.useCallback((C,S)=>{g.current[C]=S},[]),w=v.useCallback(C=>{r.current[C]&&gu(r.current[C],!0)},[]),k=v.useMemo(()=>e&&s.includes(e)?e:s.length?s[0]:a,[s,a,e]);return v.useEffect(()=>{c&&(e&&r.current[e]?f(C=>(gu(r.current[e],C),!0)):f(!0),setTimeout(()=>b()))},[c,e,b]),v.useEffect(()=>{c&&k&&g.current[k]&&m(C=>(YI(g.current[k],C),!0))},[c,k]),u.jsx(ty.Provider,{value:{updateSection:x,updateNav:y,currentSection:k,updateNavigatedSection:p,scrollToSection:w},children:t})},ZI=t=>{const{updateSection:e}=yc(),n=v.useRef(null);return v.useEffect(()=>{t&&n.current&&e(t,n.current)},[t,e]),{ref:n}},QI=t=>{const{updateNav:e}=yc(),n=v.useRef(null);return v.useEffect(()=>{t&&n.current&&(Array.isArray(t)?t:[t]).forEach(i=>{e(i,n.current)})},[t,e]),{ref:n,props:{"data-setting-nav-item":!0}}},Yo="IntegrationsResponseType",s9=Yo,eP=Xd({dataType:Yo,path:"/integrations/",defaultSearchParams:{include:"api_keys,webhooks",limit:"50"}}),o9=Ot({method:"POST",path:()=>"/integrations/",body:t=>({integrations:[t]}),searchParams:()=>({include:"api_keys,webhooks"}),updateQueries:{dataType:Yo,emberUpdateType:"createOrUpdate",update:(t,e)=>e&&{...e,integrations:e.integrations.concat(t.integrations)}}}),a9=Ot({method:"PUT",path:t=>`/integrations/${t.id}/`,body:t=>({integrations:[t]}),searchParams:()=>({include:"api_keys,webhooks"}),updateQueries:{dataType:Yo,emberUpdateType:"createOrUpdate",update:(t,e)=>e&&{...e,integrations:e.integrations.map(n=>t.integrations.find(({id:i})=>i===n.id)||n)}}}),tP=Ot({method:"DELETE",path:t=>`/integrations/${t}/`,updateQueries:{dataType:Yo,emberUpdateType:"delete",update:(t,e,n)=>({...e,integrations:e.integrations.filter(r=>r.id!==n)})}}),nP=""+new URL("Alto-DoS3yH_j.png",import.meta.url).href,rP=""+new URL("Bulletin-BUpcurG5.png",import.meta.url).href,iP=""+new URL("Casper-ASA9Ix4v.png",import.meta.url).href,sP=""+new URL("Dawn-aeEVEPie.png",import.meta.url).href,oP=""+new URL("Digest-DJl0U_FG.png",import.meta.url).href,aP=""+new URL("Dope-D_CgP0p0.png",import.meta.url).href,lP=""+new URL("Ease-B4NuA7sj.png",import.meta.url).href,cP=""+new URL("Edge-BPZxvKka.png",import.meta.url).href,uP=""+new URL("Edition-cIDLjlhj.png",import.meta.url).href,dP=""+new URL("Episode-D7bgV2bY.png",import.meta.url).href,hP=""+new URL("Headline-BFXOunIb.png",import.meta.url).href,fP=""+new URL("Journal-D3UW9T2b.png",import.meta.url).href,mP=""+new URL("London-CSCVHwS0.png",import.meta.url).href,pP=""+new URL("Ruby-DVEXVMTx.png",import.meta.url).href,gP=""+new URL("Solo-c-yPo0gw.png",import.meta.url).href,bP=""+new URL("Source-V-WXZXnS.png",import.meta.url).href,vP=""+new URL("Source-Magazine-Czq1p0a_.png",import.meta.url).href,xP=""+new URL("Source-Newsletter-CwTcfhJ-.png",import.meta.url).href,yP=""+new URL("Taste-U2cRR2yO.png",import.meta.url).href,wP=""+new URL("Wave-DE2aI-FM.png",import.meta.url).href,ry=[{name:"Source",category:"News",previewUrl:"https://source.ghost.io/",ref:"default",image:bP,variants:[{category:"Magazine",previewUrl:"https://source-magazine.ghost.io/",image:vP},{category:"Newsletter",previewUrl:"https://source-newsletter.ghost.io/",image:xP}]},{name:"Casper",category:"Blog",previewUrl:"https://demo.ghost.io/",ref:"TryGhost/Casper",image:iP},{name:"Edition",category:"Newsletter",url:"https://github.com/TryGhost/Edition",previewUrl:"https://edition.ghost.io/",ref:"TryGhost/Edition",image:uP},{name:"Solo",category:"Blog",url:"https://github.com/TryGhost/Solo",previewUrl:"https://solo.ghost.io",ref:"TryGhost/Solo",image:gP},{name:"Taste",category:"Blog",url:"https://github.com/TryGhost/Taste",previewUrl:"https://taste.ghost.io",ref:"TryGhost/Taste",image:yP},{name:"Episode",category:"Podcast",url:"https://github.com/TryGhost/Episode",previewUrl:"https://episode.ghost.io",ref:"TryGhost/Episode",image:dP},{name:"Digest",category:"Newsletter",url:"https://github.com/TryGhost/Digest",previewUrl:"https://digest.ghost.io/",ref:"TryGhost/Digest",image:oP},{name:"Bulletin",category:"Newsletter",url:"https://github.com/TryGhost/Bulletin",previewUrl:"https://bulletin.ghost.io/",ref:"TryGhost/Bulletin",image:rP},{name:"Alto",category:"Blog",url:"https://github.com/TryGhost/Alto",previewUrl:"https://alto.ghost.io",ref:"TryGhost/Alto",image:nP},{name:"Dope",category:"Magazine",url:"https://github.com/TryGhost/Dope",previewUrl:"https://dope.ghost.io",ref:"TryGhost/Dope",image:aP},{name:"Wave",category:"Podcast",url:"https://github.com/TryGhost/Wave",previewUrl:"https://wave.ghost.io",ref:"TryGhost/Wave",image:wP},{name:"Edge",category:"Photography",url:"https://github.com/TryGhost/Edge",previewUrl:"https://edge.ghost.io",ref:"TryGhost/Edge",image:cP},{name:"Dawn",category:"Newsletter",url:"https://github.com/TryGhost/Dawn",previewUrl:"https://dawn.ghost.io/",ref:"TryGhost/Dawn",image:sP},{name:"Ease",category:"Documentation",url:"https://github.com/TryGhost/Ease",previewUrl:"https://ease.ghost.io",ref:"TryGhost/Ease",image:lP},{name:"Headline",category:"News",url:"https://github.com/TryGhost/Headline",previewUrl:"https://headline.ghost.io",ref:"TryGhost/Headline",image:hP},{name:"Ruby",category:"Magazine",url:"https://github.com/TryGhost/Ruby",previewUrl:"https://ruby.ghost.io",ref:"TryGhost/Ruby",image:pP},{name:"London",category:"Photography",url:"https://github.com/TryGhost/London",previewUrl:"https://london.ghost.io",ref:"TryGhost/London",image:mP},{name:"Journal",category:"Newsletter",url:"https://github.com/TryGhost/Journal",previewUrl:"https://journal.ghost.io/",ref:"TryGhost/Journal",image:fP}],gg=""+new URL("orb-black-1-bYPPSSAp.png",import.meta.url).href,kP=""+new URL("orb-black-2-C-rcujeh.png",import.meta.url).href,bg=""+new URL("orb-black-3-DTkwRv_1.png",import.meta.url).href,vg=""+new URL("orb-black-4-BXF3fMuE.png",import.meta.url).href,SP=""+new URL("orb-black-5-94Eda1ek.png",import.meta.url).href,CP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201818.2%202500'%20style='enable-background:new%200%200%201818.2%202500'%20xml:space='preserve'%3e%3ctitle%3egoogle-docs%3c/title%3e%3cpath%20d='M1136.4%200h-966C79.6%200%200%2079.5%200%20170.5v2159.1c0%2090.9%2079.5%20170.5%20170.5%20170.5h1477.3c90.9%200%20170.5-79.5%20170.5-170.5V681.8l-397.7-284.1L1136.4%200z'%20style='fill:%234285f4'/%3e%3cpath%20d='M454.5%201818.2h909.1v-113.6h-909l-.1%20113.6zm0%20227.3h681.8v-113.6H454.5v113.6zm0-795.5v113.6h909.1V1250H454.5zm0%20340.9h909.1v-113.6h-909l-.1%20113.6z'%20style='fill:%23f1f1f1'/%3e%3cpath%20d='M1136.4%200v511.4c0%2090.9%2079.5%20170.4%20170.4%20170.4h511.4L1136.4%200z'%20style='fill:%23a1c2fa'/%3e%3c/svg%3e",AP=""+new URL("mailchimp-DwTEN-tS.svg",import.meta.url).href,MP="data:image/svg+xml,%3csvg%20height='546'%20viewBox='0%200%20569%20546'%20width='569'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3epatreon%3c/title%3e%3cg%20fill='%23FF424D'%3e%3ccircle%20cx='362.59'%20cy='204.59'%20data-fill='1'%20r='204.59'/%3e%3cpath%20data-fill='1'%20d='M0%200h100v545.8H0z'/%3e%3c/g%3e%3c/svg%3e",xg="data:image/svg+xml,%3csvg%20width='152'%20height='179'%20viewBox='0%200%20152%20179'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3epaypal%3c/title%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M136.492%2045.453c2.179-13.894-.015-23.348-7.53-31.911C120.688%204.114%20105.741.075%2086.617.075H31.105a7.943%207.943%200%200%200-7.846%206.705L.144%20153.36a4.765%204.765%200%200%200%204.707%205.507h34.27l-2.365%2015a4.168%204.168%200%200%200%204.118%204.818H69.76a6.948%206.948%200%200%200%206.863-5.865l.283-1.468%205.442-34.507.351-1.907a6.947%206.947%200%200%201%206.862-5.865h4.322c27.984%200%2049.896-11.37%2056.299-44.25%202.675-13.74%201.292-25.208-5.783-33.27-2.14-2.439-4.802-4.455-7.907-6.1'%20fill='%23238EC2'/%3e%3cpath%20d='M136.492%2045.453c2.179-13.894-.015-23.348-7.53-31.911C120.688%204.114%20105.741.075%2086.617.075H31.105a7.943%207.943%200%200%200-7.846%206.705L.144%20153.36a4.765%204.765%200%200%200%204.707%205.507h34.27l8.609-54.588-.267%201.711c.609-3.86%203.909-6.704%207.817-6.704h16.288c31.989%200%2057.037-12.996%2064.356-50.582.217-1.113.402-2.191.568-3.251'%20fill='%2320274F'/%3e%3cpath%20d='M56.978%2045.638a6.945%206.945%200%200%201%206.863-5.866h43.514c5.155%200%209.961.337%2014.356%201.045%201.256.202%202.478.435%203.665.698a53.92%2053.92%200%200%201%203.455.885c.558.162%201.106.333%201.646.512%202.157.717%204.166%201.562%206.015%202.541%202.179-13.894-.015-23.348-7.53-31.911C120.688%204.114%20105.741.075%2086.617.075H31.105a7.943%207.943%200%200%200-7.846%206.705L.144%20153.36a4.765%204.765%200%200%200%204.707%205.507h34.27L56.978%2045.638'%20fill='%23253667'/%3e%3c/g%3e%3c/svg%3e",EP=""+new URL("slackicon-37ETtpm7.png",import.meta.url).href,jP="data:image/svg+xml,%3csvg%20width='86'%20height='89'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3etypeform%3c/title%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M40.28%2087.561c12.464.154%2021.16-3.994%2030.135-12.175%208.975-8.18%2014.306-16.867%2014.741-28.73.436-11.862-3.412-21.43-12.564-30.581C63.441%206.923%2051.64.9%2039.4.899%2027.158.898%2018.967%206.252%2011.385%2016.07c-7.581%209.818-9.237%2022.212-9.894%2033.921-.657%2011.71-1.15%2017.111%206.608%2024.625%207.758%207.514%2019.718%2012.791%2032.182%2012.945z'%20stroke='%23262627'/%3e%3cpath%20d='M29.136%2037.976v-4.885h25.918v4.885H44.679v27.998H39.51V37.976z'%20fill='%23262627'%20fill-rule='nonzero'/%3e%3c/g%3e%3c/svg%3e",NP=""+new URL("zero-bounce-lzY95s9E.png",import.meta.url).href,iy=[{ghostImage:kP,appImage:EP,title:"Share scheduled posts with your team in Slack",url:"https://zapier.com/webintent/create-zap?template=359499"},{ghostImage:bg,appImage:MP,title:"Connect Patreon to your Ghost membership site",url:"https://zapier.com/webintent/create-zap?template=75801"},{ghostImage:vg,appImage:NP,title:"Protect email delivery with email verification",url:"https://zapier.com/webintent/create-zap?template=359415"},{ghostImage:SP,appImage:xg,title:"Add members for successful sales in PayPal",url:"https://zapier.com/webintent/create-zap?template=184423"},{ghostImage:bg,appImage:xg,title:"Unsubscribe members who cancel a subscription in PayPal",url:"https://zapier.com/webintent/create-zap?template=359348"},{ghostImage:gg,appImage:CP,title:"Send new post drafts from Google Docs to Ghost",url:"https://zapier.com/webintent/create-zap?template=50924"},{ghostImage:vg,appImage:jP,title:"Survey new members using Typeform",url:"https://zapier.com/webintent/create-zap?template=359407"},{ghostImage:gg,appImage:AP,title:"Sync email subscribers in Ghost + Mailchimp",url:"https://zapier.com/webintent/create-zap?template=359342"}],sy=v.createContext({officialThemes:ry,zapierTemplates:iy,search:{filter:"",setFilter:()=>{},checkVisible:()=>!0,highlightKeywords:()=>"",noResult:!1,setNoResult:()=>{},registerComponent:()=>{},unregisterComponent:()=>{},getVisibleComponents:()=>new Set,isOnlyVisibleComponent:()=>!1},sortingState:[],offersShowArchived:!1,setOffersShowArchived:()=>{}}),TP=({children:t,...e})=>{const n=UI(),[r,i]=v.useState([{type:"offers",option:"date-added",direction:"desc"}]),[s,o]=v.useState(!1);return u.jsx(sy.Provider,{value:{officialThemes:ry,zapierTemplates:iy,...e,search:n,sortingState:r,setSortingState:i,offersShowArchived:s,setOffersShowArchived:o},children:u.jsx(BI,{children:u.jsx(JI,{children:t})})})},Xo=()=>v.useContext(sy),l9=()=>Xo().officialThemes,Jo=()=>Xo().search,c9=()=>Xo().upgradeStatus,u9=()=>{const{sortingState:t,setSortingState:e}=Xo();return{sortingState:t,setSortingState:e}},d9=()=>{const{offersShowArchived:t,setOffersShowArchived:e}=Xo();return{offersShowArchived:t,setOffersShowArchived:e}},Se=({keywords:t,navid:e,children:n,...r})=>{const{checkVisible:i,noResult:s,registerComponent:o,unregisterComponent:a}=Jo(),{route:l}=fe(),[c,d]=v.useState(!1),{ref:h}=ZI(e),f=v.useId(),m=HI(e||"component",f);v.useEffect(()=>(o(m,t),()=>{a(m)}),[m,t,o,a]),v.useEffect(()=>{if(d(l===e),l===e){const b=setTimeout(()=>d(!1),2e3);return()=>clearTimeout(b)}},[l,e]);const g=W.Children.toArray(n).some(b=>W.isValidElement(b)&&b.type==="img")?u.jsx("div",{className:"-mx-5 -mb-5 overflow-hidden rounded-b-xl bg-grey-50 md:-mx-7 md:-mb-7",children:W.Children.map(n,b=>W.isValidElement(b)&&b.type==="img"?W.cloneElement(b,{className:`${b.props.className||""} h-full w-full rounded-b-xl`.trim()}):b)}):n;return u.jsx(eE,{ref:h,highlight:c,isVisible:i(t)||s,navid:e,...r,children:g})},DP=({keywords:t})=>u.jsx(Se,{customHeader:u.jsxs("div",{className:"z-10 flex items-start justify-between",children:[u.jsx(ni,{description:"Add custom code to your publication.",title:"Code injection"}),u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Open",size:"sm",onClick:()=>{pe.show($I)}})]}),description:"Add custom code to your publication",keywords:t,navid:"code-injection",testId:"code-injection",title:"Code injection"}),OP=Ce(DP,"Code injection"),hf="InvitesResponseType",IP=Jd({dataType:hf,path:"/invites/",permissions:["Owner","Administrator"],defaultSearchParams:{limit:"100",include:"roles"},defaultNextPageParams:(t,e)=>({...e,page:(t.meta?.pagination.next||1).toString()}),returnData:t=>{const{pages:e}=t,n=e.flatMap(i=>i.invites),r=e[e.length-1].meta;return{invites:n,meta:r,isEnd:r?r.pagination.pages===r.pagination.page:!0}}}),PP=Ot({method:"POST",path:()=>"/invites/",body:({email:t,roleId:e})=>({invites:[{email:t,role_id:e,expires:null,status:null,token:null}]}),updateQueries:{dataType:hf,emberUpdateType:"createOrUpdate",update:xw("invites")}}),RP=Ot({path:t=>`/invites/${t}/`,method:"DELETE",updateQueries:{dataType:hf,emberUpdateType:"delete",update:yw("invites")}}),LP="RolesResponseType",_P=Xd({dataType:LP,path:"/roles/",defaultSearchParams:{limit:"100"}});function Ka(t,e){return t.filter(n=>n.roles.find(r=>r.name===e))}function FP(t,e){return t.filter(n=>n.roles.find(r=>e.includes(r.name)))}function BP(t){return Ka(t,"Owner")[0]}const ff=()=>{const{currentUser:t}=ke(),{data:{users:e,meta:n,isEnd:r}={users:[]},isLoading:i,fetchNextPage:s}=ww(),{data:{invites:o,meta:a,isEnd:l}={invites:[]},isLoading:c,fetchNextPage:d}=IP(),{data:{roles:h}={},isLoading:f}=_P(),m=v.useMemo(()=>BP(e),[e]),p=v.useMemo(()=>Ka(e,"Administrator"),[e]),g=v.useMemo(()=>FP(e,["Editor","Super Editor"]),[e]),b=v.useMemo(()=>Ka(e,"Author"),[e]),x=v.useMemo(()=>Ka(e,"Contributor"),[e]),y=v.useMemo(()=>o.map(w=>{const k=h?.find(C=>w.role_id===C.id);return{...w,role:k?.name}}),[o,h]);return{totalUsers:n?.pagination.total||0,totalInvites:a?.pagination.total||0,users:e,ownerUser:m,adminUsers:p,editorUsers:g,authorUsers:b,contributorUsers:x,currentUser:t,invites:y,isLoading:i||c||f,hasNextPage:r===!1,invitesHasNextPage:l===!1,fetchNextPage:s,fetchNextInvitePage:d}},VP=Ot({method:"POST",path:()=>"/db/",body:t=>{const e=new FormData;return e.append("importfile",t),e}}),zP=Ot({method:"DELETE",path:()=>"/db/"}),$P=()=>Zd("/db/"),HP=Ot({method:"POST",path:()=>"/authentication/reset/"}),UP=({keywords:t})=>{const{mutateAsync:e}=zP(),{mutateAsync:n}=HP(),r=Bl(),i=Ye(),{config:s}=ke(),{totalUsers:o}=ff(),a=!!s?.labs?.dangerZoneResetAuth,l=o===1?"You will be signed out and must reset your password before signing back in.":o>1?`All ${o} staff users, including you, will be signed out and must reset their password before signing back in.`:"All staff users, including you, will be signed out and must reset their password before signing back in.",c=()=>{pe.show(Wt,{title:"Would you really like to delete all content from your blog?",prompt:"This is permanent! No backups, no restores, no magic undo button. We warned you, k?",okColor:"red",okLabel:"Delete",onOk:async h=>{try{await e(null),rn({title:"All content deleted from database.",type:"success"}),h?.remove(),await r.refetchQueries()}catch(f){i(f)}}})},d=()=>{pe.show(Wt,{title:"Reset all authentication?",prompt:u.jsxs(u.Fragment,{children:[u.jsxs("p",{className:"mb-4",children:["This rotates every API key on your site. Any integration using one will stop working until you reconfigure it with the new key from ",u.jsx("strong",{children:"Settings → Advanced → Integrations"}),"."]}),u.jsxs("p",{children:[l," Your members aren't affected."]})]}),okLabel:"Reset all authentication",okRunningLabel:"Resetting...",okColor:"red",onOk:async h=>{try{const m=(await n(null))?.security_action?.[0],p=m?.api_keys_rotated??0,g=m?.users_locked??0;rn({title:`Rotated ${p} API ${p===1?"key":"keys"} and locked ${g} ${g===1?"user":"users"}. You will be signed out shortly.`,type:"success"}),h?.remove(),window.location.href=Ys().adminRoot}catch(f){i(f)}}})};return u.jsx(Se,{customHeader:u.jsx(ni,{description:"Destructive actions that affect your entire site.",title:"Danger zone"}),keywords:t,navid:"dangerzone",testId:"dangerzone",children:u.jsxs("div",{className:"flex flex-col",children:[u.jsx(Wi,{action:u.jsx(J,{"aria-label":"Delete all content",color:"red",label:"Delete",onClick:c}),bgOnHover:!1,detail:"Permanently delete all posts and tags from the database.",testId:"delete-all-content",title:"Delete all content"}),a&&u.jsx(Wi,{action:u.jsx(J,{"aria-label":"Reset all authentication",color:"red",label:"Reset",onClick:d}),bgOnHover:!1,detail:"Rotate every API key, sign out every staff user, and require a password reset. Use after a suspected credential compromise.",testId:"reset-all-authentication",title:"Reset all authentication"})]})})},WP=Ce(UP,"Danger zone"),KP=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("history/view")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"View history",size:"sm",onClick:n}),description:"View system event log",keywords:t,navid:"history",testId:"history",title:"History"})},GP=Ce(KP,"History"),qP=""+new URL("integrations-settings-Ba5Zx8yQ.png",import.meta.url).href;function oy(){const{config:t,settings:e}=ke(),[n]=we(e,["pintura"]),[r,i]=v.useState(!1),[s,o]=v.useState(!1),[a,l]=v.useState(!1),c=v.useRef(!1),[d]=we(e,["pintura_js_url"]),[h]=we(e,["pintura_css_url"]),f=n&&r&&s||!1,m=t?.pintura;v.useEffect(()=>{let b=m?.js?m?.js:d||null;if(b){if(b.startsWith("/")){const{adminRoot:x}=Ys();b=window.location.origin+x.replace(/\/$/,"")+b}if(window.pintura){i(!0);return}try{const x=new URL(b);import(`${x.protocol}//${x.host}${x.pathname}`).then(()=>{i(!0)}).catch(k=>{Ls(k)})}catch(x){Ls(x)}}},[d,m?.js]),v.useEffect(()=>{let b=m?.css?m?.css:h||null;if(b){if(b.startsWith("/")){const{adminRoot:x}=Ys();b=window.location.origin+x.replace(/\/$/,"")+b}try{if(document.querySelector(`link[href="${b}"]`))o(!0);else{const y=document.createElement("link");y.rel="stylesheet",y.type="text/css",y.href=b,y.onload=()=>{o(!0)},document.head.appendChild(y)}}catch(x){Ls(x)}}},[h,m?.css]);const p=v.useCallback(({image:g,handleSave:b})=>{if(g&&f){const x=new URL(g);x.searchParams.has("v")||x.searchParams.set("v",Date.now().toString());const y=x.href,w=window.pintura.openDefaultEditor({src:y,enableTransparencyGrid:!0,util:"crop",utils:["crop","filter","finetune","redact","annotate","trim","frame","resize"],frameOptions:[[void 0,k=>k.labelNone],["solidSharp",k=>k.frameLabelMatSharp],["solidRound",k=>k.frameLabelMatRound],["lineSingle",k=>k.frameLabelLineSingle],["hook",k=>k.frameLabelCornerHooks],["polaroid",k=>k.frameLabelPolaroid]],cropSelectPresetFilter:"landscape",cropSelectPresetOptions:[[void 0,"Custom"],[1,"Square"],[2/1,"2:1"],[3/2,"3:2"],[4/3,"4:3"],[16/10,"16:10"],[16/9,"16:9"],[1/2,"1:2"],[2/3,"2:3"],[3/4,"3:4"],[10/16,"10:16"],[9/16,"9:16"]],locale:{labelButtonExport:"Save and close"},previewPad:!0,willClose:()=>c.current?(l(!1),!0):!1});w.on("loaderror",()=>{kw("Pintura editor failed to load")}),w.on("process",k=>{b(k.dest)}),l(!0)}},[f]);return v.useEffect(()=>{const g=x=>{x.key==="Escape"&&x.stopPropagation()};if(!a)return;const b=x=>{x.target instanceof Element&&x.target.closest('.PinturaModal button[title="Close"]')&&(c.current=!0)};return window.addEventListener("click",b,{capture:!0}),window.addEventListener("keydown",g,{capture:!0}),()=>{window.removeEventListener("click",b,{capture:!0}),window.removeEventListener("keydown",g,{capture:!0})}},[a]),{isEnabled:f,openEditor:p}}const ay=({icon:t,title:e,detail:n,action:r,onDelete:i,active:s,disabled:o,testId:a,custom:l=!1})=>{const{updateRoute:c}=fe(),d=m=>{m?.stopPropagation(),o?c({route:"pro",isExternal:!0}):r()},h=m=>{m?.stopPropagation(),i?.()},f=l?u.jsx(J,{color:"red",label:"Delete",link:!0,onClick:h}):o?u.jsx(J,{icon:"lock-locked",label:"Upgrade",link:!0,onClick:d}):u.jsx(J,{color:"green",label:"Configure",link:!0,onClick:d});return u.jsx(Wi,{action:f,avatar:t,className:o?"opacity-50 saturate-0":"",detail:n,hideActions:!o,testId:a,title:s?u.jsxs("span",{className:"inline-flex items-center gap-1",children:[e," ",u.jsx("span",{className:"inline-flex items-center rounded-full bg-[rgba(48,207,67,0.15)] px-1.5 py-px text-xs font-semibold tracking-wide text-green uppercase",children:"Active"})]}):e,onClick:d})},YP=()=>{const{config:t}=ke(),{updateRoute:e}=fe(),n=m=>{e(m)},r=t.hostSettings?.limits?.customIntegrations?.disabled,i=oy(),{settings:s}=ke(),[o,a,l,c,d]=we(s,["unsplash","firstpromoter","slack_url","slack_username","transistor"]),h=[{detail:"Automation for your apps",disabled:r,icon:u.jsx(me,{name:"zapier",size:32}),modal:"integrations/zapier",testId:"zapier-integration",title:"Zapier"},{active:!!(l&&c),detail:"A messaging app for teams",icon:u.jsx(me,{name:"slack",size:32}),modal:"integrations/slack",testId:"slack-integration",title:"Slack"},{active:!!o,detail:"Beautiful, free photos",icon:u.jsx(me,{name:"unsplash",size:32}),modal:"integrations/unsplash",testId:"unsplash-integration",title:"Unsplash"},{active:!!a,detail:"Launch your member referral program",icon:u.jsx(me,{name:"firstpromoter",size:32}),modal:"integrations/firstpromoter",testId:"firstpromoter-integration",title:"FirstPromoter"},{active:i.isEnabled,detail:"Advanced image editing",icon:u.jsx(me,{name:"pintura",size:32}),modal:"integrations/pintura",testId:"pintura-integration",title:"Pintura"},{active:!!d,detail:"Give your members access to private podcasts",disabled:r,icon:u.jsx(me,{name:"transistor",size:32}),modal:"integrations/transistor",testId:"transistor-integration",title:"Transistor.fm"},{detail:"Access your content programmatically",icon:u.jsx(me,{name:"angle-brackets",size:32}),modal:"integrations/contentapi",testId:"content-api-integration",title:"Content API"}],f=[...h.filter(m=>!m.disabled),...h.filter(m=>m.disabled)];return u.jsx(is,{titleSeparator:!1,children:f.map(m=>u.jsx(ay,{action:()=>{n(m.modal)},active:m.active,detail:m.detail,disabled:m.disabled,icon:m.icon,testId:m.testId,title:m.title},m.testId))})},XP=({integrations:t})=>{const{updateRoute:e}=fe(),{mutateAsync:n}=tP(),r=Ye();return t.length?u.jsx(is,{borderTop:!1,children:t.map(i=>u.jsx(ay,{action:()=>e({route:`integrations/${i.id}`}),detail:u.jsx("div",{className:"line-clamp-2 break-words",children:u.jsx("span",{title:`${i.name}: ${i.description||"No description"}`,children:i.description||"No description"})}),icon:i.icon_image?u.jsx("img",{className:"size-8 shrink-0 object-cover",role:"presentation",src:i.icon_image}):u.jsx(me,{className:"w-8 shrink-0",name:"integration"}),title:i.name,custom:!0,onDelete:()=>{pe.show(Wt,{title:"Are you sure?",prompt:"Deleting this integration will remove all webhooks and api keys associated with it.",okColor:"red",okLabel:"Delete Integration",onOk:async s=>{try{await n(i.id),s?.remove(),rn({title:"Integration deleted",type:"info",options:{position:"bottom-left"}})}catch(o){r(o)}}})}},i.id))}):u.jsx(li,{icon:"integration",children:"No custom integration."})},JP=({keywords:t})=>{const[e,n]=v.useState("built-in"),{data:{integrations:r}={integrations:[]}}=eP(),{updateRoute:i}=fe(),s=[{id:"built-in",title:"Built-in",contents:u.jsx(YP,{})},{id:"custom",title:"Custom",contents:u.jsx(XP,{integrations:r.filter(a=>a.type==="custom")})}],o=u.jsx(J,{className:"mt-[-5px] inline-flex h-7 cursor-pointer items-center justify-center rounded px-3 font-semibold whitespace-nowrap text-grey-900 transition hover:bg-grey-200 dark:text-white dark:hover:bg-grey-900 [&:hover]:text-black",color:"clear",label:"Add custom integration",link:!0,onClick:()=>{i("integrations/new"),n("custom")}});return u.jsx(Se,{customButtons:o,customHeader:u.jsxs("div",{className:"sm:-mt-5 md:-mt-7",children:[u.jsx("div",{className:"-mx-5 overflow-hidden rounded-t-xl border-b border-grey-200 md:-mx-7 dark:border-grey-800",children:u.jsx("img",{className:"size-full",src:qP})}),u.jsxs("div",{className:" z-10 mt-6 flex items-start justify-between",children:[u.jsx(ni,{description:"Make Ghost work with apps and tools.",title:"Integrations"}),u.jsx(J,{className:"mt-[-5px] inline-flex h-7 cursor-pointer items-center justify-center rounded px-3 font-semibold whitespace-nowrap text-grey-900 transition hover:bg-grey-200 dark:text-white dark:hover:bg-grey-900 [&:hover]:text-black",color:"clear",label:"Add custom integration",link:!0,onClick:()=>{i("integrations/new"),n("custom")}})]})]}),keywords:t,navid:"integrations",testId:"integrations",children:u.jsx(hr,{selectedTab:e,tabs:s,onTabChange:n})})},ZP=Ce(JP,"Integrations");function QP(t,e={}){window.plausible=window.plausible||function(){(window.plausible.q=window.plausible.q||[]).push(arguments)},window.plausible(t,{props:e})}const eR=pe.create(({title:t,prompt:e,okLabel:n,okRunningLabel:r="Enabling...",onConfirm:i})=>{const s=an(),[o,a]=W.useState(!1),l=()=>{s.remove()},c=async()=>{a(!0);try{await i()&&s.remove()}finally{a(!1)}};return u.jsx(Fr,{backDropClick:!1,buttonsDisabled:o,cancelLabel:"Cancel",okLabel:o?r:n,testId:"feature-toggle-confirmation-modal",title:t,width:540,onCancel:l,onOk:c,children:u.jsx("div",{className:"py-4",children:e})})}),Rs=({label:t,flag:e,disabled:n,confirmation:r})=>{const{settings:i}=ke(),s=JSON.parse(Xs(i,"labs")||"{}"),{mutateAsync:o}=ai(),a=Bl(),l=Ye(),c=!!s[e],d=async h=>{try{return await o([{key:"labs",value:JSON.stringify({...s,[e]:h})}]),QP("Feature Toggled",{state:h?"on":"off",feature:e}),a.setQueriesData([Sw],f=>({config:{...f.config,labs:{...f.config.labs,[e]:h}}})),!0}catch(f){return l(f),!1}};return u.jsx(en,{checked:c,disabled:n,label:t,labelClasses:"sr-only",name:`feature-${e}`,onChange:async()=>{const h=!c;if(r&&h){pe.show(eR,{...r,onConfirm:()=>d(h)});return}await d(h)}})},Wr=({title:t,detail:e,action:n})=>u.jsx(Wi,{action:n,bgOnHover:!1,detail:e,paddingRight:!1,title:t}),tR=Ot({method:"POST",path:()=>"/redirects/upload/",body:t=>{const e=new FormData;return e.append("redirects",t),e}}),nR=()=>Zd("/redirects/download/"),rR=Ot({method:"POST",path:()=>"/settings/routes/yaml/",body:t=>{const e=new FormData;return e.append("routes",t),e}}),iR=()=>Zd("/settings/routes/yaml/"),sR=()=>{const{settings:t}=ke(),{mutateAsync:e}=tR(),{mutateAsync:n}=rR(),r=Ye(),[i,s]=v.useState(!1),[o,a]=v.useState(!1),c=!!JSON.parse(Xs(t,"labs")||"{}").automations;return u.jsxs(is,{titleSeparator:!1,children:[u.jsx(Wr,{action:u.jsx(Rs,{confirmation:{title:"Automations (beta)",prompt:"This is a one-way street. Once enabled, the automations beta can't be turned off. Existing welcome emails will move into your automations automatically.",okLabel:"Enable",okRunningLabel:"Enabling..."},disabled:c,flag:"automations",label:"Automations (beta)"}),detail:u.jsxs(u.Fragment,{children:["Build automated email flows for your members, and get early access to new automation features as they ship. ",u.jsx("a",{className:"text-green",href:"https://ghost.org/help/automations-beta",rel:"noopener noreferrer",target:"_blank",children:"Learn more →"})]}),title:"Automations (beta)"}),u.jsx(Wr,{action:u.jsx(Rs,{flag:"superEditors"}),detail:u.jsx(u.Fragment,{children:"Allows newly-assigned editors to manage members and comments in addition to regular roles."}),title:"Enhanced Editor role (beta)"}),u.jsx(Wr,{action:u.jsx(Rs,{flag:"editorExcerpt"}),detail:u.jsx(u.Fragment,{children:"Adds the excerpt input below the post title in the editor"}),title:"Show post excerpt inline"}),u.jsx(Wr,{action:u.jsx(Rs,{flag:"additionalPaymentMethods"}),detail:u.jsxs(u.Fragment,{children:["Enable support for CashApp, iDEAL, Bancontact, and others. ",u.jsx("a",{className:"text-green",href:"https://ghost.org/help/payment-methods",rel:"noopener noreferrer",target:"_blank",children:"Learn more →"})]}),title:"Additional payment methods"}),u.jsx(Wr,{action:u.jsxs("div",{className:"flex flex-col items-end gap-1",children:[u.jsx(Ya,{id:"upload-redirects",onUpload:async d=>{try{s(!0),await e(d),rn({title:"Redirects uploaded",type:"success"})}catch(h){r(h)}finally{s(!1)}},children:u.jsx(J,{color:"grey",label:i?"Uploading ...":"Upload redirects file",size:"sm",tag:"div"})}),u.jsx(J,{color:"green",label:"Download current redirects",link:!0,onClick:()=>nR()})]}),detail:u.jsxs(u.Fragment,{children:["Configure redirects for old or moved content, ",u.jsx("br",{})," more info in the ",u.jsx("a",{className:"text-green",href:"https://ghost.org/tutorials/implementing-redirects/",rel:"noopener noreferrer",target:"_blank",children:"docs"})]}),title:"Redirects"}),u.jsx(Wr,{action:u.jsxs("div",{className:"flex flex-col items-end gap-1",children:[u.jsx(Ya,{id:"upload-routes",onUpload:async d=>{try{a(!0),await n(d),rn({type:"success",title:"Routes uploaded"})}catch(h){r(h)}finally{a(!1)}},children:u.jsx(J,{color:"grey",label:o?"Uploading ...":"Upload routes file",size:"sm",tag:"div"})}),u.jsx(J,{color:"green",label:"Download current routes",link:!0,onClick:()=>iR()})]}),detail:"Configure dynamic routing by modifying the routes.yaml file",title:"Routes"})]})},oR="data:image/svg+xml,%3csvg%20width='267'%20height='285'%20viewBox='0%200%20267%20285'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='165'%20cy='183'%20r='102'%20fill='%23F1F3F4'/%3e%3ccircle%20cx='68'%20cy='71'%20r='31'%20fill='%23F1F3F4'/%3e%3ccircle%20cx='99'%20cy='17'%20r='17'%20fill='%23F1F3F4'/%3e%3ccircle%20cx='118'%20cy='70'%20r='7'%20fill='%23F1F3F4'/%3e%3ccircle%20cx='45'%20cy='32'%20r='3'%20fill='%23F1F3F4'/%3e%3ccircle%20cx='12.5'%20cy='83.5'%20r='12.5'%20fill='%23F1F3F4'/%3e%3c/svg%3e",aR=Co(()=>import("./index-fbxc8Dpt.js").then(t=>t.i),__vite__mapDeps([23,1,2,24]),import.meta.url);class ly extends Error{errorType;errorDetails;constructor({errorType:e,errorDetails:n,message:r}){super(r),this.errorType=e,this.errorDetails=n}}class lR extends ly{constructor(e){super(Object.assign({errorType:"IncorrectUsageError"},e))}}class Zo extends ly{constructor(e){super(Object.assign({errorType:"HostLimitError"},e))}}const fs=()=>{const{config:t}=ke(),[e,n]=v.useState(null);v.useEffect(()=>{aR.then(d=>n(()=>d.default))},[]);const{users:r,contributorUsers:i,invites:s,isLoading:o}=ff(),{refetch:a}=Wg({searchParams:{limit:"1"},enabled:!1}),{refetch:l}=$l({searchParams:{filter:"status:active",limit:"1"},enabled:!1}),c=v.useMemo(()=>t.hostSettings?.billing?.enabled===!0&&t.hostSettings?.billing?.url?t.hostSettings.billing.url:"https://ghost.org/help/",[t.hostSettings?.billing]);return v.useMemo(()=>{const d={isLimited:()=>!1,isDisabled:()=>!1,checkWouldGoOverLimit:()=>Promise.resolve(!1),errorIfWouldGoOverLimit:()=>Promise.resolve(),errorIfIsOverLimit:()=>Promise.resolve()};if(!e||!t.hostSettings?.limits||o)return d;const h={...t.hostSettings.limits},f=new e;return h.staff&&(h.staff.currentCountQuery=async()=>{const m=r.filter(g=>g.status!=="inactive"&&!i.includes(g)),p=s.filter(g=>g.role!=="Contributor");return m.length+p.length}),h.members&&(h.members.currentCountQuery=async()=>{const{data:m}=await a();return m?.meta?.pagination?.total||0}),h.newsletters&&(h.newsletters.currentCountQuery=async()=>{const{data:{pages:m}={pages:[]}}=await l();return m[0].meta?.pagination.total||0}),f.loadLimits({limits:h,helpLink:c,errors:{HostLimitError:Zo,IncorrectUsageError:lR}}),{isLimited:m=>f.isLimited(m),isDisabled:m=>f.isDisabled(m),checkWouldGoOverLimit:m=>f.checkWouldGoOverLimit(m),errorIfWouldGoOverLimit:(m,p={})=>f.errorIfWouldGoOverLimit(m,p),errorIfIsOverLimit:m=>f.errorIfIsOverLimit(m)}},[e,t,i,a,l,c,s,o,r])},cR=[{title:"Automations",description:"Toggle the automations beta. Unexpected problems can occur if you turn this off after previously turning it on.",flag:"automations"},{title:"Stripe Automatic Tax (private beta)",description:"Use Stripe Automatic Tax at Stripe Checkout. Needs to be enabled in Stripe",flag:"stripeAutomaticTax"},{title:"Email customization (internal beta)",description:"Newsletter customization settings that have been released to Ghost's own production sites",flag:"emailCustomization"},{title:"Import Member Tier",description:"Enables tier to be specified when importing members",flag:"importMemberTier"},{title:"CSV Content Importer",description:"Enables importing posts from CSV files in the Universal Importer",flag:"csvContentImporter"},{title:"Admin UI Refresh",description:"Enable Admin UI refresh (exploration)",flag:"adminUIRefresh"},{title:"Explore",description:"Enables keeping in touch with the new Explore API",flag:"explore"},{title:"Tags X",description:"Enables the new Tags UI",flag:"tagsX"},{title:"Email Unique ID",description:"Enables {uniqueid} variable in emails for unique image URLs to bypass ESP image caching",flag:"emailUniqueid"},{title:"Updated theme translation (beta)",description:"Enable theme translation using i18next instead of the old translation package.",flag:"themeTranslation"},{title:"Featurebase Feedback",description:"Display a Feedback menu item in the admin sidebar. Requires the new admin experience.",flag:"featurebaseFeedback"},{title:"Picture Element",description:"Use the HTML picture element to serve modern image formats (AVIF, WebP) with automatic fallbacks",flag:"pictureImageFormats"},{title:"Smarter Counts",description:"Use optimized COUNT queries for API pagination when safe",flag:"smarterCounts"},{title:"LLMs.txt",description:"Serve llms.txt, per-entry markdown exports, and Accept: text/markdown content negotiation for AI and LLM tooling",flag:"llmsTxt"},{title:"Get helper deduplication",description:"Deduplicate identical {{#get}} helper queries within a single request to avoid redundant database calls",flag:"getHelperDeduplication"},{title:"Gift links",description:"Tokenized links that let anyone read a single gated post or page in full, no account required",flag:"giftLinks"}],uR=()=>{const t=fs(),[e,n]=v.useState([]);return v.useEffect(()=>{(async()=>{const i=[];for(const s of cR)if(s.limitName&&t?.isLimited(s.limitName))try{await t.errorIfWouldGoOverLimit(s.limitName),i.push(s)}catch(o){o instanceof Zo||i.push(s)}else i.push(s);n(i)})()},[t]),u.jsx(is,{titleSeparator:!1,children:e.map(r=>u.jsx(Wr,{action:u.jsx(Rs,{flag:r.flag,label:r.title}),detail:r.description,title:r.title},r.flag))})};function dR(t){const[e,n]=v.useState(!1),r=v.useRef(!1),{filter:i,getVisibleComponents:s,checkVisible:o}=Jo();return v.useEffect(()=>{i||(r.current=!1)},[i]),v.useEffect(()=>{if(r.current)return;const c=o(t),d=s(),h=!!i&&c&&d.size===1;n(h)},[i,t,o,s]),{isOpen:e,openManually:()=>{r.current=!0,n(!0)},closeManually:()=>{r.current=!0,n(!1)}}}const hR=({keywords:t})=>{const[e,n]=v.useState("labs-beta-features"),{config:r}=ke(),{isOpen:i,openManually:s,closeManually:o}=dR(t),a=[{id:"labs-beta-features",title:"Beta features",contents:u.jsx(sR,{})},r.enableDeveloperExperiments&&{id:"labs-private-features",title:"Private features",contents:u.jsx(uR,{})}].filter(Boolean);return u.jsx(Se,{customHeader:u.jsxs("div",{className:"z-10 flex items-start justify-between",children:[u.jsx(ni,{description:"This is a testing ground for new or experimental features. They may change, break or inexplicably disappear at any time.",title:"Labs"}),u.jsx(J,{className:"mt-[-5px]",color:i?"grey":"clear",label:i?"Close":"Open",size:"sm",onClick:i?o:s})]}),isEditing:i,keywords:t,navid:"labs",testId:"labs",children:i?u.jsx(hr,{selectedTab:e,tabs:a,onTabChange:n}):u.jsx("div",{className:"absolute inset-0 z-0 overflow-hidden opacity-70",children:u.jsx("img",{className:"absolute -top-6 -right-6 dark:opacity-10",src:oR})})})},fR=Ce(hR,"Labs"),mR=()=>{const[t,e]=W.useState(!1),n=Ye(),r=async()=>{if(!t){e(!0);try{await Cw("/posts/export/?limit=1000","posts.analytics.csv")}catch(i){n(i)}finally{e(!1)}}};return u.jsxs("div",{className:"grid grid-cols-1 gap-4 pt-4 md:grid-cols-2 lg:grid-cols-3",children:[u.jsx(J,{className:"h-9! font-semibold!",color:"grey",icon:"export",iconColorClass:"h-4! w-auto!",label:"Content & settings",onClick:()=>$P()}),u.jsx(J,{className:"h-9! font-semibold!",color:"grey",disabled:t,icon:"baseline-chart",iconColorClass:"h-4! w-auto!",label:"Post analytics",loading:t,testId:"post-analytics-export-button",onClick:r})]})},pR=()=>{const t=an(),{mutateAsync:e}=VP(),[n,r]=v.useState(!1),i=Ye();return u.jsx(Fr,{backDropClick:!1,footer:u.jsxs("div",{className:"flex w-full items-center justify-between p-8",children:[u.jsx(no,{href:"https://docs.ghost.org/migration/ghost",target:"_blank",children:"Learn about importing"}),u.jsx(J,{color:"outline",disabled:n,label:"Cancel",onClick:()=>t.remove()})]}),okLabel:"",size:"sm",testId:"universal-import-modal",title:"Universal import",children:u.jsx("div",{className:"py-4",children:u.jsx(Ya,{accept:"application/json, application/zip",id:"import-file",onUpload:async s=>{r(!0);try{await e(s),t.remove(),pe.show(Wt,{title:"Import in progress",prompt:"Your import is being processed, and you'll receive a confirmation email as soon as it’s complete. Usually this only takes a few minutes, but larger imports may take longer.",cancelLabel:"",okLabel:"Got it",onOk:o=>o?.remove(),formSheet:!1})}catch(o){i(o)}finally{r(!1)}},children:u.jsx("div",{className:"-mb-4 cursor-pointer bg-grey-50 p-10 text-center dark:bg-grey-950",children:n?"Uploading...":u.jsxs(u.Fragment,{children:["Select any JSON or zip file that contains ",u.jsx("br",{}),"posts and settings"]})})})})})},gR=pe.create(pR),$r=({icon:t,title:e,onClick:n})=>{const r=R("flex h-9 cursor-pointer items-center justify-center gap-2 rounded-md bg-grey-100 px-2 font-semibold transition-all hover:bg-grey-200 dark:bg-grey-900");return n?u.jsxs("button",{className:r,type:"button",onClick:n,children:[t,e]}):u.jsx(u.Fragment,{})},bR=()=>{const{updateRoute:t}=fe(),e=()=>{pe.show(gR)};return u.jsxs("div",{className:"grid grid-cols-1 gap-4 pt-4 md:grid-cols-2 lg:grid-cols-3",children:[u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"substack",size:18}),title:"Substack",onClick:()=>t({isExternal:!0,route:"/migrate/substack"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"beehiiv",size:18}),title:"beehiiv",onClick:()=>t({isExternal:!0,route:"/migrate/beehiiv"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"wordpress",size:18}),title:"WordPress",onClick:()=>t({isExternal:!0,route:"/migrate/wordpress"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"squarespace",size:18}),title:"Squarespace",onClick:()=>t({isExternal:!0,route:"/migrate/squarespace"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto dark:invert",name:"medium",size:18}),title:"Medium",onClick:()=>t({isExternal:!0,route:"/migrate/medium"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"mailchimp",size:20}),title:"Mailchimp",onClick:()=>t({isExternal:!0,route:"/migrate/mailchimp"})}),u.jsx($r,{icon:u.jsx(me,{className:"w-auto",name:"import",size:16}),title:"Universal import",onClick:e})]})},vR=({keywords:t})=>{const[e,n]=v.useState("import"),r=[{id:"import",title:"Import",contents:u.jsx(bR,{})},{id:"export",title:"Export",contents:u.jsx(mR,{})}].filter(Boolean);return u.jsx(Se,{customHeader:u.jsx(ni,{description:"Import content, members and subscriptions from other platforms or export your Ghost data.",title:"Migration tools"}),keywords:t,navid:"migration",testId:"migrationtools",children:u.jsx(hr,{selectedTab:e,tabs:r,onTabChange:n})})},xR=Ce(vR,"Migration tools"),ui=({keywords:t,...e})=>{const{checkVisible:n,noResult:r}=Jo();return u.jsx(oE,{isVisible:n(t)||r,...e})},Pt={integrations:["advanced","integrations","zapier","slack","unsplash","first promoter","firstpromoter","pintura","disqus","analytics","ulysses","typeform","buffer","plausible","github","webhooks"],migrationtools:["import","export","migrate","substack","substack","migration","medium","wordpress","wp","squarespace","beehiiv"],codeInjection:["advanced","code injection","head","footer"],labs:["advanced","labs","alpha","private","beta","flag","routes","redirect","translation","editor","portal"],history:["advanced","history","log","events","user events","staff","audit","action"],dangerzone:["danger zone","delete all content","delete site","reset all authentication","reset api keys","reset password","compromised credentials","lock staff users","sign out all staff"]},yR=()=>u.jsxs(ui,{keywords:Object.values(Pt).flat(),title:"Advanced",children:[u.jsx(ZP,{keywords:Pt.integrations}),u.jsx(xR,{keywords:Pt.migrationtools}),u.jsx(OP,{keywords:Pt.codeInjection}),u.jsx(fR,{keywords:Pt.labs}),u.jsx(GP,{keywords:Pt.history}),u.jsx(WP,{keywords:Pt.dangerzone})]});function yg(t){const e=new Date,n={timeZone:t},r=navigator.language.startsWith("en")?navigator.language:"en-US";return e.toLocaleString(r,n)}function cy(t=""){const e=new RegExp(/([A-Za-z\u00C0-\u017F]{1})[A-Za-z\u00C0-\u017F]+/,"g"),n=[...t.matchAll(e)];return((n.shift()?.[1]||"")+(n.pop()?.[1]||"")).toUpperCase()}function mf(t){let r=0;for(let s=0;s<t.length;s++)r=t.charCodeAt(s)+((r<<5)-r);return"hsl("+r%360+", 70%, 40%)"}function So(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function wR(t){return/^[a-z0-9]{24}$/.test(t)}const kR=[{label:"Free members",value:"status:free",color:"green"},{label:"Paid members",value:"status:-free",color:"pink"}],SR=(t,e)=>{const n=Sc({path:"/tiers/",filterKey:"name",responseKey:"tiers"}),r=Sc({path:"/labels/",filterKey:"name",responseKey:"labels"}),i=Sc({path:"/offers/",filterKey:"name",responseKey:"offers"}),[s,o]=v.useState(null),a=f=>({value:f.id,label:f.name,color:"black"}),l=f=>({value:`label:${f.slug}`,label:f.name,color:"grey"}),c=f=>({value:`offer_redemptions:${f.id}`,label:f.name,color:"black"}),d=async(f,m)=>{const[p,g,b]=await Promise.all([n.loadData(f),r.loadData(f),i.loadData(f)]),x=[{options:kR.filter(({label:y})=>y.toLowerCase().includes(f.toLowerCase()))},{label:"Active Tiers",options:p.filter(({active:y,type:w})=>y&&w!=="free").map(a)||[]},{label:"Archived Tiers",options:p.filter(({active:y})=>!y).map(a)||[]},{label:"Labels",options:g.map(l)||[]},{label:"Offers",options:b.map(c)||[]}];s===null&&h(),m(x.filter(y=>y.options.length>0))},h=async()=>{const f=e?.split(",")||[],m=[],p=[],g=[];for(const x of f)x.startsWith("label:")?p.push(x.replace("label:","")):x.startsWith("offer_redemptions:")?g.push(x.replace("offer_redemptions:","")):wR(x)&&m.push(x);const b=await Promise.all([n.loadInitialValues(m,"id").then(x=>x.map(a)),r.loadInitialValues(p,"slug").then(x=>x.map(l)),i.loadInitialValues(g,"id").then(x=>x.map(c))]).then(x=>x.flat());o(f.map(x=>b.find(y=>y.value===x)))};return v.useEffect(()=>{t==="segment"&&d("",()=>{})},[t]),{loadOptions:A2(d,500),selectedSegments:s,setSelectedSegments:o}},wg=[{label:"Whoever has access to the post",hint:"Free posts to everyone, premium posts sent to paid members",value:"visibility"},{label:"All members",hint:"Everyone who is subscribed to newsletter updates, whether free or paid members",value:"all-members"},{label:"Paid-members only",hint:"People who have a premium subscription",value:"paid-only"},{label:"Specific people",hint:"Only people with any of the selected tiers or labels",value:"segment"},{label:"Usually nobody",hint:"Newsletters are off for new posts, but can be enabled when needed",value:"none"}];function kg({defaultEmailRecipients:t,defaultEmailRecipientsFilter:e}){return t==="filter"?e==="status:free,status:-free"?"all-members":e==="status:-free"?"paid-only":e===null?"none":"segment":t}const CR=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,handleEditingChange:a}=Ft(),[l,c]=we(e,["editor_default_email_recipients","editor_default_email_recipients_filter"]),[d,h]=v.useState(kg({defaultEmailRecipients:l,defaultEmailRecipientsFilter:c})),{loadOptions:f,selectedSegments:m,setSelectedSegments:p}=SR(d,c);v.useEffect(()=>{const x=kg({defaultEmailRecipients:l,defaultEmailRecipientsFilter:c});h(x)},[l,c]);const g=x=>{["visibility","disabled"].includes(x)?(o("editor_default_email_recipients",x),o("editor_default_email_recipients_filter",null)):o("editor_default_email_recipients","filter"),x==="all-members"&&o("editor_default_email_recipients_filter","status:free,status:-free"),x==="paid-only"&&o("editor_default_email_recipients_filter","status:-free"),x==="none"&&o("editor_default_email_recipients_filter",null),h(x),n||a(!0)},b=x=>{if(p(x),x.length){const y=x?.map(({value:w})=>w).join(",");o("editor_default_email_recipients_filter",y)}else o("editor_default_email_recipients_filter",null),h("none");n||a(!0)};return u.jsx(Se,{description:"When you publish new content, who do you usually want to send it to?",isEditing:n,keywords:t,navid:"default-recipients",saveState:r,testId:"default-recipients",title:"Default recipients",hideEditButton:!0,onCancel:s,onEditingChange:a,onSave:i,children:u.jsxs(tt,{columns:1,children:[u.jsx(ir,{hint:"Who should receive your posts by default?",options:wg,selectedOption:wg.find(x=>x.value===d),testId:"default-recipients-select",title:"Default Newsletter recipients",onSelect:x=>{x&&g(x.value)}}),d==="segment"&&m&&u.jsx(nb,{loadOptions:f,title:"Filter",values:m,async:!0,defaultOptions:!0,onChange:b})]})})},uy=Ce(CR,"Default recipients"),AR=({keywords:t})=>{const{settings:e}=ke(),{mutateAsync:n}=ai(),{updateRoute:r}=fe(),i=Ye(),[s,o]=we(e,["editor_default_email_recipients","members_signup_access"]),a=o==="none",l=async d=>{const h=[{key:"editor_default_email_recipients",value:d.target.checked?"visibility":"disabled"}];d.target.checked||h.push({key:"editor_default_email_recipients_filter",value:null});try{await n(h)}catch(f){i(f)}},c=u.jsx(u.Fragment,{children:u.jsx(en,{checked:s!=="disabled"&&!a,direction:"rtl",disabled:a,onChange:l})});return u.jsx(Se,{customButtons:c,description:"Newsletter features are active, posts can be sent by email",keywords:t,navid:"enable-newsletters",testId:"enable-newsletters",title:"Newsletter sending",children:u.jsx(tt,{columns:1,values:[{key:"private",value:s!=="disabled"&&!a?u.jsx("div",{className:"w-full",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(me,{colorClass:"text-green",name:"check",size:"sm"}),u.jsx("span",{children:"Enabled"})]})}):u.jsxs("div",{className:"w-full",children:[u.jsxs("div",{className:"flex items-center gap-2 text-grey-900",children:[u.jsx(me,{colorClass:"text-grey-600",name:"mail-block",size:"sm"}),u.jsx("span",{children:"Disabled"})]}),a&&u.jsxs(h0,{className:"mt-6",color:"grey",children:["Your ",u.jsx("button",{className:"underline!",type:"button",onClick:()=>{r("members")},children:"Subscription access"})," is set to ‘Nobody’, which disables all newsletter sending. Change to ‘Invite-only’ to send newsletters to existing members without allowing new signups."]})]})}]})})},dy=Ce(AR,"Newsletter sending"),bu=[{label:"🇺🇸 US",value:"https://api.mailgun.net/v3"},{label:"🇪🇺 EU",value:"https://api.eu.mailgun.net/v3"}],MR=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,handleEditingChange:a}=Ft(),{mutateAsync:l}=ai(),c=Ye(),[d,h,f]=we(e,["mailgun_base_url","mailgun_domain","mailgun_api_key"]),p=h&&f?[{key:"status",value:u.jsx(Z5,{icon:"check-circle",iconColorClass:"text-green",children:"Mailgun is set up"})}]:[{heading:"Status",key:"status",value:"Mailgun is not set up"}],g=u.jsx(tt,{columns:1,values:p}),b=u.jsxs(u.Fragment,{children:["Find your Mailgun API keys ",u.jsx(no,{href:"https://app.mailgun.com/settings/api_security",rel:"noopener noreferrer",target:"_blank",children:"here"})]}),x=u.jsx(tt,{children:u.jsxs("div",{className:"grid grid-cols-[120px_auto] gap-x-3 gap-y-6",children:[u.jsx(ir,{options:bu,selectedOption:bu.find(w=>w.value===d),title:"Mailgun region",onSelect:w=>{o("mailgun_base_url",w?.value||null)}}),u.jsx(at,{title:"Mailgun domain",value:h,onChange:w=>{o("mailgun_domain",w.target.value)}}),u.jsx("div",{className:"col-span-2",children:u.jsx(at,{hint:b,title:"Mailgun private API key",type:"password",value:f,onChange:w=>{o("mailgun_api_key",w.target.value)}})})]})}),y=u.jsxs(u.Fragment,{children:["The Mailgun API is used for bulk email newsletter delivery. ",u.jsx(no,{href:"https://ghost.org/docs/faq/mailgun-newsletters/",target:"_blank",children:"Why is this required?"})]});return u.jsx(Se,{description:y,isEditing:n,keywords:t,navid:"mailgun",saveState:r,testId:"mailgun",title:"Mailgun",onCancel:s,onEditingChange:a,onSave:async()=>{if(!d)try{await l([{key:"mailgun_base_url",value:bu[0].value}])}catch(w){c(w);return}i()},children:n?x:g})},hy=Ce(MR,"Mailgun"),Sg=({id:t,setRef:e,isDragging:n,style:r,children:i,separator:s,...o})=>{const{updateRoute:a}=fe(),l=()=>{a({route:`newsletters/${t}`})},c=u.jsxs(ls,{ref:e,action:u.jsx(J,{color:"green","data-testid":"edit-newsletter-button",label:"Edit",link:!0,onClick:l}),className:n?"opacity-75":"",hideActions:!1,style:r,onClick:l,children:[(o.dragHandleAttributes||n)&&u.jsx($n,{className:"w-10 align-middle!",children:u.jsx(Ob,{className:"h-10",isDragging:n||!1,...o})}),i]});return n?u.jsx(Mr,{children:c}):c},Cg=({newsletter:t})=>{const{updateRoute:e}=fe(),n=()=>{e({route:`newsletters/${t.id}`})};return u.jsxs(u.Fragment,{children:[u.jsx($n,{className:"w-full",onClick:n,children:u.jsxs("div",{className:"flex grow flex-col",children:[u.jsx("span",{className:"font-medium",children:t.name}),u.jsx("span",{className:"mt-0.5 text-sm leading-tight text-grey-700",children:t.description||"No description"})]})}),u.jsx($n,{className:"hidden md:visible! md:table-cell! md:min-w-[11rem]",onClick:n,children:u.jsxs("div",{className:"flex grow flex-col",children:[u.jsx("span",{children:Tf(t.count?.active_members||0)}),u.jsx("span",{className:"mt-0.5 text-sm leading-tight whitespace-nowrap text-grey-700",children:"Subscribers"})]})}),u.jsx($n,{className:"hidden md:visible! md:table-cell! md:min-w-[11rem]",onClick:n,children:u.jsxs("div",{className:"flex grow flex-col",children:[u.jsx("span",{children:Tf(t.count?.posts||0)}),u.jsx("span",{className:"mt-0.5 text-sm leading-tight whitespace-nowrap text-grey-700",children:"Delivered"})]})})]})},Rl=({newsletters:t,isLoading:e,isSortable:n,onSort:r})=>e?u.jsx(Mr,{isLoading:!0}):t.length&&n?u.jsx(ZM,{container:i=>u.jsx(Sg,{...i}),items:t,renderItem:i=>u.jsx(Cg,{newsletter:i}),wrapper:Mr,onMove:(i,s)=>r?.(i,s)}):t.length?u.jsx(Mr,{children:t.map(i=>u.jsx(Sg,{id:i.id,children:u.jsx(Cg,{newsletter:i})},i.id))}):u.jsx(li,{icon:"mail-block",children:"No newsletters found."}),Qo=()=>{const[t,e]=v.useState(new URLSearchParams);return v.useEffect(()=>{const r=()=>{const s=window.location.hash.split("?")[1];e(s?new URLSearchParams(s):new URLSearchParams)};return r(),window.addEventListener("hashchange",r),()=>{window.removeEventListener("hashchange",r)}},[]),{getParam:r=>t.get(r)}},vu=({id:t,children:e})=>{const n=an(),{updateRoute:r}=fe();return u.jsx("button",{className:"text-green",type:"button",onClick:()=>{r(`newsletters/${t}`),n.remove()},children:e})},ER=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("newsletters/new")},[r,i]=v.useState("active-newsletters"),{data:{newsletters:s,meta:o,isEnd:a}={},isLoading:l,fetchNextPage:c}=$l(),{mutateAsync:d}=Zg(),h=Bl(),f=Qo().getParam("verifyEmail"),{mutateAsync:m}=Qg(),p=Ye(),[g,b]=v.useState(s||[]);v.useEffect(()=>{b(s||[])},[s]),v.useEffect(()=>{if(!f||!window.location.href.includes("newsletters"))return;(async()=>{try{const{newsletters:[A],meta:{email_verified:M}={}}=await m({token:f});let E,j;M&&M==="sender_email"?(E="Newsletter email verified",j=u.jsxs(u.Fragment,{children:["Newsletter ",u.jsx(vu,{id:A.id,children:A.name})," will now be sent from ",u.jsx("strong",{children:A.sender_email}),"."]})):M&&M==="sender_reply_to"?(E="Reply-to address verified",j=u.jsxs(u.Fragment,{children:["Newsletter ",u.jsx(vu,{id:A.id,children:A.name})," will now use ",u.jsx("strong",{children:A.sender_reply_to})," as the reply-to address."]})):(E="Email address verified",j=u.jsxs(u.Fragment,{children:["Email address for newsletter ",u.jsx(vu,{id:A.id,children:A.name})," has been changed."]})),pe.show(Wt,{title:E,prompt:j,okLabel:"Close",cancelLabel:"",onOk:T=>T?.remove()})}catch(A){let M="There was an error verifying your email address. Try again later.";A instanceof Vl&&A.message==="Token expired"&&(M="Verification link has expired."),pe.show(Wt,{title:"Error verifying email address",prompt:M,okLabel:"Close",cancelLabel:"",onOk:E=>E?.remove()}),p(A,{withToast:!1})}})()},[f,p,m]);const x=u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Add newsletter",size:"sm",onClick:()=>{n()}}),y=g.filter(S=>S.status==="active").sort((S,A)=>S.sort_order-A.sort_order)||[],w=g.filter(S=>S.status!=="active"),k=async(S,A)=>{const M=y.findIndex(O=>O.id===S),E=y.findIndex(O=>O.id===A)||0,T=sc(y,M,E).map((O,L)=>O.sort_order===L?null:{...O,sort_order:L}).filter(O=>!!O),N=w.map((O,L)=>O.sort_order===L+y.length?null:{...O,sort_order:L}).filter(O=>!!O),D=[...T,...N].sort((O,L)=>O.sort_order-L.sort_order);b(g.map(O=>D.find(L=>L.id===O.id)||O)),h.setQueriesData([e0],O=>{if(O)return{...O,pages:O.pages.map(L=>({...L,newsletters:L.newsletters.map($=>D.find(U=>U.id===$.id)||$)}))}});for(const O of D)await d(O)},C=[{id:"active-newsletters",title:"Active",contents:u.jsx(Rl,{isLoading:l,newsletters:y,isSortable:!0,onSort:k})},{id:"archived-newsletters",title:"Archived",contents:u.jsx(Rl,{isLoading:l,newsletters:w})}];return u.jsxs(Se,{customButtons:x,description:"Edit details and customize your design",keywords:t,navid:"newsletters",testId:"newsletters",title:"Newsletters",children:[u.jsx(hr,{selectedTab:r,tabs:C,onTabChange:i}),a===!1&&u.jsx(J,{label:`Load more (showing ${g?.length||0}/${o?.pagination.total||0} newsletters)`,link:!0,onClick:()=>c()})]})},jR=Ce(ER,"Newsletters"),Rn={enableNewsletters:["emails","newsletters","newsletter sending","enable","disable","turn on","turn off"],newsletters:["newsletters","emails","design","customization"],defaultRecipients:["newsletters","default recipients","emails"],mailgun:["mailgun","emails","newsletters"]},NR=()=>{const{settings:t,config:e}=ke(),[n]=we(t,["editor_default_email_recipients"]),r=n!=="disabled",i=r&&!e.mailgunIsConfigured,s=[Rn.enableNewsletters,...r?[Rn.defaultRecipients,Rn.newsletters]:[],...i?[Rn.mailgun]:[]].flat();return u.jsxs(ui,{keywords:s,title:"Newsletters",children:[u.jsx(dy,{keywords:Rn.enableNewsletters}),r&&u.jsxs(u.Fragment,{children:[u.jsx(uy,{keywords:Rn.defaultRecipients}),u.jsx(jR,{keywords:Rn.newsletters}),i&&u.jsx(hy,{keywords:Rn.mailgun})]})]})},xu=({id:t,children:e})=>{const n=an(),{updateRoute:r}=fe();return u.jsx("button",{className:"text-green",type:"button",onClick:()=>{r(`newsletters/${t}`),n.remove()},children:e})},TR=()=>{const t=window.location.hash.slice(1),e=new URL(t||"/",window.location.origin).pathname;return e.startsWith("/settings/emails")||e.startsWith("/settings/newsletters")},DR=({filter:t})=>{const{data:{newsletters:e,meta:n,isEnd:r}={},isLoading:i,fetchNextPage:s}=$l(),{mutateAsync:o}=Zg(),a=Bl(),l=Qo().getParam("verifyEmail"),{mutateAsync:c}=Qg(),d=Ye(),[h,f]=v.useState(e||[]);v.useEffect(()=>{f(e||[])},[e]),v.useEffect(()=>{if(!l||!TR())return;(async()=>{try{const{newsletters:[y],meta:{email_verified:w}={}}=await c({token:l});let k,C;w&&w==="sender_email"?(k="Newsletter email verified",C=u.jsxs(u.Fragment,{children:["Newsletter ",u.jsx(xu,{id:y.id,children:y.name})," will now be sent from ",u.jsx("strong",{children:y.sender_email}),"."]})):w&&w==="sender_reply_to"?(k="Reply-to address verified",C=u.jsxs(u.Fragment,{children:["Newsletter ",u.jsx(xu,{id:y.id,children:y.name})," will now use ",u.jsx("strong",{children:y.sender_reply_to})," as the reply-to address."]})):(k="Email address verified",C=u.jsxs(u.Fragment,{children:["Email address for newsletter ",u.jsx(xu,{id:y.id,children:y.name})," has been changed."]})),pe.show(Wt,{title:k,prompt:C,okLabel:"Close",cancelLabel:"",onOk:S=>S?.remove()})}catch(y){let w="There was an error verifying your email address. Try again later.";y instanceof Vl&&y.message==="Token expired"&&(w="Verification link has expired."),pe.show(Wt,{title:"Error verifying email address",prompt:w,okLabel:"Close",cancelLabel:"",onOk:k=>k?.remove()}),d(y,{withToast:!1})}})()},[l,d,c]);const m=h.filter(x=>x.status==="active").sort((x,y)=>x.sort_order-y.sort_order)||[],p=h.filter(x=>x.status!=="active"),g=async(x,y)=>{const w=m.findIndex(E=>E.id===x),k=m.findIndex(E=>E.id===y)||0,S=sc(m,w,k).map((E,j)=>E.sort_order===j?null:{...E,sort_order:j}).filter(E=>!!E),A=p.map((E,j)=>E.sort_order===j+m.length?null:{...E,sort_order:j}).filter(E=>!!E),M=[...S,...A].sort((E,j)=>E.sort_order-j.sort_order);f(h.map(E=>M.find(j=>j.id===E.id)||E)),a.setQueriesData([e0],E=>{if(E)return{...E,pages:E.pages.map(j=>({...j,newsletters:j.newsletters.map(T=>M.find(N=>N.id===T.id)||T)}))}});for(const E of M)await o(E)},b=t==="active";return u.jsxs(u.Fragment,{children:[b?u.jsx(Rl,{isLoading:i,isSortable:!0,newsletters:m,onSort:g}):u.jsx(Rl,{isLoading:i,newsletters:p}),r===!1&&u.jsx(J,{label:`Load more (showing ${h?.length||0}/${n?.pagination.total||0} newsletters)`,link:!0,onClick:()=>s()})]})},OR=Ce(DR,"Newsletters"),IR=({title:t="Are you sure you want to leave this page?",description:e=u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{children:"Hey there! It looks like you didn't save the changes you made."}),u.jsx("p",{children:"Save before you go!"})]})})=>{const n=an(),r=v.useRef(n.visible),i=v.useRef(!1);return v.useEffect(()=>{r.current&&!n.visible&&(n.resolveHide(),n.remove()),r.current=n.visible},[n]),u.jsx(Aw,{open:n.visible,onOpenChange:s=>{s||(n.resolve(i.current),i.current=!1,n.hide())},children:u.jsxs(Mw,{"data-testid":"welcome-email-dirty-confirm-modal",onEscapeKeyDown:s=>{s.stopPropagation()},children:[u.jsxs(Ew,{children:[u.jsx(jw,{children:t}),u.jsx(Nw,{asChild:!0,children:e})]}),u.jsxs(Tw,{children:[u.jsx(Dw,{asChild:!0,children:u.jsx(Nr,{variant:"outline",children:"Stay"})}),u.jsx(Ow,{asChild:!0,children:u.jsx(Nr,{variant:"destructive",onClick:()=>{i.current=!0},children:"Leave"})})]})]})})},PR=pe.create(IR),RR=({open:t,title:e,preview:n,sidebar:r,dirty:i=!1,isLoading:s=!1,okProps:o,onSave:a,onClose:l,afterClose:c,testId:d})=>{const h=v.useRef(a),f=v.useRef(t);v.useEffect(()=>{h.current=a},[a]),v.useEffect(()=>{f.current&&!t&&c?.(),f.current=t},[c,t]),v.useEffect(()=>{const p=g=>{(g.metaKey||g.ctrlKey)&&g.key==="s"&&(g.preventDefault(),h.current())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[]);const m=async()=>{if(!i){l();return}await pe.show(PR)&&l()};return u.jsx(Iw,{open:t,onOpenChange:p=>{p||m()},children:u.jsx(Pw,{"aria-describedby":void 0,className:Le("top-[50%] left-[50%] h-[calc(100vh-8vmin)] w-[calc(100vw-8vmin)] max-w-none translate-x-[-50%] translate-y-[-50%] gap-0 overflow-hidden p-0"),"data-testid":d,onEscapeKeyDown:p=>{p.preventDefault(),p.stopPropagation(),m()},children:u.jsxs("div",{className:"flex h-full min-h-0",children:[u.jsx("div",{className:"hidden min-h-0 flex-1 flex-col bg-gray-50 dark:bg-black [@media(min-width:801px)]:flex",children:u.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-8",children:n})}),u.jsxs("div",{className:"flex min-h-0 w-full flex-col border-l border-gray-200 dark:border-gray-900 [@media(min-width:801px)]:w-[400px] [@media(min-width:801px)]:shrink-0",children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-5",children:[u.jsx(Rw,{children:e}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Nr,{variant:"outline",onClick:()=>m(),children:"Close"}),u.jsx(Nr,{className:o?.color==="green"?"bg-green text-white hover:bg-green/90":void 0,disabled:s||o?.disabled,variant:o?.color==="red"?"destructive":"default",onClick:a,children:o?.label||"Save"})]})]}),r]})]})})})};function pf(t,e){return e={exports:{}},t(e,e.exports),e.exports}var js={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]},LR=function(e){return!e||typeof e=="string"?!1:e instanceof Array||Array.isArray(e)||e.length>=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&e.constructor.name!=="String")},Ns=pf(function(t){var e=Array.prototype.concat,n=Array.prototype.slice,r=t.exports=function(s){for(var o=[],a=0,l=s.length;a<l;a++){var c=s[a];LR(c)?o=e.call(o,n.call(c)):o.push(c)}return o};r.wrap=function(i){return function(){return i(r(arguments))}}}),Zr=pf(function(t){var e=Object.hasOwnProperty,n=Object.create(null);for(var r in js)e.call(js,r)&&(n[js[r]]=r);var i=t.exports={to:{},get:{}};i.get=function(a){var l=a.substring(0,3).toLowerCase(),c,d;switch(l){case"hsl":c=i.get.hsl(a),d="hsl";break;case"hwb":c=i.get.hwb(a),d="hwb";break;default:c=i.get.rgb(a),d="rgb";break}return c?{model:d,value:c}:null},i.get.rgb=function(a){if(!a)return null;var l=/^#([a-f0-9]{3,4})$/i,c=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,d=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,h=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,f=/^(\w+)$/,m=[0,0,0,1],p,g,b;if(p=a.match(c)){for(b=p[2],p=p[1],g=0;g<3;g++){var x=g*2;m[g]=parseInt(p.slice(x,x+2),16)}b&&(m[3]=parseInt(b,16)/255)}else if(p=a.match(l)){for(p=p[1],b=p[3],g=0;g<3;g++)m[g]=parseInt(p[g]+p[g],16);b&&(m[3]=parseInt(b+b,16)/255)}else if(p=a.match(d)){for(g=0;g<3;g++)m[g]=parseInt(p[g+1],0);p[4]&&(p[5]?m[3]=parseFloat(p[4])*.01:m[3]=parseFloat(p[4]))}else if(p=a.match(h)){for(g=0;g<3;g++)m[g]=Math.round(parseFloat(p[g+1])*2.55);p[4]&&(p[5]?m[3]=parseFloat(p[4])*.01:m[3]=parseFloat(p[4]))}else return(p=a.match(f))?p[1]==="transparent"?[0,0,0,0]:e.call(js,p[1])?(m=js[p[1]],m[3]=1,m):null:null;for(g=0;g<3;g++)m[g]=s(m[g],0,255);return m[3]=s(m[3],0,1),m},i.get.hsl=function(a){if(!a)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*)?\)$/,c=a.match(l);if(c){var d=parseFloat(c[4]),h=(parseFloat(c[1])%360+360)%360,f=s(parseFloat(c[2]),0,100),m=s(parseFloat(c[3]),0,100),p=s(isNaN(d)?1:d,0,1);return[h,f,m,p]}return null},i.get.hwb=function(a){if(!a)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*)?\)$/,c=a.match(l);if(c){var d=parseFloat(c[4]),h=(parseFloat(c[1])%360+360)%360,f=s(parseFloat(c[2]),0,100),m=s(parseFloat(c[3]),0,100),p=s(isNaN(d)?1:d,0,1);return[h,f,m,p]}return null},i.to.hex=function(){var a=Ns(arguments);return"#"+o(a[0])+o(a[1])+o(a[2])+(a[3]<1?o(Math.round(a[3]*255)):"")},i.to.rgb=function(){var a=Ns(arguments);return a.length<4||a[3]===1?"rgb("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+")":"rgba("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+", "+a[3]+")"},i.to.rgb.percent=function(){var a=Ns(arguments),l=Math.round(a[0]/255*100),c=Math.round(a[1]/255*100),d=Math.round(a[2]/255*100);return a.length<4||a[3]===1?"rgb("+l+"%, "+c+"%, "+d+"%)":"rgba("+l+"%, "+c+"%, "+d+"%, "+a[3]+")"},i.to.hsl=function(){var a=Ns(arguments);return a.length<4||a[3]===1?"hsl("+a[0]+", "+a[1]+"%, "+a[2]+"%)":"hsla("+a[0]+", "+a[1]+"%, "+a[2]+"%, "+a[3]+")"},i.to.hwb=function(){var a=Ns(arguments),l="";return a.length>=4&&a[3]!==1&&(l=", "+a[3]),"hwb("+a[0]+", "+a[1]+"%, "+a[2]+"%"+l+")"},i.to.keyword=function(a){return n[a.slice(0,3)]};function s(a,l,c){return Math.min(Math.max(l,a),c)}function o(a){var l=Math.round(a).toString(16).toUpperCase();return l.length<2?"0"+l:l}});Zr.to;Zr.get;var Hr={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]},Ke=pf(function(t){var e={};for(var n in Hr)Hr.hasOwnProperty(n)&&(e[Hr[n]]=n);var r=t.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 i in r)if(r.hasOwnProperty(i)){if(!("channels"in r[i]))throw new Error("missing channels property: "+i);if(!("labels"in r[i]))throw new Error("missing channel labels property: "+i);if(r[i].labels.length!==r[i].channels)throw new Error("channel and label counts mismatch: "+i);var s=r[i].channels,o=r[i].labels;delete r[i].channels,delete r[i].labels,Object.defineProperty(r[i],"channels",{value:s}),Object.defineProperty(r[i],"labels",{value:o})}r.rgb.hsl=function(l){var c=l[0]/255,d=l[1]/255,h=l[2]/255,f=Math.min(c,d,h),m=Math.max(c,d,h),p=m-f,g,b,x;return m===f?g=0:c===m?g=(d-h)/p:d===m?g=2+(h-c)/p:h===m&&(g=4+(c-d)/p),g=Math.min(g*60,360),g<0&&(g+=360),x=(f+m)/2,m===f?b=0:x<=.5?b=p/(m+f):b=p/(2-m-f),[g,b*100,x*100]},r.rgb.hsv=function(l){var c,d,h,f,m,p=l[0]/255,g=l[1]/255,b=l[2]/255,x=Math.max(p,g,b),y=x-Math.min(p,g,b),w=function(k){return(x-k)/6/y+1/2};return y===0?f=m=0:(m=y/x,c=w(p),d=w(g),h=w(b),p===x?f=h-d:g===x?f=1/3+c-h:b===x&&(f=2/3+d-c),f<0?f+=1:f>1&&(f-=1)),[f*360,m*100,x*100]},r.rgb.hwb=function(l){var c=l[0],d=l[1],h=l[2],f=r.rgb.hsl(l)[0],m=1/255*Math.min(c,Math.min(d,h));return h=1-1/255*Math.max(c,Math.max(d,h)),[f,m*100,h*100]},r.rgb.cmyk=function(l){var c=l[0]/255,d=l[1]/255,h=l[2]/255,f,m,p,g;return g=Math.min(1-c,1-d,1-h),f=(1-c-g)/(1-g)||0,m=(1-d-g)/(1-g)||0,p=(1-h-g)/(1-g)||0,[f*100,m*100,p*100,g*100]};function a(l,c){return Math.pow(l[0]-c[0],2)+Math.pow(l[1]-c[1],2)+Math.pow(l[2]-c[2],2)}r.rgb.keyword=function(l){var c=e[l];if(c)return c;var d=1/0,h;for(var f in Hr)if(Hr.hasOwnProperty(f)){var m=Hr[f],p=a(l,m);p<d&&(d=p,h=f)}return h},r.keyword.rgb=function(l){return Hr[l]},r.rgb.xyz=function(l){var c=l[0]/255,d=l[1]/255,h=l[2]/255;c=c>.04045?Math.pow((c+.055)/1.055,2.4):c/12.92,d=d>.04045?Math.pow((d+.055)/1.055,2.4):d/12.92,h=h>.04045?Math.pow((h+.055)/1.055,2.4):h/12.92;var f=c*.4124+d*.3576+h*.1805,m=c*.2126+d*.7152+h*.0722,p=c*.0193+d*.1192+h*.9505;return[f*100,m*100,p*100]},r.rgb.lab=function(l){var c=r.rgb.xyz(l),d=c[0],h=c[1],f=c[2],m,p,g;return d/=95.047,h/=100,f/=108.883,d=d>.008856?Math.pow(d,1/3):7.787*d+16/116,h=h>.008856?Math.pow(h,1/3):7.787*h+16/116,f=f>.008856?Math.pow(f,1/3):7.787*f+16/116,m=116*h-16,p=500*(d-h),g=200*(h-f),[m,p,g]},r.hsl.rgb=function(l){var c=l[0]/360,d=l[1]/100,h=l[2]/100,f,m,p,g,b;if(d===0)return b=h*255,[b,b,b];h<.5?m=h*(1+d):m=h+d-h*d,f=2*h-m,g=[0,0,0];for(var x=0;x<3;x++)p=c+1/3*-(x-1),p<0&&p++,p>1&&p--,6*p<1?b=f+(m-f)*6*p:2*p<1?b=m:3*p<2?b=f+(m-f)*(2/3-p)*6:b=f,g[x]=b*255;return g},r.hsl.hsv=function(l){var c=l[0],d=l[1]/100,h=l[2]/100,f=d,m=Math.max(h,.01),p,g;return h*=2,d*=h<=1?h:2-h,f*=m<=1?m:2-m,g=(h+d)/2,p=h===0?2*f/(m+f):2*d/(h+d),[c,p*100,g*100]},r.hsv.rgb=function(l){var c=l[0]/60,d=l[1]/100,h=l[2]/100,f=Math.floor(c)%6,m=c-Math.floor(c),p=255*h*(1-d),g=255*h*(1-d*m),b=255*h*(1-d*(1-m));switch(h*=255,f){case 0:return[h,b,p];case 1:return[g,h,p];case 2:return[p,h,b];case 3:return[p,g,h];case 4:return[b,p,h];case 5:return[h,p,g]}},r.hsv.hsl=function(l){var c=l[0],d=l[1]/100,h=l[2]/100,f=Math.max(h,.01),m,p,g;return g=(2-d)*h,m=(2-d)*f,p=d*f,p/=m<=1?m:2-m,p=p||0,g/=2,[c,p*100,g*100]},r.hwb.rgb=function(l){var c=l[0]/360,d=l[1]/100,h=l[2]/100,f=d+h,m,p,g,b;f>1&&(d/=f,h/=f),m=Math.floor(6*c),p=1-h,g=6*c-m,(m&1)!==0&&(g=1-g),b=d+g*(p-d);var x,y,w;switch(m){default:case 6:case 0:x=p,y=b,w=d;break;case 1:x=b,y=p,w=d;break;case 2:x=d,y=p,w=b;break;case 3:x=d,y=b,w=p;break;case 4:x=b,y=d,w=p;break;case 5:x=p,y=d,w=b;break}return[x*255,y*255,w*255]},r.cmyk.rgb=function(l){var c=l[0]/100,d=l[1]/100,h=l[2]/100,f=l[3]/100,m,p,g;return m=1-Math.min(1,c*(1-f)+f),p=1-Math.min(1,d*(1-f)+f),g=1-Math.min(1,h*(1-f)+f),[m*255,p*255,g*255]},r.xyz.rgb=function(l){var c=l[0]/100,d=l[1]/100,h=l[2]/100,f,m,p;return f=c*3.2406+d*-1.5372+h*-.4986,m=c*-.9689+d*1.8758+h*.0415,p=c*.0557+d*-.204+h*1.057,f=f>.0031308?1.055*Math.pow(f,1/2.4)-.055:f*12.92,m=m>.0031308?1.055*Math.pow(m,1/2.4)-.055:m*12.92,p=p>.0031308?1.055*Math.pow(p,1/2.4)-.055:p*12.92,f=Math.min(Math.max(0,f),1),m=Math.min(Math.max(0,m),1),p=Math.min(Math.max(0,p),1),[f*255,m*255,p*255]},r.xyz.lab=function(l){var c=l[0],d=l[1],h=l[2],f,m,p;return c/=95.047,d/=100,h/=108.883,c=c>.008856?Math.pow(c,1/3):7.787*c+16/116,d=d>.008856?Math.pow(d,1/3):7.787*d+16/116,h=h>.008856?Math.pow(h,1/3):7.787*h+16/116,f=116*d-16,m=500*(c-d),p=200*(d-h),[f,m,p]},r.lab.xyz=function(l){var c=l[0],d=l[1],h=l[2],f,m,p;m=(c+16)/116,f=d/500+m,p=m-h/200;var g=Math.pow(m,3),b=Math.pow(f,3),x=Math.pow(p,3);return m=g>.008856?g:(m-16/116)/7.787,f=b>.008856?b:(f-16/116)/7.787,p=x>.008856?x:(p-16/116)/7.787,f*=95.047,m*=100,p*=108.883,[f,m,p]},r.lab.lch=function(l){var c=l[0],d=l[1],h=l[2],f,m,p;return f=Math.atan2(h,d),m=f*360/2/Math.PI,m<0&&(m+=360),p=Math.sqrt(d*d+h*h),[c,p,m]},r.lch.lab=function(l){var c=l[0],d=l[1],h=l[2],f,m,p;return p=h/360*2*Math.PI,f=d*Math.cos(p),m=d*Math.sin(p),[c,f,m]},r.rgb.ansi16=function(l){var c=l[0],d=l[1],h=l[2],f=1 in arguments?arguments[1]:r.rgb.hsv(l)[2];if(f=Math.round(f/50),f===0)return 30;var m=30+(Math.round(h/255)<<2|Math.round(d/255)<<1|Math.round(c/255));return f===2&&(m+=60),m},r.hsv.ansi16=function(l){return r.rgb.ansi16(r.hsv.rgb(l),l[2])},r.rgb.ansi256=function(l){var c=l[0],d=l[1],h=l[2];if(c===d&&d===h)return c<8?16:c>248?231:Math.round((c-8)/247*24)+232;var f=16+36*Math.round(c/255*5)+6*Math.round(d/255*5)+Math.round(h/255*5);return f},r.ansi16.rgb=function(l){var c=l%10;if(c===0||c===7)return l>50&&(c+=3.5),c=c/10.5*255,[c,c,c];var d=(~~(l>50)+1)*.5,h=(c&1)*d*255,f=(c>>1&1)*d*255,m=(c>>2&1)*d*255;return[h,f,m]},r.ansi256.rgb=function(l){if(l>=232){var c=(l-232)*10+8;return[c,c,c]}l-=16;var d,h=Math.floor(l/36)/5*255,f=Math.floor((d=l%36)/6)/5*255,m=d%6/5*255;return[h,f,m]},r.rgb.hex=function(l){var c=((Math.round(l[0])&255)<<16)+((Math.round(l[1])&255)<<8)+(Math.round(l[2])&255),d=c.toString(16).toUpperCase();return"000000".substring(d.length)+d},r.hex.rgb=function(l){var c=l.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!c)return[0,0,0];var d=c[0];c[0].length===3&&(d=d.split("").map(function(g){return g+g}).join(""));var h=parseInt(d,16),f=h>>16&255,m=h>>8&255,p=h&255;return[f,m,p]},r.rgb.hcg=function(l){var c=l[0]/255,d=l[1]/255,h=l[2]/255,f=Math.max(Math.max(c,d),h),m=Math.min(Math.min(c,d),h),p=f-m,g,b;return p<1?g=m/(1-p):g=0,p<=0?b=0:f===c?b=(d-h)/p%6:f===d?b=2+(h-c)/p:b=4+(c-d)/p+4,b/=6,b%=1,[b*360,p*100,g*100]},r.hsl.hcg=function(l){var c=l[1]/100,d=l[2]/100,h=1,f=0;return d<.5?h=2*c*d:h=2*c*(1-d),h<1&&(f=(d-.5*h)/(1-h)),[l[0],h*100,f*100]},r.hsv.hcg=function(l){var c=l[1]/100,d=l[2]/100,h=c*d,f=0;return h<1&&(f=(d-h)/(1-h)),[l[0],h*100,f*100]},r.hcg.rgb=function(l){var c=l[0]/360,d=l[1]/100,h=l[2]/100;if(d===0)return[h*255,h*255,h*255];var f=[0,0,0],m=c%1*6,p=m%1,g=1-p,b=0;switch(Math.floor(m)){case 0:f[0]=1,f[1]=p,f[2]=0;break;case 1:f[0]=g,f[1]=1,f[2]=0;break;case 2:f[0]=0,f[1]=1,f[2]=p;break;case 3:f[0]=0,f[1]=g,f[2]=1;break;case 4:f[0]=p,f[1]=0,f[2]=1;break;default:f[0]=1,f[1]=0,f[2]=g}return b=(1-d)*h,[(d*f[0]+b)*255,(d*f[1]+b)*255,(d*f[2]+b)*255]},r.hcg.hsv=function(l){var c=l[1]/100,d=l[2]/100,h=c+d*(1-c),f=0;return h>0&&(f=c/h),[l[0],f*100,h*100]},r.hcg.hsl=function(l){var c=l[1]/100,d=l[2]/100,h=d*(1-c)+.5*c,f=0;return h>0&&h<.5?f=c/(2*h):h>=.5&&h<1&&(f=c/(2*(1-h))),[l[0],f*100,h*100]},r.hcg.hwb=function(l){var c=l[1]/100,d=l[2]/100,h=c+d*(1-c);return[l[0],(h-c)*100,(1-h)*100]},r.hwb.hcg=function(l){var c=l[1]/100,d=l[2]/100,h=1-d,f=h-c,m=0;return f<1&&(m=(h-f)/(1-f)),[l[0],f*100,m*100]},r.apple.rgb=function(l){return[l[0]/65535*255,l[1]/65535*255,l[2]/65535*255]},r.rgb.apple=function(l){return[l[0]/255*65535,l[1]/255*65535,l[2]/255*65535]},r.gray.rgb=function(l){return[l[0]/100*255,l[0]/100*255,l[0]/100*255]},r.gray.hsl=r.gray.hsv=function(l){return[0,0,l[0]]},r.gray.hwb=function(l){return[0,100,l[0]]},r.gray.cmyk=function(l){return[0,0,0,l[0]]},r.gray.lab=function(l){return[l[0],0,0]},r.gray.hex=function(l){var c=Math.round(l[0]/100*255)&255,d=(c<<16)+(c<<8)+c,h=d.toString(16).toUpperCase();return"000000".substring(h.length)+h},r.rgb.gray=function(l){var c=(l[0]+l[1]+l[2])/3;return[c/255*100]}});Ke.rgb;Ke.hsl;Ke.hsv;Ke.hwb;Ke.cmyk;Ke.xyz;Ke.lab;Ke.lch;Ke.hex;Ke.keyword;Ke.ansi16;Ke.ansi256;Ke.hcg;Ke.apple;Ke.gray;function _R(){for(var t={},e=Object.keys(Ke),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}function FR(t){var e=_R(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),i=Object.keys(Ke[r]),s=i.length,o=0;o<s;o++){var a=i[o],l=e[a];l.distance===-1&&(l.distance=e[r].distance+1,l.parent=r,n.unshift(a))}return e}function BR(t,e){return function(n){return e(t(n))}}function VR(t,e){for(var n=[e[t].parent,t],r=Ke[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=BR(Ke[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var zR=function(t){for(var e=FR(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s],a=e[o];a.parent!==null&&(n[o]=VR(o,e))}return n},yi={},$R=Object.keys(Ke);function HR(t){var e=function(n){return n==null?n:(arguments.length>1&&(n=Array.prototype.slice.call(arguments)),t(n))};return"conversion"in t&&(e.conversion=t.conversion),e}function UR(t){var e=function(n){if(n==null)return n;arguments.length>1&&(n=Array.prototype.slice.call(arguments));var r=t(n);if(typeof r=="object")for(var i=r.length,s=0;s<i;s++)r[s]=Math.round(r[s]);return r};return"conversion"in t&&(e.conversion=t.conversion),e}$R.forEach(function(t){yi[t]={},Object.defineProperty(yi[t],"channels",{value:Ke[t].channels}),Object.defineProperty(yi[t],"labels",{value:Ke[t].labels});var e=zR(t),n=Object.keys(e);n.forEach(function(r){var i=e[r];yi[t][r]=UR(i),yi[t][r].raw=HR(i)})});var tn=yi,gf=[].slice,fy=["keyword","gray","hex"],Wd={};Object.keys(tn).forEach(function(t){Wd[gf.call(tn[t].labels).sort().join("")]=t});var Ll={};function vt(t,e){if(!(this instanceof vt))return new vt(t,e);if(e&&e in fy&&(e=null),e&&!(e in tn))throw new Error("Unknown model: "+e);var n,r;if(t==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof vt)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if(typeof t=="string"){var i=Zr.get(t);if(i===null)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=tn[this.model].channels,this.color=i.value.slice(0,r),this.valpha=typeof i.value[r]=="number"?i.value[r]:1}else if(t.length){this.model=e||"rgb",r=tn[this.model].channels;var s=gf.call(t,0,r);this.color=Kd(s,r),this.valpha=typeof t[r]=="number"?t[r]:1}else if(typeof t=="number")t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,t&255],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha=typeof t.alpha=="number"?t.alpha:0);var a=o.sort().join("");if(!(a in Wd))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=Wd[a];var l=tn[this.model].labels,c=[];for(n=0;n<l.length;n++)c.push(t[l[n]]);this.color=Kd(c)}if(Ll[this.model])for(r=tn[this.model].channels,n=0;n<r;n++){var d=Ll[this.model][n];d&&(this.color[n]=d(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}vt.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in Zr.to?this:this.rgb();e=e.round(typeof t=="number"?t:1);var n=e.valpha===1?e.color:e.color.concat(this.valpha);return Zr.to[e.model](n)},percentString:function(t){var e=this.rgb().round(typeof t=="number"?t:1),n=e.valpha===1?e.color:e.color.concat(this.valpha);return Zr.to.rgb.percent(n)},array:function(){return this.valpha===1?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=tn[this.model].channels,n=tn[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return this.valpha!==1&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,this.valpha!==1&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,this.valpha!==1&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new vt(this.color.map(KR(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new vt(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:$e("rgb",0,rt(255)),green:$e("rgb",1,rt(255)),blue:$e("rgb",2,rt(255)),hue:$e(["hsl","hsv","hsl","hwb","hcg"],0,function(t){return(t%360+360)%360}),saturationl:$e("hsl",1,rt(100)),lightness:$e("hsl",2,rt(100)),saturationv:$e("hsv",1,rt(100)),value:$e("hsv",2,rt(100)),chroma:$e("hcg",1,rt(100)),gray:$e("hcg",2,rt(100)),white:$e("hwb",1,rt(100)),wblack:$e("hwb",2,rt(100)),cyan:$e("cmyk",0,rt(100)),magenta:$e("cmyk",1,rt(100)),yellow:$e("cmyk",2,rt(100)),black:$e("cmyk",3,rt(100)),x:$e("xyz",0,rt(100)),y:$e("xyz",1,rt(100)),z:$e("xyz",2,rt(100)),l:$e("lab",0,rt(100)),a:$e("lab",1),b:$e("lab",2),keyword:function(t){return arguments.length?new vt(t):tn[this.model].keyword(this.color)},hex:function(t){return arguments.length?new vt(t):Zr.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return .2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color,e=(t[0]*299+t[1]*587+t[2]*114)/1e3;return e<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=t[0]*.3+t[1]*.59+t[2]*.11;return vt.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n+t)%360,n=n<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),i=e===void 0?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o===-1?s:(s+o)/(1+s*o))+1)/2,l=1-a;return vt.rgb(a*n.red()+l*r.red(),a*n.green()+l*r.green(),a*n.blue()+l*r.blue(),n.alpha()*i+r.alpha()*(1-i))}};Object.keys(tn).forEach(function(t){if(fy.indexOf(t)===-1){var e=tn[t].channels;vt.prototype[t]=function(){if(this.model===t)return new vt(this);if(arguments.length)return new vt(arguments,t);var n=typeof arguments[e]=="number"?e:this.valpha;return new vt(GR(tn[this.model][t].raw(this.color)).concat(n),t)},vt[t]=function(n){return typeof n=="number"&&(n=Kd(gf.call(arguments),e)),new vt(n,t)}}});function WR(t,e){return Number(t.toFixed(e))}function KR(t){return function(e){return WR(e,t)}}function $e(t,e,n){return t=Array.isArray(t)?t:[t],t.forEach(function(r){(Ll[r]||(Ll[r]=[]))[e]=n}),t=t[0],function(r){var i;return arguments.length?(n&&(r=n(r)),i=this[t](),i.color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function rt(t){return function(e){return Math.max(0,Math.min(t,e))}}function GR(t){return Array.isArray(t)?t:[t]}function Kd(t,e){for(var n=0;n<e;n++)typeof t[n]!="number"&&(t[n]=0);return t}var yu=vt;function sr(t){const e=yu(t),n=yu({r:255,g:255,b:255}),r=yu({r:0,g:0,b:0});return e.red()*.299+e.green()*.587+e.b()*.114>=186?r:n}const ms=/^#(?:[0-9a-f]{3}){1,2}$/i;function qR(t){return ms.test(t)?t:"#ffffff"}function YR(t,e){return!t||t==="transparent"?"transparent":t==="accent"?e:ms.test(t)?t:"transparent"}function XR(t,e,n){return ms.test(t||"")?t:t===null?sr(n).hex():e}function JR(t,e){if(t==="fill")return sr(e).hex()}function ZR(t,e,n){const r=t===void 0?"accent":t;return r==="accent"?e:ms.test(r||"")?r:sr(n).hex()}function QR(t,e,n){return ms.test(t||"")?t:t==="accent"?e:sr(n).hex()}function eL(t,e){return ms.test(t||"")?t:t==="accent"?e:"#e0e7eb"}function my(t,e){const n=qR(t.background_color),r=YR(t.header_background_color,e),i=XR(t.button_color,e,n),s=sr(n).hex(),o=sr(n).alpha(.5).toString(),a=r==="transparent"?s:sr(r).hex(),l=r==="transparent"?o:sr(r).alpha(.5).toString();return{backgroundColor:n,headerBackgroundColor:r,sectionTitleColor:QR(t.section_title_color,e,n),buttonColor:i,buttonTextColor:JR(t.button_style,i),linkColor:ZR(t.link_color,e,n),dividerColor:eL(t.divider_color,e),textColor:s,secondaryTextColor:o,headerTextColor:a,secondaryHeaderTextColor:l}}function tL(t){return t==="serif"?"Georgia, serif":'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'}function nL(t){switch(t){case"square":return"rounded-none";case"pill":return"rounded-full";default:return"rounded-[6px]"}}function py(t){return t==="rounded"?"rounded-md":""}const rL=({senderName:t,senderEmail:e,replyToEmail:n,subject:r,showRecipientLine:i=!0,showSubjectLine:s=!0})=>{const o=n||e,a=t&&e?`${t} (${e})`:t||e;return!a&&!o&&(!s||!r)?null:u.jsxs("div",{className:"flex flex-col justify-center gap-1 border-b border-grey-200 bg-white p-6 text-grey-700",children:[a&&u.jsxs("div",{children:[u.jsx("span",{className:"font-semibold text-grey-900",children:"From:"})," ",a]}),i&&e&&u.jsxs("div",{children:[u.jsx("span",{className:"font-semibold text-grey-900",children:"To:"})," subscriber@example.com"]}),o&&u.jsxs("div",{children:[u.jsx("span",{className:"font-semibold text-grey-900",children:"Reply-to:"})," ",o]}),s&&r&&u.jsx("div",{className:"text-base font-medium text-grey-900",children:r})]})},iL=({iconUrl:t,showIcon:e,showTitle:n,siteTitle:r,backgroundColor:i,textColor:s})=>!e&&(!n||!r)?null:u.jsxs("div",{className:"px-[7rem] py-3 text-center",style:{backgroundColor:i==="transparent"?void 0:i},children:[e&&t&&u.jsx("img",{alt:r||"Publication icon",className:"mx-auto mb-3 h-12 w-12 rounded",src:t}),n&&r&&u.jsx("h4",{className:"mb-1 text-[1.6rem] leading-tight font-bold tracking-tight uppercase",style:{color:s},children:r})]}),sL=({siteTitle:t,footerLinkText:e="Unsubscribe",emailFooter:n,showBadge:r,color:i,textColor:s})=>u.jsxs("div",{className:"flex flex-col items-center pt-10",children:[n&&u.jsx("div",{className:"px-8 py-3 text-center text-[1.3rem] leading-base break-words whitespace-pre-line",style:{color:i},children:n}),u.jsxs("div",{className:"px-8 pt-3 pb-14 text-center text-[1.3rem]",children:[u.jsxs("span",{style:{color:i},children:[t||"Your publication"," © ",new Date().getFullYear()," — "]}),u.jsx("span",{className:"underline",style:{color:i},children:e})]}),r&&u.jsx("div",{className:"flex flex-col items-center pt-[10px] pb-[40px]",children:u.jsxs("span",{className:"inline-flex items-center px-2 py-1 text-[1.25rem] font-semibold tracking-tight",style:{color:s},children:[u.jsx(dE,{className:"mr-[6px] size-4"}),u.jsx("span",{children:"Powered by Ghost"})]})})]}),oL=({settings:t,accentColor:e,publicationIcon:n,siteTitle:r,senderName:i,senderEmail:s,replyToEmail:o,subject:a,showRecipientLine:l=!0,showSubjectLine:c=!0,headerImage:d,showPublicationIcon:h=!1,showPublicationTitle:f=!0,showBadge:m=!0,emailFooter:p,footerLinkText:g,children:b})=>{const x=my(t,e),y=py(t.image_corners),w=r||void 0;return u.jsxs("div",{className:"mx-auto flex max-h-full min-h-0 w-full max-w-[700px] flex-col overflow-hidden rounded-[4px] text-black shadow-sm",children:[u.jsx(rL,{replyToEmail:o,senderEmail:s,senderName:i,showRecipientLine:l,showSubjectLine:c,subject:a}),u.jsxs("div",{className:"min-h-0 w-full flex-1 overflow-y-auto",style:{backgroundColor:x.backgroundColor},children:[u.jsxs("div",{className:"px-[7rem]",style:{backgroundColor:x.headerBackgroundColor==="transparent"?void 0:x.headerBackgroundColor},children:[d&&u.jsx("div",{className:"pt-8",children:u.jsx("img",{alt:"Header",className:Le("h-auto w-full",y),src:d})}),u.jsx(iL,{backgroundColor:"transparent",iconUrl:n,showIcon:h&&!!n,showTitle:f,siteTitle:w,textColor:x.headerTextColor})]}),b,u.jsx(sL,{color:x.secondaryTextColor,emailFooter:p,footerLinkText:g,showBadge:m,siteTitle:w,textColor:x.textColor})]})]})},gy=Ot({method:"POST",path:()=>"/images/upload/",body:({file:t})=>{const e=new FormData;return e.append("file",t),e.append("purpose","image"),e}}),Ga=t=>t.images[0].url,aL=({value:t,onChange:e})=>{const{mutateAsync:n}=gy(),r=async i=>{const s=Ga(await n({file:i}));e(s)};return u.jsxs("div",{className:"flex flex-col gap-1.5","data-testid":"header-image-field",children:[u.jsx("label",{className:"font-medium",htmlFor:"welcome-email-header-image",children:"Header image"}),t?u.jsxs("div",{className:"relative overflow-hidden rounded-md border border-gray-200 dark:border-gray-800",children:[u.jsx("img",{alt:"Header",className:"h-auto w-full",src:t}),u.jsx("button",{className:"absolute top-2 right-2 rounded bg-black/50 px-2 py-1 text-sm text-white hover:bg-black/70",type:"button",onClick:()=>e(""),children:"Remove"})]}):u.jsxs(u.Fragment,{children:[u.jsx(f2,{accept:{"image/*":[".jpg",".jpeg",".png",".gif",".webp",".svg"]},className:"flex h-24 items-center justify-center p-0",id:"welcome-email-header-image",onDropAccepted:i=>i[0]&&r(i[0]),children:u.jsx("span",{className:"text-gray-700",children:"Upload header image"})}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"1200x600 recommended. Use a transparent PNG for best results on any background."})]})]})},lL=({value:t,onChange:e})=>u.jsxs("div",{className:"mt-6 flex items-start justify-between gap-4",children:[u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx(Lw,{className:"mt-0.5 size-4 shrink-0 text-red-500"}),u.jsxs("div",{className:"flex flex-col gap-0.5",children:[u.jsx("span",{children:"Promote independent publishing"}),u.jsx("span",{className:"text-sm leading-tight text-muted-foreground",children:"Show you're a part of the indie publishing movement with a small badge in the footer"})]})]}),u.jsx(ju,{checked:t,size:"sm",onCheckedChange:e})]}),cL=""+new URL("email-design-user-image-BWe5RYS0.jpg",import.meta.url).href,by=v.createContext(void 0),uL=({settings:t,onSettingsChange:e,accentColor:n,children:r})=>u.jsx(by.Provider,{value:{settings:t,onSettingsChange:e,accentColor:n},children:r}),qt=()=>{const t=v.useContext(by);if(!t)throw new Error("useEmailDesign must be used within an EmailDesignProvider");return t},dL=()=>{const{settings:t,accentColor:e}=qt(),n=my(t,e),r=tL(t.body_font_category),i=nL(t.button_corners),s=t.button_style==="outline",o=Le("no-underline",t.link_style==="underline"&&"underline",t.link_style==="bold"&&"font-bold"),a=Le("mb-5 text-[2.6rem] tracking-tighter",t.title_font_category==="serif"&&"font-serif",t.title_font_category==="sans_serif"&&"font-sans",t.title_font_weight==="normal"&&"font-normal",t.title_font_weight==="medium"&&"font-medium",t.title_font_weight==="semibold"&&"font-semibold",t.title_font_weight==="bold"&&"font-bold"),l=Le(t.body_font_category==="serif"?"font-serif text-[1.8rem]":"text-[1.7rem]");return u.jsxs("div",{className:"mx-auto w-full max-w-[600px] px-10 pt-16",children:[u.jsx("h3",{className:a,style:{color:n.sectionTitleColor},children:"Your welcome email"}),u.jsxs("div",{className:Le(l),style:{color:n.textColor,fontFamily:r},children:[u.jsx("p",{className:"mt-0 mb-6",children:"This is what your welcome email will look like when someone signs up to your site."}),u.jsx("p",{className:"mt-0 mb-8",children:"Use the settings on the right to shape the design — from colors and typography to layout and buttons — so it feels like a natural extension of your brand."}),u.jsx("div",{className:Le("h-[unset] w-full max-w-[600px] bg-cover bg-no-repeat"),children:u.jsx("img",{alt:"Example cover image",className:Le("min-h-full min-w-full shrink-0",py(t.image_corners)),src:cL})}),u.jsx("div",{className:"mt-1 w-full max-w-[600px] pb-8 text-center text-body-sm",style:{color:n.secondaryTextColor},children:"Image caption"}),u.jsx("p",{className:"mt-0 mb-6",children:"Welcome emails set the tone for your relationship with new members. We’ve optimized this template to look great across devices and inboxes, so your first impression lands exactly how you want it."})]}),u.jsx("div",{className:"my-5 py-4",children:u.jsx("hr",{className:"m-0 border-0 border-t",style:{borderColor:n.dividerColor}})}),u.jsx("h3",{className:a,style:{color:n.sectionTitleColor},children:"Need inspiration?"}),u.jsx("div",{className:Le(l),style:{color:n.textColor,fontFamily:r},children:u.jsxs("p",{className:"mt-0 mb-6",children:["We’ve put together a ",u.jsx("a",{className:o,href:"https://ghost.org/help/email-design/",rel:"noopener noreferrer",style:{color:n.linkColor},target:"_blank",children:"quick guide"})," that walks through all the available settings, along with a few examples of what’s possible."]})}),u.jsx("div",{className:"pb-6",children:u.jsx("a",{className:Le("inline-block border px-[18px] py-2.5 font-sans text-[15px] no-underline",i,s?"bg-transparent":"border-transparent",t.link_style==="bold"?"font-bold":"font-semibold"),href:"https://ghost.org/help/email-design/",rel:"noopener noreferrer",style:s?{borderColor:n.buttonColor,color:n.buttonColor}:{backgroundColor:n.buttonColor,color:n.buttonTextColor},target:"_blank",children:"Learn more"})}),u.jsx("div",{className:"py-4",children:u.jsx("hr",{className:"m-0 border-0 border-t",style:{borderColor:n.dividerColor}})})]})},ea=t=>{const{config:e}=ke();return e.labs[t]||!1},vy="AutomatedEmailDesignResponseType",hL=Xd({dataType:vy,path:"/automated_emails/design/"}),fL=Ot({method:"PUT",path:()=>"/automated_emails/design/",body:t=>({automated_email_design:[t]}),updateQueries:{emberUpdateType:"skip",dataType:vy,update:t=>t}}),Ag=/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i,mL=(t,e,n=[])=>{if(t&&Ag.test(t))return t;switch(t){case"accent":return e&&Ag.test(e)?e:"#ffffff";case"light":return"#ffffff";case"transparent":return"#00000000"}const r=n.find(i=>i.value===t);return r?r.hex:"#ffffff"},pL=t=>{const e=t.toLowerCase();return e.length===5&&e[4]==="0"||e.length===9&&e.slice(7)==="00"},gL=()=>u.jsx("span",{className:"pointer-events-none absolute inset-0 overflow-hidden rounded-full","data-testid":"transparent-indicator","aria-hidden":!0,children:u.jsx("span",{className:"absolute top-1/2 left-[-30%] block h-px w-[160%] -translate-y-1/2 -rotate-45 bg-red"})}),ps=({title:t,value:e,onChange:n,accentColor:r,swatches:i=[]})=>{const[s,o]=v.useState(!1),a=mL(e,r,i),l=v.useRef(!1),c=v.useRef(!1),d=v.useRef(null),h=i.find(b=>b.value===e||e&&b.hex.toLowerCase()===e.toLowerCase()),f=()=>{l.current=!1,c.current=!1},m=v.useCallback(()=>{d.current&&(window.removeEventListener("keydown",d.current,!0),d.current=null)},[]),p=()=>{m(),f(),o(!1)},g=()=>{if(d.current)return;const b=x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),p())};d.current=b,window.addEventListener("keydown",b,!0)};return v.useEffect(()=>()=>{m()},[m]),u.jsxs(_w,{open:s,onOpenChange:b=>{f(),b?g():m(),o(b)},children:[u.jsx(Fw,{asChild:!0,children:u.jsxs("div",{className:"flex w-full cursor-pointer items-start justify-between",children:[u.jsx("span",{className:"mt-px flex-1",children:t}),u.jsxs("div",{className:"flex shrink-0 gap-1",children:[s&&i.length>0&&u.jsx("div",{className:"flex items-center gap-1",children:i.map(b=>{const x=b.value===void 0?b.hex:b.value,y=h?.title===b.title;return u.jsx("button",{"aria-label":b.title,className:`relative flex h-5 w-5 shrink-0 cursor-pointer items-center overflow-hidden rounded-full border border-grey-300 dark:border-grey-800 ${y?"outline-2 outline-green":""}`,style:{backgroundColor:b.hex},title:b.title,type:"button",onClick:()=>{l.current=!1,c.current=!0,n(x),p()},children:pL(b.hex)&&u.jsx(gL,{})},b.title)})}),u.jsxs("button",{"aria-label":"Pick color",className:"relative size-6 cursor-pointer rounded-full border border-grey-200 dark:border-grey-800",type:"button",children:[u.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%))]"}),u.jsx("div",{className:"absolute inset-[3px] overflow-hidden rounded-full border border-white dark:border-grey-950",style:{backgroundColor:a}})]})]})]})}),u.jsx(Bw,{align:"end",className:"w-auto p-4",onEscapeKeyDown:b=>{b.stopPropagation()},children:u.jsx("div",{onInputCapture:()=>{l.current=!0},onKeyDownCapture:()=>{l.current=!0},onMouseDownCapture:()=>{l.current=!0},onPointerDownCapture:()=>{l.current=!0},onTouchStartCapture:()=>{l.current=!0},children:u.jsx(RI,{value:a,onChange:b=>{c.current||!l.current||n(b)}})})})]})},bL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsx(ps,{swatches:[{title:"White",value:"light",hex:"#ffffff"}],title:"Background color",value:t.background_color,onChange:n=>n&&e({background_color:n})})},xy=[{value:"serif",label:"Elegant serif"},{value:"sans_serif",label:"Clean sans-serif"}],_l={sans_serif:{options:[{value:"normal",label:"Regular"},{value:"medium",label:"Medium"},{value:"semibold",label:"Semi-bold"},{value:"bold",label:"Bold"}]},serif:{options:[{value:"normal",label:"Regular"},{value:"bold",label:"Bold"}],map:{medium:"normal",semibold:"bold"}}};function yy(t,e){const n=_l[t]||_l.sans_serif;return n.options.find(r=>r.value===e)?e:n.map?.[e]||"bold"}const vL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Body font"}),u.jsxs(Eo,{value:t.body_font_category||"sans_serif",onValueChange:n=>e({body_font_category:n}),children:[u.jsx(jo,{className:"w-[180px]",children:u.jsx(No,{})}),u.jsx(To,{onEscapeKeyDown:n=>{n.stopPropagation()},children:xy.map(n=>u.jsx($i,{value:n.value,children:n.label},n.value))})]})]})},xL=/^#(?:[0-9a-f]{3}){1,2}$/i,yL=t=>t==="light"?"#ffffff":xL.test(t)?t:"#ffffff",bf=t=>sr(yL(t)).hex(),wL=()=>{const{settings:t,onSettingsChange:e,accentColor:n}=qt(),r=bf(t.background_color);return u.jsx(ps,{accentColor:n,swatches:[{title:"Accent",value:"accent",hex:n},{title:"Auto",value:null,hex:r}],title:"Button color",value:t.button_color,onChange:i=>e({button_color:i})})},kL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Button corners"}),u.jsxs(Hl,{type:"single",value:t.button_corners||"rounded",onValueChange:n=>n&&e({button_corners:n}),children:[u.jsx(Gn,{"aria-label":"Square",value:"square",children:u.jsx("span",{className:"inline-block size-4 border-[1.5px] border-current"})}),u.jsx(Gn,{"aria-label":"Rounded",value:"rounded",children:u.jsx("span",{className:"inline-block size-4 rounded-sm border-[1.5px] border-current"})}),u.jsx(Gn,{"aria-label":"Pill",value:"pill",children:u.jsx("span",{className:"inline-block size-4 rounded-full border-[1.5px] border-current"})})]})]})},SL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Button style"}),u.jsxs(Hl,{type:"single",value:t.button_style||"fill",onValueChange:n=>n&&e({button_style:n}),children:[u.jsx(Gn,{"aria-label":"Fill",value:"fill",children:u.jsx("span",{className:"inline-block h-4 w-5 rounded-sm bg-current"})}),u.jsx(Gn,{"aria-label":"Outline",value:"outline",children:u.jsx("span",{className:"inline-block h-4 w-5 rounded-sm border-[1.5px] border-current"})})]})]})},CL=()=>{const{settings:t,onSettingsChange:e,accentColor:n}=qt();return u.jsx(ps,{accentColor:n,swatches:[{title:"Light",value:null,hex:"#e0e7eb"},{title:"Accent",value:"accent",hex:n}],title:"Divider color",value:t.divider_color,onChange:r=>e({divider_color:r})})},AL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsx(ps,{swatches:[{title:"Transparent",value:"transparent",hex:"#00000000"}],title:"Header background color",value:t.header_background_color,onChange:n=>n&&e({header_background_color:n})})},ML=()=>{const{settings:t,onSettingsChange:e}=qt(),n=r=>{const i=yy(r,t.title_font_weight);e({title_font_category:r,title_font_weight:i})};return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Heading font"}),u.jsxs(Eo,{value:t.title_font_category||"sans_serif",onValueChange:n,children:[u.jsx(jo,{className:"w-[180px]",children:u.jsx(No,{})}),u.jsx(To,{onEscapeKeyDown:r=>{r.stopPropagation()},children:xy.map(r=>u.jsx($i,{value:r.value,children:r.label},r.value))})]})]})},EL=()=>{const{settings:t,onSettingsChange:e}=qt(),n=t.title_font_category||"sans_serif",r=_l[n]?.options||_l.sans_serif.options,i=yy(n,t.title_font_weight);return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Heading weight"}),u.jsxs(Eo,{value:i,onValueChange:s=>e({title_font_weight:s}),children:[u.jsx(jo,{className:"w-[180px]",children:u.jsx(No,{})}),u.jsx(To,{onEscapeKeyDown:s=>{s.stopPropagation()},children:r.map(s=>u.jsx($i,{value:s.value,children:s.label},s.value))})]})]})},jL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Image corners"}),u.jsxs(Hl,{type:"single",value:t.image_corners||"square",onValueChange:n=>n&&e({image_corners:n}),children:[u.jsx(Gn,{"aria-label":"Square",value:"square",children:u.jsx("span",{className:"inline-block size-4 border-[1.5px] border-current"})}),u.jsx(Gn,{"aria-label":"Rounded",value:"rounded",children:u.jsx("span",{className:"inline-block size-4 rounded-sm border-[1.5px] border-current"})})]})]})},NL=()=>{const{settings:t,onSettingsChange:e,accentColor:n}=qt(),r=bf(t.background_color);return u.jsx(ps,{accentColor:n,swatches:[{title:"Accent",value:"accent",hex:n},{title:"Auto",value:null,hex:r}],title:"Link color",value:t.link_color,onChange:i=>e({link_color:i})})},TL=()=>{const{settings:t,onSettingsChange:e}=qt();return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{children:"Link style"}),u.jsxs(Hl,{type:"single",value:t.link_style||"underline",onValueChange:n=>n&&e({link_style:n}),children:[u.jsx(Gn,{"aria-label":"Underline",value:"underline",children:u.jsx(p2,{className:"size-4"})}),u.jsx(Gn,{"aria-label":"Regular",value:"regular",children:u.jsx(g2,{className:"size-4"})}),u.jsx(Gn,{"aria-label":"Bold",value:"bold",children:u.jsx(b2,{className:"size-4"})})]})]})},DL=()=>{const{settings:t,onSettingsChange:e,accentColor:n}=qt(),r=bf(t.background_color);return u.jsx(ps,{accentColor:n,swatches:[{title:"Auto",value:null,hex:r},{title:"Accent",value:"accent",hex:n}],title:"Section title color",value:t.section_title_color,onChange:i=>e({section_title_color:i})})},wy={background_color:"light",title_font_category:"sans_serif",title_font_weight:"bold",body_font_category:"sans_serif",header_background_color:"transparent",section_title_color:null,button_color:"accent",button_style:"fill",button_corners:"rounded",link_color:"accent",link_style:"underline",image_corners:"square",divider_color:null},Ar={free:"member-welcome-email-free",paid:"member-welcome-email-paid"},OL=`{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Welcome! Thanks for subscribing — it's great to have you here.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"You'll now receive new posts straight to your inbox. You can also log in any time to read the ","type":"extended-text","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"full archive","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"link","version":1,"rel":"noreferrer","target":null,"title":null,"url":"__GHOST_URL__/"},{"detail":0,"format":0,"mode":"normal","style":"","text":" or catch up on new posts as they go live.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"A little housekeeping: If this email landed in spam or promotions, try moving it to your primary inbox and adding this address to your contacts. Small signals like that help your inbox recognize that these messages matter to you.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Have questions or just want to say hi? Feel free to reply directly to this email or any newsletter in the future.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}`,IL=`{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Welcome, and thank you for your support — it means a lot.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"As a paid member, you now have full access to everything: the complete archive, and any paid-only content going forward. New posts will land straight to your inbox, and you can log in any time to ","type":"extended-text","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"catch up","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"link","version":1,"rel":"noreferrer","target":null,"title":null,"url":"__GHOST_URL__/"},{"detail":0,"format":0,"mode":"normal","style":"","text":" on anything you've missed.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"A little housekeeping: If this email landed in spam or promotions, try moving it to your primary inbox and adding this address to your contacts. Small signals like that help your inbox recognize that these messages matter to you.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Have questions or just want to say hi? Feel free to reply directly to this email or any newsletter in the future.","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}`,vf=(t,e)=>({name:t==="free"?"Free member welcome flow":"Paid member welcome flow",slug:Ar[t],subject:t==="free"?`Welcome to ${e||"our site"}`:"Welcome to your paid subscription",lexical:t==="free"?OL:IL}),Mg=(t,e)=>({id:"",status:"inactive",...vf(t,e),sender_name:null,sender_email:null,sender_reply_to:null,created_at:"",updated_at:null}),xf=(t,e,n)=>Qd(e)&&!Kg(e)&&n?n:t.sender_email||n||"",PL=(t,e,n,r)=>t.sender_reply_to==="newsletter"?Qd(e)?"":xf(t,e,r):t.sender_reply_to==="support"?n||r||"":t.sender_reply_to,RL=(t,e,n,r)=>{const i=PL(t,e,n,r);return i||(t.sender_reply_to==="newsletter"?xf(t,e,r)||n||r||"":n||r||"")},xr=t=>t?.trim()||"",wu=(...t)=>t.map(xr).find(Boolean)||"",LL=({automatedEmails:t=[],config:e,defaultEmailAddress:n,newsletter:r,siteTitle:i,supportEmailAddress:s})=>{const o=t.find(A=>A.slug===Ar.free),a=t.find(A=>A.slug===Ar.paid),l=wu(o?.sender_name,a?.sender_name),c=wu(o?.sender_email,a?.sender_email),d=wu(o?.sender_reply_to,a?.sender_reply_to),h=xr(r?.sender_name),f=r?xr(xf(r,e,n||void 0)):"",m=r?xr(RL(r,e,s||void 0,n||void 0)):"",p=h||xr(i)||"Your site name",g=f||xr(n),b=m||xr(s)||xr(n),x=l||p,y=c||g||"",w=d||b||"",k=w!==""&&w!==y,C=Qd(e),S=Kg(e);return{hasDistinctReplyTo:k,replyToEmailInput:d,replyToEmailPlaceholder:b,resolvedReplyToEmail:w,resolvedSenderEmail:y,resolvedSenderName:x,senderEmailDomain:S?Vw(e):null,senderEmailInput:c,senderEmailPlaceholder:g,senderNameInput:l,senderNamePlaceholder:p,showSenderEmailInput:!C||S}},ky=(t=[],{config:e,defaultEmailAddress:n,siteTitle:r,supportEmailAddress:i})=>{const{data:s}=$l({searchParams:{filter:"status:active",limit:"1"}}),o=s?.newsletters?.[0];return v.useMemo(()=>LL({automatedEmails:t,config:e,defaultEmailAddress:n,newsletter:o,siteTitle:r,supportEmailAddress:i}),[t,e,n,o,r,i])},Ts="welcome-email-design-save-error",_L=new Set(Object.keys(wy)),Sy=t=>_L.has(t),FL=({generalSettings:t,onGeneralChange:e,showPublicationIconToggle:n,senderNamePlaceholder:r,senderEmailPlaceholder:i,replyToEmailPlaceholder:s,showSenderEmailInput:o,senderNameError:a,senderEmailError:l,replyToEmailError:c})=>u.jsxs("div",{className:"flex flex-col gap-6 pt-6",children:[u.jsxs("section",{children:[u.jsx("h4",{className:"mb-4 font-semibold md:text-lg",children:"Email info"}),u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{className:"font-medium",htmlFor:"welcome-email-sender-name",children:"Sender name"}),u.jsx(_s,{id:"welcome-email-sender-name",placeholder:r,value:t.senderName,onChange:d=>e({senderName:d.target.value})}),a?u.jsx("p",{className:"text-sm text-red",children:a}):null]}),o?u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{className:"font-medium",htmlFor:"welcome-email-sender-email",children:"Sender email"}),u.jsx(_s,{id:"welcome-email-sender-email",placeholder:i,value:t.senderEmail,onChange:d=>e({senderEmail:d.target.value})}),l?u.jsx("p",{className:"text-sm text-red",children:l}):null]}):null,u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{className:"font-medium",htmlFor:"welcome-email-reply-to-email",children:"Reply-to email"}),u.jsx(_s,{id:"welcome-email-reply-to-email",placeholder:s,value:t.replyToEmail,onChange:d=>e({replyToEmail:d.target.value})}),c?u.jsx("p",{className:"text-sm text-red",children:c}):null]})]})]}),u.jsx(Nu,{}),u.jsxs("section",{children:[u.jsx("h4",{className:"mb-4 font-semibold md:text-lg",children:"Content"}),u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx(aL,{value:t.headerImage,onChange:d=>e({headerImage:d})}),n&&u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"font-medium",children:"Publication icon"}),u.jsx(ju,{checked:t.showPublicationIcon,size:"sm",onCheckedChange:d=>e({showPublicationIcon:d})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"font-medium",children:"Publication title"}),u.jsx(ju,{checked:t.showPublicationTitle,size:"sm",onCheckedChange:d=>e({showPublicationTitle:d})})]}),u.jsxs("div",{className:"mt-2 flex flex-col gap-1.5",children:[u.jsx("label",{className:"font-medium",htmlFor:"welcome-email-footer",children:"Email footer"}),u.jsx(v2,{id:"welcome-email-footer",placeholder:"Any extra information or legal text",rows:3,value:t.emailFooter,onChange:d=>e({emailFooter:d.target.value})})]}),u.jsx(lL,{value:t.showBadge,onChange:d=>e({showBadge:d})})]})]})]}),BL=()=>u.jsxs("div",{className:"flex flex-col gap-6 pt-6",children:[u.jsxs("section",{children:[u.jsx("h4",{className:"mb-4 font-semibold md:text-lg",children:"Global"}),u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx(bL,{}),u.jsx(ML,{}),u.jsx(EL,{}),u.jsx(vL,{})]})]}),u.jsx(Nu,{}),u.jsxs("section",{children:[u.jsx("h4",{className:"mb-4 font-semibold md:text-lg",children:"Header"}),u.jsx("div",{className:"flex flex-col gap-4",children:u.jsx(AL,{})})]}),u.jsx(Nu,{}),u.jsxs("section",{children:[u.jsx("h4",{className:"mb-4 font-semibold md:text-lg",children:"Body"}),u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx(DL,{}),u.jsx(wL,{}),u.jsx(SL,{}),u.jsx(kL,{}),u.jsx(NL,{}),u.jsx(TL,{}),u.jsx(jL,{}),u.jsx(CL,{})]})]})]}),VL=({generalSettings:t,onGeneralChange:e,showPublicationIconToggle:n,senderNamePlaceholder:r,senderEmailPlaceholder:i,replyToEmailPlaceholder:s,showSenderEmailInput:o,senderNameError:a,senderEmailError:l,replyToEmailError:c,isLoading:d,errorMessage:h})=>u.jsxs(th,{className:"flex min-h-0 flex-1 flex-col",defaultValue:"general",variant:"underline",children:[u.jsxs(nh,{className:"px-5",children:[u.jsx(zi,{value:"general",children:"General"}),u.jsx(zi,{value:"design",children:"Design"})]}),d?u.jsx("div",{className:"flex flex-1 items-center justify-center",children:u.jsx(zw,{size:"md"})}):h?u.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-center text-gray-700 dark:text-gray-300",children:h}):u.jsxs(u.Fragment,{children:[u.jsx(qa,{className:"min-h-0 flex-1 overflow-y-auto px-5 pb-5",value:"general",children:u.jsx(FL,{generalSettings:t,replyToEmailError:c,replyToEmailPlaceholder:s,senderEmailError:l,senderEmailPlaceholder:i,senderNameError:a,senderNamePlaceholder:r,showPublicationIconToggle:n,showSenderEmailInput:o,onGeneralChange:e})}),u.jsx(qa,{className:"min-h-0 flex-1 overflow-y-auto px-5 pb-5",value:"design",children:u.jsx(BL,{})})]})]});function zL(t,e){return{senderName:e.senderName,senderEmail:e.senderEmail,replyToEmail:e.replyToEmail,headerImage:t.header_image||"",showPublicationIcon:t.show_header_icon,showPublicationTitle:t.show_header_title,showBadge:t.show_badge,emailFooter:t.footer_content||""}}function $L(t){return Object.fromEntries(Object.entries(t).filter(([e])=>Sy(e)))}function HL(t){return{...Object.fromEntries(Object.entries(t.designSettings).filter(([n])=>Sy(n))),header_image:t.generalSettings.headerImage||null,show_header_icon:t.generalSettings.showPublicationIcon,show_header_title:t.generalSettings.showPublicationTitle,show_badge:t.generalSettings.showBadge,footer_content:t.generalSettings.emailFooter||null}}const UL=({message:t})=>u.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-gray-700 dark:text-gray-300",children:t}),ku=t=>t?.trim()||""||null,Cy=pe.create(()=>{const t=an(),{siteData:e,settings:n,config:r}=ke(),[i,s,o,a]=we(n,["title","default_email_address","icon","support_email_address"]),l=Ye(),{data:c,isLoading:d,isError:h}=hL(),{data:f}=eh(),{mutateAsync:m}=fL(),{mutateAsync:p}=Yg(),{mutateAsync:g}=e2(),b=ea("automations"),[x,y]=v.useState(!1),[w,k]=v.useState(!1),C=f?.automated_emails||[],{senderNameInput:S,senderEmailInput:A,replyToEmailInput:M,senderNamePlaceholder:E,senderEmailPlaceholder:j,replyToEmailPlaceholder:T,showSenderEmailInput:N,senderEmailDomain:D}=ky(C,{config:r,defaultEmailAddress:s,siteTitle:i,supportEmailAddress:a}),O=v.useMemo(()=>({senderName:S,senderEmail:A,replyToEmail:M,headerImage:"",showPublicationIcon:!0,showPublicationTitle:!0,showBadge:!0,emailFooter:""}),[M,A,S]),L=v.useCallback(async()=>{const de=new Map((f?.automated_emails||[]).map(he=>[he.slug,he]));for(const he of["free","paid"]){if(de.has(Ar[he]))continue;const _e=vf(he,i),Mt=(await p({..._e,status:"inactive"})).automated_emails?.[0];Mt&&de.set(Mt.slug,Mt)}},[p,f?.automated_emails,i]),{formState:$,saveState:U,updateForm:q,setFormState:_,handleSave:te,okProps:ce,errors:G}=zl({initialState:{designSettings:{...wy},generalSettings:O},savingDelay:500,onSave:async de=>{if(!Y)throw pi.error("Unable to load email design settings. Please try again.",{id:Ts}),y(!0),new Error("Unable to load email design settings");b||await L();const he={sender_name:ku(de.generalSettings.senderName),sender_reply_to:ku(de.generalSettings.replyToEmail),...N?{sender_email:ku(de.generalSettings.senderEmail)}:{}},{meta:{sent_email_verification:_e=[]}={}}=await g(he);await m(HL(de)),_e.length>0&&pi.info("We’ve sent a confirmation email to the new address."),y(!1),pi.dismiss(Ts)},onSaveError:de=>{l(de,{withToast:!1}),pi.error("Unable to save email design settings. Please try again.",{id:Ts}),y(!0)},onValidate:de=>{const he={},_e=de.generalSettings.senderEmail?.trim(),At=de.generalSettings.replyToEmail?.trim();return N&&_e&&(wt.isEmail(_e)?D&&_e.split("@")[1]?.toLowerCase()!==D.toLowerCase()&&(he.senderEmail=`Email address must end with @${D}`):he.senderEmail="Enter a valid email address"),At&&!wt.isEmail(At)&&(he.replyToEmail="Enter a valid email address"),he}}),[oe,B]=v.useState(null),Y=c?.automated_email_design?.[0],ee=Y?`${Y.id}:${Y.updated_at??"initial"}`:null,{designSettings:ae,generalSettings:ue}=$;v.useEffect(()=>{Y&&oe===null&&(_(de=>({designSettings:$L(Y),generalSettings:zL(Y,de.generalSettings)})),B(ee))},[Y,ee,oe,_]),v.useEffect(()=>{w||f===void 0||(_(de=>({...de,generalSettings:{...de.generalSettings,senderName:S,senderEmail:A,replyToEmail:M}})),k(!0))},[f,M,A,w,S,_]);const ve=v.useCallback(de=>{y(!1),pi.dismiss(Ts),q(he=>({...he,designSettings:{...he.designSettings,...de}}))},[q]),X=v.useCallback(de=>{y(!1),pi.dismiss(Ts),q(he=>({...he,generalSettings:{...he.generalSettings,...de}}))},[q]),se=v.useCallback(()=>{t.hide()},[t]),ie="Unable to load email design settings. Please try again.",Ne=x?{...ce,color:"red",label:"Retry"}:ce;return u.jsx(uL,{accentColor:e.accent_color,settings:ae,onSettingsChange:ve,children:u.jsx(RR,{afterClose:()=>{t.resolveHide(),t.remove()},dirty:U==="unsaved",isLoading:d||h,okProps:Ne,open:t.visible,preview:h?u.jsx(UL,{message:ie}):u.jsx(oL,{accentColor:e.accent_color,emailFooter:ue.emailFooter,footerLinkText:"Manage your preferences",headerImage:ue.headerImage,publicationIcon:o,replyToEmail:ue.replyToEmail||T||"",senderEmail:ue.senderEmail||j||s||"",senderName:ue.senderName||E||i||"Your site",settings:ae,showBadge:ue.showBadge,showPublicationIcon:ue.showPublicationIcon&&!!o,showPublicationTitle:ue.showPublicationTitle,showRecipientLine:!1,showSubjectLine:!1,siteTitle:i,subject:`Welcome to ${ue.senderName||E||i||"our publication"}`,children:u.jsx(dL,{})}),sidebar:u.jsx(VL,{errorMessage:h?ie:void 0,generalSettings:ue,isLoading:d,replyToEmailError:G.replyToEmail,replyToEmailPlaceholder:T,senderEmailError:G.senderEmail,senderEmailPlaceholder:j,senderNameError:G.senderName,senderNamePlaceholder:E,showPublicationIconToggle:!!o,showSenderEmailInput:N,onGeneralChange:X}),testId:"welcome-email-customize-modal",title:"Welcome emails",onClose:se,onSave:()=>te({fakeWhenUnchanged:!0})})})}),Ln={enableNewsletters:["emails","newsletters","newsletter sending","enable","disable","turn on","turn off"],emails:["emails","newsletters","automation emails","transactional","design","customization","automations","welcome"],defaultRecipients:["newsletters","default recipients","emails"],mailgun:["mailgun","emails","newsletters"]},WL=()=>{const t=()=>{pe.show(Cy)};return u.jsx(Mr,{children:u.jsx(ls,{action:u.jsx("button",{className:"font-semibold text-green hover:opacity-80",type:"button",onClick:t,children:"Edit"}),hideActions:!1,testId:"automations-transactional-row",children:u.jsxs("button",{className:"flex w-full min-w-0 items-center gap-3 py-3 text-left focus-visible:ring-2 focus-visible:ring-green focus-visible:ring-offset-2 focus-visible:outline-none dark:focus-visible:ring-offset-black",type:"button",onClick:t,children:[u.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-grey-100 dark:bg-grey-900",children:u.jsx(me,{colorClass:"text-grey-700 dark:text-grey-600",name:"mailplus",size:"md"})}),u.jsxs("div",{className:"min-w-0 grow",children:[u.jsx("div",{className:"leading-tight font-medium",children:"Email design"}),u.jsx("div",{className:"mt-1 text-sm leading-[1.35] text-grey-700 dark:text-grey-600",children:"Customize the appearance of automation emails"})]})]})})})},KL=()=>{const t=window.location.hash.slice(1);return new URL(t||"/",window.location.origin).pathname.startsWith("/settings/memberemails")},GL=({keywords:t,newslettersEnabled:e})=>{const{updateRoute:n}=fe(),r=Qo().getParam("verifyEmail"),{mutateAsync:i}=Xg(),s=Ye(),o=v.useRef(null),[a,l]=v.useState(e?"newsletters":"transactional"),[c,d]=v.useState("active");v.useEffect(()=>{!e&&a==="newsletters"&&l("transactional")},[e,a]),v.useEffect(()=>{if(!r||!KL()||o.current===r)return;o.current=r,l("transactional"),(async()=>{try{const{meta:{email_verified:p}={}}=await i({token:r});let g="Sender email verified",b=u.jsx(u.Fragment,{children:"Automation email sender settings have been updated."});p==="sender_reply_to"&&(g="Reply-to address verified",b=u.jsx(u.Fragment,{children:"Automation email reply-to address has been verified and updated."})),n("emails"),pe.show(Wt,{title:g,prompt:b,okLabel:"Close",cancelLabel:"",onOk:x=>x?.remove()})}catch(p){let g="There was an error verifying your email address. Try again later.";p instanceof Vl&&p.message==="Token expired"&&(g="Verification link has expired."),n("emails"),pe.show(Wt,{title:"Error verifying email address",prompt:g,okLabel:"Close",cancelLabel:"",onOk:b=>b?.remove()}),s(p,{withToast:!1})}})()},[s,n,r,i]);const h=()=>{n("newsletters/new")},f=e&&a==="newsletters"?u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Add newsletter",size:"sm",onClick:h}):void 0;return u.jsx(Se,{customButtons:f,description:"Manage newsletters and design automation emails.",keywords:t,navid:"emails",testId:"emails",title:"Newsletters & automation emails",children:u.jsxs(th,{value:a,variant:"underline",onValueChange:m=>l(m),children:[u.jsxs("div",{className:"flex items-center justify-between border-b border-grey-200 dark:border-grey-900",children:[u.jsxs(nh,{className:"border-b-0",children:[e&&u.jsx(zi,{value:"newsletters",children:"Newsletters"}),u.jsx(zi,{value:"transactional",children:"Automation emails"})]}),e&&a==="newsletters"&&u.jsxs(Eo,{value:c,onValueChange:m=>d(m),children:[u.jsx(jo,{className:"h-7 w-auto gap-1 border-0 bg-transparent px-2 text-sm shadow-none hover:bg-muted focus:ring-0 focus:ring-offset-0","data-testid":"newsletters-filter",children:u.jsx(No,{})}),u.jsxs(To,{children:[u.jsx($i,{value:"active",children:"Active"}),u.jsx($i,{value:"archived",children:"Archived"})]})]})]}),e&&u.jsx(qa,{value:"newsletters",children:u.jsx(OR,{filter:c})}),u.jsx(qa,{value:"transactional",children:u.jsx(WL,{})})]})})},qL=()=>{const{settings:t,config:e}=ke(),[n]=we(t,["editor_default_email_recipients"]),r=n!=="disabled",i=r&&!e.mailgunIsConfigured,s=[Ln.enableNewsletters,...r?[Ln.defaultRecipients]:[],Ln.emails,...i?[Ln.mailgun]:[]].flat();return u.jsxs(ui,{keywords:s,title:"Email",children:[u.jsx(dy,{keywords:Ln.enableNewsletters}),r&&u.jsx(uy,{keywords:Ln.defaultRecipients}),u.jsx(GL,{keywords:Ln.emails,newslettersEnabled:r}),i&&u.jsx(hy,{keywords:Ln.mailgun})]})},YL=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,handleEditingChange:a}=Ft(),[l,c,d,h,f,m]=we(e,["email_track_opens","email_track_clicks","members_track_sources","outbound_link_tagging","web_analytics","web_analytics_configured"]),p=Tu(e,"email_track_clicks"),[g,b]=v.useState(!1),x=fs(),{updateRoute:y}=fe();v.useEffect(()=>{x?.isLimited("limitAnalytics")?x.errorIfWouldGoOverLimit("limitAnalytics").catch(S=>{S instanceof Zo&&b(!0)}):b(!1)},[x]);const w=(S,A)=>{o(S,A.target.checked),a(!0)},k=m&&!g,C=u.jsxs(tt,{className:"analytics-settings gap-y-0!",columns:1,children:[u.jsx(en,{align:"center",checked:f&&k,containerClasses:"py-4",direction:"rtl",disabled:!k,gap:"gap-0",hint:m?u.jsxs(u.Fragment,{children:["Cookie-free, first party traffic analytics for your site, powered by ",u.jsx("a",{className:"text-green",href:"https://ghost.org/integrations/tinybird",rel:"noopener noreferrer",target:"_blank",children:"Tinybird"})]}):u.jsx(u.Fragment,{children:"Cookie-free, first party traffic analytics for your site"}),label:"Web analytics",onChange:S=>{w("web_analytics",S)}}),g?u.jsx("div",{className:"mb-5 rounded-md border border-grey-200 bg-grey-50 px-4 py-2.5 dark:border-grey-900 dark:bg-grey-900",children:u.jsx("span",{className:"flex items-start gap-2",children:u.jsxs("span",{children:["Web analytics is available on the Publisher plan and above. ",u.jsx("span",{className:"cursor-pointer text-green",onClick:()=>y({route:"/pro",isExternal:!0}),children:"Upgrade now →"})]})})}):m?u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}):u.jsx("div",{className:"mb-5 rounded-md border border-grey-200 bg-grey-50 px-4 py-2.5 dark:border-grey-900 dark:bg-grey-900",children:u.jsx("span",{className:"flex items-start gap-2",children:u.jsxs("span",{children:["Web analytics in Ghost is powered by ",u.jsx("a",{className:"font-medium text-green",href:"https://tbrd.co/ghost",rel:"noopener noreferrer",target:"_blank",children:"Tinybird"})," and requires configuration to start collecting data. ",u.jsx("a",{className:"font-medium text-green",href:"https://docs.ghost.org/install/docker#tinybird-integration",rel:"noopener noreferrer",target:"_blank",children:"Get started →"})]})})}),u.jsx(en,{align:"center",checked:l,containerClasses:"py-4",direction:"rtl",gap:"gap-0",hint:"Record when a member opens an email",label:"Newsletter opens",onChange:S=>{w("email_track_opens",S)}}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsx(en,{align:"center",checked:c,containerClasses:"py-4",direction:"rtl",disabled:p,gap:"gap-0",hint:"Record when a member clicks on any link in an email",label:"Newsletter clicks",onChange:S=>{w("email_track_clicks",S)}}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsx(en,{align:"center",checked:d,containerClasses:"py-4",direction:"rtl",gap:"gap-0",hint:"Track the traffic sources and posts that drive the most member growth",label:"Member sources",onChange:S=>{w("members_track_sources",S)}}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsx(en,{align:"center",checked:h,containerClasses:"py-4",direction:"rtl",gap:"gap-0",hint:"Make it easier for other sites to track the traffic you send them in their analytics",label:"Outbound link tagging",onChange:S=>{w("outbound_link_tagging",S)}})]});return u.jsxs(Se,{description:"Decide what data you collect across your publication",isEditing:n,keywords:t,navid:"analytics",saveState:r,testId:"analytics",title:"Analytics",hideEditButton:!0,onCancel:s,onEditingChange:a,onSave:i,children:[C,u.jsx("div",{className:"items-center-mt-1 flex justify-between",children:u.jsx("a",{className:"font-medium text-green",href:"https://ghost.org/help/post-analytics/",rel:"noopener noreferrer",target:"_blank",children:"Learn about analytics"})})]})},XL=Ce(YL,"Analytics"),JL=[{code:"af",label:"Afrikaans"},{code:"ar",label:"Arabic"},{code:"bg",label:"Bulgarian"},{code:"bn",label:"Bengali"},{code:"bs",label:"Bosnian"},{code:"ca",label:"Catalan"},{code:"cs",label:"Czech"},{code:"da",label:"Danish"},{code:"de",label:"German"},{code:"de-CH",label:"Swiss German"},{code:"el",label:"Greek"},{code:"en",label:"English"},{code:"eo",label:"Esperanto"},{code:"es",label:"Spanish"},{code:"et",label:"Estonian"},{code:"eu",label:"Basque"},{code:"fa",label:"Persian/Farsi"},{code:"fi",label:"Finnish"},{code:"fr",label:"French"},{code:"gd",label:"Gaelic (Scottish)"},{code:"he",label:"Hebrew"},{code:"hi",label:"Hindi"},{code:"hr",label:"Croatian"},{code:"hu",label:"Hungarian"},{code:"id",label:"Indonesian"},{code:"is",label:"Icelandic"},{code:"it",label:"Italian"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"kz",label:"Kazakh"},{code:"lt",label:"Lithuanian"},{code:"lv",label:"Latvian"},{code:"mk",label:"Macedonian"},{code:"mn",label:"Mongolian"},{code:"ms",label:"Malay"},{code:"nb",label:"Norwegian Bokmål"},{code:"ne",label:"Nepali"},{code:"nl",label:"Dutch"},{code:"nn",label:"Norwegian Nynorsk"},{code:"pa",label:"Punjabi"},{code:"pl",label:"Polish"},{code:"pt",label:"Portuguese"},{code:"pt-BR",label:"Portuguese (Brazil)"},{code:"ro",label:"Romanian"},{code:"ru",label:"Russian"},{code:"si",label:"Sinhala"},{code:"sk",label:"Slovak"},{code:"sl",label:"Slovenian"},{code:"sq",label:"Albanian"},{code:"sr",label:"Serbian"},{code:"sr-Cyrl",label:"Serbian (Cyrillic)"},{code:"sv",label:"Swedish"},{code:"sw",label:"Swahili"},{code:"ta",label:"Tamil"},{code:"th",label:"Thai"},{code:"tr",label:"Turkish"},{code:"uk",label:"Ukrainian"},{code:"ur",label:"Urdu"},{code:"uz",label:"Uzbek"},{code:"vi",label:"Vietnamese"},{code:"zh",label:"Chinese"},{code:"zh-Hant",label:"Traditional Chinese"}],ZL=new Set(["en-gb-oed","i-ami","i-bnn","i-default","i-enochian","i-hak","i-klingon","i-lux","i-mingo","i-navajo","i-pwn","i-tao","i-tay","i-tsu","sgn-be-fr","sgn-be-nl","sgn-ch-de","art-lojban","cel-gaulish","no-bok","no-nyn","zh-guoyu","zh-hakka","zh-min","zh-min-nan","zh-xiang"]),Eg=t=>{const e="Invalid locale format. Examples: en, pt-BR, zh-Hant, sr-Cyrl, x-private";if(!t)return"Enter a value";const n=t.trim();if(!n)return e;if(ZL.has(n.toLowerCase()))return null;if(!/^[a-z0-9]+(-[a-z0-9]+)*$/i.test(n))return e;const r=n.split("-");if(r[0].toLowerCase()==="x"){if(r.length<2)return e;for(let l=1;l<r.length;l++)if(r[l].length<1||r[l].length>8)return e;return null}let i=0;const s=r[i];if(!/^[a-z]{2,3}$/i.test(s))return e;for(i+=1,i<r.length&&/^[a-z]{4}$/i.test(r[i])&&(i+=1),i<r.length&&/^([a-z]{2}|[0-9]{3})$/i.test(r[i])&&(i+=1);i<r.length&&/^([a-z0-9]{5,8}|[0-9][a-z0-9]{3})$/i.test(r[i]);)i+=1;for(;i<r.length&&/^[0-9a-wy-z]$/i.test(r[i]);){if(i+=1,i>=r.length||!/^[a-z0-9]{2,8}$/i.test(r[i]))return e;for(i+=1;i<r.length&&/^[a-z0-9]{2,8}$/i.test(r[i]);)i+=1}if(i<r.length&&r[i].toLowerCase()==="x"){if(i+=1,i>=r.length)return e;for(;i<r.length;){if(!/^[a-z0-9]+$/i.test(r[i]))return e;i+=1}}if(i!==r.length)return e;const o=r.findIndex(l=>l.toLowerCase()==="x"),a=["english","french","spanish","german","italian","chinese","japanese","korean","russian","arabic","united","states","kingdom","traditional","simplified"];for(let l=0;l<r.length;l++){const c=r[l];if(!["i","x","sgn","art","cel","no","zh"].includes(c.toLowerCase())&&!(o!==-1&&l>o)&&(c.length>16||a.includes(c.toLowerCase())))return e}return null},QL=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,errors:a,handleEditingChange:l}=Ft({onValidate:()=>{const m=Eg(c);return m?{publicationLanguage:m}:{}}}),[c]=we(e,["locale"]),d=W.useMemo(()=>JL.map(p=>({value:p.code,label:`${p.label} (${p.code})`})),[]),h=m=>{o("locale",m),n||l(!0)},f=u.jsxs(u.Fragment,{children:["Default: English (",u.jsx("strong",{children:"en"}),"); find out more about",u.jsx("a",{className:"text-green-400",href:"https://ghost.org/docs/faq/translation/",rel:"noopener noreferrer",target:"_blank",children:" using Ghost in other languages"})]});return u.jsx(Se,{description:"Set the language/locale which is used on your site",isEditing:n,keywords:t,navid:"publication-language",saveState:r,testId:"publication-language",title:"Publication Language",hideEditButton:!0,onCancel:s,onEditingChange:l,onSave:i,children:u.jsx(tt,{columns:1,children:u.jsx(T5,{defaultListValue:"en",error:!!a.publicationLanguage,hint:a.publicationLanguage||f,options:d,otherHint:"Enter a custom locale code.",otherPlaceholder:"e.g. pt-BR, sr-Cyrl, en",selectedValue:c,testId:"locale-select",title:"Site language",validate:Eg,isSearchable:!0,onSelect:h})})})},e6=Ce(QL,"Publication language"),t6=({title:t,description:e,icon:n,url:r})=>{const i=r?.replace(/\/$/,""),s=i?.replace(/^https?:\/\//,"").replace(/\/?$/,"");return u.jsx("div",{children:u.jsxs("div",{className:"-mx-5 -mb-5 overflow-hidden rounded-b-xl bg-grey-50 px-5 pt-2 md:-mx-7 md:-mb-7 md:px-7 md:pt-7 dark:bg-grey-950",children:[u.jsx("div",{className:"-mt-4 mb-2 text-sm text-grey-500 uppercase dark:text-grey-800",children:"Preview"}),u.jsxs("div",{className:"rounded-t-sm bg-white px-5 py-3 shadow-lg dark:bg-grey-950",children:[u.jsxs("div",{className:"mt-3 flex items-center",children:[u.jsx("div",{children:u.jsx(cE,{className:"mr-7 h-7"})}),u.jsx("div",{className:"grow",children:u.jsx("div",{className:"flex w-full items-center justify-end rounded-full bg-white p-3 px-4 shadow dark:bg-grey-900",children:u.jsx(me,{className:"stroke-[2px] text-blue-600",name:"magnifying-glass",size:"sm"})})})]}),u.jsxs("div",{className:"mt-4 flex items-center gap-2 border-t border-grey-200 pt-4 dark:border-grey-900",children:[u.jsx("div",{className:"flex size-7 items-center justify-center rounded-full bg-grey-200 dark:bg-grey-700",style:{backgroundImage:n?`url(${n})`:"none",backgroundSize:"contain"}}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{children:s}),u.jsx("span",{className:"-mt-0.5 inline-block text-sm text-grey-600",children:i})]})]}),u.jsxs("div",{className:"mt-1 flex flex-col",children:[u.jsx("span",{className:"text-lg text-[#1a0dab] dark:text-blue",children:t}),u.jsx("span",{className:"text-grey-900 dark:text-grey-700",children:e})]})]})]})})},n6=({keywords:t})=>{const{localSettings:e,saveState:n,siteData:r,focusRef:i,isEditing:s,handleSave:o,handleCancel:a,handleEditingChange:l,updateSetting:c}=Ft(),d=Ye(),{mutateAsync:h}=gy(),f=oy(),m=ea("llmsTxt"),[p,g,b,x,y,w,k,C,S,A]=we(e,["meta_title","meta_description","title","description","og_title","og_description","og_image","twitter_title","twitter_description","twitter_image"]).map(X=>X||""),[M]=we(e,["llms_enabled"]),E=M!==!1,[j,T]=v.useState("metadata"),N=X=>se=>{c(X,se.target.value),s||l(!0)},D=X=>async se=>{try{const ie=Ga(await h({file:se}));c(X,ie),s||l(!0)}catch(ie){const Ne=ie;Ne.response.status===415&&(Ne.message="Unsupported file type"),d(Ne)}},O=X=>()=>{c(X,""),s||l(!0)},L=X=>{c("llms_enabled",X.target.checked),s||l(!0)},$=N("meta_title"),U=N("meta_description"),q=N("og_title"),_=N("og_description"),te=D("og_image"),ce=O("og_image"),G=N("twitter_title"),oe=N("twitter_description"),B=D("twitter_image"),Y=O("twitter_image"),ee=u.jsxs(u.Fragment,{children:[u.jsxs(tt,{className:"my-6 gap-3",children:[m&&u.jsx(en,{checked:E,direction:"rtl",label:"Enable structured data for LLMs and AI search engines",onChange:L}),u.jsx(at,{hint:"Recommended: 70 characters",inputRef:i,maxLength:300,placeholder:b,title:"Meta title",value:p,onChange:$}),u.jsx(at,{hint:"Recommended: 156 characters",maxLength:500,placeholder:x,title:"Meta description",value:g,onChange:U})]}),u.jsx(t6,{description:g||x,icon:r?.icon,title:p||b,url:r?.url})]}),ae=u.jsxs("div",{className:"mt-6 md:mx-[52px]",children:[u.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[u.jsx("div",{children:u.jsx(lE,{className:"size-10"})}),u.jsxs("div",{children:[u.jsx("div",{className:"mb-1 leading-none font-semibold text-grey-900 dark:text-grey-300",children:b}),u.jsx("div",{className:"leading-none text-grey-700",children:"2h"})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"mb-2 h-3 w-full rounded bg-grey-200 dark:bg-grey-900"}),u.jsx("div",{className:"mb-4 h-3 w-3/5 rounded bg-grey-200 dark:bg-grey-900"}),u.jsxs(tt,{className:"overflow-hidden rounded-md border border-grey-300 dark:border-grey-900",children:[u.jsx(Of,{fileUploadClassName:"flex cursor-pointer items-center justify-center rounded rounded-b-none border border-grey-100 border-b-0 bg-grey-50 p-3 font-semibold text-grey-800 hover:text-black dark:border-grey-900",height:"300px",id:"facebook-image",imageURL:k,pintura:{isEnabled:f.isEnabled,openEditor:async()=>f.openEditor({image:k||"",handleSave:async X=>{const se=Ga(await h({file:X}));c("og_image",se)}})},onDelete:ce,onUpload:te,children:"Upload Facebook image"}),u.jsxs("div",{className:"mt-5 flex flex-col gap-x-6 gap-y-7 px-4 pb-7",children:[u.jsx(at,{maxLength:300,placeholder:b,title:"Facebook title",value:y,onChange:q}),u.jsx(at,{maxLength:300,placeholder:x,title:"Facebook description",value:w,onChange:_})]})]})]})]}),ue=u.jsxs("div",{className:"mt-6 flex flex-col gap-3 md:flex-row",children:[u.jsx("div",{className:"pt-1",children:u.jsx(uE,{className:"-mb-1 size-10"})}),u.jsxs("div",{className:"w-full md:mr-[52px]",children:[u.jsxs("div",{className:"mb-2",children:[u.jsx("span",{className:"mr-1 font-semibold text-grey-900 dark:text-grey-300",children:b}),u.jsx("span",{className:"text-grey-700",children:"· 2h"})]}),u.jsx("div",{className:"mb-2 h-3 w-full rounded bg-grey-200 dark:bg-grey-900"}),u.jsx("div",{className:"mb-4 h-3 w-3/5 rounded bg-grey-200 dark:bg-grey-900"}),u.jsxs(tt,{className:"overflow-hidden rounded-md border border-grey-300 dark:border-grey-900",children:[u.jsx(Of,{fileUploadClassName:"flex cursor-pointer items-center justify-center rounded rounded-b-none border border-grey-100 border-b-0 bg-grey-50 p-3 font-semibold text-grey-800 hover:text-black dark:border-grey-900",height:"300px",id:"twitter-image",imageURL:A,pintura:{isEnabled:f.isEnabled,openEditor:async()=>f.openEditor({image:A||"",handleSave:async X=>{const se=Ga(await h({file:X}));c("twitter_image",se)}})},onDelete:Y,onUpload:B,children:"Upload X image"}),u.jsxs("div",{className:"mt-6 flex flex-col gap-x-6 gap-y-7 px-4 pb-7",children:[u.jsx(at,{maxLength:300,placeholder:b,title:"X title",value:C,onChange:G}),u.jsx(at,{maxLength:300,placeholder:x,title:"X description",value:S,onChange:oe})]})]})]})]}),ve=[{id:"metadata",title:"Search",contents:ee},{id:"twitter",title:"X card",contents:ue},{id:"facebook",title:"Facebook card",contents:ae}];return u.jsx(Se,{description:"Extra content for search engines and social accounts",isEditing:s,keywords:t,navid:"metadata",saveState:n,testId:"seometa",title:"Meta data",hideEditButton:!0,onCancel:a,onEditingChange:l,onSave:o,children:u.jsx(hr,{selectedTab:j,tabs:ve,testId:"seo-tabview",onTabChange:T})})},r6=Ce(n6,"SEO meta");function i6(t){const e="The URL must be in a format like https://www.facebook.com/yourPage";if(!t)return"";if(t=t.replace(/(https?:\/\/)?(www\.)?facebook\.com/i,""),t.match(/^(http|\/\/)/i))throw new Error(e);if(t=t.replace(/^\//,""),t=`https://www.facebook.com/${t}`,!wt.isURL(t))throw new Error(e);return t}const s6=t=>`https://www.facebook.com/${t}`,o6=t=>t.match(/(?:https:\/\/)(?:www\.)(?:facebook\.com)\/(?:#!\/)?(\w+\/?\S+)/i)?.[1]||null,Su=/^x\.com\/([a-zA-Z0-9_]{1,15})$/;function a6(t){if(!t)return"";if(t.match(Su)||t.match(/([a-z\d.]+)/i)){let e=[];if(t.match(Su)?[,e]=t.match(Su):[e]=t.match(/([^/]+)\/?$/i),e.startsWith("@")&&(e=e.slice(1)),!e.match(/^[a-z\d_]{1,15}$/i))throw new Error("Your Username is not a valid Twitter Username");return`https://x.com/${e}`}else{const e="The URL must be in a format like https://x.com/yourUsername";throw new Error(e)}}const l6=t=>`https://x.com/${t.replace("@","")}`,c6=t=>{const e=t.match(/(?:https:\/\/)(?:x\.com)\/(?:#!\/)?@?([^/]*)/)?.[1];return e?`@${e}`:null};function u6(t){const e="The URL must be in a format like https://www.threads.net/@yourUsername";if(!t)return"";if(t.startsWith("http")){if(!t.includes("threads.net")&&!t.includes("threads.com"))throw new Error(e);if(t=t.replace("threads.com","threads.net"),t.includes("www.")||(t=t.replace("https://","https://www.")),!wt.isURL(t))throw new Error(e);if(!t.match(/^https:\/\/www\.threads\.net\/@?[a-zA-Z0-9._]+$/))throw new Error(e);return t}if(!t.includes("/")){if(t.startsWith("@")&&(t=t.slice(1)),!t.match(/^[a-zA-Z0-9._]+$/))throw new Error(e);return`https://www.threads.net/@${t}`}throw new Error(e)}const d6=t=>`https://www.threads.net/${t}`,h6=t=>{const e=t.match(/(?:https:\/\/)(?:www\.)?(?:threads\.(?:com|net))(?:\/)?(?:#!\/)?@?([^/]*)/)?.[1];return e?`@${e}`:null},Ei={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 Ay(t){return[/^did:plc:[a-z2-7]{24}$/,/^[a-zA-Z0-9._]{1,15}$/,/^(?=.{1,191}$)[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$/].some(n=>n.test(t))}function Gd(t){let e=t.trim();return e.startsWith("@")&&(e=e.slice(1)),e.startsWith("did:plc:")?e.toLowerCase():e}function f6(t){if(!t)return"";let e;if(t.startsWith("http")||t.startsWith("www.")||t.includes("bsky.app")){if(!t.includes("bsky.app"))throw new Error(Ei.INVALID_URL);const r=t.match(/bsky\.app\/profile\/@?([^/]+)/);if(!r)throw new Error(Ei.INVALID_URL);e=Gd(r[1])}else e=Gd(t);if(!Ay(e))throw new Error(Ei.INVALID_USERNAME);const n=`https://bsky.app/profile/${e}`;if(!wt.isURL(n))throw new Error(Ei.INVALID_URL);return n}const m6=t=>{if(!t)throw new Error(Ei.INVALID_USERNAME);const e=Gd(t);if(!Ay(e))throw new Error(Ei.INVALID_USERNAME);return`https://bsky.app/profile/${e}`},p6=t=>{const e=t.match(/(?:https?:\/\/)?(?:www\.)?bsky\.app\/profile\/@?([^/]*)/);return e?`${e[1]}`:null},ti={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"},g6=["in","pub","company","school"],b6=/^[a-zA-Z0-9-]{3,100}$/,v6=/^[a-zA-Z0-9-]{3,100}(?:\/[a-zA-Z0-9-]*)*$/,My=/^(?:https?:\/\/)?(?:www\.)?(?:([a-z]{2})\.)?linkedin\.com\/(in|pub|company|school)\/([^?#]+)/i,qd=t=>t.trim().replace(/^@/,"").replace(/\/$/,""),Ey=t=>{if(/^(https?:\/\/|www\.)/.test(t)||t.includes("linkedin.com")){const r=t.match(My);if(!r)throw new Error(ti.INVALID_URL);if(r[0].length!==t.length)throw new Error(ti.INVALID_USERNAME);const[,i,s,o]=r,a=qd(o);if(i&&!/^[A-Z]{2}$/.test(i.toUpperCase()))throw new Error(ti.INVALID_URL);return{regional:i,pathType:s,username:a}}const e=qd(t),n=e.indexOf("/");if(n!==-1){const r=e.substring(0,n);if(g6.includes(r))return{pathType:r,username:e.substring(n+1)}}return{username:e}},jy=(t,e)=>(t==="pub"?v6:b6).test(e),Ny=({regional:t,pathType:e,username:n})=>{const i=`https://${t?`${t.toLowerCase()}.`:"www."}linkedin.com/${e}/${n}`;if(!wt.isURL(i))throw new Error(ti.INVALID_URL);return i};function x6(t){if(!t)return"";const{regional:e,pathType:n="in",username:r}=Ey(t);if(!jy(n,r))throw new Error(ti.INVALID_USERNAME);return Ny({regional:e,pathType:n,username:r})}const y6=t=>{if(!t)throw new Error(ti.INVALID_USERNAME);const{regional:e,pathType:n="in",username:r}=Ey(t);if(!jy(n,r))throw new Error(ti.INVALID_USERNAME);return Ny({regional:e,pathType:n,username:r})},w6=t=>{const e=t.match(My);if(!e)return null;const[,,n,r]=e,i=qd(r);return n==="in"?i:`${n}/${i}`};function k6(t){const e="The URL must be in a format like https://www.instagram.com/yourUsername",n="Your Username is not a valid Instagram Username";if(!t)return"";let r;if(t.startsWith("http")||t.startsWith("www.")||t.includes("instagram.com")){if(!t.includes("instagram.com"))throw new Error(e);const s=t.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]+)/);if(!s)throw new Error(e);r=s[1]}else r=t.startsWith("@")?t.slice(1):t;if(!r.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||r.includes("..")||r.length>30)throw new Error(n);const i=`https://www.instagram.com/${r}`;if(!wt.isURL(i))throw new Error(e);return i}const S6=t=>{const e="Your Username is not a valid Instagram Username";if(!t)throw new Error(e);let n=t;if(n.startsWith("@")&&(n=n.slice(1)),!n.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||n.includes("..")||n.length>30)throw new Error(e);return`https://www.instagram.com/${n}`},C6=t=>{const e=t.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]*)/);return e?`${e[1]}`:null};function A6(t){const e="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",n="Your Username is not a valid YouTube Username";if(!t)return"";let r;if(t.startsWith("http")||t.startsWith("www.")||t.includes("youtube.com")){if(!t.includes("youtube.com"))throw new Error(e);const s=t.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]+)/);if(!s)throw new Error(e);r=s[1]}else r=t;if(r.startsWith("@")){const s=r.slice(1);if(!s.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||s.includes("..")||s.length>30)throw new Error(n)}else if(r.startsWith("user/")){if(!r.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(n)}else if(r.startsWith("channel/")){if(!r.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(n)}else throw new Error(e);const i=`https://www.youtube.com/${r}`;if(!wt.isURL(i))throw new Error(e);return i}const M6=t=>{const e="Your Username is not a valid YouTube Username";if(!t)throw new Error(e);if(t.startsWith("@")){const n=t.slice(1);if(!n.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||n.includes("..")||n.length>30)throw new Error(e)}else if(t.startsWith("user/")){if(!t.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(e)}else if(t.startsWith("channel/")){if(!t.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(e)}else throw new Error("The handle must be in a format like @yourUsername, user/yourUsername, or channel/yourChannelId");return`https://www.youtube.com/${t}`},E6=t=>{const e=t.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]*)/);return e?e[1]:null};function j6(t){const e="The URL must be in a format like https://www.tiktok.com/@yourUsername",n="Your Username is not a valid TikTok Username";if(!t)return"";let r;if(t.startsWith("http")||t.startsWith("www.")||t.includes("tiktok.com")){if(!t.includes("tiktok.com"))throw new Error(e);const o=t.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]+)/);if(!o)throw new Error(e);r=o[1]}else r=t.startsWith("@")?t:`@${t}`;const i=r.slice(1);if(!i.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||i.includes("..")||i.length<2||i.length>24)throw new Error(n);const s=`https://www.tiktok.com/${r}`;if(!wt.isURL(s))throw new Error(e);return s}const N6=t=>{const e="Your Username is not a valid TikTok Username";if(!t)throw new Error(e);const n=t.startsWith("@")?t:`@${t}`,r=n.slice(1);if(!r.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||r.includes("..")||r.length<2||r.length>24)throw new Error(e);return`https://www.tiktok.com/${n}`},T6=t=>{const e=t.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]*)/);return e?e[1]:null};function D6(t){const e="The URL must be in a format like @username@instance.tld or https://instance.tld/@username or https://website.com/@username@instance.tld";if(!t)return"";let n=t;if(n=n.replace(/^https?:\/\//,""),n.match(/^@[^@]+@[^/]+$/)){const[r,i]=n.split("@").slice(1);if(!wt.isFQDN(i))throw new Error(e);return`https://${i}/@${r}`}if(n.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[r,i]=n.split("/@");if(!wt.isFQDN(r))throw new Error(e);if(i.includes("@")){const[,s]=i.split("@");if(!wt.isFQDN(s))throw new Error(e)}return`https://${n}`}throw new Error(e)}const O6=t=>{const e="Your Username is not a valid Mastodon Username";if(!t)throw new Error(e);if(t.match(/^@[^@]+@[^/]+$/)){const[n,r]=t.split("@").slice(1);if(!wt.isFQDN(r))throw new Error(e);return`https://${r}/@${n}`}if(t.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[n,r]=t.split("/@");if(!wt.isFQDN(n))throw new Error(e);if(r.includes("@")){const[,i]=r.split("@");if(!wt.isFQDN(i))throw new Error(e)}return`https://${t}`}throw new Error(e)},I6=t=>t.replace(/^https?:\/\//,""),yf=["twitter","facebook","linkedin","bluesky","threads","mastodon","tiktok","youtube","instagram"],er=(t,e)=>t?e(t):"",Fl=[{key:"twitter",staffTitle:"X",publicationTitle:"X",placeholder:"https://x.com/username",testId:"x-input",validate:a6,toDisplayValue:t=>er(t,l6),toStoredValue:t=>c6(t)},{key:"facebook",staffTitle:"Facebook",publicationTitle:"Facebook",placeholder:"https://www.facebook.com/username",testId:"facebook-input",validate:i6,toDisplayValue:t=>er(t,s6),toStoredValue:t=>o6(t)},{key:"linkedin",staffTitle:"LinkedIn",publicationTitle:"LinkedIn",placeholder:"https://www.linkedin.com/in/username",testId:"linkedin-input",validate:x6,toDisplayValue:t=>er(t,y6),toStoredValue:t=>w6(t)},{key:"bluesky",staffTitle:"Bluesky",publicationTitle:"Bluesky",placeholder:"https://bsky.app/profile/username",testId:"bluesky-input",validate:f6,toDisplayValue:t=>er(t,m6),toStoredValue:t=>p6(t)},{key:"threads",staffTitle:"Threads",publicationTitle:"Threads",placeholder:"https://threads.net/@username",testId:"threads-input",validate:u6,toDisplayValue:t=>er(t,d6),toStoredValue:t=>h6(t)},{key:"mastodon",staffTitle:"Mastodon",publicationTitle:"Mastodon",placeholder:"https://mastodon.social/@username",testId:"mastodon-input",validate:D6,toDisplayValue:t=>er(t,O6),toStoredValue:t=>t?I6(t):null},{key:"tiktok",staffTitle:"TikTok",publicationTitle:"TikTok",placeholder:"https://www.tiktok.com/@username",testId:"tiktok-input",validate:j6,toDisplayValue:t=>er(t,N6),toStoredValue:t=>T6(t)},{key:"youtube",staffTitle:"YouTube",publicationTitle:"YouTube",placeholder:"https://www.youtube.com/@channel",testId:"youtube-input",validate:A6,toDisplayValue:t=>er(t,M6),toStoredValue:t=>E6(t)},{key:"instagram",staffTitle:"Instagram",publicationTitle:"Instagram",placeholder:"https://www.instagram.com/username",testId:"instagram-input",validate:k6,toDisplayValue:t=>er(t,S6),toStoredValue:t=>C6(t)}],Ty=Object.fromEntries(Fl.map(t=>[t.key,t])),jg=(t,e)=>{const n=Ty[t],r=n.validate(e),i=r?n.toStoredValue(r):null;return{displayValue:n.toDisplayValue(i),storedValue:i}},Cu=(t,e)=>{try{return Ty[t].validate(e||""),""}catch(n){return n instanceof Error?n.message:""}},Dy=["facebook","twitter"],P6=yf.filter(t=>!Dy.includes(t)),Ng=t=>{const e=we(t,[...yf]);return Object.fromEntries(Fl.map((n,r)=>{const i=e[r];return[n.key,n.toDisplayValue(i)]}))},R6=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,handleEditingChange:a}=Ft(),[l,c]=v.useState({}),[d,h]=v.useState(()=>Ng(e)),[f,m]=v.useState(null),p=we(e,[...yf]),g=P6.some(k=>e?.some(C=>C.key===k)),b=v.useMemo(()=>g?Fl:Fl.filter(k=>Dy.includes(k.key)),[g]);v.useEffect(()=>{f||h(Ng(e))},[p.map(k=>k??"").join("|")]);const x=(k,C)=>{h(S=>({...S,[k]:C})),n||a(!0);try{const{storedValue:S}=jg(k,C);o(k,S),l[k]&&c(A=>({...A,[k]:""}))}catch{c(S=>({...S,[k]:Cu(k,C)}))}},y=k=>{if(m(S=>S===k?null:S),Cu(k,d[k]))return;const{displayValue:C}=jg(k,d[k]);h(S=>({...S,[k]:C}))},w=()=>{const k=b.reduce((C,S)=>{const A=Cu(S.key,d[S.key]);return A&&(C[S.key]=A),C},{});c(k),Object.keys(k).length===0&&i()};return u.jsx(Se,{description:"Link your social accounts for full structured data and rich card support",isEditing:n,keywords:t,navid:"social-accounts",saveState:r,testId:"social-accounts",title:"Social accounts",hideEditButton:!0,onCancel:s,onEditingChange:a,onSave:w,children:u.jsx(tt,{children:b.map(k=>u.jsx(at,{"data-testid":k.testId,error:!!l[k.key],hint:l[k.key],placeholder:k.placeholder,title:k.publicationTitle,value:d[k.key],onBlur:()=>y(k.key),onChange:C=>x(k.key,C.target.value),onFocus:()=>m(k.key)},k.key))})})},L6=Ce(R6,"Social accounts"),_6=[{name:"Pacific/Pago_Pago",label:"Midway Island, Samoa"},{name:"Pacific/Honolulu",label:"Hawaii"},{name:"America/Anchorage",label:"Alaska"},{name:"America/Tijuana",label:"Tijuana"},{name:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{name:"America/Mazatlan",label:"La Paz, Mazatlan"},{name:"America/Phoenix",label:"Arizona"},{name:"America/Denver",label:"Mountain Time (US & Canada)"},{name:"America/Chihuahua",label:"Chihuahua"},{name:"America/Costa_Rica",label:"Central America"},{name:"America/Chicago",label:"Central Time (US & Canada)"},{name:"America/Mexico_City",label:"Guadalajara, Mexico City, Monterrey"},{name:"America/Regina",label:"Saskatchewan"},{name:"America/Bogota",label:"Bogota, Lima, Quito"},{name:"America/New_York",label:"Eastern Time (US & Canada)"},{name:"America/Fort_Wayne",label:"Indiana (East)"},{name:"America/Caracas",label:"Caracas, La Paz, Georgetown"},{name:"America/Halifax",label:"Atlantic Time (Canada); Greenland"},{name:"America/Santiago",label:"Santiago"},{name:"America/St_Johns",label:"Newfoundland"},{name:"America/Argentina/Buenos_Aires",label:"Buenos Aires, Brasilia"},{name:"America/Noronha",label:"Fernando de Noronha"},{name:"Atlantic/Azores",label:"Azores"},{name:"Atlantic/Cape_Verde",label:"Cape Verde Is."},{name:"Etc/UTC",label:"UTC"},{name:"Africa/Casablanca",label:"Casablanca, Monrovia"},{name:"Europe/Dublin",label:"Dublin, Edinburgh, London"},{name:"Europe/Amsterdam",label:"Amsterdam, Berlin, Rome, Stockholm, Vienna"},{name:"Europe/Prague",label:"Belgrade, Bratislava, Budapest, Prague"},{name:"Europe/Paris",label:"Brussels, Copenhagen, Madrid, Paris"},{name:"Europe/Warsaw",label:"Sarajevo, Skopje, Warsaw, Zagreb"},{name:"Africa/Lagos",label:"West Central Africa"},{name:"Europe/Athens",label:"Athens, Beirut, Bucharest"},{name:"Africa/Cairo",label:"Cairo, Egypt"},{name:"Africa/Maputo",label:"Harare"},{name:"Europe/Kiev",label:"Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius"},{name:"Asia/Jerusalem",label:"Jerusalem"},{name:"Africa/Johannesburg",label:"Pretoria"},{name:"Asia/Baghdad",label:"Baghdad"},{name:"Asia/Riyadh",label:"Kuwait, Nairobi, Riyadh"},{name:"Europe/Istanbul",label:"Istanbul, Ankara"},{name:"Europe/Moscow",label:"Moscow, St. Petersburg, Volgograd"},{name:"Asia/Tehran",label:"Tehran"},{name:"Asia/Dubai",label:"Abu Dhabi, Muscat"},{name:"Asia/Baku",label:"Baku, Tbilisi, Yerevan"},{name:"Asia/Kabul",label:"Kabul"},{name:"Asia/Almaty",label:"Almaty, Astana"},{name:"Asia/Karachi",label:"Islamabad, Karachi, Tashkent"},{name:"Asia/Yekaterinburg",label:"Yekaterinburg"},{name:"Asia/Kolkata",label:"Chennai, Kolkata, Mumbai, New Delhi"},{name:"Asia/Colombo",label:"Colombo, Sri Jayawardenepura"},{name:"Asia/Kathmandu",label:"Kathmandu"},{name:"Asia/Dhaka",label:"Dhaka"},{name:"Asia/Rangoon",label:"Yangon (Rangoon)"},{name:"Asia/Bangkok",label:"Bangkok, Hanoi, Jakarta"},{name:"Asia/Krasnoyarsk",label:"Krasnoyarsk, Novosibirsk"},{name:"Asia/Hong_Kong",label:"Beijing, Chongqing, Hong Kong, Urumqi"},{name:"Asia/Irkutsk",label:"Irkutsk, Ulaanbaatar"},{name:"Asia/Singapore",label:"Kuala Lumpur, Perth, Singapore, Taipei"},{name:"Asia/Tokyo",label:"Osaka, Sapporo, Tokyo"},{name:"Asia/Seoul",label:"Seoul"},{name:"Asia/Yakutsk",label:"Yakutsk"},{name:"Australia/Adelaide",label:"Adelaide"},{name:"Australia/Darwin",label:"Darwin"},{name:"Australia/Brisbane",label:"Brisbane, Guam, Port Moresby"},{name:"Australia/Sydney",label:"Canberra, Hobart, Melbourne, Sydney, Vladivostok"},{name:"Asia/Magadan",label:"Magadan, Soloman Is., New Caledonia"},{name:"Pacific/Auckland",label:"Auckland, Wellington"},{name:"Pacific/Fiji",label:"Fiji, Kamchatka, Marshall Is."},{name:"Pacific/Kwajalein",label:"International Date Line West"}],F6=t=>{const e={timeZone:t,timeZoneName:"longOffset"};try{const i=new Intl.DateTimeFormat("en-GB",e).formatToParts(new Date).find(m=>m.type==="timeZoneName")?.value;if(!i)return{offsetString:null,offsetMinutes:0};const s=i.match(/^GMT([+-])(\d{2}):(\d{2})$/);if(!s)return{offsetString:i,offsetMinutes:0};const[,o,a,l]=s,c=parseInt(a,10),d=parseInt(l,10),h=o==="+"?c*60+d:-(c*60+d);return{offsetString:h===0?"GMT":`GMT ${o}${c}:${d.toString().padStart(2,"0")}`,offsetMinutes:h}}catch{return{offsetString:null,offsetMinutes:0}}},B6=(t,e)=>`(${e}) ${t}`,V6=()=>_6.map(({name:t,label:e})=>{const{offsetString:n,offsetMinutes:r}=F6(t);return{name:t,label:n?B6(e,n):e,offsetMinutes:r}}).sort((t,e)=>t.offsetMinutes-e.offsetMinutes),z6=({timezone:t})=>{const[e,n]=v.useState(yg(t));return v.useEffect(()=>{const r=setInterval(()=>{n(yg(t))},1e3);return()=>{clearInterval(r)}},[t]),u.jsxs(u.Fragment,{children:["The local time here is currently ",e]})},$6=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,handleEditingChange:a}=Ft(),[l]=we(e,["timezone"]),c=V6().map(h=>({value:h.name,label:h.label})),d=h=>{o("timezone",h||null),a(!0)};return u.jsx(Se,{description:"Set the time and date of your publication, used for all published posts",hideEditButton:!0,isEditing:n,keywords:t,navid:"timezone",saveState:r,testId:"timezone",title:"Site timezone",onCancel:s,onEditingChange:a,onSave:i,children:u.jsx(tt,{columns:1,children:u.jsx(ir,{hint:u.jsx(z6,{timezone:l}),options:c,selectedOption:c.find(h=>h.value===l),testId:"timezone-select",title:"Site timezone",isSearchable:!0,onSelect:h=>d(h?.value)})})})},H6=Ce($6,"Site timezone"),U6=({keywords:t})=>{const{errors:e,localSettings:n,isEditing:r,saveState:i,focusRef:s,clearError:o,handleSave:a,handleCancel:l,updateSetting:c,handleEditingChange:d}=Ft({onValidate:()=>h?h.length<4?{title:"Please use a site title longer than 3 characters."}:h.length>63?{title:"Please use a site title shorter than 63 characters."}:{}:{title:"Please enter a site title."}}),[h,f]=we(n,["title","description"]),m=x=>{c("title",x.target.value)},p=x=>{c("description",x.target.value)},g=u.jsx(tt,{columns:2,values:[{heading:"Site title",key:"site-title",value:h},{heading:"Site description",key:"site-description",value:f}]}),b=u.jsxs(tt,{children:[u.jsx(at,{error:!!e.title,hint:e.title||"The name of your site",inputRef:s,maxLength:63,placeholder:"Site title",title:"Site title",value:h,onChange:m,onKeyDown:()=>o("title")}),u.jsx(at,{hint:"A short description, used in your theme, meta data and search results",maxLength:200,placeholder:"Site description",title:"Site description",value:f,onChange:p})]});return u.jsx(Se,{description:"The details used to identify your publication around the web",isEditing:r,keywords:t,navid:"general",saveState:i,testId:"title-and-description",title:"Title & description",onCancel:l,onEditingChange:d,onSave:a,children:r?b:g})},W6=Ce(U6,"Title & description"),K6=({user:t})=>{const{updateRoute:e}=fe(),{currentUser:n}=ke(),r=()=>{Fs(n)&&e({route:`staff/${t.slug}`})};return t?u.jsxs("div",{className:R("group flex gap-3",Fs(n)&&"cursor-pointer"),"data-testid":"owner-user",onClick:r,children:[u.jsx(gh,{bgColor:mf(t.name?t.name:t.email),image:t.profile_image??void 0,label:cy(t.name),labelColor:"white",size:"lg"}),u.jsxs("div",{className:"flex flex-col",children:[u.jsxs("span",{children:[t.name," — ",u.jsx("strong",{children:"Owner"})," ",Fs(n)&&u.jsx("button",{className:"ml-2 inline-block font-semibold text-green group-hover:visible md:invisible",type:"button",children:"View profile"})]}),u.jsx("span",{className:"text-sm text-grey-700",children:t.email})]})]}):null},Da=({users:t,groupname:e})=>{const{updateRoute:n}=fe(),{currentUser:r}=ke(),i=s=>{n({route:`staff/${s.slug}`})};return!t||!t.length?u.jsxs(li,{icon:"single-user-block",children:["No ",e," found."]}):u.jsx(is,{titleSeparator:!1,children:t.map(s=>{let o=s.name||"";s.status==="inactive"&&(o=`${o} (Suspended)`);const a=Fs(r)||Gg(r)&&$w(s)||r.id===s.id;return u.jsx(Wi,{action:a&&u.jsx(J,{color:"green",label:"Edit",link:!0,onClick:()=>i(s)}),avatar:u.jsx(gh,{bgColor:mf(s.name?s.name:s.email),image:s.profile_image??void 0,label:cy(s.name),labelColor:"white"}),bgOnHover:a,className:"min-h-[64px]",detail:s.email,hideActions:!0,id:`list-item-${s.id}`,separator:!1,testId:"user-list-item",title:o,onClick:()=>a&&i(s)},s.id)})})},G6=({invite:t})=>{const[e,n]=v.useState(""),[r,i]=v.useState(""),{mutateAsync:s}=RP(),{mutateAsync:o}=PP(),a=Ye();let l="Revoke";e==="progress"&&(l="Revoking...");let c="Resend";return r==="progress"&&(c="Resending..."),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(J,{color:"red",label:l,link:!0,onClick:async()=>{try{n("progress"),await s(t.id),rn({title:"Invitation revoked",message:t.email,type:"success"})}catch(d){a(d)}finally{n("")}}}),u.jsx(J,{className:"ml-2",color:"green",label:c,link:!0,onClick:async()=>{try{i("progress"),await s(t.id),await o({email:t.email,roleId:t.role_id}),rn({title:"Invitation resent",message:t.email,type:"success"})}catch(d){a(d)}finally{i("")}}})]})},q6=({users:t})=>!t||!t.length?u.jsx(li,{icon:"single-user-block",children:"No invitations found."}):u.jsx(is,{children:t.map(e=>u.jsx(Wi,{action:u.jsx(G6,{invite:e}),avatar:u.jsx(gh,{bgColor:mf(e.email),image:"",label:e.email.charAt(0).toUpperCase(),labelColor:"white"}),className:"min-h-[64px]",detail:e.role,hideActions:!0,id:`list-item-${e.id}`,separator:!1,testId:"user-invite",title:e.email,onClick:()=>{}},e.id))}),Y6=({keywords:t,highlight:e=!0})=>{const{totalUsers:n,totalInvites:r,users:i,ownerUser:s,adminUsers:o,editorUsers:a,authorUsers:l,contributorUsers:c,invites:d,hasNextPage:h,fetchNextPage:f,invitesHasNextPage:m,fetchNextInvitePage:p}=ff(),{updateRoute:g}=fe(),{settings:b,config:x,currentUser:y}=ke(),w=()=>{g("staff/invite")},k=u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Invite people",size:"sm",linkWithPadding:!0,onClick:()=>{w()}}),C=Qo().getParam("tab"),S=C||"administrators",[A,M]=v.useState(S);v.useEffect(()=>{C&&M(C)},[C]);const E=O=>{g(`staff?tab=${O}`),M(O)},j=[{id:"administrators",title:"Administrators",contents:u.jsx(Da,{groupname:"administrators",users:o}),counter:o.length?o.length:void 0},{id:"editors",title:"Editors",contents:u.jsx(Da,{groupname:"editors",users:a}),counter:a.length?a.length:void 0},{id:"authors",title:"Authors",contents:u.jsx(Da,{groupname:"authors",users:l}),counter:l.length?l.length:void 0},{id:"contributors",title:"Contributors",contents:u.jsx(Da,{groupname:"contributors",users:c}),counter:c.length?c.length:void 0},{id:"invited",title:"Invited",contents:u.jsx(q6,{users:d}),counter:r||void 0}],T=Xs(b,"require_email_mfa")||!1,{mutateAsync:N}=ai(),D=Ye();return u.jsxs(Se,{customButtons:k,highlightOnModalClose:e,keywords:t,navid:"staff",testId:"users",title:"Staff",children:[u.jsx(K6,{user:s}),(i.length>1||d.length>0)&&u.jsx(hr,{selectedTab:A,tabs:j,testId:"user-tabview",onTabChange:E}),h&&A!=="invited"&&u.jsx(J,{label:`Load more (showing ${i.length}/${n} users)`,link:!0,onClick:()=>f()}),m&&A==="invited"&&u.jsx(J,{label:`Load more (showing ${d.length}/${r} invites)`,link:!0,onClick:()=>p()}),x?.security?.staffDeviceVerification&&Fs(y)&&u.jsxs("div",{className:`flex flex-col gap-6 ${i.length>1||d.length>0?"-mt-6":""}`,children:[u.jsx(Tt,{}),u.jsxs("div",{className:"flex items-baseline justify-between",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{className:"text-[1.5rem] font-semibold tracking-tight",children:"Security settings"}),u.jsx("span",{children:"Require email 2FA codes to be used on all staff logins"})]}),u.jsx(en,{checked:T,direction:"rtl",gap:"gap-0",onChange:async()=>{const O=!T;try{await N([{key:"require_email_mfa",value:O}])}catch(L){D(L)}}})]})]})]})},Oy=Ce(Y6,"Staff"),gt={titleAndDescription:["general","title and description","site title","site description","title & description"],timeZone:["general","time","date","site timezone","time zone"],publicationLanguage:["general","publication language","locale"],users:["general","users and permissions","roles","staff","invite people","contributors","editors","authors","administrators"],metadata:["general","metadata","title","description","search","engine","google","meta data","twitter card","structured data","rich cards","x card","social","facebook card","llms","ai","ai search engines","llm"],socialAccounts:["general","social accounts","facebook","twitter","threads","bluesky","mastodon","tiktok","youtube","instagram","linkedin","structured data","rich cards"],analytics:["general","analytics","tracking","privacy","membership"]},X6=()=>u.jsxs(ui,{keywords:Object.values(gt).flat(),title:"General settings",children:[u.jsx(W6,{keywords:gt.titleAndDescription}),u.jsx(H6,{keywords:gt.timeZone}),u.jsx(e6,{keywords:gt.publicationLanguage}),u.jsx(Oy,{keywords:gt.users}),u.jsx(r6,{keywords:gt.metadata}),u.jsx(L6,{keywords:gt.socialAccounts}),u.jsx(XL,{keywords:gt.analytics})]}),J6=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("embed-signup-form/show")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Embed",size:"sm",onClick:n}),description:"Grow your audience from anywhere on the web",keywords:t,navid:"embed-signup-form",testId:"embed-signup-form",title:"Signup forms"})},Z6=""+new URL("explore-default-logo-P7UjmPqe.png",import.meta.url).href,Q6=""+new URL("ghost-explore-BuZQ7HbF.png",import.meta.url).href,e8=({keywords:t})=>{const{settings:e}=ke(),{mutateAsync:n}=ai(),r=Ye(),{updateRoute:i}=fe(),{refetch:s}=Wg({searchParams:{limit:"1"}}),[o,a]=v.useState(0);v.useEffect(()=>{(async()=>{const{data:C}=await s(),S=C?.meta?.pagination?.total||0;a(S)})()},[s]);const[l,c]=we(e,["accent_color","icon"]),{localSettings:d,siteData:h}=Ft(),[f,m]=we(d,["title","description"]),p=!!Xs(e,"explore_ping"),g=!!Xs(e,"explore_ping_growth"),b=h?.url,x=b?.replace(/^https?:\/\//,"").replace(/\/?$/,""),y=l||"#F6414E",w=async(k,C)=>{const S=[{key:k,value:C.target.checked}];try{await n(S)}catch(A){r(A)}};return u.jsx(Se,{customButtons:u.jsx(en,{checked:p,direction:"rtl",testId:"explore-toggle",onChange:k=>w("explore_ping",k)}),description:"Promote your site across Ghost's website and publishing network",keywords:t,navid:"explore",testId:"explore",title:"Ghost Explore",children:p?u.jsxs(tt,{columns:1,children:[u.jsx(Tt,{}),u.jsx(en,{checked:g,containerClasses:"items-center!",direction:"rtl",gap:"gap-0",hint:"Enabling this will use your revenue/member growth data to rank your site more highly on Ghost Explore. Total member count will be displayed publicly, other data will be kept private.",label:"Share growth data to rank higher?",labelClasses:"w-full",testId:"explore-growth-toggle",onChange:k=>w("explore_ping_growth",k)}),u.jsx("div",{className:"-mx-5 -mb-5 flex flex-col items-center bg-grey-50 px-7 py-10 md:-mx-7 md:-mb-7","data-testid":"explore-preview",children:u.jsxs("div",{className:"relative w-full max-w-[320px] rounded-lg bg-white p-6 text-black shadow-lg",children:[u.jsx("div",{className:"absolute top-2.5 right-3 text-sm text-grey-300 uppercase",children:"Preview"}),c?u.jsx("div",{className:"size-9 rounded-sm bg-cover bg-center",style:{backgroundImage:`url(${c})`}}):u.jsx("div",{className:"flex aspect-square size-10 items-center justify-center overflow-hidden rounded-full p-1 text-white",style:{backgroundColor:y},children:u.jsx("img",{className:"h-auto w-8",src:Z6})}),u.jsx("div",{className:"mt-3 text-lg font-semibold tracking-tight",children:f}),m&&u.jsx("div",{className:"mt-0.5 leading-tight text-grey-700",children:m}),u.jsxs("a",{className:"group mt-8 flex h-6 w-full items-center justify-between gap-5 hover:cursor-pointer",href:b,rel:"noopener noreferrer",target:"_blank",children:[u.jsx("span",{className:"font-semibold",children:x}),g?u.jsxs("span",{className:"rounded-sm bg-black px-2 py-0.5 text-sm font-semibold text-white","data-testid":"explore-members-count",children:[Hw(o)," ",o===1?"member":"members"]}):u.jsx("span",{className:"flex size-5 items-center justify-center rounded-full border border-black text-black group-hover:bg-black group-hover:text-white",children:u.jsx(me,{name:"arrow-right",size:10})})]})]})}),u.jsxs("div",{className:"-mx-5 -mb-5 flex items-center justify-between gap-4 rounded-b-xl border-t border-[rgba(142,66,255,0.1)] bg-gradient-to-tr from-[rgba(142,66,255,0.07)] to-[rgba(142,66,255,0.02)] p-6 px-7 md:-mx-7 md:-mb-7",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:"Get featured on the Ghost.org homepage"}),u.jsx("span",{className:"text-pretty text-black/80 dark:text-white/80",children:"Send us a quote we can use to highlight your site"})]}),u.jsx(J,{className:"border border-purple bg-white text-purple hover:bg-purple/5 hover:text-purple dark:bg-transparent",icon:"send",label:"Send testimonial",onClick:()=>{i("explore/testimonial")}})]})]}):u.jsx("img",{src:Q6})})},t8=Ce(e8,"Ghost Explore"),n8=""+new URL("network-C2Wz-Sfw.png",import.meta.url).href,r8=({keywords:t})=>{const{settings:e}=ke(),{mutateAsync:n}=ai(),r=Ye(),{updateRoute:i}=fe(),o=fs()?.isDisabled("limitSocialWeb"),{subdir:a}=Ys(),[l]=we(e,["is_private"]),c=!!a,d=["localhost","127.0.0.1","::1"].includes(window.location.hostname),h=wt.isIP(window.location.hostname),f=o||c||d||h,m=!!l,p=f||m,[g]=we(e,["social_web"]),b=!!g&&!p,x=async y=>{const w=[{key:"social_web",value:y.target.checked}];try{await n(w)}catch(k){r(k)}};return u.jsx(Se,{customButtons:u.jsx(en,{checked:b,direction:"rtl",disabled:p,onChange:x},`${b}-${p}`),description:"Distribute posts to the social web, so people can discover and follow your content across BlueSky, Threads, Mastodon, Flipboard, WordPress, and more.",keywords:t,navid:"network",testId:"network",title:"Network",children:u.jsxs(u.Fragment,{children:[u.jsx(tt,{columns:1,values:[{key:"private",value:p&&u.jsxs("div",{className:"flex w-full gap-1.5 rounded-md border border-grey-200 bg-grey-50 p-3 dark:border-grey-900 dark:bg-grey-900",children:[u.jsx(me,{name:"info",size:16}),u.jsx("div",{className:"-mt-0.5",children:m?u.jsxs(u.Fragment,{children:["Network is automatically disabled while your site is in ",u.jsx("span",{className:"cursor-pointer text-green",onClick:()=>i("members"),children:"private mode"})]}):u.jsxs(u.Fragment,{children:["You need to configure a supported custom domain to use this feature. ",u.jsx("a",{className:"text-green",href:"https://ghost.org/help/social-web/#custom-domain-required",rel:"noopener noreferrer",target:"_blank",children:"Help →"})]})})]})}]}),u.jsx("div",{className:"-mx-5 -mb-5 overflow-hidden rounded-b-xl md:-mx-7 md:-mb-7",children:u.jsx("img",{className:"dark:opacity-90",src:n8})})]})})},i8=Ce(r8,"Network"),s8=({keywords:t})=>{const{updateRoute:e}=fe(),{settings:n,config:r}=ke(),{data:{offers:i=[]}={}}=k2(),{data:{tiers:s}={}}=rh(),o=x2(s||[]),a=i.filter(d=>d.redemption_type==="signup"),l=()=>{e("offers/edit")},c=()=>{e("/tiers")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",disabled:!nr(n,r),label:"Manage offers",size:"sm",onClick:l}),description:u.jsxs(u.Fragment,{children:["Create discounts & coupons to boost new subscriptions and retain existing members.",u.jsx("span",{children:" "}),u.jsx("a",{className:"text-green",href:"https://ghost.org/help/offers",rel:"noopener noreferrer",target:"_blank",children:"Learn more"})]}),keywords:t,navid:"offers",testId:"offers",title:"Offers",children:o.length===0&&a.length===0?u.jsxs("div",{children:[u.jsx("span",{children:"You must have an active tier to create an offer."})," ",u.jsx(J,{className:"font-normal",color:"green",label:"Manage tiers",link:!0,linkWithPadding:!0,onClick:c})]}):""})},o8=Ce(s8,"Portal settings"),a8="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAA81BMVEUAAAAQEBAVFRUVFRgVFxkVFhoVFxkWFxkVFhoVFxoVFxoWFxoVFxkUFBgVFRsQGBgVFxsVFxkVFxoyNDZPUVNtbnBeX2FBQkVBQ0WKi43Excb////FxcaKi4xQUVMUGBgVFhkyNDenqKnx8fHw8fGYmZt7fX7i4uIUFxkjJSgUFhrS09Th4uOZmZokJiji4uPw8PHh4uLT09QTFRsTFxtsbnAUFhp7fH4UFxkUFhoWFxoVFxpAQkXT09O2triZmpq1tri2t7iZmpsXFxd7fX8QECB8fX4VGBgVFRsYGBgUGBoVFhoVGBgTFhkTFhoVFxkUFxrWJPvbAAAAUXRSTlMAEDBgkJ+/3+//z69vQF8gj4/f////////////////QKD/////////cP+A//////////9gkP+v/7/P3+//////////T/8Q/18wIIDPYFCf36+gOKr5AAACJ0lEQVR4AY3U1WLrMAwGYJX7l5mSMo6ZmRne/2nOnFqOm+N5/a5CiiQT6ULhSDQWTySS8CQTqXg6msmSWSgTT8IsnstTUDYOq9hiSKiAPxXJl09hCSWVJFRCQLlSrVXqCEiFaG6xnkaz5Uhuu2yqKg9Nh7/mmAo0XRJ6UPr8uWagZYkHEtSGjjByx9VKuTKR0dMaFNHFDKwpi1hRCQeOpwm2SkTxhe/XKtD11/0IrknVI95sIGBznqTm15Tlf23x9wFexDZ3HvZa4Oc7MNjc9TrD3B7tw1MRTw8gGfqQvUXpEJ6WIQGraClicpD64lkbvzgSb+ddHNMJhAlnNWup35XoVD1xVgBLUa4MSELwlgBgS7EN4YwgnMu2LCm4CeJ7c89sc8QtagEVWFwYAlZg0eIA7oGbWjKgbxskLmlFC8DoJwIWfTWscuIu1bCZXTnONc+0WhoTS4ItXsopOuFxtk3cjbb4DlVO80Twbh/w8t6XSS0pbh2/w1W1Rds/D2+N9e/q6+aOupB2+ThZdD909M0Ypgd/6xoiOruOsMNDfqYfZI2RmO+y4WQeNSAdE9Fq4HhwqysQVh75ZN5pgD0R0fP/h/euO7jecpirJX0hrkk68JLoRhP4YiTwOJlCdtsrYJyAeO5YY9LyxmbrZhKY+1eae3jDUlLEXpaKSL2Q7xV/ioZI99KD1XGXgl7ej5MwO34Nk9nzx+rn8ckXB359nXxHM90Qaf4BNjt9poiwMVcAAAAASUVORK5CYII=",wf=({title:t,favicon:e,featured_image:n,isGhostSite:r})=>{const[i,s]=v.useState(e||n||null),o=()=>{s(null)};if(!i)return u.jsx("div",{className:"relative size-6 shrink-0 rounded-sm"});const a=r?"This is a Ghost site that supports one-click subscribe":"";return u.jsxs("div",{className:"relative size-6 shrink-0 rounded-sm dark:group-hover/table-row:bg-grey-950",title:a,children:[u.jsx("img",{alt:t,className:"size-6 rounded-sm",src:i,onError:o}),r&&u.jsx("img",{alt:"Ghost Logo",className:"absolute right-[-3px] bottom-[-3px] size-[14px]",src:a8})]})},ta="RecommendationResponseType",l8=Jd({dataType:ta,path:"/recommendations/",returnData:t=>{const{pages:e}=t;let n=e.flatMap(r=>r.recommendations);return n=n.filter((r,i)=>n.findIndex(({id:s})=>s===r.id)===i),{recommendations:n,meta:e[e.length-1].meta}}}),c8=Ot({method:"DELETE",path:t=>`/recommendations/${t.id}/`,invalidateQueries:{dataType:ta}}),u8=Ot({method:"PUT",path:t=>`/recommendations/${t.id}/`,body:t=>({recommendations:[t]}),invalidateQueries:{dataType:ta}}),h9=Ot({method:"POST",path:()=>"/recommendations/",body:({...t})=>({recommendations:[t]}),invalidateQueries:{dataType:ta}}),f9=Ot({method:"POST",path:()=>"/recommendations/check/",body:t=>({recommendations:[{url:t.toString()}]})}),d8=Jd({dataType:ta,path:"/incoming_recommendations/",returnData:t=>{const{pages:e}=t;let n=e.flatMap(r=>r.recommendations);return n=n.filter((r,i)=>n.findIndex(({id:s})=>s===r.id)===i),{recommendations:n,meta:e[e.length-1].meta}}}),h8=({incomingRecommendation:t,stats:e})=>{const{updateRoute:n}=fe(),r=v.useMemo(()=>{let a=t.url;try{a=new URL(t.url).hostname.replace(/^www\./,"")}catch{}return e.reduce((l,c)=>c.source===a?l+c.signups:l,0)},[e,t.url]),i=()=>{n({route:`recommendations/add?url=${t.url}`})},s=()=>{window.open(t.url,"_blank")},o=r===1?"free member":"free members";return u.jsxs(ls,{action:!t.recommending_back&&u.jsx("div",{className:"flex items-center justify-end",children:u.jsx(J,{color:"green",label:"Recommend back",size:"sm",link:!0,onClick:i})}),testId:"incoming-recommendation-list-item",hideActions:!0,children:[u.jsx($n,{className:"w-80",onClick:s,children:u.jsx("div",{className:"group flex items-center gap-3 hover:cursor-pointer",children:u.jsx("div",{className:"flex grow flex-col",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(wf,{favicon:t.favicon,featured_image:t.featured_image,title:t.title||t.url}),u.jsx("span",{className:"line-clamp-1 font-medium",children:t.title||t.url})]})})})}),u.jsx($n,{className:"hidden w-auto text-left whitespace-nowrap md:visible! md:table-cell!",padding:!1,valign:"middle",onClick:s,children:r===0?u.jsx("span",{className:"text-grey-500 dark:text-grey-900",children:"-"}):u.jsx("div",{className:"mr-2",children:u.jsx("span",{children:So(r)})})}),u.jsx($n,{className:"hidden w-[1%] whitespace-nowrap md:visible! md:table-cell!",valign:"middle",onClick:s,children:r===0?null:u.jsx("div",{className:"-mt-px text-left",children:u.jsx("span",{className:"-mb-px inline-block min-w-[60px] text-left whitespace-nowrap text-grey-700 lowercase",children:o})})}),t.recommending_back&&u.jsx($n,{className:"w-[1%] whitespace-nowrap group-hover/table-row:visible md:invisible",children:u.jsx("div",{className:"mt-1 text-right whitespace-nowrap text-grey-700",children:"Recommending"})})]})},f8=({incomingRecommendations:t,stats:e,pagination:n,showMore:r,isLoading:i})=>i||t.length?u.jsx(Mr,{isLoading:i,pagination:n,showMore:r,hintSeparator:!0,children:t.map(s=>u.jsx(h8,{incomingRecommendation:s,stats:e},s.id))}):u.jsx(li,{children:u.jsx("span",{className:"max-w-[40ch] text-center",children:"No one’s recommended you yet. Once they do, you’ll find them here along with how many memberships they’ve driven."})}),Tg=function(t,e,n){const r={...t};switch(e){case"title":n?delete r.title:r.title="Title is required";break;case"description":n&&n.length>200?r.description="Description cannot be longer than 200 characters":delete r.description;break;default:{const i=e;throw new Error(`Unknown field ${i}`)}}return r},Iy=function(t){let e={};return e=Tg(e,"title",t.title),e=Tg(e,"description",t.description),e};function m8({showURL:t,formState:e,updateForm:n,errors:r,clearError:i,setErrors:s}){const[o,a]=W.useState(e?.description?.length||0),l=o>200?"text-red":"text-green",c=W.useRef(!1);return W.useEffect(()=>{c.current||(c.current=!0,s(Iy(e)))},[e,s]),u.jsxs(K2,{marginBottom:!1,marginTop:!0,children:[u.jsxs("div",{children:[u.jsx(qe,{className:"mb-2 block text-xs font-semibold tracking-wider uppercase",grey:!0,level:6,children:"Preview"}),u.jsx("div",{className:"-mx-8 flex items-center justify-center overflow-hidden border-y border-grey-100 bg-grey-50 px-7 py-4 dark:border-grey-950 dark:bg-black",children:u.jsx("div",{className:"w-full rounded bg-white py-3 shadow",children:u.jsx("div",{className:"",children:u.jsxs("a",{className:"flex items-center justify-between bg-white px-5 py-3",href:e.url,rel:"noopener noreferrer",target:"_blank",children:[u.jsxs("div",{className:"flex flex-col gap-[2px]",children:[u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx(wf,{...e}),u.jsx("span",{className:"text-[1.6rem] font-semibold text-grey-900",children:e.title})]}),e.description&&u.jsx("span",{className:"pl-[31px] text-[1.35rem] leading-snug text-grey-700",children:e.description})]}),e.one_click_subscribe&&u.jsx("span",{className:"flex pl-6 text-md font-semibold whitespace-nowrap text-green",children:"Subscribe"})]})})})}),e.one_click_subscribe&&u.jsx(on,{children:"This is a Ghost site, so your readers can subscribe with just one click"})]}),t&&u.jsx(K5,{disabled:!0,title:"URL",value:e.url,onChange:d=>n(h=>({...h,url:d||""}))}),u.jsx(at,{autoFocus:!0,error:!!r.title,hint:r.title,maxLength:2e3,title:"Title",value:e.title??"",onChange:d=>{i?.("title"),n(h=>({...h,title:d.target.value}))}}),u.jsx(rb,{error:!!r.description,hint:u.jsxs(u.Fragment,{children:["Max: ",u.jsx("strong",{children:"200"})," characters. You’ve used ",u.jsx("strong",{className:l,children:o})]}),rows:4,title:"Short description",value:e.description??"",onChange:d=>{i?.("description"),a(d.target.value.length),n(h=>({...h,description:d.target.value}))}})]})}const p8=({recommendation:t,animate:e})=>{const n=an(),{updateRoute:r}=fe(),{mutateAsync:i}=u8(),{mutateAsync:s}=c8(),o=Ye(),{formState:a,updateForm:l,handleSave:c,errors:d,clearError:h,setErrors:f,okProps:m}=zl({initialState:{...t},savingDelay:500,savedDelay:500,onSave:async g=>{await i(g)},onSaveError:o,onValidate:g=>Iy(g)}),p={label:"Delete",link:!0,color:"red",size:"sm",onClick:()=>{n.remove(),pe.show(Wt,{title:"Delete recommendation",prompt:u.jsx(u.Fragment,{children:u.jsxs("p",{children:["Your recommendation ",u.jsx("strong",{children:t.title})," will no longer be visible to your audience."]})}),okLabel:"Delete",onOk:async g=>{try{await s(t),g?.remove()}catch(b){rn({title:"Failed to delete the recommendation",message:"Please try again later.",type:"error"}),o(b,{withToast:!1})}}})}};return u.jsx(Fr,{afterClose:()=>{r("recommendations")},animate:e??!0,backDropClick:!1,buttonsDisabled:m.disabled,cancelLabel:"Close",leftButtonProps:p,okColor:m.color,okLabel:m.label||"Save",size:"sm",testId:"edit-recommendation-modal",title:"Edit recommendation",stickyFooter:!0,onOk:async()=>{Uw();try{await c({force:!0})}catch{rn({title:"Something went wrong",type:"error",message:"Please try again later."})}},children:u.jsx(m8,{clearError:h,errors:d,formState:a,setErrors:f,showURL:!0,updateForm:l})})},g8=pe.create(p8),b8=({recommendation:t})=>{const{route:e}=fe(),n=()=>{pe.show(g8,{pathName:e,animate:!1,recommendation:t})},r=t.one_click_subscribe,i=r&&!!t.count?.subscribers,s=(i?t.count?.subscribers:t.count?.clicks)||0,o=s===1?"signup":"signups",a=s===1?"click":"clicks";return u.jsxs(ls,{className:"group hover:cursor-pointer",testId:"recommendation-list-item",onClick:n,children:[u.jsx($n,{className:"w-80",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(wf,{isGhostSite:r,...t}),u.jsx("span",{className:"line-clamp-1 font-medium",children:t.title})]})}),u.jsx($n,{className:"hidden w-auto text-left align-middle whitespace-nowrap md:visible! md:table-cell!",children:s===0?u.jsx("span",{className:"text-grey-500 dark:text-grey-900",children:"-"}):u.jsx(u.Fragment,{children:u.jsxs("div",{className:"flex items-center",children:[u.jsx("div",{className:"mr-2",children:u.jsx("span",{children:So(s)})}),u.jsxs("div",{className:"text-grey-700 lowercase",children:[u.jsx("span",{children:i?o:a}),u.jsx("span",{className:"invisible group-hover:visible",children:" from you"})]})]})})})]})},v8=({recommendations:t,pagination:e,showMore:n,isLoading:r})=>{const{siteData:i}=Ft(),s=`${i?.url.replace(/\/$/,"")}/#/portal/recommendations`,{updateRoute:o}=fe(),a=()=>{o("recommendations/add")},[l,c]=v.useState(!1),d=()=>{navigator.clipboard.writeText(s),c(!0),setTimeout(()=>c(!1),2e3)};return r||t.length?u.jsx(Mr,{hint:u.jsxs("span",{children:["Shared with new members after signup, or anytime using ",u.jsx(no,{href:s,target:"_blank",children:"this link"}),u.jsx(sb,{containerClassName:"ml-1 align-middle leading-none",content:l?"Copied":"Copy link",size:"sm",children:u.jsx(J,{color:"clear",hideLabel:!0,icon:l?"check-circle":"duplicate",iconColorClass:l?"text-green w-[14px] h-[14px]":"text-grey-600 hover:opacity-80 w-[14px] h-[14px]",label:l?"Copied":"Copy",unstyled:!0,onClick:d})})]}),isLoading:r,pagination:e,showMore:n,hintSeparator:!0,children:t&&t.map(h=>u.jsx(b8,{recommendation:h},h.id))}):u.jsxs(li,{children:[u.jsx(J,{color:"grey",label:"Add first recommendation",size:"sm",onClick:()=>{a()}}),u.jsxs("span",{className:"mt-2 max-w-[40ch] text-center text-sm",children:["Need inspiration? ",u.jsx(no,{href:"https://ghost.org/explore",target:"_blank",children:"Explore thousands of sites"})]})]})},x8=({keywords:t})=>{const{saveState:e,handleSave:n}=Ft(),{data:{meta:r,recommendations:i}={},isLoading:s,hasNextPage:o,fetchNextPage:a}=l8({searchParams:{include:"count.clicks,count.subscribers",order:"created_at desc",limit:"5"},getNextPageParams:(M,E)=>{if(!M.meta)return;const{limit:j,page:T,pages:N}=M.meta.pagination;if(T>=N)return;const D=typeof j=="number"&&j<100?1:T+1;return{...E,page:D.toString(),limit:"100"}},keepPreviousData:!0}),l={hasMore:!!o,loadMore:a},{data:{recommendations:c,meta:d}={},isLoading:h,hasNextPage:f,fetchNextPage:m}=d8({searchParams:{limit:"5",order:"created_at desc"},getNextPageParams:(M,E)=>{if(!M.meta)return;const{limit:j,page:T,pages:N}=M.meta.pagination;if(T>=N)return;const D=typeof j=="number"&&j<100?1:T+1;return{...E,page:D.toString(),limit:"100"}},keepPreviousData:!0}),{data:{stats:p}={},isLoading:g}=S2({}),b={hasMore:!!f,loadMore:m},[x,y]=v.useState("your-recommendations"),w=[{id:"your-recommendations",title:"Your recommendations",counter:r?.pagination?.total,contents:u.jsx(v8,{isLoading:s,recommendations:i??[],showMore:l})},{id:"recommending-you",title:"Recommending you",counter:d?.pagination?.total,contents:u.jsx(f8,{incomingRecommendations:c??[],isLoading:h||g,showMore:b,stats:p??[]})}],k=u.jsx(u.Fragment,{children:"Recommend any publication that your audience will find valuable, and find out when others are recommending you."}),{updateRoute:C}=fe(),S=()=>{C("recommendations/add")},A=u.jsx(J,{className:"mt-[-5px] hidden md:!visible md:!block",color:"clear",label:"Add recommendation",size:"sm",onClick:()=>{S()}});return u.jsxs(Se,{beta:!0,customButtons:A,description:k,keywords:t,navid:"recommendations",saveState:e,testId:"recommendations",title:"Recommendations",onSave:n,children:[u.jsx("div",{className:"flex justify-center rounded border border-green px-4 py-2 md:hidden",children:u.jsx(J,{color:"light-grey",label:"Add recommendation",link:!0,onClick:()=>{S()}})}),u.jsx(hr,{selectedTab:x,tabs:w,onTabChange:y})]})},y8=Ce(x8,"Recommendations"),Je={network:["growth","network","activitypub","blog","fediverse","sharing"],explore:["ghost explore","explore","growth","share","list","listing"],recommendations:["growth","recommendations","recommend","blogroll"],embedSignupForm:["growth","embeddable signup form","embeddable form","embeddable sign up form","embeddable sign up"],offers:["growth","offers","discounts","coupons","promotions"]},w8=()=>{const{config:t,settings:e}=ke(),n=nr(e||[],t||{}),r=[Je.network,Je.explore,Je.recommendations,Je.embedSignupForm,...n?[Je.offers]:[]].flat();return u.jsxs(ui,{keywords:r,title:"Growth",children:[u.jsx(i8,{keywords:Je.network}),u.jsx(t8,{keywords:Je.explore}),u.jsx(y8,{keywords:Je.recommendations}),u.jsx(J6,{keywords:Je.embedSignupForm}),n&&u.jsx(o8,{keywords:Je.offers})]})},Dg=[{value:"public",label:"Public",hint:"Anyone can visit and read the website"},{value:"private",label:"Private",hint:"Access code required"}],Og=[{value:"all",label:"Public",hint:"Anyone can sign up and log in"},{value:"paid",label:"Paid-members only",hint:"A paid Stripe subscription is required to sign up"},{value:"invite",label:"Invite-only",hint:"People can sign in but won't be able to sign up"},{value:"none",label:"Nobody",hint:"Disable all member features, including newsletters"}],Ig=[{value:"public",label:"Public",hint:"All site visitors to your site, no login required"},{value:"members",label:"Members only",hint:"All logged-in members"},{value:"paid",label:"Paid-members only",hint:"Only logged-in members with an active Stripe subscription"},{value:"tiers",label:"Specific tiers",hint:"Members with any of the selected tiers"}],Pg=[{value:"all",label:"All members",hint:"Logged-in members"},{value:"paid",label:"Paid-members only",hint:"Only logged-in members with an active Stripe subscription"},{value:"off",label:"Nobody",hint:"Disable commenting completely"}],k8=({keywords:t})=>{const{settings:e}=ke(),r=fs()?.isDisabled("publicSiteAccess"),i=Tu(e,"is_private")||Tu(e,"password"),{mutateAsync:s}=Ww(),[o,a]=W.useState(!1),{localSettings:l,isEditing:c,saveState:d,siteData:h,handleSave:f,handleCancel:m,updateSetting:p,handleEditingChange:g,errors:b,clearError:x}=Ft({onValidate:()=>y&&!w?{password:"Enter an access code"}:{}}),[y,w,k,C,S,A]=we(l,["is_private","password","members_signup_access","default_content_visibility","default_content_visibility_tiers","comments_enabled"]),[M,E]=we(e,["is_private","public_hash"]),j=i?!0:y,{data:{tiers:T}={}}=rh(),N=[{label:"Active Tiers",options:T?.filter(({active:_})=>_).map(_=>({value:_.id,label:_.name}))||[]},{label:"Archived Tiers",options:T?.filter(({active:_})=>!_).map(_=>({value:_.id,label:_.name}))||[]}],D=JSON.parse(S||"[]"),O=N.flatMap(_=>_.options).filter(_=>D.includes(_.value)),L=M&&j&&h?.url&&E?`${h.url.replace(/\/$/,"")}/${E}/rss`:null,$=_=>{const te=_.map(ce=>ce.value);p("default_content_visibility_tiers",JSON.stringify(te))},U=async()=>{a(!0);try{const te=(await s(null)).settings.find(ce=>ce.key==="password")?.value;typeof te=="string"&&(p("password",te),x("password"))}catch{rn({type:"error",title:"Could not regenerate access code"})}finally{a(!1)}},q=u.jsxs(tt,{className:"gap-y-4",columns:1,children:[r&&u.jsx("div",{className:"-m-5 overflow-hidden p-5",children:u.jsxs(Kw,{className:"mb-2 flex w-full cursor-default flex-col gap-4 border-0 p-6 pt-5 transition-none hover:translate-y-0 hover:scale-100 hover:shadow-[-7px_-6px_42px_8px_rgb(75_225_226_/_28%),7px_6px_42px_8px_rgb(202_103_255_/_32%)] md:flex-row md:items-center md:justify-between dark:hover:shadow-[-7px_-6px_42px_8px_rgb(75_225_226_/_36%),7px_6px_42px_8px_rgb(202_103_255_/_38%)]",size:"lg",variant:"gradient",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-base font-semibold",children:"Pre-launch mode"}),u.jsx("div",{className:"mt-2 text-gray-700",children:"During your free trial, a private access code is required to browse your site. When you're ready to launch, pick a plan to upgrade your account and make everything public."})]}),u.jsx(Nr,{className:"shrink-0 self-start md:self-center",asChild:!0,children:u.jsx("a",{href:"#/pro/billing/plans",children:"Upgrade now"})})]})}),u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px]",children:"Who should be able to browse your site?"}),u.jsx("div",{className:"w-full md:flex-1",children:u.jsx(ir,{containerClassName:i?"relative z-10":void 0,disabled:i,options:Dg,selectedOption:Dg.find(_=>_.value===(j?"private":"public")),testId:"site-visibility-select",onSelect:_=>{p("is_private",_?.value==="private"),g(!0)}})})]}),(j||i)&&u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row md:items-start",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px] md:pt-3",children:"What access code should visitors use?"}),u.jsxs("div",{className:"w-full md:flex-1",children:[u.jsx(at,{containerClassName:i?"relative z-10":void 0,"data-testid":"site-access-code",disabled:i,error:!!b.password,hint:b.password,placeholder:"Enter access code",rightPlaceholder:u.jsx("span",{className:"flex h-full items-center",children:u.jsx("button",{"aria-label":"Regenerate access code",className:"mr-[5px] flex size-5 cursor-pointer items-center justify-center p-0 text-grey-900 disabled:cursor-not-allowed disabled:opacity-40 dark:text-grey-400","data-testid":"regenerate-access-code",disabled:o,title:"Regenerate access code",type:"button",onClick:U,children:u.jsx(Gw,{"aria-hidden":!0,className:"size-3.5",strokeWidth:1.5})})}),title:"Access code",value:w||"",hideTitle:!0,onChange:_=>{p("password",_.target.value),g(!0)},onKeyDown:()=>x("password")}),L&&!i&&u.jsx(on,{className:"mt-2",children:u.jsxs(u.Fragment,{children:["A private RSS feed is available ",u.jsx("a",{className:"text-green",href:L,rel:"noopener noreferrer",target:"_blank",children:"here"})]})})]})]}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px]",children:"Who should be able to subscribe to your site?"}),u.jsx("div",{className:"w-full md:flex-1",children:u.jsx(ir,{options:Og,selectedOption:Og.find(_=>_.value===k),testId:"subscription-access-select",onSelect:_=>{p("members_signup_access",_?.value||null),g(!0)}})})]}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px]",children:"Who should have access to new posts?"}),u.jsx("div",{className:"w-full md:flex-1",children:u.jsx(ir,{options:Ig,selectedOption:Ig.find(_=>_.value===C),testId:"default-post-access-select",onSelect:_=>{p("default_content_visibility",_?.value||null),g(!0)}})})]}),C==="tiers"&&u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px]",children:"Select specific tiers"}),u.jsx("div",{className:"w-full md:flex-1",children:u.jsx(nb,{color:"black",options:N.filter(_=>_.options.length>0),testId:"tiers-select",values:O,onChange:_=>{$(_),g(!0)}})})]}),u.jsx(Tt,{className:"border-grey-200 dark:border-grey-900"}),u.jsxs("div",{className:"flex flex-col content-center items-center gap-4 md:flex-row",children:[u.jsx("div",{className:"w-full max-w-none min-w-[160px] md:w-2/3 md:max-w-[320px]",children:"Who can comment on posts?"}),u.jsx("div",{className:"w-full md:flex-1",children:u.jsx(ir,{options:Pg,selectedOption:Pg.find(_=>_.value===A),testId:"commenting-select",title:"",onSelect:_=>{p("comments_enabled",_?.value||null),g(!0)}})})]})]});return u.jsx(Se,{description:"Set up who can browse your site, subscribe, read posts, and comment",isEditing:c,keywords:t,navid:"members",saveState:d,testId:"access",title:"Access",hideEditButton:!0,onCancel:m,onEditingChange:g,onSave:f,children:q})},S8=Ce(k8,"Access"),C8=({keywords:t})=>{const{siteData:e}=ke(),[n,r]=v.useState(!1),i=`${e?.url.replace(/\/$/,"")}/#/portal/gift`,s=()=>{navigator.clipboard.writeText(i),r(!0),setTimeout(()=>r(!1),2e3)},o=()=>{window.open(i,"_blank")};return u.jsx(Se,{description:u.jsxs(u.Fragment,{children:["Allow your readers to share your work by purchasing a gift subscription for a friend or colleague. ",u.jsx("a",{className:"text-green",href:"https://ghost.org/help/gift-subscriptions/",rel:"noopener noreferrer",target:"_blank",children:"Learn more"})]}),keywords:t,navid:"gift-subscriptions",testId:"gift-subscriptions",title:"Gift subscriptions",hideEditButton:!0,children:u.jsx(tt,{columns:1,children:u.jsxs("div",{className:"w-100",children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx(qe,{level:6,children:"Shareable link"})}),u.jsxs("div",{className:"group relative mt-0 flex w-100 items-center justify-between overflow-hidden border-b border-transparent pt-1 pb-2 hover:border-grey-300 dark:hover:border-grey-600",children:[u.jsx("span",{"data-testid":"gift-url",children:i}),u.jsxs("div",{className:"invisible flex gap-1 bg-white pl-1 group-hover:visible dark:bg-black",children:[u.jsx(J,{color:"clear","data-testid":"preview-shareable-link",label:"Preview",size:"sm",onClick:o}),u.jsx(J,{color:"light-grey","data-testid":"copy-shareable-link",label:n?"Copied":"Copy link",size:"sm",onClick:s})]})]})]})})})},A8=Ce(C8,"Gift subscriptions"),M8=()=>{const{settings:t,siteData:e}=ke(),[n,r=!1,i=!1]=we(t,["members_signup_access","donations_enabled","recommendations_enabled"]);if(typeof n!="string")throw new TypeError("members_signup_access should be a string");if(typeof r!="boolean")throw new TypeError("donations_enabled should be a boolean");if(typeof i!="boolean")throw new TypeError("recommendations_enabled should be a boolean");return t2({siteUrl:e.url,membersSignupAccess:n,donationsEnabled:r,recommendationsEnabled:i})},E8={useFileUpload:o2,fileTypes:s2},j8=Le("text-[1.6rem] leading-[1.6] tracking-[-0.01em] pb-10","dark:text-white dark:selection:bg-[rgba(88,101,116,0.99)]","[&_.koenig-lexical-editor-input-placeholder]:font-sans! [&_.koenig-lexical-editor-input-placeholder]:text-[1.6rem] [&_.koenig-lexical-editor-input-placeholder]:tracking-tight","[&_:is(h2,h3)]:dark:text-white","[&_.koenig-lexical_input]:text-[1.4rem]","[&_[data-kg-plus-button]]:top-[-4px]","[&_[data-kg-card-selected]]:isolate","[&_:is(p,blockquote,aside,ul,ol)]:tracking-tight","[&_figcaption_:is(p,blockquote,aside,ul,ol)]:text-[1.4rem] [&_figcaption_:is(p,blockquote,aside,ul,ol)]:tracking-[.025em]","[&_figcaption_p]:mb-0","[&_:is(h1)]:text-[36px] [&_:is(h2)]:text-[32px] [&_:is(h3)]:text-[26px] [&_:is(h4)]:text-[21px] [&_:is(h5)]:text-[19px] [&_:is(h6)]:text-[19px] [&_:is(h1,h2,h3,h4,h5,h6)]:mb-[0.5em]","[&_:is(hr)]:pt-0","[&_p]:mb-4 [&_strong]:font-semibold","[&_[data-kg-settings-panel]_p]:!mb-0","[&_.not-kg-prose>div]:font-sans! [&_.not-kg-prose>div]:tracking-tight! [&_.not-kg-prose>div]:text-[1.6rem]! [&_.not-kg-prose>div]:leading-[1.6]!","[&_.kg-inherit-styles_p]:mb-0!","[&_.kg-inherit-styles]:pt-[3px]!","[&_.koenig-lexical-cta-label_p]:!text-[12.5px]"),N8=({editor:t,darkMode:e,cardConfig:n,initialEditorState:r,placeholder:i,className:s,registerAPI:o,onChange:a})=>{const c=t.read().EmailEditor;return u.jsx("div",{className:Le("koenig-react-editor w-full",j8,s),children:u.jsx(c,{cardConfig:n,className:"koenig-lexical koenig-lexical-editor-input",darkMode:e,fileUploader:E8,initialEditorState:r,placeholderText:i,registerAPI:o,onChange:a})})},T8=({value:t,placeholder:e,className:n,onChange:r})=>{const i=v.useRef(null),s=v.useRef(t),{unsplashConfig:o}=Ug(),a=n2(),{config:l,settings:c}=ke(),{fetchAutocompleteLinks:d,searchLinks:h}=M8(),f=r2(),m=l.tenor?.googleApiKey?l.tenor:null,p=l.klipy?.apiKey?l.klipy:null,{fetchKoenigLexical:g,darkMode:b}=ah(),x=v.useMemo(()=>f0(g),[g]),[y]=we(c,["transistor"]),w=v.useMemo(()=>({unsplash:o,pinturaConfig:a,tenor:m,klipy:p,fetchEmbed:f,fetchAutocompleteLinks:d,searchLinks:h,feature:{transistor:y},visibilitySettings:"none"}),[o,a,m,p,f,d,h,y]),k=v.useCallback(M=>{i.current=M},[]),C=v.useCallback(M=>{r&&M&&typeof M=="object"&&r(JSON.stringify(M))},[r]),S=v.useCallback(M=>{(M.metaKey||M.ctrlKey)&&M.key==="k"&&M.stopPropagation()},[]),A=M=>{i.current&&i2(i.current,M)};return u.jsx("div",{className:"h-full",onKeyDown:S,onMouseDown:A,children:u.jsx(lh,{name:"email-editor",children:u.jsx(v.Suspense,{fallback:u.jsx(Ul,{delay:200,size:"lg"}),children:u.jsx(N8,{cardConfig:w,className:n,darkMode:b,editor:x,initialEditorState:s.current,placeholder:e,registerAPI:k,onChange:C})})})})},D8=W.memo(T8),O8=({previewState:t})=>{const[e,n]=v.useState(null),[r,i]=v.useState(!1),s=v.useRef(!1),o=v.useRef(null),a=v.useRef(null),l=v.useRef(null),c=v.useRef(null);function d(){a.current?.disconnect(),a.current=null,l.current!==null&&(window.cancelAnimationFrame(l.current),l.current=null),c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)}const h=t.status==="success"?t.html:"";v.useEffect(()=>(d(),s.current=!1,i(!1),n(null),()=>{d()}),[h,t.status]);function f(){const b=o.current,x=b?.contentDocument;if(!b||!x)return;x.documentElement.style.overflowY="hidden",x.body.style.overflowY="hidden";const y=Math.max(x.documentElement?.scrollHeight||0,x.body?.scrollHeight||0,x.documentElement?.offsetHeight||0,x.body?.offsetHeight||0);y>0&&(n(w=>w===y?w:y),!s.current&&c.current===null&&(c.current=window.requestAnimationFrame(()=>{c.current=window.requestAnimationFrame(()=>{c.current=null,s.current=!0,i(!0)})})))}function m(){l.current!==null&&window.cancelAnimationFrame(l.current),l.current=window.requestAnimationFrame(()=>{l.current=null,f()})}function p(){const b=o.current,x=b?.contentDocument;if(!(!b||!x)&&(d(),m(),typeof ResizeObserver<"u")){const y=new ResizeObserver(()=>{m()});y.observe(x.documentElement),y.observe(x.body),a.current=y}}const g=t.status==="loading"||t.status==="success"&&!r;return u.jsxs("div",{className:"relative w-full","data-testid":"welcome-email-preview",children:[g&&u.jsx("div",{className:"flex min-h-full items-start justify-center pt-24","data-testid":"welcome-email-preview-loading",style:e?{height:`${e}px`}:void 0,children:u.jsx(Ul,{})}),t.status==="success"&&u.jsx("div",{"aria-hidden":!r,className:Le("w-full",!r&&"pointer-events-none absolute left-0 top-0 opacity-0"),children:u.jsx("iframe",{ref:o,className:"w-full rounded bg-white","data-testid":"welcome-email-preview-iframe",sandbox:"allow-same-origin allow-popups allow-popups-to-escape-sandbox",srcDoc:t.html,style:{height:e?`${e}px`:"600px"},title:"Welcome email preview",onLoad:p})}),(t.status==="error"||t.status==="invalid")&&u.jsx("div",{className:"flex h-full items-center justify-center px-4","data-testid":"welcome-email-preview-error",children:u.jsx(on,{color:"red",children:t.message})})]})},I8=t=>{if(!t)return!0;try{const n=JSON.parse(t)?.root?.children;return!n||n.length===0||n.length===1&&n[0].type==="paragraph"&&(!n[0].children||n[0].children.length===0)}catch{return!0}},Py=t=>{const e={};return t.subject?.trim()||(e.subject="A subject is required"),I8(t.lexical)&&(e.lexical="Email content is required"),e},P8=t=>{if(typeof DOMParser>"u")return t;const n=new DOMParser().parseFromString(t,"text/html");return n.querySelectorAll("a[href]").forEach(r=>{r.target="_blank",r.rel="noopener noreferrer"}),`<!doctype html>${n.documentElement.outerHTML}`},R8=t=>{const e="Failed to render preview";return t instanceof qg&&t.data?.errors?.[0]?t.data.errors[0].context||t.data.errors[0].message||e:t instanceof Error&&t.message?t.message:e},L8=({automatedEmailId:t,previewWelcomeEmail:e,setErrors:n})=>{const[r,i]=v.useState({status:"idle"}),s=v.useRef(0),o=()=>{s.current+=1,i({status:"idle"})},a=async c=>{const d=s.current+1;s.current=d;const h=Py(c);if(n(h),!!(h.subject||h.lexical)){i({status:"invalid",message:h.subject||h.lexical});return}i({status:"loading"});try{const m=await e({id:t,subject:c.subject,lexical:c.lexical});if(s.current!==d)return;const p=m.automated_emails?.[0];if(!p?.html||!p?.plaintext||!p?.subject)throw new Error("Preview response was incomplete");i({status:"success",preview:{...p,html:P8(p.html)}})}catch(m){if(s.current!==d)return;i({status:"error",message:R8(m)})}};let l={status:"loading"};return r.status==="success"?l={status:"success",html:r.preview.html}:(r.status==="error"||r.status==="invalid")&&(l={status:r.status,message:r.message}),{previewFrameState:l,previewState:r,enterPreview:a,exitPreview:o}},_8=({automatedEmailId:t,subject:e,lexical:n,validateForm:r,onClose:i})=>{const{data:s}=Hg(),{mutateAsync:o}=a2(),[a,l]=v.useState(s?.email||""),[c,d]=v.useState(""),[h,f]=v.useState("idle"),m=v.useRef(null);v.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),v.useEffect(()=>{s?.email&&l(s.email)},[s?.email]),v.useEffect(()=>{const g=b=>{b.key==="Escape"&&(b.stopPropagation(),i())};return document.addEventListener("keydown",g,!0),()=>document.removeEventListener("keydown",g,!0)},[i]);const p=async()=>{if(d(""),!wt.isEmail(a)){d("Please enter a valid email address");return}if(!r()){d("Please complete the required fields");return}f("sending");try{await o({id:t,email:a,subject:e,lexical:n}),f("sent"),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>f("idle"),2e3)}catch(g){f("idle");let b;g instanceof qg&&g.data&&g.data.errors[0]?b=g.data.errors[0].context||g.data.errors[0].message:g instanceof Error&&(b=g.message),d(b||"Failed to send test email")}};return u.jsxs("div",{className:"absolute top-full right-0 z-10 mt-2 w-[260px] rounded border border-grey-200 bg-white p-4 shadow-lg dark:border-grey-900 dark:bg-grey-950","data-testid":"test-email-dropdown",children:[u.jsxs("div",{className:"mb-3",children:[u.jsx("label",{className:"mb-2 block font-semibold",htmlFor:"test-email-input",children:"Send test email"}),u.jsx(at,{className:"h-[36px]!",id:"test-email-input",placeholder:"you@yoursite.com",value:a,onChange:g=>{l(g.target.value)}})]}),u.jsx(J,{className:"w-full",color:h==="sent"?"green":"black",disabled:h==="sending",label:h==="sent"?"Sent":h==="sending"?"Sending...":"Send",onClick:p}),c&&u.jsx(on,{className:"mt-2",color:"red",children:c})]})},Ry=W.forwardRef(({title:t,centeredHeaderContent:e,headerActions:n,children:r,className:i,isEditMode:s=!1},o)=>u.jsxs("div",{ref:o,className:Le("flex h-full w-full flex-col gap-0 overflow-hidden rounded-xl p-0",s?"bg-white":"bg-gray-100","dark:bg-gray-950",i),children:[u.jsxs("div",{className:"sticky top-0 grid shrink-0 grid-cols-[1fr_auto_1fr] items-center border-b border-gray-200 bg-white px-5 py-3 dark:border-gray-900 dark:bg-gray-950",children:[u.jsx("h3",{className:"justify-self-start text-xl font-semibold",children:t}),u.jsx("div",{className:"justify-self-center",children:e}),u.jsx("div",{className:"flex items-center gap-2 justify-self-end",children:n})]}),u.jsx("div",{className:"flex h-[clamp(0px,calc(100dvh-320px),82vh)] min-h-0 grow flex-col overflow-y-auto [scrollbar-gutter:stable]",children:r})]}));Ry.displayName="EmailPreviewModalContent";const F8=({children:t,className:e})=>u.jsx("div",{className:Le("relative z-20 isolate mx-auto w-full max-w-[780px] rounded-t-lg border border-b-0 border-gray-200 bg-white px-6 py-4 transition-[max-width,padding] duration-300 ease-out motion-reduce:transition-none dark:border-grey-900 dark:bg-grey-950",e),children:t}),B8=({children:t,className:e})=>u.jsx("div",{className:Le("flex mx-auto w-full rounded-b-lg transition-[max-width,height,padding] duration-300 ease-out motion-reduce:transition-none dark:border-grey-900 dark:shadow-none grow max-w-[780px]",e),children:t}),Rg=pe.create(({emailType:t="free",automatedEmail:e})=>{const n=an(),{settings:r,config:i}=ke(),[s,o,a]=we(r,["title","default_email_address","support_email_address"]),{updateRoute:l}=fe(),{mutateAsync:c}=Jg(),{mutateAsync:d}=l2(),{data:h}=eh(),[f,m]=v.useState(!1),[p,g]=v.useState("edit"),[b,x]=v.useState(null),y=v.useRef(null),w=v.useRef(e?.lexical||""),k=v.useRef(!1),C=Ye(),S=h?.automated_emails||[],{resolvedSenderName:A,resolvedSenderEmail:M,resolvedReplyToEmail:E,hasDistinctReplyTo:j}=ky(S,{config:i,defaultEmailAddress:o,siteTitle:s,supportEmailAddress:a}),N=`${t==="paid"?"Paid":"Free"} members welcome email`,{formState:D,saveState:O,updateForm:L,setFormState:$,setErrors:U,handleSave:q,okProps:_,errors:te,validate:ce}=zl({initialState:{subject:e?.subject||"Welcome",lexical:e?.lexical||""},savingDelay:500,onSave:async se=>{await c({...e,...se})},onSaveError:C,onValidate:Py}),G=_.label||"Save",{previewFrameState:oe,enterPreview:B,exitPreview:Y}=L8({automatedEmailId:e.id,previewWelcomeEmail:d,setErrors:U}),ee=O==="unsaved",ae=v.useCallback(()=>{Ui(ee,()=>{n.remove()})},[n,ee]);v.useEffect(()=>{const se=ie=>{y.current&&!y.current.contains(ie.target)&&m(!1)};return f&&document.addEventListener("mousedown",se),()=>{document.removeEventListener("mousedown",se)}},[f]);const ue=v.useRef(q);v.useEffect(()=>{ue.current=q},[q]),v.useEffect(()=>{const se=ie=>{(ie.metaKey||ie.ctrlKey)&&ie.key==="s"&&(ie.preventDefault(),ue.current({fakeWhenUnchanged:!0}))};return window.addEventListener("keydown",se),()=>{window.removeEventListener("keydown",se)}},[]);const ve=v.useCallback(se=>{g(se),se==="preview"?(x(null),B(D)):(m(!1),x(null),Y())},[B,Y,D]),X=v.useCallback(se=>{if(!k.current){w.current=se,$(ie=>({...ie,lexical:se}));return}se!==w.current?L(ie=>({...ie,lexical:se})):$(ie=>({...ie,lexical:se}))},[$,L]);return u.jsx(Fr,{afterClose:()=>{l("memberemails")},backDropClick:!1,dirty:ee,footer:!1,header:!1,padding:!1,scrolling:!1,size:"full",testId:"welcome-email-modal",width:"full",children:u.jsx(Ry,{centeredHeaderContent:u.jsx(th,{"data-testid":"welcome-email-mode-toggle",value:p,variant:"segmented-sm",onValueChange:se=>se&&ve(se),children:u.jsxs(nh,{className:"grid w-[240px] grid-cols-2 bg-gray-100 shadow-[inset_0_0_0_1px_rgba(0,0,0,0.04)]",children:[u.jsx(zi,{className:"w-full justify-center data-[state=active]:bg-white dark:data-[state=active]:bg-white dark:data-[state=active]:text-black","data-testid":"welcome-email-mode-edit",value:"edit",children:"Email content"}),u.jsx(zi,{className:"w-full justify-center","data-testid":"welcome-email-mode-preview",value:"preview",children:"Preview"})]})}),className:"dark:bg-[#151719]",headerActions:u.jsxs(u.Fragment,{children:[u.jsx(Nr,{variant:"outline",onClick:ae,children:"Close"}),u.jsx(Nr,{disabled:_.disabled,onClick:async()=>await q({fakeWhenUnchanged:!0}),children:G})]}),isEditMode:p==="edit",title:N,children:u.jsxs("div",{className:"flex grow flex-col items-center p-6",children:[p==="preview"&&u.jsx(F8,{className:"border-x-0 border-t-0 border-b",children:u.jsxs("div",{className:"flex flex-col gap-2",children:[u.jsxs("div",{className:"flex items-center py-1",children:[u.jsx("div",{className:"w-20 shrink-0 font-semibold",children:"From:"}),u.jsx("div",{className:"min-w-0 grow pr-4",children:u.jsxs("span",{className:"flex gap-1 truncate whitespace-nowrap",children:[u.jsx("span",{children:A}),u.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:`<${M}>`})]})}),u.jsxs("div",{ref:y,className:"relative",children:[u.jsx(J,{className:"border border-grey-200 font-semibold hover:border-grey-300 hover:bg-white! dark:border-grey-900 dark:hover:border-grey-800 dark:hover:bg-grey-950!",color:"clear",icon:"send",label:"Test",onClick:()=>m(!f)}),f&&u.jsx(_8,{automatedEmailId:e.id,lexical:D.lexical,subject:D.subject,validateForm:ce,onClose:()=>m(!1)})]})]}),j&&u.jsxs("div",{className:"flex items-center",children:[u.jsx("div",{className:"w-20 shrink-0 font-semibold",children:"Reply-to:"}),u.jsx("div",{className:"grow text-gray-500 dark:text-gray-400",children:E})]}),u.jsxs("div",{className:"flex items-center",children:[u.jsx("div",{className:"w-20 shrink-0 font-semibold",children:"Subject:"}),u.jsxs("div",{className:"grow",children:[u.jsx(at,{className:"w-full","data-testid":"welcome-email-preview-subject",value:b??D.subject,onChange:se=>{const ie=se.target.value;x(ie),L(Ne=>({...Ne,subject:ie}))}}),te.subject&&u.jsx(on,{className:"mt-2",color:"red",children:te.subject})]})]})]})}),u.jsxs(B8,{className:Le(p==="preview"&&"shadow-sm bg-white dark:bg-grey-950",p==="edit"&&"px-6",p==="edit"&&"rounded-lg",p==="edit"&&te.lexical&&"border border-red-500"),children:[u.jsx("div",{className:Le("mx-auto w-full max-w-[600px] pt-10 pb-8 transition-[max-width,padding] duration-300 ease-out motion-reduce:transition-none",p==="preview"&&"hidden"),"data-testid":"welcome-email-editor",onFocus:()=>{k.current=!0},children:u.jsx(D8,{className:"welcome-email-editor",placeholder:"Begin writing your email...",value:D.lexical,onChange:X},e?.id||"new")}),p==="preview"&&u.jsx(O8,{previewState:oe})]}),p==="edit"&&te.lexical&&u.jsx(on,{className:"mt-2 max-w-[740px]",color:"red",children:te.lexical})]})})})}),Lg=({automatedEmail:t,emailType:e,icon:n,title:r,enabled:i,isBusy:s,isInitialLoading:o,onEdit:a,onToggle:l})=>u.jsx(ls,{action:u.jsxs("div",{className:`flex items-center gap-7 ${s&&!o?"pointer-events-none":""}`,children:[o?u.jsx("div",{className:"h-4 w-7 rounded-full bg-grey-300 dark:bg-grey-800"}):u.jsx(en,{checked:i,onChange:l}),u.jsx("button",{className:"font-semibold text-green hover:opacity-80",type:"button",onClick:a,children:"Edit"})]}),hideActions:!1,testId:`${e}-welcome-email-row`,children:u.jsx("div",{className:"w-full",children:u.jsxs("button",{className:"flex w-full min-w-0 items-center gap-3 py-3 text-left focus-visible:ring-2 focus-visible:ring-green focus-visible:ring-offset-2 focus-visible:outline-none dark:focus-visible:ring-offset-black","data-testid":`${e}-welcome-email-preview`,type:"button",onClick:a,children:[u.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-grey-100 dark:bg-grey-900",children:u.jsx(me,{colorClass:"text-grey-700 dark:text-grey-600",name:n,size:"md"})}),u.jsxs("div",{className:"min-w-0 grow",children:[u.jsx("div",{className:"leading-tight font-medium","data-testid":`${e}-welcome-email-title`,children:r}),u.jsx("div",{className:"mt-1 text-sm leading-[1.35] text-grey-700 dark:text-grey-600",children:t.subject})]})]})})}),V8=({settings:t,config:e,freeEmailForDisplay:n,paidEmailForDisplay:r,freeWelcomeEmailEnabled:i,paidWelcomeEmailEnabled:s,isBusy:o,isLoading:a,onFreeEdit:l,onFreeToggle:c,onPaidEdit:d,onPaidToggle:h})=>u.jsxs(Mr,{borderTop:!0,children:[u.jsx(Lg,{automatedEmail:n,emailType:"free",enabled:i,icon:"user-add",isBusy:o,isInitialLoading:a,title:"Free members welcome email",onEdit:l,onToggle:c}),nr(t,e)&&u.jsx(Lg,{automatedEmail:r,emailType:"paid",enabled:s,icon:"bills",isBusy:o,isInitialLoading:a,title:"Paid members welcome email",onEdit:d,onToggle:h})]}),z8=({keywords:t})=>{const{settings:e,config:n}=ke(),[r]=we(e,["title"]),i=Qo().getParam("verifyEmail"),{data:s,isLoading:o}=eh(),{mutateAsync:a,isLoading:l}=Yg(),{mutateAsync:c,isLoading:d}=Jg(),{mutateAsync:h}=Xg(),f=Ye(),m=s?.automated_emails||[],g=o||(l||d),b=m.find(j=>j.slug===Ar.free),x=m.find(j=>j.slug===Ar.paid),y=b?.status==="active",w=x?.status==="active",k=async(j,T)=>{const N=vf(j,r);return a({...N,status:T})},C=v.useRef(null);v.useEffect(()=>{if(!i||!window.location.href.includes("memberemails")||C.current===i)return;C.current=i;const j=()=>{const N=window.location.hash.slice(1),D=new URL(N||"/memberemails",window.location.origin);D.searchParams.delete("verifyEmail");const O=D.search?`#${D.pathname}${D.search}`:`#${D.pathname}`;window.history.replaceState(null,"",`${window.location.pathname}${O}`)};(async()=>{try{const{meta:{email_verified:N}={}}=await h({token:i});j();let D="Sender email verified",O=u.jsx(u.Fragment,{children:"Welcome email sender settings have been updated."});N==="sender_reply_to"&&(D="Reply-to address verified",O=u.jsx(u.Fragment,{children:"Welcome email reply-to address has been verified and updated."})),pe.show(Wt,{title:D,prompt:O,okLabel:"Close",cancelLabel:"",onOk:L=>L?.remove()})}catch(N){let D="There was an error verifying your email address. Try again later.";N instanceof Vl&&N.message==="Token expired"&&(D="Verification link has expired."),j(),pe.show(Wt,{title:"Error verifying email address",prompt:D,okLabel:"Close",cancelLabel:"",onOk:O=>O?.remove()}),f(N,{withToast:!1})}})()},[f,i,h]);const S=async j=>{const T=m.find(D=>D.slug===Ar[j]),N=j==="free"?"Free members":"Paid members";if(!g)try{T?T.status==="active"?(await c({...T,status:"inactive"}),rn({type:"success",title:`${N} welcome email disabled`})):(await c({...T,status:"active"}),rn({type:"success",title:`${N} welcome email enabled`})):(await k(j,"active"),rn({type:"success",title:`${N} welcome email enabled`}))}catch(D){f(D)}},A=async j=>{const T=m.find(N=>N.slug===Ar[j]);if(!g)if(T)pe.show(Rg,{emailType:j,automatedEmail:T});else try{const D=(await k(j,"inactive"))?.automated_emails?.[0];D&&pe.show(Rg,{emailType:j,automatedEmail:D})}catch(N){f(N)}},M=b||Mg("free",r),E=x||Mg("paid",r);return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Customize",size:"sm",onClick:()=>pe.show(Cy)}),description:"Create and manage automated emails for your members",keywords:t,navid:"memberemails",testId:"memberemails",title:"Welcome emails",children:u.jsx(V8,{config:n,freeEmailForDisplay:M,freeWelcomeEmailEnabled:y,isBusy:g,isLoading:o,paidEmailForDisplay:E,paidWelcomeEmailEnabled:w,settings:e,onFreeEdit:()=>A("free"),onFreeToggle:()=>S("free"),onPaidEdit:()=>A("paid"),onPaidToggle:()=>S("paid")})})},$8=Ce(z8,"MemberEmails"),H8="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAcCAQAAADc8cciAAADJ0lEQVR4AYyUA2DsaBCAZ3X2s23btm3btm3btm3btm2VqyT31W3K9DfGkkjNJGaRkeZW8dpl6Zwpz295Al5i2awiCwt5nOQeGxjJUNZ9Or2i5AoRS6xQfW78f1sbTk+6UJ+SpMdEU49HeX4TS8wSWLrEAbU5qZXCDGO0MtF9xHWVB+oGZSjuh0UeipijRe2Umif8Qhd13/kubZOWtAaBZvnpaHpasY2vH4d8DJAtKoHrpOMscTk2r/A8EZNOxMBzr19fTeaJ1wGvKLS3tIrHK6847EGi0c0s8nAIezgxJkMgOf0Hqj0pqxqn1msVGf3LWnU9qx7UfqBzn+neKNqojT/P/CwxdTHX/IcLbNAGnyuv480j/mPLvLSG4WBRq3BLW8C0Zr8HyzggB2MpzS7EuN+tSD1OaEOud7su1wOEXtKAcjTxXeYrxn1GTn5nMytZl8eWRySPvF9ELSozu0ycMmLUu6QgLRXYxMqemQKVdM9jLCXoMjDXQDHqhf4jB39ynHF7W+8V2SvKaBaQl6bdinUToy5WSvI3Sxj3bMKzAAu6WzCY8VTc0jw2yfexLKnoxHrvWd4i3uIowUBGMMo+3S7G/XJFslCc/fYpdhG7PC1FZsYylV2DExnnraMNecnCbu+R3iJiGpSeJMyggTLNfsUec9qbeyejKSUoybr7be+L3PfvvjVcmVlAL3dPLpWJEx16wLs2g9JkYhGLuiYOspC58b8U0LrSnqH+6Ic25tDljS4x89i+LKICBciu3Hzd67W8FglczNOSUc/Zmeb0V8az7Hbl23rxTSKVE55qwESlCAWIo1xWt6iizz9z+d99RzFKbUJHbbk24d2Ad/JOKv1cNcnYvGerO9pSm7z+vRxJOM3+qXHFHClf52dnpjaaHZxX9rpuOFpSjIJkJSNZSEMmGlOV1+5eL3O/lKAuL3VdzGI6V5qSSnFGsJWbXGAFA2lJA7qygItMJ+Hjco91IkfiXzj+0bquBtRSW9OYNgxmGetZSB/iU/pQxkPRoupKXvn4s/I8LO1ZicqUIAfZFb/ZHtY3ZoXIEQaMMNqBRYXdgcWBAVMjAKGlEzkN2rk9AAAAAElFTkSuQmCC",U8="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAQlBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////8IX9KGAAAAFnRSTlMAQI+v38+/cCD/n3/vkFAwYBCAoLBfxGozVwAAAT1JREFUeAHd1NEO2yAMheGTBhL/idtAu73/q67VFIkRAevVpH13KDkYkGX9C9NtDiEuq/3l7wunzTR2o7RrZAH8/jA70jxKnPvPWb9ZAFb1JOBZrF/AoY4Ad5UiLP0CIat0AKam+XrkpXsLh+Na9IdaMqCKQdBp/HEQyOCqHL2A/Pokj/pdR0+ywV1NK8TLFZjUlB3WukBQxxP4Wax34KGeWHZ0vtG5QdHRIZkk2x2IGrDIhwfn46WRvFPwpIHd+VNI4/P4lg4zm9Z5NDoOB2LKOlkKQLDO/75WNe/tOWAO4VAtuZve9ljlcmgUz1lv+dIjO7ipyeqAAUlfBDZY9EUgO0zfBB6dvt/DBxDezrfa2vMqUzr3jZ0TLRTOWQ1ktdjbBME+qok0uHRrOQ5o4fldQKZxQEODMwyY/h+/ADWjEK3gLf0/AAAAAElFTkSuQmCC",Au=({title:t,color:e,price:n})=>u.jsxs("div",{className:"rounded-lg bg-grey-100/70 px-3 pt-1.5 pb-3",children:[u.jsx("div",{className:"font-space-grotesk text-[1.5rem] font-bold",style:{color:e},children:t}),u.jsx("div",{className:"-mt-1 font-space-grotesk text-[1.7rem] font-bold",children:n}),u.jsxs("div",{className:"mt-5 flex flex-col gap-1.5",children:[u.jsx("div",{className:"h-1.5 w-[100%] bg-grey-300/60"}),u.jsx("div",{className:"h-1.5 w-[70%] bg-grey-300/60"}),u.jsx("div",{className:"h-1.5 w-[90%] bg-grey-300/60"})]})]}),W8=({keywords:t})=>{const{updateRoute:e}=fe(),{settings:n}=ke(),[r,i,s]=we(n,["accent_color","icon","members_signup_access"]),o=()=>{e("portal/edit")},a=r||"#F6414E";return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",disabled:s==="none",label:"Customize",size:"sm",onClick:o}),description:"Customize members modal signup flow",keywords:t,navid:"portal",testId:"portal",title:"Signup portal",children:u.jsxs("div",{className:"relative isolate -mx-5 -mb-5 hidden flex-col items-center justify-end overflow-hidden rounded-b-xl bg-grey-50 px-5 pt-6 text-black sm:visible! sm:flex! md:-mx-7 md:-mb-7",children:[u.jsx("div",{className:"absolute right-6 bottom-6 flex size-12 items-center justify-center rounded-full text-white shadow-lg",style:{backgroundColor:a},children:u.jsx("img",{className:"size-6",src:U8})}),u.jsxs("div",{className:"grid w-full max-w-[440px] grid-cols-3 gap-5 rounded-t-xl bg-white px-9 py-6 shadow-xl",children:[u.jsxs("div",{className:"col-span-3 mb-1 flex flex-col items-center justify-center",children:[i?u.jsx("div",{className:"size-6 rounded-sm bg-cover bg-center",style:{backgroundImage:`url(${i})`}}):u.jsx("div",{className:"flex aspect-square items-center justify-center overflow-hidden rounded-full p-1 text-white",style:{backgroundColor:a},children:u.jsx("img",{className:"h-auto w-5",src:H8})}),u.jsx("div",{className:"mt-1.5 font-space-grotesk text-lg font-bold",children:"Sign up"}),u.jsx("div",{className:"mt-1.5 flex h-6 w-1/2 items-center rounded border border-grey-200 p-2 text-sm text-grey-700",children:"jamie@example.com"})]}),u.jsx(Au,{color:a,price:"$0",title:"Free"}),u.jsx(Au,{color:a,price:"$5",title:"Silver"}),u.jsx(Au,{color:a,price:"$10",title:"Gold"})]})]})})},K8=Ce(W8,"Portal settings"),G8=({keywords:t})=>{const{localSettings:e,isEditing:n,saveState:r,handleSave:i,handleCancel:s,updateSetting:o,errors:a,clearError:l,handleEditingChange:c}=Ft({onValidate:()=>({})}),[d]=we(e,["blocked_email_domains"]),h=JSON.parse(d||"[]"),[f,m]=W.useState(h.join(`
|
|
30
30
|
`)),p=b=>{const x=b.target.value;m(x);const y=x.split(/[\s,]+/).map(w=>w.trim().toLowerCase().split("@").pop()).filter(w=>w&&w.includes("."));o("blocked_email_domains",JSON.stringify(y)),n||c(!0)},g=u.jsxs(u.Fragment,{children:["Prevent unwanted signups by blocking email domains. Add one domain per line, e.g., ",u.jsx("code",{children:"spam.xyz"})," to block signups from email addresses like ",u.jsx("code",{children:"hello@spam.xyz"}),"."]});return u.jsx(Se,{description:"Protect your member signups from spam",isEditing:n,keywords:t,navid:"spam-filters",saveState:r,testId:"spam-filters",title:"Spam filters",hideEditButton:!0,onCancel:s,onEditingChange:c,onSave:i,children:u.jsx(tt,{columns:1,children:u.jsx(rb,{className:"h-[86px]",error:!!a.blockedEmailDomains,hint:a.blockedEmailDomains||g,placeholder:`spam.xyz
|
|
31
|
-
junk.com`,resize:"vertical",title:"Blocked email domains",value:f,onChange:p,onKeyDown:()=>l("spam-filters")})})})},q8=Ce(G8,"Spam Filters"),_g=[{isoCode:"USD",name:"United States dollar"},{isoCode:"EUR",name:"Euro"},{isoCode:"GBP",name:"Pound sterling"},{isoCode:"AUD",name:"Australian dollar"},{isoCode:"CAD",name:"Canadian dollar"},{isoCode:"AED",name:"United Arab Emirates dirham"},{isoCode:"AFN",name:"Afghan afghani"},{isoCode:"ALL",name:"Albanian lek"},{isoCode:"AMD",name:"Armenian dram"},{isoCode:"ANG",name:"Netherlands Antillean guilder"},{isoCode:"AOA",name:"Angolan kwanza"},{isoCode:"ARS",name:"Argentine peso"},{isoCode:"AWG",name:"Aruban florin"},{isoCode:"AZN",name:"Azerbaijani manat"},{isoCode:"BAM",name:"Bosnia and Herzegovina convertible mark"},{isoCode:"BBD",name:"Barbados dollar"},{isoCode:"BDT",name:"Bangladeshi taka"},{isoCode:"BGN",name:"Bulgarian lev"},{isoCode:"BMD",name:"Bermudian dollar"},{isoCode:"BND",name:"Brunei dollar"},{isoCode:"BOB",name:"Boliviano"},{isoCode:"BRL",name:"Brazilian real"},{isoCode:"BSD",name:"Bahamian dollar"},{isoCode:"BWP",name:"Botswana pula"},{isoCode:"BZD",name:"Belize dollar"},{isoCode:"CDF",name:"Congolese franc"},{isoCode:"CHF",name:"Swiss franc"},{isoCode:"CNY",name:"Chinese yuan"},{isoCode:"COP",name:"Colombian peso"},{isoCode:"CRC",name:"Costa Rican colon"},{isoCode:"CVE",name:"Cape Verdean escudo"},{isoCode:"CZK",name:"Czech koruna"},{isoCode:"DKK",name:"Danish krone"},{isoCode:"DOP",name:"Dominican peso"},{isoCode:"DZD",name:"Algerian dinar"},{isoCode:"EGP",name:"Egyptian pound"},{isoCode:"ETB",name:"Ethiopian birr"},{isoCode:"FJD",name:"Fiji dollar"},{isoCode:"FKP",name:"Falkland Islands pound"},{isoCode:"GEL",name:"Georgian lari"},{isoCode:"GIP",name:"Gibraltar pound"},{isoCode:"GMD",name:"Gambian dalasi"},{isoCode:"GTQ",name:"Guatemalan queztal"},{isoCode:"GYD",name:"Guyanese dollar"},{isoCode:"HKD",name:"Hong Kong dollar"},{isoCode:"HNL",name:"Honduran lempira"},{isoCode:"HRK",name:"Croation kuna"},{isoCode:"HTG",name:"Haitian gourde"},{isoCode:"HUF",name:"Hungarian forint"},{isoCode:"IDR",name:"Indonesian rupiah"},{isoCode:"ILS",name:"Israeli new shekel"},{isoCode:"INR",name:"Indian rupee"},{isoCode:"ISK",name:"Icelandic króna"},{isoCode:"JMD",name:"Jamaican dollar"},{isoCode:"KES",name:"Kenyan shilling"},{isoCode:"KGS",name:"Kyrgyzstani som"},{isoCode:"KHR",name:"Cambodian riel"},{isoCode:"KYD",name:"Cayman Islands dollar"},{isoCode:"KZT",name:"Kazakhstani tenge"},{isoCode:"LAK",name:"Lao kip"},{isoCode:"LBP",name:"Lebanese pound"},{isoCode:"LKR",name:"Sri Lankan rupee"},{isoCode:"LRD",name:"Liberian dollar"},{isoCode:"LSL",name:"Lesotho loti"},{isoCode:"MAD",name:"Moroccan dirham"},{isoCode:"MDL",name:"Moldovan leu"},{isoCode:"MKD",name:"Macedonian denar"},{isoCode:"MMK",name:"Myanmar kyat"},{isoCode:"MNT",name:"Mongolian tögrög"},{isoCode:"MOP",name:"Macanese pataca"},{isoCode:"MRO",name:"Mauritanian ouguiya"},{isoCode:"MUR",name:"Mauritian rupee"},{isoCode:"MVR",name:"Maldivian rufiyaa"},{isoCode:"MWK",name:"Malawian kwacha"},{isoCode:"MXN",name:"Mexican peso"},{isoCode:"MYR",name:"Malaysian ringgit"},{isoCode:"MZN",name:"Mozambican metical"},{isoCode:"NAD",name:"Namibian dollar"},{isoCode:"NGN",name:"Nigerian naira"},{isoCode:"NIO",name:"Nicaraguan córdoba"},{isoCode:"NOK",name:"Norwegian krone"},{isoCode:"NPR",name:"Nepalese rupee"},{isoCode:"NZD",name:"New Zealand dollar"},{isoCode:"PAB",name:"Panamanian balboa"},{isoCode:"PEN",name:"Peruvian sol"},{isoCode:"PGK",name:"Papua New Guinean kina"},{isoCode:"PHP",name:"Philippine peso"},{isoCode:"PKR",name:"Pakistani rupee"},{isoCode:"PLN",name:"Polish złoty"},{isoCode:"QAR",name:"Qatari riyal"},{isoCode:"RON",name:"Romanian leu"},{isoCode:"RSD",name:"Serbian dinar"},{isoCode:"RUB",name:"Russian ruble"},{isoCode:"SAR",name:"Saudi riyal"},{isoCode:"SBD",name:"Solomon Islands dollar"},{isoCode:"SCR",name:"Seychelles rupee"},{isoCode:"SEK",name:"Swedish krona"},{isoCode:"SGD",name:"Singapore dollar"},{isoCode:"SHP",name:"Saint Helena pound"},{isoCode:"SLL",name:"Sierra Leonean leone"},{isoCode:"SOS",name:"Somali shilling"},{isoCode:"SRD",name:"Surinamese dollar"},{isoCode:"STD",name:"São Tomé and Príncipe dobra"},{isoCode:"SZL",name:"Salvadoran colón"},{isoCode:"THB",name:"Thai baht"},{isoCode:"TJS",name:"Tajikistani somoni"},{isoCode:"TOP",name:"Tongan paʻanga"},{isoCode:"TRY",name:"Turkish lira"},{isoCode:"TTD",name:"Trinidad and Tobago dollar"},{isoCode:"TWD",name:"New Taiwan dollar"},{isoCode:"TZS",name:"Tanzanian shilling"},{isoCode:"UAH",name:"Ukrainian hryvnia"},{isoCode:"UYU",name:"Uruguayan peso"},{isoCode:"UZS",name:"Uzbekistan som"},{isoCode:"WST",name:"Samoan tala"},{isoCode:"XCD",name:"East Caribbean dollar"},{isoCode:"YER",name:"Yemeni rial"},{isoCode:"ZAR",name:"South African rand"},{isoCode:"ZMW",name:"Zambian kwacha"}];function Y8(){return{top:_g.slice(0,5),other:_g.slice(5)}}function Fg({showName:t=!1}={}){return Object.values(Y8()).map((e,n)=>({label:"—",key:n.toString(),options:e.map(({isoCode:r,name:i})=>({value:r,label:t?`${r} - ${i}`:r}))}))}function kf(t){return t?Intl.NumberFormat("en",{currency:t,style:"currency"}).format(0).replace(/[\d\s.]/g,""):""}function Yd(t){return t/100}function X8(t){switch(t?.toUpperCase()){case"AED":return 4;case"BGN":return 2;case"CZK":return 30;case"DKK":return 5;case"HKD":return 8;case"HUF":return 250;case"JPY":return 100;case"MXN":return 20;case"MYR":return 4;case"NOK":return 6;case"PLN":return 4;case"RON":return 4;case"SEK":return 6;case"THB":return 20;default:return 1}}function J8(t,e,{allowZero:n=!0,maxAmount:r}={}){if(t===void 0||!e)return;const i=kf(e),s=X8(e);if(!n&&t===0)return`Amount must be at least ${i}${s}.`;if(t!==0&&t<s*100)return`Non-zero amount must be at least ${i}${s}.`;if(r&&t!==0&&t>r*100)return`Suggested amount cannot be more than ${i}${r}.`}const Ly=({size:t="md",trialDays:e})=>{if(!e)return null;const n=R(t==="sm"?"px-1.5 py-0.5 text-sm":"px-2.5 py-1.5","relative -mt-1 -mr-1 rounded-full leading-none font-semibold tracking-wide whitespace-nowrap text-grey-900");return u.jsxs("span",{className:n,children:[u.jsx("span",{className:"absolute inset-0 block rounded-full bg-ghostaccent opacity-20 dark:bg-pink"}),u.jsxs("span",{className:"dark:text-pink",children:[e," days free"]})]})},Z8=({benefits:t})=>t?.length?u.jsx(u.Fragment,{children:t.map(e=>u.jsx("div",{className:"mt-4 w-full text-md leading-snug text-grey-900",children:u.jsxs("div",{className:"mb-2.5 flex items-start",children:[u.jsx(me,{className:"mt-[3px] mr-[10px] h-3.5! w-3.5! min-w-[14px] overflow-visible stroke-[3px]!",name:"check"}),u.jsx("div",{children:e})]})},e))}):u.jsx("div",{className:"mt-4 w-full text-md leading-snug text-grey-900 opacity-30",children:u.jsxs("div",{className:"mb-2.5 flex items-start",children:[u.jsx(me,{className:"mt-[3px] mr-[10px] h-3.5! w-3.5! min-w-[14px] overflow-visible stroke-[3px]!",name:"check"}),u.jsx("div",{children:"Expert analysis"})]})}),Q8=({discount:t})=>t?u.jsxs("span",{className:"mt-1 leading-none font-semibold text-pink",children:[t,"% discount"]}):null,m9=({tier:t,isFreeTier:e})=>{const[n,r]=v.useState(!1),i=t?.name||"",s=t?.description||"",o=parseFloat(t?.trial_days||"0"),a=t?.currency||"USD",l=kf(a),c=t?.benefits||[],d=e?0:500,h=e?0:5e3,f=Yd(t?.monthly_price??d),m=Yd(t?.yearly_price??h),p=t?.monthly_price&&t?.yearly_price?Math.ceil((f*12-m)/(f*12)*100):0;return u.jsxs("div",{"data-testid":"tier-preview",children:[u.jsxs("div",{className:"flex items-baseline justify-between",children:[u.jsx(qe,{className:"pb-2",level:6,grey:!0,children:e?"Free membership preview":"Tier preview"}),!e&&u.jsxs("div",{className:"flex gap-1",children:[u.jsx(J,{className:`${n===!0?"text-grey-500":"text-grey-900 dark:text-white"}`,label:"Monthly",link:!0,unstyled:!0,onClick:()=>r(!1)}),u.jsx(J,{className:`ml-2 ${n===!0?"text-grey-900 dark:text-white":"text-grey-500"}`,label:"Yearly",link:!0,unstyled:!0,onClick:()=>r(!0)})]})]}),u.jsx("div",{className:"rounded-sm border border-grey-200 bg-white dark:border-transparent",children:u.jsxs("div",{className:"flex-column relative flex min-h-[200px] w-full max-w-[420px] scale-90 items-start justify-stretch rounded bg-white p-4",children:[u.jsxs("div",{className:"min-h-[56px] w-full",children:[u.jsx("h4",{className:`-mt-1 mb-0 w-full text-lg leading-tight font-semibold break-words text-ghostaccent ${!i&&"opacity-30"}`,children:i||(e?"Free":"Bronze")}),u.jsxs("div",{className:"mt-4 flex w-full flex-row flex-wrap items-end justify-between gap-x-1 gap-y-[10px]",children:[u.jsxs("div",{className:`flex flex-wrap text-black ${(n&&t?.yearly_price===void 0||!n&&t?.monthly_price===void 0)&&!e?"opacity-30":""}`,children:[u.jsx("span",{className:"self-start text-[2.7rem] leading-[1.115] font-bold uppercase",children:l}),u.jsx("span",{className:"text-[3.4rem] leading-none font-bold tracking-tight break-all",children:So(n?m:f)}),!e&&u.jsxs("span",{className:"ml-1 self-end text-[1.5rem] leading-snug text-grey-800",children:["/",n?"year":"month"]})]}),u.jsx(Ly,{trialDays:o})]}),n&&p>0&&u.jsx(Q8,{discount:p})]}),u.jsx("div",{className:"flex-column flex w-full flex-1",children:u.jsxs("div",{className:"flex-1",children:[u.jsx("div",{className:`mt-4 w-full text-[1.55rem] leading-snug font-semibold text-grey-900 ${!s&&"opacity-30"}`,children:s||(e?"Free preview":"Full access to premium content")}),u.jsx(Z8,{benefits:c})]})})]})})]})},_y=R("group/tiercard flex cursor-pointer flex-col items-start justify-between gap-4 self-stretch rounded-sm border border-transparent bg-grey-100 p-4 transition-all hover:border-grey-100 hover:bg-grey-50 hover:shadow-sm min-[900px]:min-h-[200px] dark:bg-grey-950 dark:hover:border-grey-800"),e_=({tier:t})=>{const{updateRoute:e}=fe(),n=t?.currency||"USD",r=kf(n);return u.jsx("div",{className:_y,"data-testid":"tier-card","data-tier":t.slug,children:u.jsxs("div",{className:"w-full grow",onClick:()=>{e({route:`tiers/${t.id}`})},children:[u.jsx("div",{className:"text-[1.65rem] leading-tight font-bold tracking-tight text-black dark:text-white",children:t.name}),u.jsxs("div",{className:"mt-2 flex items-baseline",children:[u.jsx("span",{className:"ml-1 translate-y-[-3px] text-md font-bold uppercase",children:r}),u.jsx("span",{className:"text-xl font-bold tracking-tighter",children:So(Yd(t.monthly_price||0))}),t.monthly_price&&t.monthly_price>0&&u.jsx("span",{className:"text-grey-700",children:"/month"})]}),t.trial_days?u.jsx("div",{className:"mt-1 mb-4",children:u.jsx(Ly,{size:"sm",trialDays:t.trial_days})}):"",u.jsx("div",{className:"mt-2 line-clamp-2 text-[1.4rem] font-medium",children:t.description||u.jsx("span",{className:"opacity-30",children:"No description"})})]})})},Mu=({tab:t,tiers:e})=>{const{updateRoute:n}=fe(),r=()=>{n("tiers/add")};return e.length?u.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 min-[900px]:grid-cols-3",children:[e.map(i=>u.jsx(e_,{tier:i},i.id)),t==="active-tiers"&&u.jsx("button",{className:`${_y} group cursor-pointer`,type:"button",onClick:()=>{r()},children:u.jsx("div",{className:"flex size-full flex-col items-center justify-center",children:u.jsxs("div",{className:"flex flex-col items-center justify-center",children:[u.jsx("div",{className:"translate-y-[15px] transition-all group-hover:translate-y-0",children:u.jsx(me,{colorClass:"text-green",name:"add"})}),u.jsx("div",{className:"mt-2 translate-y-[-10px] font-semibold text-green opacity-0 transition-all group-hover:translate-y-0 group-hover:opacity-100",children:"Add tier"})]})})})]}):u.jsxs(li,{icon:"money-bags",children:["No ",t==="active-tiers"?"active":"archived"," tiers found."]})},Bg=({className:t,onClick:e})=>(t=R("group flex shrink-0 items-center justify-center rounded border border-grey-300 px-3 py-1.5 font-semibold whitespace-nowrap text-grey-900 transition-all hover:border-grey-500 dark:border-grey-900 dark:text-white",t),u.jsxs("button",{className:t,"data-testid":"stripe-connected",type:"button",onClick:e,children:[u.jsx("span",{className:"inline-flex size-2 rounded-full bg-green transition-all group-hover:bg-[#625BF6]"}),u.jsx("span",{className:"ml-2",children:"Connected to Stripe"})]})),t_=({keywords:t})=>{const[e,n]=v.useState("active-tiers"),{settings:r,config:i}=ke(),{data:{tiers:s,meta:o,isEnd:a}={},fetchNextPage:l}=rh(),c=y2(s||[]),d=w2(s||[]),{updateRoute:h}=fe(),f=fs(),m=async()=>{if(f?.isDisabled("limitStripeConnect")&&!nr(r,i))try{await f.errorIfWouldGoOverLimit("limitStripeConnect")}catch(x){if(x instanceof Zo){pe.show(Vu,{prompt:x.message||"Your current plan doesn't support Stripe Connect.",onOk:()=>h({route:"/pro",isExternal:!0})});return}}h("stripe-connect")},p=x=>[...x].sort((y,w)=>(y.monthly_price??0)-(w.monthly_price??0)),g=[{id:"active-tiers",title:"Active",contents:u.jsx(Mu,{tab:"active-tiers",tiers:p(c)})},{id:"archived-tiers",title:"Archived",contents:u.jsx(Mu,{tab:"archive-tiers",tiers:p(d)})}];let b;return nr(r,i)?b=u.jsx(hr,{selectedTab:e,tabs:g,onTabChange:n}):b=u.jsx(Mu,{tab:"free-tier",tiers:c.filter(x=>x.type==="free")}),u.jsxs(Se,{customButtons:nr(r,i)?u.jsx(Bg,{className:"hidden tablet:!visible tablet:!block",onClick:m}):u.jsx(vm,{className:"hidden tablet:!visible tablet:!block",onClick:m}),description:"Set prices and paid member sign up settings",keywords:t,navid:"tiers",testId:"tiers",title:"Tiers",children:[u.jsx("div",{className:"w-full tablet:hidden",children:nr(r,i)?u.jsx(Bg,{className:"w-full",onClick:m}):u.jsx(vm,{onClick:m})}),b,a===!1&&u.jsx(J,{label:`Load more (showing ${s?.length||0}/${o?.pagination.total||0} tiers)`,link:!0,onClick:()=>l()})]})},n_=Ce(t_,"Tiers"),r_=1e4,i_=({keywords:t})=>{const{localSettings:e,siteData:n,updateSetting:r,saveState:i,handleSave:s,handleCancel:o,focusRef:a,errors:l,validate:c,clearError:d,handleEditingChange:h}=Ft({onValidate:()=>({donationsSuggestedAmount:J8(p,f,{maxAmount:r_})})}),[f="USD",m="500"]=we(e,["donations_currency","donations_suggested_amount"]),p=parseInt(m),g=`${n?.url.replace(/\/$/,"")}/#/portal/support`;v.useEffect(()=>{c()},[f]);const[b,x]=v.useState(!1),[y,w]=v.useState(!1);v.useEffect(()=>{e.some(j=>j.dirty)&&!y&&(w(!0),h(!0))},[e,y,h]);const k=()=>{navigator.clipboard.writeText(g),x(!0),setTimeout(()=>x(!1),2e3)},C=()=>{Ui(i==="unsaved",()=>window.open(g,"_blank"))},S=(E,j)=>{r(E,j)},A=()=>{o(),w(!1)},M=async()=>{await s()&&w(!1)};return u.jsxs(Se,{description:"Give your audience a simple way to support your work with one-time payments.",isEditing:y,keywords:t,navid:"tips-and-donations",saveState:i,testId:"tips-and-donations",title:"Tips & donations",hideEditButton:!0,onCancel:A,onEditingChange:w,onSave:M,children:[u.jsxs(tt,{columns:1,children:[u.jsx("div",{className:"flex max-w-[180px] items-end gap-[.6rem]",children:u.jsx(W2,{error:!!l.donationsSuggestedAmount,hint:l.donationsSuggestedAmount,inputRef:a,placeholder:"5",rightPlaceholder:u.jsx(ir,{border:!1,clearBg:!0,containerClassName:"w-14",fullWidth:!1,options:Fg(),selectedOption:Fg().flatMap(E=>E.options).find(E=>E.value===f),title:"Currency",hideTitle:!0,isSearchable:!0,onSelect:E=>S("donations_currency",E?.value||"USD")}),title:"Suggested amount",valueInCents:parseInt(m),onBlur:c,onChange:E=>S("donations_suggested_amount",E.toString()),onKeyDown:()=>d("donationsSuggestedAmount")},m)}),u.jsxs("div",{className:"w-100",children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx(qe,{level:6,children:"Shareable link"})}),u.jsxs("div",{className:"group relative mt-0 flex w-100 items-center justify-between overflow-hidden border-b border-transparent pt-1 pb-2 hover:border-grey-300 dark:hover:border-grey-600",children:[u.jsx("span",{"data-testid":"donate-url",children:g}),u.jsxs("div",{className:"invisible flex gap-1 bg-white pl-1 group-hover:visible dark:bg-black",children:[u.jsx(J,{color:"clear","data-testid":"preview-shareable-link",label:"Preview",size:"sm",onClick:C}),u.jsx(J,{color:"light-grey","data-testid":"copy-shareable-link",label:b?"Copied":"Copy link",size:"sm",onClick:k})]})]})]})]}),u.jsxs("div",{className:"items-center-mt-1 flex",children:["All tips and donations are subject to Stripe's ",u.jsx("a",{className:"ml-1 font-medium text-green",href:"https://ghost.org/help/tips-donations/",rel:"noopener noreferrer",target:"_blank",children:" tipping policy"}),"."]})]})},s_=Ce(i_,"Tips & donations"),Re={access:["membership","default","access","subscription","post","membership","comments","commenting","signup","sign up","spam","filters","prevention","prevent","block","domains","email","password protection","lock site","private site","private site mode","make this site private"],tiers:["membership","tiers","payment","paid","stripe"],portal:["membership","portal","signup","sign up","signin","sign in","login","account","membership","support","email","address","support email address","support address"],giftSubscriptions:["membership","gift","gifts","gift subscriptions","present","share","shareable link"],memberEmails:["membership","signup","welcome email","welcome emails","email","new user","new member","account"],tips:["membership","tips","donations","one time","payment"]},o_=()=>{const{config:t,settings:e}=ke(),[n,r]=we(e,["donations_enabled","paid_members_enabled"]),i=nr(e||[],t||{}),s=ea("automations"),o=[Re.access,Re.tiers,Re.portal,...r?[Re.giftSubscriptions]:[],...s?[]:[Re.memberEmails],...n&&i?[Re.tips]:[]].flat();return u.jsxs(ui,{keywords:o,title:"Membership",children:[u.jsx(S8,{keywords:Re.access}),u.jsx(q8,{keywords:Re.access}),u.jsx(n_,{keywords:Re.tiers}),u.jsx(K8,{keywords:Re.portal}),r&&u.jsx(A8,{keywords:Re.giftSubscriptions}),!s&&u.jsx($8,{keywords:Re.memberEmails}),n&&i&&u.jsx(s_,{keywords:Re.tips})]})},a_=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("announcement-bar/edit")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Customize",size:"sm",onClick:n}),description:"Highlight important updates or offers",keywords:t,navid:"announcement-bar",testId:"announcement-bar",title:"Announcement bar"})},l_=Ce(a_,"Announcement bar"),c_=()=>{const t=fs(),{config:e}=ke(),n=e.hostSettings?.limits?.customThemes?.allowlist,r=n?.length===1||!1;return{checkThemeLimitError:v.useCallback(async s=>{if(!t?.isLimited("customThemes")||!(r||s&&n&&!n.includes(s.toLowerCase())))return null;try{const a=r?".":s||".";return await t.errorIfWouldGoOverLimit("customThemes",{value:a}),null}catch(a){return a instanceof Zo?a.message||"Your current plan doesn't support changing themes.":null}},[t,n,r]),isThemeLimited:t?.isLimited("customThemes")||!1,isThemeLimitCheckReady:t!==void 0,allowedThemesList:n,noThemeChangesAllowed:r}},u_=({keywords:t})=>{const[e,n]=v.useState(null),[r,i]=v.useState(!1),{checkThemeLimitError:s}=c_(),{route:o,updateRoute:a}=fe(),{data:l}=qw(),c=l?.themes.find(g=>g.active);v.useEffect(()=>{(async()=>{i(!0);const b=await s();n(b),i(!1)})()},[s]);const d=async()=>{r||(e?pe.show(Vu,{prompt:e,onOk:()=>a({route:"/pro",isExternal:!0})}):a("design/change-theme"))},m=[{id:"edit-code",label:"Edit code",onClick:async()=>{if(!c)return;const g=await s(".");if(g){pe.show(Vu,{prompt:g,onOk:()=>a({route:"/pro",isExternal:!0})});return}a(`theme/edit/${encodeURIComponent(c.name)}?from=${encodeURIComponent(o??"")}`)}},{id:"download",label:"Download",onClick:()=>{if(!c)return;const{apiRoot:g}=Ys();Yw(`${g}/themes/${c.name}/download`)}}],p=u.jsx(tt,{children:u.jsxs("div",{className:"flex flex-col",children:[u.jsx(qe,{grey:!1,level:6,children:"Active theme"}),u.jsxs("div",{className:"mt-1 flex w-full items-center justify-between gap-4",children:[u.jsx("div",{children:c?`${c.name} (v${c.package?.version||"1.0"})`:"Loading..."}),u.jsx("div",{className:"-mr-3",children:u.jsx(tA,{items:m,position:"end",triggerButtonProps:{disabled:!c,iconColorClass:"text-base",size:"sm"}})})]})]})});return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Change theme",size:"sm",onClick:d}),description:"Browse and install official themes or upload one",keywords:t,navid:"theme",testId:"theme",title:"Theme",children:p})},d_=Ce(u_,"Branding and design"),h_=""+new URL("design-settings-R1OjGW68.png",import.meta.url).href,f_=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("design/edit")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Customize",size:"sm",onClick:n}),description:"Customize the style and layout of your site",keywords:t,navid:"design",testId:"design",title:"Design & branding",children:u.jsx("img",{src:h_})})},m_=Ce(f_,"Branding and design"),p_=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("navigation/edit")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Customize",size:"sm",onClick:n}),description:"Set up primary and secondary menus",keywords:t,navid:"navigation",testId:"navigation",title:"Navigation"})},g_=Ce(p_,"Navigation"),gn={design:["site","logo","cover","colors","fonts","background","themes","appearance","style","design & branding","design and branding"],theme:["theme","template","upload"],navigation:["site","navigation","menus","primary","secondary","links"],announcementBar:["site","announcement bar","important","banner"]},b_=()=>u.jsx(u.Fragment,{children:u.jsxs(ui,{keywords:Object.values(gn).flat(),title:"Site",children:[u.jsx(m_,{keywords:gn.design}),u.jsx(d_,{keywords:gn.theme}),u.jsx(g_,{keywords:gn.navigation}),u.jsx(l_,{keywords:gn.announcementBar})]})}),v_=()=>{const t=ea("automations");return u.jsx(u.Fragment,{children:u.jsxs("div",{className:"mb-[60vh] px-8 pt-16 tablet:max-w-[760px] tablet:px-14 tablet:pt-0",children:[u.jsx(X6,{}),u.jsx(b_,{}),u.jsx(o_,{}),t?u.jsx(qL,{}):u.jsx(NR,{}),u.jsx(w8,{}),u.jsx(yR,{})]})})},x_="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAC9FBMVEUAAAB+J/tXRf9mPP99M/9bQP9XQ/9VRv9VRv9WRf9WRP9XRP9XRf9VRf9cQP9aP/9bQP9ZQf9WRf9bQf9VRf9VRf9YRP9cPv9hPf9hPf9gPf9XPf9qN/9kOv9kOv9oOP9WQv9jOv9tNf9pN/9mOv9bP/95Kv9zMP9uNf9yMP9sNP9xMf9sM/9qNv9iPv9fP/9dQP9eP/96LP94Lv9yMf9oOP9qOP9hPf9mO/9fPv+FJP+DJf95LP+DIv93Lf94Lv92L/9uNv9kPP9lO/+BJ/+MH/9/Jv+HI/+FJf+AKf9+Kv9dP/+UGv+QHf+KH/+PG/+JIv+HI/+bFP+NIP+UGf9tNf+eFP+aFf+WGP+UGv+VGf9yMv+hEv+oDP+cE/+dFP+bFf95Lf+hDf+cFv+rCf+uB/+vCP+rC/+jEP+lDv+xB/+vB/+4A/+FJf+9BPa9AP64A/6wCP+vCP+NH/+IJP+FIf+2Bv+5Av+9AP64Bv6/AP6OHv/KAPfFAPrEAPvEAPrDAPvCAPi+AP66Af7HAPjCAPzFAPnRAPLMAPbNAPbQAPXNAPfhAPPXAPPTAPTKAPSpCv/UAPTUAPPQAPbGAPerC//VAPPUAPPXAPS2BP/bAPK1BP/dAPHeAPLgAPLdAPDcHO65AP+4Av/lAPXfAPLfAPC8AP3rAfDoAPHeAPHgAPDGAPryAfDlAPHsAPLyAPLoAPDzHPP1DvHsAPHzAPPvAPLpAPL7APP6APHzAPPOAPbNAPbRAPX0APH5A/L4APPvAPPLAPb4BPP+BfPyAPL3APP5APLdAO//GfH/Ku/8CvL/Nev/L+3/Ke//HfH/EfP8BPLxAPH9O+f1APDfAPH/QOn/POr/MO3/MO7/K+/8APH4AvLjAPL/Sef/Ref/ROj/Nuz/Nez/H/D2APDuAe7mAO//SOr/Rej/Ref/Qej/Qen/POr/LO37BvL/R+j/N+v/M+z/F/H+E/L/QOj/R+f/R+f/Ner/SOr/Suf/Qej/Tej/R+axG5kdAAAA/HRSTlMABQ4SCStddYWDfGhhVU04IDWViX9vZD5vmIAZi4ZoUUYmk3RiMCJsfVg5MitItayeWY+GPrrXzam+fW5cMC670J1ea1x3HoS1xp55aYlFLK1VdJg8mUx9XqaVpGdrRJacry+MTXk1iaBFXnGRqQ9mR6ZVT7skHn5YJoO0LGleo5lYt01xxzkmZJ2EzR1flzI9smy8P7tYw6moTb01mtZuB3iWGLllQk5Jej3ANovJjmIKE2ykf3Q5W5aNr0pRhcBnKjB5d39tK1WRpXV3hrDHYUIOKzd6mn6n0XFevluglbfHZUQ0Lhdtgom2pV5WpWuIdE1HnLFTL1+QOFCCqXMxAAAELklEQVR4AYXVtZ4jRxSF8XOru5rFtMzMu2ZmptjsFzDzEzgzQ2hKzJSZmdle5mEeSSN1S2qoWtSwNP/4fr8TXsI0RARIFqKFqQEnIhBFKp1QmitI1U2QC4DsShwA0ZDAdMpEOo+bzNMjJ3TqeuAHgTbGpZGrtFpYSBRoREUwQBjmiJDCIciqsEqzLixXVUX3vNhQkDdqDhN6lI0Cr2GGLDSWjokZC2tCTidAKGPFvCdzIOqqM5iez0N1Te+QmBooW13HYyDDFe58AgnFs+Eeb+AxJgMtM6IWpwTnU90kUNF3HKL+vhIAZT3laFewRjR6F+5T5gXokBPBleSSIkl4MapU9qOJJbZ3LNu9hO2vqKyRrlVkM7iaqo4HimJEB/djiuUretwUUcb4vbgQR5vBjSAiDMUN+hAzbC5q+e5IYsOfK3YGABTgalOJGLyUrnyAmQYXh9m15bNGxWjcHgXAgKTPDZhZi94jzES7zAVa9c96aEZ+AYACdavJaglVDd4hiVnQoL6gUD+zx2ZclAGGu8j1M1VS3obEbCT+ODAISHIX0QaAgSGTZDlDk4RWfqhuKZ4nOZZKgEGL19Hg8hVItPSvg36x7Gh/RgG7j/sxK85ttEGhJjYuwS3LcAGYgXScOVDRhsRzq2HWsNVIQlWgCK2KZ9BWeHTLKvq4kAWYEh/TkElhLof16i2FFQADsmVT0TCHPB3O7fcPrAADZA6KgvbuCyNN40kNpNpEVLXKaM/2IxgC6ALjnEsLGbRXQN6EDUCyToSGZXC0t9Osb5awLzTAnjcNrc4Z2iFo6wKowdp9BhhUFboX3oc2JGKMHZTYHSShgqmKLtkWtPNao+986hhZ1rkBKvQKl3pgop19jtiteGcfOvM2MNyZMjUf6jtoicDX+KY4e9T9H2AAh5lM6vJNtCI/Zjs1fxQH8dTJQIOmSW5lPkYrf5ib5IL1R+NxnAxuTnCuNRgYWnj5oh1HL+pHXC4AoAIIbOKwPPbNpZjFJ0fZzsjm2PFz4R4ABADf0XDCsznR+Zju570Nb2GxrI3Ykj2BZoBfyA8cV5eN6s2Y5E1eiw+lvBrzt2rfaP6TE8HHC4RCx/XHnI6TyX+fXVNM9NSAktN9zb9yW+WbzIorMRHgP4U8m6gkSyuGLdv1BBBGWRzRypsruy79dQW6uh7GSSpO2oJDBnmsQGQw2+3na3a6OKc+kExtodShfy9FMeiY8XZ7qQaLqGZ15K2DWN1lDSgd/Nyuxf8EZ9GP+a47gZMYmhbM3ylr3BUyHTuyjg8uN7aWF64trvnHirA3P9a8B2GKChFc1R+BtyqyQpT6eTW+fGfux3vQpGKKGGoUDS2NSV5KHsq5FLdWlmT5fEwgzNCb7bIdv5QfskQiUjz9q1swiYoZFgD/JbhURRqIqHcLpiC09NoO/HUPpjsGm6qha0KGUP0AAAAASUVORK5CYII=",je=({keywords:t,navid:e,...n})=>{const{ref:r,props:i}=QI(e),{currentSection:s}=yc(),{checkVisible:o}=Jo(),l=(Array.isArray(e)?e:[e]).includes(s||"");return u.jsx(tE,{ref:r,isCurrent:l,isVisible:o(t),navid:Array.isArray(e)?e[0]:e,...i,...n})},y_=()=>u.jsxs(Xw,{className:"gap-1 border-transparent bg-orange-100 px-1.5 py-0 text-[11px] leading-5 font-semibold text-orange-700 shadow-[0_0_0_1px_rgba(255,255,255,0.55)] dark:bg-orange-500/20 dark:text-orange-300 dark:shadow-[0_0_0_1px_rgba(255,255,255,0.12)]",variant:"secondary",children:[u.jsx(Jw,{className:"size-3",strokeWidth:2.25}),"Private"]}),w_=()=>{const{filter:t,setFilter:e,checkVisible:n,noResult:r,setNoResult:i}=Jo(),{updateRoute:s}=fe(),o=v.useRef(null),{isAnyTextFieldFocused:a}=ts(),{settings:l,config:c}=ke(),[d,h,f,m]=we(l,["donations_enabled","is_private","paid_members_enabled","editor_default_email_recipients"]),p=nr(l||[],c||{}),g=ea("automations"),b=m!=="disabled",x=!!c.mailgunIsConfigured,y=b&&!x,w=W.useMemo(()=>[Re.access,Re.tiers,Re.portal,...f?[Re.giftSubscriptions]:[],...g?[]:[Re.memberEmails],...d&&p?[Re.tips]:[]].flat(),[p,d,f,g]),k=W.useMemo(()=>{const E=g?Ln:Rn;return[E.enableNewsletters,...b?[E.defaultRecipients]:[],...g?[Ln.emails]:b?[Rn.newsletters]:[],...y?[E.mailgun]:[]].flat()},[g,b,y]),C=W.useMemo(()=>[Je.network,Je.explore,Je.recommendations,Je.embedSignupForm,...p?[Je.offers]:[]].flat(),[p]);v.useEffect(()=>{const E=j=>{j.target instanceof HTMLElement&&(j.target.nodeName==="INPUT"||j.target.nodeName==="TEXTAREA"||j.target.isContentEditable)||j.key==="/"&&!a&&(j?.preventDefault(),o.current&&o.current.focus())};return window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E)}}),v.useEffect(()=>{o.current&&o.current.focus()},[]),v.useEffect(()=>{!n(Object.values(gt).flat())&&!n(Object.values(gn).flat())&&!n([...w,...k])&&!n(C)&&!n(Object.values(Pt).flat())?i(!0):i(!1)},[n,i,t,k,w,C]),v.useEffect(()=>{const E=o.current,j=T=>{T.key==="Escape"&&t&&(o.current?.blur(),T.stopPropagation())};return E?.addEventListener("keydown",j),()=>{E?.removeEventListener("keydown",j)}},[t]);const S=E=>{E&&(e(""),i(!1),s(E.currentTarget.id))},A=E=>{e(E.target.value),E.target.value&&document.querySelector(".admin-x-settings")?.scrollTo({top:0,left:0})},M=R("hidden pt-10 tablet:visible! tablet:block!");return u.jsxs("div",{className:"ml-auto flex w-full flex-col pt-0 tablet:max-w-[240px]","data-testid":"sidebar",children:[u.jsx("div",{className:"sticky top-0 flex content-stretch items-end tablet:h-20 tablet:bg-grey-50 xl:h-20 dark:bg-grey-950 dark:tablet:bg-[#101114]",children:u.jsxs("div",{className:"relative w-full",children:[u.jsx(me,{className:"absolute top-2.5 left-3 z-10",colorClass:"text-grey-500",name:"magnifying-glass",size:"sm"}),u.jsx(at,{autoComplete:"off",autoCorrect:"off",className:"mr-8 flex h-9 w-full items-center rounded-full border border-transparent bg-white px-[33px] py-1.5 shadow-[0_0_1px_rgba(21,23,26,0.25),0_1px_3px_rgba(0,0,0,0.03),0_8px_10px_-12px_rgba(0,0,0,.1)] transition-colors hover:shadow-sm focus:border-green focus:bg-white focus:shadow-[0_0_0_2px_rgba(48,207,67,0.25)] tablet:mr-0 dark:border-transparent dark:bg-grey-900 dark:text-white dark:placeholder:text-grey-800 dark:focus:border-green dark:focus:bg-grey-950",containerClassName:"w-100",inputRef:o,placeholder:"Search settings",title:"Search",value:t,clearBg:!0,hideTitle:!0,unstyled:!0,onChange:A}),t?u.jsx(J,{className:"absolute top-3 right-14 p-1 tablet:right-3",icon:"close",iconColorClass:"text-grey-700 w-[10px]! h-[10px]!",size:"sm",unstyled:!0,onClick:()=>{e(""),o.current?.focus()}}):u.jsx("div",{className:"absolute top-[7px] -right-1/2 hidden rounded border border-grey-400 bg-white px-1.5 py-0.5 text-2xs font-semibold tracking-wider text-grey-600 uppercase shadow-[0px_1px_#CED4D9] tablet:visible! tablet:right-3 tablet:block! dark:border-grey-800 dark:bg-grey-900 dark:text-grey-500 dark:shadow-[0px_1px_#626D79]",children:"/"})]})}),u.jsxs("nav",{className:M,id:"admin-x-settings-sidebar",children:[r&&u.jsxs("div",{className:"ml-2 text-base text-grey-700",children:[u.jsx("h2",{className:"mb-2 text-base font-semibold tracking-normal text-black dark:text-white",children:"No result"}),u.jsxs("div",{children:[`We couldn't find any setting matching '${t}'`,"."]})]}),u.jsxs(ks,{isVisible:n(Object.values(gt).flat()),title:"General settings",children:[u.jsx(je,{icon:"textfield",keywords:gt.titleAndDescription,navid:"general",title:"Title & description",onClick:S}),u.jsx(je,{icon:"world-clock",keywords:gt.timeZone,navid:"timezone",title:"Timezone",onClick:S}),u.jsx(je,{icon:"language",keywords:gt.publicationLanguage,navid:"publication-language",title:"Publication language",onClick:S}),u.jsx(je,{icon:"user-pen",keywords:gt.users,navid:"staff",title:"Staff",onClick:S}),u.jsx(je,{icon:"layer",keywords:gt.metadata,navid:"metadata",title:"Meta data",onClick:S}),u.jsx(je,{icon:"like",keywords:gt.socialAccounts,navid:"social-accounts",title:"Social accounts",onClick:S}),u.jsx(je,{icon:"baseline-chart",keywords:gt.analytics,navid:"analytics",title:"Analytics",onClick:S})]}),u.jsxs(ks,{isVisible:n(Object.values(gn).flat()),title:"Site",children:[u.jsx(je,{icon:"palette",keywords:gn.design,navid:"design",title:"Design & branding",onClick:S}),u.jsx(je,{icon:"layout-2-col",keywords:gn.theme,navid:"theme",title:"Theme",onClick:S}),u.jsx(je,{icon:"navigation",keywords:gn.navigation,navid:"navigation",title:"Navigation",onClick:S}),u.jsx(je,{icon:"megaphone",keywords:gn.announcementBar,navid:"announcement-bar",title:"Announcement bar",onClick:S})]}),u.jsxs(ks,{isVisible:n([...w,...k]),title:"Membership",children:[u.jsx(je,{icon:"key",keywords:Re.access,navid:["members","spam-filters"],title:u.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-2",children:[u.jsx("span",{className:"min-w-0 truncate",children:"Access"}),h&&u.jsx(y_,{})]}),onClick:S}),u.jsx(je,{icon:"bills",keywords:Re.tiers,navid:"tiers",title:"Tiers",onClick:S}),u.jsx(je,{icon:"portal",keywords:Re.portal,navid:"portal",title:"Signup portal",onClick:S}),f&&u.jsx(je,{icon:"gift",keywords:Re.giftSubscriptions,navid:"gift-subscriptions",title:"Gift subscriptions",onClick:S}),!g&&u.jsx(je,{icon:"mailplus",keywords:Re.memberEmails,navid:"memberemails",title:"Welcome emails",onClick:S}),d&&p&&u.jsx(je,{icon:"piggybank",keywords:Re.tips,navid:"tips-and-donations",title:"Tips & donations",onClick:S}),g?u.jsx(je,{icon:"email",keywords:k,navid:["enable-newsletters","default-recipients","emails","mailgun"],title:"Email",onClick:S}):u.jsx(je,{icon:"email",keywords:k,navid:["enable-newsletters","default-recipients","newsletters","mailgun"],title:"Newsletters",onClick:S})]}),u.jsxs(ks,{isVisible:n(C),title:"Growth",children:[u.jsx(je,{icon:"ap-network",keywords:Je.network,navid:"network",title:"Network",onClick:S}),u.jsx(je,{icon:"globe-simple",keywords:Je.explore,navid:"explore",title:"Ghost Explore",onClick:S}),u.jsx(je,{icon:"heart",keywords:Je.recommendations,navid:"recommendations",title:"Recommendations",onClick:S}),u.jsx(je,{icon:"emailfield",keywords:Je.embedSignupForm,navid:"embed-signup-form",title:"Signup forms",onClick:S}),p&&u.jsx(je,{icon:"discount",keywords:Je.offers,navid:"offers",title:"Offers",onClick:S})]}),u.jsxs(ks,{isVisible:n(Object.values(Pt).flat()),title:"Advanced",children:[u.jsx(je,{icon:"modules-3",keywords:Pt.integrations,navid:"integrations",title:"Integrations",onClick:S}),u.jsx(je,{icon:"download",keywords:Pt.migrationtools,navid:"migration",title:"Import/Export",onClick:S}),u.jsx(je,{icon:"brackets",keywords:Pt.codeInjection,navid:"code-injection",title:"Code injection",onClick:S}),u.jsx(je,{icon:"labs-flask",keywords:Pt.labs,navid:"labs",title:"Labs",onClick:S}),u.jsx(je,{icon:"time-back",keywords:Pt.history,navid:"history",title:"History",onClick:S}),u.jsx(je,{icon:"warning",keywords:Pt.dangerzone,navid:"dangerzone",title:"Danger zone",onClick:S})]}),!t&&u.jsxs("a",{className:"mt-1 mb-10 flex h-[38px] w-100 cursor-pointer items-center rounded-lg px-3 py-2 text-left text-[14px] font-medium text-grey-800 transition-all hover:bg-grey-200 focus:bg-grey-100 dark:text-grey-600 dark:hover:bg-grey-950 dark:focus:bg-grey-900",onClick:()=>{s("about")},children:[u.jsx("img",{alt:"Ghost Logo",className:"mr-[7px] size-[18px]",src:x_}),"About Ghost"]})]})]})},k_=[],S_=':is([role="dialog"], [role="alertdialog"])[data-state="open"]',Vg=({children:t})=>u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed top-2 right-0 z-50 m-8 flex justify-end bg-transparent tablet:fixed tablet:top-0",id:"done-button-container",children:u.jsx(LI,{})}),u.jsx("div",{className:"fixed top-0 left-0 flex size-full bg-grey-50 dark:bg-grey-950 dark:tablet:bg-[#101114]",id:"admin-x-settings-content",children:t})]}),C_=()=>{const{currentUser:t}=ke(),{loadingModal:e}=fe(),{isDirty:n}=Gl(),r=s=>{window.location.hash=s},i=()=>document.getElementById("modal-backdrop")?!0:!!document.querySelector(S_);return v.useEffect(()=>{const s=o=>{if(o.key==="Escape"){if(i())return;Ui(n,()=>{r("/")})}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[n]),v.useEffect(()=>{Zw.remove()},[]),Qw(t)?Gg(t)?u.jsx(Vg,{children:u.jsx("div",{className:"flex-1 bg-white dark:bg-grey-950",children:u.jsx("div",{className:"h-full overflow-y-auto overscroll-y-contain",id:"admin-x-settings-scroller",children:u.jsxs("div",{className:"mx-auto max-w-5xl px-[5vmin] tablet:mt-16 xl:mt-10",children:[u.jsx(qe,{className:"mb-[5vmin]",children:"Settings"}),u.jsx(Oy,{highlight:!1,keywords:k_})]})})})}):u.jsxs(Vg,{children:[e&&u.jsx("div",{className:`fixed inset-0 z-40 h-[calc(100vh-55px)] w-[100vw] tablet:h-[100vh] ${ob}`}),u.jsx("div",{className:"fixed inset-x-0 top-0 z-[35] max-w-[calc(100%-16px)] flex-1 basis-[320px] overscroll-y-contain bg-white p-8 tablet:relative tablet:inset-x-auto tablet:top-auto tablet:h-full tablet:overflow-y-scroll tablet:bg-grey-50 tablet:py-0 dark:bg-grey-950 dark:tablet:bg-[#101114]",id:"admin-x-settings-sidebar-scroller",children:u.jsx("div",{className:"relative w-full",children:u.jsx(w_,{})})}),u.jsx("div",{className:"h-full flex-1 bg-white tablet:basis-[800px] dark:bg-grey-950 dark:tablet:bg-black",children:u.jsx("div",{className:"relative h-full overflow-y-scroll overscroll-y-contain pt-13",id:"admin-x-settings-scroller",children:u.jsx(v_,{})})})]}):null},A_={"design/change-theme":"DesignAndThemeModal","design/edit":"DesignAndThemeModal","theme/install":"DesignAndThemeModal","theme/edit/:name":"DesignAndThemeModal","navigation/edit":"NavigationModal","staff/invite":"InviteUserModal","staff/:slug/social-links":"UserDetailModal","staff/:slug/email-notifications":"UserDetailModal","staff/:slug/edit":"UserDetailModal","staff/:slug":"UserDetailModal","portal/edit":"PortalModal","tiers/add":"TierDetailModal","tiers/:id":"TierDetailModal","stripe-connect":"StripeConnectModal","newsletters/new":"AddNewsletterModal","newsletters/:id":"NewsletterDetailModal","history/view":"HistoryModal","history/view/:user":"HistoryModal","integrations/contentapi":"ContentApiModal","integrations/zapier":"ZapierModal","integrations/transistor":"TransistorModal","integrations/slack":"SlackModal","integrations/unsplash":"UnsplashModal","integrations/firstpromoter":"FirstPromoterModal","integrations/pintura":"PinturaModal","integrations/new":"AddIntegrationModal","integrations/:id":"CustomIntegrationModal","recommendations/add":"AddRecommendationModal","recommendations/edit":"EditRecommendationModal","announcement-bar/edit":"AnnouncementBarModal","embed-signup-form/show":"EmbedSignupFormModal","offers/edit":"OffersContainerModal","offers/edit/:id":"OffersContainerModal","offers/edit/retention/:id":"OffersContainerModal","offers/new":"OffersContainerModal","explore/testimonial":"TestimonialsModal",about:"AboutModal"},M_=()=>Co(()=>import("./modals-dnqxCS3l.js"),__vite__mapDeps([25,1,2,8,3,4,5,6,26,27,28,9,29,17,7,10,11,12,13,14,15,16,18]),import.meta.url),E_=()=>{const{updateNavigatedSection:t,scrollToSection:e}=yc(),{route:n,updateRoute:r}=fe();return qI((i,s)=>{i===s&&e(i.split("/")[0])},[e]),v.useEffect(()=>{if(n!==void 0){if(n.split("/")[0]==="locksite"){r("members");return}t(n.split("/")[0])}},[n,t,r]),null};function j_({designSystem:t,upgradeStatus:e}){return u.jsx(TP,{upgradeStatus:e,children:u.jsx(pe.Provider,{children:u.jsx(GI,{basePath:"settings",modals:{paths:A_,load:M_},children:u.jsxs(aE,{className:"admin-x-settings",...t,children:[u.jsx(E_,{}),u.jsx(C_,{})]})})})})}async function N_(){return await Co(()=>import("./koenig-lexical-DlzcWUPw.js"),__vite__mapDeps([30,1,2]),import.meta.url)}function T_(){return qr.createPortal(u.jsx("div",{className:"shade shade-admin",style:{position:"absolute",inset:0,zIndex:20},children:u.jsx(j_,{designSystem:{darkMode:!1,fetchKoenigLexical:N_}})}),document.body)}const p9=Object.freeze(Object.defineProperty({__proto__:null,default:T_},Symbol.toStringTag,{value:"Module"}));export{Mr as $,gh as A,J as B,m1 as C,SN as D,g8 as E,Ya as F,x_ as G,qe as H,Of as I,m8 as J,U_ as K,jd as L,tA as M,pe as N,ir as O,Sl as P,Tt as Q,tI as R,Fl as S,eE as T,tt as U,ZM as V,G5 as W,vm as X,W_ as Y,K_ as Z,hr as _,rl as a,a9 as a$,$n as a0,ls as a1,un as a2,rb as a3,at as a4,m9 as a5,en as a6,et as a7,K5 as a8,sc as a9,s9 as aA,Vo as aB,Ai as aC,Vu as aD,jg as aE,So as aF,W4 as aG,Y_ as aH,PL as aI,xf as aJ,n9 as aK,p9 as aL,i9 as aM,$N as aN,qN as aO,St as aP,I as aQ,sr as aR,QP as aS,PP as aT,h9 as aU,eP as aV,IP as aW,_P as aX,f9 as aY,c_ as aZ,o9 as a_,OT as aa,MO as ab,rs as ac,Ui as ad,Wt as ae,e9 as af,cs as ag,_g as ah,Fg as ai,Yd as aj,A2 as ak,GN as al,Z_ as am,Q_ as an,t9 as ao,lT as ap,aT as aq,Pc as ar,mf as as,Ga as at,cy as au,Cu as av,kf as aw,r9 as ax,ZN as ay,zo as az,q5 as b,ea as b0,ts as b1,ke as b2,Gl as b3,fs as b4,an as b5,d9 as b6,l9 as b7,oy as b8,Qo as b9,fe as ba,Ft as bb,Xo as bc,u9 as bd,ff as be,c9 as bf,gy as bg,J8 as bh,Iy as bi,W2 as c,P as d,xe as e,V as f,K2 as g,on as h,Zo as i,Oe as j,xn as k,dx as l,J_ as m,is as n,Wi as o,Ul as p,Fr as q,nb as r,li as s,be as t,ix as u,Gt as v,q_ as w,TN as x,eA as y,Br as z};
|
|
31
|
+
junk.com`,resize:"vertical",title:"Blocked email domains",value:f,onChange:p,onKeyDown:()=>l("spam-filters")})})})},q8=Ce(G8,"Spam Filters"),_g=[{isoCode:"USD",name:"United States dollar"},{isoCode:"EUR",name:"Euro"},{isoCode:"GBP",name:"Pound sterling"},{isoCode:"AUD",name:"Australian dollar"},{isoCode:"CAD",name:"Canadian dollar"},{isoCode:"AED",name:"United Arab Emirates dirham"},{isoCode:"AFN",name:"Afghan afghani"},{isoCode:"ALL",name:"Albanian lek"},{isoCode:"AMD",name:"Armenian dram"},{isoCode:"ANG",name:"Netherlands Antillean guilder"},{isoCode:"AOA",name:"Angolan kwanza"},{isoCode:"ARS",name:"Argentine peso"},{isoCode:"AWG",name:"Aruban florin"},{isoCode:"AZN",name:"Azerbaijani manat"},{isoCode:"BAM",name:"Bosnia and Herzegovina convertible mark"},{isoCode:"BBD",name:"Barbados dollar"},{isoCode:"BDT",name:"Bangladeshi taka"},{isoCode:"BGN",name:"Bulgarian lev"},{isoCode:"BMD",name:"Bermudian dollar"},{isoCode:"BND",name:"Brunei dollar"},{isoCode:"BOB",name:"Boliviano"},{isoCode:"BRL",name:"Brazilian real"},{isoCode:"BSD",name:"Bahamian dollar"},{isoCode:"BWP",name:"Botswana pula"},{isoCode:"BZD",name:"Belize dollar"},{isoCode:"CDF",name:"Congolese franc"},{isoCode:"CHF",name:"Swiss franc"},{isoCode:"CNY",name:"Chinese yuan"},{isoCode:"COP",name:"Colombian peso"},{isoCode:"CRC",name:"Costa Rican colon"},{isoCode:"CVE",name:"Cape Verdean escudo"},{isoCode:"CZK",name:"Czech koruna"},{isoCode:"DKK",name:"Danish krone"},{isoCode:"DOP",name:"Dominican peso"},{isoCode:"DZD",name:"Algerian dinar"},{isoCode:"EGP",name:"Egyptian pound"},{isoCode:"ETB",name:"Ethiopian birr"},{isoCode:"FJD",name:"Fiji dollar"},{isoCode:"FKP",name:"Falkland Islands pound"},{isoCode:"GEL",name:"Georgian lari"},{isoCode:"GIP",name:"Gibraltar pound"},{isoCode:"GMD",name:"Gambian dalasi"},{isoCode:"GTQ",name:"Guatemalan queztal"},{isoCode:"GYD",name:"Guyanese dollar"},{isoCode:"HKD",name:"Hong Kong dollar"},{isoCode:"HNL",name:"Honduran lempira"},{isoCode:"HRK",name:"Croation kuna"},{isoCode:"HTG",name:"Haitian gourde"},{isoCode:"HUF",name:"Hungarian forint"},{isoCode:"IDR",name:"Indonesian rupiah"},{isoCode:"ILS",name:"Israeli new shekel"},{isoCode:"INR",name:"Indian rupee"},{isoCode:"ISK",name:"Icelandic króna"},{isoCode:"JMD",name:"Jamaican dollar"},{isoCode:"KES",name:"Kenyan shilling"},{isoCode:"KGS",name:"Kyrgyzstani som"},{isoCode:"KHR",name:"Cambodian riel"},{isoCode:"KYD",name:"Cayman Islands dollar"},{isoCode:"KZT",name:"Kazakhstani tenge"},{isoCode:"LAK",name:"Lao kip"},{isoCode:"LBP",name:"Lebanese pound"},{isoCode:"LKR",name:"Sri Lankan rupee"},{isoCode:"LRD",name:"Liberian dollar"},{isoCode:"LSL",name:"Lesotho loti"},{isoCode:"MAD",name:"Moroccan dirham"},{isoCode:"MDL",name:"Moldovan leu"},{isoCode:"MKD",name:"Macedonian denar"},{isoCode:"MMK",name:"Myanmar kyat"},{isoCode:"MNT",name:"Mongolian tögrög"},{isoCode:"MOP",name:"Macanese pataca"},{isoCode:"MRO",name:"Mauritanian ouguiya"},{isoCode:"MUR",name:"Mauritian rupee"},{isoCode:"MVR",name:"Maldivian rufiyaa"},{isoCode:"MWK",name:"Malawian kwacha"},{isoCode:"MXN",name:"Mexican peso"},{isoCode:"MYR",name:"Malaysian ringgit"},{isoCode:"MZN",name:"Mozambican metical"},{isoCode:"NAD",name:"Namibian dollar"},{isoCode:"NGN",name:"Nigerian naira"},{isoCode:"NIO",name:"Nicaraguan córdoba"},{isoCode:"NOK",name:"Norwegian krone"},{isoCode:"NPR",name:"Nepalese rupee"},{isoCode:"NZD",name:"New Zealand dollar"},{isoCode:"PAB",name:"Panamanian balboa"},{isoCode:"PEN",name:"Peruvian sol"},{isoCode:"PGK",name:"Papua New Guinean kina"},{isoCode:"PHP",name:"Philippine peso"},{isoCode:"PKR",name:"Pakistani rupee"},{isoCode:"PLN",name:"Polish złoty"},{isoCode:"QAR",name:"Qatari riyal"},{isoCode:"RON",name:"Romanian leu"},{isoCode:"RSD",name:"Serbian dinar"},{isoCode:"RUB",name:"Russian ruble"},{isoCode:"SAR",name:"Saudi riyal"},{isoCode:"SBD",name:"Solomon Islands dollar"},{isoCode:"SCR",name:"Seychelles rupee"},{isoCode:"SEK",name:"Swedish krona"},{isoCode:"SGD",name:"Singapore dollar"},{isoCode:"SHP",name:"Saint Helena pound"},{isoCode:"SLL",name:"Sierra Leonean leone"},{isoCode:"SOS",name:"Somali shilling"},{isoCode:"SRD",name:"Surinamese dollar"},{isoCode:"STD",name:"São Tomé and Príncipe dobra"},{isoCode:"SZL",name:"Salvadoran colón"},{isoCode:"THB",name:"Thai baht"},{isoCode:"TJS",name:"Tajikistani somoni"},{isoCode:"TOP",name:"Tongan paʻanga"},{isoCode:"TRY",name:"Turkish lira"},{isoCode:"TTD",name:"Trinidad and Tobago dollar"},{isoCode:"TWD",name:"New Taiwan dollar"},{isoCode:"TZS",name:"Tanzanian shilling"},{isoCode:"UAH",name:"Ukrainian hryvnia"},{isoCode:"UYU",name:"Uruguayan peso"},{isoCode:"UZS",name:"Uzbekistan som"},{isoCode:"WST",name:"Samoan tala"},{isoCode:"XCD",name:"East Caribbean dollar"},{isoCode:"YER",name:"Yemeni rial"},{isoCode:"ZAR",name:"South African rand"},{isoCode:"ZMW",name:"Zambian kwacha"}];function Y8(){return{top:_g.slice(0,5),other:_g.slice(5)}}function Fg({showName:t=!1}={}){return Object.values(Y8()).map((e,n)=>({label:"—",key:n.toString(),options:e.map(({isoCode:r,name:i})=>({value:r,label:t?`${r} - ${i}`:r}))}))}function kf(t){return t?Intl.NumberFormat("en",{currency:t,style:"currency"}).format(0).replace(/[\d\s.]/g,""):""}function Yd(t){return t/100}function X8(t){switch(t?.toUpperCase()){case"AED":return 4;case"BGN":return 2;case"CZK":return 30;case"DKK":return 5;case"HKD":return 8;case"HUF":return 250;case"JPY":return 100;case"MXN":return 20;case"MYR":return 4;case"NOK":return 6;case"PLN":return 4;case"RON":return 4;case"SEK":return 6;case"THB":return 20;default:return 1}}function J8(t,e,{allowZero:n=!0,maxAmount:r}={}){if(t===void 0||!e)return;const i=kf(e),s=X8(e);if(!n&&t===0)return`Amount must be at least ${i}${s}.`;if(t!==0&&t<s*100)return`Non-zero amount must be at least ${i}${s}.`;if(r&&t!==0&&t>r*100)return`Suggested amount cannot be more than ${i}${r}.`}const Ly=({size:t="md",trialDays:e})=>{if(!e)return null;const n=R(t==="sm"?"px-1.5 py-0.5 text-sm":"px-2.5 py-1.5","relative -mt-1 -mr-1 rounded-full leading-none font-semibold tracking-wide whitespace-nowrap text-grey-900");return u.jsxs("span",{className:n,children:[u.jsx("span",{className:"absolute inset-0 block rounded-full bg-ghostaccent opacity-20 dark:bg-pink"}),u.jsxs("span",{className:"dark:text-pink",children:[e," days free"]})]})},Z8=({benefits:t})=>t?.length?u.jsx(u.Fragment,{children:t.map(e=>u.jsx("div",{className:"mt-4 w-full text-md leading-snug text-grey-900",children:u.jsxs("div",{className:"mb-2.5 flex items-start",children:[u.jsx(me,{className:"mt-[3px] mr-[10px] h-3.5! w-3.5! min-w-[14px] overflow-visible stroke-[3px]!",name:"check"}),u.jsx("div",{children:e})]})},e))}):u.jsx("div",{className:"mt-4 w-full text-md leading-snug text-grey-900 opacity-30",children:u.jsxs("div",{className:"mb-2.5 flex items-start",children:[u.jsx(me,{className:"mt-[3px] mr-[10px] h-3.5! w-3.5! min-w-[14px] overflow-visible stroke-[3px]!",name:"check"}),u.jsx("div",{children:"Expert analysis"})]})}),Q8=({discount:t})=>t?u.jsxs("span",{className:"mt-1 leading-none font-semibold text-pink",children:[t,"% discount"]}):null,m9=({tier:t,isFreeTier:e})=>{const[n,r]=v.useState(!1),i=t?.name||"",s=t?.description||"",o=parseFloat(t?.trial_days||"0"),a=t?.currency||"USD",l=kf(a),c=t?.benefits||[],d=e?0:500,h=e?0:5e3,f=Yd(t?.monthly_price??d),m=Yd(t?.yearly_price??h),p=t?.monthly_price&&t?.yearly_price?Math.ceil((f*12-m)/(f*12)*100):0;return u.jsxs("div",{"data-testid":"tier-preview",children:[u.jsxs("div",{className:"flex items-baseline justify-between",children:[u.jsx(qe,{className:"pb-2",level:6,grey:!0,children:e?"Free membership preview":"Tier preview"}),!e&&u.jsxs("div",{className:"flex gap-1",children:[u.jsx(J,{className:`${n===!0?"text-grey-500":"text-grey-900 dark:text-white"}`,label:"Monthly",link:!0,unstyled:!0,onClick:()=>r(!1)}),u.jsx(J,{className:`ml-2 ${n===!0?"text-grey-900 dark:text-white":"text-grey-500"}`,label:"Yearly",link:!0,unstyled:!0,onClick:()=>r(!0)})]})]}),u.jsx("div",{className:"rounded-sm border border-grey-200 bg-white dark:border-transparent",children:u.jsxs("div",{className:"flex-column relative flex min-h-[200px] w-full max-w-[420px] scale-90 items-start justify-stretch rounded bg-white p-4",children:[u.jsxs("div",{className:"min-h-[56px] w-full",children:[u.jsx("h4",{className:`-mt-1 mb-0 w-full text-lg leading-tight font-semibold break-words text-ghostaccent ${!i&&"opacity-30"}`,children:i||(e?"Free":"Bronze")}),u.jsxs("div",{className:"mt-4 flex w-full flex-row flex-wrap items-end justify-between gap-x-1 gap-y-[10px]",children:[u.jsxs("div",{className:`flex flex-wrap text-black ${(n&&t?.yearly_price===void 0||!n&&t?.monthly_price===void 0)&&!e?"opacity-30":""}`,children:[u.jsx("span",{className:"self-start text-[2.7rem] leading-[1.115] font-bold uppercase",children:l}),u.jsx("span",{className:"text-[3.4rem] leading-none font-bold tracking-tight break-all",children:So(n?m:f)}),!e&&u.jsxs("span",{className:"ml-1 self-end text-[1.5rem] leading-snug text-grey-800",children:["/",n?"year":"month"]})]}),u.jsx(Ly,{trialDays:o})]}),n&&p>0&&u.jsx(Q8,{discount:p})]}),u.jsx("div",{className:"flex-column flex w-full flex-1",children:u.jsxs("div",{className:"flex-1",children:[u.jsx("div",{className:`mt-4 w-full text-[1.55rem] leading-snug font-semibold text-grey-900 ${!s&&"opacity-30"}`,children:s||(e?"Free preview":"Full access to premium content")}),u.jsx(Z8,{benefits:c})]})})]})})]})},_y=R("group/tiercard flex cursor-pointer flex-col items-start justify-between gap-4 self-stretch rounded-sm border border-transparent bg-grey-100 p-4 transition-all hover:border-grey-100 hover:bg-grey-50 hover:shadow-sm min-[900px]:min-h-[200px] dark:bg-grey-950 dark:hover:border-grey-800"),e_=({tier:t})=>{const{updateRoute:e}=fe(),n=t?.currency||"USD",r=kf(n);return u.jsx("div",{className:_y,"data-testid":"tier-card","data-tier":t.slug,children:u.jsxs("div",{className:"w-full grow",onClick:()=>{e({route:`tiers/${t.id}`})},children:[u.jsx("div",{className:"text-[1.65rem] leading-tight font-bold tracking-tight text-black dark:text-white",children:t.name}),u.jsxs("div",{className:"mt-2 flex items-baseline",children:[u.jsx("span",{className:"ml-1 translate-y-[-3px] text-md font-bold uppercase",children:r}),u.jsx("span",{className:"text-xl font-bold tracking-tighter",children:So(Yd(t.monthly_price||0))}),t.monthly_price&&t.monthly_price>0&&u.jsx("span",{className:"text-grey-700",children:"/month"})]}),t.trial_days?u.jsx("div",{className:"mt-1 mb-4",children:u.jsx(Ly,{size:"sm",trialDays:t.trial_days})}):"",u.jsx("div",{className:"mt-2 line-clamp-2 text-[1.4rem] font-medium",children:t.description||u.jsx("span",{className:"opacity-30",children:"No description"})})]})})},Mu=({tab:t,tiers:e})=>{const{updateRoute:n}=fe(),r=()=>{n("tiers/add")};return e.length?u.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 min-[900px]:grid-cols-3",children:[e.map(i=>u.jsx(e_,{tier:i},i.id)),t==="active-tiers"&&u.jsx("button",{className:`${_y} group cursor-pointer`,type:"button",onClick:()=>{r()},children:u.jsx("div",{className:"flex size-full flex-col items-center justify-center",children:u.jsxs("div",{className:"flex flex-col items-center justify-center",children:[u.jsx("div",{className:"translate-y-[15px] transition-all group-hover:translate-y-0",children:u.jsx(me,{colorClass:"text-green",name:"add"})}),u.jsx("div",{className:"mt-2 translate-y-[-10px] font-semibold text-green opacity-0 transition-all group-hover:translate-y-0 group-hover:opacity-100",children:"Add tier"})]})})})]}):u.jsxs(li,{icon:"money-bags",children:["No ",t==="active-tiers"?"active":"archived"," tiers found."]})},Bg=({className:t,onClick:e})=>(t=R("group flex shrink-0 items-center justify-center rounded border border-grey-300 px-3 py-1.5 font-semibold whitespace-nowrap text-grey-900 transition-all hover:border-grey-500 dark:border-grey-900 dark:text-white",t),u.jsxs("button",{className:t,"data-testid":"stripe-connected",type:"button",onClick:e,children:[u.jsx("span",{className:"inline-flex size-2 rounded-full bg-green transition-all group-hover:bg-[#625BF6]"}),u.jsx("span",{className:"ml-2",children:"Connected to Stripe"})]})),t_=({keywords:t})=>{const[e,n]=v.useState("active-tiers"),{settings:r,config:i}=ke(),{data:{tiers:s,meta:o,isEnd:a}={},fetchNextPage:l}=rh(),c=y2(s||[]),d=w2(s||[]),{updateRoute:h}=fe(),f=fs(),m=async()=>{if(f?.isDisabled("limitStripeConnect")&&!nr(r,i))try{await f.errorIfWouldGoOverLimit("limitStripeConnect")}catch(x){if(x instanceof Zo){pe.show(Vu,{prompt:x.message||"Your current plan doesn't support Stripe Connect.",onOk:()=>h({route:"/pro",isExternal:!0})});return}}h("stripe-connect")},p=x=>[...x].sort((y,w)=>(y.monthly_price??0)-(w.monthly_price??0)),g=[{id:"active-tiers",title:"Active",contents:u.jsx(Mu,{tab:"active-tiers",tiers:p(c)})},{id:"archived-tiers",title:"Archived",contents:u.jsx(Mu,{tab:"archive-tiers",tiers:p(d)})}];let b;return nr(r,i)?b=u.jsx(hr,{selectedTab:e,tabs:g,onTabChange:n}):b=u.jsx(Mu,{tab:"free-tier",tiers:c.filter(x=>x.type==="free")}),u.jsxs(Se,{customButtons:nr(r,i)?u.jsx(Bg,{className:"hidden tablet:!visible tablet:!block",onClick:m}):u.jsx(vm,{className:"hidden tablet:!visible tablet:!block",onClick:m}),description:"Set prices and paid member sign up settings",keywords:t,navid:"tiers",testId:"tiers",title:"Tiers",children:[u.jsx("div",{className:"w-full tablet:hidden",children:nr(r,i)?u.jsx(Bg,{className:"w-full",onClick:m}):u.jsx(vm,{onClick:m})}),b,a===!1&&u.jsx(J,{label:`Load more (showing ${s?.length||0}/${o?.pagination.total||0} tiers)`,link:!0,onClick:()=>l()})]})},n_=Ce(t_,"Tiers"),r_=1e4,i_=({keywords:t})=>{const{localSettings:e,siteData:n,updateSetting:r,saveState:i,handleSave:s,handleCancel:o,focusRef:a,errors:l,validate:c,clearError:d,handleEditingChange:h}=Ft({onValidate:()=>({donationsSuggestedAmount:J8(p,f,{maxAmount:r_})})}),[f="USD",m="500"]=we(e,["donations_currency","donations_suggested_amount"]),p=parseInt(m),g=`${n?.url.replace(/\/$/,"")}/#/portal/support`;v.useEffect(()=>{c()},[f]);const[b,x]=v.useState(!1),[y,w]=v.useState(!1);v.useEffect(()=>{e.some(j=>j.dirty)&&!y&&(w(!0),h(!0))},[e,y,h]);const k=()=>{navigator.clipboard.writeText(g),x(!0),setTimeout(()=>x(!1),2e3)},C=()=>{Ui(i==="unsaved",()=>window.open(g,"_blank"))},S=(E,j)=>{r(E,j)},A=()=>{o(),w(!1)},M=async()=>{await s()&&w(!1)};return u.jsxs(Se,{description:"Give your audience a simple way to support your work with one-time payments.",isEditing:y,keywords:t,navid:"tips-and-donations",saveState:i,testId:"tips-and-donations",title:"Tips & donations",hideEditButton:!0,onCancel:A,onEditingChange:w,onSave:M,children:[u.jsxs(tt,{columns:1,children:[u.jsx("div",{className:"flex max-w-[180px] items-end gap-[.6rem]",children:u.jsx(W2,{error:!!l.donationsSuggestedAmount,hint:l.donationsSuggestedAmount,inputRef:a,placeholder:"5",rightPlaceholder:u.jsx(ir,{border:!1,clearBg:!0,containerClassName:"w-14",fullWidth:!1,options:Fg(),selectedOption:Fg().flatMap(E=>E.options).find(E=>E.value===f),title:"Currency",hideTitle:!0,isSearchable:!0,onSelect:E=>S("donations_currency",E?.value||"USD")}),title:"Suggested amount",valueInCents:parseInt(m),onBlur:c,onChange:E=>S("donations_suggested_amount",E.toString()),onKeyDown:()=>d("donationsSuggestedAmount")},m)}),u.jsxs("div",{className:"w-100",children:[u.jsx("div",{className:"flex items-center gap-2",children:u.jsx(qe,{level:6,children:"Shareable link"})}),u.jsxs("div",{className:"group relative mt-0 flex w-100 items-center justify-between overflow-hidden border-b border-transparent pt-1 pb-2 hover:border-grey-300 dark:hover:border-grey-600",children:[u.jsx("span",{"data-testid":"donate-url",children:g}),u.jsxs("div",{className:"invisible flex gap-1 bg-white pl-1 group-hover:visible dark:bg-black",children:[u.jsx(J,{color:"clear","data-testid":"preview-shareable-link",label:"Preview",size:"sm",onClick:C}),u.jsx(J,{color:"light-grey","data-testid":"copy-shareable-link",label:b?"Copied":"Copy link",size:"sm",onClick:k})]})]})]})]}),u.jsxs("div",{className:"items-center-mt-1 flex",children:["All tips and donations are subject to Stripe's ",u.jsx("a",{className:"ml-1 font-medium text-green",href:"https://ghost.org/help/tips-donations/",rel:"noopener noreferrer",target:"_blank",children:" tipping policy"}),"."]})]})},s_=Ce(i_,"Tips & donations"),Re={access:["membership","default","access","subscription","post","membership","comments","commenting","signup","sign up","spam","filters","prevention","prevent","block","domains","email","password protection","lock site","private site","private site mode","make this site private"],tiers:["membership","tiers","payment","paid","stripe"],portal:["membership","portal","signup","sign up","signin","sign in","login","account","membership","support","email","address","support email address","support address"],giftSubscriptions:["membership","gift","gifts","gift subscriptions","present","share","shareable link"],memberEmails:["membership","signup","welcome email","welcome emails","email","new user","new member","account"],tips:["membership","tips","donations","one time","payment"]},o_=()=>{const{config:t,settings:e}=ke(),[n,r]=we(e,["donations_enabled","paid_members_enabled"]),i=nr(e||[],t||{}),s=ea("automations"),o=[Re.access,Re.tiers,Re.portal,...r?[Re.giftSubscriptions]:[],...s?[]:[Re.memberEmails],...n&&i?[Re.tips]:[]].flat();return u.jsxs(ui,{keywords:o,title:"Membership",children:[u.jsx(S8,{keywords:Re.access}),u.jsx(q8,{keywords:Re.access}),u.jsx(n_,{keywords:Re.tiers}),u.jsx(K8,{keywords:Re.portal}),r&&u.jsx(A8,{keywords:Re.giftSubscriptions}),!s&&u.jsx($8,{keywords:Re.memberEmails}),n&&i&&u.jsx(s_,{keywords:Re.tips})]})},a_=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("announcement-bar/edit")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Customize",size:"sm",onClick:n}),description:"Highlight important updates or offers",keywords:t,navid:"announcement-bar",testId:"announcement-bar",title:"Announcement bar"})},l_=Ce(a_,"Announcement bar"),c_=()=>{const t=fs(),{config:e}=ke(),n=e.hostSettings?.limits?.customThemes?.allowlist,r=n?.length===1||!1;return{checkThemeLimitError:v.useCallback(async s=>{if(!t?.isLimited("customThemes")||!(r||s&&n&&!n.includes(s.toLowerCase())))return null;try{const a=r?".":s||".";return await t.errorIfWouldGoOverLimit("customThemes",{value:a}),null}catch(a){return a instanceof Zo?a.message||"Your current plan doesn't support changing themes.":null}},[t,n,r]),isThemeLimited:t?.isLimited("customThemes")||!1,isThemeLimitCheckReady:t!==void 0,allowedThemesList:n,noThemeChangesAllowed:r}},u_=({keywords:t})=>{const[e,n]=v.useState(null),[r,i]=v.useState(!1),{checkThemeLimitError:s}=c_(),{route:o,updateRoute:a}=fe(),{data:l}=qw(),c=l?.themes.find(g=>g.active);v.useEffect(()=>{(async()=>{i(!0);const b=await s();n(b),i(!1)})()},[s]);const d=async()=>{r||(e?pe.show(Vu,{prompt:e,onOk:()=>a({route:"/pro",isExternal:!0})}):a("design/change-theme"))},m=[{id:"edit-code",label:"Edit code",onClick:async()=>{if(!c)return;const g=await s(".");if(g){pe.show(Vu,{prompt:g,onOk:()=>a({route:"/pro",isExternal:!0})});return}a(`theme/edit/${encodeURIComponent(c.name)}?from=${encodeURIComponent(o??"")}`)}},{id:"download",label:"Download",onClick:()=>{if(!c)return;const{apiRoot:g}=Ys();Yw(`${g}/themes/${c.name}/download`)}}],p=u.jsx(tt,{children:u.jsxs("div",{className:"flex flex-col",children:[u.jsx(qe,{grey:!1,level:6,children:"Active theme"}),u.jsxs("div",{className:"mt-1 flex w-full items-center justify-between gap-4",children:[u.jsx("div",{children:c?`${c.name} (v${c.package?.version||"1.0"})`:"Loading..."}),u.jsx("div",{className:"-mr-3",children:u.jsx(tA,{items:m,position:"end",triggerButtonProps:{disabled:!c,iconColorClass:"text-base",size:"sm"}})})]})]})});return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Change theme",size:"sm",onClick:d}),description:"Browse and install official themes or upload one",keywords:t,navid:"theme",testId:"theme",title:"Theme",children:p})},d_=Ce(u_,"Branding and design"),h_=""+new URL("design-settings-R1OjGW68.png",import.meta.url).href,f_=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("design/edit")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Customize",size:"sm",onClick:n}),description:"Customize the style and layout of your site",keywords:t,navid:"design",testId:"design",title:"Design & branding",children:u.jsx("img",{src:h_})})},m_=Ce(f_,"Branding and design"),p_=({keywords:t})=>{const{updateRoute:e}=fe(),n=()=>{e("navigation/edit")};return u.jsx(Se,{customButtons:u.jsx(J,{className:"mt-[-5px]",color:"clear",label:"Customize",size:"sm",onClick:n}),description:"Set up primary and secondary menus",keywords:t,navid:"navigation",testId:"navigation",title:"Navigation"})},g_=Ce(p_,"Navigation"),gn={design:["site","logo","cover","colors","fonts","background","themes","appearance","style","design & branding","design and branding"],theme:["theme","template","upload"],navigation:["site","navigation","menus","primary","secondary","links"],announcementBar:["site","announcement bar","important","banner"]},b_=()=>u.jsx(u.Fragment,{children:u.jsxs(ui,{keywords:Object.values(gn).flat(),title:"Site",children:[u.jsx(m_,{keywords:gn.design}),u.jsx(d_,{keywords:gn.theme}),u.jsx(g_,{keywords:gn.navigation}),u.jsx(l_,{keywords:gn.announcementBar})]})}),v_=()=>{const t=ea("automations");return u.jsx(u.Fragment,{children:u.jsxs("div",{className:"mb-[60vh] px-8 pt-16 tablet:max-w-[760px] tablet:px-14 tablet:pt-0",children:[u.jsx(X6,{}),u.jsx(b_,{}),u.jsx(o_,{}),t?u.jsx(qL,{}):u.jsx(NR,{}),u.jsx(w8,{}),u.jsx(yR,{})]})})},x_="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAC9FBMVEUAAAB+J/tXRf9mPP99M/9bQP9XQ/9VRv9VRv9WRf9WRP9XRP9XRf9VRf9cQP9aP/9bQP9ZQf9WRf9bQf9VRf9VRf9YRP9cPv9hPf9hPf9gPf9XPf9qN/9kOv9kOv9oOP9WQv9jOv9tNf9pN/9mOv9bP/95Kv9zMP9uNf9yMP9sNP9xMf9sM/9qNv9iPv9fP/9dQP9eP/96LP94Lv9yMf9oOP9qOP9hPf9mO/9fPv+FJP+DJf95LP+DIv93Lf94Lv92L/9uNv9kPP9lO/+BJ/+MH/9/Jv+HI/+FJf+AKf9+Kv9dP/+UGv+QHf+KH/+PG/+JIv+HI/+bFP+NIP+UGf9tNf+eFP+aFf+WGP+UGv+VGf9yMv+hEv+oDP+cE/+dFP+bFf95Lf+hDf+cFv+rCf+uB/+vCP+rC/+jEP+lDv+xB/+vB/+4A/+FJf+9BPa9AP64A/6wCP+vCP+NH/+IJP+FIf+2Bv+5Av+9AP64Bv6/AP6OHv/KAPfFAPrEAPvEAPrDAPvCAPi+AP66Af7HAPjCAPzFAPnRAPLMAPbNAPbQAPXNAPfhAPPXAPPTAPTKAPSpCv/UAPTUAPPQAPbGAPerC//VAPPUAPPXAPS2BP/bAPK1BP/dAPHeAPLgAPLdAPDcHO65AP+4Av/lAPXfAPLfAPC8AP3rAfDoAPHeAPHgAPDGAPryAfDlAPHsAPLyAPLoAPDzHPP1DvHsAPHzAPPvAPLpAPL7APP6APHzAPPOAPbNAPbRAPX0APH5A/L4APPvAPPLAPb4BPP+BfPyAPL3APP5APLdAO//GfH/Ku/8CvL/Nev/L+3/Ke//HfH/EfP8BPLxAPH9O+f1APDfAPH/QOn/POr/MO3/MO7/K+/8APH4AvLjAPL/Sef/Ref/ROj/Nuz/Nez/H/D2APDuAe7mAO//SOr/Rej/Ref/Qej/Qen/POr/LO37BvL/R+j/N+v/M+z/F/H+E/L/QOj/R+f/R+f/Ner/SOr/Suf/Qej/Tej/R+axG5kdAAAA/HRSTlMABQ4SCStddYWDfGhhVU04IDWViX9vZD5vmIAZi4ZoUUYmk3RiMCJsfVg5MitItayeWY+GPrrXzam+fW5cMC670J1ea1x3HoS1xp55aYlFLK1VdJg8mUx9XqaVpGdrRJacry+MTXk1iaBFXnGRqQ9mR6ZVT7skHn5YJoO0LGleo5lYt01xxzkmZJ2EzR1flzI9smy8P7tYw6moTb01mtZuB3iWGLllQk5Jej3ANovJjmIKE2ykf3Q5W5aNr0pRhcBnKjB5d39tK1WRpXV3hrDHYUIOKzd6mn6n0XFevluglbfHZUQ0Lhdtgom2pV5WpWuIdE1HnLFTL1+QOFCCqXMxAAAELklEQVR4AYXVtZ4jRxSF8XOru5rFtMzMu2ZmptjsFzDzEzgzQ2hKzJSZmdle5mEeSSN1S2qoWtSwNP/4fr8TXsI0RARIFqKFqQEnIhBFKp1QmitI1U2QC4DsShwA0ZDAdMpEOo+bzNMjJ3TqeuAHgTbGpZGrtFpYSBRoREUwQBjmiJDCIciqsEqzLixXVUX3vNhQkDdqDhN6lI0Cr2GGLDSWjokZC2tCTidAKGPFvCdzIOqqM5iez0N1Te+QmBooW13HYyDDFe58AgnFs+Eeb+AxJgMtM6IWpwTnU90kUNF3HKL+vhIAZT3laFewRjR6F+5T5gXokBPBleSSIkl4MapU9qOJJbZ3LNu9hO2vqKyRrlVkM7iaqo4HimJEB/djiuUretwUUcb4vbgQR5vBjSAiDMUN+hAzbC5q+e5IYsOfK3YGABTgalOJGLyUrnyAmQYXh9m15bNGxWjcHgXAgKTPDZhZi94jzES7zAVa9c96aEZ+AYACdavJaglVDd4hiVnQoL6gUD+zx2ZclAGGu8j1M1VS3obEbCT+ODAISHIX0QaAgSGTZDlDk4RWfqhuKZ4nOZZKgEGL19Hg8hVItPSvg36x7Gh/RgG7j/sxK85ttEGhJjYuwS3LcAGYgXScOVDRhsRzq2HWsNVIQlWgCK2KZ9BWeHTLKvq4kAWYEh/TkElhLof16i2FFQADsmVT0TCHPB3O7fcPrAADZA6KgvbuCyNN40kNpNpEVLXKaM/2IxgC6ALjnEsLGbRXQN6EDUCyToSGZXC0t9Osb5awLzTAnjcNrc4Z2iFo6wKowdp9BhhUFboX3oc2JGKMHZTYHSShgqmKLtkWtPNao+986hhZ1rkBKvQKl3pgop19jtiteGcfOvM2MNyZMjUf6jtoicDX+KY4e9T9H2AAh5lM6vJNtCI/Zjs1fxQH8dTJQIOmSW5lPkYrf5ib5IL1R+NxnAxuTnCuNRgYWnj5oh1HL+pHXC4AoAIIbOKwPPbNpZjFJ0fZzsjm2PFz4R4ABADf0XDCsznR+Zju570Nb2GxrI3Ykj2BZoBfyA8cV5eN6s2Y5E1eiw+lvBrzt2rfaP6TE8HHC4RCx/XHnI6TyX+fXVNM9NSAktN9zb9yW+WbzIorMRHgP4U8m6gkSyuGLdv1BBBGWRzRypsruy79dQW6uh7GSSpO2oJDBnmsQGQw2+3na3a6OKc+kExtodShfy9FMeiY8XZ7qQaLqGZ15K2DWN1lDSgd/Nyuxf8EZ9GP+a47gZMYmhbM3ylr3BUyHTuyjg8uN7aWF64trvnHirA3P9a8B2GKChFc1R+BtyqyQpT6eTW+fGfux3vQpGKKGGoUDS2NSV5KHsq5FLdWlmT5fEwgzNCb7bIdv5QfskQiUjz9q1swiYoZFgD/JbhURRqIqHcLpiC09NoO/HUPpjsGm6qha0KGUP0AAAAASUVORK5CYII=",je=({keywords:t,navid:e,...n})=>{const{ref:r,props:i}=QI(e),{currentSection:s}=yc(),{checkVisible:o}=Jo(),l=(Array.isArray(e)?e:[e]).includes(s||"");return u.jsx(tE,{ref:r,isCurrent:l,isVisible:o(t),navid:Array.isArray(e)?e[0]:e,...i,...n})},y_=()=>u.jsxs(Xw,{className:"gap-1 border-transparent bg-orange-100 px-1.5 py-0 text-[11px] leading-5 font-semibold text-orange-700 shadow-[0_0_0_1px_rgba(255,255,255,0.55)] dark:bg-orange-500/20 dark:text-orange-300 dark:shadow-[0_0_0_1px_rgba(255,255,255,0.12)]",variant:"secondary",children:[u.jsx(Jw,{className:"size-3",strokeWidth:2.25}),"Private"]}),w_=()=>{const{filter:t,setFilter:e,checkVisible:n,noResult:r,setNoResult:i}=Jo(),{updateRoute:s}=fe(),o=v.useRef(null),{isAnyTextFieldFocused:a}=ts(),{settings:l,config:c}=ke(),[d,h,f,m]=we(l,["donations_enabled","is_private","paid_members_enabled","editor_default_email_recipients"]),p=nr(l||[],c||{}),g=ea("automations"),b=m!=="disabled",x=!!c.mailgunIsConfigured,y=b&&!x,w=W.useMemo(()=>[Re.access,Re.tiers,Re.portal,...f?[Re.giftSubscriptions]:[],...g?[]:[Re.memberEmails],...d&&p?[Re.tips]:[]].flat(),[p,d,f,g]),k=W.useMemo(()=>{const E=g?Ln:Rn;return[E.enableNewsletters,...b?[E.defaultRecipients]:[],...g?[Ln.emails]:b?[Rn.newsletters]:[],...y?[E.mailgun]:[]].flat()},[g,b,y]),C=W.useMemo(()=>[Je.network,Je.explore,Je.recommendations,Je.embedSignupForm,...p?[Je.offers]:[]].flat(),[p]);v.useEffect(()=>{const E=j=>{j.target instanceof HTMLElement&&(j.target.nodeName==="INPUT"||j.target.nodeName==="TEXTAREA"||j.target.isContentEditable)||j.key==="/"&&!a&&(j?.preventDefault(),o.current&&o.current.focus())};return window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E)}}),v.useEffect(()=>{o.current&&o.current.focus()},[]),v.useEffect(()=>{!n(Object.values(gt).flat())&&!n(Object.values(gn).flat())&&!n([...w,...k])&&!n(C)&&!n(Object.values(Pt).flat())?i(!0):i(!1)},[n,i,t,k,w,C]),v.useEffect(()=>{const E=o.current,j=T=>{T.key==="Escape"&&t&&(o.current?.blur(),T.stopPropagation())};return E?.addEventListener("keydown",j),()=>{E?.removeEventListener("keydown",j)}},[t]);const S=E=>{E&&(e(""),i(!1),s(E.currentTarget.id))},A=E=>{e(E.target.value),E.target.value&&document.querySelector(".admin-x-settings")?.scrollTo({top:0,left:0})},M=R("hidden pt-10 tablet:visible! tablet:block!");return u.jsxs("div",{className:"ml-auto flex w-full flex-col pt-0 tablet:max-w-[240px]","data-testid":"sidebar",children:[u.jsx("div",{className:"sticky top-0 flex content-stretch items-end tablet:h-20 tablet:bg-grey-50 xl:h-20 dark:bg-grey-950 dark:tablet:bg-[#101114]",children:u.jsxs("div",{className:"relative w-full",children:[u.jsx(me,{className:"absolute top-2.5 left-3 z-10",colorClass:"text-grey-500",name:"magnifying-glass",size:"sm"}),u.jsx(at,{autoComplete:"off",autoCorrect:"off",className:"mr-8 flex h-9 w-full items-center rounded-full border border-transparent bg-white px-[33px] py-1.5 shadow-[0_0_1px_rgba(21,23,26,0.25),0_1px_3px_rgba(0,0,0,0.03),0_8px_10px_-12px_rgba(0,0,0,.1)] transition-colors hover:shadow-sm focus:border-green focus:bg-white focus:shadow-[0_0_0_2px_rgba(48,207,67,0.25)] tablet:mr-0 dark:border-transparent dark:bg-grey-900 dark:text-white dark:placeholder:text-grey-800 dark:focus:border-green dark:focus:bg-grey-950",containerClassName:"w-100",inputRef:o,placeholder:"Search settings",title:"Search",value:t,clearBg:!0,hideTitle:!0,unstyled:!0,onChange:A}),t?u.jsx(J,{className:"absolute top-3 right-14 p-1 tablet:right-3",icon:"close",iconColorClass:"text-grey-700 w-[10px]! h-[10px]!",size:"sm",unstyled:!0,onClick:()=>{e(""),o.current?.focus()}}):u.jsx("div",{className:"absolute top-[7px] -right-1/2 hidden rounded border border-grey-400 bg-white px-1.5 py-0.5 text-2xs font-semibold tracking-wider text-grey-600 uppercase shadow-[0px_1px_#CED4D9] tablet:visible! tablet:right-3 tablet:block! dark:border-grey-800 dark:bg-grey-900 dark:text-grey-500 dark:shadow-[0px_1px_#626D79]",children:"/"})]})}),u.jsxs("nav",{className:M,id:"admin-x-settings-sidebar",children:[r&&u.jsxs("div",{className:"ml-2 text-base text-grey-700",children:[u.jsx("h2",{className:"mb-2 text-base font-semibold tracking-normal text-black dark:text-white",children:"No result"}),u.jsxs("div",{children:[`We couldn't find any setting matching '${t}'`,"."]})]}),u.jsxs(ks,{isVisible:n(Object.values(gt).flat()),title:"General settings",children:[u.jsx(je,{icon:"textfield",keywords:gt.titleAndDescription,navid:"general",title:"Title & description",onClick:S}),u.jsx(je,{icon:"world-clock",keywords:gt.timeZone,navid:"timezone",title:"Timezone",onClick:S}),u.jsx(je,{icon:"language",keywords:gt.publicationLanguage,navid:"publication-language",title:"Publication language",onClick:S}),u.jsx(je,{icon:"user-pen",keywords:gt.users,navid:"staff",title:"Staff",onClick:S}),u.jsx(je,{icon:"layer",keywords:gt.metadata,navid:"metadata",title:"Meta data",onClick:S}),u.jsx(je,{icon:"like",keywords:gt.socialAccounts,navid:"social-accounts",title:"Social accounts",onClick:S}),u.jsx(je,{icon:"baseline-chart",keywords:gt.analytics,navid:"analytics",title:"Analytics",onClick:S})]}),u.jsxs(ks,{isVisible:n(Object.values(gn).flat()),title:"Site",children:[u.jsx(je,{icon:"palette",keywords:gn.design,navid:"design",title:"Design & branding",onClick:S}),u.jsx(je,{icon:"layout-2-col",keywords:gn.theme,navid:"theme",title:"Theme",onClick:S}),u.jsx(je,{icon:"navigation",keywords:gn.navigation,navid:"navigation",title:"Navigation",onClick:S}),u.jsx(je,{icon:"megaphone",keywords:gn.announcementBar,navid:"announcement-bar",title:"Announcement bar",onClick:S})]}),u.jsxs(ks,{isVisible:n([...w,...k]),title:"Membership",children:[u.jsx(je,{icon:"key",keywords:Re.access,navid:["members","spam-filters"],title:u.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-2",children:[u.jsx("span",{className:"min-w-0 truncate",children:"Access"}),h&&u.jsx(y_,{})]}),onClick:S}),u.jsx(je,{icon:"bills",keywords:Re.tiers,navid:"tiers",title:"Tiers",onClick:S}),u.jsx(je,{icon:"portal",keywords:Re.portal,navid:"portal",title:"Signup portal",onClick:S}),f&&u.jsx(je,{icon:"gift",keywords:Re.giftSubscriptions,navid:"gift-subscriptions",title:"Gift subscriptions",onClick:S}),!g&&u.jsx(je,{icon:"mailplus",keywords:Re.memberEmails,navid:"memberemails",title:"Welcome emails",onClick:S}),d&&p&&u.jsx(je,{icon:"piggybank",keywords:Re.tips,navid:"tips-and-donations",title:"Tips & donations",onClick:S}),g?u.jsx(je,{icon:"email",keywords:k,navid:["enable-newsletters","default-recipients","emails","mailgun"],title:"Email",onClick:S}):u.jsx(je,{icon:"email",keywords:k,navid:["enable-newsletters","default-recipients","newsletters","mailgun"],title:"Newsletters",onClick:S})]}),u.jsxs(ks,{isVisible:n(C),title:"Growth",children:[u.jsx(je,{icon:"ap-network",keywords:Je.network,navid:"network",title:"Network",onClick:S}),u.jsx(je,{icon:"globe-simple",keywords:Je.explore,navid:"explore",title:"Ghost Explore",onClick:S}),u.jsx(je,{icon:"heart",keywords:Je.recommendations,navid:"recommendations",title:"Recommendations",onClick:S}),u.jsx(je,{icon:"emailfield",keywords:Je.embedSignupForm,navid:"embed-signup-form",title:"Signup forms",onClick:S}),p&&u.jsx(je,{icon:"discount",keywords:Je.offers,navid:"offers",title:"Offers",onClick:S})]}),u.jsxs(ks,{isVisible:n(Object.values(Pt).flat()),title:"Advanced",children:[u.jsx(je,{icon:"modules-3",keywords:Pt.integrations,navid:"integrations",title:"Integrations",onClick:S}),u.jsx(je,{icon:"download",keywords:Pt.migrationtools,navid:"migration",title:"Import/Export",onClick:S}),u.jsx(je,{icon:"brackets",keywords:Pt.codeInjection,navid:"code-injection",title:"Code injection",onClick:S}),u.jsx(je,{icon:"labs-flask",keywords:Pt.labs,navid:"labs",title:"Labs",onClick:S}),u.jsx(je,{icon:"time-back",keywords:Pt.history,navid:"history",title:"History",onClick:S}),u.jsx(je,{icon:"warning",keywords:Pt.dangerzone,navid:"dangerzone",title:"Danger zone",onClick:S})]}),!t&&u.jsxs("a",{className:"mt-1 mb-10 flex h-[38px] w-100 cursor-pointer items-center rounded-lg px-3 py-2 text-left text-[14px] font-medium text-grey-800 transition-all hover:bg-grey-200 focus:bg-grey-100 dark:text-grey-600 dark:hover:bg-grey-950 dark:focus:bg-grey-900",onClick:()=>{s("about")},children:[u.jsx("img",{alt:"Ghost Logo",className:"mr-[7px] size-[18px]",src:x_}),"About Ghost"]})]})]})},k_=[],S_=':is([role="dialog"], [role="alertdialog"])[data-state="open"]',Vg=({children:t})=>u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed top-2 right-0 z-50 m-8 flex justify-end bg-transparent tablet:fixed tablet:top-0",id:"done-button-container",children:u.jsx(LI,{})}),u.jsx("div",{className:"fixed top-0 left-0 flex size-full bg-grey-50 dark:bg-grey-950 dark:tablet:bg-[#101114]",id:"admin-x-settings-content",children:t})]}),C_=()=>{const{currentUser:t}=ke(),{loadingModal:e}=fe(),{isDirty:n}=Gl(),r=s=>{window.location.hash=s},i=()=>document.getElementById("modal-backdrop")?!0:!!document.querySelector(S_);return v.useEffect(()=>{const s=o=>{if(o.key==="Escape"){if(i())return;Ui(n,()=>{r("/")})}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[n]),v.useEffect(()=>{Zw.remove()},[]),Qw(t)?Gg(t)?u.jsx(Vg,{children:u.jsx("div",{className:"flex-1 bg-white dark:bg-grey-950",children:u.jsx("div",{className:"h-full overflow-y-auto overscroll-y-contain",id:"admin-x-settings-scroller",children:u.jsxs("div",{className:"mx-auto max-w-5xl px-[5vmin] tablet:mt-16 xl:mt-10",children:[u.jsx(qe,{className:"mb-[5vmin]",children:"Settings"}),u.jsx(Oy,{highlight:!1,keywords:k_})]})})})}):u.jsxs(Vg,{children:[e&&u.jsx("div",{className:`fixed inset-0 z-40 h-[calc(100vh-55px)] w-[100vw] tablet:h-[100vh] ${ob}`}),u.jsx("div",{className:"fixed inset-x-0 top-0 z-[35] max-w-[calc(100%-16px)] flex-1 basis-[320px] overscroll-y-contain bg-white p-8 tablet:relative tablet:inset-x-auto tablet:top-auto tablet:h-full tablet:overflow-y-scroll tablet:bg-grey-50 tablet:py-0 dark:bg-grey-950 dark:tablet:bg-[#101114]",id:"admin-x-settings-sidebar-scroller",children:u.jsx("div",{className:"relative w-full",children:u.jsx(w_,{})})}),u.jsx("div",{className:"h-full flex-1 bg-white tablet:basis-[800px] dark:bg-grey-950 dark:tablet:bg-black",children:u.jsx("div",{className:"relative h-full overflow-y-scroll overscroll-y-contain pt-13",id:"admin-x-settings-scroller",children:u.jsx(v_,{})})})]}):null},A_={"design/change-theme":"DesignAndThemeModal","design/edit":"DesignAndThemeModal","theme/install":"DesignAndThemeModal","theme/edit/:name":"DesignAndThemeModal","navigation/edit":"NavigationModal","staff/invite":"InviteUserModal","staff/:slug/social-links":"UserDetailModal","staff/:slug/email-notifications":"UserDetailModal","staff/:slug/edit":"UserDetailModal","staff/:slug":"UserDetailModal","portal/edit":"PortalModal","tiers/add":"TierDetailModal","tiers/:id":"TierDetailModal","stripe-connect":"StripeConnectModal","newsletters/new":"AddNewsletterModal","newsletters/:id":"NewsletterDetailModal","history/view":"HistoryModal","history/view/:user":"HistoryModal","integrations/contentapi":"ContentApiModal","integrations/zapier":"ZapierModal","integrations/transistor":"TransistorModal","integrations/slack":"SlackModal","integrations/unsplash":"UnsplashModal","integrations/firstpromoter":"FirstPromoterModal","integrations/pintura":"PinturaModal","integrations/new":"AddIntegrationModal","integrations/:id":"CustomIntegrationModal","recommendations/add":"AddRecommendationModal","recommendations/edit":"EditRecommendationModal","announcement-bar/edit":"AnnouncementBarModal","embed-signup-form/show":"EmbedSignupFormModal","offers/edit":"OffersContainerModal","offers/edit/:id":"OffersContainerModal","offers/edit/retention/:id":"OffersContainerModal","offers/new":"OffersContainerModal","explore/testimonial":"TestimonialsModal",about:"AboutModal"},M_=()=>Co(()=>import("./modals-CVsVi0zu.js"),__vite__mapDeps([25,1,2,8,3,4,5,6,26,27,28,9,29,17,7,10,11,12,13,14,15,16,18]),import.meta.url),E_=()=>{const{updateNavigatedSection:t,scrollToSection:e}=yc(),{route:n,updateRoute:r}=fe();return qI((i,s)=>{i===s&&e(i.split("/")[0])},[e]),v.useEffect(()=>{if(n!==void 0){if(n.split("/")[0]==="locksite"){r("members");return}t(n.split("/")[0])}},[n,t,r]),null};function j_({designSystem:t,upgradeStatus:e}){return u.jsx(TP,{upgradeStatus:e,children:u.jsx(pe.Provider,{children:u.jsx(GI,{basePath:"settings",modals:{paths:A_,load:M_},children:u.jsxs(aE,{className:"admin-x-settings",...t,children:[u.jsx(E_,{}),u.jsx(C_,{})]})})})})}async function N_(){return await Co(()=>import("./koenig-lexical-B9U3sBS5.js"),__vite__mapDeps([30,1,2]),import.meta.url)}function T_(){return qr.createPortal(u.jsx("div",{className:"shade shade-admin",style:{position:"absolute",inset:0,zIndex:20},children:u.jsx(j_,{designSystem:{darkMode:!1,fetchKoenigLexical:N_}})}),document.body)}const p9=Object.freeze(Object.defineProperty({__proto__:null,default:T_},Symbol.toStringTag,{value:"Module"}));export{Mr as $,gh as A,J as B,m1 as C,SN as D,g8 as E,Ya as F,x_ as G,qe as H,Of as I,m8 as J,U_ as K,jd as L,tA as M,pe as N,ir as O,Sl as P,Tt as Q,tI as R,Fl as S,eE as T,tt as U,ZM as V,G5 as W,vm as X,W_ as Y,K_ as Z,hr as _,rl as a,a9 as a$,$n as a0,ls as a1,un as a2,rb as a3,at as a4,m9 as a5,en as a6,et as a7,K5 as a8,sc as a9,s9 as aA,Vo as aB,Ai as aC,Vu as aD,jg as aE,So as aF,W4 as aG,Y_ as aH,PL as aI,xf as aJ,n9 as aK,p9 as aL,i9 as aM,$N as aN,qN as aO,St as aP,I as aQ,sr as aR,QP as aS,PP as aT,h9 as aU,eP as aV,IP as aW,_P as aX,f9 as aY,c_ as aZ,o9 as a_,OT as aa,MO as ab,rs as ac,Ui as ad,Wt as ae,e9 as af,cs as ag,_g as ah,Fg as ai,Yd as aj,A2 as ak,GN as al,Z_ as am,Q_ as an,t9 as ao,lT as ap,aT as aq,Pc as ar,mf as as,Ga as at,cy as au,Cu as av,kf as aw,r9 as ax,ZN as ay,zo as az,q5 as b,ea as b0,ts as b1,ke as b2,Gl as b3,fs as b4,an as b5,d9 as b6,l9 as b7,oy as b8,Qo as b9,fe as ba,Ft as bb,Xo as bc,u9 as bd,ff as be,c9 as bf,gy as bg,J8 as bh,Iy as bi,W2 as c,P as d,xe as e,V as f,K2 as g,on as h,Zo as i,Oe as j,xn as k,dx as l,J_ as m,is as n,Wi as o,Ul as p,Fr as q,nb as r,li as s,be as t,ix as u,Gt as v,q_ as w,TN as x,eA as y,Br as z};
|