1import{j as c,a as mt,u as bt,r as A,D as mh,e as Jt,R as gh,H as xh,a8 as Na}from"./index.esm-BxWFwCRV.js";import{e as Hr,f as Ao,i as Rs,n as Is,g as Ps,h as je,o as Ls,t as dc,u as gn,d as Z,k as sr,b as uc,l as hi,m as fi,A as bh,a as yh,q as on}from"./admin-page-Dy2uu4-Z.js";import{B as en}from"./badge-CtVZLXvY.js";import{T as zs,a as $s,b as Mt,c as Te,d as _s,e as oe}from"./table-aikJtiyk.js";import{d as hc,T as fc,g as vh,h as Ji,c as wa}from"./date-utils-COFYKiIG.js";import{c as tn}from"./createLucideIcon-CDNZ6-WK.js";import{C as Ma}from"./confirm-dialog-N_9eulz5.js";import{D as Rt,r as It,s as Pt,t as Lt,u as zt,v as $t,a as $n,b as _n,c as Bn,d as Hn,e as Vn,f as Fn,g as Wn,h as Un,a0 as Oo,a9 as kh,P as Bs,Y as Sh,F as Ch,T as Nh,A as wh,x as Mh}from"./app-layout-Di5W296C.js";import{B}from"./button-C-SSWUAC.js";import{L as R,I as U}from"./label-DYLOJOI3.js";import{ae as jh,af as Th,ag as Eh,ah as Ah,ai as Oh,aj as Dh,ak as Rh,al as Ih,am as Ph,o as ja,y as Ta,an as Lh,ao as zh,ap as $h,aq as _h,ar as Bh,as as Hh,at as Vh}from"./index-CeXmm55O.js";import{c as re}from"./index-DSDuzvrg.js";import{D as Do,y as Ro,z as Io,A as Je,P as Gi,u as pc,b5 as Fh,b6 as mc,S as pi,C as gc}from"./index-Dg8k4TaQ.js";import{U as xc}from"./users-round-DDln4Jq0.js";import{B as Vr}from"./badge-check-BE1q6XP9.js";import{K as Wh}from"./key-round-BXSgVs0h.js";import{M as Po}from"./mail-D-17oFXd.js";import{U as Uh}from"./user-minus-D1Mrho4i.js";import{T as Hs}from"./trash-2-DtXE2Ow8.js";import{P as Lo}from"./pencil-B-HYA1SD.js";import{C as bc}from"./circle-check-Cxj0YP_N.js";import{T as Kh}from"./triangle-alert-BNjnHes0.js";import{S as Ge,a as Ye,b as Qe,c as Xe,d as W}from"./select-B1-_EmGF.js";import{T as qh}from"./timezones-CyaPygIe.js";import{t as J}from"./index-GQWG8pxW.js";import{L as yc}from"./loader-circle-B8EBsjRh.js";import{f as Jh,a as Gh,c as Yh,h as Qh}from"./source-partner-cycle-presentation-DkT-vPBm.js";import{l as Xh,S as Yi,g as Zh,b as ef,c as tf,d as vc}from"./source-partner-language-options-DleboiTE.js";import{L as nf}from"./layers-BD0vYt61.js";import{I as be}from"./input-error-C6rcpTIP.js";import{S as Fr}from"./switch-R83msVfT.js";import{C as kc}from"./clock-3-StRgMiRi.js";import{C as rf,a as sf,b as of,c as af,d as lf,e as cf}from"./command-Dt_1gsNE.js";import{P as df,a as uf,b as hf}from"./popover-Cvi_sG6Z.js";import{S as ff}from"./source-partner-service-categories-C8j05iTb.js";import{C as pf}from"./chevrons-up-down-CMPk3JOL.js";import{C as Sc}from"./index-CzMU6HRa.js";import{X as Cc}from"./sheet-DvMn9DJh.js";import{T as Qi}from"./index-BH5iaPk6.js";import{b as Ea}from"./hub-actions-B9KOtnaA.js";import{B as mf}from"./briefcase-business-gqdSKchU.js";import{M as gf}from"./map-pin-BkPmdd13.js";import{S as xf}from"./safe-html-lcY3DRu4.js";import{d as bf}from"./index-Dh4i1-J3.js";import{a as yf}from"./toggle-C_Z6TWXP.js";import{H as vf,a as kf,b as Sf,B as Cf,I as Nf,U as wf,S as Mf}from"./underline-B1QOfgwM.js";import{L as jf}from"./link-Cpc-Y851.js";import{C as Tf}from"./copy-L-YDBtJV.js";import{E as Ef}from"./eye-DPPPSx9o.js";import{L as Af}from"./link-2-D7sga4H_.js";import{S as Of}from"./save-OjXvbRlP.js";import{S as Nc}from"./settings-2-BvuiLzNm.js";import{M as Df}from"./minus-DABRMtBG.js";import{A as Rf}from"./arrow-up-down-DmynaTJE.js";import{b as If}from"./isSameYear-CeJLWhC0.js";import{S as mi}from"./skeleton-DYlpjNkD.js";import{T as Pf,a as Lf,b as an,c as ln}from"./tabs-CSTkul2i.js";import{u as zf}from"./use-typed-page-DXO81OlP.js";import{E as $f}from"./external-link-BT95J2U2.js";import{B as _f}from"./building-2-DMbCoBho.js";import{C as Bf}from"./chart-column-DxvYUjI8.js";import"./hub-page-C_jgOclR.js";import"./card-9qfFMYBn.js";import"./format-C7KB_mWR.js";import"./toDate-BoFoOYoS.js";import"./index-CMdn6XKl.js";import"./index-D4-ptLa7.js";import"./parseISO-BZ6cSQhi.js";import"./index-D-HdmRDX.js";import"./index-XmWYkZJ5.js";import"./app-logo-icon-CicL3Kjq.js";import"./index-C_SHgnPd.js";import"./alert-DJht7zHt.js";import"./checkbox-ZUXC5Ltz.js";import"./index-C0CRxioY.js";import"./building-ByqHc_3B.js";import"./index-wW2BnLNW.js";import"./log-out-DtCYhMEq.js";import"./index-BdQq_4o_.js";import"./chevron-up-PsQYZ1B6.js";import"./country-BjFmDPMO.js";import"./company-discovery-country-options-CicgbO63.js";import"./search-CBzGfPz5.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Hf=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],Vf=tn("AtSign",Hf);/** 7 * @license lucide-react v0.475.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Ff=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],Wf=tn("BellRing",Ff);/** 12 * @license lucide-react v0.475.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const Uf=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],Kf=tn("Braces",Uf);/** 17 * @license lucide-react v0.475.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const qf=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],Jf=tn("Coins",qf);/** 22 * @license lucide-react v0.475.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const Gf=[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]],Yf=tn("ListOrdered",Gf);/** 27 * @license lucide-react v0.475.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const Qf=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],Xf=tn("Quote",Qf);/** 32 * @license lucide-react v0.475.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const Zf=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],wc=tn("ScrollText",Zf),Aa={info:{variant:"secondary",className:"bg-blue-100 text-blue-800"},warning:{variant:"secondary",className:"bg-amber-100 text-amber-800"},error:{variant:"secondary",className:"bg-red-100 text-red-800"},critical:{variant:"destructive",className:""}};function ep({data:n,timezone:e}){return n.length===0?c.jsx(Hr,{title:"Activity log",description:"Administrative and account events for this organization.",children:c.jsx(Ao,{icon:wc,title:"No activity recorded yet",description:"Organization and administrator events will appear here as they occur."})}):c.jsx(Hr,{title:"Activity log",description:"Administrative and account events for this organization.",count:`${n.length.toLocaleStr
36ing()} ${n.length===1?"event":"events"}`,contentClassName:"max-h-[600px] overflow-auto",children:c.jsxs(zs,{className:Rs,containerClassName:"bg-[var(--hub-surface)]",children:[c.jsx($s,{className:Is,children:c.jsxs(Mt,{className:Ps,children:[c.jsx(Te,{className:je,children:"When"}),c.jsx(Te,{className:je,children:"User"}),c.jsx(Te,{className:je,children:"Action"}),c.jsx(Te,{className:je,children:"Category"}),c.jsx(Te,{className:je,children:"Severity"})]})}),c.jsx(_s,{children:n.map(t=>{var s;const r=Aa[t.severity]??Aa.info;return c.jsxs(Mt,{className:Ls,children:[c.jsx(oe,{className:"text-muted-foreground text-xs whitespace-nowrap",children:t.createdAt?hc(t.createdAt,e,fc.DATETIME_FULL):"N/A"}),c.jsx(oe,{children:t.user?c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:"text-sm",children:t.user.name}),c.jsx("span",{className:"text-muted-foreground text-xs",children:t.user.email})]}):c.jsx("span",{className:"text-muted-foreground text-xs",children:"System"})}),c.jsx(oe,{className:"text-sm",children:t.description??t.action.replace(/_/g," ")}),c.jsx(oe,{className:"text-muted-foreground text-xs capitalize",children:((s=t.category)==null?void 0:s.replace(/_/g," "))??"-"}),c.jsx(oe,{children:c.jsx(en,{variant:r.variant,className:`text-xs ${r.className}`,children:t.severity})})]},t.uuid)})})]})})}function tp({organization:n,organizationSlug:e,resetPasswordMember:t,setResetPasswordMember:r,passwordForm:s,onResetPassword:i,changeEmailMember:o,setChangeEmailMember:a,emailForm:l,onChangeEmail:d,removeMember:u,setRemoveMember:h,onConfirmRemoveMember:f,deleteMemberUser:p,setDeleteMemberUser:m,onConfirmDeleteMemberUser:g,companyPageAction:x,setCompanyPageAction:b,onConfirmCompanyPageAction:y,showEditCompanyPage:k,setShowEditCompanyPage:C,companyPageForm:v}){return c.jsxs(c.Fragment,{children:[c.jsx(Rt,{open:!!t,onOpenChange:w=>!w&&r(null),children:c.jsxs(It,{children:[c.jsxs(Pt,{children:[c.jsx(Lt,{children:"Reset Password"}),c.jsxs(zt,{children:["Set a new password for ",c.jsx("span",{className:"text-foreground font-medium",children:t==null?void 0:t.user.email}),"."]})]}),c.jsxs("div",{className:"space-y-2 py-2",children:[c.jsx(R,{htmlFor:"new-password",children:"New Password"}),c.jsx(U,{id:"new-password",type:"password",placeholder:"Enter new password",value:s.data.password,onChange:w=>s.setData("password",w.target.value)}),s.errors.password&&c.jsx("p",{className:"text-sm text-red-500",children:s.errors.password}),c.jsx("p",{className:"text-muted-foreground text-xs",children:"Minimum 8 characters with uppercase, lowercase, numbers, and symbols."})]}),c.jsxs($t,{children:[c.jsx(B,{variant:"outline",onClick:()=>r(null),disabled:s.processing,children:"Cancel"}),c.jsx(B,{onClick:i,disabled:s.processing||!s.data.password,children:s.processing?"Saving...":"Reset Password"})]})]})}),c.jsx(Rt,{open:!!o,onOpenChange:w=>!w&&a(null),children:c.jsxs(It,{children:[c.jsxs(Pt,{children:[c.jsx(Lt,{children:"Change Email"}),c.jsxs(zt,{children:["Update email for ",c.jsx("span",{className:"text-foreground font-medium",children:o==null?void 0:o.user.name}),". This will reset their email verification status."]})]}),c.jsxs("div",{className:"space-y-2 py-2",children:[c.jsx(R,{htmlFor:"new-email",children:"New Email"}),c.jsx(U,{id:"new-email",type:"email",placeholder:"Enter new email address",value:l.data.email,onChange:w=>l.setData("email",w.target.value)}),l.errors.email&&c.jsx("p",{className:"text-sm text-red-500",children:l.errors.email})]}),c.jsxs($t,{children:[c.jsx(B,{variant:"outline",onClick:()=>a(null),disabled:l.processing,children:"Cancel"}),c.jsx(B,{onClick:d,disabled:l.processing||!l.data.email,children:l.processing?"Saving...":"Change Email"})]})]})}),c.jsx(Ma,{open:!!u,title:"Remove Member From Organization",description:u?`Remove ${u.user.email} from ${n.name}? This will soft delete their membership and remove their access to this organization.`:"",confirmLabel:"Remove Member",confirmVariant:"destructive",onConfirm:f,onCancel:()=>h(null)}),c.jsx(Ma,{open:!!p,title:"Delete User Completely",description:p?`Delete ${p.user.email} completely? This will soft delete the user account and remove all of their organization memberships.`:"",confirmLabel:"Delete User",confirmVariant:"destructive",onConfirm:g,onCancel:()=>m(null)}),c.jsx($n,{open:!!x,onOpenChange:w=>!w&&b(null),children:c.jsxs(_n,{children:[c.jsxs(Bn,{children:[c.jsx(Hn,{children:x==="approve"?"Approve Company Page":"Unapprove Company Page"}),c.jsx(Vn,{children:x==="approve"?"This approves the company page immediately, notifies the claimant, and queues WordPress verification and link synchronization.":"This revokes the company page approval, sets it back to pending, and queues the WordPress verification update."})]}),c.jsxs(Fn,{children:[c.jsx(Wn,{children:"Cancel"}),c.jsx(Un,{onClick:y,children:x==="approve"?"Approve":"Unapprove"})]})]})}),c.jsx(Rt,{open:k,onOpenChange:C,children:c.jsxs(It,{children:[c.jsxs(Pt,{children:[c.jsx(Lt,{children:"Edit Company Page"}),c.jsx(zt,{children:"Update the WordPress Post ID and OA Company Slug for this company page. Please verify these values are correct as they directly affect the company's live listing on OA."})]}),c.jsxs("form",{onSubmit:w=>{w.preventDefault(),v.put(jh.url({organization:e,targetOrganization:n.slug}),{preserveScroll:!0,onSuccess:()=>C(!1)})},children:[c.jsxs("div",{className:"space-y-4 py-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{htmlFor:"wp_post_id",children:"WordPress Post ID"}),c.jsx(U,{id:"wp_post_id",type:"number",value:v.data.wp_post_id,onChange:w=>v.setData("wp_post_id",w.target.value),placeholder:"e.g. 12345"}),v.errors.wp_post_id&&c.jsx("p",{className:"text-sm text-red-600",children:v.errors.wp_post_id})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{htmlFor:"oa_company_
36slug",children:"OA Company Slug"}),c.jsx(U,{id:"oa_company_slug",value:v.data.oa_company_slug,onChange:w=>v.setData("oa_company_slug",w.target.value),placeholder:"e.g. company-name"}),v.errors.oa_company_slug&&c.jsx("p",{className:"text-sm text-red-600",children:v.errors.oa_company_slug})]})]}),c.jsxs($t,{children:[c.jsx(B,{type:"button",variant:"outline",onClick:()=>C(!1),children:"Cancel"}),c.jsx(B,{type:"submit",disabled:v.processing,children:"Save"})]})]})]})})]})}function np({organization:n}){const e=[{label:"Members",value:n.memberCount.toLocaleString(),note:"People with access"},{label:"Available credits",value:n.creditBalance.toLocaleString(),note:"Current balance"},{label:"Active plans",value:n.activeSubscriptionCount.toLocaleString(),note:"Active or trialing"},{label:"Last access",value:n.lastLoginAt?vh(n.lastLoginAt):"Never",note:"Latest member sign-in"}];return c.jsx(dc,{"aria-label":"Organization health summary",className:"overflow-hidden",children:c.jsx("dl",{className:"grid grid-cols-2 lg:grid-cols-4",children:e.map((t,r)=>c.jsxs("div",{className:re("min-w-0 px-4 py-3",r<2&&"border-b border-[var(--hub-border)] lg:border-b-0",r%2===1&&"border-l border-[var(--hub-border)]",r>=2&&"lg:border-l lg:border-[var(--hub-border)]"),children:[c.jsx("dt",{className:"text-[11px] font-medium text-[var(--hub-text-muted)]",children:t.label}),c.jsx("dd",{className:"mt-1 truncate text-base leading-5 font-medium tracking-[-0.01em] text-[var(--hub-text)] tabular-nums",children:t.value}),c.jsx("p",{className:"mt-0.5 truncate text-[11px] text-[var(--hub-text-muted)]",children:t.note})]},t.label))})})}function rp({members:n,organization:e,organizationSlug:t,formatTimestamp:r,onResetPassword:s,onChangeEmail:i,onRemoveMember:o,onDeleteMemberUser:a}){return c.jsx(Hr,{title:"Members",description:"People with access to this organization.",count:`${n.length.toLocaleString()} ${n.length===1?"member":"members"}`,children:n.length===0?c.jsx(Ao,{icon:xc,title:"No members found",description:"Members will appear here after they are granted access to this organization."}):c.jsxs(zs,{className:Rs,containerClassName:"bg-[var(--hub-surface)]",children:[c.jsx($s,{className:Is,children:c.jsxs(Mt,{className:Ps,children:[c.jsx(Te,{className:je,children:"Name"}),c.jsx(Te,{className:je,children:"Email"}),c.jsx(Te,{className:je,children:"Role"}),c.jsx(Te,{className:je,children:"Joined"}),c.jsx(Te,{className:re(je,"w-10")})]})}),c.jsx(_s,{children:n.map(l=>{var u;const d=((u=e.owner)==null?void 0:u.uuid)===l.user.uuid;return c.jsxs(Mt,{className:Ls,children:[c.jsx(oe,{className:"font-medium",children:l.user.name}),c.jsx(oe,{children:c.jsxs("span",{className:"flex items-center gap-1",children:[l.user.email,l.user.emailVerifiedAt&&c.jsxs("span",{className:"inline-flex shrink-0 text-emerald-600",children:[c.jsx(Vr,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{className:"sr-only",children:"Email verified"})]})]})}),c.jsx(oe,{children:c.jsx(en,{variant:"outline",children:l.role})}),c.jsx(oe,{className:"text-muted-foreground text-sm",children:l.joinedAt?r(l.joinedAt):"N/A"}),c.jsx(oe,{children:c.jsxs(Do,{children:[c.jsx(Ro,{asChild:!0,children:c.jsx(B,{variant:"ghost",size:"sm",className:"size-8 p-0","aria-label":`Actions for ${l.user.name}`,children:c.jsx(Oo,{className:"size-4"})})}),c.jsxs(Io,{align:"end",children:[c.jsxs(Je,{onClick:()=>s(l),children:[c.jsx(Wh,{className:"mr-2 size-4"}),"Reset password"]}),c.jsxs(Je,{onClick:()=>i(l),children:[c.jsx(Vf,{className:"mr-2 size-4"}),"Change email"]}),!l.user.emailVerifiedAt&&c.jsxs(c.Fragment,{children:[c.jsx(Gi,{}),c.jsxs(Je,{onClick:()=>{mt.post(Th.url({organization:t,targetOrganization:e.slug,user:l.user.uuid}),{},{preserveScroll:!0})},children:[c.jsx(Vr,{className:"mr-2 size-4"}),"Mark email verified"]}),c.jsxs(Je,{onClick:()=>{mt.post(Eh.url({organization:t,targetOrganization:e.slug,user:l.user.uuid}),{},{preserveScroll:!0})},children:[c.jsx(Po,{className:"mr-2 size-4"}),"Resend verification"]})]}),!d&&c.jsxs(c.Fragment,{children:[c.jsx(Gi,{}),c.jsxs(Je,{onClick:()=>o(l),className:"text-rose-600 focus:text-rose-600",children:[c.jsx(Uh,{className:"mr-2 size-4"}),"Remove from organization"]}),c.jsxs(Je,{onClick:()=>a(l),className:"text-rose-600 focus:text-rose-600",children:[c.jsx(Hs,{className:"mr-2 size-4"}),"Delete user completely"]})]})]})]})})]},l.uuid)})})]})})}function Kn(n){return{active:{variant:"default",label:"Active",className:"bg-green-100 text-green-800"},suspended:{variant:"secondary",label:"Suspended",className:"bg-amber-100 text-amber-800"},cancelled:{variant:"secondary",label:"Cancelled",className:"bg-red-100 text-red-800"},trialing:{variant:"default",label:"Trialing",className:"bg-blue-100 text-blue-800"},past_due:{variant:"secondary",label:"Past Due",className:"bg-orange-100 text-orange-800"},canceled:{variant:"secondary",label:"Canceled",className:"bg-gray-100 text-gray-800"}}[n]??{variant:"outline",label:n,className:""}}const yn=n=>n.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase());function Xi(n){const e={free:{variant:"outline",className:"text-gray-500"},standard:{variant:"default",className:"bg-blue-100 text-blue-800"},premium:{variant:"default",className:"bg-purple-100 text-purple-800"},starter:{variant:"secondary",className:"bg-slate-100 text-slate-800"},bronze:{variant:"secondary",className:"bg-orange-100 text-orange-800"},silver:{variant:"secondary",className:"bg-gray-200 text-gray-800"},gold:{variant:"secondary",className:"bg-yellow-100 text-yellow-800"},platinum:{variant:"secondary",className:"bg-purple-100 text-purple-800"}};return e[n]??e.free}function sp({organization:n,companyPage:e,formatTimestamp:t,onEditCompanyPage:r,onCompanyPageAction:s}){var d,u,h;const i=[{label:"Sales Hub",access:n.hubs.sales},{label:"Marketing Hub",access:n.hubs.marketing},{label:"Source Partner Hub",access:n.hubs.source_partner}],o=[{label:"Lifecycle",detail:n.status==="active"?"Organization is active and available.":`Organization is ${n.status}.`,healthy:n.status==="active"},{label:"Owner",detail:n.owner?`${n.owner.name} · ${n.owner.email}`:"No organization owner is assigned.",healthy:!!n.owner}
36,{label:"Plans",detail:n.activeSubscriptionCount>0?`${n.activeSubscriptionCount.toLocaleString()} active or trialing plan${n.activeSubscriptionCount===1?"":"s"}.`:"No active or trialing plans are on file.",healthy:n.activeSubscriptionCount>0},{label:"Billing",detail:n.paymentMethod?`${n.paymentMethod.type} ending in ${n.paymentMethod.lastFour}`:"No payment method is on file.",healthy:n.hasPaymentMethod}],a=!!(e!=null&&e.isPublished&&e.claimStatus==="approved"&&((d=e.oaCompanySlug)!=null&&d.trim())),l=ap(e);return c.jsxs("div",{className:"grid items-start gap-4 xl:grid-cols-[minmax(0,1.2fr)_minmax(22rem,0.8fr)]",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsx(gn,{title:"Hub access",description:"Current service tier and assigned users for each operational workspace.",contentClassName:"p-0",children:c.jsx("div",{className:"divide-y divide-[var(--hub-border)]",children:i.map(({label:f,access:p})=>{const m=Xi(p.tier);return c.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3.5",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("p",{className:"text-sm font-medium text-[var(--hub-text)]",children:f}),c.jsxs("p",{className:"mt-0.5 text-xs text-[var(--hub-text-muted)]",children:[p.userCount.toLocaleString()," assigned user",p.userCount===1?"":"s"]})]}),c.jsx(en,{variant:m.variant,className:m.className,children:yn(p.tier)})]},f)})})}),c.jsx(gn,{title:"Account record",description:"Stable ownership, billing, and regional details for support and audit work.",contentClassName:"p-0",children:c.jsx("dl",{className:"grid sm:grid-cols-2",children:[{label:"Owner",value:((u=n.owner)==null?void 0:u.name)??"Unassigned",note:((h=n.owner)==null?void 0:h.email)??"Assign an owner in organization administration"},{label:"Payment method",value:n.paymentMethod?`${n.paymentMethod.type} â¢â¢â¢â¢ ${n.paymentMethod.lastFour}`:"None",note:n.paymentMethod?"Available for billing":"No payment method on file"},{label:"Created",value:n.createdAt?t(n.createdAt):"N/A",note:"Organization creation date"},{label:"Timezone",value:Ji(n.timezone),note:Ji(n.timezone)===n.timezone?"Used for Admin timestamps":`${n.timezone} · Used for Admin timestamps`}].map((f,p)=>c.jsx(op,{...f,index:p},f.label))})})]}),c.jsx(gn,{title:"Account checks",description:"Signals that may need an administratorâs attention.",contentClassName:"p-0",children:c.jsxs("div",{className:"divide-y divide-[var(--hub-border)]",children:[o.map(f=>c.jsx(ip,{check:f},f.label)),c.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[c.jsx(Mc,{healthy:a}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"text-sm font-medium text-[var(--hub-text)]",children:"Company page"}),c.jsx("p",{className:"mt-0.5 text-xs leading-5 text-[var(--hub-text-muted)]",children:l})]}),e?c.jsxs(Do,{children:[c.jsx(Ro,{asChild:!0,children:c.jsx(B,{variant:"ghost",size:"sm",className:"size-8 shrink-0 p-0","aria-label":"Company page actions",children:c.jsx(Oo,{className:"size-4"})})}),c.jsxs(Io,{align:"end",children:[c.jsxs(Je,{onClick:r,children:[c.jsx(Lo,{className:"mr-2 size-4"}),"Edit company page"]}),c.jsx(Gi,{}),e.claimStatus==="approved"?c.jsxs(Je,{onClick:()=>s("unapprove"),children:[c.jsx(Vr,{className:"mr-2 size-4"}),"Remove approval"]}):c.jsxs(Je,{onClick:()=>s("approve"),children:[c.jsx(Vr,{className:"mr-2 size-4"}),"Approve company page"]})]})]}):null]})]})})]})}function ip({check:n}){return c.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[c.jsx(Mc,{healthy:n.healthy}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("p",{className:"text-sm font-medium text-[var(--hub-text)]",children:n.label}),c.jsx("p",{className:"mt-0.5 text-xs leading-5 text-[var(--hub-text-muted)]",children:n.detail})]})]})}function Mc({healthy:n}){const e=n?bc:Kh;return c.jsxs("span",{className:re("mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-[var(--hub-radius-control)]",n?"bg-emerald-50 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300":"bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300"),children:[c.jsx(e,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{className:"sr-only",children:n?"Healthy":"Needs attention"})]})}function op({label:n,value:e,note:t,index:r}){return c.jsxs("div",{className:re("min-w-0 px-4 py-3.5",r>0&&"border-t border-[var(--hub-border)]",r===1&&"sm:border-t-0 sm:border-l",r===3&&"sm:border-l"),children:[c.jsx("dt",{className:"text-[11px] font-medium text-[var(--hub-text-muted)]",children:n}),c.jsx("dd",{className:"mt-1 truncate text-sm font-medium text-[var(--hub-text)]",children:e}),c.jsx("p",{className:"mt-0.5 truncate text-xs text-[var(--hub-text-muted)]",children:t})]})}function ap(n){var e;return n?n.claimStatus==="pending"?"Claim approval is pending.":n.isPublished?n.claimStatus!=="approved"?"Company profile is published but not approved.":(e=n.oaCompanySlug)!=null&&e.trim()?"Company profile is published and approved.":"Approved, but the OA company page link is unavailable. WordPress sync may still be retrying.":"Company profile is not published.":"No company page has been created."}function lp({organization:n,hasUnsavedPartnerChanges:e=!1}){const t=pc(),{data:r,setData:s,put:i,processing:o,errors:a}=bt({name:n.name,status:n.status,timezone:n.timezone||"Etc/UTC"}),l=d=>{if(d.preventDefault(),e){J.error("Save Source Partner settings below before saving organization details.");return}
36i(Ah.url({organization:t,targetOrganization:n.slug}),{preserveScroll:!0,preserveState:!1})};return c.jsxs("form",{onSubmit:l,className:"grid gap-4 md:grid-cols-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{htmlFor:"name",children:"Organization Name"}),c.jsx(U,{id:"name",value:r.name,onChange:d=>s("name",d.target.value),placeholder:"Organization name",className:Z}),a.name&&c.jsx("p",{className:"text-sm text-red-500",children:a.name})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{htmlFor:"slug",children:"Org ID"}),c.jsx(U,{id:"slug",value:n.slug,disabled:!0,className:re(Z,"bg-[var(--hub-surface-subtle)]")}),c.jsx("p",{className:"text-muted-foreground text-xs",children:"Org ID cannot be changed"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{htmlFor:"status",children:"Status"}),c.jsxs(Ge,{value:r.status,onValueChange:d=>s("status",d),children:[c.jsx(Ye,{id:"status",className:Z,children:c.jsx(Qe,{placeholder:"Select status"})}),c.jsxs(Xe,{children:[c.jsx(W,{value:"active",children:"Active"}),c.jsx(W,{value:"suspended",children:"Suspended"}),c.jsx(W,{value:"cancelled",children:"Cancelled"})]})]}),a.status&&c.jsx("p",{className:"text-sm text-red-500",children:a.status})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{htmlFor:"timezone",children:"Timezone"}),c.jsxs(Ge,{value:r.timezone,onValueChange:d=>s("timezone",d),children:[c.jsx(Ye,{id:"timezone",className:Z,children:c.jsx(Qe,{placeholder:"Select timezone"})}),c.jsx(Xe,{children:qh.map(d=>c.jsx(W,{value:d.value,children:d.label},d.value))})]}),a.timezone&&c.jsx("p",{className:"text-sm text-red-500",children:a.timezone})]}),c.jsx("div",{className:"flex justify-end border-t border-[var(--hub-border)] pt-4 md:col-span-2",children:c.jsxs(B,{type:"submit",size:"sm",disabled:o,children:[o&&c.jsx(yc,{className:"mr-2 h-4 w-4 animate-spin"}),"Save organization"]})})]})}function cp(n){const e=n==null?void 0:n.countries,t=e&&typeof e=="object"&&"values"in e&&Array.isArray(e.values)?e.values.filter(i=>typeof i=="string"):[],r=e&&typeof e=="object"&&"mode"in e&&e.mode==="exclude"?"exclude":"include",s=Array.isArray(n==null?void 0:n.categories)?n.categories.filter(i=>typeof i=="string"):[];return{countries:t.length?{mode:r,values:t}:null,categories:s}}function Sr({values:n}){return c.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.map(e=>c.jsx("span",{className:"inline-flex min-h-6 items-center rounded-[var(--hub-radius-control)] bg-[var(--hub-surface-emphasis)] px-2 py-0.5 text-xs font-medium text-[var(--hub-text)]",children:e},e))})}function dp(n){var e;return((e=Yi.find(t=>t.value===n))==null?void 0:e.label)??n}function up({cycle:n}){const e=cp(n.leadFilters),t=e.countries!==null||e.categories.length>0||n.languages.length>0||n.countriesOfFulfillment.length>0||!!n.customEligibilityRule,r=`source-partner-cycle-${n.uuid}`;return c.jsxs("article",{"aria-labelledby":r,className:"mt-4 border-t border-[var(--hub-border)] pt-4",children:[c.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsxs("h4",{id:r,className:"text-sm font-semibold text-[var(--hub-text)] capitalize",children:[n.type," · ",n.cycle," cycle"]}),c.jsx("span",{className:n.isActive?"rounded-full bg-emerald-100 px-2 py-0.5 text-xs font-medium text-emerald-800":"rounded-full bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-800",children:n.isActive?"Active":"Inactive"})]}),c.jsx("p",{className:"mt-0.5 text-xs text-[var(--hub-text-muted)]",children:Jh(n.cycleStart,n.cycleEnd)})]}),c.jsxs("dl",{className:"grid grid-cols-2 gap-x-8 gap-y-2 sm:min-w-72",children:[c.jsxs("div",{children:[c.jsx("dt",{className:"text-xs text-[var(--hub-text-muted)]",children:"Capacity"}),c.jsxs("dd",{className:"mt-0.5 text-sm font-medium text-[var(--hub-text)]",children:[n.discoveryCallCapacity.toLocaleString()," discovery ",n.discoveryCallCapacity===1?"call":"calls"]})]}),c.jsxs("div",{children:[c.jsx("dt",{className:"text-xs text-[var(--hub-text-muted)]",children:"Allocation"}),c.jsx("dd",{className:"mt-0.5 text-sm font-medium text-[var(--hub-text)]",children:Gh(n.leadAllocationMode)})]})]})]}),t?c.jsxs("dl",{className:"mt-4 grid gap-3 border-t border-[var(--hub-border)] pt-4",children:[e.countries?c.jsxs("div",{className:"grid gap-2 sm:grid-cols-[10rem_minmax(0,1fr)] sm:items-start",children:[c.jsx("dt",{className:"text-xs font-medium text-[var(--hub-text-muted)]",children:"Countries"}),c.jsxs("dd",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[c.jsx("span",{className:"text-xs text-[var(--hub-text-muted)]",children:e.countries.mode==="exclude"?"Exclude":"Include"}),c.jsx(Sr,{values:e.countries.values.map(Yh)})]})]}):null,e.categories.length?c.jsxs("div",{className:"grid gap-2 sm:grid-cols-[10rem_minmax(0,1fr)] sm:items-start",children:[c.jsx("dt",{className:"text-xs font-medium text-[var(--hub-text-muted)]",children:"Services"}),c.jsx("dd",{className:"min-w-0",children:c.jsx(Sr,{values:e.categories.map(Qh)})})]}):null,n.languages.length?c.jsxs("div",{className:"grid gap-2 sm:grid-cols-[10rem_minmax(0,1fr)] sm:items-start",children:[c.jsx("dt",{className:"text-xs font-medium text-[var(--hub-text-muted)]",children:"Languages"}),c.jsx("dd",{className:"min-w-0",children:c.jsx(Sr,{values:n.languages.map(Xh)})})]}):null,n.countriesOfFulfillment.length?c.jsxs("div",{className:"grid gap-2 sm:grid-cols-[10rem_minmax(0,1fr)] sm:items-start",children:[c.jsx("dt",{className:"text-xs font-medium text-[var(--hub-text-muted)]",children:"Countries of fulfilment"}),c.jsx("dd",{className:"min-w-0",children:c.jsx(Sr,{values:n.countriesOfFulfillment.map(dp)})})]}):null,n.customEligibilityRule?c.jsxs("div",{className:"grid gap-2 sm:grid-cols-[10rem_minmax(0,1fr)] sm:items-start",children:[c.jsx("dt",{className:"text-xs font-medium text-[var(--hub-text-muted)]",children:"Custom eligibility rule"}),c.jsx("dd",{className:"text-xs whitespace-pre-wrap text-[var(--hub-text)]",children:n.customEligibilityRule})]}):null]}):c.jsx("p",{className:"mt-4 border-t border-[var(--hub-border)] pt-4 text-xs text-[var(--hub-text-muted)]",children:"No country or service restrictions; no partner capabilities specified"})]})}function hp({cycle:n}){return c.jsxs("section",{className:"px-[var(--hub-surface-padding)] py-5",children:[c.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[c.jsx(kh,{className:"size-4 text-[var(--hub-accent)]","aria-hidden":"true"}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-text)]",children:"Eligibility and capacity"}),c.jsx("p",{className:"mt-0.5 text-xs text-[var(--hub-text-muted)]",children:"These rules determine which qualified leads can be matched with this Source Partner."})]})]}),c.jsx("div",{className:"overflow-hidden rounded-[var(--hub-radius-control)] border border-[var(--hub-border)]",children:c.jsxs("div",{className:"p-4",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[var(--hub-text)]",children:[c.jsx(nf,{className:"size-3.5 text-[var(--hub-text-muted)]","aria-hidden":"true"}),"Latest subscription cycle"]}),c.jsx("p",{className:"mt-1 text-xs text-[var(--hub-text-muted)]",children:"Managed from Source Partner cycles. Read-only here."}),n?c.jsx(up,{cycle:n}):c.jsx("p",{className:"mt-4 text-xs text-[var(--hub-text-muted)]",children:"No Source Partner subscription cycle found."})]})})]})}function fp(n){return n?["when_selected","always"]:["always","never"]}function Oa(n,e){return n&&e==="never"?"when_selected":!n&&e==="when_selected"?"never":e}function jc(n,e,t){return{isSelectableMeetingPoc:n,emailCcMode:Oa(n,e),calendarInviteMode:Oa(n,t)}}function Tc(n){return n.trim().toLowerCase()}function pp(n){return n.map(e=>({...e,key:Tc(e.key)})).filter(e=>e.key!=="")}function mp(n,e){if(n===null)return{value:"__default__",unavailableKey:null};const t=Tc(n),r=e.find(s=>
36s.key===t);return r?{value:r.key,unavailableKey:null}:{value:n,unavailableKey:n}}function gp({contact:n,contactId:e,templateOptions:t,errors:r,errorPrefix:s,onChange:i}){const o=r[`${s}.intro_email_template_key`],a=mp(n.introEmailTemplateKey,t),[l,d]=A.useState(!!o);return A.useEffect(()=>{o&&d(!0)},[o]),c.jsxs("details",{open:l,onToggle:u=>d(u.currentTarget.open),className:"rounded-[var(--hub-radius-control)] border border-[var(--hub-border)] bg-[var(--hub-surface)]",children:[c.jsx("summary",{className:"cursor-pointer px-4 py-3 text-sm font-medium text-[var(--hub-text)]",children:"Advanced settings"}),c.jsxs("div",{className:"grid gap-4 border-t border-[var(--hub-border)] p-4 lg:grid-cols-2",children:[c.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-[var(--hub-radius-control)] bg-[var(--hub-surface-subtle)] p-3",children:[c.jsxs("div",{children:[c.jsx(R,{htmlFor:`${e}-primary`,children:"Primary administrative contact"}),c.jsx("p",{className:"mt-1 text-xs text-[var(--hub-text-muted)]",children:"Identifies the Partner's administrative owner."})]}),c.jsx(Fr,{id:`${e}-primary`,checked:n.isPrimary,onCheckedChange:u=>i({isPrimary:u})})]}),c.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-[var(--hub-radius-control)] bg-[var(--hub-surface-subtle)] p-3",children:[c.jsxs("div",{children:[c.jsx(R,{htmlFor:`${e}-lead-notifications`,children:"Lead notifications"}),c.jsx("p",{className:"mt-1 text-xs text-[var(--hub-text-muted)]",children:"Separate from email CC and calendar instructions."})]}),c.jsx(Fr,{id:`${e}-lead-notifications`,checked:n.receivesLeadNotifications,onCheckedChange:u=>i({receivesLeadNotifications:u})})]}),c.jsxs("div",{className:"space-y-1.5 lg:col-span-2",children:[c.jsx(R,{htmlFor:`${e}-template`,children:"Introduction template"}),c.jsxs(Ge,{value:a.value,onValueChange:u=>i({introEmailTemplateKey:u==="__default__"?null:u}),children:[c.jsx(Ye,{id:`${e}-template`,className:Z,"aria-invalid":!!o,children:c.jsx(Qe,{})}),c.jsxs(Xe,{children:[c.jsx(W,{value:"__default__",children:"Use default template"}),a.unavailableKey?c.jsxs(W,{value:a.unavailableKey,children:["Unavailable template: ",a.unavailableKey]}):null,t.map(u=>c.jsx(W,{value:u.key,children:u.label||u.key},u.key))]})]}),a.unavailableKey?c.jsxs("p",{className:"text-xs text-amber-700",role:"status",children:["Template â",a.unavailableKey,"â is unavailable. Choose another template or restore that key."]}):null,c.jsx(be,{message:o,className:"text-xs"})]})]})]})}const xp=[{value:1,shortLabel:"Mon",label:"Monday"},{value:2,shortLabel:"Tue",label:"Tuesday"},{value:3,shortLabel:"Wed",label:"Wednesday"},{value:4,shortLabel:"Thu",label:"Thursday"},{value:5,shortLabel:"Fri",label:"Friday"},{value:6,shortLabel:"Sat",label:"Saturday"},{value:7,shortLabel:"Sun",label:"Sunday"}],bp=["Asia/Manila","Australia/Sydney","Europe/London","America/New_York","America/Chicago","America/Los_Angeles"];function yp({contactId:n,timezone:e,windows:t,errors:r,errorPrefix:s,onTimezoneChange:i,onWindowsChange:o}){const a=`sp-contact-timezone-${n}`,l=r[`${s}.availability_timezone`],d=r[`${s}.availability_windows`],u=(f,p)=>{o(t.map((m,g)=>g===f?{...m,...p}:m))},h=(f,p)=>{const m=t[f],g=m.weekdays.includes(p)?m.weekdays.filter(x=>x!==p):[...m.weekdays,p].sort((x,b)=>x-b);u(f,{weekdays:g})};return c.jsxs("fieldset",{className:"space-y-3 rounded-[var(--hub-radius-control)] border border-[var(--hub-border)] bg-[var(--hub-surface)] p-3.5",children:[c.jsx("legend",{className:"px-1 text-xs font-semibold text-[var(--hub-text)]",children:"Usual working hours"}),c.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(220px,0.7fr)_minmax(0,1.3fr)] md:items-end",children:[c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:a,className:"text-xs",children:"Timezone"}),c.jsx(U,{id:a,list:`${a}-options`,value:e??"",onChange:f=>i(f.target.value||null),placeholder:"Asia/Manila","aria-invalid":!!l,"aria-describedby":l?`${a}-error`:void 0,className:Z}),c.jsx("datalist",{id:`${a}-options`,children:bp.map(f=>c.jsx("option",{value:f},f))}),c.jsx(be,{id:`${a}-error`,message:l,className:"text-xs"})]}),c.jsx("p",{className:"text-xs leading-5 text-[var(--hub-text-muted)]",children:"Times are evaluated in this timezone."})]}),t.length===0?c.jsxs("div",{className:"rounded-[var(--hub-radius-control)] border border-dashed border-[var(--hub-border)] px-3 py-4 text-center",children:[c.jsx("p",{className:"text-xs font-medium text-[var(--hub-text)]",children:"Working hours not provided"}),c.jsx("p",{className:"mt-1 text-xs text-[var(--hub-text-muted)]",children:"The SDR can still select this POC."})]}):c.jsx("div",{className:"space-y-2.5",children:t.map((f,p)=>{var y;const m=`${s}.availability_windows.${p}
36.weekdays`,g=r[m]??((y=Object.entries(r).find(([k])=>k.startsWith(`${m}.`)))==null?void 0:y[1]),x=r[`${s}.availability_windows.${p}.start_time`],b=r[`${s}.availability_windows.${p}.end_time`];return c.jsx("div",{className:"rounded-[var(--hub-radius-control)] border border-[var(--hub-border)] p-3",children:c.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[c.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[c.jsx("span",{className:"block text-xs font-medium text-[var(--hub-text)]",children:"Days and times"}),c.jsx("div",{className:"flex flex-wrap gap-1","aria-label":`Availability window ${p+1} weekdays`,children:xp.map(k=>{const C=f.weekdays.includes(k.value);return c.jsx("button",{type:"button","aria-label":k.label,"aria-pressed":C,onClick:()=>h(p,k.value),className:re("h-8 min-w-10 rounded-md border px-2 text-[11px] font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-[var(--hub-accent)] focus-visible:ring-offset-1",C?"border-[var(--hub-accent)] bg-[var(--hub-surface-emphasis)] text-[var(--hub-accent)]":"border-[var(--hub-control-border)] bg-[var(--hub-control-background)] text-[var(--hub-text-muted)] hover:text-[var(--hub-text)]"),children:k.shortLabel},k.value)})}),c.jsx(be,{message:g,className:"text-xs"})]}),c.jsxs("div",{className:"grid grid-cols-[minmax(100px,1fr)_auto_minmax(100px,1fr)_auto] items-end gap-2",children:[c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:`${n}-window-${p}-start`,className:"text-xs",children:"Starts"}),c.jsx(U,{id:`${n}-window-${p}-start`,type:"time",step:60,value:f.startTime,onChange:k=>u(p,{startTime:k.target.value}),"aria-invalid":!!x,className:Z}),c.jsx(be,{message:x,className:"text-xs"})]}),c.jsx(kc,{className:"mb-2.5 size-3.5 text-[var(--hub-text-muted)]","aria-hidden":"true"}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:`${n}-window-${p}-end`,className:"text-xs",children:"Ends"}),c.jsx(U,{id:`${n}-window-${p}-end`,type:"time",step:60,value:f.endTime,onChange:k=>u(p,{endTime:k.target.value}),"aria-invalid":!!b,className:Z}),c.jsx(be,{message:b,className:"text-xs"})]}
36),c.jsx(B,{type:"button",size:"icon",variant:"ghost",className:"size-9 text-[var(--hub-text-muted)] hover:text-red-600","aria-label":`Remove availability window ${p+1}`,onClick:()=>o(t.filter((k,C)=>C!==p)),children:c.jsx(Hs,{className:"size-3.5"})})]})]})},`${n}-window-${p}`)})}),c.jsx(be,{message:d,className:"text-xs"}),c.jsxs(B,{type:"button",size:"sm",variant:"outline",className:"gap-1.5",onClick:()=>o([...t,{weekdays:[1,2,3,4,5],startTime:"09:00",endTime:"17:00"}]),children:[c.jsx(Bs,{className:"size-3.5"}),"Add working hours"]})]})}const vp={1:"Mon",2:"Tue",3:"Wed",4:"Thu",5:"Fri",6:"Sat",7:"Sun"};function Da(n){const[e,t="00"]=n.split(":"),r=Number(e),s=r>=12?"PM":"AM";return`${r%12||12}:${t} ${s}`}function kp(n){return n.join(",")==="1,2,3,4,5"?"MonâFri":n.join(",")==="6,7"?"SatâSun":n.map(e=>vp[e]).filter(Boolean).join(", ")}function Ra(n,e){return n==="when_selected"?"When selected":n==="always"?e==="email"?"Always CC":"Always include":"Never include"}function Sp(n){const e=n.availabilityWindows[0];if(!e||!n.availabilityTimezone)return"Working hours not provided";const t=`${kp(e.weekdays)} · ${Da(e.startTime)}â${Da(e.endTime)}`,r=n.availabilityWindows.length>1?` +${n.availabilityWindows.length-1} more`:"";return`${t}${r} · ${n.availabilityTimezone}`}function Cp(n){return n.trim().split("_").filter(Boolean).map(e=>`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()}`).join(" ")}function Np(n){const e=n.routingConditions.serviceCategories.map(Cp).filter(Boolean);return e.length>0?e.join(" · "):"All services"}function wp(n){const{geographyMode:e,countryCodes:t,regionKeys:r}=n.routingConditions;if(e==="all")return"All locations";const s=Zh(t,r)||"No locations selected";return e==="include"?`Only in · ${s}`:`Everywhere except · ${s}`}function Ec(n){var o;const e=n.name.trim()||"this POC",t=[];n.emailCcMode==="when_selected"&&t.push("the introduction email CC"),n.calendarInviteMode==="when_selected"&&t.push("calendar invitation");const r=t.length===2?` When selected, add ${e} to the introduction email CC and calendar invitation.`:t.length===1?` When selected, add ${e} to ${t[0]}.`:"",s=[];n.emailCcMode==="always"&&s.push(`Always add ${e} to the introduction email CC.`),n.calendarInviteMode==="always"&&s.push(`Always add ${e} to the calendar invitation.`);const i=(o=n.notes)!=null&&o.trim()?` ${n.notes.trim()}`:"";return{selectableLabel:n.isSelectableMeetingPoc?"SDR can select":"Standing instruction",emailLabel:Ra(n.emailCcMode,"email"),calendarLabel:Ra(n.calendarInviteMode,"calendar"),workingHoursLabel:Sp(n),serviceConditionsLabel:Np(n),geographyConditionsLabel:wp(n),summary:`${n.isSelectableMeetingPoc?`SDR may select ${e}.`:`${e} is not selected by the SDR.`}${r} ${s.join(" ")}`.trim()+i}}function Mp({routingConditions:n,contactId:e,errors:t,errorPrefix:r,onChange:s}){const[i,o]=A.useState(!1),a=`${e}-service-categories-label`,l=`${e}-geography-label`,d=`${r}.routing_conditions.service_categories`,u=`${r}.routing_conditions.country_codes`,h=`${r}.routing_conditions.region_keys`,f=gi(t,d),p=gi(t,u)??gi(t,h),m=y=>{const k=n.serviceCategories,C=k.includes(y)?k.filter(v=>v!==y):[...k,y];s({...n,serviceCategories:C})},g=y=>{s({...n,...vc(y,n.countryCodes,n.regionKeys)})},x=y=>{const k=n.regionKeys,C=k.includes(y)?k.filter(v=>v!==y):[...k,y];s({...n,regionKeys:C})},b=y=>{const k=n.countryCodes,C=k.includes(y)?k.filter(v=>v!==y):[...k,y];s({...n,countryCodes:C})};return c.jsxs("div",{className:"space-y-4 border-t border-[var(--hub-border)] pt-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{children:[c.jsx(R,{id:a,className:"text-xs",children:"Which services is this instruction for?"}),c.jsx("p",{className:"mt-1 text-[11px] leading-4 text-[var(--hub-text-muted)]",children:"Leave all unselected when this POC can support every service."})]}),c.jsx("div",{role:"group","aria-labelledby":a,className:"grid gap-1.5 sm:grid-cols-2 xl:grid-cols-4",children:ff.map(y=>{const k=n.serviceCategories.includes(y.value);return c.jsx(Ia,{selected:k,onClick:()=>m(y.value),children:y.label},y.value)})}),c.jsx(be,{message:f,className:"text-xs"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{children:[c.jsx(R,{id:l,className:"text-xs",children:"Which lead locations is this instruction for?"}),c.jsx("p",{className:"mt-1 text-[11px] leading-4 text-[var(--hub-text-muted)]",children:"The SDR sees whether the qualified lead matches this rule and still makes the final POC selection."})]}),c.jsx("div",{role:"radiogroup","aria-labelledby":l,className:"grid gap-2 lg:grid-cols-3",children:ef.map(y=>{const k=n.geographyMode===y.value;return c.jsxs("button",{type:"button",role:"radio","aria-checked":k,onClick:()=>
36g(y.value),className:re("rounded-md border px-3 py-2 text-left transition-colors outline-none focus-visible:ring-2 focus-visible:ring-[var(--hub-accent)]",k?"border-[var(--hub-accent)] bg-[var(--hub-surface-emphasis)]":"border-[var(--hub-control-border)] bg-[var(--hub-control-background)] hover:bg-[var(--hub-surface-subtle)]"),children:[c.jsx("span",{className:"block text-xs font-medium text-[var(--hub-text)]",children:y.label}),c.jsx("span",{className:"mt-1 block text-[11px] leading-4 text-[var(--hub-text-muted)]",children:y.description})]},y.value)})}),n.geographyMode!=="all"?c.jsxs("div",{className:"space-y-3 rounded-md border border-[var(--hub-border)] bg-[var(--hub-surface-subtle)] p-3",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-xs font-medium text-[var(--hub-text)]",children:"Region shortcuts"}),c.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:tf.map(y=>c.jsx(Ia,{selected:n.regionKeys.includes(y.value),onClick:()=>x(y.value),children:y.label},y.value))})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{className:"text-xs",children:"Individual countries"}),c.jsxs(df,{open:i,onOpenChange:o,children:[c.jsx(uf,{asChild:!0,children:c.jsxs(B,{type:"button",variant:"outline",className:re(Z,"w-full justify-between sm:max-w-sm"),children:["Add or remove countries",c.jsx(pf,{className:"size-3.5 opacity-60","aria-hidden":"true"})]})}),c.jsx(hf,{className:"w-[min(24rem,var(--radix-popover-trigger-width))] p-0",align:"start",children:c.jsxs(rf,{children:[c.jsx(sf,{placeholder:"Search countries..."}),c.jsxs(of,{children:[c.jsx(af,{children:"No country found."}),c.jsx(lf,{children:Yi.map(y=>{const k=n.countryCodes.includes(y.value);return c.jsxs(cf,{value:`${y.label} ${y.value}`,onSelect:()=>b(y.value),children:[c.jsx(Sc,{className:re("size-4",k?"opacity-100":"opacity-0"),"aria-hidden":"true"}),c.jsx("span",{children:y.label})]},y.value)})})]})]})})]}),n.countryCodes.length>0?c.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.countryCodes.map(y=>{var C;const k=((C=Yi.find(v=>v.value===y))==null?void 0:C.label)??y;return c.jsxs("button",{type:"button",onClick:()=>b(y),className:"inline-flex items-center gap-1 rounded-full border border-[var(--hub-control-border)] bg-[var(--hub-control-background)] px-2 py-1 text-[11px] text-[var(--hub-text)]",children:[k,c.jsx(Cc,{className:"size-3","aria-hidden":"true"})]},y)})}):null]})]}):null,c.jsx(be,{message:p,className:"text-xs"})]})]})}function Ia({selected:n,onClick:e,children:t}){return c.jsxs("button",{type:"button","aria-pressed":n,onClick:e,className:re("flex min-h-9 items-center gap-2 rounded-md border px-2.5 py-2 text-left text-xs transition-colors outline-none focus-visible:ring-2 focus-visible:ring-[var(--hub-accent)] focus-visible:ring-offset-1",n?"border-[var(--hub-accent)] bg-[var(--hub-surface-emphasis)] text-[var(--hub-accent)]":"border-[var(--hub-control-border)] bg-[var(--hub-control-background)] text-[var(--hub-text)] hover:bg-[var(--hub-surface-subtle)]"),children:[c.jsx("span",{className:re("flex size-4 shrink-0 items-center justify-center rounded border",n?"border-[var(--hub-accent)] bg-[var(--hub-accent)] text-white":"border-[var(--hub-control-border)]"),children:n?c.jsx(Sc,{className:"size-3","aria-hidden":"true"}):null}),c.jsx("span",{children:t})]})}function gi(n,e){var t;return n[e]??((t=Object.entries(n).find(([r])=>r.startsWith(`${e}.`)))==null?void 0:t[1])}const jp=[{value:"when_selected",label:"When the SDR selects them"},{value:"always",label:"Always add to CC"},{value:"never",label:"Never add to email"}],Tp=[{value:"when_selected",label:"When the SDR selects them"},{value:"always",label:"Always add to invite"},{value:"never",label:"Never add to invite"}];function Ep({contact:n,contactId:e,errors:t,errorPrefix:r,onChange:s}){const i=u=>{s(jc(u,n.emailCcMode,n.calendarInviteMode))},o=fp(n.isSelectableMeetingPoc),a=jp.filter(u=>o.includes(u.value)),l=Tp.filter(u=>o.includes(u.value)),d=t[r];return c.jsxs("fieldset",{className:"space-y-3 rounded-[var(--hub-radius-control)] border border-[var(--hub-border)] bg-[var(--hub-surface)] p-3.5",children:[c.jsx("legend",{className:"px-1 text-xs font-semibold text-[var(--hub-text)]",children:"Routing questions"}),c.jsxs("div",{className:"grid gap-3 lg:grid-cols-3",children:[c.jsxs("div",{className:"flex items-start justify-between gap-4 roun
36ded-[var(--hub-radius-control)] border border-[var(--hub-border)] bg-[var(--hub-surface-subtle)] px-3 py-2.5",children:[c.jsxs("div",{children:[c.jsx(R,{htmlFor:`${e}-selectable`,className:"text-xs",children:"Can the SDR choose this person for a meeting?"}),c.jsx("p",{className:"mt-1 text-[11px] leading-4 text-[var(--hub-text-muted)]",children:"Can be chosen for an eligible meeting."})]}),c.jsx(Fr,{id:`${e}-selectable`,checked:n.isSelectableMeetingPoc,onCheckedChange:i})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:`${e}-email-cc`,className:"text-xs",children:"Should the SDR add them to the introduction email CC?"}),c.jsxs(Ge,{value:n.isSelectableMeetingPoc&&n.emailCcMode==="never"?"when_selected":n.emailCcMode,onValueChange:u=>s({emailCcMode:u}),children:[c.jsx(Ye,{id:`${e}-email-cc`,className:Z,children:c.jsx(Qe,{})}),c.jsx(Xe,{children:a.map(u=>c.jsx(W,{value:u.value,children:u.label},u.value))})]})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:`${e}-calendar-mode`,className:"text-xs",children:"Should the SDR add them to the calendar invitation?"}),c.jsxs(Ge,{value:n.isSelectableMeetingPoc&&n.calendarInviteMode==="never"?"when_selected":n.calendarInviteMode,onValueChange:u=>s({calendarInviteMode:u}),children:[c.jsx(Ye,{id:`${e}-calendar-mode`,className:Z,children:c.jsx(Qe,{})}),c.jsx(Xe,{children:l.map(u=>c.jsx(W,{value:u.value,children:u.label},u.value))})]})]})]}),c.jsx(Mp,{routingConditions:n.routingConditions,contactId:e,errors:t,errorPrefix:r,onChange:u=>s({routingConditions:u})}),c.jsx(be,{message:d,className:"text-xs"})]})}function Ap({contact:n,index:e,templateOptions:t,errors:r,onChange:s,onClose:i}){const o=`sp-contact-${n.uuid}`,a=`contacts.${e}`,l=u=>s({...n,...u}),d=Ec(n);return c.jsxs("article",{id:`sp-contact-editor-${n.uuid}`,className:"overflow-hidden rounded-[var(--hub-radius-control)] border border-[var(--hub-border)] bg-[var(--hub-surface-subtle)]",children:[c.jsxs("header",{className:"flex items-center justify-between gap-4 border-b border-[var(--hub-border)] bg-[var(--hub-surface)] px-4 py-2.5",children:[c.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[c.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-[var(--hub-surface-emphasis)] text-xs font-semibold text-[var(--hub-text)]",children:e+1}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("h4",{className:"truncate text-sm font-medium text-[var(--hub-text)]",children:n.name||"New contact"}),c.jsxs("p",{className:"truncate text-[11px] text-[var(--hub-text-muted)]",children:[n.email||"Add contact details",n.isSelectableMeetingPoc?" · Selectable POC":""]})]})]}
36),c.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:i,children:"Close editor"})]}),c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("fieldset",{className:"grid gap-3 lg:grid-cols-[1fr_1fr_0.75fr]",children:[c.jsx("legend",{className:"px-1 text-xs font-semibold text-[var(--hub-text)]",children:"Who is this person?"}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:`${o}-name`,className:"text-xs",children:"Name"}),c.jsx(U,{id:`${o}-name`,value:n.name,onChange:u=>l({name:u.target.value}),placeholder:"Full name",autoComplete:"name","aria-invalid":!!r[`${a}.name`],className:Z}),c.jsx(be,{message:r[`${a}.name`],className:"text-xs"})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:`${o}-email`,className:"text-xs",children:"Email"}),c.jsx(U,{id:`${o}-email`,type:"email",value:n.email,onChange:u=>l({email:u.target.value}),placeholder:"[email protected]",autoComplete:"email","aria-invalid":!!r[`${a}.email`],className:Z}),c.jsx(be,{message:r[`${a}.email`],className:"text-xs"})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs(R,{htmlFor:`${o}-phone`,className:"text-xs",children:["Phone ",c.jsx("span",{className:"font-normal text-[var(--hub-text-muted)]",children:"Optional"})]}),c.jsx(U,{id:`${o}-phone`,type:"tel",value:n.phone??"",onChange:u=>l({phone:u.target.value||null}),placeholder:"+63 917 000 0000",autoComplete:"tel","aria-invalid":!!r[`${a}.phone`],className:Z}),c.jsx(be,{message:r[`${a}.phone`],className:"text-xs"})]})]}),c.jsx(Ep,{contact:n,contactId:o,errors:r,errorPrefix:a,onChange:l}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:`${o}-notes`,className:"text-xs",children:"When should the SDR choose or include this person?"}),c.jsx(Qi,{id:`${o}-notes`,value:n.notes??"",onChange:u=>l({notes:u.target.value||null}),placeholder:"Example: Use for US, Canada, and Europe leads from 6 PMâ1 AM PHT.","aria-invalid":!!r[`${a}.notes`],className:"min-h-18 resize-y rounded-[var(--hub-radius-control)] border-[var(--hub-control-border)] bg-[var(--hub-control-background)] text-xs"}),c.jsx(be,{message:r[`${a}.notes`],className:"text-xs"})]}),c.jsx(yp,{contactId:o,timezone:n.availabilityTimezone,windows:n.availabilityWindows,errors:r,errorPrefix:a,onTimezoneChange:u=>l({availabilityTimezone:u}),onWindowsChange:u=>l({availabilityWindows:u})}),c.jsxs("section",{className:"rounded-[var(--hub-radius-control)] border border-[var(--hub-border)] bg-[var(--hub-surface)] p-3.5","aria-live":"polite",children:[c.jsx("h5",{className:"text-xs font-semibold text-[var(--hub-text)]",children:"Contact guidance preview"}),c.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--hub-text-muted)]",children:d.summary})]}),c.jsx(gp,{contact:n,contactId:o,templateOptions:t,errors:r,errorPrefix:a,onChange:l})]})]})}function Op({contact:n,index:e,expanded:t,hasError:r,onEdit:s,onRemove:i}){const o=Ec(n),a=n.name||`contact ${e+1}`;return c.jsx("article",{className:"rounded-[var(--hub-radius-control)] border border-[var(--hub-border)] bg-[var(--hub-surface-subtle)] p-3",children:c.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(12rem,1fr)_minmax(8rem,0.6fr)_minmax(8rem,0.6fr)_minmax(15rem,1.25fr)_auto] lg:items-center",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[c.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-[var(--hub-surface-emphasis)] text-[11px] font-semibold text-[var(--hub-text)]",children:e+1}),c.jsx("p",{className:"truncate text-sm font-medium text-[var(--hub-text)]",children:n.name||"New contact"}),c.jsx(Ea,{tone:n.isSelectableMeetingPoc?"info":"neutral",children:o.selectableLabel}),r?c.jsx(Ea,{tone:"danger",children:"Needs attention"}):null]}),c.jsx("p",{className:"mt-1 truncate text-xs text-[var(--hub-text-muted)]",children:n.email||"Add contact details"})]}),c.jsxs("dl",{className:"min-w-0",children:[c.jsx("dt",{className:"text-[11px] font-medium tracking-wide text-[var(--hub-text-muted)] uppercase",children:"Intro email"}),c.jsx("dd",{className:"mt-1 text-xs text-[var(--hub-text)]",children:o.emailLabel})]}),c.jsxs("dl",{className:"min-w-0",children:[c.jsx("dt",{className:"text-[11px] font-medium tracking-wide text-[var(--hub-text-muted)] uppercase",children:"Meeting invite"}),c.jsx("dd",{className:"mt-1 text-xs text-[var(--hub-text)]",children:o.calendarLabel})]}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("p",{className:"text-[11px] font-medium tracking-wide text-[var(--hub-text-muted)] uppercase",children:"SDR guidance"}),c.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--hub-text)]",children:o.summary}),c.jsxs("p",{className:"mt-1 flex items-start gap-1.5 text-[11px] leading-4 text-[var(--hub-text-muted)]",children:[c.jsx(kc,{"aria-hidden":"true",className:"mt-0.5 size-3 shrink-0"}),o.workingHoursLabel]}),c.jsxs("p",{className:"mt-1 flex items-start gap-1.5 text-[11px] leading-4 text-[var(--hub-text-muted)]",children:[c.jsx(mf,{"aria-hidden":"true",className:"mt-0.5 size-3 shrink-0"}),c.jsxs("span",{children:["Service conditions · ",o.serviceConditionsLabel]})]}),c.jsxs("p",{className:"mt-1 flex items-start gap-1.5 text-[11px] leading-4 text-[var(--hub-text-muted)]",children:[c.jsx(gf,{"aria-hidden":"true",className:"mt-0.5 size-3 shrink-0"}),c.jsxs("span",{children:["Location conditions · ",o.geographyConditionsLabel]})]})]}),c.jsxs("div",{className:"flex items-center gap-1.5 lg:justify-self-end",children:[c.jsxs(B,{type:"button",size:"sm",variant:t?"secondary":"outline","aria-expanded":t,"aria-controls":t?`sp-contact-editor-${n.uuid}`:void 0,onClick:s,children:[c.jsx(Lo,{"aria-hidden":"true",className:"size-3.5"}),t?"Editing":"Edit"]}
36),c.jsx(B,{type:"button",size:"icon",variant:"ghost",className:"size-8 text-[var(--hub-text-muted)] hover:text-red-600","aria-label":`Remove ${a}`,onClick:i,children:c.jsx(Hs,{"aria-hidden":"true",className:"size-4"})})]})]})})}function Dp(n){return{uuid:`new-${Date.now()}-${Math.random().toString(36).slice(2)}`,name:"",email:"",phone:null,isPrimary:n,isSelectableMeetingPoc:!1,availabilityTimezone:null,availabilityWindows:[],emailCcMode:"never",calendarInviteMode:"never",routingConditions:{serviceCategories:[],geographyMode:"all",countryCodes:[],regionKeys:[]},introEmailTemplateKey:null,receivesLeadNotifications:!1,notes:null}}function Rp({contacts:n,templates:e,errors:t,onChange:r,onStructureChange:s}){var u;const i=pp(e),[o,a]=A.useState(((u=n[0])==null?void 0:u.uuid)??null),l=A.useCallback(h=>Object.keys(t).some(f=>f===`contacts.${h}`||f.startsWith(`contacts.${h}.`)),[t]);A.useEffect(()=>{const h=n.findIndex((f,p)=>l(p));h>=0&&a(n[h].uuid)},[n,l]);const d=()=>{const h=Dp(n.length===0);s([...n,h]),a(h.uuid)};return c.jsxs("section",{className:"border-t border-[var(--hub-border)] px-[var(--hub-surface-padding)] py-5",children:[c.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(xc,{className:"size-4 text-[var(--hub-accent)]","aria-hidden":"true"}),c.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-text)]",children:"Partner points of contact"})]}),c.jsx("p",{className:"mt-1 max-w-3xl text-xs leading-5 text-[var(--hub-text-muted)]",children:"Configure Primary contact ownership, selectable POCs, Email routing (CC), Calendar invite rules, and Lead notifications."})]}),c.jsxs(B,{type:"button",size:"sm",variant:"outline",className:"shrink-0 gap-1.5",onClick:d,children:[c.jsx(Bs,{className:"size-3.5"}),"Add contact"]})]}),n.length===0?c.jsxs("div",{className:"rounded-[var(--hub-radius-control)] border border-dashed border-[var(--hub-border)] bg-[var(--hub-surface-subtle)] px-4 py-7 text-center",children:[c.jsx("p",{className:"text-sm font-medium text-[var(--hub-text)]",children:"No Partner POCs configured"}),c.jsx("p",{className:"mt-1 text-xs text-[var(--hub-text-muted)]",children:"Add the contacts who participate in meeting handoffs."})]}):c.jsx("div",{className:"space-y-3",children:n.map((h,f)=>{const p=o===h.uuid;return c.jsxs("div",{className:"space-y-3",children:[c.jsx(Op,{contact:h,index:f,expanded:p,hasError:l(f),onEdit:()=>a(h.uuid),onRemove:()=>{var g;const m=n.filter((x,b)=>b!==f);p&&a(((g=m[f])==null?void 0:g.uuid)??null),s(m)}}),p?c.jsx(Ap,{contact:h,index:f,templateOptions:i,errors:t,onChange:m=>r(n.map((g,x)=>x===f?m:g)),onClose:()=>a(null)}):null]},h.uuid)})}),t.contacts?c.jsx("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:t.contacts}):null]})}const Ac=["text-sm leading-6","[&>:first-child]:mt-0 [&>:last-child]:mb-0","[&_p]:my-3","[&_h1]:my-5 [&_h1]:text-2xl [&_h1]:leading-tight [&_h1]:font-bold","[&_h2]:my-4 [&_h2]:text-xl [&_h2]:leading-tight [&_h2]:font-semibold","[&_h3]:my-3 [&_h3]:text-lg [&_h3]:leading-snug [&_h3]:font-semibold","[&_ul]:my-3 [&_ul]:list-disc [&_ul]:pl-6","[&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-6","[&_li]:my-1 [&_li>p]:my-0","[&_blockquote]:my-4 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-4 [&_blockquote]:italic","[&_pre]:my-4 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:bg-muted [&_pre]:p-3","[&_code]:font-mono [&_code]:text-[0.875em]","[&_hr]:my-6 [&_hr]:border-border"].join(" ");function me(n){this.content=n}me.prototype={constructor:me,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new me(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new me(t)},addToStart:function(n,e){return new me([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new me(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new me(s)}
vendor: 31,872 bytes, lines 36-37
36,forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=me.from(n),n.size?new me(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=me.from(n),n.size?new me(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=me.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};me.from=function(n){if(n instanceof me)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new me(e)};function Oc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=Oc(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function Dc(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),a=e.child(--i),l=o.nodeSize;if(o==a){t-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:t,b:r};if(o.isText&&o.text!=a.text){let d=0,u=Math.min(o.text.length,a.text.length);for(;d<u&&o.text[o.text.length-d-1]==a.text[a.text.length-d-1];)d++,t--,r--;return{a:t,b:r}}if(o.content.size||a.content.size){let d=Dc(o.content,a.content,t-1,r-1);if(d)return d}t-=l,r-=l}}class N{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,a=0;a<t;o++){let l=this.content[o],d=a+l.nodeSize;if(d>e&&r(l,s+a,i||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,t-u),r,s+u)}a=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(a,l)=>{let d=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&d||a.isTextblock)&&r&&(o?o=!1:i+=r),i+=d},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new N(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let a=this.content[i],l=o+a.nodeSize;l>e&&((o<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,t-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,t-o-1))),r.push(a),s+=a.nodeSize),o=l}return new N(r,s)}cutByIndex(e,t){return e==t?N.empty:e==0&&t==this.content.length?this:new N(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new N(s,i)}addToStart(e){return new N([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new N(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Oc(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Dc(this,e,t,r)}findIndex(e){if(e==0)return Cr(0,e);if(e==this.size)return Cr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),i=r+s.nodeSize;if(i>=e)return i==e?Cr(t+1,i):Cr(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return N.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new N(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return N.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new N(t||e,r)}static from(e){if(!e)return N.empty;if(e instanceof N)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new N([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}N.empty=new N([],0);const xi={index:0,offset:0};function Cr(n,e){return xi.index=n,xi.offset=e,xi}function Wr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Wr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Wr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let K=class Zi{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Wr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Zi.none;if(e instanceof Zi)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};K.none=[];class Ur extends Error{}class T{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Ic(this.content,e+this.openStart,t);return r&&new T(r,this.openStart,this.openEnd)}removeBetween(e,t){return new T(Rc(this.content,e+this.openStart,t+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(e,t){if(!t)return T.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new T(N.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new T(e,r,s)}}T.empty=new T(N.empty,0,0);function Rc(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:a}=n.findIndex(t);if(s==e||i.isText){if(a!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Rc(i.content,e-s-1,t-s-1)))}function Ic(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let a=Ic(o.content,e-i-1,t,o);return a&&n.replaceChild(s,o.copy(a))}function Ip(n,e,t){if(t.openStart>n.depth)throw new Ur("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ur("Inconsistent open depths");return Pc(n,e,t,0)}function Pc(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=Pc(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,a=o.content;return Wt(o,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=Pp(t,n);return Wt(i,zc(n,o,a,e,r))}else return Wt(i,Kr(n,e,r))}function Lc(n,e){if(!e.type.compatibleContent(n.type))throw new Ur("Cannot join "+e.type.name+" onto "+n.type.name)}function eo(n,e,t){let r=n.node(t);return Lc(r,e.node(t)),r}function Ft(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function qn(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Ft(n.nodeAfter,r),i++));for(let a=i;a<o;a++)Ft(s.child(a),r);e&&e.depth==t&&e.textOffset&&Ft(e.nodeBefore,r)}function Wt(n,e){return n.type.checkContent(e),n.copy(e)}function zc(n,e,t,r,s){let i=n.depth>s&&eo(n,e,s+1),o=r.depth>s&&eo(t,r,s+1),a=[];return qn(null,n,s,a),i&&o&&e.index(s)==t.index(s)?(Lc(i,o),Ft(Wt(i,zc(n,e,t,r,s+1)),a)):(i&&Ft(Wt(i,Kr(n,e,s+1)),a),qn(e,t,s,a),o&&Ft(Wt(o,Kr(t,r,s+1)),a)),qn(r,null,s,a),new N(a)}function Kr(n,e,t){let r=[];if(qn(null,n,t,r),n.depth>t){let s=eo(n,e,t+1);Ft(Wt(s,Kr(n,e,t+1)),r)}return qn(e,null,t,r),new N(r)}function Pp(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(N.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class ir{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 new 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 new 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 r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}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 r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return K.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let a=r;r=s,s=a}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new qr(this,e,r);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<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(i),d=i-l;if(r.push(o,a,s+l),!d||(o=o.child(a),o.isText))break;i=d-1,s+=l+1}return new ir(t,r,i)}static resolveCached(e,t){let r=Pa.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else Pa.set(e,r=new Lp);let s=r.elts[r.i]=ir.resolve(e,t);return r.i=(r.i+1)%zp,s}}class Lp{constructor(){this.elts=[],this.i=0}}const zp=12,Pa=new WeakMap;class qr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const $p=Object.create(null);class Fe{constructor(e,t,r,s=K.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||N.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Wr(this.attrs,t||e.defaultAttrs||$p)&&K.sameSet(this.marks,r||K.none)}copy(e=null){return e==this.content?this:new Fe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Fe(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return T.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),a=s.start(o),d=s.node(o).content.cut(s.pos-a,i.pos-a);return new T(d,s.depth-o,i.depth-o)}replace(e,t,r){return Ip(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return ir.resolveCached(this,e)}resolveNoCache(e){return ir.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}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()+")"),$c(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=N.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=s;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=K.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!K.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=N.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}Fe.prototype.text=void 0;class Jr extends Fe{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$c(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(e){return e==this.marks?this:new Jr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Jr(this.type,this.attrs,e,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 $c(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Gt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new _p(e,t);if(r.next==null)return Gt.empty;let s=_c(r);r.next&&r.err("Unexpected trailing text");let i=Kp(Up(s));return qp(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let i=t;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function i(o,a){let l=o.matchFragment(e,r);if(l&&(!t||l.validEnd))return N.from(a.map(d=>d.createAndFill()));for(let d=0;d<o.next.length;d++){let{type:u,next:h}=o.next[d];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(h)==-1){s.push(h);let f=i(h,a.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let a=s;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:a,next:l}=i.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!s.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:s}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(` 37`)}}Gt.empty=new Gt(!0);class _p{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 new SyntaxError(e+" (in content expression '"+this.string+"')")}}function _c(n){let e=[];do e.push(Bp(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Bp(n){let e=[];do e.push(Hp(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Hp(n){let e=Wp(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Vp(n,e);else break;return e}function La(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Vp(n,e){let t=La(n),r=t;return n.eat(",")&&(n.next!="}"?r=La(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Fp(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function Wp(n){if(n.eat("(")){let e=_c(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Fp(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Up(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,a,l){let d={term:l,to:a};return e[o].push(d),d}function s(o,a){o.forEach(l=>l.to=a)}function i(o,a){if(o.type=="choice")return o.exprs.reduce((l,d)=>l.concat(i(d,a)),[]);if(o.type=="seq")for(let l=0;;l++){let d=i(o.exprs[l],a);if(l==o.exprs.length-1)return d;s(d,a=t())}else if(o.type=="star"){let l=t();return r(a,l),s(i(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=t();return s(i(o.expr,a),l),s(i(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(i(o.expr,a));if(o.type=="range"){let l=a;for(let d=0;d<o.min;d++){let u=t();s(i(o.expr,l),u),l=u}if(o.max==-1)s(i(o.expr,l),l);else for(let d=o.min;d<o.max;d++){let u=t();r(l,u),s(i(o.expr,l),u),l=u}return[r(l)]}else{if(o.type=="name")return[r(a,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Bc(n,e){return e-n}function za(n,e){let t=[];return r(e),t.sort(Bc);function r(s){let i=n[s];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(s);for(let o=0;o<i.length;o++){let{term:a,to:l}=i[o];!a&&t.indexOf(l)==-1&&r(l)}}}function Kp(n){let e=Object.create(null);return t(za(n,0));function t(r){let s=[];r.forEach(o=>{n[o].forEach(({term:a,to:l})=>{if(!a)return;let d;for(let u=0;u<s.length;u++)s[u][0]==a&&(d=s[u][1]);za(n,l).forEach(u=>{d||s.push([a,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let i=e[r.join(",")]=new Gt(r.indexOf(n.length-1)>-1);for(let o=0;o<s.length;o++){let a=s[o][1].sort(Bc);i.next.push({type:s[o][0],next:e[a.join(",")]||t(a)})}return i}}function qp(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],i=!s.validEnd,o=[];for(let a=0;a<s.next.length;a++){let{type:l,next:d}=s.next[a];o.push(l.name),i&&!(l.isText||l.hasRequiredAttrs())&&(i=!1),r.indexOf(d)==-1&&r.push(d)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Hc(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Vc(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let i=n[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function Fc(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function Wc(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Gp(n,r,e[r]);return t}let $a=class Uc{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Wc(e,r.attrs),this.defaultAttrs=Hc(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Gt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(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:Vc(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Fe(this,this.computeAttrs(e),N.from(t),K.setFrom(r))}createChecked(e=null,t,r){return t=N.from(t),this.checkContent(t),new Fe(this,this.computeAttrs(e),t,K.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=N.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(N.empty,!0);return i?new Fe(this,e,t.append(i),K.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Fc(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:K.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,o)=>r[i]=new Uc(i,t,o));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Jp(n,e,t){let r=t.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class Gp{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Jp(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Vs{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=Wc(e,s.attrs),this.excluded=null;let i=Hc(this.attrs);this.instance=i?new K(this,i):null}create(e=null){return!e&&this.instance?this.instance:new K(this,Vc(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new Vs(i,s++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Fc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Kc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=me.from(e.nodes),t.marks=me.from(e.marks||{}),this.nodes=$a.compile(this.spec.nodes,this),this.marks=Vs.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",a=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Gt.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=a=="_"?null:a?_a(this,a.split(" ")):a==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:_a(this,o.split(" "))}this.nodeFromJSON=s=>Fe.fromJSON(this,s),this.markFromJSON=s=>K.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof $a){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new Jr(r,r.defaultAttrs,e,K.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 new RangeError("Unknown node type: "+e);return t}}function _a(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],i=n.marks[s],o=i;if(i)t.push(i);else for(let a in n.marks){let l=n.marks[a];(s=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(s)>-1)&&t.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Yp(n){return n.tag!=null}function Qp(n){return n.style!=null}class St{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(Yp(s))this.tags.push(s);else if(Qp(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Ha(this,t,!1);return r.addAll(e,K.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ha(this,t,!0);return r.addAll(e,K.none,t.from,t.to),T.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(em(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs
vendor: 5,387 bytes, lines 37-39
37){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let a=t[o];if((a.priority==null?50:a.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Va(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Va(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new St(e,St.schemaRules(e)))}}const qc={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},Xp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Jc={ol:!0,ul:!0},or=1,to=2,Jn=4;function Ba(n,e,t){return e!=null?(e?or:0)|(e==="full"?to:0):n&&n.whitespace=="pre"?or|to:t&~Jn}class Nr{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=K.none,this.match=i||(o&Jn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(N.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&or)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=N.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(N.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&&!qc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ha{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=Ba(null,t.preserveWhitespace,0)|(r?Jn:0);s?i=new Nr(s.type,s.attrs,K.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new Nr(null,null,K.none,!0,null,o):i=new Nr(e.schema.topNodeType,null,K.none,!0,null,o),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 r=e.nodeValue,s=this.top,i=s.options&to?"full":this.localPreserveWS||(s.options&or)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,` 38`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(o.linebreakReplacement.create(),t,!0),a[l]&&this.insertNode(o.text(a[l]),t,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=s.content[s.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;Jc.hasOwnProperty(o)&&this.parser.normalizeLists&&Zp(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:Xp.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let d,u=this.needsBlock;if(qc.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),d=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let h=l&&l.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),d&&this.sync(i),this.needsBlock=u}else{let d=this.readStyles(e,t);d&&this.addElementByRule(e,l,d,l.consuming===!1?a:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` 39`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(i,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(d=>
vendor: 4,153 bytes, line 39
39!l.clearMark(d)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,r,s){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(o,t.attrs||null,r,t.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[t.mark];r=r.concat(l.create(t.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(a)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=s==null?null:e.childNodes[s];o!=a;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,r){let s,i;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],d=l.findWrapping(e);if(d&&(!s||s.length>d.length+a)&&(s=d,i=l,!d.length))break;if(l.solid){if(r)break;a+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)t=this.enterInner(s[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=K.none;for(let a of s.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):Fa(a.type,e.type))&&(o=a.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=Ba(e,i,o.options);o.options&Jn&&o.content.length==0&&(a|=Jn);let l=K.none;return r=r.filter(d=>(o.type?o.type.allowsMarkType(d.type):Fa(d.type,e))?(l=d.addToSet(l),!1):!0),this.nodes.push(new Nr(e,t,l,s,null,a)),this.open++,r}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;this.localPreserveWS&&(this.nodes[t].options|=or)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(a,l)=>{for(;a>=0;a--){let d=t[a];if(d==""){if(a==t.length-1||a==0)continue;for(;l>=i;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&s?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;l--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;
vendor: 11,127 bytes, line 39
39if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Zp(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Jc.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function em(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Va(n){let e={};for(let t in n)e[t]=n[t];return e}function Fa(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=a=>{i.push(a);for(let l=0;l<a.edgeCount;l++){let{type:d,next:u}=a.edge(l);if(d==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class nn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=bi(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let a=0,l=0;for(;a<i.length&&l<o.marks.length;){let d=o.marks[l];if(!this.marks[d.type.name]){l++;continue}if(!d.eq(i[a][0])||d.type.spec.spanning===!1)break;a++,l++}for(;a<i.length;)s=i.pop()[1];for(;l<o.marks.length;){let d=o.marks[l++],u=this.serializeMark(d,o.isInline,t);u&&(i.push([d,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Lr(bi(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Lr(bi(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Lr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new nn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Wa(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Wa(e.marks)}}function Wa(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function bi(n){return n.document||window.document}const Ua=new WeakMap;function tm(n){let e=Ua.get(n);return e===void 0&&Ua.set(n,e=nm(n)),e}function nm(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Lr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=tm(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(t=s.slice(0,o),s=s.slice(o+1));let a,l=t?n.createElementNS(t,s):n.createElement(s),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let h in d)if(d[h]!=null){let f=h.indexOf(" ");f>0?l.setAttributeNS(h.slice(0,f),h.slice(f+1),d[h]):h=="style"&&l.style?l.style.cssText=d[h]:l.setAttribute(h,d[h])}}for(let h=u;h<e.length;h++){let f=e[h];if(f===0){if(h<e.length-1||h>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:m}=Lr(n,f,t,r);if(l.appendChild(p),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const Gc=65535,Yc=Math.pow(2,16);function rm(n,e){return n+e*Yc}function Ka(n){return n&Gc}function sm(n){return(n-(n&Gc))/Yc}const Qc=1,Xc=2,zr=4,Zc=8;class no{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Zc)>0}get deletedBefore(){return(this.delInfo&(Qc|zr))>0}get deletedAfter(){return(this.delInfo&(Xc|zr))>0}get deletedAcross(){return(this.delInfo&zr)>0}}class Ae{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ae.empty)return Ae.empty}recover(e){let t=0,r=Ka(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+sm(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?s:0);if(l>e)break;let d=this.ranges[a+i],u=this.ranges[a+o],h=l+d;if(e<=h){let f=d?e==l?-1:e==h?1:t:t,p=l+s+(f<0?0:u);if(r)return p;let m=e==(t<0?l:h)?null:rm(a/3,e-l),g=e==l?Xc:e==h?Qc:zr;return(t<0?e!=l:e!=h)&&(g|=Zc),new no(p,g,m)}s+=u-d}return r?e+s:new no(e+s,0,null)}touches(e,t){let r=0,s=Ka(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let d=this.ranges[a+i],u=l+d;if(e<=u&&a==s*3)return!0;r+=this.ranges[a+o]-d}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],a=o-(this.inverted?i:0),l=o+(this.inverted?0:i),d=this.ranges[s+t],u=this.ranges[s+r];e(a,a+d,l,l+u),i+=u-d}}invert(){return new Ae(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ae.empty:new Ae(e<0?[0,-e,0]:[0,0,e])}}Ae.empty=new Ae([]);class ar{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new ar(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new ar;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],a=o.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(a.recover);continue}}s|=a.delInfo,e=a.pos}return r?e:new no(e,s,null)}}const yi=Object.create(null);class Se{getMap(){return Ae.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=yi[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in yi)throw new RangeError("Duplicate use of step JSON ID "+e);return yi[e]=t,t.prototype.jsonID=e,t}}class le{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new le(e,null)}static fail(e){return new le(null,e)}static fromReplace(e,t,r,s){try{return le.ok(e.replace(t,r,s))}catch(i){if(i instanceof Ur)return le.fail(i.message);throw i}}}function zo(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(zo(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return N.fromArray(r)}class yt extends Se{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new T(zo(t.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return le.fromReplace(e,this.from,this.to,i)}invert(){return new Ve(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new yt(t.pos,r.pos,this.mark)}merge(e){return e instanceof yt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new yt(t.from,t.to,e.markFromJSON(t.mark))}}Se.jsonID("addMark",yt);class Ve extends Se{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new T(zo(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return le.fromReplace(e,this.from,this.to,r)}invert(){return new yt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ve(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ve&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ve(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ve(t.from,t.to,e.markFromJSON(t.mark))}}Se.jsonID("removeMark",Ve);class vt extends Se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return le.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return le.fromReplace(e,this.pos,this.pos+1,new T(N.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new vt(this.pos,t.marks[s]);return new vt(this.pos,this.mark)}}return new Yt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new vt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new vt(t.pos,e.markFromJSON(t.mark))}}Se.jsonID("addNodeMark",vt);class Yt extends Se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return le.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return le.fromReplace(e,this.pos,this.pos+1,new T(N.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new vt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Yt(t.pos,this.mark)}
vendor: 9,015 bytes, lines 39-40
39toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Yt(t.pos,e.markFromJSON(t.mark))}}Se.jsonID("removeNodeMark",Yt);class ae extends Se{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&ro(e,this.from,this.to)?le.fail("Structure replace would overwrite content"):le.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ae([this.from,this.to-this.from,this.slice.size])}invert(e){return new ae(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&ae.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new ae(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ae)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?T.empty:new T(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ae(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?T.empty:new T(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ae(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ae(t.from,t.to,T.fromJSON(e,t.slice),!!t.structure)}}ae.MAP_BIAS=1;Se.jsonID("replace",ae);class fe extends Se{constructor(e,t,r,s,i,o,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=a}apply(e){if(this.structure&&(ro(e,this.from,this.gapFrom)||ro(e,this.gapTo,this.to)))return le.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return le.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?le.fromReplace(e,this.from,this.to,r):le.fail("Content does not fit in gap")}getMap(){return new Ae([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new fe(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new fe(t.pos,r.pos,s,i,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(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new fe(t.from,t.to,t.gapFrom,t.gapTo,T.fromJSON(e,t.slice),t.insert,!!t.structure)}}Se.jsonID("replaceAround",fe);function ro(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function im(n,e,t,r){let s=[],i=[],o,a;n.doc.nodesBetween(e,t,(l,d,u)=>{if(!l.isInline)return;let h=l.marks;if(!r.isInSet(h)&&u.type.allowsMarkType(r.type)){let f=Math.max(d,e),p=Math.min(d+l.nodeSize,t),m=r.addToSet(h);for(let g=0;g<h.length;g++)h[g].isInSet(m)||(o&&o.to==f&&o.mark.eq(h[g])?o.to=p:s.push(o=new Ve(f,p,h[g])));a&&a.to==f?a.to=p:i.push(a=new yt(f,p,r))}}),s.forEach(l=>n.step(l)),i.forEach(l=>n.step(l))}function om(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,a)=>{if(!o.isInline)return;i++;let l=null;if(r instanceof Vs){let d=o.marks,u;for(;u=r.isInSet(d);)(l||(l=[])).push(u),d=u.removeFromSet(d)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let d=Math.min(a+o.nodeSize,t);for(let u=0;u<l.length;u++){let h=l[u],f;for(let p=0;p<s.length;p++){let m=s[p];m.step==i-1&&h.eq(s[p].style)&&(f=m)}f?(f.to=d,f.step=i):s.push({style:h,from:Math.max(a,e),to:d,step:i})}}}),s.forEach(o=>n.step(new Ve(o.from,o.to,o.style)))}function $o(n,e,t,r=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l<i.childCount;l++){let d=i.child(l),u=a+d.nodeSize,h=r.matchType(d.type);if(!h)o.push(new ae(a,u,T.empty));else{r=h;for(let f=0;f<d.marks.length;f++)t.allowsMarkType(d.marks[f].type)||n.step(new Ve(a,u,d.marks[f]));if(s&&d.isText&&t.whitespace!="pre"){let f,p=/\r?\n|\r/g,m;for(;f=p.exec(d.text);)m||(m=new T(N.from(t.schema.text(" ",t.allowedMarks(d.marks))),0,0)),o.push(new ae(a+f.index,a+f.index+f[0].length,m))}}a=u}if(!r.validEnd){let l=r.fillBefore(N.empty,!0);n.replace(a,a,new T(l,0,0))}for(let l=o.length-1;l>=0;l--)n.step(o[l])}function am(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function jn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,i=0;;--r){let o=n.$from.node(r),a=n.$from.index(r)+s,l=n.$to.indexAfter(r)-i;if(r<n.depth&&o.canReplace(a,l,t))return r;if(r==0||o.type.spec.isolating||!am(o,a,l))break;a&&(s=1),l<o.childCount&&(i=1)}return null}function lm(n,e,t){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),a=s.after(i+1),l=o,d=a,u=N.empty,h=0;for(let m=i,g=!1;m>t;m--)g||r.index(m)>0?(g=!0,u=N.from(r.node(m).copy(u)),h++):l--;let f=N.empty,p=0;for(let m=i,g=!1;m>t;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=N.from(s.node(m).copy(f)),p++):d++;n.step(new fe(l,d,o,a,new T(u.append(f),h,p),u.size-h,!0))}function _o(n,e,t=null,r=n){let s=cm(n,e),i=s&&dm(r,e);return i?s.map(qa).concat({type:e,attrs:t}).concat(i.map(qa)):null}function qa(n){return{type:n,attrs:null}}function cm(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return t.canReplaceWith(r,s,o)?i:null}function dm(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let d=r;l&&d<s;d++)l=l.matchType(t.child(d).type);return!l||!l.validEnd?null:o}function um(n,e,t){let r=N.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let a=t[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=N.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new fe(s,i,s,i,new T(r,0,0),t.length,!0))}function hm(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,a)=>{let l=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,l)&&fm(n.doc,n.mapping.slice(i).map(a),r)){let d=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?d=!1:!p&&m&&(d=!0)}d===!1&&td(n,o,a,i),$o(n,n.mapping.slice(i).map(a,1),r,void 0,d===null);let u=n.mapping.slice(i),h=u.map(a,1),f=u.map(a+o.nodeSize,1);return n.step(new fe(h,f,h+1,f-1,new T(N.from(r.create(l,null,o.marks)),0,0),1,!0)),d===!0&&ed(n,o,a,i),!1}})}function ed(n,e,t,r){e.forEach((s,i)=>{if(s.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(s.text);){let l=n.mapping.slice(r).map(t+1+i+o.index);n.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function td(n,e,t,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+i);n.replaceWith(o,o+1,e.type.schema.text(` 40`))}})}function fm(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function pm(n,e,t,r,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let o=t.create(r,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,o);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new fe(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new T(N.from(o),0,0),1,!0))}function at(n,e,t=1,r){let s=n.resolve(e),i=s.depth-t,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let d=s.depth-1,u=t-2;d>i;
vendor: 8,066 bytes, line 40
40d--,u--){let h=s.node(d),f=s.index(d);if(h.type.spec.isolating)return!1;let p=h.content.cutByIndex(f,h.childCount),m=r&&r[u+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[u]||h;if(!h.canReplace(f+1,h.childCount)||!g.type.validContent(p))return!1}let a=s.indexAfter(i),l=r&&r[0];return s.node(i).canReplaceWith(a,a,l?l.type:s.node(i+1).type)}function mm(n,e,t=1,r){let s=n.doc.resolve(e),i=N.empty,o=N.empty;for(let a=s.depth,l=s.depth-t,d=t-1;a>l;a--,d--){i=N.from(s.node(a).copy(i));let u=r&&r[d];o=N.from(u?u.type.create(u.attrs,o):s.node(a).copy(o))}n.step(new ae(e,e,new T(i.append(o),t,t),!0))}function Et(n,e){let t=n.resolve(e),r=t.index();return nd(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function gm(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function nd(n,e){return!!(n&&e&&!n.isLeaf&&gm(n,e))}function Fs(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let i,o,a=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):t>0?(i=r.node(s+1),a++,o=r.node(s).maybeChild(a)):(i=r.node(s).maybeChild(a-1),o=r.node(s+1)),i&&!i.isTextblock&&nd(i,o)&&r.node(s).canReplace(a,a+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function xm(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,i=n.doc.resolve(e-t),o=i.node().type;if(s&&o.inlineContent){let u=o.whitespace=="pre",h=!!o.contentMatch.matchType(s);u&&!h?r=!1:!u&&h&&(r=!0)}let a=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);td(n,u.node(),u.before(),a)}o.inlineContent&&$o(n,e+t-1,o,i.node().contentMatchAt(i.index()),r==null);let l=n.mapping.slice(a),d=l.map(e-t);if(n.step(new ae(d,l.map(e+t,-1),T.empty,!0)),r===!0){let u=n.doc.resolve(d);ed(n,u.node(),u.before(),n.steps.length)}return n}function bm(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,t))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,t))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function rd(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let o=r.depth;o>=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),d=r.node(o),u=!1;if(i==1)u=d.canReplace(l,l,s);else{let h=d.contentMatchAt(l).findWrapping(s.firstChild.type);u=h&&d.canReplaceWith(l,l,h[0])}if(u)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}function Ws(n,e,t=e,r=T.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),i=n.resolve(t);return sd(s,i,r)?new ae(e,t,r):new ym(s,i,r).fit()}function sd(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class ym{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=N.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=N.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,a=s.depth;for(;o&&a&&i.childCount==1;)i=i.firstChild.content,o--,a--;let l=new T(i,o,a);return e>-1?new fe(r.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||r.pos!=this.$to.pos?new ae(r.pos,s.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=vi(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:d}=this.frontier[a],u,h=null;if(t==1&&(o?d.matchType(o.type)||(h=d.fillBefore(N.from(o),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:a,parent:i,inject:h};if(t==2&&o&&(u=d.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:i,wrap:u};if(i&&d.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=vi(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new T(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=vi(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new T(Rn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new T(Rn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let o=this.unplaced,a=r?r.content:o.content,l=o.openStart-e,d=0,u=[],{match:h,type:f}=this.frontier[t];if(s){for(let g=0;g<s.childCount;g++)u.push(s.child(g));h=h.matchFragment(s)}let p=a.size+e-(o.content.size-o.openEnd);for(;d<a.childCount;){let g=a.child(d),x=h.matchType(g.type);if(!x)break;d++,(d>1||l==0||g.content.size)&&(h=x,u.push(id(g.mark(f.allowedMarks(g.marks)),d==1?l:0,d==a.childCount?p:-1)))}let m=d==a.childCount;m||(p=-1),this.placed=In(this.placed,t,N.from(u)),this.frontier[t].match=h,m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,x=a;g<p;g++){let b=x.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),x=b.content}this.unplaced=m?e==0?T.empty:new T(Rn(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new T(Rn(o.content,e,d),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ki(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=ki(e,t,s,r,i);if(o){for(let a=t-1;a>=0;a--){let{match:l,type:d}=this.frontier[a],u=ki(e,a,d,l,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,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=In(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=In(this.placed,this.depth,N.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(N.empty,!0);t.childCount&&(this.placed=In(this.placed,this.frontier.length,t))}}function Rn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Rn(n.firstChild.content,e-1,t)))}function In(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(In(n.lastChild.content,e-1,t)))}function vi(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function id(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,id(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.t
vendor: 15,488 bytes, line 40
40ype.contentMatch.matchFragment(r).fillBefore(N.empty,!0)))),n.copy(r)}function ki(n,e,t,r,s){let i=n.node(e),o=s?n.indexAfter(e):n.index(e);if(o==i.childCount&&!t.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,o);return a&&!vm(t,i.content,o)?a:null}function vm(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function km(n){return n.spec.defining||n.spec.definingForContent}function Sm(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(sd(s,i,r))return n.step(new ae(e,t,r));let o=ad(s,i);o[o.length-1]==0&&o.pop();let a=-(s.depth+1);o.unshift(a);for(let f=s.depth,p=s.pos-1;f>0;f--,p--){let m=s.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;o.indexOf(f)>-1?a=f:s.before(f)==p&&o.splice(1,0,-f)}let l=o.indexOf(a),d=[],u=r.openStart;for(let f=r.content,p=0;;p++){let m=f.firstChild;if(d.push(m),p==r.openStart)break;f=m.content}for(let f=u-1;f>=0;f--){let p=d[f],m=km(p.type);if(m&&!p.sameMarkup(s.node(Math.abs(a)-1)))u=f;else if(m||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+u+1)%(r.openStart+1),m=d[p];if(m)for(let g=0;g<o.length;g++){let x=o[(g+l)%o.length],b=!0;x<0&&(b=!1,x=-x);let y=s.node(x-1),k=s.index(x-1);if(y.canReplaceWith(k,k,m.type,m.marks))return n.replace(s.before(x),b?i.after(x):t,new T(od(r.content,0,r.openStart,p),p,r.openEnd))}}let h=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>h));f--){let p=o[f];p<0||(e=s.before(p),t=i.after(p))}}function od(n,e,t,r,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(od(i.content,e+1,t,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(n).append(n);n=o.append(i.matchFragment(o).fillBefore(N.empty,!0))}return n}function Cm(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=bm(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new T(N.from(r),0,0))}function Nm(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(t),a=!1;for(let l=r.depth;l>o;l--)r.node(l).type.spec.isolating&&(a=!0);for(let l=s.depth;l>o;l--)s.node(l).type.spec.isolating&&(a=!0);if(!a){for(let l=r.depth;l>0&&e==r.start(l);l--)e=r.before(l);for(let l=s.depth;l>0&&t==s.start(l);l--)t=s.before(l);r=n.doc.resolve(e),s=n.doc.resolve(t)}}let i=ad(r,s);for(let o=0;o<i.length;o++){let a=i[o],l=o==i.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),s.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),s.indexAfter(a-1))))return n.delete(r.before(a),s.after(a))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&s.end(o)-t!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function ad(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let i=n.start(s);if(i<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class xn extends Se{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return le.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return le.fromReplace(e,this.pos,this.pos+1,new T(N.from(s),0,t.isLeaf?0:1))}getMap(){return Ae.empty}invert(e){return new xn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new xn(t.pos,t.attr,t.value)}}Se.jsonID("attr",xn);class lr extends Se{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return le.ok(r)}getMap(){return Ae.empty}invert(e){return new lr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new lr(t.attr,t.value)}}Se.jsonID("docAttr",lr);let vn=class extends Error{};vn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};vn.prototype=Object.create(Error.prototype);vn.prototype.constructor=vn;vn.prototype.name="TransformError";class ld{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ar}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new vn(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 r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),t=s.map(t,-1)),s.forEach((i,o,a,l)=>{e=Math.min(e,a),t=Math.max(t,l)})}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,r=T.empty){let s=Ws(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new T(N.from(r),0,0))}delete(e,t){return this.replace(e,t,T.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Sm(this,e,t,r),this}replaceRangeWith(e,t,r){return Cm(this,e,t,r),this}deleteRange(e,t){return Nm(this,e,t),this}lift(e,t){return lm(this,e,t),this}join(e,t=1){return xm(this,e,t),this}wrap(e,t){return um(this,e,t),this}setBlockType(e,t=e,r,s=null){return hm(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return pm(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new xn(e,t,r)),this}setDocAttribute(e,t){return this.step(new lr(e,t)),this}addNodeMark(e,t){return this.step(new vt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof K)t.isInSet(r.marks)&&this.step(new Yt(e,t));else{let s=r.marks,i,o=[];for(;i=t.isInSet(s);)o.push(new Yt(e,i)),s=i.removeFromSet(s);for(let a=o.length-1;a>=0;a--)this.step(o[a])}return this}split(e,t=1,r){return mm(this,e,t,r),this}addMark(e,t,r){return im(this,e,t,r),this}removeMark(e,t,r){return om(this,e,t,r),this}clearIncompatible(e,t,r){return $o(this,e,t,r),this}}const Si=Object.create(null);class z{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new wm(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<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=T.empty){let r=t.content.lastChild,s=null;for(let a=0;a<t.openEnd;a++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:d}=o[a],u=e.mapping.slice(i);e.replaceRange(u.map(l.pos),u.map(d.pos),a?T.empty:t),a==0&&Ya(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:a}=s[i],l=e.mapping.slice(r),d=l.map(o.pos),u=l.map(a.pos);i?e.deleteRange(d,u):(e.replaceRangeWith(d,u,t),Ya(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new I(e):hn(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=t<0?hn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):hn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Oe(e.node(0))}static atStart(e){return hn(e,e,0,0,1)||new Oe(e)}static atEnd(e){return hn(e,e,e.content.size,e.childCount,-1)||new Oe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Si[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Si)throw new RangeError("Duplicate use of selection JSON ID "+e);return Si[e]=t,t.prototype.jsonID=e,t}getBookmark(){return I.between(this.$anchor,this.$head).getBookmark()}}z.prototype.visible=!0;class wm{constructor(e,t){this.$from=e,this.$to=t}}let Ja=!1;function Ga(n){!Ja&&!n.parent.inlineContent&&(Ja=!0)}class I extends z{constructor(e,t=e){Ga(e),Ga(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return z.near(r);let s=e.resolve(t.map(this.anchor));return new I(s.parent.inlineContent?s:r,r)}replace(e,t=T.empty){if(super.replace(e,t),t==T.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof I&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Us(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new I(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=z.findFrom(t,r,!0)||z.findFrom(t,-r,!0);if(i)t=i.$head;else return z.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(z.findFrom(e,-r,!0)||z.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new I(e,t)}}z.jsonID("text",I);class Us{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Us(e.map(this.anchor),e.map(this.head))}resolve(e){return I.between(e.resolve(this.anchor),e.resolve(this.head))}}class D extends z{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return r?z.near(i):new D(i)}content(){return new T(N.from(this.node),0,0)}eq(e){return e instanceof D&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Bo(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new D(e.resolve(t.anchor))}static create(e,t){return new D(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}D.prototype.visible=!1;z.jsonID("node",D);class Bo{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Us(r,r):new Bo(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&D.isSelectable(r)?new D(t):z.near(t)}}class Oe extends z{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=T.empty){if(t==T.empty){e.delete(0,e.doc.content.size);let r=z.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Oe(e)}map(e){return new Oe(e)}eq(e){return e instanceof Oe}getBookmark(){return Mm}}z.jsonID("all",Oe);const Mm={map(){return this},resolve(n){return new Oe(n)}};function hn(n,e,t,r,s,i=!1){if(e.inlineContent)return I.create(n,t);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let a=e.child(o);if(a.isAtom){if(!i&&D.isSelectable(a))return D.create(n,t-(s<0?a.nodeSize:0))}else{let l=hn(n,a,t+s,s<0?a.childCount:0,s,i);if(l)return l}t+=a.nodeSize*s}return null}function Ya(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof ae||s instanceof fe))return;let i=n.mapping.maps[r],o;i.forEach((a,l,d,u)=>{o==null&&(o=u)}),n.setSelection(z.near(n.doc.resolve(o),t))}const Qa=1,wr=2,Xa=4;class jm extends ld{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.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Qa)&~wr,this.storedMarks=null,this}get selectionSet(){return(this.updated&Qa)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=wr,this}ensureMarks(e){return K.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&wr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~wr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||K.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(t);i=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(z.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|=Xa,this}get scrolledIntoView(){return(this.updated&Xa)>0}}function Za(n,e){return!e||!n?n:n.bind(e)}class Pn{constructor(e,t,r){this.name=e,this.init=Za(t.init,r),this.apply=Za(t.apply,r)}}const Tm=[new Pn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Pn("selection",{init(n,e){return n.selection||z.atStart(e.doc)},apply(n){return n.selection}}),new Pn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Pn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Ci{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Tm.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Pn(r.key,r.spec.state,r))})}}class mn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}
vendor: 8,601 bytes, lines 40-41
40apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let a=this.config.plugins[o];if(a.spec.appendTransaction){let l=s?s[o].n:0,d=s?s[o].state:this,u=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,d,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let h=0;h<this.config.plugins.length;h++)s.push(h<o?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new mn(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new jm(this)}static create(e){let t=new Ci(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new mn(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new Ci(this.schema,e.plugins),r=t.fields,s=new mn(t);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Ci(e.schema,e.plugins),i=new mn(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Fe.fromJSON(e.schema,t.doc);else if(o.name=="selection")i.selection=z.fromJSON(i.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],d=l.spec.state;if(l.key==o.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){i[o.name]=d.fromJSON.call(l,e,t[a],i);return}}i[o.name]=o.init(e,i)}}),i}}function cd(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=cd(s,e,{})),t[r]=s}return t}class ee{constructor(e){this.spec=e,this.props={},e.props&&cd(e.props,this,this.props),this.key=e.key?e.key.key:dd("plugin")}getState(e){return e[this.key]}}const Ni=Object.create(null);function dd(n){return n in Ni?n+"$"+ ++Ni[n]:(Ni[n]=0,n+"$")}class ue{constructor(e="key"){this.key=dd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ho=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function ud(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const hd=(n,e,t)=>{let r=ud(n,t);if(!r)return!1;let s=Vo(r);if(!s){let o=r.blockRange(),a=o&&jn(o);return a==null?!1:(e&&e(n.tr.lift(o,a).scrollIntoView()),!0)}let i=s.nodeBefore;if(kd(n,s,e,-1))return!0;if(r.parent.content.size==0&&(kn(i,"end")||D.isSelectable(i)))for(let o=r.depth;;o--){let a=Ws(n.doc,r.before(o),r.after(o),T.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(kn(i,"end")?z.findFrom(l.doc.resolve(l.mapping.map(s.pos,-1)),-1):D.create(l.doc,s.pos-i.nodeSize)),e(l.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},Em=(n,e,t)=>{let r=ud(n,t);if(!r)return!1;let s=Vo(r);return s?fd(n,s,e):!1},Am=(n,e,t)=>{let r=md(n,t);if(!r)return!1;let s=Fo(r);return s?fd(n,s,e):!1};function fd(n,e,t){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let o=e.nodeAfter,a=o,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let d=Ws(n.doc,i,l,T.empty);if(!d||d.from!=i||d instanceof ae&&d.slice.size>=l-i)return!1;if(t){let u=n.tr.step(d);u.setSelection(I.create(u.doc,i)),t(u.scrollIntoView())}return!0}function kn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const pd=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=Vo(r)}let o=i&&i.nodeBefore;return!o||!D.isSelectable(o)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function Vo(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function md(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const gd=(n,e,t)=>{let r=md(n,t);if(!r)return!1;let s=Fo(r);if(!s)return!1;let i=s.nodeAfter;if(kd(n,s,e,1))return!0;if(r.parent.content.size==0&&(kn(i,"start")||D.isSelectable(i))){let o=Ws(n.doc,r.before(),r.after(),T.empty);if(o&&o.slice.size<o.to-o.from){if(e){let a=n.tr.step(o);a.setSelection(kn(i,"start")?z.findFrom(a.doc.resolve(a.mapping.map(s.pos)),1):D.create(a.doc,a.mapping.map(s.pos))),e(a.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},xd=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=Fo(r)}let o=i&&i.nodeAfter;return!o||!D.isSelectable(o)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,i.pos)).scrollIntoView()),!0)};function Fo(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Om=(n,e)=>{let t=n.selection,r=t instanceof D,s;if(r){if(t.node.isTextblock||!Et(n.doc,t.from))return!1;s=t.from}else if(s=Fs(n.doc,t.from,-1),s==null)return!1;if(e){let i=n.tr.join(s);r&&i.setSelection(D.create(i.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Dm=(n,e)=>{let t=n.selection,r;if(t instanceof D){if(t.node.isTextblock||!Et(n.doc,t.to))return!1;r=t.to}else if(r=Fs(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Rm=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),i=s&&jn(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)},bd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` 41`).scrollIntoView()),!0)};function Wo(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Im=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),i=t.indexAfter(-1),o=Wo(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let a=t.after(),l=n.tr.replaceWith(a,a,o.createAndFill());l.setSelection(z.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},yd=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof Oe||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=Wo(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,a=n.tr.insert(o,i.createAndFill());a.setSelection(I.create(a.doc,o+1)),e(a.scrollIntoView())}return!0},vd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(at(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),s=r&&jn(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function Pm(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!r.parentOffset||!at(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,a,l=!1,d=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){l=r.end(p)==r.pos+(r.depth-p),d=r.start(p)==r.pos-(r.depth-p),a=Wo(r.node(p-1).c
vendor: 10,485 bytes, line 41
41ontentMatchAt(r.indexAfter(p-1))),i.unshift(l&&a?{type:a}:null),o=p;break}else{if(p==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof I||e.selection instanceof Oe)&&u.deleteSelection();let h=u.mapping.map(r.pos),f=at(u.doc,h,i.length,i);if(f||(i[0]=a?{type:a}:null,f=at(u.doc,h,i.length,i)),!f)return!1;if(u.split(h,i.length,i),!l&&d&&r.node(o).type!=a){let p=u.mapping.map(r.before(o)),m=u.doc.resolve(p);a&&r.node(o-1).canReplaceWith(m.index(),m.index()+1,a)&&u.setNodeMarkup(u.mapping.map(r.before(o)),a)}return t&&t(u.scrollIntoView()),!0}}const Lm=Pm(),zm=(n,e)=>{let{$from:t,to:r}=n.selection,s,i=t.sharedDepth(r);return i==0?!1:(s=t.before(i),e&&e(n.tr.setSelection(D.create(n.doc,s))),!0)};function $m(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Et(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function kd(n,e,t,r){let s=e.nodeBefore,i=e.nodeAfter,o,a,l=s.type.spec.isolating||i.type.spec.isolating;if(!l&&$m(n,e,t))return!0;let d=!l&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(o=(a=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&a.matchType(o[0]||i.type).validEnd){if(t){let p=e.pos+i.nodeSize,m=N.empty;for(let b=o.length-1;b>=0;b--)m=N.from(o[b].create(null,m));m=N.from(s.copy(m));let g=n.tr.step(new fe(e.pos-1,p,e.pos,p,new T(m,1,0),o.length,!0)),x=g.doc.resolve(p+2*o.length);x.nodeAfter&&x.nodeAfter.type==s.type&&Et(g.doc,x.pos)&&g.join(x.pos),t(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&l?null:z.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),f=h&&jn(h);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(h,f).scrollIntoView()),!0;if(d&&kn(i,"start",!0)&&kn(s,"end")){let p=s,m=[];for(;m.push(p),!p.isTextblock;)p=p.lastChild;let g=i,x=1;for(;!g.isTextblock;g=g.firstChild)x++;if(p.canReplace(p.childCount,p.childCount,g.content)){if(t){let b=N.empty;for(let k=m.length-1;k>=0;k--)b=N.from(m[k].copy(b));let y=n.tr.step(new fe(e.pos-m.length,e.pos+i.nodeSize,e.pos+x,e.pos+i.nodeSize-x,new T(b,m.length,0),0,!0));t(y.scrollIntoView())}return!0}}return!1}function Sd(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(I.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const _m=Sd(-1),Bm=Sd(1);function Hm(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),a=o&&_o(o,n,e);return a?(r&&r(t.tr.wrap(o,a).scrollIntoView()),!0):!1}}function el(n,e=null){return function(t,r){let s=!1;for(let i=0;i<t.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:a}}=t.selection.ranges[i];t.doc.nodesBetween(o,a,(l,d)=>{if(s)return!1;if(!(!l.isTextblock||l.hasMarkup(n,e)))if(l.type==n)s=!0;else{let u=t.doc.resolve(d),h=u.index();s=u.parent.canReplaceWith(h,h+1,n)}})}if(!s)return!1;if(r){let i=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[o];i.setBlockType(a,l,n,e)}r(i.scrollIntoView())}return!0}}function Uo(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}Uo(Ho,hd,pd);Uo(Ho,gd,xd);Uo(bd,yd,vd,Lm);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Vm(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i);if(!o)return!1;let a=r?t.tr:null;return Fm(a,o,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function Fm(n,e,t,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=o.resolve(e.start-2);i=new qr(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new qr(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let a=_o(i,t,r,e);return a?(n&&Wm(n,e,a,s,t),!0):!1}function Wm(n,e,t,r,s){let i=N.empty;for(let u=t.length-1;u>=0;u--)i=N.from(t[u].type.create(t[u].attrs,i));n.step(new fe(e.start-(r?2:0),e.end,e.start,e.end,new T(i,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==s&&(o=u+1);let a=t.length-o,l=e.start+t.length-(r?2:0),d=e.parent;for(let u=e.startIndex,h=e.endIndex,f=!0;u<h;u++,f=!1)!f&&at(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=d.child(u).nodeSize;return n}function Um(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?Km(e,t,n,i):qm(e,t,i):!0:!1}}function Km(n,e,t,r){let s=n.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new fe(i-1,o,i,o,new T(N.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new qr(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const a=jn(r);if(a==null)return!1;s.lift(r,a);let l=s.doc.resolve(s.mapping.map(i,-1)-1);return Et(s.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&s.join(l.pos),e(s.scrollIntoView()),!0}function qm(n,e,t){let r=n.tr,s=t.parent;for(let p=t.end,m=t.endIndex-1,g=t.startIndex;m>g;m--)p-=s.child(m).nodeSize,r.delete(p-1,p+1);let i=r.doc.resolve(t.start),o=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==s.childCount,d=i.node(-1),u=i.index(-1);if(!d.canReplace(u+(a?0:1),u+1,o.content.append(l?N.empty:N.from(s))))return!1;let h=i.pos,f=h+o.nodeSize;return r.step(new fe(h-(a?1:0),f+(l?1:0),h+1,f-1,new T((a?N.empty:N.from(s.copy(N.empty))).append(l?N.empty:N.from(s.copy(N.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function Jm(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,d=>d.childCount>0&&d.firstChild.type==n);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let a=i.parent,l=a.child(o-1);if(l.type!=n)return!1;if(t){let d=l.lastChild&&l.lastChild.type==a.type,u=N.from(d?n.create():null),h=new T(N.from(n.create(null,N.from(a.type.create(null,u)))),d?3:1,0),f=i.start,p=i.end;t(e.tr.step(new fe(f-(d?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0}}const ge=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Sn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let so=null;const it=function(n,e,t){let r=so||(so=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Gm=function(){so=null},Qt=function(n,e,t,r){return t&&(tl(n,e,t,r,-1)||tl(n,e,t,r,1))},Ym=/^(img|br|input|textarea|hr)$/i;function tl(n,e,t,r,s){for(var i;;){if(n==t&&e==r)return!0;if(e==(s<0?0:Le(n))){let o=n.parentNode;if(!o||o.nodeType!=1||gr(n)||Ym.test(n.nodeName)||n.contentEditable=="false")return!1;e=ge(n)+(s<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else n=o,e=s<0?Le(n):0}else return!1}}function Le(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Qm(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Le(n)}else if(n.parentNode&&!gr(n))e=ge(n),n=n.parentNode;else return null}}function Xm(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!gr(n))e=ge(n)+1,n=n.parentNode;else return null}}function Zm(n,e,t){for(let r=e==0,s=e==Le(n);r||s;){if(n==t)return!0;let i=ge(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,s=s&&i==Le(n)}}function gr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ks=function(n){return n.focusNode&&Qt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Dt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function eg(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function tg(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Le(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Le(r.startContainer),r.startOffset)}}}const Ze=typeof navigator<"u"?navigator:null,nl=typeof document<"u"?document:null,At=Ze&&Ze.userAgent||"",io=/Edge\/(\d+)/.exec(At),Cd=/MSIE \d/.exec(At),oo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(At),Ee=!!(Cd||oo||io),Ct=Cd?document.documentMode:oo?+oo[1]:io?+io[1]:0,ze=!Ee&&/gecko\/(\d+)/i.test(At);ze&&+(/Firefox\/(\d+)/.exec(At)||[0,0])[1];const ao=!Ee&&/Chrome\/(\d+)/.exec(At),ye=!!ao,Nd=ao?+ao[1]:0,ke=!Ee&&!!Ze&&/Apple Computer/.test(Ze.vendor),Cn=ke&&(/Mobile\/\w+/.test(At)||!!Ze&&Ze.maxTouchPoints>2),Pe=Cn||(Ze?/Mac/.test(Ze.platform):!1),wd=Ze?/Win/.test(Ze.platform):!1,ot=/Android \d/.test(At),xr=!!nl&&"webkitFontSmoothing"in nl.documentElement.style,ng=xr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function rg(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function tt(n,e){return typeof n=="number"?n:n[e]}function sg(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function rl(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Sn(o);continue}let a=o,l=a==i.body,d=l?rg(i):sg(a),u=0,h=0;if(e.top<d.top+tt(r,"top")?h=-(d.top-e.top+tt(s,"top")):e.bottom>d.bottom-tt(r,"bottom")&&(h=e.bottom-e.top>d.bottom-d.top?e.top+tt(s,"top")-d.top:e.bottom-d.bottom+tt(s,"bottom")),e.left<d.left+tt(r,"left")?u=-(d.left-e.left+tt(s,"left")):e.right>d.right-tt(r,"right")&&(u=e.right-d.right+tt(s,"right")),u||h)if(l)i.defaultView.scrollBy(u,h);else{let p=a.scrollLeft,m=a.scrollTop;h&&(a.scrollTop+=h),u&&(a.scrollLeft+=u);let g=a.scrollLeft-p,x=a.scrollTop-m;e={left:e.left-g,top:e.top-x,right:e.right-g,bottom:e.bottom-x}}let f=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Sn(o)}}function ig(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.to
vendor: 4,047 bytes, line 41
41p),r,s;for(let i=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let a=n.root.elementFromPoint(i,o);if(!a||a==n.dom||!n.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){r=a,s=l.top;break}}return{refDOM:r,refTop:s,stack:Md(n.dom)}}function Md(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Sn(r));return e}function og({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;jd(t,r==0?0:r-e)}function jd(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:i}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let cn=null;function ag(n){if(n.setActive)return n.setActive();if(cn)return n.focus(cn);let e=Md(n);n.focus(cn==null?{get preventScroll(){return cn={preventScroll:!0},!0}}:void 0),cn||(cn=!1,jd(e,0))}function Td(n,e){let t,r=2e8,s,i=0,o=e.top,a=e.top,l,d;for(let u=n.firstChild,h=0;u;u=u.nextSibling,h++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=it(u).getClientRects();else continue;for(let p=0;p<f.length;p++){let m=f[p];if(m.top<=o&&m.bottom>=a){o=Math.max(m.bottom,o),a=Math.min(m.top,a);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<r){t=u,r=g,s=g&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&g&&(i=h+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!l&&m.left<=e.left&&m.right>=e.left&&(l=u,d={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(i=h+1)}}return!t&&l&&(t=l,s=d,r=0),t&&t.nodeType==3?lg(t,s):!t||r&&t.nodeType==1?{node:n,offset:i}:Td(t,s)}function lg(n,e){let t=n.nodeValue.length,r=document.createRange(),s;for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let o=ut(r,1);if(o.top!=o.bottom&&Ko(e,o)){s={node:n,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:n,offset:0}}function Ko(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function cg(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function dg(n,e,t){let{node:r,offset:s}=Td(e,t),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,s,i)}function ug(n,e,t,r){let s=-1;for(let i=e,o=!1;i!=n.dom;){let a=n.docView.nearestDesc(i,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!o&&l.left>r.left||l.top>r.top?s=a.posBefore:(!o&&l.right<r.left||l.bottom<r.top)&&(s=a.posAfter),o=!0),!a.contentDOM&&s<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;i=a.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function Ed(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=s;;){let o=n.childNodes[i];if(o.nodeType==1){let a=o.getClientRects();for(let l=0;l<a.length;l++){let d=a[l];if(Ko(e,d))return Ed(o,e,d)}}if((i=(i+1)%r)==s)break}return n}function hg(n,e){let t=n.dom.ownerDocument,r,s=0,i=tg(t,e.left,e.top);i&&({node:r,offset:s}=i);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),a;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let d=n.dom.getBoundingClientRect();if(!Ko(e,d)||(o=Ed(n.dom,e,d),!o))return null}if(ke)for(let d=o;r&&d;d=Sn(d))d.draggable&&(r=void 0);if(o=cg(o,e),r){if(ze&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],h;u.nodeName=="IMG"&&(h=u.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&s++}let d;xr&&s&&r.nodeType==1&&(d=r.childNodes[s-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>
vendor: 8,080 bytes, line 41
41r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(a=ug(n,r,s,e))}a==null&&(a=dg(n,o,e));let l=n.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function sl(n){return n.top<n.bottom||n.left<n.right}function ut(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(sl(r))return r}return Array.prototype.find.call(t,sl)||n.getBoundingClientRect()}const fg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ad(n,e,t){let{node:r,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),o=xr||ze;if(r.nodeType==3)if(o&&(fg.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let l=ut(it(r,s,s),t);if(ze&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let d=ut(it(r,s-1,s-1),-1);if(d.top==l.top){let u=ut(it(r,s,s+1),-1);if(u.top!=l.top)return An(u,u.left<d.left)}}return l}else{let l=s,d=s,u=t<0?1:-1;return t<0&&!s?(d++,u=-1):t>=0&&s==r.nodeValue.length?(l--,u=1):t<0?l--:d++,An(ut(it(r,l,d),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==Le(r))){let l=r.childNodes[s-1];if(l.nodeType==1)return wi(l.getBoundingClientRect(),!1)}if(i==null&&s<Le(r)){let l=r.childNodes[s];if(l.nodeType==1)return wi(l.getBoundingClientRect(),!0)}return wi(r.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==Le(r))){let l=r.childNodes[s-1],d=l.nodeType==3?it(l,Le(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(d)return An(ut(d,1),!1)}if(i==null&&s<Le(r)){let l=r.childNodes[s];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let d=l?l.nodeType==3?it(l,0,o?0:1):l.nodeType==1?l:null:null;if(d)return An(ut(d,-1),!0)}return An(ut(r.nodeType==3?it(r):r,-t),t>=0)}function An(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function wi(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Od(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function pg(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return Od(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.contentDOM||a.dom;break}i=a.dom.parentNode}let o=Ad(n,s.pos,1);for(let a=i.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=it(a,0,a.nodeValue.length).getClientRects();else continue;for(let d=0;d<l.length;d++){let u=l[d];if(u.bottom>u.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const mg=/[\u0590-\u08ac]/;function gg(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,a=n.domSelection();return a?!mg.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?i:o:Od(n,e,()=>{let{focusNode:l,focusOffset:d,anchorNode:u,anchorOffset:h}=n.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:m,focusOffset:g}=n.domSelectionRange(),x=m&&!p.contains(m.nodeType==1?m:m.parentNode)||l==m&&d==g;try{a.collapse(u,h),l&&(l!=u||d!=h)&&a.extend&&a.extend(l,d)}catch{}return f!=null&&(a.caretBidiLevel=f),x}):r.pos==r.start()||r.pos==r.end()}let il=null,ol=null,al=!1;function xg(n,e,t){return il==e&&ol==t?al:(il=e,ol=t,al=t=="up"||t=="down"?pg(n,e,t):gg(n,e,t))}const $e=0,ll=1,_t=2,et=3;class br{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=$e,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ge(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!t||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let a=s.children[o];if(a.size){s=a;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],a=i+o.size;if(a>e||o instanceof Rd){s=e-i;break}i=a}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Dd&&i.side>=0;r--);if(t<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&t&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?ge(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?ge(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,a=0;;a++){let l=this.children[a],d=o+l.size;if(s==-1&&e<=d){let u=o+l.border;if(e>=u&&t<=d-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,u);e=o;for(let h=a;h>0;h--){let f=this.children[h-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=ge(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(d>t||a==this.children.length-1)){t=d;for(let u=a+1;u<this.children.length;u++){let h=this.children[u];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){i=ge(h.dom);break}t+=h.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=d}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);
vendor: 4,411 bytes, lines 41-42
41if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let p=0,m=0;p<this.children.length;p++){let g=this.children[p],x=m+g.size;if(i>m&&o<x)return g.setSelection(e-m-g.border,t-m-g.border,r,s);m=x}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),d=r.root.getSelection(),u=r.domSelectionRange(),h=!1;if((ze||ke)&&e==t){let{node:p,offset:m}=a;if(p.nodeType==3){if(h=!!(m&&p.nodeValue[m-1]==` 42`),h&&m==p.nodeValue.length)for(let g=p,x;g;g=g.parentNode){if(x=g.nextSibling){x.nodeName=="BR"&&(a=l={node:x.parentNode,offset:ge(x)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=p.childNodes[m-1];h=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(ze&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(s=!0)}if(!(s||h&&ke)&&Qt(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Qt(l.node,l.offset,u.focusNode,u.focusOffset))return;let f=!1;if((d.extend||e==t)&&!(h&&ze)){d.collapse(a.node,a.offset);try{e!=t&&d.extend(l.node,l.offset),f=!0}catch{}}if(!f){if(e>t){let m=a;a=l,l=m}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),d.removeAllRanges(),d.addRange(p)}}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 r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let a=r+i.border,l=o-i.border;if(e>=a&&t<=l){this.dirty=e==r||t==o?_t:ll,e==a&&t==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=et:i.markDirty(e-a,t-a);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?_t:et}r=o}this.dirty=_t}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?_t:ll;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Dd extends br{constructor(e,t,r,s){let i,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(o.nodeType!=1){let a=document.createElement("span");a.appendChild(o),o=a}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==$e&&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}}class bg extends br{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Xt extends br{constructor(e,t,r,s,i){super(e,[],r,s),this.mark=t,this.spec=i}static create(e,t,r,s){let i=s.nodeViews[t.type.name],o=i&&i(t,s,r);return(!o||!o.dom)&&(o=nn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Xt(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&et||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=et&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=$e){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=$e}}slice(e,t,r){let s=Xt.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;t<o&&(i=co(i,t,o,r)),e>0&&(i=co(i,0,e,r));for(let a=0;a<i.length;a++)i[a].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Nt extends br{constructor(e,t,r,s,i,o,a,l,d){super(e,[],i,o),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=a}
vendor: 7,530 bytes, line 42
42static create(e,t,r,s,i,o){let a=i.nodeViews[t.type.name],l,d=a&&a(t,i,()=>{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,s),u=d&&d.dom,h=d&&d.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=nn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Ld(u,r,t),d?l=new yg(e,t,r,s,u,h||null,f,d,i,o+1):t.isText?new qs(e,t,r,s,u,f,i):new Nt(e,t,r,s,u,h||null,f,i,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 r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>N.empty)}return e}matchesNode(e,t,r){return this.dirty==$e&&e.eq(this.node)&&Gr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,a=i&&i.pos<0,l=new kg(this,o&&o.node,e);Ng(this.node,this.innerDeco,(d,u,h)=>{d.spec.marks?l.syncToMarks(d.spec.marks,r,e,u):d.type.side>=0&&!h&&l.syncToMarks(u==this.node.childCount?K.none:this.node.child(u).marks,r,e,u),l.placeWidget(d,e,s)},(d,u,h,f)=>{l.syncToMarks(d.marks,r,e,f);let p;l.findNodeMatch(d,u,h,f)||a&&e.state.selection.from>s&&e.state.selection.to<s+d.nodeSize&&(p=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(d,u,h,p,e)||l.updateNextNode(d,u,h,e,f,s)||l.addNode(d,u,h,e,s),s+=d.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==_t)&&(o&&this.protectLocalComposition(e,o),Id(this.contentDOM,this.children,e),Cn&&wg(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof I)||r<t||s>t+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 o=i.nodeValue,a=Mg(this.node.content,o,r-t,s-t);return a<0?null:{node:i,pos:a,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){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 o=new bg(this,i,t,s);e.input.compositionNodes.push(o),this.children=co(this.children,r,r+s.length,e,o)}update(e,t,r,s){return this.dirty==et||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=$e}updateOuterDeco(e){if(Gr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Pd(this.dom,this.nodeDOM,lo(this.outerDeco,this.node,t),lo(e,this.node,t)),this.dom!=r&&(r.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 cl(n,e,t,r,s){Ld(r,e,n);let i=new Nt(void 0,n,e,t,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class qs extends Nt{constructor(e,t,r,s,i,o,a){super(e,t,r,s,i,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==et||this.dirty!=$e&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=$e||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=$e,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new qs(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=et)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Rd extends br{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==$e&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class yg extends Nt{constructor(e,t,r,s,i,o,a,l,d,u){super(e,t,r,s,i,o,a,d,u),this.spec=l}update(e,t,r,s){if(this.dirty==et)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}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 Id(n,e,t){let r=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],a=o.dom;if(a.parentNode==n){for(;a!=r;)r=dl(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(a,r);if(o instanceof Xt){let l=r?r.previousSibling:n.lastChild;Id(o.contentDOM,o.children,t),r=l?l.nextSibling:n.firstChild}}for(;r;)r=dl(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Gn=function(n){n&&(this.nodeName=n)};Gn.prototype=Object.create(null);const Bt=[new Gn];function lo(n,e,t){if(n.length==0)return Bt;let r=t?Bt[0]:new Gn,s=[r];for(let i=0;i<n.length;i++){let o=n[i].type.attrs;if(o){o.nodeName&&s.push(r=new Gn(o.nodeName));for(let a in o){let l=o[a];l!=null&&(t&&s.length==1&&s.push(r=new Gn(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return s}function Pd(n,e,t,r){if(t==Bt&&r==Bt)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],a=t[i];if(i){let l;a&&a.nodeName==o.nodeName&&s!=n&&(l=s.parentNode)&&l.nodeName.toLowerCase()==o.nodeName||(l=document.createElement(o.nodeName),l.pmIsDeco=!0,l.appendChild(s),a=Bt[0]),s=l}vg(s,a||Bt[0],o)}return s}function vg(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);
vendor: 5,799 bytes, line 42
42if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function Ld(n,e,t){return Pd(n,n,Bt,lo(e,t,n.nodeType!=1))}function Gr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function dl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class kg{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Sg(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,s){let i=0,o=this.stack.length>>1,a=Math.min(o,e.length);for(;i<a&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=$e,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1,d=this.top.children.length;s<this.preMatch.index&&(d=Math.min(this.index+3,d));for(let u=this.index;u<d;u++){let h=this.top.children[u];if(h.matchesMark(e[o])&&!this.isLocked(h.dom)){l=u;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=Xt.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))i=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let d=this.top.children[a];if(d.matchesNode(e,t,r)&&!this.preMatch.matched.has(d)){i=a;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,s,i){let o=this.top.children[s];return o.dirty==et&&o.dom==o.contentDOM&&(o.dirty=_t),o.update(e,t,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,i,o){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof Nt){let d=this.preMatch.matched.get(l);if(d!=null&&d!=i)return!1;let u=l.dom,h,f=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=et&&Gr(t,l.outerDeco));if(!f&&l.update(e,t,r,s))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(h=this.recreateWrapper(l,e,t,r,s,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=_t,h.updateChildren(s,o+1),h.dirty=$e),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Gr(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let a=Nt.create(this.top,t,r,s,i,o);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,r,s,i){let o=Nt.create(this.top,e,t,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Dd(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Xt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof qs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ke||ye)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Rd(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Sg(n,e){let t=e,r=t.children.length,s=n.childCount,i=new Map,o=[];e:for(;s>0;){let a;for(;;)if(r){let d=t.children[r-1];if(d instanceof Xt)t=d,r=d.children.length;else{a=d,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=n.child(s-1))break;--s,i.set(a,s),o.push(a)}}return{index:s,matched:i,matches:o.reverse()}}function Cg(n,e){return n.type.side-e.type.side}function Ng(n,e,t,r){let s=e.locals(n),i=0;if(s.length==0){for(let d=0;d<n.childCount;d++){let u=n.child(d);r(u,s,e.forChild(i,u),d),i+=u.nodeSize}return}let o=0,a=[],l=null;for(let d=0;;){let u,h;for(;o<s.length&&s[o].to==i;){let x=s[o++];x.widget&&(u?(h||(h=[u])).push(x):u=x)}if(u)if(h){h.sort(Cg);for(let x=0;x<h.length;x++)t(h[x],d,!!l)}else t(u,d,!!l);let f,p;if(l)p=-1,f=l,l=null;else if(d<n.childCount)p=d,f=n.child(d++);else break;for(let x=0;x<a.length;
vendor: 9,922 bytes, line 42
42x++)a[x].to<=i&&a.splice(x--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)a.push(s[o++]);let m=i+f.nodeSize;if(f.isText){let x=m;o<s.length&&s[o].from<x&&(x=s[o].from);for(let b=0;b<a.length;b++)a[b].to<x&&(x=a[b].to);x<m&&(l=f.cut(x-i),f=f.cut(0,x-i),m=x,p=-1)}else for(;o<s.length&&s[o].to<m;)o++;let g=f.isInline&&!f.isLeaf?a.filter(x=>!x.inline):a.slice();r(f,g,e.forChild(i,f),p),i=m}}function wg(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Mg(n,e,t,r){for(let s=0,i=0;s<n.childCount&&i<=r;){let o=n.child(s++),a=i;if(i+=o.nodeSize,!o.isText)continue;let l=o.text;for(;s<n.childCount;){let d=n.child(s++);if(i+=d.nodeSize,!d.isText)break;l+=d.text}if(i>=t){if(i>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let d=a<r?l.lastIndexOf(e,r-a-1):-1;if(d>=0&&d+e.length+a>=t)return a+d;if(t==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function co(n,e,t,r,s){let i=[];for(let o=0,a=0;o<n.length;o++){let l=n[o],d=a,u=a+=l.size;d>=t||u<=e?i.push(l):(d<e&&i.push(l.slice(0,e-d,r)),s&&(i.push(s),s=void 0),u>t&&i.push(l.slice(t-d,l.size,r)))}return i}function qo(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,d;if(Ks(t)){for(l=o;s&&!s.node;)s=s.parent;let h=s.node;if(s&&h.isAtom&&D.isSelectable(h)&&s.parent&&!(h.isInline&&Zm(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;d=new D(o==f?a:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=o,f=o;for(let p=0;p<t.rangeCount;p++){let m=t.getRangeAt(p);h=Math.min(h,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(h<0)return null;[l,o]=f==n.state.selection.anchor?[f,h]:[h,f],a=r.resolve(o)}else l=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!d){let h=e=="pointer"||n.state.selection.head<a.pos&&!i?1:-1;d=Jo(n,u,a,h)}return d}function zd(n){return n.editable?n.hasFocus():_d(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function lt(n,e=!1){let t=n.state.selection;if($d(n,t),!!zd(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ye){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Qt(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Tg(n);else{let{anchor:r,head:s}=t,i,o;ul&&!(t instanceof I)&&(t.$from.parent.inlineContent||(i=hl(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=hl(n,t.to))),n.docView.setSelection(r,s,n,e),ul&&(i&&fl(i),o&&fl(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&jg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const ul=ke||ye&&Nd<63;function hl(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(ke&&s&&s.contentEditable=="false")return Mi(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Mi(s);if(i)return Mi(i)}}function Mi(n){return n.contentEditable="true",ke&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function fl(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function jg(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!zd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Tg(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,ge(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Ee&&Ct<=11&&(t.disabled=!0,t.disabled=!1)}function $d(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(pl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else pl(n)}function pl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Jo(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||I.between(e,t,r)}function ml(n){return n.editable&&!n.hasFocus()?!1:_d(n)}function _d(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Eg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Qt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function uo(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&z.findFrom(i,e)}function ht(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function gl(n,e,t){let r=n.state.selection;if(r instanceof I)if(t.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return ht(n,new I(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=uo(n.state,e);return s&&s instanceof D?ht(n,s):!1}else if(!(Pe&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let a=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(a))&&!o.contentDOM?D.isSelectable(i)?ht(n,new D(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):xr?ht(n,new I(n.state.doc.resolve(e<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof D&&r.node.isInline)return ht(n,new I(e>0?r.$to:r.$from));{let s=uo(n.state,e);return s?ht(n,s):!1}}}function Yr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Yn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function dn(n,e){return e<0?Ag(n):Og(n)}function Ag(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(ze&&t.nodeType==1&&r<Yr(t)&&Yn(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(Yn(a,-1))s=t,i=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(Bd(t))break;{let a=t.previousSibling;for(;a&&Yn(a,-1);)s=t.parentNode,i=ge(a),a=a.previousSibling;if(a)t=a,r=Yr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?ho(n,t,r):s&&ho(n,s,i)}function Og(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=Yr(t),i,o;for(;;)if(r<s){if(t.nodeType!=1)break;let a=t.childNodes[r];if(Yn(a,1))i=t,o=++r;else break}else{if(Bd(t))break;{let a=t.nextSibling;for(;a&&Yn(a,1);)i=a.parentNode,o=ge(a)+1,a=a.nextSibling;if(a)t=a,r=0,s=Yr(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}i&&ho(n,i,o)}function Bd(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Dg(n,e){for(;n&&e==n.childNodes.length&&!gr(n);)e=ge(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Rg(n,e){for(;n&&!e&&!gr(n);)e=ge(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function ho(n,e,t){if(e.nodeType!=3){let i,o;(o=Dg(e,t))?(e=o,t=0):(i=Rg(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ks(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&<(n)},50)}function xl(n,e){let t=n.state.doc.resolve(e);if(!(ye||wd)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function bl(n,e,t){let r=n.state.selection;if(r instanceof I&&!r.empty||t.indexOf("s")>-1||Pe&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=uo(n.state,e);if(o&&o instanceof D)return ht(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,a=r instanceof Oe?z.near(o,e):z.findFrom(o,e);return a?ht(n,a):!1}return!1}function yl(n,e){if(!(n.state.selection instanceof I))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function vl(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Ig(n){if(!ke||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;vl(n,r,"true"),setTimeout(()=>vl(n,r,"false"),20)}return!1}function Pg(n){let e="";
vendor: 5,485 bytes, lines 42-45
42return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Lg(n,e){let t=e.keyCode,r=Pg(e);if(t==8||Pe&&t==72&&r=="c")return yl(n,-1)||dn(n,-1);if(t==46&&!e.shiftKey||Pe&&t==68&&r=="c")return yl(n,1)||dn(n,1);if(t==13||t==27)return!0;if(t==37||Pe&&t==66&&r=="c"){let s=t==37?xl(n,n.state.selection.from)=="ltr"?-1:1:-1;return gl(n,s,r)||dn(n,s)}else if(t==39||Pe&&t==70&&r=="c"){let s=t==39?xl(n,n.state.selection.from)=="ltr"?1:-1:1;return gl(n,s,r)||dn(n,s)}else{if(t==38||Pe&&t==80&&r=="c")return bl(n,-1,r)||dn(n,-1);if(t==40||Pe&&t==78&&r=="c")return Ig(n)||bl(n,1,r)||dn(n,1);if(r==(Pe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Go(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=n.someProp("clipboardSerializer")||nn.fromSchema(n.state.schema),a=Kd(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let d=l.firstChild,u,h=0;for(;d&&d.nodeType==1&&(u=Ud[d.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let m=a.createElement(u[p]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),h++}d=l.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${h?` -${h}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,` 43 44`);return{dom:l,text:f,slice:e}}function Hd(n,e,t,r,s){let i=s.parent.type.spec.code,o,a;if(!t&&!e)return null;let l=!!e&&(r||i||!t);if(l){if(n.someProp("transformPastedText",f=>{e=f(e,i||r,n)}),i)return a=new T(N.from(n.state.schema.text(e.replace(/\r\n?/g,` 45`))),0,0),n.someProp("transformPasted",f=>{a=f(a,n,!0)}),a;let h=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(h)a=h;else{let f=s.marks(),{schema:p}=n.state,m=nn.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let x=o.appendChild(document.createElement("p"));g&&x.appendChild(m.serializeNode(p.text(g,f)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),o=Bg(t),xr&&Hg(o);let d=o&&o.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||St.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!zg.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=Vg(kl(a,+u[1],+u[2]),u[4]);else if(a=T.maxOpen($g(a.content,s),!0),a.openStart||a.openEnd){let h=0,f=0;for(let p=a.content.firstChild;h<a.openStart&&!p.type.spec.isolating;h++,p=p.firstChild);for(let p=a.content.lastChild;f<a.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);a=kl(a,h,f)}return n.someProp("transformPasted",h=>{a=h(a,n,l)}),a}const zg=/^(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 $g(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(a=>{if(!o)return;let l=s.findWrapping(a.type),d;if(!l)return o=null;if(d=o.length&&i.length&&Fd(l,i,a,o[o.length-1],0))o[o.length-1]=d;else{o.length&&(o[o.length-1]=Wd(o[o.length-1],i.length));let u=Vd(a,l);o.push(u),s=s.matchType(u.type),i=l}}),o)return N.from(o)}return n}function Vd(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,N.from(n));return n}function Fd(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=Fd(n,e,t,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(N.from(Vd(t,n,s+1))))}}function Wd(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Wd(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(N.empty,!0);return n.copy(t.append(r))}function fo(n,e,t,r,s,i){let o=e<0?n.firstChild:n.lastChild,a=o.content;return n.childCount>1&&(i=0),s<r-1&&(a=fo(a,e,t,r,s+1,i)),s>=t&&(a=e<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(N.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(a))}function kl(n,e,t){return e<n.openStart&&(n=new T(fo(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new T(fo(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ud={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Sl=null;function Kd(){return Sl||(Sl=document.implementation.createHTMLDocument("title"))}let ji=null;function _g(n){let e=window.trustedTypes;return e?(ji||(ji=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ji.createHTML(n)):n}function Bg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Kd().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&Ud[r[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=_g(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function Hg(n){let e=n.querySelectorAll(ye?"span:not([class]):not
45([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="Â "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Vg(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:o}=n;for(let a=r.length-2;a>=0;a-=2){let l=t.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;s=N.from(l.create(r[a+1],s)),i++,o++}return new T(s,i,o)}const Ne={},we={},Fg={touchstart:!0,touchmove:!0};class Wg{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 Ug(n){for(let e in Ne){let t=Ne[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{qg(n,r)&&!Yo(n,r)&&(n.editable||!(r.type in we))&&t(n,r)},Fg[e]?{passive:!0}:void 0)}ke&&n.dom.addEventListener("input",()=>null),po(n)}function kt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Kg(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function po(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Yo(n,r))})}function Yo(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function qg(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Jg(n,e){!Yo(n,e)&&Ne[e.type]&&(n.editable||!(e.type in we))&&Ne[e.type](n,e)}we.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Jd(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ot&&ye&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Cn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,Dt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Lg(n,t)?t.preventDefault():kt(n,"key")};we.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};we.keypress=(n,e)=>{let t=e;if(Jd(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Pe&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof I)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,s,i))&&n.dispatch(i()),t.preventDefault()}};function Js(n){return{left:n.clientX,top:n.clientY}}function Gg(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Qo(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,a=>o>i.depth?a(n,t,i.nodeAfter,i.before(o),s,!0):a(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function bn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Yg(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?(bn(n,new D(t)),!0):!1}function Qg(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof D&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let a=o>i.depth?i.nodeAfter:i.node(o);if(D.isSelectable(a)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(bn(n,D.create(n.state.doc,s)),!0):!1}function Xg(n,e,t,r,s){return Qo(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?Qg(n,t):Yg(n,t))}function Zg(n,e,t,r){return Qo(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",
vendor: 19,449 bytes, line 45
45s=>s(n,e,r))}function ex(n,e,t,r){return Qo(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||tx(n,t,r)}function tx(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(bn(n,I.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),a=s.before(i);if(o.inlineContent)bn(n,I.create(r,a+1,a+1+o.content.size));else if(D.isSelectable(o))bn(n,D.create(r,a));else continue;return!0}}function Xo(n){return Qr(n)}const qd=Pe?"metaKey":"ctrlKey";Ne.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Xo(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Gg(t,n.input.lastClick)&&!t[qd]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i,button:t.button};let o=n.posAtCoords(Js(t));o&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new nx(n,o,t,!!r)):(i=="doubleClick"?Zg:ex)(n,o.pos,o.inside,t)?t.preventDefault():kt(n,"pointer"))};class nx{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[qd],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);i=u.parent,o=u.depth?u.before():0}const a=s?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:d}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof D&&d.from<=o&&d.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ze&&!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)),kt(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(()=>lt(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(Js(e))),this.updateAllowDefault(e),this.allowDefault||!t?kt(this.view,"pointer"):Xg(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ke&&this.mightDrag&&!this.mightDrag.node.isAtom||ye&&!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)?(bn(this.view,z.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):kt(this.view,"pointer")}move(e){this.updateAllowDefault(e),kt(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)}}Ne.touchstart=n=>{n.input.lastTouch=Date.now(),Xo(n),kt(n,"pointer")};Ne.touchmove=n=>{n.input.lastTouch=Date.now(),kt(n,"pointer")};Ne.contextmenu=n=>Xo(n);function Jd(n,e){return n.composing?!0:ke&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const rx=ot?5e3:-1;we.compositionstart=we.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof I&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ye&&wd&&sx(n)))n.markCursor=n.state.storedMarks||t.marks(),Qr(n,!0),n.markCursor=null;else if(Qr(n,!e.selection.empty),ze&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let a=n.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}Gd(n,rx)};function sx(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}we.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Gd(n,20))};function Gd(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Qr(n),e))}function Yd(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ox());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function ix(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Qm(e.focusNode,e.focusOffset),r=Xm(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function ox(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Qr(n,e=!1){if(!(ot&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Yd(n),e||n.docView&&n.docView.dirty){let t=qo(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function ax(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const cr=Ee&&Ct<15||Cn&&ng<604;Ne.copy=we.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=cr?null:t.clipboardData,o=r.content(),{dom:a,text:l}=Go(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):ax(n,a),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function lx(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function cx(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?dr(n,r.value,null,s,e):dr(n,r.textContent,r.innerHTML,s,e)},50)}function dr(n,e,t,r,s){let i=Hd(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,s,i||T.empty)))return!0;if(!i)return!1;let o=lx(i),a=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Qd(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}we.paste=(n,e)=>{let t=e;if(n.composing&&!ot)return;let r=cr?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&dr(n,Qd(r),r.getData("text/html"),s,t)?t.preventDefault():cx(n,t)};class Xd{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const dx=Pe?"altKey":"ctrlKey";function Zd(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[dx]}Ne.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(Js(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof D?s.to-1:s.to))){if(r&&r.mightDrag)o=D.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(o=D.create(n.state.doc,h.posBefore))}}let a=(o||n.state.selection).content(),{dom:l,text:d,slice:u}=Go(n,a);(!t.dataTransfer.files.length||!ye||Nd>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(cr?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",cr||t.dataTransfer.setData("text/plain",d),n.dragging=new Xd(u,Zd(n,t),o)};Ne.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};we.dragover=we.dragenter=(n,e)=>e.preventDefault();we.drop=(n,e)=>{try{ux(n,e,n.dragging)}finally{n.dragging=null}};function ux(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Js(e));if(!r)return;let s=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",p=>{i=p(i,n,!1)}):i=Hd(n,Qd(e.dataTransfer),cr?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(t&&Zd(n,e));if(n.someProp("handleDrop",p=>p(n,e,i||T.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let a=i?rd(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let l=n.state.tr;if(o){let{node:p}=t;p?p.replace(l):l.deleteSelection()}let d=l.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,h=l.doc;if(u?l.replaceRangeWith(d,d,i.content.firstChild):l.replaceRange(d,d,i),l.doc.eq(h))return;let f=l.doc.resolve(d);if(u&&D.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new D(f));else{let p=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,g,x,b)=>p=b),l.setSelection(Jo(n,f,l.doc.resolve(p)))}n.focus(),n.dispatch(l.setMeta("uiEvent","drop"))}Ne.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&<(n)},20))};Ne.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ne.beforeinput=(n,e)=>{if(ye&&ot&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Dt(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in we)Ne[n]=we[n];function ur(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Xr{constructor(e,t){this.toDOM=e,this.spec=t||Ut,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new Ce(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Xr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ur(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class wt{constructor(e,t){this.attrs=e,this.spec=t||Ut}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Ce(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof wt&&ur(this.attrs,e.attrs)&&ur(this.spec,e.spec)}static is(e){return e.type instanceof wt}destroy(){}}class Zo{constructor(e,t){this.attrs=e,this.spec=t||Ut}map(e,t,r,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let o=e.mapResult(t.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Ce(i.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(r)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof Zo&&ur(this.attrs,e.attrs)&&ur(this.spec,e.spec)}destroy(){}}class Ce{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Ce(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Ce(e,e,new Xr(t,r))}static inline(e,t,r,s){return new Ce(e,t,new wt(r,s))}static node(e,t,r,s){return new Ce(e,t,new Zo(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof wt}get widget(){return this.type instanceof Xr}}const fn=[],Ut={};class X{constructor(e,t){this.local=e.length?e:fn,this.children=t.length?t:fn}static create(e,t){return t.length?Zr(t,e,0,Ut):ve}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,i){for(let o=0;o<this.local.length;o++){let a=this.local[o];a.from<=t&&a.to>=e&&(!i||i(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,t-a,r,s+a,i)}}map(e,t,r){return this==ve||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ut)}mapInner(e,t,r,s,i){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,s);l&&l.type.valid(t,l)?(o||(o=[])).push(l):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?hx(this.children,o||[],e,t,r,s,i):o?new X(o.sort(Kt),fn):ve}add(e,t){return t.length?this==ve?X.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,i=0;e.forEach((a,l)=>{let d=l+r,u;if(u=tu(t,a,d)){for(s||(s=this.children.slice());i<s.length&&s[i]<l;)i+=3;s[i]==l?s[i+2]=s[i+2].addInner(a,u,d+1):s.splice(i,0,l,l+a.nodeSize,Zr(u,a,d+1,Ut)),i+=3}});let o=eu(i?nu(t):t,-r);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new X(o.length?this.local.concat(o).sort(Kt):this.local,s||this.children)}remove(e){return e.length==0||this==ve?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,a=r[i]+t,l=r[i+1]+t;for(let u=0,h;u<e.length;u++)(h=e[u])&&h.from>a&&h.to<l&&(e[u]=null,(o||(o=[])).push(h));if(!o)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(o,a+1);d!=ve?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let a=0;a<s.length;a++)s[a].eq(o,t)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new X(s,r):ve}forChild(e,t){if(this==ve)return this;if(t.isLeaf)return X.empty;let r,s;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let i=e+1,o=i+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<o&&l.to>i&&l.type instanceof wt){let d=Math.max(i,l.from)-i,u=Math.min(o,l.to)-i;d<u&&(s||(s=[])).push(l.copy(d,u))}}if(s){let a=new X(s.sort(Kt),fn);return r?new gt([a,r]):a}return r||ve}eq(e){if(this==e)return!0;if(!(e instanceof X)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ea(this.localsInner(e))}localsInner(e){if(this==ve)return fn;if(e.inlineContent||!this.local.some(wt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof wt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}X.empty=new X([],[]);X.removeOverlap=ea;const ve=X.empty;class gt{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,Ut));return gt.from(r)}forChild(e,t){if(t.isLeaf)return X.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=ve&&(i instanceof gt?r=r.concat(i.members):r.push(i))}return gt.from(r)}eq(e){if(!(e instanceof gt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let o=0;o<i.length;o++)t.push(i[o])}}return t?ea(r?t:t.sort(Kt)):fn}static from(e){switch(e.length){case 0:return ve;case 1:return e[0];default:return new gt(e.every(t=>t instanceof X)?e:e.reduce((t,r)=>t.concat(r instanceof X?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function hx(n,e,t,r,s,i,o){let a=n.slice();for(let d=0,u=i;d<t.maps.length;d++){let h=0;t.maps[d].forEach((f,p,m,g)=>{let x=g-m-(p-f);for(let b=0;b<a.length;b+=3){let y=a[b+1];if(y<0||f>y+u-h)continue;let k=a[b]+u-h;p>=k?a[b+1]=f<=k?-2:-1:f>=u&&x&&(a[b]+=x,a[b+1]+=x)}h+=x}),u=t.maps[d].map(u,-1)}let l=!1;for(let d=0;d<a.length;d+=3)if(a[d+1]<0){if(a[d+1]==-2){l=!0,a[d+1]=-1;continue}let u=t.map(n[d]+i),h=u-s;if(h<0||h>=r.content.size){l=!0;continue}let f=t.map(n[d+1]+i,-1),p=f-s,{index:m,offset:g}=r.content.findIndex(h),x=r.maybeChild(m);if(x&&g==h&&g+x.nodeSize==p){let b=a[d+2].mapInner(t,x,u+1,n[d]+i+1,o);b!=ve?(a[d]=h,a[d+1]=p,a[d+2]=b):(a[d+1]=-2,l=!0)}else l=!0}if(l){let d=fx(a,n,e,t,s,i,o),u=Zr(d,r,0,o);e=u.local;for(let h=0;h<a.length;h+=3)a[h+1]<0&&(a.splice(h,3),h-=3);for(let h=0,f=0;h<u.children.length;h+=3){let p=u.children[h];for(;f<a.length&&a[f]<p;)f+=3;a.splice(f,0,u.children[h],u.children[h+1],u.children[h+2])}}return new X(e.sort(Kt),a)}function eu(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new Ce(s.from+e,s.to+e,s.type))}return t}function fx(n,e,t,r,s,i,o){function a(l,d){for(let u=0;u<l.local.length;u++){let h=l.local[u].map(r,s,d);h?t.push(h):o.onRemove&&o.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+d+1)}for(let l=0;l<n.length;l+=3)n[l+1]==-1&&a(n[l+2],e[l]+i+1);return t}function tu(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let i=0,o;i<n.length;i++)(o=n[i])&&o.from>t&&o.to<r&&((s||(s=[])).push(o),n[i]=null);return s}function nu(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Zr(n,e,t,r){let s=[],i=!1;e.forEach((a,l)=>{let d=tu(n,a,l+t);if(d){i=!0;let u=Zr(d,a,t+l+1,r);u!=ve&&s.push(l,l+a.nodeSize,u)}});let o=eu(i?nu(n):n,-t).sort(Kt);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1));return o.length||s.length?new X(o,s):ve}function Kt(n,e){return n.from-e.from||n.to-e.to}function ea(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;
vendor: 10,428 bytes, line 45
45s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,r.to),Cl(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),Cl(e,s,r.copy(i.from,r.to)));break}}}return e}function Cl(n,e,t){for(;e<n.length&&Kt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ti(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ve&&e.push(r)}),n.cursorWrapper&&e.push(X.create(n.state.doc,[n.cursorWrapper.deco])),gt.from(e)}const px={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},mx=Ee&&Ct<=11;class gx{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}}class xx{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new gx,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Ee&&Ct<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():ke&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),mx&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,px)),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;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.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(ml(this.view)){if(this.suppressingSelectionUpdates)return lt(this.view);if(Ee&&Ct<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qt(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,r;for(let i=e.focusNode;i;i=Sn(i))t.add(i);for(let i=e.anchorNode;i;i=Sn(i))if(t.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))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 r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ml(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,a=!1,l=[];if(e.editable)for(let u=0;u<t.length;u++){let h=this.registerMutation(t[u],l);h&&(i=i<0?h.from:Math.min(h.from,i),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(a=!0))}if(l.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let h=u.nextSibling;for(;h&&h.nodeType==1;){if(h.contentEditable=="false"){u.parentNode.removeChild(u);break}h=h.firstChild}}}else if(ze&&l.length){let u=l.filter(h=>h.nodeName=="BR");if(u.length==2){let[h,f]=u;h.parentNode&&h.parentNode.parentNode==f.parentNode?f.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let f of u){let p=f.parentNode;p&&p.nodeName=="LI"&&(!h||vx(e,h)!=p)&&f.remove()}}}let d=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ks(r)&&(d=qo(e))&&d.eq(z.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,lt(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),bx(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,kx(e,l)),this.handleDOMChange(i,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||lt(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let h=e.addedNodes[u];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Ee&&Ct<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:h,nextSibling:f}=e.addedNodes[u];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(s=h),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let o=s&&s.parentNode==e.target?ge(s)+1:0,a=r.localPosFromDOM(e.target,o,-1),l=i&&i.parentNode==e.target?ge(i):e.target.childNodes.length,d=r.localPosFromDOM(e.target,l,1);return{from:a,to:d}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Nl=new WeakMap,wl=!1;function bx(n){if(!Nl.has(n)&&(Nl.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ze,wl)return;wl=!0}}function Ml(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Qt(o.node,o.offset,s,i)&&([t,r,s,i]=[s,i,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:i}}function yx(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Ml(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ml(n,t):null}function vx(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function kx(n,e){var t;let{focusNode:r,focusOffset:s}=n.domSelectionRange();for(let i of e)if(((t=i.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let a=o;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(i,a.firstChild),r==i&&n.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function Sx(n,e,t){let{node:r,fromOffset:s,toOffset:i,from:o,to:a}=n.docView.parseRange(e,t),l=n.domSelectionRange(),d,u=l.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(d=[{node:u,offset:l.anchorOffset}],Ks(l)||d.push({node:l.focusNode,offset:l.focusOffset})),ye&&n.input.lastKeyCode===8)for(let x=i;x>s;x--){let b=r.childNodes[x-1],y=b.pmViewDesc;if(b.nodeName=="BR"&&!y){i=x;break}if(!y||y.size)break}let h=n.state.doc,f=n.someProp("domParser")||St.fromSchema(n.state.schema),p=h.resolve(o),m=null,g=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:i,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:Cx,context:p});if(d&&d[0].pos!=null){let x=d[0].pos,b=d[1]&&d[1].pos;b==null&&(b=x),m={anchor:x+o,head:b+o}}return{doc:g,sel:m,from:o,to:a}}function Cx(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ke&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ke&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Nx=/^(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 wx(n,e,t,r,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let j=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,E=qo(n,j);if(E&&!n.state.selection.eq(E)){if(ye&&ot&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",_=>_(n,Dt(13,"Enter"))))return;let P=n.state.tr.setSelection(E);j=="pointer"?P.setMeta("pointer",!0):j=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}return}let o=n.state.doc.resolve(e),a=o.sharedDepth(t);e=o.before(a+1),t=n.state.doc.resolve(t).after(a+1);let l=n.state.selection,d=Sx(n,e,t),u=n.state.doc,h=u.slice(d.from,d.to),f,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,p="end"):(f=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let m=Tx(h.content,d.doc.content,d.from,f,p);if(m&&n.input.domChangeCount++,(Cn&&n.input.lastIOSEnter>Date.now()-225||ot)&&s.some(j=>j.nodeType==1&&!Nx.test(j.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",j=>
vendor: 4,301 bytes, line 45
45j(n,Dt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof I&&!l.empty&&l.$head.sameParent(l.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(d.sel){let j=jl(n,n.state.doc,d.sel);if(j&&!j.eq(n.state.selection)){let E=n.state.tr.setSelection(j);i&&E.setMeta("composition",i),n.dispatch(E)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof I&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=d.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),Ee&&Ct<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>d.from&&d.doc.textBetween(m.start-d.from-1,m.start-d.from+1)==" Â "&&(m.start--,m.endA--,m.endB--);let g=d.doc.resolveNoCache(m.start-d.from),x=d.doc.resolveNoCache(m.endB-d.from),b=u.resolve(m.start),y=g.sameParent(x)&&g.parent.inlineContent&&b.end()>=m.endA;if((Cn&&n.input.lastIOSEnter>Date.now()-225&&(!y||s.some(j=>j.nodeName=="DIV"||j.nodeName=="P"))||!y&&g.pos<d.doc.content.size&&(!g.sameParent(x)||!g.parent.inlineContent)&&g.pos<x.pos&&!/\S/.test(d.doc.textBetween(g.pos,x.pos,"","")))&&n.someProp("handleKeyDown",j=>j(n,Dt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&jx(u,m.start,m.endA,g,x)&&n.someProp("handleKeyDown",j=>j(n,Dt(8,"Backspace")))){ot&&ye&&n.domObserver.suppressSelectionUpdates();return}ye&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),ot&&!y&&g.start()!=x.start()&&x.parentOffset==0&&g.depth==x.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==m.endA&&(m.endB-=2,x=d.doc.resolveNoCache(m.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(j){return j(n,Dt(13,"Enter"))})},20));let k=m.start,C=m.endA,v=j=>{let E=j||n.state.tr.replace(k,C,d.doc.slice(m.start-d.from,m.endB-d.from));if(d.sel){let P=jl(n,E.doc,d.sel);P&&!(ye&&n.composing&&P.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(P.head==k||P.head==E.mapping.map(C)-1)||Ee&&P.empty&&P.head==k)&&E.setSelection(P)}return i&&E.setMeta("composition",i),E.scrollIntoView()},w;if(y)if(g.pos==x.pos){Ee&&Ct<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>lt(n),20));let j=v(n.state.tr.delete(k,C)),E=u.resolve(m.start).marksAcross(u.resolve(m.endA));E&&j.ensureMarks(E),n.dispatch(j)}else if(m.endA==m.endB&&(w=Mx(g.parent.content.cut(g.parentOffset,x.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let j=v(n.state.tr);w.type=="add"?j.addMark(k,C,w.mark):j.removeMark(k,C,w.mark),n.dispatch(j)}else if(g.parent.child(g.index()).isText&&g.index()==x.index()-(x.textOffset?0:1)){let j=g.parent.textBetween(g.parentOffset,x.parentOffset),E=()=>v(n.state.tr.insertText(j,k,C));n.someProp("handleTextInput",P=>P(n,k,C,j,E))||n.dispatch(E())}else n.dispatch(v());else n.dispatch(v())}function jl(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Jo(n,e.resolve(t.anchor),e.resolve(t.head))}function Mx(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,i=r,o,a,l;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(s.length==1&&i.length==0)a=s[0],o="add",l=u=>u.mark(a.addToSet(u.marks));else if(s.length==0&&i.length==1)a=i[0],o="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let d=[];for(let u=0;u<e.childCount;u++)d.push(l(e.child(u)));if(N.from(d).eq(n))return{mark:a,type:o}}function jx(n,e,t,r,s){if(t-e<=s.pos-r.pos||Ei(r,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!r.parent.isTextblock){let a=i.nodeAfter;return a!=null&&t==e+a.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=n.resolve(Ei(i,!0,!0));return!o.parent.isTextblock||o.pos>t||Ei(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Ei(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function Tx(n,e,t,r,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:o,b:a}=n.findDiffEnd(e,t+n.size,t+e.size);
vendor: 4,448 bytes, line 45
45if(s=="end"){let l=Math.max(0,i-Math.min(o,a));r-=o+l-i}if(o<i&&n.size<e.size){let l=r<=i&&r>=o?i-r:0;i-=l,i&&i<e.size&&Tl(e.textBetween(i-1,i+1))&&(i+=l?1:-1),a=i+(a-o),o=i}else if(a<i){let l=r<=i&&r>=a?i-r:0;i-=l,i&&i<n.size&&Tl(n.textBetween(i-1,i+1))&&(i+=l?1:-1),o=i+(o-a),a=i}return{start:i,endA:o,endB:a}}function Tl(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class ru{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 Wg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Rl),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=Ol(this),Al(this),this.nodeViews=Dl(this),this.docView=cl(this.state.doc,El(this),Ti(this),this.dom,this),this.domObserver=new xx(this,(r,s,i,o)=>wx(this,r,s,i,o)),this.domObserver.start(),Ug(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&&po(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Rl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Yd(this),o=!0),this.state=e;let a=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Dl(this);Ax(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&po(this),this.editable=Ol(this),Al(this);let l=Ti(this),d=El(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",h=i||!this.docView.matchesNode(e.doc,d,l);(h||!e.selection.eq(s.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&ig(this);if(o){this.domObserver.stop();let p=h&&(Ee||ye)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Ex(s.selection,e.selection);if(h){let m=ye?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ix(this)),(i||!this.docView.update(e.doc,d,l,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=cl(e.doc,d,l,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Eg(this))?lt(this,p):($d(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&og(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&rl(this,t.getBoundingClientRect(),e)}else rl(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;
vendor: 6,060 bytes, line 45
45if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new Xd(e.slice,e.move,s<0?void 0:D.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let a=this.directPlugins[o].props[e];if(a!=null&&(s=t?t(a):a))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let a=i[o].props[e];if(a!=null&&(s=t?t(a):a))return s}}hasFocus(){if(Ee){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&ag(this.dom),lt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return hg(this,e)}coordsAtPos(e,t=1){return Ad(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,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return xg(this,t||this.state,e)}pasteHTML(e,t){return dr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return dr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Go(this,e)}destroy(){this.docView&&(Kg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ti(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Gm())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Jg(this,e)}domSelectionRange(){let e=this.domSelection();return e?ke&&this.root.nodeType===11&&eg(this.dom.ownerDocument)==this.dom&&yx(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}ru.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function El(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ce.node(0,n.state.doc.content.size,e)]}function Al(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ce.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ol(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Ex(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Dl(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Ax(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function Rl(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var jt={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:"'"},es={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ox=typeof navigator<"u"&&/Mac/.test(navigator.platform),Dx=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var xe=0;xe<10;xe++)jt[48+xe]=jt[96+xe]=String(xe);for(var xe=1;xe<=24;xe++)jt[xe+111]="F"+xe;for(var xe=65;xe<=90;xe++)jt[xe]=String.fromCharCode(xe+32),es[xe]=String.fromCharCode(xe);for(var Ai in jt)es.hasOwnProperty(Ai)||(es[Ai]=jt[Ai]);function Rx(n){var e=Ox&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Dx&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?es:jt)[n.keyCode]||n.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}const Ix=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Px=typeof navigator<"u"&&/Win/.test(navigator.platform);function Lx(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))Ix?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),o&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function zx(n){let e=Object.create(null);for(let t in n)e[Lx(t)]=n[t];return e}
vendor: 13,946 bytes, line 45
45function Oi(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function $x(n){return new ee({props:{handleKeyDown:su(n)}})}function su(n){let e=zx(n);return function(t,r){let s=Rx(r),i,o=e[Oi(s,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[Oi(s,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Px&&r.ctrlKey&&r.altKey)&&(i=jt[r.keyCode])&&i!=s){let a=e[Oi(i,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}var _x=Object.defineProperty,ta=(n,e)=>{for(var t in e)_x(n,t,{get:e[t],enumerable:!0})};function Gs(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,i=t.storedMarks,t}}}var Ys=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:s}=t,i=this.buildProps(s);return Object.fromEntries(Object.entries(n).map(([o,a])=>[o,(...d)=>{const u=a(...d)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:i}=r,o=[],a=!!n,l=n||s.tr,d=()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),o.every(h=>h===!0)),u={...Object.fromEntries(Object.entries(t).map(([h,f])=>[h,(...m)=>{const g=this.buildProps(l,e),x=f(...m)(g);return o.push(x),u}])),run:d};return u}createCan(n){const{rawCommands:e,state:t}=this,r=!1,s=n||t.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...d)=>l(...d)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:i}=r,o={tr:n,editor:r,view:i,state:Gs({state:s,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([a,l])=>[a,(...d)=>l(...d)(o)]))}};return o}},iu={};ta(iu,{blur:()=>Bx,clearContent:()=>Hx,clearNodes:()=>Vx,command:()=>Fx,createParagraphNear:()=>Wx,cut:()=>Ux,deleteCurrentNode:()=>Kx,deleteNode:()=>qx,deleteRange:()=>Jx,deleteSelection:()=>Gx,enter:()=>Yx,exitCode:()=>Qx,extendMarkRange:()=>Xx,first:()=>Zx,focus:()=>tb,forEach:()=>nb,insertContent:()=>rb,insertContentAt:()=>ob,joinBackward:()=>cb,joinDown:()=>lb,joinForward:()=>db,joinItemBackward:()=>ub,joinItemForward:()=>hb,joinTextblockBackward:()=>fb,joinTextblockForward:()=>pb,joinUp:()=>ab,keyboardShortcut:()=>gb,lift:()=>xb,liftEmptyBlock:()=>bb,liftListItem:()=>yb,newlineInCode:()=>vb,resetAttributes:()=>kb,scrollIntoView:()=>Sb,selectAll:()=>Cb,selectNodeBackward:()=>Nb,selectNodeForward:()=>wb,selectParentNode:()=>Mb,selectTextblockEnd:()=>jb,selectTextblockStart:()=>Tb,setContent:()=>Eb,setMark:()=>Yb,setMeta:()=>Qb,setNode:()=>Xb,setNodeSelection:()=>Zb,setTextDirection:()=>ey,setTextSelection:()=>ty,sinkListItem:()=>ny,splitBlock:()=>ry,splitListItem:()=>sy,toggleList:()=>iy,toggleMark:()=>oy,toggleNode:()=>ay,toggleWrap:()=>ly,undoInputRule:()=>cy,unsetAllMarks:()=>dy,unsetMark:()=>uy,unsetTextDirection:()=>hy,updateAttributes:()=>fy,wrapIn:()=>py,wrapInList:()=>my});var Bx=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())==null||t.removeAllRanges())}),!0),Hx=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),Vx=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:i,$to:o})=>{n.doc.nodesBetween(i.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:d,mapping:u}=e,h=d.resolve(u.map(l)),f=d.resolve(u.map(l+a.nodeSize)),p=h.blockRange(f);if(!p)return;const m=jn(p);if(a.type.isTextblock){const{defaultType:g}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(p.start,g)}(m||m===0)&&e.lift(p,m)})}),!0},Fx=n=>e=>n(e),Wx=()=>({state:n,dispatch:e})=>yd(n,e),Ux=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,i=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new I(r.doc.resolve(Math.max(o-1,0)))),!0},Kx=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const a=s.before(i),l=s.after(i);n.delete(a,l).scrollIntoView()}return!0}return!1};function ce(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var qx=n=>({tr:e,state:t,dispatch:r})=>{const s=ce(n,t.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const l=i.before(o),d=i.after(o);e.delete(l,d).scrollIntoView()}return!0}return!1},Jx=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},Gx=()=>({state:n,dispatch:e})=>Ho(n,e),Yx=()=>({commands:n})=>n.keyboardShortcut("Enter"),Qx=()=>({state:n,dispatch:e})=>Im(n,e);function na(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function ts(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:na(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function ou(n,e,t={}){return n.find(r=>r.type===e&&ts(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function Il(n,e,t={}){return!!ou(n,e,t)}function ra(n,e,t){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if((!r.node||!r.node.marks.some(d=>d.type===e))&&(r=n.parent.childBefore(n.parentOffset)),!r.node||!r.node.marks.some(d=>d.type===e))return;if(!t){const d=r.node.marks.find(u=>u.type===e);d&&(t=d.attrs)}if(!ou([...r.node.marks],e,t))return;let i=r.index,o=n.start()+r.offset,a=i+1,l=o+r.node.nodeSize;for(;i>0&&Il([...n.parent.child(i-1).marks],e,t);)i-=1,o-=n.parent.child(i).nodeSize;for(;a<n.parent.childCount&&Il([...n.parent.child(a).marks],e,t);)l+=n.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function ct(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var Xx=(n,e)=>({tr:t,state:r,dispatch:s})=>{const i=ct(n,r.schema),{doc:o,selection:a}=t,{$from:l,from:d,to:u}=a;if(s){const h=ra(l,i,e);if(h&&h.from<=d&&h.to>=u){const f=I.create(o,h.from,h.to);t.setSelection(f)}}return!0},Zx=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function au(n){return n instanceof I}function Ht(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function lu(n,e=null){if(!e)return null;const t=z.atStart(n),r=z.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,i=r.to;return e==="all"?I.create(n,Ht(0,s,i),Ht(n.content.size,s,i)):I.create(n,Ht(e,s,i),Ht(e,s,i))}function Pl(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function ns(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function eb(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var tb=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(ns()||Pl())&&r.dom.focus(),eb()&&!ns()&&!Pl()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};try{if(r.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(i&&n===null&&!au(t.state.selection))return o(),!0;const a=lu(s.doc,n)||t.state.selection,l=t.state.selection.eq(a);return i&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},nb=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),rb=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),cu=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&cu(r)}return n};function Mr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return cu(t)}function hr(n,e,t){if(n instanceof Fe||n instanceof N)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return N.fromArray(n.map(a=>e.nodeFromJSON(a)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return hr("",e,t)}if(s){if(t.errorOnInvalidContent){let o=!1,a="";const l=new Kc({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(o=!0,a=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?St.fromSchema(l).parseSlice(Mr(n),t.parseOptions):St.fromSchema(l).parse(Mr(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const i=St.fromSchema(e);return t.slice?i.parseSlice(Mr(n),t.parseOptions).content:i.parse(Mr(n),t.parseOptions)}return hr("",e,t)}function sb(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof ae||s instanceof fe))return;const i=n.mapping.maps[r];let o=0;i.forEach((a,l,d,u)=>{o===0&&(o=u)}),n.setSelection(z.near(n.doc.resolve(o),t))}var ib=n=>!("type"in n),ob=(n,e,t)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){t={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let a;const l=x=>{i.emit("contentError",{editor:i,error:x,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{hr(e,i.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(x){l(x)}try{a=hr(e,i.schema,{parseOptions:d,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(x){return l(x),!1}let{from:u,to:h}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,p=!0;if((ib(a)?a:[a]).forEach(x=>{x.check(),f=f?x.isText&&x.marks.length===0:!1,p=p?x.isBlock:!1}),u===h&&p){const{parent:x}=r.doc.resolve(u);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(u-=1,h+=1)}let g;if(f){if(Array.isArray(e))g=e.map(x=>x.text||"").join("");else if(e instanceof N){let x="";e.forEach(b=>{b.text&&(x+=b.text)}),g=x}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,h)}else{g=a;const x=r.doc.resolve(u),b=x.node(),y=x.parentOffset===0,k=b.isText||b.isTextblock,C=b.content.size>0;y&&k&&C&&(u=Math.max(0,u-1)),r.replaceWith(u,h,g)}t.updateSelection&&sb(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},ab=()=>({state:n,dispatch:e})=>Om(n,e),lb=()=>({state:n,dispatch:e})=>Dm(n,e),cb=()=>({state:n,dispatch:e})=>hd(n,e),db=()=>({state:n,dispatch:e})=>gd(n,e),ub=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Fs(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},hb=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Fs(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},fb=()=>({state:n,dispatch:e})=>Em(n,e),pb=()=>({state:n,dispatch:e})=>Am(n,e);function du(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function mb(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,i,o;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))ns()||du()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),i&&(t=`Shift-${t}`),t}var gb=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const i=mb(n).split(/-(?!$)/),o=i.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,a))});return l==null||l.steps.forEach(d=>{const u=d.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function Tt(n,e,t={}){const{from:r,to:s,empty:i}=n.selection,o=e?ce(e,n.schema):null,a=[];n.doc.nodesBetween(r,s,(h,f)=>{if(h.isText)return;const p=Math.max(r,f),m=Math.min(s,f+h.nodeSize);a.push({node:h,from:p,to:m})});const l=s-r,d=a.filter(h=>o?o.name===h.node.type.name:!0).filter(h=>ts(h.node.attrs,t,{strict:!1}));return i?!!d.length:d.reduce((h,f)=>h+f.to-f.from,0)>=l}var xb=(n,e={})=>({state:t,dispatch:r})=>{const s=ce(n,t.schema);return Tt(t,s,e)?Rm(t,r):!1},bb=()=>({state:n,dispatch:e})=>vd(n,e),yb=n=>({state:e,dispatch:t})=>{const r=ce(n,e.schema);return Um(r)(e,t)},vb=()=>({state:n,dispatch:e})=>bd(n,e);
45function Qs(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Ll(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}var kb=(n,e)=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const a=Qs(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(i=ce(n,r.schema)),a==="mark"&&(o=ct(n,r.schema));let l=!1;return t.selection.ranges.forEach(d=>{r.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,h)=>{i&&i===u.type&&(l=!0,s&&t.setNodeMarkup(h,void 0,Ll(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(f=>{o===f.type&&(l=!0,s&&t.addMark(h,h+u.nodeSize,o.create(Ll(f.attrs,e))))})})}),l},Sb=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Cb=()=>({tr:n,dispatch:e})=>{if(e){const t=new Oe(n.doc);n.setSelection(t)}return!0},Nb=()=>({state:n,dispatch:e})=>pd(n,e),wb=()=>({state:n,dispatch:e})=>xd(n,e),Mb=()=>({state:n,dispatch:e})=>zm(n,e),jb=()=>({state:n,dispatch:e})=>Bm(n,e),Tb=()=>({state:n,dispatch:e})=>_m(n,e);function mo(n,e,t={},r={}){return hr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var Eb=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:a})=>{const{doc:l}=i;if(r.preserveWhitespace!=="full"){const d=mo(n,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,l.content.size,d).setMeta("preventUpdate",!t),!0}return o&&i.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:l.content.size},n,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function uu(n,e){const t=ct(e,n.schema),{from:r,to:s,empty:i}=n.selection,o=[];i?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===t.name);return a?{...a.attrs}:{}}function hu(n,e){const t=new ld(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function Ab(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Ob(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,i)=>{t(s)&&r.push({node:s,pos:i})}),r}function Db(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Xs(n){return e=>Db(e.$from,n)}function O(n,e,t){return n.config[e]===void 0&&n.parent?O(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?O(n.parent,e,t):null}):n.config[e]}function sa(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=O(e,"addExtensions",t);return r?[e,...sa(r())]:e}).flat(10)}function ia(n,e){const t=nn.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}function fu(n){return typeof n=="function"}function F(n,e=void 0,...t){return fu(n)?e?n.bind(e)(...t):n(...t):n}function Rb(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Nn(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function pu(n){const e=[],{nodeExtensions:t,markExtensions:r}=Nn(n),s=[...t,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=t.filter(d=>d.name!=="text").map(d=>d.name),a=r.map(d=>d.name),l=[...o,...a];return n.forEach(d=>{const u={name:d.name,options:d.options,storage:d.storage,extensions:s},h=O(d,"addGlobalAttributes",u);if(!h)return;h().forEach(p=>{let m;Array.isArray(p.types)?m=p.types:p.types==="*"?m=l:p.types==="nodes"?m=o:p.types==="marks"?m=a:m=[],m.forEach(g=>{Object.entries(p.attributes).forEach(([x,b])=>{e.push({type:g,name:x,attribute:{...i,...b}})})})})}),s.forEach(d=>{const u={name:d.name,options:d.options,storage:d.storage},h=O(d,"addAttributes",u);if(!h)return;const f=h();Object.entries(f).forEach(([p,m])=>{const g={...i,...m};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:d.name,name:p,attribute:g})})}),e}function Ib(n){const e=[];let t="",r=!1,s=!1,i=0;const o=n.length;for(let a=0;a<o;a+=1){const l=n[a];if(l==="'"&&!s){r=!r,t+=l;continue}if(l==='"'&&!r){s=!s,t+=l;continue}if(!r&&!s){if(l==="("){i+=1,t+=l;continue}if(l===")"&&i>0){i-=1,t+=l;continue}if(l===";"&&i===0){e.push(t),t="";continue}}t+=l}return t&&e.push(t),e}function zl(n){const e=[],t=Ib(n||""),r=t.length;for(let s=0;s<r;s+=1){const i=t[s],o=i.indexOf(":");if(o===-1)continue;const a=i.slice(0,o).trim(),l=i.slice(o+1).trim();a&&l&&e.push([a,l])}return e}function de(...n){return n.filter(e=>!!e).reduce((e,t)=>
vendor: 49,590 bytes, lines 45-120
45{const r={...e};return Object.entries(t).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const a=i?String(i).split(" "):[],l=r[s]?r[s].split(" "):[],d=a.filter(u=>!l.includes(u));r[s]=[...l,...d].join(" ")}else if(s==="style"){const a=new Map([...zl(r[s]),...zl(i)]);r[s]=Array.from(a.entries()).map(([l,d])=>`${l}: ${d}`).join("; ")}else r[s]=i}),r},{})}function fr(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>de(t,r),{})}function Pb(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function $l(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(t):Pb(t.getAttribute(o.name));return a==null?i:{...i,[o.name]:a}},{});return{...r,...s}}}}function _l(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Rb(t)?!1:t!=null))}function Bl(n){var e,t;const r={};return!((e=n==null?void 0:n.attribute)!=null&&e.isRequired)&&"default"in((n==null?void 0:n.attribute)||{})&&(r.default=n.attribute.default),((t=n==null?void 0:n.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function Lb(n,e){var t;const r=pu(n),{nodeExtensions:s,markExtensions:i}=Nn(n),o=(t=s.find(d=>O(d,"topNode")))==null?void 0:t.name,a=Object.fromEntries(s.map(d=>{const u=r.filter(b=>b.type===d.name),h={name:d.name,options:d.options,storage:d.storage,editor:e},f=n.reduce((b,y)=>{const k=O(y,"extendNodeSchema",h);return{...b,...k?k(d):{}}},{}),p=_l({...f,content:F(O(d,"content",h)),marks:F(O(d,"marks",h)),group:F(O(d,"group",h)),inline:F(O(d,"inline",h)),atom:F(O(d,"atom",h)),selectable:F(O(d,"selectable",h)),draggable:F(O(d,"draggable",h)),code:F(O(d,"code",h)),whitespace:F(O(d,"whitespace",h)),linebreakReplacement:F(O(d,"linebreakReplacement",h)),defining:F(O(d,"defining",h)),isolating:F(O(d,"isolating",h)),attrs:Object.fromEntries(u.map(Bl))}),m=F(O(d,"parseHTML",h));m&&(p.parseDOM=m.map(b=>$l(b,u)));const g=O(d,"renderHTML",h);g&&(p.toDOM=b=>g({node:b,HTMLAttributes:fr(b,u)}));const x=O(d,"renderText",h);return x&&(p.toText=x),[d.name,p]})),l=Object.fromEntries(i.map(d=>{const u=r.filter(x=>x.type===d.name),h={name:d.name,options:d.options,storage:d.storage,editor:e},f=n.reduce((x,b)=>{const y=O(b,"extendMarkSchema",h);return{...x,...y?y(d):{}}},{}),p=_l({...f,inclusive:F(O(d,"inclusive",h)),excludes:F(O(d,"excludes",h)),group:F(O(d,"group",h)),spanning:F(O(d,"spanning",h)),code:F(O(d,"code",h)),attrs:Object.fromEntries(u.map(Bl))}),m=F(O(d,"parseHTML",h));m&&(p.parseDOM=m.map(x=>$l(x,u)));const g=O(d,"renderHTML",h);return g&&(p.toDOM=x=>g({mark:x,HTMLAttributes:fr(x,u)})),[d.name,p]}));return new Kc({topNode:o,nodes:a,marks:l})}function zb(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function Qn(n){return n.sort((t,r)=>{const s=O(t,"priority")||100,i=O(r,"priority")||100;return s>i?-1:s<i?1:0})}function mu(n){const e=Qn(sa(n));return zb(e.map(r=>r.name)).length,e}function gu(n,e,t){const{from:r,to:s}=e,{blockSeparator:i=` 46 47`,textSerializers:o={}}=t||{};let a="";return n.nodesBetween(r,s,(l,d,u,h)=>{var f;l.isBlock&&d>r&&(a+=i);const p=o==null?void 0:o[l.type.name];if(p)return u&&(a+=p({node:l,pos:d,parent:u,index:h,range:e})),!1;l.isText&&(a+=(f=l==null?void 0:l.text)==null?void 0:f.slice(Math.max(r,d)-d,s-d))}),a}function $b(n,e){const t={from:0,to:n.content.size};return gu(n,t,e)}function xu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function _b(n,e){const t=ce(e,n.schema),{from:r,to:s}=n.selection,i=[];n.doc.nodesBetween(r,s,a=>{i.push(a)});const o=i.reverse().find(a=>a.type.name===t.name);return o?{...o.attrs}:{}}function bu(n,e){const t=Qs(typeof e=="string"?e:e.name,n.schema);return t==="node"?_b(n,e):t==="mark"?uu(n,e):{}}function Bb(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function Hb(n){const e=Bb(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,o)=>o!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function yu(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((a,l)=>{o.push({from:a,to:l})});else{const{from:a,to:l}=t[i];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{const d=e.slice(i).map(a,-1),u=e.slice(i).map(l),h=e.invert().map(d,-1),f=e.invert().map(u);r.push({oldRange:{from:h,to:f},newRange:{from:d,to:u}})})}),Hb(r)}function oa(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const i=t.resolve(n),o=ra(i,s.type);o&&r.push({mark:s,...o})}):t.nodesBetween(n,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var Vb=(n,e,t,r=20)=>{const s=n.doc.resolve(t);let i=r,o=null;for(;i>0&&o===null;){const a=s.node(i);(a==null?void 0:a.type.name)===e?o=a:i-=1}return[o,i]};function On(n,e){return e.nodes[n]||e.marks[n]||null}function $r(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var Fb=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,a)=>{var l,d;const u=((d=(l=s.type.spec).toText)==null?void 0:d.call(l,{node:s,pos:i,parent:o,index:a}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),t};function go(n,e,t={}){const{empty:r,ranges:s}=n.selection,i=e?ct(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(h=>i?i.name===h.type.name:!0).find(h=>ts(h.attrs,t,{strict:!1}));let o=0;const a=[];if(s.forEach(({$from:h,$to:f})=>{const p=h.pos,m=f.pos;n.doc.nodesBetween(p,m,(g,x)=>{if(i&&g.inlineContent&&!g.type.allowsMarkType(i))return!1;if(!g.isText&&!g.marks.length)return;const b=Math.max(p,x),y=Math.min(m,x+g.nodeSize),k=y-b;o+=k,a.push(...g.marks.map(C=>({mark:C,from:b,to:y})))})}),o===0)return!1;const l=a.filter(h=>i?i.name===h.mark.type.name:!0).filter(h=>ts(h.mark.attrs,t,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),d=a.filter(h=>i?h.mark.type!==i&&h.mark.type.excludes(i):!0).reduce((h,f)=>h+f.to-f.from,0);return(l>0?l+d:l)>=o}function Wb(n,e,t={}){if(!e)return Tt(n,null,t)||go(n,null,t);const r=Qs(e,n.schema);return r==="node"?Tt(n,e,t):r==="mark"?go(n,e,t):!1}var Ub=(n,e)=>{const{$from:t,$to:r,$anchor:s}=n.selection;if(e){const i=Xs(a=>a.type.name===e)(n.selection);if(!i)return!1;const o=n.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},Kb=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Hl(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Vl(n,e){const{nodeExtensions:t}=Nn(e),r=t.find(o=>o.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=F(O(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Zs(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return!/\S/.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(i=>{s!==!1&&(Zs(i,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function vu(n){return n instanceof D}var ku=class Su{constructor(e){this.position=e}static fromJSON(e){return new Su(e.position)}toJSON(){return{position:this.position}}};function qb(n,e){const t=e.mapping.mapResult(n.position);return{position:new ku(t.pos),mapResult:t}}function Jb(n){return new ku(n)}function Gb(n,e,t){var r;const{selection:s}=e;let i=null;if(au(s)&&(i=s.$cursor),i){const a=(r=n.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(t)&&(!!t.isInSet(a)||!a.some(d=>d.type.excludes(t)))}const{ranges:o}=s;return o.some(({$from:a,$to:l})=>{let d=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(a.pos,l.pos,(u,h,f)=>{if(d)return!1;if(u.isInline){const p=!f||f.type.allowsMarkType(t),m=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));d=p&&m}return!d}),d})}var Yb=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:i}=t,{empty:o,ranges:a}=i,l=ct(n,r.schema);if(s)if(o){const d=uu(r,l);t.addStoredMark(l.create({...d,...e}))}else a.forEach(d=>{const u=d.$from.pos,h=d.$to.pos;r.doc.nodesBetween(u,h,(f,p)=>{const m=Math.max(p,u),g=Math.min(p+f.nodeSize,h);f.marks.find(b=>b.type===l)?f.marks.forEach(b=>{l===b.type&&t.addMark(m,g,l.create({...b.attrs,...e}))}):t.addMark(m,g,l.create(e))})});return Gb(r,t,l)},Qb=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Xb=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const i=ce(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:a})=>el(i,{...o,...e})(t)?!0:a.clearNodes()).command(({state:a})=>el(i,{...o,...e})(a,r)).run():!1},Zb=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=Ht(n,0,r.content.size),i=D.create(r,s);e.setSelection(i)}return!0},ey=(n,e)=>({tr:t,state:r,dispatch:s})=>{const{selection:i}=r;let o,a;return typeof e=="number"?(o=e,a=e):e&&"from"in e&&"to"in e?(o=e.from,a=e.to):(o=i.from,a=i.to),s&&t.doc.nodesBetween(o,a,(l,d)=>{l.isText||t.setNodeMarkup(d,void 0,{...l.attrs,dir:n})}),!0},ty=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:i}=typeof n=="number"?{from:n,to:n}:n,o=I.atStart(r).from,a=I.atEnd(r).to,l=Ht(s,o,a),d=Ht(i,o,a),u=I.create(r,l,d);e.setSelection(u)}return!0},ny=n=>({state:e,dispatch:t})=>{const r=ce(n,e.schema);return Jm(r)(e,t)};function Fl(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e==null?void 0:e.includes(s.type.name));n.tr.ensureMarks(r)}}var ry=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:a,$to:l}=i,d=s.extensionManager.attributes,u=$r(d,a.node().type.name,a.node().attrs);if(i instanceof D&&i.node.isBlock)return!a.parentOffset||!at(o,a.pos)?!1:(r&&(n&&Fl(t,s.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const h=l.parentOffset===l.parent.content.size,f=a.depth===0?void 0:Ab(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=h&&f?[{type:f,attrs:u}]:void 0,m=at(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!m&&at(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(i instanceof I&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),f&&!h&&!a.parentOffset&&a.parent.type!==f)){const g=e.mapping.map(a.before()),x=e.doc.resolve(g);a.node(-1).canReplaceWith(x.index(),x.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}n&&Fl(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},sy=(n,e={})=>({tr:t,state:r,dispatch:s,editor:i})=>{var o;const a=ce(n,r.schema),{$from:l,$to:d}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(d))return!1;const h=l.node(-1);if(h.type!==a)return!1;const f=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){let b=N.empty;const y=l.index(-1)?1:l.index(-2)?2:3;for(let E=l.depth-y;E>=l.depth-3;E-=1)b=N.from(l.node(E).copy(b));const k=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,C={...$r(f,l.node().type.name,l.node().attrs),...e},v=((o=a.contentMatch.defaultType)==null?void 0:o.createAndFill(C))||void 0;b=b.append(N.from(a.createAndFill(null,v)||void 0));const w=l.before(l.depth-(y-1));t.replace(w,l.after(-k),new T(b,4-y,0));let j=-1;t.doc.nodesBetween(w,t.doc.content.size,(E,P)=>{if(j>-1)return!1;E.isTextblock&&E.content.size===0&&(j=P+1)}),j>-1&&t.setSelection(I.near(t.doc.resolve(j))),t.scrollIntoView()}return!0}const p=d.pos===l.end()?h.contentMatchAt(0).defaultType:null,m={...$r(f,h.type.name,h.attrs),...e},g={...$r(f,l.node().type.name,l.node().attrs),...e};t.delete(l.pos,d.pos);const x=p?[{type:a,attrs:m},{type:p,attrs:g}]:[{type:a,attrs:m}];if(!at(t.doc,l.pos,2))return!1;if(s){const{selection:b,storedMarks:y}=r,{splittableMarks:k}=i.extensionManager,C=y||b.$to.parentOffset&&b.$from.marks();if(t.split(l.pos,2,x).scrollIntoView(),!C||!s)return!0;const v=C.filter(w=>k.includes(w.type.name));t.ensureMarks(v)}return!0},Di=(n,e)=>{const t=Xs(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===(s==null?void 0:s.type)&&Et(n.doc,t.pos)&&n.join(t.pos),!0},Ri=(n,e)=>{const t=Xs(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===(s==null?void 0:s.type)&&Et(n.doc,r)&&n.join(r),!0},iy=(n,e,t,r={})=>({editor:s,tr:i,state:o,dispatch:a,chain:l,commands:d,can:u})=>{const{extensions:h,splittableMarks:f}=s.extensionManager,p=ce(n,o.schema),m=ce(e,o.schema),{selection:g,storedMarks:x}=o,{$from:b,$to:y}=g,k=b.blockRange(y),C=x||g.$to.parentOffset&&g.$from.marks();if(!k)return!1;const v=Xs(w=>Vl(w.type.name,h))(g);if(k.depth>=1&&v&&k.depth-v.depth<=1){if(v.node.type===p)return d.liftListItem(m);if(Vl(v.node.type.name,h)&&p.validContent(v.node.content)&&a)return l().command(()=>(i.setNodeMarkup(v.pos,p),!0)).command(()=>Di(i,p)).command(()=>Ri(i,p)).run()}return!t||!C||!a?l().command(()=>u().wrapInList(p,r)?!0:d.clearNodes()).wrapInList(p,r).command(()=>Di(i,p)).command(()=>Ri(i,p)).run():l().command(()=>{const w=u().wrapInList(p,r),j=C.filter(E=>f.includes(E.type.name));return i.ensureMarks(j),w?!0:d.clearNodes()}).wrapInList(p,r).command(()=>Di(i,p)).command(()=>Ri(i,p)).run()},oy=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=t,o=ct(n,r.schema);return go(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},ay=(n,e,t={})=>({state:r,commands:s})=>{const i=ce(n,r.schema),o=ce(e,r.schema),a=Tt(r,i,t);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?s.setNode(o,l):s.setNode(i,{...l,...t})},ly=(n,e={})=>({state:t,commands:r})=>{const s=ce(n,t.schema);return Tt(t,s,e)?r.lift(s):r.wrapIn(s,e)},cy=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let i;if(s.spec.isInputRules&&(i=s.getState(n))){if(e){const o=n.tr,a=i.transform;for(let l=a.steps.length-1;l>=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(i.text){const l=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,n.schema.text(i.text,l))}else o.delete(i.from,i.to)}return!0}}return!1},dy=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},uy=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=t,l=ct(n,r.schema),{$from:d,empty:u,ranges:h}=a;if(!s)return!0;if(u&&o){let{from:f,to:p}=a;const m=(i=d.marks().find(x=>x.type===l))==null?void 0:i.attrs,g=ra(d,l,m);g&&(f=g.from,p=g.to),t.removeMark(f,p,l)}else h.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,l)});return t.removeStoredMark(l),!0},hy=n=>({tr:e,state:t,dispatch:r})=>{const{selection:s}=t;let i,o;return typeof n=="number"?(i=n,o=n):n&&"from"in n&&"to"in n?(i=n.from,o=n.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(a,l)=>{if(a.isText)return;const d={...a.attrs};delete d.dir,e.setNodeMarkup(l,void 0,d)}),!0},fy=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const a=Qs(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(i=ce(n,r.schema)),a==="mark"&&(o=ct(n,r.schema));let l=!1;return t.selection.ranges.forEach(d=>{const u=d.$from.pos,h=d.$to.pos;let f,p,m,g;t.selection.empty?r.doc.nodesBetween(u,h,(x,b)=>{i&&i===x.type&&(l=!0,m=Math.max(b,u),g=Math.min(b+x.nodeSize,h),f=b,p=x)}):r.doc.nodesBetween(u,h,(x,b)=>{b<u&&i&&i===x.type&&(l=!0,m=Math.max(b,u),g=Math.min(b+x.nodeSize,h),f=b,p=x),b>=u&&b<=h&&(i&&i===x.type&&(l=!0,s&&t.setNodeMarkup(b,void 0,{...x.attrs,...e})),o&&x.marks.length&&x.marks.forEach(y=>{if(o===y.type&&(l=!0,s)){const k=Math.max(b,u),C=Math.min(b+x.nodeSize,h);t.addMark(k,C,o.create({...y.attrs,...e}))}}))}),p&&(f!==void 0&&s&&t.setNodeMarkup(f,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(x=>{o===x.type&&s&&t.addMark(m,g,o.create({...x.attrs,...e}))}))}),l},py=(n,e={})=>({state:t,dispatch:r})=>{const s=ce(n,t.schema);return Hm(s,e)(t,r)},my=(n,e={})=>({state:t,dispatch:r})=>{const s=ce(n,t.schema);return Vm(s,e)(t,r)},gy=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},ei=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},xy=(n,e)=>{if(na(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith),r.push(t.replaceWith)),r};function jr(n){var e;const{editor:t,from:r,to:s,text:i,rules:o,plugin:a}=n,{view:l}=t;if(l.composing)return!1;const d=l.state.doc.resolve(r);if(d.parent.type.spec.code||(e=d.nodeBefore||d.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const h=Fb(d)+i;return o.forEach(f=>{if(u)return;const p=xy(h,f.find);if(!p)return;const m=l.state.tr,g=Gs({state:l.state,transaction:m}),x={from:r-(p[0].length-i.length),to:s},{commands:b,chain:y,can:k}=new Ys({editor:t,state:g});f.handler({state:g,range:x,match:p,commands:b,chain:y,can:k})===null||!m.steps.length||(f.undoable&&m.setMeta(a,{transform:m,from:r,to:s,text:i}),l.dispatch(m),u=!0)}),u}function by(n){const{editor:e,rules:t}=n,r=new ee({state:{init(){return null},apply(s,i,o){const a=s.getMeta(r);if(a)return a;const l=s.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=ia(N.from(u),o.schema);const{from:h}=l,f=h+u.length;jr({editor:e,from:h,to:f,text:u,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,a){return jr({editor:e,from:i,to:o,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&jr({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?jr({editor:e,from:o.pos,to:o.pos,text:` 48`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function yy(n){return Object.prototype.toString.call(n).slice(8,-1)}function Tr(n){return yy(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Cu(n,e){const t={...n};return Tr(n)&&Tr(e)&&Object.keys(e).forEach(r=>{Tr(e[r])&&Tr(n[r])?t[r]=Cu(n[r],e[r]):t[r]=e[r]}),t}var aa=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...F(O(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...F(O(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>Cu(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},rn=class Nu extends aa{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new Nu(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(d=>(d==null?void 0:d.type.name)===t.name))return!1;const l=o.find(d=>(d==null?void 0:d.type.name)===t.name);return l&&r.removeStoredMark(l),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function vy(n){return typeof n=="number"}var ky=class{constructor(n){this.find=n.find,this.handler=n.handler}},Sy=(n,e,t)=>{if(na(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=n,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith),i.push(s.replaceWith)),i}):[]};function Cy(n){const{editor:e,state:t,from:r,to:s,rule:i,pasteEvent:o,dropEvent:a}=n,{commands:l,chain:d,can:u}=new Ys({editor:e,state:t}),h=[];return t.doc.nodesBetween(r,s,(p,m)=>{var g,x,b,y,k;if((x=(g=p.type)==null?void 0:g.spec)!=null&&x.code||!(p.isText||p.isTextblock||p.isInline))return;const C=(k=(y=(b=p.content)==null?void 0:b.size)!=null?y:p.nodeSize)!=null?k:0,v=Math.max(r,m),w=Math.min(s,m+C);if(v>=w)return;const j=p.isText?p.text||"":p.textBetween(v-m,w-m,void 0,"");Sy(j,i.find,o).forEach(P=>{if(P.index===void 0)return;const _=v+P.index+1,Y=_+P[0].length,Q={from:t.tr.mapping.map(_),to:t.tr.mapping.map(Y)},V=i.handler({state:t,range:Q,match:P,commands:l,chain:d,can:u,pasteEvent:o,dropEvent:a});h.push(V)})}),h.every(p=>p!==null)}var Er=null,Ny=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function wy(n){const{editor:e,rules:t}=n;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:u,from:h,to:f,rule:p,pasteEvt:m})=>{const g=u.tr,x=Gs({state:u,transaction:g});if(!(!Cy({editor:e,state:x,from:Math.max(h-1,0),to:f.b-1,rule:p,pasteEvent:m,dropEvent:a})||!g.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(u=>new ee({view(h){const f=m=>{var g;r=(g=h.dom.parentElement)!=null&&g.contains(m.target)?h.dom.parentElement:null,r&&(Er=e)},p=()=>{Er&&(Er=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(h,f)=>{if(i=r===h.dom.parentElement,a=f,!i){const p=Er;p!=null&&p.isEditable&&setTimeout(()=>{const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(h,f)=>{var p;const m=(p=f.clipboardData)==null?void 0:p.getData("text/html");return o=f,s=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(h,f,p)=>{const m=h[0],g=m.getMeta("uiEvent")==="paste"&&!s,x=m.getMeta("uiEvent")==="drop"&&!i,b=m.getMeta("applyPasteRules"),y=!!b;if(!g&&!x&&!y)return;if(y){let{text:v}=b;typeof v=="string"?v=v:v=ia(N.from(v),p.schema);const{from:w}=b,j=w+v.length,E=Ny(v);return l({rule:u,state:p,from:w,to:{b:j},pasteEvt:E})}const k=f.doc.content.findDiffStart(p.doc.content),C=f.doc.content.findDiffEnd(p.doc.content);if(!(!vy(k)||!C||k===C.b))return l({rule:u,state:p,from:k,to:C,pasteEvt:o})}}))}var ti=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=mu(n),this.schema=Lb(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:On(e.name,this.schema)},r=O(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return Qn([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:On(r.name,this.schema)},i=[],o=O(r,"addKeyboardShortcuts",s);let a={};if(r.type==="mark"&&O(r,"exitable",s)&&(a.ArrowRight=()=>rn.handleExit({editor:n,mark:r})),o){const f=Object.fromEntries(Object.entries(o()).map(([p,m])=>[p,()=>m({editor:n})]));a={...a,...f}}const l=$x(a);i.push(l);const d=O(r,"addInputRules",s);if(Hl(r,n.options.enableInputRules)&&d){const f=d();if(f&&f.length){const p=by({editor:n,rules:f}),m=Array.isArray(p)?p:[p];i.push(...m)}}const u=O(r,"addPasteRules",s);if(Hl(r,n.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const p=wy({editor:n,rules:f});i.push(...p)}}const h=O(r,"addProseMirrorPlugins",s);if(h){const f=h();i.push(...f)}return i})}get attributes(){return pu(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=Nn(this.extensions);return Object.fromEntries(e.filter(t=>!!O(t,"addNodeView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ce(t.name,this.schema)},i=O(t,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const a=(l,d,u,h,f)=>{const p=fr(l,r);return o({node:l,view:d,getPos:u,decorations:h,innerDecorations:f,editor:n,extension:t,HTMLAttributes:p})};return[t.name,a]}))}dispatchTransaction(n){const{editor:e}=this;return Qn([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:On(s.name,this.schema)},o=O(s,"dispatchTransaction",i);return o?a=>{o.call(i,{transaction:a,next:r})}:r},n)}transformPastedHTML(n){const{editor:e}=this;return Qn([...this.extensions]).reduce((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:On(s.name,this.schema)},o=O(s,"transformPastedHTML",i);return o?(a,l)=>{const d=r(a,l);return o.call(i,d)}:r},n||(r=>r))}get markViews(){const{editor:n}=this,{markExtensions:e}=Nn(this.extensions);return Object.fromEntries(e.filter(t=>!!O(t,"addMarkView")).map(t=>{const r=this.attributes.filter(a=>a.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ct(t.name,this.schema)},i=O(t,"addMarkView",s);if(!i)return[];const o=(a,l,d)=>{const u=fr(a,r);return i()({mark:a,view:l,inline:d,editor:n,extension:t,HTMLAttributes:u,updateAttributes:h=>{_y(a,n,h)}})};return[t.name,o]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:On(e.name,this.schema)};e.type==="mark"&&((t=F(O(e,"keepOnSplit",r)))==null||t)&&this.splittableMarks.push(e.name);const s=O(e,"onBeforeCreate",r),i=O(e,"onCreate",r),o=O(e,"onUpdate",r),a=O(e,"onSelectionUpdate",r),l=O(e,"onTransaction",r),d=O(e,"onFocus",r),u=O(e,"onBlur",r),h=O(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),h&&this.editor.on("destroy",h)})}};ti.resolve=mu;ti.sort=Qn;ti.flatten=sa;var My={};ta(My,{ClipboardTextSerializer:()=>Mu,Commands:()=>ju,Delete:()=>Tu,Drop:()=>Eu,Editable:()=>Au,FocusEvents:()=>Du,Keymap:()=>Ru,Paste:()=>Iu,Tabindex:()=>Pu,TextDirection:()=>Lu,focusEventsPluginKey:()=>Ou});var se=class wu extends aa{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new wu(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Mu=se.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ee({key:new ue("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(u=>u.$from.pos)),a=Math.max(...i.map(u=>u.$to.pos)),l=xu(t);return gu(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),ju=se.create({name:"commands",addCommands(){return{...iu}}}),Tu=se.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,s;const i=()=>{var o,a,l,d;if((d=(l=(a=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:a.filterTransaction)==null?void 0:l.call(a,n))!=null?d:n.getMeta("y-sync$"))return;const u=hu(n.before,[n,...e]);yu(u).forEach(p=>{u.mapping.mapResult(p.oldRange.from).deletedAfter&&u.mapping.mapResult(p.oldRange.to).deletedBefore&&u.before.nodesBetween(p.oldRange.from,p.oldRange.to,(m,g)=>{const x=g+m.nodeSize-2,b=p.oldRange.from<=g&&x<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:g,to:x,newFrom:u.mapping.map(g),newTo:u.mapping.map(x),deletedRange:p.oldRange,newRange:p.newRange,partial:!b,editor:this.editor,transaction:n,combinedTransform:u})})});const f=u.mapping;u.steps.forEach((p,m)=>{var g,x;if(p instanceof Ve){const b=f.slice(m).map(p.from,-1),y=f.slice(m).map(p.to),k=f.invert().map(b,-1),C=f.invert().map(y),v=b>0?(g=u.doc.nodeAt(b-1))==null?void 0:g.marks.some(j=>j.eq(p.mark)):!1,w=(x=u.doc.nodeAt(y))==null?void 0:x.marks.some(j=>j.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:k,to:C},newRange:{from:b,to:y},partial:!!(w||v),editor:this.editor,transaction:n,combinedTransform:u})}})};(s=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),Eu=se.create({name:"drop",addProseMirrorPlugins(){return[new ee({key:new ue("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Au=se.create({name:"editable",addProseMirrorPlugins(){return[new ee({key:new ue("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Ou=new ue("focusEvents"),Du=se.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new ee({key:Ou,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Ru=se.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:d}=a,{empty:u,$anchor:h}=l,{pos:f,parent:p}=h,m=h.parent.isTextblock&&f>0?a.doc.resolve(f-1):h,g=m.parent.type.spec.isolating,x=h.pos-h.parentOffset,b=g&&m.parent.childCount===1?x===h.pos:z.atStart(d).from===f;return!u||!p.type.isTextblock||p.textContent.length||!b||b&&h.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ns()||du()?i:s},addProseMirrorPlugins(){return[new ee({key:new ue("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),s=n.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:a}=e.selection,l=z.atStart(e.doc).from,d=z.atEnd(e.doc).to;if(i||!(o===l&&a===d)||!Zs(t.doc))return;const f=t.tr,p=Gs({state:t,transaction:f}),{commands:m}=new Ys({editor:this.editor,state:p});if(m.clearNodes(),!!f.steps.length)return f}})]}}),Iu=se.create({name:"paste",addProseMirrorPlugins(){return[new ee({key:new ue("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Pu=se.create({name:"tabindex",addProseMirrorPlugins(){return[new ee({key:new ue("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Lu=se.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=Nn(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new ee({key:new ue("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),jy=class Ln{constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0)return;t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Ln(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Ln(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Ln(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,o=t.isInline,a=this.pos+r+(i?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(a);if(!s&&!o&&l.depth<=this.depth)return;const d=new Ln(l,this.editor,s,s||o?t:null);s&&(d.actualDepth=this.depth+1),e.push(d)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const i=s.node.attrs,o=Object.keys(t);for(let a=0;a<o.length;a+=1){const l=o[a];if(i[l]!==t[l])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(t);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(l=>t[l]===o.node.attrs[l])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},Ty=`.ProseMirror { 49 position: relative; 50} 51 52.ProseMirror { 53 word-wrap: break-word; 54 white-space: pre-wrap; 55 white-space: break-spaces; 56 -webkit-font-variant-ligatures: none; 57 font-variant-ligatures: none; 58 font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ 59} 60 61.ProseMirror [contenteditable="false"] { 62 white-space: normal; 63} 64 65.ProseMirror [contenteditable="false"] [contenteditable="true"] { 66 white-space: pre-wrap; 67} 68 69.ProseMirror pre { 70 white-space: pre-wrap; 71} 72 73img.ProseMirror-separator { 74 display: inline !important; 75 border: none !important; 76 margin: 0 !important; 77 width: 0 !important; 78 height: 0 !important; 79} 80 81.ProseMirror-gapcursor { 82 display: none; 83 pointer-events: none; 84 position: absolute; 85 margin: 0; 86} 87 88.ProseMirror-gapcursor:after { 89 content: ""; 90 display: block; 91 position: absolute; 92 top: -2px; 93 width: 20px; 94 border-top: 1px solid black; 95 animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; 96} 97 98@keyframes ProseMirror-cursor-blink { 99 to { 100 visibility: hidden; 101 } 102} 103 104.ProseMirror-hideselection *::selection { 105 background: transparent; 106} 107 108.ProseMirror-hideselection *::-moz-selection { 109 background: transparent; 110} 111 112.ProseMirror-hideselection * { 113 caret-color: transparent; 114} 115 116.ProseMirror-focused .ProseMirror-gapcursor { 117 display: block; 118}`;function Ey(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}var Ay=class extends gy{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:qb,createMappablePosition:Jb},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:i})=>this.options.onDrop(r,s,i)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=lu(e,this.options.autofocus);this.editorState=mn.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const n=this.editorView.dom;n!=null&&n.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch{}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Ey(Ty,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=fu(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;t=t.filter(o=>!o.key.startsWith(i))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;const r=[...this.options.enableCoreExtensions?[Au,Mu.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),ju,Du,Ru,Pu,Eu,Iu,Tu,Lu.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new ti(r,this)}createCommandManager(){this.commandManager=new Ys({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=mo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=mo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){const{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=t?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new ru(n,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:s,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const l=this.view.dom;l.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(d=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(d)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),s=t.includes(n),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const o=t.findLast(d=>d.getMeta("focus")||d.getMeta("blur")),a=o==null?void 0:o.getMeta("focus"),l=o==null?void 0:o.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:o}),l&&this.emit("blur",{editor:this,event:l.event,transaction:o}),!(n.getMeta("preventUpdate")||!t.some(d=>d.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return bu(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return Wb(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ia(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=` 119 120`,textSerializers:t={}}=n||{};return $b(this.state.doc,{blockSeparator:e,textSerializers:{...xu(this.schema),...t}})}get isEmpty(){return Zs(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new jy(e,this)}get $doc(){return this.$pos(0)}};function wn(n){return new ei({find:n.find,handler:({state:e,range:t,match:r})=>{const s=F(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),d=t.from+a.indexOf(o),u=d+o.length;if(oa(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>d).length)return null;u<t.to&&i.delete(u,t.to),d>t.from&&i.delete(t.from+l,d);const f=t.from+l+o.length;i.addMark(t.from+l,f,n.type.create(s||{})),i.removeStoredMark(n.type)}},undoable:n.undoable})}function Oy(n){return new ei({find:n.find,handler:({state:e,range:t,match:r})=>{const s=F(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let a=t.to;const l=n.type.create(s);if(r[1]){const d=r[0].lastIndexOf(r[1]);let u=o+d;u>a?u=a:a=u+r[1].length;const h=r[0][r[0].length-1];i.insertText(h,o+r[0].length-1),i.replaceWith(u,a,l)}else if(r[0]){const d=n.type.isInline?o:o-1;i.insert(d,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(a))}i.scrollIntoView()},undoable:n.undoable})}function xo(n){return new ei({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=F(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)},undoable:n.undoable})}function Mn(n){return new ei({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=F(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),l=o.doc.resolve(t.from).blockRange(),d=l&&_o(l,n.type,i);if(!d)return null;if(o.wrap(l,d),n.keepMarks&&n.editor){const{selection:h,storedMarks:f}=e,{splittableMarks:p}=n.editor.extensionManager,m=f||h.$to.parentOffset&&h.$from.marks();if(m){const g=m.filter(x=>p.includes(x.type.name));o.ensureMarks(g)}}if(n.keepAttributes){const h=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(h,i).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Et(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)},undoable:n.undoable})}function Dy(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof D){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}var Ry={};ta(Ry,{createAtomBlockMarkdownSpec:()=>Iy,createBlockMarkdownSpec:()=>Py,createInlineMarkdownSpec:()=>$y,parseAttributes:()=>la,parseIndentedBlocks:()=>bo,renderNestedMarkdownContent:()=>da,serializeAttributes:()=>ca});function la(n){if(!(n!=null&&n.trim()))return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,d=>(t.push(d),`__QUOTED_${t.length-1}
120__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const d=s.map(u=>u.trim().slice(1));e.class=d.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,d,u])=>{var h;const f=parseInt(((h=u.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),p=t[f];p&&(e[d]=p.slice(1,-1))});const l=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return l&&l.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function ca(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function Iy(n){const{nodeName:e,name:t,parseAttributes:r=la,serializeAttributes:s=ca,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:a}=n,l=t||e,d=u=>{if(!a)return u;const h={};return a.forEach(f=>{f in u&&(h[f]=u[f])}),h};return{parseMarkdown:(u,h)=>{const f={...i,...u.attributes};return h.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var h;const f=new RegExp(`^:::${l}(?:\\s|$)`,"m"),p=(h=u.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(u,h,f){const p=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(p);if(!m)return;const g=m[1]||"",x=r(g);if(!o.find(y=>!(y in x)))return{type:e,raw:m[0],attributes:x}}},renderMarkdown:u=>{const h=d(u.attrs||{}),f=s(h),p=f?` {${f}}`:"";return`:::${l}${p} :::`}}}function Py(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=la,serializeAttributes:i=ca,defaultAttributes:o={},content:a="block",allowedAttributes:l}=n,d=t||e,u=h=>{if(!l)return h;const f={};return l.forEach(p=>{p in h&&(f[p]=h[p])}),f};return{parseMarkdown:(h,f)=>{let p;if(r){const g=r(h);p=typeof g=="string"?[{type:"text",text:g}]:g}else a==="block"?p=f.parseChildren(h.tokens||[]):p=f.parseInline(h.tokens||[]);const m={...o,...h.attributes};return f.createNode(e,m,p)},markdownTokenizer:{name:e,level:"block",start(h){var f;const p=new RegExp(`^:::${d}`,"m"),m=(f=h.match(p))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(h,f,p){var m;const g=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=h.match(g);if(!x)return;const[b,y=""]=x,k=s(y);let C=1;const v=b.length;let w="";const j=/^:::([\w-]*)(\s.*)?/gm,E=h.slice(v);for(j.lastIndex=0;;){const P=j.exec(E);if(P===null)break;const _=P.index,Y=P[1];if(!((m=P[2])!=null&&m.endsWith(":::"))){if(Y)C+=1;else if(C-=1,C===0){const Q=E.slice(0,_);w=Q.trim();const V=h.slice(0,v+_+P[0].length);let H=[];if(w)if(a==="block")for(H=p.blockTokens(Q),H.forEach(S=>{S.text&&(!S.tokens||S.tokens.length===0)&&(S.tokens=p.inlineTokens(S.text))});H.length>0;){const S=H[H.length-1];if(S.type==="paragraph"&&(!S.text||S.text.trim()===""))H.pop();else break}else H=p.inlineTokens(w);return{type:e,raw:V,attributes:k,content:w,tokens:H}}}}}},renderMarkdown:(h,f)=>{const p=u(h.attrs||{}),m=i(p),g=m?` {${m}}`:"",x=f.renderChildren(h.content||[],` 121 122`);return`:::${d}${g} 123 124${x} 125 126:::`}}}function Ly(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=t.exec(n)}return e}function zy(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function $y(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=Ly,serializeAttributes:i=zy,defaultAttributes:o={},selfClosing:a=!1,allowedAttributes:l}=n,d=t||e,u=f=>{if(!l)return f;const p={};return l.forEach(m=>{const g=typeof m=="string"?m:m.name,x=typeof m=="string"?void 0:m.skipIfDefault;if(g in f){const b=f[g];if(x!==void 0&&b===x)return;p[g]=b}}),p},h=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,p)=>{const m={...o,...f.attributes};if(a)return p.createNode(e,m);const g=r?r(f):f.content||"";return g?p.createNode(e,m,[p.createTextNode(g)]):p.createNode(e,m,[])},markdownTokenizer:{name:e,level:"inline",start(f){const p=a?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),m=f.match(p),g=m==null?void 0:m.index;return g!==void 0?g:-1},tokenize(f,p,m){const g=a?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),x=f.match(g);if(!x)return;let b="",y="";if(a){const[,C]=x;y=C}else{const[,C,v]=x;y=C,b=v||""}const k=s(y.trim());return{type:e,raw:x[0],content:b.trim(),attributes:k}}},renderMarkdown:f=>{let p="";r?p=r(f):f.content&&f.content.length>0&&(p=f.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const m=u(f.attrs||{}),g=i(m),x=g?` ${g}`:"";return a?`[${d}${x}]`:`[${d}${x}]${p}[/${d}]`}}}function bo(n,e,t){var r,s,i,o;const a=n.split(` 127`),l=[];let d="",u=0;const h=e.baseIndentSize||2;for(;u<a.length;){const f=a[u],p=f.match(e.itemPattern);if(!p){if(l.length>0)break;if(f.trim()===""){u+=1,d=`${d}${f} 128`;continue}else return}const m=e.extractItemData(p),{indentLevel:g,mainContent:x}=m;d=`${d}${f} 129`;const b=[x];for(u+=1;u<a.length;){const v=a[u];if(v.trim()===""){const j=a.slice(u+1).findIndex(_=>_.trim()!=="");if(j===-1)break;if((((s=(r=a[u+1+j].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>g){b.push(v),d=`${d}${v} 130`,u+=1;continue}else break}if((((o=(i=v.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>g)b.push(v),d=`${d}${v} 131`,u+=1;else break}let y;const k=b.slice(1);if(k.length>0){const v=k.map(w=>w.slice(g+h)).join(` 132`);v.trim()&&(e.customNestedParser?y=e.customNestedParser(v):y=t.blockTokens(v))}const C=e.createToken(m,y);l.push(C)}if(l.length!==0)return{items:l,raw:d}}function da(n,e,t,r){if(!n||!Array.isArray(n.content))return"";const s=typeof t=="function"?t(r):t,[i,...o]=n.content,a=e.renderChildren([i]);let l=`${s}${a}`;return o&&o.length>0&&o.forEach((d,u)=>{var h,f;const p=(f=(h=e.renderChild)==null?void 0:h.call(e,d,u+1))!=null?f:e.renderChildren([d]);if(p!=null){const m=p.split(` 133`).map(g=>g?e.indent(g):e.indent("")).join(` 134`);l+=d.type==="paragraph"?` 135 136${m}`:` 137${m}`}}),l}function _y(n,e,t={}){const{state:r}=e,{doc:s,tr:i}=r,o=n;s.descendants((a,l)=>{const d=i.mapping.map(l),u=i.mapping.map(l)+a.nodeSize;let h=null;if(a.marks.forEach(p=>{if(p!==o)return!1;h=p}),!h)return;let f=!1;if(Object.keys(t).forEach(p=>{t[p]!==h.attrs[p]&&(f=!0)}),f){const p=n.type.create({...n.attrs,...t});i.removeMark(d,u,n.type),i.addMark(d,u,p)}}),i.docChanged&&e.view.dispatch(i)}var De=class zu extends aa{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new zu(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Zt(n){return new ky({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=F(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let d=t.to;if(a){const u=l.search(/\S/),h=t.from+l.indexOf(a),f=h+a.length;if(oa(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(x=>x===n.type&&x!==m.mark.type)).filter(m=>m.to>h).length)return null;f<t.to&&o.delete(f,t.to),h>t.from&&o.delete(t.from+u,h),d=t.from+u+a.length,o.addMark(t.from+u,d,n.type.create(i||{}
137)),o.removeStoredMark(n.type)}}})}const By="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yac
137hts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Hy="ελ1Ï 2бг1ел3деÑи4еÑ2каÑолик6ом3мкд2он1Ñква6онлайн5Ñг3ÑÑÑ2Ñ2ÑайÑ3Ñб3ÑкÑ3Òаз3Õ°Õ¡Õµ3×שר××5×§××3Ø§Ø¨ÙØ¸Ø¨Ù5را٠ÙÙ5ÙØ§Ø±Ø¯Ù4Ø¨ØØ±ÙÙ5جزائر5Ø³Ø¹ÙØ¯ÙØ©6عÙÙØ§Ù5٠غرب5٠ارات5ÛØ±Ø§Ù5بارت2زار4ÙØªÙ3ھارت5تÙÙØ³4Ø³ÙØ¯Ø§Ù3Ø±ÙØ©5Ø´Ø¨ÙØ©4عراÙ2ب2٠اÙ4ÙÙØ³Ø·ÙÙ6ÙØ·Ø±3ÙØ§Ø«ÙÙÙÙ6ÙÙ 3٠صر2ÙÙØ³Ùا5ÙØ±ÙتاÙÙØ§7ÙØ¹4Ù٠راÙ5پاکستاÙ7ÚØ§Ø±Øª4à¤à¥à¤®3नà¥à¤3à¤à¤¾à¤°à¤¤0मà¥3à¥à¤¤5सà¤à¤à¤ न5বাà¦à¦²à¦¾5à¦à¦¾à¦°à¦¤2ৰত4à¨à¨¾à¨°à¨¤4àªàª¾àª°àª¤4à¬à¬¾à¬°à¬¤4à®à®¨à¯à®¤à®¿à®¯à®¾6லà®à¯à®à¯6à®à®¿à®à¯à®à®ªà¯à®ªà¯à®°à¯11à°à°¾à°°à°¤à±5à²à²¾à²°à²¤4à´à´¾à´°à´¤à´5à¶½à¶à¶à·4à¸à¸à¸¡3à¹à¸à¸¢3ລາວ3áá2ã¿ããª3ã¢ãã¾ã³4ã¯ã©ã¦ã4ã°ã¼ã°ã«4ã³ã 2ã¹ãã¢3ã»ã¼ã«3ãã¡ãã·ã§ã³6ãã¤ã³ã4ä¸ç2ä¸ä¿¡1å½1å1æç½3äºé©¬é3ä¼ä¸2ä½å±±2ä¿¡æ¯2å¥åº·2å «å¦2å ¬å¸1ç2å°æ¹¾1ç£2åå1åº1æ 2åé0大é åº5å¨çº¿2大æ¿2天主æ3娱ä¹2å®¶é»2广ä¸2å¾®å2æ å2æç±ä½ 3ææº2æè2æ¿å¡1åº2æ°å å¡2é»2æ¶å°2æ¸ç±2æºæ2淡马é¡3游æ2æ¾³é2ç¹ç2ç§»å¨2ç»ç»æºæ4ç½å1åº1ç«1ç»2èé2è°·æ2è´ç©2é販2éå¢2é»è¨çç§4é£å©æµ¦3é£å2é¤å 2馿 ¼éæ3港2ë·ë·1ì»´2ì¼ì±2íêµ2",yo="numeric",vo="ascii",ko="alpha",Xn="asciinumeric",zn="alphanumeric",So="domain",$u="emoji",Vy="scheme",Fy="slashscheme",Ii="whitespace";function Wy(n,e){return n in e||(e[n]=[]),e[n]}function Vt(n,e,t){e[yo]&&(e[Xn]=!0,e[zn]=!0),e[vo]&&(e[Xn]=!0,e[ko]=!0),e[Xn]&&(e[zn]=!0),e[ko]&&(e[zn]=!0),e[zn]&&(e[So]=!0),e[$u]&&(e[So]=!0);for(const r in e){const s=Wy(r,t);s.indexOf(n)<0&&s.push(n)}}function Uy(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Me(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Me.groups={};Me.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(n))return i}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||Me.groups;let s;return e&&e.j?s=e:(s=new Me(e),t&&r&&Vt(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const i=n.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(n[o]);return s.tt(n[i-1],e,t,r)},tt(n,e,t,r){r=r||Me.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const i=e;let o,a=s.go(n);if(a?(o=new Me,Object.assign(o.j,a.j),o.jr.push.apply(o.jr,a.jr),o.jd=a.jd,o.t=a.t):o=new Me,i){if(r)if(o.t&&typeof o.t=="string"){const l=Object.assign(Uy(o.t,r),t);Vt(i,l,r)}else t&&Vt(i,t,r);o.t=i}return s.j[n]=o,o}};const L=(n,e,t,r,s)=>n.ta(e,t,r,s),te=(n,e,t,r,s)=>n.tr(e,t,r,s),Wl=(n,e,t,r,s)=>n.ts(e,t,r,s),M=(n,e,t,r,s)=>n.tt(e,t,r,s),st="WORD",Co="UWORD",_u="ASCIINUMERICAL",Bu="ALPHANUMERICAL",pr="LOCALHOST",No="TLD",wo="UTLD",_r="SCHEME",pn="SLASH_SCHEME",ua="NUM",Mo="WS",ha="NL",Zn="OPENBRACE",er="CLOSEBRACE",rs="OPENBRACKET",ss="CLOSEBRACKET",is="OPENPAREN",as="CLOSEPAREN",ls="OPENANGLEBRACKET",cs="CLOSEANGLEBRACKET",ds="FULLWIDTHLEFTPAREN",us="FULLWIDTHRIGHTPAREN",hs="LEFTCORNERBRACKET",fs="RIGHTCORNERBRACKET",ps="LEFTWHITECORNERBRACKET",ms="RIGHTWHITECORNERBRACKET",gs="FULLWIDTHLESSTHAN",xs="FULLWIDTHGREATERTHAN",bs="AMPERSAND",ys="APOSTROPHE",vs="ASTERISK",ft="AT",ks="BACKSLASH",Ss="BACKTICK",Cs="CARET",xt="COLON",fa="COMMA",Ns="DOLLAR",Ue="DOT",ws="EQUALS",pa="EXCLAMATION",Ie="HYPHEN",tr="PERCENT",Ms="PIPE",js="PLUS",Ts="POUND",nr="QUERY",ma="QUOTE",Hu="FULLWIDTHMIDDLEDOT",ga="SEMI",Ke="SLASH",rr="TILDE",Es="UNDERSCORE",Vu="EMOJI",As="SYM";var Fu=Object.freeze({__proto__:null,ALPHANUMERICAL:Bu,AMPERSAND:bs,APOSTROPHE:ys,ASCIINUMERICAL:_u,ASTERISK:vs,AT:ft,BACKSLASH:ks,BACKTICK:Ss,CARET:Cs,CLOSEANGLEBRACKET:cs,CLOSEBRACE:er,CLOSEBRACKET:ss,CLOSEPAREN:as,COLON:xt,COMMA:fa,DOLLAR:Ns,DOT:Ue,EMOJI:Vu,EQUALS:ws,EXCLAMATION:pa,FULLWIDTHGREATERTHAN:xs,FULLWIDTHLEFTPAREN:ds,FULLWIDTHLESSTHAN:gs,FULLWIDTHMIDDLEDOT:Hu,FULLWIDTHRIGHTPAREN:us,HYPHEN:Ie,LEFTCORNERBRACKET:hs,LEFTWHITECORNERBRACKET:ps,LOCALHOST:pr,NL:ha,NUM:ua,OPENANGLEBRACKET:ls,OPENBRACE:Zn,OPENBRACKET:rs,OPENPAREN:is,PERCENT:tr,PIPE:Ms,PLUS:js,POUND:Ts,QUERY:nr,QUOTE:ma,RIGHTCORNERBRACKET:fs,RIGHTWHITECORNERBRACKET:ms,SCHEME:_r,SEMI:ga,SLASH:Ke,SLASH_SCHEME:pn,SYM:As,TILDE:rr,TLD:No,UNDERSCORE:Es,UTLD:wo,UWORD:Co,WORD:st,WS:Mo});const nt=/[a-z]/,Dn=new RegExp("\\p{L}","u"),Pi=new RegExp("\\p{Emoji}","u"),rt=/\d/,Li=/\s/,Ul="\r",zi=` 138`,Ky="ï¸",qy="â",$i="";let Ar=null,Or=null;function Jy(n=[]){const e={};Me.groups=e;const t=new Me;Ar==null&&(Ar=Kl(By)),Or==null&&(Or=Kl(Hy)),M(t,"'",ys),M(t,"{",Zn),M(t,"}",er),M(t,"[",rs),M(t,"]",ss),M(t,"(",is),M(t,")",as),M(t,"<",ls),M(t,">",cs),M(t,"ï¼",ds),M(t,"ï¼",us),M(t,"ã",hs),M(t,"ã",fs),M(t,"ã",ps),M(t,"ã",ms),M(t,"ï¼",gs),M(t,"ï¼",xs),M(t,"&",bs),M(t,"*",vs),M(t,"@",ft),M(t,"`",Ss),M(t,"^",Cs),M(t,":",xt),M(t,",",fa),M(t,"$",Ns),M(t,".",Ue),M(t,"=",ws),M(t,"!",pa),M(t,"-",Ie),M(t,"%",tr),M(t,"|",Ms),M(t,"+",js),M(t,"#",Ts),M(t,"?",nr),M(t,'"',ma),M(t,"/",Ke),M(t,";",ga),M(t,"~",rr),M(t,"_",Es),M(t,"\\",ks),M(t,"ã»",Hu);const r=te(t,rt,ua,{[yo]:!0});te(r,rt,r);const s=te(r,nt,_u,{[Xn]:!0}),i=te(r,Dn,Bu,{[zn]:!0}),o=te(t,nt,st,{[vo]:!0});te(o,rt,s),te(o,nt,o),te(s,rt,s),te(s,nt,s);const a=te(t,Dn,Co,{[ko]:!0});te(a,nt),te(a,rt,i),te(a,Dn,a),te(i,rt,i),te(i,nt),te(i,Dn,i);const l=M(t,zi,ha,{[Ii]:!0}),d=M(t,Ul,Mo,{[Ii]:!0}),u=te(t,Li,Mo,{[Ii]:!0});M(t,$i,u),M(d,zi,l),M(d,$i,u),te(d,Li,u),M(u,Ul),M(u,zi),te(u,Li,u),M(u,$i,u);const h=te(t,Pi,Vu,{[$u]:!0});M(h,"#"),te(h,Pi,h),M(h,Ky,h);const f=M(h,qy);M(f,"#"),te(f,Pi,h);const p=[[nt,o],[rt,s]],m=[[nt,null],[Dn,a],[rt,i]];for(let g=0;g<Ar.length;g++)dt(t,Ar[g],No,st,p);for(let g=0;g<Or.length;g++)dt(t,Or[g],wo,Co,m);Vt(No,{tld:!0,ascii:!0},e),Vt(wo,{utld:!0,alpha:!0},e),dt(t,"file",_r,st,p),dt(t,"mailto",_r,st,p),dt(t,"http",pn,st,p),dt(t,"https",pn,st,p),dt(t,"ftp",pn,st,p),dt(t,"ftps",pn,st,p),Vt(_r,{scheme:!0,ascii:!0},e),Vt(pn,{slashscheme:!0,ascii:!0},e),n=n.sort((g,x)=>g[0]>x[0]?1:-1);for(let g=0;g<n.length;g++){const x=n[g][0],y=n[g][1]?{[Vy]:!0}:{[Fy]:!0};x.indexOf("-")>=0?y[So]=!0:nt.test(x)?rt.test(x)?y[Xn]=!0:y[vo]=!0:y[yo]=!0,Wl(t,x,x,y)}return Wl(t,"localhost",pr,{ascii:!0}),t.jd=new Me(As),{start:t,tokens:Object.assign({groups:e},Fu)}}function Wu(n,e){const t=Gy(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,s=[];let i=0,o=0;for(;o<r;){let a=n,l=null,d=0,u=null,h=-1,f=-1;for(;o<r&&(l=a.go(t[o]));
vendor: 7,207 bytes, lines 138-141
138)a=l,a.accepts()?(h=0,f=0,u=a):h>=0&&(h+=t[o].length,f++),d+=t[o].length,i+=t[o].length,o++;i-=h,o-=f,d-=h,s.push({t:u.t,v:e.slice(i-d,i),s:i-d,e:i})}return s}function Gy(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),i,o=s<55296||s>56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function dt(n,e,t,r,s){let i;const o=e.length;for(let a=0;a<o-1;a++){const l=e[a];n.j[l]?i=n.j[l]:(i=new Me(r),i.jr=s.slice(),n.j[l]=i),n=i}return i=new Me(t),i.jr=s.slice(),n.j[e[o-1]]=i,i}function Kl(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let i=0;for(;s.indexOf(n[r+i])>=0;)i++;if(i>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+i),10);o>0;o--)t.pop();r+=i}else t.push(n[r]),r++}return e}const mr={defaultProtocol:"http",events:null,format:ql,formatHref:ql,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function xa(n,e=null){let t=Object.assign({},mr);n&&(t=Object.assign(t,n instanceof xa?n.o:n));const r=t.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}xa.prototype={o:mr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:mr[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function ql(n){return n}function Uu(n,e){this.t="token",this.v=n,this.tk=e}Uu.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"â¦":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=mr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),i=this.toFormattedString(n),o={},a=n.get("className",t,e),l=n.get("target",t,e),d=n.get("rel",t,e),u=n.getObj("attributes",t,e),h=n.getObj("events",t,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),d&&(o.rel=d),u&&Object.assign(o,u),{tagName:s,attributes:o,content:i,eventListeners:h}}};function ni(n,e){class t extends Uu{constructor(s,i){super(s,i),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const Jl=ni("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Gl=ni("text"),Yy=ni("nl"),Dr=ni("url",{isLink:!0,toHref(n=mr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==pr&&n[1].t===xt}}),Re=n=>new Me(n);function Qy({groups:n}){const e=n.domain.concat([bs,vs,ft,ks,Ss,Cs,Ns,ws,Ie,ua,tr,Ms,js,Ts,Ke,As,rr,Es]),t=[ys,xt,fa,Ue,pa,tr,nr,ma,ga,ls,cs,Zn,er,ss,rs,is,as,ds,us,hs,fs,ps,ms,gs,xs],r=[bs,ys,vs,ks,Ss,Cs,Ns,ws,Ie,Zn,er,tr,Ms,js,Ts,nr,Ke,As,rr,Es],s=Re(),i=M(s,rr);L(i,r,i),L(i,n.domain,i);const o=Re(),a=Re(),l=Re();L(s,n.domain,o),L(s,n.scheme,a),L(s,n.slashscheme,l),L(o,r,i),L(o,n.domain,o);const d=M(o,ft);M(i,ft,d),M(a,ft,d),M(l,ft,d);const u=M(i,Ue);L(u,r,i),L(u,n.domain,i);const h=Re();L(d,n.domain,h),L(h,n.domain,h);const f=M(h,Ue);L(f,n.domain,h);const p=Re(Jl);L(f,n.tld,p),L(f,n.utld,p),M(d,pr,p);const m=M(h,Ie);M(m,Ie,m),L(m,n.domain,h),L(p,n.domain,h),M(p,Ue,f),M(p,Ie,m);const g=M(p,xt);L(g,n.numeric,Jl);const x=M(o,Ie),b=M(o,Ue);M(x,Ie,x),L(x,n.domain,o),L(b,r,i),L(b,n.domain,o);const y=Re(Dr);L(b,n.tld,y),L(b,n.utld,y),L(y,n.domain,o),L(y,r,i),M(y,Ue,b),M(y,Ie,x),M(y,ft,d);const k=M(y,xt),C=Re(Dr);L(k,n.numeric,C);const v=Re(Dr),w=Re();L(v,e,v),L(v,t,w),L(w,e,v),L(w,t,w),M(y,Ke,v),M(C,Ke,v);const j=M(a,xt),E=M(l,xt),P=M(E,Ke),_=M(P,Ke);L(a,n.domain,o),M(a,Ue,b),M(a,Ie,x),L(l,n.domain,o),M(l,Ue,b),M(l,Ie,x),L(j,n.domain,v),M(j,Ke,v),M(j,nr,v),L(_,n.domain,v),L(_,e,v),M(_,Ke,v);const Y=[[Zn,er],[rs,ss],[is,as],[ls,cs],[ds,us],[hs,fs],[ps,ms],[gs,xs]];for(let Q=0;Q<Y.length;Q++){const[V,H]=Y[Q],S=M(v,V);M(w,V,S),M(S,H,v);const q=Re(Dr);L(S,e,q);const _e=Re();L(S,t),L(q,e,q),L(q,t,_e),L(_e,e,q),L(_e,t,_e),M(q,H,v),M(_e,H,v)}return M(s,pr,y),M(s,ha,Yy),{start:s,tokens:Fu}}function Xy(n,e,t){let r=t.length,s=0,i=[],o=[];for(;s<r;){let a=n,l=null,d=null,u=0,h=null,f=-1;for(;s<r&&!(l=a.go(t[s].t));)o.push(t[s++]);for(;s<r&&(d=l||a.go(t[s].t));)l=null,a=d,a.accepts()?(f=0,h=a):f>=0&&f++,s++,u++;if(f<0)s-=u,s<r&&(o.push(t[s]),s++);else{o.length>0&&(i.push(_i(Gl,e,o)),o=[]),s-=f,u-=f;const p=h.t,m=t.slice(s-u,s);i.push(_i(p,e,m))}}return o.length>0&&i.push(_i(Gl,e,o)),i}function _i(n,e,t){const r=t[0].s,s=t[t.length-1].e,i=e.slice(r,s);return new n(i,t)}const Zy=typeof console<"u"&&console&&console.warn||(()=>{}),ev="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",G={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function tv(){return Me.groups={},G.scanner=null,G.parser=null,G.tokenQueue=[],G.pluginQueue=[],G.customSchemes=[],G.initialized=!1,G}function Yl(n,e=!1){if(G.initialized&&Zy(`linkifyjs: already initialized - will not register custom scheme "${n}" ${ev}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. 1391. Must only contain digits, lowercase ASCII letters or "-" 1402. Cannot start or end with "-" 1413. "-" cannot repeat`);G.customSchemes.push([n,e])}function nv(){G.scanner=Jy(G.customSchemes);for(let n=0;n<G.tokenQueue.length;n++)G.tokenQueue[n][1]({scanner:G.scanner});G.parser=Qy(G.scanner.tokens);for(let n=0;n<G.pluginQueue.length;n++)G.pluginQueue[n][1]({scanner:G.scanner,parser:G.parser});return G.initialized=!0,G}function ba(n){return G.initialized||nv(),Xy(G.parser.start,n,Wu(G.scanner.start,n))}ba.scan=Wu;function Ku(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new xa(t),s=ba(n),i=[];for(let o=0;o<s.length;o++){const a=s[o];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}var ya="[\0-  áá â-\u2029âã]",rv=new RegExp(ya),sv=new RegExp(`${ya}$`),iv=new RegExp(ya,"g");function ov(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function av(n){return new ee({key:new ue("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(d=>d.docChanged)&&!t.doc.eq(r.doc),i=e.some(d=>d.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,a=hu(t.doc,[...e]);
141if(yu(a).forEach(({newRange:d})=>{const u=Ob(r.doc,d,p=>p.isTextblock);let h,f;if(u.length>1)h=u[0],f=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(u.length){const p=r.doc.textBetween(d.from,d.to," "," ");if(!sv.test(p))return;h=u[0],f=r.doc.textBetween(h.pos,d.to,void 0," ")}if(h&&f){const p=f.split(rv).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],g=h.pos+f.lastIndexOf(m);if(!m)return!1;const x=ba(m).map(b=>b.toObject(n.defaultProtocol));if(!ov(x))return!1;x.filter(b=>b.isLink).map(b=>({...b,from:g+b.start+1,to:g+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate(b.value)).filter(b=>n.shouldAutoLink(b.value)).forEach(b=>{oa(b.from,b.to,r.doc).some(y=>y.mark.type===n.type)||o.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function lv(n){return new ee({key:new ue("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const l=r.target;if(!l)return!1;const d=n.editor.view.dom;o=l.closest("a"),o&&!d.contains(o)&&(o=null)}if(!o)return!1;let a=!1;if(n.enableClickSelection&&(a=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){const l=bu(e.state,n.type.name),d=(s=o.href)!=null?s:l.href,u=(i=o.target)!=null?i:l.target;d&&(window.open(d,u),a=!0)}return a}}})}function cv(n){return new ee({key:new ue("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:s}=n,{state:i}=e,{selection:o}=i,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(u=>{l+=u.textContent});const d=Ku(l,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!d||s!==void 0&&!s(d.value)?!1:n.editor.commands.setMark(n.type,{href:d.href})}}})}function Ot(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(iv,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var qu=rn.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate),this.options.protocols.forEach(n=>{if(typeof n=="string"){Yl(n);return}Yl(n.scheme,n.optionalSlashes)})},onDestroy(){tv()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Ot(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const s=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Ot(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Ot(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",de(this.options.HTMLAttributes,n),0]:["a",de(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,r,s,i;const o=(r=(t=n.attrs)==null?void 0:t.href)!=null?r:"",a=(i=(s=n.attrs)==null?void 0:s.title)!=null?i:"",l=e.renderChildren(n);return a?`[${l}](${o} "${a}")`:`[${l}](${o})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Ot(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>
vendor: 5,349 bytes, line 141
141({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!Ot(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Zt({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=Ku(n).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Ot(o,t),protocols:t,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(av({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Ot(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(lv({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(cv({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),dv=qu;function uv(n={}){return new ee({view(e){return new hv(e,n)}})}class hv{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,a=i.height/s.offsetHeight;if(t){let h=e.nodeBefore,f=e.nodeAfter;if(h||f){let p=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(p){let m=p.getBoundingClientRect(),g=h?m.bottom:m.top;h&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*a;r={left:m.left,right:m.right,top:g-x,bottom:g+x}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:h.left-f,right:h.left+f,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let d,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")d=-pageXOffset,u=-pageYOffset;else{let h=l.getBoundingClientRect(),f=h.width/l.offsetWidth,p=h.height/l.offsetHeight;d=h.left-l.scrollLeft*f,u=h.top-l.scrollTop*p}this.element.style.left=(r.left-d)/o+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=rd(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ne extends z{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ne.valid(r)?new ne(r):z.near(r)}content(){return T.empty}eq(e){return e instanceof ne&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ne(e.resolve(t.pos))}getBookmark(){return new va(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!fv(e)||!pv(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ne.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let a=e.node(o);if(t>
vendor: 16,518 bytes, line 141
1410?e.indexAfter(o)<a.childCount:e.index(o)>0){i=a.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let l=e.doc.resolve(s);if(ne.valid(l))return l}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!D.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let a=e.doc.resolve(s);if(ne.valid(a))return a}return null}}}ne.prototype.visible=!1;ne.findFrom=ne.findGapCursorFrom;z.jsonID("gapcursor",ne);class va{constructor(e){this.pos=e}map(e){return new va(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ne.valid(t)?new ne(t):z.near(t)}}function Ju(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function fv(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Ju(s.type))return!0;if(s.inlineContent)return!1}}return!0}function pv(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Ju(s.type))return!0;if(s.inlineContent)return!1}}return!0}function mv(){return new ee({props:{decorations:yv,createSelectionBetween(n,e,t){return e.pos==t.pos&&ne.valid(t)?new ne(t):null},handleClick:xv,handleKeyDown:gv,handleDOMEvents:{beforeinput:bv}}})}const gv=su({ArrowLeft:Rr("horiz",-1),ArrowRight:Rr("horiz",1),ArrowUp:Rr("vert",-1),ArrowDown:Rr("vert",1)});function Rr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof I){if(!i.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let d=ne.findGapCursorFrom(a,e,l);return d?(s&&s(r.tr.setSelection(new ne(d))),!0):!1}}function xv(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ne.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&D.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ne(r))),!0)}function bv(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ne))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=N.empty;for(let o=r.length-1;o>=0;o--)s=N.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new T(s,0,0));return i.setSelection(I.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function yv(n){if(!(n.selection instanceof ne))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",X.create(n.doc,[Ce.widget(n.selection.head,e,{key:"gapcursor"})])}var Os=200,pe=function(){};pe.prototype.append=function(e){return e.length?(e=pe.from(e),!this.length&&e||e.length<Os&&this.leafAppend(e)||this.length<Os&&e.leafPrepend(this)||this.appendInner(e)):this};pe.prototype.prepend=function(e){return e.length?pe.from(e).append(this):this};pe.prototype.appendInner=function(e){return new vv(this,e)};pe.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?pe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};pe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};pe.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};pe.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};pe.from=function(e){return e instanceof pe?e:e&&e.length?new Gu(e):pe.empty};var Gu=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,a){for(var l=i;l<o;l++)if(s(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,a){for(var l=i-1;l>=o;l--)if(s(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Os)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Os)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(pe);pe.empty=new Gu([]);var vv=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var a=this.left.length;if(s<a&&this.left.forEachInner(r,s,Math.min(i,a),o)===!1||i>a&&this.right.forEachInner(r,Math.max(s-a,0),Math.min(this.length,i)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(r,s-a,Math.max(i,a)-a,o+a)===!1||i<a&&this.left.forEachInvertedInner(r,Math.min(s,a),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(pe);const kv=500;class He{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,a,l,d=[],u=[];return this.items.forEach((h,f)=>{if(!h.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,u.push(h);return}if(s){u.push(new qe(h.map));let p=h.step.map(s.slice(i)),m;p&&o.maybeStep(p).doc&&(m=o.mapping.maps[o.mapping.maps.length-1],d.push(new qe(m,void 0,void 0,d.length+u.length))),i--,m&&s.appendMap(m,i)}else o.maybeStep(h.step);if(h.selection)return a=s?h.selection.map(s.slice(i)):h.selection,l=new He(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,t,r,s){let i=[],o=this.eventCount,a=this.items,l=!s&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let h=e.steps[u].invert(e.docs[u]),f=new qe(e.mapping.maps[u],h,t),p;(p=l&&l.merge(f))&&(f=p,u?i.pop():a=a.slice(0,a.length-1)),i.push(f),t&&(o++,t=void 0),s||(l=f)}let d=o-r.depth;return d>Cv&&(a=Sv(a,d),o-=d),new He(a.append(i),o)}remapping(e,t){let r=new ar;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new He(this.items.append(e.map(t=>new qe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},s);let l=t;this.items.forEach(f=>{let p=i.getMirror(--l);if(p==null)return;o=Math.min(o,p);let m=i.maps[p];if(f.step){let g=e.steps[p].invert(e.docs[p]),x=f.selection&&f.selection.map(i.slice(l+1,p));x&&a++,r.push(new qe(m,g,x))}else r.push(new qe(m))},s);let d=[];for(let f=t;f<o;f++)d.push(new qe(i.maps[f]));let u=this.items.slice(0,s).append(d).append(r),h=new He(u,a);return h.emptyItemCount()>kv&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],i=0;return this.items.forEach((o,a)=>{if(a>=e)s.push(o),o.selection&&i++;else if(o.step){let l=o.step.map(t.slice(r)),d=l&&l.getMap();if(r--,d&&t.appendMap(d,r),l){let u=o.selection&&o.selection.map(t.slice(r));u&&i++;let h=new qe(d.invert(),l,u),f,p=s.length-1;(f=s.length&&s[p].merge(h))?s[p]=f:s.push(h)}}else o.map&&r--},this.items.length,0),new He(pe.from(s.reverse()),i)}}He.empty=new He(pe.empty,0);function Sv(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class qe{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new qe(t.getMap().invert(),t,this.selection)}}}class pt{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const Cv=20;function Nv(n,e,t,r){let s=t.getMeta(qt),i;if(s)return s.historyState;t.getMeta(jv)&&(n=new pt(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(qt))return o.getMeta(qt).redo?new pt(n.done.addTransform(t,void 0,r,Br(e)),n.undone,Ql(t.mapping.maps),n.prevTime,n.prevComposition):new pt(n.done,n.undone.addTransform(t,void 0,r,Br(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!o&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!wv(t,n.prevRanges)),d=o?Bi(n.prevRanges,t.mapping):Ql(t.mapping.maps);return new pt(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,Br(e)),He.empty,d,t.time,a??n.prevComposition)}else return(i=t.getMeta("rebased"))?new pt(n.done.rebased(t,i),n.undone.rebased(t,i),Bi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new pt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Bi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function wv(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function Ql(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function Bi(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function Mv(n,e,t){let r=Br(e),s=qt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),a=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),l=new pt(t?a:i.remaining,t?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(qt,{redo:t,historyState:l})}let Hi=!1,Xl=null;function Br(n){let e=n.plugins;if(Xl!=e){Hi=!1,Xl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Hi=!0;break}}return Hi}const qt=new ue("history"),jv=new ue("closeHistory");function Tv(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ee({key:qt,state:{init(){return new pt(He.empty,He.empty,null,0,-1)},apply(e,t,r){return Nv(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?Qu:r=="historyRedo"?Xu:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function Yu(n,e){return(t,r)=>{let s=qt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=Mv(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const Qu=Yu(!1,!0),Xu=Yu(!0,!0);se.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new ee({key:new ue("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,a=0,l=o,d=r.tr.deleteRange(a,l);return n=!0,d}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=i-r,d=a-l,u=a;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>r)}})]}});var Ev=se.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[uv(this.options)]}});se.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ee({key:new ue("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!t||!r)return X.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((l,d)=>{if(l.isText)return;if(!(s>=d&&s<=d+l.nodeSize-1))return!1;o+=1});let a=0;return n.descendants((l,d)=>{if(l.isText||!(s>=d&&s<=d+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&o-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";i.push(Ce.node(d,d+l.nodeSize,{class:this.options.className}))}),X.create(n,i)}}})]}});var Av=se.create({name:"gapCursor",addProseMirrorPlugins(){return[mv()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=F(O(n,"allowGapCursor",t)))!=null?e:null}}}),Zl="placeholder";function Ov(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Dv=se.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Zl,placeholder:"Write something â¦",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${Ov(this.options.dataAttribute)}`:`data-${Zl}`;return[new ee({key:new ue("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=t,i=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((a,l)=>{const d=s>=l&&s<=l+a.nodeSize,u=!a.isLeaf&&Zs(a);if(!a.type.isTextblock)return this.options.includeChildren;if((d||!this.options.showOnlyCurrent)&&u){const h=[this.options.emptyNodeClass];o&&h.push(this.options.emptyEditorClass);const f=Ce.node(l,l+a.nodeSize,{class:h.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:l,hasAnchor:d}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),X.create(e,i)}}})]}});se.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new ee({key:new ue("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||vu(t.selection)||n.view.dragging?null:X.create(t.doc,[Ce.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});var Rv="skipTrailingNode";function ec({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}var Iv=se.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new ue(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new ee({key:e,appendTransaction:(s,i,o)=>{const{doc:a,tr:l,schema:d}
141=o,u=e.getState(o),h=a.content.size,f=d.nodes[t];if(!s.some(p=>p.getMeta(Rv))&&u)return l.insert(h,f.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!ec({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!ec({node:o,types:r})}}})]}}),Pv=se.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Qu(n,e),redo:()=>({state:n,dispatch:e})=>Xu(n,e)}},addProseMirrorPlugins(){return[Tv(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-Ñ":()=>this.editor.commands.undo(),"Shift-Mod-Ñ":()=>this.editor.commands.redo()}}}),Lv=Dv,Zu=rn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",de(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:t.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),zv=Zu,Vi={exports:{}},Fi={};/** 142 * @license React 143 * use-sync-external-store-shim/with-selector.production.js 144 * 145 * Copyright (c) Meta Platforms, Inc. and affiliates. 146 * 147 * This source code is licensed under the MIT license found in the 148 * LICENSE file in the root directory of this source tree. 149 */var tc;function $v(){if(tc)return Fi;tc=1;var n=mh(),e=Fh();function t(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var r=typeof Object.is=="function"?Object.is:t,s=e.useSyncExternalStore,i=n.useRef,o=n.useEffect,a=n.useMemo,l=n.useDebugValue;return Fi.useSyncExternalStoreWithSelector=function(d,u,h,f,p){var m=i(null);if(m.current===null){var g={hasValue:!1,value:null};m.current=g}else g=m.current;m=a(function(){function b(w){if(!y){if(y=!0,k=w,w=f(w),p!==void 0&&g.hasValue){var j=g.value;if(p(j,w))return C=j}return C=w}if(j=C,r(k,w))return j;var E=f(w);return p!==void 0&&p(j,E)?(k=w,j):(k=w,C=E)}var y=!1,k,C,v=h===void 0?null:h;return[function(){return b(u())},v===null?void 0:function(){return b(v())}]},[u,h,f,p]);var x=s(d,m[0],m[1]);return o(function(){g.hasValue=!0,g.value=x},[x]),l(x),x},Fi}var nc;function _v(){return nc||(nc=1,Vi.exports=$v()),Vi.exports}var Bv=_v(),Hv=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},Vv=({contentComponent:n})=>{const e=mc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return c.jsx(c.Fragment,{children:Object.values(e)})};function Fv(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:gh.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}var Wv=class extends Jt.Component{constructor(n){var e;super(n),this.editorContentRef=Jt.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Fv(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return c.jsxs(c.Fragment,{children:[c.jsx("div",{ref:Hv(e,this.editorContentRef),...t}),(n==null?void 0:n.contentComponent)&&c.jsx(Vv,{contentComponent:n.contentComponent})]})}},Uv=A.forwardRef((n,e)=>{const t=Jt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return Jt.createElement(Wv,{key:t,innerRef:e,...n})}),eh=Jt.memo(Uv),Kv=typeof window<"u"?A.useLayoutEffect:A.useEffect,qv=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0}
149,this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Jv(n){var e;const[t]=A.useState(()=>new qv(n.editor)),r=Bv.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:bf);return Kv(()=>t.watch(n.editor),[n.editor,t]),A.useDebugValue(r),r}var Gv=!1,jo=typeof window>"u",Yv=jo||!!(typeof window<"u"&&window.next),Qv=class th{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?jo||Yv?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new Ay(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=t.extensions)==null?void 0:o[i])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?th.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}
149):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Xv(n={},e=[]){const t=A.useRef(n);t.current=n;const[r]=A.useState(()=>new Qv(t)),s=mc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return A.useDebugValue(s),A.useEffect(r.onRender(e)),Jv({editor:s,selector:({transactionNumber:i})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&i===0?0:i+1}),s}var nh=A.createContext({editor:null});nh.Consumer;var Zv=A.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),e0=()=>A.useContext(Zv);Jt.forwardRef((n,e)=>{const{onDragStart:t}=e0(),r=n.as||"div";return c.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});Jt.createContext({markViewContentRef:()=>{}});var ka=A.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});ka.displayName="TiptapContext";var t0=()=>A.useContext(ka);function rh({editor:n,instance:e,children:t}){const r=n??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=A.useMemo(()=>({editor:r}),[r]),i=A.useMemo(()=>({editor:r}),[r]);return c.jsx(nh.Provider,{value:i,children:c.jsx(ka.Provider,{value:s,children:t})})}rh.displayName="Tiptap";function sh({...n}){const{editor:e}=t0();return c.jsx(eh,{editor:e,...n})}sh.displayName="Tiptap.Content";Object.assign(rh,{Content:sh});var Ds=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},n0=/^\s*>\s$/,r0=De.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return Ds("blockquote",{...de(this.options.HTMLAttributes,n),children:Ds("slot",{})})},parseMarkdown:(n,e)=>{var t;const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach((s,i)=>{var o,a;const u=((a=(o=e.renderChild)==null?void 0:o.call(e,s,i))!=null?a:e.renderChildren([s])).split(` 150`).map(h=>h.trim()===""?t:`${t} ${h}`);r.push(u.join(` 151`))}),r.join(` 152${t} 153`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}}
vendor: 1,201 bytes, line 153
153,addInputRules(){return[Mn({find:n0,type:this.type})]}}),s0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,i0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,o0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,a0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,l0=rn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return Ds("strong",{...de(this.options.HTMLAttributes,n),children:Ds("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}}
vendor: 7,847 bytes, lines 153-174
153,addInputRules(){return[wn({find:s0,type:this.type}),wn({find:o0,type:this.type})]},addPasteRules(){return[Zt({find:i0,type:this.type}),Zt({find:a0,type:this.type})]}}),c0=/(^|[^`])`([^`]+)`(?!`)$/,d0=/(^|[^`])`([^`]+)`(?!`)/g,u0=rn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",de(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e)=>n.content?`\`${e.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[wn({find:c0,type:this.type})]},addPasteRules(){return[Zt({find:d0,type:this.type})]}}),Wi=4,h0=/^```([a-z]+)?[\s\n]$/,f0=/^~~~([a-z]+)?[\s\n]$/,p0=De.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Wi,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const i=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",de(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t,r;return((t=n.raw)==null?void 0:t.startsWith("```"))===!1&&((r=n.raw)==null?void 0:r.startsWith("~~~"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const s=((t=n.attrs)==null?void 0:t.language)||"";return n.content?r=[`\`\`\`${s}`,e.renderChildren(n.content),"```"].join(` 154`):r=`\`\`\`${s} 155 156\`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Wi,{state:r}=n,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const a=" ".repeat(t);return o?n.commands.insertContent(a):n.commands.command(({tr:l})=>{const{from:d,to:u}=s,p=r.doc.textBetween(d,u,` 157`,` 158`).split(` 159`).map(m=>a+m).join(` 160`);return l.replaceWith(d,u,r.schema.text(p)),!0})},"Shift-Tab":({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Wi,{state:r}=n,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?n.commands.command(({tr:a})=>{var l;const{pos:d}=i,u=i.start(),h=i.end(),p=r.doc.textBetween(u,h,` 161`,` 162`).split(` 163`);let m=0,g=0;const x=d-u;for(let w=0;w<p.length;w+=1){if(g+p[w].length>=x){m=w;break}g+=p[w].length+1}const y=((l=p[m].match(/^ */))==null?void 0:l[0])||"",k=Math.min(y.length,t);if(k===0)return!0;let C=u;for(let w=0;w<m;w+=1)C+=p[w].length+1;return a.delete(C,C+k),d-C<=k&&a.setSelection(I.create(a.doc,C)),!0}):n.commands.command(({tr:a})=>{const{from:l,to:d}=s,f=r.doc.textBetween(l,d,` 164`,` 165`).split(` 166`).map(p=>{var m;const g=((m=p.match(/^ */))==null?void 0:m[0])||"",x=Math.min(g.length,t);return p.slice(x)}).join(` 167`);return a.replaceWith(l,d,r.schema.text(f)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` 168 169`);return!i||!o?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const a=s.after();return a===void 0?!1:r.nodeAt(a)?n.commands.command(({tr:d})=>(d.setSelection(z.near(r.resolve(a))),!0)):n.commands.exitCode()}}},addInputRules(){return[xo({find:h0,type:this.type,getAttributes:n=>({language:n[1]})}),xo({find:f0,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new ee({key:new ue("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;if(!t||!i)return!1;const{tr:o,schema:a}=n.state,l=a.text(t.replace(/\r\n?/g,` 170`));return o.replaceSelectionWith(this.type.create({language:i},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(I.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),m0=De.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` 171 172`):""}),g0=De.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",de(this.options.HTMLAttributes,n)]},renderText(){return` 173`},renderMarkdown:()=>` 174`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&l&&o){const h=l.filter(f=>a.includes(f.type.name));d.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),x0=De.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,de(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,s="#".repeat(r);return n.content?`${s} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>xo({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}}
174)\\s$`),type:this.type,getAttributes:{level:n}}))}}),b0=De.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",de(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Dy(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,s=n();return vu(t)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:a})=>{if(a){const{$to:l}=o.selection,d=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?o.setSelection(I.create(o.doc,l.pos+1)):l.nodeAfter.isBlock?o.setSelection(D.create(o.doc,l.pos)):o.setSelection(I.create(o.doc,l.pos));else{const u=i.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,h=u==null?void 0:u.create();h&&(o.insert(d,h),o.setSelection(I.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Oy({find:/^(?:---|â-|___\s|\*\*\*\s)$/,type:this.t
vendor: 1,046 bytes, line 174
174ype})]}}),y0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,v0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,k0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,S0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,C0=rn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",de(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}}
vendor: 9,055 bytes, lines 174-184
174,addInputRules(){return[wn({find:y0,type:this.type}),wn({find:k0,type:this.type})]},addPasteRules(){return[Zt({find:v0,type:this.type}),Zt({find:S0,type:this.type})]}}),N0=Object.defineProperty,w0=(n,e)=>{for(var t in e)N0(n,t,{get:e[t],enumerable:!0})},M0="listItem",rc="textStyle",sc=/^\s*([-+*])\s$/,ih=De.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",de(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` 175`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(M0,this.editor.getAttributes(rc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Mn({find:sc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Mn({find:sc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(rc),editor:this.editor})),[n]}}),oh=De.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",de(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{var t;if(n.type!=="list_item")return[];const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;let s=[];if(n.tokens&&n.tokens.length>0)if(n.tokens.some(o=>o.type==="paragraph"))s=r(n.tokens);else{const o=n.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(o.tokens)}],n.tokens.length>1){const l=n.tokens.slice(1),d=r(l);s.push(...d)}}else s=r(n.tokens)}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(n,e,t)=>da(n,e,r=>{var s,i;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((i=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:i.start)||1)+r.index}. `:"- "},t),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),j0={};w0(j0,{findListItemPos:()=>yr,getNextListDepth:()=>Sa,handleBackspace:()=>To,handleDelete:()=>Eo,hasListBefore:()=>ah,hasListItemAfter:()=>T0,hasListItemBefore:()=>lh,listItemHasSubList:()=>ch,nextListIsDeeper:()=>dh,nextListIsHigher:()=>uh});var yr=(n,e)=>{const{$from:t}=e.selection,r=ce(n,e.schema);let s=null,i=t.depth,o=t.pos,a=null;for(;i>0&&a===null;)s=t.node(i),s.type===r?a=i:(i-=1,o-=1);return a===null?null:{$pos:e.doc.resolve(o),depth:a}},Sa=(n,e)=>{const t=yr(n,e);if(!t)return!1;const[,r]=Vb(e,n,t.$pos.pos+4);return r},ah=(n,e,t)=>{const{$anchor:r}=n.selection,s=Math.max(0,r.pos-2),i=n.doc.resolve(s).node();return!(!i||!t.includes(i.type.name))},lh=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((t=s.nodeBefore)==null?void 0:t.type.name)!==n)},ch=(n,e,t)=>{if(!t)return!1;const r=ce(n,e.schema);let s=!1;return t.descendants(i=>{i.type===r&&(s=!0)}),s},To=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Tt(n.state,e)&&ah(n.state,e,t)){const{$anchor:a}=n.state.selection,l=n.state.doc.resolve(a.before()-1),d=[];l.node().descendants((f,p)=>{f.type.name===e&&d.push({node:f,pos:p})});const u=d.at(-1);if(!u)return!1;const h=n.state.doc.resolve(l.start()+u.pos+1);return n.chain().cut({from:a.start()-1,to:a.end()+1},h.end()).joinForward().run()}if(!Tt(n.state,e)||!Kb(n.state))return!1;const r=yr(e,n.state);if(!r)return!1;const i=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=ch(e,n.state,i);return lh(e,n.state)&&!o?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},dh=(n,e)=>{const t=Sa(n,e),r=yr(n,e);return!r||!t?!1:t>r.depth},uh=(n,e)=>{const t=Sa(n,e),r=yr(n,e);return!r||!t?!1:t<r.depth},Eo=(n,e)=>{if(!Tt(n.state,e)||!Ub(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:s}=t;return!t.empty&&r.sameParent(s)?!1:dh(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():uh(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},T0=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((t=s.nodeAfter)==null?void 0:t.type.name)!==n)},hh=se.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Eo(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Eo(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&To(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&To(n,t,r)&&(e=!0)}),e}}}}),ic=/^(\s*)(\d+)\.\s+(.*)$/,E0=/^\s/;function A0(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t],i=s.match(ic);if(!i)break;const[,o,a,l]=i,d=o.length;let u=l,h=t+1;const f=[s];for(;h<n.length;){const p=n[h];if(p.match(ic))break;if(p.trim()==="")f.push(p),u+=` 176`,h+=1;else if(p.match(E0))f.push(p),u+=` 177${p.slice(d+2)}`,h+=1;else break}e.push({indent:d,number:parseInt(a,10),content:u.trim(),raw:f.join(` 178`)}),r=h,t=h}return[e,r]}function fh(n,e,t){var r;const s=[];let i=0;for(;i<n.length;){const o=n[i];if(o.indent===e){const a=o.content.split(` 179`),l=((r=a[0])==null?void 0:r.trim())||"",d=[];l&&d.push({type:"paragraph",raw:l,tokens:t.inlineTokens(l)});const u=a.slice(1).join(` 180`).trim();if(u){const p=t.blockTokens(u);d.push(...p)}let h=i+1;const f=[];for(;h<n.length&&n[h].indent>e;)f.push(n[h]),h+=1;if(f.length>0){const p=Math.min(...f.map(g=>g.indent)),m=fh(f,p,t);d.push({type:"list",ordered:!0,start:f[0].number,items:m,raw:f.map(g=>g.raw).join(` 181`)})}s.push({type:"list_item",raw:o.raw,tokens:d}),i=h}else i+=1}return s}function O0(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var D0="listItem",oc="textStyle",ac=/^(\d+)\.\s$/,ph=De.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",de(this.options.HTMLAttributes,t),0]:["ol",de(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.items?O0(n.items,e):[];return t!==1?{type:"orderedList",attrs:{start:t},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` 182`):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{const e=n.match(/^(\s*)(\d+)\.\s+/),t=e==null?void 0:e.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;const s=n.split(` 183`),[i,o]=A0(s);if(i.length===0)return;const a=fh(i,0,t);return a.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:a,raw:s.slice(0,o).join(` 184`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(D0,this.editor.getAttributes(oc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}}
184,addInputRules(){let n=Mn({find:ac,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Mn({find:ac,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(oc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),R0=/^\s*(\[([( |x])?\])\s$/,I0=De.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",de(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const s=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return da(n,e,s)},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),d=h=>{var f,p;a.ariaLabel=((p=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:p.call(f,h,a.checked))||`Task item checkbox for ${h.textContent||"empty task item"}`};d(n),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",h=>h.preventDefault()),a.addEventListener("change",h=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:f}=h.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const m=t();if(typeof m!="number")return!1;const g=p.doc.nodeAt(m);return p.setNodeMarkup(m,void 0,{...g==null?void 0:g.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([h,f])=>{s.setAttribute(h,f)}),s.dataset.checked=n.attrs.checked,a.checked=n.attrs.checked,i.append(a,o),s.append(i,l),Object.entries(e).forEach(([h,f])=>{s.setAttribute(h,f)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:l,update:h=>{if(h.type!==this.type)return!1;s.dataset.checked=h.attrs.checked,a.checked=h.attrs.checked,d(h);const f=r.extensionManager.attributes,p=fr(h,f),m=new Set(Object.keys(p)),g=this.options.HTMLAttributes;return u.forEach(x=>{m.has(x)||(x in g?s.setAttribute(x,g[x]):s.removeAttribute(x))}),Object.entries(p).forEach(([x,b])=>{b==null?x in g?s.setAttribute(x,g[x]):s.removeAttribute(x):s.setAttribute(x,b)}),u=m,!0}}}}
184,addInputRules(){return[Mn({find:R0,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),P0=De.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",de(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` 185`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=i=>{const o=bo(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:t.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},t);return o?[{type:"taskList",raw:o.raw,items:o.items}]:t.blockTokens(i)},s=bo(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:t.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});se.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(ih.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(oh.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(hh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(ph.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(I0.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(P0.configure(this.options.taskList)),n}});var Ir=" ",Ui="Â ",L0=De.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",de(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===Ir||t[0].text===Ir||t[0].raw===Ui||t[0].text===Ui)&&r.length===1&&r[0].type==="text"&&(r[0].text===Ir||r[0].text===Ui)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,s;if(!n)return"";const i=Array.isArray(n.content)?n.content:[];if(i.length===0){const o=Array.isArray((r=t==null?void 0:t.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((s=t==null?void 0:t.previousNode)==null?void 0:s.type)==="paragraph"&&o.length===0?Ir:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),z0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,$0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,_0=rn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",de(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}}
vendor: 2,077 bytes, line 185
185,addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[wn({find:z0,type:this.type})]},addPasteRules(){return[Zt({find:$0,type:this.type})]}}),B0=De.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),H0=se.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(l0.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(r0.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(ih.configure(this.options.bulletList)),this.options.code!==!1&&s.push(u0.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(p0.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(m0.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(Ev.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Av.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(g0.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(x0.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(Pv.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(b0.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(C0.configure(this.options.italic)),this.options.listItem!==!1&&s.push(oh.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(hh.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(qu.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(ph.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(L0.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(_0.configure(this.options.strike)),this.options.text!==!1&&s.push(B0.configure(this.options.text)),this.options.underline!==!1&&s.push(Zu.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(Iv.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),V0=H0;
185function We({pressed:n,onPressedChange:e,disabled:t,children:r,title:s}){return c.jsx(yf,{size:"sm",pressed:n,onPressedChange:e,disabled:t,title:s,className:"data-[state=on]:bg-primary/10 h-8 w-8 p-0",children:r})}function F0({content:n,onChange:e,placeholder:t="Start writing...",className:r,error:s,allowedLinkHrefs:i=[],id:o,"aria-label":a,"aria-labelledby":l,"aria-invalid":d,"aria-describedby":u}){const h=A.useMemo(()=>({class:re(Ac,"min-h-[400px] px-4 py-3 focus:outline-none"),...o?{id:o}:{},...a?{"aria-label":a}:{},...l?{"aria-labelledby":l}:{},...d!==void 0?{"aria-invalid":String(d)}:{},...u?{"aria-describedby":u}:{}}),[u,d,a,l,o]),f=Xv({extensions:[V0.configure({heading:{levels:[1,2,3]},link:!1,underline:!1}),zv,dv.configure({openOnClick:!1,isAllowedUri:(m,{defaultValidate:g})=>i.includes(m)||g(m),HTMLAttributes:{class:"text-primary underline cursor-pointer"}}),Lv.configure({placeholder:t,emptyEditorClass:"before:content-[attr(data-placeholder)] before:text-muted-foreground before:float-left before:pointer-events-none before:h-0"})],content:n,editorProps:{attributes:h},onUpdate:({editor:m})=>{e(m.getHTML())}});A.useEffect(()=>{f&&f.setOptions({editorProps:{attributes:h}})},[f,h]),A.useEffect(()=>{f&&n!==f.getHTML()&&f.commands.setContent(n)},[n,f]);const p=()=>{if(!f)return;const m=f.getAttributes("link").href,g=i[0],x=window.prompt(g?`URL or ${g}`:"URL",m);if(x!==null){if(x===""){f.chain().focus().extendMarkRange("link").unsetLink().run();return}f.chain().focus().extendMarkRange("link").setLink({href:x}).run()}};return f?c.jsxs("div",{className:re("rounded-md border",s&&"border-destructive",r),children:[c.jsxs("div",{className:"bg-muted/30 flex flex-wrap items-center gap-1 border-b p-2",children:[c.jsx(We,{pressed:f.isActive("heading",{level:1}
185),onPressedChange:()=>f.chain().focus().toggleHeading({level:1}).run(),title:"Heading 1",children:c.jsx(vf,{className:"h-4 w-4"})}),c.jsx(We,{pressed:f.isActive("heading",{level:2}),onPressedChange:()=>f.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2",children:c.jsx(kf,{className:"h-4 w-4"})}),c.jsx(We,{pressed:f.isActive("heading",{level:3}),onPressedChange:()=>f.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3",children:c.jsx(Sf,{className:"h-4 w-4"})}),c.jsx(pi,{orientation:"vertical",className:"mx-1 h-6"}),c.jsx(We,{pressed:f.isActive("bold"),onPressedChange:()=>f.chain().focus().toggleBold().run(),title:"Bold",children:c.jsx(Cf,{className:"h-4 w-4"})}),c.jsx(We,{pressed:f.isActive("italic"),onPressedChange:()=>f.chain().focus().toggleItalic().run(),title:"Italic",children:c.jsx(Nf,{className:"h-4 w-4"})}),c.jsx(We,{pressed:f.isActive("underline"),onPressedChange:()=>f.chain().focus().toggleUnderline().run(),title:"Underline",children:c.jsx(wf,{className:"h-4 w-4"})}),c.jsx(We,{pressed:f.isActive("strike"),onPressedCh
185ange:()=>f.chain().focus().toggleStrike().run(),title:"Strikethrough",children:c.jsx(Mf,{className:"h-4 w-4"})}),c.jsx(pi,{orientation:"vertical",className:"mx-1 h-6"}),c.jsx(We,{pressed:f.isActive("bulletList"),onPressedChange:()=>f.chain().focus().toggleBulletList().run(),title:"Bullet List",children:c.jsx(Sh,{className:"h-4 w-4"})}),c.jsx(We,{pressed:f.isActive("orderedList"),onPressedChange:()=>f.chain().focus().toggleOrderedList().run(),title:"Ordered List",children:c.jsx(Yf,{className:"h-4 w-4"})}),c.jsx(pi,{orientation:"vertical",className:"mx-1 h-6"}),c.jsx(We,{pressed:f.isActive("blockquote"),onPressedChange:()=>f.chain().focus().toggleBlockquote().run(),title:"Quote",children:c.jsx(Xf,{className:"h-4 w-4"})}),c.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:p,className:re("h-8 w-8 p-0",f.isActive("link")&&"bg-primary/10"),title:"Add or edit link","aria-label":"Add or edit link",children:c.jsx(jf,{className:"h-4 w-4"})})]}),c.jsx(eh,{editor:f})]}):null}const W0=["{{ lead.first_name }}","{{ lead.full_name }}","{{ lead.job_title }}","{{ lead.company_name }}","{{ lead.role_to_outsource }}","{{ partner.name }}","{{ partner.poc_names }}","{{ meeting.date }}","{{ meeting.time }}","{{ meeting.link }}"],lc="{{ meeting.link }}",U0={"{{ lead.first_name }}":"Maya","{{ lead.full_name }}":"Maya Chen","{{ lead.job_title }}":"VP of Customer Experience","{{ lead.company_name }}":"Northstar Systems","{{ lead.role_to_outsource }}":"Customer support specialists","{{ partner.name }}":"Atlas Service Group","{{ partner.poc_names }}":"Jordan Reyes and Alex Santos","{{ meeting.date }}":"Tuesday, July 28","{{ meeting.time }}":"2:00 PM Asia/Manila","{{ meeting.link }}":"https://meet.example.com/discovery"};function cc(n){return Object.entries(U0).reduce((e,[t,r])=>e.replaceAll(t,r),n)}function K0({template:n,index:e,errors:t,onChange:r}){const s=`intro_email_templates.${e}`,i=`sp-intro-${n.uuid}`,o=t[`${s}.body_html`],a=`${i}-body-label`,l=`${i}-body-error`,d=h=>r({...n,...h}),u=async h=>{await navigator.clipboard.writeText(h),J.success("Merge token copied.")};return c.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.25fr)_minmax(320px,0.75fr)]",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"grid gap-3 sm:grid-cols-[minmax(180px,0.7fr)_minmax(0,1.3fr)]",children:[c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:`${i}-key`,className:"text-xs",children:"Template key"}),c.jsx(U,{id:`${i}-key`,value:n.key,onChange:h=>d({key:h.target.value}),placeholder:"default",spellCheck:!1,"aria-invalid":!!t[`${s}.key`],className:`${Z} font-mono text-xs`}),c.jsx("p",{className:"text-[11px] text-[var(--hub-text-muted)]",children:"Lowercase letters, numbers, and hyphens."}),c.jsx(be,{message:t[`${s}.key`],className:"text-xs"})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:`${i}-label`,className:"text-xs",children:"Admin label"}),c.jsx(U,{id:`${i}-label`,value:n.label,onChange:h=>d({label:h.target.value}),placeholder:"Default introduction","aria-invalid":!!t[`${s}.label`],className:Z}),c.jsx(be,{message:t[`${s}.label`],className:"text-xs"})]})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{htmlFor:`${i}-subject`,className:"text-xs",children:"Subject"}),c.jsx(U,{id:`${i}-subject`,value:n.subject,onChange:h=>d({subject:h.target.value}),placeholder:"Meeting Confirmation: {{ partner.name }} <> {{ lead.full_name }}","aria-invalid":!!t[`${s}.subject`],className:Z}),c.jsx(be,{message:t[`${s}.subject`],className:"text-xs"})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(R,{id:a,htmlFor:`${i}-body`,className:"text-xs",children:"Email body"}),c.jsx(F0,{id:`${i}-body`,content:n.bodyHtml,onChange:h=>d({bodyHtml:h}),allowedLinkHrefs:[lc],placeholder:"Write the approved introduction emailâ¦",error:!!o,"aria-labelledby":a,"aria-invalid":!!o,"aria-describedby":o?l:void 0,className:"overflow-hidden rounded-[var(--hub-radius-control)] border-[var(--hub-control-border)] [&_.ProseMirror]:min-h-[260px]"}),c.jsx(be,{id:l,message:o,className:"text-xs"})]}),c.jsxs("div",{className:"rounded-[var(--hub-radius-control)] border border-[var(--hub-border)] bg-[var(--hub-surface-subtle)] p-3",children:[c.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs font-medium text-[var(--hub-text)]",children:[c.jsx(Kf,{className:"size-3.5","aria-hidden":"true"}),"Approved merge tokens"]}),c.jsxs("p",{className:"mb-2 text-[11px] leading-4 text-[var(--hub-text-muted)]",children:["These values are replaced for each lead handoff. For dynamic linked text, select the text, choose Add or edit link, and use"," ",c.jsx("code",{className:"font-mono text-[var(--hub-text)]",children:lc})," as the URL."]}),c.jsx("div",{className:"flex flex-wrap gap-1.5",children:W0.map(h=>c.jsxs(B,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1 font-mono text-[11px] font-normal","aria-label":`Copy ${h}`,onClick:()=>void u(h),children:[c.jsx(Tf,{className:"size-3","aria-hidden":"true"}),h]},h))})]})]}),c.jsxs("aside",{className:"h-fit overflow-hidden rounded-[var(--hub-radius-control)] border border-[var(--hub-border)] bg-[var(--hub-surface)]",children:[c.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--hub-border)] bg-[var(--hub-surface-subtle)] px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ef,{className:"size-4 text-[var(--hub-text-muted)]","aria-hidden":"true"}),c.jsx("h4",{className:"text-xs font-semibold text-[var(--hub-text)]",children:"Template preview"})]}),c.jsxs("span",{className:"text-[10px] font-medium tracking-wide text-[var(--hub-text-muted)] uppercase",children:["Sample values · ",n.version>0?`Version ${n.version}`:"Unsaved"]})]}),c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-[10px] font-semibold tracking-[0.08em] text-[var(--hub-text-muted)] uppercase",children:"Subject"}),c.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--hub-text)]",children:n.subject?cc(n.subject):"Add a subject to preview the email."})]}),c.jsx("div",{className:"border-t border-[var(--hub-border)] pt-4",children:n.bodyHtml?c.jsx(xf,{html:cc(n.bodyHtml),className:`${Ac} text-[var(--hub-text)] [&_a]:text-[var(--hub-accent)]`}):c.jsx("p",{className:"text-sm text-[var(--hub-text-muted)]",children:"The formatted email preview will appear here."})})]})]})]})}function q0(n){let e=n.length+1,t=n.length===0?"default":`variant-${e}`;for(;n.some(r=>r.key===t);)e+=1,t=`variant-${e}`;return{uuid:`new-template-${Date.now()}-${Math.random().toString(36).slice(2)}`,key:t,label:n.length===0?"Default introduction":`Introduction variant ${e}`,version:0,subject:"",bodyHtml:"",activatedAt:null}}function J0({templates:n,errors:e,onChange:t,onStructureChange:r}){var h;const[s,i]=A.useState(((h=n[0])==null?void 0:h.uuid)??null),o=n.findIndex(f=>f.uuid===s),a=o>=0?o:0,l=n[a],d=()=>{const f=q0(n);r([...n,f]),i(f.uuid)},u=f=>{var g,x;const p=((g=n[f])==null?void 0:g.uuid)===s,m=n.filter((b,y)=>y!==f);r(m),p&&i(((x=m[Math.min(f,m.length-1)])==null?void 0:x.uuid)??null)};return c.jsxs("section",{className:"border-t border-[var(--hub-border)] px-[var(--hub-surface-padding)] py-5",children:[c.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Po,{className:"size-4 text-[var(--hub-accent)]","aria-hidden":"true"}),c.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-text)]",children:"Introduction email templates"})]}),c.jsx("p",{className:"mt-1 max-w-3xl text-xs leading-5 text-[var(--hub-text-muted)]",children:"Maintain keyed variants for different Partner POCs while keeping each approved message easy to review."})]}),c.jsxs(B,{type:"button",size:"sm",variant:"outline",className:"shrink-0 gap-1.5",onClick:d,children:[c.jsx(Bs,{className:"size-3.5"}),"Add template"]})]}),n.length===0?c.jsxs("div",{className:"rounded-[var(--hub-radius-control)] border border-dashed border-[var(--hub-border)] bg-[var(--hub-surface-subtle)] px-4 py-7 text-center",children:[c.jsx(Ch,{className:"mx-auto
185size-5 text-[var(--hub-text-muted)]","aria-hidden":"true"}),c.jsx("p",{className:"mt-2 text-sm font-medium text-[var(--hub-text)]",children:"No introduction templates configured"}),c.jsx("p",{className:"mt-1 text-xs text-[var(--hub-text-muted)]",children:"Add a keyed template for the Partner handoff email."})]}):c.jsxs("div",{className:"grid gap-4 xl:grid-cols-[220px_minmax(0,1fr)]",children:[c.jsx("nav",{"aria-label":"Introduction templates",className:"space-y-1.5",children:n.map((f,p)=>{const m=p===a;return c.jsxs("div",{className:`group flex items-center gap-1 rounded-[var(--hub-radius-control)] border p-1 ${m?"border-[var(--hub-accent)] bg-[var(--hub-surface-emphasis)]":"border-[var(--hub-border)] bg-[var(--hub-surface)]"}`,children:[c.jsxs("button",{type:"button","aria-current":m?"true":void 0,onClick:()=>i(f.uuid),className:"min-w-0 flex-1 rounded px-2 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--hub-accent)]",children:[c.jsx("span",{className:"block truncate text-xs font-medium text-[var(--hub-text)]",children:f.label||"Untitled template"}),c.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-[var(--hub-text-muted)]",children:f.key||"missing-key"})]}
185),c.jsx(B,{type:"button",size:"icon",variant:"ghost",className:"size-7 shrink-0 text-[var(--hub-text-muted)] hover:text-red-600","aria-label":`Remove ${f.label||`template ${p+1}`}`,onClick:()=>u(p),children:c.jsx(Hs,{className:"size-3.5"})})]},f.uuid)})}),l?c.jsx(K0,{template:l,index:a,errors:e,onChange:f=>t(n.map((p,m)=>m===a?f:p))}):null]}),e.intro_email_templates?c.jsx("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:e.intro_email_templates}):null]})}const G0=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Y0({enabled:n,recipients:e,error:t,onEnabledChange:r,onRecipientsChange:s}){const[i,o]=A.useState(""),a=()=>{const l=i.trim().toLowerCase();if(!G0.test(l)){J.error("Enter a valid email address.");return}if(e.some(d=>d.email.toLowerCase()===l)){J.error("This email address has already been added.");return}s([...e,{id:l,email:l}]),o("")};return c.jsxs("section",{className:"border-t border-[var(--hub-border)] px-[var(--hub-surface-padding)] py-5",children:[c.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Wf,{className:"size-4 text-[var(--hub-accent)]","aria-hidden":"true"}),c.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-text)]",children:"Operational notifications"})]}),c.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--hub-text-muted)]",children:"Preserve the existing organization-level alerts for lead allocations and discovery bookings."})]}),c.jsx(Fr,{"aria-label":"Enable email notifications",checked:n,onCheckedChange:r})]}),c.jsxs("div",{className:"max-w-3xl space-y-3",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[c.jsx(U,{type:"email",placeholder:"[email protected]",value:i,onChange:l=>o(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),a())},disabled:!n,className:Z,"aria-label":"Notification recipient"}
185),c.jsx(B,{type:"button",size:"sm",variant:"outline",onClick:a,disabled:!n,children:"Add recipient"})]}),e.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(l=>c.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[var(--hub-border)] bg-[var(--hub-surface-subtle)] py-1 pr-1 pl-2.5 text-xs text-[var(--hub-text)]",children:[c.jsx(Po,{className:"size-3 text-[var(--hub-text-muted)]"}),l.email,c.jsx("button",{type:"button","aria-label":`Remove ${l.email}`,disabled:!n,onClick:()=>s(e.filter(d=>d.id!==l.id)),className:"rounded-full p-0.5 text-[var(--hub-text-muted)] hover:bg-[var(--hub-surface-emphasis)] hover:text-[var(--hub-text)] disabled:opacity-50",children:c.jsx(Cc,{className:"size-3"})})]},l.id))}),t&&c.jsx("p",{className:"text-xs text-red-600",children:t}),c.jsx(R,{className:"sr-only",children:"Email recipients"})]})]})}function Q0({meetingHost:n,meetingSchedulerUrl:e,hubspotMeetingLinkSlug:t,tag:r,errors:s,onMeetingHostChange:i,onMeetingSchedulerUrlChange:o,onHubspotMeetingLinkSlugChange:a,onTagChange:l}){const d=!!(n&&e&&t);return c.jsxs("section",{className:"border-t border-[var(--hub-border)] px-[var(--hub-surface-padding)] py-5",children:[c.jsxs("div",{className:"mb-4 flex flex-col justify-between gap-3 sm:flex-row sm:items-start",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Nh,{className:"size-4 text-[var(--hub-accent)]","aria-hidden":"true"}),c.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-text)]",children:"HubSpot scheduling"})]}),c.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--hub-text-muted)]",children:"Connect this partner to its OA-owned HubSpot scheduler and synced calendar."})]}),c.jsxs("span",{className:"inline-flex w-fit items-center gap-1.5 rounded-full border border-[var(--hub-border)] px-2 py-1 text-xs text-[var(--hub-text-muted)]",children:[c.jsx(bc,{className:d?"size-3.5 text-emerald-600":"size-3.5"}),d?"Scheduler configured":"Configuration incomplete"]})]}),c.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[c.jsxs("div",{className:"space-y-2 lg:col-span-2",children:[c.jsx(R,{htmlFor:"sp-meeting-scheduler-url",children:"HubSpot meeting scheduler URL"}),c.jsxs("div",{className:"relative",children:[c.jsx(Af,{className:"pointer-events-none absolute top-2.5 left-3 size-4 text-[var(--hub-text-muted)]"}),c.jsx(U,{id:"sp-meeting-scheduler-url",type:"url",value:e,onChange:u=>o(u.target.value),placeholder:"https://me.outsourceaccelerator.com/meetings/partner-name",className:`${Z} pl-9`})]}),s.meeting_scheduler_url&&c.jsx("p",{className:"text-xs text-red-600",children:s.meeting_scheduler_url})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{htmlFor:"sp-meeting-host",children:"Meeting host"}),c.jsx(U,{id:"sp-meeting-host",type:"email",value:n,onChange:u=>i(u.target.value),placeholder:"[email protected]",className:Z}),c.jsx("p",{className:"text-xs text-[var(--hub-text-muted)]",children:"Used to verify the organizer on booked HubSpot meetings."}),s.meeting_host&&c.jsx("p",{className:"text-xs text-red-600",children:s.meeting_host})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{htmlFor:"sp-hubspot-link-slug",children:"HubSpot meeting link slug"}),c.jsx(U,{id:"sp-hubspot-link-slug",value:t,onChange:u=>a(u.target.value),placeholder:"partner-name",className:Z}),c.jsx("p",{className:"text-xs text-[var(--hub-text-muted)]",children:"The stable scheduler identity used for live availability checks."}),s.hubspot_meeting_link_slug&&c.jsx("p",{className:"text-xs text-red-600",children:s.hubspot_meeting_link_slug})]}),c.jsxs("div",{className:"space-y-2 lg:max-w-md",children:[c.jsx(R,{htmlFor:"sp-tag",children:"Organization tag"}),c.jsx(U,{id:"sp-tag",value:r,onChange:u=>l(u.target.value),placeholder:"partner_tag",className:Z}),c.jsx("p",{className:"text-xs text-[var(--hub-text-muted)]",children:"Written to the assigned_source_partner HubSpot contact property."}),s.tag&&c.jsx("p",{className:"text-xs text-red-600",children:s.tag})]})]})]})}function X0({organization:n,organizationSlug:e,settings:t,onDirtyChange:r}){const[s,i]=A.useState(t.emailNotificationsEnabled),[o,a]=A.useState(t.emailRecipients),[l,d]=A.useState(t.meetingHost??""),[u,h]=A.useState(t.meetingSchedulerUrl??""),[f,p]=A.useState(t.hub
185spotMeetingLinkSlug??""),[m,g]=A.useState(t.tag??""),[x,b]=A.useState(()=>t.contacts.map(V=>{const H=V.routingConditions??{},S=H.geographyMode??H.geography_mode??"all",q=vc(S,H.countryCodes??H.country_codes??[],H.regionKeys??H.region_keys??[]),_e=jc(V.isSelectableMeetingPoc,V.emailCcMode,V.calendarInviteMode);return{...V,routingConditions:{serviceCategories:H.serviceCategories??H.service_categories??[],...q},..._e}})),[y,k]=A.useState(t.introEmailTemplates??[]),[C,v]=A.useState(!1),[w,j]=A.useState({});A.useEffect(()=>()=>r==null?void 0:r(!1),[r]);const E=V=>H=>{r==null||r(!0),V(H)},P=V=>{j(H=>Object.fromEntries(Object.entries(H).filter(([S])=>S!==V&&!S.startsWith(`${V}.`))))},_=V=>{r==null||r(!0),b(V),P("contacts")},Y=V=>{r==null||r(!0),k(V),P("intro_email_templates")},Q=V=>{if(V.preventDefault(),s&&o.length===0){J.error("Add at least one recipient to enable email notifications.");return}if(x.length>0&&!x.some(S=>S.isPrimary)){J.error("Select at least one primary Source Partner contact.");return}r==null||r(!0),v(!0),j({});const H={email_notifications_enabled:s,email_recipients:o.map(S=>({id:S.id,email:S.email})),meeting_host:l||null,meeting_scheduler_url:u||null,hubspot_meeting_link_slug:f||null,tag:m||null,contacts_revision:t.contactsRevision,contacts:x.map(S=>({uuid:S.uuid.startsWith("new-")?null:S.uuid,name:S.name,email:S.email,phone:S.phone,is_primary:S.isPrimary,is_selectable_meeting_poc:S.isSelectableMeetingPoc,availability_timezone:S.availabilityTimezone,availability_windows:S.availabilityWindows.map(q=>({weekdays:q.weekdays,start_time:q.startTime,end_time:q.endTime})),email_cc_mode:S.emailCcMode,calendar_invite_mode:S.calendarInviteMode,routing_conditions:{service_categories:S.routingConditions.serviceCategories,geography_mode:S.routingConditions.geographyMode,country_codes:S.routingConditions.countryCodes,region_keys:S.routingConditions.regionKeys},intro_email_template_key:S.introEmailTemplateKey,receives_lead_notifications:S.receivesLeadNotifications,notes:S.notes})),intro_email_templates:y.map(S=>({key:S.key,label:S.label,subject:S.subject,body_html:S.bodyHtml}))};mt.put(Oh.url({organization:e,targetOrganization:n.slug}),H,{preserveScroll:!0,preserveState:"errors",onSuccess:()=>{r==null||r(!1),J.success("Source Partner settings saved.")},onError:S=>{j(S);const q=Object.values(S)[0];J.error(typeof q=="string"?q:"Unable to save Source Partner settings.")},onFinish:()=>v(!1)})};return c.jsx("form",{onSubmit:Q,inert:C,"aria-busy":C,children:c.jsxs(gn,{title:c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(Nc,{className:"size-4 text-[var(--hub-text-muted)]","aria-hidden":"true"}),"Source Partner settings"]}),description:"Configure the partner handoff once, then reuse it across qualification, booking, and introduction workflows.",contentClassName:"p-0",children:[c.jsx(hp,{cycle:t.latestSubscriptionCycle}),c.jsx(Q0,{meetingHost:l,meetingSchedulerUrl:u,hubspotMeetingLinkSlug:f,tag:m,errors:w,onMeetingHostChange:E(d),onMeetingSchedulerUrlChange:E(h),onHubspotMeetingLinkSlugChange:E(p),onTagChange:E(g)}),c.jsx(Rp,{contacts:x,templates:y,errors:w,onChange:E(b),onStructureChange:_}),c.jsx(J0,{templates:y,errors:w,onChange:E(k),onStructureChange:Y}),c.jsx(Y0,{enabled:s,recipients:o,error:w.email_recipients,onEnabledChange:E(i),onRecipientsChange:E(a)}),c.jsx("div",{className:"flex justify-end border-t border-[var(--hub-border)] px-[var(--hub-surface-padding)] py-4",children:c.jsxs(B,{type:"submit",size:"sm",disabled:C,className:"gap-2",children:[C?c.jsx(yc,{className:"size-4 animate-spin"}):c.jsx(Of,{className:"size-4"}),"Save Source Partner settings"]})})]})})}function Z0({organization:n,organizationSlug:e,sourcePartnerSettings:t,hasUnsavedPartnerChanges:r,onPartnerDirtyChange:s}){return c.jsxs("div",{className:"space-y-4",children:[c.jsx(gn,{title:"Organization settings",description:"Manage the organization identity, lifecycle status, and timezone used across its workspaces.",children:c.jsx(lp,{organization:n,hasUnsavedPartnerChanges:r})}),c.jsx(X0,{organization:n,organizationSlug:e,settings:t,onDirtyChange:s})]})}
185function ek({organization:n,today:e,availablePlans:t,selectedHubPlan:r,selectedTierLabel:s,currentHubSubscription:i,showManualSubscribe:o,setShowManualSubscribe:a,showSubscribeConfirm:l,setShowSubscribeConfirm:d,showAllocateCredits:u,setShowAllocateCredits:h,showAllocateConfirm:f,setShowAllocateConfirm:p,showDeductCredits:m,setShowDeductCredits:g,showDeductConfirm:x,setShowDeductConfirm:b,editingSubscription:y,setEditingSubscription:k,subscribeForm:C,allocateForm:v,deductForm:w,editForm:j,onSubscribeClick:E,onManualSubscribe:P,onAllocateClick:_,onAllocateCredits:Y,onDeductClick:Q,onDeductCredits:V,onEditSubscription:H}){return c.jsxs(c.Fragment,{children:[c.jsx(Rt,{open:o,onOpenChange:a,children:c.jsxs(It,{children:[c.jsxs(Pt,{children:[c.jsx(Lt,{children:"Add plan"}),c.jsxs(zt,{children:["Add a plan record for ",n.name,"."]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Plan group"}),c.jsxs(Ge,{value:C.data.hub,onValueChange:S=>{C.setData(q=>({...q,hub:S,tier:""}))},children:[c.jsx(Ye,{children:c.jsx(Qe,{placeholder:"Select a plan group"})}),c.jsx(Xe,{children:t.map(S=>c.jsx(W,{value:S.hub,children:S.hubLabel},S.hub))})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Plan"}),c.jsxs(Ge,{value:C.data.tier,onValueChange:S=>C.setData("tier",S),disabled:!C.data.hub,children:[c.jsx(Ye,{children:c.jsx(Qe,{placeholder:"Select a plan"})}),c.jsx(Xe,{children:r==null?void 0:r.tiers.map(S=>c.jsx(W,{value:S.key,children:S.label},S.key))})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Start date"}),c.jsx(U,{type:"date",value:C.data.start_date,onChange:S=>C.setData("start_date",S.target.value)})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"End date"}),c.jsx(U,{type:"date",value:C.data.end_date,onChange:S=>C.setData("end_date",S.target.value)})]})]})]}),c.jsxs($t,{children:[c.jsx(B,{variant:"outline",onClick:()=>{a(!1),C.reset()},disabled:C.processing,children:"Cancel"}),c.jsx(B,{onClick:E,disabled:C.processing||!C.data.hub||!C.data.tier,children:C.processing?"Creating...":"Review plan"})]})]})}),c.jsx($n,{open:l,onOpenChange:d,children:c.jsxs(_n,{children:[c.jsxs(Bn,{children:[c.jsx(Hn,{children:"Confirm plan"}),c.jsxs(Vn,{children:["You are about to add a plan for ",c.jsx("strong",{children:n.name}),":"]})]}),c.jsxs("div",{className:"bg-muted space-y-2 rounded-lg p-4 text-sm",children:[i&&c.jsxs("p",{className:"text-amber-600",children:[c.jsx("strong",{children:"Current:"})," ",yn(i.type)," (",Kn(i.status).label,") â will be replaced"]}),c.jsxs("p",{children:[c.jsx("strong",{children:"Plan group:"})," ",r==null?void 0:r.hubLabel]}),c.jsxs("p",{children:[c.jsx("strong",{children:"Plan:"})," ",s]}),c.jsxs("p",{children:[c.jsx("strong",{children:"Period:"})," ",C.data.start_date," to ",C.data.end_date]})]}),c.jsxs(Fn,{children:[c.jsx(Wn,{children:"Cancel"}),c.jsx(Un,{onClick:P,children:"Add plan"})]})]})}),c.jsx(Rt,{open:!!y,onOpenChange:S=>!S&&k(null),children:c.jsxs(It,{children:[c.jsxs(Pt,{children:[c.jsx(Lt,{children:"Edit subscription"}),c.jsxs(zt,{children:["Update ",y?yn(y.type):""," subscription."]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Stripe subscription ID"}),c.jsx(U,{value:j.data.stripe_id,onChange:S=>j.setData("stripe_id",S.target.value),placeholder:"sub_... or manual_..."})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Status"}),c.jsxs(Ge,{value:j.data.stripe_status,onValueChange:S=>j.setData("stripe_status",S),children:[c.jsx(Ye,{children:c.jsx(Qe,{})}),c.jsxs(Xe,{children:[c.jsx(W,{value:"active",children:"Active"}),c.jsx(W,{value:"trialing",children:"Trialing"}),c.jsx(W,{value:"canceled",children:"Canceled"}),c.jsx(W,{value:"past_due",children:"Past due"})]})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Period start"}),c.jsx(U,{type:"date",value:j.data.start_date,onChange:S=>j.setData("start_date",S.target.value)})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Period end"}),c.jsx(U,{type:"date",value:j.data.end_date,onChange:S=>j.setData("end_date",S.target.value)})]})]})]}),c.jsxs($t,{children:[c.jsx(B,{variant:"outline",onClick:()=>k(null),disabled:j.processing,children:"Cancel"}),c.jsx(B,{onClick:H,disabled:j.processing,children:j.processing?"Saving...":"Save changes"})]})]})}),c.jsx(Rt,{open:u,onOpenChange:S=>{h(S),S||v.reset()},children:c.jsxs(It,{children:[c.jsxs(Pt,{children:[c.jsx(Lt,{children:"Allocate credits"}),c.jsxs(zt,{children:["Award credits to ",n.name,"."]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"bg-muted rounded-lg p-3 text-sm",children:["Current balance: ",c.jsx("strong",{children:n.creditBalance.toLocaleStr
185ing()})," credits"]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Amount"}),c.jsx(U,{type:"number",min:"1",step:"1",value:v.data.amount,onChange:S=>v.setData("amount",S.target.value),placeholder:"Enter credit amount"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Source"}),c.jsxs(Ge,{value:v.data.source,onValueChange:S=>v.setData("source",S),children:[c.jsx(Ye,{children:c.jsx(Qe,{placeholder:"Select a source"})}),c.jsxs(Xe,{children:[c.jsx(W,{value:"bonus",children:"Bonus"}),c.jsx(W,{value:"additional",children:"Additional"}),c.jsx(W,{value:"achievement",children:"Achievement"}),c.jsx(W,{value:"promo",children:"Promo"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Expiration"}),c.jsxs(Ge,{value:v.data.expiration,onValueChange:S=>{v.setData(q=>({...q,expiration:S,custom_expires_at:S==="custom"?q.custom_expires_at:""}))},children:[c.jsx(Ye,{children:c.jsx(Qe,{})}),c.jsxs(Xe,{children:[c.jsx(W,{value:"7",children:"7 days"}),c.jsx(W,{value:"14",children:"14 days"}),c.jsx(W,{value:"30",children:"1 month"}),c.jsx(W,{value:"60",children:"2 months"}),c.jsx(W,{value:"90",children:"3 months"}),c.jsx(W,{value:"180",children:"6 months"}),c.jsx(W,{value:"365",children:"1 year"}),c.jsx(W,{value:"never",children:"Never"}),c.jsx(W,{value:"custom",children:"Custom date"})]})]}),v.data.expiration==="custom"&&c.jsx(U,{type:"date",value:v.data.custom_expires_at,onChange:S=>v.setData("custom_expires_at",S.target.value),min:e})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Reason (optional)"}),c.jsx(Qi,{value:v.data.reason,onChange:S=>v.setData("reason",S.target.value),placeholder:"Reason for this allocation...",rows:3})]})]}),c.jsxs($t,{children:[c.jsx(B,{variant:"outline",onClick:()=>{h(!1),v.reset()},disabled:v.processing,children:"Cancel"}),c.jsx(B,{onClick:_,disabled:v.processing||!v.data.amount||!v.data.source,children:v.processing?"Allocating...":"Allocate credits"})]})]})}),c.jsx($n,{open:f,onOpenChange:p,children:c.jsxs(_n,{children:[c.jsxs(Bn,{children:[c.jsx(Hn,{children:"Confirm credit allocation"}),c.jsxs(Vn,{children:["You are about to allocate credits to ",c.jsx("strong",{children:n.name}),":"]})]}),c.jsxs("div",{className:"bg-muted space-y-2 rounded-lg p-4 text-sm",children:[c.jsxs("p",{children:[c.jsx("strong",{children:"Amount:"})," ",Number(v.data.amount).toLocaleString()," credits"]}),c.jsxs("p",{children:[c.jsx("strong",{children:"Source:"})," ",v.data.source.replace(/^\w/,S=>S.toUpperCase())]}),c.jsxs("p",{children:[c.jsx("strong",{children:"Expires:"})," ",v.data.expiration==="never"?"Never":v.data.expiration==="custom"?v.data.custom_expires_at:`In ${v.data.expiration} days`]}),v.data.reason&&c.jsxs("p",{children:[c.jsx("strong",{children:"Reason:"})," ",v.data.reason]}),c.jsxs("p",{className:"border-t pt-2",children:[c.jsx("strong",{children:"New balance:"})," ",(n.creditBalance+Number(v.data.amount)).toLocaleString()," credits"]})]}),c.jsxs(Fn,{children:[c.jsx(Wn,{children:"Cancel"}),c.jsx(Un,{onClick:Y,children:"Confirm"})]})]})}),c.jsx(Rt,{open:m,onOpenChange:S=>{g(S),S||w.reset()},children:c.jsxs(It,{children:[c.jsxs(Pt,{children:[c.jsx(Lt,{children:"Deduct credits"}),c.jsxs(zt,{children:["Remove credits from ",n.name,"."]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"bg-muted rounded-lg p-3 text-sm",children:["Current balance: ",c.jsx("strong",{children:n.creditBalance.toLocaleString()})," credits"]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Amount"}),c.jsx(U,{type:"number",min:"1",max:Math.max(n.creditBalance,1),step:"1",value:w.data.amount,onChange:S=>w.setData("amount",S.target.value),placeholder:"Enter credit amount"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(R,{children:"Reason"}),c.jsx(Qi,{value:w.data.reason,onChange:S=>w.setData("reason",S.target.value),placeholder:"Reason for this deduction...",rows:3})]})]}),c.jsxs($t,{children:[c.jsx(B,{variant:"outline",onClick:()=>{g(!1),w.reset()},disabled:w.processing,children:"Cancel"}),c.jsx(B,{variant:"destructive",onClick:Q,disabled:w.processing||!w.data.amount||!w.data.reason.trim(),children:w.processing?"Deducting...":"Deduct credits"})]})]})}),c.jsx($n,{open:x,onOpenChange:b,children:c.jsxs(_n,{children:[c.jsxs(Bn,{children:[c.jsx(Hn,{children:"Confirm credit deduction"}),c.jsxs(Vn,{children:["You are about to deduct credits from ",c.jsx("strong",{children:n.name}),":"]})]}),c.jsxs("div",{className:"bg-muted space-y-2 rounded-lg p-4 text-sm",children:[c.jsxs("p",{children:[c.jsx("strong",{children:"Amount:"}
185)," ",Number(w.data.amount).toLocaleString()," credits"]}),c.jsxs("p",{children:[c.jsx("strong",{children:"Reason:"})," ",w.data.reason]}),c.jsxs("p",{className:"border-t pt-2",children:[c.jsx("strong",{children:"New balance:"})," ",Math.max(n.creditBalance-Number(w.data.amount),0).toLocaleString()," ","credits"]})]}),c.jsxs(Fn,{children:[c.jsx(Wn,{children:"Cancel"}),c.jsx(Un,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Confirm deduction"})]})]})})]})}function tk({organization:n,onAllocateCredits:e,onDeductCredits:t,onManualSubscribe:r}){return c.jsx(gn,{title:"Current hub tiers",description:"Active service tier for each operational workspace.",action:c.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[c.jsxs(B,{size:"sm",variant:"outline",onClick:e,children:[c.jsx(Jf,{className:"mr-1 size-4"}),"Allocate credits"]}),c.jsxs(B,{size:"sm",variant:"outline",onClick:t,children:[c.jsx(Df,{className:"mr-1 size-4"}),"Deduct credits"]}),c.jsxs(B,{size:"sm",onClick:r,children:[c.jsx(Bs,{className:"mr-1 size-4"}),"Add plan"]})]}),children:c.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:[{label:"Sales Hub",tier:n.hubs.sales.tier},{label:"Marketing Hub",tier:n.hubs.marketing.tier},{label:"Source Partner Hub",tier:n.hubs.source_partner.tier}].map(s=>c.jsxs("div",{className:"flex items-center justify-between rounded-[var(--hub-radius-control)] border border-[var(--hub-border)] bg-[var(--hub-surface-subtle)] px-3 py-2.5",children:[c.jsx("span",{className:"text-sm text-[var(--hub-text)]",children:s.label}),c.jsx(en,{variant:Xi(s.tier).variant,className:Xi(s.tier).className,children:yn(s.tier)})]},s.label))})})}function nk({subscriptions:n,sortColumn:e,onToggleSort:t,formatTimestamp:r,onEditSubscription:s}){return c.jsx(Hr,{title:"Subscription records",description:"Active and past plan records for this organization.",count:`${n.length.toLocaleString()} ${n.length===1?"record":"records"}`,children:n.length===0?c.jsx(Ao,{icon:gc,title:"No subscription records",description:"Plans added to this organization will appear here with their status and billing period."}):c.jsxs(zs,{className:Rs,containerClassName:"bg-[var(--hub-surface)]",children:[c.jsx($s,{className:Is,children:c.jsxs(Mt,{className:Ps,children:[[{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"quantity",label:"Quantity"},{key:"periodStart",label:"Period"},{key:"trialEndsAt",label:"Trial Ends"},{key:"endsAt",label:"Cancels At"},{key:"createdAt",label:"Created"}].map(i=>c.jsx(Te,{className:je,children:c.jsxs(B,{variant:"ghost",size:"sm",className:"-ml-3 h-8",onClick:()=>t(i.key),children:[i.label,c.jsx(Rf,{className:`ml-1 h-3 w-3 ${e===i.key?"opacity-100":"opacity-50"}`})]})},i.key)),c.jsx(Te,{className:re(je,"w-10")})]})}),c.jsx(_s,{children:n.map(i=>c.jsxs(Mt,{className:Ls,children:[c.jsx(oe,{className:"font-medium",children:yn(i.type)}),c.jsx(oe,{children:c.jsx(en,{variant:Kn(i.status).variant,className:Kn(i.status).className,children:Kn(i.status).label})}),c.jsx(oe,{children:i.quantity??"-"}),c.jsx(oe,{className:"text-muted-foreground text-sm",children:i.periodStart&&i.periodEnd?`${r(i.periodStart)} â ${r(i.periodEnd)}`:"-"}),c.jsx(oe,{className:"text-muted-foreground text-sm",children:i.trialEndsAt?r(i.trialEndsAt):"-"}),c.jsx(oe,{className:"text-muted-foreground text-sm",children:i.endsAt?r(i.endsAt):"-"}),c.jsx(oe,{className:"text-muted-foreground text-sm",children:i.createdAt?r(i.createdAt):"N/A"}),c.jsx(oe,{children:c.jsxs(Do,{children:[c.jsx(Ro,{asChild:!0,children:c.jsx(B,{variant:"ghost",size:"sm",className:"size-8 p-0","aria-label":`Actions for ${yn(i.type)} subscription`,children:c.jsx(Oo,{className:"size-4"})})}),c.jsx(Io,{align:"end",children:c.jsxs(Je,{onClick:()=>s(i),children:[c.jsx(Lo,{className:"mr-2 size-4"}),"Edit subscription"]})})]})})]},i.id))})]})})}function rk({organization:n,subscriptions:e,availablePlans:t,organizationSlug:r,formatTimestamp:s}){var vr;const[i,o]=A.useState(!1),[a,l]=A.useState(!1),[d,u]=A.useState(!1),[h,f]=A.useState(!1),[p,m]=A.useState(!1),[g,x]=A.useState(!1),[b,y]=A.useState(null),[k,C]=A.useState("createdAt"),[v,w]=A.useState("desc"),j=bt({stripe_id:"",stripe_status:"",start_date:"",end_date:""}),E=wa(),P=wa(If(new Date,1)),_=bt({hub:"",tier:"",start_date:E,end_date:P}),Y=bt({amount:"",source:"",reason:"",expiration:"30",custom_expires_at:""}),Q=bt({amount:"",reason:""}),V=$=>{if(k===$){w(he=>he==="asc"?"desc":"asc");return}C($),w("asc")},H=A.useMemo(()=>[...e].sort(($,he)=>{const sn=$[k]??"",kr=he[k]??"",En=String(sn).localeCompare(String(kr));return v==="asc"?En:-En}),[k,v,e]),S=t.find($=>$.hub===_.data.hub),q=(vr=S==null?void 0:S.tiers.find($=>$.key===_.data.tier))==null?void 0:vr.label,_e=(_.data.hub?_.data.hub==="products"?e.find($=>$.type===_.data.tier&&["active","trialing"].includes($.status)):e.find($=>$.type.startsWith(_.data.hub+"_")&&["active","trialing"].includes($.status)):null)??null,Tn=()=>_.data.hub?_.data.tier?_.data.start_date?_.data.end_date?_.data.end_date<=_.data.start_date?"End date must be after start date.":null:"Please select an end date.":"Please select a start date.":"Please select a plan.":"Please select a plan group.",ri=()=>{const $=Tn();if($){J.error($);return}l(!0)},si=()=>{l(!1),_.post(Ph.url({organization:r,targetOrganization:n.slug}),{preserveScroll:!0,onSuccess:()=>{o(!1),_.reset(),J.success("Subscription created successfully.")},onError:$=>{const he=Object.values($).flat().join(" ");he&&J.error(he)}})},ii=()=>
185{if(!Y.data.amount||Number(Y.data.amount)<1){J.error("Please enter a valid amount.");return}if(!Y.data.source){J.error("Please select a source.");return}if(Y.data.expiration==="custom"&&!Y.data.custom_expires_at){J.error("Please select an expiration date.");return}f(!0)},oi=()=>{f(!1),Y.post(Ih.url({organization:r,targetOrganization:n.slug}),{preserveScroll:!0,onSuccess:()=>{u(!1),Y.reset(),J.success(`Allocated ${Y.data.amount} credits successfully.`)},onError:$=>{const he=Object.values($).flat().join(" ");he&&J.error(he)}})},ai=()=>{const $=Number(Q.data.amount);if(!Q.data.amount||$<1){J.error("Please enter a valid amount.");return}if($>n.creditBalance){J.error("Amount may not exceed the organization's current balance.");return}if(!Q.data.reason.trim()){J.error("Please provide a reason for this deduction.");return}x(!0)},li=()=>{x(!1);const $=Q.data.amount;Q.post(Rh.url({organization:r,targetOrganization:n.slug}),{preserveScroll:!0,onSuccess:()=>{m(!1),Q.reset(),J.success(`Deducted ${$} credits successfully.`)},onError:he=>{const sn=Object.values(he).flat().join(" ");sn&&J.error(sn)}})},ci=$=>{y($),j.setData({stripe_id:$.stripeId??"",stripe_status:$.status,start_date:$.periodStart?$.periodStart.split("T")[0]:"",end_date:$.periodEnd?$.periodEnd.split("T")[0]:""}),j.clearErrors()},di=()=>{b&&j.put(Dh.url({organization:r,targetOrganization:n.slug,subscription:b.id}),{preserveScroll:!0,onSuccess:()=>{y(null),j.reset(),J.success("Subscription updated successfully.")},onError:$=>{const he=Object.values($).flat().join(" ");he&&J.error(he)}})};return c.jsxs("div",{className:"space-y-4",children:[c.jsx(tk,{organization:n,onAllocateCredits:()=>u(!0),onDeductCredits:()=>m(!0),onManualSubscribe:()=>o(!0)}),c.jsx(nk,{subscriptions:H,sortColumn:k,onToggleSort:V,formatTimestamp:s,onEditSubscription:ci}),c.jsx(ek,{organization:n,today:E,availablePlans:t,selectedHubPlan:S,selectedTierLabel:q,currentHubSubscription:_e,showManualSubscribe:i,setShowManualSubscribe:o,showSubscribeConfirm:a,setShowSubscribeConfirm:l,showAllocateCredits:d,setShowAllocateCredits:u,showAllocateConfirm:h,setShowAllocateConfirm:f,showDeductCredits:p,setShowDeductCredits:m,showDeductConfirm:g,setShowDeductConfirm:x,editingSubscription:b,setEditingSubscription:y,subscribeForm:_,allocateForm:Y,deductForm:Q,editForm:j,onSubscribeClick:ri,onManualSubscribe:si,onAllocateClick:ii,onAllocateCredits:oi,onDeductClick:ai,onDeductCredits:li,onEditSubscription:di})]})}function sk({data:n}){return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-6",children:[c.jsx(un,{title:"Current Balance",value:n.currentBalance.toLocaleString(),color:"text-foreground"}),c.jsx(un,{title:"Total Earned",value:n.totalEarned.toLocaleString(),color:"text-green-600"}),c.jsx(un,{title:"Total Used",value:Math.abs(n.totalUsed).toLocaleString(),color:"text-blue-600"}),c.jsx(un,{title:"Total Purchased",value:n.totalPurchased.toLocaleString(),color:"text-purple-600"}),c.jsx(un,{title:"Total Refunded",value:n.totalRefunded.toLocaleString(),color:"text-amber-600"}),c.jsx(un,{title:"Total Expired",value:Math.abs(n.totalExpired).toLocaleString(),color:"text-red-600"})]}),n.topUsageByFeature.length>0&&c.jsxs("div",{className:re(sr,"p-4"),children:[c.jsx("span",{className:"mb-3 block text-sm font-semibold text-[var(--hub-text)]",children:"Top Credit Usage by Feature"}),c.jsxs(zs,{className:Rs,containerClassName:"bg-[var(--hub-surface)]",children:[c.jsx($s,{className:Is,children:c.jsxs(Mt,{className:Ps,children:[c.jsx(Te,{className:je,children:"Feature"}),c.jsx(Te,{className:re(je,"text-right"),children:"Credits Used"})]})}),c.jsx(_s,{children:n.topUsageByFeature.map(e=>c.jsxs(Mt,{className:Ls,children:[c.jsx(oe,{className:"text-sm capitalize",children:e.feature.replace(/_/g," ")}),c.jsx(oe,{className:"text-right text-sm font-medium",children:Math.abs(e.amount).toLocaleString()})]},e.feature))})]})]})]})}function un({title:n,value:e,color:t}){return c.jsx(uc,{label:n,value:e,valueClassName:t})}function ik({data:n}){return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[c.jsx(Pr,{title:"Companies Accessed",value:n.companiesAccessed.toLocaleStr
185ing()}),c.jsx(Pr,{title:"People Accessed",value:n.peopleAccessed.toLocaleString()}),c.jsx(Pr,{title:"Saved Lists",value:n.savedLists.toLocaleString()}),c.jsx(Pr,{title:"Saved Searches",value:n.savedSearches.toLocaleString()})]}),c.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[c.jsxs("div",{className:re(sr,"p-4"),children:[c.jsx("span",{className:"mb-3 block text-sm font-semibold text-[var(--hub-text)]",children:"Email Campaigns"}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(Be,{label:"Active",value:n.engageCampaigns.active,color:"text-green-600"}),c.jsx(Be,{label:"Draft",value:n.engageCampaigns.draft,color:"text-[var(--hub-text-muted)]"}),c.jsx(Be,{label:"Paused",value:n.engageCampaigns.paused,color:"text-amber-600"}),c.jsx(Be,{label:"Completed",value:n.engageCampaigns.completed,color:"text-blue-600"})]})]}),c.jsxs("div",{className:re(sr,"p-4"),children:[c.jsx("span",{className:"mb-3 block text-sm font-semibold text-[var(--hub-text)]",children:"Call Campaigns"}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(Be,{label:"Active",value:n.callCampaigns.active,color:"text-green-600"}),c.jsx(Be,{label:"Draft",value:n.callCampaigns.draft,color:"text-[var(--hub-text-muted)]"}),c.jsx(Be,{label:"Paused",value:n.callCampaigns.paused,color:"text-amber-600"}),c.jsx(Be,{label:"Completed",value:n.callCampaigns.completed,color:"text-blue-600"})]})]})]})]})}function ok({data:n,companyPage:e}){const t=ak(e),r=lk(n.bannerAds),s=ck(n.sourceTrack);return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[c.jsx(Ki,{title:"Company Profile",badge:t.badge,badgeActive:t.active,headline:t.headline,subtitle:t.subtitle}),c.jsx(Ki,{title:"Banner Ad",badge:r.badge,badgeActive:r.active,headline:r.headline,subtitle:r.subtitle}),c.jsx(Ki,{title:"Source Track",badge:s.badge,badgeActive:s.active,headline:s.headline,subtitle:s.subtitle})]}),c.jsxs("div",{className:re(sr,"p-4"),children:[c.jsx("span",{className:"mb-3 block text-sm font-semibold text-[var(--hub-text)]",children:"Content Submissions"}),c.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[c.jsx(Be,{label:"Published",value:n.contentSubmissions.published,color:"text-green-600"}),c.jsx(Be,{label:"Pending",value:n.contentSubmissions.pending,color:"text-amber-600"}),c.jsx(Be,{label:"Rejected",value:n.contentSubmissions.rejected,color:"text-red-600"})]})]})]})}function ak(n){var e;return n?n.isPublished&&n.claimStatus==="approved"&&((e=n.oaCompanySlug)!=null&&e.trim())?{badge:"Active",active:!0,headline:"Published",subtitle:"Profile is live and approved"}:n.isPublished&&n.claimStatus==="approved"?{badge:"Needs attention",active:!1,headline:"Link unavailable",subtitle:"Approved profile is missing its OA company slug"}:n.claimStatus==="pending"?{badge:"Needs attention",active:!1,headline:"Pending",subtitle:"Claim awaiting approval"}:{badge:"Needs attention",active:!1,headline:"Incomplete",subtitle:"Profile not yet published"}:{badge:"Not created",active:!1,headline:"Inactive",subtitle:"No company profile set up"}}function lk(n){return n.total===0?{badge:"Not set up",active:!1,headline:"Inactive",subtitle:"No banner uploaded"}:n.active>0?{badge:"Active",active:!0,headline:`${n.active} Active`,subtitle:`${n.total} total banner${n.total!==1?"s":""}`}:{badge:"Inactive",active:!1,headline:"Inactive",subtitle:`${n.total} banner${n.total!==1?"s":""} uploaded`}}function ck(n){return n.status==="active"?{badge:"Active",active:!0,headline:`${n.uniqueVisitors24h.toLocaleString()} visitors (24h)`,subtitle:n.lastEventAt?`Last event: ${new Date(n.lastEventAt).toLocaleDateString()}`:"Receiving events"}:n.status==="inactive"?{badge:"Inactive",active:!1,headline:"No recent activity",subtitle:n.lastEventAt?`Last event: ${new Date(n.lastEventAt).toLocaleDateString()}`:"Script installed but no recent events"}:{badge:"Not installed",active:!1,headline:"Never seen",subtitle:"Tracking script not detected"}}function Ki({title:n,badge:e,badgeActive:t,headline:r,subtitle:s}){return c.jsxs("div",{className:re("flex flex-col gap-3 p-5",sr),children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm font-semibold text-[var(--hub-text)]",children:n}),c.jsx(en,{variant:t?"default":"outline",className:t?"bg-green-100 text-green-800":"",children:e})]}),c.jsx("span",{className:"text-2xl font-semibold text-[var(--hub-text)]",children:r}),c.jsx("span",{className:"text-muted-foreground text-sm",children:s})]})}function Pr({title:n,value:e}){return c.jsx(uc,{label:n,value:e})}function Be({label:n,value:e,color:t}){return c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:"text-xs text-[var(--hub-text-muted)]",children:n}),c.jsx("span",{className:`text-lg font-bold ${t}
185`,children:e.toLocaleString()})]})}function dk({creditSummary:n,usageStats:e,companyPage:t}){return c.jsxs("div",{className:"space-y-8",children:[c.jsxs("section",{"aria-labelledby":"platform-credit-heading",className:"space-y-3",children:[c.jsxs("div",{children:[c.jsx("h2",{id:"platform-credit-heading",className:hi,children:"Platform credits"}),c.jsx("p",{className:fi,children:"Balance movement and the features consuming this organizationâs credits."})]}),c.jsx(sk,{data:n})]}),c.jsxs("section",{"aria-labelledby":"sales-activity-heading",className:"space-y-3 border-t border-[var(--hub-border)] pt-6",children:[c.jsxs("div",{children:[c.jsx("h2",{id:"sales-activity-heading",className:hi,children:"Sales activity"}),c.jsx("p",{className:fi,children:"Current prospecting access, saved work, and campaign activity."})]}),c.jsx(ik,{data:e})]}),c.jsxs("section",{"aria-labelledby":"marketing-activity-heading",className:"space-y-3 border-t border-[var(--hub-border)] pt-6",children:[c.jsxs("div",{children:[c.jsx("h2",{id:"marketing-activity-heading",className:hi,children:"Marketing activity"}),c.jsx("p",{className:fi,children:"Company profile readiness, campaign assets, tracking, and content submissions."})]}),c.jsx(ok,{data:e,companyPage:t})]})]})}function qi(){return c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:Array.from({length:4}).map((n,e)=>c.jsxs("div",{className:"border-border/70 bg-background rounded-[var(--hub-radius-surface)] border p-4",children:[c.jsx(mi,{className:"mb-3 h-4 w-24"}),c.jsx(mi,{className:"h-8 w-16"})]},e))}),c.jsx(mi,{className:"border-border/70 h-32 w-full rounded-[var(--hub-radius-surface)] border"})]})}function B1(){var kr,En;const n=pc(),{organization:e,members:t,subscriptions:r,companyPage:s,availablePlans:i,usageStats:o,creditSummary:a,activityLog:l,sourcePartnerSettings:d}=zf(),h=new URLSearchParams(window.location.search).get("tab")??"overview",f=["overview","members","subscriptions","usage","activity","settings"].includes(h)?h:"overview",[p,m]=A.useState(f),[g,x]=A.useState(!1),b=A.useCallback(ie=>x(ie),[]),y=ie=>hc(ie,e.timezone,fc.DATETIME_FULL),[k,C]=A.useState(null),v=bt({password:""}),[w,j]=A.useState(null),E=bt({email:""}),[P,_]=A.useState(null),[Y,Q]=A.useState(null),[V,H]=A.useState(null),[S,q]=A.useState(!1),[_e,Tn]=A.useState(!1),ri=bt({wp_post_id:((kr=s==null?void 0:s.wpPostId)==null?void 0:kr.toString())??"",oa_company_slug:(s==null?void 0:s.oaCompanySlug)??""}),si=ie=>{C(ie),v.reset(),v.clearErrors()},ii=ie=>{j(ie),E.setData("email",ie.user.email),E.clearErrors()},oi=()=>{k&&v.post(Lh.url({organization:n,targetOrganization:e.slug,user:k.user.uuid}),{preserveState:!0,preserveScroll:!0,onSuccess:()=>{C(null),v.reset()}})},ai=()=>{if(!w)return;const ie=w;E.post(zh.url({organization:n,targetOrganization:e.slug,user:ie.user.uuid}),{preserveState:!0,preserveScroll:!0,onSuccess:()=>{j(null),E.reset()},onError:ui=>{j(ie);const Ca=Object.values(ui).flat().join(" ");Ca&&J.error(Ca)}})},li=()=>{if(!V)return;const ie=V==="approve"?$h.url({organization:n,targetOrganization:e.slug}):_h.url({organization:n,targetOrganization:e.slug});mt.post(ie,{},{preserveScroll:!0,onSuccess:()=>H(null)})},ci=()=>{mt.post(Bh.url({organization:n,targetOrganization:e.slug}),{},{preserveScroll:!0,onFinish:()=>Tn(!1)})},di=()=>{P&&mt.delete(Hh.url({organization:n,targetOrganization:e.slug,user:P.user.uuid}),{preserveState:!0,preserveScroll:!0,onFinish:()=>_(null)})},vr=()=>{Y&&mt.delete(Vh.user.destroy.url({organization:n,targetOrganization:e.slug,user:Y.user.uuid}),{preserveState:!0,preserveScroll:!0,onFinish:()=>Q(null)})},$=[{title:"Admin",href:ja.url(n)},{title:"Organizations",href:ja.url(n)},{title:e.name,href:Ta.url({organization:n,targetOrganization:e.slug})}],he=Kn(e.status),sn=ie=>{if(p==="settings"&&g){J.error("Save Source Partner settings before leaving this tab.");return}ie!=="settings"&&m(ie);const ui={overview:["companyPage"],members:["members"],subscriptions:["subscriptions","availablePlans"],usage:["companyPage","usageStats","creditSummary"],activity:["activityLog"],settings:["sourcePartnerSettings"]};mt.get(Ta.url({organization:n,targetOrganization:e.slug}),{tab:ie},{preserveState:!0,preserveScroll:!0,replace:!0,only:ui[ie]??[],onSuccess:()=>{ie==="settings"&&m(ie)}})};return c.jsxs(wh,{breadcrumbs:$,children:[c.jsx(xh,{title:`${e.name} - Admin`}),c.jsxs(bh,{children:[c.jsx(yh,{title:e.name,description:"Monitor account health, access, services, and administrative activity.",actions:c.jsxs(B,{size:"sm",onClick:()=>Tn(!0),className:re(Z,"gap-2"),children:[c.jsx($f,{className:"h-4 w-4"}),"Access organization"]}),meta:c.jsxs(c.Fragment,{children:[c.jsx(en,{variant:he.variant,className:he.className,children:he.label}),c.jsxs("span",{children:["ID: ",e.slug]}),c.jsxs("span",{children:["Owner: ",((En=e.owner)==null?void 0:En.name)??"Unassigned"]}),c.jsx("span",{title:e.timezone,children:Ji(e.timezone)})]})}),c.jsxs(Pf,{value:p,onValueChange:sn,className:"flex min-h-0 flex-1 flex-col gap-3",children:[c.jsx(dc,{className:"overflow-hidden px-3 py-2",children:c.jsxs(Lf,{className:"h-9 min-w-full justify-start gap-2 overflow-x-auto rounded-none bg-transparent p-0",children:[c.jsxs(an,{value:"overview",className:on,children:[c.jsx(_f,{className:"h-4 w-4"}),"Overview"]}),c.jsxs(an,{value:"members",className:on,children:[c.jsx(Mh,{className:"h-4 w-4"}
185),"Members (",e.memberCount.toLocaleString(),")"]}),c.jsxs(an,{value:"subscriptions",className:on,children:[c.jsx(gc,{className:"h-4 w-4"}),"Plans & credits"]}),c.jsxs(an,{value:"usage",className:on,children:[c.jsx(Bf,{className:"h-4 w-4"}),"Usage"]}),c.jsxs(an,{value:"activity",className:on,children:[c.jsx(wc,{className:"h-4 w-4"}),"Activity"]}),c.jsxs(an,{value:"settings",className:on,children:[c.jsx(Nc,{className:"h-4 w-4"}),"Settings"]})]})}),c.jsxs(ln,{value:"overview",className:"mt-0 space-y-4",children:[c.jsx(np,{organization:e}),c.jsx(sp,{organization:e,companyPage:s,formatTimestamp:y,onEditCompanyPage:()=>q(!0),onCompanyPageAction:H})]}),c.jsx(ln,{value:"members",className:"mt-0",children:c.jsx(rp,{members:t,organization:e,organizationSlug:n,formatTimestamp:y,onResetPassword:si,onChangeEmail:ii,onRemoveMember:_,onDeleteMemberUser:Q})}),c.jsx(ln,{value:"subscriptions",className:"mt-0 space-y-4",children:c.jsx(rk,{organization:e,subscriptions:r,availablePlans:i,organizationSlug:n,formatTimestamp:y})}),c.jsx(ln,{value:"usage",className:"mt-0",children:c.jsx(Na,{data:["creditSummary","usageStats"],fallback:c.jsx(qi,{}),children:c.jsx(dk,{creditSummary:a,usageStats:o,companyPage:s})})}),c.jsx(ln,{value:"activity",className:"mt-0",children:c.jsx(Na,{data:"activityLog",fallback:c.jsx(qi,{}),children:c.jsx(ep,{data:l,timezone:e.timezone})})}),c.jsx(ln,{value:"settings",className:"mt-0",children:d?c.jsx(Z0,{organization:e,organizationSlug:n,sourcePartnerSettings:d,hasUnsavedPartnerChanges:g,onPartnerDirtyChange:b}):c.jsx(qi,{})})]}),c.jsx(tp,{organization:e,organizationSlug:n,resetPasswordMember:k,setResetPasswordMember:C,passwordForm:v,onResetPassword:oi,changeEmailMember:w,setChangeEmailMember:j,emailForm:E,onChangeEmail:ai,removeMember:P,setRemoveMember:_,onConfirmRemoveMember:di,deleteMemberUser:Y,setDeleteMemberUser:Q,onConfirmDeleteMemberUser:vr,companyPageAction:V,setCompanyPageAction:H,onConfirmCompanyPageAction:li,showEditCompanyPage:S,setShowEditCompanyPage:q,companyPageForm:ri}),c.jsx($n,{open:_e,onOpenChange:Tn,children:c.jsxs(_n,{children:[c.jsxs(Bn,{children:[c.jsxs(Hn,{children:["Access ",e.name,"?"]}),c.jsx(Vn,{children:"You will stay logged in as your admin user and enter this organization with elevated admin access. Your actions will be attributed to your admin account."})]}),c.jsxs(Fn,{children:[c.jsx(Wn,{children:"Cancel"}),c.jsx(Un,{onClick:ci,children:"Access organization"})]})]})})]})]})}export{B1 as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.