const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/esm-B23bzHOe.js","assets/rolldown-runtime-hePW80VL.js","assets/lucide-icons-6JcOMNkr.js","assets/web-Vqru6ABN.js","assets/dist-C2I8JNdt.js","assets/web-BB2R3iQI.js","assets/esm-JCo1H0uQ.js","assets/preload-helper-Czpn1I53.js","assets/CampaignsPage-ifEOpgvd.js","assets/jsx-runtime-NZYk81nU.js","assets/CampaignCard-i2mQdn0N.js","assets/useAuthor-K0SVHIbr.js","assets/esm-0y5H0J9W.js","assets/TranslateButton-DiWnIeAQ.js","assets/useAppContext-DVsgK-HT.js","assets/utils-CFLjoQCu.js","assets/useTranslation-DClBQ1v-.js","assets/button-DwJ7jtrK.js","assets/dist--t6UMBpz.js","assets/dist-U-Iv1vyA.js","assets/dist-6F83Gh1K.js","assets/useCurrentUser-CgUH2vq7.js","assets/useToast-BZaXaeWY.js","assets/appUrls-CRSwgtcj.js","assets/chunk-62JRHF6Z-ByakpFgU.js","assets/useImageProxy-C0ThLkT_.js","assets/avatar-8iFLkhAN.js","assets/skeleton-C53mCyi9.js","assets/genUserName-DLQrbfFW.js","assets/sanitizeUrl-Bd1A9ELz.js","assets/lib-7uQUP1a1.js","assets/lib-BWxi2zkG.js","assets/popover-CdTvSJAh.js","assets/dist-CitWBVEa.js","assets/dist-D7pvA9fR.js","assets/dist-BUUm7xJW.js","assets/dist-B243A_v0.js","assets/dist-CQNJl2wh.js","assets/dist-pkeM7iu9.js","assets/dist-TclcpL79.js","assets/es2015-CQgmJOvf.js","assets/useBtcPrice-s5UGsaE4.js","assets/useEventTranslation-JqEZgW2T.js","assets/useMutation-B3AB1JC6.js","assets/fetchFreshEvent-CXox1SyJ.js","assets/useNostrPublish-D4pB8G4O.js","assets/appRelays-Duq5P3DM.js","assets/Trans-BCdErB0a.js","assets/i18next-pPed_4FM.js","assets/input-Dkzlj0L8.js","assets/dialog-Bh2SYyZW.js","assets/dist-QjkaCeV2.js","assets/dropdown-menu-BbdDfqao.js","assets/dist-B8UZnK_Y.js","assets/collapsible-DeI_R02F.js","assets/communityUtils-CML5SRHR.js","assets/dist-CxcvWxxD.js","assets/dist-ByRx2HZA.js","assets/dist-E3kMcwQP.js","assets/dist-C2J943E6.js","assets/dist-UrnQoaTI.js","assets/useUploadFile-fBcRCPnG.js","assets/appBlossom-CsMDSd4h.js","assets/countryIdentifiers-DkqoLpd_.js","assets/countries-DOXck9T3.js","assets/label-DbuWtQm3.js","assets/useVerifierStatement-SKZOT1GH.js","assets/agoraNoteTags-D6RY6yl8.js","assets/card-D83yFPTL.js","assets/badge-ABjrmSMr.js","assets/textarea-FOlFw9be.js","assets/campaignCategories-BcBEkSPQ.js","assets/formatCampaignAmount-BEWIejQ7.js","assets/dist-BzLRu4gs.js","assets/CampaignListsStrip-Bx1zKRld.js","assets/useIsMobile-8UO1VB7D.js","assets/alert-dialog-GUtjwCor.js","assets/dist-CCP8JwMC.js","assets/StartCampaignLink-B6pfoRgl.js","assets/AuthDialog-CMCRm2cf.js","assets/qrcode-COnCKZdj.js","assets/browser-Cpc4qo6y.js","assets/useLoginActions-FsDTF83f.js","assets/useCampaigns-DgB46I8R.js","assets/useMuteList-AuK7yw18.js","assets/storageKey-Hu6452Ya.js","assets/nostrId-hlO3XEuY.js","assets/muteHelpers-BysE7siS.js","assets/useVerifierPacks-BLCoN3a3.js","assets/PartnersPressBand-CHsrFDxh.js","assets/downloadFile-BTSWd5cT.js","assets/CreateCampaignPage-DhzuG0N2.js","assets/tooltip-1urWnwwM.js","assets/ProfileCard-CLgNOMYZ.js","assets/EmbeddedNote-DrUd4Foc.js","assets/useFollowActions-CAUj_2Cc.js","assets/useEventInteractions-COCeUaO7.js","assets/utils-1bOINbOx.js","assets/sha256-BgZ4MAII.js","assets/customEmoji-kpim4Htm.js","assets/CustomEmoji-DxjyZluk.js","assets/haptics-DWDOjcyW.js","assets/timeAgo-BXjjbyXp.js","assets/useActions-Dp20S8bZ.js","assets/CountryFlag-D9w0wcAf.js","assets/defaultActionCovers-CtOtrsxB.js","assets/colorUtils-KIRxbuSj.js","assets/useInsertText-CHKvCW0R.js","assets/useDebounce-f-le_qDD.js","assets/useSearchProfiles-BIBrVHne.js","assets/tabs-CWGKXyj_.js","assets/dist-DeYz_NLh.js","assets/alert-BT6B1GYM.js","assets/ArticleContent-BPp4GtXB.js","assets/useCampaign-Bl84iXMz.js","assets/useManageableOrganizations-k0gKRPcN.js","assets/addressableEvents-tJKPsQXx.js","assets/Wizard-CY6HXV4J.js","assets/CountrySelect-LEgjrnEj.js","assets/FormSection-2yjrWhq9.js","assets/OrganizationContextChip-e1vgR92R.js","assets/organizationContext-DlFMNpLc.js","assets/seedDetailCache-D1muYB1l.js","assets/EmbeddedNote-CCnCjowl.css","assets/AllCampaignsPage-BoTPnnMw.js","assets/useDiscoveryFilters-B7oIBRf-.js","assets/command-BrtQBbGX.js","assets/useAllCampaigns-CoCUSRDc.js","assets/HeroBanner-BGG9lF4f.js","assets/CampaignListDetailPage-DJymTIZU.js","assets/CampaignByNip05Page-CebHQjls.js","assets/CampaignDetailPage-BNDv8xhA.js","assets/useInfiniteQuery-PCW9UqzB.js","assets/NoteCard-gIqQ9c4s.js","assets/useLocalStorage-B6ue6X7-.js","assets/nostrEvents-CCXNIbkt.js","assets/useWallet-CGlbjv_C.js","assets/useFeedSettings-BBOZbM3C.js","assets/useEncryptedSettings-Xhb6VgJS.js","assets/sheet-BY7IUyy8.js","assets/separator-CCPnlDZv.js","assets/scroll-area-B3M47T-8.js","assets/useTheme-C5QTa_U0.js","assets/useShareOrigin-BF96RqOS.js","assets/contentWarning-DcKHjdNG.js","assets/bitcoinFeeSpeed-B65cB0kZ.js","assets/radio-group-B40RS2I7.js","assets/campaignEmbed-Le5cURTV.js","assets/admins-7SV8oI_M.js","assets/useOrganizers-CqkWQWLZ.js","assets/zapHelpers-CY_iVNCt.js","assets/HelpTip-CaxXULj6.js","assets/helpContent-BNibnXjg.js","assets/i18n-Dgk7hNi5.js","assets/helpMarkup-CkQgoO3j.js","assets/useHdWalletAccess-DshlghHC.js","assets/english-C44olSCx.js","assets/CampaignWalletDonatePanel-DWmF7geL.js","assets/PendingBadge-C0l763u-.js","assets/scan-B46sivMl.js","assets/checkbox-oUnAxl2y.js","assets/spend-BbCRQhEo.js","assets/crypto-CMBh4hYN.js","assets/transaction-D8CaMhTL.js","assets/useComments-YE4a7Tzj.js","assets/EmbedCampaignPage-_L1YrIdu.js","assets/ActionsPage-b-W1S5qn.js","assets/PledgeCard-CZZ0GmL3.js","assets/useNip50Search-Dr5OFjuA.js","assets/CreateActionPage-B2HfcHtJ.js","assets/timezone-DF4XmxUG.js","assets/AdvancedSettingsPage-IJkBMmwQ.js","assets/RequestToVanishDialog-BjgJCUVW.js","assets/PageHeader-BsRDdl0n.js","assets/switch-BdajVCG5.js","assets/WalletSettings-5JYSiXcD.js","assets/AppearanceSettingsPage-a3xihrNt.js","assets/ChangelogPage-BdlIaOGf.js","assets/CommunitiesPage-BRb09SaJ.js","assets/useCommunityBookmarks-D7jAY3eO.js","assets/useUserOrganizations-DeSLHTbI.js","assets/ContentPage-BNSGCRgV.js","assets/accordion-q9TDBfyh.js","assets/CreateCommunityPage-DmW4O_C7.js","assets/CreateEventPage-D5njsIiH.js","assets/usePublishRSVP-Dz-thVrz.js","assets/CSAEPolicyPage-DMkuIS-m.js","assets/PolicyMarkdown-BgJP2ubz.js","assets/usePolicyMarkdown-D5Jqgpog.js","assets/ExternalContentPage-BEVEK0y2.js","assets/bookstr-BDAofZUZ.js","assets/GeotagPage-BuL07bfb.js","assets/TagFeedPage-BNV1R2Qp.js","assets/HashtagPage-BPe2jILv.js","assets/MessagesPage-ofMnjm7R.js","assets/MyDashboardPage-CzZ017hu.js","assets/AboutPage-CWGiaqRi.js","assets/DonorGuidePage-Dpu_3ubn.js","assets/guide-UCMGkiO_.js","assets/RecipientGuidePage-BFr7mIrZ.js","assets/CorporateSponsorshipPage-BaJH0WJ6.js","assets/LanguageSettingsPage-7ML1A3l7.js","assets/NetworkSettingsPage-CvuRjNDH.js","assets/NIP19Page-Cc2SHdbX.js","assets/WeatherStationCard-CidPsybK.js","assets/select-B5Gy5N4A.js","assets/useStreamPosts-Dx5-gTM_.js","assets/useContentFilters-CBzflXwM.js","assets/NotificationSettings-9gidUwR6.js","assets/secureStorage-BUKCueQo.js","assets/NotificationsPage-C77vP0-W.js","assets/OrganizationsPage-BVm7rDB9.js","assets/OrganizersPage-DEeIqehb.js","assets/EventDashboardPage-CPeYZN6F.js","assets/PrivacyPolicyPage-DdO2at9f.js","assets/ProfileSettings-jwPlbCtl.js","assets/WalletBackupMnemonic-CVj3uZBP.js","assets/SearchPage-CaWUghPr.js","assets/SettingsPage-fotkjy56.js","assets/SomethingWrongPage-CD0S7e6h.js","assets/WalletPage-CHMw39TQ.js","assets/WalletMigrateV1Page-BwmTPwFw.js","assets/logger-DjzgStrs.js","assets/useHdWalletV1Migration-BABH41cT.js","assets/WalletDoubleTweakFixPage-LutVlhC0.js","assets/WalletRecoveryPage-DAQJc43L.js","assets/WalletSettingsPage-B71td1Ro.js","assets/LegacyWalletRecoveryPage-iT_1Ghtl.js","assets/RemoteLoginSuccessPage-BRwZDCGc.js","assets/DonateCallbackPage-DS0kQPxP.js","assets/esm-E85gkrsK.js"])))=>i.map(i=>d[i]); import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{$ as n,$t as r,B as i,Bn as a,Bt as o,Fr as s,Gt as c,Ht as l,In as u,Jr as d,Jt as f,Ln as p,Mn as m,Mr as h,Nn as g,Nr as _,O as v,Pr as y,Qr as b,Qt as x,Rn as S,Sn as C,T as ee,Tr as te,Xr as w,b as ne,bt as re,ct as ie,di as ae,dr as oe,dt as se,ei as ce,en as T,et as E,fn as le,gn as ue,ir as de,jn as fe,jt as pe,l as me,ln as he,o as ge,oi as _e,on as ve,ot as ye,p as be,pn as xe,rn as Se,rr as Ce,si as we,sn as Te,sr as Ee,ui as De,vn as Oe,vr as ke,wn as Ae,wt as je,x as Me,xn as Ne,yt as Pe,z as Fe}from"./lucide-icons-6JcOMNkr.js";import{a as Ie,o as Le,r as Re,t as ze}from"./dist-CitWBVEa.js";import{$ as Be,B as Ve,C as He,Ct as Ue,D as We,Dt as Ge,F as Ke,G as qe,H as Je,I as Ye,K as Xe,L as Ze,M as Qe,N as $e,O as et,P as tt,Q as nt,R as rt,T as it,U as at,W as ot,Z as st,a as ct,b as lt,ct as ut,et as dt,ht as ft,i as pt,n as mt,o as ht,ot as gt,s as _t,t as vt,tt as yt,wt as bt,x as xt}from"./useAuthor-K0SVHIbr.js";import{n as St,o as Ct}from"./TranslateButton-DiWnIeAQ.js";import{t as wt}from"./jsx-runtime-NZYk81nU.js";import{t as D}from"./preload-helper-Czpn1I53.js";import{a as Tt,d as Et,i as Dt,l as Ot,r as kt,s as At,t as jt,u as Mt}from"./esm-0y5H0J9W.js";import{n as Nt,t as Pt}from"./useMutation-B3AB1JC6.js";import{n as Ft,t as It}from"./useInfiniteQuery-PCW9UqzB.js";import{g as Lt}from"./CampaignCard-i2mQdn0N.js";import{a as Rt,c as zt,d as Bt,i as Vt,l as Ht,n as Ut,o as Wt,r as Gt,s as Kt,t as qt,u as Jt}from"./dist-BzLRu4gs.js";import{t as Yt}from"./useLocalStorage-B6ue6X7-.js";import{n as Xt,t as Zt}from"./useAppContext-DVsgK-HT.js";import{n as Qt,t as $t}from"./useTheme-C5QTa_U0.js";import{a as en,i as tn,n as nn,r as rn,t as an}from"./useEncryptedSettings-Xhb6VgJS.js";import{r as on}from"./appBlossom-CsMDSd4h.js";import{t as sn}from"./storageKey-Hu6452Ya.js";import{t as cn,v as ln}from"./useCurrentUser-CgUH2vq7.js";import{n as un,t as dn}from"./useToast-BZaXaeWY.js";import{t as fn}from"./fetchFreshEvent-CXox1SyJ.js";import{t as pn}from"./useNostrPublish-D4pB8G4O.js";import{t as mn}from"./nostrId-hlO3XEuY.js";import{n as hn,r as gn,t as _n}from"./useMuteList-AuK7yw18.js";import{t as vn}from"./appUrls-CRSwgtcj.js";import{n as yn,o as bn,r as xn,t as Sn}from"./dist-C2I8JNdt.js";import{n as Cn}from"./useFollowActions-CAUj_2Cc.js";import{a as wn,i as Tn,o as En,r as Dn}from"./appRelays-Duq5P3DM.js";import{a as On,r as kn,s as An}from"./nostrEvents-CCXNIbkt.js";import{i as jn,n as Mn,r as Nn,t as Pn}from"./tooltip-1urWnwwM.js";import{n as Fn}from"./dist-U-Iv1vyA.js";import{t as In}from"./dist-BUUm7xJW.js";import{t as Ln}from"./dist-B243A_v0.js";import{a as Rn,h as zn,t as O}from"./utils-CFLjoQCu.js";import{Nt as Bn,Pt as Vn,Q as Hn,et as Un,jt as Wn,nt as Gn,r as Kn,tt as qn}from"./NoteCard-gIqQ9c4s.js";import{t as Jn}from"./secureStorage-BUKCueQo.js";import{a as Yn}from"./useEventInteractions-COCeUaO7.js";import{n as Xn}from"./useWallet-CGlbjv_C.js";import{i as Zn,n as Qn,r as $n,t as er}from"./AuthDialog-CMCRm2cf.js";import{c as tr,l as nr,s as rr,t as ir}from"./useHdWalletAccess-DshlghHC.js";import{a as ar,c as or,l as sr,n as cr,o as lr,t as ur}from"./scan-B46sivMl.js";import{a as dr,i as fr,n as pr,o as mr,r as hr,t as gr}from"./crypto-CMBh4hYN.js";import{a as _r,c as vr,i as yr,l as br,n as xr,o as k,r as Sr,s as Cr,t as wr,u as Tr}from"./chunk-62JRHF6Z-ByakpFgU.js";import{t as A}from"./useTranslation-DClBQ1v-.js";import{n as Er,t as Dr}from"./i18n-Dgk7hNi5.js";import{t as Or}from"./dist-CxcvWxxD.js";import{t as kr}from"./dist-ByRx2HZA.js";import{n as Ar,t as jr}from"./dist-E3kMcwQP.js";import{t as Mr}from"./dist-CCP8JwMC.js";import{t as Nr}from"./dist-6F83Gh1K.js";import{t as Pr}from"./button-DwJ7jtrK.js";import{t as Fr}from"./input-Dkzlj0L8.js";import{a as Ir,c as Lr,i as Rr,n as zr,t as Br}from"./dialog-Bh2SYyZW.js";import{a as Vr,c as Hr,i as Ur,l as Wr,o as Gr,r as Kr,s as qr,t as Jr}from"./dropdown-menu-BbdDfqao.js";import{t as Yr}from"./useLoginActions-FsDTF83f.js";import{n as Xr}from"./useImageProxy-C0ThLkT_.js";import{i as Zr,n as Qr,r as $r,t as ei}from"./avatar-8iFLkhAN.js";import{t as ti}from"./skeleton-C53mCyi9.js";import{t as ni}from"./useFeedSettings-BBOZbM3C.js";import{t as ri}from"./genUserName-DLQrbfFW.js";import{n as ii,t as ai}from"./sheet-BY7IUyy8.js";import{t as oi}from"./sanitizeUrl-Bd1A9ELz.js";import{n as si,t as ci}from"./ProfileCard-CLgNOMYZ.js";import{y as li}from"./communityUtils-CML5SRHR.js";import{t as ui}from"./useUploadFile-fBcRCPnG.js";import{C as di,D as fi,E as pi,S as mi,T as hi,_ as gi,b as _i,c as vi,d as yi,f as bi,g as xi,h as Si,l as Ci,m as wi,o as Ti,p as Ei,s as Di,t as Oi,u as ki,v as Ai,w as ji,x as Mi,y as Ni}from"./lib-BWxi2zkG.js";import{t as Pi}from"./label-DbuWtQm3.js";import{i as Fi,r as Ii,t as Li}from"./popover-CdTvSJAh.js";import{t as Ri}from"./separator-CCPnlDZv.js";import{n as zi,t as Bi}from"./useVerifierStatement-SKZOT1GH.js";import{n as Vi,t as j}from"./downloadFile-BTSWd5cT.js";import{n as Hi}from"./haptics-DWDOjcyW.js";import{T as Ui}from"./useEventTranslation-JqEZgW2T.js";import{i as Wi,r as Gi}from"./countryIdentifiers-DkqoLpd_.js";import{o as Ki}from"./colorUtils-KIRxbuSj.js";import{a as qi,i as Ji}from"./zapHelpers-CY_iVNCt.js";import{t as Yi}from"./useContentFilters-CBzflXwM.js";import{t as Xi}from"./muteHelpers-BysE7siS.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Zi=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,re());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}}var S=!1,C=-1,ee=5,te=-1;function w(){return g?!0:!(e.unstable_now()-tet&&w());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&oe(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?re():S=!1}}}var re;if(typeof y==`function`)re=function(){y(ne)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=ne,re=function(){ae.postMessage(null)}}else re=function(){_(ne,0)};function oe(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,oe(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,re()))),r},e.unstable_shouldYield=w,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Qi=t(((e,t)=>{t.exports=Zi()})),$i=t((e=>{var t=Qi(),n=ae(),r=Le();function i(e){var t=`https://react.dev/errors/`+e;if(1de||(e.current=ue[de],ue[de]=null,de--)}function me(e,t){de++,ue[de]=e.current,e.current=t}var he=fe(null),ge=fe(null),_e=fe(null),ve=fe(null);function ye(e,t){switch(me(_e,t),me(ge,e),me(he,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?$d(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=$d(t),e=ef(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}pe(he),me(he,e)}function be(){pe(he),pe(ge),pe(_e)}function xe(e){e.memoizedState!==null&&me(ve,e);var t=he.current,n=ef(t,e.type);t!==n&&(me(ge,e),me(he,n))}function Se(e){ge.current===e&&(pe(he),pe(ge)),ve.current===e&&(pe(ve),up._currentValue=le)}var Ce,we;function Te(e){if(Ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ce=t&&t[1]||``,we=-1)`:-1i||c[r]!==l[i]){var u=` `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Ee=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Te(n):``}function Oe(e,t){switch(e.tag){case 26:case 27:case 5:return Te(e.type);case 16:return Te(`Lazy`);case 13:return e.child!==t&&t!==null?Te(`Suspense Fallback`):Te(`Suspense`);case 19:return Te(`SuspenseList`);case 0:case 15:return De(e.type,!1);case 11:return De(e.type.render,!1);case 1:return De(e.type,!0);case 31:return Te(`Activity`);default:return``}}function ke(e){try{var t=``,n=null;do t+=Oe(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}var Ae=Object.prototype.hasOwnProperty,je=t.unstable_scheduleCallback,Me=t.unstable_cancelCallback,Ne=t.unstable_shouldYield,Pe=t.unstable_requestPaint,Fe=t.unstable_now,Ie=t.unstable_getCurrentPriorityLevel,Re=t.unstable_ImmediatePriority,ze=t.unstable_UserBlockingPriority,Be=t.unstable_NormalPriority,Ve=t.unstable_LowPriority,He=t.unstable_IdlePriority,Ue=t.log,We=t.unstable_setDisableYieldValue,Ge=null,Ke=null;function qe(e){if(typeof Ue==`function`&&We(e),Ke&&typeof Ke.setStrictMode==`function`)try{Ke.setStrictMode(Ge,e)}catch{}}var Je=Math.clz32?Math.clz32:Ze,Ye=Math.log,Xe=Math.LN2;function Ze(e){return e>>>=0,e===0?32:31-(Ye(e)/Xe|0)|0}var Qe=256,$e=262144,et=4194304;function tt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function nt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=tt(n))):i=tt(o):i=tt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=tt(n))):i=tt(o)):i=tt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function rt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function it(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function at(){var e=et;return et<<=1,!(et&62914560)&&(et=4194304),e}function ot(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function st(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ct(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0`u`||window.document===void 0||window.document.createElement===void 0),bn=!1;if(yn)try{var xn={};Object.defineProperty(xn,"passive",{get:function(){bn=!0}}),window.addEventListener(`test`,xn,xn),window.removeEventListener(`test`,xn,xn)}catch{bn=!1}var Sn=null,Cn=null,wn=null;function Tn(){if(wn)return wn;var e,t=Cn,n=t.length,r,i=`value`in Sn?Sn.value:Sn.textContent,a=i.length;for(e=0;e=nr),ar=` `,or=!1;function sr(e,t){switch(e){case`keyup`:return er.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function cr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var lr=!1;function ur(e,t){switch(e){case`compositionend`:return cr(t);case`keypress`:return t.which===32?(or=!0,ar):null;case`textInput`:return e=t.data,e===ar&&or?null:e;default:return null}}function dr(e,t){if(lr)return e===`compositionend`||!tr&&sr(e,t)?(e=Tn(),wn=Cn=Sn=null,lr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=jr(n)}}function Nr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Nr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Pr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Kt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Kt(e.document)}return t}function Fr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Ir=yn&&`documentMode`in document&&11>=document.documentMode,Lr=null,Rr=null,zr=null,Br=!1;function Vr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Br||Lr==null||Lr!==Kt(r)||(r=Lr,`selectionStart`in r&&Fr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),zr&&Ar(zr,r)||(zr=r,r=Rd(Rr,`onSelect`),0>=o,i-=o,Ni=1<<32-Je(t)+i|n<m?(h=d,d=null):h=d.sibling;var g=p(i,d,s[m],c);if(g===null){d===null&&(d=h);break}e&&d&&g.alternate===null&&t(i,d),a=o(g,a,m),u===null?l=g:u.sibling=g,u=g,d=h}if(m===s.length)return n(i,d),j&&Fi(i,m),l;if(d===null){for(;mh?(g=m,m=null):g=m.sibling;var y=p(a,m,v.value,l);if(y===null){m===null&&(m=g);break}e&&m&&y.alternate===null&&t(a,m),s=o(y,s,h),d===null?u=y:d.sibling=y,d=y,m=g}if(v.done)return n(a,m),j&&Fi(a,h),u;if(m===null){for(;!v.done;h++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return j&&Fi(a,h),u}for(m=r(m);!v.done;h++,v=c.next())v=_(m,a,h,v.value,l),v!==null&&(e&&v.alternate!==null&&m.delete(v.key===null?h:v.key),s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return e&&m.forEach(function(e){return t(a,e)}),j&&Fi(a,h),u}function x(e,r,o,c){if(typeof o==`object`&&o&&o.type===g&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case m:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===g){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===te&&Pa(l)===r.type){n(e,r.sibling),c=a(r,o.props),Va(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===g?(c=bi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=yi(o.type,o.key,o.props,null,e.mode,c),Va(c,o),c.return=e,e=c)}return s(e);case h:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Ci(o,e.mode,c),c.return=e,e=c}return s(e);case te:return o=Pa(o),x(e,r,o,c)}if(ce(o))return v(e,r,o,c);if(ie(o)){if(l=ie(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return x(e,r,Ba(o),c);if(o.$$typeof===b)return x(e,r,ca(e,o),c);Ha(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=xi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{za=0;var i=x(e,t,n,r);return Ra=null,i}catch(t){if(t===Oa||t===Aa)throw t;var a=hi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Wa=Ua(!0),Ga=Ua(!1),Ka=!1;function qa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ja(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ya(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Xa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,F&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=fi(e),di(e,null,n),t}return ci(e,r,t,n),fi(e)}function Za(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ut(e,n)}}function Qa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var $a=!1;function eo(){if($a){var e=ya;if(e!==null)throw e}}function to(e,t,n,r){$a=!1;var i=e.updateQueue;Ka=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(R&p)===p:(r&p)===p){p!==0&&p===va&&($a=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:Ka=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),ru|=o,e.lanes=o,e.memoizedState=d}}function no(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function ro(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=T.T,s={};T.T=s,Ws(e,!1,t,n);try{var c=i(),l=T.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Us(e,t,Sa(c,r),Tu(e)):Us(e,t,r,Tu(e))}catch(n){Us(e,t,{then:function(){},status:`rejected`,reason:n},Tu())}finally{E.p=a,o!==null&&s.types!==null&&(o.types=s.types),T.T=o}}function Ns(){}function Ps(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Fs(e).queue;Ms(e,a,t,le,n===null?Ns:function(){return Is(e),n(r)})}function Fs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:le,baseState:le,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wo,lastRenderedState:le},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Is(e){var t=Fs(e);t.next===null&&(t=e.alternate.memoizedState),Us(e,t.next.queue,{},Tu())}function Ls(){return sa(up)}function Rs(){return zo().memoizedState}function zs(){return zo().memoizedState}function Bs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Tu();e=Ya(n);var r=Xa(t,e,n);r!==null&&(Du(r,t,n),Za(r,t,n)),t={cache:ma()},e.payload=t;return}t=t.return}}function Vs(e,t,n){var r=Tu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Gs(e)?Ks(t,n):(n=li(e,t,n,r),n!==null&&(Du(n,e,r),qs(n,t,r)))}function Hs(e,t,n){Us(e,t,n,Tu())}function Us(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Gs(e))Ks(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,kr(s,o))return ci(e,t,i,0),I===null&&si(),!1}catch{}if(n=li(e,t,i,r),n!==null)return Du(n,e,r),qs(n,t,r),!0}return!1}function Ws(e,t,n,r){if(r={lane:2,revertLane:Cd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Gs(e)){if(t)throw Error(i(479))}else t=li(e,n,r,2),t!==null&&Du(t,e,2)}function Gs(e){var t=e.alternate;return e===P||t!==null&&t===P}function Ks(e,t){Co=So=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function qs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ut(e,n)}}var Js={readContext:sa,use:Ho,useCallback:ko,useContext:ko,useEffect:ko,useImperativeHandle:ko,useLayoutEffect:ko,useInsertionEffect:ko,useMemo:ko,useReducer:ko,useRef:ko,useState:ko,useDebugValue:ko,useDeferredValue:ko,useTransition:ko,useSyncExternalStore:ko,useId:ko,useHostTransitionStatus:ko,useFormState:ko,useActionState:ko,useOptimistic:ko,useMemoCache:ko,useCacheRefresh:ko};Js.useEffectEvent=ko;var Ys={readContext:sa,use:Ho,useCallback:function(e,t){return Ro().memoizedState=[e,t===void 0?null:t],e},useContext:sa,useEffect:ys,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),_s(4194308,4,Ts.bind(null,t,e),n)},useLayoutEffect:function(e,t){return _s(4194308,4,e,t)},useInsertionEffect:function(e,t){_s(4,2,e,t)},useMemo:function(e,t){var n=Ro();t=t===void 0?null:t;var r=e();if(wo){qe(!0);try{e()}finally{qe(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Ro();if(n!==void 0){var i=n(t);if(wo){qe(!0);try{n(t)}finally{qe(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Vs.bind(null,P,e),[r.memoizedState,e]},useRef:function(e){var t=Ro();return e={current:e},t.memoizedState=e},useState:function(e){e=es(e);var t=e.queue,n=Hs.bind(null,P,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ds,useDeferredValue:function(e,t){return As(Ro(),e,t)},useTransition:function(){var e=es(!1);return e=Ms.bind(null,P,e.queue,!0,!1),Ro().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=P,a=Ro();if(j){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),I===null)throw Error(i(349));R&127||Yo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ys(Zo.bind(null,r,o,e),[e]),r.flags|=2048,hs(9,{destroy:void 0},Xo.bind(null,r,o,n,t),null),n},useId:function(){var e=Ro(),t=I.identifierPrefix;if(j){var n=Pi,r=Ni;n=(r&~(1<<32-Je(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=To++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[_t]=t,o[vt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Kd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Uc(t)}}return Jc(t),Wc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Uc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=_e.current,Ji(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Bi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[_t]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||H(e.nodeValue,n)),e||Gi(t,!0)}else e=Qd(e).createTextNode(r),e[_t]=t,t.stateNode=e}return Jc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ji(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[_t]=t}else Yi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Jc(t),e=!1}else n=Xi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(go(t),t):(go(t),null);if(t.flags&128)throw Error(i(558))}return Jc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ji(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[_t]=t}else Yi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Jc(t),a=!1}else a=Xi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(go(t),t):(go(t),null)}return go(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Kc(t,t.updateQueue),Jc(t),null);case 4:return be(),e===null&&Pd(t.stateNode.containerInfo),Jc(t),null;case 10:return ta(t.type),Jc(t),null;case 19:if(pe(_o),r=t.memoizedState,r===null)return Jc(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)qc(r,!1);else{if(nu!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=vo(e),o!==null){for(t.flags|=128,qc(r,!1),e=o.updateQueue,t.updateQueue=e,Kc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)vi(n,e),n=n.sibling;return me(_o,_o.current&1|2),j&&Fi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Fe()>pu&&(t.flags|=128,a=!0,qc(r,!1),t.lanes=4194304)}}else{if(!a){if(e=vo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Kc(t,e),qc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!j)return Jc(t),null}else 2*Fe()-r.renderingStartTime>pu&&n!==536870912&&(t.flags|=128,a=!0,qc(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Jc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Fe(),e.sibling=null,n=_o.current,me(_o,a?n&1|2:n&1),j&&Fi(t,r.treeForkCount),e);case 22:case 23:return go(t),co(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Jc(t),t.subtreeFlags&6&&(t.flags|=8192)):Jc(t),n=t.updateQueue,n!==null&&Kc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&pe(wa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ta(pa),Jc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Xc(e,t){switch(Ri(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ta(pa),be(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Se(t),null;case 31:if(t.memoizedState!==null){if(go(t),t.alternate===null)throw Error(i(340));Yi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(go(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Yi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return pe(_o),null;case 4:return be(),null;case 10:return ta(t.type),null;case 22:case 23:return go(t),co(),e!==null&&pe(wa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ta(pa),null;case 25:return null;default:return null}}function Zc(e,t){switch(Ri(t),t.tag){case 3:ta(pa),be();break;case 26:case 27:case 5:Se(t);break;case 4:be();break;case 31:t.memoizedState!==null&&go(t);break;case 13:go(t);break;case 19:pe(_o);break;case 10:ta(t.type);break;case 22:case 23:go(t),co(),e!==null&&pe(wa);break;case 24:ta(pa)}}function Qc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){B(t,t.return,e)}}function $c(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){B(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){B(t,t.return,e)}}function el(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{ro(t,n)}catch(t){B(e,e.return,t)}}}function tl(e,t,n){n.props=nc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){B(e,t,n)}}function nl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){B(e,t,n)}}function rl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){B(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){B(e,t,n)}else n.current=null}}function il(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){B(e,e.return,t)}}function al(e,t,n){try{var r=e.stateNode;qd(r,e.type,n,t),r[vt]=t}catch(t){B(e,e.return,t)}}function ol(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&uf(e.type)||e.tag===4}function sl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||ol(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&uf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function cl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=un));else if(r!==4&&(r===27&&uf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(cl(e,t,n),e=e.sibling;e!==null;)cl(e,t,n),e=e.sibling}function ll(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&uf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(ll(e,t,n),e=e.sibling;e!==null;)ll(e,t,n),e=e.sibling}function ul(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Kd(t,r,n),t[_t]=e,t[vt]=n}catch(t){B(e,e.return,t)}}var dl=!1,fl=!1,pl=!1,ml=typeof WeakSet==`function`?WeakSet:Set,hl=null;function gl(e,t){if(e=e.containerInfo,Xd=yp,e=Pr(e),Fr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Zd={focusedElem:e,selectionRange:n},yp=!1,hl=t;hl!==null;)if(t=hl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,hl=e;else for(;hl!==null;){switch(t=hl,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Kd(o,r,n),o[_t]=e,kt(o),r=o;break a;case`link`:var s=$f(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=Mr(s,h),v=Mr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,T.T=null,n=xu,xu=null;var o=_u,s=yu;if(gu=0,vu=_u=null,yu=0,F&6)throw Error(i(331));var c=F;if(F|=4,Kl(o.current),Rl(o,o.current,s,n),F=c,gd(0,!1),Ke&&typeof Ke.onPostCommitFiberRoot==`function`)try{Ke.onPostCommitFiberRoot(Ge,o)}catch{}return!0}finally{E.p=a,T.T=r,$u(e,t)}}function nd(e,t,n){t=Ti(n,t),t=cc(e.stateNode,t,2),e=Xa(e,t,2),e!==null&&(st(e,2),hd(e))}function B(e,t,n){if(e.tag===3)nd(e,e,n);else for(;t!==null;){if(t.tag===3){nd(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(hu===null||!hu.has(r))){e=Ti(n,e),n=lc(2),r=Xa(t,n,2),r!==null&&(uc(n,r,t,e),st(r,2),hd(r));break}}t=t.return}}function rd(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Xl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(eu=!0,i.add(n),e=id.bind(null,e,t,n),t.then(e,e))}function id(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,I===e&&(R&n)===n&&(nu===4||nu===3&&(R&62914560)===R&&300>Fe()-du?!(F&2)&&Pu(e,0):au|=n,su===R&&(su=0)),hd(e)}function ad(e,t){t===0&&(t=at()),e=ui(e,t),e!==null&&(st(e,t),hd(e))}function od(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ad(e,n)}function sd(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),ad(e,n)}function cd(e,t){return je(e,t)}var ld=null,ud=null,dd=!1,fd=!1,pd=!1,md=0;function hd(e){e!==ud&&e.next===null&&(ud===null?ld=ud=e:ud=ud.next=e),fd=!0,dd||(dd=!0,Sd())}function gd(e,t){if(!pd&&fd){pd=!0;do for(var n=!1,r=ld;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Je(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,xd(r,a))}else a=R,a=nt(r,r===I?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||rt(r,a)||(n=!0,xd(r,a))}r=r.next}while(n);pd=!1}}function _d(){vd()}function vd(){fd=dd=!1;var e=0;md!==0&&rf()&&(e=md);for(var t=Fe(),n=null,r=ld;r!==null;){var i=r.next,a=yd(r,t);a===0?(r.next=null,n===null?ld=i:n.next=i,i===null&&(ud=n)):(n=r,(e!==0||a&3)&&(fd=!0)),r=i}gu!==0&&gu!==5||gd(e,!1),md!==0&&(md=0)}function yd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&Jd(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function Nf(e,t,n){var r=Mf;if(r&&typeof t==`string`&&t){var i=Jt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Df.has(i)||(Df.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Kd(t,`link`,e),kt(t),r.head.appendChild(t)))}}function Pf(e){kf.D(e),Nf(`dns-prefetch`,e,null)}function Ff(e,t){kf.C(e,t),Nf(`preconnect`,e,t)}function If(e,t,n){kf.L(e,t,n);var r=Mf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Jt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Jt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Jt(n.imageSizes)+`"]`)):i+=`[href="`+Jt(e)+`"]`;var a=i;switch(t){case`style`:a=Hf(e);break;case`script`:a=Kf(e)}Ef.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Ef.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Uf(a))||t===`script`&&r.querySelector(qf(a))||(t=r.createElement(`link`),Kd(t,`link`,e),kt(t),r.head.appendChild(t)))}}function Lf(e,t){kf.m(e,t);var n=Mf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Jt(r)+`"][href="`+Jt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Kf(e)}if(!Ef.has(a)&&(e=f({rel:`modulepreload`,href:e},t),Ef.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(qf(a)))return}r=n.createElement(`link`),Kd(r,`link`,e),kt(r),n.head.appendChild(r)}}}function Rf(e,t,n){kf.S(e,t,n);var r=Mf;if(r&&e){var i=Ot(r).hoistableStyles,a=Hf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Uf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Ef.get(a))&&Xf(e,n);var c=o=r.createElement(`link`);kt(c),Kd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Yf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function zf(e,t){kf.X(e,t);var n=Mf;if(n&&e){var r=Ot(n).hoistableScripts,i=Kf(e),a=r.get(i);a||(a=n.querySelector(qf(i)),a||(e=f({src:e,async:!0},t),(t=Ef.get(i))&&Zf(e,t),a=n.createElement(`script`),kt(a),Kd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Bf(e,t){kf.M(e,t);var n=Mf;if(n&&e){var r=Ot(n).hoistableScripts,i=Kf(e),a=r.get(i);a||(a=n.querySelector(qf(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=Ef.get(i))&&Zf(e,t),a=n.createElement(`script`),kt(a),Kd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Vf(e,t,n,r){var a=(a=_e.current)?Of(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Hf(n.href),n=Ot(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Hf(n.href);var o=Ot(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Uf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),Ef.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Ef.set(e,n),o||Gf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Kf(n),n=Ot(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Hf(e){return`href="`+Jt(e)+`"`}function Uf(e){return`link[rel="stylesheet"][`+e+`]`}function Wf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Gf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Kd(t,`link`,n),kt(t),e.head.appendChild(t))}function Kf(e){return`[src="`+Jt(e)+`"]`}function qf(e){return`script[async]`+e}function Jf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Jt(n.href)+`"]`);if(r)return t.instance=r,kt(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),kt(r),Kd(r,`style`,a),Yf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Hf(n.href);var o=e.querySelector(Uf(a));if(o)return t.state.loading|=4,t.instance=o,kt(o),o;r=Wf(n),(a=Ef.get(a))&&Xf(r,a),o=(e.ownerDocument||e).createElement(`link`),kt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Kd(o,`link`,r),t.state.loading|=4,Yf(o,n.precedence,e),t.instance=o;case`script`:return o=Kf(n.src),(a=e.querySelector(qf(o)))?(t.instance=a,kt(a),a):(r=n,(a=Ef.get(o))&&(r=f({},n),Zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),kt(a),Kd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Yf(r,n.precedence,e));return t.instance}function Yf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function tp(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function np(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function rp(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Hf(r.href),a=t.querySelector(Uf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=op.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,kt(a);return}a=t.ownerDocument||t,r=Wf(r),(i=Ef.get(i))&&Xf(r,i),a=a.createElement(`link`),kt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Kd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=op.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var ip=0;function ap(e,t){return e.stylesheets&&e.count===0&&cp(e,e.stylesheets),0ip?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function op(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)cp(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var sp=null;function cp(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,sp=new Map,t.forEach(lp,e),sp=null,op.call(e))}function lp(e,t){if(!(t.state.loading&4)){var n=sp.get(e);if(n)var r=n.get(null);else{n=new Map,sp.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=$i()}))();AbortSignal.any||(AbortSignal.any=function(e){if(e.length===0)return new AbortController().signal;if(e.length===1)return e[0];for(let t of e)if(t.aborted){let e=new AbortController;return e.abort(t.reason),e.signal}let t=new AbortController,n=e=>{let n=e.target;t.abort(n.reason)};for(let t of e)t.addEventListener(`abort`,n,{once:!0});return t.signal.addEventListener(`abort`,()=>{for(let t of e)t.removeEventListener(`abort`,n)},{once:!0}),t.signal}),AbortSignal.timeout||(AbortSignal.timeout=function(e){let t=new AbortController;return setTimeout(()=>{t.abort(new DOMException(`The operation was aborted due to timeout`,`TimeoutError`))},e),t.signal});var M=e(ae(),1),N=wt(),ta=null,na=!1,ra=!1;async function ia(e){if(!e){console.log(`Sentry DSN is empty, skipping initialization`);return}if(na&&ta){console.log(`Sentry already initialized, re-enabling`);let e=ta.getClient();e&&(e.getOptions().enabled=!0),ra=!0;return}try{let{init:t,getClient:n,browserTracingIntegration:r,captureException:i,captureMessage:a,setUser:o}=await D(async()=>{let{init:e,getClient:t,browserTracingIntegration:n,captureException:r,captureMessage:i,setUser:a}=await import(`./esm-B23bzHOe.js`);return{init:e,getClient:t,browserTracingIntegration:n,captureException:r,captureMessage:i,setUser:a}},__vite__mapDeps([0,1,2]));ta={init:t,getClient:n,browserTracingIntegration:r,captureException:i,captureMessage:a,setUser:o},t({dsn:e,integrations:[r()],defaultIntegrations:void 0,tracesSampleRate:.1,environment:`production`,release:`2.11.1`,beforeSend(e){let t=/nsec1[023456789acdefghjklmnpqrstuvwxyz]{58}/g;function n(e){if(typeof e==`string`)return e.replace(t,`nsec1**********************************************************`);if(Array.isArray(e))return e.map(n);if(e&&typeof e==`object`){let t={};for(let[r,i]of Object.entries(e))t[r]=n(i);return t}return e}function r(e){return n(e)}return r(e)}}),na=!0,ra=!0,console.log(`Sentry initialized successfully`)}catch(e){throw console.error(`Failed to initialize Sentry:`,e),e}}async function aa(){if(!(!na||!ta||!ra))try{let e=ta.getClient();e&&(e.getOptions().enabled=!1),ra=!1,console.log(`Sentry disabled successfully`)}catch(e){console.error(`Failed to disable Sentry:`,e)}}function oa(){return na&&ra}function sa(){return ra?ta:null}var ca=class extends M.Component{constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(console.error(`Error caught by ErrorBoundary:`,e,t),this.setState({error:e,errorInfo:t}),this.props.reportToSentry!==!1){let n=sa();n&&n.captureException(e,{level:`fatal`,contexts:{react:{componentStack:t.componentStack??void 0}},tags:{errorBoundary:`true`}})}}handleReset=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,N.jsx)(`div`,{className:`bg-background flex items-center justify-center p-4`,children:(0,N.jsxs)(`div`,{className:`max-w-md w-full space-y-4`,children:[(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(`h2`,{className:`text-2xl font-bold text-foreground mb-2`,children:`Something went wrong`}),(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:`An unexpected error occurred. The error has been reported.`})]}),(0,N.jsx)(`div`,{className:`bg-muted p-4 rounded-lg`,children:(0,N.jsxs)(`details`,{className:`text-sm`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer font-medium text-foreground`,children:`Error details`}),(0,N.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`strong`,{className:`text-foreground`,children:`Message:`}),(0,N.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:this.state.error?.message})]}),this.state.error?.stack&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`strong`,{className:`text-foreground`,children:`Stack trace:`}),(0,N.jsx)(`pre`,{className:`text-xs text-muted-foreground mt-1 overflow-auto max-h-32`,children:this.state.error.stack})]})]})]})}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{onClick:this.handleReset,className:`flex-1 px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors`,children:`Try again`}),(0,N.jsx)(`button`,{onClick:()=>window.location.reload(),className:`flex-1 px-4 py-2 bg-secondary text-secondary-foreground rounded-md hover:bg-secondary/90 transition-colors`,children:`Reload page`})]}),(0,N.jsx)(`a`,{href:`/issues`,className:`block text-center text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Report this problem`})]})}):this.props.children}},la=class{static parseInput(e){let t=/(\B-\w+:[^\s"]+)|(\b\w+:[^\s"]+)|(".*?")|(\S+)/g,n=[],r;for(;(r=t.exec(e))!==null;)if(r[1]||r[2]){let[e,...t]=(r[1]||r[2]).split(`:`);n.push({key:e,value:t.join(`:`)})}else r[3]?n.push(r[3].replace(/"/g,``)):r[4]&&n.push(r[4]);return n}},ua=class{set;capacity;constructor(e){this.set=new Set,this.capacity=e}add(e){if(!this.set.has(e)){if(this.set.size>=this.capacity){let{value:e,done:t}=this.set.values().next();t||this.set.delete(e)}this.set.add(e)}}has(e){return this.set.has(e)}[Symbol.iterator](){return this.set.values()}},da=class e{_relays=new Map;opts;constructor(e){this.opts=e}relay(e){let t=this._relays.get(e);if(t)return t;{let t=this.opts.open(e);return this._relays.set(e,t),t}}group(t){return new e({open:e=>this.relay(e),reqRouter:e=>new Map(t.map(t=>[t,e])),eventRouter:()=>t,eoseTimeout:this.opts.eoseTimeout})}get relays(){return this._relays}async*req(e,t){let n=new AbortController,r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=t?.relays?new Map(t.relays.map(t=>[t,e])):await this.opts.reqRouter(e);if(i.size<1)return;let a=new nt(r),o=new Set,s=new Set,c=new ua(1e3),l=t?.eoseTimeout,u,d,f=[];for(let[e,t]of i.entries()){let p=this.relay(e),m=(async()=>{try{for await(let f of p.req(t,{signal:r}))if(f[0]===`EOSE`&&(o.add(e),o.size===1&&l!==void 0&&l>0&&(d=performance.now(),u===void 0&&(u=setTimeout(()=>{n.abort()},l))),d!==void 0&&l!==void 0&&l>0&&performance.now()-d>=l&&n.abort(),o.size===i.size&&a.push(f)),f[0]===`CLOSED`&&(s.add(e),s.size===i.size&&a.push(f)),f[0]===`EVENT`){d!==void 0&&l!==void 0&&l>0&&performance.now()-d>=l&&n.abort();let[,,e]=f;c.has(e.id)||(c.add(e.id),a.push(f))}}catch{}})();f.push(m)}try{for await(let e of a)yield e}finally{u!==void 0&&clearTimeout(u),n.abort(),await Promise.allSettled(f)}}async event(e,t){let n=t?.relays??await this.opts.eventRouter(e);n.length&&await Promise.any(n.map(n=>this.relay(n).event(e,t)))}async query(e,t){let n=new Be;if(e.reduce((e,t)=>e+dt(t),0)===0)return[];let r=this.opts.eoseTimeout??1e3;try{for await(let i of this.req(e,{...t,eoseTimeout:r}))if(i[0]===`EOSE`||(i[0]===`EVENT`&&n.add(i[2]),i[0]===`CLOSED`))break}catch{}return e.some(e=>typeof e.search==`string`)?n.toReceivedArray():n.toArray()}async close(){await Promise.all([...this._relays.values()].map(e=>e.close()))}async[Symbol.asyncDispose](){await this.close()}},fa=class extends at{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??tt(r,t),a=this.get(i);return a||(a=new He({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){it.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Ye(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Ye(e,t)):t}notify(e){it.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){it.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){it.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},pa=class extends at{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Nt({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=ma(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=ma(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=ma(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=ma(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){it.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Ke(t,e))}findAll(e={}){return this.getAll().filter(t=>Ke(e,t))}notify(e){it.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return it.batch(()=>Promise.all(e.map(e=>e.continue().catch(Ze))))}};function ma(e){return e.options.scope?.id}var ha=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new fa,this.#t=e.mutationCache||new pa,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=et.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=We.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Ve(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Qe(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return it.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;it.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return it.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=it.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Ze).catch(Ze)}invalidateQueries(e,t={}){return it.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=it.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Ze)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Ze)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Ve(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ze).catch(Ze)}fetchInfiniteQuery(e){return e.behavior=Ft(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ze).catch(Ze)}ensureInfiniteQueryData(e){return e.behavior=Ft(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return We.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set($e(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{rt(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set($e(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{rt(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=tt(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Je&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},ga=(e,t)=>e._w===t._w?e._p-t._p:e._w-t._w,_a={base:-10,title:10},va={critical:-8,high:-1,low:2},ya={meta:{"content-security-policy":-30,charset:-20,viewport:-15},link:{preconnect:20,stylesheet:60,preload:70,modulepreload:70,prefetch:90,"dns-prefetch":90,prerender:90},script:{async:30,defer:80,sync:50},style:{imported:40,sync:60}},ba=/@import/,xa=e=>e===``||e===!0;function Sa(e,t){if(typeof t.tagPriority==`number`)return t.tagPriority;let n=100,r=va[t.tagPriority]||0,i=e.resolvedOptions.disableCapoSorting?{link:{},script:{},style:{}}:ya;if(t.tag in _a)n=_a[t.tag];else if(t.tag===`meta`){let e=t.props[`http-equiv`]===`content-security-policy`?`content-security-policy`:t.props.charset?`charset`:t.props.name===`viewport`?`viewport`:null;e&&(n=ya.meta[e])}else if(t.tag===`link`&&t.props.rel)n=i.link[t.props.rel];else if(t.tag===`script`){let e=String(t.props.type);xa(t.props.async)?n=i.script.async:t.props.src&&!xa(t.props.defer)&&!xa(t.props.async)&&e!==`module`&&!e.endsWith(`json`)||t.innerHTML&&!e.endsWith(`json`)?n=i.script.sync:(xa(t.props.defer)&&t.props.src&&!xa(t.props.async)||e===`module`)&&(n=i.script.defer)}else t.tag===`style`&&(n=t.innerHTML&&ba.test(t.innerHTML)?i.style.imported:i.style.sync);return(n||100)+r}function Ca(e={}){return Gt(t=>(t.push({meta:[{name:`twitter:card`,content:e.twitterCard||`summary_large_image`,tagPriority:`low`},{property:`og:title`,tagPriority:`low`,"data-infer":``},{property:`og:description`,tagPriority:`low`,"data-infer":``}]}),{key:`infer-seo-meta`,hooks:{"tags:beforeResolve":({tagMap:n})=>{let r=t._titleTemplate||t._title,i=n.get(`meta:og:title`);i?.props[`data-infer`]!==void 0&&(typeof r==`function`&&(r=r(t._title)),i.props.content=e.ogTitle?e.ogTitle(r):r||``,i.processTemplateParams=!0);let a=n.get(`meta:description`)?.props?.content,o=n.get(`meta:og:description`);o?.props[`data-infer`]!==void 0&&(o.props.content=e.ogDescription?e.ogDescription(a):a||``,o.processTemplateParams=!0)}}}))}function wa(e,t={},n){for(let r in e){let i=e[r],a=n?`${n}:${r}`:r;typeof i==`object`&&i?wa(i,t,a):typeof i==`function`&&(t[a]=i)}return t}var Ta=(()=>{if(console.createTask)return console.createTask;let e={run:e=>e()};return()=>e})();function Ea(e,t,n,r){for(let i=n;ie[i](...t)):e[i](...t);if(n instanceof Promise)return n.then(()=>Ea(e,t,i+1,r))}catch(e){return Promise.reject(e)}}function Da(e,t,n){if(e.length>0)return Ea(e,t,0,Ta(n))}function Oa(e,t,n){if(e.length>0){let r=Ta(n);return Promise.all(e.map(e=>r.run(()=>e(...t))))}}function ka(e,t){for(let n of[...e])n(t)}var Aa=class{_hooks;_before;_after;_deprecatedHooks;_deprecatedMessages;constructor(){this._hooks={},this._before=void 0,this._after=void 0,this._deprecatedMessages=void 0,this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this),this.callHookWith=this.callHookWith.bind(this)}hook(e,t,n={}){if(!e||typeof t!=`function`)return()=>{};let r=e,i;for(;this._deprecatedHooks[e];)i=this._deprecatedHooks[e],e=i.to;if(i&&!n.allowDeprecated){let e=i.message;e||=`${r} hook has been deprecated`+(i.to?`, please use ${i.to}`:``),this._deprecatedMessages||=new Set,this._deprecatedMessages.has(e)||(console.warn(e),this._deprecatedMessages.add(e))}if(!t.name)try{Object.defineProperty(t,"name",{get:()=>`_`+e.replace(/\W+/g,`_`)+`_hook_cb`,configurable:!0})}catch{}return this._hooks[e]=this._hooks[e]||[],this._hooks[e].push(t),()=>{t&&=(this.removeHook(e,t),void 0)}}hookOnce(e,t){let n,r=(...e)=>(typeof n==`function`&&n(),n=void 0,r=void 0,t(...e));return n=this.hook(e,r),n}removeHook(e,t){let n=this._hooks[e];if(n){let r=n.indexOf(t);r!==-1&&n.splice(r,1),n.length===0&&(this._hooks[e]=void 0)}}deprecateHook(e,t){this._deprecatedHooks[e]=typeof t==`string`?{to:t}:t;let n=this._hooks[e]||[];this._hooks[e]=void 0;for(let t of n)this.hook(e,t)}deprecateHooks(e){for(let t in e)this.deprecateHook(t,e[t])}addHooks(e){let t=wa(e),n=Object.keys(t).map(e=>this.hook(e,t[e]));return()=>{for(let e of n)e();n.length=0}}removeHooks(e){let t=wa(e);for(let e in t)this.removeHook(e,t[e])}removeAllHooks(){this._hooks={}}callHook(e,...t){return this.callHookWith(Da,e,t)}callHookParallel(e,...t){return this.callHookWith(Oa,e,t)}callHookWith(e,t,n){let r=this._before||this._after?{name:t,args:n,context:{}}:void 0;this._before&&ka(this._before,r);let i=e(this._hooks[t]?[...this._hooks[t]]:[],n,t);return i instanceof Promise?i.finally(()=>{this._after&&r&&ka(this._after,r)}):(this._after&&r&&ka(this._after,r),i)}beforeEach(e){return this._before=this._before||[],this._before.push(e),()=>{if(this._before!==void 0){let t=this._before.indexOf(e);t!==-1&&this._before.splice(t,1)}}}afterEach(e){return this._after=this._after||[],this._after.push(e),()=>{if(this._after!==void 0){let t=this._after.indexOf(e);t!==-1&&this._after.splice(t,1)}}}};function ja(){return new Aa}var Ma=[`name`,`property`,`http-equiv`],Na=new Set([`viewport`,`description`,`keywords`,`robots`]);function Pa(e){let t=e.split(`:`);return t.length?Wt.has(t[1]):!1}function Fa(e){let{props:t,tag:n}=e;if(Ht.has(n))return n;if(n===`link`&&t.rel===`canonical`)return`canonical`;if(n===`link`&&t.rel===`alternate`){let e=t.hreflang||t.type;if(e)return`alternate:${e}`}if(t.charset)return`charset`;if(e.tag===`meta`){for(let r of Ma)if(t[r]!==void 0){let i=t[r],a=i&&typeof i==`string`&&i.includes(`:`),o=i&&Na.has(i);return`${n}:${i}${!(a||o)&&e.key?`:key:${e.key}`:``}`}}if(e.key)return`${n}:key:${e.key}`;if(t.id)return`${n}:id:${t.id}`;if(n===`link`&&t.rel===`alternate`)return`alternate:${t.href||``}`;if(zt.has(n)){let t=e.textContent||e.innerHTML;if(t)return`${n}:content:${t}`}}function Ia(e){return e._h||e._d||e.textContent||e.innerHTML||`${e.tag}:${Object.entries(e.props).map(([e,t])=>`${e}:${String(t)}`).join(`,`)}`}function La(e,t,n){typeof e==`function`&&(!n||n!==`titleTemplate`&&(n[0]!==`o`||n[1]!==`n`))&&(e=e());let r=t?t(n,e):e;if(Array.isArray(r))return r.map(e=>La(e,t));if(r?.constructor===Object){let e={};for(let n of Object.keys(r))e[n]=La(r[n],t,n);return e}return r}function Ra(e,t){let n=e===`style`?new Map:new Set;function r(t){if(t==null||t===void 0)return;let r=String(t).trim();if(r){if(e===`style`){let[e,...t]=r.split(`:`).map(e=>e?e.trim():``);e&&t.length&&n.set(e,t.join(`:`))}else r.split(` `).filter(Boolean).forEach(e=>n.add(e))}}return typeof t==`string`?e===`style`?t.split(`;`).forEach(r):r(t):Array.isArray(t)?t.forEach(e=>r(e)):t&&typeof t==`object`&&Object.entries(t).forEach(([t,i])=>{i&&i!==`false`&&(e===`style`?n.set(String(t).trim(),String(i)):r(t))}),n}function za(e,t){if(e.props=e.props||{},!t)return e;if(e.tag===`templateParams`)return e.props=t,e;let n=Rt.has(e.tag)||e.tag===`htmlAttrs`||e.tag===`bodyAttrs`;return Object.entries(t).forEach(([r,i])=>{if(r===`__proto__`||r===`constructor`||r===`prototype`)return;if(i===null){e.props[r]=null;return}if(r===`class`||r===`style`){e.props[r]=Ra(r,i);return}if(Kt.has(r)){if((r===`textContent`||r===`innerHTML`)&&typeof i==`object`){let n=t.type;if(t.type||(n=`application/json`),!n?.endsWith(`json`)&&n!==`speculationrules`)return;t.type=n,e.props.type=n,e[r]=JSON.stringify(i)}else e[r]=i;return}let a=r.startsWith(`data-`),o=n&&!a?r.toLowerCase():r,s=String(i),c=e.tag===`meta`&&o===`content`;s===`true`||s===``?e.props[o]=a||c?s:!0:!i&&a&&s===`false`?e.props[o]=`false`:i!==void 0&&(e.props[o]=i)}),e}function Ba(e,t){let n=za({tag:e,props:{}},typeof t==`object`&&typeof t!=`function`?t:{[e===`script`||e===`noscript`||e===`style`?`innerHTML`:`textContent`]:t});return n.key&&Vt.has(n.tag)&&(n.props[`data-hid`]=n._h=n.key),n.tag===`script`&&typeof n.innerHTML==`object`&&(n.innerHTML=JSON.stringify(n.innerHTML),n.props.type=n.props.type||`application/json`),Array.isArray(n.props.content)?n.props.content.map(e=>({...n,props:{...n.props,content:e}})):n}function Va(e,t){if(!e)return[];typeof e==`function`&&(e=e());let n=(e,n)=>{for(let r=0;r{if(t!==void 0)for(let n of Array.isArray(t)?t:[t])r.push(Ba(e,n))}),r.flat()}function Ha(e,t){let n=typeof t==`function`?t(e):t,r=n.key||String(e.plugins.size+1);e.plugins.get(r)||(e.plugins.set(r,n),e.hooks.addHooks(n.hooks||{}))}function Ua(e={}){let t=ja();t.addHooks(e.hooks||{});let n=!e.document,r=new Map,i=new Map,a=new Set,o={_entryCount:1,plugins:i,dirty:!1,resolvedOptions:e,hooks:t,ssr:n,entries:r,headEntries(){return[...r.values()]},use:e=>Ha(o,e),push(e,i){let s={...i||{}};delete s.head;let c=s._index??o._entryCount++,l={_i:c,input:e,options:s},u={_poll(e=!1){o.dirty=!0,!e&&a.add(c),t.callHook(`entries:updated`,o)},dispose(){r.delete(c)&&o.invalidate()},patch(e){(!s.mode||s.mode===`server`&&n||s.mode===`client`&&!n)&&(l.input=e,r.set(c,l),u._poll())}};return u.patch(e),u},async resolveTags(){let n={tagMap:new Map,tags:[],entries:[...o.entries.values()]};for(await t.callHook(`entries:resolve`,n);a.size;){let n=a.values().next().value;a.delete(n);let i=r.get(n);if(i){let n={tags:Va(i.input,e.propResolvers||[]).map(e=>Object.assign(e,i.options)),entry:i};await t.callHook(`entries:normalize`,n),i._tags=n.tags.map((e,t)=>(e._w=Sa(o,e),e._p=(i._i<<10)+t,e._d=Fa(e),e._d||(e._h=Ia(e)),e))}}let i=!1;n.entries.flatMap(e=>(e._tags||[]).map(e=>({...e,props:{...e.props}}))).sort(ga).reduce((e,t)=>{let n=t._d||t._h;if(!e.has(n))return e.set(n,t);let r=e.get(n);if((t?.tagDuplicateStrategy||(Jt.has(t.tag)?`merge`:null)||(t.key&&t.key===r.key?`merge`:null))===`merge`){let i={...r.props};Object.entries(t.props).forEach(([e,t])=>i[e]=e===`style`?new Map([...r.props.style||new Map,...t]):e===`class`?new Set([...r.props.class||new Set,...t]):t),e.set(n,{...t,props:i})}else t._p>>10==r._p>>10&&t.tag===`meta`&&Pa(n)?(e.set(n,Object.assign([...Array.isArray(r)?r:[r],t],t)),i=!0):(t._w===r._w?t._p>r._p:t?._wHa(o,e)),o.hooks.callHook(`init`,o),e.init?.forEach(e=>e&&o.push(e)),o}async function Wa(e,t={}){let n=t.document||e.resolvedOptions.document;if(!n||!e.dirty)return;let r={shouldRender:!0,tags:[]};if(await e.hooks.callHook(`dom:beforeRender`,r),r.shouldRender)return e._domUpdatePromise||=new Promise(async t=>{let r=new Map,i=new Promise(t=>{e.resolveTags().then(e=>{t(e.map(e=>{let t=r.get(e._d)||0,n={tag:e,id:(t?`${e._d}:${t}`:e._d)||e._h,shouldRender:!0};return e._d&&Pa(e._d)&&r.set(e._d,t+1),n}))})}),a=e._dom;if(!a){a={title:n.title,elMap:new Map().set(`htmlAttrs`,n.documentElement).set(`bodyAttrs`,n.body)};for(let e of[`body`,`head`]){let t=n[e]?.children;for(let e of t){let t=e.tagName.toLowerCase();if(!Rt.has(t))continue;let n=za({tag:t,props:{}},{innerHTML:e.innerHTML,...e.getAttributeNames().reduce((t,n)=>(t[n]=e.getAttribute(n),t),{})||{}});if(n.key=e.getAttribute(`data-hid`)||void 0,n._d=Fa(n)||Ia(n),a.elMap.has(n._d)){let t=1,r=n._d;for(;a.elMap.has(r);)r=`${n._d}:${t++}`;a.elMap.set(r,e)}else a.elMap.set(n._d,e)}}}a.pendingSideEffects={...a.sideEffects},a.sideEffects={};function o(e,t,n){let r=`${e}:${t}`;a.sideEffects[r]=n,delete a.pendingSideEffects[r]}function s({id:e,$el:t,tag:r}){let i=r.tag.endsWith(`Attrs`);a.elMap.set(e,t),i||(r.textContent&&r.textContent!==t.textContent&&(t.textContent=r.textContent),r.innerHTML&&r.innerHTML!==t.innerHTML&&(t.innerHTML=r.innerHTML),o(e,`el`,()=>{t?.remove(),a.elMap.delete(e)}));for(let a in r.props){if(!Object.prototype.hasOwnProperty.call(r.props,a))continue;let s=r.props[a];if(a.startsWith(`on`)&&typeof s==`function`){let e=t?.dataset;if(e&&e[`${a}fired`]){let e=a.slice(0,-5);s.call(t,new Event(e.substring(2)))}t.getAttribute(`data-${a}`)!==``&&((r.tag===`bodyAttrs`?n.defaultView:t).addEventListener(a.substring(2),s.bind(t)),t.setAttribute(`data-${a}`,``));continue}let c=`attr:${a}`;if(a===`class`){if(!s)continue;for(let n of s)i&&o(e,`${c}:${n}`,()=>t.classList.remove(n)),!t.classList.contains(n)&&t.classList.add(n)}else if(a===`style`){if(!s)continue;for(let[n,r]of s)o(e,`${c}:${n}`,()=>{t.style.removeProperty(n)}),t.style.setProperty(n,r)}else s!==!1&&s!==null&&(t.getAttribute(a)!==s&&t.setAttribute(a,s===!0?``:String(s)),i&&o(e,c,()=>t.removeAttribute(a)))}}let c=[],l={bodyClose:void 0,bodyOpen:void 0,head:void 0},u=await i;for(let e of u){let{tag:t,shouldRender:r,id:i}=e;if(r){if(t.tag===`title`){n.title=t.textContent,o(`title`,``,()=>n.title=a.title);continue}e.$el=e.$el||a.elMap.get(i),e.$el?s(e):Rt.has(t.tag)&&c.push(e)}}for(let e of c){let t=e.tag.tagPosition||`head`;e.$el=n.createElement(e.tag.tag),s(e),l[t]=l[t]||n.createDocumentFragment(),l[t].appendChild(e.$el)}for(let t of u)await e.hooks.callHook(`dom:renderTag`,t,n,o);l.head&&n.head.appendChild(l.head),l.bodyOpen&&n.body.insertBefore(l.bodyOpen,n.body.firstChild),l.bodyClose&&n.body.appendChild(l.bodyClose);for(let e in a.pendingSideEffects)a.pendingSideEffects[e]();e._dom=a,await e.hooks.callHook(`dom:rendered`,{renders:u}),t()}).finally(()=>{e._domUpdatePromise=void 0,e.dirty=!1}),e._domUpdatePromise}function Ga(e={}){let t=e.domOptions?.render||Wa;e.document=e.document||(typeof window<`u`?document:void 0);let n=e.document?.head.querySelector(`script[id="unhead:payload"]`)?.innerHTML||!1;return Ua({...e,plugins:[...e.plugins||[],{key:`client`,hooks:{"entries:updated":t}}],init:[n?JSON.parse(n):!1,...e.init||[]]})}function Ka(e,t){let n=0;return()=>{let r=++n;t(()=>{n===r&&e()})}}function qa(e={}){let t=Ga({domOptions:{render:Ka(()=>Wa(t),e=>setTimeout(e,0))},...e});return t}function Ja({children:e,head:t}){return(0,M.createElement)(Ut.Provider,{value:t||qa()},e)}function Ya(e){let{children:t,storageKey:n,defaultConfig:r}=e,[i,a]=Yt(n,{},{serialize:JSON.stringify,deserialize:e=>{let t=JSON.parse(e);if(typeof t!=`object`||!t)return{};let n={};for(let e of Object.keys(t)){let r=rn.shape[e];if(r){let i=r.safeParse(t[e]);i.success&&(n[e]=i.data)}}if(!n.blossomServerMetadata){let e=t.blossomServers;if(Array.isArray(e)){let t=ut(ft().url()).safeParse(e);t.success&&t.data.length>0&&(n.blossomServerMetadata={servers:t.data,updatedAt:0})}}return n}}),o=e=>{a(e)},s={...r,...i,translateWorkerUrl:i.translateWorkerUrl?.trim()?i.translateWorkerUrl:r.translateWorkerUrl,feedSettings:{...r.feedSettings,...i.feedSettings}},c={config:s,updateConfig:o};return Xa(s.theme),(0,N.jsx)(Xt.Provider,{value:c,children:t})}function Xa(e){(0,M.useLayoutEffect)(()=>{function t(){document.documentElement.className=Qt(e),document.body.removeAttribute(`style`)}if(t(),e===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}},[e])}var Za=8e3;function Qa(e,t){try{return localStorage.getItem(sn(e,`sync-done:${t}`))===`1`}catch{return!1}}function $a(){let{nostr:e}=ct(),{user:t}=cn(),{config:n,updateConfig:r}=Zt(),i=xt(),[a,o]=(0,M.useState)(()=>t&&Qa(n.appId,t.pubkey)?`complete`:`idle`),s=(0,M.useRef)(!1),c=(0,M.useCallback)(()=>{if(t)try{localStorage.setItem(sn(n.appId,`sync-done:${t.pubkey}`),`1`)}catch{}},[t,n.appId]);return(0,M.useEffect)(()=>{if(!t){o(`idle`),s.current=!1;return}if(Qa(n.appId,t.pubkey)){o(`complete`);return}if(s.current)return;s.current=!0,o(`syncing`);let a=new AbortController,l=setTimeout(()=>a.abort(),Za);return(async()=>{let s=!1;try{let[o,c,l,u]=await Promise.all([e.query([{kinds:[10002],authors:[t.pubkey],limit:1}],{signal:a.signal}).catch(()=>[]),e.query([{kinds:[10063],authors:[t.pubkey],limit:1}],{signal:a.signal}).catch(()=>[]),e.query([{kinds:[30078],authors:[t.pubkey],"#d":[`${n.appId}/metadata`],limit:1}],{signal:a.signal}).catch(()=>[]),e.query([{kinds:[1e4],authors:[t.pubkey],limit:1}],{signal:a.signal}).catch(()=>[])]);if(o.length>0){let e=o[0];if(i.setQueryData([`relayList`,t.pubkey],e),e.created_at>n.relayMetadata.updatedAt){let t=e.tags.filter(([e])=>e===`r`).map(([,e,t])=>({url:e.replace(/\/+$/,``),read:!t||t===`read`,write:!t||t===`write`}));t.length>0&&(r(n=>({...n,relayMetadata:{relays:t,updatedAt:e.created_at}})),s=!0)}}if(c.length>0){let e=c[0];if(i.setQueryData([`blossomServerList`,t.pubkey],e),e.created_at>n.blossomServerMetadata.updatedAt){let t=on(e);t.length>0&&(r(n=>({...n,blossomServerMetadata:{servers:t,updatedAt:e.created_at}})),s=!0)}}if(l.length>0&&l[0].content&&t.signer.nip44){let e=l[0];try{let n=await t.signer.nip44.decrypt(t.pubkey,e.content),a=JSON.parse(n),o=en.safeParse(a);o.success||console.warn(`Encrypted settings failed validation during initial sync:`,o.error.issues);let c=o.success?o.data:{};r(e=>{let t={...e};return c.theme&&(t.theme=c.theme),c.useAppRelays!==void 0&&(t.useAppRelays=c.useAppRelays),c.useUserRelays!==void 0&&(t.useUserRelays=c.useUserRelays),c.feedSettings&&(t.feedSettings={...e.feedSettings,...c.feedSettings}),c.contentWarningPolicy&&(t.contentWarningPolicy=c.contentWarningPolicy),c.sidebarOrder&&c.sidebarOrder.length>0&&(t.sidebarOrder=c.sidebarOrder),c.homePage&&(t.homePage=c.homePage),c.corsProxy&&(t.corsProxy=c.corsProxy),c.faviconUrl&&(t.faviconUrl=c.faviconUrl),c.linkPreviewUrl&&(t.linkPreviewUrl=c.linkPreviewUrl),c.translateWorkerUrl&&(t.translateWorkerUrl=c.translateWorkerUrl),t}),i.setQueryData([`encryptedSettings`,t.pubkey],e),i.setQueryData([`parsedSettings`,e.id],c),c.lastSync&&an(t.pubkey,c.lastSync),s=!0}catch(e){console.error(`Failed to decrypt settings during initial sync:`,e),s=!0}}if(u.length>0){let e=u[0];i.setQueryData([`muteList`,t.pubkey],e);let r=_n(e.tags),a=[];if(e.content)try{let n=e.content.includes(`?iv=`),r=null;if(n&&t.signer.nip04?r=await t.signer.nip04.decrypt(t.pubkey,e.content):!n&&t.signer.nip44&&(r=await t.signer.nip44.decrypt(t.pubkey,e.content)),r){let e=JSON.parse(r);a=_n(e)}}catch(e){console.error(`Failed to decrypt mute list during initial sync:`,e)}let o=new Set,c=[];for(let e of[...r,...a]){let t=`${e.type}:${e.value}`;o.has(t)||(o.add(t),c.push(e))}i.setQueryData([`muteItems`,e.id],c),hn(n.appId,t.pubkey,c),s=!0}}catch(e){e instanceof Error&&e.name===`AbortError`?console.warn(`Initial sync timed out`):console.error(`Initial sync failed:`,e)}clearTimeout(l),s?(o(`found`),setTimeout(()=>{c(),o(`complete`)},1200)):o(`not-found`)})(),()=>{clearTimeout(l),a.abort()}},[t,e,n.appId,n.relayMetadata.updatedAt,n.blossomServerMetadata.updatedAt,r,i,c]),{phase:a,markComplete:(0,M.useCallback)(()=>{c(),o(`complete`)},[c])}}function eo(){return $a(),Lt(),null}var to;(function(e){e[e.Sunday=1]=`Sunday`,e[e.Monday=2]=`Monday`,e[e.Tuesday=3]=`Tuesday`,e[e.Wednesday=4]=`Wednesday`,e[e.Thursday=5]=`Thursday`,e[e.Friday=6]=`Friday`,e[e.Saturday=7]=`Saturday`})(to||={});var no=bn(`LocalNotifications`,{web:()=>D(()=>import(`./web-Vqru6ABN.js`).then(e=>new e.LocalNotificationsWeb),__vite__mapDeps([3,4]))}),ro=[1,6,16,7,9735,8333,1111,1222,1244];function io(e){let t=e??{},n=[];return t.reactions!==!1&&n.push(7),t.reposts!==!1&&n.push(6,16),t.zaps!==!1&&n.push(9735,8333),t.mentions!==!1&&n.push(1),t.comments!==!1&&n.push(1111,1222,1244),n.length>0?n:[...ro]}var ao=bn(`DittoNotification`);function oo(){let{user:e}=cn(),{config:t}=Zt(),{settings:n}=nn(),{data:r}=Cn(),i=n?.notificationPreferences,a=n?.notificationsEnabled??!0,o=n?.notificationStyle??`push`,s=(0,M.useMemo)(()=>io(i),[i]),c=(0,M.useMemo)(()=>r?.pubkeys??[],[r?.pubkeys]),l=i?.onlyFollowing===!0&&c.length>0?c:void 0;(0,M.useEffect)(()=>{Sn.isNativePlatform()&&(async()=>{try{let{display:e}=await no.checkPermissions();(e===`prompt`||e===`prompt-with-rationale`)&&await no.requestPermissions()}catch{}})()},[]),(0,M.useEffect)(()=>{if(!Sn.isNativePlatform())return;if(!e||!a){ao.configure({});return}let n=En(t.relayMetadata,t.useAppRelays,t.useUserRelays).relays.filter(e=>e.read).map(e=>e.url);n.length!==0&&ao.configure({userPubkey:e.pubkey,relayUrls:n,enabledKinds:s,notificationStyle:o,...l?{authors:l}:{}})},[e,t.relayMetadata,t.useAppRelays,t.useUserRelays,a,o,s,l])}function so(){return oo(),null}var co=`events`,lo=1,uo={createdAt:`by-created_at`,pubkey:`by-pubkey`,kind:`by-kind`,pubkeyKind:`by-pubkey-kind`,tag:`by-tag`},fo=class e{pendingWrites=new Map;pendingResolvers=[];flushScheduled=!1;indexTags;db;constructor(t,n={}){this.db=e.openDatabase(t),this.indexTags=n.indexTags??e.indexTags}static async openDatabase(e){if(typeof indexedDB>`u`)return null;try{return await Ge(e,lo,{upgrade(e){let t=e.createObjectStore(co,{keyPath:`id`});t.createIndex(uo.createdAt,`created_at`),t.createIndex(uo.pubkey,[`pubkey`,`created_at`]),t.createIndex(uo.kind,[`kind`,`created_at`]),t.createIndex(uo.pubkeyKind,[`pubkey`,`kind`,`created_at`]),t.createIndex(uo.tag,`_tagsCreated`,{multiEntry:!0})}})}catch{return null}}getDB(){return this.db}static indexTags(e){return e.tags.filter(([e,t])=>e.length===1&&!!t&&t.length<200)}event(e,t){if(yt.ephemeral(e.kind))return Promise.resolve();this.pendingWrites.set(e.id,e);let n=new Promise(e=>{this.pendingResolvers.push(e)});return this.scheduleFlush(),n}scheduleFlush(){if(this.flushScheduled)return;this.flushScheduled=!0;let e=()=>void this.flushWrites();typeof requestIdleCallback==`function`?requestIdleCallback(e,{timeout:1e3}):setTimeout(e,0)}async flushWrites(){this.flushScheduled=!1;let e=[...this.pendingWrites.values()],t=this.pendingResolvers;this.pendingWrites=new Map,this.pendingResolvers=[];let n=await this.getDB();if(!n||e.length===0){for(let e of t)e();return}try{let t=n.transaction(co,`readwrite`),r=t.objectStore(co),i=await this.resolveSupersession(r,e);for(let t of e){let e=i.get(t.id);if(e!==null){if(e)for(let t of e)r.delete(t);r.put(this.toStored(t))}}await this.applyDeletions(r,e),await t.done}catch{}finally{for(let e of t)e()}}async resolveSupersession(t,n){let r=new Map,i=new Map;for(let t of n){if(!yt.replaceable(t.kind)&&!yt.addressable(t.kind)){r.set(t.id,void 0);continue}let n=yt.addressable(t.kind)?e.getDTag(t):``,a=`${t.kind}:${t.pubkey}:${n}`;(i.get(a)??i.set(a,[]).get(a)).push(t)}let a=[...i.values()],o=await Promise.all(a.map(([e])=>t.index(uo.pubkeyKind).getAll(IDBKeyRange.bound([e.pubkey,e.kind,0],[e.pubkey,e.kind,1/0]))));return a.forEach((t,n)=>{let i=yt.addressable(t[0].kind)?e.getDTag(t[0]):``,a=o[n].filter(t=>!yt.addressable(t.kind)||e.getDTag(t)===i),s=t.reduce((t,n)=>e.isNewer(n,t)?n:t);for(let e of t)e!==s&&r.set(e.id,null);let c=[],l=!1;for(let t of a)if(t.id!==s.id){if(e.isNewer(t,s)){l=!0;break}c.push(t.id)}r.set(s.id,l?null:c)}),r}async applyDeletions(t,n){let r=n.filter(e=>e.kind===5);if(r.length!==0){for(let n of r)for(let[r,i]of n.tags)if(r===`e`){if(!i)continue;let e=await t.get(i);e&&e.pubkey===n.pubkey&&t.delete(i)}else if(r===`a`){if(!i)continue;let[r,a,...o]=i.split(`:`),s=Number(r);if(!Number.isInteger(s)||a!==n.pubkey)continue;let c=o.join(`:`),l=await t.index(uo.pubkeyKind).getAll(IDBKeyRange.bound([a,s,0],[a,s,1/0]));for(let r of l)yt.addressable(r.kind)&&e.getDTag(r)!==c||r.created_at>n.created_at||t.delete(r.id)}}}async query(t,n){let r=await this.getDB();if(!r)return[];let i=new Map;try{let a=r.transaction(co,`readonly`).objectStore(co),o=await Promise.all(t.map(e=>this.queryFilter(a,new po(e),n?.signal)));for(let t of o)for(let n of t)i.set(n.id,e.fromStored(n))}catch(e){if(n?.signal?.aborted)throw e;return[]}return[...i.values()].sort(e.compareNewest)}async queryFilter(t,n,r){if(n.neverMatch)return[];let i=n.limit??1/0;if(i<=0)return[];r?.throwIfAborted();let a=e.planScan(n),o=e=>a.indexOnly?n.matchesTime(e.created_at):n.matches(e);if(a.ids){let n=(await Promise.all(a.ids.map(e=>t.get(e)))).filter(e=>e!==void 0&&o(e));return n.sort(e.compareNewest),n.length>i?n.slice(0,i):n}if(n.searchKeywords)return e.searchScan(t,a,o,i,r);if(i===1/0){let n=await Promise.all(a.cursors.map(({indexName:e,range:n})=>(e?t.index(e):t).getAll(n)));r?.throwIfAborted();let i=a.disjoint?void 0:new Set,s=[];for(let e of n)for(let t of e){if(i){if(i.has(t.id))continue;i.add(t.id)}o(t)&&s.push(t)}return s.sort(e.compareNewest),s}let s=(await Promise.all(a.cursors.map(({indexName:e,range:n})=>(e?t.index(e):t).openCursor(n,`prev`)))).filter(e=>e!==null),c=a.disjoint?void 0:new Set,l=[];for(;s.length>0&&l.lengths[e].value.created_at&&(e=t);let t=s[e],n=t.value;!c?.has(n.id)&&o(n)&&(c?.add(n.id),l.push(n)),await t.continue()===null&&s.splice(e,1)}return l.sort(e.compareNewest),l}static async searchScan(t,n,r,i,a){let o=await Promise.all(n.cursors.map(n=>e.searchScanCursor(t,n,r,i,a))),s=n.disjoint?void 0:new Set,c=[];for(let e of o)for(let t of e){if(s){if(s.has(t.id))continue;s.add(t.id)}c.push(t)}return c.sort(e.compareNewest),c.length>i?c.slice(0,i):c}static async searchScanCursor(e,{indexName:t,range:n},r,i,a){let o=t?e.index(t):e,s=[],c=await o.openKeyCursor(n,`prevunique`);for(;c!==null&&s.length=0&&s.length0){let r=e.tags.reduce((e,t)=>t.values.length({indexName:uo.tag,range:IDBKeyRange.bound([r.name,e,t],[r.name,e,n])}))}}if(e.authors&&e.kinds&&e.authors.length*e.kinds.length<1e3){let r=[];for(let i of e.authors)for(let a of e.kinds)r.push({indexName:uo.pubkeyKind,range:IDBKeyRange.bound([i,a,t],[i,a,n])});return{indexOnly:e.indexOnly,disjoint:!0,cursors:r}}return e.authors?{indexOnly:e.indexOnly&&!e.kinds,disjoint:!0,cursors:e.authors.map(e=>({indexName:uo.pubkey,range:IDBKeyRange.bound([e,t],[e,n])}))}:e.kinds?{indexOnly:e.indexOnly,disjoint:!0,cursors:e.kinds.map(e=>({indexName:uo.kind,range:IDBKeyRange.bound([e,t],[e,n])}))}:{indexOnly:e.indexOnly,disjoint:!0,cursors:[{indexName:uo.createdAt,range:IDBKeyRange.bound(t,n)}]}}async count(t,n){let r=await this.getDB();if(!r)return{count:0,approximate:!1};if(t.length===1){let n=new po(t[0]);if(n.neverMatch)return{count:0,approximate:!1};if(n.limit===void 0&&n.indexOnly){let t=e.planScan(n);if(t.disjoint&&!t.ids)try{let e=r.transaction(co,`readonly`).objectStore(co);return{count:(await Promise.all(t.cursors.map(({indexName:t,range:n})=>(t?e.index(t):e).count(n)))).reduce((e,t)=>e+t,0),approximate:!1}}catch{}}}return{count:(await this.query(t,n)).length,approximate:!1}}async remove(e,t){let n=await this.getDB();if(!n)return;let r=await this.query(e,t);try{let e=n.transaction(co,`readwrite`);await Promise.all(r.map(t=>e.store.delete(t.id))),await e.done}catch{}}async close(){(await this.getDB())?.close()}toStored(e){let t=[],n=new Set;for(let[r,i]of this.indexTags(e)){if(typeof r!=`string`||typeof i!=`string`)continue;let a=`${r}\0${i}`;n.has(a)||(n.add(a),t.push([r,i,e.created_at]))}return t.length>0?{...e,_tagsCreated:t}:{...e}}static fromStored(e){if(!(`_tagsCreated`in e))return e;let{_tagsCreated:t,...n}=e;return n}static getDTag(e){return e.tags.find(([e])=>e===`d`)?.[1]??``}static isNewer(e,t){return e.created_at>t.created_at?!0:e.created_att.id):t.created_at-e.created_at}[Symbol.toStringTag]=`NIndexedDB`},po=class{ids;authors;kinds;tags;search;searchKeywords;since;until;limit;idSet;authorSet;kindSet;neverMatch;indexOnly;constructor(e){let t=!1,n=0,r=[];for(let[i,a]of Object.entries(e)){if(Array.isArray(a)&&a.length===0){t=!0;continue}if(i===`ids`)this.ids=mo(a),n++;else if(i===`authors`)this.authors=mo(a),n++;else if(i===`kinds`)this.kinds=ho(a),n++;else if(i===`since`)this.since=a;else if(i===`until`)this.until=a;else if(i===`limit`)this.limit=a;else if(i===`search`)this.search=a;else if(i.startsWith(`#`)&&i.length>=2){let e=mo(a);r.push({name:i.slice(1),values:e,valueSet:new Set(e)}),n++}}if(this.tags=r,this.neverMatch=t,this.idSet=this.ids&&new Set(this.ids),this.authorSet=this.authors&&new Set(this.authors),this.kindSet=this.kinds&&new Set(this.kinds),this.search!==void 0){let e=[],t=[];for(let n of la.parseInput(this.search)){if(typeof n!=`string`)continue;let r=n.toLowerCase();r.startsWith(`-`)?r.length>1&&t.push(r.slice(1)):r.length>0&&e.push(r)}(e.length>0||t.length>0)&&(this.searchKeywords={required:e,negated:t})}this.indexOnly=!this.searchKeywords&&(n<=1||n===2&&!!this.authors&&!!this.kinds)}matchesTime(e){return!(this.since!==void 0&&ethis.until)}matches(e){if(this.neverMatch||!this.matchesTime(e.created_at)||this.idSet&&!this.idSet.has(e.id)||this.authorSet&&!this.authorSet.has(e.pubkey)||this.kindSet&&!this.kindSet.has(e.kind))return!1;for(let{name:t,valueSet:n}of this.tags)if(!e.tags.some(([e,r])=>e===t&&n.has(r)))return!1;if(this.searchKeywords){let t=e.content.toLowerCase();for(let e of this.searchKeywords.required)if(!t.includes(e))return!1;for(let e of this.searchKeywords.negated)if(t.includes(e))return!1}return!0}};function mo(e){return[...new Set(e)].sort()}function ho(e){return[...new Set(e)].sort((e,t)=>e-t)}var go=50,_o=new Set([33863,1985,5]),vo=class{executeBatch;pending=[];scheduled=!1;constructor(e){this.executeBatch=e}request(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason);return}this.pending.push({key:e,resolve:n,reject:r,signal:t}),this.scheduled||(this.scheduled=!0,queueMicrotask(()=>this.flush()))})}async flush(){let e=this.pending;if(this.pending=[],this.scheduled=!1,e.length===0)return;let t=e.filter(e=>!e.signal?.aborted),n=e.filter(e=>e.signal?.aborted);for(let e of n)e.reject(e.signal.reason);if(t.length===0)return;let r=[],i=new Set;for(let e of t)i.has(e.key)||(i.add(e.key),r.push(e.key));let a=new AbortController,o=t.map(e=>e.signal).filter(Boolean);if(o.length>0&&o.length===t.length){let e=()=>{o.every(e=>e.aborted)&&a.abort(o[0].reason)};for(let t of o)t.addEventListener(`abort`,e,{once:!0})}try{let e=new Map,n=[];for(let e=0;e{let n=await this.executeBatch(t,a.signal);for(let[t,r]of n)e.set(t,r)}));for(let n of t)n.signal?.aborted?n.reject(n.signal.reason):n.resolve(e.get(n.key))}catch(e){for(let n of t)n.reject(e)}}};function yo(e){return Object.keys(e).every(e=>e===`ids`||e===`limit`)&&Array.isArray(e.ids)&&e.ids.length===1}var P=new Set([0,3,1e4,10001,10002,10003,10015,10030,10063]);function bo(e){return Object.keys(e).every(e=>e===`kinds`||e===`authors`||e===`limit`)&&e.kinds?.length===1&&P.has(e.kinds[0])&&e.authors?.length===1&&e.limit!==void 0}var xo=class{pool;pending=[];scheduled=!1;constructor(e){this.pool=e}request(e,t,n){return new Promise((r,i)=>{if(n?.aborted){i(n.reason);return}this.pending.push({pubkey:e,kind:t,resolve:r,reject:i,signal:n}),this.scheduled||(this.scheduled=!0,queueMicrotask(()=>this.flush()))})}async flush(){let e=this.pending;if(this.pending=[],this.scheduled=!1,e.length===0)return;let t=e.filter(e=>!e.signal?.aborted);for(let t of e.filter(e=>e.signal?.aborted))t.reject(t.signal.reason);if(t.length===0)return;let n=new Map;for(let{pubkey:e,kind:r}of t)n.has(e)||n.set(e,new Set),n.get(e).add(r);let r=new Map;for(let[e,t]of n){let n=[...t].sort((e,t)=>e-t).join(`,`);r.has(n)||r.set(n,{kinds:[...t].sort((e,t)=>e-t),pubkeys:[]}),r.get(n).pubkeys.push(e)}let i=new AbortController,a=t.map(e=>e.signal).filter(Boolean);if(a.length>0&&a.length===t.length){let e=()=>{a.every(e=>e.aborted)&&i.abort(a[0].reason)};for(let t of a)t.addEventListener(`abort`,e,{once:!0})}let o=new Map;try{await Promise.all([...r.values()].map(async({kinds:e,pubkeys:t})=>{let n=await this.pool.query([{kinds:e,authors:t,limit:e.length*t.length}],{signal:i.signal});for(let e of t)o.has(e)||o.set(e,new Map);for(let e of n){let t=o.get(e.pubkey);if(!t)continue;let n=t.get(e.kind);(!n||e.created_at>n.created_at)&&t.set(e.kind,e)}}))}catch(e){for(let n of t)n.reject(e);return}let s=[...r.values()].filter(({kinds:e})=>e.includes(0)).flatMap(({pubkeys:e})=>e).filter(e=>!o.get(e)?.get(0));if(s.length>0&&!i.signal.aborted)try{let e=[];for(let t=0;t{let t=await this.pool.query([{kinds:[0],authors:e,limit:e.length}],{signal:i.signal});for(let e of t){o.has(e.pubkey)||o.set(e.pubkey,new Map);let t=o.get(e.pubkey),n=t.get(0);(!n||e.created_at>n.created_at)&&t.set(0,e)}}))}catch{}for(let e of t)e.signal?.aborted?e.reject(e.signal.reason):e.resolve(o.get(e.pubkey)?.get(e.kind))}};function So(e){return Object.keys(e).every(e=>e===`kinds`||e===`authors`||e===`#e`||e===`limit`)&&e.kinds?.length===1&&e.kinds[0]===7&&e.authors?.length===1&&e[`#e`]!==void 0&&Array.isArray(e[`#e`])&&e[`#e`].length===1}function Co(e){let t=Object.keys(e),n=e.kinds;if(!n||n.length===0)return!1;let r=e[`#e`];return t.every(e=>e===`kinds`||e===`authors`||e===`#e`||e===`limit`)&&n.every(e=>e===6||e===16)&&e.authors?.length===1&&r!==void 0&&Array.isArray(r)&&r.length===1}function wo(e){return Object.keys(e).every(e=>e===`kinds`||e===`#e`||e===`limit`)&&Array.isArray(e.kinds)&&e.kinds.length>0&&!e.authors&&e[`#e`]!==void 0&&Array.isArray(e[`#e`])&&e[`#e`].length===1}function To(e){return e[`#e`][0]}function Eo(e){return Object.keys(e).every(e=>e===`kinds`||e===`#a`||e===`limit`)&&Array.isArray(e.kinds)&&e.kinds.length>0&&!e.authors&&e[`#a`]!==void 0&&Array.isArray(e[`#a`])&&e[`#a`].length===1}function Do(e){return e[`#a`][0]}function Oo(e){if(e.length<2)return null;let t=null;for(let n of e){let e=Object.keys(n),r=e.every(e=>e===`kinds`||e===`#e`||e===`limit`)&&n[`#e`]!==void 0&&Array.isArray(n[`#e`])&&n[`#e`].length===1,i=e.every(e=>e===`kinds`||e===`#q`||e===`limit`)&&n[`#q`]!==void 0&&Array.isArray(n[`#q`])&&n[`#q`].length===1;if(!r&&!i)return null;let a=r?n[`#e`][0]:n[`#q`][0];if(t===null)t=a;else if(a!==t)return null}return t}function ko(e){return Object.keys(e).every(e=>e===`kinds`||e===`authors`||e===`#d`||e===`limit`)&&e.kinds?.length===1&&e.authors?.length===1&&e[`#d`]!==void 0&&Array.isArray(e[`#d`])&&e[`#d`].length===1}var Ao=class{pool;replaceableCollector;eventCollector;reactionCollectors=new Map;repostCollectors=new Map;dTagCollectors=new Map;eTagCollectors=new Map;aTagCollectors=new Map;multiFilterCollectors=new Map;store;loggedInPubkeys=new Set;followedPubkeys;constructor(e,t){this.pool=e,this.store=t,this.replaceableCollector=new xo(e),this.eventCollector=new vo((e,t)=>this.executeEventBatch(e,t))}setLoggedInPubkeys(e){let t=new Set(e.filter(mn));t.size===this.loggedInPubkeys.size&&[...t].every(e=>this.loggedInPubkeys.has(e))||(this.loggedInPubkeys=t,this.followedPubkeys=void 0)}getFollowedPubkeys(e){return this.followedPubkeys??=(async()=>{let t=[...this.loggedInPubkeys];if(t.length===0)return new Set;let n=await e.query([{kinds:[3],authors:t}]),r=new Set;for(let e of n)if(this.loggedInPubkeys.has(e.pubkey))for(let[t,n]of e.tags)t===`p`&&mn(n)&&r.add(n);return r})(),this.followedPubkeys}shouldCache(e,t){return this.loggedInPubkeys.has(e.pubkey)||_o.has(e.kind)?!0:yt.replaceable(e.kind)?t.has(e.pubkey):!1}cacheEvents(e){let t=this.store;!t||e.length===0||(async()=>{try{let n=await this.getFollowedPubkeys(t),r=e.filter(e=>this.shouldCache(e,n));if(r.length===0)return;await Promise.all(r.map(e=>t.event(e))),r.some(e=>e.kind===3&&this.loggedInPubkeys.has(e.pubkey))&&(this.followedPubkeys=void 0)}catch{}})()}async query(e,t){let n=await this.queryInner(e,t);return this.cacheEvents(n),n}async queryInner(e,t){if(e.length===1){let n=e[0];if(yo(n)){let e=await this.eventCollector.request(n.ids[0],t?.signal);return e?[e]:[]}if(bo(n)){let e=await this.replaceableCollector.request(n.authors[0],n.kinds[0],t?.signal);return e?[e]:[]}if(So(n)){let e=n.authors[0],r=n[`#e`][0],i=this.reactionCollectors.get(e);i||(i=new vo((t,n)=>this.executeReactionBatch(e,t,n)),this.reactionCollectors.set(e,i));let a=await i.request(r,t?.signal);return a?[a]:[]}if(Co(n)){let e=n.authors[0],r=n[`#e`][0],i=`${e}:${[...n.kinds].sort().join(`,`)}`,a=this.repostCollectors.get(i);a||(a=new vo((t,r)=>this.executeRepostBatch(e,n.kinds,t,r)),this.repostCollectors.set(i,a));let o=await a.request(r,t?.signal);return o?[o]:[]}if(wo(n)){let e=To(n),r=[...n.kinds].sort().join(`,`),i=n.limit??50,a=`${r}:${i}`,o=this.eTagCollectors.get(a);return o||(o=new vo((e,t)=>this.executeETagBatch(n.kinds,e,i,t)),this.eTagCollectors.set(a,o)),o.request(e,t?.signal)}if(Eo(n)){let e=Do(n),r=[...n.kinds].sort().join(`,`),i=n.limit??50,a=`${r}:${i}`,o=this.aTagCollectors.get(a);return o||(o=new vo((e,t)=>this.executeATagBatch(n.kinds,e,i,t)),this.aTagCollectors.set(a,o)),o.request(e,t?.signal)}if(ko(n)){let e=n.kinds[0],r=n.authors[0],i=n[`#d`][0],a=`${e}:${r}`,o=this.dTagCollectors.get(a);o||(o=new vo((t,n)=>this.executeDTagBatch(e,r,t,n)),this.dTagCollectors.set(a,o));let s=await o.request(i,t?.signal);return s?[s]:[]}}let n=Oo(e);if(n!==null){let r=e.map(e=>Object.keys(e).sort().map(t=>t===`#e`||t===`#q`?t:`${t}:${JSON.stringify(e[t])}`).join(`|`)).join(`;;`),i=this.multiFilterCollectors.get(r);return i||(i=new vo((t,n)=>this.executeMultiFilterBatch(e,t,n)),this.multiFilterCollectors.set(r,i)),i.request(n,t?.signal)}return this.pool.query(e,t)}async event(e,t){await this.pool.event(e,t),this.cacheEvents([e])}req(e,t){let n=this.pool.req(e,t),r=this.cacheEvents.bind(this);return(async function*(){for await(let e of n)e[0]===`EVENT`&&r([e[2]]),yield e})()}relay(e){return this.pool.relay(e)}group(e){return this.pool.group(e)}close(){return this.pool.close()}async executeRepostBatch(e,t,n,r){let i=new Map;try{let a=await this.pool.query([{kinds:t,authors:[e],"#e":n,limit:n.length}],{signal:r}),o=new Map;for(let e of a){let t=e.tags.find(([e])=>e===`e`)?.[1];if(!t)continue;let n=o.get(t);(!n||e.created_at>n.created_at)&&o.set(t,e)}for(let e of n)i.set(e,o.get(e))}catch{for(let e of n)i.set(e,void 0)}return i}async executeEventBatch(e,t){let n=new Map;try{let r=await this.pool.query([{ids:e,limit:e.length}],{signal:t}),i=new Map;for(let e of r)i.set(e.id,e);for(let t of e)n.set(t,i.get(t))}catch{for(let t of e)n.set(t,void 0)}return n}async executeReactionBatch(e,t,n){let r=new Map;try{let i=await this.pool.query([{kinds:[7],authors:[e],"#e":t,limit:t.length}],{signal:n}),a=new Map;for(let e of i){let t=e.tags.findLast(([e])=>e===`e`)?.[1];if(!t)continue;let n=a.get(t);(!n||e.created_at>n.created_at)&&a.set(t,e)}for(let e of t)r.set(e,a.get(e))}catch{for(let e of t)r.set(e,void 0)}return r}async executeDTagBatch(e,t,n,r){let i=new Map;try{let a=await this.pool.query([{kinds:[e],authors:[t],"#d":n,limit:n.length}],{signal:r}),o=new Map;for(let e of a){let t=e.tags.find(([e])=>e===`d`)?.[1];if(!t)continue;let n=o.get(t);(!n||e.created_at>n.created_at)&&o.set(t,e)}for(let e of n)i.set(e,o.get(e))}catch{for(let e of n)i.set(e,void 0)}return i}async executeETagBatch(e,t,n,r){let i=new Map;try{let a=await this.pool.query([{kinds:e,"#e":t,limit:t.length*n}],{signal:r}),o=new Map,s=new Set(t);for(let e of a)for(let t of e.tags)if(t[0]===`e`&&s.has(t[1])){let n=o.get(t[1])??[];n.push(e),o.set(t[1],n)}for(let e of t)i.set(e,o.get(e)??[])}catch{for(let e of t)i.set(e,[])}return i}async executeATagBatch(e,t,n,r){let i=new Map;try{let a=await this.pool.query([{kinds:e,"#a":t,limit:t.length*n}],{signal:r}),o=new Map,s=new Set(t);for(let e of a)for(let t of e.tags)if(t[0]===`a`&&s.has(t[1])){let n=o.get(t[1])??[];n.push(e),o.set(t[1],n)}for(let e of t)i.set(e,o.get(e)??[])}catch{for(let e of t)i.set(e,[])}return i}async executeMultiFilterBatch(e,t,n){let r=new Map;try{let i=e.map(e=>{let n={...e},r=n;return r[`#e`]!==void 0&&(r[`#e`]=t,n.limit&&(n.limit*=t.length)),r[`#q`]!==void 0&&(r[`#q`]=t,n.limit&&(n.limit*=t.length)),n}),a=await this.pool.query(i,{signal:n}),o=new Map,s=new Set(t);for(let e of a){let t=new Set;for(let n of e.tags)(n[0]===`e`||n[0]===`q`)&&s.has(n[1])&&t.add(n[1]);for(let n of t){let t=o.get(n)??[];t.push(e),o.set(n,t)}}for(let e of t)r.set(e,o.get(e)??[])}catch{for(let e of t)r.set(e,[])}return r}},jo=`nostr`,Mo=e=>{let{children:t}=e,{config:n}=Zt(),{logins:r}=ot(),i=(0,M.useRef)(void 0),a=(0,M.useRef)(void 0);a.current??=new fo(jo);let o=(0,M.useRef)(En(n.relayMetadata,n.useAppRelays,n.useUserRelays)),s=(0,M.useRef)(void 0),c=r[0];s.current=(0,M.useMemo)(()=>{if(c)try{switch(c.type){case`nsec`:return qe.fromNsecLogin(c).signer;case`bunker`:return qe.fromBunkerLogin(c,i.current).signer;case`extension`:return qe.fromExtensionLogin(c).signer;default:return}}catch{return}},[c]),(0,M.useEffect)(()=>{o.current=En(n.relayMetadata,n.useAppRelays,n.useUserRelays)},[n.relayMetadata,n.useAppRelays,n.useUserRelays]),i.current||=new da({open(e){let t=new st(e,{auth:async t=>{let n=s.current;if(!n)throw Error(`AUTH failed: no signer available (user not logged in)`);return n.signEvent({kind:22242,content:``,tags:[[`relay`,e],[`challenge`,t]],created_at:Math.floor(Date.now()/1e3)})}});return new On(e,t)},reqRouter(e){let t=new Map;if(e.some(e=>`search`in e)||e.every(e=>e?.kinds?.length===1&&e?.kinds[0]===1985))return new Map(Dn.map(t=>[t,e]));if(e.every(e=>e?.kinds?.length===1&&e?.kinds[0]===34236))return new Map([...Dn,Tn].map(t=>[t,e]));let n=o.current.relays.filter(e=>e.read).map(e=>e.url),r=[32267,30063,3063];if(e.every(e=>e?.kinds?.every(e=>r.includes(e))))return new Map([wn,...n].map(t=>[t,e]));for(let r of n)t.set(r,e);return t},eventRouter(e){let t=o.current.relays.filter(e=>e.write).map(e=>e.url);return[...new Set(t)]},eoseTimeout:300});let l=(0,M.useRef)(void 0);return!l.current&&i.current&&(l.current=new Ao(i.current,a.current),l.current.setLoggedInPubkeys(r.map(e=>e.pubkey))),(0,M.useEffect)(()=>{l.current?.setLoggedInPubkeys(r.map(e=>e.pubkey))},[r]),(0,M.useEffect)(()=>()=>{i.current&&i.current.close()},[]),(0,N.jsx)(ht.Provider,{value:{nostr:l.current??i.current},children:(0,N.jsx)(pt.Provider,{value:a.current,children:t})})};function No(){let{nostr:e}=ct(),{user:t}=cn(),{config:n,updateConfig:r}=Zt(),i=xt(),{settings:a,isLoading:o,recentlyWritten:s}=nn(),c=(0,M.useRef)(0),[l,u]=(0,M.useState)(!1),d=(0,M.useRef)(void 0),f=(0,M.useRef)(!1);(0,M.useEffect)(()=>{let e=t?.pubkey;if(d.current!==void 0&&e!==d.current){c.current=0,f.current=!0;for(let e of[`user-reaction`,`user-repost`,`external-user-reaction`,`external-user-repost`,`feed`,`vines-follows`,`theme-feed`,`book-feed`])i.removeQueries({queryKey:[e]});for(let e of[`encryptedSettings`,`parsedSettings`,`notifications`,`notifications-unread`,`interests`,`muteList`,`muteItems`,`user-lists`,`bookmarks`,`bookmarked-events`,`custom-emojis`,`emoji-list`,`own-follow-packs`,`follow-list`,`relayList`,`blossomServerList`,`pinned-notes`,`my-rsvp`,`user-book-review`])i.invalidateQueries({queryKey:[e]});i.invalidateQueries({queryKey:[`nostr`,`logins`]})}d.current=e},[t?.pubkey,i]);let{data:p}=_t({queryKey:[`relayList`,t?.pubkey??``],queryFn:async({signal:n})=>t?(await e.query([{kinds:[10002],authors:[t.pubkey],limit:1}],{signal:n}))[0]??null:null,enabled:!!t,staleTime:3e5,gcTime:6e5,retry:1});(0,M.useEffect)(()=>{if(p&&p.created_at>n.relayMetadata.updatedAt){let e=p.tags.filter(([e])=>e===`r`).map(([,e,t])=>({url:e.replace(/\/+$/,``),read:!t||t===`read`,write:!t||t===`write`}));e.length>0&&(console.log(`Syncing relay list from Nostr:`,e),r(t=>({...t,relayMetadata:{relays:e,updatedAt:p.created_at}})))}},[p,n.relayMetadata.updatedAt,r]);let{data:m}=_t({queryKey:[`blossomServerList`,t?.pubkey??``],queryFn:async({signal:n})=>t?(await e.query([{kinds:[10063],authors:[t.pubkey],limit:1}],{signal:n}))[0]??null:null,enabled:!!t,staleTime:3e5,gcTime:6e5,retry:1});return(0,M.useEffect)(()=>{if(m&&m.created_at>n.blossomServerMetadata.updatedAt){let e=on(m);e.length>0&&(console.log(`Syncing Blossom server list from Nostr (kind 10063):`,e),r(t=>({...t,blossomServerMetadata:{servers:e,updatedAt:m.created_at}})))}},[m,n.blossomServerMetadata.updatedAt,r]),(0,M.useEffect)(()=>{if(!t||o)return;if(!a){f.current&&=(Qa(n.appId,t.pubkey)&&r(e=>{let t=!1,n={...e};return e.theme!==`system`&&(n.theme=`system`,t=!0),(e.sidebarOrder??[]).length>0&&(n.sidebarOrder=[],t=!0),e.homePage!==`feed`&&(n.homePage=`feed`,t=!0),t?n:e}),!1);return}let e=a.lastSync||0;if(l||u(!0),s()){console.log(`Skipping settings sync - recent write`),c.current=e;return}if(e<=c.current)return;console.log(`Syncing encrypted settings from Nostr`,e),c.current=e;let i=f.current;if(f.current=!1,r(e=>{let t=!1,n={...e};if(a.theme?a.theme!==e.theme&&(n.theme=a.theme,t=!0):i&&e.theme!==`system`&&(n.theme=`system`,t=!0),a.useAppRelays!==void 0&&a.useAppRelays!==e.useAppRelays&&(n.useAppRelays=a.useAppRelays,t=!0),a.useUserRelays!==void 0&&a.useUserRelays!==e.useUserRelays&&(n.useUserRelays=a.useUserRelays,t=!0),a.feedSettings){let r=e.feedSettings,i=a.feedSettings;Object.keys(i).some(e=>i[e]!==r?.[e])&&(n.feedSettings={...r,...i},t=!0)}return a.contentWarningPolicy&&a.contentWarningPolicy!==e.contentWarningPolicy&&(n.contentWarningPolicy=a.contentWarningPolicy,t=!0),a.sidebarOrder&&JSON.stringify(a.sidebarOrder)!==JSON.stringify(e.sidebarOrder)&&(n.sidebarOrder=a.sidebarOrder,t=!0),a.homePage&&a.homePage!==e.homePage&&(n.homePage=a.homePage,t=!0),a.corsProxy&&a.corsProxy!==e.corsProxy&&(n.corsProxy=a.corsProxy,t=!0),a.faviconUrl&&a.faviconUrl!==e.faviconUrl&&(n.faviconUrl=a.faviconUrl,t=!0),a.linkPreviewUrl&&a.linkPreviewUrl!==e.linkPreviewUrl&&(n.linkPreviewUrl=a.linkPreviewUrl,t=!0),a.translateWorkerUrl&&a.translateWorkerUrl!==e.translateWorkerUrl&&(n.translateWorkerUrl=a.translateWorkerUrl,t=!0),t?n:e}),a.showGlobalFeed!==void 0){let e=sn(n.appId,`showGlobalFeed`),t=localStorage.getItem(e),r=String(a.showGlobalFeed);t!==r&&localStorage.setItem(e,r)}if(a.showCommunityFeed!==void 0){let e=sn(n.appId,`showCommunityFeed`),t=localStorage.getItem(e),r=String(a.showCommunityFeed);t!==r&&localStorage.setItem(e,r)}if(a.communityData){let e={domain:a.communityData.domain,label:a.communityData.label,userCount:a.communityData.userCount},t=sn(n.appId,`community`),r=localStorage.getItem(t),i=JSON.stringify(e);r!==i&&(localStorage.setItem(t,i),localStorage.setItem(sn(n.appId,`communityData`),JSON.stringify({names:a.communityData.nip05})))}t&&e>0&&an(t.pubkey,e)},[t,a,o,r,s,l,n.appId]),null}function Po({children:e}){let{config:t}=Zt(),n=(0,M.useRef)(!1);return(0,M.useEffect)(()=>{n.current||!t.plausibleDomain||(n.current=!0,D(async()=>{let{init:e}=await import(`./plausible-BCeIv-rh.js`);return{init:e}},[]).then(({init:e})=>{e({domain:t.plausibleDomain,...t.plausibleEndpoint&&{endpoint:t.plausibleEndpoint}})}).catch(console.error))},[t.plausibleDomain,t.plausibleEndpoint]),(0,N.jsx)(N.Fragment,{children:e})}function Fo({children:e}){let{config:t}=Zt();return(0,M.useEffect)(()=>{let e=t.sentryDsn&&t.sentryEnabled;e&&!oa()?ia(t.sentryDsn).catch(console.error):!e&&oa()&&aa().catch(console.error)},[t.sentryDsn,t.sentryEnabled]),(0,N.jsx)(N.Fragment,{children:e})}var Io=/nsec1[a-z0-9]{58}/i;function Lo(){(0,M.useEffect)(()=>{function e(e){let t=e.clipboardData?.getData(`text`);if(!t||!Io.test(t))return;let n=e.target;n.id===`nsec`||n.closest?.(`[data-nsec-allowed]`)||(e.preventDefault(),e.stopImmediatePropagation(),dn({title:`Secret key detected`,description:`Your clipboard contains a secret key. Posting it publicly could give someone else full access to your account.`,variant:`destructive`}))}return document.addEventListener(`paste`,e,{capture:!0}),()=>document.removeEventListener(`paste`,e,{capture:!0})},[])}var Ro=bn(`Tor`);function zo(){return Sn.getPlatform()===`android`}async function Bo(){if(!zo())return null;try{return await Ro.getStatus()}catch{return null}}async function Vo(){if(zo())try{await Ro.retry()}catch{}}async function Ho(){if(zo())try{await Ro.start()}catch{}}async function Uo(){if(zo())try{await Ro.stop()}catch{}}function Wo(){let e=zo(),[t,n]=(0,M.useState)(!1),[r,i]=(0,M.useState)(!zo()),[a,o]=(0,M.useState)(`disabled`),[s,c]=(0,M.useState)(0),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(null);return(0,M.useEffect)(()=>{if(!e)return;let t=!0,r;return Bo().then(e=>{t&&(e&&(n(e.enabled),o(e.status),c(e.bootstrapPercent),u(e.error),f(e.exitIp??null)),i(!0))}),Ro.addListener(`torStatus`,e=>{o(e.status),c(e.bootstrapPercent),u(e.error),f(e.exitIp??null)}).then(e=>{t?r=e:e.remove()}),()=>{t=!1,r?.remove()}},[e]),{supported:e,enabled:t,loaded:r,status:a,bootstrapPercent:s,error:l,exitIp:d,setEnabled:async e=>{e?await Ho():await Uo(),n(e)}}}var Go=`audio-player-volume`;function Ko(){try{let e=localStorage.getItem(Go);if(e!==null){let t=parseFloat(e);if(isFinite(t)&&t>=0&&t<=1)return t}}catch{}return .8}function qo({children:e}){let t=(0,M.useRef)(null),[n,r]=(0,M.useState)(null),[i,a]=(0,M.useState)([]),[o,s]=(0,M.useState)(0),[c,l]=(0,M.useState)(!1),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(0),[m,h]=(0,M.useState)(0),[g,_]=(0,M.useState)(Ko);(0,M.useEffect)(()=>{t.current&&(t.current.volume=g)},[g]),(0,M.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>d(!0),a=()=>d(!1),c=()=>{if(d(!1),i.length>0&&o{})}},l=()=>p(e.currentTime),u=()=>{e.duration&&isFinite(e.duration)&&h(e.duration)};return e.addEventListener(`play`,n),e.addEventListener(`pause`,a),e.addEventListener(`ended`,c),e.addEventListener(`timeupdate`,l),e.addEventListener(`durationchange`,u),e.addEventListener(`loadedmetadata`,u),()=>{e.removeEventListener(`play`,n),e.removeEventListener(`pause`,a),e.removeEventListener(`ended`,c),e.removeEventListener(`timeupdate`,l),e.removeEventListener(`durationchange`,u),e.removeEventListener(`loadedmetadata`,u)}},[i,o]),(0,M.useEffect)(()=>{if(!(`mediaSession`in navigator))return;if(!n){navigator.mediaSession.metadata=null;return}let e=n.artwork?[{src:n.artwork,sizes:`512x512`,type:`image/jpeg`}]:[];navigator.mediaSession.metadata=new MediaMetadata({title:n.title,artist:n.artist,artwork:e})},[n]),(0,M.useEffect)(()=>{`mediaSession`in navigator&&(navigator.mediaSession.playbackState=u?`playing`:`paused`)},[u]),(0,M.useEffect)(()=>{if(`mediaSession`in navigator&&!(!n||m<=0))try{navigator.mediaSession.setPositionState({duration:m,playbackRate:t.current?.playbackRate??1,position:Math.min(f,m)})}catch{}},[f,m,n]),(0,M.useEffect)(()=>{if(!(`mediaSession`in navigator))return;let e=t.current;return navigator.mediaSession.setActionHandler(`play`,()=>e?.play().catch(()=>{})),navigator.mediaSession.setActionHandler(`pause`,()=>e?.pause()),navigator.mediaSession.setActionHandler(`previoustrack`,()=>{if(e&&e.currentTime>3){e.currentTime=0;return}let t=o-1;t<0||i.length===0||(s(t),r(i[t]),p(0),h(i[t].duration??0),e&&(e.src=i[t].url,e.play().catch(()=>{})))}),navigator.mediaSession.setActionHandler(`nexttrack`,()=>{let t=o+1;t>=i.length||(s(t),r(i[t]),p(0),h(i[t].duration??0),e&&(e.src=i[t].url,e.play().catch(()=>{})))}),navigator.mediaSession.setActionHandler(`seekto`,t=>{e&&t.seekTime!=null&&(e.currentTime=t.seekTime)}),()=>{navigator.mediaSession.setActionHandler(`play`,null),navigator.mediaSession.setActionHandler(`pause`,null),navigator.mediaSession.setActionHandler(`previoustrack`,null),navigator.mediaSession.setActionHandler(`nexttrack`,null),navigator.mediaSession.setActionHandler(`seekto`,null)}},[o,i]),(0,M.useEffect)(()=>{if(!n)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[n]);let v=(0,M.useCallback)(e=>{let n=t.current;n&&(r(e),a([]),s(0),l(!1),p(0),h(e.duration??0),n.src=e.url,n.play().catch(()=>{}))},[]),y=(0,M.useCallback)((e,n=0)=>{let i=t.current;if(!i||e.length===0)return;let o=Math.max(0,Math.min(n,e.length-1));a(e),s(o),r(e[o]),l(!1),p(0),h(e[o].duration??0),i.src=e[o].url,i.play().catch(()=>{})},[]),b=(0,M.useCallback)(()=>{t.current?.pause()},[]),x=(0,M.useCallback)(()=>{t.current?.play().catch(()=>{})},[]),S=(0,M.useCallback)(e=>{let n=t.current;n&&(n.currentTime=e)},[]),C=(0,M.useCallback)(e=>{let t=Math.max(0,Math.min(1,e));_(t);try{localStorage.setItem(Go,String(t))}catch{}},[]),ee=(0,M.useCallback)(()=>{let e=t.current;if(!e||i.length===0)return;let n=o+1;n>=i.length||(s(n),r(i[n]),p(0),h(i[n].duration??0),e.src=i[n].url,e.play().catch(()=>{}))},[i,o]),te=(0,M.useCallback)(()=>{let e=t.current;if(!e||i.length===0)return;if(e.currentTime>3){e.currentTime=0;return}let n=o-1;n<0||(s(n),r(i[n]),p(0),h(i[n].duration??0),e.src=i[n].url,e.play().catch(()=>{}))},[i,o]),w=(0,M.useCallback)(()=>l(!0),[]),ne=(0,M.useCallback)(()=>l(!1),[]),re=(0,M.useCallback)(()=>{let e=t.current;e&&(e.pause(),e.src=``),r(null),a([]),s(0),l(!1),d(!1),p(0),h(0)},[]);return(0,N.jsxs)(Bn.Provider,{value:{currentTrack:n,playlist:i,currentIndex:o,minimized:c,isPlaying:u,currentTime:f,duration:m,volume:g,playTrack:v,playPlaylist:y,pause:b,resume:x,seek:S,setVolume:C,nextTrack:ee,prevTrack:te,minimize:w,expand:ne,stop:re},children:[(0,N.jsx)(`audio`,{ref:t,preload:`metadata`,className:`hidden`}),e]})}function Jo(e,t,n){let r=n?.serialize||JSON.stringify,i=n?.deserialize||JSON.parse,a=Sn.isNativePlatform(),[o,s]=(0,M.useState)(()=>{if(a)return t;try{let n=localStorage.getItem(e);return n?i(n):t}catch(n){return console.warn(`Failed to load ${e} from localStorage:`,n),t}}),[c,l]=(0,M.useState)(!a),u=(0,M.useRef)(e);return u.current=e,(0,M.useEffect)(()=>{let n=!1;async function r(){try{if(a){let r=await Jn.getItem(e);if(n||u.current!==e)return;s(r?i(r):t)}else{let r=localStorage.getItem(e);if(n||u.current!==e)return;s(r?i(r):t)}}catch(r){n||(console.warn(`Failed to load ${e} from secure storage:`,r),s(t))}finally{n||l(!0)}}return l(!1),r(),()=>{n=!0}},[e,a]),(0,M.useEffect)(()=>{if(a)return;let t=t=>{if(t.key===e&&t.newValue!==null)try{s(i(t.newValue))}catch(t){console.warn(`Failed to sync ${e} from localStorage:`,t)}};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[e,a,i]),[o,t=>{let n=t=>{try{let n=r(t);a?Jn.setItem(e,n).catch(t=>{console.warn(`Failed to save ${e} to secure storage:`,t)}):localStorage.setItem(e,n)}catch(t){console.warn(`Failed to serialize ${e}:`,t)}};t instanceof Function?s(e=>{let r=t(e);return r===e?e:(n(r),r)}):s(e=>t===e?e:(n(t),t))},c]}var Yo,Xo,{bech32:Zo,hex:Qo,utf8:$o}=(Yo=function(e,t){function n(e){if(!Number.isSafeInteger(e))throw Error(`Wrong integer: ${e}`)}function r(...e){let t=(e,t)=>n=>e(t(n));return{encode:Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),decode:e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0)}}function i(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!=`number`)throw Error(`alphabet.encode input should be an array of numbers`);return t.map(t=>{if(n(t),t<0||t>=e.length)throw Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!=`string`)throw Error(`alphabet.decode input should be array of strings`);return t.map(t=>{if(typeof t!=`string`)throw Error(`alphabet.decode: not string element=${t}`);let n=e.indexOf(t);if(n===-1)throw Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function a(e=``){if(typeof e!=`string`)throw Error(`join separator should be string`);return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!=`string`)throw Error(`join.encode input should be array of strings`);for(let e of t)if(typeof e!=`string`)throw Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if(typeof t!=`string`)throw Error(`join.decode input should be string`);return t.split(e)}}}function o(e,t=`=`){if(n(e),typeof t!=`string`)throw Error(`padding chr should be string`);return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!=`string`)throw Error(`padding.encode input should be array of strings`);for(let e of n)if(typeof e!=`string`)throw Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!=`string`)throw Error(`padding.encode input should be array of strings`);for(let e of n)if(typeof e!=`string`)throw Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw Error(`Invalid padding: string should have whole number of bytes`);for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw Error(`Invalid padding: string has too much padding`);return n.slice(0,r)}}}function s(e){if(typeof e!=`function`)throw Error(`normalize fn should be function`);return{encode:e=>e,decode:t=>e(t)}}function c(e,t,r){if(t<2)throw Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(r<2)throw Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw Error(`convertRadix: data should be array`);if(!e.length)return[];let i=0,a=[],o=Array.from(e);for(o.forEach(e=>{if(n(e),e<0||e>=t)throw Error(`Wrong integer: ${e}`)});;){let e=0,n=!0;for(let a=i;at?l(t,e%t):e,u=(e,t)=>e+(t-l(e,t));function d(e,t,r,i){if(!Array.isArray(e))throw Error(`convertRadix2: data should be array`);if(t<=0||t>32)throw Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw Error(`convertRadix2: wrong to=${r}`);if(u(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${u(t,r)}`);let a=0,o=0,s=2**r-1,c=[];for(let i of e){if(n(i),i>=2**t)throw Error(`convertRadix2: invalid data word=${i} from=${t}`);if(a=a<32)throw Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=r;o-=r)c.push((a>>o-r&s)>>>0);a&=2**o-1}if(a=a<=t)throw Error(`Excess padding`);if(!i&&a)throw Error(`Non-zero padding: ${a}`);return i&&o>0&&c.push(a>>>0),c}function f(e){return n(e),{encode:t=>{if(!(t instanceof Uint8Array))throw Error(`radix.encode input should be Uint8Array`);return c(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!=`number`)throw Error(`radix.decode input should be array of strings`);return Uint8Array.from(c(t,e,256))}}}function p(e,t=!1){if(n(e),e<=0||e>32)throw Error(`radix2: bits should be in (0..32]`);if(u(8,e)>32||u(e,8)>32)throw Error(`radix2: carry overflow`);return{encode:n=>{if(!(n instanceof Uint8Array))throw Error(`radix2.encode input should be Uint8Array`);return d(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!=`number`)throw Error(`radix2.decode input should be array of strings`);return Uint8Array.from(d(n,e,8,t))}}}function m(e){if(typeof e!=`function`)throw Error(`unsafeWrapper fn should be function`);return function(...t){try{return e.apply(null,t)}catch{}}}function h(e,t){if(n(e),typeof t!=`function`)throw Error(`checksum fn should be function`);return{encode(n){if(!(n instanceof Uint8Array))throw Error(`checksum.encode: input should be Uint8Array`);let r=t(n).slice(0,e),i=new Uint8Array(n.length+e);return i.set(n),i.set(r,n.length),i},decode(n){if(!(n instanceof Uint8Array))throw Error(`checksum.decode: input should be Uint8Array`);let r=n.slice(0,-e),i=t(r).slice(0,e),a=n.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,`0`).replace(/[IL]/g,`1`))),t.base64=r(p(6),i(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`),o(6),a(``)),t.base64url=r(p(6),i(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`),o(6),a(``));let g=e=>r(f(58),i(e),a(``));t.base58=g(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`),t.base58flickr=g(`123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ`),t.base58xrp=g(`rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz`);let _=[0,2,3,5,6,7,9,10,11];t.base58xmr={encode(e){let n=``;for(let r=0;rr(h(4,t=>e(e(t))),t.base58);let v=r(i(`qpzry9x8gf2tvdw0s3jn54khce6mua7l`),a(``)),y=[996825010,642813549,513874426,1027748829,705979059];function b(e){let t=e>>25,n=(33554431&e)<<5;for(let e=0;e>e&1)==1&&(n^=y[e]);return n}function x(e,t,n=1){let r=e.length,i=1;for(let t=0;t126)throw Error(`Invalid prefix (${e})`);i=b(i)^n>>5}i=b(i);for(let t=0;tn)throw TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);let r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw Error(`String must be lowercase or uppercase`);let i=(e=r).lastIndexOf(`1`);if(i===0||i===-1)throw Error(`Letter "1" must be present between prefix and data only`);let a=e.slice(0,i),o=e.slice(i+1);if(o.length<6)throw Error(`Data must be at least 6 characters long`);let s=v.decode(o).slice(0,-6),c=x(a,s,t);if(!o.endsWith(c))throw Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:a,words:s}}return{encode:function(e,n,r=90){if(typeof e!=`string`)throw Error(`bech32.encode prefix should be string, not `+typeof e);if(!Array.isArray(n)||n.length&&typeof n[0]!=`number`)throw Error(`bech32.encode words should be array of numbers, not `+typeof n);let i=e.length+7+n.length;if(!1!==r&&i>r)throw TypeError(`Length ${i} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${v.encode(n)}${x(e,n,t)}`},decode:o,decodeToBytes:function(e){let{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:m(o),fromWords:r,fromWordsUnsafe:a,toWords:i}}t.bech32=S(`bech32`),t.bech32m=S(`bech32m`),t.utf8={encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)},t.hex=r(p(4),i(`0123456789abcdef`),a(``),s(e=>{if(typeof e!=`string`||e.length%2)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));let C={utf8:t.utf8,hex:t.hex,base16:t.base16,base32:t.base32,base64:t.base64,base64url:t.base64url,base58:t.base58,base58xmr:t.base58xmr},ee=`Invalid encoding type. Available types: ${Object.keys(C).join(`, `)}`;t.bytesToString=(e,t)=>{if(typeof e!=`string`||!C.hasOwnProperty(e))throw TypeError(ee);if(!(t instanceof Uint8Array))throw TypeError(`bytesToString() expects Uint8Array`);return C[e].encode(t)},t.str=t.bytesToString,t.stringToBytes=(e,t)=>{if(!C.hasOwnProperty(e))throw TypeError(ee);if(typeof t!=`string`)throw TypeError(`stringToBytes() expects string`);return C[e].decode(t)},t.bytes=t.stringToBytes},Yo(Xo={exports:{}},Xo.exports),Xo.exports),es={bech32:`bc`,pubKeyHash:0,scriptHash:5,validWitnessVersions:[0]},ts={bech32:`tb`,pubKeyHash:111,scriptHash:196,validWitnessVersions:[0]},ns={bech32:`tbs`,pubKeyHash:111,scriptHash:196,validWitnessVersions:[0]},rs={bech32:`bcrt`,pubKeyHash:111,scriptHash:196,validWitnessVersions:[0]},is={bech32:`sb`,pubKeyHash:63,scriptHash:123,validWitnessVersions:[0]},as=[`option_data_loss_protect`,`initial_routing_sync`,`option_upfront_shutdown_script`,`gossip_queries`,`var_onion_optin`,`gossip_queries_ex`,`option_static_remotekey`,`payment_secret`,`basic_mpp`,`option_support_large_channel`],ss={m:BigInt(1e3),u:BigInt(1e6),n:BigInt(1e9),p:BigInt(0xe8d4a51000)},cs=BigInt(`2100000000000000000`),ls=BigInt(1e11),us={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27},ds={};for(let e=0,t=Object.keys(us);eQo.encode(Zo.fromWordsUnsafe(e)),16:e=>Qo.encode(Zo.fromWordsUnsafe(e)),13:e=>$o.encode(Zo.fromWordsUnsafe(e)),19:e=>Qo.encode(Zo.fromWordsUnsafe(e)),23:e=>Qo.encode(Zo.fromWordsUnsafe(e)),27:e=>Qo.encode(Zo.fromWordsUnsafe(e)),6:ms,24:ms,3:function(e){let t=[],n,r,i,a,o,s=Zo.fromWordsUnsafe(e);for(;s.length>0;)n=Qo.encode(s.slice(0,33)),r=Qo.encode(s.slice(33,41)),i=parseInt(Qo.encode(s.slice(41,45)),16),a=parseInt(Qo.encode(s.slice(45,49)),16),o=parseInt(Qo.encode(s.slice(49,51)),16),s=s.slice(51),t.push({pubkey:n,short_channel_id:r,fee_base_msat:i,fee_proportional_millionths:a,cltv_expiry_delta:o});return t},5:function(e){let t=e.slice().reverse().map(e=>[!!(1&e),!!(2&e),!!(4&e),!!(8&e),!!(16&e)]).reduce((e,t)=>e.concat(t),[]);for(;t.length<2*as.length;)t.push(!1);let n={};as.forEach((e,r)=>{let i;i=t[2*r]?`required`:t[2*r+1]?`supported`:`unsupported`,n[e]=i});let r=t.slice(2*as.length);return n.extra_bits={start_bit:2*as.length,bits:r,has_required:r.reduce((e,t,n)=>n%2==0?e||t:e||!1,!1)},n}};function ps(e){return t=>({tagCode:parseInt(e),words:Zo.encode(`unknown`,t,2**53-1)})}function ms(e){return e.reverse().reduce((e,t,n)=>e+t*32**n,0)}var hs=e=>Uint8Array.from(e.match(/.{1,2}/g).map(e=>parseInt(e,16))),gs=e=>{if(!e)return null;try{let t=function(e,t){if(typeof e!=`string`)throw Error(`Lightning Payment Request must be string`);if(e.slice(0,2).toLowerCase()!==`ln`)throw Error(`Not a proper lightning payment request`);let n=[],r=Zo.decode(e,2**53-1);e=e.toLowerCase();let i=r.prefix,a=r.words,o=e.slice(i.length+1),s=a.slice(-104);a=a.slice(0,-104);let c=i.match(/^ln(\S+?)(\d*)([a-zA-Z]?)$/);if(c&&!c[2]&&(c=i.match(/^ln(\S+)$/)),!c)throw Error(`Not a proper lightning payment request`);n.push({name:`lightning_network`,letters:`ln`});let l=c[1],u;switch(l){case es.bech32:u=es;break;case ts.bech32:u=ts;break;case ns.bech32:u=ns;break;case rs.bech32:u=rs;break;case is.bech32:u=is}if(!u||u.bech32!==l)throw Error(`Unknown coin bech32 prefix`);n.push({name:`coin_network`,letters:l,value:u});let d=c[2],f;d?(f=function(e,t){let n,r;if(e.slice(-1).match(/^[munp]$/))n=e.slice(-1),r=e.slice(0,-1);else{if(e.slice(-1).match(/^[^munp0-9]$/))throw Error(`Not a valid multiplier for the amount`);r=e}if(!r.match(/^\d+$/))throw Error(`Not a valid human readable amount`);let i=BigInt(r),a=n?i*ls/ss[n]:i*ls;if(n===`p`&&i%BigInt(10)!==BigInt(0)||a>cs)throw Error(`Amount is outside of valid range`);return a.toString()}(d+c[3]),n.push({name:`amount`,letters:c[2]+c[3],value:f})):f=null,n.push({name:`separator`,letters:`1`});let p=ms(a.slice(0,7)),m,h,g,_;for(a=a.slice(7),n.push({name:`timestamp`,letters:o.slice(0,7),value:p}),o=o.slice(7);a.length>0;){let e=a[0].toString();m=ds[e]||`unknown_tag`,h=fs[e]||ps(e),a=a.slice(1),g=ms(a.slice(0,2)),a=a.slice(2),_=a.slice(0,g),a=a.slice(g),n.push({name:m,tag:o[0],letters:o.slice(0,3+g),value:h(_)}),o=o.slice(3+g)}n.push({name:`signature`,letters:o.slice(0,104),value:Qo.encode(Zo.fromWordsUnsafe(s))}),o=o.slice(104),n.push({name:`checksum`,letters:o});let v={paymentRequest:e,sections:n,get expiry(){let e=n.find(e=>e.name===`expiry`);if(e)return y(`timestamp`)+e.value},get route_hints(){return n.filter(e=>e.name===`route_hint`).map(e=>e.value)}};for(let e in us)e!==`route_hint`&&Object.defineProperty(v,e,{get:()=>y(e)});return v;function y(e){let t=n.find(t=>t.name===e);return t?t.value:void 0}}(e);if(!t||!t.sections)return null;let n=t.sections.find(e=>e.name===`payment_hash`);if(n?.name!==`payment_hash`||!n.value)return null;let r=n.value,i=0,a=t.sections.find(e=>e.name===`amount`);a?.name===`amount`&&a.value&&(i=parseInt(a.value)/1e3);let o=t.sections.find(e=>e.name===`timestamp`);if(o?.name!==`timestamp`||!o.value)return null;let s=o.value,c,l=t.sections.find(e=>e.name===`expiry`);l?.name===`expiry`&&(c=l.value);let u=t.sections.find(e=>e.name===`description`);return{paymentHash:r,satoshi:i,timestamp:s,expiry:c,description:u?.name===`description`?u?.value:void 0}}catch{return null}};function _s(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}var vs=e=>e instanceof Uint8Array,ys=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),bs=(e,t)=>e<<32-t|e>>>t;if(new Uint8Array(new Uint32Array([287454020]).buffer)[0]!==68)throw Error(`Non little-endian hardware is not supported`);var xs=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Ss(e){if(!vs(e))throw Error(`Uint8Array expected`);let t=``;for(let n=0;ne().update(Cs(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}var Es=class extends ws{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ys(this.buffer)}update(e){_s(this);let{view:t,buffer:n,blockLen:r}=this,i=(e=Cs(e)).length;for(let a=0;a0&&!t.includes(e.length))throw Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)})(e);let n=t.outputLen;if(e.lengthr-a&&(this.process(n,0),a=0);for(let e=a;e>i&a),s=Number(n&a),c=r?0:4;e.setUint32(t+(r?4:0),o,r),e.setUint32(t+c,s,r)})(n,r-8,BigInt(8*this.length),i),this.process(n,0);let o=ys(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;ee&t^e&n^t&n,Os=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ks=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),As=new Uint32Array(64),js=class extends Es{constructor(){super(64,32,8,!1),this.A=0|ks[0],this.B=0|ks[1],this.C=0|ks[2],this.D=0|ks[3],this.E=0|ks[4],this.F=0|ks[5],this.G=0|ks[6],this.H=0|ks[7]}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|a,this.G=0|o,this.H=0|s}process(e,t){for(let n=0;n<16;n++,t+=4)As[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=As[e-15],n=As[e-2],r=bs(t,7)^bs(t,18)^t>>>3,i=bs(n,17)^bs(n,19)^n>>>10;As[e]=i+As[e-7]+r+As[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=l+(bs(o,6)^bs(o,11)^bs(o,25))+((u=o)&s^~u&c)+Os[e]+As[e]|0,d=(bs(n,2)^bs(n,13)^bs(n,22))+Ds(n,r,i)|0;l=c,c=s,s=o,o=a+t|0,a=i,i=r,r=n,n=t+d|0}var u;n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){As.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Ms=Ts(()=>new js),Ns=class{constructor(e){if(this.paymentRequest=void 0,this.paymentHash=void 0,this.preimage=void 0,this.verify=void 0,this.satoshi=void 0,this.expiry=void 0,this.timestamp=void 0,this.createdDate=void 0,this.expiryDate=void 0,this.description=void 0,this.successAction=void 0,this.paymentRequest=e.pr,!this.paymentRequest)throw Error(`Invalid payment request`);let t=gs(this.paymentRequest);if(!t)throw Error(`Failed to decode payment request`);this.paymentHash=t.paymentHash,this.satoshi=t.satoshi,this.timestamp=t.timestamp,this.expiry=t.expiry,this.createdDate=new Date(1e3*this.timestamp),this.expiryDate=this.expiry?new Date(1e3*(this.timestamp+this.expiry)):void 0,this.description=t.description??null,this.verify=e.verify??null,this.preimage=e.preimage??null,this.successAction=e.successAction??null}async isPaid(){if(this.preimage)return this.validatePreimage(this.preimage);if(this.verify)return await this.verifyPayment();throw Error(`Could not verify payment`)}validatePreimage(e){if(!e||!this.paymentHash)return!1;try{let t=Ss(Ms(hs(e)));return this.paymentHash===t}catch{return!1}}async verifyPayment(){try{if(!this.verify)throw Error(`LNURL verify not available`);let e=await fetch(this.verify);if(!e.ok)throw Error(`Verification request failed: ${e.status} ${e.statusText}`);let t=await e.json();return t.preimage&&(this.preimage=t.preimage),t.settled}catch(e){return console.error(`Failed to check LNURL-verify`,e),!1}}hasExpired(){let{expiryDate:e}=this;return!!e&&e.getTime(){if(e.tag!==`keysend`)throw Error(`Invalid keysend params`);if(e.status!==`OK`)throw Error(`Keysend status not OK`);if(!e.pubkey)throw Error(`Pubkey does not exist`);let t,n;return e.customData&&e.customData[0]&&(t=e.customData[0].customKey,n=e.customData[0].customValue),{destination:e.pubkey,customKey:t,customValue:n}};async function Fs({satoshi:e,comment:t,p:n,e:r,relays:i},a={}){let o=a.nostr||globalThis.nostr;if(!o)throw Error(`nostr option or window.nostr is not available`);let s=[[`relays`,...i],[`amount`,e.toString()]];n&&s.push([`p`,n]),r&&s.push([`e`,r]);let c={pubkey:await o.getPublicKey(),created_at:Math.floor(Date.now()/1e3),kind:9734,tags:s,content:t??``};return c.id=Rs(c),await o.signEvent(c)}function Is(e){if(typeof e.content!=`string`||typeof e.created_at!=`number`||!Array.isArray(e.tags))return!1;for(let t=0;t!!e&&Bs.test(e),Hs=({amount:e,min:t,max:n})=>e>0&&e>=t&&e<=n,Us=async e=>{if(e.tag!==`payRequest`)throw Error(`Invalid pay service params`);let t=(e.callback+``).trim();if(!Vs(t))throw Error(`Callback must be a valid url`);let n=Math.ceil(Number(e.minSendable||0)),r=Math.floor(Number(e.maxSendable));if(!n||!r||n>r)throw Error(`Invalid pay service params`);let i,a;try{i=JSON.parse(e.metadata+``),a=Ss(Ms(e.metadata+``))}catch{i=[],a=Ss(Ms(`[]`))}let o=``,s=``,c=``,l=``;for(let e=0;e{let{boost:n}=e;t||={};let r=t.webln||globalThis.webln;if(!r)throw Error(`WebLN not available`);if(!r.keysend)throw Error(`Keysend not available in current WebLN provider`);let i=e.amount||Math.floor(n.value_msat/1e3),a={destination:e.destination,amount:i,customRecords:{7629169:JSON.stringify(n)}};return e.customKey&&e.customValue&&(a.customRecords[e.customKey]=e.customValue),await r.enable(),await r.keysend(a)},Ks=/^((?:[^<>()[\]\\.,;:\s@"]+(?:\.[^<>()[\]\\.,;:\s@"]+)*)|(?:".+"))@((?:\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(?:(?:[a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,qs=class{constructor(e,t){this.address=void 0,this.options=void 0,this.username=void 0,this.domain=void 0,this.pubkey=void 0,this.lnurlpData=void 0,this.keysendData=void 0,this.nostrData=void 0,this.nostrPubkey=void 0,this.nostrRelays=void 0,this.webln=void 0,this.address=e,this.options={proxy:`https://api.getalby.com/lnurl`},this.options=Object.assign(this.options,t),this.parse(),this.webln=this.options.webln}parse(){let e=Ks.exec(this.address.toLowerCase());e&&(this.username=e[1],this.domain=e[2])}getWebLN(){return this.webln||globalThis.webln}async fetch(){return this.options.proxy?this.fetchWithProxy():this.fetchWithoutProxy()}async fetchWithProxy(){let e=await fetch(`${this.options.proxy}/lightning-address-details?${new URLSearchParams({ln:this.address}).toString()}`);if(!e.ok)throw Error(`Failed to fetch lnurl info: ${e.status} ${e.statusText}`);let t=await e.json();await this.parseLnUrlPayResponse(t.lnurlp),this.parseKeysendResponse(t.keysend),this.parseNostrResponse(t.nostr)}async fetchWithoutProxy(){this.domain&&this.username&&await Promise.all([this.fetchLnurlData(),this.fetchKeysendData(),this.fetchNostrData()])}async fetchLnurlData(){let e=await fetch(this.lnurlpUrl());if(e.ok){let t=await e.json();await this.parseLnUrlPayResponse(t)}}async fetchKeysendData(){let e=await fetch(this.keysendUrl());if(e.ok){let t=await e.json();this.parseKeysendResponse(t)}}async fetchNostrData(){let e=await fetch(this.nostrUrl());if(e.ok){let t=await e.json();this.parseNostrResponse(t)}}lnurlpUrl(){return`https://${this.domain}/.well-known/lnurlp/${this.username}`}keysendUrl(){return`https://${this.domain}/.well-known/keysend/${this.username}`}nostrUrl(){return`https://${this.domain}/.well-known/nostr.json?name=${this.username}`}async generateInvoice(e){let t;if(this.options.proxy){let n=await fetch(`${this.options.proxy}/generate-invoice?${new URLSearchParams(Ws({ln:this.address},e)).toString()}`);if(!n.ok)throw Error(`Failed to generate invoice: ${n.status} ${n.statusText}`);t=(await n.json()).invoice}else{if(!this.lnurlpData)throw Error(`No lnurlpData available. Please call fetch() first.`);if(!this.lnurlpData.callback||!Vs(this.lnurlpData.callback))throw Error(`Valid callback does not exist in lnurlpData`);let n=new URL(this.lnurlpData.callback);n.search=new URLSearchParams(e).toString();let r=await fetch(n.toString());if(!r.ok)throw Error(`Failed to generate invoice: ${r.status} ${r.statusText}`);t=await r.json()}let n=t&&t.pr&&t.pr.toString();if(!n)throw Error(`Invalid pay service invoice`);let r={pr:n};if(t&&t.verify&&(r.verify=t.verify.toString()),t&&t.successAction&&typeof t.successAction==`object`){let{tag:e,message:n,description:i,url:a}=t.successAction;e===`message`?r.successAction={tag:e,message:n}:e===`url`&&(r.successAction={tag:e,description:i,url:a})}return new Ns(r)}async requestInvoice(e){if(!this.lnurlpData)throw Error(`No lnurlpData available. Please call fetch() first.`);let t=1e3*e.satoshi,{commentAllowed:n,min:r,max:i}=this.lnurlpData;if(!Hs({amount:t,min:r,max:i}))throw Error(`Invalid amount`);if(e.comment&&n&&n>0&&e.comment.length>n)throw Error(`The comment length must be ${n} characters or fewer`);let a={amount:t.toString()};return e.comment&&(a.comment=e.comment),e.payerdata&&(a.payerdata=JSON.stringify(e.payerdata)),this.generateInvoice(a)}async boost(e,t=0){if(!this.keysendData)throw Error(`No keysendData available. Please call fetch() first.`);let{destination:n,customKey:r,customValue:i}=this.keysendData,a=this.getWebLN();if(!a)throw Error(`WebLN not available`);return Gs({destination:n,customKey:r,customValue:i,amount:t,boost:e},{webln:a})}async zapInvoice({satoshi:e,comment:t,relays:n,e:r},i={}){if(!this.lnurlpData)throw Error(`No lnurlpData available. Please call fetch() first.`);if(!this.nostrPubkey)throw Error(`Nostr Pubkey is missing`);let a=this.nostrPubkey,o=1e3*e,{allowsNostr:s,min:c,max:l}=this.lnurlpData;if(!Hs({amount:o,min:c,max:l}))throw Error(`Invalid amount`);if(!s)throw Error(`Your provider does not support zaps`);let u=await Fs({satoshi:o,comment:t,p:a,e:r,relays:n},i),d={amount:o.toString(),nostr:JSON.stringify(u)};return await this.generateInvoice(d)}async zap(e,t={}){let n=this.zapInvoice(e,t),r=this.getWebLN();if(!r)throw Error(`WebLN not available`);return await r.enable(),r.sendPayment((await n).paymentRequest)}async parseLnUrlPayResponse(e){e&&(this.lnurlpData=await Us(e))}parseKeysendResponse(e){e&&(this.keysendData=Ps(e))}parseNostrResponse(e){e&&([this.nostrData,this.nostrPubkey,this.nostrRelays]=zs(e,this.username))}};new class{constructor(e){this.storage=void 0,this.storage=e||{}}getItem(e){return this.storage[e]}setItem(e,t){this.storage[e]=t}};function Js(){return Js=Object.assign?Object.assign.bind():function(e){for(var t=1;tt.toString(16).padStart(2,`0`));function Xs(e){if(!(e instanceof Uint8Array))throw Error(`Uint8Array expected`);let t=``;for(let n=0;n-1)throw Error(`hash router paths not supported`);let r=new URL(e);return t.name&&r.searchParams.set(`name`,t.name),r.searchParams.set(`pubkey`,n),t.returnTo&&r.searchParams.set(`return_to`,t.returnTo),t.budgetRenewal&&r.searchParams.set(`budget_renewal`,t.budgetRenewal),t.expiresAt&&r.searchParams.set(`expires_at`,Math.floor(t.expiresAt.getTime()/1e3).toString()),t.maxAmount&&r.searchParams.set(`max_amount`,t.maxAmount.toString()),t.requestMethods&&r.searchParams.set(`request_methods`,t.requestMethods.join(` `)),t.notificationTypes&&r.searchParams.set(`notification_types`,t.notificationTypes.join(` `)),t.isolated&&r.searchParams.set(`isolated`,`true`),t.metadata&&r.searchParams.set(`metadata`,JSON.stringify(t.metadata)),r}static fromAuthorizationUrl(t,n={},r){r||=Xs(Dt()),n.name||=document.location.host;let i=this.getAuthorizationUrl(t,n,At(Zs(r))),a=window.outerHeight/2+window.screenY-300,o=window.outerWidth/2+window.screenX-200;return new Promise((t,n)=>{let s=window.open(i.toString(),`${document.title} - Wallet Connect`,`height=600,width=400,top=${a},left=${o}`);if(!s)return void n(Error(`failed to execute window.open`));let c=a=>{let o=a.data;o&&o.type===`nwc:success`&&a.origin===`${i.protocol}//${i.host}`&&(o.relayUrl||n(Error(`no relayUrl in response`)),o.walletPubkey||n(Error(`no walletPubkey in response`)),t(new e({relayUrl:o.relayUrl,walletPubkey:o.walletPubkey,secret:r,lud16:o.lud16})),clearInterval(l),window.removeEventListener(`message`,c),s&&s.close())},l=setInterval(()=>{s&&s.closed&&(clearInterval(l),window.removeEventListener(`message`,c),n(Error(`Popup closed`)))},500);window.addEventListener(`message`,c)})}async getWalletServiceInfo(){var e;await this._checkConnected();let t=await new Promise((e,t)=>{let n=[],r=this.relay.subscribe([{kinds:[13194],limit:1,authors:[this.walletPubkey]}],{eoseTimeout:1e4});r.onevent=e=>{n.push(e)},r.oneose=()=>{r.close(),e(n)}});if(!t.length)throw Error(`no info event (kind 13194) returned from relay`);let n=t[0].content,r=t[0].tags.find(e=>e[0]===`notifications`),i=t[0].tags.find(e=>e[0]===`v`),a=t[0].tags.find(e=>e[0]===`encryption`),o=[`nip04`];return i&&i[1].includes(`1.0`)&&o.push(`nip44_v2`),a&&(o=a[1].split(` `)),{encryptions:o,capabilities:n.split(/[ |,]/g),notifications:(r==null||(e=r[1])==null?void 0:e.split(` `))||[]}}async getInfo(){try{return await this.executeNip47Request(`get_info`,{},e=>!!e.methods,{replyTimeout:1e4})}catch(e){throw console.error(`Failed to request get_info`,e),e}}async getBudget(){try{return await this.executeNip47Request(`get_budget`,{},e=>e!==void 0,{replyTimeout:1e4})}catch(e){throw console.error(`Failed to request get_budget`,e),e}}async getBalance(){try{return await this.executeNip47Request(`get_balance`,{},e=>e.balance!==void 0,{replyTimeout:1e4})}catch(e){throw console.error(`Failed to request get_balance`,e),e}}async payInvoice(e){try{return await this.executeNip47Request(`pay_invoice`,e,e=>!!e)}catch(e){throw console.error(`Failed to request pay_invoice`,e),e}}async payKeysend(e){try{return await this.executeNip47Request(`pay_keysend`,e,e=>!!e.preimage)}catch(e){throw console.error(`Failed to request pay_keysend`,e),e}}async signMessage(e){try{return await this.executeNip47Request(`sign_message`,e,t=>t.message===e.message&&!!t.signature)}catch(e){throw console.error(`Failed to request sign_message`,e),e}}async createConnection(e){try{return await this.executeNip47Request(`create_connection`,e,e=>!!e.wallet_pubkey)}catch(e){throw console.error(`Failed to request create_connection`,e),e}}async multiPayInvoice(e){try{return{invoices:await this.executeMultiNip47Request(`multi_pay_invoice`,e,e.invoices.length,e=>!!e.preimage),errors:[]}}catch(e){throw console.error(`Failed to request multi_pay_invoice`,e),e}}async multiPayKeysend(e){try{return{keysends:await this.executeMultiNip47Request(`multi_pay_keysend`,e,e.keysends.length,e=>!!e.preimage),errors:[]}}catch(e){throw console.error(`Failed to request multi_pay_keysend`,e),e}}async makeInvoice(e){try{if(!e.amount)throw Error(`No amount specified`);return await this.executeNip47Request(`make_invoice`,e,e=>!!e.invoice)}catch(e){throw console.error(`Failed to request make_invoice`,e),e}}async makeHoldInvoice(e){try{if(!e.amount)throw Error(`No amount specified`);if(!e.payment_hash)throw Error(`No payment hash specified`);return await this.executeNip47Request(`make_hold_invoice`,e,e=>!!e.invoice)}catch(e){throw console.error(`Failed to request make_hold_invoice`,e),e}}async settleHoldInvoice(e){try{return await this.executeNip47Request(`settle_hold_invoice`,e,e=>!!e)}catch(e){throw console.error(`Failed to request settle_hold_invoice`,e),e}}async cancelHoldInvoice(e){try{return await this.executeNip47Request(`cancel_hold_invoice`,e,e=>!!e)}catch(e){throw console.error(`Failed to request cancel_hold_invoice`,e),e}}async lookupInvoice(e){try{return await this.executeNip47Request(`lookup_invoice`,e,e=>!!e.invoice)}catch(e){throw console.error(`Failed to request lookup_invoice`,e),e}}async listTransactions(e){try{return await this.executeNip47Request(`list_transactions`,e,e=>!!e.transactions,{replyTimeout:1e4})}catch(e){throw console.error(`Failed to request list_transactions`,e),e}}async subscribeNotifications(e,t){var n=this;let r,i,a,o=!0;return async function(){for(;o;){try{await n._checkConnected(),await n._selectEncryptionType(),a=n.relay.subscribe([{kinds:[...n.encryptionType===`nip04`?[23196]:[23197]],authors:[n.walletPubkey],"#p":[n.publicKey]}],{}),console.info(`subscribed to relay`),a.onevent=async function(r){let i=await n.decrypt(n.walletPubkey,r.content),a;try{a=JSON.parse(i)}catch(e){console.error(`Failed to parse decrypted event content`,e);return}a.notification?(!t||t.indexOf(a.notification_type)>-1)&&e(a):console.error(`No notification in response`,a)},await new Promise(e=>{r=()=>{e()},i=()=>{console.info(`relay disconnected`),r?.()},n.relay.onclose=i}),i!==void 0&&(n.relay.onclose=null)}catch(e){console.error(`error subscribing to notifications`,e||`unknown relay error`)}o&&await new Promise(e=>setTimeout(e,1e3))}}(),()=>{var e;o=!1,r?.(),(e=a)==null||e.close()}}async executeNip47Request(e,t,n,r){var i=this;return await this._checkConnected(),await this._selectEncryptionType(),new Promise((a,o)=>{(async function(){let s={method:e,params:t},c=await i.encrypt(i.walletPubkey,JSON.stringify(s)),l={kind:23194,created_at:Math.floor(Date.now()/1e3),tags:[[`p`,i.walletPubkey],[`v`,i.encryptionType===`nip44_v2`?`1.0`:`0.0`],[`encryption`,i.encryptionType]],content:c},u=await i.signEvent(l),d=i.relay.subscribe([{kinds:[23195],authors:[i.walletPubkey],"#e":[u.id]}],{}),f=setTimeout(function(){d.close(),o(new rc(`reply timeout: event ${u.id}`,`INTERNAL`))},r?.replyTimeout||6e4);d.onevent=async function(e){clearTimeout(f),d.close();let t=await i.decrypt(i.walletPubkey,e.content),r;try{r=JSON.parse(t)}catch{clearTimeout(f),d.close(),o(new ac(`failed to deserialize response`,`INTERNAL`));return}r.result?n(r.result)?a(r.result):(clearTimeout(f),d.close(),o(new oc(`response from NWC failed validation: `+JSON.stringify(r.result),`INTERNAL`))):(clearTimeout(f),d.close(),o(new ec(r.error?.message||`unknown Error`,r.error?.code||`INTERNAL`)))};let p=setTimeout(function(){d.close(),o(new nc(`publish timeout: ${u.id}`,`INTERNAL`))},r?.publishTimeout||5e3);try{await i.relay.publish(u),clearTimeout(p)}catch(e){clearTimeout(p),o(new ic(`failed to publish: ${e}`,`INTERNAL`))}})()})}async executeMultiNip47Request(e,t,n,r,i){var a=this;await this._checkConnected(),await this._selectEncryptionType();let o=[];return new Promise((s,c)=>{(async function(){let l={method:e,params:t},u=await a.encrypt(a.walletPubkey,JSON.stringify(l)),d={kind:23194,created_at:Math.floor(Date.now()/1e3),tags:[[`p`,a.walletPubkey],[`v`,a.encryptionType===`nip44_v2`?`1.0`:`0.0`],[`encryption`,a.encryptionType]],content:u},f=await a.signEvent(d),p=a.relay.subscribe([{kinds:[23195],authors:[a.walletPubkey],"#e":[f.id]}],{}),m=setTimeout(function(){p.close(),c(new rc(`reply timeout: event ${f.id}`,`INTERNAL`))},i?.replyTimeout||6e4);p.onevent=async function(e){let t=await a.decrypt(a.walletPubkey,e.content),i;try{i=JSON.parse(t)}catch{clearTimeout(m),p.close(),c(new ac(`failed to deserialize response`,`INTERNAL`))}if(i.result){if(!r(i.result))return clearTimeout(m),p.close(),void c(new oc(`Response from NWC failed validation: `+JSON.stringify(i.result),`INTERNAL`));let t=e.tags.find(e=>e[0]===`d`)?.[1];if(t===void 0)return clearTimeout(m),p.close(),void c(new oc(`No d tag found in response event`,`INTERNAL`));o.push(Js({},i.result,{dTag:t})),o.length===n&&(clearTimeout(m),p.close(),s(o))}else clearTimeout(m),p.close(),c(new sc(i.error?.message,i.error?.code))};let h=setTimeout(function(){p.close(),c(new nc(`Publish timeout: ${f.id}`,`INTERNAL`))},i?.publishTimeout||5e3);try{await a.relay.publish(f),clearTimeout(h)}catch(e){clearTimeout(h),c(new ic(`Failed to publish: ${e}`,`INTERNAL`))}})()})}async _checkConnected(){if(!this.secret)throw Error(`Missing secret key`);if(!this.relayUrl)throw Error(`Missing relay url`);try{this.relay.connected||await this.relay.connect()}catch{throw console.error(`failed to connect to relay`,this.relayUrl),new $s(`Failed to connect to `+this.relayUrl,`OTHER`)}}async _selectEncryptionType(){if(!this._encryptionType){let e=await this.getWalletServiceInfo(),t=this._findPreferredEncryptionType(e.encryptions);if(!t)throw new cc(`no compatible encryption or version found between wallet and client`,`UNSUPPORTED_ENCRYPTION`);t===`nip04`&&console.warn(`NIP-04 encryption is about to be deprecated. Please upgrade your wallet service to use NIP-44 instead.`),this._encryptionType=t}}_findPreferredEncryptionType(e){return e.includes(`nip44_v2`)?`nip44_v2`:e.includes(`nip04`)?`nip04`:null}},uc=class{constructor(e,t){this.transaction=void 0,this.invoice=void 0,this._nwcClient=void 0,this._unsubscribeFunc=void 0,this._timeoutFunc=void 0,this._timeoutId=void 0,this.transaction=t,this.invoice=new Ns({pr:t.invoice}),this._nwcClient=e}onPaid(e){var t=this;return async function(){let n;try{n=(await t._nwcClient.getInfo()).notifications?.includes(`payment_received`)}catch{console.error(`failed to fetch info, falling back to polling`)}let r=n=>{t._unsubscribeFunc==null||t._unsubscribeFunc(),e(n)},i=e=>()=>{t._timeoutFunc=void 0,clearTimeout(t._timeoutId),e()};n?t._unsubscribeFunc=i(await t._nwcClient.subscribeNotifications(e=>{e.notification.payment_hash===t.transaction.payment_hash&&r(e.notification)},[`payment_received`])):(console.warn(`current connection does not support notifications, falling back to polling`),t._unsubscribeFunc=i(t._onPaidPollingFallback(r)))}(),this}onTimeout(e,t){return this._timeoutFunc=()=>{var e;(e=this._unsubscribeFunc)==null||e.call(this),t()},this._timeoutId=setTimeout(()=>{var e;(e=this._timeoutFunc)==null||e.call(this)},1e3*e),this}unsubscribe(){var e;(e=this._unsubscribeFunc)==null||e.call(this)}_onPaidPollingFallback(e){var t=this;let n=!0;return async function(){for(;n;){let r=await t._nwcClient.lookupInvoice({payment_hash:t.transaction.payment_hash});if(r.settled_at&&r.preimage){e(r),n=!1;break}await new Promise(e=>setTimeout(e,3e3))}}(),()=>{n=!1}}};async function dc(e){if(typeof e==`number`)return{satoshi:e,millisat:1e3*e};let t=await Promise.resolve(e.satoshi);return{satoshi:t,millisat:1e3*t}}var fc=class{constructor(e){this.nwcClient=void 0,this.nwcClient=typeof e==`string`?new lc({nostrWalletConnectUrl:e}):e instanceof lc?e:new lc(e)}async pay(e,t,n){let r=e,i=t?await dc(t):void 0;if(r.indexOf(`@`)>-1){var a,o;if(!i)throw Error(`Amount must be provided when paying to a lightning address`);let t=new qs(e);await t.fetch(),r=(await t.requestInvoice({satoshi:i.satoshi,comment:n==null||(a=n.metadata)==null?void 0:a.comment,payerdata:n==null||(o=n.metadata)==null?void 0:o.payer_data})).paymentRequest}let s=await this.nwcClient.payInvoice(Js({},n||{},{invoice:r,amount:i?.millisat}));return Js({},s,{invoice:new Ns({pr:r})})}async requestPayment(e,t){let n=await dc(e),r=await this.nwcClient.makeInvoice(Js({},t||{},{amount:n.millisat}));return new uc(this.nwcClient,r)}close(){this.nwcClient.close()}};function pc(e){let{toast:t}=un(),n=e?`nwc-connections:${e}`:`nwc-connections`,r=e?`nwc-active-connection:${e}`:`nwc-active-connection`,[i,a]=Jo(n,[]),[o,s]=Jo(r,null),[c,l]=(0,M.useState)({});return{connections:i,activeConnection:o,connectionInfo:c,addConnection:async(e,n)=>{let r=(e=>{try{return!e.startsWith(`nostr+walletconnect://`)&&!e.startsWith(`nostrwalletconnect://`)?(console.error(`Invalid NWC URI protocol:`,{protocol:e.split(`://`)[0]}),null):{connectionString:e}}catch(e){return console.error(`Failed to parse NWC URI:`,e),null}})(e);if(!r)return t({title:`Invalid NWC URI`,description:`Please check the connection string and try again.`,variant:`destructive`}),!1;if(i.find(e=>e.connectionString===r.connectionString))return t({title:`Connection already exists`,description:`This wallet is already connected.`,variant:`destructive`}),!1;try{let e,c=new Promise((e,t)=>{try{e(new fc(r.connectionString))}catch(e){t(e)}}),u=new Promise((t,n)=>{e=setTimeout(()=>n(Error(`Connection test timeout`)),1e4)});try{await Promise.race([c,u]),e&&clearTimeout(e)}catch(t){throw e&&clearTimeout(e),t}let d={connectionString:r.connectionString,alias:n||`NWC Wallet`,isConnected:!0};l(e=>({...e,[r.connectionString]:{alias:d.alias,methods:[`pay_invoice`]}}));let f=[...i,d];return a(f),(i.length===0||!o)&&s(r.connectionString),t({title:`Wallet connected`,description:`Successfully connected to ${d.alias}.`}),!0}catch(e){console.error(`NWC connection failed:`,e);let n=e instanceof Error?e.message:`Unknown error occurred`;return t({title:`Connection failed`,description:`Could not connect to the wallet: ${n}`,variant:`destructive`}),!1}},removeConnection:e=>{let n=i.filter(t=>t.connectionString!==e);if(a(n),o===e){let e=n.length>0?n[0].connectionString:null;s(e)}l(t=>{let n={...t};return delete n[e],n}),t({title:`Wallet disconnected`,description:`The wallet connection has been removed.`})},setActiveConnection:s,getActiveConnection:(0,M.useCallback)(()=>!o&&i.length>0?(s(i[0].connectionString),i[0]):o&&i.find(e=>e.connectionString===o)||null,[o,i,s]),sendPayment:(0,M.useCallback)(async(e,t,n)=>{if(!e.connectionString)throw Error(`Invalid connection: missing connection string`);Yn(t,n);let r;try{r=new fc(e.connectionString)}catch(e){throw console.error(`Failed to create NWC client:`,e),Error(`Failed to create NWC client: ${e instanceof Error?e.message:`Unknown error`}`)}try{let e,n=new Promise((t,n)=>{e=setTimeout(()=>n(Error(`Payment timeout after 15 seconds`)),15e3)}),i=r.pay(t);try{let t=await Promise.race([i,n]);return e&&clearTimeout(e),t}catch(t){throw e&&clearTimeout(e),t}}catch(e){throw console.error(`NWC payment failed:`,e),e instanceof Error?e.message.includes(`timeout`)?Error(`Payment timed out. Please try again.`):e.message.includes(`insufficient`)?Error(`Insufficient balance in connected wallet.`):e.message.includes(`invalid`)?Error(`Invalid invoice or connection. Please check your wallet.`):Error(`Payment failed: ${e.message}`):Error(`Payment failed with unknown error`)}},[])}}function mc({children:e}){let{user:t}=cn(),n=pc(t?.pubkey);return(0,N.jsx)(Xn.Provider,{value:n,children:e})}function hc({children:e}){let[t,n]=(0,M.useState)(!1),[r,i]=(0,M.useState)(null),a=(0,M.useCallback)(e=>{i(e?.role??null),n(!0)},[]),o=(0,M.useCallback)(()=>{n(!1)},[]),s=(0,M.useCallback)(e=>{i(e)},[]);return(0,N.jsx)($n.Provider,{value:{active:t,role:r,startSignup:a,cancel:o,setRole:s},children:e})}function gc(e,t){return typeof e==`string`&&e.length===t&&/^[0-9a-fA-F]+$/.test(e)}function _c(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0}function vc(e){if(e.length!==68||!e.toLowerCase().startsWith(`5120`))return null;try{return dr(e.slice(4))}catch{return null}}function yc(e){if(!gc(e.txid,64)||!_c(e.vout)||!_c(e.value)||typeof e.scriptpubkey!=`string`)return null;let t=vc(e.scriptpubkey);return t?{txid:e.txid.toLowerCase(),vout:e.vout,xonlyPk:t,value:e.value,spent:e.spent===!0}:null}function bc(e){return e.replace(/\/+$/,``)}function xc(e){let t=bc(e);if(!t)throw Error(`BIP-352 indexer base URL must not be empty`);return t}async function Sc(e,t,n){let r=await fetch(`${e}/tweaks/${t}`,{signal:n});if(!r.ok)throw Error(`BIP-352 /tweaks/${t} returned ${r.status}`);let i=await r.json();if(!Array.isArray(i))throw Error(`BIP-352 /tweaks/${t} response is not an array`);let a=[];for(let e of i)if(gc(e,66))try{a.push(dr(e.toLowerCase()))}catch{}return a}async function Cc(e,t,n,r=!1){let i=await fetch(`${e}/utxos/${t}`,{signal:n});if(!i.ok)throw Error(`BIP-352 /utxos/${t} returned ${i.status}`);let a=await i.json();if(!Array.isArray(a))throw Error(`BIP-352 /utxos/${t} response is not an array`);let o=[];for(let e of a){if(!r&&e&&e.spent===!0)continue;let t=yc(e);t&&o.push(t)}return o}async function wc(e,t){let n=xc(e),r=await fetch(`${n}/info`,{signal:t});if(!r.ok)throw Error(`BIP-352 /info returned ${r.status}`);let i=(await r.json()).height;if(!_c(i))throw Error("BIP-352 /info response missing valid `height`");return i}async function Tc(e,t,n,r=!1){let i=xc(e),a=await Sc(i,t,n);if(a.length===0||n?.aborted)return[];let o=await Cc(i,t,n,r);if(o.length===0)return[];let s=o;return a.map(e=>({height:t,tweak:e,outputs:s}))}var Ec=`agora-sp-block-cache`,Dc=1,Oc=`blocks`,kc=null;function Ac(){return kc||(kc=new Promise((e,t)=>{if(typeof indexedDB>`u`){t(Error(`IndexedDB not available`));return}let n=indexedDB.open(Ec,Dc);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(Oc)||e.createObjectStore(Oc,{keyPath:`key`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),kc.catch(()=>{kc=null}),kc)}async function jc(e,t){return new Promise(n=>{let r=e.transaction(Oc,`readonly`).objectStore(Oc).get(t);r.onsuccess=()=>n(r.result),r.onerror=()=>n(void 0)})}async function Mc(e,t){return new Promise(n=>{let r=e.transaction(Oc,`readwrite`).objectStore(Oc).put(t);r.onsuccess=()=>n(),r.onerror=()=>n()})}async function Nc(e,t,n,r=!1){let i=e.replace(/\/+$/,``),a=`${i}|${t}`,o=null;try{o=await Ac();let e=await jc(o,a);if(e&&(!r||e.includeSpent))return e.entries}catch{}let s=await Tc(i,t,n,r);return o&&Mc(o,{key:a,indexerUrl:i,height:t,includeSpent:r,entries:s}).catch(()=>{}),s}function Pc(e,t,n){if(t.length!==32)throw Error(`bscan must be 32 bytes`);if(n.length!==33)throw Error(`Bspend must be 33-byte compressed`);if(e.tweak.length!==33)throw Error(`entry.tweak must be 33-byte compressed`);let r;try{r=mr(e.tweak,t)}catch{return[]}if(e.outputs.length===0)return[];let i=new Set(e.outputs.map((e,t)=>t)),a=[],o=r,s=0;for(;i.size>0;){let{xonlyPk:t,tweak:r}=hr(o,n,s),c=null;for(let n of i)if(gr(e.outputs[n].xonlyPk,t)){c=n;break}if(c===null)break;let l=e.outputs[c];a.push({txid:l.txid,vout:l.vout,value:l.value,height:e.height,tweak:r,k:s,...l.spent?{spent:!0}:{}}),i.delete(c),s+=1}return a}async function Fc(e,t,n,r={}){let i=r.yieldEvery??64,a=[],o=-1,s=0;for(let c of e){if(r.signal?.aborted)break;try{let e=Pc(c,t,n);e.length>0&&a.push(...e)}catch{}c.height>o&&(o=c.height),s+=1,s>=i&&(s=0,r.onProgress?.(o),await new Promise(e=>setTimeout(e,0)))}return o>=0&&r.onProgress?.(o),a}function Ic(e,t){if(typeof Worker>`u`)return null;let n;try{n=new Worker(new URL(`/assets/scan.worker-COaZTFoz.js`,``+import.meta.url),{type:`module`})}catch{return null}let r=new Map,i=1,a=!1,o=n=>Fc(n,e,t),s=()=>{a=!0;for(let[,e]of r)o(e.entries).then(e.resolve,e.reject);r.clear()};return n.onmessage=e=>{let t=e.data,n=r.get(t.id);n&&(r.delete(t.id),t.type===`result`?n.resolve(t.matches):o(n.entries).then(n.resolve,n.reject))},n.onerror=()=>{s()},n.postMessage({type:`init`,bscan:e,Bspend:t}),{scanEntries(e){if(a)return o(e);let t=i++;return new Promise((i,a)=>{r.set(t,{resolve:i,reject:a,entries:e});try{n.postMessage({type:`scan`,id:t,entries:e})}catch{r.delete(t),o(e).then(i,a)}})},terminate(){a=!0;try{n.terminate()}catch{}for(let[,e]of r)e.reject(Error(`scan worker terminated`));r.clear()}}}var Lc=`hdwallet/sp-utxos/v2`;function Rc(e){return`${e}/${Lc}`}var zc=`hdwallet/sp-utxos`;function Bc(e){return`${e}/${zc}`}var Vc={version:1,scanHeight:0,utxos:[],spent:[]};function Hc(e){let t;try{t=JSON.parse(e)}catch{return{...Vc}}if(!t||typeof t!=`object`)return{...Vc};let n=t;return{version:1,scanHeight:typeof n.scanHeight==`number`&&Number.isInteger(n.scanHeight)&&n.scanHeight>=0?n.scanHeight:0,utxos:Uc(n.utxos),spent:Uc(n.spent)}}function Uc(e){let t=Array.isArray(e)?e:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.txid!=`string`||!/^[0-9a-f]{64}$/.test(t.txid)||typeof t.vout!=`number`||!Number.isInteger(t.vout)||t.vout<0||typeof t.value!=`number`||!Number.isInteger(t.value)||t.value<0||typeof t.height!=`number`||!Number.isInteger(t.height)||t.height<0||typeof t.tweak!=`string`||!/^[0-9a-f]{64}$/.test(t.tweak)||typeof t.k!=`number`||!Number.isInteger(t.k)||t.k<0)continue;let r=typeof t.time==`number`&&Number.isInteger(t.time)&&t.time>0?t.time:void 0,i=typeof t.spentTxid==`string`&&/^[0-9a-f]{64}$/.test(t.spentTxid)?t.spentTxid:void 0,a=typeof t.spentHeight==`number`&&Number.isInteger(t.spentHeight)&&t.spentHeight>0?t.spentHeight:void 0,o=typeof t.spentTime==`number`&&Number.isInteger(t.spentTime)&&t.spentTime>0?t.spentTime:void 0;n.push({txid:t.txid,vout:t.vout,value:t.value,height:t.height,tweak:t.tweak,k:t.k,...r===void 0?{}:{time:r},...i===void 0?{}:{spentTxid:i},...a===void 0?{}:{spentHeight:a},...o===void 0?{}:{spentTime:o}})}return n}function Wc(e){return JSON.stringify({version:1,scanHeight:e.scanHeight,utxos:e.utxos,spent:e.spent??[]})}function Gc(e){return{txid:e.txid,vout:e.vout,value:e.value,height:e.height,tweak:pr(e.tweak),k:e.k}}function Kc(e,t){let n=e=>`${e.txid}:${e.vout}`,r=new Map;for(let t of e)r.set(n(t),t);for(let e of t){let t=n(e),i=r.get(t);if(!i){r.set(t,e);continue}let a={...e};a.time===void 0&&i.time!==void 0&&(a.time=i.time),a.spentTxid===void 0&&i.spentTxid!==void 0&&(a.spentTxid=i.spentTxid,a.spentHeight===void 0&&i.spentHeight!==void 0&&(a.spentHeight=i.spentHeight),a.spentTime===void 0&&i.spentTime!==void 0&&(a.spentTime=i.spentTime)),r.set(t,a)}return Array.from(r.values())}function qc(e){let t=0;for(let n of e.utxos)t+=n.value;return t}function Jc(e,t){if(t.length===0)return e.slice();let n=new Set(t.map(e=>`${e.txid}:${e.vout}`));return e.filter(e=>!n.has(`${e.txid}:${e.vout}`))}function Yc(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[`${e.txid}:${e.vout}`,e])),r=[],i=[];for(let t of e.utxos){let e=n.get(`${t.txid}:${t.vout}`);e?i.push(Xc(t,e)):r.push(t)}if(i.length===0)return e;let a=e.spent??[],o=new Map;for(let e of a)o.set(`${e.txid}:${e.vout}`,e);for(let e of i){let t=`${e.txid}:${e.vout}`,n=o.get(t);n?n.spentTxid===void 0&&e.spentTxid!==void 0&&o.set(t,Xc(n,e)):o.set(t,e)}return{version:1,scanHeight:e.scanHeight,utxos:r,spent:Array.from(o.values())}}function Xc(e,t){return t.spentTxid===void 0&&t.spentHeight===void 0&&t.spentTime===void 0?e:{...e,...t.spentTxid===void 0?{}:{spentTxid:t.spentTxid},...t.spentHeight===void 0?{}:{spentHeight:t.spentHeight},...t.spentTime===void 0?{}:{spentTime:t.spentTime}}}function Zc(e,t){let n=e.spent??[];if(t.length===0||n.length===0)return e;let r=new Map(t.map(e=>[`${e.txid}:${e.vout}`,e])),i=!1,a=n.map(e=>{if(e.spentTxid!==void 0)return e;let t=r.get(`${e.txid}:${e.vout}`);return!t||t.spentTxid===void 0?e:(i=!0,Xc(e,t))});return i?{...e,spent:a}:e}var Qc=144,$c=1008,el=50,tl=8,nl=1,rl=32;function il(e){return Number.isInteger(e)?Math.min(rl,Math.max(nl,e)):tl}var al=`hdwallet:sp:auto-scan`,ol=5e3;function sl(e,t){return`hdwallet:sp:checkpoint:${e}:${t}`}function cl(e,t){if(!e||!t)return 0;try{let n=localStorage.getItem(sl(e,t));if(n===null)return 0;let r=Number(n);return Number.isInteger(r)&&r>=0?r:0}catch{return 0}}function ll(e,t,n){if(!(!e||!t))try{let r=sl(e,t);if(n<=cl(e,t))return;localStorage.setItem(r,String(n))}catch{}}var ul={enabled:!1,balance:0,isLoading:!1,isScanning:!1,isAutoScanning:!1,autoScanEnabled:!0,setAutoScanEnabled:()=>{},scanRange:async()=>{},scanRecent:async()=>{},cancelScan:()=>{},pruneSpentUtxos:()=>{},correctUtxoValues:()=>{},isReconciling:!1,reconcileSpentUtxos:async()=>0};function dl(){let{config:e}=Zt(),{user:t}=cn(),{nostr:n}=ct(),r=ir(),i=xt(),a=(e.bip352IndexerUrl??``).trim(),o=(e.blockbookBaseUrl??``).trim(),s=il(e.bip352ScanConcurrency),c=r.status===`available`?r.pubkey:``,l=r.status===`available`?r.seed:void 0,u=(0,M.useMemo)(()=>{if(l)return nr(l)},[l]),d=r.status===`logged-out`?`logged-out`:r.status===`unsupported`?`unsupported-signer`:a===``?`no-indexer`:void 0,f=d===void 0,p=Rc(e.appId),m=`${c}:${p}`,{data:h}=_t({queryKey:[`hdwallet-sp-tip`,a],queryFn:({signal:e})=>wc(a,e),enabled:f,refetchInterval:6e4,staleTime:3e4,refetchOnWindowFocus:!1}),g=_t({queryKey:[`hdwallet-sp-event`,c,p],queryFn:async({signal:e})=>{if(!t)return null;let r=await n.query([{kinds:[30078],authors:[t.pubkey],"#d":[p],limit:1}],{signal:AbortSignal.any([e,AbortSignal.timeout(8e3)])});return r.length===0?null:r.reduce((e,t)=>t.created_at>e.created_at?t:e)},enabled:f&&!!t,staleTime:3e5,refetchOnWindowFocus:!0,refetchOnMount:!1,refetchOnReconnect:!1}),_=_t({queryKey:[`hdwallet-sp-doc`,c,g.data?.id??`(none)`],queryFn:async()=>{let e=g.data;if(!e||!t?.signer.nip44||!e.content)return{...Vc};try{return Hc(await t.signer.nip44.decrypt(t.pubkey,e.content))}catch(e){return console.warn(`Failed to decrypt SP storage event; treating as empty:`,e),{...Vc}}},enabled:f&&!!t&&g.isFetched,staleTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),v=(0,M.useRef)(null),[y,b]=(0,M.useState)(0),x=(0,M.useRef)(m);x.current!==m&&(x.current=m,v.current=null);let S=(0,M.useMemo)(()=>{if(!f||!_.data)return;let e=_.data,t=v.current;if(!t)return e;let n=t.utxos.length+(t.spent?.length??0),r=e.utxos.length+(e.spent?.length??0);return t.scanHeight>=e.scanHeight&&n>=r?t:e},[f,_.data]),C=Pt({mutationFn:async r=>{let{next:i,spent:a,owner:o,purge:s}=r;if(!t)throw Error(`not logged in`);if(o!==t.pubkey)throw Error(`SP storage publish dropped: wallet identity changed since this document was built`);let c=new Set((s??[]).map(e=>`${e.txid}:${e.vout}`));if(!t.signer.nip44)throw Error(`signer does not support NIP-44`);let l=await fn(n,{kinds:[30078],authors:[t.pubkey],"#d":[p]}),u=i;if(l?.content)try{let e=Hc(await t.signer.nip44.decrypt(t.pubkey,l.content)),n=(a&&a.length>0?Jc(e.utxos,a):e.utxos).filter(e=>!c.has(`${e.txid}:${e.vout}`)),r=(i.spent??[]).filter(e=>!c.has(`${e.txid}:${e.vout}`)),o=(e.spent??[]).filter(e=>!c.has(`${e.txid}:${e.vout}`)),s=new Map;for(let e of o)s.set(`${e.txid}:${e.vout}`,e);for(let e of r){let t=`${e.txid}:${e.vout}`,n=s.get(t);(!n||n.spentTxid===void 0&&e.spentTxid!==void 0)&&s.set(t,e)}if(a&&a.length>0){let t=new Map(a.map(e=>[`${e.txid}:${e.vout}`,e]));for(let n of e.utxos){let e=`${n.txid}:${n.vout}`,r=t.get(e);r&&!s.has(e)&&s.set(e,{...n,...r.spentTxid===void 0?{}:{spentTxid:r.spentTxid},...r.spentHeight===void 0?{}:{spentHeight:r.spentHeight},...r.spentTime===void 0?{}:{spentTime:r.spentTime}})}}u={version:1,scanHeight:Math.max(e.scanHeight,i.scanHeight),utxos:Kc(n,i.utxos).filter(e=>!s.has(`${e.txid}:${e.vout}`)&&!c.has(`${e.txid}:${e.vout}`)),spent:Array.from(s.values())}}catch{}let d={kind:30078,content:await t.signer.nip44.encrypt(t.pubkey,Wc(u)),tags:[[`d`,p],[`title`,`${e.appName} HD Wallet — Silent Payment UTXOs`],[`client`,e.appName,...e.client?[e.client]:[]],[`alt`,`Encrypted silent-payment UTXO set for the HD wallet`]],created_at:Math.floor(Date.now()/1e3)},f=await t.signer.signEvent(d);return n.event(f,{signal:AbortSignal.timeout(5e3)}).catch(e=>{console.warn(`Failed to publish SP storage event:`,e)}),{merged:u,signed:f}},onSuccess:({merged:e,signed:t})=>{t.pubkey===c&&(i.setQueryData([`hdwallet-sp-event`,c,p],t),i.setQueryData([`hdwallet-sp-doc`,c,t.id],e))}}),[ee,te]=(0,M.useState)(),[w,ne]=(0,M.useState)(),[re,ie]=(0,M.useState)(!1),[ae,oe]=(0,M.useState)(!1),se=(0,M.useRef)(null),ce=(0,M.useRef)(null),T=(0,M.useRef)(!1),E=(0,M.useRef)(0),le=(0,M.useCallback)(()=>{se.current?.abort()},[]),ue=(0,M.useCallback)(()=>{ce.current&&=(clearTimeout(ce.current),null);let e=v.current;e&&(T.current=!1,C.mutate({next:e,owner:c}))},[C,c]),de=(0,M.useCallback)(()=>{ce.current||T.current&&(ce.current=setTimeout(()=>{ce.current=null;let e=v.current;e&&T.current&&(T.current=!1,C.mutate({next:e,owner:c}))},5e3))},[C,c]),fe=(0,M.useCallback)(async({fromHeight:e,toHeight:t,includeSpent:n=!1,auto:r=!1})=>{if(!f||!u||!S)return;if(!Number.isInteger(e)||e<0)throw Error(`Invalid fromHeight: ${e}`);let i=t??h??await wc(a);if(!Number.isInteger(i)||i{for(;x<=i&&y.size0&&(f=_?await _.scanEntries(r):await Fc(r,u.bscan,u.Bspend,{signal:l.signal})),f.length>0){let e;if(o)try{e=await ar(o,t,l.signal)}catch(e){console.warn(`Failed to fetch block time for height ${t}:`,e)}let n=[],r=[];for(let t of f){let i=Gc(t),a=e===void 0?i:{...i,time:e};t.spent?r.push(a):n.push(a)}let i=v.current,a=new Set([...i.spent??[],...r].map(e=>`${e.txid}:${e.vout}`));v.current={version:1,scanHeight:i.scanHeight,utxos:Kc(i.utxos,n).filter(e=>!a.has(`${e.txid}:${e.vout}`)),spent:Kc(i.spent??[],r)},d+=f.length,T.current=!0}if(g&&t===p+1){p=t;let e=v.current;v.current={...e,scanHeight:Math.max(e.scanHeight,p)};let n=Date.now();n-E.current>=ol&&(E.current=n,ll(c,a,p))}te({fromHeight:e,toHeight:i,currentHeight:t,matchesFound:d}),b(e=>e+1),de()}}catch(e){l.signal.aborted||ne(e instanceof Error?e:Error(String(e)))}finally{if(_?.terminate(),y.size>0){l.signal.aborted||l.abort();for(let e of y.values())e.catch(()=>{});y.clear()}ie(!1),oe(!1),v.current&&ll(c,a,v.current.scanHeight),ue(),se.current===l&&(se.current=null)}},[f,u,S,h,a,o,c,s,de,ue]),pe=(0,M.useCallback)(e=>fe({...e,auto:!1}),[fe]),me=(0,M.useCallback)(async()=>{if(!f)return;let e=h??await wc(a),t=Math.max(0,e-Qc+1);await pe({fromHeight:t,toHeight:e})},[f,a,h,pe]),he=(0,M.useMemo)(()=>S?qc(S):0,[S]),ge=(0,M.useRef)(S);ge.current=S;let[_e,ve]=Yt(al,!0),ye=(0,M.useCallback)(e=>ve(e),[ve]),be=(0,M.useRef)(0);(0,M.useEffect)(()=>{be.current=0},[c,a]),(0,M.useEffect)(()=>{if(!f||!_e||!S||h===void 0||re)return;let e=cl(c,a),t=Math.max(S.scanHeight,e),n=t>0?t+1:Math.max(0,h-$c+1);n>h||h<=be.current||(be.current=h,fe({fromHeight:n,toHeight:h,auto:!0}).catch(e=>{console.warn(`Automatic SP scan failed:`,e),be.current=0}))},[f,_e,S,h,re,fe,c,a]);let xe=(0,M.useCallback)((e,t)=>{if(!e.length&&!t?.length)return;ce.current&&=(clearTimeout(ce.current),null),T.current=!1;let n=ge.current??v.current;if(!n)return;let r=Yc(n,e);t&&t.length>0&&(r={...r,utxos:Kc(r.utxos,t)}),v.current=r,b(e=>e+1);let a=i.getQueryData([`hdwallet-sp-event`,c,p])?.id;a&&i.setQueryData([`hdwallet-sp-doc`,c,a],r),C.mutate({next:r,spent:e,owner:c})},[C,i,c,p]),Se=(0,M.useCallback)(e=>{if(!e.length)return;let t=ge.current??v.current;if(!t)return;let n=new Map(e.map(e=>[`${e.txid}:${e.vout}`,e.value])),r=!1,a=t.utxos.map(e=>{let t=n.get(`${e.txid}:${e.vout}`);return t===void 0||t===e.value?e:(r=!0,{...e,value:t})});if(!r)return;let o={...t,utxos:a};v.current=o,b(e=>e+1);let s=i.getQueryData([`hdwallet-sp-event`,c,p])?.id;s&&i.setQueryData([`hdwallet-sp-doc`,c,s],o),C.mutate({next:o,owner:c})},[C,i,c,p]),[Ce,we]=(0,M.useState)(!1),[Te,Ee]=(0,M.useState)(),[De,Oe]=(0,M.useState)(),ke=(0,M.useRef)(null),Ae=(0,M.useCallback)(async()=>{if(!f||!o)return 0;let e=ge.current;if(!e||e.utxos.length===0)return 0;let t=new Set,n=[];for(let r of e.utxos)!t.has(r.txid)&&t.size>=el||(t.add(r.txid),n.push({txid:r.txid,vout:r.vout}));if(n.length===0)return 0;ke.current?.abort();let r=new AbortController;ke.current=r,Oe(void 0),we(!0),Ee({total:n.length,checked:0,prunedSoFar:0});try{let e=await sr(o,n,r.signal);if(r.signal.aborted)return 0;let t=[];for(let r of n){let n=e.get(`${r.txid}:${r.vout}`);n?.spent===!0&&t.push({...r,...n.spentTxid===void 0?{}:{spentTxid:n.spentTxid},...n.spentHeight===void 0?{}:{spentHeight:n.spentHeight}})}return Ee({total:n.length,checked:n.length,prunedSoFar:t.length}),t.length>0&&xe(t),t.length}catch(e){if(r.signal.aborted)return 0;let t=e instanceof Error?e:Error(String(e));throw Oe(t),t}finally{we(!1),ke.current===r&&(ke.current=null)}},[f,o,xe]),je=(0,M.useRef)(null),Me=(0,M.useRef)(null);(0,M.useEffect)(()=>()=>Me.current?.abort(),[]),(0,M.useEffect)(()=>{if(!f||!o||!S||je.current===m||re)return;let e=S.utxos.filter(e=>e.time===void 0);if(e.length===0)return;je.current=m;let t=new AbortController;Me.current=t,(async()=>{let n=Array.from(new Set(e.map(e=>e.height))).slice(0,50),r=new Map;for(let e of n){if(t.signal.aborted)return;try{let n=await ar(o,e,t.signal);r.set(e,n)}catch(t){console.warn(`Failed to backfill block time for height ${e}:`,t)}}if(r.size===0||t.signal.aborted)return;let i=v.current??S,a={version:1,scanHeight:i.scanHeight,utxos:i.utxos.map(e=>{if(e.time!==void 0)return e;let t=r.get(e.height);return t===void 0?e:{...e,time:t}}),spent:(i.spent??[]).slice()};v.current=a,b(e=>e+1),C.mutate({next:a,owner:c})})()},[f,o,S,m]);let Ne=(0,M.useRef)(null),Pe=(0,M.useRef)(null);(0,M.useEffect)(()=>()=>Pe.current?.abort(),[]);let Fe=(0,M.useRef)(null),Ie=(0,M.useRef)(null);(0,M.useEffect)(()=>()=>Ie.current?.abort(),[]);let Le=(0,M.useRef)(m);return(0,M.useLayoutEffect)(()=>{Le.current!==m&&(Le.current=m,se.current?.abort(),ke.current?.abort(),Me.current?.abort(),Pe.current?.abort(),Ie.current?.abort(),ce.current&&=(clearTimeout(ce.current),null),T.current=!1)},[m]),(0,M.useEffect)(()=>{if(!f||!o||!S||Ne.current===m||re)return;let e=(S.spent??[]).filter(e=>e.spentTxid===void 0);if(e.length===0)return;Ne.current=m;let t=new AbortController;Pe.current=t,(async()=>{let n=e.slice(0,25),r=await sr(o,n,t.signal);if(t.signal.aborted)return;let i=[];for(let e of n){let t=r.get(`${e.txid}:${e.vout}`);t?.spent===!0&&t.spentTxid!==void 0&&i.push({txid:e.txid,vout:e.vout,spentTxid:t.spentTxid,...t.spentHeight===void 0?{}:{spentHeight:t.spentHeight}})}if(i.length===0)return;let a=Array.from(new Set(i.map(e=>e.spentHeight).filter(e=>e!==void 0))),s=new Map;for(let e of a){if(t.signal.aborted)return;try{s.set(e,await ar(o,e,t.signal))}catch(t){console.warn(`Failed to fetch block time for spend height ${e}:`,t)}}for(let e of i){let t=e.spentHeight===void 0?void 0:s.get(e.spentHeight);t!==void 0&&(e.spentTime=t)}if(t.signal.aborted)return;let l=v.current??S,u=Zc(l,i);u!==l&&(v.current=u,b(e=>e+1),C.mutate({next:u,owner:c}))})().catch(e=>{console.warn(`Failed to backfill SP spender info:`,e)})},[f,o,S,m]),(0,M.useEffect)(()=>{if(!f||!o||!S||!u||Fe.current===m||re)return;let e=[...S.utxos,...S.spent??[]];if(e.length===0)return;Fe.current=m;let t=new AbortController;Ie.current=t,(async()=>{let n=new Map;for(let t of e){let e=n.get(t.txid)??[];e.push({vout:t.vout,tweak:t.tweak}),n.set(t.txid,e)}let r=[],a=0;for(let[e,i]of n){if(a>=25)break;if(t.signal.aborted)return;a+=1;let n;try{n=await or(o,e,t.signal)}catch{continue}for(let t of i){let i=n.find(e=>e.n===t.vout);if(!i?.scriptHex)continue;let a=`5120`+pr(fr(u.Bspend,dr(t.tweak)));i.scriptHex!==a&&r.push({txid:e,vout:t.vout})}}if(r.length===0||t.signal.aborted)return;let s=new Set(r.map(e=>`${e.txid}:${e.vout}`)),l=v.current??S,d={version:1,scanHeight:l.scanHeight,utxos:l.utxos.filter(e=>!s.has(`${e.txid}:${e.vout}`)),spent:(l.spent??[]).filter(e=>!s.has(`${e.txid}:${e.vout}`))};console.warn(`SP ownership audit: purging ${r.length} foreign entries from wallet storage`),v.current=d,b(e=>e+1);let f=i.getQueryData([`hdwallet-sp-event`,c,p])?.id;f&&i.setQueryData([`hdwallet-sp-doc`,c,f],d),C.mutate({next:d,purge:r,owner:c})})().catch(e=>{console.warn(`SP ownership audit failed:`,e)})},[f,o,S,u,m]),f?{enabled:f,keys:u,storage:S,balance:he,isLoading:g.isLoading||_.isLoading,scanProgress:ee,isScanning:re,isAutoScanning:ae,scanError:w,autoScanEnabled:_e,setAutoScanEnabled:ye,tipHeight:h,scanRange:pe,scanRecent:me,cancelScan:le,pruneSpentUtxos:xe,correctUtxoValues:Se,isReconciling:Ce,reconcileProgress:Te,reconcileError:De,reconcileSpentUtxos:Ae}:{...ul,unavailableReason:d,keys:u}}var fl=(0,M.createContext)(null);function pl(){let e=(0,M.useContext)(fl);if(!e)throw Error(`useHdWalletSp must be used within an HdWalletSpProvider`);return e}function ml({children:e}){let t=dl();return(0,N.jsx)(fl.Provider,{value:t,children:e})}var hl=e(Le(),1),gl=`DismissableLayer`,_l=`dismissableLayer.update`,vl=`dismissableLayer.pointerDownOutside`,yl=`dismissableLayer.focusOutside`,bl,xl=M.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Sl=M.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=M.useContext(xl),[u,d]=M.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=M.useState({}),m=Fn(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=Tl(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=El(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return Ln(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),M.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(bl=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),Dl(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=bl)}},[u,f,n,l]),M.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),Dl())},[u,l]),M.useEffect(()=>{let e=()=>p({});return document.addEventListener(_l,e),()=>document.removeEventListener(_l,e)},[]),(0,N.jsx)(jr.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:Or(e.onFocusCapture,S.onFocusCapture),onBlurCapture:Or(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:Or(e.onPointerDownCapture,x.onPointerDownCapture)})});Sl.displayName=gl;var Cl=`DismissableLayerBranch`,wl=M.forwardRef((e,t)=>{let n=M.useContext(xl),r=M.useRef(null),i=Fn(t,r);return M.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,N.jsx)(jr.div,{...e,ref:i})});wl.displayName=Cl;function Tl(e,t=globalThis?.document){let n=In(e),r=M.useRef(!1),i=M.useRef(()=>{});return M.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){Ol(vl,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function El(e,t=globalThis?.document){let n=In(e),r=M.useRef(!1);return M.useEffect(()=>{let e=e=>{e.target&&!r.current&&Ol(yl,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Dl(){let e=new CustomEvent(_l);document.dispatchEvent(e)}function Ol(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Ar(i,a):i.dispatchEvent(a)}var kl=Sl,Al=wl,jl=`Portal`,Ml=M.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=M.useState(!1);Re(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?hl.createPortal((0,N.jsx)(jr.div,{...r,ref:t}),o):null});Ml.displayName=jl;var Nl=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Pl=`VisuallyHidden`,Fl=M.forwardRef((e,t)=>(0,N.jsx)(jr.span,{...e,ref:t,style:{...Nl,...e.style}}));Fl.displayName=Pl;var Il=`ToastProvider`,[Ll,Rl,zl]=kr(`Toast`),[Bl,Vl]=Ie(`Toast`,[zl]),[Hl,Ul]=Bl(Il),Wl=e=>{let{__scopeToast:t,label:n=`Notification`,duration:r=5e3,swipeDirection:i=`right`,swipeThreshold:a=50,children:o}=e,[s,c]=M.useState(null),[l,u]=M.useState(0),d=M.useRef(!1),f=M.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Il}\`. Expected non-empty \`string\`.`),(0,N.jsx)(Ll.Provider,{scope:t,children:(0,N.jsx)(Hl,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:a,toastCount:l,viewport:s,onViewportChange:c,onToastAdd:M.useCallback(()=>u(e=>e+1),[]),onToastRemove:M.useCallback(()=>u(e=>e-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:f,children:o})})};Wl.displayName=Il;var Gl=`ToastViewport`,Kl=[`F8`],ql=`toast.viewportPause`,Jl=`toast.viewportResume`,Yl=M.forwardRef((e,t)=>{let{__scopeToast:n,hotkey:r=Kl,label:i=`Notifications ({hotkey})`,...a}=e,o=Ul(Gl,n),s=Rl(n),c=M.useRef(null),l=M.useRef(null),u=M.useRef(null),d=M.useRef(null),f=Fn(t,d,o.onViewportChange),p=r.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),m=o.toastCount>0;M.useEffect(()=>{let e=e=>{r.length!==0&&r.every(t=>e[t]||e.code===t)&&d.current?.focus()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),M.useEffect(()=>{let e=c.current,t=d.current;if(m&&e&&t){let n=()=>{if(!o.isClosePausedRef.current){let e=new CustomEvent(ql);t.dispatchEvent(e),o.isClosePausedRef.current=!0}},r=()=>{if(o.isClosePausedRef.current){let e=new CustomEvent(Jl);t.dispatchEvent(e),o.isClosePausedRef.current=!1}},i=t=>{e.contains(t.relatedTarget)||r()},a=()=>{e.contains(document.activeElement)||r()};return e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,i),e.addEventListener(`pointermove`,n),e.addEventListener(`pointerleave`,a),window.addEventListener(`blur`,n),window.addEventListener(`focus`,r),()=>{e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,i),e.removeEventListener(`pointermove`,n),e.removeEventListener(`pointerleave`,a),window.removeEventListener(`blur`,n),window.removeEventListener(`focus`,r)}}},[m,o.isClosePausedRef]);let h=M.useCallback(({tabbingDirection:e})=>{let t=s().map(t=>{let n=t.ref.current,r=[n,..._u(n)];return e===`forwards`?r:r.reverse()});return(e===`forwards`?t.reverse():t).flat()},[s]);return M.useEffect(()=>{let e=d.current;if(e){let t=t=>{let n=t.altKey||t.ctrlKey||t.metaKey;if(t.key===`Tab`&&!n){let n=document.activeElement,r=t.shiftKey;if(t.target===e&&r){l.current?.focus();return}let i=h({tabbingDirection:r?`backwards`:`forwards`}),a=i.findIndex(e=>e===n);vu(i.slice(a+1))?t.preventDefault():r?l.current?.focus():u.current?.focus()}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}},[s,h]),(0,N.jsxs)(Al,{ref:c,role:`region`,"aria-label":i.replace(`{hotkey}`,p),tabIndex:-1,style:{pointerEvents:m?void 0:`none`},children:[m&&(0,N.jsx)(F,{ref:l,onFocusFromOutsideViewport:()=>{vu(h({tabbingDirection:`forwards`}))}}),(0,N.jsx)(Ll.Slot,{scope:n,children:(0,N.jsx)(jr.ol,{tabIndex:-1,...a,ref:f})}),m&&(0,N.jsx)(F,{ref:u,onFocusFromOutsideViewport:()=>{vu(h({tabbingDirection:`backwards`}))}})]})});Yl.displayName=Gl;var Xl=`ToastFocusProxy`,F=M.forwardRef((e,t)=>{let{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,a=Ul(Xl,n);return(0,N.jsx)(Fl,{"aria-hidden":!0,tabIndex:0,...i,ref:t,style:{position:`fixed`},onFocus:e=>{let t=e.relatedTarget;a.viewport?.contains(t)||r()}})});F.displayName=Xl;var I=`Toast`,L=`toast.swipeStart`,R=`toast.swipeMove`,z=`toast.swipeCancel`,Zl=`toast.swipeEnd`,Ql=M.forwardRef((e,t)=>{let{forceMount:n,open:r,defaultOpen:i,onOpenChange:a,...o}=e,[s,c]=ze({prop:r,defaultProp:i??!0,onChange:a,caller:I});return(0,N.jsx)(Mr,{present:n||s,children:(0,N.jsx)(tu,{open:s,...o,ref:t,onClose:()=>c(!1),onPause:In(e.onPause),onResume:In(e.onResume),onSwipeStart:Or(e.onSwipeStart,e=>{e.currentTarget.setAttribute(`data-swipe`,`start`)}),onSwipeMove:Or(e.onSwipeMove,e=>{let{x:t,y:n}=e.detail.delta;e.currentTarget.setAttribute(`data-swipe`,`move`),e.currentTarget.style.setProperty(`--radix-toast-swipe-move-x`,`${t}px`),e.currentTarget.style.setProperty(`--radix-toast-swipe-move-y`,`${n}px`)}),onSwipeCancel:Or(e.onSwipeCancel,e=>{e.currentTarget.setAttribute(`data-swipe`,`cancel`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-y`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-end-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-end-y`)}),onSwipeEnd:Or(e.onSwipeEnd,e=>{let{x:t,y:n}=e.detail.delta;e.currentTarget.setAttribute(`data-swipe`,`end`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-y`),e.currentTarget.style.setProperty(`--radix-toast-swipe-end-x`,`${t}px`),e.currentTarget.style.setProperty(`--radix-toast-swipe-end-y`,`${n}px`),c(!1)})})})});Ql.displayName=I;var[$l,eu]=Bl(I,{onClose(){}}),tu=M.forwardRef((e,t)=>{let{__scopeToast:n,type:r=`foreground`,duration:i,open:a,onClose:o,onEscapeKeyDown:s,onPause:c,onResume:l,onSwipeStart:u,onSwipeMove:d,onSwipeCancel:f,onSwipeEnd:p,...m}=e,h=Ul(I,n),[g,_]=M.useState(null),v=Fn(t,e=>_(e)),y=M.useRef(null),b=M.useRef(null),x=i||h.duration,S=M.useRef(0),C=M.useRef(x),ee=M.useRef(0),{onToastAdd:te,onToastRemove:w}=h,ne=In(()=>{g?.contains(document.activeElement)&&h.viewport?.focus(),o()}),re=M.useCallback(e=>{!e||e===1/0||(window.clearTimeout(ee.current),S.current=new Date().getTime(),ee.current=window.setTimeout(ne,e))},[ne]);M.useEffect(()=>{let e=h.viewport;if(e){let t=()=>{re(C.current),l?.()},n=()=>{let e=new Date().getTime()-S.current;C.current-=e,window.clearTimeout(ee.current),c?.()};return e.addEventListener(ql,n),e.addEventListener(Jl,t),()=>{e.removeEventListener(ql,n),e.removeEventListener(Jl,t)}}},[h.viewport,x,c,l,re]),M.useEffect(()=>{a&&!h.isClosePausedRef.current&&re(x)},[a,x,h.isClosePausedRef,re]),M.useEffect(()=>(te(),()=>w()),[te,w]);let ie=M.useMemo(()=>g?fu(g):null,[g]);return h.viewport?(0,N.jsxs)(N.Fragment,{children:[ie&&(0,N.jsx)(nu,{__scopeToast:n,role:`status`,"aria-live":r===`foreground`?`assertive`:`polite`,"aria-atomic":!0,children:ie}),(0,N.jsx)($l,{scope:n,onClose:ne,children:hl.createPortal((0,N.jsx)(Ll.ItemSlot,{scope:n,children:(0,N.jsx)(kl,{asChild:!0,onEscapeKeyDown:Or(s,()=>{h.isFocusedToastEscapeKeyDownRef.current||ne(),h.isFocusedToastEscapeKeyDownRef.current=!1}),children:(0,N.jsx)(jr.li,{role:`status`,"aria-live":`off`,"aria-atomic":!0,tabIndex:0,"data-state":a?`open`:`closed`,"data-swipe-direction":h.swipeDirection,...m,ref:v,style:{userSelect:`none`,touchAction:`none`,...e.style},onKeyDown:Or(e.onKeyDown,e=>{e.key===`Escape`&&(s?.(e.nativeEvent),e.nativeEvent.defaultPrevented||(h.isFocusedToastEscapeKeyDownRef.current=!0,ne()))}),onPointerDown:Or(e.onPointerDown,e=>{e.button===0&&(y.current={x:e.clientX,y:e.clientY})}),onPointerMove:Or(e.onPointerMove,e=>{if(!y.current)return;let t=e.clientX-y.current.x,n=e.clientY-y.current.y,r=!!b.current,i=[`left`,`right`].includes(h.swipeDirection),a=[`left`,`up`].includes(h.swipeDirection)?Math.min:Math.max,o=i?a(0,t):0,s=i?0:a(0,n),c=e.pointerType===`touch`?10:2,l={x:o,y:s},f={originalEvent:e,delta:l};r?(b.current=l,pu(R,d,f,{discrete:!1})):mu(l,h.swipeDirection,c)?(b.current=l,pu(L,u,f,{discrete:!1}),e.target.setPointerCapture(e.pointerId)):(Math.abs(t)>c||Math.abs(n)>c)&&(y.current=null)}),onPointerUp:Or(e.onPointerUp,e=>{let t=b.current,n=e.target;if(n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId),b.current=null,y.current=null,t){let n=e.currentTarget,r={originalEvent:e,delta:t};mu(t,h.swipeDirection,h.swipeThreshold)?pu(Zl,p,r,{discrete:!0}):pu(z,f,r,{discrete:!0}),n.addEventListener(`click`,e=>e.preventDefault(),{once:!0})}})})})}),h.viewport)})]}):null}),nu=e=>{let{__scopeToast:t,children:n,...r}=e,i=Ul(I,t),[a,o]=M.useState(!1),[s,c]=M.useState(!1);return hu(()=>o(!0)),M.useEffect(()=>{let e=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(e)},[]),s?null:(0,N.jsx)(Ml,{asChild:!0,children:(0,N.jsx)(Fl,{...r,children:a&&(0,N.jsxs)(N.Fragment,{children:[i.label,` `,n]})})})},ru=`ToastTitle`,iu=M.forwardRef((e,t)=>{let{__scopeToast:n,...r}=e;return(0,N.jsx)(jr.div,{...r,ref:t})});iu.displayName=ru;var au=`ToastDescription`,ou=M.forwardRef((e,t)=>{let{__scopeToast:n,...r}=e;return(0,N.jsx)(jr.div,{...r,ref:t})});ou.displayName=au;var su=`ToastAction`,cu=M.forwardRef((e,t)=>{let{altText:n,...r}=e;return n.trim()?(0,N.jsx)(du,{altText:n,asChild:!0,children:(0,N.jsx)(uu,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${su}\`. Expected non-empty \`string\`.`),null)});cu.displayName=su;var lu=`ToastClose`,uu=M.forwardRef((e,t)=>{let{__scopeToast:n,...r}=e,i=eu(lu,n);return(0,N.jsx)(du,{asChild:!0,children:(0,N.jsx)(jr.button,{type:`button`,...r,ref:t,onClick:Or(e.onClick,i.onClose)})})});uu.displayName=lu;var du=M.forwardRef((e,t)=>{let{__scopeToast:n,altText:r,...i}=e;return(0,N.jsx)(jr.div,{"data-radix-toast-announce-exclude":``,"data-radix-toast-announce-alt":r||void 0,...i,ref:t})});function fu(e){let t=[];return Array.from(e.childNodes).forEach(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent&&t.push(e.textContent),gu(e)){let n=e.ariaHidden||e.hidden||e.style.display===`none`,r=e.dataset.radixToastAnnounceExclude===``;if(!n){if(r){let n=e.dataset.radixToastAnnounceAlt;n&&t.push(n)}else t.push(...fu(e))}}}),t}function pu(e,t,n,{discrete:r}){let i=n.originalEvent.currentTarget,a=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Ar(i,a):i.dispatchEvent(a)}var mu=(e,t,n=0)=>{let r=Math.abs(e.x),i=Math.abs(e.y),a=r>i;return t===`left`||t===`right`?a&&r>n:!a&&i>n};function hu(e=()=>{}){let t=In(e);Re(()=>{let e=0,n=0;return e=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(n)}},[t])}function gu(e){return e.nodeType===e.ELEMENT_NODE}function _u(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function vu(e){let t=document.activeElement;return e.some(e=>e===t||(e.focus(),document.activeElement!==t))}var yu=Wl,bu=Yl,xu=Ql,Su=iu,Cu=ou,wu=cu,Tu=uu,Eu=yu,Du=M.forwardRef(({className:e,...t},n)=>(0,N.jsx)(bu,{ref:n,className:O(`fixed top-0 z-[300] flex max-h-screen w-full flex-col-reverse p-4 pt-[max(1rem,var(--safe-area-inset-top,env(safe-area-inset-top,0px)))] md:bottom-0 md:right-0 md:top-auto md:flex-col md:pt-4 md:max-w-[420px]`,e),...t}));Du.displayName=bu.displayName;var Ou=Nr(`group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 max-md:data-[swipe=cancel]:translate-y-0 max-md:data-[swipe=end]:translate-y-[var(--radix-toast-swipe-end-y)] max-md:data-[swipe=move]:translate-y-[var(--radix-toast-swipe-move-y)] max-md:data-[state=open]:slide-in-from-top-full max-md:data-[state=closed]:slide-out-to-top-full md:data-[swipe=cancel]:translate-x-0 md:data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] md:data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] md:data-[state=open]:slide-in-from-bottom-full md:data-[state=closed]:slide-out-to-right-full`,{variants:{variant:{default:`border bg-background text-foreground`,destructive:`destructive group border-destructive bg-destructive text-destructive-foreground`,success:`success group border-success bg-success text-success-foreground`}},defaultVariants:{variant:`default`}}),ku=M.forwardRef(({className:e,variant:t,...n},r)=>(0,N.jsx)(xu,{ref:r,className:O(Ou({variant:t}),e),...n}));ku.displayName=xu.displayName;var Au=M.forwardRef(({className:e,...t},n)=>(0,N.jsx)(wu,{ref:n,className:O(`inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive`,e),...t}));Au.displayName=wu.displayName;var ju=M.forwardRef(({className:e,...t},n)=>(0,N.jsx)(Tu,{ref:n,className:O(`absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600 group-[.success]:text-success-foreground/70 group-[.success]:hover:text-success-foreground`,e),"toast-close":``,...t,children:(0,N.jsx)(ge,{className:`h-4 w-4`})}));ju.displayName=Tu.displayName;var Mu=M.forwardRef(({className:e,...t},n)=>(0,N.jsx)(Su,{ref:n,className:O(`text-sm font-semibold`,e),...t}));Mu.displayName=Su.displayName;var Nu=M.forwardRef(({className:e,...t},n)=>(0,N.jsx)(Cu,{ref:n,className:O(`text-sm opacity-90`,e),...t}));Nu.displayName=Cu.displayName;var Pu=768;function Fu(){let{toasts:e}=un(),[t,n]=(0,M.useState)(window.innerWidth>=Pu);return(0,M.useEffect)(()=>{let e=window.matchMedia(`(min-width: ${Pu}px)`),t=()=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,N.jsxs)(Eu,{swipeDirection:t?`right`:`up`,swipeThreshold:30,children:[e.map(function({id:e,title:t,description:n,action:r,...i}){return(0,N.jsxs)(ku,{...i,children:[(0,N.jsxs)(`div`,{className:`grid gap-1`,children:[t&&(0,N.jsx)(Mu,{children:t}),n&&(0,N.jsx)(Nu,{children:n})]}),r,(0,N.jsx)(ju,{})]},e)}),(0,N.jsx)(Du,{})]})}function Iu({isOpen:e,pubkey:t,onClose:n,onOtherLogin:r}){let{t:i}=A(),a=mt(t),o=Yr(),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(``),d=a.data?.metadata,f=d?.display_name||d?.name||Lu(t),p=d?.picture,m=Zr(d);return(0,N.jsx)(Br,{open:e,onOpenChange:n,children:(0,N.jsxs)(zr,{className:`max-w-[95vw] sm:max-w-sm rounded-2xl`,children:[(0,N.jsx)(Lr,{className:`sr-only`,children:i(`auth.login`)}),(0,N.jsx)(`div`,{className:`flex flex-col items-center gap-3 pt-4 pb-3`,children:a.isLoading?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ti,{className:`size-20 rounded-full`}),(0,N.jsx)(ti,{className:`h-5 w-32`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(ei,{shape:m,className:`size-20 ring-4 ring-primary/10`,children:[(0,N.jsx)($r,{src:p,alt:f,proxyWidth:160}),(0,N.jsx)(Qr,{className:`bg-primary/15 text-xl font-semibold text-primary`,children:f.slice(0,2).toUpperCase()})]}),(0,N.jsx)(`p`,{className:`text-lg font-semibold leading-none text-center break-words max-w-full`,children:f})]})}),l&&(0,N.jsx)(`p`,{className:`text-sm text-destructive text-center`,role:`alert`,children:l}),(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,N.jsx)(Pr,{className:`w-full h-12 rounded-full`,onClick:async()=>{c(!0),u(``);try{await o.extension(),n()}catch(e){u(e instanceof Error?e.message:i(`auth.errorExtensionFailed`)),c(!1)}},disabled:s,children:s?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ve,{className:`size-4 mr-2 animate-spin`}),i(`auth.loggingIn`)]}):i(`auth.login`)}),(0,N.jsx)(Pr,{type:`button`,variant:`link`,size:`sm`,className:`text-muted-foreground`,onClick:r,disabled:s,children:i(`auth.moreLoginOptions`)})]})]})})}function Lu(e){try{let t=Mt.npubEncode(e);return`${t.slice(0,10)}…${t.slice(-4)}`}catch{return`Nostr user`}}function Ru(){if(typeof window>`u`||!(`nostr`in window))return;let e=window.nostr;if(e&&typeof e.getPublicKey==`function`)return e}function zu({isOpen:e,onClose:t}){let[n,r]=(0,M.useState)(`probing`),[i,a]=(0,M.useState)(null);return(0,M.useEffect)(()=>{if(!e){r(`probing`),a(null);return}let t=!1;return(async()=>{let e=Ru();if(e)try{let n=await e.getPublicKey();if(t)return;if(n){a(n),r(`quick`);return}}catch{}t||r(`full`)})(),()=>{t=!0}},[e]),(0,N.jsxs)(N.Fragment,{children:[i&&(0,N.jsx)(Iu,{isOpen:e&&n===`quick`,pubkey:i,onClose:t,onOtherLogin:()=>r(`full`)}),(0,N.jsx)(er,{isOpen:e&&n===`full`,onClose:t})]})}function Bu(){let{nostr:e}=ct(),{logins:t,setLogin:n,removeLogin:r}=ot(),{data:i=[],isLoading:a}=_t({queryKey:[`nostr`,`logins`,t.map(e=>e.id).join(`;`)],queryFn:async({signal:n})=>{let r=await e.query([{kinds:[0],authors:t.map(e=>e.pubkey)}],{signal:AbortSignal.any([n,AbortSignal.timeout(1500)])});return t.map(({id:e,pubkey:t})=>{let n=r.find(e=>e.pubkey===t);try{return{id:e,pubkey:t,metadata:gt.json().pipe(gt.metadata()).parse(n?.content),event:n}}catch{return{id:e,pubkey:t,metadata:{},event:n}}})},retry:3});return{authors:i,currentUser:(()=>{let e=t[0];if(e)return{metadata:{},...i.find(t=>t.id===e.id),id:e.id,pubkey:e.pubkey}})(),otherUsers:(i||[]).slice(1),isLoading:a,setLogin:n,removeLogin:r}}function Vu({onAddAccountClick:e}){let{t}=A(),{currentUser:n,otherUsers:r,isLoading:i,setLogin:a,removeLogin:o}=Bu(),{orderedItems:s}=ni(),[c,l]=(0,M.useState)(!1),u={...mt(n?.pubkey).data?.metadata??{},...n?.metadata??{}};if(!n)return null;let d=()=>{l(!1),setTimeout(()=>{o(n.id)},0)},p=e=>e.metadata.name||e.metadata.display_name||ri(e.pubkey),m=u.name||u.display_name||ri(n.pubkey),h=u.picture;return(0,N.jsxs)(Jr,{modal:!1,open:c,onOpenChange:l,children:[(0,N.jsx)(Wr,{asChild:!0,children:(0,N.jsxs)(`button`,{className:`group flex items-center gap-2 h-10 p-1 pr-2.5 rounded-full hover:bg-accent transition-all text-foreground`,children:[i?(0,N.jsx)(ti,{className:`w-8 h-8 rounded-full shrink-0`}):(0,N.jsxs)(ei,{className:`w-8 h-8`,children:[(0,N.jsx)($r,{src:h,alt:m}),(0,N.jsx)(Qr,{children:m.charAt(0)})]}),(0,N.jsx)(y,{className:`w-4 h-4 text-muted-foreground motion-safe:transition-colors group-hover:text-foreground`})]})}),(0,N.jsxs)(Kr,{className:`w-56 p-2 animate-scale-in`,children:[(0,N.jsx)(Ur,{asChild:!0,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:(0,N.jsxs)(xr,{to:`/${Mt.npubEncode(n.pubkey)}`,children:[(0,N.jsxs)(ei,{className:`w-8 h-8`,children:[(0,N.jsx)($r,{src:h,alt:m}),(0,N.jsx)(Qr,{children:m?.charAt(0)||(0,N.jsx)(Me,{})})]}),(0,N.jsx)(`div`,{className:`flex-1 truncate`,children:(0,N.jsx)(`p`,{className:`text-sm font-medium`,children:m})})]})}),r.map(e=>(0,N.jsxs)(Ur,{onClick:()=>a(e.id),className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:[(0,N.jsxs)(ei,{className:`w-8 h-8`,children:[(0,N.jsx)($r,{src:e.metadata.picture,alt:p(e)}),(0,N.jsx)(Qr,{children:p(e)?.charAt(0)||(0,N.jsx)(Me,{})})]}),(0,N.jsx)(`div`,{className:`flex-1 truncate`,children:(0,N.jsx)(`p`,{className:`text-sm font-medium`,children:p(e)})})]},e.id)),s.includes(`dashboard`)&&(0,N.jsx)(Ur,{asChild:!0,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:(0,N.jsxs)(xr,{to:`/dashboard`,children:[(0,N.jsx)(De,{className:`w-4 h-4`}),(0,N.jsx)(`span`,{children:t(`nav.dashboard`)})]})}),(0,N.jsx)(Ur,{asChild:!0,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:(0,N.jsxs)(xr,{to:`/search`,children:[(0,N.jsx)(se,{className:`w-4 h-4`}),(0,N.jsx)(`span`,{children:t(`nav.search`)})]})}),(0,N.jsx)(Ur,{asChild:!0,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:(0,N.jsxs)(xr,{to:`/wallet`,children:[(0,N.jsx)(be,{className:`w-4 h-4`}),(0,N.jsx)(`span`,{children:t(`nav.wallet`)})]})}),(0,N.jsx)(Ur,{asChild:!0,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:(0,N.jsxs)(xr,{to:`/messages`,children:[(0,N.jsx)(f,{className:`w-4 h-4`}),(0,N.jsx)(`span`,{children:t(`nav.messages`)})]})}),(0,N.jsx)(Ur,{asChild:!0,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:(0,N.jsxs)(xr,{to:`/notifications`,children:[(0,N.jsx)(b,{className:`w-4 h-4`}),(0,N.jsx)(`span`,{children:t(`nav.notifications`)})]})}),(0,N.jsx)(Ur,{asChild:!0,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:(0,N.jsxs)(xr,{to:`/my-dashboard`,children:[(0,N.jsx)(ue,{className:`w-4 h-4`}),(0,N.jsx)(`span`,{children:t(`nav.myDashboard`)})]})}),(0,N.jsx)(Ur,{asChild:!0,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:(0,N.jsxs)(xr,{to:`/settings`,children:[(0,N.jsx)(ie,{className:`w-4 h-4`}),(0,N.jsx)(`span`,{children:t(`nav.settings`)})]})}),(0,N.jsx)(Hr,{}),(0,N.jsxs)(Ur,{onClick:e,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md`,children:[(0,N.jsx)(ee,{className:`w-4 h-4`}),(0,N.jsx)(`span`,{children:t(`auth.addAccount`)})]}),(0,N.jsxs)(Ur,{onClick:d,className:`flex items-center gap-2 cursor-pointer p-2 rounded-md text-red-500`,children:[(0,N.jsx)(Se,{className:`w-4 h-4`}),(0,N.jsx)(`span`,{children:t(`auth.logout`)})]})]})]})}function Hu({className:e}){let{t}=A(),{currentUser:n}=Bu(),[r,i]=(0,M.useState)(!1);return(0,N.jsxs)(`div`,{className:O(`inline-flex items-center justify-center`,e),children:[n?(0,N.jsx)(Vu,{onAddAccountClick:()=>i(!0)}):(0,N.jsx)(Pr,{onClick:()=>i(!0),className:`flex items-center gap-2 px-5 py-2 rounded-full bg-primary text-white font-medium transition-all hover:bg-primary/90 animate-scale-in`,children:(0,N.jsx)(`span`,{className:`truncate`,children:t(`auth.join`)})}),(0,N.jsx)(zu,{isOpen:r,onClose:()=>i(!1)})]})}function Uu(e){let t=e.toLowerCase(),n=Dr.find(e=>e.code.toLowerCase()===t);return n?n.code:t===`zh-tw`||t===`zh-hk`?`zh-Hant`:t.split(`-`)[0]}function Wu({className:e}){let{t,i18n:n}=A(),r=Uu(n.language??`en`);return(0,N.jsxs)(Jr,{children:[(0,N.jsx)(Wr,{asChild:!0,children:(0,N.jsx)(`button`,{type:`button`,className:O(`shrink-0 size-9 rounded-full flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary motion-safe:transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,e),"aria-label":t(`nav.language`),title:t(`nav.language`),children:(0,N.jsx)(Oe,{className:`size-5`})})}),(0,N.jsxs)(Kr,{align:`end`,className:`max-h-[70vh] w-56 overflow-y-auto`,children:[(0,N.jsx)(Vr,{className:`text-left`,children:t(`language.title`)}),(0,N.jsx)(Hr,{}),(0,N.jsx)(Gr,{value:r,onValueChange:e=>{e!==r&&Er(e)},children:Dr.map(e=>(0,N.jsx)(qr,{value:e.code,lang:e.code,dir:`ltr`,className:`text-left`,children:e.nativeName},e.code))})]})]})}function Gu(){let{config:e}=Zt(),{blockbookBaseUrl:t}=e;return _t({queryKey:[`hd-btc-price`,t],queryFn:({signal:e})=>lr(t,`usd`,e),refetchInterval:6e4,staleTime:3e4})}var Ku=18e5;function qu(e){return`hdwallet:spent-outpoints:v1:${e}`}function Ju(e){return`${e.txid}:${e.vout}`}function Yu(e){if(!e)return[];try{let t=localStorage.getItem(qu(e));if(!t)return[];let n=JSON.parse(t);if(!Array.isArray(n))return[];let r=Date.now(),i=[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=e;typeof t.txid==`string`&&(typeof t.vout!=`number`||!Number.isInteger(t.vout)||typeof t.spentAt==`number`&&(r-t.spentAt>Ku||i.push({txid:t.txid,vout:t.vout,spentAt:t.spentAt})))}return i}catch{return[]}}function Xu(e,t){if(e)try{t.length===0?localStorage.removeItem(qu(e)):localStorage.setItem(qu(e),JSON.stringify(t))}catch{}}function Zu(e,t){if(!e||t.length===0)return;let n=Date.now(),r=Yu(e),i=new Map(r.map(e=>[Ju(e),e]));for(let e of t)i.set(Ju(e),{txid:e.txid,vout:e.vout,spentAt:n});Xu(e,Array.from(i.values()))}function Qu(e,t){let n=Yu(e);if(n.length===0)return t;let r=new Set(t.utxos.map(e=>Ju(e))),i=n.filter(e=>r.has(Ju(e)));if(i.length!==n.length&&Xu(e,i),i.length===0)return t;let a=new Set(i.map(e=>Ju(e))),o=t.utxos.filter(e=>!a.has(Ju(e)));if(o.length===t.utxos.length)return t;let s=t.utxos.reduce((e,t)=>a.has(Ju(t))?e+t.value:e,0);return{...t,utxos:o,totalBalance:Math.max(0,t.totalBalance-s)}}var $u=e=>`hdwallet:cursor:v2:${e}`,ed={receiveIndex:0},td=6e4;function nd(){let{config:e}=Zt(),{blockbookBaseUrl:t}=e,n=ir(),r=xt(),i=pl(),a=n.status===`available`?n.pubkey:``,o=n.status===`available`?n.account:void 0,s=n.status===`available`?n.seed:void 0,[c,l]=Jo(a?$u(a):`hdwallet:cursor:v2:none`,ed),{data:u,isLoading:d,isFetching:f,error:p,refetch:m}=_t({queryKey:[`hdwallet-scan`,t,a],queryFn:async({signal:e})=>{if(!o||!a)throw Error(`HD wallet account unavailable`);let n=await cr(o,t,e);return Qu(a,n)},enabled:!!o&&a!==``,refetchInterval:td,staleTime:td/2,refetchOnWindowFocus:!1}),h=(0,M.useMemo)(()=>{if(!u&&!i.storage)return;let e=new Map,t=i.storage?.spent??[];for(let t of i.storage?.utxos??[])e.set(`${t.txid}:${t.vout}`,t.value);for(let n of t)e.has(`${n.txid}:${n.vout}`)||e.set(`${n.txid}:${n.vout}`,n.value);let n=u?ur(u,e):[],r=new Map,a=[...i.storage?.utxos??[],...t];for(let e of a){let t=r.get(e.txid);t?(t.amount+=e.value,t.time===void 0&&e.time!==void 0&&(t.time=e.time)):r.set(e.txid,{amount:e.value,height:e.height,time:e.time})}let o=new Map;for(let e of t){if(e.spentTxid===void 0)continue;let t=o.get(e.spentTxid);t?(t.sent+=e.value,t.time===void 0&&e.spentTime!==void 0&&(t.time=e.spentTime),t.height===void 0&&e.spentHeight!==void 0&&(t.height=e.spentHeight)):o.set(e.spentTxid,{sent:e.value,height:e.spentHeight,time:e.spentTime})}let s=Math.floor(Date.now()/1e3),c=(e,t)=>{if(e!==void 0)return e;if(t===void 0)return;let n=1690070400+(t-8e5)*600;return Math.min(n,s)},l=[];for(let e of n){let t=o.get(e.txid);o.delete(e.txid);let n=e.spOutflow??0,i=Math.max(n,t?.sent??0);if(i===0){l.push(e);continue}let a=(e.type===`receive`?e.amount:-e.amount)+n;a!==0&&l.push({txid:e.txid,amount:Math.abs(a),type:a>=0?`receive`:`send`,confirmed:e.confirmed,timestamp:e.timestamp,source:`bip86`});let s=-i,c=r.get(e.txid);c&&(s+=c.amount,r.delete(e.txid)),l.push({txid:e.txid,amount:Math.abs(s),type:s>=0?`receive`:`send`,confirmed:e.confirmed,timestamp:e.timestamp,source:`silent-payment`})}for(let[e,t]of o){let n=-t.sent,i=t.time,a=t.height,o=r.get(e);o&&(n+=o.amount,o.time!==void 0&&(i=o.time),a===void 0&&(a=o.height),r.delete(e)),l.push({txid:e,amount:Math.abs(n),type:n>=0?`receive`:`send`,confirmed:!0,timestamp:c(i,a),source:`silent-payment`})}for(let[e,t]of r)l.push({txid:e,amount:t.amount,type:`receive`,confirmed:!0,timestamp:c(t.time,t.height),source:`silent-payment`});return l.sort((e,t)=>!e.timestamp&&!t.timestamp?0:e.timestamp?t.timestamp?t.timestamp-e.timestamp:1:-1),l},[u,i.storage]),g=(0,M.useMemo)(()=>{if(!o)return;let e=u?.receive.firstUnusedIndex??0,t=Math.max(e,c.receiveIndex);return rr(o,t)},[o,u,c.receiveIndex]),_=(0,M.useMemo)(()=>{if(s)return tr(s)},[s]),v=(0,M.useCallback)(()=>{if(!o)return;let e=u?.receive.firstUnusedIndex??0,t=Math.max(e,c.receiveIndex)+1;return l({receiveIndex:t}),rr(o,t)},[o,u,c.receiveIndex,l]),y=(0,M.useCallback)(async()=>(await r.invalidateQueries({queryKey:[`hdwallet-scan`]}),m()),[r,m]),b=u?.totalBalance??0,x=i.balance,S=(0,M.useMemo)(()=>h?.filter(e=>e.source!==`silent-payment`),[h]),C=(0,M.useMemo)(()=>h?.filter(e=>e.source===`silent-payment`),[h]),ee=(0,M.useMemo)(()=>{let e=new Set;if(u){for(let t of u.addressMap.keys())e.add(t);for(let t of u.lookaheadAddresses)e.add(t)}return g&&e.add(g.address),e},[u,g]);return{availability:n,currentReceiveAddress:g,silentPaymentAddress:_,scan:u,transactions:h,publicTransactions:S,privateTransactions:C,totalBalance:(u?.totalBalance??0)+i.balance,pendingBalance:u?.pendingBalance??0,silentPaymentBalance:i.balance,publicBalance:b,privateBalance:x,ownPublicAddresses:ee,silentPaymentStorage:i.storage,isLoading:d,isFetching:f,error:p,refetch:y,nextReceiveAddress:v,pruneSpentSilentPaymentUtxos:i.pruneSpentUtxos,correctSilentPaymentUtxoValues:i.correctUtxoValues}}var B=`agora:hide-wallet-balance`;function rd(e){try{let t=localStorage.getItem(e);return t!==null&&JSON.parse(t)===!0}catch{return!1}}function id(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}window.dispatchEvent(new CustomEvent(B,{detail:{key:e}}))}function ad(e,t){let n=n=>{n instanceof CustomEvent&&n.detail?.key&&n.detail.key!==e||t()},r=n=>{(n.key===null||n.key===e)&&t()};return window.addEventListener(B,n),window.addEventListener(`storage`,r),()=>{window.removeEventListener(B,n),window.removeEventListener(`storage`,r)}}function od(){let{config:e}=Zt(),t=sn(e.appId,`hideWalletBalance`),n=(0,M.useSyncExternalStore)(e=>ad(t,e),()=>rd(t),()=>!1),r=(0,M.useCallback)(e=>{let n=rd(t),r=typeof e==`function`?e(n):e;r!==n&&id(t,r)},[t]);return{hideBalance:n,setHideBalance:r,toggleHideBalance:(0,M.useCallback)(()=>{r(e=>!e)},[r])}}var sd=`$***`,cd=`*** BTC`,ld=`https://zapstore.dev/apps/spot.agora.app`,ud=[{labelKey:`nav.campaigns`,to:`/campaigns`,icon:u},{labelKey:`nav.activity`,to:`/feed`,icon:De}];function dd(){let{t:e}=A(),{config:t}=Zt(),{user:n}=cn(),{orderedItems:r}=ni(),[i,a]=(0,M.useState)(!1);return(0,N.jsxs)(`header`,{className:`safe-area-top sticky top-0 z-40 w-full border-b border-border bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/70`,children:[(0,N.jsxs)(`div`,{className:`mx-auto flex h-16 max-w-7xl items-center gap-1 md:gap-4 px-4 sm:px-6`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`md:hidden -ml-2 p-2 rounded-full hover:bg-secondary motion-safe:transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":e(`nav.openMenu`),children:(0,N.jsx)(x,{className:`size-5`})}),(0,N.jsxs)(xr,{to:`/`,className:`flex items-center text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md px-1`,"aria-label":e(`nav.brandHome`,{appName:t.appName}),children:[(0,N.jsx)(zn,{className:`size-9`}),(0,N.jsx)(`span`,{className:`latin-display font-display font-normal tracking-wide leading-none uppercase text-3xl inline-block -ml-0.5`,style:{WebkitTextStroke:`0.022em currentColor`,transform:`skewX(-6deg) scaleX(1.1)`,transformOrigin:`0 100%`},children:t.appName})]}),(0,N.jsx)(`nav`,{className:`hidden md:flex items-center gap-1 ml-6`,children:ud.map(e=>(0,N.jsx)(hd,{item:e},e.to))}),(0,N.jsx)(`div`,{className:`flex-1`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[n?(0,N.jsx)(fd,{}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Wu,{}),(0,N.jsx)(xr,{to:`/search`,className:`shrink-0 size-9 rounded-full flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary motion-safe:transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":e(`nav.search`),title:e(`nav.search`),children:(0,N.jsx)(se,{className:`size-5`})})]}),(0,N.jsx)(md,{className:`hidden md:flex`}),(0,N.jsx)(Hu,{className:O(n?`shrink-0`:`max-w-[260px]`)})]})]}),(0,N.jsx)(ai,{open:i,onOpenChange:a,children:(0,N.jsxs)(ii,{side:`left`,hideClose:!0,className:`w-72 p-0 flex flex-col gap-0`,children:[(0,N.jsx)(`div`,{className:`safe-area-top`,children:(0,N.jsxs)(`div`,{className:`flex h-16 items-center justify-between px-5`,children:[(0,N.jsxs)(xr,{to:`/`,onClick:()=>a(!1),className:`flex items-center text-primary`,children:[(0,N.jsx)(zn,{className:`size-9`}),(0,N.jsx)(`span`,{className:`latin-display font-display font-normal tracking-wide leading-none uppercase text-3xl inline-block -ml-0.5`,style:{WebkitTextStroke:`0.022em currentColor`,transform:`skewX(-6deg) scaleX(1.1)`,transformOrigin:`0 100%`},children:t.appName})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,N.jsx)(md,{}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`p-1.5 -mr-1.5 rounded-full hover:bg-secondary motion-safe:transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":e(`nav.closeMenu`),children:(0,N.jsx)(ge,{className:`size-5`})})]})]})}),(0,N.jsxs)(`nav`,{className:`flex-1 overflow-y-auto px-3 py-4`,children:[(0,N.jsx)(vd,{items:ud,onClose:()=>a(!1)}),(0,N.jsx)(vd,{items:_d({userPubkey:n?.pubkey,showDashboard:r.includes(`dashboard`)}),onClose:()=>a(!1)}),!Sn.isNativePlatform()&&(0,N.jsxs)(`a`,{href:ld,target:`_blank`,rel:`noopener noreferrer`,onClick:()=>a(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-secondary motion-safe:transition-colors`,children:[(0,N.jsx)(oe,{className:`size-4 shrink-0`}),e(`nav.getApp`)]})]}),(0,N.jsx)(`div`,{className:`p-4 space-y-3`,children:(0,N.jsx)(gd,{onClose:()=>a(!1)})})]})})]})}function fd(){let[e,t]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{(0,M.startTransition)(()=>t(!0))},[]),e?(0,N.jsx)(pd,{}):null}function pd(){let{t:e}=A(),{availability:t,totalBalance:n,isLoading:r,error:i}=nd(),{data:a}=Gu(),{hideBalance:o}=od();if(t.status!==`available`||r||i||!a)return null;let s=o?sd:ln(n,a);return(0,N.jsx)(xr,{to:`/wallet`,className:`shrink-0 inline-flex items-center text-primary rounded-md px-1 hover:bg-primary/10 motion-safe:transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":e(o?`nav.walletBalanceHidden`:`nav.wallet`),title:e(o?`nav.walletBalanceHidden`:`nav.wallet`),children:(0,N.jsx)(`span`,{className:`latin-display font-display font-normal tracking-wide leading-none uppercase text-xl inline-block tabular-nums`,style:{WebkitTextStroke:`0.022em currentColor`,transform:`skewX(-6deg) scaleX(1.1)`,transformOrigin:`0 100%`},children:s})})}function md({className:e}){let{t}=A(),{theme:n,setTheme:r}=$t(),i=Qt(n)===`dark`,a=t(i?`nav.switchToLight`:`nav.switchToDark`);return(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(i?`light`:`dark`),className:O(`shrink-0 size-9 rounded-full flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary motion-safe:transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,e),"aria-label":a,title:a,children:i?(0,N.jsx)(Fe,{className:`size-5`}):(0,N.jsx)(l,{className:`size-5`})})}function hd({item:e}){let{t}=A();return(0,N.jsx)(Sr,{to:e.to,end:e.exact,className:({isActive:e})=>O(`px-3 py-2 rounded-md text-sm font-medium motion-safe:transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,e?`text-primary`:`text-muted-foreground hover:text-foreground hover:bg-secondary`),children:t(e.labelKey)})}function gd({onClose:e}){let{t}=A();return(0,N.jsx)(`nav`,{className:`flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[{labelKey:`nav.privacy`,to:`/privacy`},{labelKey:`nav.safety`,to:`/safety`},{labelKey:`nav.changelog`,to:`/changelog`}].map(n=>(0,N.jsx)(xr,{to:n.to,onClick:e,className:`hover:text-foreground motion-safe:transition-colors`,children:t(n.labelKey)},n.to))})}function _d({userPubkey:e,showDashboard:t}){return e?[...t?[{labelKey:`nav.dashboard`,to:`/dashboard`,icon:De}]:[],{labelKey:`nav.myDashboard`,to:`/my-dashboard`,icon:ue},{labelKey:`nav.wallet`,to:`/wallet`,icon:be},{labelKey:`nav.notifications`,to:`/notifications`,icon:b},{labelKey:`nav.profile`,to:`/${Mt.npubEncode(e)}`,icon:Me},{labelKey:`nav.search`,to:`/search`,icon:se},{labelKey:`nav.settings`,to:`/settings`,icon:ie},{labelKey:`nav.about`,to:`/about`,icon:C}]:[{labelKey:`nav.search`,to:`/search`,icon:se},{labelKey:`nav.settings`,to:`/settings`,icon:ie},{labelKey:`nav.about`,to:`/about`,icon:C}]}function vd({items:e,onClose:t}){let{t:n}=A();return e.length===0?null:(0,N.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,N.jsx)(`li`,{children:(0,N.jsxs)(Sr,{to:e.to,end:e.exact,onClick:t,className:({isActive:e})=>O(`flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium motion-safe:transition-colors`,e?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-secondary`),children:[(0,N.jsx)(e.icon,{className:`size-4 shrink-0`}),n(e.labelKey)]})},e.to))})}var yd={picture:1,banner:3};function bd({draft:e,onChange:t,bioField:n,aboutPlaceholder:r,showBanner:i=!0,showAvatar:a=!0,namePlaceholder:o,nameMaxLength:s,onImageUploadComplete:c,onUploadingChange:l,className:u}){let{t:d}=A(),{toast:f}=un(),{mutateAsync:p}=ui(),{config:m}=Zt(),h=(0,M.useRef)(null),g=(0,M.useRef)(null),[_,v]=(0,M.useState)(null),y=(0,M.useCallback)(e=>{g.current=e,h.current?.click()},[]),b=(0,M.useCallback)(async e=>{let t=``;try{t=(await navigator.clipboard.readText()).trim()}catch{f({title:d(`onboarding.verifier.identity.clipboardFailed`),variant:`destructive`});return}let n=oi(t);if(!n){f({title:d(`onboarding.verifier.identity.pasteUrlInvalid`),variant:`destructive`});return}let r;try{r=await Xr(n,m.imageProxy,e===`banner`?1500:1024)}catch(e){f({title:d(`onboarding.verifier.identity.pasteUrlFetchFailed`),description:e instanceof Error?e.message:void 0,variant:`destructive`});return}v({field:e,imageSrc:URL.createObjectURL(r),objectUrl:!0})},[m.imageProxy,d,f]),x=(0,M.useCallback)(e=>{let t=e.target.files?.[0];e.target.value=``;let n=g.current;if(g.current=null,!t||!n)return;if(!t.type.startsWith(`image/`)){f({title:d(`onboarding.profile.imageOnly`),variant:`destructive`});return}if(t.size>5242880){f({title:d(`onboarding.profile.imageTooLarge`),variant:`destructive`});return}let r=URL.createObjectURL(t);v({field:n,imageSrc:r,objectUrl:!0})},[d,f]),S=(0,M.useCallback)(()=>{_?.objectUrl&&URL.revokeObjectURL(_.imageSrc),v(null)},[_]),C=(0,M.useCallback)(async e=>{if(!_)return;let{field:n,imageSrc:r,objectUrl:i}=_;i&&URL.revokeObjectURL(r),v(null),l?.(!0);try{let r=await p(e),i=r[0]?.[1];i&&(t({[n]:i}),c?.(n,r))}catch{f({title:d(`onboarding.profile.uploadFailed`),variant:`destructive`})}finally{l?.(!1)}},[_,p,t,c,l,d,f]),ee=(0,M.useCallback)(e=>{f({title:d(`onboarding.profile.uploadFailed`),description:e instanceof Error?e.message:String(e),variant:`destructive`})},[d,f]);return(0,N.jsxs)(`div`,{className:u,children:[(0,N.jsx)(`input`,{ref:h,type:`file`,accept:`image/*`,className:`hidden`,onChange:x}),_&&(0,N.jsx)(li,{open:!0,imageSrc:_.imageSrc,aspect:yd[_.field],showCircleGuide:_.field===`picture`,title:_.field===`picture`?d(`onboarding.verifier.identity.cropAvatar`):d(`onboarding.verifier.identity.cropBanner`),maxOutputSize:_.field===`banner`?1500:512,onCancel:S,onCrop:C,onError:ee}),(0,N.jsx)(ci,{className:`rounded-none border-0 bg-transparent`,metadata:{name:e.name,website:e.website,about:e.about,picture:e.picture,banner:e.banner},onChange:e=>{e.name!==void 0&&t({name:e.name}),e.website!==void 0&&t({website:e.website}),e.about!==void 0&&t({about:e.about})},onPickImage:y,onPasteUrl:b,onRemoveAvatar:()=>t({picture:``}),onRemoveBanner:()=>t({banner:``}),bioField:n,aboutPlaceholder:r,showBanner:i,showAvatar:a,namePlaceholder:o,nameMaxLength:s,showNip05:!1,showBadges:!1})]})}function xd({draft:e,onChange:t,onContinue:n}){let{t:r}=A(),[i,a]=(0,M.useState)(!1),o=(0,M.useCallback)(e=>t(e),[t]),s=e.name.trim().length>0,c=e.picture.trim().length>0,l=e.website.trim().length>0,u=!l||!!oi(e.website.trim()),d=s&&c&&u&&!i;return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,N.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:r(`onboarding.verifier.identity.title`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`onboarding.verifier.identity.subtitle`)})]}),(0,N.jsx)(bd,{className:O(i&&`opacity-50 pointer-events-none`),draft:e,onChange:o,bioField:`website`,onUploadingChange:a}),l&&!u&&(0,N.jsx)(`p`,{className:`text-xs text-destructive`,children:r(`onboarding.verifier.identity.websiteInvalid`)}),i&&(0,N.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,N.jsx)(ve,{className:`size-3.5 animate-spin`}),r(`onboarding.verifier.identity.uploading`)]}),(0,N.jsxs)(Pr,{onClick:n,disabled:!d,className:`w-full h-12 text-base rounded-full`,children:[r(`common.continue`),(0,N.jsx)(_e,{className:`ml-2 h-4 w-4 rtl:rotate-180`})]})]})}var Sd=O(`min-h-[200px] w-full resize-none overflow-hidden p-3`,`text-lg leading-7 md:text-lg`,`rounded-lg border-2 border-transparent bg-muted/40`,`hover:bg-muted/60 hover:border-border`,`focus-visible:bg-transparent focus-visible:border-primary focus-visible:ring-0 focus-visible:ring-offset-0`,`placeholder:text-muted-foreground/40 transition-colors duration-150`),Cd=(0,M.forwardRef)(function({value:e,onValueChange:t,className:n,...r},i){let a=(0,M.useCallback)(e=>{t(e.target.value),si(e.target)},[t]),o=(0,M.useCallback)(e=>{si(e.target)},[]);return(0,N.jsx)(`textarea`,{ref:i,value:e,onChange:a,onFocus:o,className:O(Sd,n),...r})});function wd({draft:e,onChange:t,onContinue:n,isPublishing:r=!1}){let{t:i}=A(),a=e.about.trim().length>0&&!r;return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,N.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:i(`onboarding.verifier.bio.title`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`onboarding.verifier.bio.subtitle`)})]}),(0,N.jsx)(`div`,{children:(0,N.jsx)(Cd,{id:`verifier-org-bio`,value:e.about,onValueChange:e=>t({about:e}),placeholder:i(`onboarding.verifier.bio.placeholder`),"aria-required":!0})}),(0,N.jsx)(Pr,{onClick:n,disabled:!a,className:O(`w-full h-12 text-base rounded-full`),children:r?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ve,{className:`mr-2 h-4 w-4 animate-spin`}),i(`onboarding.verifier.bio.publishing`)]}):(0,N.jsxs)(N.Fragment,{children:[i(`common.continue`),(0,N.jsx)(_e,{className:`ml-2 h-4 w-4 rtl:rotate-180`})]})})]})}var Td=function(e){return e.docTypeError=`docTypeError`,e.contextNotFound=`contextNotFound`,e.timerNotFound=`timerNotFound`,e.ctxCallOutOfScope=`ctxCallOutOfScope`,e.createNodeInParserFail=`createNodeInParserFail`,e.stackOverFlow=`stackOverFlow`,e.parserMatchError=`parserMatchError`,e.serializerMatchError=`serializerMatchError`,e.getAtomFromSchemaFail=`getAtomFromSchemaFail`,e.expectDomTypeError=`expectDomTypeError`,e.callCommandBeforeEditorView=`callCommandBeforeEditorView`,e.missingRootElement=`missingRootElement`,e.missingNodeInSchema=`missingNodeInSchema`,e.missingMarkInSchema=`missingMarkInSchema`,e.ctxNotBind=`ctxNotBind`,e.missingYjsDoc=`missingYjsDoc`,e}({}),Ed=class extends Error{constructor(e,t){super(t),this.name=`MilkdownError`,this.code=e}},Dd=(e,t)=>typeof t==`function`?`[Function]`:t,Od=e=>JSON.stringify(e,Dd);function kd(e){return new Ed(Td.docTypeError,`Doc type error, unsupported type: ${Od(e)}`)}function Ad(e){return new Ed(Td.contextNotFound,`Context "${e}" not found, do you forget to inject it?`)}function jd(e){return new Ed(Td.timerNotFound,`Timer "${e}" not found, do you forget to record it?`)}function V(){return new Ed(Td.ctxCallOutOfScope,`Should not call a context out of the plugin.`)}function Md(e,t,n){let r=`Cannot create node for ${`name`in e?e.name:e}`,i=e=>{if(e==null)return`null`;if(Array.isArray(e))return`[${e.map(i).join(`, `)}]`;if(typeof e==`object`)return`toJSON`in e&&typeof e.toJSON==`function`?JSON.stringify(e.toJSON()):`spec`in e?JSON.stringify(e.spec):JSON.stringify(e);if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;try{return String(e)}catch{return`[Unserializable]`}},a=[[`[Description]`,r],[`[Attributes]`,t],[`[Content]`,(n??[]).map(e=>e?typeof e==`object`&&`type`in e?`${e}`:i(e):`null`)]].reduce((e,[t,n])=>{let r=`${t}: ${i(n)}.`;return e.concat(r)},[]);return new Ed(Td.createNodeInParserFail,a.join(` `))}function Nd(){return new Ed(Td.stackOverFlow,`Stack over flow, cannot pop on an empty stack.`)}function Pd(e){return new Ed(Td.parserMatchError,`Cannot match target parser for node: ${Od(e)}.`)}function Fd(e){return new Ed(Td.serializerMatchError,`Cannot match target serializer for node: ${Od(e)}.`)}function Id(e,t){return new Ed(Td.getAtomFromSchemaFail,`Cannot get ${e}: ${t} from schema.`)}function Ld(e){return new Ed(Td.expectDomTypeError,`Expect to be a dom, but get: ${Od(e)}.`)}function Rd(){return new Ed(Td.callCommandBeforeEditorView,`You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized`)}function zd(e){return new Ed(Td.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function Bd(e){return new Ed(Td.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${e}" in schema.`)}var Vd=class{constructor(){this.sliceMap=new Map,this.get=e=>{let t=typeof e==`string`?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t)throw Ad(typeof e==`string`?e:e.name);return t},this.remove=e=>{let t=typeof e==`string`?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>typeof e==`string`?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},Hd=class{#e=[];#t;#n=()=>{this.#e.forEach(e=>e(this.#t))};constructor(e,t,n){this.set=e=>{this.#t=e,this.#n()},this.get=()=>this.#t,this.update=e=>{this.#t=e(this.#t),this.#n()},this.type=n,this.#t=t,e.set(n.id,this)}on(e){return this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}}once(e){let t=this.on(n=>{e(n),t()});return t}off(e){this.#e=this.#e.filter(t=>t!==e)}offAll(){this.#e=[]}},Ud=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw V()}}create(e,t=this._defaultValue){return new Hd(e,t,this)}},H=(e,t)=>new Ud(e,t),Wd=class{#e;#t;#n;#r=new Set;#i=new Set;#a=new Map;#o=new Map;constructor(e,t,n){this.read=()=>({metadata:this.#e,injectedSlices:[...this.#r].map(e=>({name:typeof e==`string`?e:e.name,value:this.#s(e)})),consumedSlices:[...this.#i].map(e=>({name:typeof e==`string`?e:e.name,value:this.#s(e)})),recordedTimers:[...this.#a].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#c(e)})),waitTimers:[...this.#o].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#c(e)}))}),this.onRecord=e=>{this.#a.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#a.delete(e)},this.onDone=e=>{let t=this.#a.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{let n=Date.now();t.finally(()=>{this.#o.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#r.add(e)},this.onRemove=e=>{this.#r.delete(e)},this.onUse=e=>{this.#i.add(e)},this.#t=e,this.#n=t,this.#e=n}#s=e=>this.#t.get(e).get();#c=e=>this.#n.get(e).status},Gd=class e{#e;#t;#n;#r;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#e,this.#t,{...t}):this,this.inject=(e,t)=>{let n=e.create(this.#e.sliceMap);return t!=null&&n.set(t),this.#r?.onInject(e),this},this.remove=e=>(this.#e.remove(e),this.#r?.onRemove(e),this),this.record=e=>(e.create(this.#t.store),this.#r?.onRecord(e),this),this.clearTimer=e=>(this.#t.remove(e),this.#r?.onClear(e),this),this.isInjected=e=>this.#e.has(e),this.isRecorded=e=>this.#t.has(e),this.use=e=>(this.#r?.onUse(e),this.#e.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#t.get(e),this.done=e=>{this.timer(e).done(),this.#r?.onDone(e)},this.wait=e=>{let t=this.timer(e).start();return this.#r?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#e=t,this.#t=n,this.#n=r,r&&(this.#r=new Wd(t,n,r))}get meta(){return this.#n}get inspector(){return this.#r}},Kd=class{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t)throw jd(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},qd=class{#e=null;#t=null;#n;#r=`pending`;constructor(e,t){this.start=()=>(this.#e??=new Promise((e,t)=>{this.#t=t=>{t instanceof CustomEvent&&t.detail.id===this.#n&&(this.#r=`resolved`,this.#i(),t.stopImmediatePropagation(),e())},this.#a(()=>{this.#r===`pending`&&(this.#r=`rejected`),this.#i(),t(Error(`Timing ${this.type.name} timeout.`))}),this.#r=`pending`,addEventListener(this.type.name,this.#t)}),this.#e),this.done=()=>{let e=new CustomEvent(this.type.name,{detail:{id:this.#n}});dispatchEvent(e)},this.#n=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#r}#i=()=>{this.#t&&removeEventListener(this.type.name,this.#t)};#a=e=>{setTimeout(()=>{e()},this.type.timeout)}},Jd=class{constructor(e,t=3e3){this.create=e=>new qd(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},Yd=(e,t=3e3)=>new Jd(e,t),Xd={}.hasOwnProperty;function Zd(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&Xd.call(t,e)){let n=String(t[e]);i=Xd.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var Qd={}.hasOwnProperty;function $d(e,t){let n=-1,r;if(t.extensions)for(;++n `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),rf);return i(),o}function rf(e,t,n){return`>`+(n?``:` `)+e}function af(e,t){return of(e,t.inConstruct,!0)&&!of(e,t.notInConstruct,!1)}function of(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++ro&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function lf(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function uf(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function df(e,t,n,r){let i=uf(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(lf(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,ff);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(cf(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:` `,encode:["`"],...s.current()})),t()}return u+=s.move(` `),a&&(u+=s.move(a+` `)),u+=s.move(c),l(),u}function ff(e,t,n){return(n?``:` `)+e}function pf(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function mf(e,t,n,r){let i=pf(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:` `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function hf(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function gf(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function _f(e,t,n){let r=wi(e),i=wi(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}vf.peek=yf;function vf(e,t,n,r){let i=hf(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=_f(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=gf(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=_f(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+gf(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function yf(e,t,n){return n.options.emphasis||`*`}function bf(e,t){let n=!1;return Ti(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&fi(e)&&(t.options.setext||n))}function xf(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(bf(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:` `,after:` `});return r(),t(),o+` `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(` `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:` `,...a.current()});return/^[\t ]/.test(l)&&(l=gf(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Sf.peek=Cf;function Sf(e){return e.value||``}function Cf(){return`<`}wf.peek=Tf;function wf(e,t,n,r){let i=pf(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Tf(){return`!`}Ef.peek=Df;function Ef(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Df(){return`!`}Of.peek=kf;function Of(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a\u007F]/.test(e.url))}jf.peek=Mf;function jf(e,t,n,r){let i=pf(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Af(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Mf(e,t,n){return Af(e,n)?`<`:`[`}Nf.peek=Pf;function Nf(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Pf(){return`[`}function Ff(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function If(e){let t=Ff(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Lf(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Rf(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function zf(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Lf(n):Ff(n),s=e.ordered?o===`.`?`)`:`.`:If(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Rf(n)===o&&t){let t=-1;for(;++t-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function Hf(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var Uf=Ci([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Wf(e,t,n,r){return(e.children.some(function(e){return Uf(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Gf(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Kf.peek=qf;function Kf(e,t,n,r){let i=Gf(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=_f(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=gf(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=_f(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+gf(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function qf(e,t,n){return n.options.strong||`*`}function Jf(e,t,n,r){return n.safe(e.value,r)}function Yf(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Xf(e,t,n){let r=(Rf(n)+(n.options.ruleSpaces?` `:``)).repeat(Yf(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Zf={blockquote:nf,break:sf,code:df,definition:mf,emphasis:vf,hardBreak:sf,heading:xf,html:Sf,image:wf,imageReference:Ef,inlineCode:Of,link:jf,linkReference:Nf,list:zf,listItem:Vf,paragraph:Hf,root:Wf,strong:Kf,text:Jf,thematicBreak:Xf},Qf=[$f];function $f(e,t,n,r){if(t.type===`code`&&lf(t,r)&&(e.type===`list`||e.type===t.type&&lf(e,r)))return!1;if(`spread`in n&&typeof n.spread==`boolean`)return e.type===`paragraph`&&(e.type===t.type||t.type===`definition`||t.type===`heading`&&bf(t,r))?void 0:+!!n.spread}var ep=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`],tp=[{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`\r`,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`!`,after:`\\[`,inConstruct:`phrasing`,notInConstruct:ep},{character:`"`,inConstruct:`titleQuote`},{atBreak:!0,character:`#`},{character:`#`,inConstruct:`headingAtx`,after:`(?:[\r ]|$)`},{character:`&`,after:`[#A-Za-z]`,inConstruct:`phrasing`},{character:`'`,inConstruct:`titleApostrophe`},{character:`(`,inConstruct:`destinationRaw`},{before:`\\]`,character:`(`,inConstruct:`phrasing`,notInConstruct:ep},{atBreak:!0,before:`\\d+`,character:`)`},{character:`)`,inConstruct:`destinationRaw`},{atBreak:!0,character:`*`,after:`(?:[ \r *])`},{character:`*`,inConstruct:`phrasing`,notInConstruct:ep},{atBreak:!0,character:`+`,after:`(?:[ \r ])`},{atBreak:!0,character:`-`,after:`(?:[ \r -])`},{atBreak:!0,before:`\\d+`,character:`.`,after:`(?:[ \r ]|$)`},{atBreak:!0,character:`<`,after:`[!/?A-Za-z]`},{character:`<`,after:`[!/?A-Za-z]`,inConstruct:`phrasing`,notInConstruct:ep},{character:`<`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`=`},{atBreak:!0,character:`>`},{character:`>`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`[`},{character:`[`,inConstruct:`phrasing`,notInConstruct:ep},{character:`[`,inConstruct:[`label`,`reference`]},{character:`\\`,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:`]`,inConstruct:[`label`,`reference`]},{atBreak:!0,character:`_`},{character:`_`,inConstruct:`phrasing`,notInConstruct:ep},{atBreak:!0,character:"`"},{character:"`",inConstruct:[`codeFencedLangGraveAccent`,`codeFencedMetaGraveAccent`]},{character:"`",inConstruct:`phrasing`,notInConstruct:ep},{atBreak:!0,character:`~`}];function np(e){return e.label||!e.identifier?e.label||``:yi(e.identifier)}function rp(e){if(!e._compiled){let t=(e.atBreak?`[\\r\\n][\\t ]*`:``)+(e.before?`(?:`+e.before+`)`:``);e._compiled=RegExp((t?`(`+t+`)`:``)+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?`\\`:``)+e.character+(e.after?`(?:`+e.after+`)`:``),`g`)}return e._compiled}function ip(e,t,n){let r=t.indexStack,i=e.children||[],a=[],o=-1,s=n.before,c;r.push(-1);let l=t.createTracker(n);for(;++o0&&(s===`\r`||s===` `)&&u.type===`html`&&(a[a.length-1]=a[a.length-1].replace(/(\r?\n|\r)$/,` `),s=` `,l=t.createTracker(n),l.move(a.join(``)));let f=t.handle(u,e,t,{...l.current(),after:d,before:s});c&&c===f.slice(0,1)&&(f=gf(c.charCodeAt(0))+f.slice(1));let p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,c=void 0,p&&(a.length>0&&p.before&&s===a[a.length-1].slice(-1)&&(a[a.length-1]=a[a.length-1].slice(0,-1)+gf(s.charCodeAt(0))),p.after&&(c=d)),l.move(f),a.push(f),s=f.slice(-1)}return r.pop(),a.join(``)}function ap(e,t,n){let r=t.indexStack,i=e.children||[],a=t.createTracker(n),o=[],s=-1;for(r.push(-1);++s `}return` `}var sp=/\r?\n|\r/g;function cp(e,t){let n=[],r=0,i=0,a;for(;a=sp.exec(e);)o(e.slice(r,a.index)),n.push(a[0]),r=a.index+a[0].length,i++;return o(e.slice(r)),n.join(``);function o(e){n.push(t(e,i,!e))}}function lp(e,t,n){let r=(n.before||``)+(t||``)+(n.after||``),i=[],a=[],o={},s=-1;for(;++s=l||e+1>1}},xp.from=function(e){if(e instanceof xp)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new xp(t)};function Sp(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=Sp(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Cp(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;ee&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);at)for(let e=0,a=0;at&&((an)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Tp(t+1,i):Tp(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;ethis.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),n}};W.none=[];var Dp=class extends Error{},G=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=kp(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Op(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(U.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};G.empty=new G(U.empty,0,0);function Op(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Op(a.content,t-i-1,n-i-1)))}function kp(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=kp(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function Ap(e,t,n){if(n.openStart>e.depth)throw new Dp(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Dp(`Inconsistent open depths`);return jp(e,t,n,0)}function jp(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Fp(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Pp(e.nodeAfter,r),a++));for(let e=a;ei&&Np(e,t,i+1),o=r.depth>i&&Np(n,r,i+1),s=[];return Fp(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Mp(a,o),Pp(Ip(a,Lp(e,t,n,r,i+1)),s)):(a&&Pp(Ip(a,Rp(e,t,i+1)),s),Fp(t,n,i,s),o&&Pp(Ip(o,Rp(n,r,i+1)),s)),Fp(r,null,i,s),new U(s)}function Rp(e,t,n){let r=[];return Fp(null,e,n,r),e.depth>n&&Pp(Ip(Np(e,t,n+1),Rp(e,t,n+1)),r),Fp(t,null,n,r),new U(r)}function zp(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(U.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Bp=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Wp(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Up.get(t);if(r)for(let e=0;ee&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Jp(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=U.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=U.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Kp.prototype.text=void 0;var qp=class e extends Kp{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Jp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Jp(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Yp=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Xp(t,n);if(r.next==null)return e.empty;let i=Zp(r);r.next&&r.err(`Unexpected trailing text`);let a=sm(im(i));return cm(a,r),a}matchType(e){for(let t=0;te.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n`+e.indexOf(t.next[n].next);return r}).join(` `)}};Yp.empty=new Yp(!0);var Xp=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Zp(e){let t=[];do t.push(Qp(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Qp(e){let t=[];do t.push($p(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function $p(e){let t=rm(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=tm(e,t);else break;return t}function em(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function tm(e,t){let n=em(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:em(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function nm(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function rm(e){if(e.eat(`(`)){let t=Zp(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=nm(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function im(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Yp(r.indexOf(e.length-1)>-1);for(let e=0;e-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:um(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Kp(this,this.computeAttrs(e),U.from(t),W.setFrom(n))}createChecked(e=null,t,n){return t=U.from(t),this.checkContent(t),new Kp(this,this.computeAttrs(e),t,W.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=U.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(U.empty,!0);return i?new Kp(this,e,t.append(i),W.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function mm(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var hm=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?mm(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},gm=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=fm(e,r.attrs),this.excluded=null;let i=lm(this.attrs);this.instance=i?new W(this,i):null}create(e=null){return!e&&this.instance?this.instance:new W(this,um(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t-1}},_m=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=xp.from(e.nodes),t.marks=xp.from(e.marks||{}),this.nodes=pm.compile(this.spec.nodes,this),this.marks=gm.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Yp.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?vm(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:vm(this,n.split(` `))}this.nodeFromJSON=e=>Kp.fromJSON(this,e),this.markFromJSON=e=>W.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof pm))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new qp(n,n.defaultAttrs,e,W.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function vm(e,t){let n=[];for(let r=0;r-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function ym(e){return e.tag!=null}function bm(e){return e.style!=null}var xm=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(ym(e))this.tags.push(e);else if(bm(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Am(this,t,!1);return n.addAll(e,W.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Am(this,t,!0);return n.addAll(e,W.none,t.from,t.to),G.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;re.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r{n(e=Nm(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Nm(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Sm={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Cm={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},wm={ol:!0,ul:!0},Tm=1,Em=2,Dm=4;function Om(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?Tm:0)|(t===`full`?Em:0)}var km=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=W.none,this.match=i||(a&Dm?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(U.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Tm)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=U.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(U.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Sm.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Am=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=Om(null,t.preserveWhitespace,0)|(n?Dm:0);i=r?new km(r.type,r.attrs,W.none,!0,t.topMatch||r.type.contentMatch,a):n?new km(null,null,W.none,!0,null,a):new km(e.schema.topNodeType,null,W.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Em?`full`:this.localPreserveWS||(r.options&Tm)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,` `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e!(a.type?a.type.allowsMarkType(t.type):Pm(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new km(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Tm);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function jm(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&wm.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Mm(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Nm(e){let t={};for(let n in e)t[n]=e[n];return t}function Pm(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n{if(i.length||e.marks.length){let n=0,a=0;for(;n=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Vm(Lm(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return Vm(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=Im(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return Im(e.marks)}};function Im(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Lm(e){return e.document||window.document}var Rm=new WeakMap;function zm(e){let t=Rm.get(e);return t===void 0&&Rm.set(e,t=Bm(e)),t}function Bm(e){let t=null;function n(e){if(e&&typeof e==`object`){if(Array.isArray(e)){if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;iu)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}{let{dom:t,contentDOM:i}=Vm(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Hm=65535,Um=2**16;function Wm(e,t){return e+t*Um}function Gm(e){return e&Hm}function Km(e){return(e-(e&Hm))/Um}var qm=1,Jm=2,Ym=4,Xm=8,Zm=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Xm)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Ym)>0}},Qm=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Gm(e);if(!this.inverted)for(let e=0;ee)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Wm(o/3,e-s),f=e==s?Jm:e==u?qm:Ym;return(t<0?e!=s:e!=u)&&(f|=Xm),new Zm(a,f,d)}r+=l-c}return n?e+r:new Zm(e+r,0,null)}touches(e,t){let n=0,r=Gm(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;te)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&t!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return nh.fromReplace(e,this.from,this.to,i)}invert(){return new ah(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};th.jsonID(`addMark`,ih);var ah=class e extends th{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new G(rh(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return nh.fromReplace(e,this.from,this.to,n)}invert(){return new ih(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};th.jsonID(`removeMark`,ah);var oh=class e extends th{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return nh.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return nh.fromReplace(e,this.pos,this.pos+1,new G(U.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;rr.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,G.fromJSON(t,n.slice),n.insert,!!n.structure)}};th.jsonID(`replaceAround`,lh);function uh(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function dh(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;ee.step(t)),a.forEach(t=>e.step(t))}function fh(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof gm){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;ee.step(new ah(t.from,t.to,t.style)))}function ph(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t=0;t--)e.step(o[t])}function mh(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function hh(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(nn;e--)t||r.index(e)>0?(t=!0,u=U.from(r.node(e).copy(u)),d++):c--;let f=U.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=U.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new lh(i,a,i,a,new G(r,0,0),n.length,!0))}function Sh(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Th(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&wh(e,t,n,a),ph(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new lh(c,l,c+1,l-1,new G(U.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Ch(e,t,n,a),!1}})}function Ch(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function wh(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(` `))}})}function Th(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Eh(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new lh(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new G(U.from(o),0,0),1,!0))}function Dh(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Oh(e,t,n=1,r){let i=e.doc.resolve(t),a=U.empty,o=U.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=U.from(i.node(e).copy(a));let t=r&&r[s];o=U.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new ch(t,t,new G(a.append(o),n,n),!0))}function kh(e,t){let n=e.resolve(t),r=n.index();return jh(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Ah(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function Fh(e,t,n=t,r=G.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Ih(i,a,r)?new ch(t,n,r):new Lh(i,a,r).fit()}function Ih(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Lh=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=U.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=U.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new G(i,a,o);return e>-1?new lh(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new ch(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Bh(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(U.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Bh(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new G(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Bh(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new G(Rh(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new G(Rh(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e1||s==0||e.content.size)&&(u=t,l.push(Vh(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=zh(this.placed,t,U.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t=0;n--){let{match:t,type:r}=this.frontier[n],i=Hh(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=zh(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=zh(this.placed,this.depth,U.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(U.empty,!0);e.childCount&&(this.placed=zh(this.placed,this.frontier.length,e))}};function Rh(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Rh(e.firstChild.content,t-1,n)))}function zh(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(zh(e.lastChild.content,t-1,n)))}function Bh(e,t){for(let n=0;n1&&(r=r.replaceChild(0,Vh(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(U.empty,!0)))),e.copy(r)}function Hh(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Uh(n,a.content,o)?s:null}function Uh(e,t,n){for(let r=n;r0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Wh(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Kh(e,t,n,r,i){if(tr){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(U.empty,!0))}return e}function qh(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Nh(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new G(U.from(r),0,0))}function Jh(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=Yh(r,i);for(let t=0;t0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Yh(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(rt.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var Xh=class e extends th{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return nh.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return nh.fromReplace(e,this.pos,this.pos+1,new G(U.from(r),0,+!t.isLeaf))}getMap(){return Qm.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};th.jsonID(`attr`,Xh);var Zh=class e extends th{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return nh.ok(n)}getMap(){return Qm.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};th.jsonID(`docAttr`,Zh);var Qh=class extends Error{};Qh=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Qh.prototype=Object.create(Error.prototype),Qh.prototype.constructor=Qh,Qh.prototype.name=`TransformError`;var $h=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new $m}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Qh(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=G.empty){let r=Fh(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new G(U.from(n),0,0))}delete(e,t){return this.replace(e,t,G.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Gh(this,e,t,n),this}replaceRangeWith(e,t,n){return qh(this,e,t,n),this}deleteRange(e,t){return Jh(this,e,t),this}lift(e,t){return gh(this,e,t),this}join(e,t=1){return Mh(this,e,t),this}wrap(e,t){return xh(this,e,t),this}setBlockType(e,t=e,n,r=null){return Sh(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return Eh(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Xh(e,t,n)),this}setDocAttribute(e,t){return this.step(new Zh(e,t)),this}addNodeMark(e,t){return this.step(new oh(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof W)t.isInSet(n.marks)&&this.step(new sh(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new sh(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return Oh(this,e,t,n),this}addMark(e,t,n){return dh(this,e,t,n),this}removeMark(e,t,n){return fh(this,e,t,n),this}clearIncompatible(e,t,n){return ph(this,e,t,n),this}},eg=Object.create(null),K=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new tg(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let i=t<0?cg(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):cg(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new og(e.node(0))}static atStart(e){return cg(e,e,0,0,1)||new og(e)}static atEnd(e){return cg(e,e,e.content.size,e.childCount,-1)||new og(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=eg[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in eg)throw RangeError(`Duplicate use of selection JSON ID `+e);return eg[e]=t,t.prototype.jsonID=e,t}getBookmark(){return q.between(this.$anchor,this.$head).getBookmark()}};K.prototype.visible=!0;var tg=class{constructor(e,t){this.$from=e,this.$to=t}},ng=!1;function rg(e){!ng&&!e.parent.inlineContent&&(ng=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var q=class e extends K{constructor(e,t=e){rg(e),rg(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return K.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=G.empty){if(super.replace(e,t),t==G.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ig(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=K.findFrom(n,r,!0)||K.findFrom(n,-r,!0);if(e)n=e.$head;else return K.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(K.findFrom(t,-r,!0)||K.findFrom(t,r,!0)).$anchor,t.pos0?0:1);i>0?o=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=cg(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&J.isSelectable(r))return J.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function lg(e,t,n){let r=e.steps.length-1;if(r{o??=r}),e.setSelection(K.near(e.doc.resolve(o),n))}var ug=1,dg=2,fg=4,pg=class extends $h{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=dg,this}ensureMarks(e){return W.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&dg)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||W.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(K.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=fg,this}get scrolledIntoView(){return(this.updated&fg)>0}};function mg(e,t){return!t||!e?e:e.bind(t)}var hg=class{constructor(e,t,n){this.name=e,this.init=mg(t.init,n),this.apply=mg(t.apply,n)}},gg=[new hg(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new hg(`selection`,{init(e,t){return e.selection||K.atStart(t.doc)},apply(e){return e.selection}}),new hg(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new hg(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],_g=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=gg.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new hg(e.key,e.spec.state,e))})}},vg=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;ne.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new _g(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=Kp.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=K.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function yg(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=yg(i,t,{})),n[r]=i}return n}var bg=class{constructor(e){this.spec=e,this.props={},e.props&&yg(e.props,this,this.props),this.key=e.key?e.key.key:Sg(`plugin`)}getState(e){return e[this.key]}},xg=Object.create(null);function Sg(e){return e in xg?e+`$`+ ++xg[e]:(xg[e]=0,e+`$`)}var Cg=class{constructor(e=`key`){this.key=Sg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},wg=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Tg(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var Eg=(e,t,n)=>{let r=Tg(e,n);if(!r)return!1;let i=jg(r);if(!i){let n=r.blockRange(),i=n&&hh(n);return i!=null&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(Gg(e,i,t,-1))return!0;if(r.parent.content.size==0&&(kg(a,`end`)||J.isSelectable(a)))for(let n=r.depth;;n--){let o=Fh(e.doc,r.before(n),r.after(n),G.empty);if(o&&o.slice.size1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},Dg=(e,t,n)=>{let r=Tg(e,n);if(!r)return!1;let i=jg(r);return i?Og(e,i,t):!1};function Og(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=Fh(e.doc,i,o,G.empty);if(!s||s.from!=i||s instanceof ch&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(q.create(t.doc,i)),n(t.scrollIntoView())}return!0}function kg(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Ag=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=jg(r)}let o=a&&a.nodeBefore;return!o||!J.isSelectable(o)?!1:(t&&t(e.tr.setSelection(J.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function jg(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Mg(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset{let r=Mg(e,n);if(!r)return!1;let i=Fg(r);if(!i)return!1;let a=i.nodeAfter;if(Gg(e,i,t,1))return!0;if(r.parent.content.size==0&&(kg(a,`start`)||J.isSelectable(a))){let n=Fh(e.doc,r.before(),r.after(),G.empty);if(n&&n.slice.size{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset=0;t--){let n=e.node(t);if(e.index(t)+1{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(` `).scrollIntoView()),!0)};function Lg(e){for(let t=0;t{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=Lg(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(K.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},zg=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof og||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=Lg(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index(){let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Dh(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&hh(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function Vg(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof J&&t.selection.node.isBlock)return!r.parentOffset||!Dh(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=Lg(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof q||t.selection instanceof og)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=Dh(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,Dh(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var Hg=Vg(),Ug=(e,t)=>(t&&t(e.tr.setSelection(new og(e.doc))),!0);function Wg(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||kh(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function Gg(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&Wg(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=U.empty;for(let e=o.length-1;e>=0;e--)s=U.from(o[e].create(null,s));s=U.from(i.copy(s));let c=e.tr.step(new lh(t.pos-1,r,t.pos,r,new G(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&kh(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:K.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&hh(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&kg(a,`start`,!0)&&kg(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=U.empty;for(let e=o.length-1;e>=0;e--)r=U.from(o[e].copy(r));n(e.tr.step(new lh(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new G(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Kg(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(q.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var qg=Kg(-1),Jg=Kg(1);function Yg(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&_h(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function Xg(e,t=null){return function(n,r){let i=!1;for(let r=0;r{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t))){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function Qg(e){let t=[];for(let n=0;n{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new tg(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.posn.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var c_=(e,t)=>{let n=e.plugins;for(let r=0;r=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(a.text){let t=n.doc.resolve(a.from).marks();n.replaceWith(a.from,a.to,e.schema.text(a.text,t))}else n.delete(a.from,a.to);t(n)}return!0}}return!1};new o_(/--$/,`—`,{inCodeMark:!1}),new o_(/\.\.\.$/,`…`,{inCodeMark:!1}),new o_(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new o_(/"$/,`”`,{inCodeMark:!1}),new o_(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new o_(/'$/,`’`,{inCodeMark:!1});function l_(e,t,n=null,r){return new o_(e,(e,i,a,o)=>{let s=n instanceof Function?n(i):n,c=e.tr.delete(a,o),l=c.doc.resolve(a).blockRange(),u=l&&_h(l,t,s);if(!u)return null;c.wrap(l,u);let d=c.doc.resolve(a-1).nodeBefore;return d&&d.type==t&&kh(c.doc,a-1)&&(!r||r(i,d))&&c.join(a-1),c})}function u_(e,t,n=null){return new o_(e,(e,r,i,a)=>{let o=e.doc.resolve(i),s=n instanceof Function?n(r):n;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t)?e.tr.delete(i,a).setBlockType(i,i,t,s):null})}var d_=typeof navigator<`u`?navigator:null,f_=typeof document<`u`?document:null,p_=d_&&d_.userAgent||``,m_=/Edge\/(\d+)/.exec(p_),h_=/MSIE \d/.exec(p_),g_=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(p_),__=!!(h_||g_||m_);h_?document.documentMode:g_?+g_[1]:m_&&+m_[1],!__&&/gecko\/(\d+)/i.test(p_)&&+(/Firefox\/(\d+)/.exec(p_)||[0,0])[1];var v_=!__&&/Chrome\/(\d+)/.exec(p_),y_=!!v_;v_&&+v_[1],!__&&d_&&/Apple Computer/.test(d_.vendor)&&(/Mobile\/\w+/.test(p_)||d_&&d_.maxTouchPoints>2)||d_&&/Mac/.test(d_.platform);var b_=/Android \d/.test(p_);f_&&`webkitFontSmoothing`in f_.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function x_(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t);if(s.parent.type.spec.code)return!1;let c=s.parent.textBetween(Math.max(0,s.parentOffset-500),s.parentOffset,void 0,``)+r;for(let s of i){let i=s,l=i.match.exec(c),u=l&&l[0]&&i.handler(o,l,t-(l[0].length-r.length),n);if(u)return i.undoable!==!1&&u.setMeta(a,{transform:u,from:t,to:n,text:r}),e.dispatch(u),!0}return!1}var S_=new Cg(`MILKDOWN_CUSTOM_INPUTRULES`);function C_({rules:e}){let t=new bg({key:S_,isInputRules:!0,state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return x_(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&x_(n,r.pos,r.pos,``,e,t)}),!1),keydown:(e,t)=>!(b_&&y_&&t.key===`Enter`)||e.composing?!1:e.someProp(`handleKeyDown`,n=>n(e,t))?(t.preventDefault(),!0):!1},handleKeyDown(n,r){if(r.key!==`Enter`)return!1;let{$cursor:i}=n.state.selection;return i?x_(n,i.pos,i.pos,` `,e,t):!1}}});return t}function w_(e,t,n={}){return new o_(e,(e,r,i,a)=>{var o;let{tr:s}=e,c=r[r.length-1],l=r[0],u=[],d,f={group:c,fullMatch:l,start:i,end:a},p=n.updateCaptured?.call(n,f);if(Object.assign(f,p),{group:c,fullMatch:l,start:i,end:a}=f,l===null||c?.trim()===``)return null;if(c){let e=l.search(/\S/),f=i+l.indexOf(c),p=f+c.length;u=s.storedMarks??[],pi&&s.delete(i+e,f),d=i+e+c.length;let m=n.getAttr?.call(n,r);s.addMark(i,d,t.create(m)),s.setStoredMarks(u),(o=n.beforeDispatch)==null||o.call(n,{match:r,start:i,end:a,tr:s})}return s})}function T_(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function E_(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}function D_(e){if(e.content.childCount===1){let t=e.content.firstChild;if(t?.type.name===`text`&&t.marks.length===0)return t;if(t?.type.name===`paragraph`&&t.childCount===1){let e=t.firstChild;if(e?.type.name===`text`&&e.marks.length===0)return e}}return!1}function O_(e){return t=>{for(let n=t.depth;n>0;--n){let r=t.node(n);if(e(r))return{from:t.before(n),to:t.after(n),node:r}}}}function k_(e,t){return O_(e=>e.type===t)(e)}function A_(e,t){let n=t.nodes[e];if(!n)throw Id(`node`,e);return n}function j_(e){return t=>{for(let n=t.depth;n>0;n--){let r=t.node(n);if(e(r))return{pos:t.before(n),start:t.start(n),depth:n,node:r}}}}function M_(e,t){if(!(e instanceof J))return;let{node:n,$from:r}=e;if(E_(t,n))return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}for(var N_=(e,t)=>{let{selection:n,doc:r}=e;if(n instanceof J)return{hasNode:n.node.type===t,pos:n.from,target:n.node};let{from:i,to:a}=n,o=!1,s=-1,c=null;return r.nodesBetween(i,a,(e,n)=>c?!1:e.type!==t||(o=!0,s=n,c=e,!1)),{hasNode:o,pos:s,target:c}},P_={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},F_={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},I_=typeof navigator<`u`&&/Mac/.test(navigator.platform),L_=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),R_=0;R_<10;R_++)P_[48+R_]=P_[96+R_]=String(R_);for(var R_=1;R_<=24;R_++)P_[R_+111]=`F`+R_;for(var R_=65;R_<=90;R_++)P_[R_]=String.fromCharCode(R_+32),F_[R_]=String.fromCharCode(R_);for(var z_ in P_)F_.hasOwnProperty(z_)||(F_[z_]=P_[z_]);function B_(e){var t=!(I_&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||L_&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?F_:P_)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var V_=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),H_=typeof navigator<`u`&&/Win/.test(navigator.platform);function U_(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;ethis.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw Nd();return e}}},X_=class e extends J_{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,r){return new e(t,n,r)}},Z_=class extends Y_{#e=W.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(X_.create(e,[],t)),this),this.closeNode=()=>{try{this.#a()}catch(e){console.error(e)}return this},this.addNode=(e,t,n)=>{try{this.#o(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>(this.#e=e.create(t).addToSet(this.#e),this),this.closeMark=e=>(this.#e=e.removeFromSet(this.#e),this),this.addText=e=>{try{let t=this.top();if(!t)throw Nd();let n=t.pop(),r=this.schema.text(e,this.#e);if(!n)return t.push(r),this;let i=this.#n(n,r);return i?(t.push(i),this):(t.push(n,r),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do e=this.#a();while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#i(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{let n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#t=e=>e.isText;#n=(e,t)=>{if(this.#t(e)&&this.#t(t)&&W.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)};#r=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t)throw Pd(e);return t};#i=e=>{let t=this.#r(e);t.spec.parseMarkdown.runner(this,e,t)};#a=()=>{this.#e=W.none;let e=this.close();return this.#o(e.type,e.attrs,e.content)};#o=(e,t,n)=>{let r=e.createAndFill(t,n,this.#e);if(!r)throw Md(e,t,n);return this.push(r),r}},Q_=class e extends J_{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||=[],this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,i={})=>new e(t,n,r,i)}},$_=e=>Object.prototype.hasOwnProperty.call(e,`size`),ev=class extends Y_{#e=W.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.openNode=(e,t,n)=>(this.open(Q_.create(e,void 0,t,n)),this),this.closeNode=()=>(this.#l(),this),this.addNode=(e,t,n,r)=>(this.#u(e,t,n,r),this),this.withMark=(e,t,n,r)=>(this.#d(e,t,n,r),this),this.closeMark=e=>(this.#f(e),this),this.build=()=>{let e=null;do e=this.#l();while(this.size());return e},this.next=e=>$_(e)?(e.forEach(e=>{this.#i(e)}),this):(this.#i(e),this),this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}#t=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t)throw Fd(e.type);return t};#n=e=>this.#t(e).spec.toMarkdown.runner(this,e);#r=(e,t)=>this.#t(e).spec.toMarkdown.runner(this,e,t);#i=e=>{let{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!this.#r(t,e))&&this.#n(e),t.forEach(e=>this.#f(e))};#a=(e,t)=>{if(e.type===t||e.children?.length!==1)return e;let n=e=>{if(e.type===t)return e.value==null?e:null;if(e.children?.length!==1)return null;let[r]=e.children;return r?n(r):null},r=n(e);if(!r)return e;let i=r.children?[...r.children]:void 0,a={...e,children:i};return a.children=i,r.children=[a],r};#o=e=>{let{children:t}=e;return t&&(e.children=t.reduce((e,t,n)=>{if(n===0)return[t];let r=e.at(-1);if(r&&r.isMark&&t.isMark){t=this.#a(t,r.type);let{children:n,...i}=t,{children:a,...o}=r;if(t.type===r.type&&n&&a&&JSON.stringify(i)===JSON.stringify(o)){let t={...o,children:[...a,...n]};return e.slice(0,-1).concat(this.#o(t))}}return e.concat(t)},[])),e};#s=e=>{let t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t};#c=(e,t)=>{let n=``,r=``,i=e.children,a=-1,o=-1,s=e=>{e&&e.forEach((e,t)=>{e.type===`text`&&e.value&&(a<0&&(a=t),o=t)})};if(i){s(i);let e=i?.[o],t=i?.[a];if(e&&e.value.endsWith(` `)){let t=e.value,n=t.trimEnd();r=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(` `)){let e=t.value,r=e.trimStart();n=e.slice(0,e.length-r.length),t.value=r}}n.length&&this.#u(`text`,void 0,n);let c=t();return r.length&&this.#u(`text`,void 0,r),c};#l=(e=!1)=>{let t=this.close(),n=()=>this.#u(t.type,t.children,t.value,t.props);return e?this.#c(t,n):n()};#u=(e,t,n,r)=>{let i=Q_.create(e,t,n,r),a=this.#o(this.#s(i));return this.push(a),a};#d=(e,t,n,r)=>e.isInSet(this.#e)?this:(this.#e=e.addToSet(this.#e),this.openNode(t,n,{...r,isMark:!0}));#f=e=>{e.isInSet(this.#e)&&(this.#e=e.type.removeFromSet(this.#e),this.#l(!0))}},tv=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},nv=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},rv=null,iv=function(e,t,n){let r=rv||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},av=function(){rv=null},ov=function(e,t,n,r){return n&&(cv(e,t,n,r,-1)||cv(e,t,n,r,1))},sv=/^(img|br|input|textarea|hr)$/i;function cv(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:lv(e))){let n=e.parentNode;if(!n||n.nodeType!=1||pv(e)||sv.test(e.nodeName)||e.contentEditable==`false`)return!1;t=tv(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`){if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1}else e=n,t=i<0?lv(e):0}else return!1}}function lv(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function uv(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=lv(e)}else if(e.parentNode&&!pv(e))t=tv(e),e=e.parentNode;else return null}}function dv(e,t){for(;;){if(e.nodeType==3&&t2),Mv=jv||(vv?/Mac/.test(vv.platform):!1),Nv=vv?/Win/.test(vv.platform):!1,Pv=/Android \d/.test(bv),Fv=!!yv&&`webkitFontSmoothing`in yv.documentElement.style,Iv=Fv?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Lv(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Rv(e,t){return typeof e==`number`?e:e[t]}function zv(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function Bv(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=nv(o);continue}let e=o,n=e==a.body,s=n?Lv(a):zv(e),c=0,l=0;if(t.tops.bottom-Rv(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+Rv(i,`top`)-s.top:t.bottom-s.bottom+Rv(i,`bottom`)),t.lefts.right-Rv(r,`right`)&&(c=t.right-s.right+Rv(i,`right`)),c||l){if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:nv(o)}}function Vv(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:Hv(e.dom)}}function Hv(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=nv(r));return t}function Uv({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Wv(n,r==0?0:r-t)}function Wv(e,t){for(let n=0;n=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?Jv(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:qv(n,i)}function Jv(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function Yv(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Xv(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function Qv(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right-1?i:e.docView.posFromDOM(t,n,-1)}function $v(e,t,n){let r=e.childNodes.length;if(r&&n.topt.top&&i++}let n;Fv&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=Qv(e,r,i,t))}s??=Zv(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function ty(e){return e.top=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,ay(ny(iv(r,e,t),a),a<0)}}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==lv(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return oy(e.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==lv(r))){let e=r.childNodes[i-1],t=e.nodeType==3?iv(e,lv(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return ay(ny(t,1),!1)}if(a==null&&i=0)}function ay(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function oy(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function sy(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function cy(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return sy(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=iy(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=iv(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;ei.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var ly=/[\u0590-\u08ac]/;function uy(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!ly.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:sy(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var dy=null,fy=null,py=!1;function my(e,t,n){return dy==t&&fy==n?py:(dy=t,fy=n,py=n==`up`||n==`down`?cy(e,t,n):uy(e,t,n))}var hy=0,gy=1,_y=2,vy=3,yy=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=hy,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;ttv(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node)){if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;te||i instanceof Ey){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof by&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?tv(e.dom)+1:0}}{let e,r=!0;for(;e=n=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=tv(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;es&&at){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r=n:en){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?_y:gy,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=vy:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?_y:vy}n=a}this.dirty=_y}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?_y:gy;t.dirty{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==hy&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},xy=class extends yy{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Sy=class e extends yy{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=Fm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&vy||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=vy&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=hy){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty0&&(a=Uy(a,0,t,r));for(let e=0;e{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=Fm.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Py(u,r,n),l?c=new Dy(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new Ty(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>U.empty)}return e}matchesNode(e,t,n){return this.dirty==hy&&e.eq(this.node)&&Fy(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new Ly(this,a&&a.node,e);By(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?W.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==_y)&&(a&&this.protectLocalComposition(e,a),Oy(this.contentDOM,this.children,e),jv&&Vy(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof q)||nt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=Hy(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let a=new xy(this,i,t,r);e.input.compositionNodes.push(a),this.children=Uy(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==vy||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=hy}updateOuterDeco(e){if(Fy(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=My(this.dom,this.nodeDOM,jy(this.outerDeco,this.node,t),jy(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function wy(e,t,n,r,i){Py(r,t,e);let a=new Cy(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var Ty=class e extends Cy{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==vy||this.dirty!=hy&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=hy||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=hy,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=vy)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ey=class extends yy{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==hy&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},Dy=class extends Cy{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==vy)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Oy(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a>1,o=Math.min(a,e.length);for(;i-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Sy.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Sy)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function zy(e,t){return e.type.side-t.type.side}function By(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;na;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function Vy(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function Hy(e,t,n,r){for(let i=0,a=0;i=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function Uy(e,t,n,r,i){let a=[];for(let o=0,s=0;o=n||u<=t?a.push(c):(ln&&a.push(c.slice(n-l,c.size,r)))}return a}function Wy(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(mv(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&J.isSelectable(e)&&i.parent&&!(e.isInline&&fv(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new J(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!Gy(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Qy(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,tv(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&wv&&Tv<=11&&(n.disabled=!0,n.disabled=!1)}function $y(e,t){if(t instanceof J){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(eb(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else eb(e)}function eb(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function tb(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||q.between(t,n,r)}function nb(e){return e.editable&&!e.hasFocus()?!1:rb(e)}function rb(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function ib(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return ov(t.node,t.offset,n.anchorNode,n.anchorOffset)}function ab(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&K.findFrom(a,t)}function ob(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function sb(e,t,n){let r=e.state.selection;if(r instanceof q){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return ob(e,new q(r.$anchor,a))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=ab(e.state,t);return n&&n instanceof J?ob(e,n):!1}if(!(Mv&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?J.isSelectable(i)?ob(e,new J(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):Fv?ob(e,new q(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof J&&r.node.isInline)return ob(e,new q(t>0?r.$to:r.$from));else{let n=ab(e.state,t);return n?ob(e,n):!1}}function cb(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function lb(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function ub(e,t){return t<0?db(e):fb(e)}function db(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(Ev&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(lb(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(pb(n))break;else{let t=n.previousSibling;for(;t&&lb(t,-1);)i=n.parentNode,a=tv(t),t=t.previousSibling;if(t)n=t,r=cb(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?gb(e,n,r):i&&gb(e,i,a)}function fb(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=cb(n),a,o;for(;;)if(r{e.state==i&&Ky(e)},50)}function _b(e,t){let n=e.state.doc.resolve(t);if(!(Ov||Nv)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i1)return n.leftr.top&&i1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function vb(e,t,n){let r=e.state.selection;if(r instanceof q&&!r.empty||n.indexOf(`s`)>-1||Mv&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=ab(e.state,t);if(n&&n instanceof J)return ob(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof og?K.near(n,t):K.findFrom(n,t);return o?ob(e,o):!1}return!1}function yb(e,t){if(!(e.state.selection instanceof q))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function bb(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function xb(e){if(!Av||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;bb(e,n,`true`),setTimeout(()=>bb(e,n,`false`),20)}return!1}function Sb(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Cb(e,t){let n=t.keyCode,r=Sb(t);if(n==8||Mv&&n==72&&r==`c`)return yb(e,-1)||ub(e,-1);if(n==46&&!t.shiftKey||Mv&&n==68&&r==`c`)return yb(e,1)||ub(e,1);if(n==13||n==27)return!0;if(n==37||Mv&&n==66&&r==`c`){let t=n==37?_b(e,e.state.selection.from)==`ltr`?-1:1:-1;return sb(e,t,r)||ub(e,t)}if(n==39||Mv&&n==70&&r==`c`){let t=n==39?_b(e,e.state.selection.from)==`ltr`?1:-1:1;return sb(e,t,r)||ub(e,t)}return n==38||Mv&&n==80&&r==`c`?vb(e,-1,r)||ub(e,-1):n==40||Mv&&n==78&&r==`c`?xb(e)||vb(e,1,r)||ub(e,1):!(r!=(Mv?`m`:`c`)||n!=66&&n!=73&&n!=89&&n!=90)}function wb(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||Fm.fromSchema(e.state.schema),s=Fb(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=Nb[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,` `),slice:t}}function Tb(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new G(U.from(e.state.schema.text(t.replace(/\r\n?/g,` `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=Fm.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=Rb(n),Fv&&zb(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||xm.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Eb.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=Bb(Mb(s,+u[1],+u[2]),u[4]);else if(s=G.maxOpen(Db(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e{s=t(s,e,c)}),s}var Eb=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Db(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&kb(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Ab(a[a.length-1],i.length));let n=Ob(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return U.from(a)}return e}function Ob(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,U.from(e));return e}function kb(e,t,n,r,i){if(i1&&(a=0),i=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(U.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function Mb(e,t,n){return te}),Ib.createHTML(e)):e}function Rb(e){let t=/^(\s*]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Fb().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&Nb[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>``).reverse().join(``)),n.innerHTML=Lb(e),i)for(let e=0;e=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=U.from(t.create(r[e+1],i)),a++,o++}return new G(i,a,o)}var Vb={},Hb={},Ub={touchstart:!0,touchmove:!0},Wb=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Gb(e){for(let t in Vb){let n=Vb[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{Xb(e,t)&&!Yb(e,t)&&(e.editable||!(t.type in Hb))&&n(e,t)},Ub[t]?{passive:!0}:void 0)}Av&&e.dom.addEventListener(`input`,()=>null),Jb(e)}function Kb(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function qb(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function Jb(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Yb(e,t))})}function Yb(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Xb(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Zb(e,t){!Yb(e,t)&&Vb[t.type]&&(e.editable||!(t.type in Hb))&&Vb[t.type](e,t)}Hb.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!dx(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Pv&&Ov&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),jv&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,hv(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||Cb(e,n)?n.preventDefault():Kb(e,`key`)}},Hb.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},Hb.keypress=(e,t)=>{let n=t;if(dx(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Mv&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof q)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function Qb(e){return{left:e.clientX,top:e.clientY}}function $b(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function ex(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function tx(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function nx(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&J.isSelectable(r)?(tx(e,new J(n),`pointer`),!0):!1}function rx(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof J&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(J.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(tx(e,J.create(e.state.doc,i),`pointer`),!0)}function ix(e,t,n,r,i){return ex(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?rx(e,n):nx(e,n))}function ax(e,t,n,r){return ex(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function ox(e,t,n,r){return ex(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||sx(e,n,r)}function sx(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(tx(e,q.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)tx(e,q.create(r,a+1,a+1+n.content.size),`pointer`);else if(J.isSelectable(n))tx(e,J.create(r,a),`pointer`);else continue;return!0}}function cx(e){return vx(e)}var lx=Mv?`metaKey`:`ctrlKey`;Vb.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=cx(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&$b(n,e.input.lastClick)&&!n[lx]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(Qb(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ux(e,o,n,!!r)):(a==`doubleClick`?ax:ox)(e,o.pos,o.inside,n)?n.preventDefault():Kb(e,`pointer`))};var ux=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[lx],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof J&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ev&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),Kb(e,`pointer`)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ky(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Qb(e))),this.updateAllowDefault(e),this.allowDefault||!t?Kb(this.view,`pointer`):ix(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Av&&this.mightDrag&&!this.mightDrag.node.isAtom||Ov&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(tx(this.view,K.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):Kb(this.view,`pointer`)}move(e){this.updateAllowDefault(e),Kb(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};Vb.touchstart=e=>{e.input.lastTouch=Date.now(),cx(e),Kb(e,`pointer`)},Vb.touchmove=e=>{e.input.lastTouch=Date.now(),Kb(e,`pointer`)},Vb.contextmenu=e=>cx(e);function dx(e,t){return e.composing?!0:Av&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var fx=Pv?5e3:-1;Hb.compositionstart=Hb.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof q&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||Ov&&Nv&&px(e)))e.markCursor=e.state.storedMarks||n.marks(),vx(e,!0),e.markCursor=null;else if(vx(e,!t.selection.empty),Ev&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}mx(e,fx)};function px(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}Hb.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,mx(e,20))};function mx(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>vx(e),t))}function hx(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=_x());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function gx(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=uv(t.focusNode,t.focusOffset),r=dv(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function _x(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function vx(e,t=!1){if(!(Pv&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),hx(e),t||e.docView&&e.docView.dirty){let n=Wy(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function yx(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var bx=wv&&Tv<15||jv&&Iv<604;Vb.copy=Hb.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=bx?null:n.clipboardData,{dom:o,text:s}=wb(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):yx(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function xx(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Sx(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Cx(e,r.value,null,i,t):Cx(e,r.textContent,r.innerHTML,i,t)},50)}function Cx(e,t,n,r,i){let a=Tb(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||G.empty)))return!0;if(!a)return!1;let o=xx(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function wx(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}Hb.paste=(e,t)=>{let n=t;if(e.composing&&!Pv)return;let r=bx?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Cx(e,wx(r),r.getData(`text/html`),i,n)?n.preventDefault():Sx(e,n)};var Tx=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Ex=Mv?`altKey`:`ctrlKey`;function Dx(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[Ex]}Vb.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(Qb(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof J?i.to-1:i.to))){if(r&&r.mightDrag)o=J.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=J.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=wb(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!Ov||kv>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(bx?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,bx||n.dataTransfer.setData(`text/plain`,c),e.dragging=new Tx(l,Dx(e,n),o)},Vb.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Hb.dragover=Hb.dragenter=(e,t)=>t.preventDefault(),Hb.drop=(e,t)=>{try{Ox(e,t,e.dragging)}finally{e.dragging=null}};function Ox(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Qb(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Tb(e,wx(t.dataTransfer),bx?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Dx(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||G.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Ph(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&J.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new J(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(tb(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}Vb.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Ky(e)},20))},Vb.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},Vb.beforeinput=(e,t)=>{if(Ov&&Pv&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,hv(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in Hb)Vb[e]=Hb[e];function kx(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var Ax=class e{constructor(e,t){this.toDOM=e,this.spec=t||Fx,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new Nx(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&kx(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},jx=class e{constructor(e,t){this.attrs=e,this.spec=t||Fx}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new Nx(i,a,this)}valid(e,t){return t.from=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;ae){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==Lx||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Fx)}mapInner(t,n,r,i,a){let o;for(let e=0;e{let o=t+r,s;if(s=Hx(n,e,o)){for(i||=this.children.slice();aa&&n.to=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;ea&&t.type instanceof jx){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;ee.map(t,n,Fx));return e.from(r)}forChild(t,n){if(n.isLeaf)return Ix.empty;let r=[];for(let i=0;ie instanceof Ix)?t:t.reduce((e,t)=>e.concat(t instanceof Ix?t:t.members),[]))}}forEachSet(e){for(let t=0;t{let o=a-i-(n-e);for(let i=0;ia+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==Lx?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=Wx(Vx(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;en&&a.to{let s=Hx(e,t,o+n);if(s){a=!0;let e=Wx(s,t,n+o+1,r);e!=Lx&&i.push(o,o+t.nodeSize,e)}});let o=Bx(a?Ux(e):e,-n).sort(Gx);for(let e=0;e0;)t++;e.splice(t,0,n)}function Jx(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=Lx&&t.push(r)}),e.cursorWrapper&&t.push(Ix.create(e.state.doc,[e.cursorWrapper.deco])),Rx.from(t)}var Yx={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Xx=wv&&Tv<=11,Zx=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Qx=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Zx,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;ee.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():Av&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Xx&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Yx)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(nb(this.view)){if(this.suppressingSelectionUpdates)return Ky(this.view);if(wv&&Tv<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ov(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=nv(n))t.add(n);for(let r=e.anchorNode;r;r=nv(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&nb(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;ee.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(Ev&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||iS(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(i>-1&&(e.docView.markDirty(i,a),tS(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,aS(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Ky(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;ni;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||xm.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace!=`pre`||`full`,findPositions:l,ruleFromNode:sS,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function sS(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(Av&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(e.parentNode.lastChild==e||Av&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var cS=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function lS(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Wy(e,t);if(n&&!e.state.selection.eq(n)){if(Ov&&Pv&&e.input.lastKeyCode===13&&Date.now()-100t(e,hv(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=oS(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Pv)&&i.some(e=>e.nodeType==1&&!cS.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,hv(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof q&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=uS(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.frome.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),wv&&Tv<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((jv&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.post(e,hv(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&fS(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,hv(8,`Backspace`)))){Pv&&Ov&&e.domObserver.suppressSelectionUpdates();return}Ov&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),Pv&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,hv(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=uS(e,n.doc,l.sel);t&&!(Ov&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDeleteKy(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=dS(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x())}else e.dispatch(x())}function uS(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:tb(e,t.resolve(n.anchor),t.resolve(n.head))}function dS(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;ee.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;en||pS(o,!0,!1)0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function mS(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o=o?a-r:0;a-=e,a&&a=s?a-r:0;a-=t,a&&a=56320&&t<=57343&&n>=55296&&n<=56319}var gS=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Wb,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(CS),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=yS(this),vS(this),this.nodeViews=xS(this),this.docView=wy(this.state.doc,_S(this),Jx(this),this.dom,this),this.domObserver=new Qx(this,(e,t,n,r)=>lS(this,e,t,n,r)),this.domObserver.start(),Gb(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Jb(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(CS),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(hx(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=xS(this);SS(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Jb(this),this.editable=yS(this),vS(this);let o=Jx(this),s=_S(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&Vv(this);if(i){this.domObserver.stop();let t=l&&(wv||Ov)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&bS(n.selection,e.selection);if(l){let n=Ov?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=gx(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=wy(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ib(this))?Ky(this,t):($y(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&Uv(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof J){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Bv(this,t.getBoundingClientRect(),e)}else Bv(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&ee.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return ey(this,e)}coordsAtPos(e,t=1){return iy(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return my(this,t||this.state,e)}pasteHTML(e,t){return Cx(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Cx(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return wb(this,e)}destroy(){this.docView&&(qb(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Jx(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,av())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Zb(this,e)}domSelectionRange(){let e=this.domSelection();return e?Av&&this.root.nodeType===11&&gv(this.dom.ownerDocument)==this.dom&&rS(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};gS.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function _S(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[Nx.node(0,e.state.doc.content.size,t)]}function vS(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:Nx.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function yS(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function bS(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function xS(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function SS(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function CS(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}function wS(e,t){return e.meta={package:`@milkdown/core`,group:`System`,...t},e}var TS={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||`*`,a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i+i),a(),s},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||`*`,a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i),a(),s}},ES=H({},`editorView`),DS=H({},`editorState`),OS=H([],`initTimer`),kS=H({},`editor`),AS=H([],`inputRules`),jS=H([],`prosePlugins`),MS=H([],`remarkPlugins`),NS=H([],`nodeView`),PS=H([],`markView`),FS=H(Oi().use(ki).use(bp),`remark`),IS=H({handlers:TS,encode:[]},`remarkStringifyOptions`),LS=Yd(`ConfigReady`);function RS(e){let t=t=>(t.record(LS),async()=>(await e(t),t.done(LS),()=>{t.clearTimer(LS)}));return wS(t,{displayName:`Config`}),t}var zS=Yd(`InitReady`);function BS(e){let t=t=>(t.inject(kS,e).inject(jS,[]).inject(MS,[]).inject(AS,[]).inject(NS,[]).inject(PS,[]).inject(IS,{handlers:TS,encode:[]}).inject(FS,Oi().use(ki).use(bp)).inject(OS,[LS]).record(zS),async()=>{await t.waitTimers(OS);let e=t.get(IS);return t.set(FS,Oi().use(ki).use(bp,e)),t.done(zS),()=>{t.remove(kS).remove(jS).remove(MS).remove(AS).remove(NS).remove(PS).remove(IS).remove(FS).remove(OS).clearTimer(zS)}});return wS(t,{displayName:`Init`}),t}var VS=Yd(`SchemaReady`),HS=H([],`schemaTimer`),US=H({},`schema`),WS=H([],`nodes`),GS=H([],`marks`);function KS(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var qS=e=>(e.inject(US,{}).inject(WS,[]).inject(GS,[]).inject(HS,[zS]).record(VS),async()=>{await e.waitTimers(HS);let t=e.get(FS),n=e.get(MS).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(FS,n);let r=new _m({nodes:Object.fromEntries(e.get(WS).map(([e,t])=>[e,KS(t)])),marks:Object.fromEntries(e.get(GS).map(([e,t])=>[e,KS(t)]))});return e.set(US,r),e.done(VS),()=>{e.remove(US).remove(WS).remove(GS).remove(HS).clearTimer(VS)}});wS(qS,{displayName:`Schema`});var JS=class{constructor(){this.setCtx=e=>{this.#t=e},this.chain=()=>{if(this.#t==null)throw Rd();let e=this.#t,t=[],n=this.get.bind(this),r={run:()=>{let n=e_(...t),r=e.get(ES);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:i.bind(this)};function i(e,i){let a=n(e);return t.push(a(i)),r}return r}}#e=new Vd;#t=null;get ctx(){return this.#t}create(e,t){let n=e.create(this.#e.sliceMap);return n.set(t),n}get(e){return this.#e.get(e).get()}remove(e){return this.#e.remove(e)}call(e,t){if(this.#t==null)throw Rd();let n=this.get(e)(t),r=this.#t.get(ES);return n(r.state,r.dispatch,r)}inline(e){if(this.#t==null)throw Rd();let t=this.#t.get(ES);return e(t.state,t.dispatch,t)}};function YS(e=`cmdKey`){return H((()=>()=>!1),e)}var Y=H(new JS,`commands`),XS=H([VS],`commandsTimer`),ZS=Yd(`CommandsReady`),QS=e=>{let t=new JS;return t.setCtx(e),e.inject(Y,t).inject(XS,[VS]).record(ZS),async()=>(await e.waitTimers(XS),e.done(ZS),()=>{e.remove(Y).remove(XS).clearTimer(ZS)})};wS(QS,{displayName:`Commands`});function $S(e){return e.Backspace=e_(c_,wg,Dg,Ag),e}var eC=class{constructor(){this.setCtx=e=>{this.#e=e},this.add=e=>(this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if(typeof n==`function`){let r={key:e,onRun:()=>n};this.#t.push(r),t.push(()=>{this.#t=this.#t.filter(e=>e!==r)})}else this.#t.push(n),t.push(()=>{this.#t=this.#t.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=$S(a_);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#t.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#e;if(i==null)throw V();return e_(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#e=null;#t=[];get ctx(){return this.#e}},tC=H(new eC,`keymap`),nC=H([VS],`keymapTimer`),rC=Yd(`KeymapReady`),iC=e=>{let t=new eC;return t.setCtx(e),e.inject(tC,t).inject(nC,[VS]).record(rC),async()=>(await e.waitTimers(nC),e.done(rC),()=>{e.remove(tC).remove(nC).clearTimer(rC)})},aC=Yd(`ParserReady`),oC=(()=>{throw V()}),sC=H(oC,`parser`),cC=H([],`parserTimer`),lC=e=>(e.inject(sC,oC).inject(cC,[VS]).record(aC),async()=>{await e.waitTimers(cC);let t=e.get(FS),n=e.get(US);return e.set(sC,Z_.create(n,t)),e.done(aC),()=>{e.remove(sC).remove(cC).clearTimer(aC)}});wS(lC,{displayName:`Parser`});var uC=Yd(`SerializerReady`),dC=H([],`serializerTimer`),fC=(()=>{throw V()}),pC=H(fC,`serializer`),mC=e=>(e.inject(pC,fC).inject(dC,[VS]).record(uC),async()=>{await e.waitTimers(dC);let t=e.get(FS),n=e.get(US);return e.set(pC,ev.create(n,t)),e.done(uC),()=>{e.remove(pC).remove(dC).clearTimer(uC)}});wS(mC,{displayName:`Serializer`});var hC=H(``,`defaultValue`),gC=H(e=>e,`stateOptions`),_C=H([],`editorStateTimer`),vC=Yd(`EditorStateReady`);function yC(e,t,n){if(typeof e==`string`)return t(e);if(e.type===`html`)return xm.fromSchema(n).parse(e.dom);if(e.type===`json`)return Kp.fromJSON(n,e.value);throw kd(e)}var bC=new Cg(`MILKDOWN_STATE_TRACKER`),xC=e=>(e.inject(hC,``).inject(DS,{}).inject(gC,e=>e).inject(_C,[aC,uC,ZS,rC]).record(vC),async()=>{await e.waitTimers(_C);let t=e.get(US),n=e.get(sC),r=e.get(AS),i=e.get(gC),a=e.get(jS),o=yC(e.get(hC),n,t),s=e.get(tC),c=s.addBaseKeymap(),l=[...a,new bg({key:bC,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(DS,i)}}}),C_({rules:r}),K_(s.build())];e.set(jS,l);let u=i({schema:t,doc:o,plugins:l}),d=vg.create(u);return e.set(DS,d),e.done(vC),()=>{c(),e.remove(hC).remove(DS).remove(gC).remove(_C).clearTimer(vC)}});wS(xC,{displayName:`EditorState`});var SC=H([],`pasteRule`),CC=H([VS],`pasteRuleTimer`),wC=Yd(`PasteRuleReady`),TC=e=>(e.inject(SC,[]).inject(CC,[VS]).record(wC),async()=>(await e.waitTimers(CC),e.done(wC),()=>{e.remove(SC).remove(CC).clearTimer(wC)}));wS(TC,{displayName:`PasteRule`});var EC=Yd(`EditorViewReady`),DC=H([],`editorViewTimer`),OC=H({},`editorViewOptions`),kC=H(null,`root`),AC=H(null,`rootDOM`),jC=H({},`rootAttrs`);function MC(e,t){let n=document.createElement(`div`);n.className=`milkdown`,e.appendChild(n),t.set(AC,n);let r=t.get(jC);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}function NC(e){e.classList.add(`editor`),e.setAttribute(`role`,`textbox`)}var PC=new Cg(`MILKDOWN_VIEW_CLEAR`),FC=e=>(e.inject(kC,document.body).inject(ES,{}).inject(OC,{}).inject(AC,null).inject(jC,{}).inject(DC,[vC,wC]).record(EC),async()=>{await e.wait(zS);let t=e.get(kC)||document.body,n=typeof t==`string`?document.querySelector(t):t;e.update(jS,t=>[new bg({key:PC,view:t=>{let r=n?MC(n,e):void 0;return(()=>{if(r&&n){let e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(DC);let r=e.get(DS),i=e.get(OC),a=new gS(n,{state:r,nodeViews:Object.fromEntries(e.get(NS)),markViews:Object.fromEntries(e.get(PS)),transformPasted:(t,n,r)=>(e.get(SC).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...i});return NC(a.dom),e.set(ES,a),e.done(EC),()=>{a?.destroy(),e.remove(kC).remove(ES).remove(OC).remove(AC).remove(jC).remove(DC).clearTimer(EC)}});wS(FC,{displayName:`EditorView`});var IC=function(e){return e.Idle=`Idle`,e.OnCreate=`OnCreate`,e.Created=`Created`,e.OnDestroy=`OnDestroy`,e.Destroyed=`Destroyed`,e}({}),LC=class e{constructor(){this.enableInspector=(e=!0)=>(this.#e=e,this),this.onStatusChange=e=>(this.#r=e,this),this.config=e=>(this.#n.push(e),this),this.removeConfig=e=>(this.#n=this.#n.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#t===IC.Created&&this.#u(t,this.#o),this},this.remove=async e=>this.#t===IC.OnCreate?(console.warn(`[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code.`),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#d([e].flat(),!0),this),this.create=async()=>this.#t===IC.OnCreate?this:(this.#t===IC.Created&&await this.destroy(),this.#p(IC.OnCreate),this.#l(),this.#u([...this.#o.keys()],this.#o),await Promise.all([this.#m(this.#s),this.#m(this.#o)].flat()),this.#p(IC.Created),this),this.destroy=async(e=!1)=>this.#t===IC.Destroyed||this.#t===IC.OnDestroy?this:this.#t===IC.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#n=[]),this.#p(IC.OnDestroy),await this.#d([...this.#o.keys()],e),await this.#f(),this.#p(IC.Destroyed),this),this.action=e=>e(this.#c),this.inspect=()=>this.#e?[...this.#s.values(),...this.#o.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#e=!1;#t=IC.Idle;#n=[];#r=()=>void 0;#i=new Vd;#a=new Kd;#o=new Map;#s=new Map;#c=new Gd(this.#i,this.#a);#l=()=>{let e=RS(async e=>{await Promise.all(this.#n.map(t=>Promise.resolve(t(e))))}),t=[qS,lC,mC,QS,iC,TC,xC,FC,BS(this),e];this.#u(t,this.#s)};#u=(e,t)=>{e.forEach(e=>{let n=this.#c.produce(this.#e?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})};#d=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#o.get(e)?.cleanup;return t?this.#o.delete(e):this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof n==`function`?n():n}));#f=async()=>{await Promise.all([...this.#s.entries()].map(async([e,{cleanup:t}])=>typeof t==`function`?t():t)),this.#s.clear()};#p=e=>{this.#t=e,this.#r(e)};#m=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let a=await i();e.set(t,{ctx:r,handler:i,cleanup:a})});get ctx(){return this.#c}get status(){return this.#t}},RC=(0,M.createContext)({});function zC(){let{dom:e,editor:t,setLoading:n,editorFactory:r}=(0,M.useContext)(RC),i=(0,M.useRef)(null);return(0,M.useEffect)(()=>{let a=i.current;if(!r||!a)return;e.current=a;let o=r(a);if(o)return n(!0),o.create().then(e=>{t.current=e}).finally(()=>{n(!1)}).catch(console.error),()=>{o.destroy().catch(console.error)}},[e,t,r,n]),i}var BC=()=>{let e=zC();return M.createElement(`div`,{"data-milkdown-root":!0,ref:e})},VC=({children:e})=>{let t=(0,M.useRef)(void 0),[n,r]=(0,M.useState)(void 0),i=(0,M.useRef)(void 0),[a,o]=(0,M.useState)(!0),s=(0,M.useMemo)(()=>({loading:a,dom:t,editor:i,setLoading:o,editorFactory:n,setEditorFactory:r}),[a,n]);return M.createElement(RC.Provider,{value:s},e)};function HC(e,t=[]){let n=(0,M.useContext)(RC),r=(0,M.useCallback)(e,t);return(0,M.useLayoutEffect)(()=>{n.setEditorFactory(()=>r)},[n,r]),{loading:n.loading,get:()=>n.editor.current}}var UC=e=>crypto.getRandomValues(new Uint8Array(e)),WC=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(409.6*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]=a))return o}}};((e,t=21)=>WC(e,t|0,UC))(`abcedfghicklmn`,10);function X(e,t){let n=YS(e),r=i=>async()=>{r.key=n,await i.wait(ZS);let a=t(i);return i.get(Y).create(n,a),r.run=t=>i.get(Y).call(e,t),()=>{i.get(Y).remove(n)}};return r}function GC(e){let t=n=>async()=>{await n.wait(VS);let r=e(n);return n.update(AS,e=>[...e,r]),t.inputRule=r,()=>{n.update(AS,e=>e.filter(e=>e!==r))}};return t}function KC(e){let t=n=>async()=>{await n.wait(VS);let r=e(n);return n.update(SC,e=>[...e,r]),t.pasteRule=r,()=>{n.update(SC,e=>e.filter(e=>e!==r))}};return t}function qC(e,t){let n=r=>async()=>{let i=t(r);return r.update(GS,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(GS,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(US).marks[e];if(!n)throw Bd(e);return n},n}function JC(e,t){let n=r=>async()=>{let i=t(r);return r.update(WS,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(WS,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(US).nodes[e];if(!n)throw zd(e);return n},n}function YC(e){let t,n=n=>async()=>(await n.wait(VS),t=e(n),n.update(jS,e=>[...e,t]),()=>{n.update(jS,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function XC(e){let t=n=>async()=>{await n.wait(rC);let r=n.get(tC),i=e(n),a=r.addObjectKeymap(i);return t.keymap=i,()=>{a()}};return t}function ZC(e,t){let n=H(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function QC(e,t){let n=ZC(t,e),r=JC(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.node=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>QC(e,n(t)),i}function $C(e,t){let n=ZC(t,e),r=qC(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.mark=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>$C(e,n(t)),i}function ew(e,t){let n=ZC(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=XC(e=>{let r=e.get(n.key),i=Object.entries(t).flatMap(([e,{command:t}])=>{let n=r[e],i=[n.shortcuts].flat(),a=n.priority;return i.map(e=>[e,{key:e,onRun:t,priority:a}])});return Object.fromEntries(i)}),i=[n,r];return i.ctx=n,i.shortcuts=r,i.key=n.key,i.keymap=r.keymap,i}var tw=(e,t=()=>({}))=>ZC(t,`${e}Attr`),nw=(e,t=()=>({}))=>ZC(t,`${e}Attr`);function rw(e,t,n){let r=ZC(n??{},e),i=e=>async()=>{await e.wait(zS);let n={plugin:t(e),options:e.get(r.key)};return e.update(MS,e=>[...e,n]),()=>{e.update(MS,e=>e.filter(e=>e!==n))}},a=[r,i];return a.id=e,a.plugin=i,a.options=r,a}function iw(e,t){return n=>n.get(Y).call(e,t)}function aw(e,t=!1){return n=>{let r=n.get(ES),i=n.get(sC)(e);if(!i)return;if(!t){let{state:e}=r;return r.dispatch(e.tr.replace(0,e.doc.content.size,new G(i.content,0,0)))}let a=n.get(US),o=n.get(gC)({schema:a,doc:i,plugins:n.get(jS)}),s=vg.create(o);r.updateState(s)}}function ow(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(s.type!=e)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let t=U.empty,a=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-a;e>=i.depth-3;e--)t=U.from(i.node(e).copy(t));let o=i.indexAfter(-1){if(l>-1)return!1;e.isTextblock&&e.content.size==0&&(l=t+1)}),l>-1&&c.setSelection(K.near(c.doc.resolve(l))),r(c.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return Dh(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function sw(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?cw(t,n,e,a):lw(t,n,a):!0:!1}}function cw(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);aa;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?U.empty:U.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new lh(d-+!!s,f+ +!!c,d+1,f-1,new G((s?U.empty:U.from(i.copy(U.empty))).append(c?U.empty:U.from(i.copy(U.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function uw(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=U.from(r?e.create():null),o=new G(U.from(e.create(null,U.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new lh(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}function dw(e){let t=new Map;if(!e||!e.type)throw Error(`mdast-util-definitions expected node`);return Ti(e,`definition`,function(e){let n=fw(e.identifier);n&&!t.get(n)&&t.set(n,e)}),n;function n(e){let n=fw(e);return t.get(n)}}function fw(e){return String(e||``).toUpperCase()}function pw(){return function(e){let t=dw(e);Ti(e,function(e,n,r){if(e.type===`definition`&&r!==void 0&&typeof n==`number`)return r.children.splice(n,1),[Di,n];if(e.type===`imageReference`||e.type===`linkReference`){let i=t(e.identifier);if(i&&r&&typeof n==`number`)return r.children[n]=e.type===`imageReference`?{type:`image`,url:i.url,title:i.title,alt:e.alt}:{type:`link`,url:i.url,title:i.title,children:e.children},[Di,n]}})}}function mw(e,t){if(!(t.childCount>=1&&t.lastChild?.type.name===`hardbreak`)){e.next(t.content);return}let n=[];t.content.forEach((e,r,i)=>{i!==t.childCount-1&&n.push(e)}),e.next(U.fromArray(n))}function Z(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-commonmark`,...t}}),e}var hw=nw(`emphasis`);Z(hw,{displayName:`Attr`,group:`Emphasis`});var gw=$C(`emphasis`,e=>({attrs:{marker:{default:e.get(IS).emphasis||`*`,validate:`string`}},parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style`,getAttrs:e=>e===`italic`}],toDOM:t=>[`em`,e.get(hw.key)(t)],parseMarkdown:{match:e=>e.type===`emphasis`,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`emphasis`,runner:(e,t)=>{e.withMark(t,`emphasis`,void 0,{marker:t.attrs.marker})}}}));Z(gw.mark,{displayName:`MarkSchema`,group:`Emphasis`}),Z(gw.ctx,{displayName:`MarkSchemaCtx`,group:`Emphasis`});var _w=X(`ToggleEmphasis`,e=>()=>$g(gw.type(e)));Z(_w,{displayName:`Command`,group:`Emphasis`});var vw=GC(e=>w_(/(?:^|[^*])\*([^*]+)\*$/,gw.type(e),{getAttr:()=>({marker:`*`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`*`)?{}:{fullMatch:e.slice(1),start:t+1}}));Z(vw,{displayName:`InputRule|Star`,group:`Emphasis`});var yw=GC(e=>w_(/\b_(?![_\s])(.*?[^_\s])_\b/,gw.type(e),{getAttr:()=>({marker:`_`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`_`)?{}:{fullMatch:e.slice(1),start:t+1}}));Z(yw,{displayName:`InputRule|Underscore`,group:`Emphasis`});var bw=ew(`emphasisKeymap`,{ToggleEmphasis:{shortcuts:`Mod-i`,command:e=>{let t=e.get(Y);return()=>t.call(_w.key)}}});Z(bw.ctx,{displayName:`KeymapCtx`,group:`Emphasis`}),Z(bw.shortcuts,{displayName:`Keymap`,group:`Emphasis`});var xw=nw(`strong`);Z(xw,{displayName:`Attr`,group:`Strong`});var Sw=$C(`strong`,e=>({attrs:{marker:{default:e.get(IS).strong||`*`,validate:`string`}},parseDOM:[{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{tag:`strong`},{style:`font-style`,getAttrs:e=>e===`bold`},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>[`strong`,e.get(xw.key)(t)],parseMarkdown:{match:e=>e.type===`strong`,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strong`,runner:(e,t)=>{e.withMark(t,`strong`,void 0,{marker:t.attrs.marker})}}}));Z(Sw.mark,{displayName:`MarkSchema`,group:`Strong`}),Z(Sw.ctx,{displayName:`MarkSchemaCtx`,group:`Strong`});var Cw=X(`ToggleStrong`,e=>()=>$g(Sw.type(e)));Z(Cw,{displayName:`Command`,group:`Strong`});var ww=GC(e=>w_(/(?({marker:e[0].startsWith(`*`)?`*`:`_`})}));Z(ww,{displayName:`InputRule`,group:`Strong`});var Tw=ew(`strongKeymap`,{ToggleBold:{shortcuts:[`Mod-b`],command:e=>{let t=e.get(Y);return()=>t.call(Cw.key)}}});Z(Tw.ctx,{displayName:`KeymapCtx`,group:`Strong`}),Z(Tw.shortcuts,{displayName:`Keymap`,group:`Strong`});var Ew=nw(`inlineCode`);Z(Ew,{displayName:`Attr`,group:`InlineCode`});var Dw=$C(`inlineCode`,e=>({priority:100,code:!0,parseDOM:[{tag:`code`}],toDOM:t=>[`code`,e.get(Ew.key)(t)],parseMarkdown:{match:e=>e.type===`inlineCode`,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`inlineCode`,runner:(e,t,n)=>(e.withMark(t,`inlineCode`,n.text||``),!0)}}));Z(Dw.mark,{displayName:`MarkSchema`,group:`InlineCode`}),Z(Dw.ctx,{displayName:`MarkSchemaCtx`,group:`InlineCode`});var Ow=X(`ToggleInlineCode`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(r.empty)return!1;let{from:a,to:o}=r;return t.doc.rangeHasMark(a,o,Dw.type(e))?(n?.(i.removeMark(a,o,Dw.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==Dw.type.name).map(e=>t.schema.marks[e]).forEach(e=>{i.removeMark(a,o,e)}),n?.(i.addMark(a,o,Dw.type(e).create())),!0)});Z(Ow,{displayName:`Command`,group:`InlineCode`});var kw=GC(e=>w_(/(?:`)([^`]+)(?:`)$/,Dw.type(e)));Z(kw,{displayName:`InputRule`,group:`InlineCode`});var Aw=ew(`inlineCodeKeymap`,{ToggleInlineCode:{shortcuts:`Mod-e`,command:e=>{let t=e.get(Y);return()=>t.call(Ow.key)}}});Z(Aw.ctx,{displayName:`KeymapCtx`,group:`InlineCode`}),Z(Aw.shortcuts,{displayName:`Keymap`,group:`InlineCode`});var jw=nw(`link`);Z(jw,{displayName:`Attr`,group:`Link`});var Mw=$C(`link`,e=>({attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},parseDOM:[{tag:`a[href]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ld(e);return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM:t=>[`a`,{...e.get(jw.key)(t),...t.attrs}],parseMarkdown:{match:e=>e.type===`link`,runner:(e,t,n)=>{let r=t.url,i=t.title;e.openMark(n,{href:r,title:i}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`link`,runner:(e,t)=>{e.withMark(t,`link`,void 0,{title:t.attrs.title,url:t.attrs.href})}}}));Z(Mw.mark,{displayName:`MarkSchema`,group:`Link`});var Nw=X(`ToggleLink`,e=>(t={})=>$g(Mw.type(e),t));Z(Nw,{displayName:`Command`,group:`Link`});var Pw=X(`UpdateLink`,e=>(t={})=>(n,r)=>{if(!r)return!1;let i,a=-1,{selection:o}=n,{from:s,to:c}=o;if(n.doc.nodesBetween(s,s===c?c+1:c,(t,n)=>{if(Mw.type(e).isInSet(t.marks))return i=t,a=n,!1}),!i)return!1;let l=i.marks.find(({type:t})=>t===Mw.type(e));if(!l)return!1;let u=a,d=a+i.nodeSize,{tr:f}=n,p=Mw.type(e).create({...l.attrs,...t});return p?(r(f.removeMark(u,d,l).addMark(u,d,p).setSelection(new q(f.selection.$anchor)).scrollIntoView()),!0):!1});Z(Pw,{displayName:`Command`,group:`Link`});var Fw=JC(`doc`,()=>({content:`block+`,parseMarkdown:{match:({type:e})=>e===`root`,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>e.type.name===`doc`,runner:(e,t)=>{e.openNode(`root`),e.next(t.content)}}}));Z(Fw,{displayName:`NodeSchema`,group:`Doc`});function Iw(e){return vi(e,e=>e.type===`html`&&[`
`,`
`,`
`,`
`].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;let n=t[t.length-1];if(!n)return;let r=n.children.indexOf(e);r!==-1&&n.children.splice(r,1)},!0)}var Lw=rw(`remark-preserve-empty-line`,()=>()=>Iw);Z(Lw.plugin,{displayName:`Remark`,group:`Remark`}),Z(Lw.options,{displayName:`RemarkConfig`,group:`Remark`});var Rw=tw(`paragraph`);Z(Rw,{displayName:`Attr`,group:`Paragraph`});var zw=QC(`paragraph`,e=>({content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM:t=>[`p`,e.get(Rw.key)(t),0],parseMarkdown:{match:e=>e.type===`paragraph`,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||``),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`paragraph`,runner:(t,n)=>{let r=e.get(ES).state?.doc.lastChild;t.openNode(`paragraph`),(!n.content||n.content.size===0)&&n!==r&&Bw(e)?t.addNode(`html`,void 0,`
`):mw(t,n),t.closeNode()}}}));function Bw(e){let t=!1;try{e.get(Lw.id),t=!0}catch{t=!1}return t}Z(zw.node,{displayName:`NodeSchema`,group:`Paragraph`}),Z(zw.ctx,{displayName:`NodeSchemaCtx`,group:`Paragraph`});var Vw=X(`TurnIntoText`,e=>()=>Xg(zw.type(e)));Z(Vw,{displayName:`Command`,group:`Paragraph`});var Hw=ew(`paragraphKeymap`,{TurnIntoText:{shortcuts:`Mod-Alt-0`,command:e=>{let t=e.get(Y);return()=>t.call(Vw.key)}}});Z(Hw.ctx,{displayName:`KeymapCtx`,group:`Paragraph`}),Z(Hw.shortcuts,{displayName:`Keymap`,group:`Paragraph`});var Uw=[,,,,,,].fill(0).map((e,t)=>t+1);function Ww(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,`-`)}var Gw=ZC(Ww,`headingIdGenerator`);Z(Gw,{displayName:`Ctx`,group:`Heading`});var Kw=tw(`heading`);Z(Kw,{displayName:`Attr`,group:`Heading`});var qw=QC(`heading`,e=>{let t=e.get(Gw.key);return{content:`inline*`,group:`block`,defining:!0,attrs:{id:{default:``,validate:`string`},level:{default:1,validate:`number`}},parseDOM:Uw.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Ld(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(Kw.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>e===`heading`,runner:(e,t,n)=>{let r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`heading`,runner:(e,t)=>{e.openNode(`heading`,void 0,{depth:t.attrs.level}),mw(e,t),e.closeNode()}}}});Z(qw.node,{displayName:`NodeSchema`,group:`Heading`}),Z(qw.ctx,{displayName:`NodeSchemaCtx`,group:`Heading`});var Jw=GC(e=>u_(/^(?#+)\s$/,qw.type(e),t=>{let n=t.groups?.hashes?.length||0,{$from:r}=e.get(ES).state.selection,i=r.node();if(i.type.name===`heading`){let e=Number(i.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));Z(Jw,{displayName:`InputRule`,group:`Heading`});var Yw=X(`WrapInHeading`,e=>t=>(t??=1,t<1?Xg(zw.type(e)):Xg(qw.type(e),{level:t})));Z(Yw,{displayName:`Command`,group:`Heading`});var Xw=X(`DowngradeHeading`,e=>()=>(t,n,r)=>{let{$from:i}=t.selection,a=i.node();if(a.type!==qw.type(e)||!t.selection.empty||i.parentOffset!==0)return!1;let o=a.attrs.level-1;return o?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...a.attrs,level:o})),!0):Xg(zw.type(e))(t,n,r)});Z(Xw,{displayName:`Command`,group:`Heading`});var Zw=ew(`headingKeymap`,{TurnIntoH1:{shortcuts:`Mod-Alt-1`,command:e=>{let t=e.get(Y);return()=>t.call(Yw.key,1)}},TurnIntoH2:{shortcuts:`Mod-Alt-2`,command:e=>{let t=e.get(Y);return()=>t.call(Yw.key,2)}},TurnIntoH3:{shortcuts:`Mod-Alt-3`,command:e=>{let t=e.get(Y);return()=>t.call(Yw.key,3)}},TurnIntoH4:{shortcuts:`Mod-Alt-4`,command:e=>{let t=e.get(Y);return()=>t.call(Yw.key,4)}},TurnIntoH5:{shortcuts:`Mod-Alt-5`,command:e=>{let t=e.get(Y);return()=>t.call(Yw.key,5)}},TurnIntoH6:{shortcuts:`Mod-Alt-6`,command:e=>{let t=e.get(Y);return()=>t.call(Yw.key,6)}},DowngradeHeading:{shortcuts:[`Delete`,`Backspace`],command:e=>{let t=e.get(Y);return()=>t.call(Xw.key)}}});Z(Zw.ctx,{displayName:`KeymapCtx`,group:`Heading`}),Z(Zw.shortcuts,{displayName:`Keymap`,group:`Heading`});var Qw=tw(`blockquote`);Z(Qw,{displayName:`Attr
`,group:`Blockquote`});var $w=QC(`blockquote`,e=>({content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM:t=>[`blockquote`,e.get(Qw.key)(t),0],parseMarkdown:{match:({type:e})=>e===`blockquote`,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`blockquote`,runner:(e,t)=>{e.openNode(`blockquote`).next(t.content).closeNode()}}}));Z($w.node,{displayName:`NodeSchema
`,group:`Blockquote`}),Z($w.ctx,{displayName:`NodeSchemaCtx
`,group:`Blockquote`});var eT=GC(e=>l_(/^\s*>\s$/,$w.type(e)));Z(eT,{displayName:`InputRule`,group:`Blockquote`});var tT=X(`WrapInBlockquote`,e=>()=>Yg($w.type(e)));Z(tT,{displayName:`Command`,group:`Blockquote`});var nT=ew(`blockquoteKeymap`,{WrapInBlockquote:{shortcuts:`Mod-Shift-b`,command:e=>{let t=e.get(Y);return()=>t.call(tT.key)}}});Z(nT.ctx,{displayName:`KeymapCtx
`,group:`Blockquote`}),Z(nT.shortcuts,{displayName:`Keymap
`,group:`Blockquote`});var rT=tw(`codeBlock`,()=>({pre:{},code:{}}));Z(rT,{displayName:`Attr`,group:`CodeBlock`});var iT=QC(`code_block`,e=>({content:`text*`,group:`block`,marks:``,defining:!0,code:!0,attrs:{language:{default:``,validate:`string`}},parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ld(e);return{language:e.dataset.language}}}],toDOM:t=>{let n=e.get(rT.key)(t),r=t.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return[`pre`,{...n.pre,...i},[`code`,n.code,0]]},parseMarkdown:{match:({type:e})=>e===`code`,runner:(e,t,n)=>{let r=t.lang??``,i=t.value;e.openNode(n,{language:r}),i&&e.addText(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`code_block`,runner:(e,t)=>{e.addNode(`code`,void 0,t.content.firstChild?.text||``,{lang:t.attrs.language})}}}));Z(iT.node,{displayName:`NodeSchema`,group:`CodeBlock`}),Z(iT.ctx,{displayName:`NodeSchemaCtx`,group:`CodeBlock`});var aT=GC(e=>u_(/^```(?[a-z]*)?[\s\n]$/,iT.type(e),e=>({language:e.groups?.language??``})));Z(aT,{displayName:`InputRule`,group:`CodeBlock`});var oT=X(`CreateCodeBlock`,e=>(t=``)=>Xg(iT.type(e),{language:t}));Z(oT,{displayName:`Command`,group:`CodeBlock`}),Z(X(`UpdateCodeBlockLanguage`,()=>({pos:e,language:t}={pos:-1,language:``})=>(n,r)=>e>=0&&(r?.(n.tr.setNodeAttribute(e,`language`,t)),!0)),{displayName:`Command`,group:`CodeBlock`});var sT=ew(`codeBlockKeymap`,{CreateCodeBlock:{shortcuts:`Mod-Alt-c`,command:e=>{let t=e.get(Y);return()=>t.call(oT.key)}}});Z(sT.ctx,{displayName:`KeymapCtx`,group:`CodeBlock`}),Z(sT.shortcuts,{displayName:`Keymap`,group:`CodeBlock`});var cT=tw(`image`);Z(cT,{displayName:`Attr`,group:`Image`});var lT=QC(`image`,e=>({inline:!0,group:`inline`,selectable:!0,draggable:!0,marks:``,atom:!0,defining:!0,isolating:!0,attrs:{src:{default:``,validate:`string`},alt:{default:``,validate:`string`},title:{default:``,validate:`string`}},parseDOM:[{tag:`img[src]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ld(e);return{src:e.getAttribute(`src`)||``,alt:e.getAttribute(`alt`)||``,title:e.getAttribute(`title`)||e.getAttribute(`alt`)||``}}}],toDOM:t=>[`img`,{...e.get(cT.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>e===`image`,runner:(e,t,n)=>{let r=t.url,i=t.alt,a=t.title;e.addNode(n,{src:r,alt:i,title:a})}},toMarkdown:{match:e=>e.type.name===`image`,runner:(e,t)=>{e.addNode(`image`,void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));Z(lT.node,{displayName:`NodeSchema`,group:`Image`}),Z(lT.ctx,{displayName:`NodeSchemaCtx`,group:`Image`});var uT=X(`InsertImage`,e=>(t={})=>(n,r)=>{if(!r)return!0;let{src:i=``,alt:a=``,title:o=``}=t,s=lT.type(e).create({src:i,alt:a,title:o});return s&&r(n.tr.replaceSelectionWith(s).scrollIntoView()),!0});Z(uT,{displayName:`Command`,group:`Image`});var dT=X(`UpdateImage`,e=>(t={})=>(n,r)=>{let i=M_(n.selection,lT.type(e));if(!i)return!1;let{node:a,pos:o}=i,s={...a.attrs},{src:c,alt:l,title:u}=t;return c!==void 0&&(s.src=c),l!==void 0&&(s.alt=l),u!==void 0&&(s.title=u),r?.(n.tr.setNodeMarkup(o,void 0,s).scrollIntoView()),!0});Z(dT,{displayName:`Command`,group:`Image`}),Z(GC(e=>new o_(/!\[(?.*?)]\((?.*?)\s*(?="|\))"?(?[^"]+)?"?\)/,(t,n,r,i)=>{let[a,o,s=``,c]=n;return a?t.tr.replaceWith(r,i,lT.type(e).create({src:s,alt:o,title:c})):null})),{displayName:`InputRule<insertImageInputRule>`,group:`Image`});var fT=tw(`hardbreak`,e=>({"data-type":`hardbreak`,"data-is-inline":e.attrs.isInline}));Z(fT,{displayName:`Attr<hardbreak>`,group:`Hardbreak`});var pT=QC(`hardbreak`,e=>({inline:!0,group:`inline`,attrs:{isInline:{default:!1,validate:`boolean`}},selectable:!1,parseDOM:[{tag:`br`},{tag:`span[data-type="hardbreak"]`,getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?[`span`,e.get(fT.key)(t),` `]:[`br`,e.get(fT.key)(t)],parseMarkdown:{match:({type:e})=>e===`break`,runner:(e,t,n)=>{e.addNode(n,{isInline:!!t.data?.isInline})}},leafText:()=>` `,toMarkdown:{match:e=>e.type.name===`hardbreak`,runner:(e,t)=>{t.attrs.isInline?e.addNode(`text`,void 0,` `):e.addNode(`break`)}}}));Z(pT.node,{displayName:`NodeSchema<hardbreak>`,group:`Hardbreak`}),Z(pT.ctx,{displayName:`NodeSchemaCtx<hardbreak>`,group:`Hardbreak`});var mT=X(`InsertHardbreak`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(!(r instanceof q))return!1;if(r.empty){let e=r.$from.node();if(e.childCount>0&&e.lastChild?.type.name===`hardbreak`)return n?.(i.replaceRangeWith(r.to-1,r.to,t.schema.node(`paragraph`)).setSelection(K.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(i.setMeta(`hardbreak`,!0).replaceSelectionWith(pT.type(e).create()).scrollIntoView()),!0});Z(mT,{displayName:`Command<insertHardbreakCommand>`,group:`Hardbreak`});var hT=ew(`hardbreakKeymap`,{InsertHardbreak:{shortcuts:`Shift-Enter`,command:e=>{let t=e.get(Y);return()=>t.call(mT.key)}}});Z(hT.ctx,{displayName:`KeymapCtx<hardbreak>`,group:`Hardbreak`}),Z(hT.shortcuts,{displayName:`Keymap<hardbreak>`,group:`Hardbreak`});var gT=tw(`hr`);Z(gT,{displayName:`Attr<hr>`,group:`Hr`});var _T=QC(`hr`,e=>({group:`block`,parseDOM:[{tag:`hr`}],toDOM:t=>[`hr`,e.get(gT.key)(t)],parseMarkdown:{match:({type:e})=>e===`thematicBreak`,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>e.type.name===`hr`,runner:e=>{e.addNode(`thematicBreak`)}}}));Z(_T.node,{displayName:`NodeSchema<hr>`,group:`Hr`}),Z(_T.ctx,{displayName:`NodeSchemaCtx<hr>`,group:`Hr`});var vT=GC(e=>new o_(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,i)=>{let{tr:a}=t;return n[0]&&a.replaceWith(r-1,i,_T.type(e).create()),a}));Z(vT,{displayName:`InputRule<insertHrInputRule>`,group:`Hr`});var yT=X(`InsertHr`,e=>()=>(t,n)=>{if(!n)return!0;let r=zw.node.type(e).create(),{tr:i,selection:a}=t,{from:o}=a,s=_T.type(e).create();if(!s)return!0;let c=i.replaceSelectionWith(s).insert(o,r),l=K.findFrom(c.doc.resolve(o),1,!0);return l&&n(c.setSelection(l).scrollIntoView()),!0});Z(yT,{displayName:`Command<insertHrCommand>`,group:`Hr`});var bT=tw(`bulletList`);Z(bT,{displayName:`Attr<bulletList>`,group:`BulletList`});var xT=QC(`bullet_list`,e=>({content:`listItem+`,group:`block`,attrs:{spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ul`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ld(e);return{spread:e.dataset.spread===`true`}}}],toDOM:t=>[`ul`,{...e.get(bT.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!t,runner:(e,t,n)=>{let r=t.spread==null?`false`:`${t.spread}`;e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`bullet_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));Z(xT.node,{displayName:`NodeSchema<bulletList>`,group:`BulletList`}),Z(xT.ctx,{displayName:`NodeSchemaCtx<bulletList>`,group:`BulletList`});var ST=GC(e=>l_(/^\s*([-+*])\s$/,xT.type(e)));Z(ST,{displayName:`InputRule<wrapInBulletListInputRule>`,group:`BulletList`});var CT=X(`WrapInBulletList`,e=>()=>Yg(xT.type(e)));Z(CT,{displayName:`Command<wrapInBulletListCommand>`,group:`BulletList`});var wT=ew(`bulletListKeymap`,{WrapInBulletList:{shortcuts:`Mod-Alt-8`,command:e=>{let t=e.get(Y);return()=>t.call(CT.key)}}});Z(wT.ctx,{displayName:`KeymapCtx<bulletListKeymap>`,group:`BulletList`}),Z(wT.shortcuts,{displayName:`Keymap<bulletListKeymap>`,group:`BulletList`});var TT=tw(`orderedList`);Z(TT,{displayName:`Attr<orderedList>`,group:`OrderedList`});var ET=QC(`ordered_list`,e=>({content:`listItem+`,group:`block`,attrs:{order:{default:1,validate:`number`},spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ol`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ld(e);return{spread:e.dataset.spread,order:e.hasAttribute(`start`)?Number(e.getAttribute(`start`)):1}}}],toDOM:t=>[`ol`,{...e.get(TT.key)(t),...t.attrs.order===1?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!!t,runner:(e,t,n)=>{let r=t.spread==null?`true`:`${t.spread}`;e.openNode(n,{spread:r,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`ordered_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!0,start:t.attrs.order??1,spread:t.attrs.spread===`true`}),e.next(t.content),e.closeNode()}}}));Z(ET.node,{displayName:`NodeSchema<orderedList>`,group:`OrderedList`}),Z(ET.ctx,{displayName:`NodeSchemaCtx<orderedList>`,group:`OrderedList`});var DT=GC(e=>l_(/^\s*(\d+)\.\s$/,ET.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));Z(DT,{displayName:`InputRule<wrapInOrderedListInputRule>`,group:`OrderedList`});var OT=X(`WrapInOrderedList`,e=>()=>Yg(ET.type(e)));Z(OT,{displayName:`Command<wrapInOrderedListCommand>`,group:`OrderedList`});var kT=ew(`orderedListKeymap`,{WrapInOrderedList:{shortcuts:`Mod-Alt-7`,command:e=>{let t=e.get(Y);return()=>t.call(OT.key)}}});Z(kT.ctx,{displayName:`KeymapCtx<orderedList>`,group:`OrderedList`}),Z(kT.shortcuts,{displayName:`Keymap<orderedList>`,group:`OrderedList`});var AT=tw(`listItem`);Z(AT,{displayName:`Attr<listItem>`,group:`ListItem`});var jT=QC(`list_item`,e=>({group:`listItem`,content:`paragraph block*`,attrs:{label:{default:`•`,validate:`string`},listType:{default:`bullet`,validate:`string`},spread:{default:!0,validate:`boolean`}},defining:!0,parseDOM:[{tag:`li`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ld(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread===`true`}}}],toDOM:t=>[`li`,{...e.get(AT.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,n)=>{let r=t.label==null?`•`:`${t.label}.`,i=t.label==null?`bullet`:`ordered`,a=t.spread==null?`true`:`${t.spread}`;e.openNode(n,{label:r,listType:i,spread:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{e.openNode(`listItem`,void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));Z(jT.node,{displayName:`NodeSchema<listItem>`,group:`ListItem`}),Z(jT.ctx,{displayName:`NodeSchemaCtx<listItem>`,group:`ListItem`});var MT=X(`SinkListItem`,e=>()=>uw(jT.type(e)));Z(MT,{displayName:`Command<sinkListItemCommand>`,group:`ListItem`});var NT=X(`LiftListItem`,e=>()=>sw(jT.type(e)));Z(NT,{displayName:`Command<liftListItemCommand>`,group:`ListItem`});var PT=X(`SplitListItem`,e=>()=>ow(jT.type(e)));Z(PT,{displayName:`Command<splitListItemCommand>`,group:`ListItem`});function FT(e){return(t,n,r)=>{let{selection:i}=t;if(!(i instanceof q))return!1;let{empty:a,$from:o}=i;return!a||o.parentOffset!==0||o.node(-1).type!==jT.type(e)?!1:Eg(t,n,r)}}var IT=X(`LiftFirstListItem`,e=>()=>FT(e));Z(IT,{displayName:`Command<liftFirstListItemCommand>`,group:`ListItem`});var LT=ew(`listItemKeymap`,{NextListItem:{shortcuts:`Enter`,command:e=>{let t=e.get(Y);return()=>t.call(PT.key)}},SinkListItem:{shortcuts:[`Tab`,`Mod-]`],command:e=>{let t=e.get(Y);return()=>t.call(MT.key)}},LiftListItem:{shortcuts:[`Shift-Tab`,`Mod-[`],command:e=>{let t=e.get(Y);return()=>t.call(NT.key)}},LiftFirstListItem:{shortcuts:[`Backspace`,`Delete`],command:e=>{let t=e.get(Y);return()=>t.call(IT.key)}}});Z(LT.ctx,{displayName:`KeymapCtx<listItem>`,group:`ListItem`}),Z(LT.shortcuts,{displayName:`Keymap<listItem>`,group:`ListItem`});var RT=JC(`text`,()=>({group:`inline`,parseMarkdown:{match:({type:e})=>e===`text`,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>e.type.name===`text`,runner:(e,t)=>{e.addNode(`text`,void 0,t.text)}}}));Z(RT,{displayName:`NodeSchema<text>`,group:`Text`});var zT=tw(`html`);Z(zT,{displayName:`Attr<html>`,group:`Html`});var BT=QC(`html`,e=>({atom:!0,group:`inline`,inline:!0,attrs:{value:{default:``,validate:`string`}},toDOM:t=>{let n=document.createElement(`span`),r={...e.get(zT.key)(t),"data-value":t.attrs.value,"data-type":`html`};return n.textContent=t.attrs.value,[`span`,r,t.attrs.value]},parseDOM:[{tag:`span[data-type="html"]`,getAttrs:e=>({value:e.dataset.value??``})}],parseMarkdown:{match:({type:e})=>e===`html`,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===`html`,runner:(e,t)=>{e.addNode(`html`,void 0,t.attrs.value)}}}));Z(BT.node,{displayName:`NodeSchema<html>`,group:`Html`}),Z(BT.ctx,{displayName:`NodeSchemaCtx<html>`,group:`Html`});var VT=[Fw,Rw,zw,Gw,Kw,qw,fT,pT,Qw,$w,rT,iT,gT,_T,cT,lT,bT,xT,TT,ET,AT,jT,hw,gw,xw,Sw,Ew,Dw,jw,Mw,zT,BT,RT].flat(),HT=[eT,ST,DT,aT,vT,Jw].flat(),UT=[vw,yw,kw,ww],WT=[Vw,tT,Yw,Xw,oT,mT,yT,uT,dT,OT,CT,MT,PT,NT,IT,_w,Ow,Cw,Nw,Pw,X(`IsMarkSelected`,()=>e=>t=>{if(!e)return!1;let{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),X(`IsNoteSelected`,()=>e=>t=>e?N_(t,e).hasNode:!1),X(`ClearTextInCurrentBlock`,()=>()=>(e,t)=>{let n=e.tr,{$from:r,$to:i}=n.selection,{pos:a}=r,{pos:o}=i,s=a-r.node().content.size;return s<0?!1:(n=n.deleteRange(s,o),t?.(n),!0)}),X(`SetBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr,{from:o,to:s}=a.selection;try{a.setBlockType(o,s,r,i)}catch{return!1}return n?.(a),!0}),X(`WrapInBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let{$from:e,$to:t}=a.selection,n=e.blockRange(t),o=n&&_h(n,r,i);if(!o)return!1;a=a.wrap(n,o)}catch{return!1}return n?.(a),!0}),X(`AddBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let e=r instanceof Kp?r:r.createAndFill(i);if(!e)return!1;a.replaceSelectionWith(e)}catch{return!1}return n?.(a),!0}),X(`SelectTextNearPos`,()=>e=>(t,n)=>{let{pos:r}=e??{};if(r==null)return!1;let i=(e,t,n)=>Math.min(Math.max(e,t),n),a=t.tr;try{let e=t.doc.resolve(i(r,0,t.doc.content.size));a.setSelection(q.near(e))}catch{return!1}return n?.(a.scrollIntoView()),!0})],GT=[nT,sT,hT,Zw,LT,kT,wT,Hw,bw,Aw,Tw].flat(),KT=rw(`remarkAddOrderInList`,()=>()=>e=>{Ti(e,`list`,e=>{if(e.ordered){let t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});Z(KT.plugin,{displayName:`Remark<remarkAddOrderInListPlugin>`,group:`Remark`}),Z(KT.options,{displayName:`RemarkConfig<remarkAddOrderInListPlugin>`,group:`Remark`});var qT=rw(`remarkLineBreak`,()=>()=>e=>{let t=/[\t ]*(?:\r?\n|\r)/g;Ti(e,`text`,(e,n,r)=>{if(!e.value||typeof e.value!=`string`)return;let i=[],a=0;t.lastIndex=0;let o=t.exec(e.value);for(;o;){let n=o.index;a!==n&&i.push({type:`text`,value:e.value.slice(a,n)}),i.push({type:`break`,data:{isInline:!0}}),a=n+o[0].length,o=t.exec(e.value)}if(i.length>0&&r&&typeof n==`number`)return a<e.value.length&&i.push({type:`text`,value:e.value.slice(a)}),r.children.splice(n,1,...i),n+i.length})});Z(qT.plugin,{displayName:`Remark<remarkLineBreak>`,group:`Remark`}),Z(qT.options,{displayName:`RemarkConfig<remarkLineBreak>`,group:`Remark`});var JT=rw(`remarkInlineLink`,()=>pw);Z(JT.plugin,{displayName:`Remark<remarkInlineLinkPlugin>`,group:`Remark`}),Z(JT.options,{displayName:`RemarkConfig<remarkInlineLinkPlugin>`,group:`Remark`});var YT=e=>!!e.children,XT=e=>e.type===`html`;function ZT(e,t){return n(e,0,null)[0];function n(e,r,i){if(YT(e)){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i){let a=n(i,r,e);if(a)for(let e=0,n=a.length;e<n;e++){let n=a[e];n&&t.push(n)}}}e.children=t}return t(e,r,i)}}var QT=[`root`,`blockquote`,`listItem`],$T=rw(`remarkHTMLTransformer`,()=>()=>e=>{ZT(e,(e,t,n)=>(XT(e)&&n&&QT.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type=`paragraph`),[e]))});Z($T.plugin,{displayName:`Remark<remarkHtmlTransformer>`,group:`Remark`}),Z($T.options,{displayName:`RemarkConfig<remarkHtmlTransformer>`,group:`Remark`});var eE=rw(`remarkMarker`,()=>()=>(e,t)=>{let n=e=>t.value.charAt(e.position.start.offset);Ti(e,e=>[`strong`,`emphasis`].includes(e.type),e=>{e.marker=n(e)})});Z(eE.plugin,{displayName:`Remark<remarkMarker>`,group:`Remark`}),Z(eE.options,{displayName:`RemarkConfig<remarkMarker>`,group:`Remark`});var tE=YC(()=>{let e=!1,t=new bg({key:new Cg(`MILKDOWN_INLINE_NODES_CURSOR`),state:{init(){return!1},apply(e){if(!e.selection.empty)return!1;let t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!!(n&&r&&n.isInline&&!n.isText&&r.isInline&&!r.isText)}},props:{handleDOMEvents:{compositionend:(n,r)=>e?(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){let e=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e))}}),!0):!1,compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!e){let e=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e)),!0}return!1}},decorations(e){if(t.getState(e)){let t=e.selection.$from.pos,n=document.createElement(`span`),r=Nx.widget(t,n,{side:-1}),i=document.createElement(`span`),a=Nx.widget(t,i);return setTimeout(()=>{n.contentEditable=`true`,i.contentEditable=`true`}),Ix.create(e.doc,[r,a])}return Ix.empty}}});return t});Z(tE,{displayName:`Prose<inlineNodesCursorPlugin>`,group:`Prose`});var nE=YC(e=>new bg({key:new Cg(`MILKDOWN_HARDBREAK_MARKS`),appendTransaction:(t,n,r)=>{if(!t.length)return;let[i]=t;if(!i)return;let[a]=i.steps;if(i.getMeta(`hardbreak`)){if(!(a instanceof ch))return;let{from:t}=a;return r.tr.setNodeMarkup(t,pT.type(e),void 0,[])}if(a instanceof ih){let t=r.tr,{from:n,to:i}=a;return r.doc.nodesBetween(n,i,(n,r)=>{n.type===pT.type(e)&&(t=t.setNodeMarkup(r,pT.type(e),void 0,[]))}),t}}}));Z(nE,{displayName:`Prose<hardbreakClearMarkPlugin>`,group:`Prose`});var rE=ZC([`table`,`code_block`],`hardbreakFilterNodes`);Z(rE,{displayName:`Ctx<hardbreakFilterNodes>`,group:`Prose`});var iE=YC(e=>{let t=e.get(rE.key);return new bg({key:new Cg(`MILKDOWN_HARDBREAK_FILTER`),filterTransaction:(e,n)=>{let r=e.getMeta(`hardbreak`),[i]=e.steps;if(r&&i){let{from:e}=i,r=n.doc.resolve(e),a=r.depth,o=!0;for(;a>0;)t.includes(r.node(a).type.name)&&(o=!1),a--;return o}return!0}})});Z(iE,{displayName:`Prose<hardbreakFilterPlugin>`,group:`Prose`});var aE=YC(e=>{let t=new Cg(`MILKDOWN_HEADING_ID`),n=n=>{if(n.composing)return;let r=e.get(Gw.key),i=n.state.tr.setMeta(`addToHistory`,!1),a=!1,o={};n.state.doc.descendants((n,s)=>{if(n.type===qw.type(e)){if(n.textContent.trim().length===0)return;let e=n.attrs,c=r(n);o[c]?(o[c]+=1,c+=`-#${o[c]}`):o[c]=1,e.id!==c&&(a=!0,i.setMeta(t,!0).setNodeMarkup(s,void 0,{...e,id:c}))}}),a&&n.dispatch(i)};return new bg({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});Z(aE,{displayName:`Prose<syncHeadingIdPlugin>`,group:`Prose`});var oE=YC(e=>new bg({key:new Cg(`MILKDOWN_KEEP_LIST_ORDER`),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>e.getMeta(`addToHistory`)===!1||!e.isGeneric))return null;let i=ET.type(e),a=xT.type(e),o=jT.type(e),s=(e,t,n=1)=>{let r=!1,i=`${t+n}.`;return e.label!==i&&(e.label=i,r=!0),r},c=r.tr,l=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===a){let n=e.maybeChild(0);n?.type===o&&n.attrs.listType===`ordered`&&(l=!0,c.setNodeMarkup(t,i,{spread:`true`}),e.descendants((e,t,n,r)=>{if(e.type===o){let n={...e.attrs};s(n,r)&&(c=c.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===o&&n?.type===i){let i={...e.attrs},a=!1;i.listType!==`ordered`&&(i.listType=`ordered`,a=!0),n?.maybeChild(0)&&(a=s(i,r,n?.attrs.order??1)),a&&(c=c.setNodeMarkup(t,void 0,i),l=!0)}}),l?c.setMeta(`addToHistory`,!1):null}}));Z(oE,{displayName:`Prose<syncListOrderPlugin>`,group:`Prose`});var sE=[VT,HT,UT,WT,GT,[nE,rE,iE,tE,KT,JT,qT,$T,eE,Lw,aE,oE].flat()].flat(),cE,lE;if(typeof WeakMap<`u`){let e=new WeakMap;cE=t=>e.get(t),lE=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;cE=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},lE=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var Q=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return cE(e)||lE(e,uE(e))}};function uE(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=dE(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new Q(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&fE(s,o,e),s}function dE(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function fE(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=pE(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function pE(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function mE(e,t){if(typeof e==`string`)return{};let n=e.getAttribute(`data-colwidth`),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(`,`).map(e=>Number(e)):null,i=Number(e.getAttribute(`colspan`)||1),a={colspan:i,rowspan:Number(e.getAttribute(`rowspan`)||1),colwidth:r&&r.length==i?r:null};for(let n in t){let r=t[n].getFromDOM,i=r&&r(e);i!=null&&(a[n]=i)}return a}function hE(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n[`data-colwidth`]=e.attrs.colwidth.join(`,`));for(let r in t){let i=t[r].setDOMAttr;i&&i(e.attrs[r],n)}return n}function gE(e){if(e!==null){if(!Array.isArray(e))throw TypeError(`colwidth must be null or an array`);for(let t of e)if(typeof t!=`number`)throw TypeError(`colwidth must be null or an array of numbers`)}}function _E(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:`number`},rowspan:{default:1,validate:`number`},colwidth:{default:null,validate:gE}};for(let e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:`table_row+`,tableRole:`table`,isolating:!0,group:e.tableGroup,parseDOM:[{tag:`table`}],toDOM(){return[`table`,[`tbody`,0]]}},table_row:{content:`(table_cell | table_header)*`,tableRole:`row`,parseDOM:[{tag:`tr`}],toDOM(){return[`tr`,0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:`cell`,isolating:!0,parseDOM:[{tag:`td`,getAttrs:e=>mE(e,t)}],toDOM(e){return[`td`,hE(e,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:`header_cell`,isolating:!0,parseDOM:[{tag:`th`,getAttrs:e=>mE(e,t)}],toDOM(e){return[`th`,hE(e,t),0]}}}}function vE(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var yE=new Cg(`selectingCells`);function bE(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function xE(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function SE(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=bE(t.$head)||CE(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function CE(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function wE(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function TE(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function EE(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function DE(e,t,n){let r=e.node(-1),i=Q.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function OE(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function kE(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function AE(e,t,n){let r=vE(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var jE=class e extends K{constructor(e,t=e){let n=e.node(-1),r=Q.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new tg(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(wE(r)&&wE(i)&&EE(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return q.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=Q.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=OE(e,0,l)),u>0&&(e=OE(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(U.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new G(U.from(o),1,1)}replace(e,t=G.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?G.empty:t)}let i=K.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new G(U.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=Q.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=Q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=Q.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=Q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new ME(this.$anchorCell.pos,this.$headCell.pos)}};jE.prototype.visible=!1,K.jsonID(`cell`,jE);var ME=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&EE(t,n)?new jE(t,n):K.near(n,1)}};function NE(e){if(!(e.selection instanceof jE))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(Nx.node(n,n+e.nodeSize,{class:`selectedCell`}))}),Ix.create(e.doc,t)}function PE({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function FE({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function IE(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof J&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=jE.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=jE.rowSelection(e,e)}else if(!n){let e=Q.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=jE.create(i,t+1,n)}}else r instanceof q&&PE(r)?a=q.create(i,r.from):r instanceof q&&FE(r)&&(a=q.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var LE=new Cg(`fix-tables`);function RE(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?RE(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function zE(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=BE(e,t,r,n))};return t?t.doc!=e.doc&&RE(t.doc,e.doc,0,r):e.doc.descendants(r),n}function BE(e,t,n,r){let i=Q.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,OE(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=vE(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(LE,{fixTables:!0})}function VE(e){let t=Q.get(e),n=[],r=t.height,i=t.width;for(let a=0;a<r;a++){let r=[];for(let n=0;n<i;n++){let o=a*i+n,s=t.map[o];if(a>0){let e=o-i;if(s===t.map[e]){r.push(null);continue}}if(n>0){let e=o-1;if(s===t.map[e]){r.push(null);continue}}r.push(e.nodeAt(s))}n.push(r)}return n}function HE(e,t){let n=[],r=Q.get(e),i=r.height,a=r.width;for(let o=0;o<i;o++){let i=e.child(o),s=[];for(let n=0;n<a;n++){let i=t[o][n];if(!i)continue;let a=r.map[o*r.width+n],c=e.nodeAt(a);if(!c)continue;let l=c.type.createChecked(i.attrs,i.content,i.marks);s.push(l)}let c=i.type.createChecked(i.attrs,s,i.marks);n.push(c)}return e.type.createChecked(e.attrs,n,e.marks)}function UE(e,t,n,r){let i=t[0]>n[0]?-1:1,a=e.splice(t[0],t.length),o=+(a.length%2==0),s;return s=r===-1&&i===1?n[0]-1:r===1&&i===-1?n[n.length-1]-o+1:i===-1?n[0]:n[n.length-1]-o,e.splice(s,0,...a),e}function WE(e){return GE(e=>e.type.spec.tableRole===`table`,e)}function GE(e,t){for(let n=t.depth;n>=0;--n){let r=t.node(n);if(e(r))return{node:r,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function KE(e,t){let n=WE(t.$from);if(!n)return;let r=Q.get(n.node);if(!(e<0||e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function qE(e,t){let n=WE(t.$from);if(!n)return;let r=Q.get(n.node);if(!(e<0||e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function JE(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=KE(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=KE(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=KE(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=KE(r,e.selection),s=qE(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=KE(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function YE(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=qE(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=qE(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=qE(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=qE(r,e.selection),s=KE(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=qE(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function XE(e){return e[0].map((t,n)=>e.map(e=>e[n]))}function ZE(e){let{tr:t,originIndex:n,targetIndex:r,select:i,pos:a}=e,o=WE(t.doc.resolve(a));if(!o)return!1;let s=JE(t,n)?.indexes,c=JE(t,r)?.indexes;if(!s||!c||s.includes(r))return!1;let l=QE(o.node,s,c,0);if(t.replaceWith(o.pos,o.pos+o.node.nodeSize,l),!i)return!0;let u=Q.get(l),d=o.start,f=r,p=u.positionAt(u.height-1,f,l),m=t.doc.resolve(d+p),h=u.positionAt(0,f,l),g=t.doc.resolve(d+h);return t.setSelection(jE.colSelection(m,g)),!0}function QE(e,t,n,r){let i=XE(VE(e));return i=UE(i,t,n,r),i=XE(i),HE(e,i)}function $E(e){let{tr:t,originIndex:n,targetIndex:r,select:i,pos:a}=e,o=WE(t.doc.resolve(a));if(!o)return!1;let s=YE(t,n)?.indexes,c=YE(t,r)?.indexes;if(!s||!c||s.includes(r))return!1;let l=eD(o.node,s,c,0);if(t.replaceWith(o.pos,o.pos+o.node.nodeSize,l),!i)return!0;let u=Q.get(l),d=o.start,f=r,p=u.positionAt(f,u.width-1,l),m=t.doc.resolve(d+p),h=u.positionAt(f,0,l),g=t.doc.resolve(d+h);return t.setSelection(jE.rowSelection(m,g)),!0}function eD(e,t,n,r){let i=VE(e);return i=UE(i,t,n,r),HE(e,i)}function tD(e){let t=e.selection,n=SE(e),r=n.node(-1),i=n.start(-1),a=Q.get(r);return{...t instanceof jE?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function nD(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;AE(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,kE(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?vE(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function rD(e,t){if(!xE(e))return!1;if(t){let n=tD(e);t(nD(e.tr,n,n.left))}return!0}function iD(e,t){if(!xE(e))return!1;if(t){let n=tD(e);t(nD(e.tr,n,n.right))}return!0}function aD(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,OE(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function oD(e,t){if(!xE(e))return!1;if(t){let n=tD(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;aD(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=Q.get(e)}t(r)}return!0}function sD(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function cD(e,t){if(!xE(e))return!1;if(t){let n=tD(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;sD(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=Q.get(n.table)}t(r)}return!0}function lD(e,t){return function(n,r){if(!xE(n))return!1;let i=SE(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof jE?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function uD(e){return function(t,n){if(!xE(t))return!1;if(n){let r=vE(t.schema),i=tD(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function dD(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function fD(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?uD(e):function(t,n){if(!xE(t))return!1;if(n){let r=vE(t.schema),i=tD(t),a=t.tr,o=dD(`row`,i,r),s=dD(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}fD(`row`,{useDeprecatedLogic:!0}),fD(`column`,{useDeprecatedLogic:!0}),fD(`cell`,{useDeprecatedLogic:!0});function pD(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function mD(e){return function(t,n){if(!xE(t))return!1;let r=pD(SE(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(q.between(e,TE(e))).scrollIntoView())}return!0}}function hD(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function gD(e,t){let n=e.selection;if(!(n instanceof jE))return!1;if(t){let r=e.tr,i=vE(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new G(i,0,0))}),r.docChanged&&t(r)}return!0}function _D(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return $E({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function vD(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return ZE({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function yD(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=xD(vE(o).row,new G(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?xD(vE(o).row,new G(t,n,r)).content:t);else return null;return bD(o,s)}function bD(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(U.empty),n[i]<r){let a=vE(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(U.from(o))}return{height:t.length,width:r,rows:t}}function xD(e,t){let n=e.createAndFill();return new $h(n).replace(0,n.content.size,t).doc}function SD({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(OE(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(U.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(U.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function CD(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=vE(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,U.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function wD(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function TD(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,OE(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(OE(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function ED(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=Q.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=Q.get(a),f=d.mapping.maps.length}CD(d,o,a,n,l,u,f)&&p(),wD(d,o,a,n,c,l,s,f)&&p(),wD(d,o,a,n,c,l,u,f)&&p(),TD(d,o,a,n,s,u,c,f)&&p(),TD(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new G(i.rows[e-s],0,0))}p(),d.setSelection(new jE(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var DD=q_({ArrowLeft:kD(`horiz`,-1),ArrowRight:kD(`horiz`,1),ArrowUp:kD(`vert`,-1),ArrowDown:kD(`vert`,1),"Shift-ArrowLeft":AD(`horiz`,-1),"Shift-ArrowRight":AD(`horiz`,1),"Shift-ArrowUp":AD(`vert`,-1),"Shift-ArrowDown":AD(`vert`,1),Backspace:gD,"Mod-Backspace":gD,Delete:gD,"Mod-Delete":gD});function OD(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function kD(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof jE)return OD(n,r,K.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=PD(i,e,t);if(o==null)return!1;if(e==`horiz`)return OD(n,r,K.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=DE(i,e,t),s;return s=a?K.near(a,1):t<0?K.near(n.doc.resolve(i.before(-1)),-1):K.near(n.doc.resolve(i.after(-1)),1),OD(n,r,s)}}}function AD(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof jE)o=a;else{let r=PD(i,e,t);if(r==null)return!1;o=new jE(n.doc.resolve(r))}let s=DE(o.$headCell,e,t);return s?OD(n,r,new jE(o.$anchorCell,s)):!1}}function jD(e,t){let n=e.state.doc,r=bE(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new jE(r))),!0):!1}function MD(e,t,n){if(!xE(e.state))return!1;let r=yD(n),i=e.state.selection;if(i instanceof jE){r||={width:1,height:1,rows:[U.from(xD(vE(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=Q.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=SD(r,o.right-o.left,o.bottom-o.top),ED(e.state,e.dispatch,a,o,r),!0}if(r){let t=SE(e.state),n=t.start(-1);return ED(e.state,e.dispatch,n,Q.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function ND(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=FD(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof jE)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=bE(e.state.selection.$anchor))!=null&&ID(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=ID(e,n),i=yE.getState(e.state)==null;if(!r||!EE(t,r)){if(i)r=t;else return}let a=new jE(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(yE,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),yE.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(yE,-1))}function o(r){let o=r,s=yE.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(FD(e,o.target)!=n&&(c=ID(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function PD(e,t,n){if(!(e.state.selection instanceof q))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function FD(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function ID(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&bE(e.state.doc.resolve(r))||bE(e.state.doc.resolve(i))}var LD=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),RD(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,RD(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function RD(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var zD=new Cg(`tableColumnResizing`);function BD({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=LD,lastColumnResizable:i=!0}={}){let a=new bg({key:zD,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=vE(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new VD(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=zD.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{HD(t,n,e,i)},mouseleave:e=>{UD(e)},mousedown:(e,r)=>{WD(e,r,t,n)}},decorations:e=>{let t=zD.getState(e);if(t&&t.activeHandle>-1)return $D(e,t.activeHandle)},nodeViews:{}}});return a}var VD=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(zD);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return wE(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function HD(e,t,n,r){if(!e.editable)return;let i=zD.getState(e.state);if(i&&!i.dragging){let a=KD(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=qD(e,t,`left`,n):i-t.clientX<=n&&(o=qD(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=Q.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}YD(e,o)}}}function UD(e){if(!e.editable)return;let t=zD.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&YD(e,-1)}function WD(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=zD.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=GD(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(zD,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=zD.getState(e.state);r?.dragging&&(XD(e,r.activeHandle,JD(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(zD,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=zD.getState(e.state);if(i&&i.dragging){let a=JD(i.dragging,t,n);ZD(e,i.activeHandle,a,r)}}return ZD(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function GD(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function KD(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function qD(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=bE(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=Q.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function JD(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function YD(e,t){e.dispatch(e.state.tr.setMeta(zD,{setHandle:t}))}function XD(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=Q.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():QD(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function ZD(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=Q.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&RD(a,c.firstChild,c,r,s,n)}function QD(e){return Array(e).fill(0)}function $D(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return Ix.empty;let a=Q.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,zD.getState(e)?.dragging&&n.push(Nx.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(Nx.widget(s,c))}}return Ix.create(e.doc,n)}function eO({allowTableNodeSelection:e=!1}={}){return new bg({key:yE,state:{init(){return null},apply(e,t){let n=e.getMeta(yE);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:NE,handleDOMEvents:{mousedown:ND},createSelectionBetween(e){return yE.getState(e.state)==null?null:e.state.selection},handleTripleClick:jD,handleKeyDown:DD,handlePaste:MD},appendTransaction(t,n,r){return IE(r,zE(r,n),e)}})}var tO=typeof navigator<`u`?navigator:null,nO=tO&&tO.userAgent||``,rO=/Edge\/(\d+)/.exec(nO),iO=/MSIE \d/.exec(nO),aO=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nO),oO=!(iO||aO||rO)&&!!tO&&/Apple Computer/.test(tO.vendor),sO=new Cg(`safari-ime-span`),cO=!1,lO={key:sO,props:{decorations:uO,handleDOMEvents:{compositionstart:()=>{cO=!0},compositionend:()=>{cO=!1}}}};function uO(e){let{$from:t,$to:n,to:r}=e.selection;if(cO&&t.sameParent(n)){let t=Nx.widget(r,dO,{ignoreSelection:!0,key:`safari-ime-span`});return Ix.create(e.doc,[t])}}function dO(e){let t=e.dom.ownerDocument.createElement(`span`);return t.className=`ProseMirror-safari-ime-span`,t}var fO=new bg(oO?lO:{key:sO});function pO(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function mO(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function hO(e,t,n){let r=Ci((n||{}).ignore||[]),i=gO(t),a=-1;for(;++a<i.length;)vi(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function gO(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([_O(e[0]),vO(e[1])])}return t}function _O(e){return typeof e==`string`?new RegExp(mO(e),`g`):e}function vO(e){return typeof e==`function`?e:function(){return e}}var yO=`phrasing`,bO=[`autolink`,`link`,`image`,`label`];function xO(){return{transforms:[kO],enter:{literalAutolink:CO,literalAutolinkEmail:wO,literalAutolinkHttp:wO,literalAutolinkWww:wO},exit:{literalAutolink:OO,literalAutolinkEmail:DO,literalAutolinkHttp:TO,literalAutolinkWww:EO}}}function SO(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:yO,notInConstruct:bO},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:yO,notInConstruct:bO},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:yO,notInConstruct:bO}]}}function CO(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function wO(e){this.config.enter.autolinkProtocol.call(this,e)}function TO(e){this.config.exit.autolinkProtocol.call(this,e)}function EO(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function DO(e){this.config.exit.autolinkEmail.call(this,e)}function OO(e){this.exit(e)}function kO(e){hO(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,AO],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,jO]],{ignore:[`link`,`linkReference`]})}function AO(e,t,n,r,i){let a=``;if(!PO(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!MO(n)))return!1;let o=NO(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function jO(e,t,n,r){return!PO(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function MO(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function NO(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=pO(e,`(`),a=pO(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function PO(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||di(n)||mi(n))&&(!t||n!==47)}WO.peek=UO;function FO(){this.buffer()}function IO(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function LO(){this.buffer()}function RO(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function zO(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function BO(e){this.exit(e)}function VO(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function HO(e){this.exit(e)}function UO(){return`[`}function WO(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function GO(){return{enter:{gfmFootnoteCallString:FO,gfmFootnoteCall:IO,gfmFootnoteDefinitionLabelString:LO,gfmFootnoteDefinition:RO},exit:{gfmFootnoteCallString:zO,gfmFootnoteCall:BO,gfmFootnoteDefinitionLabelString:VO,gfmFootnoteDefinition:HO}}}function KO(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:WO},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?` `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?JO:qO))),s(),o}}function qO(e,t,n){return t===0?e:JO(e,t,n)}function JO(e,t,n){return(n?``:` `)+e}var YO=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];ek.peek=tk;function XO(){return{canContainEols:[`delete`],enter:{strikethrough:QO},exit:{strikethrough:$O}}}function ZO(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:YO}],handlers:{delete:ek}}}function QO(e){this.enter({type:`delete`,children:[]},e)}function $O(e){this.exit(e)}function ek(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function tk(){return`~`}function nk(e){return e.length}function rk(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||nk,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=ik(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=ak(r[d]);else{let e=ak(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(` `)}function ik(e){return e==null?``:String(e)}function ak(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function ok(){return{enter:{table:sk,tableData:dk,tableHeader:dk,tableRow:lk},exit:{codeText:fk,table:ck,tableData:uk,tableHeader:uk,tableRow:uk}}}function sk(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function ck(e){this.exit(e),this.data.inTable=void 0}function lk(e){this.enter({type:`tableRow`,children:[]},e)}function uk(e){this.exit(e)}function dk(e){this.enter({type:`tableCell`,children:[]},e)}function fk(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,pk));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function pk(e,t){return t===`|`?t:e}function mk(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:` `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(` `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return rk(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Zf.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function hk(){return{exit:{taskListCheckValueChecked:_k,taskListCheckValueUnchecked:_k,paragraph:vk}}}function gk(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:yk}}}function _k(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function vk(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function yk(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Zf.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function bk(){return[xO(),GO(),XO(),ok(),hk()]}function xk(e){return{extensions:[SO(),KO(e),ZO(),mk(e),gk()]}}var Sk={tokenize:Ik,partial:!0},Ck={tokenize:Lk,partial:!0},wk={tokenize:Rk,partial:!0},Tk={tokenize:zk,partial:!0},Ek={tokenize:Bk,partial:!0},Dk={name:`wwwAutolink`,tokenize:Pk,previous:Vk},Ok={name:`protocolAutolink`,tokenize:Fk,previous:Hk},kk={name:`emailAutolink`,tokenize:Nk,previous:Uk},Ak={};function jk(){return{text:Ak}}for(var Mk=48;Mk<123;)Ak[Mk]=kk,Mk++,Mk===58?Mk=65:Mk===91&&(Mk=97);Ak[43]=kk,Ak[45]=kk,Ak[46]=kk,Ak[95]=kk,Ak[72]=[kk,Ok],Ak[104]=[kk,Ok],Ak[87]=[kk,Dk],Ak[119]=[kk,Dk];function Nk(e,t,n){let r=this,i,a;return o;function o(t){return!Wk(t)||!Uk.call(r,r.previous)||Gk(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Wk(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Ek,u,l)(t):t===45||t===95||gi(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&xi(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Pk(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Vk.call(r,r.previous)||Gk(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Sk,e.attempt(Ck,e.attempt(wk,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Fk(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Hk.call(r,r.previous)&&!Gk(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(xi(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Ai(t)||_i(t)||di(t)||mi(t)?n(t):e.attempt(Ck,e.attempt(wk,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Ik(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Lk(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Tk,c,s)(t):t===null||_i(t)||di(t)||t!==45&&mi(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Rk(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Tk,t,a)(o):o===null||_i(o)||di(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function zk(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||_i(o)||di(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||_i(e)||di(e)?t(e):r(e)}function a(e){return xi(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):xi(t)?(e.consume(t),o):n(t)}}function Bk(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return gi(e)?n(e):t(e)}}function Vk(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||_i(e)}function Hk(e){return!xi(e)}function Uk(e){return!(e===47||Wk(e))}function Wk(e){return e===43||e===45||e===46||e===95||gi(e)}function Gk(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Kk={tokenize:eA,partial:!0};function qk(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Zk,continuation:{tokenize:Qk},exit:$k}},text:{91:{name:`gfmFootnoteCall`,tokenize:Xk},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Jk,resolveTo:Yk}}}}function Jk(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=ji(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Yk(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Xk(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||_i(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(ji(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return _i(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Zk(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||_i(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=ji(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return _i(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Si(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Qk(e,t,n){return e.check(bi,t,e.attempt(Kk,t,n))}function $k(e){e.exit(`gfmFootnoteDefinition`)}function eA(e,t,n){let r=this;return Si(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function tA(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&pi(o,o.length,0,Ei(s,e.slice(r+1,n),t)),pi(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),pi(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=wi(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=wi(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var nA=class{constructor(){this.map=[]}add(e,t,n){rA(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function rA(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function iA(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function aA(){return{flow:{null:{name:`table`,tokenize:oA,resolveAll:sA}}}}function oA(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Ni(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Mi(t)?Si(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||_i(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Mi(t)?Si(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Mi(t)?Si(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Ni(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Mi(t)?Si(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Ni(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Ni(n)?(e.exit(`tableRow`),t(n)):Mi(n)?Si(e,C,`whitespace`)(n):(e.enter(`data`),ee(n))}function ee(t){return t===null||t===124||_i(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?te:ee)}function te(t){return t===92||t===124?(e.consume(t),ee):ee(t)}}function sA(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new nA;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(lA(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=cA(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=cA(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=cA(f,t,o,i,n,d)):(o[0]=o[1],d=cA(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&lA(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=iA(t.events,n))}return e}function cA(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},uA(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=uA(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=uA(t.events,n[2]),a=uA(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},uA(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function lA(e,t,n,r,i){let a=[],o=uA(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function uA(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var dA={name:`tasklistCheck`,tokenize:pA};function fA(){return{text:{91:dA}}}function pA(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return _i(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Ni(r)?t(r):Mi(r)?e.check({tokenize:mA},t,n)(r):n(r)}}function mA(e,t,n){return Si(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function hA(e){return hi([jk(),qk(),tA(e),aA(),fA()])}var gA={};function _A(e){let t=this,n=e||gA,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(hA(n)),a.push(bk()),o.push(xk(n))}function $(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-gfm`,...t}}),e}var vA=nw(`strike_through`);$(vA,{displayName:`Attr<strikethrough>`,group:`Strikethrough`});var yA=$C(`strike_through`,e=>({parseDOM:[{tag:`del`},{style:`text-decoration`,getAttrs:e=>e===`line-through`}],toDOM:t=>[`del`,e.get(vA.key)(t)],parseMarkdown:{match:e=>e.type===`delete`,runner:(e,t,n)=>{e.openMark(n),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strike_through`,runner:(e,t)=>{e.withMark(t,`delete`)}}}));$(yA.mark,{displayName:`MarkSchema<strikethrough>`,group:`Strikethrough`}),$(yA.ctx,{displayName:`MarkSchemaCtx<strikethrough>`,group:`Strikethrough`});var bA=X(`ToggleStrikeThrough`,e=>()=>$g(yA.type(e)));$(bA,{displayName:`Command<ToggleStrikethrough>`,group:`Strikethrough`});var xA=GC(e=>w_(/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)/,yA.type(e)));$(xA,{displayName:`InputRule<strikethrough>`,group:`Strikethrough`});var SA=ew(`strikeThroughKeymap`,{ToggleStrikethrough:{shortcuts:`Mod-Alt-x`,command:e=>{let t=e.get(Y);return()=>t.call(bA.key)}}});$(SA.ctx,{displayName:`KeymapCtx<strikethrough>`,group:`Strikethrough`}),$(SA.shortcuts,{displayName:`Keymap<strikethrough>`,group:`Strikethrough`});var CA=_E({tableGroup:`block`,cellContent:`paragraph`,cellAttributes:{alignment:{default:`left`,getFromDOM:e=>e.style.textAlign||`left`,setDOMAttr:(e,t)=>{t.style=`text-align: ${e||`left`}`}}}}),wA=QC(`table`,()=>({...CA.table,content:`table_header_row table_row+`,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`table`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r,isHeader:t===0}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table`,runner:(e,t)=>{let n=t.content.firstChild?.content;if(!n)return;let r=[];n.forEach(e=>{r.push(e.attrs.alignment)}),e.openNode(`table`,void 0,{align:r}),e.next(t.content),e.closeNode()}}}));$(wA.node,{displayName:`NodeSchema<table>`,group:`Table`}),$(wA.ctx,{displayName:`NodeSchemaCtx<table>`,group:`Table`});var TA=QC(`table_header_row`,()=>({...CA.table_row,disableDropCursor:!0,content:`(table_header)*`,parseDOM:[{tag:`tr[data-is-header]`},{tag:`tr`,getAttrs:e=>e instanceof HTMLElement&&e.querySelector(`th`)?{}:!1}],toDOM(){return[`tr`,{"data-is-header":!0},0]},parseMarkdown:{match:e=>!!(e.type===`tableRow`&&e.isHeader),runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,n)=>({...e,align:r[n],isHeader:t.isHeader}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`,void 0,{isHeader:!0}),e.next(t.content),e.closeNode())}}}));$(TA.node,{displayName:`NodeSchema<tableHeaderRow>`,group:`Table`}),$(TA.ctx,{displayName:`NodeSchemaCtx<tableHeaderRow>`,group:`Table`});var EA=QC(`table_row`,()=>({...CA.table_row,disableDropCursor:!0,content:`(table_cell)*`,parseMarkdown:{match:e=>e.type===`tableRow`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r[t]}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`),e.next(t.content),e.closeNode())}}}));$(EA.node,{displayName:`NodeSchema<tableRow>`,group:`Table`}),$(EA.ctx,{displayName:`NodeSchemaCtx<tableRow>`,group:`Table`});var DA=QC(`table_cell`,()=>({...CA.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>e.type.name===`table_cell`,runner:(e,t)=>{e.openNode(`tableCell`).next(t.content).closeNode()}}}));$(DA.node,{displayName:`NodeSchema<tableCell>`,group:`Table`}),$(DA.ctx,{displayName:`NodeSchemaCtx<tableCell>`,group:`Table`});var OA=QC(`table_header`,()=>({...CA.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header`,runner:(e,t)=>{e.openNode(`tableCell`),e.next(t.content),e.closeNode()}}}));$(OA.node,{displayName:`NodeSchema<tableHeader>`,group:`Table`}),$(OA.ctx,{displayName:`NodeSchemaCtx<tableHeader>`,group:`Table`});function kA(e,t=3,n=3){let r=Array(n).fill(0).map(()=>DA.type(e).createAndFill()),i=Array(n).fill(0).map(()=>OA.type(e).createAndFill()),a=Array(t).fill(0).map((t,n)=>n===0?TA.type(e).create(null,i):EA.type(e).create(null,r));return wA.type(e).create(null,a)}function AA(e){return(t,n)=>r=>{n??=r.selection.from;let i=r.doc.resolve(n),a=j_(e=>e.type.name===`table`)(i),o=a?{node:a.node,from:a.start}:void 0,s=e===`row`;if(o){let e=Q.get(o.node);if(t>=0&&t<(s?e.height:e.width)){let n=e.positionAt(s?t:e.height-1,s?e.width-1:t,o.node),i=r.doc.resolve(o.from+n),a=s?jE.rowSelection:jE.colSelection,c=e.positionAt(s?t:0,s?0:t,o.node),l=r.doc.resolve(o.from+c);return T_(r.setSelection(a(i,l)))}}return r}}var jA=AA(`row`),MA=AA(`col`);function NA(e,t,{map:n,tableStart:r,table:i},a){let o=Array(a).fill(0).reduce((e,t,n)=>e+i.child(n).nodeSize,r),s=Array(n.width).fill(0).map((t,r)=>{let a=i.nodeAt(n.map[r]);return DA.type(e).createAndFill({alignment:a?.attrs.alignment})});return t.insert(o,EA.type(e).create(null,s)),t}function PA(e){let t=WE(e.$from);if(!t)return;let n=Q.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(e=>{let n=t.node.nodeAt(e),r=e+t.start;return{pos:r,start:r+1,node:n}})}function FA(e){let t=PA(e.selection);if(t&&t[0]){let n=e.doc.resolve(t[0].pos),r=t[t.length-1];if(r){let t=e.doc.resolve(r.pos);return T_(e.setSelection(new jE(t,n)))}}return e}var IA=X(`GoToPrevTableCell`,()=>()=>mD(-1));$(IA,{displayName:`Command<goToPrevTableCellCommand>`,group:`Table`});var LA=X(`GoToNextTableCell`,()=>()=>mD(1));$(LA,{displayName:`Command<goToNextTableCellCommand>`,group:`Table`});var RA=X(`ExitTable`,e=>()=>(t,n)=>{if(!xE(t))return!1;let{$head:r}=t.selection,i=k_(r,wA.type(e));if(!i)return!1;let{to:a}=i,o=t.tr.replaceWith(a,a,zw.type(e).createAndFill());return o.setSelection(K.near(o.doc.resolve(a),1)).scrollIntoView(),n?.(o),!0});$(RA,{displayName:`Command<breakTableCommand>`,group:`Table`});var zA=X(`InsertTable`,e=>({row:t,col:n}={})=>(r,i)=>{let{selection:a,tr:o}=r,{from:s}=a,c=kA(e,t,n),l=o.replaceSelectionWith(c),u=K.findFrom(l.doc.resolve(s),1,!0);return u&&l.setSelection(u),i?.(l),!0});$(zA,{displayName:`Command<insertTableCommand>`,group:`Table`});var BA=X(`MoveRow`,()=>({from:e,to:t,pos:n}={})=>_D({from:e??0,to:t??0,pos:n}));$(BA,{displayName:`Command<moveRowCommand>`,group:`Table`});var VA=X(`MoveCol`,()=>({from:e,to:t,pos:n}={})=>vD({from:e??0,to:t??0,pos:n}));$(VA,{displayName:`Command<moveColCommand>`,group:`Table`});var HA=X(`SelectRow`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(jA(e.index,e.pos)(r))});$(HA,{displayName:`Command<selectRowCommand>`,group:`Table`});var UA=X(`SelectCol`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(MA(e.index,e.pos)(r))});$(UA,{displayName:`Command<selectColCommand>`,group:`Table`});var WA=X(`SelectTable`,()=>()=>(e,t)=>{let{tr:n}=e;return!!t?.(FA(n))});$(WA,{displayName:`Command<selectTableCommand>`,group:`Table`});var GA=X(`DeleteSelectedCells`,()=>()=>(e,t)=>{let{selection:n}=e;if(!(n instanceof jE))return!1;let r=n.isRowSelection(),i=n.isColSelection();return r&&i?hD(e,t):i?oD(e,t):cD(e,t)});$(GA,{displayName:`Command<deleteSelectedCellsCommand>`,group:`Table`});var KA=X(`AddColBefore`,()=>()=>rD);$(KA,{displayName:`Command<addColBeforeCommand>`,group:`Table`});var qA=X(`AddColAfter`,()=>()=>iD);$(qA,{displayName:`Command<addColAfterCommand>`,group:`Table`});var JA=X(`AddRowBefore`,e=>()=>(t,n)=>{if(!xE(t))return!1;if(n){let r=tD(t);n(NA(e,t.tr,r,r.top))}return!0});$(JA,{displayName:`Command<addRowBeforeCommand>`,group:`Table`});var YA=X(`AddRowAfter`,e=>()=>(t,n)=>{if(!xE(t))return!1;if(n){let r=tD(t);n(NA(e,t.tr,r,r.bottom))}return!0});$(YA,{displayName:`Command<addRowAfterCommand>`,group:`Table`});var XA=X(`SetAlign`,()=>(e=`left`)=>lD(`alignment`,e));$(XA,{displayName:`Command<setAlignCommand>`,group:`Table`});var ZA=GC(e=>new o_(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(t,n,r,i)=>{let a=t.doc.resolve(r);if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),wA.type(e)))return null;let o=kA(e,Math.max(Number(n.groups?.row??0),2),Number(n.groups?.col)),s=t.tr.replaceRangeWith(r,i,o);return s.setSelection(q.create(s.doc,r+3)).scrollIntoView()}));$(ZA,{displayName:`InputRule<insertTableInputRule>`,group:`Table`});var QA=KC(e=>({run:(t,n,r)=>{if(r)return t;function i(t){let n=t.childCount,r=t.lastChild?.childCount??0;if(n===0||r===0)return zw.type(e).create();let i=t.firstChild;if(!(r>0&&i&&i.childCount===0))return t;if(n>=3){let r=t.child(1),a=[];for(let t=0;t<r.childCount;t++){let n=r.child(t);a.push(OA.type(e).create(n.attrs,n.content,n.marks))}let o=i.type.create(i.attrs,a),s=[];for(let e=2;e<n;e++)s.push(t.child(e));return t.type.create(t.attrs,[o,...s])}let a=Array(r).fill(0).map(()=>OA.type(e).createAndFill()),o=new G(U.from(a),0,0),s=i.replace(0,0,o);return t.replace(0,i.nodeSize,new G(U.from(s),0,0))}function a(t){let n=EA.type(e),r=[],a=[],o=!1;function s(){if(a.length===0)return;let t=TA.type(e).createAndFill(),n=wA.type(e).create(null,[t,...a]);r.push(i(n)),a=[]}return t.forEach(e=>{e.type===n?(o=!0,a.push(e)):(s(),r.push(e))}),s(),o?U.from(r):t}function o(t){let n=a(t),r=n!==t,s=[];return n.forEach(t=>{if(t.type===wA.type(e)){let e=i(t);e!==t&&(r=!0),s.push(e)}else if(t.childCount>0){let e=o(t.content);e===t.content?s.push(t):(r=!0,s.push(t.copy(e)))}else s.push(t)}),r?U.from(s):t}function s(t){let n=[],r=[];t.forEach(e=>r.push(e));for(let t=0;t<r.length;t++){let i=r[t],a=r[t+1];i.type===zw.type(e)&&i.content.size===0&&a&&a.type===wA.type(e)||n.push(i)}return n.length<r.length?U.from(n):t}let c=o(t.content);return c=s(c),new G(U.from(c),t.openStart,t.openEnd)}}));$(QA,{displayName:`PasteRule<table>`,group:`Table`});var $A=ew(`tableKeymap`,{NextCell:{priority:100,shortcuts:[`Mod-]`,`Tab`],command:e=>{let t=e.get(Y);return()=>t.call(LA.key)}},PrevCell:{shortcuts:[`Mod-[`,`Shift-Tab`],command:e=>{let t=e.get(Y);return()=>t.call(IA.key)}},ExitTable:{shortcuts:[`Mod-Enter`,`Enter`],command:e=>{let t=e.get(Y);return()=>t.call(RA.key)}}});$($A.ctx,{displayName:`KeymapCtx<table>`,group:`Table`}),$($A.shortcuts,{displayName:`Keymap<table>`,group:`Table`});var ej=`footnote_definition`,tj=`footnoteDefinition`,nj=QC(`footnote_definition`,()=>({group:`block`,content:`block+`,defining:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`dl[data-type="${ej}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ld(e);return{label:e.dataset.label}},contentElement:`dd`}],toDOM:e=>{let t=e.attrs.label;return[`dl`,{"data-label":t,"data-type":ej},[`dt`,t],[`dd`,0]]},parseMarkdown:{match:({type:e})=>e===tj,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===ej,runner:(e,t)=>{e.openNode(tj,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}}));$(nj.ctx,{displayName:`NodeSchemaCtx<footnodeDef>`,group:`footnote`}),$(nj.node,{displayName:`NodeSchema<footnodeDef>`,group:`footnote`});var rj=`footnote_reference`,ij=QC(`footnote_reference`,()=>({group:`inline`,inline:!0,atom:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`sup[data-type="${rj}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ld(e);return{label:e.dataset.label}}}],toDOM:e=>{let t=e.attrs.label;return[`sup`,{"data-label":t,"data-type":rj},t]},parseMarkdown:{match:({type:e})=>e===`footnoteReference`,runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===rj,runner:(e,t)=>{e.addNode(`footnoteReference`,void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}}));$(ij.ctx,{displayName:`NodeSchemaCtx<footnodeRef>`,group:`footnote`}),$(ij.node,{displayName:`NodeSchema<footnodeRef>`,group:`footnote`});var aj=jT.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null,validate:`boolean|null`}},parseDOM:[{tag:`li[data-item-type="task"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ld(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread,checked:e.dataset.checked?e.dataset.checked===`true`:null}}},...n?.parseDOM||[]],toDOM:e=>n.toDOM&&e.attrs.checked==null?n.toDOM(e):[`li`,{"data-item-type":`task`,"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread,"data-checked":e.attrs.checked},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,r)=>{if(t.checked==null){n.parseMarkdown.runner(e,t,r);return}let i=t.label==null?`•`:`${t.label}.`,a=t.checked==null?null:!!t.checked,o=t.label==null?`bullet`:`ordered`,s=t.spread==null?`true`:`${t.spread}`;e.openNode(r,{label:i,listType:o,spread:s,checked:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{if(t.attrs.checked==null){n.toMarkdown.runner(e,t);return}let r=t.attrs.label,i=t.attrs.listType,a=t.attrs.spread===`true`,o=t.attrs.checked;e.openNode(`listItem`,void 0,{label:r,listType:i,spread:a,checked:o}),e.next(t.content),e.closeNode()}}}});$(aj.node,{displayName:`NodeSchema<taskListItem>`,group:`ListItem`}),$(aj.ctx,{displayName:`NodeSchemaCtx<taskListItem>`,group:`ListItem`});var oj=GC(()=>new o_(/^\[(?<checked>\s|x)\]\s$/,(e,t,n,r)=>{let i=e.doc.resolve(n),a=0,o=i.node(a);for(;o&&o.type.name!==`list_item`;)a--,o=i.node(a);if(!o||o.attrs.checked!=null)return null;let s=t.groups?.checked===`x`,c=i.before(a),l=e.tr;return l.deleteRange(n,r).setNodeMarkup(c,void 0,{...o.attrs,checked:s}),l}));$(oj,{displayName:`InputRule<wrapInTaskListInputRule>`,group:`ListItem`});var sj=[SA,$A].flat(),cj=[ZA,oj],lj=[xA],uj=[QA],dj=YC(()=>fO);$(dj,{displayName:`Prose<autoInsertSpanPlugin>`,group:`Prose`}),$(YC(()=>BD({})),{displayName:`Prose<columnResizingPlugin>`,group:`Prose`});var fj=YC(()=>eO({allowTableNodeSelection:!0}));$(fj,{displayName:`Prose<tableEditingPlugin>`,group:`Prose`});var pj=rw(`remarkGFM`,()=>_A);$(pj.plugin,{displayName:`Remark<remarkGFMPlugin>`,group:`Remark`}),$(pj.options,{displayName:`RemarkConfig<remarkGFMPlugin>`,group:`Remark`});var mj=new Cg(`MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN`);function hj(e,t){let n=0;return t.forEach((t,r,i)=>{t===e&&(n=i)}),n}var gj=YC(()=>new bg({key:mj,appendTransaction:(e,t,n)=>{let r;return t.doc!==n.doc&&n.doc.descendants((e,t)=>{if(r||=n.tr,e.type.name!==`table_cell`)return;let i=n.doc.resolve(t),a=i.node(i.depth),o=i.node(i.depth-1).firstChild;if(!o)return;let s=hj(e,a),c=o.maybeChild(s);if(!c)return;let l=c.attrs.alignment;l!==e.attrs.alignment&&r.setNodeMarkup(t,void 0,{...e.attrs,alignment:l})}),r}}));$(gj,{displayName:`Prose<keepTableAlignPlugin>`,group:`Prose`});var _j=[gj,dj,pj,fj].flat(),vj=[[aj,wA,TA,EA,OA,DA,nj,ij,vA,yA].flat(),cj,uj,lj,sj,[LA,IA,RA,zA,BA,VA,HA,UA,WA,GA,JA,YA,KA,qA,XA,bA],_j].flat(),yj=200,bj=function(){};bj.prototype.append=function(e){return e.length?(e=bj.from(e),!this.length&&e||e.length<yj&&this.leafAppend(e)||this.length<yj&&e.leafPrepend(this)||this.appendInner(e)):this},bj.prototype.prepend=function(e){return e.length?bj.from(e).append(this):this},bj.prototype.appendInner=function(e){return new Sj(this,e)},bj.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?bj.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},bj.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},bj.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},bj.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},bj.from=function(e){return e instanceof bj?e:e&&e.length?new xj(e):bj.empty};var xj=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=yj)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=yj)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(bj);bj.empty=new xj([]);var Sj=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(bj),Cj=500,wj=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new Ej(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new Ej(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new Ej(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>Oj&&(s=Tj(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new $m;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new Ej(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new Ej(i,o,l))}else r.push(new Ej(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new Ej(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>Cj&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new Ej(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(bj.from(i.reverse()),a)}};wj.empty=new wj(bj.empty,0);function Tj(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var Ej=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},Dj=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},Oj=20;function kj(e,t,n,r){let i=n.getMeta(Lj),a;if(i)return i.historyState;n.getMeta(Rj)&&(e=new Dj(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Lj))return o.getMeta(Lj).redo?new Dj(e.done.addTransform(n,void 0,r,Ij(t)),e.undone,jj(n.mapping.maps),e.prevTime,e.prevComposition):new Dj(e.done,e.undone.addTransform(n,void 0,r,Ij(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Aj(n,e.prevRanges)),s=o?Mj(e.prevRanges,n.mapping):jj(n.mapping.maps);return new Dj(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Ij(t)),wj.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new Dj(e.done.rebased(n,a),e.undone.rebased(n,a),Mj(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Dj(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Mj(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Aj(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function jj(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Mj(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function Nj(e,t,n){let r=Ij(t),i=Lj.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new Dj(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Lj,{redo:n,historyState:c})}var Pj=!1,Fj=null;function Ij(e){let t=e.plugins;if(Fj!=t){Pj=!1,Fj=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Pj=!0;break}}return Pj}var Lj=new Cg(`history`),Rj=new Cg(`closeHistory`);function zj(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new bg({key:Lj,state:{init(){return new Dj(wj.empty,wj.empty,null,0,-1)},apply(t,n,r){return kj(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?Vj:n==`historyRedo`?Hj:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Bj(e,t){return(n,r)=>{let i=Lj.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=Nj(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Vj=Bj(!1,!0),Hj=Bj(!0,!0);function Uj(e,t){return Object.assign(e,{meta:{package:`@milkdown/plugin-history`,...t}}),e}var Wj=X(`Undo`,()=>()=>Vj);Uj(Wj,{displayName:`Command<undo>`});var Gj=X(`Redo`,()=>()=>Hj);Uj(Gj,{displayName:`Command<redo>`});var Kj=ZC({},`historyProviderConfig`);Uj(Kj,{displayName:`Ctx<historyProviderConfig>`});var qj=YC(e=>zj(e.get(Kj.key)));Uj(qj,{displayName:`Ctx<historyProviderPlugin>`});var Jj=ew(`historyKeymap`,{Undo:{shortcuts:`Mod-z`,command:e=>{let t=e.get(Y);return()=>t.call(Wj.key)}},Redo:{shortcuts:[`Mod-y`,`Shift-Mod-z`],command:e=>{let t=e.get(Y);return()=>t.call(Gj.key)}}});Uj(Jj.ctx,{displayName:`KeymapCtx<history>`}),Uj(Jj.shortcuts,{displayName:`Keymap<history>`});var Yj=[Kj,qj,Jj,Wj,Gj].flat();function Xj(e){if(!e)return!1;if(Array.isArray(e))return e.length>1?!1:Xj(e[0]);let t=e.content;return t?Xj(t):e.type===`text`}function Zj(e,t){return Object.assign(e,{meta:{package:`@milkdown/plugin-clipboard`,...t}}),e}function Qj(e,t){let n=D_(t);if(n)return e.dispatch(e.state.tr.replaceSelectionWith(n,!0)),!0;try{return e.dispatch(e.state.tr.replaceSelection(t)),!0}catch{return!1}}var $j=YC(e=>{let t=e.get(US);return e.update(OC,e=>({...e,editable:e.editable??(()=>!0),transformPastedHTML:(t,n)=>{let r=e.transformPastedHTML;return r&&(t=r(t,n)),t.includes(`docs-internal-guid`)&&(t=t.replace(/<b[^>]*id="docs-internal-guid[^"]*"[^>]*>([\s\S]*)<\/b>/,`$1`),t=t.replace(/<div[^>]*>(<table[\s\S]*?<\/table>)<\/div>/g,`$1`)),t}})),new bg({key:new Cg(`MILKDOWN_CLIPBOARD`),props:{handlePaste:(n,r,i)=>{let a=e.get(sC),o=n.props.editable?.(n.state),{clipboardData:s}=r;if(!o||!s||n.state.selection.$from.node().type.spec.code)return!1;let c=s.getData(`text/plain`),l=s.getData(`vscode-editor-data`);if(l){let e=JSON.parse(l)?.mode;if(c&&e){let{tr:r}=n.state,i=A_(`code_block`,t);return r.replaceSelectionWith(i.create({language:e})).setSelection(q.near(r.doc.resolve(Math.max(0,r.selection.from-2)))).insertText(c.replace(/\r\n?/g,` `)),n.dispatch(r),!0}}let u=s.getData(`text/html`);if(u.length===0&&c.length===0)return!1;if(u.length>0&&i)return Qj(n,i);let d=xm.fromSchema(t),f;if(u.length===0){let e=a(c);if(!e||typeof e==`string`)return!1;f=Fm.fromSchema(t).serializeFragment(e.content)}else{let e=document.createElement(`template`);e.innerHTML=u,f=e.content.cloneNode(!0),e.remove()}return Qj(n,d.parseSlice(f))},clipboardTextSerializer:n=>{let r=e.get(pC);if(Xj(n.content.toJSON()))return n.content.textBetween(0,n.content.size,` `);let i=t.topNodeType.createAndFill(void 0,n.content);return i?r(i):``}}})});Zj($j,{displayName:`Prose<clipboard>`});var eM=typeof global==`object`&&global&&global.Object===Object&&global,tM=typeof self==`object`&&self&&self.Object===Object&&self,nM=eM||tM||Function(`return this`)(),rM=nM.Symbol,iM=Object.prototype,aM=iM.hasOwnProperty,oM=iM.toString,sM=rM?rM.toStringTag:void 0;function cM(e){var t=aM.call(e,sM),n=e[sM];try{e[sM]=void 0;var r=!0}catch{}var i=oM.call(e);return r&&(t?e[sM]=n:delete e[sM]),i}var lM=Object.prototype.toString;function uM(e){return lM.call(e)}var dM=`[object Null]`,fM=`[object Undefined]`,pM=rM?rM.toStringTag:void 0;function mM(e){return e==null?e===void 0?fM:dM:pM&&pM in Object(e)?cM(e):uM(e)}function hM(e){return typeof e==`object`&&!!e}var gM=`[object Symbol]`;function _M(e){return typeof e==`symbol`||hM(e)&&mM(e)==gM}var vM=/\s/;function yM(e){for(var t=e.length;t--&&vM.test(e.charAt(t)););return t}var bM=/^\s+/;function xM(e){return e&&e.slice(0,yM(e)+1).replace(bM,``)}function SM(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var CM=NaN,wM=/^[-+]0x[0-9a-f]+$/i,TM=/^0b[01]+$/i,EM=/^0o[0-7]+$/i,DM=parseInt;function OM(e){if(typeof e==`number`)return e;if(_M(e))return CM;if(SM(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=SM(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=xM(e);var n=TM.test(e);return n||EM.test(e)?DM(e.slice(2),n?2:8):wM.test(e)?CM:+e}var kM=function(){return nM.Date.now()},AM=`Expected a function`,jM=Math.max,MM=Math.min;function NM(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(AM);t=OM(t)||0,SM(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?jM(OM(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?MM(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=kM();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(kM())}function x(){var e=kM(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}var PM=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}selectionUpdated(e){return this.selectionUpdatedListeners.push(e),this}},FM=H(new PM,`listener`),IM=new Cg(`MILKDOWN_LISTENER`),LM=e=>(e.inject(FM,new PM),async()=>{await e.wait(zS);let{listeners:t}=e.get(FM);t.beforeMount.forEach(t=>t(e)),await e.wait(uC);let n=e.get(pC),r=null,i=null,a=null,o=null,s=NM(()=>{if(!o)return;let{doc:a}=o;if(t.updated.length>0&&r&&!r.eq(a)&&t.updated.forEach(t=>{t(e,a,r)}),t.markdownUpdated.length>0&&r&&!r.eq(a)){let r=n(a);t.markdownUpdated.forEach(t=>{t(e,r,i)}),i=r}r=a,o=null},200),c=new bg({key:IM,view:()=>({destroy:()=>{t.destroy.forEach(t=>t(e))}}),props:{handleDOMEvents:{focus:()=>(t.focus.forEach(t=>t(e)),!1),blur:()=>(t.blur.forEach(t=>t(e)),!1)}},state:{init:(e,t)=>{r=t.doc,i=n(t.doc)},apply:n=>{let r=n.selection;(!a&&r||a&&!r.eq(a))&&(t.selectionUpdated.forEach(t=>{t(e,r,a)}),a=r),!(!(n.docChanged||n.storedMarksSet)||n.getMeta(`addToHistory`)===!1)&&(o=n,s())}}});e.update(jS,e=>e.concat(c)),await e.wait(EC),t.mounted.forEach(t=>t(e))});LM.meta={package:`@milkdown/plugin-listener`,displayName:`Listener`};function RM(e){return new Promise(t=>{let n=new FileReader;n.addEventListener(`load`,()=>{t({alt:e.name,src:n.result})},!1),n.readAsDataURL(e)})}var zM=ZC({uploader:async(e,t)=>{let n=[];for(let t=0;t<e.length;t++){let r=e.item(t);r&&r.type.includes(`image`)&&n.push(r)}let{image:r}=t.nodes;if(!r)throw zd(`image`);return(await Promise.all(n.map(e=>RM(e)))).map(({alt:e,src:t})=>r.createAndFill({src:t,alt:e}))},enableHtmlFileUploader:!1,uploadWidgetFactory:(e,t)=>{let n=document.createElement(`span`);return n.textContent=`Upload in progress...`,Nx.widget(e,n,t)}},`uploadConfig`);zM.meta={package:`@milkdown/plugin-upload`,displayName:`Ctx<uploadConfig>`};var BM=YC(e=>{let t=new Cg(`MILKDOWN_UPLOAD`),n=(e,n)=>{let r=t.getState(e);if(!r)return-1;let i=r.find(void 0,void 0,e=>e.id===n);return i.length?i[0]?.from??-1:-1},r=(r,i,a)=>{if(!a||a.length<=0)return!1;let o=Symbol(`upload symbol`),s=e.get(US),{uploader:c,getInsertPos:l}=e.get(zM.key),{tr:u}=r.state,d=i instanceof DragEvent?r.posAtCoords({left:i.clientX,top:i.clientY})?.pos??u.selection.from:u.selection.from,f=typeof l==`function`?l(i,e,d):d;return r.dispatch(u.setMeta(t,{add:{id:o,pos:f}})),c(a,s,e,f).then(e=>{let i=n(r.state,o);i<0||r.dispatch(r.state.tr.replaceWith(i,i,e).setMeta(t,{remove:{id:o}}))}).catch(e=>{console.error(e)}),!0};return new bg({key:t,state:{init(){return Ix.empty},apply(t,n){let r=n.map(t.mapping,t.doc),i=t.getMeta(this);if(!i)return r;if(i.add){let{uploadWidgetFactory:n}=e.get(zM.key),a=n(i.add.pos,{id:i.add.id});return r.add(t.doc,[a])}if(i.remove){let e=r.find(void 0,void 0,e=>e.id===i.remove.id);return r.remove(e)}return r}},props:{decorations(e){return this.getState(e)},handlePaste:(t,n)=>{let{enableHtmlFileUploader:i}=e.get(zM.key);return!(n instanceof ClipboardEvent)||!i&&n.clipboardData?.getData(`text/html`)?!1:r(t,n,n.clipboardData?.files)},handleDrop:(e,t)=>t instanceof DragEvent&&r(e,t,t.dataTransfer?.files)}})});BM.meta={package:`@milkdown/plugin-upload`,displayName:`Prose<upload>`};var VM=[zM,BM];function HM({open:e,onOpenChange:t,selectedText:n,onSubmit:r}){let{t:i}=A(),[a,o]=(0,M.useState)(``),[s,c]=(0,M.useState)(``);(0,M.useEffect)(()=>{e&&(o(n||``),c(``))},[e,n]);let l=e=>{if(e.preventDefault(),!s.trim())return;let n=a.trim()||s.trim(),i=s.trim();/^https?:\/\//i.test(i)||(i=`https://`+i),r(n,i),t(!1)},u=!!n;return(0,N.jsx)(Br,{open:e,onOpenChange:t,children:(0,N.jsxs)(zr,{className:`sm:max-w-md`,children:[(0,N.jsx)(Ir,{children:(0,N.jsx)(Lr,{children:i(`mdEditor.link.title`)})}),(0,N.jsxs)(`form`,{onSubmit:l,children:[(0,N.jsxs)(`div`,{className:`space-y-4 py-4`,children:[u?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(Pi,{className:`text-muted-foreground`,children:i(`mdEditor.link.textLabel`)}),(0,N.jsx)(`p`,{className:`text-sm bg-muted px-3 py-2 rounded-md break-words`,children:n})]}):(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(Pi,{htmlFor:`link-text`,children:i(`mdEditor.link.textLabel`)}),(0,N.jsx)(Fr,{id:`link-text`,value:a,onChange:e=>o(e.target.value),placeholder:i(`mdEditor.link.textPlaceholder`),autoFocus:!0})]}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(Pi,{htmlFor:`link-url`,children:i(`mdEditor.link.urlLabel`)}),(0,N.jsx)(Fr,{id:`link-url`,value:s,onChange:e=>c(e.target.value),placeholder:`https://example.com`,type:`url`,autoFocus:u})]})]}),(0,N.jsxs)(Rr,{children:[(0,N.jsx)(Pr,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:i(`mdEditor.link.cancel`)}),(0,N.jsx)(Pr,{type:`submit`,disabled:!s.trim(),children:i(`mdEditor.link.insert`)})]})]})]})})}function UM(){let{t:e}=A();return(0,N.jsxs)(Li,{children:[(0,N.jsx)(Fi,{asChild:!0,children:(0,N.jsx)(Pr,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:text-foreground`,"aria-label":e(`mdEditor.help.title`),children:(0,N.jsx)(te,{className:`h-4 w-4`})})}),(0,N.jsx)(Ii,{className:`w-72`,align:`end`,children:(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`h4`,{className:`font-medium text-sm`,children:e(`mdEditor.help.title`)}),(0,N.jsxs)(`div`,{className:`text-xs space-y-1.5 font-mono text-muted-foreground`,children:[(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`span`,{children:`**bold**`}),(0,N.jsx)(`span`,{className:`font-sans font-bold`,children:e(`mdEditor.help.bold`)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`span`,{children:`*italic*`}),(0,N.jsx)(`span`,{className:`font-sans italic`,children:e(`mdEditor.help.italic`)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`span`,{children:`# Heading 1`}),(0,N.jsx)(`span`,{className:`font-sans`,children:`H1`})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`span`,{children:`## Heading 2`}),(0,N.jsx)(`span`,{className:`font-sans`,children:`H2`})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`span`,{children:`- list item`}),(0,N.jsx)(`span`,{className:`font-sans`,children:e(`mdEditor.help.bulletList`)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`span`,{children:`1. numbered`}),(0,N.jsx)(`span`,{className:`font-sans`,children:e(`mdEditor.help.numberedList`)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`span`,{children:`[text](url)`}),(0,N.jsx)(`span`,{className:`font-sans text-primary`,children:e(`mdEditor.help.link`)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`span`,{children:`> quote`}),(0,N.jsx)(`span`,{className:`font-sans border-l-2 pl-1`,children:e(`mdEditor.help.quote`)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`span`,{children:"`code`"}),(0,N.jsx)(`span`,{className:`font-sans bg-muted px-1 rounded`,children:e(`mdEditor.help.code`)})]})]})]})})]})}function WM({icon:e,label:t,shortcut:n,onClick:r,active:i}){return(0,N.jsxs)(Pn,{children:[(0,N.jsx)(jn,{asChild:!0,children:(0,N.jsx)(Pr,{type:`button`,variant:`ghost`,size:`icon`,onClick:r,"aria-label":t,className:O(`h-8 w-8 text-muted-foreground hover:text-foreground`,i&&`bg-muted text-foreground`),children:e})}),(0,N.jsxs)(Mn,{children:[(0,N.jsx)(`span`,{children:t}),n&&(0,N.jsx)(`span`,{className:`ml-2 text-muted-foreground text-xs`,children:n})]})]})}function GM({onCommand:e,onImageUpload:t,className:n}){let{t:r}=A();return(0,N.jsxs)(`div`,{className:O(`flex items-center gap-0.5 p-1.5 border-b border-border bg-muted/40 flex-wrap`,n),children:[(0,N.jsx)(WM,{icon:(0,N.jsx)(d,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.bold`),shortcut:`Ctrl+B`,onClick:()=>e(`toggleBold`)}),(0,N.jsx)(WM,{icon:(0,N.jsx)(Ne,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.italic`),shortcut:`Ctrl+I`,onClick:()=>e(`toggleItalic`)}),(0,N.jsx)(WM,{icon:(0,N.jsx)(i,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.strikethrough`),onClick:()=>e(`toggleStrikethrough`)}),(0,N.jsx)(WM,{icon:(0,N.jsx)(ke,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.inlineCode`),onClick:()=>e(`toggleInlineCode`)}),(0,N.jsx)(Ri,{orientation:`vertical`,className:`mx-1 h-6`}),(0,N.jsx)(WM,{icon:(0,N.jsx)(g,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.heading1`),onClick:()=>e(`heading1`)}),(0,N.jsx)(WM,{icon:(0,N.jsx)(m,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.heading2`),onClick:()=>e(`heading2`)}),(0,N.jsx)(WM,{icon:(0,N.jsx)(fe,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.heading3`),onClick:()=>e(`heading3`)}),(0,N.jsx)(Ri,{orientation:`vertical`,className:`mx-1 h-6`}),(0,N.jsx)(WM,{icon:(0,N.jsx)(Te,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.bulletList`),onClick:()=>e(`bulletList`)}),(0,N.jsx)(WM,{icon:(0,N.jsx)(he,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.numberedList`),onClick:()=>e(`orderedList`)}),(0,N.jsx)(WM,{icon:(0,N.jsx)(re,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.blockquote`),onClick:()=>e(`blockquote`)}),(0,N.jsx)(Ri,{orientation:`vertical`,className:`mx-1 h-6`}),(0,N.jsx)(WM,{icon:(0,N.jsx)(le,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.insertLink`),onClick:()=>e(`link`)}),t&&(0,N.jsx)(WM,{icon:(0,N.jsx)(Ae,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.insertImage`),onClick:t}),(0,N.jsx)(WM,{icon:(0,N.jsx)(c,{className:`h-4 w-4`}),label:r(`mdEditor.toolbar.horizontalRule`),onClick:()=>e(`hr`)}),(0,N.jsx)(Ri,{orientation:`vertical`,className:`mx-1 h-6`}),(0,N.jsx)(UM,{})]})}function KM({value:e,onChange:t,onUploadImage:n,onImageButtonClick:r,placeholder:i,showToolbar:a=!0}){let o=(0,M.useRef)(e),s=(0,M.useRef)(null),c=(0,M.useRef)(e),l=(0,M.useRef)(n),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(``),m=(0,M.useRef)(null);(0,M.useEffect)(()=>{l.current=n},[n]);let{get:h}=HC(e=>LC.make().config(n=>{n.set(kC,e),n.set(hC,o.current),n.get(FM).markdownUpdated((e,n)=>{c.current=n,t(n)}),n.set(zM.key,{uploader:async(e,t)=>{let n=[];for(let t=0;t<e.length;t++){let r=e.item(t);r&&r.type.includes(`image`)&&n.push(r)}let r=[];for(let e of n)try{if(l.current){let n=await l.current(e);if(n){let i=t.nodes.image.createAndFill({src:n,alt:e.name});i&&r.push(i)}}else{let n=new FileReader,i=await new Promise(t=>{n.onload=()=>t(n.result),n.readAsDataURL(e)}),a=t.nodes.image.createAndFill({src:i,alt:e.name});a&&r.push(a)}}catch(e){console.error(`Failed to upload image:`,e)}return r.filter(e=>e!==null)},enableHtmlFileUploader:!0,uploadWidgetFactory:(e,t)=>{let n=document.createElement(`span`);return n.className=`milkdown-upload-placeholder`,Nx.widget(e,n,t)}})}).use(sE).use(vj).use(Yj).use($j).use(LM).use(VM));(0,M.useEffect)(()=>{s.current=h()??null},[h]),(0,M.useEffect)(()=>{let t=h();t&&e!==c.current&&(t.action(aw(e)),c.current=e)},[e,h]),(0,M.useEffect)(()=>{let e=h();if(e&&i)try{e.ctx.get(ES).dom.style.setProperty(`--ph`,`"${i.replace(/"/g,`\\"`)}"`)}catch{}},[h,i]),(0,M.useEffect)(()=>{let t=h();if(t)try{t.ctx.get(ES).dom.classList.toggle(`has-content`,e.trim().length>0)}catch{}},[h,e]);let g=(0,M.useCallback)(()=>{let e=h();if(e)try{let{state:t}=e.ctx.get(ES),{from:n,to:r}=t.selection,i=t.doc.textBetween(n,r);m.current={from:n,to:r},p(i),d(!0)}catch(e){console.error(`Failed to get selection:`,e)}},[h]),_=(0,M.useCallback)((e,t)=>{let n=h();if(n)try{let r=n.ctx.get(ES),{state:i,dispatch:a}=r,{schema:o}=i,s=o.marks.link.create({href:t}),c=o.text(e,[s]),l=i.tr;if(m.current){let{from:e,to:t}=m.current;l.replaceWith(e,t,c)}else{let{from:e}=i.selection;l.insert(e,c)}a(l),r.focus()}catch(e){console.error(`Failed to insert link:`,e)}},[h]),v=(0,M.useCallback)(e=>{let t=h();if(t)try{let n=t.ctx.get(ES);switch(e){case`toggleBold`:t.action(iw(Cw.key));break;case`toggleItalic`:t.action(iw(_w.key));break;case`toggleStrikethrough`:t.action(iw(bA.key));break;case`toggleInlineCode`:t.action(iw(Ow.key));break;case`heading1`:t.action(iw(Yw.key,1));break;case`heading2`:t.action(iw(Yw.key,2));break;case`heading3`:t.action(iw(Yw.key,3));break;case`bulletList`:t.action(iw(CT.key));break;case`orderedList`:t.action(iw(OT.key));break;case`blockquote`:t.action(iw(tT.key));break;case`link`:g();return;case`hr`:t.action(iw(yT.key));break;case`paragraph`:t.action(iw(Vw.key))}n.focus()}catch(e){console.error(`Command failed:`,e)}},[h,g]);return(0,N.jsxs)(N.Fragment,{children:[a&&(0,N.jsx)(GM,{onCommand:v,onImageUpload:r}),(0,N.jsx)(`div`,{className:`milkdown-content`,children:(0,N.jsx)(BC,{})}),(0,N.jsx)(HM,{open:u,onOpenChange:d,selectedText:f,onSubmit:_})]})}function qM({value:e,onChange:t,onUploadImage:n,onImageButtonClick:r,placeholder:i,className:a,showToolbar:o=!0}){return(0,N.jsx)(`div`,{className:O(`milkdown-editor`,a),children:(0,N.jsx)(VC,{children:(0,N.jsx)(KM,{value:e,onChange:t,onUploadImage:n,onImageButtonClick:r,placeholder:i,showToolbar:o})})})}function JM({value:e,onChange:t,onHydrated:n,className:r}){let{t:i}=A(),{user:a}=cn(),{statement:o,isLoading:s}=zi(a?.pubkey),[c,l]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{!c&&!s&&(t(o??``),n?.(o??``),l(!0))},[c,s,o,t,n]),s&&!c?(0,N.jsxs)(`div`,{className:O(`flex items-center gap-2 text-sm text-muted-foreground`,r),children:[(0,N.jsx)(ve,{className:`size-4 animate-spin`}),i(`verifier.loading`)]}):(0,N.jsx)(`div`,{className:O(`space-y-4`,r),children:(0,N.jsx)(`div`,{className:O(`rounded-lg border-2 border-transparent bg-muted/40 overflow-hidden transition-colors duration-150`,`hover:bg-muted/60 hover:border-border`,`focus-within:bg-transparent focus-within:border-primary`),children:(0,N.jsx)(qM,{className:`verifier-statement-editor`,value:e,onChange:t,placeholder:i(`verifier.placeholder`)})})})}var YM={idle:`menuOpen`,menuOpen:`verified`,verified:`idle`},XM={idle:2e3,menuOpen:2e3,verified:1200};function ZM(){let e=(0,M.useRef)(!1);return typeof window<`u`&&typeof window.matchMedia==`function`&&(e.current=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches),e.current}function QM({className:e,hideHeader:t=!1,bare:n=!1,stacked:r=!1,verifierName:i,verifierPicture:a,onLoopComplete:o}){let{t:s}=A(),c=ZM(),[l,u]=(0,M.useState)(`idle`);(0,M.useEffect)(()=>{let e=window.setTimeout(()=>{l===`verified`&&o?.(),u(e=>YM[e])},XM[l]);return()=>window.clearTimeout(e)},[l,o]);let d=l===`menuOpen`,f=l===`verified`;return(0,N.jsxs)(`section`,{className:O(!n&&`rounded-2xl border border-primary/20 bg-gradient-to-br from-primary/[0.07] via-background to-background p-6 sm:p-8 shadow-sm`,e),"aria-labelledby":`verify-tutorial-title`,children:[!t&&(0,N.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4 mb-8`,children:(0,N.jsxs)(`div`,{className:`max-w-md`,children:[(0,N.jsxs)(`p`,{className:`inline-flex items-center gap-1.5 text-xs font-semibold tracking-widest uppercase text-primary mb-2`,children:[(0,N.jsx)(ce,{className:`size-4`}),s(`organizations.tutorial.eyebrow`)]}),(0,N.jsx)(`h3`,{id:`verify-tutorial-title`,className:`text-xl sm:text-2xl font-bold tracking-tight mb-2`,children:s(`organizations.tutorial.title`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:s(`organizations.tutorial.lede`)})]})}),(0,N.jsx)(eN,{phase:l,menuVisible:d,verified:f,reducedMotion:c,fullWidth:r,verifierName:i,verifierPicture:a})]})}var $M={title:`Agora App Development Fund`,organizer:`Team Soapbox`,organizerPicture:`https://blossom.primal.net/e93f617f8331509acdddde3df0c1cd23cda1803d92c70815fc96e2d5f8d48ac8.png`,story:`Help fund the development of Agora!`,banner:`https://blossom.primal.net/aade02e86584a7ab269550992d0266bae31059a34e6e08fddba1f6f5acb6e7d6.jpg`,goalLabel:`$1,000`,raisedLabel:`$670`,pct:67};function eN({phase:e,menuVisible:t,verified:n,reducedMotion:r,fullWidth:i=!1,verifierName:a,verifierPicture:s}){let{t:c}=A(),l=oi(s),u=(a?.trim()||``).slice(0,2).toUpperCase()||`?`,d=oi($M.banner),f=oi($M.organizerPicture);return(0,N.jsxs)(`div`,{className:O(`relative w-full select-none`,i?`mx-0`:`mx-auto max-w-md`),"aria-hidden":`true`,children:[(0,N.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/60 bg-card shadow-md`,children:[(0,N.jsxs)(`div`,{className:`relative h-40 bg-gradient-to-br from-sky-500/80 via-cyan-500/70 to-emerald-500/80 bg-cover bg-center`,style:d?{backgroundImage:`url("${d}")`}:void 0,children:[(0,N.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-x-0 top-0 h-16 bg-gradient-to-b from-black/30 to-transparent`}),(0,N.jsxs)(`div`,{className:O(`absolute left-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-black/40 px-1.5 py-1 text-white backdrop-blur-md transition-all duration-500`,n?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1 pointer-events-none`),children:[(0,N.jsx)(`span`,{className:`flex items-center -space-x-2`,children:(0,N.jsxs)(ei,{className:`size-6 ring-2 ring-background`,children:[l&&(0,N.jsx)($r,{src:l,alt:``,className:`object-cover`}),(0,N.jsx)(Qr,{className:`bg-secondary text-[9px] text-secondary-foreground`,children:u})]})}),(0,N.jsx)(`span`,{className:`ml-0.5 inline-flex items-center gap-1 pr-1 text-xs font-semibold`,children:(0,N.jsx)(ce,{className:`size-4 text-sky-300`})})]}),(0,N.jsxs)(`div`,{className:`absolute right-3 top-3`,children:[(0,N.jsx)(`div`,{className:O(`flex size-8 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur transition-all duration-300`,e===`idle`&&!r&&`motion-safe:animate-pulse ring-2 ring-primary/60`,t&&`bg-background text-foreground ring-2 ring-primary/50`),children:(0,N.jsx)(Ee,{className:`size-4`})}),(0,N.jsx)(`div`,{className:O(`absolute right-0 top-10 z-20 w-52 origin-top-right rounded-md border bg-popover p-1 text-popover-foreground shadow-lg transition-all duration-200`,t?`scale-100 opacity-100`:`pointer-events-none scale-95 opacity-0`),children:(0,N.jsxs)(`div`,{className:O(`flex items-center gap-2 rounded-sm px-2 py-2 text-sm font-medium transition-colors`,t?`bg-primary/10 text-primary`:`text-foreground`),children:[(0,N.jsx)(ce,{className:`size-4 shrink-0`}),c(`organizations.tutorial.demo.menuVerify`)]})})]})]}),(0,N.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`font-semibold leading-snug truncate`,children:$M.title}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:$M.story})]}),(0,N.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,N.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-foreground/15`,children:(0,N.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${$M.pct}%`}})}),(0,N.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,N.jsx)(`span`,{className:`font-semibold`,children:$M.raisedLabel}),(0,N.jsx)(`span`,{className:`text-muted-foreground`,children:c(`campaignsDetail.ofGoal`,{amount:$M.goalLabel})})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border/60 pt-3 text-xs text-muted-foreground`,children:[(0,N.jsxs)(ei,{className:`size-5`,children:[f&&(0,N.jsx)($r,{src:f,alt:``,className:`object-cover`}),(0,N.jsx)(Qr,{className:`bg-secondary text-[9px] text-secondary-foreground`,children:$M.organizer.slice(0,1).toUpperCase()})]}),(0,N.jsx)(`span`,{className:`truncate font-medium text-foreground/80`,children:$M.organizer})]})]})]}),!r&&(0,N.jsx)(`div`,{className:O(`pointer-events-none absolute z-30 transition-all duration-700 ease-out`,e===`idle`?`right-4 top-5`:`right-8 top-[4.5rem]`),children:(0,N.jsx)(o,{className:O(`size-6 fill-foreground text-background drop-shadow-md transition-transform`,`motion-safe:animate-tutorial-tap`)},e)})]})}function tN(){return{name:``,picture:``,banner:``,website:``,about:``}}function nN(e){if(!e)return{};try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return{}}function rN(e,t){let n=t.name.trim(),r=t.website.trim(),i=t.picture.trim(),a=t.banner.trim(),o=t.about.trim();return n&&(e.name=n,e.display_name=n),r&&(e.website=r),i&&(e.picture=i),a&&(e.banner=a),o&&(e.about=o),e}function iN(){let{nostr:e}=ct(),{user:t}=cn(),{mutateAsync:n}=pn(),r=xt();return Pt({mutationFn:async({draft:r,expectedPubkey:i})=>{if(!t)throw Error(`Not logged in`);if(i&&t.pubkey!==i)throw Error(`Active account does not match the new key`);let a=await fn(e,{kinds:[0],authors:[t.pubkey]}),o=rN(nN(a?.content),r);await n({kind:0,content:JSON.stringify(o),prev:a??void 0})},onSuccess:()=>{t&&(r.invalidateQueries({queryKey:[`author`,t.pubkey]}),r.invalidateQueries({queryKey:[`logins`]}))}})}var aN=bn(`SavePassword`,{web:()=>D(()=>import(`./web-BB2R3iQI.js`).then(e=>new e.SavePasswordWeb),__vite__mapDeps([5,4]))}),oN=vn;function sN(){return typeof window<`u`&&`PasswordCredential`in window}async function cN(e,t,n){if(Sn.isNativePlatform())try{return await aN.promptDialog({username:e,password:t,url:oN}),!0}catch{return!1}if(!sN())return!1;try{let r=new PasswordCredential({id:e,password:t,name:n??e});return await navigator.credentials.store(r),!0}catch{return!1}}async function lN(){if(Sn.isNativePlatform())try{let e=await aN.readPassword();return e.username&&e.password?{npub:e.username,nsec:e.password}:void 0}catch{return}if(sN())try{let e=await navigator.credentials.get({password:!0,mediation:`optional`});if(e&&`password`in e){let t=e;if(t.id&&t.password)return{npub:t.id,nsec:t.password}}return}catch{return}}function uN(e,t){return`${(t??location.hostname).toLowerCase().replaceAll(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`nostr`}-${e.slice(5,9)}.nsec.txt`}async function dN(e,t,n){return Sn.isNativePlatform()?await cN(e,t,n)?`saved`:Sn.getPlatform()===`android`?(await j(uN(e,n),t),`saved-to-file`):`dismissed`:(await j(uN(e,n),t),cN(e,t,n).catch(()=>{}),`saved`)}var fN=[`keygen`,`secure`,`verify`,`role`],pN=[`keygen`,`secure`,`verify`,`role`,`orgIdentity`,`orgBio`,`orgStatement`,`orgVerifyHowto`],mN=[`orgIdentity`,`orgBio`,`orgStatement`,`orgVerifyHowto`];function hN({children:e}){let{active:t}=Zn();return(0,N.jsxs)(N.Fragment,{children:[e,t&&(0,N.jsx)(gN,{})]})}function gN(){let{t:e}=A(),{cancel:t,role:n,setRole:r}=Zn(),i=br(),{toast:a}=un(),o=Yr(),{user:s}=cn(),c=(0,M.useMemo)(()=>s?`role`:`keygen`,[s]),[l,u]=(0,M.useState)(c),[d,f]=(0,M.useState)(``),[p,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(tN),y=(0,M.useCallback)(e=>v(t=>({...t,...e})),[]),b=(0,M.useMemo)(()=>{if(d)try{let e=Mt.decode(d);return e.type===`nsec`?At(e.data):void 0}catch{return}},[d]),{mutateAsync:x,isPending:S}=iN(),C=n===`verifier`||mN.includes(l)?pN:fN,ee=C.indexOf(l),te=ee<0?0:(ee+1)/C.length*100,w=(0,M.useCallback)(e=>{u(e)},[]),ne=!(l===`keygen`&&p),re=(0,M.useCallback)(()=>{if(l===`keygen`)t();else if(l===`secure`)w(`keygen`);else if(l===`verify`)w(`secure`);else if(mN.includes(l)){let e=mN.indexOf(l);w(e<=0?`role`:mN[e-1])}else s?t():w(`verify`)},[l,s,t,w]),ie=(0,M.useCallback)(()=>{let e=mN.indexOf(l);e<0?w(mN[0]):e<mN.length-1&&w(mN[e+1])},[l,w]),ae=(0,M.useCallback)(e=>{if(r(e),e===`verifier`){w(`orgIdentity`);return}t(),i(e===`creator`?`/campaigns/new`:`/campaigns`)},[r,t,i,w]),oe=(0,M.useCallback)(()=>{t(),i(`/campaigns`)},[t,i]),se=(0,M.useCallback)(async()=>{try{await x({draft:_,expectedPubkey:b})}catch{a({title:e(`onboarding.verifier.publishFailedTitle`),description:e(`onboarding.verifier.publishFailedDescription`),variant:`destructive`})}ie()},[x,_,b,a,e,ie]),ce=(0,M.useCallback)(()=>{m(!0),setTimeout(()=>{let e=Dt();f(Mt.nsecEncode(e)),m(!1),w(`secure`)},700)},[w]),T=(0,M.useCallback)(async()=>{try{let e=Mt.decode(d);if(e.type!==`nsec`)throw Error(`Invalid nsec`);let t=At(e.data);await dN(Mt.npubEncode(t),d,`Agora`),w(`verify`)}catch{a({title:e(`onboarding.secure.downloadFailedTitle`),description:e(`onboarding.secure.downloadFailedDescription`),variant:`destructive`})}},[d,w,a,e]),E=(0,M.useCallback)(()=>{o.nsec(d),w(`role`)},[o,d,w]),le=(()=>{switch(l){case`keygen`:return(0,N.jsx)(xN,{isGenerating:p,onGenerate:ce});case`secure`:return(0,N.jsx)(SN,{nsec:d,showKey:h,onToggleShow:()=>g(e=>!e),onContinue:T});case`verify`:return(0,N.jsx)(wN,{expectedNsec:d,onVerified:E});case`role`:return(0,N.jsx)(_N,{role:n,onPick:ae});case`orgIdentity`:return(0,N.jsx)(xd,{draft:_,onChange:y,onContinue:ie});case`orgBio`:return(0,N.jsx)(wd,{draft:_,onChange:y,onContinue:se,isPublishing:S});case`orgStatement`:return(0,N.jsx)(yN,{onContinue:ie});case`orgVerifyHowto`:return(0,N.jsx)(vN,{draft:_,onFinish:oe})}})();return(0,N.jsxs)(`div`,{className:`safe-area-top fixed inset-0 z-50 bg-background overflow-y-auto flex flex-col`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`onboarding.ariaLabel`),children:[(0,N.jsx)(`div`,{className:`sticky top-0 z-10 h-1 bg-muted`,children:(0,N.jsx)(`div`,{className:`h-full bg-primary transition-all duration-500 ease-out`,style:{width:`${te}%`}})}),ne&&(0,N.jsx)(`button`,{type:`button`,onClick:re,"aria-label":e(`common.back`),className:`absolute left-4 top-4 z-20 sm:left-6 sm:top-6 inline-flex h-9 w-9 items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,children:(0,N.jsx)(we,{className:`h-5 w-5 rtl:rotate-180`})}),(0,N.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e(`onboarding.close`),className:`absolute right-4 top-4 z-20 sm:right-6 sm:top-6 inline-flex h-9 w-9 items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,children:(0,N.jsx)(ge,{className:`h-5 w-5`})}),(0,N.jsx)(`div`,{className:`flex-1 flex items-start sm:items-center justify-center px-6 pt-16 pb-12`,children:(0,N.jsx)(`div`,{className:O(`w-full mx-auto animate-in fade-in slide-in-from-bottom-2 duration-300`,l===`orgBio`||l===`orgStatement`||l===`orgVerifyHowto`?`max-w-xl`:`max-w-md`),children:le},l)})]})}function _N({role:e,onPick:t}){let{t:n}=A();return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,N.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:n(`onboarding.role.title`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`onboarding.role.subtitle`)})]}),(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsx)(bN,{icon:(0,N.jsx)(r,{className:`h-5 w-5 md:h-6 md:w-6 text-primary`}),title:n(`onboarding.role.creator.title`),description:n(`onboarding.role.creator.description`),finderNote:n(`onboarding.role.creator.finderNote`),selected:e===`creator`,onClick:()=>t(`creator`)}),(0,N.jsx)(bN,{icon:(0,N.jsx)(p,{className:`h-5 w-5 md:h-6 md:w-6 text-primary`}),title:n(`onboarding.role.donor.title`),description:n(`onboarding.role.donor.description`),finderNote:n(`onboarding.role.donor.finderNote`),selected:e===`donor`,onClick:()=>t(`donor`)}),(0,N.jsx)(bN,{icon:(0,N.jsx)(ce,{className:`h-5 w-5 md:h-6 md:w-6 text-primary`}),title:n(`onboarding.role.verifier.title`),description:n(`onboarding.role.verifier.description`),finderNote:n(`onboarding.role.verifier.finderNote`),selected:e===`verifier`,onClick:()=>t(`verifier`)})]})]})}function vN({draft:e,onFinish:t}){let{t:n}=A(),[r,i]=(0,M.useState)(!1),a=(0,M.useCallback)(()=>i(!0),[]);return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,N.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:n(`onboarding.verifier.howto.title`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`onboarding.verifier.howto.subtitle`)})]}),(0,N.jsx)(QM,{hideHeader:!0,bare:!0,stacked:!0,verifierName:e.name,verifierPicture:e.picture,onLoopComplete:a}),(0,N.jsxs)(Pr,{onClick:t,disabled:!r,className:`w-full h-12 text-base rounded-full`,children:[n(`onboarding.verifier.howto.finish`),(0,N.jsx)(_e,{className:`ml-2 h-4 w-4 rtl:rotate-180`})]})]})}function yN({onContinue:e}){let{t}=A(),{toast:n}=un(),{mutateAsync:r,isPending:i}=Bi(),[a,o]=(0,M.useState)(``),s=a.trim(),c=(0,M.useCallback)(async()=>{try{await r(s),e()}catch(e){n({title:t(`verifier.errorToast`),description:e instanceof Error?e.message:String(e),variant:`destructive`})}},[r,s,n,t,e]);return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,N.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:t(`onboarding.verifier.statement.title`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`onboarding.verifier.statement.subtitle`)})]}),(0,N.jsx)(JM,{value:a,onChange:o}),(0,N.jsxs)(Pr,{onClick:c,disabled:!s||i,className:`w-full h-12 text-base rounded-full`,children:[i?(0,N.jsx)(ve,{className:`mr-2 h-4 w-4 animate-spin`}):null,t(`common.continue`),!i&&(0,N.jsx)(_e,{className:`ml-2 h-4 w-4 rtl:rotate-180`})]})]})}function bN({icon:e,title:t,description:n,finderNote:r,selected:i,onClick:a}){return(0,N.jsx)(`button`,{type:`button`,onClick:a,className:O(`w-full text-left rounded-xl border bg-card p-5 md:p-6 transition-all`,`hover:border-primary/50 hover:shadow-md`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2`,i&&`border-primary shadow-md ring-1 ring-primary`),children:(0,N.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,N.jsx)(`div`,{className:`flex-shrink-0 w-10 h-10 md:w-12 md:h-12 rounded-full bg-primary/10 flex items-center justify-center`,children:e}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsx)(`h3`,{className:`text-sm md:text-base font-semibold text-foreground`,children:t}),(0,N.jsx)(`p`,{className:`text-xs md:text-sm text-muted-foreground mt-0.5`,children:n}),(0,N.jsx)(`p`,{className:`text-xs md:text-sm font-medium text-primary mt-1.5`,children:r})]}),(0,N.jsx)(_e,{className:`h-4 w-4 md:h-5 md:w-5 text-muted-foreground flex-shrink-0 mt-1 rtl:rotate-180`})]})})}function xN({isGenerating:e,onGenerate:t}){let{t:n}=A();return(0,N.jsxs)(`div`,{className:`space-y-6 text-center`,children:[(0,N.jsx)(`div`,{className:`relative w-24 h-24 mx-auto`,children:e?(0,N.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,N.jsx)(ve,{className:`w-14 h-14 text-primary animate-spin`})}):(0,N.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,N.jsx)(Qn,{className:`size-20 drop-shadow-md`})})}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:n(e?`onboarding.keygen.generatingTitle`:`onboarding.keygen.title`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(e?`onboarding.keygen.generatingDescription`:`onboarding.keygen.description`)})]}),!e&&(0,N.jsx)(Pr,{onClick:t,className:`w-full h-12 text-base rounded-full`,children:n(`onboarding.keygen.button`)})]})}function SN({nsec:e,showKey:t,onToggleShow:n,onContinue:r}){let{t:i}=A();return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,N.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:i(`onboarding.secure.title`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`onboarding.secure.subtitle`)})]}),(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(Fr,{type:t?`text`:`password`,value:e,readOnly:!0,className:`pr-10 font-mono text-sm`,"aria-label":i(`onboarding.secure.secretKeyAriaLabel`)}),(0,N.jsx)(Pr,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-full px-3 hover:bg-transparent`,onClick:n,children:t?(0,N.jsx)(de,{className:`h-4 w-4 text-muted-foreground`}):(0,N.jsx)(Ce,{className:`h-4 w-4 text-muted-foreground`})})]}),(0,N.jsxs)(`div`,{className:`rounded-xl bg-primary/10 border-2 border-primary/30 p-5 space-y-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,N.jsx)(`div`,{className:`w-14 h-14 rounded-full bg-background ring-2 ring-primary/30 flex items-center justify-center shadow-sm`,children:(0,N.jsx)(Me,{className:`h-7 w-7 text-primary`})}),(0,N.jsx)(`div`,{className:`w-7 h-7 rounded-full bg-primary text-primary-foreground flex items-center justify-center shadow`,children:(0,N.jsx)(xe,{className:`h-4 w-4`})}),(0,N.jsx)(`div`,{className:`w-14 h-14 rounded-full bg-background ring-2 ring-primary/30 flex items-center justify-center shadow-sm`,children:(0,N.jsx)(w,{className:`h-7 w-7 text-primary`})})]}),(0,N.jsx)(`p`,{className:`text-sm text-foreground text-center leading-relaxed`,children:i(`onboarding.secure.couplingNote`)}),(0,N.jsxs)(`div`,{className:`border-t border-primary/20 pt-3 text-center`,children:[(0,N.jsx)(`p`,{className:`text-base font-bold tracking-tight text-foreground leading-snug`,children:i(`onboarding.secure.permanenceHeadline`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5 leading-relaxed`,children:i(`onboarding.secure.permanenceBody`)})]})]}),(0,N.jsxs)(Pr,{onClick:r,className:`w-full h-12 text-base rounded-full`,children:[(0,N.jsx)(oe,{className:`w-4 h-4 mr-2`}),i(`onboarding.secure.button`)]})]})}var CN=/^nsec1[a-z0-9]{58}$/;function wN({expectedNsec:e,onVerified:t}){let{t:n}=A(),[r,i]=(0,M.useState)(``),[a,o]=(0,M.useState)(null),s=(0,M.useRef)(null),c=(0,M.useRef)(!1),l=(0,M.useCallback)(()=>{c.current||(c.current=!0,t())},[t]),u=r.trim()===e;(0,M.useEffect)(()=>{u&&l()},[u,l]),(0,M.useEffect)(()=>{let t=!1;return lN().then(n=>{t||!n||n.nsec===e&&(i(n.nsec),o(null))}),()=>{t=!0}},[e]);let d=(0,M.useCallback)(e=>{i(e),o(null)},[]),f=(0,M.useCallback)(t=>{let r=t.target.files?.[0];if(t.target.value=``,!r)return;let i=new FileReader;i.onload=t=>{let r=(t.target?.result)?.trim()??``;if(!CN.test(r)){o(n(`onboarding.verify.fileInvalid`));return}r===e?l():o(n(`onboarding.verify.mismatch`))},i.onerror=()=>o(n(`onboarding.verify.fileReadFailed`)),i.readAsText(r)},[e,l,n]);return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,N.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:n(`onboarding.verify.title`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`onboarding.verify.subtitle`)})]}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(Fr,{type:`text`,value:r,onChange:e=>d(e.target.value),placeholder:n(`onboarding.verify.placeholder`),autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"aria-invalid":!!a,"aria-label":n(`onboarding.verify.inputAriaLabel`),className:`font-mono text-sm`,"data-nsec-allowed":!0}),a&&(0,N.jsx)(`p`,{className:`text-xs text-destructive`,role:`alert`,children:a})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,N.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,N.jsx)(`span`,{children:n(`onboarding.verify.or`)}),(0,N.jsx)(`div`,{className:`h-px flex-1 bg-border`})]}),(0,N.jsxs)(Pr,{type:`button`,variant:`outline`,onClick:()=>s.current?.click(),className:`w-full h-11 rounded-full`,children:[(0,N.jsx)(v,{className:`w-4 h-4 mr-2`}),n(`onboarding.verify.uploadButton`)]}),(0,N.jsx)(`input`,{ref:s,type:`file`,accept:`.txt,text/plain`,className:`hidden`,onChange:f})]})}function TN(){let{pathname:e}=vr(),t=Tr();return(0,M.useEffect)(()=>{t===`PUSH`&&window.scrollTo(0,0)},[e,t]),null}function EN(e){return e.replace(/ -- /g,` — `).replace(/(\w)--(\w)/g,`$1–$2`).replace(/ (\S+)$/,`\xA0$1`)}function DN(e){let t=[],n=null,r=null,i=[],a=()=>{n&&i.length&&(n.summary=i.join(` `)),i=[]};for(let o of e.split(` `)){let e=o.match(/^## \[([^\]]+)\]\s*-\s*(.+)$/);if(e){a(),n={version:e[1],date:e[2].trim(),sections:[]},t.push(n),r=null;continue}let s=o.match(/^### (.+)$/);if(s&&n){a(),r=s[1].trim(),n.sections.push({category:r,items:[]});continue}let c=o.match(/^- (.+)$/);if(c&&n){let e=n.sections[n.sections.length-1];e?e.items.push(EN(c[1])):(a(),n.sections.push({category:`Changed`,items:[EN(c[1])]}));continue}let l=o.trim();if(l&&n&&!l.startsWith(`#`)){let e=n.sections[n.sections.length-1];e?e.items.push(EN(l)):i.push(l)}}return a(),t}var ON=60;function kN(e,t){if(e.length<=t)return e;let n=e.slice(0,t).trimEnd(),r=n.lastIndexOf(` `);return(r>t*.6?n.slice(0,r).trimEnd():n)+`…`}async function AN(e){try{let t=await fetch(`/CHANGELOG.md`);if(!t.ok)return;let n=DN(await t.text()),r=n.find(t=>t.version===e)??n[0];if(!r)return;if(r.summary)return kN(r.summary,ON);let i=r.sections[0]?.items[0];return i?kN(i,ON):void 0}catch{return}}function jN(){let{config:e}=Zt();return(0,M.useEffect)(()=>{let t=`2.11.1`,n=sn(e.appId,`app-version`),r=localStorage.getItem(n);if(localStorage.setItem(n,t),r&&r!==t){let{update:e,id:n}=dn({title:`What's new in v${t}`,action:(0,N.jsx)(Au,{altText:`View changelog`,asChild:!0,children:(0,N.jsx)(xr,{to:`/changelog`,children:`See all`})})});AN(t).then(r=>{r&&e({id:n,title:`What's new in v${t}`,description:r,action:(0,N.jsx)(Au,{altText:`View changelog`,asChild:!0,children:(0,N.jsx)(xr,{to:`/changelog`,children:`See all`})})})})}},[e.appId]),null}var MN=`audio-minibar-position`,NN=4;function PN(){try{let e=localStorage.getItem(MN);if(e)return JSON.parse(e)}catch{}return null}function FN(){return window.matchMedia(`(min-width: 900px)`).matches?0:56}function IN(e,t,n,r){let i=window.innerWidth-n,a=window.innerHeight-r-FN();return{x:Math.max(0,Math.min(e,i)),y:Math.max(0,Math.min(t,a))}}function LN(){let e=Vn(),{currentTrack:t,minimized:r,isPlaying:i,currentTime:a,duration:o,playlist:s,currentIndex:c}=e,l=br(),u=(0,M.useRef)(null),[d,f]=(0,M.useState)(()=>{let e=PN(),t={x:16,y:window.innerHeight-80-FN()};return e?IN(e.x,e.y,300,64):t}),p=(0,M.useRef)(!1),m=(0,M.useRef)(!1),h=(0,M.useRef)({x:0,y:0}),g=(0,M.useRef)({x:0,y:0});(0,M.useEffect)(()=>{let e=()=>{f(e=>{let t=u.current,n=t?.offsetWidth??300,r=t?.offsetHeight??64;return IN(e.x,e.y,n,r)})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,M.useEffect)(()=>{try{localStorage.setItem(MN,JSON.stringify(d))}catch{}},[d]);let _=(0,M.useCallback)(e=>{e.target.closest(`[data-drag-handle]`)&&(e.preventDefault(),e.target.setPointerCapture(e.pointerId),p.current=!0,m.current=!1,h.current={x:e.clientX,y:e.clientY},g.current={...d})},[d]),v=(0,M.useCallback)(e=>{if(!p.current)return;let t=e.clientX-h.current.x,n=e.clientY-h.current.y;if(!m.current&&Math.abs(t)+Math.abs(n)<NN)return;m.current=!0;let r=u.current,i=r?.offsetWidth??300,a=r?.offsetHeight??64;f(IN(g.current.x+t,g.current.y+n,i,a))},[]),y=(0,M.useCallback)(e=>{p.current&&=(e.target.releasePointerCapture(e.pointerId),!1)},[]);if(!t||!r)return null;let b=o>0?a/o*100:0,x=s.length>1,C=x&&(c>0||a>3),ee=x&&c<s.length-1;return(0,N.jsxs)(`div`,{ref:u,className:`fixed z-30 select-none touch-none sidebar:block hidden`,style:{left:d.x,top:d.y},onPointerDown:_,onPointerMove:v,onPointerUp:y,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 rounded-2xl bg-background/95 backdrop-blur-md border border-border shadow-lg px-2 py-1.5 min-w-[280px] max-w-[360px]`,children:[(0,N.jsx)(`div`,{"data-drag-handle":!0,className:`cursor-grab active:cursor-grabbing shrink-0 p-1 -ml-0.5 text-muted-foreground/50 hover:text-muted-foreground`,children:(0,N.jsx)(S,{className:`size-4`})}),t.artwork?(0,N.jsx)(`img`,{src:t.artwork,alt:``,className:`size-10 rounded-lg object-cover shrink-0`}):(0,N.jsx)(`div`,{className:`size-10 rounded-lg bg-primary/15 flex items-center justify-center shrink-0`,children:(0,N.jsx)(je,{className:`size-4 text-primary`})}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0 px-1`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium truncate leading-tight`,children:t.title}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:t.artist})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[x&&(0,N.jsx)(`button`,{onClick:()=>e.prevTrack(),disabled:!C,className:`p-1.5 rounded-full hover:bg-secondary transition-colors disabled:opacity-30`,"aria-label":`Previous`,children:(0,N.jsx)(E,{className:`size-3.5`})}),(0,N.jsx)(`button`,{onClick:()=>i?e.pause():e.resume(),className:`p-1.5 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,"aria-label":i?`Pause`:`Play`,children:i?(0,N.jsx)(pe,{className:`size-3.5`,fill:`currentColor`}):(0,N.jsx)(je,{className:`size-3.5 ml-0.5`,fill:`currentColor`})}),x&&(0,N.jsx)(`button`,{onClick:()=>e.nextTrack(),disabled:!ee,className:`p-1.5 rounded-full hover:bg-secondary transition-colors disabled:opacity-30`,"aria-label":`Next`,children:(0,N.jsx)(n,{className:`size-3.5`})}),(0,N.jsx)(`button`,{onClick:()=>{e.expand(),t.path&&l(t.path)},className:`p-1.5 rounded-full hover:bg-secondary transition-colors`,"aria-label":`Expand`,children:(0,N.jsx)(T,{className:`size-3.5`})}),(0,N.jsx)(`button`,{onClick:()=>e.stop(),className:`p-1.5 rounded-full hover:bg-secondary transition-colors`,"aria-label":`Close`,children:(0,N.jsx)(ge,{className:`size-3.5`})})]})]}),(0,N.jsx)(`div`,{className:`mx-3 h-0.5 rounded-full bg-border overflow-hidden -mt-0.5`,children:(0,N.jsx)(`div`,{className:O(`h-full bg-primary transition-[width] duration-200`),style:{width:`${b}%`}})})]})}function RN(){let{currentTrack:e,minimized:t,minimize:n}=Vn(),r=vr(),i=(0,M.useRef)(r.pathname);return(0,M.useEffect)(()=>{r.pathname!==i.current&&(e&&!t&&n(),i.current=r.pathname)},[r.pathname,e,t,n]),null}function zN(){let{config:e}=Zt(),{supported:t,status:n,bootstrapPercent:r,error:i}=Wo(),{t:a}=A();if(!t||!e.torEnabled||n===`connected`)return null;let o=n===`failed`;return(0,N.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`fixed inset-x-0 bottom-0 z-50 safe-area-bottom border-t px-4 py-2 ${o?`border-destructive bg-destructive text-destructive-foreground`:`border-amber-600 bg-amber-500 text-black`}`,children:(0,N.jsxs)(`div`,{className:`mx-auto flex max-w-3xl items-center gap-3 text-xs`,children:[o?(0,N.jsx)(ye,{className:`size-4 shrink-0`}):(0,N.jsx)(ve,{className:`size-4 shrink-0 animate-spin`}),(0,N.jsx)(`span`,{className:`flex-1 leading-snug`,children:o?i||a(`tor.banner.failed`):a(`tor.banner.connecting`)+(r>0?` (${r}%)`:``)}),o&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>Vo(),className:`shrink-0 font-semibold underline underline-offset-2`,children:a(`tor.banner.retry`)})]})})}function BN(){let e=br();return(0,M.useEffect)(()=>{if(!Sn.isNativePlatform())return;let t;async function n(){let{App:n}=await D(async()=>{let{App:e}=await import(`./esm-JCo1H0uQ.js`);return{App:e}},__vite__mapDeps([6,7,4])),r=await n.addListener(`appUrlOpen`,t=>{let n=t.url?.trim();if(n)try{let t=new URL(n);if(t.protocol!==`https:`||t.pathname.startsWith(`//`))return;let r=t.pathname+t.search+t.hash;r&&e(r)}catch{}});t=()=>r.remove()}return n(),()=>{t?.()}},[e]),null}var VN=bn(`DittoNotification`);function HN(e){return/^\/(?!\/)[A-Za-z0-9\-._~!$&'()*+,;=:@%/?#[\]]*$/.test(e)}function UN(){let e=br();return(0,M.useEffect)(()=>{if(!Sn.isNativePlatform())return;let t=[],n=!1;async function r(){let r=await VN.addListener(`notificationTap`,({path:t})=>{!t||!HN(t)||e(t)});if(n){r.remove();return}t.push(r)}return r(),()=>{n=!0;for(let e of t)e.remove()}},[e]),null}var WN=new Map,GN=new WeakMap,KN=0,qN=void 0;function JN(e){return e?GN.has(e)?GN.get(e):(KN+=1,GN.set(e,KN.toString()),GN.get(e)):`0`}function YN(e){return Object.keys(e).sort().filter(t=>e[t]!==void 0).map(t=>`${t}_${t===`root`?JN(e.root):e[t]}`).toString()}function XN(e){let t=YN(e),n=WN.get(t);if(!n){let r=new Map,i,a=new IntersectionObserver(t=>{t.forEach(t=>{var n;let a=t.isIntersecting&&i.some(e=>t.intersectionRatio>=e);e.trackVisibility&&t.isVisible===void 0&&(t.isVisible=a),(n=r.get(t.target))==null||n.forEach(e=>{e(a,t)})})},e);i=a.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:a,elements:r},WN.set(t,n)}return n}function ZN(e,t,n={},r=qN){if(window.IntersectionObserver===void 0&&r!==void 0){let i=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:typeof n.threshold==`number`?n.threshold:0,time:0,boundingClientRect:i,intersectionRect:i,rootBounds:i}),()=>{}}let{id:i,observer:a,elements:o}=XN(n),s=o.get(e)||[];return o.has(e)||o.set(e,s),s.push(t),a.observe(e),function(){s.splice(s.indexOf(t),1),s.length===0&&(o.delete(e),a.unobserve(e)),o.size===0&&(a.disconnect(),WN.delete(i))}}M.Component;function QN({threshold:e,delay:t,trackVisibility:n,rootMargin:r,root:i,triggerOnce:a,skip:o,initialInView:s,fallbackInView:c,onChange:l}={}){let[u,d]=M.useState(null),f=M.useRef(l),[p,m]=M.useState({inView:!!s,entry:void 0});f.current=l,M.useEffect(()=>{if(o||!u)return;let s;return s=ZN(u,(e,t)=>{m({inView:e,entry:t}),f.current&&f.current(e,t),t.isIntersecting&&a&&s&&(s(),s=void 0)},{root:i,rootMargin:r,threshold:e,trackVisibility:n,delay:t},c),()=>{s&&s()}},[Array.isArray(e)?e.toString():e,u,i,r,a,o,n,c,t]);let h=p.entry?.target,g=M.useRef(void 0);!u&&h&&!a&&!o&&g.current!==h&&(g.current=h,m({inView:!!s,entry:void 0}));let _=[d,p.inView,p.entry];return _.ref=_[0],_.inView=_[1],_.entry=_[2],_}function $N(e){let t=xt(),n=(0,M.useRef)(e);return n.current=e,(0,M.useCallback)(async()=>{let e=n.current,r=Array.isArray(e[0])?e:[e];await Promise.all(r.map(e=>t.invalidateQueries({queryKey:e})))},[t])}function eP({onJoinClick:e}){return(0,N.jsxs)(`div`,{className:`landing-hero`,children:[(0,N.jsxs)(`div`,{className:`px-4 pt-8 pb-6 text-center space-y-4`,children:[(0,N.jsx)(`div`,{className:`flex justify-center landing-hero-fade`,style:{animationDelay:`0ms`},children:(0,N.jsx)(Qn,{className:`size-16 drop-shadow-md`})}),(0,N.jsxs)(`div`,{className:`space-y-1 landing-hero-fade`,style:{animationDelay:`80ms`},children:[(0,N.jsx)(`h1`,{className:`text-2xl sidebar:text-3xl font-black tracking-tight leading-none`,children:`ÁGORA`}),(0,N.jsx)(`p`,{className:`text-[11px] sidebar:text-xs uppercase tracking-wider text-muted-foreground font-semibold`,children:`Give Without Borders`})]}),(0,N.jsxs)(`div`,{className:`flex gap-3 justify-center landing-hero-fade`,style:{animationDelay:`160ms`},children:[(0,N.jsx)(Pr,{onClick:e,className:`rounded-full px-6`,size:`sm`,children:`Join`}),(0,N.jsx)(Pr,{variant:`outline`,className:`rounded-full px-6`,size:`sm`,asChild:!0,children:(0,N.jsx)(xr,{to:`/about#faq`,children:`FAQ`})})]})]}),(0,N.jsx)(`div`,{className:`border-b border-border`})]})}var tP=80,nP=120,rP=.45;function iP({onRefresh:e,children:t,className:n}){let[r,i]=(0,M.useState)(0),[a,o]=(0,M.useState)(!1),s=(0,M.useRef)(0),c=(0,M.useRef)(!1),l=(0,M.useRef)(!1),u=(0,M.useRef)(0),d=(0,M.useRef)(null),f=(0,M.useRef)(e);f.current=e,(0,M.useEffect)(()=>{let e=document.documentElement.style.overscrollBehaviorY;return document.documentElement.style.overscrollBehaviorY=`contain`,()=>{document.documentElement.style.overscrollBehaviorY=e}},[]),(0,M.useEffect)(()=>{let e=d.current;if(!e)return;let t=()=>window.scrollY<=0;function n(e){l.current||!t()||(s.current=e.touches[0].clientY,c.current=!1)}function r(e){if(l.current)return;let n=e.touches[0].clientY-s.current;if(n>0&&t()){e.preventDefault(),c.current=!0;let t=Math.min(n*rP,nP);u.current=t,i(t)}else c.current&&(c.current=!1,u.current=0,i(0))}async function a(){if(l.current||!c.current){c.current=!1,u.current=0,i(0);return}if(c.current=!1,u.current>=tP*rP){Hi(),l.current=!0,u.current=40,i(40),o(!0);try{await f.current()}finally{l.current=!1,o(!1),u.current=0,i(0)}}else u.current=0,i(0)}return e.addEventListener(`touchstart`,n,{passive:!0}),e.addEventListener(`touchmove`,r,{passive:!1}),e.addEventListener(`touchend`,a,{passive:!0}),()=>{e.removeEventListener(`touchstart`,n),e.removeEventListener(`touchmove`,r),e.removeEventListener(`touchend`,a)}},[]);let p=Math.min(r/(tP*rP),1);return(0,N.jsxs)(`div`,{ref:d,className:n,children:[(0,N.jsx)(`div`,{className:`flex items-center justify-center overflow-hidden sidebar:hidden`,style:{height:r>4||a?`${r}px`:`0px`,transition:c.current?`none`:`height 150ms ease-out`},children:(0,N.jsx)(`div`,{className:`flex items-center justify-center size-8 rounded-full bg-secondary/80 border border-border shadow-sm`,style:{opacity:p,transform:a?`scale(1)`:`scale(${.5+p*.5}) rotate(${p*360}deg)`,transition:`transform 150ms ease-out`},children:(0,N.jsx)(ve,{className:O(`size-4 text-primary`,a&&`animate-spin`)})})}),t]})}function aP({message:e,onSwitchToGlobal:t,showDiscover:n,className:r}){let{t:i}=A(),{config:a}=Zt();return(0,N.jsxs)(`div`,{className:O(`py-20 px-8 flex flex-col items-center text-center`,r),children:[(0,N.jsx)(`div`,{className:`size-12 rounded-full bg-muted flex items-center justify-center mb-4`,children:(0,N.jsx)(ne,{className:`size-6 text-muted-foreground`})}),(0,N.jsx)(`p`,{className:`text-muted-foreground max-w-xs`,children:e}),(n||t)&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-2 mt-5 w-full max-w-xs`,children:[n&&(0,N.jsx)(Pr,{asChild:!0,className:`rounded-full`,children:(0,N.jsx)(xr,{to:`/packs`,onClick:()=>{try{sessionStorage.setItem(sn(a.appId,`feed-tab:packs`),`global`)}catch{}},children:i(`feed.empty.discoverPeople`)})}),t&&(0,N.jsx)(Pr,{variant:`ghost`,className:`rounded-full`,onClick:t,children:i(`feed.empty.browseGlobal`)})]})]})}var oP=[{mode:`agora`,i18nKey:`agora`},{mode:`all-nostr`,i18nKey:`allNostr`},{mode:`following`,i18nKey:`following`}];function sP({mode:e,className:t}){return e===`agora`?(0,N.jsx)(Pe,{className:O(`shrink-0`,t),"aria-hidden":!0}):(0,N.jsx)(e===`following`?ne:a,{className:O(`shrink-0`,t),"aria-hidden":!0})}function cP({value:e,onChange:t,followingAvailable:n,onLoginRequested:r,className:i}){let{t:a}=A(),o=oP.find(t=>t.mode===e)??oP[0],c=a(`feed.modeSwitcher.${o.i18nKey}`);return(0,N.jsxs)(Jr,{children:[(0,N.jsxs)(Wr,{className:O(`group inline-flex items-center gap-2 rounded-lg -ml-1 px-1 py-1 outline-none`,`text-foreground hover:text-foreground motion-safe:transition-colors`,`focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background`,i),"aria-label":a(`feed.modeSwitcher.ariaLabel`,{label:c}),children:[(0,N.jsx)(sP,{mode:o.mode,className:`size-6 text-primary sm:size-7`}),(0,N.jsx)(`span`,{className:O(`text-2xl sm:text-3xl font-bold tracking-tight leading-none text-primary`),children:c}),(0,N.jsx)(y,{className:`size-5 text-muted-foreground motion-safe:transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]}),(0,N.jsx)(Kr,{align:`start`,sideOffset:8,className:`w-56 p-1.5`,children:oP.map(i=>{let o=a(`feed.modeSwitcher.${i.i18nKey}`),c=i.mode===e,l=i.mode===`following`&&!n,u=(0,N.jsxs)(Ur,{onSelect:e=>{if(l){e.preventDefault(),r?.();return}t(i.mode)},className:O(`flex items-center gap-3 rounded-md px-3 py-2 cursor-pointer`,l&&`opacity-60 data-[disabled]:opacity-60`),"data-disabled":l||void 0,children:[(0,N.jsx)(sP,{mode:i.mode,className:O(`size-4`,c?`text-primary`:`text-muted-foreground`)}),(0,N.jsx)(`span`,{className:O(`flex-1 text-sm font-medium`,c&&`text-primary`),children:o}),c&&(0,N.jsx)(s,{className:`size-4 shrink-0 text-primary`,"aria-hidden":!0})]},i.mode);return l?(0,N.jsxs)(Pn,{children:[(0,N.jsx)(jn,{asChild:!0,children:u}),(0,N.jsx)(Mn,{side:`right`,children:a(`feed.modeSwitcher.loginRequired`)})]},i.mode):u})})]})}var lP=15;function uP(e,t){let{nostr:n}=ct(),r=xt(),{user:i}=cn(),{data:a}=Cn(),o=a?.pubkeys,{feedSettings:s}=ni(),c=t?.kinds??Rn(s),l=t?.tagFilters,u=t?.authors,d=[...c].sort().join(`,`),f=u?[...u].sort().join(`,`):``,p=l?JSON.stringify(l):``,m=e===`follows`||e===`network`,h=u?u.length>0:!m||!!i&&o!==void 0,g=(()=>{if(e!==`communities`)return[];try{let e=localStorage.getItem(`ditto:communityData`);if(!e)return[];let t=JSON.parse(e);return t.names?Object.values(t.names).filter(e=>typeof e==`string`):[]}catch{return[]}})();return It({queryKey:[`feed`,e,i?.pubkey??``,d,f,p,g.length,s.followsFeedShowReplies],queryFn:async({pageParam:a})=>{let d=AbortSignal.timeout(8e3),f=Math.floor(Date.now()/1e3);function p(e){for(let{event:t}of e)r.getQueryData([`event`,t.id])||r.setQueryData([`event`,t.id],t)}if(e===`communities`&&g.length>0){let e=s.followsFeedShowReplies?lP:45,t={kinds:c,authors:g,limit:e,...l};a&&(t.until=a);let i=await n.query([t],{signal:d}),o=``;try{let e=localStorage.getItem(`ditto:community`);e&&(o=JSON.parse(e).domain)}catch{}let u=[...new Set(i.map(e=>e.pubkey))],m=await n.query([{kinds:[0],authors:u}],{signal:d});for(let e of m)if(!r.getQueryData([`author`,e.pubkey])){let t=vt(e);r.setQueryData([`author`,e.pubkey],t),bt(e,t.metadata)}let h=new Map;for(let e of m)try{let t=JSON.parse(e.content);t.nip05&&h.set(e.pubkey,t.nip05.toLowerCase())}catch{}let _=(o?i.filter(e=>{let t=h.get(e.pubkey);if(!t)return!1;let n=`@${o}`;return t.endsWith(n)}):i).filter(e=>e.created_at<=f),v=Hn(_),y=[],b=[],x=new Map;for(let e of _)if(Un(e.kind)){let t=qn(e);if(t&&t.created_at<=f)y.push({event:t,repostedBy:e.pubkey,sortTimestamp:e.created_at});else{let t=e.tags.find(([e])=>e===`e`)?.[1];t&&(b.push(t),x.set(t,e))}}else y.push({event:e,sortTimestamp:e.created_at});if(b.length>0)try{let e=await n.query([{ids:b,limit:b.length}],{signal:d});for(let t of e){let e=x.get(t.id);e&&t.created_at<=f&&y.push({event:t,repostedBy:e.pubkey,sortTimestamp:e.created_at})}}catch{}let S=new Map;for(let e of y){let t=S.get(e.event.id);t?!e.repostedBy&&t.repostedBy&&S.set(e.event.id,e):S.set(e.event.id,e)}let C=Array.from(S.values()).sort((e,t)=>t.sortTimestamp-e.sortTimestamp);return s.followsFeedShowReplies||(C=C.filter(e=>e.repostedBy||!kn(e.event))),p(C),{items:C,oldestQueryTimestamp:v,rawCount:_.length}}if(u&&u.length>0||m&&i&&o!==void 0){let e=u??(i&&o?o.length>0?[...o,i.pubkey]:[i.pubkey]:[]),t=s.followsFeedShowReplies?lP:45,r={kinds:c,authors:e,limit:t,...l};a&&(r.until=a);let m=(await n.query([r],{signal:d})).filter(e=>e.created_at<=f),h=Hn(m),g=[],_=[],v=new Map;for(let e of m)if(Un(e.kind)){let t=qn(e);if(t&&t.created_at<=f)g.push({event:t,repostedBy:e.pubkey,sortTimestamp:e.created_at});else{let t=e.tags.find(([e])=>e===`e`)?.[1];t&&(_.push(t),v.set(t,e))}}else g.push({event:e,sortTimestamp:e.created_at});if(_.length>0)try{let e=await n.query([{ids:_,limit:_.length}],{signal:d});for(let t of e){let e=v.get(t.id);e&&t.created_at<=f&&g.push({event:t,repostedBy:e.pubkey,sortTimestamp:e.created_at})}}catch{}let y=new Map;for(let e of g){let t=y.get(e.event.id);t?!e.repostedBy&&t.repostedBy&&y.set(e.event.id,e):y.set(e.event.id,e)}let b=Array.from(y.values()).sort((e,t)=>t.sortTimestamp-e.sortTimestamp);return s.followsFeedShowReplies||(b=b.filter(e=>e.repostedBy||!kn(e.event))),p(b),{items:b,oldestQueryTimestamp:h,rawCount:m.length}}{let r={kinds:c.filter(e=>!Un(e)),limit:lP,...l};e===`global`&&!t?.kinds&&(r.search=`sort:hot protocol:nostr`),a&&(r.until=a);let i=(await n.query([r],{signal:d})).filter(e=>e.created_at<=f),o=Hn(i),s=i.sort((e,t)=>t.created_at-e.created_at).map(e=>({event:e,sortTimestamp:e.created_at}));return p(s),{items:s,oldestQueryTimestamp:o,rawCount:i.length}}},getNextPageParam:e=>{if(e.rawCount!==0)return e.oldestQueryTimestamp-1},initialPageParam:void 0,enabled:h&&(t?.enabled??!0),staleTime:6e4,refetchOnWindowFocus:!1,gcTime:18e5,placeholderData:e=>e})}function dP(){let{nostr:e}=ct();return e}function fP(e,t){let n=e.trim();if(!n)return[];if(t!==`#t`)return[n];let r=[n,n.toLowerCase(),n.toUpperCase()];return Array.from(new Set(r))}var pP=40,mP=40,hP=[`agora-action`,`pathos-challenge`,`agora-challenge`],gP=1209600;function _P(e){let t=e.tags.find(([e])=>e===`i`)?.[1],n=t?Wi(t):void 0;if(n)return n;let r=e.tags.find(([e])=>e===`location`)?.[1];return r?Wi(`iso3166:${r}`):void 0}function vP(e,t){let n=dP(),r=e.join(`,`);return It({queryKey:[`following-country-feed`,r],queryFn:async({pageParam:t,signal:r})=>{if(e.length===0)return{events:[],oldestTimestamp:null,totalFetched:0};let i=AbortSignal.any([r,AbortSignal.timeout(5e3)]),a=t,o=new Set(e.map(e=>e.toUpperCase())),s=[{kinds:[1111,1068],"#i":e.flatMap(e=>Gi(e,!0)),limit:pP,...a&&{until:a}},{kinds:[36639],"#t":hP,limit:Math.floor(pP/4),...a&&{until:a}}],c=(await n.query(s,{signal:i})).filter(e=>{let t=_P(e);return!!t&&o.has(t)}).sort((e,t)=>t.created_at-e.created_at),l=c.slice(0,pP);return{events:l,oldestTimestamp:l.length>0?l[l.length-1].created_at:null,totalFetched:c.length}},initialPageParam:void 0,getNextPageParam:e=>{if(!(e.totalFetched<pP||!e.oldestTimestamp))return e.oldestTimestamp-1},enabled:t&&e.length>0,staleTime:3e4,refetchOnWindowFocus:!1,placeholderData:e=>e})}function yP(e,t,n){let r=dP(),i=e.join(`,`),a=[...t].sort().join(`,`);return It({queryKey:[`following-hashtag-feed`,i,a],queryFn:async({pageParam:n,signal:i})=>{if(e.length===0||t.length===0)return{events:[],oldestTimestamp:null,totalFetched:0};let a=AbortSignal.any([i,AbortSignal.timeout(5e3)]),o=n,s={kinds:t,"#t":Array.from(new Set(e.flatMap(e=>fP(e,`#t`)))),limit:mP,...o&&{until:o}},c=[...await r.query([s],{signal:a})].sort((e,t)=>t.created_at-e.created_at),l=c.slice(0,mP);return{events:l,oldestTimestamp:l.length>0?l[l.length-1].created_at:null,totalFetched:c.length}},initialPageParam:void 0,getNextPageParam:e=>{if(!(e.totalFetched<mP||!e.oldestTimestamp))return e.oldestTimestamp-1},enabled:n&&e.length>0&&t.length>0,staleTime:3e4,refetchOnWindowFocus:!1,placeholderData:e=>e})}function bP(e=!0){let{feedSettings:t}=ni(),n=(0,M.useMemo)(()=>Rn(t).filter(e=>!Un(e)),[t]),r=uP(`network`,{enabled:e}),{followedCountries:i,isLoading:a}=Ji(),o=vP(i,e),s=i.length>0,{hashtags:c,isLoading:l}=qi(`t`),u=yP(c,n,e),d=c.length>0,f=(0,M.useMemo)(()=>{let e=(r.data?.pages)?.flatMap(e=>e.items)??[],t=(o.data?.pages??[]).flatMap(e=>e.events).map(e=>({event:e,sortTimestamp:e.created_at})),n=(u.data?.pages??[]).flatMap(e=>e.events).map(e=>({event:e,sortTimestamp:e.created_at})),i=Math.floor(Date.now()/1e3),a=e.length>0?Math.min(...e.map(e=>e.sortTimestamp)):null,s=i-gP,c=a===null?s:Math.max(a,s),l=[...t,...n].filter(e=>e.sortTimestamp>=c),d=[...e,...l],f=new Map;for(let e of d){let t=e.repostedBy?`repost-${e.repostedBy}-${e.event.id}`:e.event.id,n=f.get(t);(!n||e.sortTimestamp>n.sortTimestamp)&&f.set(t,e)}return{pages:[{items:Array.from(f.values()).sort((e,t)=>t.sortTimestamp-e.sortTimestamp)}]}},[r.data?.pages,o.data?.pages,u.data?.pages]),p=r.hasNextPage,m=r.fetchNextPage,h=o.hasNextPage,g=o.fetchNextPage,_=u.hasNextPage,v=u.fetchNextPage,y=(0,M.useCallback)(async()=>{await Promise.all([p?m():Promise.resolve(),h?g():Promise.resolve(),_?v():Promise.resolve()])},[p,m,h,g,_,v]);return{data:f,isPending:e&&(r.isPending||a||s&&o.isPending||l||d&&u.isPending),isLoading:e&&(r.isLoading||a||s&&o.isLoading||l||d&&u.isLoading),fetchNextPage:y,hasNextPage:!!r.hasNextPage||!!o.hasNextPage||!!u.hasNextPage,isFetchingNextPage:r.isFetchingNextPage||o.isFetchingNextPage||u.isFetchingNextPage}}function xP(e,t){let{user:n}=cn(),{config:r}=Zt(),i=sn(r.appId,`feed-tab:${e}`),[a,o]=(0,M.useState)(()=>{let r=n?`follows`:`world`;try{let n=localStorage.getItem(i);if(n){if(e===`home`&&n===`network`)return localStorage.setItem(i,r),r;if(!t||t.includes(n))return n}}catch{}return t&&!t.includes(r)?t[t.length-1]:r});return[a,(0,M.useCallback)(e=>{o(e);try{localStorage.setItem(i,e)}catch{}},[i])]}var SP=25,CP=36639,wP=34550,TP=1068,EP=1111,DP=1,OP=8333,kP=9735,AP=[Ui,CP,wP,OP],jP=[String(Ui),String(CP),String(wP)],MP=[`iso3166`,`geo`],NP=[`agora`,`Agora`],PP=new Set([`4fe14ef28934b4093d71d43a8c9e9ec42ab4243febfff38470bfef05f51992ec`]);async function FP(e,t,n){let r=Math.floor(Date.now()/1e3),i=[],a=[],o=new Map;for(let t of e){if(!Un(t.kind)){i.push({event:t,sortTimestamp:t.created_at});continue}let e=qn(t);if(e&&e.created_at<=r){i.push({event:e,repostedBy:t.pubkey,repostEvent:t,sortTimestamp:t.created_at});continue}let n=t.tags.find(([e])=>e===`e`)?.[1];n&&(a.push(n),o.set(n,t))}if(a.length>0)try{let e=await t.query([{ids:a,limit:a.length}],{signal:n});for(let t of e){let e=o.get(t.id);e&&t.created_at<=r&&!Gn(t)&&i.push({event:t,repostedBy:e.pubkey,repostEvent:e,sortTimestamp:e.created_at})}}catch{}return i.sort((e,t)=>t.sortTimestamp-e.sortTimestamp)}function IP(e,t){return e.tags.filter(([e])=>e===t).map(([,e])=>e).filter(Boolean)}function LP(e,t,n){let r=new Set(n.map(e=>e.toLowerCase()));return IP(e,t).some(e=>r.has(e.toLowerCase()))}function RP(e){return LP(e,`t`,NP)}function zP(e){return e.kind===EP&&LP(e,`k`,MP)}function BP(e){return e.kind===TP&&LP(e,`k`,MP)}function VP(e){return Gn(e)?!1:zP(e)||BP(e)?!0:RP(e)?e.kind===33863||e.kind===wP||e.kind===CP?!0:e.kind===EP?LP(e,`K`,jP)||IP(e,`A`).some(e=>e.startsWith(`${wP}:`)):e.kind===DP?!PP.has(e.pubkey):e.kind===OP||e.kind===kP?LP(e,`K`,jP)||IP(e,`a`).some(HP):!1:!1}function HP(e){let t=e.split(`:`)[0];return t===`33863`||t===String(CP)||t===String(wP)}function UP(e){if(e.kind<3e4||e.kind>=4e4)return;let t=e.tags.find(([e])=>e===`d`)?.[1];if(t)return`${e.kind}:${e.pubkey}:${t}`}function WP(e){let t=new Set,n=new Set;for(let r of e){let e=UP(r);e&&(r.kind===33863||r.kind===CP)&&t.add(e),r.kind===EP&&LP(r,`K`,[String(CP)])&&n.add(r.id)}return{coordinates:Array.from(t).slice(0,40),eventIds:Array.from(n).slice(0,40)}}function GP(e,t){let{nostr:n}=ct(),{user:r}=cn(),{muteItems:i}=gn(),{shouldFilterEvent:a}=Yi(),{feedSettings:o}=ni(),s=t?.authors,c=s?[...s].sort().join(`,`):``,l=s!==void 0&&s.length===0,u=e&&!l,d=!!t?.includeAuthorNotes&&!!s&&s.length>0,f=d?Rn(o):[];d&&!f.includes(1)&&f.push(1),d&&!f.includes(6)&&f.push(6),d&&!f.includes(16)&&f.push(16);let p=[...f].sort((e,t)=>e-t).join(`,`),m=It({queryKey:[`agora-feed`,r?.pubkey??``,c,d,p],queryFn:async({pageParam:e,signal:t})=>{let r=AbortSignal.any([t,AbortSignal.timeout(8e3)]),o=e,c=s&&s.length>0?{authors:s}:{},l=[{kinds:AP,"#t":NP,limit:SP,...c,...o&&{until:o}},{kinds:[EP],"#t":NP,"#K":jP,limit:SP,...c,...o&&{until:o}},{kinds:[EP,TP],"#k":MP,limit:SP,...c,...o&&{until:o}},{kinds:[DP],"#t":NP,limit:Math.ceil(SP/2),...c,...o&&{until:o}}];d&&f.length>0&&l.push({kinds:f,...c,limit:SP,...o&&{until:o}});let u=await n.query(l,{signal:r}),p=new Set(s??[]),m=new Set(f),h=u.filter(e=>VP(e)?!0:!d||!m.has(e.kind)||Gn(e)?!1:p.has(e.pubkey)),{coordinates:g,eventIds:_}=WP(h),v=[];g.length>0&&v.push({kinds:[kP,OP],"#t":NP,"#a":g,limit:g.length*10}),_.length>0&&v.push({kinds:[kP,OP],"#t":NP,"#e":_,limit:_.length*10});let y=v.length>0?await n.query(v,{signal:r}):[],b=new Set,x=[...h,...y.filter(e=>!Gn(e)&&RP(e))].filter(e=>!(b.has(e.id)||(b.add(e.id),i.length>0&&Xi(e,i))||a(e))).sort((e,t)=>t.created_at-e.created_at),S=x.slice(0,SP);return{events:S,items:await FP(S,n,r),oldestTimestamp:S.length>0?Hn(S):null,totalFetched:x.length}},initialPageParam:void 0,getNextPageParam:e=>{if(!(e.totalFetched<SP||!e.oldestTimestamp))return e.oldestTimestamp-1},enabled:u,staleTime:3e4,placeholderData:e=>e}),h=new Set,g=[],_=new Set,v=[];for(let e of m.data?.pages??[]){for(let t of e.events)h.has(t.id)||(h.add(t.id),g.push(t));for(let t of e.items){let e=t.repostedBy?`repost-${t.repostedBy}-${t.event.id}`:t.event.id;_.has(e)||(_.add(e),v.push(t))}}return{events:g,items:v,isLoading:u?m.isPending:!1,isError:m.isError,error:m.error,refetch:m.refetch,isFetchingNextPage:m.isFetchingNextPage,hasNextPage:!l&&m.hasNextPage,fetchNextPage:m.fetchNextPage,pageCount:m.data?.pages.length}}var KP=30,qP=[1,6,16];function JP({enabled:e,authors:t}){let{nostr:n}=ct(),r=t?[...t].sort().join(`,`):``,i=t!==void 0&&t.length===0;return It({queryKey:[`nostr-layer`,r],queryFn:async({pageParam:e,signal:r})=>{let i=AbortSignal.any([r,AbortSignal.timeout(8e3)]),a=e,o=Math.floor(Date.now()/1e3),s={kinds:qP,limit:KP,...t&&t.length>0?{authors:t}:{},...a?{until:a}:{}},c=(await n.query([s],{signal:i})).filter(e=>e.created_at<=o),l=[];for(let e of c)if(Un(e.kind)){let t=qn(e);t&&t.created_at<=o&&l.push({event:t,repostedBy:e.pubkey,sortTimestamp:e.created_at})}else l.push({event:e,sortTimestamp:e.created_at});return{items:l,oldestTimestamp:c.length>0?Hn(c):null,rawCount:c.length}},initialPageParam:void 0,getNextPageParam:e=>{if(e.rawCount!==0&&e.oldestTimestamp!==null)return e.oldestTimestamp-1},enabled:e&&!i,staleTime:3e4,refetchOnWindowFocus:!1,placeholderData:e=>e})}function YP(e,t){let{user:n}=cn(),{data:r}=Cn(),{muteItems:i}=gn(),a=(0,M.useMemo)(()=>{if(e!==`following`)return;if(!n)return[];let t=r?.pubkeys;if(t!==void 0)return t.length>0?[...t,n.pubkey]:[n.pubkey]},[e,n,r?.pubkeys]),o=t&&(e!==`following`||a!==void 0),s=GP(o,(0,M.useMemo)(()=>a===void 0?void 0:{authors:a},[a])),c=e===`all-nostr`||e===`following`,l=JP({enabled:o&&c,authors:a}),u=(0,M.useMemo)(()=>c?l.data?.pages.flatMap(e=>e.items)??[]:[],[c,l.data?.pages]),d=(0,M.useMemo)(()=>s.events.map(e=>({event:e,sortTimestamp:e.created_at})),[s.events]),f=(0,M.useMemo)(()=>{if(!c||u.length===0)return null;let e=u[0].sortTimestamp;for(let t of u)t.sortTimestamp<e&&(e=t.sortTimestamp);return e},[c,u]),p=(0,M.useMemo)(()=>c?f===null?[]:d.filter(e=>e.sortTimestamp>=f):d,[c,d,f]),m=(0,M.useMemo)(()=>{let e=new Map,t=t=>{let n=t.repostedBy?`repost-${t.repostedBy}-${t.event.id}`:t.event.id;if(!n||Gn(t.event)||i.length>0&&Xi(t.event,i))return;let r=e.get(n);(!r||t.sortTimestamp>r.sortTimestamp)&&e.set(n,t)};for(let e of p)t(e);for(let e of u)t(e);return Array.from(e.values()).sort((e,t)=>t.sortTimestamp-e.sortTimestamp)},[p,u,i]),h=s.hasNextPage,g=s.fetchNextPage,_=l.hasNextPage,v=l.fetchNextPage,y=(0,M.useMemo)(()=>{if(d.length===0)return null;let e=d[0].sortTimestamp;for(let t of d)t.sortTimestamp<e&&(e=t.sortTimestamp);return e},[d]),b=(0,M.useCallback)(async()=>{if(!c){h&&await g();return}let e=h&&y!==null&&f!==null&&y>=f;await Promise.all([_?v():Promise.resolve(),e?g():Promise.resolve()])},[c,h,g,y,_,v,f]),x=c&&!!_||!!h,S=s.isFetchingNextPage||c&&l.isFetchingNextPage,C=s.isLoading||c&&l.isPending,ee=s.isError||c&&l.isError,te=s.refetch,w=l.refetch;return{items:m,isLoading:C,isError:ee,refetch:(0,M.useCallback)(async()=>{await Promise.all([te(),c?w():Promise.resolve()])},[te,c,w]),hasNextPage:x,isFetchingNextPage:S,fetchNextPage:b}}var XP=20,ZP=28,QP=`M0,0 L100,0 L100,34 L50,46 L0,34 Z`,$P=`M0,40 L50,16 L100,40 L100,64 L0,64 Z`,eF=`M0,0 L100,0 L100,64 L0,64 Z`,tF={height:`calc(100% + ${XP}px)`},nF={height:`calc(100% + ${ZP}px)`},rF={height:`100%`};function iF({variant:e,className:t,fillClassName:n}){let r=e===`down`?QP:e===`up`?$P:eF,i=e!==`rect`;return(0,N.jsxs)(`svg`,{className:O(e===`up`?`absolute bottom-0 left-0 right-0`:`absolute inset-0`,`w-full pointer-events-none`,t),viewBox:`0 0 100 64`,preserveAspectRatio:`none`,style:i?e===`up`?nF:tF:rF,children:[(0,N.jsx)(`path`,{d:r,className:O(`fill-background/85`,n)}),e===`down`&&(0,N.jsx)(`path`,{d:`M0,34 L50,46 L100,34`,fill:`none`,className:`stroke-border`,strokeWidth:`1`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`}),e===`up`&&(0,N.jsx)(`path`,{d:`M0,40 L50,16 L100,40`,fill:`none`,className:`stroke-border`,strokeWidth:`1`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`})]})}var aF=(0,M.createContext)({onHover:()=>{},onActive:()=>{},scrollContainerRef:{current:null}});function oF(){return(0,M.useContext)(aF)}function sF(e,t){let{onActive:n,scrollContainerRef:r}=oF(),i=(0,M.useCallback)(()=>{let e=t.current;if(!e)return null;let n=r.current,i=n?.scrollLeft??0,a=n?.offsetLeft??0;return{left:e.offsetLeft-i+a,width:e.offsetWidth}},[]);return(0,M.useLayoutEffect)(()=>{if(!e)return;let t=i();t&&n(t);let r=requestAnimationFrame(()=>{let e=i();e&&n(e)});return()=>{cancelAnimationFrame(r),n(null)}},[e]),(0,M.useEffect)(()=>{if(!e)return;let t=r.current;if(!t)return;let a=()=>{let e=i();e&&n(e)};t.addEventListener(`scroll`,a,{passive:!0});let o=new ResizeObserver(a);return o.observe(t),()=>{t.removeEventListener(`scroll`,a),o.disconnect()}},[e]),{reportSlice:i}}function cF({children:e,className:t,innerClassName:n,backgroundFillClassName:r,noArc:i,pinned:a}){let[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null),u=(0,M.useRef)(null),[d,f]=(0,M.useState)(!1),[p,m]=(0,M.useState)(!1),g=(0,M.useCallback)(()=>{let e=u.current;e&&(f(e.scrollLeft>2),m(e.scrollLeft+e.clientWidth<e.scrollWidth-2))},[]);(0,M.useEffect)(()=>{let e=u.current;if(!e)return;g(),e.addEventListener(`scroll`,g,{passive:!0});let t=new ResizeObserver(g);return t.observe(e),()=>{e.removeEventListener(`scroll`,g),t.disconnect()}},[g]),(0,M.useEffect)(()=>{g()},[e,g]);let v=e=>{let t=u.current;if(!t)return;let n=t.clientWidth*.6;t.scrollBy({left:e===`left`?-n:n,behavior:`smooth`})};return(0,N.jsx)(aF.Provider,{value:{onHover:s,onActive:l,scrollContainerRef:u},children:(0,N.jsx)(`div`,{className:O(`relative sticky top-mobile-bar sidebar:top-0 z-10`,t),children:(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(iF,{variant:`rect`,fillClassName:r}),o&&(0,N.jsx)(`svg`,{"aria-hidden":!0,className:`absolute top-0 left-0 w-full h-full pointer-events-none`,style:{clipPath:`inset(0 calc(100% - ${o.left+o.width}px) 0 ${o.left}px)`},viewBox:`0 0 100 64`,preserveAspectRatio:`none`,children:(0,N.jsx)(`path`,{d:`M0,0 L100,0 L100,64 L0,64 Z`,className:`fill-secondary/40`})}),c&&(0,N.jsx)(`svg`,{"aria-hidden":!0,className:`absolute top-0 left-0 w-full h-full pointer-events-none`,style:{clipPath:`inset(0 calc(100% - ${c.left+c.width}px) 0 ${c.left}px)`},viewBox:`0 0 100 64`,preserveAspectRatio:`none`,children:(0,N.jsx)(`path`,{d:`M0,62 L100,62`,fill:`none`,className:`stroke-primary`,strokeWidth:`3`,vectorEffect:`non-scaling-stroke`})}),(0,N.jsxs)(`div`,{className:`relative`,children:[d&&(0,N.jsx)(`button`,{type:`button`,"aria-label":`Scroll tabs left`,onClick:()=>v(`left`),className:`hidden sidebar:flex absolute left-0 top-0 bottom-0 z-10 items-center pl-0.5 pr-1 bg-gradient-to-r from-background via-background to-transparent cursor-pointer`,children:(0,N.jsx)(_,{className:`size-4 text-foreground drop-shadow-md`,strokeWidth:4})}),(0,N.jsx)(`div`,{ref:u,className:O(`relative flex overflow-x-auto scrollbar-none py-1`,n),children:e}),p&&(0,N.jsx)(`button`,{type:`button`,"aria-label":`Scroll tabs right`,onClick:()=>v(`right`),className:`hidden sidebar:flex absolute right-0 top-0 bottom-0 z-10 items-center pr-0.5 pl-1 bg-gradient-to-l from-background via-background to-transparent cursor-pointer`,children:(0,N.jsx)(h,{className:`size-4 text-foreground drop-shadow-md`,strokeWidth:4})})]})]})})})}function lF({label:e,active:t,onClick:n,disabled:r,className:i,children:a}){let o=(0,M.useRef)(null),{onHover:s,scrollContainerRef:c}=oF(),{reportSlice:l}=sF(t,o);return(0,M.useLayoutEffect)(()=>{if(!t)return;let e=o.current,n=c.current;if(e&&n){let t=e.offsetLeft,r=t+e.offsetWidth,i=n.scrollLeft,a=i+n.clientWidth;t<i?n.scrollTo({left:t-8,behavior:`smooth`}):r>a&&n.scrollTo({left:r-n.clientWidth+8,behavior:`smooth`})}},[t]),(0,N.jsx)(`button`,{ref:o,onClick:()=>{s(null),t?window.scrollTo({top:0,behavior:`smooth`}):(window.scrollTo({top:0}),n())},onMouseEnter:()=>{let e=l();e&&s(e)},onMouseLeave:()=>s(null),disabled:r,className:O(`flex-1 flex items-center justify-center py-1.5 text-sm font-medium transition-colors relative px-4 whitespace-nowrap`,t?`text-foreground`:`text-muted-foreground`,r&&`opacity-50 cursor-not-allowed`,i),children:a??e})}var uF=[`agora`,`all-nostr`,`following`];function dF(e){return uF.includes(e)}function fF({kinds:e,tagFilters:t,header:n,hideCompose:r,emptyMessage:i,feedId:a=`home`}={}){let{t:o}=A(),{user:s}=cn(),{muteItems:c}=gn(),{toast:l}=un(),[u,d]=xP(a),[f,p]=(0,M.useState)(!1),m=!e&&!t,h=m&&dF(u)?u:`agora`,g=m?h:u===`global`?`global`:u===`follows`&&s||s?`follows`:`global`;(0,M.useEffect)(()=>{(u.startsWith(`hashtag:`)||u.startsWith(`geotag:`))&&d(`follows`)},[u,d]);let _=e=>{d(e)},v=!!e,y=YP(h,m),b=g===`follows`&&!v&&!t&&!m,x=uP((g===`follows`||g===`network`||g===`global`||g===`communities`||g===`world`||g===`agora`)&&!m?g===`follows`?`network`:g===`network`||g===`global`||g===`communities`?g:`global`:`global`,e||t?{kinds:e,tagFilters:t,enabled:!b&&!m}:{enabled:!b&&!m}),S=bP(b),C=$N((0,M.useMemo)(()=>m?[`mixed-feed`,h]:b?[[`feed`,`network`],[`community-activity-feed`],[`following-country-feed`]]:[`feed`,g],[m,h,b,g])),{data:ee,isPending:te,isLoading:w,fetchNextPage:ne,hasNextPage:re,isFetchingNextPage:ie}=b?S:x,ae=m?y.fetchNextPage:ne,oe=m?y.hasNextPage:re,se=m?y.isFetchingNextPage:ie,ce=m&&y.isError,T=y.refetch;(0,M.useEffect)(()=>{!b&&!m&&oe&&!se&&ee?.pages?.length===1&&ae()},[b,m,oe,se,ee?.pages?.length,ae]);let{ref:E,inView:le}=QN({threshold:0,rootMargin:`400px`});(0,M.useEffect)(()=>{le&&oe&&!se&&ae()},[le,oe,se,ae]);let ue=(0,M.useMemo)(()=>{if(m)return y.items;if(!ee?.pages)return[];let e=new Set;return ee.pages.flatMap(e=>e.items).filter(t=>{let n=t.repostedBy?`repost-${t.repostedBy}-${t.event.id}`:t.event.id;return!(!n||e.has(n)||(e.add(n),Gn(t.event))||c.length>0&&Xi(t.event,c))})},[m,y.items,ee?.pages,c]);(0,M.useEffect)(()=>{ue.length!==0&&(console.groupCollapsed(`[nostr feed render]`,{feedId:a,mode:m?h:g,count:ue.length}),console.table(ue.map((e,t)=>({index:t,relay:An(e.event.id)??`unknown`,kind:e.event.kind,id:e.event.id,created_at:e.event.created_at,repostedBy:e.repostedBy??``}))),console.groupEnd())},[a,m,h,g,ue]);let de=m?y.isLoading&&ue.length===0:te||w&&!ee,fe=ce&&!de&&ue.length===0;(0,M.useEffect)(()=>{fe&&l({title:o(`feed.error.toast`),variant:`destructive`})},[fe,l,o]);let pe=o(h===`agora`?`feed.empty.homeAgora`:h===`following`?s?`feed.empty.homeFollowingLoggedIn`:`feed.empty.homeFollowingLoggedOut`:`feed.empty.homeOther`);return(0,N.jsx)(`main`,{className:`flex-1 min-w-0 min-h-dvh bg-background`,children:(0,N.jsxs)(`div`,{children:[n,!s&&!e&&(0,N.jsx)(eP,{onJoinClick:()=>p(!0)}),m&&(0,N.jsx)(`div`,{className:`px-4 pt-5 pb-3 sm:pt-6`,children:(0,N.jsx)(cP,{value:h,onChange:_,followingAvailable:!!s,onLoginRequested:()=>p(!0)})}),s&&(v||t)&&(0,N.jsxs)(cF,{children:[(0,N.jsx)(lF,{label:o(v||t?`feed.tabs.follows`:`feed.tabs.following`),active:g===`follows`,onClick:()=>d(`follows`)}),(0,N.jsx)(lF,{label:o(`feed.tabs.global`),active:g===`global`,onClick:()=>d(`global`)})]}),(0,N.jsxs)(`div`,{className:`rounded-2xl bg-muted/60 overflow-hidden border-l border-r border-primary/20 [&_article]:border-b-primary/20 [&_article]:bg-background/40`,children:[!r&&(0,N.jsx)(Wn,{compact:!0,hideBorder:!0,defaultExpanded:!0,placeholder:o(`feed.compose.placeholder`),className:`!bg-[hsl(24_100%_99%)] dark:!bg-[hsl(24_30%_12%)] border-t border-b border-t-primary/40 border-b-primary/20 rounded-t-2xl`}),(0,N.jsx)(iP,{onRefresh:C,children:de?(0,N.jsx)(`div`,{className:`divide-y divide-primary/20 [&>div]:border-b-primary/20`,children:Array.from({length:5}).map((e,t)=>(0,N.jsx)(hF,{},t))}):ue.length>0?(0,N.jsxs)(`div`,{children:[ue.map(e=>(0,N.jsx)(Kn,{event:e.event,repostedBy:e.repostedBy,className:`py-4`},e.repostedBy?`repost-${e.repostedBy}-${e.event.id}`:e.event.id)),oe&&(0,N.jsx)(`div`,{ref:E,className:`py-4`,children:se&&(0,N.jsx)(`div`,{className:`flex justify-center`,children:(0,N.jsx)(ve,{className:`size-5 animate-spin text-muted-foreground`})})})]}):fe?(0,N.jsx)(mF,{onRetry:()=>T()}):m?(0,N.jsx)(pF,{mode:h,message:pe,onSwitchToAgora:h===`agora`?void 0:()=>_(`agora`),onLoginClick:!s&&h===`following`?()=>p(!0):void 0}):(0,N.jsx)(aP,{message:i??o(g===`follows`?`feed.empty.follows`:`feed.empty.global`),showDiscover:!i&&g===`follows`,onSwitchToGlobal:g===`follows`?()=>d(`global`):void 0})})]}),!e&&(0,N.jsx)(er,{isOpen:f,onClose:()=>p(!1)})]})})}function pF({mode:e,message:t,onSwitchToAgora:n,onLoginClick:r}){let{t:i}=A();return(0,N.jsxs)(`div`,{className:`py-20 px-8 flex flex-col items-center text-center`,children:[(0,N.jsx)(`p`,{className:`text-muted-foreground max-w-sm leading-relaxed`,children:t}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-2 mt-6 w-full max-w-xs`,children:[r&&(0,N.jsx)(Pr,{className:`rounded-full`,onClick:r,children:i(`feed.empty.logIn`)}),n&&(0,N.jsx)(Pr,{variant:e===`following`?`default`:`ghost`,className:`rounded-full`,onClick:n,children:i(`feed.empty.browseAgora`)})]})]})}function mF({onRetry:e}){let{t}=A();return(0,N.jsxs)(`div`,{className:`py-20 px-8 flex flex-col items-center text-center`,children:[(0,N.jsx)(`div`,{className:`size-12 rounded-full bg-muted flex items-center justify-center mb-4`,children:(0,N.jsx)(me,{className:`size-6 text-muted-foreground`})}),(0,N.jsx)(`p`,{className:`text-muted-foreground max-w-sm leading-relaxed mb-5`,children:t(`feed.error.loadFailed`)}),(0,N.jsx)(Pr,{variant:`outline`,className:`rounded-full`,onClick:e,children:t(`feed.error.retry`)})]})}function hF({className:e}){return(0,N.jsxs)(`div`,{className:O(`px-4 py-4 border-b border-border`,e),children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(ti,{className:`size-11 rounded-full shrink-0`}),(0,N.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[(0,N.jsx)(ti,{className:`h-4 w-28`}),(0,N.jsx)(ti,{className:`h-3 w-36`})]})]}),(0,N.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[(0,N.jsx)(ti,{className:`h-4 w-full`}),(0,N.jsx)(ti,{className:`h-4 w-4/5`})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-6 mt-3 -ml-2`,children:[(0,N.jsx)(ti,{className:`h-4 w-8`}),(0,N.jsx)(ti,{className:`h-4 w-8`}),(0,N.jsx)(ti,{className:`h-4 w-8`}),(0,N.jsx)(ti,{className:`h-4 w-8`})]})]})}var gF=()=>{let{t:e}=A(),{config:t}=Zt();return qt({title:t.appName,description:e(`feed.indexTagline`)}),(0,N.jsx)(fF,{})},_F=()=>{let{t:e}=A(),t=vr(),{config:n}=Zt();return qt({title:`${e(`notFound.title`)} | ${n.appName}`,description:e(`notFound.description`)}),(0,M.useEffect)(()=>{console.error(`404 Error: User attempted to access non-existent route:`,t.pathname)},[t.pathname]),(0,N.jsx)(`main`,{className:`flex items-center justify-center`,children:(0,N.jsxs)(`div`,{className:`text-center px-8`,children:[(0,N.jsx)(`h1`,{className:`text-6xl font-bold mb-4 text-primary`,children:`404`}),(0,N.jsx)(`p`,{className:`text-xl text-muted-foreground mb-6`,children:e(`notFound.heading`)}),(0,N.jsx)(xr,{to:`/`,className:`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground px-6 py-2.5 font-bold hover:bg-primary/90 transition-colors`,children:e(`notFound.goHome`)})]})})},vF=(0,M.lazy)(()=>D(()=>import(`./CampaignsPage-ifEOpgvd.js`).then(e=>({default:e.CampaignsPage})),__vite__mapDeps([8,1,2,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,7,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,4,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90]))),yF=(0,M.lazy)(()=>D(()=>import(`./CreateCampaignPage-DhzuG0N2.js`).then(e=>({default:e.CreateCampaignPage})),__vite__mapDeps([91,1,2,11,9,12,43,73,14,21,22,44,45,92,33,19,34,35,36,37,38,15,79,16,17,18,20,49,50,51,39,40,52,53,80,81,82,46,75,24,7,26,25,27,28,29,93,94,13,10,23,30,31,32,41,42,47,48,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,95,85,96,97,98,99,100,90,4,101,102,103,104,105,106,107,108,109,110,77,111,112,113,114,115,116,117,118,119,120,121,122,123]))),bF=(0,M.lazy)(()=>D(()=>import(`./AllCampaignsPage-BoTPnnMw.js`).then(e=>({default:e.AllCampaignsPage})),__vite__mapDeps([124,1,2,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,7,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,125,104,108,126,74,75,76,77,127,84,85,86,87,128,83,78,79,80,81,82]))),xF=(0,M.lazy)(()=>D(()=>import(`./CampaignListDetailPage-DJymTIZU.js`).then(e=>({default:e.CampaignListDetailPage})),__vite__mapDeps([129,1,2,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,7,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,75,108,76,77,127,84,85,86,87,128,83]))),SF=(0,M.lazy)(()=>D(()=>import(`./CampaignByNip05Page-CebHQjls.js`).then(e=>({default:e.CampaignByNip05Page})),__vite__mapDeps([130,1,2,13,11,9,12,14,15,16,17,18,19,20,23,24,7,42,43,21,22,44,45,46,47,48,49,50,51,33,34,35,36,39,40,52,37,38,53,26,25,28,54,29,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,131,132,10,27,30,31,32,41,72,73,133,134,86,84,85,135,92,96,97,98,99,136,80,81,75,137,138,139,94,95,100,90,4,101,102,103,104,105,106,93,140,141,77,107,108,109,142,143,144,145,111,76,146,147,148,149,150,151,152,153,154,110,112,155,156,113,157,158,159,160,161,162,163,164,114,88,123]))),CF=(0,M.lazy)(()=>D(()=>import(`./EmbedCampaignPage-_L1YrIdu.js`).then(e=>({default:e.EmbedCampaignPage})),__vite__mapDeps([165,1,2,11,9,12,10,13,14,15,16,17,18,19,20,21,22,23,24,7,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,147,157,80,81,114]))),wF=(0,M.lazy)(()=>D(()=>import(`./ActionsPage-b-W1S5qn.js`),__vite__mapDeps([166,1,2,11,9,12,73,14,21,22,45,43,15,24,7,16,17,18,19,20,52,33,34,35,36,37,38,39,40,53,103,46,29,41,64,105,42,13,44,47,48,49,50,51,26,25,28,54,55,56,57,58,59,60,61,62,63,65,66,67,68,69,70,71,143,23,125,32,104,108,126,167,27,168,128]))),TF=(0,M.lazy)(()=>D(()=>import(`./CreateActionPage-B2HfcHtJ.js`).then(e=>({default:e.CreateActionPage})),__vite__mapDeps([169,1,2,11,9,12,43,73,14,21,22,45,24,7,16,49,15,29,55,33,19,38,56,57,18,58,17,20,40,50,51,34,35,36,39,53,59,60,61,62,63,64,67,41,68,70,71,112,115,116,117,118,47,48,104,119,120,170,32,37,126,121]))),EF=(0,M.lazy)(()=>D(()=>import(`./AdvancedSettingsPage-IJkBMmwQ.js`).then(e=>({default:e.AdvancedSettingsPage})),__vite__mapDeps([171,1,2,9,73,14,138,11,12,43,21,22,44,16,17,15,18,19,20,49,54,33,65,58,70,172,82,46,76,35,36,56,77,40,160,38,60,173,24,7,174,101,4,175,136,50,51,34,39,140,68,69]))),DF=(0,M.lazy)(()=>D(()=>import(`./AppearanceSettingsPage-a3xihrNt.js`).then(e=>({default:e.AppearanceSettingsPage})),__vite__mapDeps([176,2,1,9,73,14,142,138,11,12,43,21,22,44,15,16,173,24,7]))),OF=(0,M.lazy)(()=>D(()=>import(`./ChangelogPage-BdlIaOGf.js`).then(e=>({default:e.ChangelogPage})),__vite__mapDeps([177,1,2,9,73,14,92,33,19,34,35,36,37,38,15,12,16,27,173,24,7]))),kF=(0,M.lazy)(()=>D(()=>import(`./CommunitiesPage-BRb09SaJ.js`).then(e=>({default:e.CommunitiesPage})),__vite__mapDeps([178,1,2,11,9,12,73,14,21,22,15,24,7,16,17,18,19,20,27,55,33,38,56,57,58,49,40,50,51,34,35,36,39,53,29,59,60,61,43,62,63,64,42,13,44,45,46,47,48,52,37,26,25,28,54,65,66,67,68,69,70,71,72,148,125,32,104,108,126,168,128,179,135,116,180,115]))),AF=(0,M.lazy)(()=>D(()=>import(`./ContentPage-BNSGCRgV.js`).then(e=>({default:e.ContentPage})),__vite__mapDeps([181,2,1,11,9,12,73,14,21,22,84,43,85,44,45,86,24,7,16,17,15,18,19,20,26,25,27,28,69,182,33,56,57,58,77,53,173]))),jF=(0,M.lazy)(()=>D(()=>import(`./CreateCommunityPage-DmW4O_C7.js`).then(e=>({default:e.CreateCommunityPage})),__vite__mapDeps([183,1,2,11,9,12,43,73,14,21,22,44,45,24,7,16,17,15,18,19,20,49,26,25,28,100,99,29,55,33,38,56,57,58,40,50,51,34,35,36,39,53,59,60,61,62,63,64,65,32,37,67,68,70,71,108,109,95,85,112,117,118,47,48,104,119,122]))),MF=(0,M.lazy)(()=>D(()=>import(`./CreateEventPage-D5njsIiH.js`).then(e=>({default:e.CreateEventPage})),__vite__mapDeps([184,1,2,11,9,12,43,73,14,21,22,45,24,7,16,17,15,18,19,20,49,29,55,33,38,56,57,58,40,50,51,34,35,36,39,53,59,60,61,62,63,64,65,67,68,70,112,174,101,4,115,116,118,47,48,104,119,120,170,32,37,126,121,122,185]))),NF=(0,M.lazy)(()=>D(()=>import(`./CSAEPolicyPage-DMkuIS-m.js`).then(e=>({default:e.CSAEPolicyPage})),__vite__mapDeps([186,2,1,9,73,14,16,27,15,12,173,24,7,187,29,30,31,188]))),PF=(0,M.lazy)(()=>D(()=>import(`./ExternalContentPage-BEVEK0y2.js`).then(e=>({default:e.ExternalContentPage})),__vite__mapDeps([189,1,2,11,9,12,13,14,15,16,17,18,19,20,7,43,132,73,21,22,45,84,85,44,86,133,10,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,134,135,92,96,97,98,99,136,80,81,75,137,138,139,94,95,100,90,4,101,102,103,104,105,106,93,140,141,77,107,108,109,142,143,144,145,111,76,146,147,148,149,150,151,152,153,154,110,112,87,160,164,190,123]))),FF=(0,M.lazy)(()=>D(()=>import(`./GeotagPage-BuL07bfb.js`).then(e=>({default:e.GeotagPage})),__vite__mapDeps([191,2,1,9,73,14,24,7,192,11,12,21,22,84,43,85,44,45,86,46,15,133,13,16,17,18,19,20,10,23,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,134,135,92,96,97,98,99,136,80,81,75,137,138,139,94,95,100,90,4,101,102,103,104,105,106,93,140,141,77,107,108,109,142,143,144,145,111,76,146,147,148,149,150,151,152,153,154,110,112,87,173,123]))),IF=(0,M.lazy)(()=>D(()=>import(`./HashtagPage-BPe2jILv.js`).then(e=>({default:e.HashtagPage})),__vite__mapDeps([193,9,1,73,2,14,24,7,192,11,12,21,22,84,43,85,44,45,86,46,15,133,13,16,17,18,19,20,10,23,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,134,135,92,96,97,98,99,136,80,81,75,137,138,139,94,95,100,90,4,101,102,103,104,105,106,93,140,141,77,107,108,109,142,143,144,145,111,76,146,147,148,149,150,151,152,153,154,110,112,87,173,123]))),LF=(0,M.lazy)(()=>D(()=>import(`./MessagesPage-ofMnjm7R.js`).then(e=>({default:e.MessagesPage})),__vite__mapDeps([194,1,2,11,9,12,13,14,15,16,17,18,19,20,43,132,73,21,22,45,84,85,44,86,95,24,7,49,26,25,27,28,29,66,67,141,33,35,56,58,77,53,59,102,70,109,108,76,36,40,187,30,31]))),RF=(0,M.lazy)(()=>D(()=>import(`./MyDashboardPage-CzZ017hu.js`).then(e=>({default:e.MyDashboardPage})),__vite__mapDeps([195,1,2,11,9,12,10,13,14,15,16,17,18,19,20,21,22,23,24,7,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,138,95,85,104,150,96,97,98,99,78,79,80,81,82,75,83,84,86,87,179,135,180,116,115]))),zF=(0,M.lazy)(()=>D(()=>import(`./AboutPage-CWGiaqRi.js`).then(e=>({default:e.AboutPage})),__vite__mapDeps([196,1,2,9,73,14,15,12,24,7,16,152,153,48,154,182,33,19,56,57,18,58,77,53]))),BF=(0,M.lazy)(()=>D(()=>import(`./DonorGuidePage-Dpu_3ubn.js`).then(e=>({default:e.DonorGuidePage})),__vite__mapDeps([197,9,1,73,2,14,16,152,15,12,153,7,48,128,198,24,68,154]))),VF=(0,M.lazy)(()=>D(()=>import(`./RecipientGuidePage-BFr7mIrZ.js`).then(e=>({default:e.RecipientGuidePage})),__vite__mapDeps([199,9,1,73,2,14,16,105,152,15,12,153,7,48,128,198,24,68,154]))),HF=(0,M.lazy)(()=>D(()=>import(`./CorporateSponsorshipPage-BaJH0WJ6.js`).then(e=>({default:e.CorporateSponsorshipPage})),__vite__mapDeps([200,1,2,9,12,10,11,13,14,15,16,17,18,19,20,21,22,23,24,7,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,90,4,152,153,83,84,85,86,87,89]))),UF=(0,M.lazy)(()=>D(()=>import(`./LanguageSettingsPage-7ML1A3l7.js`).then(e=>({default:e.LanguageSettingsPage})),__vite__mapDeps([201,2,1,9,73,14,15,12,16,153,7,48,173,24]))),WF=(0,M.lazy)(()=>D(()=>import(`./NetworkSettingsPage-CvuRjNDH.js`).then(e=>({default:e.NetworkSettingsPage})),__vite__mapDeps([202,1,2,11,9,12,73,14,138,43,21,22,44,62,45,46,92,33,19,34,35,36,37,38,15,24,7,47,48,16,17,18,20,49,26,25,65,58,32,39,40,69,151,152,153,154,173,174,56,60,101,4]))),GF=(0,M.lazy)(()=>D(()=>import(`./NIP19Page-Cc2SHdbX.js`).then(e=>({default:e.NIP19Page})),__vite__mapDeps([203,1,2,33,9,11,12,13,14,15,16,17,18,19,20,7,43,132,10,21,22,23,24,25,26,27,28,29,30,31,32,34,35,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,84,85,86,95,135,133,134,92,96,97,98,99,136,80,81,75,137,138,139,94,100,90,4,101,102,103,104,105,106,93,140,141,77,107,108,109,142,143,144,145,111,76,146,147,148,149,150,151,152,153,154,110,112,79,82,87,167,173,174,78,83,187,131,155,156,113,157,158,159,160,161,162,163,164,114,88,179,116,118,121,185,190,204,205,206,207,123]))),KF=(0,M.lazy)(()=>D(()=>import(`./NotificationSettings-9gidUwR6.js`).then(e=>({default:e.NotificationSettings})),__vite__mapDeps([208,1,2,9,12,73,14,138,11,43,21,22,44,4,209,7,97,24,16,65,15,58,33,18,19,20,146,38,56,77,53,60,111,35,57,173,174,101]))),qF=(0,M.lazy)(()=>D(()=>import(`./NotificationsPage-C77vP0-W.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([210,1,2,11,9,12,13,14,15,16,17,18,19,20,7,132,73,138,43,21,22,44,84,85,45,86,4,95,135,133,10,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,134,92,96,97,98,99,136,80,81,75,137,139,94,100,90,101,102,103,104,105,106,93,140,141,77,107,108,109,142,143,144,145,111,76,146,147,148,149,150,151,152,153,154,110,112,87,173,123]))),JF=(0,M.lazy)(()=>D(()=>import(`./OrganizationsPage-BVm7rDB9.js`).then(e=>({default:e.OrganizationsPage})),__vite__mapDeps([211,1,2,11,9,12,73,14,21,22,16,17,15,18,19,20,28,66,43,44,45,67,68]))),YF=(0,M.lazy)(()=>D(()=>import(`./OrganizersPage-DEeIqehb.js`).then(e=>({default:e.OrganizersPage})),__vite__mapDeps([212,1,2,11,9,12,73,14,21,22,24,7,16,17,15,18,19,20,49,26,25,27,28,65,58,33,64,104,68,69,148,149,43,45,173,205,34,35,36,37,38,39,40,53,59,60]))),XF=(0,M.lazy)(()=>D(()=>import(`./EventDashboardPage-CPeYZN6F.js`).then(e=>({default:e.EventDashboardPage})),__vite__mapDeps([213,1,2,11,9,12,134,46,15,17,18,19,20,49,26,25,14,27,28,139,51,33,34,35,36,39,40,65,58,140,141,56,77,53,59,68,69,110,111,57,173,24,7]))),ZF=(0,M.lazy)(()=>D(()=>import(`./PrivacyPolicyPage-DdO2at9f.js`).then(e=>({default:e.PrivacyPolicyPage})),__vite__mapDeps([214,2,1,9,73,14,16,27,15,12,173,24,7,187,29,30,31,188]))),QF=(0,M.lazy)(()=>D(()=>import(`./ProfileSettings-jwPlbCtl.js`).then(e=>({default:e.ProfileSettings})),__vite__mapDeps([215,1,2,11,9,12,10,13,14,15,16,17,18,19,20,21,22,23,24,7,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,81,94,95,85,96,97,98,99,100,90,4,101,102,103,104,105,106,93,144,173,204,134,205,216,155,156,123]))),$F=(0,M.lazy)(()=>D(()=>import(`./SearchPage-CaWUghPr.js`).then(e=>({default:e.SearchPage})),__vite__mapDeps([217,1,2,11,9,12,13,14,15,16,17,18,19,20,73,21,22,95,85,44,45,43,92,33,34,35,36,37,38,133,7,10,23,24,25,26,27,28,29,30,31,32,39,40,41,42,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,134,86,84,135,96,97,98,99,136,80,81,75,137,138,139,94,100,90,4,101,102,103,104,105,106,93,140,141,77,107,108,109,142,143,144,145,111,76,146,147,148,149,150,151,152,153,154,110,112,173,174,205,206,207,87,123]))),eI=(0,M.lazy)(()=>D(()=>import(`./SettingsPage-fotkjy56.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([218,1,2,9,7,73,14,21,11,12,22,15,24,16,148]))),tI=(0,M.lazy)(()=>D(()=>import(`./SomethingWrongPage-CD0S7e6h.js`).then(e=>({default:e.SomethingWrongPage})),__vite__mapDeps([219,1,2,11,9,12,43,73,14,21,22,45,86,4,46,15,16,17,18,19,20,49,52,33,34,35,36,37,38,39,40,53,26,25,27,28,94,13,7,10,23,24,29,30,31,32,41,42,44,47,48,50,51,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,95,85,96,97,98,99,81,100,90,101,102,103,104,105,106,146,77,111,174,123]))),nI=(0,M.lazy)(()=>D(()=>import(`./WalletPage-CHMw39TQ.js`).then(e=>({default:e.WalletPage})),__vite__mapDeps([220,1,2,9,73,14,21,11,12,22,24,7,16,17,15,18,19,20,49,50,51,33,34,35,36,39,40,52,37,38,53,80,81,27,54,65,58,32,145,56,111,57,110,77,160,60,174,101,4,158,43,155,97,98,156,159,151,152,153,48,154,112,161,162,163,205,59,216]))),rI=(0,M.lazy)(()=>D(()=>import(`./WalletMigrateV1Page-BwmTPwFw.js`).then(e=>({default:e.WalletMigrateV1Page})),__vite__mapDeps([221,1,2,9,73,14,21,11,12,22,159,155,97,98,156,24,7,16,17,15,18,19,20,68,112,222,173,163,162,161,223]))),iI=(0,M.lazy)(()=>D(()=>import(`./WalletDoubleTweakFixPage-LutVlhC0.js`).then(e=>({default:e.WalletDoubleTweakFixPage})),__vite__mapDeps([224,1,2,11,9,12,73,14,21,22,155,97,98,156,159,162,24,7,16,17,15,18,19,20,49,65,58,33,68,112,222,173,161]))),aI=(0,M.lazy)(()=>D(()=>import(`./WalletRecoveryPage-DAQJc43L.js`).then(e=>({default:e.WalletRecoveryPage})),__vite__mapDeps([225,1,2,11,9,12,7,73,14,21,22,24,16,17,15,18,19,20,68,70,112,222,173]))),oI=(0,M.lazy)(()=>D(()=>import(`./WalletSettingsPage-B71td1Ro.js`).then(e=>({default:e.WalletSettingsPage})),__vite__mapDeps([226,9,1,73,2,14,21,11,12,22,24,7,16,151,32,33,19,34,35,36,37,38,15,39,40,152,153,48,154,173,175,136,17,18,20,49,50,51,140,58,68,69,70]))),sI=(0,M.lazy)(()=>D(()=>import(`./LegacyWalletRecoveryPage-iT_1Ghtl.js`).then(e=>({default:e.LegacyWalletRecoveryPage})),__vite__mapDeps([227,2,1,9,73,14,21,11,12,22,24,7,47,48,16,112,15,20,173,223,155,97,98,156,159]))),cI=(0,M.lazy)(()=>D(()=>import(`./RemoteLoginSuccessPage-BRwZDCGc.js`).then(e=>({default:e.RemoteLoginSuccessPage})),__vite__mapDeps([228,1,2,9,4,24,7,17,15,12,18,19,20]))),lI=(0,M.lazy)(()=>D(()=>import(`./DonateCallbackPage-DS0kQPxP.js`).then(e=>({default:e.DonateCallbackPage})),__vite__mapDeps([229,1,2,9,22,24,7,16])));function uI(){let{user:e,metadata:t}=cn(),n=St(e?.pubkey??``,t);return e?(0,N.jsx)(yr,{to:n,replace:!0}):(0,N.jsx)(yr,{to:`/`,replace:!0})}function dI(){return(0,N.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,N.jsx)(ve,{className:`size-6 animate-spin text-muted-foreground`})})}function fI(){let{t:e}=A();return(0,N.jsx)(`footer`,{className:`bg-background mt-auto pt-6 sm:pt-12`,children:(0,N.jsx)(`div`,{className:`mx-auto max-w-7xl px-4 sm:px-6 py-8 text-xs text-muted-foreground`,children:(0,N.jsxs)(`nav`,{className:`flex flex-wrap items-center justify-center gap-x-5 gap-y-2`,children:[(0,N.jsx)(xr,{to:`/about`,className:`hover:text-foreground motion-safe:transition-colors`,children:e(`nav.about`)}),(0,N.jsx)(xr,{to:`/sponsors`,className:`hover:text-foreground motion-safe:transition-colors`,children:e(`nav.sponsors`)}),(0,N.jsx)(xr,{to:`/verify`,className:`hover:text-foreground motion-safe:transition-colors`,children:e(`nav.verify`)}),(0,N.jsx)(xr,{to:`/privacy`,className:`hover:text-foreground motion-safe:transition-colors`,children:e(`nav.privacy`)}),(0,N.jsx)(xr,{to:`/safety`,className:`hover:text-foreground motion-safe:transition-colors`,children:e(`nav.safety`)}),(0,N.jsx)(xr,{to:`/issues`,className:`hover:text-foreground motion-safe:transition-colors`,children:e(`nav.issues`)}),(0,N.jsx)(xr,{to:`/changelog`,className:`hover:text-foreground motion-safe:transition-colors`,children:e(`nav.changelog`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>void Vi(`https://gitlab.com/soapbox-pub/agora`),className:`hover:text-foreground motion-safe:transition-colors`,children:e(`nav.sourceCode`)})]})})})}function pI({narrow:e,hideFooter:t}){return(0,N.jsxs)(`div`,{className:O(`flex flex-col bg-background`,t?`h-dvh overflow-hidden`:`min-h-dvh`),children:[(0,N.jsx)(dd,{}),(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(dI,{}),children:(0,N.jsx)(`div`,{className:O(`min-w-0 w-full flex-1 mx-auto`,t&&`min-h-0`,e&&`max-w-3xl`),children:(0,N.jsx)(_r,{})})}),!t&&(0,N.jsx)(fI,{})]})}function mI(){return(0,N.jsxs)(wr,{children:[(0,N.jsx)(Fu,{}),(0,N.jsx)(jN,{}),(0,N.jsx)(TN,{}),(0,N.jsx)(BN,{}),(0,N.jsx)(UN,{}),(0,N.jsx)(RN,{}),(0,N.jsx)(LN,{}),(0,N.jsx)(zN,{}),(0,N.jsx)(hN,{children:(0,N.jsxs)(Cr,{children:[(0,N.jsx)(k,{path:`/embed/campaign/:nip19`,element:(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(dI,{}),children:(0,N.jsx)(CF,{})})}),(0,N.jsxs)(k,{element:(0,N.jsx)(pI,{narrow:!0}),children:[(0,N.jsx)(k,{path:`/feed`,element:(0,N.jsx)(gF,{})}),(0,N.jsx)(k,{path:`/my-dashboard`,element:(0,N.jsx)(RF,{})}),(0,N.jsx)(k,{path:`/notifications`,element:(0,N.jsx)(qF,{})}),(0,N.jsx)(k,{path:`/search`,element:(0,N.jsx)($F,{})}),(0,N.jsx)(k,{path:`/profile`,element:(0,N.jsx)(uI,{})}),(0,N.jsx)(k,{path:`/t/:tag`,element:(0,N.jsx)(IF,{})}),(0,N.jsx)(k,{path:`/g/:geohash`,element:(0,N.jsx)(FF,{})}),(0,N.jsx)(k,{path:`/settings`,element:(0,N.jsx)(eI,{})}),(0,N.jsx)(k,{path:`/settings/appearance`,element:(0,N.jsx)(DF,{})}),(0,N.jsx)(k,{path:`/settings/language`,element:(0,N.jsx)(UF,{})}),(0,N.jsx)(k,{path:`/settings/profile`,element:(0,N.jsx)(QF,{})}),(0,N.jsx)(k,{path:`/settings/wallet`,element:(0,N.jsx)(oI,{})}),(0,N.jsx)(k,{path:`/settings/notifications`,element:(0,N.jsx)(KF,{})}),(0,N.jsx)(k,{path:`/settings/content`,element:(0,N.jsx)(AF,{})}),(0,N.jsx)(k,{path:`/settings/advanced`,element:(0,N.jsx)(EF,{})}),(0,N.jsx)(k,{path:`/settings/network`,element:(0,N.jsx)(WF,{})}),(0,N.jsx)(k,{path:`/wallet`,element:(0,N.jsx)(nI,{})}),(0,N.jsx)(k,{path:`/wallet/legacy`,element:(0,N.jsx)(sI,{})}),(0,N.jsx)(k,{path:`/wallet/settings`,element:(0,N.jsx)(yr,{to:`/wallet`,replace:!0})}),(0,N.jsx)(k,{path:`/wallet/backup`,element:(0,N.jsx)(yr,{to:`/wallet`,replace:!0})}),(0,N.jsx)(k,{path:`/wallet/settings/backup`,element:(0,N.jsx)(yr,{to:`/wallet`,replace:!0})}),(0,N.jsx)(k,{path:`/wallet/settings/legacy`,element:(0,N.jsx)(yr,{to:`/wallet/legacy`,replace:!0})}),(0,N.jsx)(k,{path:`/wallet/recovery`,element:(0,N.jsx)(aI,{})}),(0,N.jsx)(k,{path:`/wallet/migrate-v1`,element:(0,N.jsx)(rI,{})}),(0,N.jsx)(k,{path:`/wallet/double-tweak-fix`,element:(0,N.jsx)(iI,{})}),(0,N.jsx)(k,{path:`/bitcoin`,element:(0,N.jsx)(yr,{to:`/wallet`,replace:!0})}),(0,N.jsx)(k,{path:`/help`,element:(0,N.jsx)(yr,{to:`/about`,replace:!0})}),(0,N.jsx)(k,{path:`/help/donors`,element:(0,N.jsx)(yr,{to:`/about/donors`,replace:!0})}),(0,N.jsx)(k,{path:`/help/activists`,element:(0,N.jsx)(yr,{to:`/about/recipients`,replace:!0})}),(0,N.jsx)(k,{path:`/help/recipients`,element:(0,N.jsx)(yr,{to:`/about/recipients`,replace:!0})}),(0,N.jsx)(k,{path:`/privacy`,element:(0,N.jsx)(ZF,{})}),(0,N.jsx)(k,{path:`/safety`,element:(0,N.jsx)(NF,{})}),(0,N.jsx)(k,{path:`/changelog`,element:(0,N.jsx)(OF,{})}),(0,N.jsx)(k,{path:`/issues`,element:(0,N.jsx)(tI,{})}),(0,N.jsx)(k,{path:`/organizers`,element:(0,N.jsx)(YF,{})}),(0,N.jsx)(k,{path:`/settings/verifier`,element:(0,N.jsx)(yr,{to:`/verify`,replace:!0})}),(0,N.jsx)(k,{path:`/remoteloginsuccess`,element:(0,N.jsx)(cI,{})}),(0,N.jsx)(k,{path:`/donate/callback`,element:(0,N.jsx)(lI,{})})]}),(0,N.jsx)(k,{element:(0,N.jsx)(pI,{narrow:!1,hideFooter:!0}),children:(0,N.jsx)(k,{path:`/messages`,element:(0,N.jsx)(LF,{})})}),(0,N.jsxs)(k,{element:(0,N.jsx)(pI,{narrow:!1}),children:[(0,N.jsx)(k,{path:`/`,element:(0,N.jsx)(vF,{})}),(0,N.jsx)(k,{path:`/campaigns`,element:(0,N.jsx)(bF,{})}),(0,N.jsx)(k,{path:`/campaigns/new`,element:(0,N.jsx)(yF,{})}),(0,N.jsx)(k,{path:`/campaigns/lists/:slug`,element:(0,N.jsx)(xF,{})}),(0,N.jsx)(k,{path:`/campaigns/all`,element:(0,N.jsx)(yr,{to:`/campaigns`,replace:!0})}),(0,N.jsx)(k,{path:`/groups`,element:(0,N.jsx)(kF,{})}),(0,N.jsx)(k,{path:`/groups/new`,element:(0,N.jsx)(jF,{})}),(0,N.jsx)(k,{path:`/events/new`,element:(0,N.jsx)(MF,{})}),(0,N.jsx)(k,{path:`/pledges`,element:(0,N.jsx)(wF,{})}),(0,N.jsx)(k,{path:`/pledges/new`,element:(0,N.jsx)(TF,{})}),(0,N.jsx)(k,{path:`/dashboard`,element:(0,N.jsx)(XF,{})}),(0,N.jsx)(k,{path:`/i/*`,element:(0,N.jsx)(PF,{})}),(0,N.jsx)(k,{path:`/about`,element:(0,N.jsx)(zF,{})}),(0,N.jsx)(k,{path:`/about/donors`,element:(0,N.jsx)(BF,{})}),(0,N.jsx)(k,{path:`/about/recipients`,element:(0,N.jsx)(VF,{})}),(0,N.jsx)(k,{path:`/sponsors`,element:(0,N.jsx)(HF,{})}),(0,N.jsx)(k,{path:`/verify`,element:(0,N.jsx)(JF,{})}),(0,N.jsx)(k,{path:`/organizations`,element:(0,N.jsx)(yr,{to:`/verify`,replace:!0})}),(0,N.jsx)(k,{path:`/about/activists`,element:(0,N.jsx)(yr,{to:`/about/recipients`,replace:!0})}),(0,N.jsx)(k,{path:`/:nip05/:dtag`,element:(0,N.jsx)(SF,{})}),(0,N.jsx)(k,{path:`/:nip19`,element:(0,N.jsx)(GF,{})}),(0,N.jsx)(k,{path:`*`,element:(0,N.jsx)(_F,{})})]})]})})]})}var hI=qa({plugins:[Ca()]}),gI=new ha({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:6e4,gcTime:3e5}}}),_I={appName:`Agora`,appId:`agora`,shareOrigin:void 0,homePage:`campaigns`,client:`naddr1qvzqqqru7cpzq7q6z5ns2hm5c8msyv83qwzxpxe52j8c4d4q5m92wsp9sflelkh9qqzkzem0wfssdl264k`,theme:`light`,useAppRelays:!0,useUserRelays:!1,relayMetadata:{relays:[],updatedAt:0},feedSettings:{feedIncludePosts:!0,feedIncludeComments:!0,feedIncludeReposts:!0,feedIncludeGenericReposts:!0,feedIncludeReactions:!1,feedIncludeZaps:!0,feedIncludeArticles:!0,showArticles:!0,showHighlights:!0,feedIncludeHighlights:!0,showEvents:!0,feedIncludeEvents:!0,showVines:!1,showPolls:!0,showTreasures:!1,showTreasureGeocaches:!1,showTreasureFoundLogs:!1,showColors:!1,showPeopleLists:!0,feedIncludeVines:!1,feedIncludePolls:!0,feedIncludeTreasureGeocaches:!1,feedIncludeTreasureFoundLogs:!1,feedIncludeColors:!1,feedIncludePeopleLists:!0,showDecks:!1,feedIncludeDecks:!1,showPhotos:!0,feedIncludePhotos:!0,showVideos:!0,feedIncludeNormalVideos:!0,feedIncludeShortVideos:!0,feedIncludeVoiceMessages:!0,showEmojiPacks:!1,feedIncludeEmojiPacks:!1,showCustomEmojis:!1,showUserStatuses:!1,showMusic:!1,feedIncludeMusicTracks:!1,feedIncludeMusicPlaylists:!1,showPodcasts:!1,feedIncludePodcastEpisodes:!1,feedIncludePodcastTrailers:!1,showDevelopment:!1,feedIncludeDevelopment:!1,showCommunities:!0,feedIncludeCommunities:!0,showBadges:!0,showBadgeDefinitions:!0,showProfileBadges:!0,showBadgeAwards:!0,feedIncludeBadgeDefinitions:!0,feedIncludeProfileBadges:!0,feedIncludeBadgeAwards:!0,feedIncludeVanish:!0,showBirdstar:!1,feedIncludeBirdDetections:!1,feedIncludeBirdex:!1,feedIncludeConstellations:!1,followsFeedShowReplies:!0},sidebarOrder:[`feed`,`communities`,`world`,`wallet`,`agent`,`messages`,`profile`,`notifications`,`search`,`settings`],nip85StatsPubkey:`5f68e85ee174102ca8978eef302129f081f03456c884185d5ec1c1224ab633ea`,blossomServerMetadata:{servers:[],updatedAt:0},useAppBlossomServers:!0,faviconUrl:`https://ditto.pub/api/favicon/{hostname}`,linkPreviewUrl:`https://ditto.pub/api/link-preview/{url}`,corsProxy:`https://proxy.shakespeare.diy/?url={href}`,contentWarningPolicy:`blur`,sentryDsn:``,sentryEnabled:!0,plausibleDomain:`agora.spot`,plausibleEndpoint:`https://analytics.soapbox.pub/api/event`,savedFeeds:[],autoplayVideos:!1,imageQuality:`compressed`,imageProxy:`https://wsrv.nl`,lowBandwidthMode:!1,torEnabled:!1,curatorPubkey:`932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d`,esploraApis:[`https://mempool.emzy.de/api`,`https://mempool.space/api`,`https://blockstream.info/api`],blockbookBaseUrl:`https://btc.trezor.io`,bip352IndexerUrl:`https://silentpayments.dev/blindbit/mainnet`,sidebarWidgets:[{id:`trends`},{id:`hot-posts`},{id:`ai-chat`}],aiBaseURL:`https://ai.shakespeare.diy/v1`,aiApiKey:``,aiModel:`google/gemma-4-26b`,aiSystemPrompt:``,translateWorkerUrl:`https://agora-translate.lemonknowsall.workers.dev/`};function vI(){try{let e=JSON.parse(`null`);return e?tn.parse(e):{}}catch{return{}}}var yI=vI(),bI={..._I,...yI,feedSettings:{..._I.feedSettings,...yI.feedSettings}};function xI({children:e}){let{config:t}=Zt(),{status:n}=Wo(),r=t.torEnabled?n===`connected`?`tor-connected`:`tor-pending`:`direct`;return(0,N.jsx)(Mo,{children:e},r)}function SI(){return Lo(),(0,N.jsx)(Ja,{head:hI,children:(0,N.jsx)(Ya,{storageKey:`nostr:app-config`,defaultConfig:bI,children:(0,N.jsx)(Fo,{children:(0,N.jsx)(Po,{children:(0,N.jsx)(lt,{client:gI,children:(0,N.jsx)(Xe,{storageKey:`nostr:login`,storage:Jn,children:(0,N.jsxs)(xI,{children:[(0,N.jsx)(No,{}),(0,N.jsx)(eo,{}),(0,N.jsx)(so,{}),(0,N.jsx)(mc,{children:(0,N.jsx)(hc,{children:(0,N.jsx)(Nn,{children:(0,N.jsx)(ml,{children:(0,N.jsx)(qo,{children:(0,N.jsx)(mI,{})})})})})})]})})})})})})})}if(Ct(),Ue(),Sn.isNativePlatform()){Sn.getPlatform()===`ios`&&D(async()=>{let{Keyboard:e}=await import(`./esm-E85gkrsK.js`);return{Keyboard:e}},__vite__mapDeps([230,4])).then(({Keyboard:e})=>{e.setAccessoryBarVisible({isVisible:!1}).catch(()=>{})}).catch(()=>{});function e(){let e=Ki()===`dark`;yn.setStyle({style:e?xn.Dark:xn.Light}).catch(()=>{})}e(),new MutationObserver(()=>e()).observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]});let t=new MutationObserver(()=>e()),n=()=>{let e=document.getElementById(`theme-vars`);e&&t.observe(e,{characterData:!0,childList:!0,subtree:!0})};n(),new MutationObserver(()=>n()).observe(document.head,{childList:!0})}(0,ea.createRoot)(document.getElementById(`root`)).render((0,N.jsx)(ca,{children:(0,N.jsx)(SI,{})})),requestAnimationFrame(()=>{document.getElementById(`preloader`)?.remove()}),!Sn.isNativePlatform()&&`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{scope:`/`}).catch(e=>{console.warn(`[sw] registration failed:`,e)})});export{Tc as A,Gu as C,Hc as D,Vc as E,io as F,ca as I,Wo as M,Vo as N,qc as O,ro as P,Zu as S,pl as T,ld as _,fP as a,od as b,$N as c,dN as d,iN as f,bd as g,Cd as h,GP as i,wc as j,Bc as k,QN as l,qM as m,lF as n,dP as o,QM as p,cF as r,iP as s,_F as t,DN as u,cd as v,Hu as w,nd as x,sd as y};