PageSourceSearch

https://www.thedogoodcrew.com/assets/community-A8l0rs8J.js

js thedogoodcrew.com collected 2026-10-09 16:59:10 UTC 257,430 bytes, 8 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e887356f-3787-59f7-8828-5232a6e07c4f")}catch(e){}}();
3import{n as e,s as t,t as n}from"./jsx-runtime-D4ePz0Hl.js";import{t as r}from"./react-BXH-GOAS.js";import{D as i,F as a,I as o,M as s,N as c,P as l,R as u,d,f,k as p,n as m,t as h,u as g}from"./components-CDo3yjgw.js";import{n as _}from"./exports-mk284NM-.js";import{t as v}from"./useTranslation-xRzBcOIb.js";import{n as y}from"./i18next-BaeBzRnv.js";import{t as b}from"./classnames-B9Sa-P4w.js";import{t as x}from"./useDisplayMode-c6ZmgKzQ.js";import{i as S,s as C}from"./buildPostAuthRedirectUrl-BRwdZrHz.js";import{i as w,n as T,r as E,t as D}from"./pwaPromptConfig-AUACWOQD.js";import{n as O,r as k}from"./dist-DaRpaGs2.js";import{t as A}from"./client-only-_T1ty6Rk.js";import{_ as j,a as M,d as N,h as P,i as F,m as ee,n as I,r as L,s as R,u as z,y as te}from"./community-DgikVb5e.js";import{n as ne}from"./CsrfContext-NYUx1YbP.js";import{L as re,V as B,n as ie,z as ae}from"./QueryClientProvider-Cdu2unP4.js";import{t as oe}from"./CheckCircleIcon-DfoKxuek.js";import{t as se}from"./CheckIcon-BMxwwCPQ.js";import{t as V}from"./LockClosedIcon-EgqD9Np-.js";import{t as ce}from"./XMarkIcon-DddZZWBS.js";import{t as le}from"./Button-Bxwxr4Gl.js";import{t as H}from"./useGlobalModals-CJ1k8aJl.js";import{n as U,r as ue}from"./useCommunityMembership-DRaMPU7W.js";import{r as de,t as W}from"./MemberProfileLink-D6J1aiXT.js";import{t as fe}from"./useMutation-sej49wS6.js";import{n as pe,t as me}from"./useShortRelativeDate-Cpl-GDDn.js";import{t as he}from"./usePushNotification-e57ZaPMH.js";import{_ as ge,c as _e,d as ve,f as ye,g as be,h as xe,l as Se,s as Ce,v as we}from"./pushSubscription-vzO9AQ6U.js";import{i as G}from"./nectarPageBlock-Dhr05eLZ.js";import{a as Te,n as Ee,o as De,t as Oe,u as ke}from"./ProfileAvatarPicker-BOILR6sw.js";import{n as Ae,t as je}from"./transition-B4qu-R77.js";import{t as Me}from"./ArrowLeftIcon-BqBVHdLz.js";import{a as Ne,c as Pe,l as Fe,o as Ie,r as Le}from"./useProfilePinFetcher-BZnxsuMM.js";import{t as Re}from"./BellIcon-DYc2waKC.js";import{a as ze,d as Be,i as Ve,n as He,o as Ue,p as We,r as Ge,s as Ke,u as qe}from"./PricingSkeleton-D4J5bUQY.js";import{$ as Je,E as Ye,F as Xe,I as Ze,M as Qe,P as $e,T as et,_ as tt,b as nt,et as rt,g as it,h as at,l as ot,p as st,r as ct,t as lt,u as ut,v as dt,w as ft,x as pt,y as mt}from"./useCommunityPosts-BLx-UntJ.js";import{a as ht,c as gt,i as _t,o as vt,r as yt,s as bt,t as xt}from"./MobileSortSheet-DeolFyh0.js";import{n as St,t as Ct}from"./ActionMenu-BlbvXKr9.js";import{t as wt}from"./EnvelopeIcon-kH9TwEjU.js";import{t as Tt}from"./FaceSmileIcon-CbsBAqOR.js";import{n as Et,r as Dt,t as Ot}from"./communitySearch-DBKoh3Uz.js";import{n as kt,t as At}from"./CommunityDataContext-Cnmwvi8-.js";import{i as jt,r as Mt}from"./tabs-CiZpcPfZ.js";import{t as Nt}from"./UserGroupIcon-p07ZyxVw.js";import{t as Pt}from"./XMarkIcon-DmEhIDFO.js";import{p as Ft}from"./SignupAction-DkTK_L2f.js";import{t as It}from"./cn-Cz4MqTg-.js";import{_ as Lt,a as Rt,b as zt,g as Bt,l as Vt,n as Ht,o as Ut,p as Wt,r as Gt,s as Kt,u as qt}from"./floating-ui.react-SnMdqaDc.js";import{m as Jt,r as Yt}from"./ActionForm-B3lXNPlx.js";import{t as Xt}from"./FooterReferralLink-C-fLmkVJ.js";import{A as Zt,E as Qt,F as $t,M as en,N as tn,O as nn,P as rn,c as an,d as on,f as sn,h as cn,i as ln,j as un,k as dn,l as fn,o as pn,p as mn,s as hn,v as gn}from"./CommunityMemberActionsProvider-nqcY5v0-.js";import{a as _n,c as K,d as vn,f as yn,h as bn,i as xn,l as Sn,m as q,n as Cn,o as wn,p as Tn,r as En,s as Dn,t as On,u as kn}from"./useCommunityData-Cvj5h-x6.js";import{n as An,t as jn}from"./CommunityWebPostEmbedCard-BKez_y4W.js";import{n as Mn,r as Nn}from"./p-retry-DA1h3OVj.js";import{t as Pn}from"./chipValidators-C0vwFTNz.js";import{n as Fn,t as In}from"./useToast-CorSxc9g.js";import{t as Ln}from"./useIsLoggedIn-B87EngYs.js";import{n as Rn,t as zn}from"./BottomSheetDialog-DcPGSOIu.js";import{t as Bn}from"./Typography-BA7CHQQa.js";import{t as Vn}from"./PillButton-DKmaS7V0.js";import{t as Hn}from"./Dialog-CMOTIGCZ.js";import{n as Un,t as Wn}from"./Avatar-BIBwmBTY.js";import{t as Gn}from"./useCommunityLogoUrl-aJXeAVzG.js";import{t as Kn}from"./PillLink-BBFBbnTp.js";import{r as qn}from"./ConfirmDialog-qJ2hzKOi.js";import{t as Jn}from"./Tooltip-IxbCCOij.js";import{i as Yn}from"./communityTheme-D6w6V2g2.js";import{n as Xn,t as Zn}from"./MemberBadge-BxgNn_W9.js";import{t as Qn}from"./subscriptions-V9sGVK1o.js";import{t as $n}from"./useMetaViewContent-CEmVwgKq.js";import{i as er,t as tr}from"./Pricing-B24L10xc.js";import{t as nr}from"./buildStandalonePricingNode-D6Eq8Wq0.js";import{t as rr}from"./useEnablePushNotification-BzyUZ8Er.js";import{t as ir}from"./GlassIconButton-Cc28PGBC.js";import{t as ar}from"./GlassIconLink-DJiNogY5.js";
3import{a as or,i as sr,n as cr,r as lr,t as ur}from"./OnboardQuestionsPage-C_LeJpt3.js";import{n as dr,r as fr,t as pr}from"./useSpacePurchasableTiers-Cg-PeQ7d.js";import{t as mr}from"./useNectarImpression-D_F7IBi0.js";import{t as hr}from"./SkeletonBlock-Bbr4RITD.js";import{t as gr}from"./PostCardSkeleton-gW0ZC8Lo.js";import{t as _r}from"./useCommunityJoinGate-Pv84W5-d.js";import{t as vr}from"./useDebouncedCallback-B_NpnNGr.js";import{t as yr}from"./SkeletonRow-D0kuMNfb.js";import{t as br}from"./useCanMessageMember-r2E0cL4d.js";import{t as xr}from"./LabeledTextInput-DEgRELOt.js";import{t as Sr}from"./useDirectoryName-Ce5mSDYS.js";import{n as Cr}from"./useSpaceMembershipFetcher-qeMIMj9v.js";import{t as wr}from"./shouldRevalidateCommunityRoute-CpCyQi-c.js";var J=t(r());function Tr({title:e,titleId:t,...n},r){return J.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?J.createElement(`title`,{id:t},e):null,J.createElement(`path`,{fillRule:`evenodd`,d:`M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z`,clipRule:`evenodd`}))}var Er=J.forwardRef(Tr);function Dr({title:e,titleId:t,...n},r){return J.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?J.createElement(`title`,{id:t},e):null,J.createElement(`path`,{d:`M18 1.5c2.9 0 5.25 2.35 5.25 5.25v3.75a.75.75 0 0 1-1.5 0V6.75a3.75 3.75 0 1 0-7.5 0v3a3 3 0 0 1 3 3v6.75a3 3 0 0 1-3 3H3.75a3 3 0 0 1-3-3v-6.75a3 3 0 0 1 3-3h9v-3c0-2.9 2.35-5.25 5.25-5.25Z`}))}var Or=J.forwardRef(Dr);function kr({title:e,titleId:t,...n},r){return J.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?J.createElement(`title`,{id:t},e):null,J.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m4.5 19.5 15-15m0 0H8.25m11.25 0v11.25`}))}var Ar=J.forwardRef(kr);function jr({title:e,titleId:t,...n},r){return J.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?J.createElement(`title`,{id:t},e):null,J.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5`}))}var Mr=J.forwardRef(jr);function Nr({title:e,titleId:t,...n},r){return J.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?J.createElement(`title`,{id:t},e):null,J.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M20.25 8.511c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193-.34.027-.68.052-1.02.072v3.091l-3-3c-1.354 0-2.694-.055-4.02-.163a2.115 2.115 0 0 1-.825-.242m9.345-8.334a2.126 2.126 0 0 0-.476-.095 48.64 48.64 0 0 0-8.048 0c-1.131.094-1.976 1.057-1.976 2.192v4.286c0 .837.46 1.58 1.155 1.951m9.345-8.334V6.637c0-1.621-1.152-3.026-2.76-3.235A48.455 48.455 0 0 0 11.25 3c-2.115 0-4.198.137-6.24.402-1.608.209-2.76 1.614-2.76 3.235v6.226c0 1.621 1.152 3.026 2.76 3.235.577.075 1.157.14 1.74.194V21l4.155-4.155`}))}var Pr=J.forwardRef(Nr);function Fr({title:e,titleId:t,...n},r){return J.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?J.createElement(`title`,{id:t},e):null,J.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0 1 12 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 0 1 3 12c0-1.605.42-3.113 1.157-4.418`}))}var Ir=J.forwardRef(Fr);function Lr({title:e,titleId:t,...n},r){return J.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?J.createElement(`title`,{id:t},e):null,J.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m2.25 12 8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25`}))}var Rr=J.forwardRef(Lr);function zr({title:e,titleId:t,...n},r){return J.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?J.createElement(`title`,{id:t},e):null,J.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244`}))}var Br=J.forwardRef(zr);function Vr({title:e,titleId:t,...n},r){return J.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?J.createElement(`title`,{id:t},e):null,J.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m15.75 10.5 4.72-4.72a.75.75 0 0 1 1.28.53v11.38a.75.75 0 0 1-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 0 0 2.25-2.25v-9a2.25 2.25 0 0 0-2.25-2.25h-9A2.25 2.25 0 0 0 2.25 7.5v9a2.25 2.25 0 0 0 2.25 2.25Z`}))}var Hr=J.forwardRef(Vr),Ur=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M71.68,97.22,34.74,128l36.94,30.78a12,12,0,1,1-15.36,18.44l-48-40a12,12,0,0,1,0-18.44l48-40A12,12,0,0,1,71.68,97.22Zm176,21.56-48-40a12,12,0,1,0-15.36,18.44L221.26,128l-36.94,30.78a12,12,0,1,0,15.36,18.44l48-40a12,12,0,0,0,0-18.44ZM164.1,28.72a12,12,0,0,0-15.38,7.18l-64,176a12,12,0,0,0,7.18,15.37A11.79,11.79,0,0,0,96,228a12,12,0,0,0,11.28-7.9l64-176A12,12,0,0,0,164.1,28.72Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M240,128l-48,40H64L16,
3128,64,88H192Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM92.8,145.6a8,8,0,1,1-9.6,12.8l-32-24a8,8,0,0,1,0-12.8l32-24a8,8,0,0,1,9.6,12.8L69.33,128Zm58.89-71.4-32,112a8,8,0,1,1-15.38-4.4l32-112a8,8,0,0,1,15.38,4.4Zm53.11,60.2-32,24a8,8,0,0,1-9.6-12.8L186.67,128,163.2,110.4a8,8,0,1,1,9.6-12.8l32,24a8,8,0,0,1,0,12.8Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M67.84,92.61,25.37,128l42.47,35.39a6,6,0,1,1-7.68,9.22l-48-40a6,6,0,0,1,0-9.22l48-40a6,6,0,0,1,7.68,9.22Zm176,30.78-48-40a6,6,0,1,0-7.68,9.22L230.63,128l-42.47,35.39a6,6,0,1,0,7.68,9.22l48-40a6,6,0,0,0,0-9.22Zm-81.79-89A6,6,0,0,0,154.36,38l-64,176A6,6,0,0,0,94,221.64a6.15,6.15,0,0,0,2,.36,6,6,0,0,0,5.64-3.95l64-176A6,6,0,0,0,162.05,34.36Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M66.56,91.07,22.25,128l44.31,36.93A4,4,0,0,1,64,172a3.94,3.94,0,0,1-2.56-.93l-48-40a4,4,0,0,1,0-6.14l48-40a4,4,0,0,1,5.12,6.14Zm176,33.86-48-40a4,4,0,1,0-5.12,6.14L233.75,128l-44.31,36.93a4,4,0,1,0,5.12,6.14l48-40a4,4,0,0,0,0-6.14ZM161.37,36.24a4,4,0,0,0-5.13,2.39l-64,176a4,4,0,0,0,2.39,5.13A4.12,4.12,0,0,0,96,220a4,4,0,0,0,3.76-2.63l64-176A4,4,0,0,0,161.37,36.24Z`}))]]),Wr=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H185.86A41.48,41.48,0,0,1,196,168c0,14.45-7.81,28.32-21.43,38.05C162,215.05,145.44,220,128,220s-34-4.95-46.57-13.95C67.81,196.32,60,182.45,60,168a12,12,0,0,1,24,0c0,15.18,20.15,28,44,28s44-12.82,44-28c0-12.76-9.3-20.18-35.35-28H40a12,12,0,0,1,0-24H216A12,12,0,0,1,228,128ZM75.11,100a12,12,0,0,0,12-12c0-16,17.58-28,40.89-28,17.36,0,31.37,6.65,37.48,17.78a12,12,0,0,0,21-11.56C176.13,47.3,154.25,36,128,36,91,36,63.11,58.35,63.11,88A12,12,0,0,0,75.11,100Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M176,72l-55.31,51.05c-24-6.7-45.58-14.26-45.58-35,0-22.09,22-40,52.89-40C151.2,48,168.37,57.64,176,72Zm-55.31,51.05L72,168c0,22.09,25.07,40,56,40s56-17.91,56-40C184,138.43,150.52,131.4,120.69,123.05Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H175.93c9.19,7.11,16.07,17.2,16.07,32,0,13.34-7,25.7-19.75,34.79C160.33,211.31,144.61,216,128,216s-32.33-4.69-44.25-13.21C71,193.7,64,181.34,64,168a8,8,0,0,1,16,0c0,17.35,22,32,48,32s48-14.65,48-32c0-14.85-10.54-23.58-38.77-32H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM76.33,104a8,8,0,0,0,7.61-10.49A17.3,17.3,0,0,1,83.11,88c0-18.24,19.3-32,44.89-32,18.84,0,34.16,7.42,41,19.85a8,8,0,0,0,14-7.7C173.33,50.52,152.77,40,128,40,93.29,40,67.11,60.63,67.11,88a33.73,33.73,0,0,0,1.62,10.49A8,8,0,0,0,76.33,104Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM82.71,94.58C86,76.57,104.58,64,128,64c18.2,0,33.59,7.41,41.18,19.83a8,8,0,1,1-13.66,8.34C150.94,84.66,140.39,80,128,80c-15.3,0-27.73,7.33-29.55,17.42A8,8,0,0,1,90.59,104a7.76,7.76,0,0,1-1.43-.13A8,8,0,0,1,82.71,94.58ZM192,136H168.29A28.45,28.45,0,0,1,176,156c0,20.19-21.08,36-48,36-23.89,0-43.83-12.78-47.43-30.4a8,8,0,1,1,15.67-3.2c2,9.87,16,17.6,31.76,17.6,17.35,0,32-9.16,32-20,0-9.14-6.76-14.43-25.72-20H64a8,8,0,0,1,0-16H192a8,8,0,0,1,0,16Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H169.45c11.28,6.92,20.55,17.38,20.55,34,0,25.36-27.81,46-62,46s-62-20.64-62-46a6,6,0,0,1,12,0c0,18.75,22.43,34,50,34s50-15.25,50-34c0-18.23-15.46-26.59-40.47-34H40a6,6,0,0,1,0-12H216A6,6,0,0,1,222,128ZM76.33,102a6.2,6.2,0,0,0,1.88-.3A6,6,0,0,0,82,94.13,19.74,19.74,0,0,1,81.11,88c0-19.38,20.16-34,46.89-34,19.58,0,35.56,7.81,42.74,20.89a6,6,0,0,0,10.52-5.78C171.94,52.13,152,42,128,42,94.43,42,69.11,61.77,69.11,88a31.62,31.62,0,0,0,1.52,9.87A6,6,0,0,0,76.33,102Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H175.93c9.19,7.11,16.07,17.2,16.07,32,0,13.34-7,25.7-19.75,34.79C160.33,211.31,144.61,216,128,216s-32.33-4.69-44.25-13.21C71,193.7,64,181.34,64,168a8,8,0,0,1,16,0c0,17.35,22,32,48,32s48-14.65,48-32c0-14.85-10.54-23.58-38.77-32H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM76.33,104a8,8,0,0,0,7.61-10.49A17.3,17.3,0,0,1,83.11,88c0-18.24,19.3-32,44.89-32,18.84,0,34.16,7.42,41,19.85a8,8,0,0,0,14-7.7C173.33,50.52,152.77,40,128,40,93.29,40,67.11,60.63,67.11,88a33.73,33.73,0,0,0,1.62,10.49A8,8,0,0,0,76.33,104Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H161.16c15.45,7.24,26.84,17.8,26.84,36,0,24.26-26.92,44-60,44s-60-19.74-60-44a4,4,0,0,1,8,0c0,19.85,23.33,36,52,36s52-16.15,52-36c0-19.54-16.13-28.3-42.18-36H40a4,4,0,0,1,0-8H216A4,4,0,0,1,220,128ZM76.33,100a3.85,3.85,0,0,0,1.25-.2,4,4,0,0,0,2.55-5,21.9,21.9,0,0,1-1-6.75c0-20.52,21-36,48.89-36,20.32,0,37,8.2,44.49,21.92a4,4,0,0,0,7-3.85C170.54,53.75,151.29,44,128,44,95.57,44,71.11,62.92,71.11,88a29.76,29.76,0,0,0,1.42,9.25A4,4,0,0,0,76.33,100Z`}))]]),Gr=J.forwardRef((e,t)=>
3J.createElement(Jt,{ref:t,...e,weights:Ur}));Gr.displayName=`CodeIcon`;var Kr=Gr,qr=J.forwardRef((e,t)=>J.createElement(Jt,{ref:t,...e,weights:Wr}));qr.displayName=`TextStrikethroughIcon`;var Jr=qr,Yr=e=>{if(!e||typeof e!=`object`)return null;let t=e;return t.type===`status`&&typeof t.status==`string`&&typeof t.revision==`number`?{type:`status`,status:t.status,revision:t.revision}:t.type===`thumbnails`?{type:`thumbnails`}:null},Xr=e=>({selectedUrl:e.thumbnail_url??null,selectedIndex:e.thumbnail_candidate_index??null,candidates:e.thumbnail_candidates?.map(({index:e,url:t,preview_url:n})=>({index:e,url:t,previewUrl:n}))??null}),Y=t(b(),1),X=t(n(),1),Zr=(e,t)=>e.kind===`feed`?q(t,`community.composer.destination_feed`):e.space.name,Qr=({hint:e})=>{let[t,n]=(0,J.useState)(!1),r=Kt({open:t,onOpenChange:n,placement:`top-end`,middleware:[Bt(6),Wt(),Lt({padding:8})]}),i=qt([Vt(r.context),Ut(r.context)]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{ref:r.refs.setReference,className:`ml-auto inline-flex shrink-0 cursor-help text-black/40`,...i.getReferenceProps(),children:[(0,X.jsx)(Je,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`sr-only`,children:e})]}),t&&(0,X.jsx)(Gt,{children:(0,X.jsx)(`div`,{ref:r.refs.setFloating,style:r.floatingStyles,className:`z-[110] max-w-[240px] rounded bg-black px-2 py-1 text-xs text-white`,...i.getFloatingProps(),children:e})})]})},$r=({destinations:e,selected:t,onChange:n,translations:r,disabled:i=!1})=>{let[a,o]=(0,J.useState)(!1),s=nt(t),c=Zr(t,r),l=q(r,`community.action_menu.move_post_read_only_hint`),u=Kt({open:a,onOpenChange:o,placement:`bottom-start`,middleware:[Bt(4),Wt(),Lt({padding:8})],whileElementsMounted:zt}),d=qt([Rt(u.context),Ut(u.context)]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{ref:i?void 0:u.refs.setReference,type:`button`,disabled:i,className:(0,Y.default)(`flex items-center gap-2 h-8 px-3 rounded-full border border-black/10 text-[13px] font-medium leading-4 tracking-[-0.13px] text-black transition-colors disabled:cursor-not-allowed disabled:opacity-50`,{"hover:bg-black/5":!i}),...i?{}:d.getReferenceProps(),"aria-label":q(r,`community.composer.choose_destination`),"aria-expanded":i?void 0:a,children:[(0,X.jsx)(`span`,{className:`truncate max-w-[200px]`,children:c}),t.kind===`channel`&&t.space.tier_gated&&(0,X.jsx)(Or,{className:`size-3.5 shrink-0 text-black/40`,"aria-hidden":`true`}),(0,X.jsx)(Er,{className:`size-4 text-black/50`,"aria-hidden":`true`})]}),a&&!i&&(0,X.jsx)(Gt,{children:(0,X.jsx)(Ht,{context:u.context,modal:!1,children:(0,X.jsx)(`div`,{ref:u.refs.setFloating,style:u.floatingStyles,className:(0,Y.default)(`rounded-3xl bg-white border border-black/5 shadow-[0_4px_6px_rgba(0,0,0,0.08)]`,`z-[100] max-h-60 w-56 overflow-auto rounded-2xl py-1 text-sm focus:outline-none`),...d.getFloatingProps(),children:e.map(e=>{let t=nt(e),i=t===s,a=Zr(e,r),c=e.kind===`channel`&&e.space.disabled===!0;return(0,X.jsxs)(`div`,{className:`flex items-center pr-3`,children:[(0,X.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>{n(e),o(!1)},className:(0,Y.default)(`flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left select-none disabled:cursor-not-allowed disabled:text-black/40`,c?`cursor-not-allowed text-black/40`:`cursor-default text-black hover:bg-black/5`,{"font-medium":i}),children:[i?(0,X.jsx)(se,{className:`size-4 shrink-0`,"aria-hidden":`true`}):(0,X.jsx)(`span`,{className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:a}),!c&&e.kind===`channel`&&e.space.tier_gated&&(0,X.jsx)(Or,{className:`size-3.5 shrink-0 text-black/40`,"aria-hidden":`true`})]}),c&&(0,X.jsx)(Qr,{hint:l})]},t)})})})})]})},ei=({destinations:e,selectedDestination:t,onDestinationChange:n,destinationMode:r,author:i,onClose:a,translations:o})=>(0,X.jsxs)(`div`,{className:`flex h-14 items-center justify-between border-b border-black/10 pl-3 pr-2 py-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i&&(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[i.avatarUrl?(0,X.jsx)(`img`,{src:i.avatarUrl,alt:``,className:`size-8 shrink-0 rounded-full object-cover`}):(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-black/10 text-xs font-medium text-black`,"aria-hidden":`true`,children:i.name.slice(0,1)}),(0,X.jsx)(`span`,{className:`max-w-[140px] truncate text-[13px] font-medium leading-4 text-black`,children:i.name})]}),r!==`hidden`&&(0,X.jsx)($r,{destinations:e,selected:t,onChange:n,translations:o,disabled:r===`locked`})]}),(0,X.jsx)(`button`,{type:`button`,className:`flex items-center p-2 hover:bg-black/5 rounded-full transition-colors`,onClick:a,"aria-label":q(o,`community.composer.close`),children:(0,X.jsx)(Pt,{className:`size-6 text-black/50`})})]}),ti=(0,J.forwardRef)(({maxRows:e,singleLine:t,onSubmitShortcut:n,onKeyDown:r,onPaste:i,className:a,value:o,...s},c)=>{let l=(0,J.useRef)(null);return(0,J.useImperativeHandle)(c,()=>l.current),ni(l,o,e),(0,X.jsx)(`textarea`,{ref:l,rows:1,value:o,onKeyDown:e=>{!e.nativeEvent.isComposing&&e.key===`Enter`&&((e.metaKey||e.ctrlKey)&&n?(e.preventDefault(),n()):t&&e.preventDefault()),r?.(e)},onPaste:e=>{if(t){let t=e.clipboardData.getData(`text`);/[\r\n]/.test(t)&&(e.preventDefault(),document.execCommand(`insertText`,!1,t.replace(/[\r\n]+/g,` `)))}i?.(e)},className:It(`resize-none overflow-hidden`,a),...s})});ti.displayName=`AutoGrowTextarea`;var ni=(e,t,n)=>{(0,J.useEffect)(()=>{let t=e.current;if(!t)return;t.style.height=`auto`;let r=ri(t,n),i=r?Math.min(t.scrollHeight,r):t.scrollHeight;t.style.height=`${i}px`,t.style.overflowY=r&&t.scrollHeight>r?`auto`:`hidden`},[e,t,n])},ri=(e,t)=>{if(!t)return;let{lineHeight:n,fontSize:r}=getComputedStyle(e);return(Number.parseFloat(n)||Number.parseFloat(r)*1.2)*t},ii=({tr:e,dispatch:t,editor:n})=>{if(!t)return!0;let r=e.selection.to;return e.doc.resolve(r).parent.isTextblock?!0:(e.doc.nodeAt(r)?.isTextblock||e.insert(r,n.schema.nodes.paragraph.create()),e.setSelection(rn.create(e.doc,r+1)),!0)},ai=[`previewOnly`,`previewAndUrl`,`urlOnly`],Z=new tn(`linkPrompt`),oi=(e,t)=>{let n=e.doc.textBetween(t.to,Math.min(t.to+1,e.doc.content.size));return{from:t.from,to:n===` `?t.to+1:t.to}},si=(e,t,n)=>{let r=n,i=e.doc.nodeAt(r);for(;t&&i?.type===t;)r+=i.nodeSize,i=e.doc.nodeAt(r);return r},ci=({tr:e})=>(pn(e),!0),li=(e,t,n)=>e.chain().command(ci).insertContentAt(oi(e.state,t),n).command(ii).run(),ui=({state:e,tr:t,dispatch:n},r,i)=>{if(n){if(i){pn(t);let n=si(t,e.schema.nodes.linkCard,e.doc.resolve(r.from).after(1));t.insert(n,i)}t.setMeta(Z,null)}return!0},di=cn.create({name:`linkPrompt`,addCommands(){return{dismissLinkPrompt:()=>({tr:e,dispatch:t})=>
3(t&&e.setMeta(Z,null),!0),setLinkPromptActive:e=>({state:t,tr:n,dispatch:r})=>{let i=Z.getState(t);return i?(r&&i.active!==e&&n.setMeta(Z,{...i,active:e}),!0):!1}}},addKeyboardShortcuts(){let e=e=>()=>{let t=Z.getState(this.editor.state);if(!t)return!1;let n=ai[(ai.indexOf(t.active)+e+ai.length)%ai.length];return this.editor.commands.setLinkPromptActive(n)};return{Escape:()=>Z.getState(this.editor.state)?this.editor.commands.dismissLinkPrompt():!1,Tab:e(1),"Shift-Tab":e(-1),ArrowLeft:e(-1),ArrowRight:e(1),Enter:()=>{let e=Z.getState(this.editor.state);return e?e.active===`urlOnly`?this.editor.commands.dismissLinkPrompt():e.active===`previewAndUrl`?e.kind===`embed`?this.editor.commands.appendLinkPromptEmbed():this.editor.commands.appendLinkPromptPreview():e.kind===`embed`?this.editor.commands.convertLinkPromptToEmbed():this.editor.commands.showLinkPromptPreview():!1}}},addProseMirrorPlugins(){return[new en({key:Z,state:{init:()=>null,apply:(e,t)=>{let n=e.getMeta(Z);if(n!==void 0)return n;if(e.selectionSet)return null;if(!e.docChanged)return t;if(!t||e.doc.textContent!==e.before.textContent)return null;let r=e.mapping.map(t.from),i=e.mapping.map(t.to,-1);return r>=i?null:{...t,from:r,to:i}}}})]}}),fi=({editor:e,translations:t})=>{let n=sn({editor:e,selector:({editor:e})=>Z.getState(e.state)??null}),r=Kt({open:!!n,onOpenChange:t=>{t||e.commands.dismissLinkPrompt()},placement:`bottom-start`,middleware:[Bt(6),Wt(),Lt({padding:8})],whileElementsMounted:zt}),i=qt([Ut(r.context,{escapeKey:!1})]),a=n?.from,o=n?.to;(0,J.useEffect)(()=>{a===void 0||o===void 0||r.refs.setPositionReference({getBoundingClientRect:()=>{if(e.isDestroyed||o>e.state.doc.content.size)return{x:0,y:0,width:0,height:0,top:0,bottom:0,left:0,right:0};let t=e.view.coordsAtPos(a),n=e.view.coordsAtPos(o),r=Math.min(t.left,n.left),i=Math.max(t.right,n.right);return{x:r,y:t.top,width:i-r,height:n.bottom-t.top,top:t.top,bottom:n.bottom,left:r,right:i}},contextElement:e.view.dom})},[a,o,e,r.refs]);let s=n?.kind,c=(0,J.useMemo)(()=>[{action:`previewOnly`,label:`community.composer.embed_prompt_preview`,pick:()=>{let t=e.chain().focus();(s===`embed`?t.convertLinkPromptToEmbed():t.showLinkPromptPreview()).run()}},{action:`previewAndUrl`,label:`community.composer.embed_prompt_both`,pick:()=>{let t=e.chain().focus();(s===`embed`?t.appendLinkPromptEmbed():t.appendLinkPromptPreview()).run()}},{action:`urlOnly`,label:`community.composer.embed_prompt_keep_link`,pick:()=>e.chain().focus().dismissLinkPrompt().run()}],[e,s]);if(!n)return null;let l=c.findIndex(({action:e})=>e===n.active),u=c[l],d=t=>{e.commands.setLinkPromptActive(t)};return(0,X.jsx)(Gt,{children:(0,X.jsxs)(`div`,{ref:r.refs.setFloating,style:{...r.floatingStyles,visibility:r.isPositioned?`visible`:`hidden`},className:(0,Y.default)(Sn,`flex flex-col gap-1 p-1 z-[100]`),...i.getFloatingProps(),children:[(0,X.jsxs)(`span`,{role:`status`,className:`px-3 pt-1 text-[11px] font-medium text-black/40`,children:[q(t,`community.composer.embed_prompt_paste_as`),(0,X.jsxs)(`span`,{className:`sr-only`,children:[` `,q(t,u.label)]})]}),(0,X.jsxs)(`div`,{className:`relative grid min-w-[200px] grid-cols-1 gap-1 sm:min-w-0 sm:grid-cols-3 sm:gap-0`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-y-0 left-0 hidden w-1/3 rounded-full bg-black transition-transform duration-200 ease-out sm:block`,style:{transform:`translateX(${l*100}%)`}}),c.map(({action:e,label:r,pick:i})=>(0,X.jsx)(`button`,{type:`button`,onClick:i,onMouseEnter:()=>d(e),"aria-current":n.active===e||void 0,className:(0,Y.default)(`relative z-10 inline-flex h-8 items-center justify-center rounded-full px-4 text-[13px] font-medium transition-colors duration-200`,{"bg-black text-white sm:bg-transparent":n.active===e,"text-black/60":n.active!==e}),children:q(t,r)},e))]})]})})},pi=()=>(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:K,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M170.48,115.7A44,44,0,0,0,140,40H72a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8h80a48,48,0,0,0,18.48-92.3ZM80,56h60a28,28,0,0,1,0,56H80Zm72,136H80V128h72a32,32,0,0,1,0,64Z`})}),mi=()=>(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:K,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M200,56a8,8,0,0,1-8,8H157.77l-32.41,128H160a8,8,0,0,1,0,16H64a8,8,0,0,1,0-16H98.23l32.41-128H96a8,8,0,0,1,0-16h96A8,8,0,0,1,200,56Z`})}),hi=()=>(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:K,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M80,64V120a48,48,0,0,0,96,0V64a8,8,0,0,1,16,0v56a64,64,0,0,1-128,0V64a8,8,0,0,1,16,0ZM208,216H48a8,8,0,0,0,0,16H208a8,8,0,0,0,0-16Z`})}),gi=()=>(0,X.jsx)(Jr,{className:K,"aria-hidden":`true`}),_i=()=>(0,X.jsx)(Kr,{className:K,"aria-hidden":`true`}),vi=()=>(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:K,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M208,56V88a8,8,0,0,1-16,0V64H136V192h24a8,8,0,0,1,0,16H96a8,8,0,0,1,0-16h24V64H64V88a8,8,0,0,1-16,0V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z`})}),yi=({icon:e,label:t,onClick:n,active:r,disabled:i,buttonRef:a,buttonProps:o})=>(0,X.jsx)(Xe,{children:(0,X.jsxs)(Qe,{children:[(0,X.jsx)(Ze,{asChild:!0,children:(0,X.jsx)(`button`,{ref:a,type:`button`,disabled:i,onClick:n,"aria-label":t,"aria-pressed":r,className:(0,Y.default)(`flex items-center h-8 px-2 py-1 rounded-full transition-colors`,{"opacity-50 cursor-not-allowed":i,"hover:bg-black/5":!i&&!r,"bg-black/10":!i&&r}),...o,children:e})}),(0,X.jsx)($e,{sideOffset:4,style:{zIndex:100},children:(0,X.jsx)(`div`,{className:`p-1 rounded-md border text-xs font-medium bg-black text-white leading-none`,children:t})})]})}),bi=[{name:`bold`,labelKey:`community.composer.format_bold`,Icon:pi},{name:`italic`,labelKey:`community.composer.format_italic`,Icon:mi},{name:`underline`,labelKey:`community.composer.format_underline`,Icon:hi},{name:`strike`,labelKey:`community.composer.format_strike`,Icon:gi},{name:`code`,labelKey:`community.composer.format_code`,Icon:_i}],xi=e=>{e.preventDefault()},Si=({editor:e,translations:t})=>{let n=sn({editor:e,selector:({editor:e})=>({bold:e.isActive(`bold`),italic:e.isActive(`italic`),underline:e.isActive(`underline`),strike:e.isActive(`strike`),code:e.isActive(`code`)}
3)});return(0,X.jsx)(`div`,{role:`toolbar`,"aria-label":q(t,`community.composer.format_text`),className:`flex items-center gap-2`,children:bi.map(({name:r,labelKey:i,Icon:a})=>(0,X.jsx)(yi,{label:q(t,i),icon:(0,X.jsx)(a,{}),onClick:()=>e.chain().focus().toggleMark(r).run(),active:n[r],buttonProps:{onMouseDown:xi}},r))})},Ci=(e,t)=>e instanceof Node&&!!t?.contains(e),wi=(e,t,n)=>{let r=null,i=null;return e.nodesBetween(t,n,(e,a)=>{if(!e.isText||e.text===void 0)return;let o=Math.max(t,a),s=Math.min(n,a+e.nodeSize);o>=s||(r===null&&(r=o),i=s)}),r===null||i===null?{from:t,to:n}:{from:r,to:i}},Ti=({editor:e,translations:t})=>{let n=sn({editor:e,selector:({editor:e})=>{let{doc:t,selection:n}=e.state,{from:r,to:i}=n;return{from:r,to:i,qualifies:e.isEditable&&(Qt(n)||n instanceof un)&&!n.empty&&t.textBetween(r,i,` `).trim().length>0&&!Z.getState(e.state)}}}),[r,i]=(0,J.useState)(()=>e.view.hasFocus()),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(!1),u=(0,J.useRef)(null),{from:d,to:f,qualifies:p}=n,m=p&&!s&&(r||a),h=Kt({open:m,onOpenChange:(e,t,n)=>{if(!e){if(n===`escape-key`){c(!0);return}n===`outside-press`&&(i(!1),o(!1))}},placement:`top`,middleware:[Bt(8),Wt(),Lt({padding:8})],whileElementsMounted:zt}),g=qt([Ut(h.context,{ancestorScroll:!1,outsidePressEvent:`mousedown`,outsidePress:t=>!Ci(t.target,e.view.dom)})]);(0,J.useEffect)(()=>{c(!1)},[d,f]),(0,J.useEffect)(()=>{let t=()=>{i(!0),c(!1)},n=t=>{let n=t instanceof FocusEvent?t.relatedTarget:null;if(Ci(n,h.refs.floating.current)){o(!0),i(!1);return}Ci(n,e.view.dom)||n&&i(!1)},r=({event:e})=>n(e),a=()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)},s=()=>{a(),l.current=!0},d=()=>{l.current&&(l.current=!1,a(),u.current=requestAnimationFrame(()=>{u.current=null,e.isDestroyed||i(!0)}))},{dom:f}=e.view;return e.on(`focus`,t),e.on(`blur`,r),f.addEventListener(`focus`,t),f.addEventListener(`blur`,n),f.addEventListener(`mousedown`,s),window.addEventListener(`mouseup`,d),()=>{a(),e.off(`focus`,t),e.off(`blur`,r),f.removeEventListener(`focus`,t),f.removeEventListener(`blur`,n),f.removeEventListener(`mousedown`,s),window.removeEventListener(`mouseup`,d)}},[e,h.refs]),(0,J.useEffect)(()=>{m&&h.refs.setPositionReference({getBoundingClientRect:()=>{if(e.isDestroyed||f>e.state.doc.content.size)return{x:0,y:0,width:0,height:0,top:0,bottom:0,left:0,right:0};let t=wi(e.state.doc,d,f);return Zt(e.view,t.from,t.to)},contextElement:e.view.dom})},[m,d,f,e,h.refs]);let _=()=>{o(!0)},v=t=>{Ci(t.relatedTarget,t.currentTarget)||(o(!1),Ci(t.relatedTarget,e.view.dom)&&i(!0))};return m?(0,X.jsx)(Gt,{children:(0,X.jsx)(`div`,{ref:h.refs.setFloating,style:{...h.floatingStyles,visibility:h.isPositioned?`visible`:`hidden`},className:(0,Y.default)(Sn,`z-[100] p-1`),...g.getFloatingProps({onFocus:_,onBlur:v}),children:(0,X.jsx)(Si,{editor:e,translations:t})})}):null},Ei=`_6xu1qv0`,Di=({editor:e,className:t,minHeight:n})=>(0,X.jsx)(`div`,{className:(0,Y.default)(Ei,`community-post-composer-editor flex flex-1 flex-col`,t),children:(0,X.jsx)(hn,{editor:e,className:`flex flex-1 flex-col text-base leading-6 text-black`,style:{minHeight:n??200}})}),Oi=({editor:e,title:t,onTitleChange:n,onKeyboardSubmit:r,showTitleInput:i,autoFocusTitle:a=!0,titleMaxLength:o,editorMinHeight:s,quotedPost:c,attached:l,onAttachedChange:u,transformImageUrl:d,error:f,translations:p,videoDrop:m})=>{let h=l?.posts??[],g=(0,J.useRef)(null);return(0,J.useEffect)(()=>{!i||!a||queueMicrotask(()=>g.current?.focus())},[i,a]),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col justify-between min-h-0 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 overflow-y-auto`,children:[i&&(0,X.jsx)(ti,{ref:g,maxRows:3,singleLine:!0,onSubmitShortcut:r,value:t,onChange:e=>n(e.target.value),maxLength:o,placeholder:q(p,`community.composer.post_title_placeholder`),className:`w-full shrink-0 p-0 text-[28px] focus:text-[28px] font-semibold leading-8 tracking-[-0.56px] text-black placeholder:text-black/30 outline-none border-none bg-transparent focus:ring-0`}),(0,X.jsxs)(`div`,{className:`relative flex flex-1 flex-col gap-4`,...m?.handlers??{},children:[m?.isActive&&m.overlay,(0,X.jsx)(Di,{editor:e,minHeight:s}),e&&(0,X.jsx)(fi,{editor:e,translations:p}),e&&(0,X.jsx)(Ti,{editor:e,translations:p}),h.map(e=>(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(jn,{post:e,transformImageUrl:d}),u&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>u({...l,posts:h.filter(t=>t.id!==e.id)}),"aria-label":q(p,`community.composer.attached_post_remove`),className:`absolute top-2 right-2 size-7 rounded-full flex items-center justify-center bg-white/90 shadow-sm hover:bg-white transition-colors`,children:(0,X.jsx)(Pt,{className:`size-4`,"aria-hidden":`true`})})]},e.id)),c&&(0,X.jsx)(Pe,{post:c})]})]}),f&&(0,X.jsx)(`div`,{className:`pb-2`,children:(0,X.jsx)(`p`,{className:`text-[13px] leading-4 text-red-500`,children:f})})]})}
3,ki=({value:e,onChange:t,placeholder:n,ariaLabel:r,autoFocus:i})=>(0,X.jsx)(`div`,{className:`p-2 border-b border-black/5`,children:(0,X.jsx)(`input`,{autoFocus:i,value:e,type:`text`,onChange:e=>t(e.target.value),placeholder:n,"aria-label":r,className:`w-full px-3 py-1.5 text-base sm:text-sm rounded-full bg-black/5 outline-none focus:ring-2 focus:ring-black/20`})}),Ai=ft.filter(e=>!!e.emoji&&!e.name.startsWith(`regional_indicator_`)&&e.group?.trim()!==`components`),ji=e=>e?e.split(/\s+/).map(e=>e[0].toUpperCase()+e.slice(1)).join(` `):`Other`,Mi=(()=>{let e=new Map;for(let t of Ai){let n=t.group?.trim()??``,r=e.get(n);r?r.push(t):e.set(n,[t])}return Array.from(e,([e,t])=>({group:ji(e),emojis:t}))})(),Ni=(e,t)=>!!(e.name.toLowerCase().includes(t)||e.shortcodes?.some(e=>e.toLowerCase().includes(t))||e.tags?.some(e=>e.toLowerCase().includes(t))),Pi=({onSelect:e,labels:t,autoFocus:n})=>{let[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(null),s=(0,J.useMemo)(()=>{let e=r.trim().toLowerCase();if(e){let t=Ai.filter(t=>Ni(t,e));return t.length?[{group:`Results`,emojis:t}]:[]}return a?Mi.filter(e=>e.group===a):Mi},[r,a]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ki,{value:r,onChange:i,placeholder:t.searchPlaceholder,ariaLabel:t.searchPlaceholder,autoFocus:n}),!r.trim()&&(0,X.jsx)(`div`,{className:`flex gap-1 px-2 py-1 border-b border-black/5 overflow-x-auto`,children:Mi.map(({group:e,emojis:t})=>{let n=a===e;return(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(n?null:e),className:(0,Y.default)(`flex items-center justify-center size-8 rounded-md text-lg shrink-0`,{"bg-black/10":n,"hover:bg-black/5":!n}),"aria-label":e,title:e,children:t[0]?.emoji??`?`},e)})}),(0,X.jsx)(`div`,{className:`max-h-72 overflow-y-auto p-2`,children:s.length===0?(0,X.jsx)(`p`,{className:`text-sm text-black/50 text-center py-4`,children:t.noResults}):s.map(t=>(0,X.jsx)(`div`,{className:`grid grid-cols-8 gap-1 mb-2 last:mb-0`,children:t.emojis.map(t=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>e(t.emoji),className:`flex items-center justify-center size-8 rounded-md text-lg hover:bg-black/5`,"aria-label":t.name,children:t.emoji},t.name))},t.group))})]})},Fi=({triggerLabel:e,triggerIcon:t,panelClassName:n,disabled:r,open:i,onOpenChange:a,children:o})=>{let[s,c]=(0,J.useState)(!1),l=i??s,u=a??c,d=Kt({open:l,onOpenChange:u,placement:`top-start`,middleware:[Bt(8),Wt(),Lt({padding:8})],whileElementsMounted:zt}),f=qt([Rt(d.context),Ut(d.context)]),p=(0,J.useCallback)(()=>u(!1),[u]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(yi,{label:e,icon:t,active:l,disabled:r,buttonRef:d.refs.setReference,buttonProps:f.getReferenceProps()}),l&&(0,X.jsx)(Gt,{children:(0,X.jsx)(`div`,{ref:d.refs.setFloating,style:d.floatingStyles,className:(0,Y.default)(`rounded-3xl bg-white border border-black/5 shadow-[0_4px_6px_rgba(0,0,0,0.08)]`,`z-[100] flex flex-col`,n),...f.getFloatingProps(),children:o({close:p})})})]})},Ii=({editor:e,translations:t})=>{let n=(0,J.useCallback)((t,n)=>{e.chain().focus().insertContent(t).run(),n()},[e]);return(0,X.jsx)(Fi,{triggerLabel:q(t,`community.composer.add_emoji`),triggerIcon:(0,X.jsx)(Tt,{className:K,"aria-hidden":`true`}),panelClassName:`w-80`,children:({close:e})=>(0,X.jsx)(Pi,{onSelect:t=>n(t,e),labels:{searchPlaceholder:q(t,`community.composer.emoji_search_placeholder`),noResults:q(t,`community.composer.emoji_no_results`)}})})},Li={youtube:Ye},Ri=e=>typeof e==`string`?e:``,zi=({node:e,editor:t,extension:n,updateAttributes:r,deleteNode:i})=>{let{translations:a}=n.options,o=Ri(e.attrs.url),s=Ri(e.attrs.title),c=Ri(e.attrs.description),l=Ri(e.attrs.image),u=Ri(e.attrs.siteName),d=e.attrs.loading===!0,f=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(!d||f.current)return;f.current=!0;let e=n.options.onFetchLinkPreview;if(!e||!o){r({loading:!1});return}let t=!1;return e(o).then(e=>{t||r({title:e?.title??null,description:e?.description??null,image:e?.image??null,siteName:e?.siteName??null,loading:!1})}).catch(()=>{t||r({loading:!1})}),()=>{t=!0,f.current=!1}},[d,o,n,r]);let p=(0,J.useCallback)(()=>{i()},[i]),{hostname:m,faviconSrc:h}=(()=>{try{let e=new URL(o);return{hostname:e.hostname,faviconSrc:`${e.origin}/favicon.ico`}}catch{return{hostname:o,faviconSrc:``}}})();return(0,X.jsx)(an,{as:`div`,className:`community-editor-link-card`,contentEditable:!1,
3children:(0,X.jsxs)(`div`,{className:`relative my-2 flex overflow-hidden rounded-xl border border-black/10 bg-white`,children:[d?(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-3 p-3 text-sm text-black/50`,children:[(0,X.jsx)(`span`,{className:`size-4 animate-spin rounded-full border-2 border-black/20 border-t-black/60`}),(0,X.jsx)(`span`,{children:q(a,`community.composer.link_preview_loading`)})]}):(0,X.jsxs)(X.Fragment,{children:[l&&(0,X.jsx)(`div`,{className:`w-[88px] min-h-[88px] shrink-0 overflow-hidden bg-black/5`,children:(0,X.jsx)(`img`,{src:l,alt:``,className:`size-full object-cover`,draggable:!1,referrerPolicy:`no-referrer`})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center gap-0.5 p-3`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-black/50`,children:[!l&&h&&(0,X.jsx)(`img`,{src:h,alt:``,className:`size-4 shrink-0 rounded-sm`,draggable:!1,referrerPolicy:`no-referrer`,onError:e=>{e.currentTarget.style.display=`none`}}),(0,X.jsx)(`span`,{className:`truncate`,children:u||m})]}),s&&(0,X.jsx)(`span`,{className:`truncate text-sm font-semibold text-black/90`,children:s}),c&&(0,X.jsx)(`span`,{className:`line-clamp-2 text-xs text-black/60`,children:c})]})]}),t.isEditable&&(0,X.jsx)(`button`,{type:`button`,onClick:p,"aria-label":q(a,`community.composer.link_preview_remove`),className:`absolute right-1 top-1 inline-flex size-6 items-center justify-center rounded-full bg-black/70 text-white shadow-sm transition-colors hover:bg-black`,children:(0,X.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M2.5 2.5L9.5 9.5M9.5 2.5L2.5 9.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]})})},Bi=e=>{if(/\s/.test(e))return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}},Vi=e=>{let t=[];for(let n of e.matchAll(/\S+/g))n.index!==void 0&&Bi(n[0])&&t.push({offset:n.index,url:n[0]});return t},Hi=3,Ui=(e,t)=>{let n=0;return e.descendants(e=>{e.type===t&&(n+=1)}),n},Wi=(e,t,n,r,i=!1)=>{let a=!1,o=0;if(e.doc.descendants(e=>{e.type===t&&(o+=1,e.attrs.url===n&&(a=!0))}),a||o>=Hi)return e;let s=t.create({url:n,loading:!0,manual:i});if(i&&r.depth>=1){let t=r.node(1);if(t.type.name===`paragraph`&&t.textContent===``){let t=r.before(1),n=e.insert(t,s);return n.setSelection(rn.create(n.doc,t+s.nodeSize+1))}}return e.insert(si(e,t,r.after(1)),s)},Gi=(e,t,n)=>e.doc.textBetween(t,Math.min(t+1,e.doc.content.size))===` `&&!n.isInSet(e.doc.resolve(t+1).marks()),Ki=(e,t)=>{let n=!1;return e.descendants(e=>{t.isInSet(e.marks)&&(n=!0)}),n},qi=(e,t)=>{let n=new Set;return e.descendants(e=>{for(let r of e.marks)r.type===t&&typeof r.attrs.href==`string`&&n.add(r.attrs.href)}),n},Ji=gn.create({name:`linkCard`,group:`block`,atom:!0,draggable:!1,selectable:!0,addOptions(){return{onFetchLinkPreview:void 0,translations:void 0}},addAttributes(){return{url:{default:null},title:{default:null},description:{default:null},image:{default:null},siteName:{default:null},loading:{default:!1},manual:{default:!1}}},parseHTML(){return[{tag:`div[data-link-card]`}]},renderHTML({HTMLAttributes:e}){return[`div`,nn(e,{"data-link-card":``})]},addNodeView(){return fn(zi)},addCommands(){let e=this.options.onFetchLinkPreview,t=this.type;return{insertLinkCard:(n,r)=>({tr:i,dispatch:a})=>(e&&a&&Wi(i,t,n,i.selection.$from,r?.manual??!1),!0),showLinkPromptPreview:()=>n=>{let{state:r,tr:i,dispatch:a}=n,o=Z.getState(r);if(!o)return!1;if(!e||Ui(r.doc,t)>=Hi)return a&&i.setMeta(Z,null),!0;let s=r.doc.textBetween(o.from,o.to);return li(n,o,{type:t.name,attrs:{url:s,loading:!0,manual:!0}})},appendLinkPromptPreview:()=>n=>{let{state:r}=n,i=Z.getState(r);return i?ui(n,i,e&&Ui(r.doc,t)<Hi?t.create({url:r.doc.textBetween(i.from,i.to),loading:!0,manual:!0}):null):!1}}},addProseMirrorPlugins(){let e=this.options.onFetchLinkPreview,t=this.type;return[new en({appendTransaction:(n,r,i)=>{if(!e||!n.some(e=>e.docChanged))return null;let a=i.schema.marks.link;if(!a)return null;let o=i.tr,s=qi(i.doc,a),c=[];i.doc.forEach((e,n)=>{e.type===t&&e.attrs.manual!==!0&&typeof e.attrs.url==`string`&&!s.has(e.attrs.url)&&c.push({from:n,to:n+e.nodeSize})});for(let e=c.length-1;e>=0;e--)o=o.delete(c[e].from,c[e].to);if(n.some(e=>e.steps.some(e=>e instanceof $t&&e.mark.type===a))){let{$from:e}=i.selection,n=e.depth>=1?e.node(1):null,r=n?.textContent.trim()??``,s=!!Z.getState(i),c=Object.values(Li).some(e=>e.match(r));n&&Bi(r)&&Ki(n,a)&&!s&&!c&&(o=Wi(o,t,r,e))}return o.docChanged?o:null},props:{handlePaste:(n,r)=>{if(!e||!(n.state.selection instanceof rn))return!1;let i=r.clipboardData?.getData(`text/plain`)?.trim();if(!i)return!1;let a=Vi(i);if(a.length===0)return!1;let{state:o}=n,{from:s,to:c}=o.selection,l=o.schema.marks.link,u=o.tr.insertText(i,s,c);if(l)for(let{offset:e,url:t}of a)u=u.addMark(s+e,s+e+t.length,l.create({href:t}));let d=!1;if(Bi(i)&&Z.get(o)){let e={from:s,to:s+i.length,active:`previewOnly`},n=null;for(let[t,r]of Object.entries(Li)){let a=r.match(i);if(a){n={...e,kind:`embed`,service:t,data:a};break}}!n&&Ui(o.doc,t)<Hi&&(n={...e,kind:`preview`}),n&&(u=u.setMeta(Z,n),d=!0)}if(d&&l){let e=s+i.length;
3Gi(u,e,l)||(u=u.insertText(` `,e),u=u.removeMark(e,e+1,l)),u=u.setSelection(rn.create(u.doc,e+1))}if(!d)for(let{url:e}of a)u=Wi(u,t,e,u.selection.$from);return n.dispatch(u),!0}}})]}}),Yi=({editor:e,translations:t})=>{let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(!1),c=Kt({open:n,onOpenChange:t=>{if(r(t),s(!1),t){let t=e.getAttributes(`link`).href;a(typeof t==`string`?t:``)}},placement:`top-start`,middleware:[Bt(8),Wt(),Lt({padding:8})],whileElementsMounted:zt}),l=qt([Rt(c.context),Ut(c.context)]),u=sn({editor:e,selector:({editor:e})=>({isLink:e.isActive(`link`)})}),d=(0,J.useCallback)(t=>{t.preventDefault();let n=i.trim(),a=e.chain().focus();if(!n){a.extendMarkRange(`link`).unsetLink().run(),r(!1);return}let o=/^https?:\/\//i.test(n)?n:`https://${n}`;if(!Bi(o)){s(!0);return}e.state.selection.empty&&!e.isActive(`link`)?a.insertLinkCard(o,{manual:!0}).run():a.extendMarkRange(`link`).setLink({href:o}).insertLinkCard(o).run(),r(!1)},[e,i]),f=(0,J.useCallback)(()=>{e.chain().focus().extendMarkRange(`link`).unsetLink().run(),r(!1)},[e]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(yi,{label:q(t,`community.composer.add_link`),icon:(0,X.jsx)(Br,{className:K,"aria-hidden":`true`}),active:u.isLink||n,buttonRef:c.refs.setReference,buttonProps:l.getReferenceProps()}),n&&(0,X.jsx)(Gt,{children:(0,X.jsxs)(`form`,{ref:c.refs.setFloating,style:c.floatingStyles,onSubmit:d,className:(0,Y.default)(`rounded-3xl bg-white border border-black/5 shadow-[0_4px_6px_rgba(0,0,0,0.08)]`,`flex items-start gap-2 p-2 z-[100]`),...l.getFloatingProps(),children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`input`,{type:`text`,value:i,onChange:e=>{a(e.target.value),s(!1)},placeholder:q(t,`community.composer.link_url_placeholder`),autoFocus:!0,className:`w-64 px-3 py-1.5 text-sm rounded-full bg-black/5 outline-none focus:ring-2 focus:ring-black/20`}),o&&(0,X.jsx)(`p`,{role:`alert`,className:`px-3 text-[13px] leading-4 text-red-500`,children:q(t,`community.composer.link_invalid`)})]}),(0,X.jsx)(`button`,{type:`submit`,className:`inline-flex h-8 items-center justify-center rounded-full px-4 text-[13px] font-medium bg-black text-white hover:bg-black/90`,children:q(t,`community.composer.link_save`)}),u.isLink&&(0,X.jsx)(`button`,{type:`button`,onClick:f,className:`text-sm text-black/60 hover:text-black px-2`,children:q(t,`community.composer.link_remove`)})]})})]})},Xi=({editor:e,translations:t,onSearchGifs:n,onInserted:r,gifSearchLimit:i=24,gifSearchDebounceMs:a=300})=>(0,X.jsx)(_n,{onSearchGifs:n,onSelect:(0,J.useCallback)(t=>{let n=e.state.selection.to;e.chain().focus().insertContentAt(n,{type:`image`,attrs:{src:t.url,alt:t.title??``}}).command(ii).run(),r()},[e,r]),gifSearchLimit:i,gifSearchDebounceMs:a,labels:{searchPlaceholder:q(t,`community.composer.gif_search_placeholder`),loading:q(t,`community.composer.gif_loading`),error:q(t,`community.composer.gif_error`),noResults:q(t,`community.composer.gif_no_results`),poweredBy:q(t,`community.composer.gif_powered_by`)}}),Zi=({editor:e,translations:t,onUploadImage:n,isMediaUploadDisabled:r=!1,onInserted:i,uploadAccept:a=wn,uploadMaxBytes:o=Dn})=>{let[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)([]),d=(0,J.useRef)(null),f=(0,J.useCallback)(async a=>{if(r)return;let s=a.filter(e=>e.size>o),l=a.filter(e=>e.size<=o);if(l.length===0){u(s.map(e=>`${e.name}: ${q(t,`community.composer.upload_file_too_large`)}`));return}c(!0),u([]);try{let r=await Promise.allSettled(l.map(e=>n(e))),a=r.flatMap((e,t)=>{if(e.status!==`fulfilled`||!e.value)return[];let n=l[t];return[{type:`image`,attrs:{src:e.value.url,alt:e.value.alt??n.name,blobKey:e.value.blobKey}}]});if(a.length>0){let t=e.state.selection.to;e.chain().focus().insertContentAt(t,a).command(ii).run()}u([...s.map(e=>`${e.name}: ${q(t,`community.composer.upload_file_too_large`)}`),...r.flatMap((e,n)=>e.status===`rejected`||!e.value?[`${l[n].name}: ${q(t,`community.composer.upload_error`)}`]:[])]),a.length>0&&i()}finally{c(!1),d.current&&(d.current.value=``)}},[e,r,n,o,i,t]);return(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6`,children:[(0,X.jsx)(`input`,{ref:d,type:`file`,accept:a,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files?Array.from(e.target.files):[];t.length>0&&f(t)}}),(0,X.jsx)(`button`,{type:`button`,disabled:s||r,onClick:()=>d.current?.click(),className:(0,Y.default)(`inline-flex h-10 items-center justify-center rounded-full px-5 text-[13px] font-medium leading-4 tracking-[-0.13px] bg-black text-white`,{"opacity-60 cursor-not-allowed":s||r,"hover:bg-black/90":!s&&!r}),children:s?q(t,`community.composer.upload_loading`):q(t,`community.composer.upload_choose_file`)}),(0,X.jsx)(`p`,{className:`text-xs text-black/50 text-center`,children:q(t,`community.composer.upload_hint`)}),l.length>0&&(0,X.jsx)(`ul`,{className:`w-full text-sm text-red-500`,children:l.map(e=>(0,X.jsx)(`li`,{className:`text-left break-words`,children:e},e))})]})},Qi=({editor:e,translations:t,onUploadImage:n,isMediaUploadDisabled:r,uploadAccept:i,uploadMaxBytes:a,onSearchGifs:o,gifSearchLimit:s,gifSearchDebounceMs:c})=>{let l=!!o,u=!!n,[d,f]=(0,J.useState)(l?`gif`:`upload`),p=(0,J.useId)(),m=`${p}-tab-gif`,h=`${p}-tab-upload`,g=`${p}-panel-gif`,_=`${p}-panel-upload`,v=l&&u,y=(0,J.useRef)(null),b=(0,J.useRef)(null),x=(0,J.useCallback)(e=>{f(e),(e===`gif`?y:b).current?.focus()},[]),S=(0,J.useCallback)(e=>{switch(e.key){case`ArrowRight`:case`ArrowLeft`:e.preventDefault(),x(d===`gif`?`upload`:`gif`);break;case`Home`:e.preventDefault(),x(`gif`);break;case`End`:e.preventDefault(),x(`upload`);break}},[x,d]);return!l&&!u?null:(0,X.jsx)(Fi,{triggerLabel:q(t,`community.composer.add_media`),triggerIcon:(0,X.jsx)(kt,{className:K,"aria-hidden":`true`}),panelClassName:`w-80`,children:({close:l})=>(0,X.jsxs)(X.Fragment,{children:[v&&(0,X.jsxs)(`div`,{className:`flex gap-1 p-2 border-b border-black/5`,role:`tablist`,"aria-label":q(t,`community.composer.media_panel.tabs`),children:[(0,X.jsx)(`button`,{ref:y,type:`button`,role:`tab`,id:m,"aria-selected":d===`gif`,"aria-controls":g,tabIndex:d===`gif`?0:-1,onClick:()=>f(`gif`),onKeyDown:S,className:(0,Y.default)(`px-3 py-1 text-sm rounded-full`,{"bg-black/10 font-medium":d===`gif`,"hover:bg-black/5":d!==`gif`}),children:q(t,`community.composer.media_tab_gif`)}),(0,X.jsx)(`button`,{ref:b,type:`button`,role:`tab`,id:h,"aria-selected":d===`upload`,"aria-controls":_,tabIndex:d===`upload`?0:-1,onClick:()=>f(`upload`),onKeyDown:S,className:(0,Y.default)(`px-3 py-1 text-sm rounded-full`,{"bg-black/10 font-medium":d===`upload`,"hover:bg-black/5":d!==`upload`}),children:q(t,`community.composer.media_tab_upload`)})]}),d===`gif`&&o&&(v?(0,X.jsx)(`div`,{role:`tabpanel`,id:g,"aria-labelledby":m,children:(0,X.jsx)(Xi,{editor:e,translations:t,onSearchGifs:o,onInserted:l,gifSearchLimit:s,gifSearchDebounceMs:c})}):(0,X.jsx)(Xi,{editor:e,translations:t,onSearchGifs:o,onInserted:l,gifSearchLimit:s,gifSearchDebounceMs:c})),d===`upload`&&n&&(v?(0,X.jsx)(`div`,{role:`tabpanel`,id:_,"aria-labelledby":h,children:(0,X.jsx)(Zi,{editor:e,translations:t,onUploadImage:n,isMediaUploadDisabled:r,onInserted:l,uploadAccept:i,uploadMaxBytes:a})}):(0,X.jsx)(Zi,{editor:e,translations:t,onUploadImage:n,isMediaUploadDisabled:r,onInserted:l,uploadAccept:i,uploadMaxBytes:a}))]})})},$i=({translations:e,posts:t,onPostQueryChange:n,isLoadingPosts:r,attachedPosts:i,onAttachedPostsChange:a,maxAttachedPosts:o,transformImageUrl:s})=>{let c=i.length>=o,l=new Set(i.map(e=>e.id)),u=(e,t)=>
3{c||l.has(e.id)||(a([...i,e]),t())};return(0,X.jsx)(Fi,{triggerLabel:q(e,`community.composer.attach_post`),triggerIcon:(0,X.jsx)(gt,{className:K,"aria-hidden":`true`}),panelClassName:`w-96`,children:({close:i})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ki,{onChange:n,placeholder:q(e,`community.composer.post_search_placeholder`),ariaLabel:q(e,`community.composer.post_search_placeholder`),autoFocus:!0}),c&&(0,X.jsx)(`p`,{className:`text-xs text-black/50 px-3 py-2 border-b border-black/5`,children:q(e,`community.composer.post_max_reached`)}),(0,X.jsx)(`div`,{className:`max-h-80 overflow-y-auto p-1`,children:r?(0,X.jsx)(`p`,{className:`text-sm text-black/50 text-center py-6`,children:q(e,`community.composer.post_loading`)}):t.length===0?(0,X.jsx)(`p`,{className:`text-sm text-black/50 text-center py-6`,children:q(e,`community.composer.post_no_results`)}):(0,X.jsx)(`ul`,{className:`flex flex-col`,children:t.map(e=>{let t=c||l.has(e.id),n=e.authors?.[0];return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>u(e,i),className:`w-full flex items-start gap-3 p-2 rounded-xl text-left transition-colors hover:bg-black/5 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent`,children:[(0,X.jsx)(An,{imageUrl:e.image_url,logoUrl:e.publication_logo_url,transformImageUrl:s,imageWidth:96,logoWidth:96,className:`size-12 shrink-0 rounded-lg`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`text-sm font-semibold text-black line-clamp-2`,children:e.web_title}),e.web_subtitle&&(0,X.jsx)(`p`,{className:`text-xs text-black/60 line-clamp-1 mt-0.5`,children:e.web_subtitle}),n?.name&&(0,X.jsx)(`p`,{className:`text-xs text-black/50 mt-0.5 truncate`,children:n.name})]})]})},e.id)})})})]})})},ea=e=>e.startsWith(`video/`),ta=e=>Array.from(e.dataTransfer?.items??[]).some(e=>e.kind===`file`&&ea(e.type)),na=({disabled:e,onFile:t,stopPropagation:n})=>{let[r,i]=(0,J.useState)(!1),a=(0,J.useRef)(0),o=(0,J.useCallback)(()=>{a.current=0,i(!1)},[]);return{isDragActive:r,dropHandlers:{onDragEnter:(0,J.useCallback)(t=>{ta(t)&&(n&&t.stopPropagation(),t.preventDefault(),!e&&(a.current+=1,i(!0)))},[e,n]),onDragLeave:(0,J.useCallback)(t=>{ta(t)&&(n&&t.stopPropagation(),!e&&(--a.current,a.current<=0&&o()))},[e,n,o]),onDragOver:(0,J.useCallback)(t=>{ta(t)&&(n&&t.stopPropagation(),t.preventDefault(),e&&t.dataTransfer&&(t.dataTransfer.dropEffect=`none`))},[e,n]),onDrop:(0,J.useCallback)(r=>{if(!ta(r)||(n&&r.stopPropagation(),r.preventDefault(),e))return;o();let i=Array.from(r.dataTransfer?.files??[]).find(e=>ea(e.type));i&&t(i,r)},[e,n,t,o])}}},ra=({translations:e})=>(0,X.jsxs)(`div`,{className:`absolute inset-0 z-[60] flex flex-col items-center justify-center gap-2 rounded-3xl border-2 border-dashed border-black/30 bg-white/90 p-6 text-center`,children:[(0,X.jsx)(Hr,{className:`size-8 text-black/60`,"aria-hidden":`true`}),(0,X.jsx)(`p`,{className:`text-sm font-medium text-black/70`,children:q(e,`community.composer.add_video`)}),(0,X.jsx)(`p`,{className:`text-xs text-black/50`,children:q(e,`community.composer.video.hint`)})]}),ia=({onSelectFile:e,validationErrorKey:t,translations:n,accept:r})=>{let i=(0,J.useRef)(null),{isDragActive:a,dropHandlers:o}=na({onFile:e,stopPropagation:!0});return(0,X.jsxs)(`div`,{...o,className:`relative flex flex-col items-center gap-3 p-6`,children:[a&&(0,X.jsx)(ra,{translations:n}),(0,X.jsx)(`input`,{ref:i,type:`file`,accept:r??kn,className:`hidden`,onChange:t=>{let n=t.target.files?.[0];n&&e(n),t.target.value=``}}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>i.current?.click(),className:`inline-flex h-10 items-center justify-center rounded-full bg-black px-5 text-[13px] font-medium leading-4 tracking-[-0.13px] text-white hover:bg-black/90`,children:q(n,`community.composer.video.choose_file`)}),(0,X.jsx)(`p`,{className:`text-center text-xs text-black/50`,children:q(n,`community.composer.video.hint`)}),t&&(0,X.jsx)(`p`,{className:`text-center text-sm text-red-500`,role:`alert`,children:q(n,t)})]})},aa=({onSelectFile:e,validationErrorKey:t,translations:n,accept:r,open:i,onOpenChange:a})=>
3(0,X.jsx)(Fi,{triggerLabel:q(n,`community.composer.add_video`),triggerIcon:(0,X.jsx)(Hr,{className:K,"aria-hidden":`true`}),panelClassName:`w-80`,open:i,onOpenChange:a,children:()=>(0,X.jsx)(ia,{onSelectFile:e,validationErrorKey:t,translations:n,accept:r})}),oa=({translations:e,showMedia:t=!0})=>(0,X.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,X.jsx)(yi,{label:q(e,`community.composer.format_text`),icon:(0,X.jsx)(vi,{}),disabled:!0}),(0,X.jsx)(yi,{label:q(e,`community.composer.add_emoji`),icon:(0,X.jsx)(Tt,{className:K,"aria-hidden":`true`}),disabled:!0}),t&&(0,X.jsx)(yi,{label:q(e,`community.composer.add_media`),icon:(0,X.jsx)(kt,{className:`size-4`,"aria-hidden":`true`}),disabled:!0}),(0,X.jsx)(yi,{label:q(e,`community.composer.add_link`),icon:(0,X.jsx)(Br,{className:K,"aria-hidden":`true`}),disabled:!0})]}),sa=e=>(0,X.jsx)(`div`,{className:`border-b border-black/10 py-2 pl-3 pr-4`,children:(0,X.jsx)(Si,{...e})}),ca=({editor:e,isEditMode:t,isSubmitting:n,isSubmitDisabled:r,onSubmit:i,translations:a,onUploadImage:o,isMediaUploadDisabled:s,uploadAccept:c,uploadMaxBytes:l,onSelectVideoFile:u,videoValidationErrorKey:d,videoUploadAccept:f,videoPanelOpen:p,onVideoPanelOpenChange:m,onSearchGifs:h,gifSearchLimit:g,gifSearchDebounceMs:_,attachableLists:v,onPostQueryChange:y,isLoadingPosts:b,attached:x,onAttachedChange:S,maxAttachedPosts:C,transformImageUrl:w})=>{let[T,E]=(0,J.useState)(!1),D=(0,J.useCallback)(()=>E(e=>!e),[]),O=!!(o||h),k=!!(y&&S),A=n||r,j=t?`community.composer.save`:`community.composer.submit`,M=t?`community.composer.saving`:`community.composer.submitting`;return(0,X.jsxs)(`div`,{className:`border-t border-black/10`,children:[e&&T&&(0,X.jsx)(sa,{editor:e,translations:a}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between pl-3 pr-4 py-4`,children:[e?(0,X.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,X.jsx)(yi,{label:q(a,`community.composer.format_text`),icon:(0,X.jsx)(vi,{}),onClick:D,active:T}),(0,X.jsx)(Ii,{editor:e,translations:a}),O&&(0,X.jsx)(Qi,{editor:e,translations:a,onUploadImage:o,isMediaUploadDisabled:s,uploadAccept:c,uploadMaxBytes:l,onSearchGifs:h,gifSearchLimit:g,gifSearchDebounceMs:_}),u&&(0,X.jsx)(aa,{onSelectFile:u,validationErrorKey:d,translations:a,accept:f,open:p,onOpenChange:m}),(0,X.jsx)(Yi,{editor:e,translations:a}),k&&y&&S&&(0,X.jsx)($i,{translations:a,posts:v?.posts??[],onPostQueryChange:y,isLoadingPosts:b,attachedPosts:x?.posts??[],onAttachedPostsChange:e=>S({...x,posts:e}),maxAttachedPosts:C,transformImageUrl:w})]}):(0,X.jsx)(oa,{translations:a,showMedia:O}),i&&(0,X.jsx)(`button`,{type:`button`,disabled:A,onClick:i,className:(0,Y.default)(`inline-flex h-10 items-center justify-center rounded-full px-5 text-[13px] font-medium leading-4 tracking-[-0.13px] bg-[var(--community-primary,#000)] text-[var(--community-text-on-primary,#fff)] transition-opacity`,{"opacity-50 cursor-not-allowed":A,"hover:opacity-90":!A}),children:n?q(a,M):q(a,j)})]})]})},la=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,ua=gn.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,nn(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}
3,addInputRules(){return[dn({find:la,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),da=e=>typeof e==`string`&&e.startsWith(`blob:`),fa=({node:e,editor:t,extension:n,getPos:r,deleteNode:i})=>{let a=typeof e.attrs.src==`string`?e.attrs.src:``,o=typeof e.attrs.alt==`string`?e.attrs.alt:``,s=da(a),{translations:c}=n.options,l=(0,J.useCallback)(()=>{if(typeof i==`function`){i();return}if(typeof r!=`function`)return;let n=r();typeof n==`number`&&t.chain().focus().deleteRange({from:n,to:n+e.nodeSize}).run()},[i,t,r,e.nodeSize]);return(0,X.jsx)(an,{as:`div`,className:`community-editor-image-wrapper`,"data-drag-handle":!0,contentEditable:!1,children:(0,X.jsxs)(`div`,{className:`relative inline-block size-[120px] overflow-hidden rounded-xl border border-black/10 bg-black/5`,children:[(0,X.jsx)(`img`,{src:a,alt:o,className:(0,Y.default)(`size-full object-cover`,{"opacity-50":s}),draggable:!1}),s&&(0,X.jsx)(`span`,{role:`status`,"aria-label":q(c,`community.composer.upload_loading`),className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(`span`,{className:`size-5 animate-spin rounded-full border-2 border-black/20 border-t-black/60`})}),t.isEditable&&(0,X.jsx)(`button`,{type:`button`,onClick:l,"aria-label":`Remove image`,className:`absolute right-1 top-1 inline-flex size-6 items-center justify-center rounded-full bg-black/70 text-white shadow-sm transition-colors hover:bg-black`,children:(0,X.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M2.5 2.5L9.5 9.5M9.5 2.5L2.5 9.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]})})},pa=ua.extend({draggable:!0,selectable:!0,addAttributes(){return{...this.parent?.(),blobKey:{default:null,parseHTML:e=>e.getAttribute(`data-blob-key`),renderHTML:e=>e.blobKey?{"data-blob-key":e.blobKey}:{}}}},addNodeView(){return fn(fa)}}),ma=({node:e,editor:t,deleteNode:n})=>{let{service:r,data:i}=e.attrs,a=(0,J.useCallback)(()=>n(),[n]);return(0,X.jsxs)(an,{as:`div`,className:`community-editor-link-embed-wrapper relative`,"data-drag-handle":!0,contentEditable:!1,children:[(0,X.jsx)(et,{service:r,data:i}),t.isEditable&&(0,X.jsx)(`button`,{type:`button`,onClick:a,"aria-label":`Remove video`,className:`absolute right-2 top-2 inline-flex size-6 items-center justify-center rounded-full bg-black/70 text-white shadow-sm transition-colors hover:bg-black`,children:(0,X.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M2.5 2.5L9.5 9.5M9.5 2.5L2.5 9.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]})},ha=gn.create({name:`linkEmbed`,group:`block`,draggable:!0,selectable:!0,addAttributes(){return{service:{default:`youtube`,parseHTML:e=>e.getAttribute(`data-service`)??`youtube`,renderHTML:e=>({"data-service":e.service})},data:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-embed`);if(!t)return null;try{return JSON.parse(t)}catch{return null}},renderHTML:e=>({"data-embed":e.data?JSON.stringify(e.data):null})}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:e}){return[`div`,nn(e,{"data-type":this.name})]},addCommands(){return{convertLinkPromptToEmbed:()=>e=>{let t=Z.getState(e.state);return t?.kind===`embed`?li(e,t,{type:this.name,attrs:{service:t.service,data:t.data}}):!1},appendLinkPromptEmbed:()=>e=>{let t=Z.getState(e.state);return t?.kind===`embed`?ui(e,t,this.type.create({service:t.service,data:t.data})):!1}}},addNodeView(){return fn(ma)}}),ga=(0,J.createContext)(null),_a=()=>(0,J.useContext)(ga),va=`image/jpeg,image/png,image/webp,image/heic,image/heif`,ya={aspectRatio:`16 / 9`},ba=`rounded-lg p-0.5 outline-none ring-2 transition-shadow focus-visible:ring-white`,xa=({candidates:e,selectedIndex:t,onSelect:n,onUpload:r,onOpen:i,translations:a})=>{let[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),u=(0,J.useRef)(null),d=(0,J.useRef)(null),f=(0,J.useId)();(0,J.useEffect)(()=>{o&&u.current?.focus()},[o]);let p=()=>{l(!1),s(!0),i?.()},m=()=>s(!1),h=async e=>{l(!1),s(!1),await e()||(l(!0),s(!0))},g=q(a,`community.composer.video.thumbnail_frame`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:p,"aria-haspopup":`dialog`,className:`absolute left-2 top-2 z-10 inline-flex h-6 items-center gap-1 rounded-full bg-black/70 pl-2 pr-2.5 text-xs font-medium text-white shadow-sm transition-colors hover:bg-white hover:text-black`,children:[(0,X.jsx)(kt,{className:`size-3.5`,"aria-hidden":`true`}),q(a,`community.composer.video.choose_thumbnail`)]}),o&&(0,X.jsxs)(`div`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-labelledby":f,tabIndex:-1,
3className:`absolute inset-0 z-20 flex flex-col gap-3 overflow-y-auto rounded-xl bg-black/70 p-4 outline-none backdrop-blur-sm`,onKeyDown:e=>{e.key===`Escape`&&m()},children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`h3`,{id:f,className:`text-sm font-medium text-white`,children:q(a,`community.composer.video.thumbnail_dialog`)}),(0,X.jsx)(`button`,{type:`button`,onClick:m,"aria-label":q(a,`community.composer.close`),className:`-m-1.5 flex items-center rounded-full p-1.5 transition-colors hover:bg-white/10`,children:(0,X.jsx)(Pt,{className:`size-5 text-white/70`,"aria-hidden":`true`})})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[e.map(e=>{let r=e.index===t;return(0,X.jsx)(`button`,{type:`button`,"aria-label":`${g} ${e.index+1}`,"aria-pressed":r,onClick:()=>void h(()=>n(e.index)),style:ya,className:(0,Y.default)(ba,r?`ring-white`:`ring-transparent hover:ring-white/80`),children:(0,X.jsx)(`img`,{src:e.previewUrl,alt:``,className:`block size-full rounded-md bg-white/10 object-cover`})},e.index)}),r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{ref:d,type:`file`,accept:va,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&h(()=>r(t))}}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>d.current?.click(),style:ya,className:(0,Y.default)(ba,`group ring-transparent hover:ring-white/80`),children:(0,X.jsxs)(`span`,{className:`flex size-full flex-col items-center justify-center gap-1.5 rounded-md bg-white/10 px-2 text-center text-white/80 transition-colors group-hover:bg-white/20 group-hover:text-white`,children:[(0,X.jsx)(kt,{className:`size-6`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`text-xs font-medium`,children:q(a,`community.composer.video.upload_thumbnail`)})]})})]})]}),c&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-red-300`,children:q(a,`community.composer.video.thumbnail_error`)})]})]})},Sa={aspectRatio:`16 / 9`},Ca=e=>new Promise(t=>{if(!e){t();return}let n=new Image;n.onload=()=>t(),n.onerror=()=>t(),n.src=e}),wa=({status:e,videoId:t,children:n})=>(0,X.jsxs)(`div`,{className:`flex w-full flex-col items-center justify-center gap-2 rounded-xl border border-black/10 bg-black/5 p-6 text-black/50`,style:Sa,"data-video-id":t,"data-video-status":e,children:[(0,X.jsx)(`svg`,{width:`32`,height:`32`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M4 6a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6Zm12 4.5 4-2.5v8l-4-2.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`})}),n]}),Ta=({onRemove:e,label:t})=>(0,X.jsxs)(`button`,{type:`button`,onClick:e,className:`absolute right-2 top-2 inline-flex h-6 items-center gap-1 rounded-full bg-black/70 pl-2.5 pr-2 text-xs font-medium text-white shadow-sm transition-colors hover:bg-white hover:text-black`,children:[t,(0,X.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M2.5 2.5L9.5 9.5M9.5 2.5L2.5 9.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})]}),Ea=({node:e,editor:t,deleteNode:n,extension:r})=>{let i=typeof e.attrs.videoId==`string`?e.attrs.videoId:``,{subscribeToStatus:a,onRetry:o,resolvePlayback:s,loadThumbnails:c,selectThumbnail:l,uploadThumbnail:u,translations:d}=r.options,f=_a(),[p,m]=(0,J.useState)({type:`status`,status:`transcoding`,revision:0}),[h,g]=(0,J.useState)(0),_=p.status,[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1);(0,J.useEffect)(()=>{if(!(!i||!a))return a(i,e=>{if(e.type===`thumbnails`){g(e=>e+1);return}m(t=>e.revision>t.revision?e:t)})},[i,a]);let S=q(d,`community.composer.video.remove`),C=(0,J.useCallback)(()=>n(),[n]),w=(0,J.useCallback)(()=>{f?.cancel(),t.commands.removeProvisionalVideo()},[f,t]),T=(0,J.useCallback)(async()=>{if(!(!o||!i||v)){y(!0);try{await o(i)}finally{y(!1)}}},[o,i,v]),[E,D]=(0,J.useState)(null),O=(0,J.useCallback)(async()=>{if(!i||!c)return;let e=await c(i);if(e){D(e);for(let t of e.candidates??[])Ca(t.previewUrl)}},[i,c]);(0,J.useEffect)(()=>{O()},[O]),(0,J.useEffect)(()=>{h>0&&O()},[h,O]);let k=(0,J.useCallback)(async e=>{if(!i||!l)return!1;let t=E,n=t?.candidates?.find(t=>t.index===e);t&&n&&D({...t,selectedIndex:e,selectedUrl:n.url}),x(!1);let r=await l(i,e);return r&&await Ca(r.selectedUrl),D(r??t),r!==null},[i,l,E]),A=(0,J.useCallback)(async e=>{if(!i||!u)return!1;let t=E,n=URL.createObjectURL(e);D({candidates:t?.candidates??[],selectedIndex:null,selectedUrl:n}),x(!1);let r=await u(i,e);return r&&await Ca(r.selectedUrl),D(r??t),URL.revokeObjectURL(n),r!==null},[i,u,E]),j=E?.selectedUrl??void 0,M=E?.candidates,N=t.isEditable&&l&&M&&(M.length>0||u)?(0,X.jsx)(xa,{candidates:M,selectedIndex:E?.selectedIndex??null,onSelect:k,onUpload:u?A:void 0,onOpen:()=>void O(),translations:d}):null;if(!i){let e=f?.state;return(0,X.jsxs)(an,{as:`div`,className:`community-editor-video-wrapper relative`,"data-drag-handle":!0,contentEditable:!1,
3children:[(0,X.jsx)(wa,{status:`uploading`,children:e?.phase===`error`&&e.errorKind!==`validation`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-sm text-red-500`,role:`alert`,children:q(d,e?.errorKey??`community.composer.video.error_transfer`)}),f&&(0,X.jsx)(`button`,{type:`button`,onClick:f.retry,className:`rounded-full bg-black/70 px-3 py-1 text-xs text-white transition-colors hover:bg-black`,children:q(d,`community.composer.video.retry`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-sm`,children:q(d,e?.phase===`confirming`?`community.composer.video.processing`:`community.composer.video.uploading`)}),(0,X.jsx)(`div`,{className:`h-2 w-2/3 overflow-hidden rounded-full bg-black/10`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-black/60 transition-[width]`,style:{width:`${e?.progress??0}%`},role:`progressbar`,"aria-label":q(d,`community.composer.video.uploading`),"aria-valuenow":e?.progress??0,"aria-valuemin":0,"aria-valuemax":100})})]})}),(0,X.jsx)(Ta,{onRemove:w,label:q(d,`community.composer.video.cancel`)})]})}if(_===`failed`||_===`blocked`)return(0,X.jsxs)(an,{as:`div`,className:`community-editor-video-wrapper relative`,"data-drag-handle":!0,contentEditable:!1,children:[(0,X.jsxs)(wa,{status:_,videoId:i,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:_===`blocked`?q(d,`community.composer.video.status_blocked`):q(d,`community.composer.video.status_failed`)}),_===`failed`&&o&&(0,X.jsx)(`button`,{type:`button`,onClick:T,disabled:v,className:`rounded-full bg-black/70 px-3 py-1 text-xs text-white transition-colors hover:bg-black disabled:opacity-50`,children:q(d,`community.composer.video.retry`)})]}),t.isEditable&&(0,X.jsx)(Ta,{onRemove:C,label:S})]});let P=_===`ready`&&!!s;return(0,X.jsxs)(an,{as:`div`,className:`community-editor-video-wrapper relative`,"data-drag-handle":b?void 0:``,contentEditable:!1,children:[b&&P&&s?(0,X.jsx)(`div`,{className:`w-full overflow-hidden rounded-xl bg-black`,style:Sa,children:(0,X.jsx)(pt,{videoId:i,resolvePlayback:s,poster:j,autoPlay:!0,className:`w-full`})}):(0,X.jsxs)(`div`,{className:`relative w-full overflow-hidden rounded-xl bg-black`,style:Sa,"data-video-id":i,"data-video-status":_,children:[j&&(0,X.jsx)(`img`,{src:j,alt:``,className:`absolute inset-0 size-full object-cover`}),P?(0,X.jsx)(`button`,{type:`button`,onClick:()=>x(!0),"aria-label":q(d,`community.composer.video.play`),className:`absolute inset-0 m-auto flex size-14 items-center justify-center rounded-full bg-black/60 text-white transition-colors hover:bg-black/80`,children:(0,X.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M8 5v14l11-7z`})})}):(0,X.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 bg-black/40 text-white`,children:[(0,X.jsx)(`span`,{className:`size-5 animate-spin rounded-full border-2 border-current border-t-transparent`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`text-sm`,children:q(d,`community.composer.video.status_processing`)})]})]}),t.isEditable&&(0,X.jsxs)(X.Fragment,{children:[N,(0,X.jsx)(Ta,{onRemove:C,label:S})]})]})},Da=e=>e.setMeta(`addToHistory`,!1),Oa=(e,t)=>{let n=[];return e.descendants((e,r)=>{e.type.name===t&&n.push(r)}),n},ka=gn.create({name:`video`,addOptions(){return{}},group:`block`,atom:!0,draggable:!0,selectable:!0,addAttributes(){return{videoId:{default:null,parseHTML:e=>e.getAttribute(`data-video-id`),renderHTML:e=>e.videoId?{"data-video-id":e.videoId}:{}}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:e}){return[`div`,nn(e,{"data-type":this.name})]},addCommands(){let e=this.name,t=t=>{for(let n of Oa(t.doc,e).reverse())t.delete(n,n+1)};return{setVideo:e=>({tr:n,dispatch:r})=>e.videoId?(t(n),n.replaceSelectionWith(this.type.create(e)),r&&r(n),!0):!1,insertProvisionalVideo:e=>({tr:n,dispatch:r})=>{t(n);let i=this.type.create({videoId:null});return typeof e==`number`?n.insert(n.mapping.map(e),i):n.replaceSelectionWith(i),Da(n),r&&r(n),!0},setVideoId:t=>({tr:n,dispatch:r})=>{if(!t)return!1;let i=Oa(n.doc,e);return i.length===0?!1:(n.setNodeAttribute(i[0],`videoId`,t),Da(n),r&&r(n),!0)},removeProvisionalVideo:()=>({tr:t,dispatch:n})=>{let r=Oa(t.doc,e).filter(e=>!t.doc.nodeAt(e)?.attrs.videoId);if(r.length===0)return!1;for(let e of r.reverse())t.delete(e,e+1);return Da(t),n&&n(t),!0}}},addProseMirrorPlugins(){let e=this.name;return[new en({appendTransaction:(t,n,r)=>{let i=Oa(r.doc,e);if(i.length<2)return null;let a=r.tr;for(let e of i.slice(1).reverse())a.delete(e,e+1);return a}})]},addNodeView(){return fn(Ea)}});function Aa(e,t){return Object.hasOwn(e,t)}var{AbortController:ja}=globalThis,{AbortSignal:Ma}=globalThis,Na=(e=`Aborted`,t)=>{let n=new DOMException(e,`AbortError`);return t!=null&&Aa(t,`cause`)&&Object.defineProperty(n,"cause",{__proto__:null,configurable:!0,writable:!0,value:t.cause}),n}
3,Pa=class extends Error{isNetworkError;cause;constructor(e,t){super(e),this.cause=t?.cause,this.cause&&Aa(this.cause,`isNetworkError`)?this.isNetworkError=this.cause.isNetworkError:this.isNetworkError=!1}},Fa=class extends Error{cause;isNetworkError;request;constructor(e,t=null){super(`This looks like a network error, the endpoint might be blocked by an internet provider or a firewall.`),this.cause=e,this.isNetworkError=!0,this.request=t}};function Ia(...e){return fetch(...e).catch(e=>{throw e.name===`AbortError`?e:new Fa(e)})}var La=e=>`error`in e&&!!e.error,Ra=e=>e.progress.uploadComplete;function za(e){return e.filter(e=>!La(e)&&!Ra(e))}function Ba(e){return e.filter(e=>!e.progress?.uploadStarted||!e.isRestored)}function Va(e){let t=e.lastIndexOf(`.`);return t===-1||t===e.length-1?{name:e,extension:void 0}:{name:e.slice(0,t),extension:e.slice(t+1)}}var Ha={__proto__:null,md:`text/markdown`,markdown:`text/markdown`,mp4:`video/mp4`,mp3:`audio/mp3`,svg:`image/svg+xml`,jpg:`image/jpeg`,png:`image/png`,webp:`image/webp`,gif:`image/gif`,heic:`image/heic`,heif:`image/heif`,yaml:`text/yaml`,yml:`text/yaml`,csv:`text/csv`,tsv:`text/tab-separated-values`,tab:`text/tab-separated-values`,avi:`video/x-msvideo`,mks:`video/x-matroska`,mkv:`video/x-matroska`,mov:`video/quicktime`,dicom:`application/dicom`,doc:`application/msword`,msg:`application/vnd.ms-outlook`,docm:`application/vnd.ms-word.document.macroenabled.12`,docx:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,dot:`application/msword`,dotm:`application/vnd.ms-word.template.macroenabled.12`,dotx:`application/vnd.openxmlformats-officedocument.wordprocessingml.template`,xla:`application/vnd.ms-excel`,xlam:`application/vnd.ms-excel.addin.macroenabled.12`,xlc:`application/vnd.ms-excel`,xlf:`application/x-xliff+xml`,xlm:`application/vnd.ms-excel`,xls:`application/vnd.ms-excel`,xlsb:`application/vnd.ms-excel.sheet.binary.macroenabled.12`,xlsm:`application/vnd.ms-excel.sheet.macroenabled.12`,xlsx:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,xlt:`application/vnd.ms-excel`,xltm:`application/vnd.ms-excel.template.macroenabled.12`,xltx:`application/vnd.openxmlformats-officedocument.spreadsheetml.template`,xlw:`application/vnd.ms-excel`,txt:`text/plain`,text:`text/plain`,conf:`text/plain`,log:`text/plain`,pdf:`application/pdf`,zip:`application/zip`,"7z":`application/x-7z-compressed`,rar:`application/x-rar-compressed`,tar:`application/x-tar`,gz:`application/gzip`,dmg:`application/x-apple-diskimage`};function Ua(e){if(e.type)return e.type;let t=e.name?Va(e.name).extension?.toLowerCase():null;return t&&t in Ha?Ha[t]:`application/octet-stream`}function Wa(e){return e.charCodeAt(0).toString(32)}function Ga(e){let t=``;return e.replace(/[^A-Z0-9]/gi,e=>(t+=`-${Wa(e)}`,`/`))+t}function Ka(e,t){let n=t||`uppy`;return typeof e.name==`string`&&(n+=`-${Ga(e.name.toLowerCase())}`),e.type!==void 0&&(n+=`-${e.type}`),e.meta&&typeof e.meta.relativePath==`string`&&(n+=`-${Ga(e.meta.relativePath.toLowerCase())}`),e.data?.size!==void 0&&(n+=`-${e.data.size}`),e.data.lastModified!==void 0&&(n+=`-${e.data.lastModified}`),n}function qa(e){return!e.isRemote||!e.remote?!1:new Set([`box`,`dropbox`,`drive`,`facebook`,`unsplash`]).has(e.remote.provider)}function Ja(e,t){if(qa(e))return e.id;let n=Ua(e);return Ka({...e,type:n},t)}function Ya(e,t){return e===!0?Object.keys(t):Array.isArray(e)?e:[]}function Xa(e){let t=/^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?([^\n]+)/i.exec(e)?.[1];return`${/^http:\/\//i.test(e)?`ws`:`wss`}://${t}`}function Za(e){return e<10?`0${e}`:e.toString()}function Qa(){let e=new Date;return`${Za(e.getHours())}:${Za(e.getMinutes())}:${Za(e.getSeconds())}`}function $a(e){return Error(`Cancelled`,{cause:e})}function eo(e){if(e!=null){let t=()=>this.abort(e.reason);e.addEventListener(`abort`,t,{once:!0});let n=()=>{e.removeEventListener(`abort`,t)};this.then?.(n,n)}return this}var to=class{#e=0;#t=[];#n=!1;#r;#i=1;#a;#o;limit;constructor(e){typeof e!=`number`||e===0?this.limit=1/0:this.limit=e}#s(e){this.#e+=1;let t=!1,n;try{n=e()}catch(e){throw--this.#e,e}return{abort:e=>{t||(t=!0,--this.#e,n?.(e),this.#c())},done:()=>{t||(t=!0,--this.#e,this.#c())}}}#c(){queueMicrotask(()=>this.#l())}#l(){if(this.#n||this.#e>=this.limit||this.#t.length===0)return;let e=this.#t.shift();if(e==null)throw Error(`Invariant violation: next is null`);let t=this.#s(e.fn);e.abort=t.abort,e.done=t.done}#u(e,t){let n={fn:e,priority:t?.priority||0,abort:()=>{this.#d(n)},done:()=>{throw Error(`Cannot mark a queued request as done: this indicates a bug`)}},r=this.#t.findIndex(e=>n.priority>e.priority);return r===-1?this.#t.push(n):this.#t.splice(r,0,n),n}#d(e){let t=this.#t.indexOf(e);t!==-1&&this.#t.splice(t,1)}run(e,t){return!this.#n&&this.#e<this.limit?this.#s(e):this.#u(e,t)}wrapSyncFunction(e,t){return(...n)=>{let r=this.run(()=>(e(...n),queueMicrotask(()=>r.done()),()=>{}),t);return{abortOn:eo,abort(){r.abort()}}}}wrapPromiseFunction(e,t){return(...n)=>{let r,i=new Promise((i,a)=>{r=this.run(()=>{let t,o;try{o=Promise.resolve(e(...n))}catch(e){o=Promise.reject(e)}return o.then(e=>{t?a(t):(r.done(),i(e))},e=>{t?a(t):(r.done(),a(e))}),e=>{t=$a(e)}},t)});return i.abort=e=>{r.abort(e)},i.abortOn=eo,i}}resume(){this.#n=!1,clearTimeout(this.#r);for(let e=0;e<this.limit;e++)this.#c()}#f=()=>this.resume();pause(e=null){this.#n=!0,clearTimeout(this.#r),e!=null&&(this.#r=setTimeout(this.#f,e))}rateLimit(e){clearTimeout(this.#o),this.pause(e),this.limit>1&&Number.isFinite(this.limit)&&(this.#a=this.limit-1,this.limit=this.#i,this.#o=setTimeout(this.#p,e))}#p=()=>
3{if(this.#n){this.#o=setTimeout(this.#p,0);return}this.#i=this.limit,this.limit=Math.ceil((this.#a+this.#i)/2);for(let e=this.#i;e<=this.limit;e++)this.#c();this.#a-this.#i>3?this.#o=setTimeout(this.#p,2e3):this.#i=Math.floor(this.#i/2)};get isPaused(){return this.#n}};function no(e,t,n){let r=[];return e.forEach(e=>typeof e==`string`?t[Symbol.split](e).forEach((e,t,i)=>{e!==``&&r.push(e),t<i.length-1&&r.push(n)}):r.push(e)),r}function ro(e,t){let n=/\$/g,r=[e];if(t==null)return r;for(let e of Object.keys(t))if(e!==`_`){let i=t[e];typeof i==`string`&&(i=n[Symbol.replace](i,`$$$$`)),r=no(r,RegExp(`%\\{${e}\\}`,`g`),i)}return r}var io=e=>{throw Error(`missing string: ${e}`)},ao=class{locale;constructor(e,{onMissingKey:t=io}={}){this.locale={strings:{},pluralize(e){return e===1?0:1}},Array.isArray(e)?e.forEach(this.#t,this):this.#t(e),this.#e=t}#e;#t(e){if(!e?.strings)return;let t=this.locale;Object.assign(this.locale,{strings:{...t.strings,...e.strings},pluralize:e.pluralize||t.pluralize})}translate(e,t){return this.translateArray(e,t).join(``)}translateArray(e,t){let n=this.locale.strings[e];if(n??=(this.#e(e),e),typeof n==`object`){if(t&&t.smart_count!==void 0){let e=this.locale.pluralize(t.smart_count);return ro(n[e],t)}throw Error(`Attempted to use a string with plural forms, but no value was given for %{smart_count}`)}if(typeof n!=`string`)throw Error(`string was not a string`);return ro(n,t)}},oo=class extends Error{name=`UserFacingApiError`},so=e(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),co=e((e=>{var t=so();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*Math.max(t.minTimeout,1)*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1
3),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),lo=t(e(((e,t)=>{t.exports=co()}))(),1),uo=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=Error(e),this.originalError.stack=this.stack),this.name=`AbortError`,this.message=e}},fo=(e,t,n)=>{let r=n.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=r,e};async function po(e,t){return new Promise((n,r)=>{t={...t},t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.retries??=10;let i=lo.operation(t),a=()=>{i.stop(),r(t.signal?.reason)};t.signal&&!t.signal.aborted&&t.signal.addEventListener(`abort`,a,{once:!0});let o=()=>{t.signal?.removeEventListener(`abort`,a),i.stop()};i.attempt(async a=>{try{let t=await e(a);o(),n(t)}catch(e){try{if(!(e instanceof Error))throw TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(e instanceof uo)throw e.originalError;if(e instanceof TypeError&&!Nn(e))throw e;if(fo(e,a,t),await t.shouldRetry(e)||(i.stop(),r(e)),await t.onFailedAttempt(e),!i.retry(e))throw i.mainError()}catch(e){fo(e,a,t),o(),r(e)}}})})}var mo={name:`@uppy/companion-client`,description:`Client library for communication with Companion. Intended for use in Uppy plugins.`,version:`5.1.1`,license:`MIT`,type:`module`,sideEffects:!1,scripts:{build:`tsc --build tsconfig.build.json`,typecheck:`tsc --build`,test:`vitest run --environment=jsdom --silent='passed-only'`},keywords:[`file uploader`,`uppy`,`uppy-plugin`,`companion`,`provider`],homepage:`https://uppy.io`,bugs:{url:`https://github.com/transloadit/uppy/issues`},repository:{type:`git`,url:`git+https://github.com/transloadit/uppy.git`},files:[`src`,`lib`,`dist`,`CHANGELOG.md`],exports:{".":`./lib/index.js`,"./package.json":`./package.json`},dependencies:{"@uppy/utils":`^7.1.1`,"namespace-emitter":`^2.0.1`,"p-retry":`^6.1.0`},devDependencies:{jsdom:`^26.1.0`,typescript:`^5.8.3`,vitest:`^3.2.4`},peerDependencies:{"@uppy/core":`^5.1.1`}},ho=class extends Error{isAuthError;constructor(){super(`Authorization required`),this.name=`AuthError`,this.isAuthError=!0}};function go(e){return e.replace(/\/$/,``)}var _o=10,vo=300*1e3,yo=class extends Error{statusCode;constructor({statusCode:e,message:t}){super(t),this.name=`HttpError`,this.statusCode=e}};async function bo(e){if(e.status===401)throw new ho;if(e.ok)return e.json();let t=`Failed request with status: ${e.status}. ${e.statusText}`,n;try{n=await e.json(),n.message&&(t=`${t} message: ${n.message}`),n.requestId&&(t=`${t} request-Id: ${n.requestId}`)}catch(e){throw Error(t,{cause:e})}throw e.status>=400&&e.status<=499&&n.message?new oo(n.message):new yo({statusCode:e.status,message:t})}function xo(e,t,n){let{progress:r,bytesUploaded:i,bytesTotal:a}=t;r&&(e.uppy.log(`Upload progress: ${r}`),e.uppy.emit(`upload-progress`,n,{uploadStarted:n.progress.uploadStarted??0,bytesUploaded:i,bytesTotal:a}))}var So=class{static VERSION=mo.version;#e;uppy;opts;constructor(e,t){this.uppy=e,this.opts=t,this.onReceiveResponse=this.onReceiveResponse.bind(this),this.#e=t.companionHeaders}setCompanionHeaders(e){this.#e=e}[Symbol.for(`uppy test: getCompanionHeaders`)](){return this.#e}get hostname(){let{companion:e}=this.uppy.getState(),t=this.opts.companionUrl;return go(e?.[t]?e[t]:t)}async headers(e=!1){return{Accept:`application/json`,...e?void 0:{"Content-Type":`application/json`},...this.#e}}onReceiveResponse(e){let{headers:t}=e,n=this.uppy.getState().companion||{},r=this.opts.companionUrl;t.has(`i-am`)&&t.get(`i-am`)!==n[r]&&this.uppy.setState({companion:{...n,[r]:t.get(`i-am`)}})}#t(e){return/^(https?:|)\/\//.test(e)?e:`${this.hostname}/${e}`}async request({path:e,method:t=`GET`,data:n,skipPostResponse:r,signal:i}){try{let a=await this.headers(!n),o=await Ia(this.#t(e),{method:t,signal:i,headers:a,credentials:this.opts.companionCookiesRule||`same-origin`,body:n?JSON.stringify(n):null});return r||this.onReceiveResponse(o),await bo(o)}catch(n){throw n.isAuthError||n.name===`UserFacingApiError`||n.name===`AbortError`?n:new Pa(`Could not ${t} ${this.#t(e)}`,{cause:n})}}async get(e,t){return this.request({...t,path:e})}async post(e,t,n){return this.request({...n,path:e,method:`POST`,data:t})}async delete(e,t,n){return this.request({...n,path:e,method:`DELETE`,data:t})}async uploadRemoteFile(e,t,n){try{let{signal:r,getQueue:i}=n||{};return await po(async()=>{let n=this.uppy.getFile(e.id)?.serverToken;
3if(n!=null)return this.uppy.log(`Connecting to exiting websocket ${n}`),this.#r({file:e,queue:i(),signal:r});let a=await i().wrapPromiseFunction(async(...e)=>{try{return await this.#n(...e)}catch(e){if(e.isAuthError)throw new uo(e);if(e.cause==null)throw e;let t=e.cause;throw t.name===`HttpError`&&!([408,409,429,418,423].includes(t.statusCode)||t.statusCode>=500&&t.statusCode<=599&&![501,505].includes(t.statusCode))?new uo(t):t}},{priority:-1})({file:e,postBody:t,signal:r}).abortOn(r);if(this.uppy.getFile(e.id))return this.uppy.setFileState(e.id,{serverToken:a}),this.#r({file:this.uppy.getFile(e.id),queue:i(),signal:r})},{retries:_o,signal:r,onFailedAttempt:e=>this.uppy.log(`Retrying upload due to: ${e.message}`,`warning`)})}catch(t){if(t.name===`AbortError`)return;throw this.uppy.emit(`upload-error`,e,t),t}}#n=async({file:e,postBody:t,signal:n})=>{if(e.remote?.url==null)throw Error(`Cannot connect to an undefined URL`);return(await this.post(e.remote.url,{...e.remote.body,...t},{signal:n})).token};async#r({file:e,queue:t,signal:n}){let r,{capabilities:i}=this.uppy.getState();try{return await new Promise((a,o)=>{let s=e.serverToken,c=Xa(e.remote.companionUrl),l,u,d,{isPaused:f}=e,p=(t,n)=>{if(l==null||l.readyState!==l.OPEN){this.uppy.log(`Cannot send "${t}" to socket ${e.id} because the socket state was ${String(l?.readyState)}`,`warning`);return}l.send(JSON.stringify({action:t,payload:n??{}}))};function m(){i.resumableUploads&&p(f?`pause`:`resume`)}let h=async()=>{u&&u.abort(),u=new AbortController;let n=t=>{this.uppy.setFileState(e.id,{serverToken:null}),u?.abort?.(),o(t)};function r(){clearTimeout(d),!f&&(d=setTimeout(()=>n(Error(`Timeout waiting for message from Companion socket`)),vo))}try{await t.wrapPromiseFunction(async()=>{await po(async()=>new Promise((t,i)=>{l=new WebSocket(`${c}/api/${s}`),r(),l.addEventListener(`close`,()=>{l=void 0,i(Error(`Socket closed unexpectedly`))}),l.addEventListener(`error`,e=>{this.uppy.log(`Companion socket error ${JSON.stringify(e)}, closing socket`,`warning`),l?.close()}),l.addEventListener(`open`,()=>{m()}),l.addEventListener(`message`,t=>{r();try{let{action:n,payload:r}=JSON.parse(t.data);switch(n){case`progress`:xo(this,r,this.uppy.getFile(e.id));break;case`success`:{let t=r.response?.responseText;this.uppy.emit(`upload-success`,this.uppy.getFile(e.id),{uploadURL:r.url,status:r.response?.status??200,body:t?JSON.parse(t):void 0}),u?.abort?.(),a();break}case`error`:{let{message:e}=r.error;throw Object.assign(Error(e),{cause:r.error})}default:this.uppy.log(`Companion socket unknown action ${n}`,`warning`)}}catch(e){n(e)}});let o=()=>{this.uppy.log(`Closing socket ${e.id}`),clearTimeout(d),l&&l.close(),l=void 0};u.signal.addEventListener(`abort`,()=>{o()})}),{retries:_o,signal:u.signal,onFailedAttempt:()=>{u.signal.aborted||this.uppy.log(`Retrying websocket ${e.id}`)}})})().abortOn(u.signal)}catch(e){if(u.signal.aborted)return;n(e)}},g=e=>{i.resumableUploads&&(f=e,l&&m())},_=t=>{i.individualCancellation&&t.id===e.id&&(p(`cancel`),u?.abort?.(),this.uppy.log(`upload ${e.id} was removed`),a())},v=()=>{p(`cancel`),u?.abort?.(),this.uppy.log(`upload ${e.id} was canceled`),a()},y=(t,n)=>{t?.id===e.id&&g(n)},b=()=>g(!0),x=()=>g(!1);this.uppy.on(`file-removed`,_),this.uppy.on(`cancel-all`,v),this.uppy.on(`upload-pause`,y),this.uppy.on(`pause-all`,b),this.uppy.on(`resume-all`,x),r=()=>{this.uppy.off(`file-removed`,_),this.uppy.off(`cancel-all`,v),this.uppy.off(`upload-pause`,y),this.uppy.off(`pause-all`,b),this.uppy.off(`resume-all`,x)},n.addEventListener(`abort`,()=>{u?.abort()}),h()})}finally{r?.()}}},Co=class{uppy;opts;id;defaultLocale;i18n;i18nArray;type;VERSION;constructor(e,t){this.uppy=e,this.opts=t??{}}getPluginState(){let{plugins:e}=this.uppy.getState();return e?.[this.id]||{}}setPluginState(e){let{plugins:t}=this.uppy.getState();this.uppy.setState({plugins:{...t,[this.id]:{...t[this.id],...e}}})}setOptions(e){this.opts={...this.opts,...e},this.setPluginState(void 0),this.i18nInit()}i18nInit(){let e=new ao([this.defaultLocale,this.uppy.locale,this.opts.locale]);this.i18n=e.translate.bind(e),this.i18nArray=e.translateArray.bind(e),this.setPluginState(void 0)}addTarget(e){throw Error(`Extend the addTarget method to add your plugin to another plugin's target`)}install(){}uninstall(){}update(e){}afterUpdate(){}},wo=class{#e;#t=[];constructor(e){this.#e=e}on(e,t){return this.#t.push([e,t]),this.#e.on(e,t)}remove(){for(let[e,t]of this.#t.splice(0))this.#e.off(e,t)}onFilePause(e,t){this.on(`upload-pause`,(n,r)=>{e===n?.id&&t(r)})}onFileRemove(e,t){this.on(`file-removed`,n=>{e===n.id&&t(n.id)})}onPause(e,t){this.on(`upload-pause`,(n,r)=>{e===n?.id&&t(r)})}onRetry(e,t){this.on(`upload-retry`,n=>{e===n?.id&&t()})}onRetryAll(e,t){this.on(`retry-all`,()=>{this.#e.getFile(e)&&t()})}onPauseAll(e,t){this.on(`pause-all`,()=>{this.#e.getFile(e)&&t()})}onCancelAll(e,t){this.on(`cancel-all`,(...n)=>{this.#e.getFile(e)&&t(...n)})}onResumeAll(e,t){this.on(`resume-all`,()=>{this.#e.getFile(e)&&t()})}},To={debug:()=>{},warn:()=>{},error:(...e)=>console.error(`[Uppy] [${Qa()}]`,...e)},Eo={debug:(...e)=>console.debug(`[Uppy] [${Qa()}]`,...e),warn:(...e)=>console.warn(`[Uppy] [${Qa()}]`,...e),error:(...e)=>console.error(`[Uppy] [${Qa()}]`,...e)},Do=e(((e,t)=>{t.exports=function(e){if(typeof e!=`number`||Number.isNaN(e))throw TypeError(`Expected a number, got ${typeof e}`);let t=e<0,n=Math.abs(e);if(t&&(n=-n),n===0)return`0 B`;let r=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],i=Math.min(Math.floor(Math.log(n)/Math.log(1024)),r.length-1),a=Number(n/1024**i),o=r[i];return`${a>=10||a%1==0?Math.round(a):a.toFixed(1)} ${o}`}})),Oo=e(((e,t)=>{function n(e,t){this.text=e||=``,this.hasWild=~e.indexOf(`*`),this.separator=t,this.parts=e.split(t)}n.prototype.match=function(e){var t=!0,n=this.parts,r,i=n.length,a;if(typeof e==`string`||e instanceof String)if(!this.hasWild&&this.text!=e)t=!1;else{for(a=(e||``).split(this.separator),r=0;t&&r<i;r++)if(n[r]===`*`)continue;else t=r<a.length?n[r]===a[r]:!1;t&&=a}
3else if(typeof e.splice==`function`)for(t=[],r=e.length;r--;)this.match(e[r])&&(t[t.length]=e[r]);else if(typeof e==`object`)for(var o in t={},e)this.match(o)&&(t[o]=e[o]);return t},t.exports=function(e,t,r){var i=new n(e,r||/[\/\.]/);return t===void 0?i:i.match(t)}})),ko=e(((e,t)=>{var n=Oo(),r=/[\/\+\.]/;t.exports=function(e,t){function i(t){var i=n(t,e,r);return i&&i.length>=2}return t?i(t.split(`;`)[0]):i}})),Ao=t(Do(),1),jo=t(ko(),1),Mo={maxFileSize:null,minFileSize:null,maxTotalFileSize:null,maxNumberOfFiles:null,minNumberOfFiles:null,allowedFileTypes:null,requiredMetaFields:[]},No=class extends Error{isUserFacing;file;constructor(e,t){super(e),this.isUserFacing=t?.isUserFacing??!0,t?.file&&(this.file=t.file)}isRestriction=!0},Po=class{getI18n;getOpts;constructor(e,t){this.getI18n=t,this.getOpts=()=>{let t=e();if(t.restrictions?.allowedFileTypes!=null&&!Array.isArray(t.restrictions.allowedFileTypes))throw TypeError("`restrictions.allowedFileTypes` must be an array");return t}}validateAggregateRestrictions(e,t){let{maxTotalFileSize:n,maxNumberOfFiles:r}=this.getOpts().restrictions;if(r&&e.filter(e=>!e.isGhost).length+t.length>r)throw new No(`${this.getI18n()(`youCanOnlyUploadX`,{smart_count:r})}`);if(n){let r=[...e,...t].reduce((e,t)=>e+(t.size??0),0);if(r>n)throw new No(this.getI18n()(`aggregateExceedsSize`,{sizeAllowed:(0,Ao.default)(n),size:(0,Ao.default)(r)}))}}validateSingleFile(e){let{maxFileSize:t,minFileSize:n,allowedFileTypes:r}=this.getOpts().restrictions;if(r&&!r.some(t=>t.includes(`/`)?e.type?(0,jo.default)(e.type.replace(/;.*?$/,``),t):!1:t[0]===`.`&&e.extension?e.extension.toLowerCase()===t.slice(1).toLowerCase():!1)){let t=r.join(`, `);throw new No(this.getI18n()(`youCanOnlyUploadFileTypes`,{types:t}),{file:e})}if(t&&e.size!=null&&e.size>t)throw new No(this.getI18n()(`exceedsSize`,{size:(0,Ao.default)(t),file:e.name??this.getI18n()(`unnamed`)}),{file:e});if(n&&e.size!=null&&e.size<n)throw new No(this.getI18n()(`inferiorSize`,{size:(0,Ao.default)(n)}),{file:e})}validate(e,t){t.forEach(e=>{this.validateSingleFile(e)}),this.validateAggregateRestrictions(e,t)}validateMinNumberOfFiles(e){let{minNumberOfFiles:t}=this.getOpts().restrictions;if(t&&Object.keys(e).length<t)throw new No(this.getI18n()(`youHaveToAtLeastSelectX`,{smart_count:t}))}getMissingRequiredMetaFields(e){let t=new No(this.getI18n()(`missingRequiredMetaFieldOnFile`,{fileName:e.name??this.getI18n()(`unnamed`)})),{requiredMetaFields:n}=this.getOpts().restrictions,r=[];for(let t of n)(!Object.hasOwn(e.meta,t)||e.meta[t]===``)&&r.push(t);return{missingFields:r,error:t}}},Fo={name:`@uppy/store-default`,description:`The default simple object-based store for Uppy.`,version:`5.0.0`,license:`MIT`,main:`lib/index.js`,type:`module`,sideEffects:!1,scripts:{build:`tsc --build tsconfig.build.json`,typecheck:`tsc --build`,test:`vitest run --environment=jsdom --silent='passed-only'`},keywords:[`file uploader`,`uppy`,`uppy-store`],homepage:`https://uppy.io`,bugs:{url:`https://github.com/transloadit/uppy/issues`},devDependencies:{jsdom:`^26.1.0`,typescript:`^5.8.3`,vitest:`^3.2.4`},repository:{type:`git`,url:`git+https://github.com/transloadit/uppy.git`},exports:{".":`./lib/index.js`,"./package.json":`./package.json`},files:[`src`,`lib`,`dist`,`CHANGELOG.md`]},Io=class{static VERSION=Fo.version;state={};#e=new Set;getState(){return this.state}setState(e){let t={...this.state},n={...this.state,...e};this.state=n,this.#t(t,n,e)}subscribe(e){return this.#e.add(e),()=>{this.#e.delete(e)}}#t(...e){this.#e.forEach(t=>{t(...e)})}},Lo=e(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),Ro=e(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),zo=e(((e,t)=>{var n=Ro(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),Bo=e(((e,t)=>{var n=zo();t.exports=function(){return n.Date.now()}})),Vo=e(((e,t)=>{var n=/\s/;function r(e){for(var t=e.length;t--&&n.test(e.charAt(t)););return t}t.exports=r})),Ho=e(((e,t)=>{var n=Vo(),r=/^\s+/;function i(e){return e&&e.slice(0,n(e)+1).replace(r,``)}t.exports=i})),Uo=e(((e,t)=>{t.exports=zo().Symbol})),Wo=e(((e,t)=>{var n=Uo(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),Go=e(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),Ko=e(((e,t)=>
3{var n=Uo(),r=Wo(),i=Go(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),qo=e(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),Jo=e(((e,t)=>{var n=Ko(),r=qo(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),Yo=e(((e,t)=>{var n=Ho(),r=Lo(),i=Jo(),a=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;function u(e){if(typeof e==`number`)return e;if(i(e))return a;if(r(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=r(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=n(e);var u=s.test(e);return u||c.test(e)?l(e.slice(2),u?2:8):o.test(e)?a:+e}t.exports=u})),Xo=e(((e,t)=>{var n=Lo(),r=Bo(),i=Yo(),a=`Expected a function`,o=Math.max,s=Math.min;function c(e,t,c){var l,u,d,f,p,m,h=0,g=!1,_=!1,v=!0;if(typeof e!=`function`)throw TypeError(a);t=i(t)||0,n(c)&&(g=!!c.leading,_=`maxWait`in c,d=_?o(i(c.maxWait)||0,t):d,v=`trailing`in c?!!c.trailing:v);function y(t){var n=l,r=u;return l=u=void 0,h=t,f=e.apply(r,n),f}function b(e){return h=e,p=setTimeout(C,t),g?y(e):f}function x(e){var n=e-m,r=e-h,i=t-n;return _?s(i,d-r):i}function S(e){var n=e-m,r=e-h;return m===void 0||n>=t||n<0||_&&r>=d}function C(){var e=r();if(S(e))return w(e);p=setTimeout(C,x(e))}function w(e){return p=void 0,v&&l?y(e):(l=u=void 0,f)}function T(){p!==void 0&&clearTimeout(p),h=0,l=m=u=p=void 0}function E(){return p===void 0?f:w(r())}function D(){var e=r(),n=S(e);if(l=arguments,u=this,m=e,n){if(p===void 0)return b(m);if(_)return clearTimeout(p),p=setTimeout(C,t),y(m)}return p===void 0&&(p=setTimeout(C,t)),f}return D.cancel=T,D.flush=E,D}t.exports=c})),Zo=e(((e,t)=>{var n=Xo(),r=Lo(),i=`Expected a function`;function a(e,t,a){var o=!0,s=!0;if(typeof e!=`function`)throw TypeError(i);return r(a)&&(o=`leading`in a?!!a.leading:o,s=`trailing`in a?!!a.trailing:s),n(e,t,{leading:o,maxWait:t,trailing:s})}t.exports=a})),Qo=e(((e,t)=>{t.exports=function(){var e={},t=e._fns={};e.emit=function(e,t,i,a,o,s,c){var l=n(e);l.length&&r(e,l,[t,i,a,o,s,c])},e.on=function(e,n){t[e]||(t[e]=[]),t[e].push(n)},e.once=function(t,n){function r(){n.apply(this,arguments),e.off(t,r)}this.on(t,r)},e.off=function(e,t){var n=[];if(e&&t)for(var r=this._fns[e],i=0,a=r?r.length:0;i<a;i++)r[i]!==t&&n.push(r[i]);n.length?this._fns[e]=n:delete this._fns[e]};function n(e){for(var n=t[e]?t[e]:[],r=e.indexOf(`:`),i=r===-1?[e]:[e.substring(0,r),e.substring(r+1)],a=Object.keys(t),o=0,s=a.length;o<s;o++){var c=a[o];if(c===`*`&&(n=n.concat(t[c])),i.length===2&&i[0]===c){n=n.concat(t[c]);break}}return n}function r(e,t,n){for(var r=0,i=t.length;r<i&&t[r];r++)t[r].event=e,t[r].apply(t[r],n)}return e}})),$o=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,es=(e=21)=>{let t=``,n=e|0;for(;n--;)t+=$o[Math.random()*64|0];return t},ts={name:`@uppy/core`,description:`Core module for the extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:`,version:`5.2.0`,license:`MIT`,style:`dist/style.min.css`,type:`module`,sideEffects:[`*.css`],scripts:{build:`tsc --build tsconfig.build.json`,"build:css":`sass --load-path=../../ src/style.scss dist/style.css && postcss dist/style.css -u cssnano -o dist/style.min.css`,typecheck:`tsc --build`,test:`vitest run --environment=jsdom --silent='passed-only'`},keywords:[`file uploader`,`uppy`,`uppy-plugin`],homepage:`https://uppy.io`,bugs:{url:`https://github.com/transloadit/uppy/issues`},repository:{type:`git`,url:`git+https://github.com/transloadit/uppy.git`},files:[`src`,`lib`,`dist`,`CHANGELOG.md`],exports:{".":`./lib/index.js`,"./css/style.min.css":`./dist/style.min.css`,"./css/style.css":`./dist/style.css`,"./css/style.scss":`./src/style.scss`,"./package.json":`./package.json`},dependencies:{"@transloadit/prettier-bytes":`^0.3.4`,"@uppy/store-default":`^5.0.0`,"@uppy/utils":`^7.1.4`,lodash:`^4.17.21`,"mime-match":`^1.0.2`,"namespace-emitter":`^2.0.1`,nanoid:`^5.0.9`,preact:`^10.5.13`},devDependencies:{"@types/deep-freeze":`^0`,cssnano:`^7.0.7`,"deep-freeze":`^0.0.1`,jsdom:`^26.1.0`,postcss:`^8.5.
36`,"postcss-cli":`^11.0.1`,sass:`^1.89.2`,typescript:`^5.8.3`,vitest:`^3.2.4`}};function ns(e,t){return t.name?t.name:e.split(`/`)[0]===`image`?`${e.split(`/`)[0]}.${e.split(`/`)[1]}`:`noname`}var rs={strings:{addBulkFilesFailed:{0:`Failed to add %{smart_count} file due to an internal error`,1:`Failed to add %{smart_count} files due to internal errors`},youCanOnlyUploadX:{0:`You can only upload %{smart_count} file`,1:`You can only upload %{smart_count} files`},youHaveToAtLeastSelectX:{0:`You have to select at least %{smart_count} file`,1:`You have to select at least %{smart_count} files`},aggregateExceedsSize:`You selected %{size} of files, but maximum allowed size is %{sizeAllowed}`,exceedsSize:`%{file} exceeds maximum allowed size of %{size}`,missingRequiredMetaField:`Missing required meta fields`,missingRequiredMetaFieldOnFile:`Missing required meta fields in %{fileName}`,inferiorSize:`This file is smaller than the allowed size of %{size}`,youCanOnlyUploadFileTypes:`You can only upload: %{types}`,noMoreFilesAllowed:`Cannot add more files`,noDuplicates:`Cannot add the duplicate file '%{fileName}', it already exists`,companionError:`Connection with Companion failed`,authAborted:`Authentication aborted`,companionUnauthorizeHint:`To unauthorize to your %{provider} account, please go to %{url}`,failedToUpload:`Failed to upload %{file}`,noInternetConnection:`No Internet connection`,connectedToInternet:`Connected to the Internet`,noFilesFound:`You have no files or folders here`,noSearchResults:`Unfortunately, there are no results for this search`,selectX:{0:`Select %{smart_count}`,1:`Select %{smart_count}`},allFilesFromFolderNamed:`All files from folder %{name}`,openFolderNamed:`Open folder %{name}`,cancel:`Cancel`,logOut:`Log out`,logIn:`Log in`,pickFiles:`Pick files`,pickPhotos:`Pick photos`,filter:`Filter`,resetFilter:`Reset filter`,loading:`Loading...`,loadedXFiles:`Loaded %{numFiles} files`,authenticateWithTitle:`Please authenticate with %{pluginName} to select files`,authenticateWith:`Connect to %{pluginName}`,signInWithGoogle:`Sign in with Google`,searchImages:`Search for images`,enterTextToSearch:`Enter text to search for images`,search:`Search`,resetSearch:`Reset search`,emptyFolderAdded:`No files were added from empty folder`,addedNumFiles:`Added %{numFiles} file(s)`,folderAlreadyAdded:`The folder "%{folder}" was already added`,folderAdded:{0:`Added %{smart_count} file from %{folder}`,1:`Added %{smart_count} files from %{folder}`},additionalRestrictionsFailed:`%{count} additional restrictions were not fulfilled`,unnamed:`Unnamed`,pleaseWait:`Please wait`}};function is(e){if(e==null&&typeof navigator<`u`&&(e=navigator.userAgent),!e)return!0;let t=/Edge\/(\d+\.\d+)/.exec(e);if(!t)return!0;let n=t[1].split(`.`,2),r=parseInt(n[0],10),i=parseInt(n[1],10);return r<15||r===15&&i<15063||r>18||r===18&&i>=18218}var as=t(Zo(),1),os=t(Qo(),1),ss={totalProgress:0,allowNewUpload:!0,error:null,recoveredState:null},cs=class e{static VERSION=ts.version;#e=Object.create(null);#t;#n;#r=(0,os.default)();#i=new Set;#a=new Set;#o=new Set;defaultLocale;locale;opts;store;i18n;i18nArray;scheduledAutoProceed=null;wasOffline=!1;constructor(t){this.defaultLocale=rs;let n={id:`uppy`,autoProceed:!1,allowMultipleUploadBatches:!0,debug:!1,restrictions:Mo,meta:{},onBeforeFileAdded:(e,t)=>!Object.hasOwn(t,e.id),onBeforeUpload:e=>e,store:new Io,logger:To,infoTimeout:5e3},r={...n,...t};this.opts={...r,restrictions:{...n.restrictions,...t?.restrictions}},t?.logger&&t.debug?this.log("You are using a custom `logger`, but also set `debug: true`, which uses built-in logger to output logs to console. Ignoring `debug: true` and using your custom `logger`.",`warning`):t?.debug&&(this.opts.logger=Eo),this.log(`Using Core v${e.VERSION}`),this.i18nInit(),this.store=this.opts.store,this.setState({...ss,plugins:{},files:{},currentUploads:{},capabilities:{uploadProgress:is(),individualCancellation:!0,resumableUploads:!1},meta:{...this.opts.meta},info:[]}),this.#t=new Po(()=>this.opts,()=>this.i18n),this.#n=this.store.subscribe((e,t,n)=>{this.emit(`state-update`,e,t,n),this.updateAll(t)}),this.opts.debug&&typeof window<`u`&&(window[this.opts.id]=this),this.#b()}emit(e,...t){this.#r.emit(e,...t)}on(e,t){return this.#r.on(e,t),this}once(e,t){return this.#r.once(e,t),this}off(e,t){return this.#r.off(e,t),this}updateAll(e){this.iteratePlugins(t=>{t.update(e)})}setState(e){this.store.setState(e)}getState(){return this.store.getState()}patchFilesState(e){let t=this.getState().files;this.setState({files:{...t,...Object.fromEntries(Object.entries(e).map(([e,n])=>[e,{...t[e],...n}]))}})}setFileState(e,t){if(!this.getState().files[e])throw Error(`Can’t set state for ${e} (the file could have been removed)`);this.patchFilesState({[e]:t})}i18nInit(){let e=new ao([this.defaultLocale,this.opts.locale],{onMissingKey:e=>this.log(`Missing i18n string: ${e}`,`error`)});this.i18n=e.translate.bind(e),this.i18nArray=e.translateArray.bind(e),this.locale=e.locale}setOptions(e){this.opts={...this.opts,...e,restrictions:{...this.opts.restrictions,...e?.restrictions}},e.meta&&this.setMeta(e.meta),this.i18nInit(),e.locale&&this.iteratePlugins(t=>{t.setOptions(e)}),this.setState(void 0)}resetProgress(){let e={percentage:0,bytesUploaded:!1,uploadComplete:!1,uploadStarted:null}
vendor: 5,334 bytes, line 3
3,t={...this.getState().files},n=Object.create(null);Object.keys(t).forEach(r=>{n[r]={...t[r],progress:{...t[r].progress,...e},tus:void 0,transloadit:void 0}}),this.setState({files:n,...ss})}clear(){let{capabilities:e,currentUploads:t}=this.getState();if(Object.keys(t).length>0&&!e.individualCancellation)throw Error(`The installed uploader plugin does not allow removing files during an upload.`);this.setState({...ss,files:{}})}addPreProcessor(e){this.#i.add(e)}removePreProcessor(e){return this.#i.delete(e)}addPostProcessor(e){this.#o.add(e)}removePostProcessor(e){return this.#o.delete(e)}addUploader(e){this.#a.add(e)}removeUploader(e){return this.#a.delete(e)}setMeta(e){let t={...this.getState().meta,...e},n={...this.getState().files};Object.keys(n).forEach(t=>{n[t]={...n[t],meta:{...n[t].meta,...e}}}),this.log(`Adding metadata:`),this.log(e),this.setState({meta:t,files:n})}setFileMeta(e,t){let n={...this.getState().files};if(!n[e]){this.log(`Was trying to set metadata for a file that has been removed: ${e}`);return}let r={...n[e].meta,...t};n[e]={...n[e],meta:r},this.setState({files:n})}getFile(e){return this.getState().files[e]}getFiles(){let{files:e}=this.getState();return Object.values(e)}getFilesByIds(e){return e.map(e=>this.getFile(e))}getObjectOfFilesPerState(){let{files:e,totalProgress:t,error:n}=this.getState(),r=Object.values(e),i=[],a=[],o=[],s=[],c=[],l=[],u=[],d=[],f=[];for(let e of r){let{progress:t}=e;!t.uploadComplete&&t.uploadStarted&&(i.push(e),e.isPaused||d.push(e)),t.uploadStarted||a.push(e),(t.uploadStarted||t.preprocess||t.postprocess)&&o.push(e),t.uploadStarted&&s.push(e),e.isPaused&&c.push(e),t.uploadComplete&&l.push(e),e.error&&u.push(e),(t.preprocess||t.postprocess)&&f.push(e)}return{newFiles:a,startedFiles:o,uploadStartedFiles:s,pausedFiles:c,completeFiles:l,erroredFiles:u,inProgressFiles:i,inProgressNotPausedFiles:d,processingFiles:f,isUploadStarted:s.length>0,isAllComplete:t===100&&l.length===r.length&&f.length===0,isAllErrored:!!n&&u.length===r.length,isAllPaused:i.length!==0&&c.length===i.length,isUploadInProgress:i.length>0,isSomeGhost:r.some(e=>e.isGhost)}}#s(e){for(let t of e)t.isRestriction?this.emit(`restriction-failed`,t.file,t):this.emit(`error`,t,t.file),this.log(t,`warning`);let t=e.filter(e=>e.isUserFacing),n=t.slice(0,4),r=t.slice(4);n.forEach(({message:e,details:t=``})=>{this.info({message:e,details:t},`error`,this.opts.infoTimeout)}),r.length>0&&this.info({message:this.i18n(`additionalRestrictionsFailed`,{count:r.length})})}validateRestrictions(e,t=this.getFiles()){try{this.#t.validate(t,[e])}catch(e){return e}return null}validateSingleFile(e){try{this.#t.validateSingleFile(e)}catch(e){return e.message}return null}validateAggregateRestrictions(e){let t=this.getFiles();try{this.#t.validateAggregateRestrictions(t,e)}catch(e){return e.message}return null}#c(e){let{missingFields:t,error:n}=this.#t.getMissingRequiredMetaFields(e);return t.length>0?(this.setFileState(e.id,{missingRequiredMetaFields:t,error:n.message}),this.log(n.message),this.emit(`restriction-failed`,e,n),!1):(t.length===0&&e.missingRequiredMetaFields&&this.setFileState(e.id,{missingRequiredMetaFields:[]}),!0)}#l(e){let t=!0;for(let n of Object.values(e))this.#c(n)||(t=!1);return t}#u(e){let{allowNewUpload:t}=this.getState();if(t===!1){let t=new No(this.i18n(`noMoreFilesAllowed`),{file:e});throw this.#s([t]),t}}checkIfFileAlreadyExists(e){let{files:t}=this.getState();return!!(t[e]&&!t[e].isGhost)}#d(e){let t=e instanceof File?{name:e.name,type:e.type,size:e.size,data:e,meta:{},isRemote:!1,source:void 0,preview:void 0}:e,n=Ua(t),r=ns(n,t),i=Va(r).extension,a=Ja(t,this.getID()),o={...t.meta,name:r,type:n},s=Number.isFinite(t.data.size)?t.data.size:null;return{source:t.source||``,id:a,name:r,extension:i||``,meta:{...this.getState().meta,...o},type:n,progress:{percentage:0,bytesUploaded:!1,bytesTotal:s,uploadComplete:!1,uploadStarted:null},size:s,isGhost:!1,...t.isRemote?{isRemote:!0,remote:t.remote,data:t.data}:{isRemote:!1,data:t.data},preview:t.preview}}#f(){this.opts.autoProceed&&!this.scheduledAutoProceed&&(this.scheduledAutoProceed=setTimeout(()=>{this.scheduledAutoProceed=null,this.upload().catch(e=>{e.isRestriction||this.log(e.stack||e.message||e)})},4))}#p(e){let{files:t}=this.getState(),n={...t},r=[],i=[];for(let a of e)try{let e=this.#d(a);this.#u(e);let i=t[e.id],o=i?.isGhost;if(o&&!e.isRemote){if(e.data==null)throw Error(`File data is missing`);e={...i,isGhost:!1,data:e.data},this.log(`Replaced the blob in the restored ghost file: ${e.name}, ${e.id}`)}let s=this.opts.onBeforeFileAdded(e,n);if(t=this.getState().files,n={...t,...n},!s&&this.checkIfFileAlreadyExists(e.id))throw new No(this.i18n(`noDuplicates`,{fileName:e.name??this.i18n(`unnamed`)}),{file:e});if(s===!1&&!o)throw new No(`Cannot add the file because onBeforeFileAdded returned false.`,{isUserFacing:!1,file:e});typeof s==`object`&&s&&(e=s),this.#t.validateSingleFile(e),n[e.id]=e,r.push(e)}catch(e){i.push(e)}try{this.#t.validateAggregateRestrictions(Object.values(t),r)}catch(e){return i.push(e),{nextFilesState:t,validFilesToAdd:[],errors:i}}return{nextFilesState:n,validFilesToAdd:r,errors:i}}addFile(e){let{nextFilesState:t,validFilesToAdd:n,errors:r}=this.#p([e]),i=r.filter(e=>e.isRestriction);if(this.#s(i),r.length>0)throw r[0];this.setState({files:t});let[a]=n;
3return this.emit(`file-added`,a),this.emit(`files-added`,n),this.log(`Added file: ${a.name}, ${a.id}, mime type: ${a.type}`),this.#f(),a.id}addFiles(e){let{nextFilesState:t,validFilesToAdd:n,errors:r}=this.#p(e),i=r.filter(e=>e.isRestriction);this.#s(i);let a=r.filter(e=>!e.isRestriction);if(a.length>0){let e=`Multiple errors occurred while adding files:
4`;if(a.forEach(t=>{e+=`\n * ${t.message}`}),this.info({message:this.i18n(`addBulkFilesFailed`,{smart_count:a.length}),details:e},`error`,this.opts.infoTimeout),typeof AggregateError==`function`)throw AggregateError(a,e);{let t=Error(e);throw t.errors=a,t}}this.setState({files:t}),n.forEach(e=>{this.emit(`file-added`,e)}),this.emit(`files-added`,n),n.length>5?this.log(`Added batch of ${n.length} files`):Object.values(n).forEach(e=>{this.log(`Added file: ${e.name}\n id: ${e.id}\n type: ${e.type}`)}),n.length>0&&this.#f()}removeFiles(e){let{files:t,currentUploads:n}=this.getState(),r={...t},i={...n},a=Object.create(null);e.forEach(e=>{t[e]&&(a[e]=t[e],delete r[e])});function o(e){return a[e]===void 0}
4Object.keys(i).forEach(e=>{let t=n[e].fileIDs.filter(o);if(t.length===0){delete i[e];return}let{capabilities:r}=this.getState();if(t.length!==n[e].fileIDs.length&&!r.individualCancellation)throw Error(`The installed uploader plugin does not allow removing files during an upload.`);i[e]={...n[e],fileIDs:t}});let s={currentUploads:i,files:r};Object.keys(r).length===0&&(s.allowNewUpload=!0,s.error=null,s.recoveredState=null),this.setState(s),this.#v();let c=Object.keys(a);c.forEach(e=>{this.emit(`file-removed`,a[e])}),c.length>5?this.log(`Removed ${c.length} files`):this.log(`Removed files: ${c.join(`, `)}`)}removeFile(e){this.removeFiles([e])}pauseResume(e){if(!this.getState().capabilities.resumableUploads||this.getFile(e).progress.uploadComplete)return;let t=this.getFile(e),n=!t.isPaused;return this.setFileState(e,{isPaused:n}),this.emit(`upload-pause`,t,n),n}pauseAll(){let e={...this.getState().files};Object.keys(e).filter(t=>!e[t].progress.uploadComplete&&e[t].progress.uploadStarted).forEach(t=>{e[t]={...e[t],isPaused:!0}}),this.setState({files:e}),this.emit(`pause-all`)}resumeAll(){let e={...this.getState().files};Object.keys(e).filter(t=>!e[t].progress.uploadComplete&&e[t].progress.uploadStarted).forEach(t=>{e[t]={...e[t],isPaused:!1,error:null}}),this.setState({files:e}),this.emit(`resume-all`)}#m(){let{files:e}=this.getState();return Object.keys(e).filter(t=>{let n=e[t];return n.error&&(!n.missingRequiredMetaFields||n.missingRequiredMetaFields.length===0)})}async#h(){let e=this.#m(),t={...this.getState().files};if(e.forEach(e=>{t[e]={...t[e],isPaused:!1,error:null}}),this.setState({files:t,error:null}),this.emit(`retry-all`,this.getFilesByIds(e)),e.length===0)return{successful:[],failed:[]};let n=this.#C(e,{forceAllowNewUpload:!0});return this.#E(n)}async retryAll(){let e=await this.#h();return this.emit(`complete`,e),e}cancelAll(){this.emit(`cancel-all`);let{files:e}=this.getState(),t=Object.keys(e);t.length&&this.removeFiles(t),this.setState(ss)}retryUpload(e){this.setFileState(e,{error:null,isPaused:!1}),this.emit(`upload-retry`,this.getFile(e));let t=this.#C([e],{forceAllowNewUpload:!0});return this.#E(t)}logout(){this.iteratePlugins(e=>{e.provider?.logout?.()})}#g=(e,t)=>{let n=e?this.getFile(e.id):void 0;if(e==null||!n){this.log(`Not setting progress for a file that has been removed: ${e?.id}`);return}if(n.progress.percentage===100){this.log(`Not setting progress for a file that has been already uploaded: ${e.id}`);return}let r={bytesTotal:t.bytesTotal,percentage:t.bytesTotal!=null&&Number.isFinite(t.bytesTotal)&&t.bytesTotal>0?Math.round(t.bytesUploaded/t.bytesTotal*100):void 0};n.progress.uploadStarted==null?this.setFileState(e.id,{progress:{...n.progress,...r}}):this.setFileState(e.id,{progress:{...n.progress,...r,bytesUploaded:t.bytesUploaded}}),this.#v()};#_(){let e=this.#y(),t=null;e!=null&&(t=Math.round(e*100),t>100?t=100:t<0&&(t=0)),this.emit(`progress`,t??0),this.setState({totalProgress:t??0})}#v=(0,as.default)(()=>this.#_(),500,{leading:!0,trailing:!0});[Symbol.for(`uppy test: updateTotalProgress`)](){return this.#_()}#y(){let e=this.getFiles().filter(e=>e.progress.uploadStarted||e.progress.preprocess||e.progress.postprocess);if(e.length===0)return 0;if(e.every(e=>e.progress.uploadComplete))return 1;let t=e=>e.progress.bytesTotal!=null&&e.progress.bytesTotal!==0,n=e.filter(t),r=e.filter(e=>!t(e));if(n.every(e=>e.progress.uploadComplete)&&r.length>0&&!r.every(e=>e.progress.uploadComplete))return null;let i=n.reduce((e,t)=>e+(t.progress.bytesTotal??0),0),a=n.reduce((e,t)=>e+(t.progress.bytesUploaded||0),0);return i===0?0:a/i}#b(){let e=(e,t,n)=>{let r=e.message||`Unknown error`;e.details&&(r+=` ${e.details}`),this.setState({error:r}),t!=null&&t.id in this.getState().files&&this.setFileState(t.id,{error:r,response:n})};this.on(`error`,e),this.on(`upload-error`,(t,n,r)=>{if(e(n,t,r),typeof n==`object`&&n.message){this.log(n.message,`error`);let e=Error(this.i18n(`failedToUpload`,{file:t?.name??``}));e.isUserFacing=!0,e.details=n.message,n.details&&(e.details+=` ${n.details}`),this.#s([e])}else this.#s([n])});let t=null;this.on(`upload-stalled`,(e,n)=>{let{message:r}=e,i=n.map(e=>e.meta.name).join(`, `);t||=(this.info({message:r,details:i},`warning`,this.opts.infoTimeout),setTimeout(()=>{t=null},this.opts.infoTimeout)),this.log(`${r} ${i}`.trim(),`warning`)}),this.on(`upload`,()=>{this.setState({error:null})}),this.on(`upload-start`,e=>{let t=e.filter(e=>{let t=e!=null&&this.getFile(e.id);return t||this.log(`Not setting progress for a file that has been removed: ${e?.id}`),t}),n=Object.fromEntries(t.map(e=>[e.id,{progress:{uploadStarted:Date.now(),uploadComplete:!1,bytesUploaded:0,bytesTotal:e.size}}]));this.patchFilesState(n)}),this.on(`upload-progress`,this.#g),this.on(`upload-success`,(e,t)=>{if(e==null||!this.getFile(e.id)){this.log(`Not setting progress for a file that has been removed: ${e?.id}`);return}let n=this.getFile(e.id).progress,r=this.#o.size>0;this.setFileState(e.id,{progress:{...n,postprocess:r?{mode:`indeterminate`}:void 0,uploadComplete:!0,...!r&&{complete:!0},percentage:100,bytesUploaded:n.bytesTotal},response:t,uploadURL:t.uploadURL,isPaused:!1}),e.size??this.setFileState(e.id,{size:t.bytesUploaded||n.bytesTotal}),this.#v()}),this.on(`preprocess-progress`,(e,t)=>{if(e==null||!this.getFile(e.id)){this.log(`Not setting progress for a file that has been removed: ${e?.id}`);return}this.setFileState(e.id,{progress:{...this.getFile(e.id).progress,preprocess:t}})}),this.on(`preprocess-complete`,e=>{if(e==null||!this.getFile(e.id)){this.log(`Not setting progress for a file that has been removed: ${e?.id}`);return}
vendor: 3,173 bytes, line 4
4let t={...this.getState().files};t[e.id]={...t[e.id],progress:{...t[e.id].progress}},delete t[e.id].progress.preprocess,this.setState({files:t})}),this.on(`postprocess-progress`,(e,t)=>{if(e==null||!this.getFile(e.id)){this.log(`Not setting progress for a file that has been removed: ${e?.id}`);return}this.setFileState(e.id,{progress:{...this.getState().files[e.id].progress,postprocess:t}})}),this.on(`postprocess-complete`,e=>{let t=e&&this.getFile(e.id);if(t==null){this.log(`Not setting progress for a file that has been removed: ${e?.id}`);return}let{postprocess:n,...r}=t.progress;this.patchFilesState({[t.id]:{progress:{...r,complete:!0}}})}),this.on(`restored`,()=>{this.#v()}),this.on(`dashboard:file-edit-complete`,e=>{e&&this.#c(e)}),typeof window<`u`&&window.addEventListener&&(window.addEventListener(`online`,this.#x),window.addEventListener(`offline`,this.#x),setTimeout(this.#x,3e3))}updateOnlineStatus(){window.navigator.onLine??!0?(this.emit(`is-online`),this.wasOffline&&=(this.emit(`back-online`),this.info(this.i18n(`connectedToInternet`),`success`,3e3),!1)):(this.emit(`is-offline`),this.info(this.i18n(`noInternetConnection`),`error`,0),this.wasOffline=!0)}#x=this.updateOnlineStatus.bind(this);getID(){return this.opts.id}use(e,...t){if(typeof e!=`function`)throw TypeError(`Expected a plugin class, but got ${e===null?`null`:typeof e}. Please verify that the plugin was imported and spelled correctly.`);let n=new e(this,...t),r=n.id;if(!r)throw Error(`Your plugin must have an id`);if(!n.type)throw Error(`Your plugin must have a type`);let i=this.getPlugin(r);if(i){let e=`Already found a plugin named '${i.id}'. Tried to use: '${r}'.\nUppy plugins must have unique \`id\` options.`;throw Error(e)}return e.VERSION&&this.log(`Using ${r} v${e.VERSION}`),n.type in this.#e?this.#e[n.type].push(n):this.#e[n.type]=[n],n.install(),this.emit(`plugin-added`,n),this}getPlugin(e){for(let t of Object.values(this.#e)){let n=t.find(t=>t.id===e);if(n!=null)return n}}[Symbol.for(`uppy test: getPlugins`)](e){return this.#e[e]}iteratePlugins(e){Object.values(this.#e).flat(1).forEach(e)}removePlugin(e){this.log(`Removing plugin ${e.id}`),this.emit(`plugin-remove`,e),e.uninstall&&e.uninstall();let t=this.#e[e.type],n=t.findIndex(t=>t.id===e.id);n!==-1&&t.splice(n,1);let r={plugins:{...this.getState().plugins,[e.id]:void 0}};this.setState(r)}destroy(){this.log(`Closing Uppy instance ${this.opts.id}: removing all files and uninstalling plugins`),this.cancelAll(),this.#n(),this.iteratePlugins(e=>{this.removePlugin(e)}),typeof window<`u`&&window.removeEventListener&&(window.removeEventListener(`online`,this.#x),window.removeEventListener(`offline`,this.#x))}hideInfo(){let{info:e}=this.getState();this.setState({info:e.slice(1)}),this.emit(`info-hidden`)}info(e,t=`info`,n=3e3){let r=typeof e==`object`;this.setState({info:[...this.getState().info,{type:t,message:r?e.message:e,details:r?e.details:null}]}),setTimeout(()=>this.hideInfo(),n),this.emit(`info-visible`)}log(e,t){let{logger:n}=this.opts;switch(t){case`error`:n.error(e);break;case`warning`:n.warn(e);break;default:n.debug(e);break}}#S=new Map;registerRequestClient(e,t){this.#S.set(e,t)}
4getRequestClientForFile(e){if(!(`remote`in e&&e.remote))throw Error(`Tried to get RequestClient for a non-remote file ${e.id}`);let t=this.#S.get(e.remote.requestClientId);if(t==null)throw Error(`requestClientId "${e.remote.requestClientId}" not registered for file "${e.id}"`);return t}async restore(e){this.log(`Core: Running restored upload "${e}"`);let t=await this.#E(e);return this.emit(`complete`,t),t}#C(e,t={}){let{forceAllowNewUpload:n=!1}=t,{allowNewUpload:r,currentUploads:i}=this.getState();if(!r&&!n)throw Error(`Cannot create a new upload: already uploading.`);let a=es();return this.emit(`upload`,a,this.getFilesByIds(e)),this.setState({allowNewUpload:this.opts.allowMultipleUploadBatches!==!1&&this.opts.allowMultipleUploads!==!1,currentUploads:{...i,[a]:{fileIDs:e,step:0,result:{}}}}),a}[Symbol.for(`uppy test: createUpload`)](...e){return this.#C(...e)}#w(e){let{currentUploads:t}=this.getState();return t[e]}addResultData(e,t){if(!this.#w(e)){this.log(`Not setting result for an upload that has been removed: ${e}`);return}let{currentUploads:n}=this.getState(),r={...n[e],result:{...n[e].result,...t}};this.setState({currentUploads:{...n,[e]:r}})}#T(e){let{[e]:t,...n}=this.getState().currentUploads;this.setState({currentUploads:n})}async#E(e){let t=()=>{let{currentUploads:t}=this.getState();return t[e]},n=t();if(!n)throw Error(`Nonexistent upload`);let r=[...this.#i,...this.#a,...this.#o];try{for(let i=n.step||0;i<r.length;i++){let a=r[i];this.setState({currentUploads:{...this.getState().currentUploads,[e]:{...n,step:i}}});let{fileIDs:o}=n;if(await a(o,e),n=t(),!n)break}}catch(t){throw this.#T(e),t}if(n){n.fileIDs.forEach(e=>{let t=this.getFile(e);t?.progress.postprocess&&this.emit(`postprocess-complete`,t)});let r=n.fileIDs.map(e=>this.getFile(e)),i=r.filter(e=>!e.error),a=r.filter(e=>e.error);this.addResultData(e,{successful:i,failed:a,uploadID:e}),n=t()}let i;return n&&(i=n.result,this.#T(e)),i??=(this.log(`Not setting result for an upload that has been removed: ${e}`),{successful:[],failed:[],uploadID:e}),i}async upload(){this.#e.uploader?.length||this.log(`No uploader type plugins are used`,`warning`);let{files:e}=this.getState();if(this.#m().length>0){let t=await this.#h();if(!(this.getFiles().filter(e=>e.progress.uploadStarted==null).length>0))return this.emit(`complete`,t),t;({files:e}=this.getState())}let t=this.opts.onBeforeUpload(e);if(t===!1)throw Error(`Not starting the upload because onBeforeUpload returned false`);t&&typeof t==`object`&&(e=t,this.setState({files:e}));try{if(this.#t.validateMinNumberOfFiles(e),!this.#l(e))throw new No(this.i18n(`missingRequiredMetaField`));let{currentUploads:t}=this.getState(),n=Object.values(t).flatMap(e=>e.fileIDs),r=Object.keys(e).filter(e=>{let t=this.getFile(e);return t&&!t.progress.uploadStarted&&!n.includes(e)}),i=this.#C(r),a=await this.#E(i);return this.emit(`complete`,a),a}catch(e){throw this.#s([e]),e}}},ls={name:`@uppy/aws-s3`,description:`Upload to Amazon S3 with Uppy`,version:`5.1.0`,license:`MIT`,type:`module`,sideEffects:!1,scripts:{build:`tsc --build tsconfig.build.json`,typecheck:`tsc --build`,test:`vitest run --environment=jsdom --silent='passed-only'`},keywords:[`file uploader`,`aws s3`,`amazon s3`,`s3`,`uppy`,`uppy-plugin`,`multipart`],homepage:`https://uppy.io`,bugs:{url:`https://github.com/transloadit/uppy/issues`},repository:{type:`git`,url:`git+https://github.com/transloadit/uppy.git`},files:[`src`,`lib`,`dist`,`CHANGELOG.md`],exports:{".":`./lib/index.js`,"./package.json":`./package.json`},dependencies:{"@uppy/companion-client":`^5.1.1`,"@uppy/utils":`^7.1.4`},devDependencies:{"@aws-sdk/client-s3":`^3.362.0`,"@aws-sdk/s3-request-presigner":`^3.362.0`,"@uppy/core":`^5.2.0`,jsdom:`^26.1.0`,nock:`^13.1.0`,typescript:`^5.8.3`,vitest:`^3.2.4`,"whatwg-fetch":`3.6.2`},peerDependencies:{"@uppy/core":`^5.2.0`}};function us({method:e=`PUT`,CanonicalUri:t=`/`,CanonicalQueryString:n=``,SignedHeaders:r,HashedPayload:i}){let a=Object.keys(r).map(e=>e.toLowerCase()).sort();return[e,t,n,...a.map(e=>`${e}:${r[e]}`),``,a.join(`;`),i].join(`
5`)}var ds=new TextEncoder,fs={name:`HMAC`,hash:`SHA-256`};async function ps(e){let{subtle:t}=globalThis.crypto;return t.digest(fs.hash,ds.encode(e))}async function ms(e){let{subtle:t}=globalThis.crypto;return t.importKey(`raw`,typeof e==`string`?ds.encode(e):e,fs,!1,[`sign`])}function hs(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=t[e].toString(16).padStart(2,`0`);return n}async function gs(e,t){let{subtle:n}=globalThis.crypto;return n.sign(fs,await ms(e),ds.encode(t))}async function _s({accountKey:e,accountSecret:t,sessionToken:n,bucketN
5ame:r,Key:i,Region:a,expires:o,uploadId:s,partNumber:c}){let l=`s3.${a}.amazonaws.com`,u=`/${r}/${encodeURI(i).replace(/[;?:@&=+$,#!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}`,d=`UNSIGNED-PAYLOAD`,f=new Date().toISOString().replace(/[-:]|\.\d+/g,``),p=f.slice(0,8),m=`${p}/${a}/s3/aws4_request`,h=new URL(`https://${l}${u}`);h.searchParams.set(`X-Amz-Algorithm`,`AWS4-HMAC-SHA256`),h.searchParams.set(`X-Amz-Content-Sha256`,d),h.searchParams.set(`X-Amz-Credential`,`${e}/${m}`),h.searchParams.set(`X-Amz-Date`,f),h.searchParams.set(`X-Amz-Expires`,o),h.searchParams.set(`X-Amz-Security-Token`,n),h.searchParams.set(`X-Amz-SignedHeaders`,`host`),c&&h.searchParams.set(`partNumber`,c),s&&h.searchParams.set(`uploadId`,s),h.searchParams.set(`x-id`,c&&s?`UploadPart`:`PutObject`);let g=[`AWS4-HMAC-SHA256`,f,m,hs(await ps(us({CanonicalUri:u,CanonicalQueryString:h.search.slice(1),SignedHeaders:{host:l},HashedPayload:d})))].join(`
6`),_=hs(await gs(await gs(await gs(await gs(await gs(`AWS4${t}`,p),a),`s3`),`aws4_request`),g));return h.searchParams.set(`X-Amz-Signature`,_),h}var vs=1024*1024,ys={getChunkSize(e){return Math.ceil(e.size/1e4)},onProgress(){},onPartComplete(){},onSuccess(){},onError(e){throw e}};function bs(e){if(typeof e==`string`)return parseInt(e,10);if(typeof e==`number`)return e;throw TypeError(`Expected a number`)}var xs=Symbol(`pausing upload, not an actual error`),Ss=class{options;#e=new ja;#t=[];#n=[];#r;#i;#a=!1;#o;#s;#c;#l;#u=e=>e?.cause===xs?null:this.#o(e);#d=1e4;#f=5*vs;constructor(e,t){this.options={...ys,...t},this.options.getChunkSize??=ys.getChunkSize,this.#r=e,this.#i=t.file,this.#s=this.options.onSuccess,this.#o=this.options.onError,this.#c=this.options.shouldUseMultipart,this.#l=t.uploadId&&t.key,this.#p()}#p(){let e=this.#r.size,t=typeof this.#c==`function`?this.#c(this.#i):!!this.#c;if(t&&e>this.#f){let n=Math.max(this.options.getChunkSize(this.#r),this.#f),r=Math.floor(e/n);r>this.#d&&(r=this.#d,n=e/this.#d),this.#t=Array(r);for(let r=0,i=0;r<e;r+=n,i++){let a=Math.min(e,r+n),o=()=>{let e=r;return this.#r.slice(e,a)};if(this.#t[i]={getData:o,onProgress:this.#g(i),onComplete:this.#_(i),shouldUseMultipart:t},this.#l){let t=r+n>e?e-r:n;this.#t[i].setAsUploaded=()=>{this.#t[i]=null,this.#n[i].uploaded=t}}}}else this.#t=[{getData:()=>this.#r,onProgress:this.#g(0),onComplete:this.#_(0),shouldUseMultipart:t}];this.#n=this.#t.map(()=>({uploaded:0}))}#m(){this.options.companionComm.uploadFile(this.#i,this.#t,this.#e.signal).then(this.#s,this.#u),this.#a=!0}#h(){this.options.companionComm.resumeUploadFile(this.#i,this.#t,this.#e.signal).then(this.#s,this.#u)}#g=e=>t=>{if(!t.lengthComputable)return;this.#n[e].uploaded=bs(t.loaded);let n=this.#n.reduce((e,t)=>e+t.uploaded,0);this.options.onProgress(n,this.#r.size)};#_=e=>t=>{this.#t[e]=null,this.#n[e].etag=t,this.#n[e].done=!0;let n={PartNumber:e+1,ETag:t};this.options.onPartComplete(n)};#v(){this.#e.abort(),this.options.companionComm.abortFileUpload(this.#i).catch(e=>this.options.log(e))}start(){this.#a?(this.#e.signal.aborted||this.#e.abort(xs),this.#e=new ja,this.#h()):this.#l?(this.options.companionComm.restoreUploadFile(this.#i,{uploadId:this.options.uploadId,key:this.options.key}),this.#h()):this.#m()}pause(){this.#e.abort(xs),this.#e=new ja}abort(e){e?.really?this.#v():this.pause()}[Symbol.for(`uppy test: getChunkState`)](){return this.#n}};function Q(e){if(e?.aborted)throw Na(`The operation was aborted`,{cause:e.reason})}function Cs(e){let t=new URL(e);return t.search=``,t.hash=``,t.href}var ws=class{#e;#t=new WeakMap;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;constructor(e,t,n,r){this.#s=e,this.#u=n,this.#f=r,this.setOptions(t)}setOptions(e){let t=this.#s;`abortMultipartUpload`in e&&(this.#e=t.wrapPromiseFunction(e.abortMultipartUpload,{priority:1})),`createMultipartUpload`in e&&(this.#n=t.wrapPromiseFunction(e.createMultipartUpload,{priority:-1})),`signPart`in e&&(this.#r=t.wrapPromiseFunction(e.signPart)),`listParts`in e&&(this.#a=t.wrapPromiseFunction(e.listParts)),`completeMultipartUpload`in e&&(this.#l=t.wrapPromiseFunction(e.completeMultipartUpload,{priority:1})),`retryDelays`in e&&(this.#c=e.retryDelays??[]),`uploadPartBytes`in e&&(this.#d=t.wrapPromiseFunction(e.uploadPartBytes,{priority:1/0})),`getUploadParameters`in e&&(this.#i=t.wrapPromiseFunction(e.getUploadParameters))}async#p(e,t){let n=this.#s,r=e?.source?.status;if(r==null)return!1;if(r===403&&e.message===`Request has expired`){if(!n.isPaused){if(n.limit===1||this.#o==null){let e=t.next();if(e==null||e.done)return!1;this.#o=e.value}n.rateLimit(0),await new Promise(e=>setTimeout(e,this.#o))}}else if(r===429){if(!n.isPaused){let e=t.next();if(e==null||e.done)return!1;n.rateLimit(e.value)}}else if(r>400&&r<500&&r!==409)return!1;else if(typeof navigator<`u`&&navigator.onLine===!1)n.isPaused||(n.pause(),window.addEventListener(`online`,()=>{n.resume()},{once:!0}));else{let e=t.next();if(e==null||e.done)return!1;await new Promise(t=>setTimeout(t,e.value))}return!0}async getUploadId(e,t){let n;for(;;){if(e.data==null)throw Error(`File data is empty`);if(n=this.#t.get(e.data),n==null)break;try{return await n}catch{}}let r=this.#n(this.#f(e),t),i=()=>
6{if(e.data==null)throw Error(`File data is empty`);r.abort(t.reason),this.#t.delete(e.data)};return t.addEventListener(`abort`,i,{once:!0}),this.#t.set(e.data,r),r.then(async n=>{if(t.removeEventListener(`abort`,i),this.#u(e,n),e.data==null)throw Error(`File data is empty`);this.#t.set(e.data,n)},()=>{if(t.removeEventListener(`abort`,i),e.data==null)throw Error(`File data is empty`);this.#t.delete(e.data)}),r}async abortFileUpload(e){if(e.data==null)throw Error(`File data is empty`);let t=this.#t.get(e.data);if(t==null)return;this.#t.delete(e.data),this.#u(e,Object.create(null));let n;try{n=await t}catch{return}await this.#e(this.#f(e),n)}async#m(e,t,n){let{method:r=`POST`,url:i,fields:a,headers:o}=await this.#i(this.#f(e),{signal:n}).abortOn(n),s,c=t.getData();if(r.toUpperCase()===`POST`){let e=new FormData;Object.entries(a).forEach(([t,n])=>e.set(t,n)),e.set(`file`,c),s=e}else s=c;let{onProgress:l,onComplete:u}=t,d=await this.#d({signature:{url:i,headers:o,method:r},body:s,size:c.size,onProgress:l,onComplete:u,signal:n}).abortOn(n),f=a?.key;return this.#u(e,{key:f}),{...d,location:d.location??Cs(i),bucket:a?.bucket,key:f}}async uploadFile(e,t,n){if(Q(n),t.length===1&&!t[0].shouldUseMultipart)return this.#m(e,t[0],n);let{uploadId:r,key:i}=await this.getUploadId(e,n);Q(n);try{let a=await Promise.all(t.map((t,r)=>this.uploadChunk(e,r+1,t,n)));return Q(n),await this.#l(this.#f(e),{key:i,uploadId:r,parts:a,signal:n},n).abortOn(n)}catch(t){throw t?.cause!==xs&&t?.name!==`AbortError`&&this.abortFileUpload(e),t}}restoreUploadFile(e,t){if(e.data==null)throw Error(`File data is empty`);this.#t.set(e.data,t)}async resumeUploadFile(e,t,n){if(Q(n),t.length===1&&t[0]!=null&&!t[0].shouldUseMultipart)return this.#m(e,t[0],n);let{uploadId:r,key:i}=await this.getUploadId(e,n);Q(n);let a=await this.#a(this.#f(e),{uploadId:r,key:i,signal:n},n).abortOn(n);Q(n);let o=await Promise.all(t.map((t,r)=>{let i=r+1,o=a.find(({PartNumber:e})=>e===i);return o==null?this.uploadChunk(e,i,t,n):(t?.setAsUploaded?.(),{PartNumber:i,ETag:o.ETag})}));return Q(n),this.#l(this.#f(e),{key:i,uploadId:r,parts:o,signal:n},n).abortOn(n)}async uploadChunk(e,t,n,r){Q(r);let{uploadId:i,key:a}=await this.getUploadId(e,r),o=this.#c.values(),s=this.#c.values(),c=()=>{let e=o.next();return e==null||e.done?null:e.value};for(;;){Q(r);let o=n.getData(),{onProgress:l,onComplete:u}=n,d;try{d=await this.#r(this.#f(e),{uploadId:i,key:a,partNumber:t,body:o,signal:r}).abortOn(r)}catch(e){let t=c();if(t==null||r.aborted)throw e;await new Promise(e=>setTimeout(e,t));continue}Q(r);try{return{PartNumber:t,...await this.#d({signature:d,body:o,size:o.size,onProgress:l,onComplete:u,signal:r}).abortOn(r)}}catch(e){if(!await this.#p(e,s))throw e}}}};function Ts(e){if(e?.error){let t=Error(e.message);throw Object.assign(t,e.error),t}return e}function Es(e){let t=e.Expiration;if(t){let e=Math.floor((new Date(t)-Date.now())/1e3);if(e>9)return e}}function Ds({meta:e,allowedMetaFields:t,querify:n=!1}){return e?Object.fromEntries((t??Object.keys(e)).filter(t=>e[t]!=null).map(t=>[n?`metadata[${t}]`:t,String(e[t])])):{}}var Os={allowedMetaFields:!0,limit:6,getTemporarySecurityCredentials:!1,shouldUseMultipart:(e=>(e.size||0)>100*1024*1024),retryDelays:[0,1e3,3e3,5e3]},ks=class e extends Co{static VERSION=ls.version;#e;#t;requests;uploaderEvents;uploaders;constructor(t,n){super(t,{...Os,uploadPartBytes:e.uploadPartBytes,createMultipartUpload:null,listParts:null,abortMultipartUpload:null,completeMultipartUpload:null,signPart:null,getUploadParameters:null,...n}),this.type=`uploader`,this.id=this.opts.id||`AwsS3Multipart`,this.#n(n);let r={createMultipartUpload:this.createMultipartUpload,listParts:this.listParts,abortMultipartUpload:this.abortMultipartUpload,completeMultipartUpload:this.completeMultipartUpload,signPart:n?.getTemporarySecurityCredentials?this.createSignedURL:this.signPart,getUploadParameters:n?.getTemporarySecurityCredentials?this.createSignedURL:this.getUploadParameters};for(let e of Object.keys(r))this.opts[e]??(this.opts[e]=r[e].bind(this));this.requests=this.opts.rateLimitedQueue??new to(this.opts.limit),this.#e=new ws(this.requests,this.opts,this.#o,this.#s),this.uploaders=Object.create(null),this.uploaderEvents=Object.create(null)}[Symbol.for(`uppy test: getClient`)](){return this.#t}#n(e){e==null||!(`endpoint`in e||`companionUrl`in e||`headers`in e||`companionHeaders`in e||`cookiesRule`in e||`companionCookiesRule`in e)||(`companionUrl`in e&&!(`endpoint`in e)&&this.uppy.log("`companionUrl` option has been removed in @uppy/aws-s3, use `endpoint` instead.",`warning`),`companionHeaders`in e&&!(`headers`in e)&&this.uppy.log("`companionHeaders` option has been removed in @uppy/aws-s3, use `headers` instead.",`warning`),`companionCookiesRule`in e&&!(`cookiesRule`in e)&&this.uppy.log("`companionCookiesRule` option has been removed in @uppy/aws-s3, use `cookiesRule` instead.",`warning`),`endpoint`in e?this.#t=new So(this.uppy,{pluginId:this.id,provider:`AWS`,companionUrl:this.opts.endpoint,companionHeaders:this.opts.headers,companionCookiesRule:this.opts.cookiesRule}
6):(`headers`in e&&this.#d(),`cookiesRule`in e&&(this.#t.opts.companionCookiesRule=e.cookiesRule)))}setOptions(e){this.#e.setOptions(e),super.setOptions(e),this.#n(e)}resetUploaderReferences(e,t){this.uploaders[e]&&(this.uploaders[e].abort({really:t?.abort||!1}),this.uploaders[e]=null),this.uploaderEvents[e]&&(this.uploaderEvents[e].remove(),this.uploaderEvents[e]=null)}#r(e){if(!this.#t)throw Error(`Expected a \`endpoint\` option containing a URL, or if you are not using Companion, a custom \`${e}\` implementation.`)}createMultipartUpload(e,t){this.#r(`createMultipartUpload`),Q(t);let n=Ya(this.opts.allowedMetaFields,e.meta),r=Ds({meta:e.meta,allowedMetaFields:n});return this.#t.post(`s3/multipart`,{filename:e.name,type:e.type,metadata:r},{signal:t}).then(Ts)}listParts(e,{key:t,uploadId:n,signal:r},i){r??=i,this.#r(`listParts`),Q(r);let a=encodeURIComponent(t);return this.#t.get(`s3/multipart/${encodeURIComponent(n)}?key=${a}`,{signal:r}).then(Ts)}completeMultipartUpload(e,{key:t,uploadId:n,parts:r,signal:i},a){i??=a,this.#r(`completeMultipartUpload`),Q(i);let o=encodeURIComponent(t),s=encodeURIComponent(n);return this.#t.post(`s3/multipart/${s}/complete?key=${o}`,{parts:r.map(({ETag:e,PartNumber:t})=>({ETag:e,PartNumber:t}))},{signal:i}).then(Ts)}#i;async#a(e){if(Q(e?.signal),this.#i==null){let{getTemporarySecurityCredentials:t}=this.opts;t===!0?(this.#r(`getTemporarySecurityCredentials`),this.#i=this.#t.get(`s3/sts`,e).then(Ts)):this.#i=t(e),this.#i=await this.#i,setTimeout(()=>{this.#i=null},(Es(this.#i.credentials)||0)*500)}return this.#i}async createSignedURL(e,t){let n=await this.#a(t),r=Es(n.credentials)||604800,{uploadId:i,key:a,partNumber:o}=t;return{method:`PUT`,expires:r,fields:{},url:`${await _s({accountKey:n.credentials.AccessKeyId,accountSecret:n.credentials.SecretAccessKey,sessionToken:n.credentials.SessionToken,expires:r,bucketName:n.bucket,Region:n.region,Key:a??`${crypto.randomUUID()}-${e.name}`,uploadId:i,partNumber:o})}`,headers:{"Content-Type":e.type}}}signPart(e,{uploadId:t,key:n,partNumber:r,signal:i}){if(this.#r(`signPart`),Q(i),t==null||n==null||r==null)throw Error(`Cannot sign without a key, an uploadId, and a partNumber`);let a=encodeURIComponent(n);return this.#t.get(`s3/multipart/${encodeURIComponent(t)}/${r}?key=${a}`,{signal:i}).then(Ts)}abortMultipartUpload(e,{key:t,uploadId:n,signal:r}){this.#r(`abortMultipartUpload`);let i=encodeURIComponent(t),a=encodeURIComponent(n);return this.#t.delete(`s3/multipart/${a}?key=${i}`,void 0,{signal:r}).then(Ts)}getUploadParameters(e,t){this.#r(`getUploadParameters`);let{meta:n}=e,{type:r,name:i}=n,a=Ds({meta:n,allowedMetaFields:Ya(this.opts.allowedMetaFields,e.meta),querify:!0}),o=new URLSearchParams({filename:i,type:r,...a});return this.#t.get(`s3/params?${o}`,t)}static async uploadPartBytes({signature:{url:e,expires:t,headers:n,method:r=`PUT`},body:i,size:a=i.size,onProgress:o,onComplete:s,signal:c}){if(Q(c),e==null)throw Error(`Cannot upload to an undefined URL`);return new Promise((l,u)=>{let d=new XMLHttpRequest;d.open(r,e,!0),n&&Object.keys(n).forEach(e=>{d.setRequestHeader(e,n[e])}),d.responseType=`text`,typeof t==`number`&&(d.timeout=t*1e3);function f(){d.abort()}function p(){c?.removeEventListener(`abort`,f)}c?.addEventListener(`abort`,f),d.upload.addEventListener(`progress`,e=>{o(e)}),d.addEventListener(`abort`,()=>{p(),u(Na())}),d.addEventListener(`timeout`,()=>{p();let e=Error(`Request has expired`);e.source={status:403},u(e)}),d.addEventListener(`load`,()=>{if(p(),d.status===403&&d.responseText.includes(`<Message>Request has expired</Message>`)){let e=Error(`Request has expired`);e.source=d,u(e);return}if(d.status<200||d.status>=300){let e=Error(`Non 2xx`);e.source=d,u(e);return}o?.({loaded:a,lengthComputable:!0});let e=d.getAllResponseHeaders().trim().split(/[\r\n]+/),t={__proto__:null};for(let n of e){let e=n.split(`: `),r=e.shift();
6t[r]=e.join(`: `)}let{etag:n,location:i}=t;if(r.toUpperCase()===`POST`&&i==null&&console.error(`@uppy/aws-s3: Could not read the Location header. This likely means CORS is not configured correctly on the S3 Bucket. See https://uppy.io/docs/aws-s3/#setting-up-your-s3-bucket`),n==null){console.error(`@uppy/aws-s3: Could not read the ETag header. This likely means CORS is not configured correctly on the S3 Bucket. See https://uppy.io/docs/aws-s3/#setting-up-your-s3-bucket`);return}s?.(n),l({...t,ETag:n})}),d.addEventListener(`error`,e=>{p();let t=Error(`Unknown error`);t.source=e.target,u(t)}),d.send(i)})}#o=(e,{key:t,uploadId:n})=>{let r=this.uppy.getFile(e.id);r!=null&&this.uppy.setFileState(e.id,{s3Multipart:{...r.s3Multipart,key:t,uploadId:n}})};#s=e=>this.uppy.getFile(e.id)||e;#c(e){return new Promise((t,n)=>{let r=(t,n)=>{let r=this.uppy.getFile(e.id);this.uppy.emit(`upload-progress`,r,{uploadStarted:r.progress.uploadStarted??0,bytesUploaded:t,bytesTotal:n})},i=t=>{this.uppy.log(t),this.uppy.emit(`upload-error`,e,t),this.resetUploaderReferences(e.id),n(t)},a=n=>{let r={body:{...n},status:200,uploadURL:n.location};this.resetUploaderReferences(e.id),this.uppy.emit(`upload-success`,this.#s(e),r),n.location&&this.uppy.log(`Download ${e.name} from ${n.location}`),t(void 0)};if(e.data==null)throw Error(`File data is empty`);let o=new Ss(e.data,{companionComm:this.#e,log:(...e)=>this.uppy.log(...e),getChunkSize:this.opts.getChunkSize?this.opts.getChunkSize.bind(this):void 0,onProgress:r,onError:i,onSuccess:a,onPartComplete:t=>{this.uppy.emit(`s3-multipart:part-uploaded`,this.#s(e),t)},file:e,shouldUseMultipart:this.opts.shouldUseMultipart,...e.s3Multipart});this.uploaders[e.id]=o;let s=new wo(this.uppy);this.uploaderEvents[e.id]=s,s.onFileRemove(e.id,n=>{o.abort(),this.resetUploaderReferences(e.id,{abort:!0}),t(`upload ${n} was removed`)}),s.onCancelAll(e.id,()=>{o.abort(),this.resetUploaderReferences(e.id,{abort:!0}),t(`upload ${e.id} was canceled`)}),s.onFilePause(e.id,e=>{e?o.pause():o.start()}),s.onPauseAll(e.id,()=>{o.pause()}),s.onResumeAll(e.id,()=>{o.start()}),o.start()})}#l(e){return{...`remote`in e&&e.remote?.body,protocol:`s3-multipart`,size:e.data.size,metadata:e.meta}}#u=async e=>{if(e.length===0)return;let t=za(this.uppy.getFilesByIds(e)),n=Ba(t);this.uppy.emit(`upload-start`,n);let r=t.map(e=>{if(e.isRemote){let t=()=>this.requests;this.#f(!1);let n=new AbortController,r=t=>{t.id===e.id&&n.abort()};this.uppy.on(`file-removed`,r);
6let i=this.uppy.getRequestClientForFile(e).uploadRemoteFile(e,this.#l(e),{signal:n.signal,getQueue:t});return this.requests.wrapSyncFunction(()=>{this.uppy.off(`file-removed`,r)},{priority:-1})(),i}return this.#c(e)}),i=await Promise.allSettled(r);return this.#f(!0),i};#d=()=>{this.#t?.setCompanionHeaders(this.opts.headers)};#f=e=>{let{capabilities:t}=this.uppy.getState();this.uppy.setState({capabilities:{...t,resumableUploads:e}})};#p=()=>{this.#f(!0)};install(){this.#f(!0),this.uppy.addPreProcessor(this.#d),this.uppy.addUploader(this.#u),this.uppy.on(`cancel-all`,this.#p)}uninstall(){this.uppy.removePreProcessor(this.#d),this.uppy.removeUploader(this.#u),this.uppy.off(`cancel-all`,this.#p)}},As={phase:`idle`,progress:0,fileName:null,errorKey:null,errorKind:null},js=(e,t=yn)=>e.size<=0?`community.composer.video.error_empty`:e.size>t?`community.composer.video.error_too_large`:bn(e.name)?null:`community.composer.video.error_unsupported`,Ms=({adapter:e,onCompleted:t,maxBytes:n=yn})=>{let[r,i]=(0,J.useState)(As),a=(0,J.useRef)(`idle`),o=(0,J.useRef)(null),s=(0,J.useRef)(null),c=(0,J.useRef)(new Map),l=(0,J.useRef)(null),u=(0,J.useRef)(0),d=(0,J.useRef)({adapter:e,onCompleted:t});d.current={adapter:e,onCompleted:t};let f=(0,J.useCallback)(e=>{a.current=e.phase,o.current=e.errorKind,i(e)},[]),[p,m]=(0,J.useState)(null),h=!!e;(0,J.useEffect)(()=>{if(!h)return;let e=async(e,t,n)=>{let r=u.current,i={filename:e.name??``,content_type:bn(e.name??``)??e.type??``,byte_size:e.size??0},a=await d.current.adapter?.request(i,{multipart:t,signal:n});if(u.current!==r||n?.aborted)throw a?.direct_upload.transport===`s3_multipart`&&await d.current.adapter?.abort(a.video.id,{upload_id:a.direct_upload.upload_id}),Error(`upload superseded`);if(!a)throw Error(`upload authorization failed`);return s.current=a.video.id,a},t=e=>{let t=c.current.get(e);if(!t)throw Error(`missing video id`);return t},r=new cs({autoProceed:!1,restrictions:{maxNumberOfFiles:1,maxFileSize:n,allowedFileTypes:vn}}).use(ks,{id:`AwsS3`,shouldUseMultipart:e=>(e.size??0)>Tn,async getUploadParameters(t,n){let r=await e(t,!1,n?.signal);if(r.direct_upload.transport!==`s3`)throw Error(`unexpected upload transport`);return{method:`PUT`,url:r.direct_upload.url,fields:{},headers:r.direct_upload.headers}},async createMultipartUpload(t){let n=await e(t,!0);if(n.direct_upload.transport!==`s3_multipart`)throw Error(`unexpected upload transport`);return c.current.set(n.direct_upload.upload_id,n.video.id),{uploadId:n.direct_upload.upload_id,key:n.direct_upload.key}},async signPart(e,{uploadId:n,partNumber:r,signal:i}){let a=await d.current.adapter?.signPart(t(n),{upload_id:n,part_number:r,signal:i});if(!a)throw Error(`sign part failed`);return{method:`PUT`,url:a.url}},async listParts(e,{uploadId:n,signal:r}){if(!n)return[];let i=await d.current.adapter?.listParts(t(n),{upload_id:n,signal:r});return i?i.parts.map(e=>({PartNumber:e.part_number,ETag:e.etag,Size:e.size})):[]},async completeMultipartUpload(e,{uploadId:n,parts:r,signal:i}){let a=r.map(e=>({part_number:e.PartNumber??0,etag:e.ETag??``})),o=await d.current.adapter?.complete(t(n),{upload_id:n,parts:a,signal:i});if(!o)throw Error(`complete failed`);return c.current.delete(n),{location:o.location??void 0}},async abortMultipartUpload(e,{uploadId:t,signal:n}){if(!t)return;let r=c.current.get(t);r&&(c.current.delete(t),await d.current.adapter?.abort(r,{upload_id:t,signal:n}))}});return m(r),()=>{r.destroy(),m(null)}},[h,n]);let g=(0,J.useCallback)(async e=>{let t=s.current;if(!t){f({...As,phase:`error`,errorKey:`community.composer.video.error_completion`,errorKind:`completion`});return}f({phase:`confirming`,progress:100,fileName:l.current?.name??null,errorKey:null,errorKind:null});try{let n=await d.current.adapter?.confirm(t);if(u.current!==e)return;if(!n)throw Error(`confirm failed`);f({phase:`completed`,progress:100,fileName:l.current?.name??null,errorKey:null,errorKind:null}),d.current.onCompleted(n.video)}catch{if(u.current!==e)return;f({phase:`error`,progress:100,fileName:l.current?.name??null,errorKey:`community.composer.video.error_completion`,errorKind:`completion`})}},[f]);(0,J.useEffect)(()=>
6{if(!p)return;let e=(e,t)=>{if(a.current!==`uploading`)return;let n=t.bytesTotal??0,r=n>0?Math.min(100,Math.round((t.bytesUploaded??0)/n*100)):0;i(e=>e.phase===`uploading`?{...e,progress:r}:e)},t=()=>{a.current===`uploading`&&g(u.current)},n=()=>{a.current===`uploading`&&f({phase:`error`,progress:0,fileName:l.current?.name??null,errorKey:`community.composer.video.error_transfer`,errorKind:`transfer`})};return p.on(`upload-progress`,e),p.on(`upload-success`,t),p.on(`upload-error`,n),()=>{p.off(`upload-progress`,e),p.off(`upload-success`,t),p.off(`upload-error`,n)}},[p,f,g]),(0,J.useEffect)(()=>()=>{u.current+=1},[]);let _=(0,J.useCallback)(e=>{if(p){u.current+=1,s.current=null,l.current=e;for(let e of p.getFiles())p.removeFile(e.id);f({phase:`uploading`,progress:0,fileName:e.name,errorKey:null,errorKind:null});try{p.addFile({name:e.name,type:e.type,data:e})}catch{f({phase:`error`,progress:0,fileName:e.name,errorKey:`community.composer.video.error_transfer`,errorKind:`transfer`});return}p.upload()}},[p,f]),v=(0,J.useCallback)(e=>{let t=js(e,n);return t?(u.current+=1,s.current=null,l.current=null,f({phase:`error`,progress:0,fileName:e.name,errorKey:t,errorKind:`validation`}),!1):(_(e),!0)},[n,f,_]),y=(0,J.useCallback)(()=>{if(r.errorKind===`completion`){u.current+=1,g(u.current);return}r.errorKind===`transfer`&&l.current&&_(l.current)},[r.errorKind,g,_]),b=(0,J.useCallback)(()=>{u.current+=1,s.current=null,l.current=null,f(As)},[f]),x=(0,J.useCallback)(()=>{p?.cancelAll(),b()},[p,b]),S=r.phase===`uploading`||r.phase===`confirming`,C=(0,J.useCallback)(()=>{let e=a.current;return e===`uploading`||e===`confirming`||e===`error`&&o.current!==`validation`},[]);return(0,J.useMemo)(()=>({state:r,startUpload:v,retry:y,cancel:x,reset:b,isBusy:S,isBacking:C}),[r,v,y,x,b,S,C])},Ns=[`text/plain`,`text/html`,`text/rtf`],Ps=({editor:e,onUploadImage:t,disabled:n=!1,accept:r=wn,maxBytes:i=Dn,translations:a})=>{let[o,s]=(0,J.useState)(null),c=(0,J.useRef)(new Map),l=()=>{if(!e||e.isDestroyed)return;let t=e.state.tr;e.state.doc.descendants((e,n)=>{if(e.type.name!==`image`||!da(e.attrs.src))return;let r=c.current.get(e.attrs.src);if(r===null)return;let i=t.mapping.map(n);if(r){let n={...e.attrs,src:r.url,alt:r.alt??e.attrs.alt,blobKey:r.blobKey};t.setNodeMarkup(i,void 0,n)}else t.delete(i,i+e.nodeSize)}),t.docChanged&&e.view.dispatch(t.setMeta(`addToHistory`,!1))};return{error:o,clearError:()=>s(null),handlePaste:o=>{let u=o.clipboardData;if(!e||!t||n||!u)return!1;let d=r.split(`,`),f=Array.from(u.files).filter(e=>d.includes(e.type));if(f.length===0||Ns.every(e=>u.types.includes(e)))return!1;let p=f.filter(e=>e.size<=i),m=p.length<f.length?q(a,`community.composer.upload_file_too_large`):null;if(p.length===0)return s(m),!0;let h=p.map(e=>{let n=URL.createObjectURL(e);return c.current.set(n,null),t(e).catch(()=>null).then(e=>{e?c.current.set(n,e):(c.current.delete(n),s(q(a,`community.composer.upload_error`))),l(),URL.revokeObjectURL(n)}),{type:`image`,attrs:{src:n,alt:e.name}}}),{from:g,to:_}=e.state.selection;return e.chain().focus().insertContentAt({from:g,to:_},h).command(ii).run(),s(m),!0},syncUploads:l}},Fs=cn.create({name:`trailingNode`,addOptions(){return{node:`paragraph`,notAfter:[`paragraph`]}},addProseMirrorPlugins(){let e=new tn(this.name),t=Object.values(this.editor.schema.nodes).filter(e=>this.options.notAfter.includes(e.name));return[new en({key:e,appendTransaction:(t,n,r)=>{let{doc:i,tr:a,schema:o}=r,s=e.getState(r),c=o.nodes[this.options.node],l=i.content.size;if(s)return a.insert(l,c.create())},state:{init:(e,{tr:{doc:n}})=>{let r=n.lastChild;return r?!t.includes(r.type):!0},apply:({doc:e,docChanged:n},r)=>{if(!n)return r;let i=e.lastChild;return i?!t.includes(i.type):!0}}})]}}),Is={type:`doc`,content:[{type:`paragraph`}]},Ls=e=>e.type===`video`&&!e.attrs?.videoId||e.type===`image`&&da(e.attrs?.src),Rs=e=>e.content?{...e,content:e.content.filter(e=>!Ls(e)).map(Rs)}:e,zs=e=>{let t={video:!1,image:!1};return e.state.doc.descendants(e=>{e.type.name===`video`&&!e.attrs.videoId&&(t.video=!0),e.type.name===`image`&&da(e.attrs.src)&&(t.image=!0)}),t},Bs=(0,J.forwardRef)(({initialContent:e,placeholder:t,title:n,onT
6itleChange:r,showTitleInput:i=!0,autoFocusTitle:a=!0,titleMaxLength:o,editorMinHeight:s,isEditMode:c=!1,quotedPost:l,onSubmit:u,isSubmitting:d=!1,isSubmitDisabled:f=!1,onContentChange:p,onUploadImage:m,isMediaUploadDisabled:h,uploadAccept:g,uploadMaxBytes:_,videoUploadAdapter:v,videoUploadMaxBytes:y,videoUploadAccept:b,subscribeToVideoStatus:x,onRetryVideoProcessing:S,resolveVideoPlayback:C,loadVideoThumbnails:w,selectVideoThumbnail:T,uploadVideoThumbnail:E,onSearchGifs:D,gifSearchLimit:O,gifSearchDebounceMs:k,onFetchLinkPreview:A,mentionSuggestions:j,attachableLists:M,onPostQueryChange:N,isLoadingPosts:P,attached:F,onAttachedChange:ee,maxAttachedPosts:I=1,transformImageUrl:L,error:R,translations:z,className:te},ne)=>{let[re,B]=(0,J.useState)(()=>!e),[ie,ae]=(0,J.useState)(!1),oe=(0,J.useRef)(()=>{}),se=(0,J.useRef)(null),V=(0,J.useRef)(null),ce=(0,J.useRef)(p);ce.current=p;let le=(0,J.useRef)(j);le.current=j;let H=!!u,U=on({extensions:(0,J.useMemo)(()=>[tt(),mn.configure({placeholder:t??`Write something…`}),dt,mt.configure({openOnClick:!1,linkOnPaste:!0}),pa.configure({inline:!1,allowBase64:!1,HTMLAttributes:{class:`community-editor-image`},translations:z}),ha,ka.configure({subscribeToStatus:x,onRetry:S,resolvePlayback:C,loadThumbnails:w,selectThumbnail:T,uploadThumbnail:E,translations:z}),di,Fs,it(),ln({getSuggestions:()=>le.current,fallbackLabel:q(z,`community.join.former_member`),listLabel:q(z,`community.mentions.list_label`)}),...H?[at.configure({onSubmit:()=>oe.current(),shouldYieldEnter:e=>!!Z.getState(e.state)})]:[],Ji.configure({onFetchLinkPreview:A,translations:z})],[t,A,z,H,x,S,C,w,T,E]),content:e??Is,editorProps:{attributes:{class:`flex-1`},handlePaste:(e,t)=>
6V.current?.handlePaste(t)??!1},onUpdate:({editor:e,transaction:t})=>{B(e.isEmpty);let n=zs(e);ae(n.video||n.image);let r=se.current;r&&n.video!==r.isBacking()&&(n.video?e.commands.removeProvisionalVideo():r.cancel()),n.image&&V.current?.syncUploads(),t.getMeta(`addToHistory`)!==!1&&V.current?.clearError(),ce.current?.(e.isEmpty?null:Rs(e.getJSON()))}});(0,J.useEffect)(()=>{if(!U)return;let t=e??Is;U.commands.setContent(t),B(U.isEmpty)},[U,e]),(0,J.useImperativeHandle)(ne,()=>({reset:()=>{U&&(U.commands.setContent(e??Is),B(U.isEmpty),V.current?.clearError())},getContent:()=>U?Rs(U.getJSON()):Is,isEmpty:()=>U?.isEmpty??!0}),[U,e]);let[ue,de]=(0,J.useState)(!1),W=Ms({adapter:v,onCompleted:e=>{U?.commands.setVideoId(e.id)},maxBytes:y});se.current=W;let fe=Ps({editor:U,onUploadImage:m,disabled:h,accept:g,maxBytes:_,translations:z});V.current=fe;let pe=(0,J.useCallback)((e,t)=>{if(W.isBusy)return;if(!W.startUpload(e)){de(!0);return}let n=t&&U?U.view.posAtCoords({left:t.clientX,top:t.clientY})?.pos:void 0;U?.chain().focus().insertProvisionalVideo(n).run(),de(!1)},[W,U]),me=!!v,{isDragActive:he,dropHandlers:ge}=na({disabled:W.isBusy,onFile:(e,t)=>pe(e,t)}),_e=me?{handlers:ge,isActive:he,overlay:(0,X.jsx)(ra,{translations:z})}:void 0,ve=(0,J.useCallback)(()=>{u?.(U?Rs(U.getJSON()):Is)},[U,u]),ye=(F?.posts?.length??0)>0,be=f||W.isBusy||ie||re&&!l&&!ye,xe=W.state.errorKind===`validation`?W.state.errorKey:null,Se=()=>{d||be||ve()};return oe.current=Se,(0,X.jsx)(ga.Provider,{value:v?W:null,children:(0,X.jsxs)(`div`,{className:(0,Y.default)(`flex flex-1 flex-col min-h-0`,te),children:[(0,X.jsx)(Oi,{editor:U,title:n,onTitleChange:r,onKeyboardSubmit:Se,showTitleInput:i,autoFocusTitle:a,titleMaxLength:o,editorMinHeight:s,quotedPost:l,attached:F,onAttachedChange:ee,transformImageUrl:L,error:R??fe.error,translations:z,videoDrop:_e}),(0,X.jsx)(ca,{editor:U,isEditMode:c,isSubmitting:d,isSubmitDisabled:be,onSubmit:H?ve:void 0,translations:z,onUploadImage:m,isMediaUploadDisabled:h,uploadAccept:g,uploadMaxBytes:_,onSelectVideoFile:v?pe:void 0,videoValidationErrorKey:xe,videoUploadAccept:b,videoPanelOpen:ue,onVideoPanelOpenChange:de,onSearchGifs:D,gifSearchLimit:O,gifSearchDebounceMs:k,attachableLists:M,onPostQueryChange:N,isLoadingPosts:P,attached:F,onAttachedChange:ee,maxAttachedPosts:I,transformImageUrl:L})]})})});Bs.displayName=`CommunityPostComposerCore`;var Vs=(0,J.forwardRef)(({destinations:e,selectedDestination:t,onDestinationChange:n,destinationMode:r=`selectable`,author:i,onClose:a,className:o,notice:s,...c},l)=>(0,X.jsxs)(`div`,{className:(0,Y.default)(`flex flex-1 flex-col min-h-0`,o),children:[(0,X.jsx)(ei,{destinations:e,selectedDestination:t,onDestinationChange:n,destinationMode:r,author:i,onClose:a,translations:c.translations}),s?(0,X.jsx)(`div`,{className:`px-4 pt-4`,children:s}):null,(0,X.jsx)(Bs,{ref:l,...c})]}));Vs.displayName=`CommunityPostComposer`;var Hs=({className:e})=>(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,className:e,viewBox:`0 0 30 30`,children:(0,X.jsx)(`path`,{fill:`currentColor`,d:`M25.692 13.168H3.866c-.556 0-1.01-.458-1.01-1.017V10.6c0-1.755 1.414-3.178 3.157-3.178H23.52c1.743 0 3.157 1.423 3.157 3.177v1.55a.98.98 0 0 1-.985 1.018ZM21.092 5.745H8.462a1.044 1.044 0 0 1-1.036-1.042C7.426 2.11 9.523 0 12.099 0h5.356c2.576 0 4.673 2.11 4.673 4.703 0 .584-.455 1.042-1.036 1.042ZM26.702 14.845H2.855C1.288 14.845 0 16.142 0 17.718c0 1.576 1.288 2.872 2.855 2.872h8.462c.303-1.627 1.718-2.872 3.436-2.872a3.532 3.532 0 0 1 3.46 2.872h8.463c1.567 0 2.855-1.296 2.855-2.872 0-1.576-1.263-2.873-2.83-2.873ZM25.663 22.268h-7.401v5.745h5.557c1.567 0 2.855-1.297 2.855-2.873v-1.83a1.006 1.006 0 0 0-1.01-1.042ZM3.864 22.268c-.556 0-1.036.457-1.036 1.042v1.83c0 1.576 1.288 2.873 2.855 2.873h5.557v-5.745H3.864Z`})}),Us=({color:e,className:t,utmMedium:n=`footer`,variant:r=`default`})=>{let{publicationBeehiivBranding:i,publicationName:a,publicationLogoUrl:s,publicationUtmSource:c}=o();return i?r===`pill`?(0,X.jsx)(`div`,{className:`flex justify-center py-20`,children:(0,X.jsxs)(Xt,{publicationName:a??``,publicationLogoUrl:s,utmSource:c,utmMedium:n,className:`flex items-center gap-1 rounded-full border border-black/10 bg-white px-3 py-1`,children:[(0,X.jsx)(`div`,{className:`flex shrink-0 items-center justify-center size-6`,children:(0,X.jsx)(Hs,{className:`size-[15px]`})}),(0,X.jsx)(`span`,{className:`text-[11px] font-normal leading-4 tracking-[-0.11px] text-black/50`,children:y(`shared.cta.powered_by_beehiiv`)||`Powered by beehiiv`})]})}):(0,X.jsx)(`div`,{className:`w-fit`,color:e,children:(0,X.jsx)(Bn,{as:`span`,children:(0,X.jsxs)(Xt,{publicationName:a??``,publicationLogoUrl:s,utmSource:c,utmMedium:n,className:(0,Y.default)(`extra-light flex items-center rounded border px-3 py-2 text-xs`,t),style:{borderColor:e,color:e},children:[(0,X.jsx)(Hs,{className:`mr-2 h-4 w-4`}),(0,X.jsx)(Bn,{as:`span`,color:e,children:y(`shared.cta.powered_by_beehiiv`)||`Powered by beehiiv`})]})})}):null},Ws=({debug:e=!1,storageKey:t=D.publicationPush,branding:n,variant:r=`default`})=>(0,X.jsx)(A,{children:()=>(0,X.jsx)(Gs,{debug:e,storageKey:t,branding:n,variant:r})});function Gs({debug:e=!1,storageKey:t=D.publicationPush,branding:n,variant:r=`default`}){let i=Ln(),a=w(x()),{onEnable:o}=rr(),s=f(`root`)?.publication,c=n??{name:s?.name??``,logoUrl:s?.logo?.thumb?.url??``},{t:l}=v(),[u,d]=bt(t),[p,m]=(0,J.useState)(!u&&i),h=r===`community`,g=async()=>{m(!1),await o()?d(!0):m(!0)};return!c.logoUrl||!c.name||!e&&(u||!a||!i)||!p?null:(0,X.jsx)(`div`,{className:`fixed inset-0 z-50 bg-[rgba(0,0,0,0.5)]`,children:(0,X.jsx)(`div`,{className:`absolute top-0 w-full rounded-b-xl border p-6 ${h?`border-community-primary/20 bg-community-bg text-community-text-on-bg`:`bg-white text-gray-950`}`,children:(0,X.jsxs)(`div`,{className:`flex gap-6`,children:[(0,X.jsx)(`img`,{src:c.logoUrl,alt:c.name,className:`h-16 w-16 flex-none overflow-clip rounded-lg`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsx)(`p`,{children:l(`pwa.enable_push_notification_prompt.show_notifications_latest_updates`)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-4`,children:[(0,X.jsx)(le,{type:`button`,variant:`ghost`,onClick:()=>{k(l(h?`community.push.enable_from_settings`:`pwa.enable_push_notification_prompt.enable_push_notifications_from_menu`),{icon:`ℹ️`}),m(!1),d(!0)},children:l(`pwa.enable_push_notification_prompt.maybe_later`)}),h?(0,X.jsx)(Vn,{type:`button`,variant:`primary`,onClick:g,children:l(`pwa.enable_push_notification_prompt.enable`)}):(0,X.jsx)(le,{type:`button`,variant:`primary`,onClick:g,children:l(`pwa.enable_push_notification_prompt.enable`)})]})]})]})})})}var Ks=({className:e})=>(0,X.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`,fill:`none`,className:(0,Y.default)(e),children:[(0,X.jsx)(`rect`,{x:`80`,y:`80`,width:`352`,height:`352`,rx:`80`,ry:`80`,stroke:`currentColor`,strokeWidth:32}),(0,X.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:32,d:`M256 176v160M176 256h160`})]}),qs=({className:e})=>(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`,className:e,children:(0,X.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:32,d:`M336 192h40a40 40 0 0 1 40 40v192a40 40 0 0 1-40 40H136a40 40 0 0 1-40-40V232a4
60 40 0 0 1 40-40h40m160-64l-80-80l-80 80m80 193V48`})});function Js(){let e=/iphone|ipad|ipod/i.test(window.navigator.userAgent),t=/macintosh/i.test(window.navigator.userAgent)&&navigator.maxTouchPoints>2,n=`standalone`in window.navigator&&window.navigator.standalone;return(e||t)&&!n}var Ys=({icon:e,label:t,hint:n})=>(0,X.jsxs)(`li`,{className:`flex items-center gap-4`,children:[(0,X.jsx)(`span`,{className:`flex w-7 shrink-0 justify-center`,children:e}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block font-semibold`,children:t}),n&&(0,X.jsx)(`span`,{className:`block text-sm opacity-60`,children:n})]})]}),Xs=({debug:e=!1,canShowOnPath:t=E,storageKey:n=D.publicationInstall,branding:r,variant:i=`default`})=>(0,X.jsx)(A,{children:()=>(0,X.jsx)(Zs,{debug:e,canShowOnPath:t,storageKey:n,branding:r,variant:i})});function Zs({debug:e=!1,canShowOnPath:t,storageKey:n,branding:r,variant:i}){let a=s(),o=t?.(a.pathname)??!1,c=vt(),l=Js(),u=c||l,d=Ln(),{isPwaInstalled:p,markPwaInstalled:m}=_t(i===`community`?D.communityInstalled:D.publicationInstalled),h=f(`root`)?.publication,g=r??{name:h?.name??``,logoUrl:h?.logo?.thumb?.url??``,subtitle:h?.configured_domain},[_,y]=bt(n??D.publicationInstall),b=ht(),x=(0,J.useRef)(!1),[S,C]=(0,J.useState)(o&&!_&&!p&&u&&d),{t:w}=v(),T=i===`community`,E=async()=>{let e=window.__DeferredPrompt__??b;e&&(y(!0),await e.prompt(),(await e.userChoice).outcome===`accepted`&&m(),C(!1))},O=(0,J.useCallback)(()=>{k.success(w(`pwa.install_prompt.install_success`))},[w]);return(0,J.useEffect)(()=>(window.addEventListener(`appinstalled`,O),()=>{window.removeEventListener(`appinstalled`,O)}),[O]),(0,J.useEffect)(()=>{function e(e){e.preventDefault(),x.current=!0,C(!0)}return document.addEventListener(`beehiiv:showInstallPrompt`,e),()=>{document.removeEventListener(`beehiiv:showInstallPrompt`,e)}},[]),(0,J.useEffect)(()=>{p&&(x.current=!1,C(!1))},[p]),(0,J.useEffect)(()=>{x.current||C(o&&!_&&!p&&u&&d&&(!c||!!b))},[o,_,p,u,d,c,b]),!g.logoUrl||!g.name||!e&&!c&&!l||!S?null:(0,X.jsx)(`div`,{className:`fixed inset-0 z-50 bg-[rgba(0,0,0,0.5)]`,children:(0,X.jsxs)(`div`,{className:`absolute bottom-0 w-full rounded-t-xl border p-6 ${T?`border-community-primary/20 bg-community-bg text-community-text-on-bg`:`bg-white text-gray-950`}`,children:[(0,X.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,X.jsx)(`h1`,{className:`text-2xl font-bold`,children:w(`pwa.install_prompt.install_prompt`)}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close`,onClick:()=>{x.current=!1,C(!1),y(!0)},children:(0,X.jsx)(ce,{className:`h-6 w-6`})})]}),(0,X.jsxs)(`div`,{className:`mt-6 flex gap-4 rounded border p-4 ${T?`border-community-primary/20 bg-white/80 text-black`:`border-gray-200 bg-gray-100`}`,children:[(0,X.jsx)(`img`,{src:g.logoUrl,alt:g.name,className:`h-16 w-16 overflow-clip rounded-lg`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-lg font-semibold`,children:g.name}),g.subtitle?(0,X.jsx)(`p`,{children:g.subtitle}):null]})]}),c&&(0,X.jsxs)(`div`,{className:`mx-6 my-8 flex flex-col items-center`,children:[T?(0,X.jsx)(Vn,{type:`button`,variant:`primary`,onClick:E,disabled:!b,children:w(`pwa.install_prompt.install_cta`)}):(0,X.jsx)(le,{type:`button`,variant:`primary`,onClick:E,disabled:!b,children:w(`pwa.install_prompt.install_cta`)}),(0,X.jsx)(`p`,{className:`mt-4`,children:w(`pwa.install_prompt.install_sub_cta`)})]}),l&&(0,X.jsxs)(`ul`,{className:`mx-2 mb-4 mt-6 space-y-5`,children:[(0,X.jsx)(Ys,{icon:(0,X.jsx)(qs,{className:`h-6 w-6`}),label:w(`pwa.install_prompt.step_share`),hint:w(`pwa.install_prompt.step_more`)}),(0,X.jsx)(Ys,{icon:(0,X.jsx)(Ks,{className:`h-6 w-6`}),label:w(`pwa.install_prompt.step_add`)}),(0,X.jsx)(Ys,{icon:(0,X.jsx)(se,{className:`h-6 w-6`}),label:w(`pwa.install_prompt.step_confirm`)}),(0,X.jsx)(Ys,{icon:(0,X.jsx)(`img`,{src:g.logoUrl,alt:g.name,className:`h-6 w-6 overflow-clip rounded-lg`}),label:w(`pwa.install_prompt.step_find`)})]})]})})}function Qs({keyFor:e}){let t=(0,J.useRef)(null),n=(0,J.useRef)(0),r=(0,J.useRef)(void 0),i=s(),o=a(),c=e(i);return(0,J.useEffect)(()=>{let e=t.current;if(!e)return;let r=()=>{n.current=e.scrollTop};return e.addEventListener(`scroll`,r,{passive:!0}),()=>e.removeEventListener(`scroll`,r)},[]),(0,J.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let i=r.current;if(i===void 0){r.current=c;return}
6if(i!==c){if(i!=null&&sessionStorage.setItem(i,String(n.current)),c!=null){let t=o===`POP`?sessionStorage.getItem(c):null,r=t==null?0:Number(t),i=r<=e.scrollHeight-e.clientHeight?r:0;e.scrollTo(0,i),n.current=i}else e.scrollTo(0,0),n.current=0;r.current=c}},[c]),t}var $s=({onBack:e,label:t,className:n})=>(0,X.jsx)(`button`,{type:`button`,onClick:e,className:(0,Y.default)(`group flex items-center justify-center rounded-full transition-colors duration-150 hover:bg-black/5 active:scale-95`,n),"aria-label":t,children:(0,X.jsx)(Me,{className:`size-6 text-black opacity-50 transition-opacity duration-150 group-hover:opacity-80`,"aria-hidden":`true`})}),ec=10,tc=3e3,nc=(e,t)=>async()=>{let n=await fetch(e);if(!n.ok)throw Error(`Failed to fetch ${e}`);return!!(await n.json())[t]},rc=e=>(e.preventDefault(),e.returnValue=`Your order is not ready yet. Please do not close this tab.`,``),ic=({enabled:e,checkAccess:t,maxAttempts:n=ec,intervalMs:r=tc})=>{let{revalidate:i}=u(),[a,o]=(0,J.useState)(`idle`),s=(0,J.useRef)(t);return s.current=t,(0,J.useEffect)(()=>{if(!e||n<=0)return;let t=!1,a=new AbortController;o(`polling`);let c=async()=>{if(!await s.current())throw Error(`Access not granted yet`)};return(async()=>{try{window.addEventListener(`beforeunload`,rc),await Mn(c,{retries:n-1,factor:1,minTimeout:r,maxTimeout:r,signal:a.signal}),t||(o(`granted`),i())}catch{t||o(`timeout`)}finally{window.removeEventListener(`beforeunload`,rc)}})(),()=>{t=!0,a.abort(),window.removeEventListener(`beforeunload`,rc)}},[e,n,r,i]),a},ac=({onAccessGranted:e,checkAccess:t,children:n})=>{let{t:r}=v(),i=ic({enabled:!0,checkAccess:t}),a=(0,J.useRef)(!1);(0,J.useEffect)(()=>{i===`granted`&&!a.current&&(a.current=!0,e())},[i,e]);let o=i===`timeout`;return n?n(o):(0,X.jsxs)(`div`,{role:`status`,className:`mt-4 flex flex-col items-center gap-3 py-2 text-center`,children:[!o&&(0,X.jsx)(xn,{className:`size-6`}),(0,X.jsx)(`p`,{className:`text-sm leading-5 text-black/50`,children:r(o?`community.upgrade_modal.payment_received`:`community.upgrade_modal.preparing_access`)})]})},oc=({tiers:e,theme:t,checkoutCta:n})=>(0,J.useMemo)(()=>{if(!t||e.length===0)return null;let r=nr({id:`community-upgrade-pricing`,tiers:e,theme:t}),i=Be(t.primary_color,r.attrs.cardBackgroundColor)?t.primary_color:qe(r.attrs.cardBackgroundColor);return{...r,attrs:{...r.attrs,buttonColor:t.primary_color,buttonTextColor:t.text_on_primary_color,cardSelectedBorderColor:i,featureIconColor:i,featureSelectedIconColor:i,internalCheckoutCta:n,recommendedBackgroundColor:t.primary_color,recommendedTextColor:t.text_on_primary_color,renderDiscountPriceInline:!0,inputBorderRadius:`24px`,inputBorderColor:`rgba(0, 0, 0, 0.1)`,inputTextColor:`#000000`,inputPlaceholderColor:`rgba(0, 0, 0, 0.3)`,buttonBorderRadius:`9999px`}}},[e,t,n]),sc=({onSuccess:e,visibleSection:t,pricing:n,successRedirectTo:r})=>{let i=f(`routes/community`),a=(0,J.useRef)(void 0),[o,s]=(0,J.useState)(void 0),c=f(`root`),l=i?.community,[u,d]=Yt(),p=c?.subscription?.email;(0,J.useEffect)(()=>{p&&u!==p&&d(p)},[p,u,d]);let{purchasableTiers:m,isError:h}=n,g=(0,J.useMemo)(()=>{let e=c?.site.primary_theme;if(e)return l?{...e,primary_color:l.primary_color,background_color:l.background_color,text_on_background_color:l.text_on_background_color,text_on_primary_color:l.text_on_primary_color}:e},[c?.site.primary_theme,l]),_=oc({tiers:m??[],theme:g,checkoutCta:o});return m===null&&!h?(0,X.jsx)(`div`,{className:`flex w-full justify-center py-12`,children:(0,X.jsx)(`span`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-gray-300 border-t-gray-900`})}):h||!_?null:(0,X.jsx)(`div`,{className:(0,Y.default)(`flex w-full justify-center`,`[&_input[type=email]]:h-12 [&_input[type=email]]:font-medium [&_input[type=email]]:!text-[16px] sm:[&_input[type=email]]:!text-[13px]`,`[&_input[type=submit]]:h-12 [&_input[type=submit]]:!rounded-full [&_input[type=submit]]:px-5 [&_input[type=submit]]:!text-[13px] [&_input[type=submit]]:font-medium`,`[&_input[type=submit]]:!border [&_input[type=submit]]:!border-solid [&_input[type=submit]]:!border-community-text-on-primary/10 [&_input[type=submit]
6]:shadow-community-button`,`[&_input[type=submit]:disabled]:!bg-[color:var(--button-color)] [&_input[type=submit]:disabled]:!opacity-60 [&_input[type=submit]:disabled]:cursor-not-allowed`),style:{"--input-placeholder-color":`rgba(0, 0, 0, 0.3)`,"--input-background-color":`rgba(0, 0, 0, 0.05)`},children:(0,X.jsxs)(tr,{node:_,onSuccess:t=>e(t,a.current),successRedirectTo:r,forceStripePaymentElement:!0,visibleSection:t,children:[(0,X.jsx)(cc,{tierIdRef:a,onCheckoutCtaChange:s}),t===`checkout`&&(0,X.jsx)(uc,{})]})})},cc=({tierIdRef:e,onCheckoutCtaChange:t})=>{let{selectedTier:n,selectedPrice:r}=er(),i=n?.id,a=r?.cta||void 0;return(0,J.useEffect)(()=>{e.current=i},[e,i]),(0,J.useEffect)(()=>{t(a)},[t,a]),null},lc=new Set([Qn.MONTH,Qn.QUARTER,Qn.YEAR]),uc=()=>{let{t:e}=v(),{selectedPrice:t}=er(),n=t?.premium_offer;return!t||!lc.has(t.interval)||n&&!n.card_required?null:(0,X.jsx)(`p`,{className:`mt-3 text-center text-xs leading-4 text-black/60`,children:n?e(`community.upgrade_modal.recurring_terms_with_offer`):e(`community.upgrade_modal.recurring_terms`,{price:Ft({value:t.amount_cents/100,currency:t.currency}),interval:e(`billing.summary.intervals.${t.interval}`)})})},dc=`z-[70]`,fc=`bg-black/70`,pc=({isOpen:e,title:t,description:n,accessStepsContent:r,impressionPageBlock:i,pricing:a,checkAccess:o,isAwaitingAccess:s,onPaymentAccepted:c,onAccessGranted:l,successRedirectTo:u,onGuestSuccess:d,footer:p,resumeAwaitingAccessOnOpen:m})=>{let{t:h}=v(),g=Rn(),y=!!f(`root`)?.isLoggedIn,{handleCloseModal:b}=H(),x=or(),S=Gn(),C=y&&(m||s),[w,T]=(0,J.useState)(()=>C?`awaiting-access`:`plans`),E=()=>{if(w===`granted`){l();return}b({preventScrollReset:!0})},D=()=>{if(!r){l();return}T(`granted`)},O=e=>{if(d){d(e);return}_(Error(`Upgrade modal: a guest paid but the modal has no guest handler`),{extra:{title:t,ssoLoginUrl:!!e}})},k=(e,t)=>{if(e||!y){O(e);return}c(t),T(`awaiting-access`)},A=w===`plans`,j=a.isError||a.purchasableTiers!==null&&a.purchasableTiers.length===0,M=A&&j,N=(0,J.useMemo)(()=>{let e=a.purchasableTiers?.length??0;return A&&e>0?{1:`max-w-[460px] xl:max-w-[480px]`,2:`max-w-[460px] lg:max-w-[760px] xl:max-w-[888px]`,3:`max-w-[460px] lg:max-w-[1104px] xl:max-w-[1296px]`}[e]??`max-w-[460px] lg:max-w-[1448px] xl:max-w-[1704px]`:`max-w-[460px]`},[a.purchasableTiers,A]),P=e&&(w!==`plans`||!a.isPending);mr({pageBlock:i},{enabled:P});let F=w===`payment`,ee=w===`granted`,L={"awaiting-access":{title:h(`community.upgrade_modal.payment_processing`),description:r?.awaiting.description},granted:r?.granted},R=M?{title:h(`community.paid_gate.closed_title`)}:L[w]??{title:t,description:n},z=(A&&!M||ee)&&(0,X.jsx)(`div`,{className:`shrink-0 border-t border-black/10 px-6 py-4 sm:px-12`,children:(0,X.jsx)(`div`,{className:`mx-auto w-full max-w-md`,children:(0,X.jsx)(Vn,{variant:`primary`,size:`lg`,fullWidth:!0,type:`button`,onClick:ee?l:()=>T(`payment`),children:(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:ee?r?.granted.ctaLabel:h(`community.upgrade_modal.next`)})})})}),te=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ue,{className:`mb-8`,imageUrl:S,imageAlt:`${x} logo`,title:R.title,description:R.description}),M?(0,X.jsx)(`p`,{className:`text-center text-sm leading-5 text-black/60`,children:h(`community.paid_gate.closed_description`)}):w===`awaiting-access`?(0,X.jsx)(ac,{onAccessGranted:D,checkAccess:o,children:r?.awaiting.body}):ee?r?.granted.body:(0,X.jsx)(sc,{onSuccess:k,visibleSection:w===`payment`?`checkout`:`tiers`,pricing:a,successRedirectTo:u}),!F&&p]});return g?(0,X.jsxs)(zn,{isOpen:P,onClose:E,zIndexClassName:dc,backdropClassName:fc,panelClassName:`flex max-h-[85dvh] flex-col overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center justify-between py-2 pl-2 pr-2`,children:[(0,X.jsx)(`div`,{children:F&&(0,X.jsx)($s,{onBack:()=>T(`plans`),label:h(`community.upgrade_modal.back`),className:`p-2`})}),(0,X.jsx)(ze,{onClose:E,label:h(`community.upgrade_modal.close`),className:`p-2`})]}),(0,X.jsx)(`div`,{className:`flex flex-col overflow-y-auto px-5 pb-8`,children:te}),z]}):(0,X.jsxs)(Hn,{isOpen:P,onClose:E,zIndexClassName:dc,backdropClassName:fc,containerClassName:I,className:(0,Y.default)(qn,`relative flex max-h-[85vh] w-full flex-col overflow-hidden border-0`,N),children:[F&&(0,X.jsx)($s,{onBack:()=>T(`plans`),label:h(`community.upgrade_modal.back`),className:`absolute left-4 top-4 z-10 size-8`}),(0,X.jsx)(ze,{onClose:E,label:h(`community.upgrade_modal.close`),className:`absolute right-4 top-4 z-10 size-8`}),(0,X.jsx)(`div`,{className:(0,Y.default)(`flex flex-col overflow-y-auto px-6 py-8`,F?`sm:px-8`:`sm:px-12`),children:te}),z]})},mc=80,hc=8,gc=({channels:e,status:t})=>
6(0,X.jsx)(`ul`,{className:`divide-y divide-black/5 rounded-2xl border border-black/10`,children:e.map((e,n)=>(0,X.jsxs)(`li`,{className:`flex items-center gap-4 px-4 py-4`,children:[(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-black/[0.04]`,children:t===`unlocked`?(0,X.jsx)(oe,{"aria-hidden":`true`,className:`size-5 text-emerald-600 transition-[opacity,transform] duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] [@starting-style]:scale-50 [@starting-style]:opacity-0 motion-reduce:transition-none`,style:{transitionDelay:`${Math.min(n,hc)*mc}ms`}}):(0,X.jsx)(V,{"aria-hidden":`true`,className:`size-4 text-black/60`})}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-base font-medium text-black`,children:e.name}),t===`pending`&&(0,X.jsx)(xn,{className:`size-5 shrink-0`})]},e.id))}),_c=({space:e,handoff:{awaiting:t,markAwaitingAccess:n,onAccessGranted:r}})=>{let{t:i}=v(),a=or(),o=f(`routes/community`),{canAccessSpace:s}=fr(),c=pr({spaceId:e.id}),l=(0,J.useMemo)(()=>nc(`/space_access?space_id=${encodeURIComponent(e.id)}`,`space_accessible`),[e.id]),u=t?.space.id===e.id?t:null,d=u?.unlockedChannels??[],p=t=>{let n=(o?.spaces??[]).filter(e=>t&&e.premium_tier_ids.includes(t)&&!s(e));return n.length>0?n:[e]};return(0,X.jsx)(pc,{isOpen:!0,title:i(`community.upgrade_modal.channel_title`,{channelName:e.name}),description:i(`community.upgrade_modal.channel_description`,{communityName:a}),accessStepsContent:{awaiting:{description:i(`community.upgrade_modal.channel_processing_description`,{count:d.length}),body:e=>(0,X.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-6`,children:[(0,X.jsx)(gc,{channels:d,status:e?`stalled`:`pending`}),(0,X.jsx)(`p`,{className:`text-center text-sm leading-5 text-black/50`,children:i(e?`community.upgrade_modal.payment_received`:`community.upgrade_modal.takes_a_few_seconds`)})]})},granted:{title:i(`community.upgrade_modal.unlocked_title`),description:i(`community.upgrade_modal.channel_unlocked_description`,{count:d.length}),body:(0,X.jsx)(gc,{channels:d,status:`unlocked`}),ctaLabel:i(`community.upgrade_modal.go_to_channel`,{channelName:e.name})}},impressionPageBlock:G.CommunityChannelUpgradeModal,pricing:c,checkAccess:l,isAwaitingAccess:u!==null,onPaymentAccepted:t=>n({space:e,unlockedChannels:p(t)}),onAccessGranted:r,successRedirectTo:L.root})},vc=({modalType:e,isGranted:t,onGranted:n})=>{let{currentModal:r,handleCloseModal:i}=H(),a=u(),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),[d,f]=(0,J.useState)(`idle`);return(0,J.useEffect)(()=>{d!==`closing`||r===e||(a.revalidate(),f(`revalidating`))},[d,r,e,a]),(0,J.useEffect)(()=>{d!==`revalidating`||c===null||!t(c)||(f(`idle`),l(null),n(c))},[d,c,t,n]),{awaiting:o,markAwaitingAccess:(0,J.useCallback)(e=>{l(e),s(e)},[]),onAccessGranted:(0,J.useCallback)(()=>{s(null),f(`closing`),i({preventScrollReset:!0})},[i])}},yc=()=>{let{t:e}=v(),{canAccessSpace:t}=fr(),n=ie(),r=c(),i=d();return vc({modalType:`community_channel_upgrade`,isGranted:(0,J.useCallback)(({space:e})=>t(e),[t]),onGranted:(0,J.useCallback)(({space:t})=>{n.invalidateQueries({queryKey:lt.all}),n.invalidateQueries({queryKey:Ie.all}),k.success(e(`community.upgrade_modal.channel_unlocked`,{channelName:t.name})),i.some(e=>e.id===F.post)||r(L.spaces(t.slug))},[n,e,i,r])})},bc=()=>(0,X.jsx)(`div`,{className:`flex flex-col items-center w-full min-h-full`,children:(0,X.jsxs)(`div`,{className:`w-full max-w-[704px] flex flex-col gap-6 py-6 px-4 lg:px-0`,"aria-busy":`true`,children:[(0,X.jsx)(gr,{}),(0,X.jsx)(gr,{}),(0,X.jsx)(gr,{})]})}),xc=new Set([`http:`,`https:`]),Sc=e=>{try{return xc.has(new URL(e).protocol)}catch{return!1}},Cc=()=>{let e=f(`routes/community`)?.community?.nav_subtitle;return e?.text?e.type===`tagline`?(0,X.jsx)(`span`,{className:`max-w-full truncate text-xs font-normal leading-4 text-community-text-on-bg/60`,children:e.text}):!e.url||!Sc(e.url)?null:(0,X.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:e.url,className:`box-border inline-flex h-[22px] max-w-full items-center gap-1 rounded-full border border-community-text-on-bg/25 px-2 text-xs font-medium leading-4 text-community-text-on-bg/80 no-underline transition-colors hover:bg-community-text-on-bg/[0.08]`,children:[(0,X.jsx)(Ir,{className:`size-3 shrink-0`,strokeWidth:1.8,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text}),(0,X.jsx)(Ar,{className:`size-2.5 shrink-0`,strokeWidth:2.2,"aria-hidden":`true`})]}):null},wc=()=>{let e=or();return(0,X.jsxs)(`div`,{className:`flex min-h-14 w-full min-w-0 items-center gap-3 text-community-text-on-bg`,children:[(0,X.jsx)(Wn,{src:Gn(),alt:e,className:`size-12`,fallbackClassName:`bg-gray-300`}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,X.jsx)(`span`,{className:`max-w-full truncate text-[15px] font-semibold leading-5 tracking-[-0.15px]`,children:e}),(0,X.jsx)(Cc,{})]})]})},Tc=nc(`/community_access`,`community_accessible`),Ec=()=>{},Dc=({invite:e,publicationName:t})=>{let{t:n}=v(),r=l(),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1),{currentModal:c}=H(),{openJoinModal:u}=U(),[,d]=Yt(),f=Oc(e),p=()=>{a(!0),C(`token`)},m=e=>{d(e),u()},g=kc(e,f,n),_=r.state!==`idle`||i;return(0,X.jsxs)(Ve,{isOpen:!(c===`community_join`||c===`community_login`),onClose:p,title:g.title,de
6scription:g.description,closeLabel:n(`shared.close`),publicationName:t,disableInitialTransition:!0,children:[f===`wrong_account`&&(0,X.jsx)(Vn,{type:`button`,variant:`primary`,size:`lg`,fullWidth:!0,onClick:p,disabled:_,className:`transition-[opacity,transform] duration-150 hover:opacity-90 active:scale-[0.99]`,children:n(`accept_community_invite.wrong_account.cta`)}),e.state===`accept_ready`&&f===`accept`&&(0,X.jsxs)(h,{method:`post`,action:`/community-join`,className:`flex w-full flex-col gap-4`,children:[(0,X.jsx)(`input`,{type:`hidden`,name:`t`,value:e.tokenId}),(0,X.jsx)(`input`,{type:`hidden`,name:`token`,value:e.token}),(0,X.jsx)(Ke,{checked:o,onChange:s}),(0,X.jsx)(Vn,{type:`submit`,variant:`primary`,size:`lg`,fullWidth:!0,disabled:_||!o,className:`transition-[opacity,transform] duration-150 hover:opacity-90 active:scale-[0.99]`,children:r.state===`idle`?n(`accept_community_invite.accept`):n(`accept_community_invite.accepting`)})]}),f===`awaiting_access`&&(0,X.jsx)(ac,{onAccessGranted:Ec,checkAccess:Tc}),e.state===`accept_ready`&&f===`upgrade`&&(0,X.jsx)(Vn,{type:`button`,variant:`primary`,size:`lg`,fullWidth:!0,onClick:()=>m(e.email),disabled:_,className:`transition-[opacity,transform] duration-150 hover:opacity-90 active:scale-[0.99]`,children:n(`accept_community_invite.paid.cta`)}),e.state===`already_accepted`&&(0,X.jsx)(Vn,{variant:`primary`,size:`lg`,fullWidth:!0,onClick:p,disabled:_,className:`transition-[opacity,transform] duration-150 hover:opacity-90 active:scale-[0.99]`,children:n(`accept_community_invite.already_accepted.cta`)})]})};function Oc(e){let t=_r(),[n]=i(),r=f(`root`),a=!!r?.isLoggedIn,o=a?r?.subscription?.email:void 0;return e.state===`accept_ready`?o!==void 0&&Pn(o)!==Pn(e.email)?`wrong_account`:t===`upgrade`&&a&&n.get(`upgrade_return`)===`1`?`awaiting_access`:t===`closed`?`closed`:t===`upgrade`?`upgrade`:`accept`:null}function kc(e,t,n){switch(e.state){case`accept_ready`:switch(t){case`wrong_account`:return{title:n(`accept_community_invite.title`),description:n(`accept_community_invite.wrong_account.body`)};case`closed`:return{title:n(`community.paid_gate.closed_title`),description:n(`community.paid_gate.closed_description`)};case`upgrade`:return{title:n(`accept_community_invite.title`),description:n(`accept_community_invite.paid.body`,{communityName:e.communityName})};default:return{title:n(`accept_community_invite.title`),description:n(`accept_community_invite.body`,{communityName:e.communityName})}}case`already_accepted`:return{title:n(`accept_community_invite.already_accepted.title`),description:n(`accept_community_invite.already_accepted.body`)};case`invalid_token`:return{title:n(`accept_community_invite.invali
6d_token.title`),description:n(`accept_community_invite.invalid_token.body`)}}}var Ac=async()=>{let e=await fetch(`/community/posts?limit=5`);if(!e.ok)throw Error(`Failed to fetch trending posts`);return e.json()},jc=({enabled:e=!0}={})=>pe({queryKey:Ot.trending,queryFn:Ac,enabled:e}),Mc=({initialQuery:e,initialData:t}={})=>{let n=(0,J.useRef)(e?.trim()??``),[r,i]=(0,J.useState)(n.current),[a,o]=(0,J.useState)(!1),s=vr(e=>{i(e),o(!1)},500),{data:c,isFetching:l}=pe({queryKey:Ot.query(r),queryFn:()=>Et({q:r}),enabled:!!r,initialData:r===n.current?t:void 0});return{results:c,isSearching:(a||!!r&&l)&&!c,search:e=>{let t=e.trim();if(!t){s.cancel(),i(``),o(!1);return}o(!0),s(t)}}},Nc=({comment:e})=>{let{t}=v();return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-4 pr-4 pl-2 hover:bg-black/5 transition-colors`,children:[(0,X.jsx)(`div`,{className:`flex items-center justify-center size-8 shrink-0`,children:(0,X.jsx)(gt,{className:`size-4 text-black/50`})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`truncate text-[15px] leading-5 font-semibold tracking-[-0.01em] text-black`,children:e.content}),(0,X.jsx)(`span`,{className:`truncate text-[13px] leading-4 tracking-[-0.01em] text-black/70`,children:t(`community.search.comment_in_post`,{title:e.post.title,interpolation:{escapeValue:!1}})})]})]})},Pc=({member:e})=>(0,X.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-black/5 transition-colors`,children:[(0,X.jsx)(Wn,{src:e.avatar_url,alt:e.name,className:`size-8`}),(0,X.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-[6px] min-w-0`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-sm text-black truncate`,children:e.name}),(0,X.jsx)(Zn,{roles:e.roles,isBlocked:e.computed?.blocking===!0,blockedYou:e.computed?.blocked_you===!0,badges:e.badges,limit:1})]}),e.headline&&(0,X.jsx)(`span`,{className:`text-xs text-black/50 truncate`,children:e.headline})]})]}),Fc=({title:e,count:t,viewAllHref:n,onViewAllClick:r,children:i})=>{let{t:a}=v();return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-black/50 uppercase tracking-wide`,children:e}),(0,X.jsx)(`span`,{className:`text-xs text-black/40 font-medium`,children:t})]}),i,t>3&&(0,X.jsx)(m,{to:n,onClick:r,className:`flex items-center px-3 py-1.5 text-sm font-medium text-black/60 hover:text-black transition-colors`,children:a(`community.search.view_all`)})]})},Ic=({post:e,onClick:t})=>{let n=me(),{t:r}=v(),i=e.attachable?.type===`quoted_post`?e.attachable:void 0,a=!!i&&!e.title?.trim()&&!e.body_preview,o=e.title?.trim()||i?.title?.trim()||(i?r(`community.repost.repost`,`Repost`):e.title),s=a?r(`community.repost.reposted_by`,`Reposted by {{name}}`,{name:e.author.name||r(`community.join.former_member`,`Former member`),interpolation:{escapeValue:!1}}):e.body_preview;return(0,X.jsxs)(m,{to:`${L.root}/posts/${e.id}`,onClick:t,className:`flex items-center gap-2 h-[72px] py-4 pr-4 pl-2 hover:bg-black/5 transition-colors`,children:[(0,X.jsx)(`div`,{className:`flex items-center justify-center size-8 shrink-0`,children:(0,X.jsx)(gt,{className:`size-4 text-black/50`})}),(0,X.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 min-w-0 flex-1 pr-4`,children:[(0,X.jsx)(`span`,{className:`truncate text-[15px] leading-5 font-semibold tracking-[-0.01em] text-black`,children:o}),s&&(0,X.jsx)(`span`,{className:`truncate text-[13px] leading-4 tracking-[-0.01em] text-black/70`,children:s})]}),(0,X.jsx)(`span`,{className:`shrink-0 text-[13px] leading-4 tracking-[-0.01em] text-black/50`,children:n(e.created_at)})]})},Lc=({isOpen:e,query:t,onQueryChange:n,onClose:r,onKeyDown:i,onViewAll:a,results:o,isSearching:s,trendingPosts:c,inputRef:l})=>{let{t:u}=v(),d=t.trim().length>0,f=o!=null&&(o.posts.length>0||o.comments.length>0||o.members.length>0);return(0,X.jsx)(je,{appear:!0,show:e,as:J.Fragment,children:(0,X.jsxs)(Ae,{as:`div`,className:`relative z-50`,onClose:r,initialFocus:l,children:[(0,X.jsx)(je.Child,{as:J.Fragment,enter:`ease-out duration-150`,enterFrom:`opacity-0`,enterTo:`opacity-100`,leave:`ease-in duration-100`,leaveFrom:`opacity-100`,leaveTo:`opacity-0`,children:(0,X.jsx)(`div`,{className:`fixed inset-0 bg-black/50`})}),(0,X.jsx)(`div`,{className:`fixed inset-x-0 top-16 z-50 flex justify-center`,children:(0,X.jsx)(je.Child,{as:J.Fragment,enter:`ease-out duration-200`,enterFrom:`opacity-0 scale-95`,enterTo:`opacity-100 scale-100`,leave:`ease-in duration-100`,leaveFrom:`opacity-100 scale-100`,leaveTo:`opacity-0 scale-95`,children:(0,X.jsxs)(Ae.Panel,{className:`w-full md:max-w-[585px] max-h-[90vh] flex flex-col bg-white rounded-2xl border border-black/10 shadow-[0px_0px_0px_1px_rgba(0,0,0,0.02),0px_4px_8px_rgba(0,0,0,0.08),0px_12px_30px_rgba(0,0,0,0.18)] md:mx-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 py-2 pr-2 pl-3 border-b border-black/10`,children:[(0,X.jsx)(`div`,{className:`flex items-center justify-center size-8 shrink-0`,children:(0,X.jsx)(Dt,{className:`size-4 text-black`})}),(0,X.jsx)(`input`,{ref:l,type:`text`,value:t,onChange:e=>n(e.target.value),onKeyDown:i,"aria-label":u(`community.search.placeholder`),placeholder:u(`community.search.placeholder`),className:`flex-1 outline-none ring-0 focus:outline-none focus:ring-0 bg-transparent border-none p-0 text-[15px] leading-5 tracking-[-0.01em] text-black`}),(0,X.jsx)(`button`,{type:`button`,onClick:r,"aria-label":u(`community.search.close`),className:`flex items-center justify-center size-10 shrink-0`,children:(0,X.jsx)(Pt,{className:`size-6 text-black opacity-50`})})]}),(0,X.jsxs)(`div`,{className:`overflow-y-auto py-4`,children:[s&&(0,X.jsx)(`div`,{className:`flex flex-col`,children:Array.from({length:5}).map((e,t)=>(0,X.jsx)(yr,{},`skeleton-${t}`))}),!d&&!s&&(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`div`,{className:`px-4 py-2`,children:(0,X.jsx)(`span`,{className:`font-semibold opacity-50 text-[11px] leading-none text-black`,children:u(`community.search.trending_posts`)})}),c.isLoading?Array.from({length:5}).map((e,t)=>(0,X.jsx)(yr,{},`trending-skeleton-${t}`)):c.data?.posts.map(e=>(0,X.jsx)(Ic,{post:e,onClick:r},e.id))]}),!s&&d&&f&&o&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.posts.length>0&&(0,X.jsx)(Fc,{title:u(`community.search.posts`),count:o.total_counts?.posts??o.posts.length,viewAllHref:`${L.search}?q=${encodeURIComponent(t)}&tab=posts`,onViewAllClick:()=>a(`posts`),children:o.posts.slice(0,3).map(e=>(0,X.jsx)(Ic,{post:e,onClick:r},e.id))}),o.comments.length>0&&(0,X.jsx)(Fc,{title:u(`community.search.comments`),count:o.total_counts?.comments??o.comments.length,viewAllHref:`${L.search}?q=${encodeURIComponent(t)}&tab=comments`,onViewAllClick:()=>a(`comments`),children:o.comments.slice(0,3).map(e=>(0,X.jsx)(m,{to:`${L.root}/posts/${e.post.id}#${e.id}`,onClick:r,children:(0,X.jsx)(Nc,{comment:e})},e.id))}),o.members.length>0&&(0,X.jsx)(Fc,{title:u(`community.search.members`),count:o.total_counts?.members??o.members.length,viewAllHref:`${L.search}?q=${encodeURIComponent(t)}&tab=members`,onViewAllClick:()=>a(`members`),children:o.members.slice(0,3).map(e=>(0,X.jsx)(W,{memberId:e.id,onClick:r,children:(0,X.jsx)(Pc,{member:e})},e.id))})]}),!s&&d&&!f&&(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 px-4 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-black/70`,children:u(`community.search.no_results`)}),(0,X.jsx)(`p`,{className:`text-xs text-black/50 mt-1`,children:u(`community.search.no_results_description`)})]})]})]})})})]})})},Rc=({member:e,onClose:t})=>{let{t:n}=v(),r=br(e);return(0,X.jsxs)(`div`,{className:`flex items-center gap-4 p-4`,children:[(0,X.jsxs)(W,{memberId:e.id,onClick:t,className:`flex items-center gap-4 min-w-0 flex-1`,children:[(0,X.jsx)(Wn,{src:e.avatar_url,alt:e.name,className:`size-10`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-[6px] min-w-0`,children:[(0,X.jsx)(`p`,{className:`font-semibold text-[15px] leading-5 text-black truncate`,children:e.name}),(0,X.jsx)(Zn,{roles:e.roles,isBlocked:e.computed?.blocking===!0,blockedYou:e.computed?.blocked_you===!0,badges:e.badges,limit:1})]}),e.headline&&(0,X.jsx)(`p`,{className:`text-[11px] leading-4 text-black/50 truncate`,children:e.headline})]})]}),r&&(0,X.jsxs)(Kn,{variant:`primary`,size:`sm`,to:L.chatDm(e.id),onClick:t,className:`shrink-0 flex items-center justify-center gap-1 px-4`,children:[(0,X.jsx)(wt,{className:`size-4`}),n(`community.search.message`)]})]})},zc=({query:e,onQueryChange:t,onClose:n,onKeyDown:r,results:i,isSearching:a,trendingPosts:o,inputRef:s})=>{let{t:c}=v(),[l,u]=(0,J.useState)(`posts`);(0,J.useEffect)(()=>{s.current?.focus()},[s]);let d=e.trim().length>0;(0,J.useEffect)(()=>{d||u(`posts`)},[d]);let f=!!i&&(i.posts.length>0||i.comments.length>0||i.members.length>0),p={posts:i?.total_counts?.posts??i?.posts.length??0,comments:i?.total_counts?.comments??i?.comments.length??0,members:i?.total_counts?.members??i?.members.length??0};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 py-2 pr-2 pl-3 border-b border-black/10`,children:[(0,X.jsx)(`div`,{className:`flex items-center justify-center size-8 shrink-0`,children:(0,X.jsx)(Dt,{className:`size-4 text-black`})}
6),(0,X.jsx)(`input`,{ref:s,type:`text`,value:e,onChange:e=>t(e.target.value),onKeyDown:r,"aria-label":c(`community.search.placeholder`),placeholder:c(`community.search.placeholder`),className:`flex-1 outline-none ring-0 focus:outline-none focus:ring-0 bg-transparent border-none p-0 text-base leading-5 tracking-[-0.01em] text-black`}),(0,X.jsx)(`button`,{type:`button`,onClick:n,"aria-label":c(`community.search.close`),className:`flex items-center justify-center size-10 shrink-0`,children:(0,X.jsx)(Pt,{className:`size-6 text-black opacity-50`})})]}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[!d&&!a&&(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`div`,{className:`px-4 py-2`,children:(0,X.jsx)(`span`,{className:`font-semibold opacity-50 text-[11px] leading-none text-black`,children:c(`community.search.trending_posts`)})}),o.isLoading?Array.from({length:5}).map((e,t)=>(0,X.jsx)(yr,{},`trending-skeleton-${t}`)):o.data?.posts.map(e=>(0,X.jsx)(Ic,{post:e,onClick:n},e.id))]}),a&&(0,X.jsx)(`div`,{className:`flex flex-col`,children:Array.from({length:5}).map((e,t)=>(0,X.jsx)(yr,{},`skeleton-${t}`))}),!a&&d&&f&&i&&(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-4 pb-2 pt-2 text-[17px] leading-6 font-semibold tracking-[-0.02em] text-black`,children:c(`community.search.results_heading`,{query:e,interpolation:{escapeValue:!1}})}),(0,X.jsx)(`div`,{role:`tablist`,className:`flex items-center gap-6 h-9 pl-4 border-b border-black/10`,children:[`posts`,`comments`,`members`].map(e=>{let t=l===e;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,"aria-controls":`mobile-tabpanel-${e}`,id:`mobile-tab-${e}`,onClick:()=>u(e),className:(0,Y.default)(`flex items-center gap-[3px] whitespace-nowrap relative py-2 h-9`,{"border-b border-black/80":t}),children:[(0,X.jsx)(`span`,{className:(0,Y.default)(`text-[15px] leading-5 tracking-[-0.01em]`,{"font-semibold text-black":t,"font-medium text-black/50":!t}),children:c(`community.search.${e}`)}),p[e]>0&&(0,X.jsx)(`span`,{className:`text-[15px] leading-5 font-normal tracking-[-0.01em] text-black`,children:p[e]})]},e)})}),(0,X.jsxs)(`div`,{role:`tabpanel`,id:`mobile-tabpanel-${l}`,"aria-labelledby":`mobile-tab-${l}`,className:`flex flex-col`,children:[l===`posts`&&(i.posts.length>0?i.posts.map(e=>(0,X.jsx)(Ic,{post:e,onClick:n},e.id)):(0,X.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-black/50`,children:c(`community.search.no_results`)})),l===`comments`&&(i.comments.length>0?i.comments.map(e=>(0,X.jsx)(m,{to:`${L.root}/posts/${e.post.id}#${e.id}`,onClick:n,children:(0,X.jsx)(Nc,{comment:e})},e.id)):(0,X.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-black/50`,children:c(`community.search.no_results`)})),l===`members`&&(i.members.length>0?i.members.map(e=>(0,X.jsx)(Rc,{member:e,onClose:n},e.id)):(0,X.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-black/50`,children:c(`community.search.no_results`)}))]})]}),!a&&d&&!f&&(0,X.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-black/50`,children:c(`community.search.no_results`)})]})]})},Bc=()=>{let{currentModal:e,handleCloseModal:t}=H(),n=c(),r=Rn(),[i,a]=(0,J.useState)(``),o=(0,J.useRef)(null),s=e===`search`,l=jc({enabled:s}),{search:u,results:d,isSearching:f}=Mc(),p=()=>{t({preventScrollReset:!0}),a(``),u(``)},m=e=>{a(e),u(e)},h=e=>{t({preventScrollReset:!0}),n(`${L.search}?q=${encodeURIComponent(i)}&tab=${e}`),a(``)},g=e=>{e.key===`Enter`&&i.trim()&&(t({preventScrollReset:!0}),n(`${L.search}?q=${encodeURIComponent(i)}`),a(``))};return mr({pageBlock:G.CommunitySearchModal},{fireWhenInViewport:!1,enabled:s}),r?(0,X.jsx)(zn,{isOpen:s,onClose:p,panelClassName:`flex flex-col h-[100dvh] pt-[env(safe-area-inset-top)]`,children:(0,X.jsx)(zc,{query:i,onQueryChange:m,onClose:p,onKeyDown:g,results:d,isSearching:f,trendingPosts:l,inputRef:o})}):(0,X.jsx)(Lc,{isOpen:s,query:i,onQueryChange:m,onClose:p,onKeyDown:g,onViewAll:h,results:d,isSearching:f,trendingPosts:l,inputRef:o})},Vc=`/community?modal=community_join`,Hc=`${Vc}&upgrade_return=1`,Uc=(e,t)=>`/community?t=${encodeURIComponent(e)}&token=${encodeURIComponent(t)}`,Wc=()=>{let e=f(`routes/community`)?.invite;if(e?.state!==`accept_ready`)return{successRedirectTo:Hc,signInRedirectTo:Vc,resumesInviteAcceptance:!1};let t=Uc(e.tokenId,e.token);return{successRedirectTo:`${t}&upgrade_return=1`,signInRedirectTo:t,resumesInviteAcceptance:!0}},Gc=nc(`/community_access`,`community_accessible`),Kc=({handoff:{isAwaitingAccess:e,markAwaitingAccess:t,onAccessGranted:n}})=>{let{t:r}=v(),a=!!f(`root`)?.isLoggedIn,{handleOpenModal:o}=H(),s=dr(),l=c(),[u]=i(),d=or(),{successRedirectTo:p,signInRedirectTo:m}=Wc(),h=u.get(`upgrade_return`)===`1`,g=e=>{if(e){l(e);return}o(`community_login`,{preventScrollReset:!0},{redirect_to:p,upgrade_return:`1`})},_=a?void 0:(0,X.jsxs)(`p`,{className:`mt-8 text-center text-[13px] leading-6 text-black/50`,children:[r(`community.join.already_member`),` `,(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(`community_login`,{preventScrollReset:!0},{redirect_to:m}),className:`underline transition-colors duration-150 hover:text-black`,children:r(`shared.cta.sign_in`)})]});return(0,X.jsx)(pc,{isOpen:!0,title:r(`community.upgrade_modal.title`,{communityName:d}),impressionPageBlock:G.CommunityUpgradeModal,pricing:s,checkAccess:Gc,isAwaitingAccess:e,onPaymentAccepted:t,onAccessGranted:n,successRedirectTo:p,onGuestSuccess:g,footer
6:_,resumeAwaitingAccessOnOpen:h})},qc=()=>{let{isCommunityAccessible:e}=ue(),{openJoinModal:t}=U(),{resumesInviteAcceptance:n}=Wc(),{awaiting:r,markAwaitingAccess:i,onAccessGranted:a}=vc({modalType:`community_join`,isGranted:(0,J.useCallback)(()=>e,[e]),onGranted:(0,J.useCallback)(()=>{n||t()},[t,n])});return{isAwaitingAccess:r===!0,markAwaitingAccess:(0,J.useCallback)(()=>i(!0),[i]),onAccessGranted:a}},Jc=({openComposer:e,children:t})=>(0,X.jsx)(Ne.Provider,{value:{openComposer:e},children:t}),Yc={logger:typeof console<`u`?console:void 0,WebSocket:typeof WebSocket<`u`?WebSocket:void 0},$={log(...e){this.enabled&&(e.push(Date.now()),Yc.logger.log(`[ActionCable]`,...e))}},Xc=()=>new Date().getTime(),Zc=e=>(Xc()-e)/1e3,Qc=class{constructor(e){this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=e,this.reconnectAttempts=0}start(){this.isRunning()||(this.startedAt=Xc(),delete this.stoppedAt,this.startPolling(),addEventListener(`visibilitychange`,this.visibilityDidChange),$.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`))}stop(){this.isRunning()&&(this.stoppedAt=Xc(),this.stopPolling(),removeEventListener(`visibilitychange`,this.visibilityDidChange),$.log(`ConnectionMonitor stopped`))}isRunning(){return this.startedAt&&!this.stoppedAt}recordMessage(){this.pingedAt=Xc()}recordConnect(){this.reconnectAttempts=0,delete this.disconnectedAt,$.log(`ConnectionMonitor recorded connect`)}recordDisconnect(){this.disconnectedAt=Xc(),$.log(`ConnectionMonitor recorded disconnect`)}startPolling(){this.stopPolling(),this.poll()}stopPolling(){clearTimeout(this.pollTimeout)}poll(){this.pollTimeout=setTimeout((()=>{this.reconnectIfStale(),this.poll()}),this.getPollInterval())}getPollInterval(){let{staleThreshold:e,reconnectionBackoffRate:t}=this.constructor,n=(1+t)**+Math.min(this.reconnectAttempts,10),r=(this.reconnectAttempts===0?1:t)*Math.random();return e*1e3*n*(1+r)}reconnectIfStale(){this.connectionIsStale()&&($.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${Zc(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`),this.reconnectAttempts++,this.disconnectedRecently()?$.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${Zc(this.disconnectedAt)} s`):($.log(`ConnectionMonitor reopening`),this.connection.reopen()))}get refreshedAt(){return this.pingedAt?this.pingedAt:this.startedAt}connectionIsStale(){return Zc(this.refreshedAt)>this.constructor.staleThreshold}disconnectedRecently(){return this.disconnectedAt&&Zc(this.disconnectedAt)<this.constructor.staleThreshold}visibilityDidChange(){document.visibilityState===`visible`&&setTimeout((()=>{(this.connectionIsStale()||!this.connection.isOpen())&&($.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`),this.connection.reopen())}),200)}};Qc.staleThreshold=6,Qc.reconnectionBackoffRate=.15;var $c={message_types:{welcome:`welcome`,disconnect:`disconnect`,ping:`ping`,confirmation:`confirm_subscription`,rejection:`reject_subscription`},disconnect_reasons:{unauthorized:`unauthorized`,invalid_request:`invalid_request`,server_restart:`server_restart`,remote:`remote`},default_mount_path:`/cable`,protocols:[`actioncable-v1-json`,`actioncable-unsupported`]},{message_types:el,protocols:tl}=$c,nl=tl.slice(0,tl.length-1),rl=[].indexOf,il=class{constructor(e){this.open=this.open.bind(this),this.consumer=e,this.subscriptions=this.consumer.subscriptions,this.monitor=new Qc(this),this.disconnected=!0}send(e){return this.isOpen()?(this.webSocket.send(JSON.stringify(e)),!0):!1}open(){if(this.isActive())return $.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`),!1;{let e=[...tl,...this.consumer.subprotocols||[]];return $.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${e}`),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new Yc.WebSocket(this.consumer.url,e),this.installEventHandlers(),this.monitor.start(),!0}}close({allowReconnect:e}={allowReconnect:!0}){if(e||this.monitor.stop(),this.isOpen())return this.webSocket.close()}reopen(){if($.log(`Reopening WebSocket, current state is ${this.get
6State()}`),this.isActive())try{return this.close()}catch(e){$.log(`Failed to reopen WebSocket`,e)}finally{$.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`),setTimeout(this.open,this.constructor.reopenDelay)}else return this.open()}getProtocol(){if(this.webSocket)return this.webSocket.protocol}isOpen(){return this.isState(`open`)}isActive(){return this.isState(`open`,`connecting`)}triedToReconnect(){return this.monitor.reconnectAttempts>0}isProtocolSupported(){return rl.call(nl,this.getProtocol())>=0}isState(...e){return rl.call(e,this.getState())>=0}getState(){if(this.webSocket){for(let e in Yc.WebSocket)if(Yc.WebSocket[e]===this.webSocket.readyState)return e.toLowerCase()}return null}installEventHandlers(){for(let e in this.events){let t=this.events[e].bind(this);this.webSocket[`on${e}`]=t}}uninstallEventHandlers(){for(let e in this.events)this.webSocket[`on${e}`]=function(){}}};il.reopenDelay=500,il.prototype.events={message(e){if(!this.isProtocolSupported())return;let{identifier:t,message:n,reason:r,reconnect:i,type:a}=JSON.parse(e.data);switch(this.monitor.recordMessage(),a){case el.welcome:return this.triedToReconnect()&&(this.reconnectAttempted=!0),this.monitor.recordConnect(),this.subscriptions.reload();case el.disconnect:return $.log(`Disconnecting. Reason: ${r}`),this.close({allowReconnect:i});case el.ping:return null;case el.confirmation:return this.subscriptions.confirmSubscription(t),this.reconnectAttempted?(this.reconnectAttempted=!1,this.subscriptions.notify(t,`connected`,{reconnected:!0})):this.subscriptions.notify(t,`connected`,{reconnected:!1});case el.rejection:return this.subscriptions.reject(t);default:return this.subscriptions.notify(t,`received`,n)}},open(){if($.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`),this.disconnected=!1,!this.isProtocolSupported())return $.log(`Protocol is unsupported. Stopping monitor and disconnecting.`),this.close({allowReconnect:!1})},close(e){if($.log(`WebSocket onclose event`),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll(`disconnected`,{willAttemptReconnect:this.monitor.isRunning()})},error(){$.log(`WebSocket onerror event`)}};var al=function(e,t){if(t!=null)for(let n in t)e[n]=t[n];return e},ol=class{constructor(e,t={},n){this.consumer=e,this.identifier=JSON.stringify(t),al(this,n)}perform(e,t={}){return t.action=e,this.send(t)}send(e){return this.consumer.send({command:`message`,identifier:this.identifier,data:JSON.stringify(e)})}unsubscribe(){return this.consumer.subscriptions.remove(this)}},sl=class{constructor(e){this.subscriptions=e,this.pendingSubscriptions=[]}guarantee(e){this.pendingSubscriptions.indexOf(e)==-1?($.log(`SubscriptionGuarantor guaranteeing ${e.identifier}`),this.pendingSubscriptions.push(e)):$.log(`SubscriptionGuarantor already guaranteeing ${e.identifier}`),this.startGuaranteeing()}forget(e){$.log(`SubscriptionGuarantor forgetting ${e.identifier}`),this.pendingSubscriptions=this.pendingSubscriptions.filter((t=>t!==e))}startGuaranteeing(){this.stopGuaranteeing(),this.retrySubscribing()}stopGuaranteeing(){clearTimeout(this.retryTimeout)}retrySubscribing(){this.retryTimeout=setTimeout((()=>{this.subscriptions&&typeof this.subscriptions.subscribe==`function`&&this.pendingSubscriptions.map((e=>{$.log(`SubscriptionGuarantor resubscribing ${e.identifier}`),this.subscriptions.subscribe(e)}))}),500)}},cl=class{constructor(e){this.consumer=e,this.guarantor=new sl(this),this.subscriptions=[]}create(e,t){let n=e,r=typeof n==`object`?n:{channel:n},i=new ol(this.consumer,r,t);return this.add(i)}add(e){return this.subscriptions.push(e),this.consumer.ensureActiveConnection(),this.notify(e,`initialized`),this.subscribe(e),e}remove(e){return this.forget(e),this.findAll(e.identifier).length||this.sendCommand(e,`unsubscribe`),e}reject(e){return this.findAll(e).map((e=>(this.forget(e),this.notify(e,`rejected`),e)))}forget(e){return this.guarantor.forget(e),this.subscriptions=this.subscriptions.filter((t=>t!==e)),e}findAll(e){return this.subscriptions.filter((t=>
6t.identifier===e))}reload(){return this.subscriptions.map((e=>this.subscribe(e)))}notifyAll(e,...t){return this.subscriptions.map((n=>this.notify(n,e,...t)))}notify(e,t,...n){let r;return r=typeof e==`string`?this.findAll(e):[e],r.map((e=>typeof e[t]==`function`?e[t](...n):void 0))}subscribe(e){this.sendCommand(e,`subscribe`)&&this.guarantor.guarantee(e)}confirmSubscription(e){$.log(`Subscription confirmed ${e}`),this.findAll(e).map((e=>this.guarantor.forget(e)))}sendCommand(e,t){let{identifier:n}=e;return this.consumer.send({command:t,identifier:n})}},ll=class{constructor(e){this._url=e,this.subscriptions=new cl(this),this.connection=new il(this),this.subprotocols=[]}get url(){return ul(this._url)}send(e){return this.connection.send(e)}connect(){return this.connection.open()}disconnect(){return this.connection.close({allowReconnect:!1})}ensureActiveConnection(){if(!this.connection.isActive())return this.connection.open()}addSubProtocol(e){this.subprotocols=[...this.subprotocols,e]}};function ul(e){if(typeof e==`function`&&(e=e()),e&&!/^wss?:/i.test(e)){let t=document.createElement(`a`);return t.href=e,t.href=t.href,t.protocol=t.protocol.replace(`http`,`ws`),t.href}else return e}function dl(e=fl(`url`)||$c.default_mount_path){return new ll(e)}function fl(e){let t=document.head.querySelector(`meta[name='action-cable-${e}']`);if(t)return t.getAttribute(`content`)}var pl=()=>{if(typeof window>`u`)return null;let e=new URLSearchParams(window.location.search).get(`jwt_token`)||B(`token`,document.cookie);if(!e)return null;let t=window.__AppGlobals__?.CABLE_URL;if(!t)return null;let n=t.startsWith(`https`)?`wss`:`ws`;return dl(`${t.replace(/^https?/,n)}/orchid_cable?token=${encodeURIComponent(e)}`)},ml=`/posts`,hl=20,gl=250,_l=e=>typeof e==`object`&&!!e&&Array.isArray(e.posts),vl=({limit:e=hl,enabled:t=!0}={})=>{let[n,r]=(0,J.useState)(``),i=vr(r,gl);return{...pe({queryKey:[`community-composer-posts`,n,e],queryFn:async({signal:t})=>{let r=new URLSearchParams({per_page:String(e),page:`1`});n.trim()&&r.set(`q`,n.trim());let i=await fetch(`${ml}?${r}`,{signal:t});if(!i.ok)throw Error(`composer_posts_failed`);let a=await i.json();if(!_l(a))throw Error(`composer_posts_invalid`);return a},enabled:t}),setQuery:i}},yl=e=>typeof e!=`object`||!e?!1:`post`in e||`id`in e||`toast`in e,bl=()=>{let e=ne();return fe({mutationFn:async t=>{let n=await e(),r=await(await fetch(`/community_post`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded;charset=UTF-8`,"X-CSRF-Token":n},body:new URLSearchParams(ae(t,G.CommunityPostForm))})).json();if(!yl(r))throw Error(`composer_invalid_response`);return r}})},xl=e=>typeof e!=`object`||!e?!1:`id`in e||`toast`in e,Sl=()=>{let e=ne();return fe({mutationFn:async t=>{let n=await e(),r=await(await fetch(`/update_community_post`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded;charset=UTF-8`,"X-CSRF-Token":n},body:new URLSearchParams(t)})).json();if(!xl(r))throw Error(`composer_invalid_response`);return r}})},Cl=e=>t=>{if(!t||t.pages.length===0)return t;let[n,...r]=t.pages;return{...t,pages:[{...n,posts:[e,...n.posts]},...r]}},wl=e=>{let t=lt.feed(void 0,R),n=e.space?.slug;return n?[lt.feed(n,R),t]:[t]},Tl=(e,t)=>
6{let n=Cl(t),r=wl(t);for(let t of r)e.setQueryData(t,n),e.invalidateQueries({queryKey:t,refetchType:`none`})},El={kind:`feed`},Dl=e=>({id:e.id,slug:e.slug,name:e.name,is_default:e.is_default,tier_gated:e.tier_gated,read_only:e.read_only}),Ol=(e,t=!1)=>({kind:`channel`,space:{...Dl(e),...t?{disabled:!0}:{}}}),kl=({feedFirstEnabled:e,canCreatePost:t,canMovePost:n,spaces:r,canPostIn:i,defaultSpaceSlug:a,editPost:o})=>{let s=r.filter(e=>i(e)),c=s.map(e=>Ol(e));if(o){let t=o.space,i=t?r.find(e=>e.slug===t.slug):void 0,a=t?i??t:void 0,s=a?Ol(a):El;if(e&&n){let e=[El,...r.map(e=>Ol(e,e.read_only===!0&&e.slug!==t?.slug))],n=nt(s);return{destination:s,destinations:e.some(e=>nt(e)===n)?e:[s,...e],mode:`selectable`}}return{destination:s,destinations:[s],mode:!e&&t?`hidden`:`locked`}}if(!t)return null;let l=s.find(e=>e.slug===a);if(e)return{destination:l?Ol(l):El,destinations:[El,...c],mode:`selectable`};let u=l??s.find(e=>e.is_default)??s[0];return u?{destination:Ol(u),destinations:c,mode:a?`hidden`:`selectable`}:null},Al=e=>{if(e==null)return null;if(typeof e==`object`)return e;if(typeof e!=`string`)return null;try{let t=JSON.parse(e);return typeof t==`object`&&t?t:null}catch{return null}},jl=e=>e.space?{kind:`channel`,space:{id:e.space.id,slug:e.space.slug,name:e.space.name,tier_gated:e.space.tier_gated}}:{kind:`feed`},Ml=e=>typeof e!=`object`||!e||!(`toast`in e)?!1:e.toast!==void 0&&e.toast.status===In.ERROR,Nl=({isOpen:e,onClose:t,spaces:n,defaultSpaceSlug:r,quotedPost:i,editPost:a})=>{let{t:o}=v(),s=ne(),c=Rn(),l=u(),d=ie(),p=bl(),m=Sl(),h=Cn(),g=En(),{applyOptimisticPatch:_,clearOptimisticPatch:y}=ct(),{canPostIn:b}=fr(),{currentMember:x,permissions:S}=U(),C=f(`routes/community`),w=C?.community?.feed_first_enabled===!0,T=(0,J.useMemo)(()=>kl({feedFirstEnabled:w,canCreatePost:S.canCreatePost,canMovePost:S.canMoveAnyPost,spaces:n,canPostIn:b,defaultSpaceSlug:r,editPost:a}),[w,S.canCreatePost,S.canMoveAnyPost,n,b,r,a]),[E,D]=(0,J.useState)(null),O=T?E??T.destination:null,k=a&&O&&nt(O)!==nt(jl(a))?O:null,[A,j]=(0,J.useState)(()=>a?.title??``),[M,N]=(0,J.useState)(null),[P,F]=(0,J.useState)(),ee=(0,J.useRef)(null),I=i??(a?.attachable?.type===`quoted_post`?a.attachable:void 0),L=a?.attachable?.type===`post`?a.attachable:void 0,[R,z]=(0,J.useState)(()=>L?[{id:L.id,web_title:L.web_title,web_subtitle:L.web_subtitle,image_url:L.image_url,publication_logo_url:L.publication_logo_url,publication_via_label:o(`community.post_embed_card.via`,{name:L.publication_name}),authors:L.authors.map(e=>({name:e.name,avatar_url:e.profile_picture?.url??null}))}]:[]),{setQuery:te,...re}=vl({enabled:e&&!a}),B=f(`root`),ae=(0,J.useMemo)(()=>(re.data?.posts??[]).map(e=>({id:e.id,web_title:e.web_title,web_subtitle:e.web_subtitle,image_url:e.image_url,publication_logo_url:B?.publication?.logo?.url??null,publication_via_label:B?.publication?.name?o(`community.post_embed_card.via`,{name:B.publication.name}):null,authors:e.authors.map(e=>({name:e.name,avatar_url:e.profile_picture?.url??null})),scheduled_at:e.override_scheduled_at})),[re.data,B?.publication,o]),oe=(0,J.useMemo)(()=>a?Al(a.tiptap_state):null,[a]),se=o(`community.composer.body_placeholder`),V=(0,J.useCallback)(()=>{D(null),j(``),N(null),z([]),te(``),ee.current?.reset()},[te]);Fn(P);let ce=p.isPending||m.isPending,le=(0,J.useCallback)(e=>{if(Ml(e)){N(e.toast.message??o(`community.composer.error`));return}if(!(`post`in e)){N(o(`community.composer.error`));return}Tl(d,e.post),e.toast?.status===In.SUCCESS&&F(e.toast),V(),t()},[t,d,V,o]),H=(0,J.useCallback)(()=>{N(o(`community.composer.error`))},[o]),ue=(0,J.useCallback)(e=>{if(!a)return;if(Ml(e)){y(a.id),N(e.toast.message??o(`community.composer.error`));return}if(!(`id`in e)){y(a.id),N(o(`community.composer.error`));return}let n={title:e.title,updated_at:e.updated_at??a.updated_at,edited_at:e.edited_at??a.edited_at};`tiptap_state`in e&&e.tiptap_state!==void 0&&(n.tiptap_state=e.tiptap_state),_(a.id,n),k&&de(d),e.toast?.status===In.SUCCESS&&F(e.toast),l.revalidate(),V(),t()},[_,y,a,k,t,d,V,l,o]),W=(0,J.useCallback)(()=>{a&&y(a.id),N(o(`community.composer.error`))},[y,a,o]),fe=(0,J.useCallback)(e=>{if(!A.trim()&&!I){F({status:In.ERROR,message:o(`community.composer.error_title_required`)});return}let t=ee.current?.isEmpty()??!0,n=R.length>0;if(t&&!I&&!n){N(o(`community.composer.error_empty`));return}N(null);let r=R[0];if(a){_(a.id,{title:A,tiptap_state:e});let t={post_id:a.id,title:A,content_json:JSON.stringify(e)};
6k&&(t.destination_kind=k.kind),k?.kind===`channel`&&(t.destination_space_slug=k.space.slug),m.mutate(t,{onSuccess:ue,onError:W});return}if(!O)return;let s={title:A,content_json:JSON.stringify(e),composer_mode:i?`quote`:`default`};O.kind===`channel`&&(s.space_slug=O.space.slug),i?.id?(s.attachable_type=`CommunityPost`,s.attachable_id=i.id):r&&(s.attachable_type=`Post`,s.attachable_id=r.id),p.mutate(s,{onSuccess:le,onError:H})},[R,I,i,a,O,k,A,o,_,p,H,le,W,ue,m.mutate]),pe=(0,J.useCallback)(async e=>{let t=await h.mutateAsync(e);return{url:t.public_url,alt:e.name,blobKey:t.key}},[h]),me=!!(C?.community?.video_enabled&&C?.currentMember?.can_upload_video),he=ut({spaceSlug:O?.kind===`channel`?O.space.slug:void 0}),ge=(0,J.useMemo)(()=>{let e=async(e,t)=>{let n=await s(),r=await fetch(e,{...t,headers:{"Content-Type":`application/json`,...n?{"X-CSRF-Token":n}:{}}});return r.ok?r.json():null};return{request:(t,{multipart:n,signal:r})=>e(`/community_video_upload`,{method:`POST`,body:JSON.stringify({file:t,multipart:n}),signal:r}),signPart:(t,{signal:n,...r})=>e(`/community_video_multipart`,{method:`POST`,body:JSON.stringify({videoId:t,...r}),signal:n}),listParts:(t,{upload_id:n,signal:r})=>e(`/community_video_multipart?${new URLSearchParams({videoId:t,upload_id:n})}`,{method:`GET`,signal:r}),complete:(t,{signal:n,...r})=>e(`/community_video_multipart`,{method:`PATCH`,body:JSON.stringify({videoId:t,...r}),signal:n}),abort:async(t,{signal:n,...r})=>{await e(`/community_video_multipart`,{method:`DELETE`,body:JSON.stringify({videoId:t,...r}),signal:n}).catch(()=>{})},confirm:t=>e(`/community_video_confirm`,{method:`POST`,body:JSON.stringify({videoId:t})})}},[s]),_e=(0,J.useCallback)(async e=>{try{let t=await s();await fetch(`/community_video_retry`,{method:`POST`,headers:{"Content-Type":`application/json`,...t?{"X-CSRF-Token":t}:{}},body:JSON.stringify({videoId:e})})}catch{}},[s]),ve=(0,J.useCallback)(async e=>{let t=e instanceof FormData;try{let n=await s(),r=await fetch(`/community_video_thumbnail`,{method:`POST`,headers:{...t?{}:{"Content-Type":`application/json`},...n?{"X-CSRF-Token":n}:{}},body:t?e:JSON.stringify(e)});if(!r.ok)return null;let i=await r.json();return i.video?Xr(i.video):null}catch{return null}},[s]),ye=(0,J.useCallback)(e=>ve({videoId:e}),[ve]),be=(0,J.useCallback)((e,t)=>ve({videoId:e,index:t}),[ve]),xe=(0,J.useCallback)((e,t)=>{let n=new FormData;return n.append(`videoId`,e),n.append(`thumbnail`,t),ve(n)},[ve]),Se=(0,J.useMemo)(()=>me?pl():null,[me]);(0,J.useEffect)(()=>()=>Se?.disconnect(),[Se]);let Ce=ot(),we=(0,J.useCallback)((e,t)=>{if(!Se)return()=>{};let n=Se.subscriptions.create({channel:`OrchidCable::CommunityVideoChannel`,video_id:e},{received:e=>{let n=Yr(e);n&&t(n)}});return()=>n.unsubscribe()},[Se]),G=(0,J.useCallback)(async e=>{try{let t=await s(),n=await(await fetch(`/community_link_preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded;charset=UTF-8`,...t?{"X-CSRF-Token":t}:{}},body:new URLSearchParams({url:e})})).json();if(typeof n!=`object`||!n)return null;let r=n;return{title:r.title??void 0,description:r.description??void 0,image:r.image??void 0,siteName:r.site_name??void 0}}catch{return null}},[s]),Te=(0,J.useMemo)(()=>({"community.composer.close":o(`community.composer.close`),"community.composer.destination_feed":o(`community.composer.destination_feed`),"community.composer.choose_destination":o(`community.composer.choose_destination`),"community.action_menu.move_post_read_only_hint":o(`community.action_menu.move_post_read_only_hint`),"community.composer.post_title_placeholder":o(`community.composer.post_title_placeholder`),"community.composer.submit":o(`community.composer.submit`),"community.composer.save":o(`community.composer.save`),"community.composer.submitting":o(`community.composer.submitting`),"community.composer.saving":o(`community.composer.saving`),"community.composer.format_text":o(`community.composer.format_text`),"community.composer.format_bold":o(`community.composer.format_bold`),"community.composer.format_italic":o(`community.composer.format_italic`),"community.composer.format_underline":o(`community.composer.format_underline`),"community.composer.format_strike":o(`community.composer.format_strike`),"community.composer.format_code":o(`community.composer.format_code`),"community.composer.add_media":o(`community.composer.add_media`),"community.composer.media_tab_gif":o(`community.composer.media_tab_gif`),"community.composer.media_tab_upload":o(`community.composer.media_tab_upload`),"community.composer.gif_search_placeholder":o(`community.composer.gif_search_placeholder`),"community.composer.gif_loading":o(`community.composer.gif_loading`),"community.composer.gif_error":o(`community.composer.gif_error`),"community.composer.gif_no_results":o(`community.composer.gif_no_results`),"community.composer.gif_powered_by":o(`community.composer.gif_powered_by`),"community.composer.upload_loading":o(`community.composer.upload_loading`),"community.composer.upload_choose_file":o(`community.composer.upload_choose_file`),"community.composer.upload_hint":o(`community.composer.upload_hint`),"community.composer.upload_error":o(`community.composer.upload_error`),"community.composer.add_link":o(`community.composer.add_link`),"community.composer.link_url_placeholder":o(`community.composer.link_url_placeholder`),"community.composer.link_save":o(`community.composer.link_save`),"community.composer.link_
6invalid":o(`community.composer.link_invalid`),"community.composer.link_remove":o(`community.composer.link_remove`),"community.composer.add_emoji":o(`community.composer.add_emoji`),"community.composer.emoji_search_placeholder":o(`community.composer.emoji_search_placeholder`),"community.composer.emoji_no_results":o(`community.composer.emoji_no_results`),"community.composer.attach_post":o(`community.composer.attach_post`),"community.composer.post_search_placeholder":o(`community.composer.post_search_placeholder`),"community.composer.post_loading":o(`community.composer.post_loading`),"community.composer.post_no_results":o(`community.composer.post_no_results`),"community.composer.post_max_reached":o(`community.composer.post_max_reached`),"community.composer.attached_post_remove":o(`community.composer.attached_post_remove`),"community.composer.link_preview_loading":o(`community.composer.link_preview_loading`),"community.composer.link_preview_remove":o(`community.composer.link_preview_remove`),"community.composer.embed_prompt_paste_as":o(`community.composer.embed_prompt_paste_as`),"community.composer.embed_prompt_preview":o(`community.composer.embed_prompt_preview`),"community.composer.embed_prompt_both":o(`community.composer.embed_prompt_both`),"community.composer.embed_prompt_keep_link":o(`community.composer.embed_prompt_keep_link`),"community.composer.add_video":o(`community.composer.add_video`),"community.composer.video.choose_file":o(`community.composer.video.choose_file`),"community.composer.video.hint":o(`community.composer.video.hint`),"community.composer.video.uploading":o(`community.composer.video.uploading`),"community.composer.video.processing":o(`community.composer.video.processing`),"community.composer.video.cancel":o(`community.composer.video.cancel`),"community.composer.video.retry":o(`community.composer.video.retry`),"community.composer.video.remove":o(`community.composer.video.remove`),"community.composer.video.play":o(`community.composer.video.play`),"community.composer.video.choose_thumbnail":o(`community.composer.video.choose_thumbnail`),"community.composer.video.thumbnail_dialog":o(`community.composer.video.thumbnail_dialog`),"community.composer.video.thumbnail_frame":o(`community.composer.video.thumbnail_frame`),"community.composer.video.upload_thumbnail":o(`community.composer.video.upload_thumbnail`),"community.composer.video.thumbnail_error":o(`community.composer.video.thumbnail_error`),"community.composer.video.error_unsupported":o(`community.composer.video.error_unsupported`),"community.composer.video.error_empty":o(`community.composer.video.error_empty`),"community.composer.video.error_too_large":o(`community.composer.video.error_too_large`),"community.composer.video.error_transfer":o(`community.composer.video.error_transfer`),"community.composer.video.error_completion":o(`community.composer.video.error_completion`),"community.composer.video.status_processing":o(`community.composer.video.status_processing`),"community.composer.video.status_ready":o(`community.composer.video.status_ready`),"community.composer.video.status_ready_to_publish":o(`community.composer.video.status_ready_to_publish`),"community.composer.video.status_failed":o(`community.composer.video.status_failed`),"community.composer.video.status_blocked":o(`community.composer.video.status_blocked`),"community.join.former_member":o(`community.join.former_member`),"community.mentions.list_label":o(`community.mentions.list_label`)}),[o]),Ee=!!a,De=x?.subscription?`${x.subscription.first_name} ${x.subscription.last_name}`.trim():``,Oe=w&&De?{name:De,avatarUrl:x?.subscription?.avatar_url}:void 0;if(!T)return null;let ke=I?{id:I.id,title:I.title??null,author:{name:I.author.name,avatar_url:I.author.avatar_url},space:I.space?{name:I.space.name,emoji:I.space.emoji,slug:I.space.slug}:null,created_at:I.created_at}:void 0,Ae=(0,X.jsx)(Vs,{ref:ee,initialContent:oe,placeholder:se,destinations:T.destinations,selectedDestination:E??T.destination,onDestinationChange:D,destinationMode:T.mode,author:Oe,title:A,onTitleChange:j,isEditMode:Ee,quotedPost:ke,onSubmit:fe,isSubmitting:ce,isSubmitDisabled:!A.trim()&&!I,onClose:t,onUploadImage:pe,isMediaUploadDisabled:!1,videoUploadAdapter:me?ge:void 0,subscribeToVideoStatus:we,onRetryVideoProcessing:_e,resolveVideoPlayback:Ce,loadVideoThumbnails:me?ye:void 0,selectVideoThumbnail:me?be:void 0,uploadVideoThumbnail:me?xe:void 0,onSearchGifs:g,onFetchLinkPreview:G,mentionSuggestions:he,attached:{posts:R},transformImageUrl:Un,...a?{}:{attachableLists:{posts:ae},onPostQueryChange:te,isLoadingPosts:re.isFetching,onAttachedChange:e=>z(e.posts??[])},error:M,notice:a?.is_pinned&&k?(0,X.jsx)(st,{}
6):null,translations:Te,autoFocusTitle:!c});return c?(0,X.jsx)(zn,{isOpen:e,onClose:t,disableInitialTransition:!0,panelClassName:`flex flex-col max-h-[90dvh] min-h-0`,children:Ae}):(0,X.jsx)(Hn,{isOpen:e,onClose:t,className:`flex flex-col w-full max-w-[600px] min-h-[520px] max-h-[80vh] rounded-[24px] bg-white border border-black/10 shadow-[0px_8px_40px_0px_rgba(0,0,0,0.15)]`,children:Ae})},Pl=({builtIn:e,needsAvatar:t,needsHeadline:n,needsLocation:r,firstName:i,totalSteps:a,disabled:o,isLastPage:s,locationSuggestion:c,avatarUrl:l,isDefaultAvatar:u,avatarError:d,onAvatarSelect:f,onLocationChange:p})=>{let{t:m}=v(),h=i.trim();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(cr,{title:h?m(`community.profile_setup.welcome_title`,{name:h}):m(`community.profile_setup.title`),subtitle:m(`community.profile_setup.subtitle`,{count:Number(t)+Number(n)+Number(r)}),currentStep:0,totalSteps:a}),t&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(Oe,{currentImageUrl:l,isDefaultAvatar:u,onFileSelect:f,disabled:o}),d&&(0,X.jsx)(`p`,{className:`text-center text-[13px] leading-4 text-red-600`,role:`alert`,children:d})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[n&&(0,X.jsx)(xr,{id:`required-setup-headline`,name:`headline`,label:e.headlineField.display??m(`community.onboard.headline_label`),placeholder:m(`community.onboard.headline_placeholder`),maxLength:100,value:e.headline,required:!0,error:e.errors.headline,disabled:o,autoFocus:!0,onChange:t=>e.setHeadline(t.target.value)}),r&&(0,X.jsx)(Ee,{id:`required-setup-location`,label:e.locationField.display??m(`community.onboard.location_label`),placeholder:m(`community.onboard.location_placeholder`),maxLength:100,value:e.location,required:!0,error:e.errors.location,disabled:o,suggestion:c,onChange:p})]}),(0,X.jsx)(Vn,{variant:`primary`,type:`submit`,size:`lg`,fullWidth:!0,disabled:o,children:lr(m,o,s)})]})},Fl=({fields:e,firstName:t,avatarUrl:n,hasAvatar:r,headline:i,location:a,locationSuggestion:o})=>{let{t:s}=v(),{revalidate:c}=u(),l=Rn(),d=(0,J.useMemo)(()=>ke(e),[e]),f=De(e,{headline:i,location:a}),[p,m]=(0,J.useState)(),[h,g]=(0,J.useState)(null),[_,y]=(0,J.useState)(),b=f.avatarField.required&&r===!1,x=f.headlineField.required&&!i.trim(),S=f.locationField.required&&!a.trim(),C=b||x||S,[w,T]=(0,J.useState)(!1),E=C&&!w,{mutate:D,isPending:O}=sr(),[A,j]=(0,J.useState)(null),M=Math.max(d.findIndex(e=>e.some(e=>e.id===A)),0),N=d[M],P=d.length>0&&M===d.length-1,F=d.length+ +!!C,{answers:ee,fieldErrors:I,handleAnswerChange:L,validateAnswers:R,submitAnswers:z,isPending:te}=Te({fields:e,currentPage:N??[],pageBlock:G.CommunityRequiredProfileSetup}),ne=t.trim();mr({pageBlock:G.CommunityRequiredProfileSetup},{enabled:d.length>0||C});let re=e=>{g(e),y(void 0)},B=e=>{f.setLocation(e.location),m(e.geolocation)},ie=()=>{if(!f.validate())return;if(b&&!h){y(s(`community.onboard.required`));return}let e=()=>{if(d.length===0){c();return}T(!0)};D({...f.requestValues(p),avatar:h},{onSuccess:e,onError:e=>k.error(e instanceof Error?e.message:s(`community.onboard.toast.error`))})},ae=e=>{if(e.preventDefault(),E){ie();return}!N||!R(N)||z(N,()=>{if(!P){j(d[M+1]?.[0]?.id??null);return}c()})};if(!E&&(d.length===0||!N))return null;let oe=(0,X.jsx)(`form`,{className:`flex w-full flex-col gap-6`,onSubmit:ae,noValidate:!0,children:E?(0,X.jsx)(Pl,{builtIn:f,needsAvatar:b,avatarUrl:n,isDefaultAvatar:r===!1,avatarError:_,onAvatarSelect:re,needsHeadline:x,needsLocation:S,firstName:t,totalSteps:F,disabled:O,isLastPage:d.length===0,locationSuggestion:o,onLocationChange:B}):(0,X.jsx)(ur,{fields:N,answers:ee,errors:I,firstName:t,currentStep:M+ +!!C,totalSteps:F,disabled:te,isLastPage:P,canGoBack:M>0,title:ne?s(`community.profile_setup.welcome_title`,{name:ne}):s(`community.profile_setup.title`),subtitle:s(`community.profile_setup.subtitle`,{count:N?.length??0}),onChange:L,onBack:()=>j(d[M-1]?.[0]?.id??null)})});return l?(0,X.jsx)(zn,{isOpen:!0,onClose:()=>void 0,disableInitialTransition:!0,panelClassName:`flex max-h-[90vh] flex-col overflow-y-auto rounded-t-[24px] bg-white px-6 py-8 shadow-xl`,children:oe}):(0,X.jsx)(Hn,{isOpen:!0,onClose:()=>void 0,disableInitialTransition:!0,className:`relative flex max-h-[calc(100dvh-2rem)] w-full max-w-[480px] flex-col overflow-y-auto rounded-[24px] bg-white px-6 py-6 shadow-xl`,children:oe})},Il=()=>{let{t:e}=v();return(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`flex w-full items-center justify-center gap-3 bg-black px-6 py-3 text-center`,children:(0,X.jsx)(`p`,{className:`text-[15px] font-medium leading-5 tracking-[-0.15px] text-white`,children:e(`community.restriction_banner.banned`)})})},Ll=()=>!!f(`routes/community`)?.community?.navigation_v2_enabled,Rl=()=>{let{pathname:e}=s(),{handleOpenModal:t}=H(),{isMember:n,openJoinModal:r}=U();return()=>{if(!n){r(G.CommunitySidebarSearch);return}e!==L.search&&t(`search`)}},zl=()=>{let e=or();return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Wn,{src:Gn(),alt:e,className:`size-10`,fallbackClassName:`bg-gray-300`}),(0,X.jsx)(`span`,{className:`text-[15px] font-semibold leading-5 tracking-[-0.15px] truncate`,children:e})]})},Bl=(0,J.memo)(({icon:e,label:t,tooltip:n,isActive:r=!1,isUnread:i=!1,trailingNode:a,badgeCount:o,to:s,onClick:c,role:l})=>{let{t:u}=v(),d=i&&!r,f=(0,Y.default)(`flex items-center gap-2 h-10 px-3 py-2 rounded-full w-full text-left transition-colors`,{"bg-community-text-on-bg/[0.08] text-community-text-on-bg":r,"hover:bg-community-text-on-bg/[0.08]":!r,"text-community-text-on-bg":d,"text-community-text-on-bg/80":!r&&!d}),p=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center [&>svg]:size-full`,children:e}),(0,X.jsx)(`span`,{className:(0,Y.default)(`flex-1 text-[15px] leading-5 tracking-[-0.13px] md:text-[13px] md:leading-4`,{"font-semibold":d,"font-medium":!d}),children:t}),d&&(0,X.jsx)(`span`,{className:`sr-only`,children:u(`community.space.unread`)}),typeof o==`number`&&o>0?(0,X.jsx)(`span`,{className:`flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-community-accent px-1 text-[10px] font-semibold leading-none text-community-text-on-primary`,children:o>99?`99+`:o}):null,a]}),h=s?(0,X.jsx)(m,{to:s,className:f,onClick:c,role:l,"aria-current":r?`page`:void 0,children:p}):(0,X.jsx)(`button`,{type:`button`,className:f,onClick:c,role:l,children:p});return n?(0,X.jsx)(Jn,{content:(0,X.jsx)(`span`,{className:`block max-w-[240px]`,children:n}),placement:`right`,children:h}):h}),Vl=({onClick:e})=>{let{t}=v();return(0,X.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 h-10 px-2.5 py-2 rounded-full border border-community-text-on-bg/25 w-full cursor-pointer text-left transition-colors hover:bg-community-text-on-bg/10`,"aria-label":t(`community.sidebar.search_placeholder`),onClick:e,children:[(0,X.jsx)(Dt,{className:`size-5 shrink-0 text-community-text-on-bg/50`}),(0,X.jsx)(`span`,{className:`text-[15px] font-medium tracking-[-0.13px] text-community-text-on-bg/50 md:text-[13px]`,children:t(`community.sidebar.search_placeholder`)})]})},Hl=(e,t)=>
6[e,t].filter(Boolean).join(` `).trim()||`Guest`,Ul=e=>{let{t}=v(),n=f(`root`),{currentMember:r}=U(),i=!!n?.isLoggedIn,a=n?.subscription,o=(0,J.useMemo)(()=>r?.subscription?{firstName:r.subscription.first_name,lastName:r.subscription.last_name,avatarUrl:r.subscription.avatar_url}:{firstName:a?.first_name??null,lastName:a?.last_name??null,avatarUrl:a?.avatar_url??null},[r?.subscription,a?.avatar_url,a?.first_name,a?.last_name]),s=(0,J.useMemo)(()=>{let n={key:`logout`,label:t(`shared.cta.logout`),onClick:()=>C(`token`)};return r?[{key:`view_profile`,label:t(`community.profile.view_profile`),to:L.member(r.id),onClick:e},{key:`settings`,label:t(`community.settings.title`),to:L.memberSettings,onClick:e},{type:`divider`,key:`settings_logout_divider`},n]:[n]},[r,e,t]);return{isLoggedIn:i,displayName:Hl(o.firstName,o.lastName),avatarUrl:o.avatarUrl??null,menuItems:s}},Wl=({onNavigate:e})=>{let{t}=v(),{openSignInModal:n}=U(),{isLoggedIn:r,displayName:i,avatarUrl:a,menuItems:o}=Ul(e);if(!r)return(0,X.jsx)(`div`,{className:`flex h-12 items-center rounded-full w-full`,children:(0,X.jsx)(Vn,{variant:`primary`,onClick:()=>n(),className:`inline-flex w-full px-6 py-2 transition-opacity hover:opacity-90`,children:t(`shared.cta.sign_in`)})});let s=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Wn,{src:a,alt:i,className:`size-6 shrink-0`,fallbackClassName:`bg-gray-300`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left text-[15px] font-medium leading-5 tracking-[-0.13px] md:text-[13px] md:leading-4`,children:i})]});return(0,X.jsx)(`div`,{className:`relative`,children:(0,X.jsx)(Ct,{className:`w-full`,triggerLabel:t(`community.join.member_menu`),triggerClassName:(0,Y.default)(`flex items-center gap-2.5 h-10 p-2 rounded-full bg-community-text-on-bg/[0.08] text-community-text-on-bg w-full`,`text-left transition-opacity hover:opacity-90`),trigger:(0,X.jsxs)(X.Fragment,{children:[s,(0,X.jsx)(St,{className:`size-4 shrink-0 text-community-text-on-bg opacity-70`})]}),placement:`top-end`,items:o})})},Gl=e=>{try{return new URL(e).pathname}catch{return e.startsWith(`/`)?e:null}},Kl=({unlocked:e=!1})=>{let{t}=v();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-community-text-on-bg/10`,children:(0,X.jsx)(e?Or:V,{className:`size-3 text-community-text-on-bg/50`,"aria-hidden":`true`})}),!e&&(0,X.jsx)(`span`,{className:`sr-only`,children:t(`community.space.locked`)})]})},ql=(e,t)=>e?(0,X.jsx)(Kl,{}):t?(0,X.jsx)(Kl,{unlocked:!0}):null,Jl=({spaces:e,onNavClick:t,variant:n=`desktop`,notificationUnreadCount:r})=>{let{pathname:i}=s(),{t:a}=v(),{canAccessSpace:o,isSpaceHidden:c}=fr(),{isCommunityAccessible:l}=ue(),{isMember:u,openJoinModal:d}=U(),p=Sr(),m=Rl(),h=Ll(),g=f(`routes/community`),_=!!f(`root`)?.isLoggedIn,y=!!g?.isMessagesEnabled,b=!!g?.community?.directory_enabled,x=g?.eventsEmbedUrl??null,S=g?.unreadSpaceIds??[],C=n===`mobile`,{messages:{unreadCount:w}}=On();return(0,X.jsxs)(`aside`,{className:(0,Y.default)(`flex flex-col justify-between text-community-text-on-bg`,{[`${M} shrink-0 p-3 h-full`]:!C,"w-full p-4 h-full":C}),children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto min-h-0`,style:{scrollbarWidth:`none`},children:[!C&&!h&&(0,X.jsx)(zl,{}),!h&&(0,X.jsx)(Vl,{onClick:()=>{t?.(),m()}}),(0,X.jsxs)(`nav`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(Bl,{icon:(0,X.jsx)(Rr,{}),label:a(`community.sidebar.community_feed`),to:L.root,isActive:i===L.root,onClick:t}),b&&(0,X.jsx)(Bl,{icon:(0,X.jsx)(Nt,{}),label:p,to:L.directory,isActive:j(i),onClick:t}),y&&!h&&(0,X.jsx)(Bl,{icon:(0,X.jsx)(Pr,{}),label:a(`community.sidebar.messages`),to:L.messages,isActive:te(i),onClick:t,badgeCount:w,trailingNode:ql(!l,!1)}),x&&(0,X.jsx)(Bl,{icon:(0,X.jsx)(We,{}),label:a(`community.sidebar.events`),to:L.events,isActive:i===L.events,onClick:t}),_&&!h&&(0,X.jsx)(Bl,{icon:(0,X.jsx)(Re,{}),label:a(`community.sidebar.notifications`),to:L.notifications,isActive:i===L.notifications,badgeCount:r??void 0,onClick:t})]}),e!=null&&e.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-[13px] md:text-[11px] text-community-text-on-bg/50 px-2 py-1`,children:a(`community.sidebar.spaces`)}),e.map(e=>{let n=Gl(e.web_url);if(!n||c(e))return null;let r=ql(!l||!o(e),e.tier_gated);return(0,X.jsx)(Bl,{icon:(0,X.jsx)(Fe,{slug:e.slug,emoji:e.emoji}),label:e.name,tooltip:C?void 0:e.description??void 0,to:u?n:void 0,isActive:i.startsWith(n),isUnread:S.includes(e.id),trailingNode:r,onClick:u?t:()=>{t?.(),d(G.CommunitySidebarChannel)}},e.id)})]})]}),(C||!h)&&(0,X.jsx)(Wl,{onNavigate:t})]})},Yl=({onClose:e})=>{let{t}=v();return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 p-4`,children:[(0,X.jsx)(wc,{}),(0,X.jsx)(Xn,{"aria-label":t(`shared.close`),className:`shrink-0`,onClick:e,children:(0,X.jsx)(Pt,{className:`size-5`,strokeWidth:1.6})})]})},Xl=({variant:e=`desktop`})=>{let t=e===`mobile`,n=Ll();return(0,X.jsxs)(`aside`,{className:(0,Y.default)(`flex flex-col justify-between animate-pulse`,{[`${M} shrink-0 p-3 h-full`]:!t,"w-full p-4 h-full":t}
6),"aria-hidden":!0,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[!t&&!n&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1`,children:[(0,X.jsx)(hr,{className:`size-8 !rounded-full shrink-0`}),(0,X.jsx)(hr,{className:`h-4 w-24`})]}),!n&&(0,X.jsx)(hr,{className:`h-8 w-full !rounded-full`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1`,children:Array.from({length:3},(e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,X.jsx)(hr,{className:`size-5 !rounded`}),(0,X.jsx)(hr,{className:`h-4 w-20`})]},t))}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(hr,{className:`h-3 w-14 mx-2 my-1`}),Array.from({length:2},(e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,X.jsx)(hr,{className:`size-5 !rounded`}),(0,X.jsx)(hr,{className:`h-4 w-16`})]},t))]})]}),(t||!n)&&(0,X.jsx)(hr,{className:`h-10 w-full !rounded-full`})]})},Zl=`inline-flex size-10 items-center justify-center rounded-full transition-colors hover:bg-community-text-on-bg/10 md:size-9`,Ql=1.2,$l=({to:e,label:t,icon:n,badgeCount:r,isActive:i=!1})=>(0,X.jsxs)(m,{to:e,className:(0,Y.default)(`relative`,Zl,{"text-community-text-on-bg":i,"text-community-text-on-bg/80":!i}),"aria-current":i?`page`:void 0,children:[n,(0,X.jsx)(`span`,{className:`sr-only`,children:t}),typeof r==`number`&&r>0?(0,X.jsx)(`span`,{className:`absolute left-[22px] top-0.5 flex md:left-5 md:top-0 h-4 min-w-4 items-center justify-center rounded-full bg-community-accent px-1 text-[10px] font-semibold leading-none text-community-text-on-primary`,children:r>99?`99+`:r}):null]}),eu=({notificationUnreadCount:e})=>{let{t}=v(),{pathname:n}=s(),{isMember:r,isMessagesEnabled:i}=U(),{messages:{unreadCount:a}}=On();return(0,X.jsxs)(X.Fragment,{children:[i&&(0,X.jsx)($l,{to:L.messages,label:t(`community.sidebar.messages`),icon:(0,X.jsx)(Pr,{className:`size-5`,strokeWidth:1.2}),badgeCount:a,isActive:te(n)}),r&&(0,X.jsx)($l,{to:L.notifications,label:t(`community.sidebar.notifications`),icon:(0,X.jsx)(Re,{className:`size-5`,strokeWidth:1.2}),badgeCount:e,isActive:n===L.notifications})]})},tu=({onClick:e})=>{let{t}=v();return(0,X.jsxs)(`button`,{type:`button`,className:`flex h-10 w-full cursor-pointer items-center gap-2 rounded-full border border-community-text-on-bg/25 px-2.5 py-2 text-left transition-colors hover:bg-community-text-on-bg/10`,"aria-label":t(`community.sidebar.search_placeholder`),onClick:e,children:[(0,X.jsx)(Dt,{className:`size-5 shrink-0 text-community-text-on-bg/80`,strokeWidth:Ql}),(0,X.jsx)(`span`,{className:`text-[13px] font-medium tracking-[-0.13px] text-community-text-on-bg/50`,children:t(`community.sidebar.search_placeholder`)})]})},nu=()=>{let{t:e}=v(),{openSignInModal:t}=U(),{isLoggedIn:n,displayName:r,avatarUrl:i,menuItems:a}=Ul();return n?(0,X.jsx)(Ct,{triggerLabel:e(`community.join.member_menu`),triggerClassName:`flex rounded-full transition-opacity hover:opacity-90`,trigger:(0,X.jsx)(Wn,{src:i,alt:r,className:`size-10`,fallbackClassName:`bg-gray-300`}),placement:`bottom-end`,items:a}):(0,X.jsx)(Vn,{variant:`primary`,onClick:()=>t(),className:`shrink-0 px-4 transition-opacity hover:opacity-90`,children:e(`shared.cta.sign_in`)})},ru=({notificationUnreadCount:e,isFetchingSubscription:t=!1})=>{let n=Rl();return(0,X.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 bg-community-bg px-3 pt-3 text-community-text-on-bg`,children:[(0,X.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,X.jsx)(wc,{})}),(0,X.jsx)(`div`,{className:`w-96 min-w-0`,children:(0,X.jsx)(tu,{onClick:n})}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,X.jsx)(`div`,{className:`flex items-center`,children:(0,X.jsx)(eu,{notificationUnreadCount:e})}),t?(0,X.jsx)(hr,{className:`size-10 animate-pulse !rounded-full`}):(0,X.jsx)(nu,{})]})]})},iu=({notificationUnreadCount:e})=>{let{t}=v(),n=Rl();return(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":t(`community.sidebar.search_placeholder`),className:`${Zl} text-community-text-on-bg/80`,onClick:n,children:(0,X.jsx)(Dt,{className:`size-5`,strokeWidth:Ql})}),(0,X.jsx)(eu,{notificationUnreadCount:e})]})},au=({enabled:e,topBar:t,children:n})=>e?(0,X.jsxs)(X.Fragment,{children:[t&&(0,X.jsx)(`div`,{className:`hidden md:block`,children:t}),(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:n})]}):n,ou=15e3;function su(e,t){(0,J.useEffect)(()=>
6{if(!e)return;let n=()=>{document.visibilityState===`visible`&&t(`heartbeat`)},r=setInterval(n,ou);return document.addEventListener(`visibilitychange`,n),()=>{document.removeEventListener(`visibilitychange`,n),clearInterval(r)}},[e,t])}function cu({isMember:e,eventHandlers:t,onRejected:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(t);i.current=t;let a=(0,J.useRef)(n);a.current=n,(0,J.useEffect)(()=>{if(!e)return;let t=pl();if(t)return r.current=t.subscriptions.create(`OrchidCable::CommunityChannel`,{received(e){let t=e;i.current[t.type]?.(t)},rejected(){a.current?.()}}),()=>{r.current?.unsubscribe(),r.current=null,t.disconnect()}},[e]);let o=(0,J.useCallback)((e,t)=>{r.current?.perform(e,t)},[]);return su(e,o),{perform:o}}var lu=({children:e,isMember:t})=>{let[n,r]=(0,J.useState)({unreadCount:void 0,unreadOverridesByChannelId:{}}),{revalidate:i}=u(),a=ie(),{perform:o}=cu({isMember:t,eventHandlers:{"chat:unread_count":e=>{r(t=>{let n={...t};return typeof e.totalUnreadChatCount==`number`&&(n.unreadCount=e.totalUnreadChatCount),typeof e.getstreamChannelId==`string`&&typeof e.unreadMessagesCount==`number`&&(n.unreadOverridesByChannelId={...t.unreadOverridesByChannelId,[e.getstreamChannelId]:e.unreadMessagesCount}),n})},"member:status_changed":()=>{i()},"member:block_changed":()=>{r(e=>({...e,unreadOverridesByChannelId:{}})),i(),de(a),a.invalidateQueries({queryKey:[`communityChatToken`]})}},onRejected:()=>{i()}}),s=(0,J.useCallback)((e,t)=>{o(`mark_read`,{getstream_channel_id:e,last_message_at:t})},[o]);return(0,X.jsx)(At.Provider,{value:{messages:n,markChatRead:s},children:e})},uu=()=>{let e=f(`routes/community`),{currentModal:t}=H(),[n]=i(),{isMember:r}=U(),{isCommunityAccessible:a}=ue(),{canAccessSpace:o}=fr(),s=n.get(`space_id`),c=(0,J.useMemo)(()=>s?e?.spaces?.find(e=>e.id===s)??null:null,[s,e?.spaces]);return{isOpen:t===`community_channel_upgrade`&&r&&a&&c!=null&&!o(c),space:c}},du=(e,t,n)=>{let r=ne(),i=t&&n?_e(t,n):void 0,{mutateAsync:a}=fe({mutationFn:async e=>{if(!i)return;let t=await Se(`/community_app_observations`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-CSRF-Token":await r()},body:JSON.stringify({...e,previous_hash:be(i),nectar_anonymous_user_id:re(),nectar_is_pwa:xe(),nectar_page_block:e.install_signal?G.CommunityAppInstallObservation:G.CommunityAppBackgroundObservation})});if(!t.ok)throw Error(`Observation failed`);let n=await t.json();n.tracking_enabled&&`push`in e&&(n.data_hash===null||typeof n.data_hash==`string`)&&Ce(i,typeof n.data_hash==`string`?n.data_hash:null)}});(0,J.useEffect)(()=>{if(!i)return;let t=!1;return r().then(n=>{t||ge({storageKey:i,csrfToken:n,trackingEnabled:e,pageBlock:G.CommunityAppPushPrompt})}),()=>{t=!0,ge(void 0)}},[i,r,e]),(0,J.useEffect)(()=>{if(!e||!i)return;let t=!1,n=!1,r=!1,o=!1,s,c=async()=>{if(!t){if(n){r=!0;return}n=!0;try{await we(async()=>{if(t)return;let e={},n=`serviceWorker`in navigator?await ve().catch(()=>null):null;if(ye()&&(o?e.install_signal=`appinstalled`:n&&xe()&&(e.install_signal=`standalone`)),n?.pushManager&&`Notification`in window)try{let t=await n.pushManager.getSubscription();e.push=Notification.permission===`granted`?t?.toJSON()??null:null}catch{}if(!t&&Object.keys(e).length){let t=JSON.stringify(e);t!==s&&(await a(e),s=t),e.install_signal===`appinstalled`&&(o=!1)}})}catch{}finally{n=!1,r&&!t&&(r=!1,c())}}},l=()=>{ye()&&(o=!0),c()},u=()=>{document.visibilityState===`visible`&&c()};return c(),window.addEventListener(`appinstalled`,l),document.addEventListener(`visibilitychange`,u),navigator.serviceWorker?.addEventListener(`controllerchange`,u),navigator.serviceWorker?.ready.then(()=>{t||c()}).catch(()=>void 0),()=>{t=!0,window.removeEventListener(`appinstalled`,l),document.removeEventListener(`visibilitychange`,u),navigator.serviceWorker?.removeEventListener(`controllerchange`,u)}},[e,i,a])},fu=e=>{let t=d(),{t:n}=v(),r=Sr(),i=t[t.length-1];return(0,J.useMemo)(()=>{switch(i?.id){case F.messages:return{title:n(`community.sidebar.messages`),readOnly:!1,showChannelDropdown:!1,plusAction:`none`,showTopbar:!0,showPageHeader:!1};case F.events:return{title:n(`community.sidebar.events`),readOnly:!1,showChannelDropdown:!1,plusAction:`none`,showTopbar:!0,showPageHeader:!0};case F.directory:return{title:r,readOnly:!1,showChannelDropdown:!1,plusAction:`none`,showTopbar:!0,showPageHeader:!1};case F.notifications:return{title:n(`community.sidebar.notifications`),readOnly:!1,showChannelDropdown:!1,plusAction:`none`,showTopbar:!1,showPageHeader:!1};case F.onboard:return{title:n(`community.onboard.title`),readOnly:!1,showChannelDropdown:!1,plusAction:`none`,showTopbar:!0,showPageHeader:!1};case F.space:{let t=i.params.slug,n=e.find(e=>e.slug===t);return{title:n?.name??t??``,readOnly:n?.read_only??!1,showChannelDropdown:!0,plusAction:`join`,showTopbar:!0,showPageHeader:!0}}case F.feed:return{title:``,readOnly:!1,showChannelDropdown:!1,plusAction:`create`,showTopbar:!0,showPageHeader:!1};default:return{title:``,readOnly:!1,showChannelDropdown:!1,plusAction:`none`,showTopbar:!0,showPageHeader:!1}}},[r,i?.id,i?.params,e,n])},pu=()=>{let{fetcher:e}=Cr();Fn(e.data?.toast)},mu=e=>{let{pathname:t,search:n}=e;return t===L.root||t.startsWith(`${L.root}/channels/`)?`community-feed-scroll:${t}`:t.startsWith(`${L.root}/members/`)?`community-profile-scroll:${t}:${Mt(new URLSearchParams(n).get(`tab`))}`:null},hu=({member:e,accessible:t})=>!!(t&&e?.onboarding_completed&&e.profile_setup_required),gu=[`icon`,`apple-touch-icon`,`apple-touch-startup-image`],_u=e=>`tagName`in e&&e.tagName===`link`&&`rel`in e?gu.includes(String(e.rel)):!1,vu=({data:e,matches:t})=>{let n=t.flatMap(e=>e.meta??[]),{name:r,logo_url:i}=e?.community??{};return n.map(e=>r&&`title`in e&&!(`tagName`in e)?{title:r}:i&&_u(e)?{...e,href:i}:e)},yu=e=>e.formAction===`/community_space_membership`||e.currentUrl.pathname===L.onboard&&e.nextUrl.pathname!==L.onboard||P(e.currentUrl.pathname)&&e.currentUrl.pathname!==e.nextUrl.pathname?!0:wr(e)?e.defaultShouldRevalidate||e.currentUrl.pathname!==e.nextUrl.pathname:!1,bu=`community-drawer-title`,xu=()=>{let{t:e}=v(),t=o(),[n,r]=(0,J.useState)(!1),[a,c]=(0,J.useState)(!1),[d,m]=(0,J.useState)(),[h,_]=(0,J.useState)(),[y,b]=(0,J.useState)(),[x,C]=(0,J.useState)(0),{spaces:w,community:E,currentMember:k,notificationUnreadCount:A,isMessagesEnabled:M,invite:P,setupProfileFields:F}=g();$n(E?.id,E?{content_type:`community`}:null),du(!!E?.app_adoption_tracking_enabled,E?.publication_id,k?.id);let[I]=i(),{currentModal:R,handleCloseModal:ne,handleOpenModal:re}=H(),B=f(`root`),ie=B?.publication,ae=!!B?.isLoggedIn,oe=B?.isFetchingSubscription??!1,se=!!k,V=!!E?.navigation_v2_enabled,{isCommunityAccessible:ce}=ue(),le=hu({member:k,accessible:ce}),de=_r(),W=qc(),fe=uu(),pe=yc(),me=R===`community_login`,{pathname:ge}=s(),_e=I.get(`redirect_to`),ve=S(_e)?_e:ge,ye=fu(w??[]),be=Yn(E),{permissions:xe,openJoinModal:Se,openSignInModal:Ce}=U(),{canPostAnywhere:we}=fr(),G=!se,Te=Qs({keyFor:mu}),Ee=l(),De=Ee.location?.pathname,Oe=Ee.state===`loading`&&De!=null&&De!==ge&&ee(De),ke=ge.replace(/\/$/,``)===L.events,Me=ge===L.onboard,{revalidate:Ne}=u(),Pe=!!E?.pwa_enabled,Fe=or(),Ie=Gn(),ze=Pe&&ae&&se,Be=(0,J.useMemo)(()=>E&&Ie?{name:E.name,logoUrl:Ie,subtitle:ie?.name}:void 0,[E,Ie,ie?.name]);he({icon:Pe?Ie:void 0}),(0,J.useEffect)(()=>{w??O.error(e(`community.sidebar.spaces_load_error`),{id:`community-spaces-load-error`})},[w,e]),(0,J.useEffect)(()=>
6{if(!se)return;let e=()=>{document.visibilityState===`visible`&&Ne()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[se,Ne]);let Ve=(0,J.useCallback)(()=>{r(!1)},[]);pu(),Le();let Ue=()=>{Ve()},We=(0,J.useCallback)(e=>{let{defaultSpaceSlug:t,quotedPost:n,editPost:r}=e??{};if(!se){Se();return}xe.canCreatePost&&(m(t),b(r),_(r?void 0:n),C(e=>e+1),c(!0))},[Se,se,xe.canCreatePost]),Ke=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Wn,{src:Ie,alt:Fe,className:`size-8 shrink-0`,fallbackClassName:`bg-gray-300`}),(0,X.jsx)(`span`,{className:`text-[15px] font-semibold leading-5 tracking-[-0.15px] truncate`,children:Fe})]});return(0,X.jsx)(lu,{isMember:se,children:(0,X.jsx)(Jc,{openComposer:We,children:(0,X.jsx)(He,{children:(0,X.jsxs)(`div`,{className:(0,Y.default)(`fixed inset-0 flex bg-community-bg`,{"flex-col":V}),children:[(0,X.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`${be}\n${N(V)}`}}),(0,X.jsxs)(au,{enabled:V,topBar:!Me&&(0,X.jsx)(ru,{notificationUnreadCount:A,isFetchingSubscription:oe}),children:[!Me&&(0,X.jsx)(`div`,{className:`hidden h-full shrink-0 overflow-y-auto md:block`,children:oe?(0,X.jsx)(Xl,{}):(0,X.jsx)(Jl,{spaces:w,notificationUnreadCount:A})}),(0,X.jsx)(je,{show:n&&!Me,as:J.Fragment,children:(0,X.jsxs)(Ae,{as:`div`,className:`relative z-50 md:hidden`,onClose:Ve,"aria-labelledby":bu,children:[(0,X.jsx)(je.Child,{as:J.Fragment,enter:`ease-out duration-100`,enterFrom:`opacity-0`,enterTo:`opacity-100`,leave:`ease-in duration-100`,leaveFrom:`opacity-100`,leaveTo:`opacity-0`,children:(0,X.jsx)(`div`,{className:`fixed inset-0 bg-black/60`})}),(0,X.jsx)(je.Child,{as:J.Fragment,enter:`ease-out duration-100`,enterFrom:`-translate-x-full`,enterTo:`translate-x-0`,leave:`ease-in duration-100`,leaveFrom:`translate-x-0`,leaveTo:`-translate-x-full`,children:(0,X.jsxs)(Ae.Panel,{className:`fixed inset-0 flex flex-col bg-community-bg text-community-text-on-bg`,children:[(0,X.jsx)(Ae.Title,{id:bu,className:`sr-only`,children:`Community navigation`}),V?(0,X.jsx)(Yl,{onClose:Ve}):(0,X.jsxs)(`div`,{className:`flex items-center justify-between p-4`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-3 min-w-0`,children:Ke}),(0,X.jsx)(Xn,{"aria-label":`Close navigation`,onClick:Ve,children:(0,X.jsx)(Pt,{className:`size-4`})})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:oe?(0,X.jsx)(Xl,{variant:`mobile`}):(0,X.jsx)(Jl,{spaces:w,onNavClick:Ue,variant:`mobile`,notificationUnreadCount:A})})]})})]})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden md:p-3`,children:[ye.showTopbar&&(0,X.jsxs)(`div`,{className:`md:hidden flex items-center justify-between pl-2 pr-4 py-3 text-community-text-on-bg`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[!Me&&(0,X.jsx)(Xn,{"aria-label":`Open navigation`,"aria-expanded":n,className:`size-8 shrink-0`,onClick:()=>r(!0),children:(0,X.jsx)(Mr,{className:`size-4`})}),V?(0,X.jsx)(wc,{}):(0,X.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,X.jsx)(Wn,{src:Ie,alt:Fe,className:`size-10`,fallbackClassName:`bg-gray-300`}),(0,X.jsx)(`span`,{className:`text-[15px] font-semibold leading-5 tracking-[-0.15px] truncate`,children:Fe})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[V&&!Me&&(0,X.jsx)(iu,{notificationUnreadCount:A}),!V&&ae&&!Me&&(0,X.jsxs)(X.Fragment,{children:[M&&(0,X.jsx)(ar,{to:L.messages,"aria-label":`Messages`,children:(0,X.jsx)(rt,{className:`size-4`})}),(0,X.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,X.jsx)(ar,{to:L.notifications,"aria-label":`Notifications`,children:(0,X.jsx)(Re,{className:`size-4`})}),typeof A==`number`&&A>0?(0,X.jsx)(`span`,{className:`pointer-events-none absolute -right-0.5 -top-0.5 size-2 rounded-full bg-community-accent ring-2 ring-community-bg`,"aria-hidden":!0}):null]})]}),!ae&&(0,X.jsx)(Vn,{variant:`primary`,onClick:()=>Ce(),className:`inline-flex shrink-0 px-4 transition-opacity hover:opacity-90`,"aria-label":e(`shared.cta.sign_in`),children:e(`shared.cta.sign_in`)})]})]}),(0,X.jsxs)(`main`,{ref:Te,className:(0,Y.default)(`flex-1 bg-white md:rounded-3xl shadow-[0px_2px_20px_0px_rgba(0,0,0,0.08)]`,{"overflow-hidden":G,"overflow-y-auto":!G,"rounded-t-[32px]":ye.showTopbar,"flex min-h-0 flex-col":te(ge)||ke||j(ge)}),children:[ye.showPageHeader&&(0,X.jsxs)(`div`,{className:`md:hidden flex items-center justify-between px-4 py-2 h-16 sticky top-0 bg-white z-10 rounded-t-[32px]`,children:[(0,X.jsx)(`div`,{className:`w-20`}),ye.showChannelDropdown&&z?(0,X.jsx)(xt,{label:ye.title}):(0,X.jsx)(`h1`,{className:`min-w-0 truncate text-xl font-semibold leading-6 tracking-[-0.4px]`,children:ye.title}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end w-20`,children:[ye.readOnly&&(0,X.jsx)(yt,{}),ye.plusAction===`create`&&we&&(0,X.jsx)(ir,{"aria-label":e(`community.composer.create_post`),onClick:()=>We(),children:(0,X.jsx)(jt,{className:`size-4`})})]})]}),xe.isRestricted&&(0,X.jsx)(Il,{}),Oe?(0,X.jsx)(bc,{}):(0,X.jsx)(p,{context:t}),(0,X.jsx)(Nl,{isOpen:a,onClose:()=>
6c(!1),spaces:w??[],defaultSpaceSlug:d,quotedPost:h,editPost:y},x),!te(ge)&&!ke&&!j(ge)&&(0,X.jsx)(Us,{utmMedium:`community_footer`,variant:`pill`})]})]})]}),(0,X.jsx)(Bc,{}),P&&(0,X.jsx)(Dc,{invite:P,publicationName:ie?.name??`Community`}),R===`community_join`&&de!==`joinable`&&!oe&&(0,X.jsx)(Kc,{handoff:W}),fe.isOpen&&fe.space&&(0,X.jsx)(_c,{space:fe.space,handoff:pe}),le?(0,X.jsx)(Fl,{fields:F,firstName:k?.subscription.first_name??``,avatarUrl:k?.subscription.avatar_url??void 0,hasAvatar:k?.subscription.has_avatar,headline:k?.headline??``,location:k?.location??``,locationSuggestion:k?.location_suggestion}):null,(0,X.jsx)(Ge,{mode:`join`,isOpen:R===`community_join`&&de===`joinable`,onClose:()=>ne({preventScrollReset:!0}),onSwitchMode:()=>re(`community_login`,{preventScrollReset:!0}),isLoggedIn:ae,publicationName:ie?.name??`Community`,community:E,publicationId:ie?.id,redirectTo:ve}),(0,X.jsx)(Ge,{mode:`login`,isOpen:me,onClose:()=>ne({preventScrollReset:!0}),onSwitchMode:()=>re(`community_join`,{preventScrollReset:!0}),isLoggedIn:ae,publicationName:ie?.name??`Community`,community:E,publicationId:ie?.id,redirectTo:ve}),ze&&Be?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Xs,{canShowOnPath:T,storageKey:D.communityInstall,branding:Be,variant:`community`}),(0,X.jsx)(Ws,{storageKey:D.communityPush,branding:Be,variant:`community`})]}):null]})})})})};export{xu as default,vu as meta,yu as shouldRevalidate};
7//# sourceMappingURL=community-A8l0rs8J.js.map
8//# debugId=e887356f-3787-59f7-8828-5232a6e07c4f

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.