ghost 6.40.0 → 6.41.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/core/boot.js +8 -8
- package/core/built/admin/assets/{PolarAngleAxis-D7m1zwVk.js → PolarAngleAxis-Bh28wbPV.js} +1 -1
- package/core/built/admin/assets/{_baseAssignValue-BDsvYKNK.js → _baseAssignValue-hdDG700N.js} +1 -1
- package/core/built/admin/assets/{a-large-small-DxRNdz0F.js → a-large-small-BiK5_5LV.js} +1 -1
- package/core/built/admin/assets/{account-migration-SYnE1jBW.js → account-migration-DsSHanIB.js} +1 -1
- 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-Bj9rgbLw.mjs → code-editor-view-BEIdFhw3.mjs} +2 -2
- package/core/built/admin/assets/admin-x-settings/{index-BrZ9YAzd.mjs → index-BEh3nFEy.mjs} +3 -3
- package/core/built/admin/assets/admin-x-settings/{index-DRndIh9T.mjs → index-BLF2n6YB.mjs} +2 -2
- package/core/built/admin/assets/admin-x-settings/{index-CIl25Teq.mjs → index-BmPIWs5F.mjs} +3 -3
- package/core/built/admin/assets/admin-x-settings/{index-CNyNY3Wh.mjs → index-CP9YnNzc.mjs} +3 -3
- package/core/built/admin/assets/admin-x-settings/{index-SGr5sE2h.mjs → index-Cd2Ns-D2.mjs} +2 -2
- package/core/built/admin/assets/admin-x-settings/{index-PGoLP2kh.mjs → index-CjqAcKpK.mjs} +5 -5
- package/core/built/admin/assets/admin-x-settings/{index-pCIv_7bB.mjs → index-CnMcD9aj.mjs} +6212 -6158
- package/core/built/admin/assets/admin-x-settings/{index-CPCcgad-.mjs → index-LzsrZC40.mjs} +3 -3
- package/core/built/admin/assets/admin-x-settings/{index-DPqY4h5h.mjs → index-ZYW0UW7I.mjs} +3 -3
- package/core/built/admin/assets/admin-x-settings/{modals-lo32WZLi.mjs → modals-C48Tq1rW.mjs} +9 -9
- package/core/built/admin/assets/{arrow-right-BixoEua4.js → arrow-right-Bk43nMGd.js} +1 -1
- package/core/built/admin/assets/{at-sign-BsHNViA_.js → at-sign-DWOf36uj.js} +1 -1
- package/core/built/admin/assets/{audience-0RCWjbIK.js → audience-CvP78Gug.js} +1 -1
- package/core/built/admin/assets/{automations-DTUfYvf6.js → automations-BBWZhrha.js} +1 -1
- package/core/built/admin/assets/{automations-DiGkcVt-.js → automations-CmulGWwu.js} +1 -1
- package/core/built/admin/assets/{avatar-flipboard-BgoH-wIq.js → avatar-flipboard-CVf-N6wp.js} +1 -1
- package/core/built/admin/assets/{bluesky-sharing-C2xwSoS-.js → bluesky-sharing-DVC3I9Um.js} +1 -1
- package/core/built/admin/assets/{chart-X5cLIH1X.js → chart-CUKSNmKY.js} +1 -1
- package/core/built/admin/assets/{checkbox-DMamS4oG.js → checkbox-B_yDSM8z.js} +1 -1
- package/core/built/admin/assets/{chevron-up-CVgBkTk5.js → chevron-up-DuaKtE_M.js} +1 -1
- package/core/built/admin/assets/{chunk.941.f47098cbbce89a049e03.js → chunk.331.2ec2e2702eda02de96cd.js} +3 -3
- package/core/built/admin/assets/{chunk.524.a1d668dcc84709a5d702.js → chunk.524.49cc01002e1a5dba8ef9.js} +4 -4
- package/core/built/admin/assets/{chunk.582.180bf2525cf552f5ac5f.js → chunk.582.4bbc54c5f7d3dfb93288.js} +6 -6
- package/core/built/admin/assets/{circle-alert-Dg3UkvRP.js → circle-alert-bcK_Yqap.js} +1 -1
- package/core/built/admin/assets/{code-editor-view-CAICoZJe.js → code-editor-view-Bl4Jzjhk.js} +1 -1
- package/core/built/admin/assets/{comments-BHru9ZQ8.js → comments-DMea0nul.js} +1 -1
- package/core/built/admin/assets/{content-helpers-BByMp-Y5.js → content-helpers-B2yRzdvJ.js} +1 -1
- package/core/built/admin/assets/{copy-D7jqplrv.js → copy-DVtQi_VJ.js} +1 -1
- package/core/built/admin/assets/{data-list-DUaY9nlT.js → data-list-BF4GeUmt.js} +1 -1
- package/core/built/admin/assets/{deleted-feed-item-jLcSKuul.js → deleted-feed-item-DO2u3qmi.js} +1 -1
- package/core/built/admin/assets/{dropzone-DSPf3N_o.js → dropzone-Cs4DrURS.js} +1 -1
- package/core/built/admin/assets/{edit-profile-BvU2-lW5.js → edit-profile-CnuBNQhO.js} +1 -1
- package/core/built/admin/assets/{editor-D3fcjt_F.js → editor-CTO9FIUW.js} +1 -1
- package/core/built/admin/assets/{empty-indicator-2Pjmce3n.js → empty-indicator-BvyaMcmw.js} +1 -1
- package/core/built/admin/assets/{en-Bu-6PYn5.js → en-CjPXRj8j.js} +1 -1
- package/core/built/admin/assets/{feed-CygLK1Ad.js → feed-D2wk4cCS.js} +1 -1
- package/core/built/admin/assets/{filter-query-core-a0PNU2EO.js → filter-query-core-VEnwTCyO.js} +1 -1
- package/core/built/admin/assets/{filters-jiyRsLMH.js → filters-DtIsuqv5.js} +1 -1
- package/core/built/admin/assets/{gh-chart-CEhBBu3F.js → gh-chart-JxzKqaoO.js} +1 -1
- package/core/built/admin/assets/{ghost-0ab96884815339963364804ab266c99f.js → ghost-30c3dedbe1cca943b92efa7efd2710e4.js} +36 -21
- package/core/built/admin/assets/{growth-Fz3Oatml.js → growth-CPNrBpHK.js} +1 -1
- package/core/built/admin/assets/{hash-CeFrjo3C.js → hash-CJzbTA5k.js} +1 -1
- package/core/built/admin/assets/{inbox-CCirPaG2.js → inbox-CVVAkCmd.js} +1 -1
- package/core/built/admin/assets/{index-Dd2BJRZH.js → index-AkQJUr1z.js} +1 -1
- package/core/built/admin/assets/{index-CYPN5csJ.js → index-BLWOUf31.js} +1 -1
- package/core/built/admin/assets/{index-D7Ui3Fih.js → index-BRBRkRqa.js} +1 -1
- package/core/built/admin/assets/{index-CFEzD2_M.js → index-BkbhBpVC.js} +3 -3
- package/core/built/admin/assets/{index-BYwL7gFN.js → index-BxFFWYdP.js} +1 -1
- package/core/built/admin/assets/{index-D3LfHeBl.js → index-C5_ZKpC1.js} +1 -1
- package/core/built/admin/assets/{index-Bjw2qAph.js → index-Cdbufdfy.js} +1 -1
- package/core/built/admin/assets/{index-BTf6YUBb.js → index-Cq5vsvxE.js} +1 -1
- package/core/built/admin/assets/{index-DPbi4ie_.js → index-CuGoX8Ub.js} +1 -1
- package/core/built/admin/assets/{index-CsaU9dfl.js → index-CuH5raTz.js} +1 -1
- package/core/built/admin/assets/{index-Bf83suMc.js → index-D3A8RTi0.js} +1 -1
- package/core/built/admin/assets/{index-Dskrbhv3.js → index-DIyK69JM.js} +1 -1
- package/core/built/admin/assets/{index-GExKMpy_.js → index-DLFVpwt3.js} +1 -1
- package/core/built/admin/assets/{index-BOMdiHRG.js → index-DQZp_NsL.js} +1 -1
- package/core/built/admin/assets/{index-2qcjFCQs.js → index-DR74ulj2.js} +1 -1
- package/core/built/admin/assets/{index-WKMARia9.js → index-DYE2untj.js} +1 -1
- package/core/built/admin/assets/{index-DNZUJQ8v.js → index-DssW7xhk.js} +1 -1
- package/core/built/admin/assets/{index-Cq4mS7QK.js → index-DvyNqFct.js} +1 -1
- package/core/built/admin/assets/{index-C7xLyJVb.js → index-DxB7NHpG.js} +1 -1
- package/core/built/admin/assets/{index-Bw4DM4Pr.js → index-IDaHqjnu.js} +1 -1
- package/core/built/admin/assets/{index-ClOB5u8L.js → index-TtBMzSeP.js} +1 -1
- package/core/built/admin/assets/{index-takfwHSn.js → index-UMWVIyz7.js} +1 -1
- package/core/built/admin/assets/{koenig-lexical-BJM9wAwQ.js → koenig-lexical-DVAmevhl.js} +1 -1
- package/core/built/admin/assets/{kpi-card-BP-2yicn.js → kpi-card-D3CzvsrI.js} +1 -1
- package/core/built/admin/assets/{kpi-card-DOplXdDT.js → kpi-card-DV-nN7xT.js} +1 -1
- package/core/built/admin/assets/{kpi-tabs-Rq5jJW2Z.js → kpi-tabs-B3NkaTwb.js} +1 -1
- package/core/built/admin/assets/{kpis-yHgME_iy.js → kpis-CVwF08QL.js} +1 -1
- package/core/built/admin/assets/{label-fijjy1Mb.js → label-BiPpMny2.js} +1 -1
- package/core/built/admin/assets/{links-s3IeAkbo.js → links-BY0Uo6O5.js} +1 -1
- package/core/built/admin/assets/{list-page-CUcB5ebB.js → list-page-COHNMpOi.js} +1 -1
- package/core/built/admin/assets/{loader-circle-C7mWzo52.js → loader-circle-B1uEfpbZ.js} +1 -1
- package/core/built/admin/assets/{mail-9TFkAaAh.js → mail-ccQhEr7k.js} +1 -1
- package/core/built/admin/assets/{main-layout-XtviVkg1.js → main-layout-BYKdA6Z1.js} +1 -1
- package/core/built/admin/assets/{members-XkHao5Yf.js → members-DkpEnvG5.js} +1 -1
- package/core/built/admin/assets/minus-C68D81nx.js +1 -0
- package/core/built/admin/assets/{modals-B6R7oqvb.js → modals-X6RSWn5Y.js} +3 -3
- package/core/built/admin/assets/{moderation-B2Tixfce.js → moderation-BFrrwfvx.js} +1 -1
- package/core/built/admin/assets/{newsletter-CbESXhxf.js → newsletter-n7kc6cxR.js} +1 -1
- package/core/built/admin/assets/{newsletters-DOIL_cOY.js → newsletters-CSCa3QdE.js} +1 -1
- package/core/built/admin/assets/{note-mUikaB-p.js → note-CMZjeK8e.js} +1 -1
- package/core/built/admin/assets/{onboarding-route-Dqv2nP7b.js → onboarding-route-BaX0a-pu.js} +1 -1
- package/core/built/admin/assets/{overview-yZ-7KJdx.js → overview-CS9dmE_6.js} +1 -1
- package/core/built/admin/assets/{pagemenu-TxGvHwRO.js → pagemenu-O_y8Jm4v.js} +1 -1
- package/core/built/admin/assets/{pencil-CKTgzafp.js → pencil-BcymGPnE.js} +1 -1
- package/core/built/admin/assets/{pin-BU_u-xRX.js → pin-Bl3nSr7I.js} +1 -1
- package/core/built/admin/assets/{post-analytics-CWA8invj.js → post-analytics-DW-TKu-t.js} +1 -1
- package/core/built/admin/assets/{post-analytics-context-BWDhMRq_.js → post-analytics-context-D7PgEMo8.js} +1 -1
- package/core/built/admin/assets/{post-analytics-header-Bm0mcxjK.js → post-analytics-header-B8C0vA5Y.js} +1 -1
- package/core/built/admin/assets/{post-share-modal-D8BtRD2u.js → post-share-modal-D0OlASBQ.js} +1 -1
- package/core/built/admin/assets/{posts-u-CAKddc.js → posts-BZaw4-dc.js} +1 -1
- package/core/built/admin/assets/{power-DR9gpiQR.js → power-DWm6pts5.js} +1 -1
- package/core/built/admin/assets/{referrers-DV_Ihg9y.js → referrers-BsZ85Z0a.js} +1 -1
- package/core/built/admin/assets/{repeat-uXmOJ6y8.js → repeat-DQay9e22.js} +1 -1
- package/core/built/admin/assets/{reply-9ZyqaxI-.js → reply-CoNqmExw.js} +1 -1
- package/core/built/admin/assets/{rocket-DMOr1OCt.js → rocket-Dne6P_8f.js} +1 -1
- package/core/built/admin/assets/{select-CPSy44ld.js → select-BfWJkrKc.js} +1 -1
- package/core/built/admin/assets/{settings-krk0432u.js → settings-BoXzKMhL.js} +1 -1
- package/core/built/admin/assets/{settings-66Zv8QvL.js → settings-rRY210wx.js} +25 -25
- package/core/built/admin/assets/{share-modal-BRmGllZq.js → share-modal-CtdLQbnQ.js} +1 -1
- package/core/built/admin/assets/{sort-button-5fyeViQL.js → sort-button-7pVgpa0d.js} +1 -1
- package/core/built/admin/assets/{source-icon-DeeHyZRn.js → source-icon-Dtua85oN.js} +1 -1
- package/core/built/admin/assets/{sprout-956Q4On2.js → sprout-CpwUJAPT.js} +1 -1
- package/core/built/admin/assets/{square-BaCvbKJY.js → square-CDrQjv8R.js} +1 -1
- package/core/built/admin/assets/{stats-BVKNZJO6.js → stats-Yo9Gco0_.js} +1 -1
- package/core/built/admin/assets/{stats-view-gtyaqudG.js → stats-view-DubukX9V.js} +1 -1
- package/core/built/admin/assets/{step-1-09wdjzdX.js → step-1-CH8jWKi7.js} +1 -1
- package/core/built/admin/assets/{step-2-8iaQ0efq.js → step-2-CWy7Qi0Q.js} +1 -1
- package/core/built/admin/assets/{step-3-BuHAZbdD.js → step-3-CNiDFH17.js} +1 -1
- package/core/built/admin/assets/{table-DTofVyjA.js → table-qQi9EXB1.js} +1 -1
- package/core/built/admin/assets/{tabs-CL5eaCGL.js → tabs-M6kFEqPE.js} +1 -1
- package/core/built/admin/assets/{tags-DJrbEw5-.js → tags-74U6lgwY.js} +1 -1
- package/core/built/admin/assets/{tags-U3lciBmd.js → tags-DuMshkTz.js} +1 -1
- package/core/built/admin/assets/{textarea-DdDuNixZ.js → textarea-CGBp9nOo.js} +1 -1
- package/core/built/admin/assets/{tiers-DXKbghdk.js → tiers-D2DYHaeO.js} +1 -1
- package/core/built/admin/assets/{toggle-group-DaZKTYDS.js → toggle-group-GYp_w6Po.js} +1 -1
- package/core/built/admin/assets/{topic-filter-BzqiVOAU.js → topic-filter-N3CzJ01P.js} +1 -1
- package/core/built/admin/assets/{trash-CKK_p9G5.js → trash-CUqAK3SQ.js} +1 -1
- package/core/built/admin/assets/{underline-Bq0P-5Zy.js → underline-CwuJG-Ql.js} +1 -1
- package/core/built/admin/assets/{undo-2-CcBtw-tW.js → undo-2-D6ZRqONE.js} +1 -1
- package/core/built/admin/assets/{upload-BcylHEMw.js → upload-BLiT66bJ.js} +1 -1
- package/core/built/admin/assets/{use-growth-stats-Ci0gymWp.js → use-growth-stats-u18So4Gq.js} +1 -1
- package/core/built/admin/assets/{use-simple-pagination-ByaFwxfZ.js → use-simple-pagination-Dp2sTt2S.js} +1 -1
- package/core/built/admin/assets/{user-round-check-D0I7NO1g.js → user-round-check-BDomHaso.js} +1 -1
- package/core/built/admin/assets/{user-round-x-DeGVH29o.js → user-round-x-Cc0RL-V9.js} +1 -1
- package/core/built/admin/assets/{virtual-list-window-S0xZxQAf.js → virtual-list-window-BnjCoNIr.js} +1 -1
- package/core/built/admin/assets/{wallet-cards-B9TQg4x3.js → wallet-cards-CVZ99Nm3.js} +1 -1
- package/core/built/admin/assets/{web-BRN2mUpo.js → web-B_MLxGxZ.js} +1 -1
- package/core/built/admin/index.html +5 -5
- package/core/server/{services/custom-redirects/file-store.js → adapters/redirects/FileStore.js} +6 -5
- package/core/server/{services/custom-redirects/file-store.ts → adapters/redirects/FileStore.ts} +6 -4
- package/core/server/adapters/redirects/RedirectsStoreBase.d.ts +9 -0
- package/core/server/adapters/redirects/RedirectsStoreBase.js +8 -0
- package/core/server/{services/custom-redirects/gcs-store.js → adapters/redirects/S3RedirectsStore.js} +50 -18
- package/core/server/adapters/redirects/S3RedirectsStore.ts +163 -0
- package/core/server/adapters/scheduling/scheduling-base.js +41 -0
- package/core/server/adapters/scheduling/types.js +2 -0
- package/core/server/adapters/scheduling/types.ts +36 -0
- package/core/server/api/endpoints/authentication.js +26 -5
- package/core/server/api/endpoints/schedules.js +0 -30
- package/core/server/api/endpoints/utils/serializers/output/authentication.js +10 -0
- package/core/server/data/migrations/versions/6.41/2026-05-13-12-00-00-rename-reset-all-passwords-permission.js +21 -0
- package/core/server/data/schema/fixtures/fixtures.json +3 -3
- package/core/server/models/api-key.js +18 -0
- package/core/server/models/user.js +18 -0
- package/core/server/services/adapter-manager/config.js +6 -0
- package/core/server/services/adapter-manager/index.js +1 -0
- package/core/server/services/auth/index.js +4 -0
- package/core/server/services/auth/reset-authentication.js +50 -0
- package/core/server/services/auth/reset-authentication.ts +75 -0
- package/core/server/services/automations/index.js +21 -15
- package/core/server/services/custom-redirects/index.js +2 -4
- package/core/server/services/gifts/gift-bookshelf-repository.js +7 -0
- package/core/server/services/gifts/gift-bookshelf-repository.ts +10 -0
- package/core/server/services/gifts/gift-reminder-scheduler.js +94 -0
- package/core/server/services/gifts/gift-reminder-scheduler.ts +109 -0
- package/core/server/services/gifts/gift-repository.ts +1 -0
- package/core/server/services/gifts/gift-service-wrapper.js +10 -7
- package/core/server/services/gifts/gift-service.js +1 -32
- package/core/server/services/gifts/gift-service.ts +3 -59
- package/core/server/services/internal-keys/index.js +1 -3
- package/core/server/services/internal-keys/index.ts +11 -3
- package/core/server/services/post-scheduling/index.js +16 -28
- package/core/server/services/post-scheduling/index.ts +14 -0
- package/core/server/services/post-scheduling/post-scheduling.js +115 -0
- package/core/server/services/post-scheduling/post-scheduling.ts +138 -0
- package/core/server/services/users.js +29 -16
- package/core/server/web/api/endpoints/admin/middleware.js +8 -4
- package/core/server/web/api/endpoints/admin/routes.js +1 -1
- package/core/shared/config/defaults.json +5 -0
- package/core/shared/labs.js +2 -1
- package/package.json +1 -1
- package/core/built/admin/assets/minus-DPrXh11r.js +0 -1
- package/core/server/services/custom-redirects/gcs-store.ts +0 -117
- package/core/server/services/post-scheduling/post-scheduler-service.js +0 -126
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,G as ae,dk as Mt,aJ as ss,ar as Fs,r as c,a1 as Qe,B as $,cW as rs,X as pt,bi as ft,ag as bt,ai as Us,cS as as,cT as ns,cU as is,D as Fe,v as Ue,w as Be,x as ze,ao as Ne,ad as ve,dl as Bs,dm as zs,dn as ls,e as Je,bD as $s,C as Vs,c2 as Hs,cL as Te,aL as gt,dp as Ws,ac as Gs,cE as os,aZ as cs,dq as Ks,dr as Ys,Y as ce,b7 as qs,aW as Qs,b8 as Js,b9 as Xs,bb as Me,bc as Rt,cv as ds,aK as Zs,ds as er,dt as tr,du as sr,b6 as et,cu as ut,dv as xt,dw as rr,dx as ar,cl as Ot,dy as nr,dz as us,dA as It,aN as $e,cz as je,dB as ms,t as ne,dd as ir,cJ as lr,c0 as or,c1 as cr,d5 as hs,bR as dr,bg as ps,d6 as ur,d8 as mr}from"./index-CFEzD2_M.js";import{M as fs}from"./main-layout-XtviVkg1.js";import{C as yt,a as hr,b as vt,d as wt,e as Xe,f as Dt,g as Ve,h as pr,F as fr}from"./filters-jiyRsLMH.js";import{P as bs}from"./pencil-CKTgzafp.js";import{h as gs,o as St,q as br,r as gr,v as xs,d as xr,D as He,a as We,w as nt,s as Se,x as it,b as Ge,t as At,y as yr,g as vr,f as wr,c as Sr,u as _r,i as jr,p as ys,j as Er,n as Nr,l as Cr,k as kr,m as Lr,F as Mr}from"./filter-query-core-a0PNU2EO.js";import{D as Rr,u as Or}from"./dropzone-DSPf3N_o.js";import{U as vs,D as Ir,b as Dr,N as Ar,T as Pr,M as Tr,P as Fr,a as Ur,S as Br,A as zr,C as $r,c as Vr,d as Hr,e as Wr}from"./upload-BcylHEMw.js";import{S as Gr,a as Kr,b as Yr,c as qr,f as Pt}from"./select-CPSy44ld.js";import{T as Ze,a as _t,b as Ee,c as be,d as ws,e as me}from"./table-DTofVyjA.js";import{b as Qr}from"./member-route-ZLy3opLv.js";import{u as Ss}from"./newsletters-DOIL_cOY.js";import{T as Jr}from"./tags-U3lciBmd.js";import{E as mt}from"./empty-indicator-2Pjmce3n.js";import{L as lt,C as Xr,E as Zr,F as ea,a as ta}from"./loader-circle-C7mWzo52.js";import{M as sa}from"./mail-9TFkAaAh.js";import{g as _s}from"./get-site-timezone-BDBAcjmq.js";import{u as ra}from"./tiers-DXKbghdk.js";import{b as aa}from"./posts-u-CAKddc.js";import{A as Tt}from"./arrow-right-BixoEua4.js";import{u as na,a as ia,L as la}from"./virtual-list-window-S0xZxQAf.js";import{L as Oe,P as ye}from"./list-page-CUcB5ebB.js";import"./circle-alert-Dg3UkvRP.js";import"./index-ClOB5u8L.js";import"./typeof-QjJsDpFa.js";import"./index-WKMARia9.js";import"./chevron-up-CVgBkTk5.js";function oa({className:t,...s}){return e.jsx("div",{className:ae(Mt.base,Mt.invalidWithin,"group/input-group relative flex w-full items-center outline-hidden","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:outline-hidden has-[[data-slot=input-group-control]:focus-visible]:bg-transparent has-[[data-slot=input-group-control]:focus-visible]:border-focus-ring has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-focus-ring/25",t),"data-slot":"input-group",role:"group",...s})}const ca=Fs("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--input-group-radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3","block-end":"order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3"}},defaultVariants:{align:"inline-start"}});function da({className:t,align:s="inline-start",...r}){return e.jsx("div",{className:ae(ca({align:s}),t),"data-align":s,"data-slot":"input-group-addon",role:"group",onClick:a=>{if(a.target.closest("button"))return;a.currentTarget.closest('[data-slot="input-group"]')?.querySelector('[data-slot="input-group-control"]')?.focus()},...r})}function ua({className:t,...s}){return e.jsx(ss,{className:ae("flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:outline-hidden focus-visible:shadow-none dark:bg-transparent",t),"data-slot":"input-group-control",...s})}const ma={searchPlaceholder:"Search...",noResultsFound:"No results found.",loading:"Loading...",loadMore:"Load more"};function ha(t,s){const r=s.trim().toLowerCase();return r?t.filter(a=>a.label.toLowerCase().includes(r)||a.detail?.toLowerCase().includes(r)):t}function pa(t,s,r,a,i,o,p){if(t)return{...t,shouldClientFilter:p??t.shouldClientFilter};const d=!!s,u=s?.useOptions({query:a,selectedValues:i});return{options:d?u?.options??[]:r??[],isInitialLoad:d?u?.isInitialLoad??!1:o&&(r?.length??0)===0,isSearching:d?u?.isSearching??!1:o&&(r?.length??0)>0,hasMore:d?u?.hasMore??!1:!1,isLoadingMore:d?u?.isLoadingMore??!1:!1,loadMore:d?u?.loadMore??(()=>{}):()=>{},shouldClientFilter:p??!d}}function fa({optionSource:t,options:s,values:r,onChange:a,valueSource:i,searchable:o=!0,isLoading:p=!1,maxSelections:d,isMultiSelect:u=!0,onClose:h,autoCloseOnSelect:b=!1,className:E,searchInputClassName:y,shouldFilter:v,onSearchChange:L,i18n:N,renderItem:f,header:M,footer:A}){const P=c.useMemo(()=>({...ma,...N}),[N]),[D,_]=c.useState(""),S=c.useCallback(C=>{_(C),t?.onSearchChange?.(C),L?.(C)},[L,t]),w=pa(t,i,s,D,r,p,v),n=w.options,[l,m]=c.useState([]),g=c.useMemo(()=>n.filter(C=>r.includes(C.value)),[n,r]);c.useEffect(()=>{if(r.length===0){m([]);return}g.length>0&&m(C=>{const G=[];for(const J of r){const T=g.find(H=>H.value===J)??C.find(H=>H.value===J);T&&G.push(T)}return G})},[g,r]);const x=c.useMemo(()=>r.length===0?[]:l.length>0?l:g,[l,r.length,g]),R=c.useMemo(()=>ha(x,D),[D,x]),V=c.useMemo(()=>n.filter(C=>!r.includes(C.value)),[n,r]),Z=c.useCallback(C=>{a(r.filter(G=>G!==C.value))},[a,r]),se=C=>{a([]),h?.()},j=C=>{const G=[...r,C.value];d&&G.length>d||(a(G),b&&h?.())},U=C=>{a([C.value]),h?.()},O=u?Z:se,Y=u?j:U,k=c.useCallback(()=>S(""),[S]),F=(C,G)=>{if(G)return;const J=C.detail?` - ${C.detail}`:"";return C.label+J},B=f??(({option:C,isSelected:G,onSelect:J})=>e.jsxs(Ve,{className:"group flex items-center gap-2",value:F(C,G),onSelect:J,children:[C.icon,e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsx("span",{className:"truncate text-accent-foreground",title:C.label,children:C.label}),C.detail&&e.jsx("span",{className:"truncate text-sm text-muted-foreground",title:C.detail,children:C.detail})]}),e.jsx(Qe,{className:ae("ms-auto text-primary",!G&&"opacity-0")})]},String(C.value)));return e.jsx("div",{className:ae("w-full",E),children:e.jsxs(yt,{shouldFilter:w.shouldClientFilter,children:[M?.({selectedOptions:x,onDeselect:Z}),o&&e.jsxs("div",{className:"relative",children:[e.jsx(hr,{className:ae("h-(--control-height) pr-8 text-sm",y),placeholder:P.searchPlaceholder,value:D,onValueChange:S}),w.isSearching&&e.jsx(lt,{className:"pointer-events-none absolute top-1/2 right-3 size-4 -translate-y-1/2 animate-spin text-muted-foreground"})]}),e.jsxs(vt,{className:"outline-hidden",children:[w.isInitialLoad?e.jsxs("div",{className:"flex items-center justify-center py-6 text-sm text-muted-foreground",children:[e.jsx(lt,{className:"mr-2 size-4 animate-spin"}),P.loading]}):e.jsx(wt,{children:P.noResultsFound}),R.length>0&&e.jsx(Xe,{heading:P.selectedHeading,children:R.map(C=>B({option:C,isSelected:!0,onSelect:()=>O(C)}))}),V.length>0&&e.jsxs(e.Fragment,{children:[R.length>0&&e.jsx(Dt,{}),e.jsx(Xe,{children:V.map(C=>B({option:C,isSelected:!1,onSelect:()=>Y(C)}))})]}),w.hasMore&&e.jsxs(e.Fragment,{children:[(R.length>0||V.length>0)&&e.jsx(Dt,{}),e.jsx("div",{className:"p-1.5",children:e.jsxs("button",{className:"flex w-full items-center justify-center rounded-xs px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-50",disabled:w.isLoadingMore,type:"button",onClick:w.loadMore,children:[w.isLoadingMore&&e.jsx(lt,{className:"mr-2 size-4 animate-spin"}),w.isLoadingMore?P.loading:P.loadMore]})})]})]}),A?.({searchInput:D,clearSearch:k})]})})}const js=({label:t,onSave:s,onCancel:r,onDelete:a,isDuplicateName:i})=>{const[o,p]=c.useState(t.name),[d,u]=c.useState(!1),[h,b]=c.useState(""),[E,y]=c.useState(!1),[v,L]=c.useState(!1),N=c.useRef(null),f=E||v;c.useEffect(()=>{N.current?.focus(),N.current?.select()},[]);const M=_=>{const S=_.trim();return S?i?.(S,t.id)?"A label with this name already exists":"":"Name is required"},A=async()=>{const _=M(o);if(_){b(_);return}y(!0);try{await s(t.id,o.trim()),r()}catch{y(!1)}},P=_=>{_.key==="Enter"?(_.preventDefault(),A()):_.key==="Escape"&&(_.preventDefault(),f||r())},D=async()=>{L(!0);try{await a(t.id)}catch{L(!1),u(!1)}};return e.jsxs("div",{className:"flex flex-col gap-2 py-1.5","data-edit-row":!0,children:[e.jsx("input",{ref:N,className:"h-7 w-full rounded border border-border bg-background px-2 text-sm outline-hidden focus:ring-1 focus:ring-ring disabled:opacity-50",disabled:f,type:"text",value:o,onChange:_=>{p(_.target.value),b("")},onKeyDown:P}),h&&e.jsx("span",{className:"text-xs text-destructive",children:h}),d?e.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[e.jsx("span",{className:"flex-1 font-semibold",children:"Delete label?"}),e.jsx($,{className:"h-6 px-2 text-xs",disabled:f,size:"sm",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsx($,{className:"h-6 px-2 text-xs",disabled:f,size:"sm",variant:"destructive",onClick:D,children:v?"Deleting...":"Delete"})]}):e.jsxs("div",{className:"flex items-center",children:[e.jsx($,{className:"h-6 gap-1 px-1.5 text-xs text-red hover:bg-red/5 hover:text-red",disabled:f,size:"sm",variant:"ghost",onClick:()=>u(!0),children:"Delete"}),e.jsxs("div",{className:"ml-auto flex gap-1",children:[e.jsx($,{className:"h-6 px-2 text-xs",disabled:f,size:"sm",variant:"outline",onClick:r,children:"Cancel"}),e.jsx($,{className:"h-6 px-2 text-xs",disabled:f,size:"sm",onClick:A,children:E?"Saving...":"Save"})]})]})]})},ba=({label:t,isSelected:s,showEdit:r,onToggle:a,onEditClick:i})=>e.jsxs(Ve,{className:"group",value:t.slug,onSelect:()=>a(t.slug),children:[e.jsx("span",{className:"flex-1 truncate",children:t.name}),r?e.jsxs("button",{"aria-label":`Edit label ${t.name}`,className:"relative ml-1 flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground",type:"button",onClick:o=>{o.stopPropagation(),o.preventDefault(),i()},children:[s&&e.jsx(Qe,{className:"absolute size-3 text-primary transition-opacity duration-150 group-hover:opacity-0"}),e.jsx(bs,{className:"absolute size-3 translate-x-2 opacity-0 transition-all duration-150 ease-out group-hover:translate-x-0 group-hover:opacity-100"})]}):s&&e.jsx(Qe,{className:"size-4 shrink-0 text-primary"})]}),ga=({labels:t,selectedSlugs:s,search:r,onToggle:a,onEdit:i,onDelete:o,isDuplicateName:p,canCreateFromSearch:d,onCreate:u,isCreating:h,onSearchClear:b})=>{const[E,y]=c.useState(null),v=r.trim().toLowerCase(),L=v?t.filter(D=>D.name.toLowerCase().includes(v)):t,N=!!u&&r.trim()&&d?.(r),f=!!i,M=async()=>{if(u){const D=await u(r.trim());D&&a(D.slug),b?.()}},A=async(D,_)=>{i&&await i(D,_)},P=async D=>{o&&(await o(D),y(null))};return e.jsxs(e.Fragment,{children:[!N&&L.length===0&&e.jsx(wt,{children:"No labels found"}),L.length>0&&e.jsx(Xe,{className:"[&_[cmdk-group-heading]]:hidden",children:L.map(D=>E===D.id?e.jsx(js,{isDuplicateName:p,label:D,onCancel:()=>y(null),onDelete:P,onSave:A},D.id):e.jsx(ba,{isSelected:s.includes(D.slug),label:D,showEdit:f,onEditClick:()=>y(D.id),onToggle:a},D.id))}),N&&e.jsx(Xe,{className:"[&_[cmdk-group-heading]]:hidden",children:e.jsxs(Ve,{disabled:h,onSelect:M,children:[e.jsx(ft,{className:"size-4"}),h?"Creating...":`Create "${r.trim()}"`]})})]})},xa=({labels:t,onToggle:s})=>e.jsx(e.Fragment,{children:t.map(r=>e.jsxs(rs,{className:"cursor-pointer gap-1 pr-1",variant:"outline",onClick:a=>{a.stopPropagation(),s(r.slug)},children:[r.name,e.jsx(pt,{className:"size-3"})]},r.id))}),jt=({labels:t,optionSource:s,selectedSlugs:r,resolvedSelectedLabels:a,onToggle:i,canCreateFromSearch:o,onCreate:p,isCreating:d,onEdit:u,onDelete:h,isDuplicateName:b})=>{const E=a||r.map(y=>t.find(v=>v.slug===y)).filter(y=>!!y);return e.jsx(ya,{canCreateFromSearch:o,isCreating:d,isDuplicateName:b,labels:t,optionSource:s,selectedLabels:E,selectedSlugs:r,onCreate:p,onDelete:h,onEdit:u,onToggle:i})},ya=({labels:t,optionSource:s,selectedLabels:r,selectedSlugs:a,onToggle:i,canCreateFromSearch:o,onCreate:p,isCreating:d,onEdit:u,onDelete:h,isDuplicateName:b})=>{const[E,y]=c.useState(!1),[v,L]=c.useState(""),N=c.useRef(null),f=c.useRef(null),M=c.useCallback(P=>{L(P),s.onSearchChange?.(P)},[s]);c.useEffect(()=>{if(!E)return;const P=D=>{f.current&&!f.current.contains(D.target)&&y(!1)};return document.addEventListener("pointerdown",P),()=>document.removeEventListener("pointerdown",P)},[E]);const A=P=>{P.key==="Backspace"&&!v&&a.length>0&&i(a[a.length-1]),P.key==="Escape"&&(y(!1),N.current?.blur())};return e.jsxs("div",{ref:f,className:"relative",children:[e.jsxs("div",{className:"flex min-h-9 w-full cursor-text flex-wrap items-center gap-1.5 rounded-md border border-transparent bg-gray-150 px-3 py-1 text-sm transition-colors focus-within:border-green focus-within:bg-transparent focus-within:shadow-[0_0_0_2px_rgba(48,207,67,.25)] dark:bg-gray-900",role:"combobox",onClick:()=>{N.current?.focus(),y(!0)},children:[e.jsx(xa,{labels:r,onToggle:i}),e.jsx("input",{ref:N,className:"min-w-[80px] flex-1 bg-transparent text-sm outline-hidden placeholder:text-muted-foreground",placeholder:r.length===0?"Search labels...":"",value:v,onChange:P=>{M(P.target.value),E||y(!0)},onFocus:()=>y(!0),onKeyDown:A})]}),E&&e.jsx("div",{className:"absolute top-full left-0 z-50 mt-1 w-full rounded-md border bg-white shadow-md dark:bg-gray-950",children:s.isInitialLoad?e.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-muted-foreground",children:"Loading labels..."}):e.jsx(yt,{shouldFilter:!1,children:e.jsx(vt,{className:"max-h-64 overflow-y-auto",children:e.jsx(ga,{canCreateFromSearch:o,isCreating:d,isDuplicateName:b,labels:t,search:v,selectedSlugs:a,onCreate:p,onDelete:h,onEdit:u,onSearchClear:()=>M(""),onToggle:i})})})})]})},tt="LabelsResponseType",va=Us({dataType:tt,path:"/labels/",defaultNextPageParams:(t,s)=>{if(t.meta?.pagination.next)return{...s,page:t.meta.pagination.next.toString()}},returnData:t=>{const{pages:s}=t,r=s.flatMap(i=>i.labels),a=s[s.length-1].meta;return{labels:r,meta:a,isEnd:a?a.pagination.pages===a.pagination.page:!0}}}),wa=bt({method:"POST",path:()=>"/labels/",body:t=>({labels:[t]}),invalidateQueries:{dataType:tt}}),Sa=bt({method:"PUT",path:t=>`/labels/${t.id}/`,body:t=>({labels:[t]}),invalidateQueries:{dataType:tt}}),_a=bt({method:"DELETE",path:t=>`/labels/${t}/`,invalidateQueries:{dataType:tt}}),ja=()=>{};function Ea(t){return function(){const a=t.useRemoteSource({enabled:!0}).useInitialBrowse(),[i,o]=c.useState(null);c.useEffect(()=>{i!==null||!a.pagination||o(a.pagination.total<=t.pageLimit||a.pagination.next===null?"local":"remote")},[i,a.pagination]);const p=t.useLocalSource(a,{enabled:i==="local"}),d=t.useRemoteSource({enabled:i==="remote"}),u=h=>{const b=p.useOptions(h),E=d.useOptions(h);return i===null?{options:[],isInitialLoad:a.isLoading,isSearching:!1,isLoadingMore:!1,hasMore:!1,loadMore:ja}:i==="remote"?E:b};return{id:t.id,useOptions:u}}}const Es="100";function ht(t){return{value:t.slug,label:t.name,metadata:{id:t.id}}}function Na(t,s){const{enabled:r=!0}=s;return{id:"posts.labels.local",useOptions:({query:i,selectedValues:o})=>{const p=(t.items||[]).map(ht),d=o.map(u=>{const h=t.items?.find(b=>b.slug===u);return h?ht(h):{value:u,label:u}});return r?{options:gr(d,xs(p,i)),isInitialLoad:t.isLoading&&p.length===0,isSearching:!1,isLoadingMore:!1,hasMore:!1,loadMore:()=>{}}:{options:[],isInitialLoad:!1,isSearching:!1,isLoadingMore:!1,hasMore:!1,loadMore:()=>{}}}}}const Ca=gs({id:"posts.labels.remote",buildBrowseSearchParams:t=>({limit:Es,order:"name asc",...t?{filter:`name:~${St(t)}`}:{}}),buildHydrateFilter:t=>br("slug",t),buildHydrateSearchParams:t=>({filter:t,order:"name asc"}),selectItems:t=>t?.labels,useQuery:({enabled:t,searchParams:s})=>va({enabled:t,keepPreviousData:!0,searchParams:s}),toOption:ht,debounceMs:250}),ka=Ea({id:"posts.labels.hybrid",pageLimit:Number(Es),useLocalSource:Na,useRemoteSource:Ca});function Ns(){return ka()}function st({selectedSlugs:t,onSelectionChange:s,valueSource:r}){const a=Ns(),i=r??a,[o,p]=c.useState(""),d=i.useOptions({query:o,selectedValues:t}),u=c.useMemo(()=>d.options.flatMap(_=>_.metadata?.id?[{id:String(_.metadata.id),name:_.label,slug:String(_.value),created_at:"",updated_at:""}]:[]),[d.options]),h={...d,shouldClientFilter:!1,onSearchChange:p},{mutateAsync:b,isLoading:E}=wa(),{mutateAsync:y}=Sa(),{mutateAsync:v}=_a(),L=c.useRef(t);L.current=t;const N=c.useCallback(_=>{const S=L.current;S.includes(_)?s(S.filter(w=>w!==_)):s([...S,_])},[s]),f=c.useCallback((_,S)=>{const w=_.trim().toLowerCase();return u.some(n=>n.name.toLowerCase()===w&&n.id!==S)},[u]),M=c.useCallback(_=>{const S=_.trim();return S?!f(S):!1},[f]),A=c.useCallback(async _=>{const S=_.trim();return!S||f(S)?void 0:(await b({name:S}))?.labels?.[0]},[b,f]),P=c.useCallback(async(_,S)=>{const w=S.trim();if(!w||f(w,_))return;const n=u.find(g=>g.id===_),m=(await y({id:_,name:w}))?.labels?.[0];if(n&&m&&n.slug!==m.slug){const g=L.current;g.includes(n.slug)&&s(g.map(x=>x===n.slug?m.slug:x))}},[y,f,u,s]),D=c.useCallback(async _=>{const S=u.find(w=>w.id===_);if(await v(_),S){const w=L.current;w.includes(S.slug)&&s(w.filter(n=>n!==S.slug))}},[v,u,s]);return{labels:u,optionSource:h,selectedSlugs:t,resolvedSelectedLabels:t.map(_=>u.find(S=>S.slug===_)).filter(_=>!!_),toggleLabel:N,createLabel:A,editLabel:P,deleteLabel:D,isDuplicateName:f,canCreateFromSearch:M,isCreating:E}}const La=({field:t,values:s,onChange:r})=>{const a=st({selectedSlugs:s,onSelectionChange:r,valueSource:t.valueSource}),i=c.useRef(null),[o,p]=c.useState(0),d=c.useCallback(()=>{const v=i.current,L=v?.parentElement;if(v&&L){const N=v.getBoundingClientRect(),f=L.getBoundingClientRect();p(Math.round(f.left-N.left))}},[]);let u="Select...";a.resolvedSelectedLabels.length===1?u=a.resolvedSelectedLabels[0].name:a.resolvedSelectedLabels.length>1&&(u=`${a.resolvedSelectedLabels.length} labels`);const[h,b]=c.useState(null),E=c.useCallback(({option:v,isSelected:L,onSelect:N})=>{const f=String(v.metadata?.id??"");if(h===f&&!L){const M={id:f,name:v.label,slug:String(v.value),created_at:"",updated_at:""};return e.jsx(js,{isDuplicateName:a.isDuplicateName,label:M,onCancel:()=>b(null),onDelete:async A=>{await a.deleteLabel(A),b(null)},onSave:async(A,P)=>{await a.editLabel(A,P),b(null)}},f)}return e.jsxs(Ve,{className:"group",value:v.label,onSelect:N,children:[e.jsx("span",{className:"flex-1 truncate",children:v.label}),L?e.jsx(Qe,{className:"size-3 shrink-0 text-primary"}):e.jsx("button",{"aria-label":`Edit label ${v.label}`,className:"relative ml-1 flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground",type:"button",onClick:M=>{M.stopPropagation(),M.preventDefault(),b(f)},children:e.jsx(bs,{className:"absolute size-3 translate-x-2 opacity-0 transition-all duration-150 ease-out group-hover:translate-x-0 group-hover:opacity-100"})})]},String(v.value))},[h,a]),y=c.useCallback(({searchInput:v,clearSearch:L})=>v.trim()&&a.canCreateFromSearch(v)?e.jsx("div",{className:"border-t p-1",children:e.jsxs($,{className:"h-8 w-full justify-start gap-2 px-2 text-sm font-normal",disabled:a.isCreating,variant:"ghost",onClick:async()=>{const f=await a.createLabel(v.trim());f&&a.toggleLabel(f.slug),L()},children:[e.jsx(ft,{className:"size-4"}),a.isCreating?"Creating...":`Create "${v.trim()}"`]})}):null,[a]);return e.jsxs(as,{onOpenChange:v=>{v?d():a.optionSource.onSearchChange?.("")},children:[e.jsx(ns,{asChild:!0,children:e.jsx("button",{ref:i,className:"flex size-full items-center truncate text-left text-sm",type:"button",children:u})}),e.jsx(is,{align:"start",alignOffset:o,className:"w-64 p-0",children:a.optionSource.isInitialLoad?e.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-muted-foreground",children:"Loading labels..."}):e.jsx(fa,{footer:y,i18n:{searchPlaceholder:"Search labels...",noResultsFound:"No labels found"},optionSource:a.optionSource,renderItem:E,values:s,onChange:r})})]})};function Ma({open:t,memberCount:s,onOpenChange:r,onConfirm:a,isLoading:i=!1}){const[o,p]=c.useState([]),d=st({selectedSlugs:o,onSelectionChange:p}),u=c.useCallback(b=>{b||p([]),r(b)},[r]),h=()=>{const b=d.labels.filter(E=>o.includes(E.slug)).map(E=>E.id);b.length>0&&a(b)};return e.jsx(Fe,{open:t,onOpenChange:u,children:e.jsxs(Ue,{className:"gap-5",onOpenAutoFocus:b=>b.preventDefault(),children:[e.jsx(Be,{children:e.jsxs(ze,{children:["Add label to ",Ne(s)," ",s===1?"member":"members"]})}),e.jsx(jt,{canCreateFromSearch:d.canCreateFromSearch,isCreating:d.isCreating,isDuplicateName:d.isDuplicateName,labels:d.labels,optionSource:d.optionSource,resolvedSelectedLabels:d.resolvedSelectedLabels,selectedSlugs:o,onCreate:d.createLabel,onDelete:d.deleteLabel,onEdit:d.editLabel,onToggle:d.toggleLabel}),e.jsxs(ve,{children:[e.jsx($,{variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsx($,{disabled:o.length===0||i,onClick:h,children:i?"Adding...":o.length>1?`Add ${Ne(o.length)} labels`:"Add label"})]})]})})}function Ra({open:t,memberCount:s,nql:r,search:a,onOpenChange:i,onConfirm:o,isLoading:p=!1}){const[d,u]=c.useState([]),{data:h,isLoading:b}=Bs({searchParams:{...r?{filter:r}:{},...a?{search:a}:{},include:"labels",limit:"all",fields:"id"},enabled:t}),E=c.useMemo(()=>{const f=new Set;for(const M of h?.members||[])for(const A of M.labels||[])f.add(A.slug);return f},[h]),y=st({selectedSlugs:d,onSelectionChange:u}),v={...y.optionSource,options:y.optionSource.options.filter(f=>E.has(String(f.value)))},L=c.useCallback(f=>{f||u([]),i(f)},[i]),N=()=>{const f=y.labels.filter(M=>d.includes(M.slug)).map(M=>M.id);f.length>0&&o(f)};return e.jsx(Fe,{open:t,onOpenChange:L,children:e.jsxs(Ue,{className:"gap-5",onOpenAutoFocus:f=>f.preventDefault(),children:[e.jsx(Be,{children:e.jsxs(ze,{children:["Remove label from ",Ne(s)," ",s===1?"member":"members"]})}),e.jsx(jt,{isDuplicateName:y.isDuplicateName,labels:y.labels.filter(f=>E.has(f.slug)),optionSource:{...v,isInitialLoad:v.isInitialLoad||b},resolvedSelectedLabels:y.resolvedSelectedLabels.filter(f=>E.has(f.slug)),selectedSlugs:d,onDelete:y.deleteLabel,onEdit:y.editLabel,onToggle:y.toggleLabel}),e.jsxs(ve,{children:[e.jsx($,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsx($,{disabled:d.length===0||p,onClick:N,children:p?"Removing...":d.length>1?`Remove ${Ne(d.length)} labels`:"Remove label"})]})]})})}function Oa({open:t,newsletters:s,memberCount:r,onOpenChange:a,onConfirm:i,isLoading:o=!1}){const[p,d]=c.useState("all"),[u,h]=c.useState([]),[b,E]=c.useState(""),[y,v]=c.useState(!1),L=c.useRef(null),N=c.useRef(null);c.useEffect(()=>{t||(d("all"),h([]),E(""),v(!1))},[t]),c.useEffect(()=>{if(!y)return;const S=w=>{L.current&&!L.current.contains(w.target)&&v(!1)};return document.addEventListener("pointerdown",S),()=>document.removeEventListener("pointerdown",S)},[y]);const f=S=>{S||(d("all"),h([]),E(""),v(!1)),a(S)},M=c.useCallback(S=>{h(w=>w.includes(S)?w.filter(n=>n!==S):[...w,S])},[]),A=s.length>=2,P=()=>{i(!A||p==="all"?null:u)},D=o||A&&p==="selected"&&u.length===0,_=r===1?"member":"members";return e.jsx(Fe,{open:t,onOpenChange:f,children:e.jsxs(Ue,{className:"gap-5",children:[e.jsx(Be,{children:e.jsx(ze,{children:"Unsubscribe members"})}),A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{"aria-label":"Unsubscribe scope",className:"flex flex-col gap-3",role:"radiogroup",children:[e.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{checked:p==="all",className:"mt-0.5 size-4 cursor-pointer accent-black",name:"unsubscribe-mode",type:"radio",value:"all",onChange:()=>d("all")}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-semibold",children:"Unsubscribe from all newsletters"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[r.toLocaleString()," ",_," will be unsubscribed from"," ",s.length," ",s.length===1?"newsletter":"newsletters","."]})]})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{checked:p==="selected",className:"mt-0.5 size-4 cursor-pointer accent-black",name:"unsubscribe-mode",type:"radio",value:"selected",onChange:()=>d("selected")}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-semibold",children:"Unsubscribe from selected newsletters"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Select which newsletters to unsubscribe"," ",r.toLocaleString()," ",_," from."]})]})]})]}),p==="selected"&&e.jsxs("div",{ref:L,className:"relative space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold",htmlFor:"newsletter-search",children:"Newsletters"}),e.jsxs("div",{className:"flex min-h-9 w-full cursor-text flex-wrap items-center gap-1.5 rounded-md border bg-background px-3 py-1 text-sm",onClick:()=>{N.current?.focus(),v(!0)},children:[u.map(S=>{const w=s.find(n=>n.id===S);return w?e.jsxs(rs,{className:"cursor-pointer gap-1 pr-1",variant:"outline",onClick:n=>{n.stopPropagation(),M(S)},children:[w.name,e.jsx(pt,{className:"size-3"})]},S):null}),e.jsx("input",{ref:N,className:"min-w-[80px] flex-1 bg-transparent py-1 text-sm outline-hidden placeholder:text-muted-foreground",id:"newsletter-search",placeholder:u.length===0?"Search newsletters...":"",value:b,onChange:S=>{E(S.target.value),y||v(!0)},onFocus:()=>v(!0),onKeyDown:S=>{S.key==="Escape"&&(v(!1),N.current?.blur()),S.key==="Backspace"&&!b&&u.length>0&&M(u[u.length-1])}})]}),y&&e.jsx("div",{className:"absolute top-full left-0 z-50 mt-1 w-full rounded-md border bg-white shadow-md dark:bg-gray-950",children:e.jsx(yt,{shouldFilter:!1,children:e.jsxs(vt,{className:"max-h-64 overflow-y-auto",children:[e.jsx(wt,{children:"No newsletters found."}),s.filter(S=>S.name.toLowerCase().includes(b.toLowerCase())).map(S=>e.jsxs(Ve,{value:S.name,onSelect:()=>M(S.id),children:[S.name,u.includes(S.id)&&e.jsx(pr,{})]},S.id))]})})})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Are you sure you want to unsubscribe"," ",r.toLocaleString()," ",_," from all newsletters? They will no longer receive any email newsletters from you."]}),e.jsxs(ve,{children:[e.jsx($,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsx($,{disabled:D,variant:"destructive",onClick:P,children:o?"Unsubscribing...":"Unsubscribe"})]})]})})}function Ia({open:t,memberCount:s,onOpenChange:r,onConfirm:a,onExportBackup:i,isLoading:o=!1}){const[p,d]=c.useState(!1),u=b=>{b||d(!1),r(b)},h=async()=>{if(!(s<1||o||p))try{d(!0),await i(),a()}catch{}finally{d(!1)}};return e.jsx(Fe,{open:t,onOpenChange:u,children:e.jsxs(Ue,{className:"gap-5",children:[e.jsx(Be,{children:e.jsx(ze,{children:"Delete selected members?"})}),e.jsx("div",{className:"text-sm",children:s>0?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["You're about to delete ",e.jsxs("strong",{children:[s.toLocaleString()," ",s===1?"member":"members"]}),". This is permanent! All Ghost data will be deleted, this will have no effect on subscriptions in Stripe."]}),e.jsx("p",{className:"mt-4",children:"A backup of your selection will be automatically downloaded to your device before deletion."})]}):e.jsx("p",{children:"No members are selected."})}),e.jsxs(ve,{children:[e.jsx($,{variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsx($,{disabled:o||p||s<1,variant:"destructive",onClick:h,children:o||p?"Deleting...":"Download backup & delete members"})]})]})})}function Da({fileError:t,onClose:s,onDropAccepted:r,onDropRejected:a}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-5 space-y-5",children:[e.jsxs(zs,{variant:"info",children:["Need some help? ",e.jsx("a",{className:"font-semibold underline",href:"https://ghost.org/help/import-members/",rel:"noopener noreferrer",target:"_blank",children:"Learn more"})," about importing members or ",e.jsx("a",{className:"font-semibold underline",href:"https://static.ghost.org/v4.0.0/files/member-import-template.csv",rel:"noopener noreferrer",target:"_blank",children:"download a sample CSV file"}),"."]}),t&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-600",children:[e.jsx(ls,{className:"mt-0.5 size-4 shrink-0"}),e.jsx("p",{children:t})]}),e.jsx(Rr,{accept:{"text/csv":[".csv"],"application/vnd.ms-excel":[".csv"]},"aria-label":"Select or drop a CSV file",onDropAccepted:i=>{const o=i[0];o&&r(o)},onDropRejected:a,children:({isDragActive:i,isDragReject:o})=>e.jsxs(e.Fragment,{children:[e.jsx(vs,{className:"mb-2 size-6 text-grey-600"}),e.jsx("span",{className:"text-sm text-grey-700",children:o?"The file type you uploaded is not supported":i?"Drop CSV file to upload":"Select or drop a CSV file"})]})})]}),e.jsx(ve,{className:"mt-5",children:e.jsx($,{variant:"outline",onClick:s,children:"Close"})})]})}function Aa({status:t,fileData:s,mapping:r,mappingError:a,showMappingErrors:i,membersCount:o,dataPreviewIndex:p,hasPrevRecord:d,hasNextRecord:u,fieldMappings:h,labelPicker:b,onUpdateMapping:E,onDataPreviewIndexChange:y,onStartOver:v,onUpload:L}){const N=s&&s.length>0&&r?Object.entries(s[p]||{}).map(([f,M])=>({key:f,value:M,mapTo:r.get(f)})):[];return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5 space-y-5",children:s===null?e.jsx("div",{className:"flex items-center justify-center rounded-md border bg-muted p-10",children:e.jsx(Je,{size:"md"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ae("overflow-hidden rounded-md border",i&&a&&"border-red-500"),children:e.jsx("div",{className:"max-h-[400px] overflow-auto",children:e.jsxs(Ze,{className:"table-fixed",children:[e.jsx(_t,{children:e.jsxs(Ee,{children:[e.jsx(be,{className:"w-1/3",children:"Field"}),e.jsx(be,{className:"w-1/3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:["Sample data ",e.jsxs("span",{className:"text-muted-foreground",children:["(#",Ne(p+1),")"]})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{"aria-label":"Show previous sample row",className:ae("rounded p-0.5 hover:bg-muted",!d&&"cursor-default opacity-30"),disabled:!d||t==="UPLOADING",type:"button",onClick:()=>y(p-1),children:e.jsx($s,{className:"size-4"})}),e.jsx("button",{"aria-label":"Show next sample row",className:ae("rounded p-0.5 hover:bg-muted",!u&&"cursor-default opacity-30"),disabled:!u||t==="UPLOADING",type:"button",onClick:()=>y(p+1),children:e.jsx(Vs,{className:"size-4"})})]})]})}),e.jsx(be,{className:"w-1/3",children:"Import as"})]})}),e.jsx(ws,{children:N.length>0?N.map(f=>e.jsxs(Ee,{className:ae(!f.mapTo&&"bg-muted"),children:[e.jsx(me,{className:"text-sm font-medium break-all",children:f.key}),e.jsx(me,{className:ae("break-all text-sm",!f.value&&"text-muted-foreground"),children:f.value||" "}),e.jsx(me,{children:e.jsxs(Gr,{disabled:t==="UPLOADING",value:f.mapTo||"__not_imported__",onValueChange:M=>{E(f.key,M==="__not_imported__"?null:M)},children:[e.jsx(Kr,{className:ae("h-8 text-sm",!f.mapTo&&"text-muted-foreground"),children:e.jsx(Yr,{})}),e.jsxs(qr,{children:[e.jsx(Pt,{value:"__not_imported__",children:"Not imported"}),h.map(M=>e.jsx(Pt,{value:M.value,children:M.label},M.value))]})]})})]},f.key)):e.jsx(Ee,{children:e.jsx(me,{className:"text-muted-foreground",colSpan:3,children:"No data found in the uploaded CSV."})})})]})})}),i&&a&&e.jsx("p",{className:"text-sm text-red-600",children:a}),o>0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"If an email address in your CSV matches an existing member, they will be updated with the mapped values."}),e.jsxs("div",{className:"mt-5",children:[e.jsx("label",{className:"mb-1 block text-sm font-semibold",children:"Label these members"}),e.jsx(jt,{canCreateFromSearch:b.canCreateFromSearch,isCreating:b.isCreating,isDuplicateName:b.isDuplicateName,labels:b.labels,optionSource:b.optionSource,resolvedSelectedLabels:b.resolvedSelectedLabels,selectedSlugs:b.selectedSlugs,onCreate:b.createLabel,onDelete:b.deleteLabel,onEdit:b.editLabel,onToggle:b.toggleLabel})]})]})}),e.jsxs(ve,{className:"mt-5",children:[e.jsx($,{disabled:t==="UPLOADING",variant:"outline",onClick:v,children:"Start over"}),e.jsx($,{disabled:t==="UPLOADING"||o===0,onClick:L,children:t==="UPLOADING"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Je,{color:"light",size:"sm"}),"Uploading"]}):o>0?`Import ${Ne(o)} ${o===1?"member":"members"}`:"Import members"})]})]})}function Pa({onUploadAnotherFile:t,onClose:s}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5",children:e.jsx("p",{className:"text-sm",children:"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."})}),e.jsxs(ve,{className:"mt-5",children:[e.jsx($,{variant:"outline",onClick:t,children:"Upload another file"}),e.jsx($,{onClick:s,children:"Got it"})]})]})}function Ta({importResponse:t,onReset:s,onClose:r}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-5 space-y-4",children:[t.importedCount===0?e.jsxs("p",{className:"text-sm",children:["No members were added",t.errorCount>0?" due to the following errors:":"."]}):e.jsxs("p",{className:"text-sm",children:["A total of ",e.jsx("strong",{children:t.importedCount.toLocaleString()})," ",t.importedCount===1?"person was":"people were"," successfully added or updated in your list of members, and now have access to your site."]}),t.errorCount>0&&e.jsxs(e.Fragment,{children:[t.importedCount>0&&e.jsxs(e.Fragment,{children:[e.jsx("hr",{className:"border-grey-200"}),e.jsxs("p",{className:"text-sm",children:[e.jsx("strong",{children:t.errorCount.toLocaleString()})," ",t.errorCount===1?"member was":"members were"," skipped due to the following errors:"]})]}),e.jsx("ul",{className:"list-inside list-disc space-y-1 text-sm text-muted-foreground",children:t.errorList.map(a=>e.jsxs("li",{children:[a.message," (",a.count,")"]},a.message))})]})]}),e.jsx(ve,{className:"mt-5",children:t.errorCount>0?e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"outline",asChild:!0,children:e.jsx("a",{download:t.errorCsvName,href:t.errorCsvUrl,children:"Download error file"})}),t.importedCount===0?e.jsx($,{onClick:s,children:"Try again"}):e.jsx($,{onClick:r,children:"View members"})]}):e.jsx(e.Fragment,{children:t.importedCount===0?e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"outline",onClick:r,children:"Close"}),e.jsx($,{onClick:s,children:"Try again"})]}):e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"outline",onClick:s,children:"Upload another file"}),e.jsx($,{onClick:r,children:"View members"})]})})})]})}function Fa({errorMessage:t,showTryAgainButton:s,onTryAgain:r,onClose:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5",children:e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-600",children:[e.jsx(ls,{className:"mt-0.5 size-4 shrink-0"}),e.jsx("p",{children:t})]})}),e.jsxs(ve,{className:"mt-5",children:[s&&e.jsx($,{variant:"outline",onClick:r,children:"Try again"}),e.jsx($,{onClick:a,children:"OK"})]})]})}const Ua=[{label:"Email",value:"email"},{label:"Name",value:"name"},{label:"Note",value:"note"},{label:"Subscribed to emails",value:"subscribed_to_emails"},{label:"Stripe Customer ID",value:"stripe_customer_id"},{label:"Complimentary plan",value:"complimentary_plan"},{label:"Labels",value:"labels"},{label:"Created at",value:"created_at"}],Cs={label:"Tier",value:"import_tier"},ks={label:"Gift ID",value:"gift_id"},Ba=["email","name","note","subscribed_to_emails","complimentary_plan","stripe_customer_id","labels","created_at"];function za({importMemberTier:t=!1,giftSubscriptionsEnabled:s=!1}={}){return[...Ba,...t?[Cs.value]:[],...s?[ks.value]:[]]}function $a({importMemberTier:t=!1,giftSubscriptionsEnabled:s=!1}={}){return[...Ua,...t?[Cs]:[],...s?[ks]:[]]}const Va=["email"],Ha=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;class Et{_mapping;constructor(s){if(this._mapping={},s)for(const[r,a]of Object.entries(s))this._mapping[a]=r}get(s){return this._mapping[s]??null}toJSON(){return{...this._mapping}}getKeyByValue(s){for(const[r,a]of Object.entries(this._mapping))if(a===s)return r;return null}updateMapping(s,r){const a=new Et({});if(a._mapping={...this._mapping},r)for(const i in a._mapping)a._mapping[i]===r&&(a._mapping[i]=null);return a._mapping[s]=r,a}}function Wa(t,s=30){if(!t||t.length<=s)return t;const r=[];return Object.keys(t[0]).forEach(i=>{const o=t.filter(d=>d[i]&&d[i].trim()!=="");let p=[];if(o.length<=s)p=o;else{const d=Math.floor(s/3),u=d,h=s-d-u,b=o.slice(0,d),E=u>0?o.slice(-u):[],y=Math.max(0,Math.floor(o.length/2)-Math.floor(h/2)),v=o.slice(y,y+h);p=[...b,...v,...E].slice(0,s)}p.forEach((d,u)=>{r[u]||(r[u]={}),r[u][i]=d[i]})}),r}function Ga(t,s={}){const r=Wa(t),a={},i=za(s);if(t.length>0)for(const p of Object.keys(t[0])){if(!a.name&&/name/i.test(p)){a.name=p;continue}!a[p]&&i.includes(p)&&!Va.includes(p)&&(a[p]=p)}let o=0;for(;o<=r.length-1&&!a.email;){const p=r[o];for(const[d,u]of Object.entries(p))!a.email&&u&&Ha.test(u)&&(a.email=d);o+=1}return a}function Ka(t){return t.replace("Value in [members.email] cannot be blank.","Missing email address").replace("Value in [members.note] exceeds maximum length of 2000 characters.","Note is too long").replace("Value in [members.subscribed] must be one of true, false, 0 or 1.",'Value of "Subscribed to emails" must be "true" or "false"').replace("Validation (isEmail) failed for email","Invalid email address").replace(/No such customer:[^,]*/,"Could not find Stripe customer")}var qe={exports:{}};var Ya=qe.exports,Ft;function qa(){return Ft||(Ft=1,(function(t,s){((r,a)=>{t.exports=a()})(Ya,function r(){var a=typeof self<"u"?self:typeof window<"u"?window:a!==void 0?a:{},i,o=!a.document&&!!a.postMessage,p=a.IS_PAPA_WORKER||!1,d={},u=0,h={};function b(n){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(l){var m=_(l);m.chunkSize=parseInt(m.chunkSize),l.step||l.chunk||(m.chunkSize=null),this._handle=new N(m),(this._handle.streamer=this)._config=m}).call(this,n),this.parseChunk=function(l,m){var g=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<g){let R=this._config.newline;R||(x=this._config.quoteChar||'"',R=this._handle.guessLineEndings(l,x)),l=[...l.split(R).slice(g)].join(R)}this.isFirstChunk&&w(this._config.beforeFirstChunk)&&(x=this._config.beforeFirstChunk(l))!==void 0&&(l=x),this.isFirstChunk=!1,this._halted=!1;var g=this._partialLine+l,x=(this._partialLine="",this._handle.parse(g,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(l=x.meta.cursor,g=(this._finished||(this._partialLine=g.substring(l-this._baseIndex),this._baseIndex=l),x&&x.data&&(this._rowCount+=x.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),p)a.postMessage({results:x,workerId:h.WORKER_ID,finished:g});else if(w(this._config.chunk)&&!m){if(this._config.chunk(x,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=x=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(x.data),this._completeResults.errors=this._completeResults.errors.concat(x.errors),this._completeResults.meta=x.meta),this._completed||!g||!w(this._config.complete)||x&&x.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),g||x&&x.meta.paused||this._nextChunk(),x}this._halted=!0},this._sendError=function(l){w(this._config.error)?this._config.error(l):p&&this._config.error&&a.postMessage({workerId:h.WORKER_ID,error:l,finished:!1})}}function E(n){var l;(n=n||{}).chunkSize||(n.chunkSize=h.RemoteChunkSize),b.call(this,n),this._nextChunk=o?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(m){this._input=m,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(l=new XMLHttpRequest,this._config.withCredentials&&(l.withCredentials=this._config.withCredentials),o||(l.onload=S(this._chunkLoaded,this),l.onerror=S(this._chunkError,this)),l.open(this._config.downloadRequestBody?"POST":"GET",this._input,!o),this._config.downloadRequestHeaders){var m,g=this._config.downloadRequestHeaders;for(m in g)l.setRequestHeader(m,g[m])}var x;this._config.chunkSize&&(x=this._start+this._config.chunkSize-1,l.setRequestHeader("Range","bytes="+this._start+"-"+x));try{l.send(this._config.downloadRequestBody)}catch(R){this._chunkError(R.message)}o&&l.status===0&&this._chunkError()}},this._chunkLoaded=function(){l.readyState===4&&(l.status<200||400<=l.status?this._chunkError():(this._start+=this._config.chunkSize||l.responseText.length,this._finished=!this._config.chunkSize||this._start>=(m=>(m=m.getResponseHeader("Content-Range"))!==null?parseInt(m.substring(m.lastIndexOf("/")+1)):-1)(l),this.parseChunk(l.responseText)))},this._chunkError=function(m){m=l.statusText||m,this._sendError(new Error(m))}}function y(n){(n=n||{}).chunkSize||(n.chunkSize=h.LocalChunkSize),b.call(this,n);var l,m,g=typeof FileReader<"u";this.stream=function(x){this._input=x,m=x.slice||x.webkitSlice||x.mozSlice,g?((l=new FileReader).onload=S(this._chunkLoaded,this),l.onerror=S(this._chunkError,this)):l=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var x=this._input,R=(this._config.chunkSize&&(R=Math.min(this._start+this._config.chunkSize,this._input.size),x=m.call(x,this._start,R)),l.readAsText(x,this._config.encoding));g||this._chunkLoaded({target:{result:R}})},this._chunkLoaded=function(x){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(x.target.result)},this._chunkError=function(){this._sendError(l.error)}}function v(n){var l;b.call(this,n=n||{}),this.stream=function(m){return l=m,this._nextChunk()},this._nextChunk=function(){var m,g;if(!this._finished)return m=this._config.chunkSize,l=m?(g=l.substring(0,m),l.substring(m)):(g=l,""),this._finished=!l,this.parseChunk(g)}}function L(n){b.call(this,n=n||{});var l=[],m=!0,g=!1;this.pause=function(){b.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){b.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(x){this._input=x,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){g&&l.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),l.length?this.parseChunk(l.shift()):m=!0},this._streamData=S(function(x){try{l.push(typeof x=="string"?x:x.toString(this._config.encoding)),m&&(m=!1,this._checkIsFinished(),this.parseChunk(l.shift()))}catch(R){this._streamError(R)}},this),this._streamError=S(function(x){this._streamCleanUp(),this._sendError(x)},this),this._streamEnd=S(function(){this._streamCleanUp(),g=!0,this._streamData("")},this),this._streamCleanUp=S(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function N(n){var l,m,g,x,R=Math.pow(2,53),V=-R,Z=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,se=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,j=this,U=0,O=0,Y=!1,k=!1,F=[],I={data:[],errors:[],meta:{}};function B(T){return n.skipEmptyLines==="greedy"?T.join("").trim()==="":T.length===1&&T[0].length===0}function C(){if(I&&g&&(J("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+h.DefaultDelimiter+"'"),g=!1),n.skipEmptyLines&&(I.data=I.data.filter(function(z){return!B(z)})),G()){let z=function(re,ie){w(n.transformHeader)&&(re=n.transformHeader(re,ie)),F.push(re)};if(I)if(Array.isArray(I.data[0])){for(var T=0;G()&&T<I.data.length;T++)I.data[T].forEach(z);I.data.splice(0,1)}else I.data.forEach(z)}function H(z,re){for(var ie=n.header?{}:[],q=0;q<z.length;q++){var Q=q,K=z[q],K=((ue,W)=>(ee=>(n.dynamicTypingFunction&&n.dynamicTyping[ee]===void 0&&(n.dynamicTyping[ee]=n.dynamicTypingFunction(ee)),(n.dynamicTyping[ee]||n.dynamicTyping)===!0))(ue)?W==="true"||W==="TRUE"||W!=="false"&&W!=="FALSE"&&((ee=>{if(Z.test(ee)&&(ee=parseFloat(ee),V<ee&&ee<R))return 1})(W)?parseFloat(W):se.test(W)?new Date(W):W===""?null:W):W)(Q=n.header?q>=F.length?"__parsed_extra":F[q]:Q,K=n.transform?n.transform(K,Q):K);Q==="__parsed_extra"?(ie[Q]=ie[Q]||[],ie[Q].push(K)):ie[Q]=K}return n.header&&(q>F.length?J("FieldMismatch","TooManyFields","Too many fields: expected "+F.length+" fields but parsed "+q,O+re):q<F.length&&J("FieldMismatch","TooFewFields","Too few fields: expected "+F.length+" fields but parsed "+q,O+re)),ie}var X;I&&(n.header||n.dynamicTyping||n.transform)&&(X=1,!I.data.length||Array.isArray(I.data[0])?(I.data=I.data.map(H),X=I.data.length):I.data=H(I.data,0),n.header&&I.meta&&(I.meta.fields=F),O+=X)}function G(){return n.header&&F.length===0}function J(T,H,X,z){T={type:T,code:H,message:X},z!==void 0&&(T.row=z),I.errors.push(T)}w(n.step)&&(x=n.step,n.step=function(T){I=T,G()?C():(C(),I.data.length!==0&&(U+=T.data.length,n.preview&&U>n.preview?m.abort():(I.data=I.data[0],x(I,j))))}),this.parse=function(T,H,X){var z=n.quoteChar||'"',z=(n.newline||(n.newline=this.guessLineEndings(T,z)),g=!1,n.delimiter?w(n.delimiter)&&(n.delimiter=n.delimiter(T),I.meta.delimiter=n.delimiter):((z=((re,ie,q,Q,K)=>{var ue,W,ee,we;K=K||[","," ","|",";",h.RECORD_SEP,h.UNIT_SEP];for(var ke=0;ke<K.length;ke++){for(var he,Ie=K[ke],oe=0,pe=0,le=0,de=(ee=void 0,new M({comments:Q,delimiter:Ie,newline:ie,preview:10}).parse(re)),ge=0;ge<de.data.length;ge++)q&&B(de.data[ge])?le++:(he=de.data[ge].length,pe+=he,ee===void 0?ee=he:0<he&&(oe+=Math.abs(he-ee),ee=he));0<de.data.length&&(pe/=de.data.length-le),(W===void 0||oe<=W)&&(we===void 0||we<pe)&&1.99<pe&&(W=oe,ue=Ie,we=pe)}return{successful:!!(n.delimiter=ue),bestDelimiter:ue}})(T,n.newline,n.skipEmptyLines,n.comments,n.delimitersToGuess)).successful?n.delimiter=z.bestDelimiter:(g=!0,n.delimiter=h.DefaultDelimiter),I.meta.delimiter=n.delimiter),_(n));return n.preview&&n.header&&z.preview++,l=T,m=new M(z),I=m.parse(l,H,X),C(),Y?{meta:{paused:!0}}:I||{meta:{paused:!1}}},this.paused=function(){return Y},this.pause=function(){Y=!0,m.abort(),l=w(n.chunk)?"":l.substring(m.getCharIndex())},this.resume=function(){j.streamer._halted?(Y=!1,j.streamer.parseChunk(l,!0)):setTimeout(j.resume,3)},this.aborted=function(){return k},this.abort=function(){k=!0,m.abort(),I.meta.aborted=!0,w(n.complete)&&n.complete(I),l=""},this.guessLineEndings=function(re,z){re=re.substring(0,1048576);var z=new RegExp(f(z)+"([^]*?)"+f(z),"gm"),X=(re=re.replace(z,"")).split("\r"),z=re.split(`
|
|
1
|
+
import{j as e,G as ae,dk as Mt,aJ as ss,ar as Fs,r as c,a1 as Qe,B as $,cW as rs,X as pt,bi as ft,ag as bt,ai as Us,cS as as,cT as ns,cU as is,D as Fe,v as Ue,w as Be,x as ze,ao as Ne,ad as ve,dl as Bs,dm as zs,dn as ls,e as Je,bD as $s,C as Vs,c2 as Hs,cL as Te,aL as gt,dp as Ws,ac as Gs,cE as os,aZ as cs,dq as Ks,dr as Ys,Y as ce,b7 as qs,aW as Qs,b8 as Js,b9 as Xs,bb as Me,bc as Rt,cv as ds,aK as Zs,ds as er,dt as tr,du as sr,b6 as et,cu as ut,dv as xt,dw as rr,dx as ar,cl as Ot,dy as nr,dz as us,dA as It,aN as $e,cz as je,dB as ms,t as ne,dd as ir,cJ as lr,c0 as or,c1 as cr,d5 as hs,bR as dr,bg as ps,d6 as ur,d8 as mr}from"./index-BkbhBpVC.js";import{M as fs}from"./main-layout-BYKdA6Z1.js";import{C as yt,a as hr,b as vt,d as wt,e as Xe,f as Dt,g as Ve,h as pr,F as fr}from"./filters-DtIsuqv5.js";import{P as bs}from"./pencil-BcymGPnE.js";import{h as gs,o as St,q as br,r as gr,v as xs,d as xr,D as He,a as We,w as nt,s as Se,x as it,b as Ge,t as At,y as yr,g as vr,f as wr,c as Sr,u as _r,i as jr,p as ys,j as Er,n as Nr,l as Cr,k as kr,m as Lr,F as Mr}from"./filter-query-core-VEnwTCyO.js";import{D as Rr,u as Or}from"./dropzone-Cs4DrURS.js";import{U as vs,D as Ir,b as Dr,N as Ar,T as Pr,M as Tr,P as Fr,a as Ur,S as Br,A as zr,C as $r,c as Vr,d as Hr,e as Wr}from"./upload-BLiT66bJ.js";import{S as Gr,a as Kr,b as Yr,c as qr,f as Pt}from"./select-BfWJkrKc.js";import{T as Ze,a as _t,b as Ee,c as be,d as ws,e as me}from"./table-qQi9EXB1.js";import{b as Qr}from"./member-route-ZLy3opLv.js";import{u as Ss}from"./newsletters-CSCa3QdE.js";import{T as Jr}from"./tags-DuMshkTz.js";import{E as mt}from"./empty-indicator-BvyaMcmw.js";import{L as lt,C as Xr,E as Zr,F as ea,a as ta}from"./loader-circle-B1uEfpbZ.js";import{M as sa}from"./mail-ccQhEr7k.js";import{g as _s}from"./get-site-timezone-BDBAcjmq.js";import{u as ra}from"./tiers-D2DYHaeO.js";import{b as aa}from"./posts-BZaw4-dc.js";import{A as Tt}from"./arrow-right-Bk43nMGd.js";import{u as na,a as ia,L as la}from"./virtual-list-window-BnjCoNIr.js";import{L as Oe,P as ye}from"./list-page-COHNMpOi.js";import"./circle-alert-bcK_Yqap.js";import"./index-TtBMzSeP.js";import"./typeof-QjJsDpFa.js";import"./index-DYE2untj.js";import"./chevron-up-DuaKtE_M.js";function oa({className:t,...s}){return e.jsx("div",{className:ae(Mt.base,Mt.invalidWithin,"group/input-group relative flex w-full items-center outline-hidden","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:outline-hidden has-[[data-slot=input-group-control]:focus-visible]:bg-transparent has-[[data-slot=input-group-control]:focus-visible]:border-focus-ring has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-focus-ring/25",t),"data-slot":"input-group",role:"group",...s})}const ca=Fs("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--input-group-radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3","block-end":"order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3"}},defaultVariants:{align:"inline-start"}});function da({className:t,align:s="inline-start",...r}){return e.jsx("div",{className:ae(ca({align:s}),t),"data-align":s,"data-slot":"input-group-addon",role:"group",onClick:a=>{if(a.target.closest("button"))return;a.currentTarget.closest('[data-slot="input-group"]')?.querySelector('[data-slot="input-group-control"]')?.focus()},...r})}function ua({className:t,...s}){return e.jsx(ss,{className:ae("flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:outline-hidden focus-visible:shadow-none dark:bg-transparent",t),"data-slot":"input-group-control",...s})}const ma={searchPlaceholder:"Search...",noResultsFound:"No results found.",loading:"Loading...",loadMore:"Load more"};function ha(t,s){const r=s.trim().toLowerCase();return r?t.filter(a=>a.label.toLowerCase().includes(r)||a.detail?.toLowerCase().includes(r)):t}function pa(t,s,r,a,i,o,p){if(t)return{...t,shouldClientFilter:p??t.shouldClientFilter};const d=!!s,u=s?.useOptions({query:a,selectedValues:i});return{options:d?u?.options??[]:r??[],isInitialLoad:d?u?.isInitialLoad??!1:o&&(r?.length??0)===0,isSearching:d?u?.isSearching??!1:o&&(r?.length??0)>0,hasMore:d?u?.hasMore??!1:!1,isLoadingMore:d?u?.isLoadingMore??!1:!1,loadMore:d?u?.loadMore??(()=>{}):()=>{},shouldClientFilter:p??!d}}function fa({optionSource:t,options:s,values:r,onChange:a,valueSource:i,searchable:o=!0,isLoading:p=!1,maxSelections:d,isMultiSelect:u=!0,onClose:h,autoCloseOnSelect:b=!1,className:E,searchInputClassName:y,shouldFilter:v,onSearchChange:L,i18n:N,renderItem:f,header:M,footer:A}){const P=c.useMemo(()=>({...ma,...N}),[N]),[D,_]=c.useState(""),S=c.useCallback(C=>{_(C),t?.onSearchChange?.(C),L?.(C)},[L,t]),w=pa(t,i,s,D,r,p,v),n=w.options,[l,m]=c.useState([]),g=c.useMemo(()=>n.filter(C=>r.includes(C.value)),[n,r]);c.useEffect(()=>{if(r.length===0){m([]);return}g.length>0&&m(C=>{const G=[];for(const J of r){const T=g.find(H=>H.value===J)??C.find(H=>H.value===J);T&&G.push(T)}return G})},[g,r]);const x=c.useMemo(()=>r.length===0?[]:l.length>0?l:g,[l,r.length,g]),R=c.useMemo(()=>ha(x,D),[D,x]),V=c.useMemo(()=>n.filter(C=>!r.includes(C.value)),[n,r]),Z=c.useCallback(C=>{a(r.filter(G=>G!==C.value))},[a,r]),se=C=>{a([]),h?.()},j=C=>{const G=[...r,C.value];d&&G.length>d||(a(G),b&&h?.())},U=C=>{a([C.value]),h?.()},O=u?Z:se,Y=u?j:U,k=c.useCallback(()=>S(""),[S]),F=(C,G)=>{if(G)return;const J=C.detail?` - ${C.detail}`:"";return C.label+J},B=f??(({option:C,isSelected:G,onSelect:J})=>e.jsxs(Ve,{className:"group flex items-center gap-2",value:F(C,G),onSelect:J,children:[C.icon,e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsx("span",{className:"truncate text-accent-foreground",title:C.label,children:C.label}),C.detail&&e.jsx("span",{className:"truncate text-sm text-muted-foreground",title:C.detail,children:C.detail})]}),e.jsx(Qe,{className:ae("ms-auto text-primary",!G&&"opacity-0")})]},String(C.value)));return e.jsx("div",{className:ae("w-full",E),children:e.jsxs(yt,{shouldFilter:w.shouldClientFilter,children:[M?.({selectedOptions:x,onDeselect:Z}),o&&e.jsxs("div",{className:"relative",children:[e.jsx(hr,{className:ae("h-(--control-height) pr-8 text-sm",y),placeholder:P.searchPlaceholder,value:D,onValueChange:S}),w.isSearching&&e.jsx(lt,{className:"pointer-events-none absolute top-1/2 right-3 size-4 -translate-y-1/2 animate-spin text-muted-foreground"})]}),e.jsxs(vt,{className:"outline-hidden",children:[w.isInitialLoad?e.jsxs("div",{className:"flex items-center justify-center py-6 text-sm text-muted-foreground",children:[e.jsx(lt,{className:"mr-2 size-4 animate-spin"}),P.loading]}):e.jsx(wt,{children:P.noResultsFound}),R.length>0&&e.jsx(Xe,{heading:P.selectedHeading,children:R.map(C=>B({option:C,isSelected:!0,onSelect:()=>O(C)}))}),V.length>0&&e.jsxs(e.Fragment,{children:[R.length>0&&e.jsx(Dt,{}),e.jsx(Xe,{children:V.map(C=>B({option:C,isSelected:!1,onSelect:()=>Y(C)}))})]}),w.hasMore&&e.jsxs(e.Fragment,{children:[(R.length>0||V.length>0)&&e.jsx(Dt,{}),e.jsx("div",{className:"p-1.5",children:e.jsxs("button",{className:"flex w-full items-center justify-center rounded-xs px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-50",disabled:w.isLoadingMore,type:"button",onClick:w.loadMore,children:[w.isLoadingMore&&e.jsx(lt,{className:"mr-2 size-4 animate-spin"}),w.isLoadingMore?P.loading:P.loadMore]})})]})]}),A?.({searchInput:D,clearSearch:k})]})})}const js=({label:t,onSave:s,onCancel:r,onDelete:a,isDuplicateName:i})=>{const[o,p]=c.useState(t.name),[d,u]=c.useState(!1),[h,b]=c.useState(""),[E,y]=c.useState(!1),[v,L]=c.useState(!1),N=c.useRef(null),f=E||v;c.useEffect(()=>{N.current?.focus(),N.current?.select()},[]);const M=_=>{const S=_.trim();return S?i?.(S,t.id)?"A label with this name already exists":"":"Name is required"},A=async()=>{const _=M(o);if(_){b(_);return}y(!0);try{await s(t.id,o.trim()),r()}catch{y(!1)}},P=_=>{_.key==="Enter"?(_.preventDefault(),A()):_.key==="Escape"&&(_.preventDefault(),f||r())},D=async()=>{L(!0);try{await a(t.id)}catch{L(!1),u(!1)}};return e.jsxs("div",{className:"flex flex-col gap-2 py-1.5","data-edit-row":!0,children:[e.jsx("input",{ref:N,className:"h-7 w-full rounded border border-border bg-background px-2 text-sm outline-hidden focus:ring-1 focus:ring-ring disabled:opacity-50",disabled:f,type:"text",value:o,onChange:_=>{p(_.target.value),b("")},onKeyDown:P}),h&&e.jsx("span",{className:"text-xs text-destructive",children:h}),d?e.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[e.jsx("span",{className:"flex-1 font-semibold",children:"Delete label?"}),e.jsx($,{className:"h-6 px-2 text-xs",disabled:f,size:"sm",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsx($,{className:"h-6 px-2 text-xs",disabled:f,size:"sm",variant:"destructive",onClick:D,children:v?"Deleting...":"Delete"})]}):e.jsxs("div",{className:"flex items-center",children:[e.jsx($,{className:"h-6 gap-1 px-1.5 text-xs text-red hover:bg-red/5 hover:text-red",disabled:f,size:"sm",variant:"ghost",onClick:()=>u(!0),children:"Delete"}),e.jsxs("div",{className:"ml-auto flex gap-1",children:[e.jsx($,{className:"h-6 px-2 text-xs",disabled:f,size:"sm",variant:"outline",onClick:r,children:"Cancel"}),e.jsx($,{className:"h-6 px-2 text-xs",disabled:f,size:"sm",onClick:A,children:E?"Saving...":"Save"})]})]})]})},ba=({label:t,isSelected:s,showEdit:r,onToggle:a,onEditClick:i})=>e.jsxs(Ve,{className:"group",value:t.slug,onSelect:()=>a(t.slug),children:[e.jsx("span",{className:"flex-1 truncate",children:t.name}),r?e.jsxs("button",{"aria-label":`Edit label ${t.name}`,className:"relative ml-1 flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground",type:"button",onClick:o=>{o.stopPropagation(),o.preventDefault(),i()},children:[s&&e.jsx(Qe,{className:"absolute size-3 text-primary transition-opacity duration-150 group-hover:opacity-0"}),e.jsx(bs,{className:"absolute size-3 translate-x-2 opacity-0 transition-all duration-150 ease-out group-hover:translate-x-0 group-hover:opacity-100"})]}):s&&e.jsx(Qe,{className:"size-4 shrink-0 text-primary"})]}),ga=({labels:t,selectedSlugs:s,search:r,onToggle:a,onEdit:i,onDelete:o,isDuplicateName:p,canCreateFromSearch:d,onCreate:u,isCreating:h,onSearchClear:b})=>{const[E,y]=c.useState(null),v=r.trim().toLowerCase(),L=v?t.filter(D=>D.name.toLowerCase().includes(v)):t,N=!!u&&r.trim()&&d?.(r),f=!!i,M=async()=>{if(u){const D=await u(r.trim());D&&a(D.slug),b?.()}},A=async(D,_)=>{i&&await i(D,_)},P=async D=>{o&&(await o(D),y(null))};return e.jsxs(e.Fragment,{children:[!N&&L.length===0&&e.jsx(wt,{children:"No labels found"}),L.length>0&&e.jsx(Xe,{className:"[&_[cmdk-group-heading]]:hidden",children:L.map(D=>E===D.id?e.jsx(js,{isDuplicateName:p,label:D,onCancel:()=>y(null),onDelete:P,onSave:A},D.id):e.jsx(ba,{isSelected:s.includes(D.slug),label:D,showEdit:f,onEditClick:()=>y(D.id),onToggle:a},D.id))}),N&&e.jsx(Xe,{className:"[&_[cmdk-group-heading]]:hidden",children:e.jsxs(Ve,{disabled:h,onSelect:M,children:[e.jsx(ft,{className:"size-4"}),h?"Creating...":`Create "${r.trim()}"`]})})]})},xa=({labels:t,onToggle:s})=>e.jsx(e.Fragment,{children:t.map(r=>e.jsxs(rs,{className:"cursor-pointer gap-1 pr-1",variant:"outline",onClick:a=>{a.stopPropagation(),s(r.slug)},children:[r.name,e.jsx(pt,{className:"size-3"})]},r.id))}),jt=({labels:t,optionSource:s,selectedSlugs:r,resolvedSelectedLabels:a,onToggle:i,canCreateFromSearch:o,onCreate:p,isCreating:d,onEdit:u,onDelete:h,isDuplicateName:b})=>{const E=a||r.map(y=>t.find(v=>v.slug===y)).filter(y=>!!y);return e.jsx(ya,{canCreateFromSearch:o,isCreating:d,isDuplicateName:b,labels:t,optionSource:s,selectedLabels:E,selectedSlugs:r,onCreate:p,onDelete:h,onEdit:u,onToggle:i})},ya=({labels:t,optionSource:s,selectedLabels:r,selectedSlugs:a,onToggle:i,canCreateFromSearch:o,onCreate:p,isCreating:d,onEdit:u,onDelete:h,isDuplicateName:b})=>{const[E,y]=c.useState(!1),[v,L]=c.useState(""),N=c.useRef(null),f=c.useRef(null),M=c.useCallback(P=>{L(P),s.onSearchChange?.(P)},[s]);c.useEffect(()=>{if(!E)return;const P=D=>{f.current&&!f.current.contains(D.target)&&y(!1)};return document.addEventListener("pointerdown",P),()=>document.removeEventListener("pointerdown",P)},[E]);const A=P=>{P.key==="Backspace"&&!v&&a.length>0&&i(a[a.length-1]),P.key==="Escape"&&(y(!1),N.current?.blur())};return e.jsxs("div",{ref:f,className:"relative",children:[e.jsxs("div",{className:"flex min-h-9 w-full cursor-text flex-wrap items-center gap-1.5 rounded-md border border-transparent bg-gray-150 px-3 py-1 text-sm transition-colors focus-within:border-green focus-within:bg-transparent focus-within:shadow-[0_0_0_2px_rgba(48,207,67,.25)] dark:bg-gray-900",role:"combobox",onClick:()=>{N.current?.focus(),y(!0)},children:[e.jsx(xa,{labels:r,onToggle:i}),e.jsx("input",{ref:N,className:"min-w-[80px] flex-1 bg-transparent text-sm outline-hidden placeholder:text-muted-foreground",placeholder:r.length===0?"Search labels...":"",value:v,onChange:P=>{M(P.target.value),E||y(!0)},onFocus:()=>y(!0),onKeyDown:A})]}),E&&e.jsx("div",{className:"absolute top-full left-0 z-50 mt-1 w-full rounded-md border bg-white shadow-md dark:bg-gray-950",children:s.isInitialLoad?e.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-muted-foreground",children:"Loading labels..."}):e.jsx(yt,{shouldFilter:!1,children:e.jsx(vt,{className:"max-h-64 overflow-y-auto",children:e.jsx(ga,{canCreateFromSearch:o,isCreating:d,isDuplicateName:b,labels:t,search:v,selectedSlugs:a,onCreate:p,onDelete:h,onEdit:u,onSearchClear:()=>M(""),onToggle:i})})})})]})},tt="LabelsResponseType",va=Us({dataType:tt,path:"/labels/",defaultNextPageParams:(t,s)=>{if(t.meta?.pagination.next)return{...s,page:t.meta.pagination.next.toString()}},returnData:t=>{const{pages:s}=t,r=s.flatMap(i=>i.labels),a=s[s.length-1].meta;return{labels:r,meta:a,isEnd:a?a.pagination.pages===a.pagination.page:!0}}}),wa=bt({method:"POST",path:()=>"/labels/",body:t=>({labels:[t]}),invalidateQueries:{dataType:tt}}),Sa=bt({method:"PUT",path:t=>`/labels/${t.id}/`,body:t=>({labels:[t]}),invalidateQueries:{dataType:tt}}),_a=bt({method:"DELETE",path:t=>`/labels/${t}/`,invalidateQueries:{dataType:tt}}),ja=()=>{};function Ea(t){return function(){const a=t.useRemoteSource({enabled:!0}).useInitialBrowse(),[i,o]=c.useState(null);c.useEffect(()=>{i!==null||!a.pagination||o(a.pagination.total<=t.pageLimit||a.pagination.next===null?"local":"remote")},[i,a.pagination]);const p=t.useLocalSource(a,{enabled:i==="local"}),d=t.useRemoteSource({enabled:i==="remote"}),u=h=>{const b=p.useOptions(h),E=d.useOptions(h);return i===null?{options:[],isInitialLoad:a.isLoading,isSearching:!1,isLoadingMore:!1,hasMore:!1,loadMore:ja}:i==="remote"?E:b};return{id:t.id,useOptions:u}}}const Es="100";function ht(t){return{value:t.slug,label:t.name,metadata:{id:t.id}}}function Na(t,s){const{enabled:r=!0}=s;return{id:"posts.labels.local",useOptions:({query:i,selectedValues:o})=>{const p=(t.items||[]).map(ht),d=o.map(u=>{const h=t.items?.find(b=>b.slug===u);return h?ht(h):{value:u,label:u}});return r?{options:gr(d,xs(p,i)),isInitialLoad:t.isLoading&&p.length===0,isSearching:!1,isLoadingMore:!1,hasMore:!1,loadMore:()=>{}}:{options:[],isInitialLoad:!1,isSearching:!1,isLoadingMore:!1,hasMore:!1,loadMore:()=>{}}}}}const Ca=gs({id:"posts.labels.remote",buildBrowseSearchParams:t=>({limit:Es,order:"name asc",...t?{filter:`name:~${St(t)}`}:{}}),buildHydrateFilter:t=>br("slug",t),buildHydrateSearchParams:t=>({filter:t,order:"name asc"}),selectItems:t=>t?.labels,useQuery:({enabled:t,searchParams:s})=>va({enabled:t,keepPreviousData:!0,searchParams:s}),toOption:ht,debounceMs:250}),ka=Ea({id:"posts.labels.hybrid",pageLimit:Number(Es),useLocalSource:Na,useRemoteSource:Ca});function Ns(){return ka()}function st({selectedSlugs:t,onSelectionChange:s,valueSource:r}){const a=Ns(),i=r??a,[o,p]=c.useState(""),d=i.useOptions({query:o,selectedValues:t}),u=c.useMemo(()=>d.options.flatMap(_=>_.metadata?.id?[{id:String(_.metadata.id),name:_.label,slug:String(_.value),created_at:"",updated_at:""}]:[]),[d.options]),h={...d,shouldClientFilter:!1,onSearchChange:p},{mutateAsync:b,isLoading:E}=wa(),{mutateAsync:y}=Sa(),{mutateAsync:v}=_a(),L=c.useRef(t);L.current=t;const N=c.useCallback(_=>{const S=L.current;S.includes(_)?s(S.filter(w=>w!==_)):s([...S,_])},[s]),f=c.useCallback((_,S)=>{const w=_.trim().toLowerCase();return u.some(n=>n.name.toLowerCase()===w&&n.id!==S)},[u]),M=c.useCallback(_=>{const S=_.trim();return S?!f(S):!1},[f]),A=c.useCallback(async _=>{const S=_.trim();return!S||f(S)?void 0:(await b({name:S}))?.labels?.[0]},[b,f]),P=c.useCallback(async(_,S)=>{const w=S.trim();if(!w||f(w,_))return;const n=u.find(g=>g.id===_),m=(await y({id:_,name:w}))?.labels?.[0];if(n&&m&&n.slug!==m.slug){const g=L.current;g.includes(n.slug)&&s(g.map(x=>x===n.slug?m.slug:x))}},[y,f,u,s]),D=c.useCallback(async _=>{const S=u.find(w=>w.id===_);if(await v(_),S){const w=L.current;w.includes(S.slug)&&s(w.filter(n=>n!==S.slug))}},[v,u,s]);return{labels:u,optionSource:h,selectedSlugs:t,resolvedSelectedLabels:t.map(_=>u.find(S=>S.slug===_)).filter(_=>!!_),toggleLabel:N,createLabel:A,editLabel:P,deleteLabel:D,isDuplicateName:f,canCreateFromSearch:M,isCreating:E}}const La=({field:t,values:s,onChange:r})=>{const a=st({selectedSlugs:s,onSelectionChange:r,valueSource:t.valueSource}),i=c.useRef(null),[o,p]=c.useState(0),d=c.useCallback(()=>{const v=i.current,L=v?.parentElement;if(v&&L){const N=v.getBoundingClientRect(),f=L.getBoundingClientRect();p(Math.round(f.left-N.left))}},[]);let u="Select...";a.resolvedSelectedLabels.length===1?u=a.resolvedSelectedLabels[0].name:a.resolvedSelectedLabels.length>1&&(u=`${a.resolvedSelectedLabels.length} labels`);const[h,b]=c.useState(null),E=c.useCallback(({option:v,isSelected:L,onSelect:N})=>{const f=String(v.metadata?.id??"");if(h===f&&!L){const M={id:f,name:v.label,slug:String(v.value),created_at:"",updated_at:""};return e.jsx(js,{isDuplicateName:a.isDuplicateName,label:M,onCancel:()=>b(null),onDelete:async A=>{await a.deleteLabel(A),b(null)},onSave:async(A,P)=>{await a.editLabel(A,P),b(null)}},f)}return e.jsxs(Ve,{className:"group",value:v.label,onSelect:N,children:[e.jsx("span",{className:"flex-1 truncate",children:v.label}),L?e.jsx(Qe,{className:"size-3 shrink-0 text-primary"}):e.jsx("button",{"aria-label":`Edit label ${v.label}`,className:"relative ml-1 flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground",type:"button",onClick:M=>{M.stopPropagation(),M.preventDefault(),b(f)},children:e.jsx(bs,{className:"absolute size-3 translate-x-2 opacity-0 transition-all duration-150 ease-out group-hover:translate-x-0 group-hover:opacity-100"})})]},String(v.value))},[h,a]),y=c.useCallback(({searchInput:v,clearSearch:L})=>v.trim()&&a.canCreateFromSearch(v)?e.jsx("div",{className:"border-t p-1",children:e.jsxs($,{className:"h-8 w-full justify-start gap-2 px-2 text-sm font-normal",disabled:a.isCreating,variant:"ghost",onClick:async()=>{const f=await a.createLabel(v.trim());f&&a.toggleLabel(f.slug),L()},children:[e.jsx(ft,{className:"size-4"}),a.isCreating?"Creating...":`Create "${v.trim()}"`]})}):null,[a]);return e.jsxs(as,{onOpenChange:v=>{v?d():a.optionSource.onSearchChange?.("")},children:[e.jsx(ns,{asChild:!0,children:e.jsx("button",{ref:i,className:"flex size-full items-center truncate text-left text-sm",type:"button",children:u})}),e.jsx(is,{align:"start",alignOffset:o,className:"w-64 p-0",children:a.optionSource.isInitialLoad?e.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-muted-foreground",children:"Loading labels..."}):e.jsx(fa,{footer:y,i18n:{searchPlaceholder:"Search labels...",noResultsFound:"No labels found"},optionSource:a.optionSource,renderItem:E,values:s,onChange:r})})]})};function Ma({open:t,memberCount:s,onOpenChange:r,onConfirm:a,isLoading:i=!1}){const[o,p]=c.useState([]),d=st({selectedSlugs:o,onSelectionChange:p}),u=c.useCallback(b=>{b||p([]),r(b)},[r]),h=()=>{const b=d.labels.filter(E=>o.includes(E.slug)).map(E=>E.id);b.length>0&&a(b)};return e.jsx(Fe,{open:t,onOpenChange:u,children:e.jsxs(Ue,{className:"gap-5",onOpenAutoFocus:b=>b.preventDefault(),children:[e.jsx(Be,{children:e.jsxs(ze,{children:["Add label to ",Ne(s)," ",s===1?"member":"members"]})}),e.jsx(jt,{canCreateFromSearch:d.canCreateFromSearch,isCreating:d.isCreating,isDuplicateName:d.isDuplicateName,labels:d.labels,optionSource:d.optionSource,resolvedSelectedLabels:d.resolvedSelectedLabels,selectedSlugs:o,onCreate:d.createLabel,onDelete:d.deleteLabel,onEdit:d.editLabel,onToggle:d.toggleLabel}),e.jsxs(ve,{children:[e.jsx($,{variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsx($,{disabled:o.length===0||i,onClick:h,children:i?"Adding...":o.length>1?`Add ${Ne(o.length)} labels`:"Add label"})]})]})})}function Ra({open:t,memberCount:s,nql:r,search:a,onOpenChange:i,onConfirm:o,isLoading:p=!1}){const[d,u]=c.useState([]),{data:h,isLoading:b}=Bs({searchParams:{...r?{filter:r}:{},...a?{search:a}:{},include:"labels",limit:"all",fields:"id"},enabled:t}),E=c.useMemo(()=>{const f=new Set;for(const M of h?.members||[])for(const A of M.labels||[])f.add(A.slug);return f},[h]),y=st({selectedSlugs:d,onSelectionChange:u}),v={...y.optionSource,options:y.optionSource.options.filter(f=>E.has(String(f.value)))},L=c.useCallback(f=>{f||u([]),i(f)},[i]),N=()=>{const f=y.labels.filter(M=>d.includes(M.slug)).map(M=>M.id);f.length>0&&o(f)};return e.jsx(Fe,{open:t,onOpenChange:L,children:e.jsxs(Ue,{className:"gap-5",onOpenAutoFocus:f=>f.preventDefault(),children:[e.jsx(Be,{children:e.jsxs(ze,{children:["Remove label from ",Ne(s)," ",s===1?"member":"members"]})}),e.jsx(jt,{isDuplicateName:y.isDuplicateName,labels:y.labels.filter(f=>E.has(f.slug)),optionSource:{...v,isInitialLoad:v.isInitialLoad||b},resolvedSelectedLabels:y.resolvedSelectedLabels.filter(f=>E.has(f.slug)),selectedSlugs:d,onDelete:y.deleteLabel,onEdit:y.editLabel,onToggle:y.toggleLabel}),e.jsxs(ve,{children:[e.jsx($,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsx($,{disabled:d.length===0||p,onClick:N,children:p?"Removing...":d.length>1?`Remove ${Ne(d.length)} labels`:"Remove label"})]})]})})}function Oa({open:t,newsletters:s,memberCount:r,onOpenChange:a,onConfirm:i,isLoading:o=!1}){const[p,d]=c.useState("all"),[u,h]=c.useState([]),[b,E]=c.useState(""),[y,v]=c.useState(!1),L=c.useRef(null),N=c.useRef(null);c.useEffect(()=>{t||(d("all"),h([]),E(""),v(!1))},[t]),c.useEffect(()=>{if(!y)return;const S=w=>{L.current&&!L.current.contains(w.target)&&v(!1)};return document.addEventListener("pointerdown",S),()=>document.removeEventListener("pointerdown",S)},[y]);const f=S=>{S||(d("all"),h([]),E(""),v(!1)),a(S)},M=c.useCallback(S=>{h(w=>w.includes(S)?w.filter(n=>n!==S):[...w,S])},[]),A=s.length>=2,P=()=>{i(!A||p==="all"?null:u)},D=o||A&&p==="selected"&&u.length===0,_=r===1?"member":"members";return e.jsx(Fe,{open:t,onOpenChange:f,children:e.jsxs(Ue,{className:"gap-5",children:[e.jsx(Be,{children:e.jsx(ze,{children:"Unsubscribe members"})}),A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{"aria-label":"Unsubscribe scope",className:"flex flex-col gap-3",role:"radiogroup",children:[e.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{checked:p==="all",className:"mt-0.5 size-4 cursor-pointer accent-black",name:"unsubscribe-mode",type:"radio",value:"all",onChange:()=>d("all")}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-semibold",children:"Unsubscribe from all newsletters"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[r.toLocaleString()," ",_," will be unsubscribed from"," ",s.length," ",s.length===1?"newsletter":"newsletters","."]})]})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{checked:p==="selected",className:"mt-0.5 size-4 cursor-pointer accent-black",name:"unsubscribe-mode",type:"radio",value:"selected",onChange:()=>d("selected")}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-semibold",children:"Unsubscribe from selected newsletters"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Select which newsletters to unsubscribe"," ",r.toLocaleString()," ",_," from."]})]})]})]}),p==="selected"&&e.jsxs("div",{ref:L,className:"relative space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold",htmlFor:"newsletter-search",children:"Newsletters"}),e.jsxs("div",{className:"flex min-h-9 w-full cursor-text flex-wrap items-center gap-1.5 rounded-md border bg-background px-3 py-1 text-sm",onClick:()=>{N.current?.focus(),v(!0)},children:[u.map(S=>{const w=s.find(n=>n.id===S);return w?e.jsxs(rs,{className:"cursor-pointer gap-1 pr-1",variant:"outline",onClick:n=>{n.stopPropagation(),M(S)},children:[w.name,e.jsx(pt,{className:"size-3"})]},S):null}),e.jsx("input",{ref:N,className:"min-w-[80px] flex-1 bg-transparent py-1 text-sm outline-hidden placeholder:text-muted-foreground",id:"newsletter-search",placeholder:u.length===0?"Search newsletters...":"",value:b,onChange:S=>{E(S.target.value),y||v(!0)},onFocus:()=>v(!0),onKeyDown:S=>{S.key==="Escape"&&(v(!1),N.current?.blur()),S.key==="Backspace"&&!b&&u.length>0&&M(u[u.length-1])}})]}),y&&e.jsx("div",{className:"absolute top-full left-0 z-50 mt-1 w-full rounded-md border bg-white shadow-md dark:bg-gray-950",children:e.jsx(yt,{shouldFilter:!1,children:e.jsxs(vt,{className:"max-h-64 overflow-y-auto",children:[e.jsx(wt,{children:"No newsletters found."}),s.filter(S=>S.name.toLowerCase().includes(b.toLowerCase())).map(S=>e.jsxs(Ve,{value:S.name,onSelect:()=>M(S.id),children:[S.name,u.includes(S.id)&&e.jsx(pr,{})]},S.id))]})})})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Are you sure you want to unsubscribe"," ",r.toLocaleString()," ",_," from all newsletters? They will no longer receive any email newsletters from you."]}),e.jsxs(ve,{children:[e.jsx($,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsx($,{disabled:D,variant:"destructive",onClick:P,children:o?"Unsubscribing...":"Unsubscribe"})]})]})})}function Ia({open:t,memberCount:s,onOpenChange:r,onConfirm:a,onExportBackup:i,isLoading:o=!1}){const[p,d]=c.useState(!1),u=b=>{b||d(!1),r(b)},h=async()=>{if(!(s<1||o||p))try{d(!0),await i(),a()}catch{}finally{d(!1)}};return e.jsx(Fe,{open:t,onOpenChange:u,children:e.jsxs(Ue,{className:"gap-5",children:[e.jsx(Be,{children:e.jsx(ze,{children:"Delete selected members?"})}),e.jsx("div",{className:"text-sm",children:s>0?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["You're about to delete ",e.jsxs("strong",{children:[s.toLocaleString()," ",s===1?"member":"members"]}),". This is permanent! All Ghost data will be deleted, this will have no effect on subscriptions in Stripe."]}),e.jsx("p",{className:"mt-4",children:"A backup of your selection will be automatically downloaded to your device before deletion."})]}):e.jsx("p",{children:"No members are selected."})}),e.jsxs(ve,{children:[e.jsx($,{variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsx($,{disabled:o||p||s<1,variant:"destructive",onClick:h,children:o||p?"Deleting...":"Download backup & delete members"})]})]})})}function Da({fileError:t,onClose:s,onDropAccepted:r,onDropRejected:a}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-5 space-y-5",children:[e.jsxs(zs,{variant:"info",children:["Need some help? ",e.jsx("a",{className:"font-semibold underline",href:"https://ghost.org/help/import-members/",rel:"noopener noreferrer",target:"_blank",children:"Learn more"})," about importing members or ",e.jsx("a",{className:"font-semibold underline",href:"https://static.ghost.org/v4.0.0/files/member-import-template.csv",rel:"noopener noreferrer",target:"_blank",children:"download a sample CSV file"}),"."]}),t&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-600",children:[e.jsx(ls,{className:"mt-0.5 size-4 shrink-0"}),e.jsx("p",{children:t})]}),e.jsx(Rr,{accept:{"text/csv":[".csv"],"application/vnd.ms-excel":[".csv"]},"aria-label":"Select or drop a CSV file",onDropAccepted:i=>{const o=i[0];o&&r(o)},onDropRejected:a,children:({isDragActive:i,isDragReject:o})=>e.jsxs(e.Fragment,{children:[e.jsx(vs,{className:"mb-2 size-6 text-grey-600"}),e.jsx("span",{className:"text-sm text-grey-700",children:o?"The file type you uploaded is not supported":i?"Drop CSV file to upload":"Select or drop a CSV file"})]})})]}),e.jsx(ve,{className:"mt-5",children:e.jsx($,{variant:"outline",onClick:s,children:"Close"})})]})}function Aa({status:t,fileData:s,mapping:r,mappingError:a,showMappingErrors:i,membersCount:o,dataPreviewIndex:p,hasPrevRecord:d,hasNextRecord:u,fieldMappings:h,labelPicker:b,onUpdateMapping:E,onDataPreviewIndexChange:y,onStartOver:v,onUpload:L}){const N=s&&s.length>0&&r?Object.entries(s[p]||{}).map(([f,M])=>({key:f,value:M,mapTo:r.get(f)})):[];return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5 space-y-5",children:s===null?e.jsx("div",{className:"flex items-center justify-center rounded-md border bg-muted p-10",children:e.jsx(Je,{size:"md"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ae("overflow-hidden rounded-md border",i&&a&&"border-red-500"),children:e.jsx("div",{className:"max-h-[400px] overflow-auto",children:e.jsxs(Ze,{className:"table-fixed",children:[e.jsx(_t,{children:e.jsxs(Ee,{children:[e.jsx(be,{className:"w-1/3",children:"Field"}),e.jsx(be,{className:"w-1/3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:["Sample data ",e.jsxs("span",{className:"text-muted-foreground",children:["(#",Ne(p+1),")"]})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{"aria-label":"Show previous sample row",className:ae("rounded p-0.5 hover:bg-muted",!d&&"cursor-default opacity-30"),disabled:!d||t==="UPLOADING",type:"button",onClick:()=>y(p-1),children:e.jsx($s,{className:"size-4"})}),e.jsx("button",{"aria-label":"Show next sample row",className:ae("rounded p-0.5 hover:bg-muted",!u&&"cursor-default opacity-30"),disabled:!u||t==="UPLOADING",type:"button",onClick:()=>y(p+1),children:e.jsx(Vs,{className:"size-4"})})]})]})}),e.jsx(be,{className:"w-1/3",children:"Import as"})]})}),e.jsx(ws,{children:N.length>0?N.map(f=>e.jsxs(Ee,{className:ae(!f.mapTo&&"bg-muted"),children:[e.jsx(me,{className:"text-sm font-medium break-all",children:f.key}),e.jsx(me,{className:ae("break-all text-sm",!f.value&&"text-muted-foreground"),children:f.value||" "}),e.jsx(me,{children:e.jsxs(Gr,{disabled:t==="UPLOADING",value:f.mapTo||"__not_imported__",onValueChange:M=>{E(f.key,M==="__not_imported__"?null:M)},children:[e.jsx(Kr,{className:ae("h-8 text-sm",!f.mapTo&&"text-muted-foreground"),children:e.jsx(Yr,{})}),e.jsxs(qr,{children:[e.jsx(Pt,{value:"__not_imported__",children:"Not imported"}),h.map(M=>e.jsx(Pt,{value:M.value,children:M.label},M.value))]})]})})]},f.key)):e.jsx(Ee,{children:e.jsx(me,{className:"text-muted-foreground",colSpan:3,children:"No data found in the uploaded CSV."})})})]})})}),i&&a&&e.jsx("p",{className:"text-sm text-red-600",children:a}),o>0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"If an email address in your CSV matches an existing member, they will be updated with the mapped values."}),e.jsxs("div",{className:"mt-5",children:[e.jsx("label",{className:"mb-1 block text-sm font-semibold",children:"Label these members"}),e.jsx(jt,{canCreateFromSearch:b.canCreateFromSearch,isCreating:b.isCreating,isDuplicateName:b.isDuplicateName,labels:b.labels,optionSource:b.optionSource,resolvedSelectedLabels:b.resolvedSelectedLabels,selectedSlugs:b.selectedSlugs,onCreate:b.createLabel,onDelete:b.deleteLabel,onEdit:b.editLabel,onToggle:b.toggleLabel})]})]})}),e.jsxs(ve,{className:"mt-5",children:[e.jsx($,{disabled:t==="UPLOADING",variant:"outline",onClick:v,children:"Start over"}),e.jsx($,{disabled:t==="UPLOADING"||o===0,onClick:L,children:t==="UPLOADING"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Je,{color:"light",size:"sm"}),"Uploading"]}):o>0?`Import ${Ne(o)} ${o===1?"member":"members"}`:"Import members"})]})]})}function Pa({onUploadAnotherFile:t,onClose:s}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5",children:e.jsx("p",{className:"text-sm",children:"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."})}),e.jsxs(ve,{className:"mt-5",children:[e.jsx($,{variant:"outline",onClick:t,children:"Upload another file"}),e.jsx($,{onClick:s,children:"Got it"})]})]})}function Ta({importResponse:t,onReset:s,onClose:r}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-5 space-y-4",children:[t.importedCount===0?e.jsxs("p",{className:"text-sm",children:["No members were added",t.errorCount>0?" due to the following errors:":"."]}):e.jsxs("p",{className:"text-sm",children:["A total of ",e.jsx("strong",{children:t.importedCount.toLocaleString()})," ",t.importedCount===1?"person was":"people were"," successfully added or updated in your list of members, and now have access to your site."]}),t.errorCount>0&&e.jsxs(e.Fragment,{children:[t.importedCount>0&&e.jsxs(e.Fragment,{children:[e.jsx("hr",{className:"border-grey-200"}),e.jsxs("p",{className:"text-sm",children:[e.jsx("strong",{children:t.errorCount.toLocaleString()})," ",t.errorCount===1?"member was":"members were"," skipped due to the following errors:"]})]}),e.jsx("ul",{className:"list-inside list-disc space-y-1 text-sm text-muted-foreground",children:t.errorList.map(a=>e.jsxs("li",{children:[a.message," (",a.count,")"]},a.message))})]})]}),e.jsx(ve,{className:"mt-5",children:t.errorCount>0?e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"outline",asChild:!0,children:e.jsx("a",{download:t.errorCsvName,href:t.errorCsvUrl,children:"Download error file"})}),t.importedCount===0?e.jsx($,{onClick:s,children:"Try again"}):e.jsx($,{onClick:r,children:"View members"})]}):e.jsx(e.Fragment,{children:t.importedCount===0?e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"outline",onClick:r,children:"Close"}),e.jsx($,{onClick:s,children:"Try again"})]}):e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"outline",onClick:s,children:"Upload another file"}),e.jsx($,{onClick:r,children:"View members"})]})})})]})}function Fa({errorMessage:t,showTryAgainButton:s,onTryAgain:r,onClose:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5",children:e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-600",children:[e.jsx(ls,{className:"mt-0.5 size-4 shrink-0"}),e.jsx("p",{children:t})]})}),e.jsxs(ve,{className:"mt-5",children:[s&&e.jsx($,{variant:"outline",onClick:r,children:"Try again"}),e.jsx($,{onClick:a,children:"OK"})]})]})}const Ua=[{label:"Email",value:"email"},{label:"Name",value:"name"},{label:"Note",value:"note"},{label:"Subscribed to emails",value:"subscribed_to_emails"},{label:"Stripe Customer ID",value:"stripe_customer_id"},{label:"Complimentary plan",value:"complimentary_plan"},{label:"Labels",value:"labels"},{label:"Created at",value:"created_at"}],Cs={label:"Tier",value:"import_tier"},ks={label:"Gift ID",value:"gift_id"},Ba=["email","name","note","subscribed_to_emails","complimentary_plan","stripe_customer_id","labels","created_at"];function za({importMemberTier:t=!1,giftSubscriptionsEnabled:s=!1}={}){return[...Ba,...t?[Cs.value]:[],...s?[ks.value]:[]]}function $a({importMemberTier:t=!1,giftSubscriptionsEnabled:s=!1}={}){return[...Ua,...t?[Cs]:[],...s?[ks]:[]]}const Va=["email"],Ha=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;class Et{_mapping;constructor(s){if(this._mapping={},s)for(const[r,a]of Object.entries(s))this._mapping[a]=r}get(s){return this._mapping[s]??null}toJSON(){return{...this._mapping}}getKeyByValue(s){for(const[r,a]of Object.entries(this._mapping))if(a===s)return r;return null}updateMapping(s,r){const a=new Et({});if(a._mapping={...this._mapping},r)for(const i in a._mapping)a._mapping[i]===r&&(a._mapping[i]=null);return a._mapping[s]=r,a}}function Wa(t,s=30){if(!t||t.length<=s)return t;const r=[];return Object.keys(t[0]).forEach(i=>{const o=t.filter(d=>d[i]&&d[i].trim()!=="");let p=[];if(o.length<=s)p=o;else{const d=Math.floor(s/3),u=d,h=s-d-u,b=o.slice(0,d),E=u>0?o.slice(-u):[],y=Math.max(0,Math.floor(o.length/2)-Math.floor(h/2)),v=o.slice(y,y+h);p=[...b,...v,...E].slice(0,s)}p.forEach((d,u)=>{r[u]||(r[u]={}),r[u][i]=d[i]})}),r}function Ga(t,s={}){const r=Wa(t),a={},i=za(s);if(t.length>0)for(const p of Object.keys(t[0])){if(!a.name&&/name/i.test(p)){a.name=p;continue}!a[p]&&i.includes(p)&&!Va.includes(p)&&(a[p]=p)}let o=0;for(;o<=r.length-1&&!a.email;){const p=r[o];for(const[d,u]of Object.entries(p))!a.email&&u&&Ha.test(u)&&(a.email=d);o+=1}return a}function Ka(t){return t.replace("Value in [members.email] cannot be blank.","Missing email address").replace("Value in [members.note] exceeds maximum length of 2000 characters.","Note is too long").replace("Value in [members.subscribed] must be one of true, false, 0 or 1.",'Value of "Subscribed to emails" must be "true" or "false"').replace("Validation (isEmail) failed for email","Invalid email address").replace(/No such customer:[^,]*/,"Could not find Stripe customer")}var qe={exports:{}};var Ya=qe.exports,Ft;function qa(){return Ft||(Ft=1,(function(t,s){((r,a)=>{t.exports=a()})(Ya,function r(){var a=typeof self<"u"?self:typeof window<"u"?window:a!==void 0?a:{},i,o=!a.document&&!!a.postMessage,p=a.IS_PAPA_WORKER||!1,d={},u=0,h={};function b(n){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(l){var m=_(l);m.chunkSize=parseInt(m.chunkSize),l.step||l.chunk||(m.chunkSize=null),this._handle=new N(m),(this._handle.streamer=this)._config=m}).call(this,n),this.parseChunk=function(l,m){var g=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<g){let R=this._config.newline;R||(x=this._config.quoteChar||'"',R=this._handle.guessLineEndings(l,x)),l=[...l.split(R).slice(g)].join(R)}this.isFirstChunk&&w(this._config.beforeFirstChunk)&&(x=this._config.beforeFirstChunk(l))!==void 0&&(l=x),this.isFirstChunk=!1,this._halted=!1;var g=this._partialLine+l,x=(this._partialLine="",this._handle.parse(g,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(l=x.meta.cursor,g=(this._finished||(this._partialLine=g.substring(l-this._baseIndex),this._baseIndex=l),x&&x.data&&(this._rowCount+=x.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),p)a.postMessage({results:x,workerId:h.WORKER_ID,finished:g});else if(w(this._config.chunk)&&!m){if(this._config.chunk(x,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=x=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(x.data),this._completeResults.errors=this._completeResults.errors.concat(x.errors),this._completeResults.meta=x.meta),this._completed||!g||!w(this._config.complete)||x&&x.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),g||x&&x.meta.paused||this._nextChunk(),x}this._halted=!0},this._sendError=function(l){w(this._config.error)?this._config.error(l):p&&this._config.error&&a.postMessage({workerId:h.WORKER_ID,error:l,finished:!1})}}function E(n){var l;(n=n||{}).chunkSize||(n.chunkSize=h.RemoteChunkSize),b.call(this,n),this._nextChunk=o?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(m){this._input=m,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(l=new XMLHttpRequest,this._config.withCredentials&&(l.withCredentials=this._config.withCredentials),o||(l.onload=S(this._chunkLoaded,this),l.onerror=S(this._chunkError,this)),l.open(this._config.downloadRequestBody?"POST":"GET",this._input,!o),this._config.downloadRequestHeaders){var m,g=this._config.downloadRequestHeaders;for(m in g)l.setRequestHeader(m,g[m])}var x;this._config.chunkSize&&(x=this._start+this._config.chunkSize-1,l.setRequestHeader("Range","bytes="+this._start+"-"+x));try{l.send(this._config.downloadRequestBody)}catch(R){this._chunkError(R.message)}o&&l.status===0&&this._chunkError()}},this._chunkLoaded=function(){l.readyState===4&&(l.status<200||400<=l.status?this._chunkError():(this._start+=this._config.chunkSize||l.responseText.length,this._finished=!this._config.chunkSize||this._start>=(m=>(m=m.getResponseHeader("Content-Range"))!==null?parseInt(m.substring(m.lastIndexOf("/")+1)):-1)(l),this.parseChunk(l.responseText)))},this._chunkError=function(m){m=l.statusText||m,this._sendError(new Error(m))}}function y(n){(n=n||{}).chunkSize||(n.chunkSize=h.LocalChunkSize),b.call(this,n);var l,m,g=typeof FileReader<"u";this.stream=function(x){this._input=x,m=x.slice||x.webkitSlice||x.mozSlice,g?((l=new FileReader).onload=S(this._chunkLoaded,this),l.onerror=S(this._chunkError,this)):l=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var x=this._input,R=(this._config.chunkSize&&(R=Math.min(this._start+this._config.chunkSize,this._input.size),x=m.call(x,this._start,R)),l.readAsText(x,this._config.encoding));g||this._chunkLoaded({target:{result:R}})},this._chunkLoaded=function(x){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(x.target.result)},this._chunkError=function(){this._sendError(l.error)}}function v(n){var l;b.call(this,n=n||{}),this.stream=function(m){return l=m,this._nextChunk()},this._nextChunk=function(){var m,g;if(!this._finished)return m=this._config.chunkSize,l=m?(g=l.substring(0,m),l.substring(m)):(g=l,""),this._finished=!l,this.parseChunk(g)}}function L(n){b.call(this,n=n||{});var l=[],m=!0,g=!1;this.pause=function(){b.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){b.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(x){this._input=x,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){g&&l.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),l.length?this.parseChunk(l.shift()):m=!0},this._streamData=S(function(x){try{l.push(typeof x=="string"?x:x.toString(this._config.encoding)),m&&(m=!1,this._checkIsFinished(),this.parseChunk(l.shift()))}catch(R){this._streamError(R)}},this),this._streamError=S(function(x){this._streamCleanUp(),this._sendError(x)},this),this._streamEnd=S(function(){this._streamCleanUp(),g=!0,this._streamData("")},this),this._streamCleanUp=S(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function N(n){var l,m,g,x,R=Math.pow(2,53),V=-R,Z=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,se=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,j=this,U=0,O=0,Y=!1,k=!1,F=[],I={data:[],errors:[],meta:{}};function B(T){return n.skipEmptyLines==="greedy"?T.join("").trim()==="":T.length===1&&T[0].length===0}function C(){if(I&&g&&(J("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+h.DefaultDelimiter+"'"),g=!1),n.skipEmptyLines&&(I.data=I.data.filter(function(z){return!B(z)})),G()){let z=function(re,ie){w(n.transformHeader)&&(re=n.transformHeader(re,ie)),F.push(re)};if(I)if(Array.isArray(I.data[0])){for(var T=0;G()&&T<I.data.length;T++)I.data[T].forEach(z);I.data.splice(0,1)}else I.data.forEach(z)}function H(z,re){for(var ie=n.header?{}:[],q=0;q<z.length;q++){var Q=q,K=z[q],K=((ue,W)=>(ee=>(n.dynamicTypingFunction&&n.dynamicTyping[ee]===void 0&&(n.dynamicTyping[ee]=n.dynamicTypingFunction(ee)),(n.dynamicTyping[ee]||n.dynamicTyping)===!0))(ue)?W==="true"||W==="TRUE"||W!=="false"&&W!=="FALSE"&&((ee=>{if(Z.test(ee)&&(ee=parseFloat(ee),V<ee&&ee<R))return 1})(W)?parseFloat(W):se.test(W)?new Date(W):W===""?null:W):W)(Q=n.header?q>=F.length?"__parsed_extra":F[q]:Q,K=n.transform?n.transform(K,Q):K);Q==="__parsed_extra"?(ie[Q]=ie[Q]||[],ie[Q].push(K)):ie[Q]=K}return n.header&&(q>F.length?J("FieldMismatch","TooManyFields","Too many fields: expected "+F.length+" fields but parsed "+q,O+re):q<F.length&&J("FieldMismatch","TooFewFields","Too few fields: expected "+F.length+" fields but parsed "+q,O+re)),ie}var X;I&&(n.header||n.dynamicTyping||n.transform)&&(X=1,!I.data.length||Array.isArray(I.data[0])?(I.data=I.data.map(H),X=I.data.length):I.data=H(I.data,0),n.header&&I.meta&&(I.meta.fields=F),O+=X)}function G(){return n.header&&F.length===0}function J(T,H,X,z){T={type:T,code:H,message:X},z!==void 0&&(T.row=z),I.errors.push(T)}w(n.step)&&(x=n.step,n.step=function(T){I=T,G()?C():(C(),I.data.length!==0&&(U+=T.data.length,n.preview&&U>n.preview?m.abort():(I.data=I.data[0],x(I,j))))}),this.parse=function(T,H,X){var z=n.quoteChar||'"',z=(n.newline||(n.newline=this.guessLineEndings(T,z)),g=!1,n.delimiter?w(n.delimiter)&&(n.delimiter=n.delimiter(T),I.meta.delimiter=n.delimiter):((z=((re,ie,q,Q,K)=>{var ue,W,ee,we;K=K||[","," ","|",";",h.RECORD_SEP,h.UNIT_SEP];for(var ke=0;ke<K.length;ke++){for(var he,Ie=K[ke],oe=0,pe=0,le=0,de=(ee=void 0,new M({comments:Q,delimiter:Ie,newline:ie,preview:10}).parse(re)),ge=0;ge<de.data.length;ge++)q&&B(de.data[ge])?le++:(he=de.data[ge].length,pe+=he,ee===void 0?ee=he:0<he&&(oe+=Math.abs(he-ee),ee=he));0<de.data.length&&(pe/=de.data.length-le),(W===void 0||oe<=W)&&(we===void 0||we<pe)&&1.99<pe&&(W=oe,ue=Ie,we=pe)}return{successful:!!(n.delimiter=ue),bestDelimiter:ue}})(T,n.newline,n.skipEmptyLines,n.comments,n.delimitersToGuess)).successful?n.delimiter=z.bestDelimiter:(g=!0,n.delimiter=h.DefaultDelimiter),I.meta.delimiter=n.delimiter),_(n));return n.preview&&n.header&&z.preview++,l=T,m=new M(z),I=m.parse(l,H,X),C(),Y?{meta:{paused:!0}}:I||{meta:{paused:!1}}},this.paused=function(){return Y},this.pause=function(){Y=!0,m.abort(),l=w(n.chunk)?"":l.substring(m.getCharIndex())},this.resume=function(){j.streamer._halted?(Y=!1,j.streamer.parseChunk(l,!0)):setTimeout(j.resume,3)},this.aborted=function(){return k},this.abort=function(){k=!0,m.abort(),I.meta.aborted=!0,w(n.complete)&&n.complete(I),l=""},this.guessLineEndings=function(re,z){re=re.substring(0,1048576);var z=new RegExp(f(z)+"([^]*?)"+f(z),"gm"),X=(re=re.replace(z,"")).split("\r"),z=re.split(`
|
|
2
2
|
`),re=1<z.length&&z[0].length<X[0].length;if(X.length===1||re)return`
|
|
3
3
|
`;for(var ie=0,q=0;q<X.length;q++)X[q][0]===`
|
|
4
4
|
`&&ie++;return ie>=X.length/2?`\r
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aq as o}from"./index-BkbhBpVC.js";const s=[["path",{d:"M5 12h14",key:"1ays0h"}]],c=o("minus",s);export{c as M};
|