1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CFAvyuXu.js","assets/vendor-motion-CPxq9Xvn.js","assets/vendor-i18n-CO3kK2bH.js","assets/vendor-react-CQmBMThG.js","assets/index-Vgzltf6D.css"])))=>i.map(i=>d[i]); 2import{n as jt,bH as Lg,aq as zg,es as Bg,D as hh,q as ph,aj as fh,r as mh,al as gh,S as oe,K as _a,et as $g,eu as _g,e as Hg,N as yi,ev as Fg,z as Vg,ap as it,A as xh,f as tn,V as qg,a9 as K,ew as Kg,a3 as ws,ai as Kn,u as Ce,a6 as Ae,an as G,dC as zr,dE as Br,ee as Ha,ef as Fa,a7 as ge,B as Y,C as Mn,aT as Wg,aI as Or,as as bh,a4 as rs,aJ as Ug,X as vi,aF as H,k as yh,ex as Jg,ey as vh,ez as wh,eA as kh,eB as Nh,eC as Sh,eD as Ch,eE as jh,eF as Th,eG as Mh,av as hr,ei as Gg,d$ as Eh,J as Qg,ao as Rt,az as sd,v as zt,eH as Yg,eI as Xg,eJ as Zg,ed as ex,a1 as Ah,aS as tx,h as Oh,P as wi,a2 as nx,R as Ih,ar as id,eK as tr,Y as nn,a as rx,b as sx,dD as od,aU as ad,eL as ix,l as ox,Z as ld}from"./index-CFAvyuXu.js";import{j as c,m as se,A as Ph}from"./vendor-motion-CPxq9Xvn.js";import{r as v,u as ho,s as Rh,R as Vt}from"./vendor-i18n-CO3kK2bH.js";import{S as ax}from"./scroll-area-nONWKjQR.js";import{H as Dh}from"./history-XBJ1h-Ju.js";import{F as rn}from"./file-text-DjkUcFVd.js";import{R as lx}from"./rotate-ccw-yv6DhBa4.js";import{C as cx}from"./circle-alert-CixghSwT.js";import{L as dx,G as ux}from"./generation-services-showcase-9mGH4LZB.js";import{M as hx,u as px}from"./mobile-pipeline-bar-wnI4Ws72.js";import{B as ar}from"./badge-B9GAfHbC.js";import{C as Va}from"./checkout-dialog-CtPFKUrs.js";import{P as Nt}from"./pricing-CEwbcjb3.js";import{D as qa}from"./download-B7FtiUYJ.js";import{U as Ka}from"./upload-BKNIN1AN.js";import{L as fx,K as mx}from"./knowledge-base-CMYZ0tCn.js";import{S as cd,a as dd,b as ud,c as hd,d as nr}from"./select-B26x0xAv.js";import{B as Gt}from"./brain-circuit-BiacJsPX.js";import{B as gx}from"./book-open-check-CQEzGy60.js";import{W as xx}from"./wand-sparkles-BFRdHggN.js";import{T as jn}from"./trash-2-BF2rPJAw.js";import{S as Lh}from"./save-QXxXVhhp.js";import{P as pd}from"./publication-pipeline-DFwPsRBR.js";import{g as bx,a as yx}from"./bookLabels-rub_prgO.js";import{f as zh,g as Bh}from"./pricing-BgVC2Us6.js";import{d as vx}from"./index-C7yKKq-w.js";import{w as wx,B as fd,I as md,R as kx}from"./with-selector-n3JMSqp4.js";import{L as Nx}from"./list-CnISzF7H.js";import{d as rr}from"./editorialDownload-CShCKB7l.js";import{P as Sx}from"./printer-Bblh7pWy.js";import{P as Ir}from"./pen-tool-Cta8E7eR.js";import{A as Cx}from"./arrow-left-DY50GvQQ.js";import{S as jx}from"./shield-alert-CdUhQ0gg.js";import{P as Qt}from"./pencil-DB7EhnQs.js";import{F as sr}from"./file-down-BbTFeZ9G.js";import{L as Tx}from"./lightbulb-BvSG_Icx.js";import{E as Mx}from"./ellipsis-vertical-0l79KCRs.js";import{M as Ex}from"./megaphone-CJoAWoYP.js";import{G as Ax}from"./globe-D0MKCb1Y.js";import{T as Ox}from"./trophy-Bk4C1tet.js";import"./vendor-react-CQmBMThG.js";import"./index-BdQq_4o_.js";import"./pen-line-CUCmRVJi.js";import"./circle-pause-B5v17gJf.js";import"./feather-BNvr0Xjc.js";import"./list-checks-EUoF5j-U.js";import"./book-marked-3-KNVwiq.js";import"./barcode-DlYH0ciP.js";import"./pix-qr-image-D45mJvPS.js";import"./wifi-BvXiCCFP.js";import"./tabs-DIYA7-w6.js";import"./progress-C8e5qZ5Y.js";import"./audio-waveform-player-CIVAPqgh.js";import"./square-BbghycB9.js";import"./arrow-up-VV5eJn02.js";import"./arrow-down-CKXfmsWg.js";import"./alert-dialog-C9feqA9b.js";import"./stamp-BZO_gJDT.js";const Ix=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]],Px=jt("circle-arrow-down",Ix);const Rx=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],Dx=jt("circle-arrow-up",Rx);const Lx=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],gd=jt("circle-plus",Lx);const zx=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Bx=jt("columns-3",zx);const $x=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],_x=jt("heading-1",$x);const Hx=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}
2]],xd=jt("heading-2",Hx);const Fx=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],Vx=jt("heading-3",Fx);const qx=[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]],bd=jt("list-tree",qx);const Kx=[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]],Wx=jt("pilcrow",Kx);const Ux=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],Jx=jt("rows-3",Ux),Gx={};function Qx({open:t,onOpenChange:e,onConfirm:n,bookId:r,bookTitle:s}){Lg(t);const[i,o]=v.useState(null),[a,l]=v.useState(!1),[d,u]=v.useState("book_generation"),{formatPrice:h}=zg(),{t:p}=ho("checkout"),f=Nt.book_generation,m=Nt.apice_automated_v1,g=Nt.publish_bundle,b=Nt.publish_bundle_original,y=Math.round((1-g/b)*100),k=X=>h(Math.round(X*100)),C=p("planSelector.apiceOutcome","Seu livro pronto para ser encontrado e lido"),j=p("planSelector.apiceAutomation","Tudo automatizado"),O=p("planSelector.apicePromise","Pague e veja seu livro publicado na ÃPICE Books em menos de 1 hora"),S=[p("planSelector.fApiceBook","Livro escrito"),p("planSelector.fApiceCover","Capa profissional"),p("planSelector.fApicePublish","Publicação ÃPICE Books"),p("planSelector.fApiceSalesPage","Página de vendas"),p("planSelector.fApiceReader","App de Leitura")],N=p("planSelector.bundlePremiumSummary","4 capas + ilustrações + kit Amazon + marketing"),P=Gx?.VITE_PAYWALL_V2!=="false",D=Kg(),{data:L}=Bg(),J=X=>{X==="book"?(u("book_generation"),o({title:p("planSelector.prodBookTitle",{defaultValue:'Texto do Livro â "{{title}}"',title:s||""}),price:f,originalPrice:99.99,description:p("planSelector.prodBookDesc","O texto completo do seu livro, escrito pelo time editorial SÃBHIA."),subtitle:p("planSelector.prodBookSubtitle","Só o texto do livro"),features:[p("planSelector.fManuscript","Manuscrito completo com todos os capÃtulos"),p("planSelector.fStyle","Estilo e tom personalizados ao seu gênero"),p("planSelector.fEditorial","Revisão editorial SÃBHIA"),p("planSelector.fFiles","PDF, DOCX e EPUB inclusos"),p("planSelector.fRights","100% dos direitos autorais são seus")]})):X==="apice"?(u("apice_automated_v1"),o({title:p("planSelector.prodApiceTitle",{defaultValue:'Pacote ÃPICE â "{{title}}"',title:s||""}),price:m,description:O,subtitle:`${C} · ${j}`,features:S})):(u("publish_bundle"),o({title:p("planSelector.prodBundleTitle",{defaultValue:'Pacote Completo â "{{title}}"',title:s||""}),price:g,originalPrice:b,description:p("planSelector.prodBundleDesc","Tudo do Pacote ÃPICE mais capas, ilustrações e materiais premium para Amazon e divulgação."),subtitle:p("planSelector.prodBundleSubtitle","A experiência mais completa da SÃBHIA"),features:[...S,p("planSelector.fCovers4","4 opções de capa profissional SÃBHIA"),p("planSelector.fIllustration","1 ilustração exclusiva por capÃtulo"),p("planSelector.fKdpKit","Kit de publicação Amazon (ISBN, sinopse, metadados)"),p("planSelector.fMktKit","Kit de marketing completo (posts, stories, banners)"),p("planSelector.fEditorial","Revisão editorial SÃBHIA"),p("planSelector.fFiles","PDF, DOCX e EPUB inclusos"),p("planSelector.fRights","100% dos direitos autorais são seus"),p("planSelector.fBundleSavings",{defaultValue:"Economia de {{pct}}% no pacote",pct:y})]})),e(!1),setTimeout(()=>l(!0),150)},Ee=X=>{X||l(!1)},le=X=>{l(!1),n(X)},ce=s?s.length>50?s.slice(0,47)+"...":s:p("planSelector.yourBook","Seu livro"),ne=[{label:S[0],book:!0,cover:!0,bundle:!0,group:"livro"},{label:p("planSelector.cmpChapters","CapÃtulos estruturados pelo time editorial SÃBHIA"),book:!0,cover:!0,bundle:!0,group:"livro"},{label:p("planSelector.fStyle","Estilo e tom personalizados ao seu gênero"),book:!0,cover:!0,bundle:!0,group:"livro"},{label:p("planSelector.cmpEditorial","Revisão editorial automatizada"),book:!0,cover:!0,bundle:!0,group:"livro"},{label:p("planSelector.cmpFiles","Arquivos PDF, DOCX e EPUB inclusos"),book:!0,cover:!0,bundle:!0,group:"livro"},{label:p("planSelector.fRights","100% dos direitos autorais são seus"),book:!0,cover:!0,bundle:!0,group:"livro"},{label:S[1],book:!1,cover:!0,bundle:!0,group:"apice"},{label:S[2],book:!1,cover:!0,bundle:!0,group:"apice"},{label:S[3],book:!1,cover:!0,bundle:!0,group:"apice"},{label:S[4],book:!1,cover:!0,bundle:!0,group:"apice"},{label:C,book:!1,cover:!0,bundle:!0,group:"apice"},{label:j,book:!1,cover:!0,bundle:!0,group:"apice"},{label:O,book:!1,cover:!0,bundle:!0,group:"apice"},{label:p("planSelector.cmpCovers","4 opções de capa profissional pela SÃBHIA"),book:!1,cover:!1,bundle:!0,group:"capa"},{label:p("planSelector.cmpCoverKdp","Capa pronta para publicar na Amazon KDP"),book:!1,cover:!1,bundle:!0,group:"capa"},{label:p("planSelector.fIllustration","1 ilustração exclusiva por capÃtulo"),book:!1,cover:!1,bundle:!0,group:"ilustracoes"},{label:p("planSelector.cmpArtStyle","Estilo artÃstico personalizado ao seu livro"),book:!1,cover:!1,bundle:!0,group:"ilustracoes"},{label:p("planSelector.cmpIsbnGuide","Guia passo a passo pra você registrar seu ISBN (o registro em si é serviço à parte)"),book:!1,cover:!1,bundle:!0,group:"publicacao"},{label:p("planSelector.cmpSynopsis","Sinopse profissional escrita pela SÃBHIA"),book:!1,cover:!1,bundle:!0,group:"publicacao"},{label:p("planSelector.cmpMetadata","Metadados otimizados para ranqueamento Amazon"),book:!1,cover:!1,bundle:!0,group:"publicacao"},{label:p("planSelector.cmpKeywords","Categorias e palavras-chave de bestseller"),book:!1,cover:!1,bundle:!0,group:"publicacao"},{label:p("planSelector.cmpInstaPosts","Kit completo de posts para Instagram"),book:!1,cover:!1,bundle:!0,group:"marketing"},{label:p("planSelector.cmpBanners","Banners e capas para redes sociais"),book:!1,cover:!1,bundle:!0,group:"marketing"},{label:p("planSelector.cmpStories","Stories prontos para divulgar"),book:!1,cover:!1,bundle:!0,group:"marketing"},{label:p("planSelector.cmpEmails","Sequência de e-mail para seus leitores"),book:!1,cover:!1,bundle:!0,group:"marketing"}];return c.jsxs(c.Fragment,{children:[c.jsx(hh,{open:t,onOpenChange:e,children:c.jsxs(ph,{className:"bg-gradient-to-b from-[#0c0c10] via-[#101015] to-[#0a0a0e] border-white/10 text-white w-[calc(100%_-_1rem)] sm:w-[96%] sm:max-w-[920px] p-0 overflow-hidden gap-0 max-h-[calc(100dvh_-_1rem)] sm:max-h-[92dvh] flex flex-col rounded-2xl shadow-2xl shadow-emerald-500/10 [&>button]:z-30 [&>button]:right-3 [&>button]:top-3 [&>button]:m-0 [&>button]:w-11 [&>button]:h-11 [&>button]:p-0 [&>button]:rounded-full [&>button]:border [&>button]:border-white/15 [&>button]:bg-[#17171d]/95 [&>button]:text-white [&>button]:opacity-100","data-testid":"dialog-plan-selector",children:[c.jsxs(fh,{className:"sr-only",children:[c.jsx(mh,{children:p("planSelector.srTitle","Escolha seu plano")}),c.jsx(gh,{children:p("planSelector.srDesc","Selecione como quer publicar seu livro")})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto",children:[c.jsxs("div",{className:"relative px-4 pr-14 pt-6 pb-3 sm:px-6 sm:pt-7 sm:pb-4 text-center",children:[c.jsx("div",{className:"absolute inset-x-0 top-0 h-32 bg-[radial-gradient(circle_at_50%_0%,rgba(16,185,129,0.18),transparent_70%)] pointer-events-none"}),c.jsxs("div",{className:"relative inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-amber-500/10 border border-amber-500/20 mb-2.5",children:[c.jsx(oe,{className:"w-3 h-3 text-amber-400"}),c.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-amber-300 uppercase tracking-wide",children:p("planSelector.badgeReady","Seu plano está pronto")})]}),c.jsx("h2",{className:"text-lg sm:text-2xl font-bold text-white font-heading leading-tight","data-testid":"text-plan-selector-title",children:p("planSelector.title","Falta 1 passo pro seu livro nascer")}),c.jsxs("p",{className:"text-xs sm:text-sm text-zinc-400 mt-1.5 px-2 italic",title:s,children:['"',ce,'"']})]}),P&&c.jsxs("div",{className:"px-3 sm:px-6 mb-1","data-testid":"paywall-trust-bar",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[c.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-emerald-500/[0.08] border border-emerald-500/20",children:[c.jsx(_a,{className:"w-3.5 h-3.5 text-emerald-400 shrink-0"}),c.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-emerald-200/90 leading-tight",children:p("planSelector.editorialIncluded","Revisão editorial inclusa")})]}),c.jsx("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-amber-500/[0.08] border border-amber-500/20",children:D&&$g(L)?c.jsx(_g,{data:L}):c.jsxs(c.Fragment,{children:[c.jsx(Hg,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400/40 shrink-0"}),c.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-amber-200/90 leading-tight",children:p("planSelector.authorsPublished","Autores de todo o Brasil já publicaram")})]})}),c.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-white/[0.04] border border-white/10",children:[c.jsx(yi,{className:"w-3.5 h-3.5 text-zinc-300 shrink-0"}),c.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-zinc-300 leading-tight",children:p("planSelector.securePayment100","Pagamento 100% seguro")})]})]}),D&&c.jsx(Fg,{data:L,limit:2,className:"mt-2 max-w-2xl mx-auto"})]}),c.jsxs("div",{className:"px-3 sm:px-6 pt-2 pb-3",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-[minmax(0,.9fr)_minmax(0,1.2fr)_minmax(0,.9fr)] sm:gap-4 items-stretch",children:[c.jsxs(se.button,{type:"button",whileTap:{scale:.985},onClick:()=>J("apice"),className:"relative col-span-2 sm:col-span-1 sm:col-start-2 sm:row-start-1 rounded-2xl border-2 border-emerald-300/70 bg-gradient-to-br from-emerald-500/[0.24] via-teal-500/[0.12] to-emerald-500/[0.05] hover:from-emerald-500/[0.30] hover:via-teal-500/[0.16] hover:border-emerald-200 transition-all p-4 sm:p-5 text-left group flex flex-col items-stretch shadow-xl shadow-emerald-500/15 focu
2s-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-200 focus-visible:ring-offset-2 focus-visible:ring-offset-[#101015]","data-testid":"plan-book-and-cover",children:[c.jsx("div",{className:"absolute -top-3 left-1/2 -translate-x-1/2",children:c.jsxs("div",{className:"bg-gradient-to-r from-emerald-300 via-teal-300 to-emerald-300 text-emerald-950 text-[10px] px-3 py-1 rounded-full shadow-lg shadow-emerald-500/40 font-extrabold uppercase tracking-wide whitespace-nowrap flex items-center gap-1",children:[c.jsx(oe,{className:"w-3 h-3"}),p("planSelector.apiceRecommended","Recomendado")]})}),c.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[c.jsx("div",{className:"w-11 h-11 rounded-xl bg-gradient-to-br from-emerald-400/30 to-teal-400/20 flex items-center justify-center border border-emerald-300/40",children:c.jsx(Vg,{className:"w-5 h-5 text-emerald-100"})}),c.jsxs("div",{children:[c.jsx("div",{className:"text-base sm:text-lg font-extrabold text-white leading-tight",children:p("planSelector.apiceName","Pacote ÃPICE")}),c.jsx("div",{className:"text-xs text-emerald-100/90 leading-snug mt-0.5",children:C})]})]}),c.jsxs("div",{className:"mt-4 flex flex-wrap items-end justify-between gap-2",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wide text-emerald-100",children:p("planSelector.apiceAllForPrice",{defaultValue:"TUDO por {{price}}",price:k(m)})}),c.jsx("div",{className:"text-3xl sm:text-4xl font-extrabold text-white tracking-tight leading-tight","data-testid":"text-price-book-cover",children:k(m)})]}),c.jsx("div",{className:"rounded-full bg-emerald-950/35 border border-emerald-300/25 px-2.5 py-1 text-[11px] font-bold text-emerald-100",children:j})]}),c.jsx("ul",{className:"mt-4 grid grid-cols-1 sm:grid-cols-2 gap-x-3 gap-y-2 text-xs sm:text-[13px] text-emerald-50",children:S.map(X=>c.jsxs("li",{className:"flex items-center gap-1.5",children:[c.jsx(it,{className:"w-3.5 h-3.5 text-emerald-200 shrink-0",strokeWidth:3,"aria-hidden":"true"}),c.jsx("span",{children:X})]},X))}),c.jsx("p",{className:"mt-4 text-xs sm:text-[13px] font-medium text-emerald-50 leading-snug",children:O}),c.jsxs("div",{className:"mt-4 min-h-11 rounded-xl bg-gradient-to-r from-emerald-300 to-teal-300 py-3 text-sm font-extrabold text-emerald-950 text-center shadow-md shadow-emerald-500/30 group-hover:from-emerald-200 group-hover:to-teal-200 transition-all flex items-center justify-center gap-1",children:[p("planSelector.apiceCta","Quero meu livro publicado"),c.jsx(xh,{className:"w-4 h-4 group-hover:translate-x-0.5 transition-transform"})]})]}),c.jsxs(se.button,{type:"button",whileTap:{scale:.985},onClick:()=>J("book"),className:"relative sm:col-start-1 sm:row-start-1 rounded-xl border border-white/10 bg-white/[0.03] hover:bg-white/[0.06] hover:border-white/20 transition-all p-3 sm:p-4 text-left group flex flex-col items-stretch min-h-[190px] sm:min-h-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-200 focus-visible:ring-offset-2 focus-visible:ring-offset-[#101015]","data-testid":"plan-book-only",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsx("div",{className:"w-9 h-9 rounded-lg bg-zinc-500/10 flex items-center justify-center border border-zinc-500/20",children:c.jsx(tn,{className:"w-4 h-4 text-zinc-300"})}),c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-bold text-white leading-tight",children:p("planSelector.bookOnlyName","Só o Texto do Livro")}),c.jsx("div",{className:"text-[11px] text-zinc-500 leading-tight mt-0.5",children:p("planSelector.bookOnlyTag","Comece simples")})]})]}),c.jsx("p",{className:"text-xs text-zinc-400 leading-snug",children:p("planSelector.bookOutcome","Manuscrito completo e arquivos para você publicar")}),c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"text-xl sm:text-2xl font-bold text-white tracking-tight","data-testid":"text-price-book",children:k(f)}),c.jsx("div",{className:"text-[11px] text-zinc-600 mt-0.5",children:p("planSelector.upfront","à vista")})]}),c.jsx("div",{className:"mt-auto rounded-lg bg-white/5 border border-white/10 min-h-11 py-2.5 text-xs font-semibold text-zinc-300 text-center group-hover:bg-white/10 group-hover:text-white transition-all",children:p("planSelector.choose","Escolher")})]}),c.jsxs(se.button,{type:"button",whileTap:{scale:.985},onClick:()=>J("bundle"),className:"relative sm:col-start-3 sm:row-start-1 rounded-xl border-2 border-amber-300/45 bg-gradient-to-br from-amber-500/[0.18] via-orange-500/[0.09] to-amber-500/[0.04] hover:from-amber-500/[0.24] hover:via-orange-500/[0.13] hover:border-amber-200/70 transition-all p-3 pt-4 sm:p-4 sm:pt-5 text-left group flex flex-col items-stretch min-h-[230px] sm:min-h-0 shadow-lg shadow-amber-500/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-200 focus-visible:ring-offset-2 focus-visible:ring-offset-[#101015]","data-testid":"plan-complete-bundle",children:[c.jsx("div",{className:"absolute -top-2.5 right-2 roun
2ded-full border border-amber-300/45 bg-gradient-to-r from-amber-300 to-orange-300 px-2 py-0.5 text-[9px] font-extrabold uppercase tracking-wide text-amber-950 shadow-md shadow-amber-500/25",children:p("planSelector.bundleBadge","Mais completo")}),c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsx("div",{className:"w-9 h-9 rounded-lg bg-gradient-to-br from-amber-400/25 to-orange-500/25 flex items-center justify-center border border-amber-400/30",children:c.jsx(qg,{className:"w-4 h-4 text-amber-300"})}),c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-bold text-white leading-tight",children:p("planSelector.bundleName","Pacote Completo")}),c.jsx("div",{className:"text-[11px] text-amber-200/90 leading-tight mt-0.5",children:p("planSelector.bundleTag","ÃPICE + experiência premium")})]})]}),c.jsx("p",{className:"text-xs font-semibold text-amber-50 leading-snug",children:p("planSelector.bundleOutcome","Tudo do Pacote ÃPICE + todos os diferenciais premium")}),c.jsxs("ul",{className:"mt-2 space-y-1 text-[10px] sm:text-[11px] text-amber-100/85",children:[c.jsxs("li",{className:"flex items-start gap-1",children:[c.jsx(it,{className:"mt-0.5 h-3 w-3 shrink-0 text-amber-300",strokeWidth:3}),c.jsx("span",{children:p("planSelector.bundleIncludesApice","Livro publicado na ÃPICE com página de vendas e App de Leitura")})]}),c.jsxs("li",{className:"flex items-start gap-1",children:[c.jsx(it,{className:"mt-0.5 h-3 w-3 shrink-0 text-amber-300",strokeWidth:3}),c.jsx("span",{children:N})]})]}),c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"text-[11px] text-zinc-500 line-through leading-none",children:k(b)}),c.jsx("div",{className:"text-xl sm:text-2xl font-extrabold text-white tracking-tight leading-tight","data-testid":"text-price-bundle",children:k(g)}),c.jsxs("span",{className:"inline-flex mt-1 px-1.5 py-0.5 rounded-md bg-amber-500/20 border border-amber-500/40 text-[10px] font-bold text-amber-200",children:["â",y,"%"]})]}),c.jsx("div",{className:"mt-auto rounded-lg bg-gradient-to-r from-amber-300 to-orange-300 border border-amber-200/50 min-h-11 px-2 py-2.5 text-xs font-extrabold text-amber-950 text-center shadow-md shadow-amber-500/20 group-hover:from-amber-200 group-hover:to-orange-200 transition-all",children:p("planSelector.bundleCta","Quero o pacote mais completo")})]})]}),c.jsxs("div",{className:"mt-4 rounded-xl border border-emerald-400/25 bg-gradient-to-r from-emerald-500/[0.10] via-teal-500/[0.08] to-emerald-500/[0.10] p-3 sm:p-3.5 flex items-center gap-3","data-testid":"banner-apice-value",children:[c.jsx("div",{className:"shrink-0 w-9 h-9 sm:w-10 sm:h-10 rounded-full bg-gradient-to-br from-emerald-400/25 to-teal-500/25 border border-emerald-300/35 flex items-center justify-center",children:c.jsx(oe,{className:"w-4 h-4 sm:w-5 sm:h-5 text-emerald-200"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-[11px] sm:text-sm font-bold text-emerald-50 leading-snug",children:p("planSelector.apiceBannerTitle","Um único pagamento, cinco entregáveis para colocar seu livro no ar")}),c.jsx("div",{className:"text-[10px] sm:text-xs text-emerald-100/75 leading-snug mt-0.5",children:p("planSelector.apiceBannerSub","Da escrita ao App de Leitura, a SÃBHIA automatiza cada etapa do Pacote ÃPICE.")})]})]})]}),c.jsxs("div",{className:"px-3 sm:px-6 pb-3 pt-2",children:[c.jsx("div",{className:"text-center mb-2.5",children:c.jsxs("div",{className:"inline-flex items-center gap-1.5 text-[10px] sm:text-[11px] font-semibold text-zinc-400 uppercase tracking-wider",children:[c.jsx(oe,{className:"w-3 h-3 text-amber-400"}),c.jsx("span",{children:p("planSelector.seeAll","Veja tudo que está incluso em cada plano")}),c.jsx(oe,{className:"w-3 h-3 text-amber-400"})]})}),c.jsx("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] overflow-hidden","data-testid":"table-plan-comparison",children:c.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_48px_54px_58px] text-[11px] sm:grid-cols-[1fr_auto_auto_auto] sm:text-xs",children:[c.jsx("div",{className:"px-2.5 sm:px-3 py-2.5 bg-white/[0.03] text-zinc-500 font-medium text-[10px] sm:text-[11px] uppercase tracking-wide",children:p("planSelector.colIncludes","Inclui")}),c.jsx("div",{className:"px-1 sm:px-2 py-2.5 bg-white/[0.03] text-center text-zinc-400 font-bold text-[10px] sm:text-[11px]",children:p("planSelector.colBook","Só texto")}),c.jsx("div",{className:"px-1 sm:px-2 py-2.5 bg-emerald-500/15 text-center text-emerald-200 font-extrabold text-[10px] sm:text-[11px]",children:p("planSelector.colApice","ÃPICE")}),c.jsx("div",{className:"px-1 sm:px-2 py-2.5 bg-gradient-to-b from-amber-500/16 to-amber-500/[0.08] text-center text-amber-200 font-bold text-[10px] sm:text-[11px] border-l border-r border-t border-amber-400/25 relative",children:p("planSelector.colBun
2dle","Pacote")}),ne.map((X,Nr)=>{const Mt=Nr%2===1;return c.jsxs("div",{className:"contents",children:[c.jsx("div",{className:K("px-2.5 sm:px-3 py-2 text-zinc-300 border-t border-white/5 leading-snug",Mt&&"bg-white/[0.015]"),children:X.label}),c.jsx("div",{className:K("px-1.5 sm:px-2 py-2 text-center border-t border-white/5",Mt&&"bg-white/[0.015]"),children:X.book?c.jsx(it,{className:"w-3.5 h-3.5 text-zinc-400 inline"}):c.jsx("span",{className:"text-zinc-700 text-base",children:"â"})}),c.jsx("div",{className:K("px-1.5 sm:px-2 py-2 text-center border-t border-white/5 bg-emerald-500/[0.07]",Mt&&"bg-emerald-500/[0.11]"),children:X.cover?c.jsx(it,{className:"w-3.5 h-3.5 text-emerald-400 inline"}):c.jsx("span",{className:"text-zinc-700 text-base",children:"â"})}),c.jsx("div",{className:K("px-1.5 sm:px-2 py-2 text-center border-t border-l border-r border-amber-400/25 bg-gradient-to-b from-amber-500/[0.08] to-amber-500/[0.03]",Mt&&"from-amber-500/[0.11] to-amber-500/[0.06]"),children:X.bundle?c.jsx(it,{className:"w-3.5 h-3.5 text-amber-300 inline",strokeWidth:2.5}):c.jsx("span",{className:"text-zinc-700 text-base",children:"â"})})]},Nr)}),c.jsx("div",{className:"border-t border-white/5"}),c.jsx("div",{className:"border-t border-white/5"}),c.jsx("div",{className:"border-t border-white/5 bg-emerald-500/[0.07]"}),c.jsx("div",{className:"border-t border-b border-l border-r border-amber-400/25 bg-amber-500/[0.08] h-1"})]})})]}),c.jsx("div",{className:"px-4 sm:px-6 pb-5 pt-2",children:c.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1.5 text-[10px] sm:text-[11px] text-zinc-500",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(yi,{className:"w-3 h-3 text-zinc-400"}),c.jsx("span",{children:p("planSelector.securePay","Pagamento seguro")})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(_a,{className:"w-3 h-3 text-emerald-500/70"}),c.jsx("span",{children:p("planSelector.pixOrCard","PIX ou Cartão")})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(oe,{className:"w-3 h-3 text-amber-500/70"}),c.jsx("span",{children:p("planSelector.rights","100% dos direitos são seus")})]})]})})]})]})}),c.jsx(Va,{open:a,onOpenChange:Ee,product:i,onConfirm:le,bookId:r,bookTitle:s,orderType:d})]})}const ss="sabhia.draft.v1",El=336*60*60*1e3;function is(t,e){return`${ss}.${t}.${e}`}function ks(){try{return typeof window>"u"||!window.localStorage?null:(window.localStorage.setItem(`${ss}.__probe`,"1"),window.localStorage.removeItem(`${ss}.__probe`),window.localStorage)}catch{return null}}function Al(t,e,n,r){const s=ks();if(s)try{const i={value:n,savedAt:Date.now(),serverValueAtCapture:r};s.setItem(is(t,e),JSON.stringify(i))}catch{$h();try{const i={value:n,savedAt:Date.now(),serverValueAtCapture:r};s.setItem(is(t,e),JSON.stringify(i))}catch{}}}function Yx(t,e){const n=ks();if(!n)return null;try{const r=n.getItem(is(t,e));if(!r)return null;const s=JSON.parse(r);return!s||typeof s.value!="string"||typeof s.savedAt!="number"?null:Date.now()-s.savedAt>El?(n.removeItem(is(t,e)),null):s}catch{return null}}function Ns(t,e){const n=ks();if(n)try{n.removeItem(is(t,e))}catch{}}function Ol(t,e,n){const r=Yx(t,e);return r?r.value===n?(Ns(t,e),null):r:null}function $h(){const t=ks();if(t)try{const e=Date.now(),n=[];for(let r=0;r<t.length;r++){const s=t.key(r);if(!(!s||!s.startsWith(ss)))try{const i=t.getItem(s);if(!i){n.push(s);continue}const o=JSON.parse(i);(!o?.savedAt||e-o.savedAt>El)&&n.push(s)}catch{n.push(s)}}for(const r of n)t.removeItem(r)}catch{}}let yd=!1;function Xx(){if(!yd){yd=!0;try{$h()}catch{}}}const Zx=45e3,e0=6e4;function vd(t,e){if(!(typeof navigator>"u"||!navigator.sendBeacon))try{const n=t0(t);if(n.length===0)return;const r=[];for(const{field:l,draft:d}of n){let u=null;if(l.startsWith("book:")){const h=l.slice(5);h&&(u={kind:"book",id:t,field:h,value:d.value,baseValue:d.serverValueAtCapture||"",savedAt:d.savedAt})}else if(l.startsWith("chapter:")){const h=l.slice(8),p=h.lastIndexOf(":");if(p>0){const f=h.slice(0,p),m=h.slice(p+1);f&&m&&!e?.has(f)&&(u={kind:"chapter",id:f,field:m,value:d.value,baseValue:d.serverValueAtCapture||"",savedAt:d.savedAt})}}u&&(u.value.length>Zx||r.push(u))}if(r.length===0)return;r.sort((l,d)=>d.savedAt-l.savedAt);const s=[];let i=64;for(const l of r){const d=l.value.length+l.baseValue.length+l.field.length+l.id.length+80;if(s.length>=20||i+d>e0)break;s.push(l),i+=d}if(s.length===0)return;const o=JSON.stringify({bookId:t,items:s}),a=new Blob([o],{type:"application/json"});navigator.sendBeacon("/api/draft-beacon",a)}catch{}}function t0(t){const e=ks();if(!e)return[];const n=[],r=`${ss}.${t}.`;try{for(let s=0;s<e.length;s++){const i=e.key(s);if(!(!i||!i.startsWith(r)))try{const o=e.getItem(i);if(!o)continue;const a=JSON.parse(o);if(!a?.savedAt)continue;if(Date.now()-a.savedAt>El){e.removeItem(i);continue}
2n.push({field:i.slice(r.length),draft:a})}catch{}}}catch{}return n}const n0={user_edit:"Edição manual",ai_generation:"Gerado pela SÃBHIA",ai_regeneration:"Regenerado pela SÃBHIA",import:"Importação",recalibration:"Recalibração",builder_action:"Ação do construtor",user_revert:"Restauração anterior"};function _h(t){try{return new Date(t).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function r0(t){const e=new Date(t).getTime(),n=Date.now()-e,r=Math.floor(n/6e4);if(r<1)return"agora há pouco";if(r<60)return`há ${r} min`;const s=Math.floor(r/60);if(s<24)return`há ${s}h`;const i=Math.floor(s/24);return i<7?`há ${i} dia${i>1?"s":""}`:_h(t)}function s0({bookId:t,open:e,onOpenChange:n}){const{toast:r}=ws(),s=Kn(),[i,o]=v.useState(null),[a,l]=v.useState(null),{data:d,isLoading:u,refetch:h}=Ce({queryKey:[`/api/books/${t}/versions`],enabled:e&&!!t,staleTime:0}),p=Ae({mutationFn:async m=>G("POST",`/api/books/${t}/versions/${m}/restore`,{}),onSuccess:()=>{r({title:"Versão restaurada!",description:"Sua escrita voltou exatamente como estava nessa data."}),s.invalidateQueries({queryKey:[`/api/books/${t}`]}),s.invalidateQueries({queryKey:[`/api/books/${t}/chapters`]}),h(),l(null),o(null),n(!1)},onError:m=>{r({title:"Não foi possÃvel restaurar",description:m?.message||"Tente novamente em alguns segundos",variant:"destructive"}),o(null),l(null)}}),f=d?.versions||[];return c.jsx(zr,{open:e,onOpenChange:n,children:c.jsxs(Br,{side:"right",className:"w-full sm:max-w-md p-0 flex flex-col bg-gradient-to-b from-stone-50 to-amber-50/40",children:[c.jsx(Ha,{className:"px-6 py-5 border-b border-stone-200 bg-white/60 backdrop-blur-sm",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-11 h-11 rounded-2xl bg-gradient-to-br from-emerald-100 to-teal-100 border border-emerald-200/60 flex items-center justify-center shrink-0",children:c.jsx(Dh,{className:"w-5 h-5 text-emerald-700"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx(Fa,{className:"text-left text-lg font-bold text-stone-900 font-['Georgia',serif]",children:"Histórico de versões"}),c.jsx("p",{className:"text-xs text-stone-600 mt-0.5 leading-relaxed",children:"Cada vez que você ou a plataforma edita o livro, salvamos uma versão aqui. Pode voltar pra qualquer uma quando quiser."})]})]})}),c.jsx(ax,{className:"flex-1",children:c.jsxs("div",{className:"px-4 py-4 space-y-2",children:[u&&c.jsxs("div",{className:"flex items-center justify-center py-12 text-stone-500",children:[c.jsx(ge,{className:"w-5 h-5 animate-spin mr-2"}),"Carregando versões..."]}),!u&&f.length===0&&c.jsxs("div",{className:"text-center py-12 px-4",children:[c.jsx(tn,{className:"w-10 h-10 text-stone-300 mx-auto mb-3"}),c.jsx("p",{className:"text-sm text-stone-600 font-medium",children:"Nenhuma versão anterior ainda"}),c.jsx("p",{className:"text-xs text-stone-500 mt-2 leading-relaxed",children:"Conforme você for editando, as versões aparecerão aqui automaticamente. Nada se perde."})]}),!u&&f.map(m=>{const g=p.isPending&&i===m.id,b=a===m.id,y=n0[m.source]||m.source,k=m.source==="user_edit";return c.jsxs("div",{className:"rounded-2xl bg-white border border-stone-200 shadow-sm overflow-hidden hover:shadow-md transition-shadow","data-testid":`version-row-${m.id}`,children:[c.jsxs("div",{className:"px-4 py-3 border-b border-stone-100 flex items-start gap-3",children:[c.jsx("div",{className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${k?"bg-emerald-100 text-emerald-700":"bg-amber-50 text-amber-700"}`,children:m.summary.kind==="chapter"?c.jsx(rn,{className:"w-4 h-4"}):c.jsx(tn,{className:"w-4 h-4"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-sm font-semibold text-stone-900 truncate",children:m.summary.kind==="chapter"?m.summary.chapterTitle||"CapÃtulo":m.summary.field?`Livro · ${m.summary.field}`:"Livro"}),c.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-stone-500",children:[c.jsx("span",{className:"font-medium text-stone-700",children:r0(m.createdAt)}),c.jsx("span",{className:"text-stone-300",children:"·"}),c.jsx("span",{children:_h(m.createdAt)})]}),c.jsx("div",{className:"mt-1.5 inline-flex items-center gap-1.5 text-[10px] uppercase tracking-wider font-semibold text-stone-600 bg-stone-100 rounded-full px-2 py-0.5",children:y})]})]}),m.summary.preview&&c.jsxs("div",{className:"px-4 py-2.5 text-xs text-stone-600 italic leading-relaxed line-clamp-2 font-['Georgia',serif] bg-stone-50/50",children:['"',m.summary.preview,'"']}),c.jsx("div",{className:"px-4 py-2.5 bg-white",children:b?c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-start gap-2 text-xs text-amber-800 bg-amber-50 border border-amber-200/70 rounded-lg px-3 py-2",children:[c.jsx(cx,{className:"w-4 h-4 shrink-0 mt-0.5"}),c.jsx("span",{className:"leading-relaxed",children:"A versão atual será salva no histórico antes de voltar â você pode desfazer depois."})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>l(null),disabled:g,className:"flex-1 min-h-10","data-testid":`button-cancel-restore-${m.id}`,children:"Cancelar"}),c.jsx(Y,{size:"sm",onClick:()=>{o(m.id),p.mutate(m.id)},disabled:g,className:"flex-1 bg-emerald-600 hover:bg-emerald-700 text-white font-semibold min-h-10","data-testid":`button-confirm-restore-${m.id}`,children:g?c.jsxs(c.Fragment,{children:[c.jsx(ge,{className:"w-4 h-4 mr-1.5 animate-spin"})," Restaurandoâ¦"]}):c.jsxs(c.Fragment,{children:[c.jsx(Mn,{className:"w-4 h-4 mr-1.5"})," Sim, voltar"]})})]})]}):c.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>l(m.id),className:"w-full justify-center text-emerald-700 hover:text-emerald-800 hover:bg-emerald-50 font-semibold min-h-10","data-testid":`button-restore-${m.id}`,children:[c.jsx(lx,{className:"w-4 h-4 mr-2"})," Voltar pra essa versão"]})})]},m.id)})]})}),c.jsx("div",{className:"px-6 py-3 border-t border-stone-200 bg-white/60 backdrop-blur-sm text-[11px] text-stone-500 text-center",children:"Versões são guardadas automaticamente. Nada se perde."})]})})}function i0({open:t,onOpenChange:e,serviceTitle:n,status:r}){const s=[{title:"Solicitação Enviada",date:"Hoje, 14:30",completed:!0},{title:"Pagamento Confirmado",date:"Hoje, 14:32",completed:!0},{title:"Profissional AtribuÃdo",date:"Hoje, 15:00",completed:!0},{title:"Em Execução",date:"Em andamento",completed:r==="in_progress"||r==="review"||r
2==="completed",current:r==="in_progress"},{title:"Entrega Preliminar",date:"Previsto: Amanhã",completed:r==="review"||r==="completed",current:r==="review"},{title:"Aprovação Final",date:"Pendente",completed:r==="completed"}];return c.jsx(hh,{open:t,onOpenChange:e,children:c.jsxs(ph,{className:"max-w-2xl bg-[#101012] border-white/10 text-white",children:[c.jsx(fh,{children:c.jsxs("div",{className:"flex justify-between items-start",children:[c.jsxs("div",{children:[c.jsx(mh,{className:"text-xl font-heading font-bold",children:n}),c.jsx(gh,{className:"text-muted-foreground mt-1",children:"ID do Pedido: #82930 ⢠Sábhia Digiwork"})]}),c.jsx(ar,{variant:"outline",className:"bg-primary/10 text-primary border-primary/20 animate-pulse",children:"EM ANDAMENTO"})]})}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 mt-6",children:[c.jsxs("div",{className:"space-y-6",children:[c.jsx("h4",{className:"text-sm font-bold uppercase tracking-widest text-muted-foreground",children:"Linha do Tempo"}),c.jsx("div",{className:"relative border-l border-white/10 ml-2 space-y-8 pl-6",children:s.map((i,o)=>c.jsxs("div",{className:"relative",children:[c.jsx("div",{className:`absolute -left-[29px] top-1 w-3 h-3 rounded-full border-2 ${i.completed?"bg-primary border-primary":i.current?"bg-[#101012] border-primary animate-pulse":"bg-[#101012] border-white/20"}`}),c.jsx("h5",{className:`text-sm font-medium ${i.completed||i.current?"text-white":"text-muted-foreground"}`,children:i.title}),c.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:i.date})]},o))})]}),c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsx("h4",{className:"text-sm font-bold uppercase tracking-widest text-muted-foreground",children:"Arquivos & Entregas"}),c.jsxs("div",{className:"p-4 rounded-xl bg-white/5 border border-white/5 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(rn,{className:"w-4 h-4 text-primary"}),c.jsx("span",{children:"Briefing_Inicial.pdf"})]}),c.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",children:c.jsx(qa,{className:"w-3 h-3"})})]}),c.jsxs("div",{className:"flex items-center justify-between text-sm opacity-50",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(rn,{className:"w-4 h-4"}),c.jsx("span",{children:"Versão_V1.docx"})]}),c.jsx("span",{className:"text-[10px] italic",children:"Aguardando"})]})]}),c.jsxs(Y,{variant:"outline",className:"w-full border-dashed border-white/20 hover:bg-white/5 text-xs h-8",children:[c.jsx(Ka,{className:"w-3 h-3 mr-2"})," Enviar Arquivo Extra"]})]}),c.jsxs("div",{className:"space-y-4 pt-4 border-t border-white/10",children:[c.jsx("h4",{className:"text-sm font-bold uppercase tracking-widest text-muted-foreground",children:"Comunicação"}),c.jsxs(Y,{className:"w-full bg-white/5 hover:bg-white/10 text-white justify-start",children:[c.jsx(Wg,{className:"w-4 h-4 mr-2 text-primary"}),"Mensagem para o Profissional"]}),c.jsx("p",{className:"text-[10px] text-muted-foreground text-center",children:"Para manter a segurança, toda a comunicação é auditada."})]})]})]})]})})}const o0={legal:{gradient:"from-amber-500/20 to-orange-500/15",accent:"text-amber-300",label:"Juridico"},manual_howto:{gradient:"from-sky-500/20 to-blue-500/15",accent:"text-sky-300",label:"Manual / Tutorial"},technical:{gradient:"from-cyan-500/20 to-teal-500/15",accent:"text-cyan-300",label:"Tecnico"},recipe:{gradient:"from-orange-500/20 to-red-500/15",accent:"text-orange-300",label:"Receitas"},verse:{gradient:"from-purple-500/20 to-fuchsia-500/15",accent:"text-purple-300",label:"Poesia"},children:{gradient:"from-pink-500/20 to-rose-500/15",accent:"text-pink-300",label:"Infantil"},devotional:{gradient:"from-yellow-500/20 to-amber-500/15",accent:"text-yellow-300",label:"Devocional"},exercises:{gradient:"from-emerald-500/20 to-green-500/15",accent:"text-emerald-300",label:"Workbook"},biography:{gradient:"from-violet-500/20 to-purple-500/15",accent:"text-violet-300",label:"Biografia"},prose_fiction:{gradient:"from-indigo-500/20 to-blue-500/15",accent:"text-indigo-300",label:"Ficcao"},prose_nonfiction:{gradient:"from-slate-500/20 to-zinc-500/15",accent:"text-slate-300",label:"Nao-ficcao"}};function wd(t){return o0[t]||{gradient:"from-slate-500/20 to-zinc-500/15",accent:"text-slate-300",label:t}}function a0({bookId:t}){const{toast:e}=ws(),n=Kn(),{data:r,isLoading:s,isError:i}=Ce({queryKey:["/api/books",t,"style-preview"],queryFn:async()=>await(await G("GET",`/api/books/${t}/style-preview`)).json(),enabled:!!t}),[o,a]=v.useState(""),[l,d]=v.useState([]),[u,h]=v.useState(!1);v.useEffect(()=>{r&&!u&&(a(r.override?.contentType||""),d(Array.isArray(r.lockedContent)?r.lockedContent:[]),h(!0))},[r,u]);const p=Ae({mutationFn:async N=>await(await G("PATCH",`/api/books/${t}/style-override`,N)).json(),onSuccess:()=>{n.invalidateQueries({queryKey:["/api/books",t,"style-preview"]}),n.invalidateQueries({queryKey:["/api/books",t]}),e({title:"Estilo salvo",description:"Suas escolhas serao aplicadas na proxima geracao."})},onError:N=>{e({title:"Erro ao salvar",description:N?.message||"Tente novamente",variant:"destructive"})}}),f=r?.detected,m=r?.effective,g=r?.autoStyle||null,b=!!r?.override?.contentType,y=v.useMemo(()=>wd(f?.contentType||""),[f?.contentType]),k=v.useMemo(()=>wd(m?.contentType||""),[m?.contentType]);function C(){if(l.length>=20){e({title:"Limite atingido",description:"Maximo de 20 trechos verbatim.",variant:"destructive"});return}d([...l,{text:"",label:"",placement:null,chapterNumber:null}])}function j(N,P){d(l.map((D,L)=>L===N?{...D,...P}:D))}function O(N){d(l.filter((P,D)=>D!==N))}function S(){const N=l.filter(P=>(P.text||"").trim().length>0).map(P=>({chapterNumber:typeof P.chapterNumber=="number"&&!Number.isNaN(P.chapterNumber)?P.chapterNumber:null,chapterTitle:P.chapterTitle?.trim()||null,label:P.label?.trim()||null,text:(P.text||"").slice(0,5e4),placement:P.placement||null}));p.mutate({styleOverride:o?{contentType:o}:null,lockedContent:N.length>0?N:null})}return s?c.jsx("div",{className:"flex items-center justify-center py-20","data-testid":"status-style-loading",children:c.jsx(ge,{className:"h-6 w-6 animate-spin text-white/40"})}):i||!r?c.jsx("div",{className:"rounded-2xl border border-red-500/30 bg-red-500/5 p-6 text-red-200","data-testid":"status-style-error",children:"Nao foi possivel carregar o estilo editorial."}):c.jsxs("div",{className:"space-y-6 pb-20 md:pb-0","data-testid":"panel-editorial-style",children:[c.jsxs("div",{className:K("roun
2ded-2xl border border-white/10 bg-gradient-to-br p-6",y.gradient),"data-testid":"card-style-detected",children:[c.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wider text-white/60 mb-2",children:[c.jsx(oe,{className:"h-3.5 w-3.5"}),"Estilo detectado automaticamente"]}),c.jsx("h3",{className:K("text-2xl font-semibold",y.accent),"data-testid":"text-detected-genre",children:f?.genreLabel}),c.jsxs("p",{className:"text-sm text-white/60 mt-1",children:["Tipo: ",c.jsx("span",{className:"font-mono",children:f?.contentType}),f?.subType?c.jsxs(c.Fragment,{children:[" · subtipo: ",c.jsx("span",{className:"font-mono",children:f.subType})]}):null]})]}),b&&c.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-white/10 px-3 py-1.5 text-xs text-white/80",children:[c.jsx(_a,{className:"h-3.5 w-3.5"}),"Override ativo"]})]}),m&&b&&c.jsxs("div",{className:K("mt-4 rounded-xl border border-white/10 p-4 bg-gradient-to-br",k.gradient),children:[c.jsx("div",{className:"text-xs uppercase tracking-wider text-white/60 mb-1",children:"Estilo efetivo (com override)"}),c.jsx("div",{className:K("text-lg font-semibold",k.accent),children:m.genreLabel}),c.jsxs("div",{className:"text-xs text-white/50 mt-1",children:["Alvo: ",m.wordsPerChapter?.target," palavras/cap · ",m.chaptersCount?.min,"-",m.chaptersCount?.max," capitulos"]})]})]}),g&&c.jsxs("div",{className:"rounded-2xl border border-white/10 bg-gradient-to-br from-emerald-500/10 to-teal-500/5 p-6 ring-1 ring-emerald-500/10","data-testid":"card-ai-classification",children:[c.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wider text-white/60 mb-2",children:[c.jsx(Gt,{className:"h-3.5 w-3.5"}),"Classificacao da IA"]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(gx,{className:"h-5 w-5 text-emerald-300"}),c.jsxs("h3",{className:"text-xl font-semibold text-emerald-200","data-testid":"text-ai-classification",children:[g.isFiction?"Ficcao":"Nao-ficcao"," · ",g.genreLabel]})]}),c.jsx("p",{className:"text-sm text-white/55 mt-1",children:g.isFiction?"A IA vai construir personagens e trama narrativa.":"A IA vai escrever conteudo informativo e fiel ao tema â sem inventar personagens ficticios."})]}),typeof g.confidence=="number"&&c.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-white/10 px-3 py-1.5 text-xs text-white/80","data-testid":"badge-ai-confidence",children:["Confianca ",Math.round((g.confidence||0)*100),"%"]})]}),!b&&c.jsx("p",{className:"text-xs text-white/45 mt-3",children:'Nao parece certo? Use "Forcar outro estilo" abaixo para corrigir antes da proxima geracao.'})]}),c.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/5 p-6 ring-1 ring-white/5","data-testid":"card-style-override",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsx(xx,{className:"h-4 w-4 text-white/70"}),c.jsx("h4",{className:"text-base font-semibold text-white",children:"Forcar outro estilo"})]}),c.jsx("p",{className:"text-sm text-white/60 mb-4",children:"Se o estilo detectado nao corresponde ao que voce quer, escolha manualmente. Isso vale a partir da proxima geracao."}),c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:c.jsxs("div",{children:[c.jsx(Or,{className:"text-xs text-white/60 mb-1.5 block",children:"Tipo de conteudo"}),c.jsxs(cd,{value:o||"_none",onValueChange:N=>a(N==="_none"?"":N),children:[c.jsx(dd,{"data-testid":"select-style-override",className:"bg-white/5 border-white/10 text-white",children:c.jsx(ud,{placeholder:"Detectar automaticamente"})}),c.jsxs(hd,{children:[c.jsx(nr,{value:"_none","data-testid":"option-style-auto",children:"Detectar automaticamente"}),r.availableTypes.map(N=>c.jsx(nr,{value:N.contentType,"data-testid":`option-style-${N.contentType}`,children:N.genreLabel},N.contentType))]})]})]})})]}),c.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/5 p-6 ring-1 ring-white/5","data-testid":"card-locked-content",children:[c.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3 flex-wrap",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(yi,{className:"h-4 w-4 text-amber-300"}),c.jsx("h4",{className:"text-base font-semibold text-white",children:"Trechos verbatim (intocaveis)"})]}),c.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:C,className:"border-white/15 bg-white/5 hover:bg-white/10 text-white min-h-10","data-testid":"button-add-locked",children:[c.jsx(bh,{className:"h-4 w-4 mr-1.5"}),"Adicionar trecho"]})]}),c.jsx("p",{className:"text-sm text-white/60 mb-4",children:"Texto colado aqui vai aparecer no capitulo final EXATAMENTE como escrito (sem reformulacao). Util para citar leis, codigos, passagens biblicas, formulas ou qualquer conteudo que precise ser preservado palavra-por-palavra."}),l.length===0?c.jsx("div",{className:"rounded-xl border border-dashed border-white/15 p-6 text-center text-sm text-white/50","data-testid":"text-locked-empty",children:"Nenhum trecho verbatim adicionado."}):c.jsx("div",{className:"space-y-4",children:l.map((N,P)=>c.jsxs("div",{className:"rounded-xl border border-white/10 bg-black/20 p-4 space-y-3 ring-1 ring-white/5","data-testid":`card-locked-entry-${P}`,children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsxs("span",{className:"text-xs text-white/50",children:["Trecho ",P+1]}),c.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>O(P),className:"h-8 text-red-300 hover:text-red-200 hover:bg-red-500/10","data-testid":`button-remove-locked-${P}`,children:c.jsx(jn,{className:"h-3.5 w-3.5"})})]}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[c.jsxs("div",{children:[c.jsx(Or,{className:"text-xs text-white/60 mb-1.5 block",children:"Rotulo (opcional)"}),c.jsx(rs,{value:N.label||"",onChange:D=>j(P,{label:D.target.value}),placeholder:"ex: Art. 121 CP",className:"bg-white/5 border-white/10 text-white","data-testid":`input-locked-label-${P}`})]}),c.jsxs("div",{children:[c.jsx(Or,{className:"text-xs text-white/60 mb-1.5 block",children:"Capitulo (numero, opcional)"}),c.jsx(rs,{type:"number",min:1,value:N.chapterNumber??"",onChange:D=>j(P,{chapterNumber:D.target.value?parseInt(D.target.value,10):null}),placeholder:"Ex: 3",className:"bg-white/5 border-white/10 text-white","data-testid":`input-locked-chapter-${P}`})]}),c.jsxs("div",{children:[c.jsx(Or,{className:"text-xs text-white/60 mb-1.5 block",children:"Posicao no capitulo"}),c.jsxs(cd,{value:N.placement||"_none",onValueChange:D=>j(P,{placement:D==="_none"?null:D}),children:[c.jsx(dd,{className:"bg-white/5 border-white/10 text-white","data-testid":`select-locked-placement-${P}`,children:c.jsx(ud,{placeholder:"Indiferente"})}),c.jsxs(hd,{children:[c.jsx(nr,{value:"_none",children:"Indiferente"}),c.jsx(nr,{value:"start",children:"Inicio"}),c.jsx(nr,{value:"middle",children:"Meio"}),c.jsx(nr,{value:"end",children:"Final"})]})]})]})]}),c.jsxs("div",{children:[c.jsx(Or,{className:"text-xs text-white/60 mb-1.5 block",children:"Texto verbatim"}),c.jsx(Ug,{value:N.text,onChange:D=>j(P,{text:D.target.value}),rows:6,placeholder:"Cole aqui o texto exato que deve aparecer no livro...",className:"bg-white/5 border-white/10 text-white font-mono text-sm","data-testid":`textarea-locked-text-${P}`}),c.jsxs("div",{className:"mt-1 text-xs text-white/40 text-right",children:[N.text.length.toLocaleStr
2ing()," / 50.000 caracteres"]})]})]},P))})]}),c.jsxs("div",{className:"rounded-2xl border border-amber-500/20 bg-amber-500/5 p-4 ring-1 ring-amber-500/10 flex gap-3","data-testid":"card-style-hint",children:[c.jsx(vi,{className:"h-5 w-5 text-amber-300 flex-shrink-0 mt-0.5"}),c.jsx("div",{className:"text-sm text-amber-100/90",children:"As mudancas aqui afetam capitulos gerados a partir de agora. Capitulos ja escritos nao mudam automaticamente â regenere-os depois de salvar para aplicar."})]}),c.jsx("div",{className:"sticky bottom-4 md:bottom-0 z-10 flex justify-end",children:c.jsx(Y,{type:"button",onClick:S,disabled:p.isPending,className:"min-h-12 px-6 bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-400 hover:to-orange-400 text-black font-semibold shadow-lg shadow-amber-500/20","data-testid":"button-save-style",children:p.isPending?c.jsxs(c.Fragment,{children:[c.jsx(ge,{className:"h-4 w-4 mr-2 animate-spin"}),"Salvando..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Lh,{className:"h-4 w-4 mr-2"}),"Salvar estilo editorial"]})})})]})}function l0({bookId:t,currentRef:e}){const{toast:n}=ws(),[r,s]=v.useState(e||"");v.useEffect(()=>{s(e||"")},[e]);const{data:i}=Ce({queryKey:["/api/books"],staleTime:6e4}),o=(i||[]).filter(d=>d.id!==t),a=Ae({mutationFn:async d=>(await G("PATCH",`/api/books/${t}`,{previousWorkRef:d})).json(),onSuccess:()=>{H.invalidateQueries({queryKey:[`/api/books/${t}`]}),n({title:r?"Referência de estilo salva":"Referência removida",description:r?"Sua IA vai usar o estilo do livro selecionado quando começar a escrever.":"A escrita seguirá apenas as outras diretrizes do plano."})},onError:d=>{n({title:"Não foi possÃvel salvar",description:d?.message||"Tente novamente em instantes.",variant:"destructive"})}}),l=d=>{s(d),a.mutate(d||null)};return o.length===0?null:c.jsxs("section",{className:"pb-6 border-b border-black/5","data-testid":"section-style-reference",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsx(oe,{className:"w-3.5 h-3.5 opacity-40"}),c.jsxs("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40",children:["Espelhar estilo de outro livro ",c.jsx("span",{className:"ml-1 opacity-50 normal-case tracking-normal text-[10px]",children:"(opcional)"})]})]}),c.jsxs("p",{className:"text-xs md:text-sm leading-relaxed opacity-70 mb-3",children:["Selecione um livro seu já escrito. A IA vai usar trechos dele como referência de ",c.jsx("strong",{children:"voz, ritmo e vocabulário"})," â sem copiar conteúdo, personagens ou eventos. Ãtil pra continuações, série, ou pra manter consistência de estilo entre obras."]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1 min-w-0",children:[c.jsxs("select",{value:r,onChange:d=>l(d.target.value),disabled:a.isPending,className:"w-full appearance-none cursor-pointer bg-black/[0.02] hover:bg-black/[0.04] border border-black/10 rounded px-3 py-2 pr-9 text-xs md:text-sm leading-relaxed opacity-90 font-['Courier_Prime'] focus:border-primary/40 focus:ring-1 focus:ring-primary/20 outline-none transition-colors disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"select-style-reference",children:[c.jsx("option",{value:"",children:"â Nenhum (estilo livre)"}),o.map(d=>c.jsx("option",{value:d.id,children:d.title},d.id))]}),c.jsx(yh,{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 opacity-40"})]}),a.isPending&&c.jsx(ge,{className:"w-4 h-4 animate-spin opacity-60 shrink-0"}),!a.isPending&&r&&r===e&&c.jsx(it,{className:"w-4 h-4 text-emerald-500 shrink-0","data-testid":"icon-style-ref-saved"})]})]})}function Oe(t){this.content=t}Oe.prototype={constructor:Oe,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new Oe(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Oe(n)},addToStart:function(t,e){return new Oe([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Oe(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new Oe(s)}
vendor: 6,708 bytes, line 2
2,forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Oe.from(t),t.size?new Oe(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Oe.from(t),t.size?new Oe(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Oe.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Oe.from=function(t){if(t instanceof Oe)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Oe(e)};function Hh(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=Hh(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function Fh(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),a=e.child(--i),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,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++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let d=Fh(o.content,a.content,n-1,r-1);if(d)return d}n-=l,r-=l}}class E{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,a=0;a<n;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,n-u),r,s+u)}a=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let d=a.isText?a.text.slice(Math.max(e,l)-l,n-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 n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new E(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let a=this.content[i],l=o+a.nodeSize;l>e&&((o<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),s+=a.nodeSize),o=l}return new E(r,s)}cutByIndex(e,n){return e==n?E.empty:e==0&&n==this.content.length?this:new E(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new E(s,i)}addToStart(e){return new E([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new E(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return Hh(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Fh(this,e,n,r)}findIndex(e){if(e==0)return Gs(0,e);if(e==this.size)return Gs(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?Gs(n+1,i):Gs(n,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,n){if(!n)return E.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return E.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return E.empty;let n,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)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new E(n||e,r)}static from(e){if(!e)return E.empty;if(e instanceof E)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new E([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}E.empty=new E([],0);const ca={index:0,offset:0};function Gs(t,e){return ca.index=t,ca.offset=e,ca}function ki(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!ki(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ki(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Z=class Wa{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,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))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ki(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Wa.none;if(e instanceof Wa)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Z.none=[];
vendor: 6,587 bytes, line 2
2class Ni extends Error{}class R{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=qh(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new R(r,this.openStart,this.openEnd)}removeBetween(e,n){return new R(Vh(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return R.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new R(E.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new R(e,r,s)}}R.empty=new R(E.empty,0,0);function Vh(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(s==e||i.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Vh(i.content,e-s-1,n-s-1)))}function qh(t,e,n,r,s,i){let{index:o,offset:a}=t.findIndex(e),l=t.maybeChild(o);if(a==e||l.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let d=qh(l.content,e-a-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,l);return d&&t.replaceChild(o,l.copy(d))}function c0(t,e,n){if(n.openStart>t.depth)throw new Ni("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Ni("Inconsistent open depths");return Kh(t,e,n,0)}function Kh(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=Kh(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,a=o.content;return Rn(o,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=d0(n,t);return Rn(i,Uh(t,o,a,e,r))}else return Rn(i,Si(t,e,r))}function Wh(t,e){if(!e.type.compatibleContent(t.type))throw new Ni("Cannot join "+e.type.name+" onto "+t.type.name)}function Ua(t,e,n){let r=t.node(n);return Wh(r,e.node(n)),r}function Pn(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Kr(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Pn(t.nodeAfter,r),i++));for(let a=i;a<o;a++)Pn(s.child(a),r);e&&e.depth==n&&e.textOffset&&Pn(e.nodeBefore,r)}function Rn(t,e){return t.type.checkContent(e),t.copy(e)}function Uh(t,e,n,r,s){let i=t.depth>s&&Ua(t,e,s+1),o=r.depth>s&&Ua(n,r,s+1),a=[];return Kr(null,t,s,a),i&&o&&e.index(s)==n.index(s)?(Wh(i,o),Pn(Rn(i,Uh(t,e,n,r,s+1)),a)):(i&&Pn(Rn(i,Si(t,e,s+1)),a),Kr(e,n,s,a),o&&Pn(Rn(o,Si(n,r,s+1)),a)),Kr(r,null,s,a),new E(a)}function Si(t,e,n){let r=[];if(Kr(null,t,n,r),t.depth>n){let s=Ua(t,e,n+1);Pn(Rn(s,Si(t,e,n+1)),r)}return Kr(e,null,n,r),new E(r)}function d0(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(E.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class as{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.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,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Z.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);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 n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.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 n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){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)&&(!n||n(this.node(r))))return new Ci(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 n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;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 as(n,r,i)}
vendor: 4,369 bytes, line 2
2static resolveCached(e,n){let r=kd.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else kd.set(e,r=new u0);let s=r.elts[r.i]=as.resolve(e,n);return r.i=(r.i+1)%h0,s}}class u0{constructor(){this.elts=[],this.i=0}}const h0=12,kd=new WeakMap;class Ci{constructor(e,n,r){this.$from=e,this.$to=n,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 p0=Object.create(null);class ft{constructor(e,n,r,s=Z.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||E.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,n,r,s=0){this.content.nodesBetween(e,n,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,n,r,s){return this.content.textBetween(e,n,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,n,r){return this.type==e&&ki(this.attrs,n||e.defaultAttrs||p0)&&Z.sameSet(this.marks,r||Z.none)}copy(e=null){return e==this.content?this:new ft(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ft(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return R.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),a=s.start(o),d=s.node(o).content.cut(s.pos-a,i.pos-a);return new R(d,s.depth-o,i.depth-o)}replace(e,n,r){return c0(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return as.resolveCached(this,e)}resolveNoCache(e){return as.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,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()+")"),Jh(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=E.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),a=o&&o.matchFragment(this.content,n);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,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);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=Z.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Z.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}
2`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n 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(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=E.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}ft.prototype.text=void 0;class ji extends ft{constructor(e,n,r,s){if(super(e,n,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):Jh(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new ji(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ji(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Jh(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Bn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new f0(e,n);if(r.next==null)return Bn.empty;let s=Gh(r);r.next&&r.err("Unexpected trailing text");let i=w0(v0(s));return k0(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;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:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,a){let l=o.matchFragment(e,r);if(l&&(!n||l.validEnd))return E.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 p=i(h,a.concat(u));if(p)return p}}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 n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=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 n)&&(!s.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:s}),n[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 n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(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(` 3`)}}Bn.empty=new Bn(!0);class f0{constructor(e,n){this.string=e,this.nodeTypes=n,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 Gh(t){let e=[];do e.push(m0(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function m0(t){let e=[];do e.push(g0(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function g0(t){let e=y0(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=x0(t,e);else break;return e}function Nd(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");
vendor: 4,718 bytes, line 3
3let e=Number(t.next);return t.pos++,e}function x0(t,e){let n=Nd(t),r=n;return t.eat(",")&&(t.next!="}"?r=Nd(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function b0(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function y0(t){if(t.eat("(")){let e=Gh(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=b0(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function v0(t){let e=[[]];return s(i(t,0),n()),e;function n(){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=n())}else if(o.type=="star"){let l=n();return r(a,l),s(i(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=n();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=n();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=n();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 Qh(t,e){return e-t}function Sd(t,e){let n=[];return r(e),n.sort(Qh);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:a,to:l}=i[o];!a&&n.indexOf(l)==-1&&r(l)}}}function w0(t){let e=Object.create(null);return n(Sd(t,0));function n(r){let s=[];r.forEach(o=>{t[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]);Sd(t,l).forEach(u=>{d||s.push([a,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let i=e[r.join(",")]=new Bn(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let a=s[o][1].sort(Qh);i.next.push({type:s[o][0],next:e[a.join(",")]||n(a)})}return i}}function k0(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],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 Yh(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Xh(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function Zh(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let i=t[s];i.validate&&i.validate(e[s])}}function ep(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new S0(t,r,e[r]);return n}let Cd=class tp{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=ep(e,r.attrs),this.defaultAttrs=Yh(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==Bn.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:Xh(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ft(this,this.computeAttrs(e),E.from(n),Z.setFrom(r))}createChecked(e=null,n,r){return n=E.from(n),this.checkContent(n),new ft(this,this.computeAttrs(e),n,Z.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=E.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(E.empty,!0);return i?new ft(this,e,n.append(i),Z.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);
vendor: 10,318 bytes, lines 3-5
3if(!n||!n.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){Zh(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 n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Z.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new tp(i,n,o));let s=n.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 N0(t,e,n){let r=n.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 ${t}, got ${i}`)}}class S0{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?N0(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class po{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=ep(e,s.attrs),this.excluded=null;let i=Yh(this.attrs);this.instance=i?new Z(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Z(this,Xh(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new po(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Zh(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class np{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=Oe.from(e.nodes),n.marks=Oe.from(e.marks||{}),this.nodes=Cd.compile(this.spec.nodes,this),this.marks=po.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]=Bn.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?jd(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==""?[]:jd(this,o.split(" "))}this.nodeFromJSON=s=>ft.fromJSON(this,s),this.markFromJSON=s=>Z.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Cd){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(n,r,s)}text(e,n){let r=this.nodes.text;return new ji(r,r.defaultAttrs,e,Z.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function jd(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let a in t.marks){let l=t.marks[a];(s=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function C0(t){return t.tag!=null}function j0(t){return t.style!=null}class dn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(C0(s))this.tags.push(s);else if(j0(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,n={}){let r=new Md(this,n,!1);return r.addAll(e,Z.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Md(this,n,!0);return r.addAll(e,Z.none,n.from,n.to),R.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(E0(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,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)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let a=n[o];if((a.priority==null?50:a.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ed(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=Ed(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new dn(e,dn.schemaRules(e)))}}const rp={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},T0={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},sp={ol:!0,ul:!0},ls=1,Ja=2,Wr=4;function Td(t,e,n){return e!=null?(e?ls:0)|(e==="full"?Ja:0):t&&t.whitespace=="pre"?ls|Ja:n&~Wr}class Qs{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Z.none,this.match=i||(o&Wr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(E.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);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&ls)){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 n=E.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(E.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!rp.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Md{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=Td(null,n.preserveWhitespace,0)|(r?Wr:0);s?i=new Qs(s.type,s.attrs,Z.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Qs(null,null,Z.none,!0,null,o):i=new Qs(e.schema.topNodeType,null,Z.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Ja?"full":this.localPreserveWS||(s.options&ls)>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,` 4`);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(),n,!0),a[l]&&this.insertNode(o.text(a[l]),n,!/\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),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,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;sp.hasOwnProperty(o)&&this.parser.normalizeLists&&M0(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:T0.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);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(rp.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,n);break e}let h=l&&l.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),d&&this.sync(i),this.needsBlock=u}else{let d=this.readStyles(e,n);d&&this.addElementByRule(e,l,d,l.consuming===!1?a:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` 5`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){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?n=n.filter(d=>
vendor: 4,153 bytes, line 5
5!l.clearMark(d)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(o,n.attrs||null,r,n.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(a)&&this.open--}addAll(e,n,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,n);this.findAtPoint(e,i)}findPlace(e,n,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++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Z.none;for(let a of s.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):Ad(a.type,e.type))&&(o=a.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=Td(e,i,o.options);o.options&Wr&&o.content.length==0&&(a|=Wr);let l=Z.none;return r=r.filter(d=>(o.type?o.type.allowsMarkType(d.type):Ad(d.type,e))?(l=d.addToSet(l),!1):!0),this.nodes.push(new Qs(e,n,l,s,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=ls)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&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)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=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=n[a];if(d==""){if(a==n.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(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;
vendor: 4,451 bytes, line 5
5if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function M0(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&sp.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function E0(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ed(t){let e={};for(let n in t)e[n]=t[n];return e}function Ad(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))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 Wn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ys(n).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,n);u&&(i.push([d,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return Ys(n).createTextNode(e.text);let{dom:r,contentDOM:s}=hi(Ys(n),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,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&hi(Ys(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:hi(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Wn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Od(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Od(e.marks)}}function Od(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ys(t){return t.document||window.document}const Id=new WeakMap;function A0(t){let e=Id.get(t);return e===void 0&&Id.set(t,e=O0(t)),e}function O0(t){let e=null;function n(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++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function hi(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=A0(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&&(n=s.slice(0,o),s=s.slice(o+1));let a,l=n?t.createElementNS(n,s):t.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 p=h.indexOf(" ");p>0?l.setAttributeNS(h.slice(0,p),h.slice(p+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 p=e[h];if(p===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 if(typeof p=="string")l.appendChild(t.createTextNode(p));else{let{dom:f,contentDOM:m}=hi(t,p,n,r);if(l.appendChild(f),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const ip=65535,op=Math.pow(2,16);function I0(t,e){return t+e*op}function Pd(t){return t&ip}function P0(t){return(t-(t&ip))/op}const ap=1,lp=2,pi=4,cp=8;class Ga{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&cp)>0}get deletedBefore(){return(this.delInfo&(ap|pi))>0}get deletedAfter(){return(this.delInfo&(lp|pi))>0}get deletedAcross(){return(this.delInfo&pi)>0}}class Ge{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ge.empty)return Ge.empty}recover(e){let n=0,r=Pd(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+P0(e)}
vendor: 5,428 bytes, line 5
5mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,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 p=d?e==l?-1:e==h?1:n:n,f=l+s+(p<0?0:u);if(r)return f;let m=e==(n<0?l:h)?null:I0(a/3,e-l),g=e==l?lp:e==h?ap:pi;return(n<0?e!=l:e!=h)&&(g|=cp),new Ga(f,g,m)}s+=u-d}return r?e+s:new Ga(e+s,0,null)}touches(e,n){let r=0,s=Pd(n),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 n=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+n],u=this.ranges[s+r];e(a,a+d,l,l+u),i+=u-d}}invert(){return new Ge(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ge.empty:new Ge(e<0?[0,-e,0]:[0,0,e])}}Ge.empty=new Ge([]);class cs{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new cs(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new cs;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],a=o.mapResult(e,n);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 Ga(e,s,null)}}const da=Object.create(null);class $e{getMap(){return Ge.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=da[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in da)throw new RangeError("Duplicate use of step JSON ID "+e);return da[e]=n,n.prototype.jsonID=e,n}}class we{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new we(e,null)}static fail(e){return new we(null,e)}static fromReplace(e,n,r,s){try{return we.ok(e.replace(n,r,s))}catch(i){if(i instanceof Ni)return we.fail(i.message);throw i}}}function Il(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Il(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return E.fromArray(r)}class an extends $e{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new R(Il(n.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return we.fromReplace(e,this.from,this.to,i)}invert(){return new pt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new an(n.pos,r.pos,this.mark)}merge(e){return e instanceof an&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new an(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new an(n.from,n.to,e.markFromJSON(n.mark))}}$e.jsonID("addMark",an);class pt extends $e{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new R(Il(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return we.fromReplace(e,this.from,this.to,r)}invert(){return new an(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new pt(n.pos,r.pos,this.mark)}merge(e){return e instanceof pt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new pt(n.from,n.to,e.markFromJSON(n.mark))}}$e.jsonID("removeMark",pt);class ln extends $e{constructor(e,n){super(),this.pos=e,this.mark=n}
vendor: 10,358 bytes, lines 5-6
5apply(e){let n=e.nodeAt(this.pos);if(!n)return we.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return we.fromReplace(e,this.pos,this.pos+1,new R(E.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new ln(this.pos,n.marks[s]);return new ln(this.pos,this.mark)}}return new $n(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ln(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ln(n.pos,e.markFromJSON(n.mark))}}$e.jsonID("addNodeMark",ln);class $n extends $e{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return we.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return we.fromReplace(e,this.pos,this.pos+1,new R(E.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ln(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new $n(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new $n(n.pos,e.markFromJSON(n.mark))}}$e.jsonID("removeNodeMark",$n);class ve extends $e{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Qa(e,this.from,this.to)?we.fail("Structure replace would overwrite content"):we.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ge([this.from,this.to-this.from,this.slice.size])}invert(e){return new ve(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&ve.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new ve(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ve)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?R.empty:new R(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ve(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?R.empty:new R(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ve(e.from,this.to,n,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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ve(n.from,n.to,R.fromJSON(e,n.slice),!!n.structure)}}ve.MAP_BIAS=1;$e.jsonID("replace",ve);class Te extends $e{constructor(e,n,r,s,i,o,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=a}apply(e){if(this.structure&&(Qa(e,this.from,this.gapFrom)||Qa(e,this.gapTo,this.to)))return we.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return we.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?we.fromReplace(e,this.from,this.to,r):we.fail("Content does not fit in gap")}getMap(){return new Ge([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Te(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Te(n.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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Te(n.from,n.to,n.gapFrom,n.gapTo,R.fromJSON(e,n.slice),n.insert,!!n.structure)}}$e.jsonID("replaceAround",Te);function Qa(t,e,n){let r=t.resolve(e),s=n-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 R0(t,e,n,r){let s=[],i=[],o,a;t.doc.nodesBetween(e,n,(l,d,u)=>{if(!l.isInline)return;let h=l.marks;if(!r.isInSet(h)&&u.type.allowsMarkType(r.type)){let p=Math.max(d,e),f=Math.min(d+l.nodeSize,n),m=r.addToSet(h);for(let g=0;g<h.length;g++)h[g].isInSet(m)||(o&&o.to==p&&o.mark.eq(h[g])?o.to=f:s.push(o=new pt(p,f,h[g])));a&&a.to==p?a.to=f:i.push(a=new an(p,f,r))}}),s.forEach(l=>t.step(l)),i.forEach(l=>t.step(l))}function D0(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,a)=>{if(!o.isInline)return;i++;let l=null;if(r instanceof po){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,n);for(let u=0;u<l.length;u++){let h=l[u],p;for(let f=0;f<s.length;f++){let m=s[f];m.step==i-1&&h.eq(s[f].style)&&(p=m)}p?(p.to=d,p.step=i):s.push({style:h,from:Math.max(a,e),to:d,step:i})}}}),s.forEach(o=>t.step(new pt(o.from,o.to,o.style)))}function Pl(t,e,n,r=n.contentMatch,s=!0){let i=t.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 ve(a,u,R.empty));else{r=h;for(let p=0;p<d.marks.length;p++)n.allowsMarkType(d.marks[p].type)||t.step(new pt(a,u,d.marks[p]));if(s&&d.isText&&n.whitespace!="pre"){let p,f=/\r?\n|\r/g,m;for(;p=f.exec(d.text);)m||(m=new R(E.from(n.schema.text(" ",n.allowedMarks(d.marks))),0,0)),o.push(new ve(a+p.index,a+p.index+p[0].length,m))}}a=u}if(!r.validEnd){let l=r.fillBefore(E.empty,!0);t.replace(a,a,new R(l,0,0))}for(let l=o.length-1;l>=0;l--)t.step(o[l])}function L0(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function kr(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),a=t.$from.index(r)+s,l=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(a,l,n))return r;if(r==0||o.type.spec.isolating||!L0(o,a,l))break;a&&(s=1),l<o.childCount&&(i=1)}return null}function z0(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),a=s.after(i+1),l=o,d=a,u=E.empty,h=0;for(let m=i,g=!1;m>n;m--)g||r.index(m)>0?(g=!0,u=E.from(r.node(m).copy(u)),h++):l--;let p=E.empty,f=0;for(let m=i,g=!1;m>n;m--)g||s.after(m+1)<s.end(m)?(g=!0,p=E.from(s.node(m).copy(p)),f++):d++;t.step(new Te(l,d,o,a,new R(u.append(p),h,f),u.size-h,!0))}function Rl(t,e,n=null,r=t){let s=B0(t,e),i=s&&$0(r,e);return i?s.map(Rd).concat({type:e,attrs:n}).concat(i.map(Rd)):null}function Rd(t){return{type:t,attrs:null}}function B0(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function $0(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.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(n.child(d).type);return!l||!l.validEnd?null:o}function _0(t,e,n){let r=E.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let a=n[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=E.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new Te(s,i,s,i,new R(r,0,0),n.length,!0))}function H0(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,a)=>{let l=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,l)&&F0(t.doc,t.mapping.slice(i).map(a),r)){let d=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!m?d=!1:!f&&m&&(d=!0)}d===!1&&up(t,o,a,i),Pl(t,t.mapping.slice(i).map(a,1),r,void 0,d===null);let u=t.mapping.slice(i),h=u.map(a,1),p=u.map(a+o.nodeSize,1);return t.step(new Te(h,p,h+1,p-1,new R(E.from(r.create(l,null,o.marks)),0,0),1,!0)),d===!0&&dp(t,o,a,i),!1}})}function dp(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(s.text);){let l=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function up(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(` 6`))}})}function F0(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function V0(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Te(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new R(E.from(o),0,0),1,!0))}function Ht(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,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=n-2;d>i;
vendor: 2,679 bytes, line 6
6d--,u--){let h=s.node(d),p=s.index(d);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(p,h.childCount),m=r&&r[u+1];m&&(f=f.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[u]||h;if(!h.canReplace(p+1,h.childCount)||!g.type.validContent(f))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 q0(t,e,n=1,r){let s=t.doc.resolve(e),i=E.empty,o=E.empty;for(let a=s.depth,l=s.depth-n,d=n-1;a>l;a--,d--){i=E.from(s.node(a).copy(i));let u=r&&r[d];o=E.from(u?u.type.create(u.attrs,o):s.node(a).copy(o))}t.step(new ve(e,e,new R(i.append(o),n,n),!0))}function gn(t,e){let n=t.resolve(e),r=n.index();return hp(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function K0(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function hp(t,e){return!!(t&&e&&!t.isLeaf&&K0(t,e))}function fo(t,e,n=-1){let r=t.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):n>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&&hp(i,o)&&r.node(s).canReplace(a,a+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function W0(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),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=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);up(t,u.node(),u.before(),a)}o.inlineContent&&Pl(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let l=t.mapping.slice(a),d=l.map(e-n);if(t.step(new ve(d,l.map(e+n,-1),R.empty,!0)),r===!0){let u=t.doc.resolve(d);dp(t,u.node(),u.before(),t.steps.length)}return t}function U0(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))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,n))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,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function pp(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.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.
vendor: 7,544 bytes, line 6
6index(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 mo(t,e,n=e,r=R.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return fp(s,i,r)?new ve(e,n,r):new J0(s,i,r).fit()}function fp(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class J0{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=E.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=E.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(),n=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 R(i,o,a);return e>-1?new Te(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new ve(r.pos,s.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=ua(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(n==1&&(o?d.matchType(o.type)||(h=d.fillBefore(E.from(o),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:a,parent:i,inject:h};if(n==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:n,openEnd:r}=this.unplaced,s=ua(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new R(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=ua(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new R($r(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new R($r(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)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:p}=this.frontier[n];if(s){for(let g=0;g<s.childCount;g++)u.push(s.child(g));h=h.matchFragment(s)}let f=a.size+e-(o.content.size-o.openEnd);for(;d<a.childCount;){let g=a.child(d),b=h.matchType(g.type);if(!b)break;d++,(d>1||l==0||g.content.size)&&(h=b,u.push(mp(g.mark(p.allowedMarks(g.marks)),d==1?l:0,d==a.childCount?f:-1)))}let m=d==a.childCount;m||(f=-1),this.placed=_r(this.placed,n,E.from(u)),this.frontier[n].match=h,m&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,b=a;g<f;g++){let y=b.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),b=y.content}this.unplaced=m?e==0?R.empty:new R($r(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new R($r(o.content,e,d),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!ha(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.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 n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=ha(e,n,s,r,i);if(o){for(let a=n-1;a>=0;a--){let{match:l,type:d}=this.frontier[a],u=ha(e,a,d,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=_r(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.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,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=_r(this.placed,this.depth,E.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(E.empty,!0);n.childCount&&(this.placed=_r(this.placed,this.frontier.length,n))}}function $r(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy($r(t.firstChild.content,e-1,n)))}function _r(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(_r(t.lastChild.content,e-1,n)))}function ua(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function mp(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,mp(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(E.empty,!0)))),t.copy(r)}function ha(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,o);return a&&!G0(n,i.content,o)?a:null}function G0(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Q0(t){return t.spec.defining||t.spec.definingForContent}function Y0(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(fp(s,i,r))return t.step(new ve(e,n,r));let o=xp(s,i);o[o.length-1]==0&&o.pop();let a=-(s.depth+1);o.unshift(a);for(let p=s.depth,f=s.pos-1;p>0;p--,f--){let m=s.node(p).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;o.indexOf(p)>-1?a=p:s.before(p)==f&&o.splice(1,0,-p)}let l=o.indexOf(a),d=[],u=r.openStart;for(let p=r.content,f=0;;f++){let m=p.firstChild;if(d.push(m),f==r.openStart)break;p=m.content}for(let p=u-1;p>=0;p--){let f=d[p],m=Q0(f.type);if(m&&!f.sameMarkup(s.node(Math.abs(a)-1)))u=p;else if(m||!f.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let f=(p+u+1)%(r.openStart+1),m=d[f];if(m)for(let g=0;g<o.length;g++){let b=o[(g+l)%o.length],y=!0;b<0&&(y=!1,b=-b);let k=s.node(b-1),C=s.index(b-1);if(k.canReplaceWith(C,C,m.type,m.marks))return t.replace(s.before(b),y?i.after(b):n,new R(gp(r.content,0,r.openStart,f),f,r.openEnd))}}let h=t.steps.length;for(let p=o.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>h));p--){let f=o[p];f<0||(e=s.before(f),n=i.after(f))}}function gp(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(gp(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(E.empty,!0))}return t}function X0(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=U0(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new R(E.from(r),0,0))}function Z0(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(n),a=!1;for(let l=r.depth;l>o;
vendor: 4,140 bytes, line 6
6l--)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&&n==s.start(l);l--)n=s.before(l);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let i=xp(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 t.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 t.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&&n>r.end(o)&&s.end(o)-n!=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 t.delete(r.before(o),n);t.delete(e,n)}function xp(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class pr extends $e{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return we.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return we.fromReplace(e,this.pos,this.pos+1,new R(E.from(s),0,n.isLeaf?0:1))}getMap(){return Ge.empty}invert(e){return new pr(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new pr(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new pr(n.pos,n.attr,n.value)}}$e.jsonID("attr",pr);class ds extends $e{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return we.ok(r)}getMap(){return Ge.empty}invert(e){return new ds(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ds(n.attr,n.value)}}$e.jsonID("docAttr",ds);let mr=class extends Error{};mr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};mr.prototype=Object.create(Error.prototype);mr.prototype.constructor=mr;mr.prototype.name="TransformError";class Dl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new cs}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new mr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,a,l)=>{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=R.empty){let s=mo(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new R(E.from(r),0,0))}delete(e,n){return this.replace(e,n,R.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Y0(this,e,n,r),this}replaceRangeWith(e,n,r){return X0(this,e,n,r),this}deleteRange(e,n){return Z0(this,e,n),this}lift(e,n){return z0(this,e,n),this}join(e,n=1){return W0(this,e,n),this}wrap(e,n){return _0(this,e,n),this}setBlockType(e,n=e,r,s=null){return H0(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return V0(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new pr(e,n,r)),this}setDocAttribute(e,n){return this.step(new ds(e,n)),this}addNodeMark(e,n){return this.step(new ln(e,n)),this}
vendor: 5,069 bytes, line 6
6removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Z)n.isInSet(r.marks)&&this.step(new $n(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new $n(e,i)),s=i.removeFromSet(s);for(let a=o.length-1;a>=0;a--)this.step(o[a])}return this}split(e,n=1,r){return q0(this,e,n,r),this}addMark(e,n,r){return R0(this,e,n,r),this}removeMark(e,n,r){return D0(this,e,n,r),this}clearIncompatible(e,n,r){return Pl(this,e,n,r),this}}const pa=Object.create(null);class F{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new bp(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=R.empty){let r=n.content.lastChild,s=null;for(let a=0;a<n.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?R.empty:n),a==0&&zd(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){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,n),zd(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new $(e):lr(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?lr(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):lr(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ye(e.node(0))}static atStart(e){return lr(e,e,0,0,1)||new Ye(e)}static atEnd(e){return lr(e,e,e.content.size,e.childCount,-1)||new Ye(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=pa[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in pa)throw new RangeError("Duplicate use of selection JSON ID "+e);return pa[e]=n,n.prototype.jsonID=e,n}getBookmark(){return $.between(this.$anchor,this.$head).getBookmark()}}F.prototype.visible=!0;class bp{constructor(e,n){this.$from=e,this.$to=n}}let Dd=!1;function Ld(t){!Dd&&!t.parent.inlineContent&&(Dd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class $ extends F{constructor(e,n=e){Ld(e),Ld(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return F.near(r);let s=e.resolve(n.map(this.anchor));return new $(s.parent.inlineContent?s:r,r)}replace(e,n=R.empty){if(super.replace(e,n),n==R.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof $&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new go(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new $(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=F.findFrom(n,r,!0)||F.findFrom(n,-r,!0);if(i)n=i.$head;else return F.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(F.findFrom(e,-r,!0)||F.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new $(e,n)}}F.jsonID("text",$);class go{constructor(e,n){this.anchor=e,this.head=n}map(e){return new go(e.map(this.anchor),e.map(this.head))}resolve(e){return $.between(e.resolve(this.anchor),e.resolve(this.head))}}class B extends F{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?F.near(i):new B(i)}content(){return new R(E.from(this.node),0,0)}eq(e){return e instanceof B&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ll(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new B(e.resolve(n.anchor))}static create(e,n){return new B(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}B.prototype.visible=!1;F.jsonID("node",B);class Ll{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new go(r,r):new Ll(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&B.isSelectable(r)?new B(n):F.near(n)}}class Ye extends F{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}
vendor: 4,231 bytes, line 6
6replace(e,n=R.empty){if(n==R.empty){e.delete(0,e.doc.content.size);let r=F.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ye(e)}map(e){return new Ye(e)}eq(e){return e instanceof Ye}getBookmark(){return eb}}F.jsonID("all",Ye);const eb={map(){return this},resolve(t){return new Ye(t)}};function lr(t,e,n,r,s,i=!1){if(e.inlineContent)return $.create(t,n);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&&B.isSelectable(a))return B.create(t,n-(s<0?a.nodeSize:0))}else{let l=lr(t,a,n+s,s<0?a.childCount:0,s,i);if(l)return l}n+=a.nodeSize*s}return null}function zd(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof ve||s instanceof Te))return;let i=t.mapping.maps[r],o;i.forEach((a,l,d,u)=>{o==null&&(o=u)}),t.setSelection(F.near(t.doc.resolve(o),n))}const Bd=1,Xs=2,$d=4;class tb extends Dl{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|Bd)&~Xs,this.storedMarks=null,this}get selectionSet(){return(this.updated&Bd)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Xs,this}ensureMarks(e){return Z.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&Xs)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Xs,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Z.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(F.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,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|=$d,this}get scrolledIntoView(){return(this.updated&$d)>0}}function _d(t,e){return!e||!t?t:t.bind(e)}class Hr{constructor(e,n,r){this.name=e,this.init=_d(n.init,r),this.apply=_d(n.apply,r)}}const nb=[new Hr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Hr("selection",{init(t,e){return t.selection||F.atStart(e.doc)},apply(t){return t.selection}}),new Hr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Hr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class fa{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=nb.slice(),n&&n.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 Hr(r.key,r.spec.state,r))})}}class ur{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}
vendor: 4,133 bytes, line 6
6apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){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 n=[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<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,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:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ur(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new tb(this)}static create(e){let n=new fa(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ur(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new fa(this.schema,e.plugins),r=n.fields,s=new ur(n);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 n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.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&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new fa(e.schema,e.plugins),i=new ur(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=ft.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=F.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.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(n,a)){i[o.name]=d.fromJSON.call(l,e,n[a],i);return}}i[o.name]=o.init(e,i)}}),i}}function yp(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=yp(s,e,{})),n[r]=s}return n}class te{constructor(e){this.spec=e,this.props={},e.props&&yp(e.props,this,this.props),this.key=e.key?e.key.key:vp("plugin")}getState(e){return e[this.key]}}const ma=Object.create(null);function vp(t){return t in ma?t+"$"+ ++ma[t]:(ma[t]=0,t+"$")}class ae{constructor(e="key"){this.key=vp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const wp=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function kp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Np=(t,e,n)=>{let r=kp(t,n);if(!r)return!1;let s=zl(r);if(!s){let o=r.blockRange(),a=o&&kr(o);return a==null?!1:(e&&e(t.tr.lift(o,a).scrollIntoView()),!0)}let i=s.nodeBefore;if(Ip(t,s,e,-1))return!0;if(r.parent.content.size==0&&(gr(i,"end")||B.isSelectable(i)))for(let o=r.depth;;o--){let a=mo(t.doc,r.before(o),r.after(o),R.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(gr(i,"end")?F.findFrom(l.doc.resolve(l.mapping.map(s.pos,-1)),-1):B.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(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},rb=(t,e,n)=>{let r=kp(t,n);if(!r)return!1;let s=zl(r);return s?Sp(t,s,e):!1},sb=(t,e,n)=>{let r=jp(t,n);if(!r)return!1;let s=Bl(r);return s?Sp(t,s,e):!1};function Sp(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;
vendor: 6,434 bytes, lines 6-7
6i--){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=mo(t.doc,i,l,R.empty);if(!d||d.from!=i||d instanceof ve&&d.slice.size>=l-i)return!1;if(n){let u=t.tr.step(d);u.setSelection($.create(u.doc,i)),n(u.scrollIntoView())}return!0}function gr(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Cp=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=zl(r)}let o=i&&i.nodeBefore;return!o||!B.isSelectable(o)?!1:(e&&e(t.tr.setSelection(B.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function zl(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function jp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Tp=(t,e,n)=>{let r=jp(t,n);if(!r)return!1;let s=Bl(r);if(!s)return!1;let i=s.nodeAfter;if(Ip(t,s,e,1))return!0;if(r.parent.content.size==0&&(gr(i,"start")||B.isSelectable(i))){let o=mo(t.doc,r.before(),r.after(),R.empty);if(o&&o.slice.size<o.to-o.from){if(e){let a=t.tr.step(o);a.setSelection(gr(i,"start")?F.findFrom(a.doc.resolve(a.mapping.map(s.pos)),1):B.create(a.doc,a.mapping.map(s.pos))),e(a.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},Mp=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=Bl(r)}let o=i&&i.nodeAfter;return!o||!B.isSelectable(o)?!1:(e&&e(t.tr.setSelection(B.create(t.doc,i.pos)).scrollIntoView()),!0)};function Bl(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const ib=(t,e)=>{let n=t.selection,r=n instanceof B,s;if(r){if(n.node.isTextblock||!gn(t.doc,n.from))return!1;s=n.from}else if(s=fo(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(B.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},ob=(t,e)=>{let n=t.selection,r;if(n instanceof B){if(n.node.isTextblock||!gn(t.doc,n.to))return!1;r=n.to}else if(r=fo(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},ab=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&kr(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},Ep=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` 7`).scrollIntoView()),!0)};function $l(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const lb=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=$l(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,o.createAndFill());l.setSelection(F.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},Ap=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof Ye||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=$l(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=t.tr.insert(o,i.createAndFill());a.setSelection($.create(a.doc,o+1)),e(a.scrollIntoView())}return!0},Op=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ht(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&kr(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function cb(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof B&&e.selection.node.isBlock)return!r.parentOffset||!Ht(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,a,l=!1,d=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){l=r.end(f)==r.pos+(r.depth-f),d=r.start(f)==r.pos-(r.depth-f),a=$l(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),i.unshift(l&&a?{type:a}:null),o=f;break}else{if(f==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof $||e.selection instanceof Ye)&&u.deleteSelection();let h=u.mapping.map(r.pos),p=Ht(u.doc,h,i.length,i);if(p||(i[0]=a?{type:a}:null,p=Ht(u.doc,h,i.length,i)),!p)return!1;if(u.split(h,i.length,i),!l&&d&&r.node(o).type!=a){let f=u.mapping.map(r.before(o)),m=u.doc.resolve(f);a&&r.node(o-1).canReplaceWith(m.index(),m.index()+1,a)&&u.setNodeMarkup(u.mapping.map(r.before(o)),a)}return n&&n(u.scrollIntoView()),!0}}const db=cb(),ub=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(B.create(t.doc,s))),!0)};function hb(t,e,n){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)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||gn(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Ip(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,a,l=s.type.spec.isolating||i.type.spec.isolating;if(!l&&hb(t,e,n))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(n){let f=e.pos+i.nodeSize,m=E.empty;for(let y=o.length-1;y>=0;y--)m=E.from(o[y].create(null,m));m=E.from(s.copy(m));let g=t.tr.step(new Te(e.pos-1,f,e.pos,f,new R(m,1,0),o.length,!0)),b=g.doc.resolve(f+2*o.length);b.nodeAfter&&b.nodeAfter.type==s.type&&gn(g.doc,b.pos)&&g.join(b.pos),n(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&l?null:F.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),p=h&&kr(h);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(h,p).scrollIntoView()),!0;if(d&&gr(i,"start",!0)&&gr(s,"end")){let f=s,m=[];for(;m.push(f),!f.isTextblock;)f=f.lastChild;let g=i,b=1;for(;!g.isTextblock;g=g.firstChild)b++;
vendor: 4,592 bytes, line 7
7if(f.canReplace(f.childCount,f.childCount,g.content)){if(n){let y=E.empty;for(let C=m.length-1;C>=0;C--)y=E.from(m[C].copy(y));let k=t.tr.step(new Te(e.pos-m.length,e.pos+i.nodeSize,e.pos+b,e.pos+i.nodeSize-b,new R(y,m.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function Pp(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection($.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const pb=Pp(-1),fb=Pp(1);function mb(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),a=o&&Rl(o,t,e);return a?(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0):!1}}function Hd(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:a}}=n.selection.ranges[i];n.doc.nodesBetween(o,a,(l,d)=>{if(s)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)s=!0;else{let u=n.doc.resolve(d),h=u.index();s=u.parent.canReplaceWith(h,h+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[o];i.setBlockType(a,l,t,e)}r(i.scrollIntoView())}return!0}}function _l(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}_l(wp,Np,Cp);_l(wp,Tp,Mp);_l(Ep,Ap,Op,db);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function gb(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let a=r?n.tr:null;return xb(a,o,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function xb(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=o.resolve(e.start-2);i=new Ci(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new Ci(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let a=Rl(i,n,r,e);return a?(t&&bb(t,e,a,s,n),!0):!1}function bb(t,e,n,r,s){let i=E.empty;for(let u=n.length-1;u>=0;u--)i=E.from(n[u].type.create(n[u].attrs,i));t.step(new Te(e.start-(r?2:0),e.end,e.start,e.end,new R(i,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==s&&(o=u+1);let a=n.length-o,l=e.start+n.length-(r?2:0),d=e.parent;for(let u=e.startIndex,h=e.endIndex,p=!0;u<h;u++,p=!1)!p&&Ht(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=d.child(u).nodeSize;return t}function yb(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?vb(e,n,t,i):wb(e,n,i):!0:!1}}function vb(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new Te(i-1,o,i,o,new R(E.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Ci(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const a=kr(r);if(a==null)return!1;s.lift(r,a);let l=s.doc.resolve(s.mapping.map(i,-1)-1);return gn(s.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&s.join(l.pos),e(s.scrollIntoView()),!0}function wb(t,e,n){let r=t.tr,s=n.parent;for(let f=n.end,m=n.endIndex-1,g=n.startIndex;m>g;m--)f-=s.child(m).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==s.childCount,d=i.node(-1),u=i.index(-1);if(!d.canReplace(u+(a?0:1),u+1,o.content.append(l?E.empty:E.from(s))))return!1;let h=i.pos,p=h+o.nodeSize;return r.step(new Te(h-(a?1:0),p+(l?1:0),h+1,p-1,new R((a?E.empty:E.from(s.copy(E.empty))).append(l?E.empty:E.from(s.copy(E.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function kb(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,d=>d.childCount>0&&d.firstChild.type==t);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!=t)return!1;if(n){let d=l.lastChild&&l.lastChild.type==a.type,u=E.from(d?t.create():null),h=new R(E.from(t.create(null,E.from(a.type.create(null,u)))),d?3:1,0),p=i.start,f=i.end;n(e.tr.step(new Te(p-(d?3:1),f,p,f,h,1,!0)).scrollIntoView())}return!0}}const Ie=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},xr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Ya=null;const Bt=function(t,e,n){let r=Ya||(Ya=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Nb=function(){Ya=null},_n=function(t,e,n,r){return n&&(Fd(t,e,n,r,-1)||Fd(t,e,n,r,1))},Sb=/^(img|br|input|textarea|hr)$/i;function Fd(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;
vendor: 5,607 bytes, line 7
7if(e==(s<0?0:ot(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ss(t)||Sb.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ie(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.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 t=o,e=s<0?ot(t):0}else return!1}}function ot(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Cb(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=ot(t)}else if(t.parentNode&&!Ss(t))e=Ie(t),t=t.parentNode;else return null}}function jb(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Ss(t))e=Ie(t)+1,t=t.parentNode;else return null}}function Tb(t,e,n){for(let r=e==0,s=e==ot(t);r||s;){if(t==n)return!0;let i=Ie(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==ot(t)}}function Ss(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const xo=function(t){return t.focusNode&&_n(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Tn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Mb(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Eb(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ot(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ot(r.startContainer),r.startOffset)}}}const St=typeof navigator<"u"?navigator:null,Vd=typeof document<"u"?document:null,xn=St&&St.userAgent||"",Xa=/Edge\/(\d+)/.exec(xn),Rp=/MSIE \d/.exec(xn),Za=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(xn),We=!!(Rp||Za||Xa),un=Rp?document.documentMode:Za?+Za[1]:Xa?+Xa[1]:0,at=!We&&/gecko\/(\d+)/i.test(xn);at&&+(/Firefox\/(\d+)/.exec(xn)||[0,0])[1];const el=!We&&/Chrome\/(\d+)/.exec(xn),Re=!!el,Dp=el?+el[1]:0,ze=!We&&!!St&&/Apple Computer/.test(St.vendor),br=ze&&(/Mobile\/\w+/.test(xn)||!!St&&St.maxTouchPoints>2),st=br||(St?/Mac/.test(St.platform):!1),Lp=St?/Win/.test(St.platform):!1,$t=/Android \d/.test(xn),Cs=!!Vd&&"webkitFontSmoothing"in Vd.documentElement.style,Ab=Cs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ob(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Ot(t,e){return typeof t=="number"?t:t[e]}function Ib(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function qd(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=xr(o);continue}let a=o,l=a==i.body,d=l?Ob(i):Ib(a),u=0,h=0;if(e.top<d.top+Ot(r,"top")?h=-(d.top-e.top+Ot(s,"top")):e.bottom>d.bottom-Ot(r,"bottom")&&(h=e.bottom-e.top>d.bottom-d.top?e.top+Ot(s,"top")-d.top:e.bottom-d.bottom+Ot(s,"bottom")),e.left<d.left+Ot(r,"left")?u=-(d.left-e.left+Ot(s,"left")):e.right>d.right-Ot(r,"right")&&(u=e.right-d.right+Ot(s,"right")),u||h)if(l)i.defaultView.scrollBy(u,h);else{let f=a.scrollLeft,m=a.scrollTop;h&&(a.scrollTop+=h),u&&(a.scrollLeft+=u);let g=a.scrollLeft-f,b=a.scrollTop-m;e={left:e.left-g,top:e.top-b,right:e.right-g,bottom:e.bottom-b}}let p=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:xr(o)}}function Pb(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let a=t.root.elementFromPoint(i,o);if(!a||a==t.dom||!t.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,s=l.top;break}}return{refDOM:r,refTop:s,stack:zp(t.dom)}}function zp(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=xr(r));return e}function Rb({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Bp(n,r==0?0:r-e)}function Bp(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let ir=null;function Db(t){if(t.setActive)return t.setActive();if(ir)return t.focus(ir);let e=zp(t);t.focus(ir==null?{get preventScroll(){return ir={preventScroll:!0},!0}}:void 0),ir||(ir=!1,Bp(e,0))}function $p(t,e){let n,r=2e8,s,i=0,o=e.top,a=e.top,l,d;for(let u=t.firstChild,h=0;u;u=u.nextSibling,h++){let p;if(u.nodeType==1)p=u.getClientRects();else if(u.nodeType==3)p=Bt(u).getClientRects();else continue;for(let f=0;f<p.length;f++){let m=p[f];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){n=u,r=g,s=g&&n.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});!n&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(i=h+1)}}return!n&&l&&(n=l,s=d,r=0),n&&n.nodeType==3?Lb(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:$p(n,s)}
vendor: 11,120 bytes, lines 7-8
7function Lb(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=Yt(r,1);if(o.top!=o.bottom&&Hl(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Hl(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function zb(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Bb(t,e,n){let{node:r,offset:s}=$p(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function $b(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let a=t.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:t.docView.posFromDOM(e,n,-1)}function _p(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let a=o.getClientRects();for(let l=0;l<a.length;l++){let d=a[l];if(Hl(e,d))return _p(o,e,d)}}if((i=(i+1)%r)==s)break}return t}function _b(t,e){let n=t.dom.ownerDocument,r,s=0,i=Eb(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),a;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let d=t.dom.getBoundingClientRect();if(!Hl(e,d)||(o=_p(t.dom,e,d),!o))return null}if(ze)for(let d=o;r&&d;d=xr(d))d.draggable&&(r=void 0);if(o=zb(o,e),r){if(at&&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;Cs&&s&&r.nodeType==1&&(d=r.childNodes[s-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(a=$b(t,r,s,e))}a==null&&(a=Bb(t,o,e));let l=t.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Kd(t){return t.top<t.bottom||t.left<t.right}function Yt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Kd(r))return r}return Array.prototype.find.call(n,Kd)||t.getBoundingClientRect()}const Hb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Hp(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=Cs||at;if(r.nodeType==3)if(o&&(Hb.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let l=Yt(Bt(r,s,s),n);if(at&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let d=Yt(Bt(r,s-1,s-1),-1);if(d.top==l.top){let u=Yt(Bt(r,s,s+1),-1);if(u.top!=l.top)return Pr(u,u.left<d.left)}}return l}else{let l=s,d=s,u=n<0?1:-1;return n<0&&!s?(d++,u=-1):n>=0&&s==r.nodeValue.length?(l--,u=1):n<0?l--:d++,Pr(Yt(Bt(r,l,d),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==ot(r))){let l=r.childNodes[s-1];if(l.nodeType==1)return ga(l.getBoundingClientRect(),!1)}if(i==null&&s<ot(r)){let l=r.childNodes[s];if(l.nodeType==1)return ga(l.getBoundingClientRect(),!0)}return ga(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==ot(r))){let l=r.childNodes[s-1],d=l.nodeType==3?Bt(l,ot(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(d)return Pr(Yt(d,1),!1)}if(i==null&&s<ot(r)){let l=r.childNodes[s];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let d=l?l.nodeType==3?Bt(l,0,o?0:1):l.nodeType==1?l:null:null;if(d)return Pr(Yt(d,-1),!0)}return Pr(Yt(r.nodeType==3?Bt(r):r,-n),n>=0)}function Pr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function ga(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Fp(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function Fb(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return Fp(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.contentDOM||a.dom;break}i=a.dom.parentNode}let o=Hp(t,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=Bt(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&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const Vb=/[\u0590-\u08ac]/;function qb(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,a=t.domSelection();return a?!Vb.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?i:o:Fp(t,e,()=>{let{focusNode:l,focusOffset:d,anchorNode:u,anchorOffset:h}=t.domSelectionRange(),p=a.caretBidiLevel;a.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:m,focusOffset:g}=t.domSelectionRange(),b=m&&!f.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 p!=null&&(a.caretBidiLevel=p),b}):r.pos==r.start()||r.pos==r.end()}let Wd=null,Ud=null,Jd=!1;function Kb(t,e,n){return Wd==e&&Ud==n?Jd:(Wd=e,Ud=n,Jd=n=="up"||n=="down"?Fb(t,e,n):qb(t,e,n))}const lt=0,Gd=1,En=2,Ct=3;class js{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=lt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].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 n=0,r=this.posAtStart;;n++){let s=this.children[n];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,n,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[n-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[n];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=n>Ie(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(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==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,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||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 n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],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,n){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 qp){s=e-i;break}i=a}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Vp&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Ie(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,n):{node:this.contentDOM,offset:i?Ie(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,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&&n<=d-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=o;for(let h=a;h>0;h--){let p=this.children[h-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){s=Ie(p.dom)+1;break}e-=p.size}s==-1&&(s=0)}if(s>-1&&(d>n||a==this.children.length-1)){n=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=Ie(h.dom);break}n+=h.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=d}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let f=0,m=0;f<this.children.length;f++){let g=this.children[f],b=m+g.size;if(i>m&&o<b)return g.setSelection(e-m-g.border,n-m-g.border,r,s);m=b}let a=this.domFromPos(e,e?-1:1),l=n==e?a:this.domFromPos(n,n?-1:1),d=r.root.getSelection(),u=r.domSelectionRange(),h=!1;if((at||ze)&&e==n){let{node:f,offset:m}=a;if(f.nodeType==3){if(h=!!(m&&f.nodeValue[m-1]==` 8`),h&&m==f.nodeValue.length)for(let g=f,b;g;g=g.parentNode){if(b=g.nextSibling){b.nodeName=="BR"&&(a=l={node:b.parentNode,offset:Ie(b)+1});break}
vendor: 4,470 bytes, line 8
8let y=g.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let g=f.childNodes[m-1];h=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(at&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(s=!0)}if(!(s||h&&ze)&&_n(a.node,a.offset,u.anchorNode,u.anchorOffset)&&_n(l.node,l.offset,u.focusNode,u.focusOffset))return;let p=!1;if((d.extend||e==n)&&!(h&&at)){d.collapse(a.node,a.offset);try{e!=n&&d.extend(l.node,l.offset),p=!0}catch{}}if(!p){if(e>n){let m=a;a=l,l=m}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),d.removeAllRanges(),d.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){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&&n>=r:e<o&&n>r){let a=r+i.border,l=o-i.border;if(e>=a&&n<=l){this.dirty=e==r||n==o?En:Gd,e==a&&n==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ct:i.markDirty(e-a,n-a);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?En:Ct}r=o}this.dirty=En}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?En:Gd;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Vp extends js{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.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=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==lt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(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 Wb extends js{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Hn extends js{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=Wn.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Hn(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ct||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ct&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=lt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=lt}}slice(e,n,r){let s=Hn.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=nl(i,n,o,r)),e>0&&(i=nl(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 hn extends js{constructor(e,n,r,s,i,o,a,l,d){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=a}static create(e,n,r,s,i,o){let a=i.nodeViews[n.type.name],l,d=a&&a(n,i,()=>{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,s),u=d&&d.dom,h=d&&d.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=Wn.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let p=u;return u=Up(u,r,n),d?l=new Ub(e,n,r,s,u,h||null,p,d,i,o+1):n.isText?new bo(e,n,r,s,u,p,i):new hn(e,n,r,s,u,h||null,p,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;
vendor: 5,105 bytes, line 8
8let 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 n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>E.empty)}return e}matchesNode(e,n,r){return this.dirty==lt&&e.eq(this.node)&&Ti(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,a=i&&i.pos<0,l=new Gb(this,o&&o.node,e);Xb(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?Z.none:this.node.child(u).marks,r,e,u),l.placeWidget(d,e,s)},(d,u,h,p)=>{l.syncToMarks(d.marks,r,e,p);let f;l.findNodeMatch(d,u,h,p)||a&&e.state.selection.from>s&&e.state.selection.to<s+d.nodeSize&&(f=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(d,u,h,f,e)||l.updateNextNode(d,u,h,e,p,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==En)&&(o&&this.protectLocalComposition(e,o),Kp(this.contentDOM,this.children,e),br&&Zb(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof $)||r<n||s>n+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=ey(this.node.content,o,r-n,s-n);return a<0?null:{node:i,pos:a,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;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 Wb(this,i,n,s);e.input.compositionNodes.push(o),this.children=nl(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==Ct||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=lt}updateOuterDeco(e){if(Ti(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Wp(this.dom,this.nodeDOM,tl(this.outerDeco,this.node,n),tl(e,this.node,n)),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 Qd(t,e,n,r,s){Up(r,e,t);let i=new hn(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class bo extends hn{constructor(e,n,r,s,i,o,a){super(e,n,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,n,r,s){return this.dirty==Ct||this.dirty!=lt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=lt||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=lt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new bo(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Ct)}get domAtom(){return!1}isText(e){return this.node.text==e}}class qp extends js{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==lt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ub extends hn{constructor(e,n,r,s,i,o,a,l,d,u){super(e,n,r,s,i,o,a,d,u),this.spec=l}update(e,n,r,s){if(this.dirty==Ct)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}
vendor: 7,831 bytes, line 8
8setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,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 Kp(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],a=o.dom;if(a.parentNode==t){for(;a!=r;)r=Yd(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(a,r);if(o instanceof Hn){let l=r?r.previousSibling:t.lastChild;Kp(o.contentDOM,o.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=Yd(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Ur=function(t){t&&(this.nodeName=t)};Ur.prototype=Object.create(null);const An=[new Ur];function tl(t,e,n){if(t.length==0)return An;let r=n?An[0]:new Ur,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new Ur(o.nodeName));for(let a in o){let l=o[a];l!=null&&(n&&s.length==1&&s.push(r=new Ur(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 Wp(t,e,n,r){if(n==An&&r==An)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],a=n[i];if(i){let l;a&&a.nodeName==o.nodeName&&s!=t&&(l=s.parentNode)&&l.nodeName.toLowerCase()==o.nodeName||(l=document.createElement(o.nodeName),l.pmIsDeco=!0,l.appendChild(s),a=An[0]),s=l}Jb(s,a||An[0],o)}return s}function Jb(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function Up(t,e,n){return Wp(t,t,An,tl(e,n,t.nodeType!=1))}function Ti(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Yd(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Gb{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Qb(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,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=lt,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=Hn.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,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,n,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,n,r)&&!this.preMatch.matched.has(d)){i=a;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==Ct&&o.dom==o.contentDOM&&(o.dirty=En),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==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=n}}updateNextNode(e,n,r,s,i,o){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof hn){let d=this.preMatch.matched.get(l);if(d!=null&&d!=i)return!1;let u=l.dom,h,p=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=Ct&&Ti(n,l.outerDeco));if(!p&&l.update(e,n,r,s))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(h=this.recreateWrapper(l,e,n,r,s,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=En,h.updateChildren(s,o+1),h.dirty=lt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Ti(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let a=hn.create(this.top,n,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,n,r,s,i){let o=hn.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,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 Vp(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Hn;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof bo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ze||Re)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.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 qp(this.top,[],r,null);n!=this.top?n.children.push(s):n.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 Qb(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let a;for(;;)if(r){let d=n.children[r-1];if(d instanceof Hn)n=d,r=d.children.length;else{a=d,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(s-1))break;--s,i.set(a,s),o.push(a)}}return{index:s,matched:i,matches:o.reverse()}}function Yb(t,e){return t.type.side-e.type.side}function Xb(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let d=0;d<t.childCount;d++){let u=t.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 b=s[o++];b.widget&&(u?(h||(h=[u])).push(b):u=b)}if(u)if(h){h.sort(Yb);for(let b=0;b<h.length;b++)n(h[b],d,!!l)}else n(u,d,!!l);let p,f;if(l)f=-1,p=l,l=null;else if(d<t.childCount)f=d,p=t.child(d++);else break;for(let b=0;b<a.length;b++)a[b].to<=i&&a.splice(b--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)a.push(s[o++]);let m=i+p.nodeSize;if(p.isText){let b=m;o<s.length&&s[o].from<b&&(b=s[o].from);for(let y=0;y<a.length;y++)a[y].to<b&&(b=a[y].to);b<m&&(l=p.cut(b-i),p=p.cut(0,b-i),m=b,f=-1)}else for(;o<s.length&&s[o].to<m;)o++;let g=p.isInline&&!p.isLeaf?a.filter(b=>
vendor: 9,583 bytes, line 8
8!b.inline):a.slice();r(p,g,e.forChild(i,p),f),i=m}}function Zb(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function ey(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),a=i;if(i+=o.nodeSize,!o.isText)continue;let l=o.text;for(;s<t.childCount;){let d=t.child(s++);if(i+=d.nodeSize,!d.isText)break;l+=d.text}if(i>=n){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>=n)return a+d;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function nl(t,e,n,r,s){let i=[];for(let o=0,a=0;o<t.length;o++){let l=t[o],d=a,u=a+=l.size;d>=n||u<=e?i.push(l):(d<e&&i.push(l.slice(0,e-d,r)),s&&(i.push(s),s=void 0),u>n&&i.push(l.slice(n-d,l.size,r)))}return i}function Fl(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,d;if(xo(n)){for(l=o;s&&!s.node;)s=s.parent;let h=s.node;if(s&&h.isAtom&&B.isSelectable(h)&&s.parent&&!(h.isInline&&Tb(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;d=new B(o==p?a:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=o,p=o;for(let f=0;f<n.rangeCount;f++){let m=n.getRangeAt(f);h=Math.min(h,t.docView.posFromDOM(m.startContainer,m.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(h<0)return null;[l,o]=p==t.state.selection.anchor?[p,h]:[h,p],a=r.resolve(o)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!d){let h=e=="pointer"||t.state.selection.head<a.pos&&!i?1:-1;d=Vl(t,u,a,h)}return d}function Jp(t){return t.editable?t.hasFocus():Qp(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ft(t,e=!1){let n=t.state.selection;if(Gp(t,n),!!Jp(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Re){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&_n(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)ny(t);else{let{anchor:r,head:s}=n,i,o;Xd&&!(n instanceof $)&&(n.$from.parent.inlineContent||(i=Zd(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Zd(t,n.to))),t.docView.setSelection(r,s,t,e),Xd&&(i&&eu(i),o&&eu(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ty(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Xd=ze||Re&&Dp<63;function Zd(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(ze&&s&&s.contentEditable=="false")return xa(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return xa(s);if(i)return xa(i)}}function xa(t){return t.contentEditable="true",ze&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function eu(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function ty(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Jp(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function ny(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ie(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&We&&un<=11&&(n.disabled=!0,n.disabled=!1)}function Gp(t,e){if(e instanceof B){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(tu(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else tu(t)}function tu(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Vl(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||$.between(e,n,r)}function nu(t){return t.editable&&!t.hasFocus()?!1:Qp(t)}function Qp(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function ry(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return _n(e.node,e.offset,n.anchorNode,n.anchorOffset)}function rl(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&F.findFrom(i,e)}function Xt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function ru(t,e,n){let r=t.state.selection;if(r instanceof $)if(n.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=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Xt(t,new $(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=rl(t.state,e);return s&&s instanceof B?Xt(t,s):!1}else if(!(st&&n.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=t.docView.descAt(a))&&!o.contentDOM?B.isSelectable(i)?Xt(t,new B(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Cs?Xt(t,new $(t.state.doc.resolve(e<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof B&&r.node.isInline)return Xt(t,new $(e>0?r.$to:r.$from));{let s=rl(t.state,e);return s?Xt(t,s):!1}}}function Mi(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Jr(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function or(t,e){return e<0?sy(t):iy(t)}function sy(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(at&&n.nodeType==1&&r<Mi(n)&&Jr(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(Jr(a,-1))s=n,i=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(Yp(n))break;{let a=n.previousSibling;for(;a&&Jr(a,-1);)s=n.parentNode,i=Ie(a),a=a.previousSibling;if(a)n=a,r=Mi(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?sl(t,n,r):s&&sl(t,s,i)}function iy(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Mi(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let a=n.childNodes[r];if(Jr(a,1))i=n,o=++r;else break}else{if(Yp(n))break;{let a=n.nextSibling;for(;a&&Jr(a,1);)i=a.parentNode,o=Ie(a)+1,a=a.nextSibling;if(a)n=a,r=0,s=Mi(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&sl(t,i,o)}function Yp(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function oy(t,e){for(;t&&e==t.childNodes.length&&!Ss(t);)e=Ie(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function ay(t,e){for(;t&&!e&&!Ss(t);)e=Ie(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function sl(t,e,n){if(e.nodeType!=3){let i,o;(o=oy(e,n))?(e=o,n=0):(i=ay(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(xo(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&Ft(t)},50)}function su(t,e){let n=t.state.doc.resolve(e);if(!(Re||Lp)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.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<n.end()){let i=t.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(t.dom).direction=="rtl"?"rtl":"ltr"}function iu(t,e,n){let r=t.state.selection;if(r instanceof $&&!r.empty||n.indexOf("s")>-1||st&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=rl(t.state,e);if(o&&o instanceof B)return Xt(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,a=r instanceof Ye?F.near(o,e):F.findFrom(o,e);return a?Xt(t,a):!1}return!1}function ou(t,e){if(!(t.state.selection instanceof $))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function au(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function ly(t){if(!ze||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;au(t,r,"true"),setTimeout(()=>au(t,r,"false"),20)}return!1}function cy(t){let e="";
vendor: 4,149 bytes, lines 8-11
8return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function dy(t,e){let n=e.keyCode,r=cy(e);if(n==8||st&&n==72&&r=="c")return ou(t,-1)||or(t,-1);if(n==46&&!e.shiftKey||st&&n==68&&r=="c")return ou(t,1)||or(t,1);if(n==13||n==27)return!0;if(n==37||st&&n==66&&r=="c"){let s=n==37?su(t,t.state.selection.from)=="ltr"?-1:1:-1;return ru(t,s,r)||or(t,s)}else if(n==39||st&&n==70&&r=="c"){let s=n==39?su(t,t.state.selection.from)=="ltr"?1:-1:1;return ru(t,s,r)||or(t,s)}else{if(n==38||st&&n==80&&r=="c")return iu(t,-1,r)||or(t,-1);if(n==40||st&&n==78&&r=="c")return ly(t)||iu(t,1,r)||or(t,1);if(r==(st?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ql(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=t.someProp("clipboardSerializer")||Wn.fromSchema(t.state.schema),a=rf(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let d=l.firstChild,u,h=0;for(;d&&d.nodeType==1&&(u=nf[d.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let m=a.createElement(u[f]);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(n)}`);let p=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,` 9 10`);return{dom:l,text:p,slice:e}}function Xp(t,e,n,r,s){let i=s.parent.type.spec.code,o,a;if(!n&&!e)return null;let l=!!e&&(r||i||!n);if(l){if(t.someProp("transformPastedText",p=>{e=p(e,i||r,t)}),i)return a=new R(E.from(t.state.schema.text(e.replace(/\r\n?/g,` 11`))),0,0),t.someProp("transformPasted",p=>{a=p(a,t,!0)}),a;let h=t.someProp("clipboardTextParser",p=>p(e,s,r,t));if(h)a=h;else{let p=s.marks(),{schema:f}=t.state,m=Wn.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let b=o.appendChild(document.createElement("p"));g&&b.appendChild(m.serializeNode(f.text(g,p)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),o=fy(n),Cs&&my(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 p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||dn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!uy.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)a=gy(lu(a,+u[1],+u[2]),u[4]);else if(a=R.maxOpen(hy(a.content,s),!0),a.openStart||a.openEnd){let h=0,p=0;for(let f=a.content.firstChild;h<a.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=a.content.lastChild;p<a.openEnd&&!f.type.spec.isolating;p++,f=f.lastChild);a=lu(a,h,p)}return t.someProp("transformPasted",h=>{a=h(a,t,l)}),a}const uy=/^(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 hy(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(a=>{if(!o)return;let l=s.findWrapping(a.type),d;if(!l)return o=null;if(d=o.length&&i.length&&ef(l,i,a,o[o.length-1],0))o[o.length-1]=d;else{o.length&&(o[o.length-1]=tf(o[o.length-1],i.length));let u=Zp(a,l);o.push(u),s=s.matchType(u.type),i=l}}),o)return E.from(o)}return t}function Zp(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,E.from(t));return t}function ef(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=ef(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(E.from(Zp(n,t,s+1))))}}function tf(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,tf(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(E.empty,!0);return t.copy(n.append(r))}
vendor: 4,227 bytes, line 11
11function il(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,a=o.content;return t.childCount>1&&(i=0),s<r-1&&(a=il(a,e,n,r,s+1,i)),s>=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(E.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function lu(t,e,n){return e<t.openStart&&(t=new R(il(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new R(il(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const nf={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 cu=null;function rf(){return cu||(cu=document.implementation.createHTMLDocument("title"))}let ba=null;function py(t){let e=window.trustedTypes;return e?(ba||(ba=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),ba.createHTML(t)):t}function fy(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=rf().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&nf[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=py(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function my(t){let e=t.querySelectorAll(Re?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent=="Â "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function gy(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;s=E.from(l.create(r[a+1],s)),i++,o++}return new R(s,i,o)}const Fe={},Ve={},xy={touchstart:!0,touchmove:!0};class by{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 yy(t){for(let e in Fe){let n=Fe[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{wy(t,r)&&!Kl(t,r)&&(t.editable||!(r.type in Ve))&&n(t,r)},xy[e]?{passive:!0}:void 0)}ze&&t.dom.addEventListener("input",()=>null),ol(t)}function cn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function vy(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function ol(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Kl(t,r))})}function Kl(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function wy(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function ky(t,e){!Kl(t,e)&&Fe[e.type]&&(t.editable||!(e.type in Ve))&&Fe[e.type](t,e)}Ve.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!of(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!($t&&Re&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),br&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,Tn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||dy(t,n)?n.preventDefault():cn(t,"key")};Ve.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ve.keypress=(t,e)=>{let n=e;
vendor: 7,343 bytes, line 11
11if(of(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||st&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof $)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function yo(t){return{left:t.clientX,top:t.clientY}}function Ny(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Wl(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,a=>o>i.depth?a(t,n,i.nodeAfter,i.before(o),s,!0):a(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function fr(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Sy(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&B.isSelectable(r)?(fr(t,new B(n)),!0):!1}function Cy(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof B&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let a=o>i.depth?i.nodeAfter:i.node(o);if(B.isSelectable(a)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(fr(t,B.create(t.state.doc,s)),!0):!1}function jy(t,e,n,r,s){return Wl(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Cy(t,n):Sy(t,n))}function Ty(t,e,n,r){return Wl(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function My(t,e,n,r){return Wl(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Ey(t,n,r)}function Ey(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(fr(t,$.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)fr(t,$.create(r,a+1,a+1+o.content.size));else if(B.isSelectable(o))fr(t,B.create(r,a));else continue;return!0}}function Ul(t){return Ei(t)}const sf=st?"metaKey":"ctrlKey";Fe.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Ul(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&Ny(n,t.input.lastClick)&&!n[sf]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(yo(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Ay(t,o,n,!!r)):(i=="doubleClick"?Ty:My)(t,o.pos,o.inside,n)?n.preventDefault():cn(t,"pointer"))};class Ay{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[sf],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.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 B&&d.from<=o&&d.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&at&&!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)),cn(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(()=>Ft(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(yo(e))),this.updateAllowDefault(e),this.allowDefault||!n?cn(this.view,"pointer"):jy(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ze&&this.mightDrag&&!this.mightDrag.node.isAtom||Re&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(fr(this.view,F.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):cn(this.view,"pointer")}move(e){this.updateAllowDefault(e),cn(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)}}Fe.touchstart=t=>{t.input.lastTouch=Date.now(),Ul(t),cn(t,"pointer")};Fe.touchmove=t=>{t.input.lastTouch=Date.now(),cn(t,"pointer")};Fe.contextmenu=t=>Ul(t);function of(t,e){return t.composing?!0:ze&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Oy=$t?5e3:-1;Ve.compositionstart=Ve.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof $&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Re&&Lp&&Iy(t)))t.markCursor=t.state.storedMarks||n.marks(),Ei(t,!0),t.markCursor=null;else if(Ei(t,!e.selection.empty),at&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.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=t.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}af(t,Oy)};function Iy(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Ve.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,af(t,20))};function af(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Ei(t),e))}function lf(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Ry());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Py(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Cb(e.focusNode,e.focusOffset),r=jb(e.focusNode,e.focusOffset);
vendor: 4,701 bytes, line 11
11if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Ry(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Ei(t,e=!1){if(!($t&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),lf(t),e||t.docView&&t.docView.dirty){let n=Fl(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Dy(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const us=We&&un<15||br&&Ab<604;Fe.copy=Ve.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=us?null:n.clipboardData,o=r.content(),{dom:a,text:l}=ql(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):Dy(t,a),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ly(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function zy(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?hs(t,r.value,null,s,e):hs(t,r.textContent,r.innerHTML,s,e)},50)}function hs(t,e,n,r,s){let i=Xp(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,s,i||R.empty)))return!0;if(!i)return!1;let o=Ly(i),a=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function cf(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ve.paste=(t,e)=>{let n=e;if(t.composing&&!$t)return;let r=us?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&hs(t,cf(r),r.getData("text/html"),s,n)?n.preventDefault():zy(t,n)};class df{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const By=st?"altKey":"ctrlKey";function uf(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[By]}Fe.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(yo(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof B?s.to-1:s.to))){if(r&&r.mightDrag)o=B.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(o=B.create(t.state.doc,h.posBefore))}}let a=(o||t.state.selection).content(),{dom:l,text:d,slice:u}=ql(t,a);(!n.dataTransfer.files.length||!Re||Dp>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(us?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",us||n.dataTransfer.setData("text/plain",d),t.dragging=new df(u,uf(t,n),o)};Fe.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ve.dragover=Ve.dragenter=(t,e)=>e.preventDefault();Ve.drop=(t,e)=>{try{$y(t,e,t.dragging)}finally{t.dragging=null}};function $y(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(yo(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",f=>{i=f(i,t,!1)}):i=Xp(t,cf(e.dataTransfer),us?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&uf(t,e));if(t.someProp("handleDrop",f=>f(t,e,i||R.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let a=i?pp(t.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let l=t.state.tr;if(o){let{node:f}=n;f?f.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 p=l.doc.resolve(d);if(u&&B.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new B(p));else{let f=l.mapping.map(a);
vendor: 9,497 bytes, line 11
11l.mapping.maps[l.mapping.maps.length-1].forEach((m,g,b,y)=>f=y),l.setSelection(Vl(t,p,l.doc.resolve(f)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}Fe.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Ft(t)},20))};Fe.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Fe.beforeinput=(t,e)=>{if(Re&&$t&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Tn(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in Ve)Fe[t]=Ve[t];function ps(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Ai{constructor(e,n){this.toDOM=e,this.spec=n||Dn,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new je(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ai&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ps(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class pn{constructor(e,n){this.attrs=e,this.spec=n||Dn}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new je(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof pn&&ps(this.attrs,e.attrs)&&ps(this.spec,e.spec)}static is(e){return e.type instanceof pn}destroy(){}}class Jl{constructor(e,n){this.attrs=e,this.spec=n||Dn}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new je(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof Jl&&ps(this.attrs,e.attrs)&&ps(this.spec,e.spec)}destroy(){}}class je{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new je(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new je(e,e,new Ai(n,r))}static inline(e,n,r,s){return new je(e,n,new pn(r,s))}static node(e,n,r,s){return new je(e,n,new Jl(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof pn}get widget(){return this.type instanceof Ai}}const cr=[],Dn={};class re{constructor(e,n){this.local=e.length?e:cr,this.children=n.length?n:cr}static create(e,n){return n.length?Oi(n,e,0,Dn):Le}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let a=this.local[o];a.from<=n&&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]<n&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,n-a,r,s+a,i)}}map(e,n,r){return this==Le||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Dn)}mapInner(e,n,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(n,l)?(o||(o=[])).push(l):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?_y(this.children,o||[],e,n,r,s,i):o?new re(o.sort(Ln),cr):Le}add(e,n){return n.length?this==Le?re.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((a,l)=>{let d=l+r,u;if(u=pf(n,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,Oi(u,a,d+1,Dn)),i+=3}});let o=hf(i?ff(n):n,-r);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new re(o.length?this.local.concat(o).sort(Ln):this.local,s||this.children)}remove(e){return e.length==0||this==Le?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,a=r[i]+n,l=r[i+1]+n;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!=Le?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,n)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new re(s,r):Le}forChild(e,n){if(this==Le)return this;if(n.isLeaf)return re.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+n.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 pn){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 re(s.sort(Ln),cr);return r?new sn([a,r]):a}return r||Le}eq(e){if(this==e)return!0;if(!(e instanceof re)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Gl(this.localsInner(e))}localsInner(e){if(this==Le)return cr;if(e.inlineContent||!this.local.some(pn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof pn||n.push(this.local[r]);return n}forEachSet(e){e(this)}}re.empty=new re([],[]);re.removeOverlap=Gl;const Le=re.empty;class sn{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Dn));return sn.from(r)}forChild(e,n){if(n.isLeaf)return re.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Le&&(i instanceof sn?r=r.concat(i.members):r.push(i))}return sn.from(r)}eq(e){if(!(e instanceof sn)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Gl(r?n:n.sort(Ln)):cr}static from(e){switch(e.length){case 0:return Le;case 1:return e[0];default:return new sn(e.every(n=>n instanceof re)?e:e.reduce((n,r)=>n.concat(r instanceof re?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function _y(t,e,n,r,s,i,o){let a=t.slice();for(let d=0,u=i;d<n.maps.length;d++){let h=0;n.maps[d].forEach((p,f,m,g)=>{let b=g-m-(f-p);for(let y=0;y<a.length;y+=3){let k=a[y+1];if(k<0||p>k+u-h)continue;let C=a[y]+u-h;f>=C?a[y+1]=p<=C?-2:-1:p>=u&&b&&(a[y]+=b,a[y+1]+=b)}h+=b}),u=n.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=n.map(t[d]+i),h=u-s;if(h<0||h>=r.content.size){l=!0;continue}let p=n.map(t[d+1]+i,-1),f=p-s,{index:m,offset:g}=r.content.findIndex(h),b=r.maybeChild(m);if(b&&g==h&&g+b.nodeSize==f){let y=a[d+2].mapInner(n,b,u+1,t[d]+i+1,o);y!=Le?(a[d]=h,a[d+1]=f,a[d+2]=y):(a[d+1]=-2,l=!0)}else l=!0}if(l){let d=Hy(a,t,e,n,s,i,o),u=Oi(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,p=0;h<u.children.length;h+=3){let f=u.children[h];for(;p<a.length&&a[p]<f;)p+=3;a.splice(p,0,u.children[h],u.children[h+1],u.children[h+2])}}return new re(e.sort(Ln),a)}function hf(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new je(s.from+e,s.to+e,s.type))}return n}function Hy(t,e,n,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?n.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<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+i+1);return n}function pf(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function ff(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Oi(t,e,n,r){let s=[],i=!1;e.forEach((a,l)=>{let d=pf(t,a,l+n);if(d){i=!0;let u=Oi(d,a,n+l+1,r);u!=Le&&s.push(l,l+a.nodeSize,u)}});let o=hf(i?ff(t):t,-n).sort(Ln);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 re(o,s):Le}function Ln(t,e){return t.from-e.from||t.to-e.to}function Gl(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),du(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),du(e,s,r.copy(i.from,r.to)));break}}}return e}function du(t,e,n){for(;e<t.length&&Ln(n,t[e])>0;)e++;t.splice(e,0,n)}function ya(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Le&&e.push(r)}
vendor: 10,362 bytes, line 11
11),t.cursorWrapper&&e.push(re.create(t.state.doc,[t.cursorWrapper.deco])),sn.from(e)}const Fy={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Vy=We&&un<=11;class qy{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 Ky{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new qy,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]);We&&un<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():ze&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Vy&&(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,Fy)),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 n=0;n<e.length;n++)this.queue.push(e[n]);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(nu(this.view)){if(this.suppressingSelectionUpdates)return Ft(this.view);if(We&&un<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&_n(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 n=new Set,r;for(let i=e.focusNode;i;i=xr(i))n.add(i);for(let i=e.anchorNode;i;i=xr(i))if(n.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 n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&nu(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,a=!1,l=[];if(e.editable)for(let u=0;u<n.length;u++){let h=this.registerMutation(n[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(at&&l.length){let u=l.filter(h=>h.nodeName=="BR");if(u.length==2){let[h,p]=u;h.parentNode&&h.parentNode.parentNode==p.parentNode?p.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let p of u){let f=p.parentNode;f&&f.nodeName=="LI"&&(!h||Jy(e,h)!=f)&&p.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&&xo(r)&&(d=Fl(e))&&d.eq(F.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ft(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),Wy(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Gy(e,l)),this.handleDOMChange(i,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ft(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.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];n.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(We&&un<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:h,nextSibling:p}=e.addedNodes[u];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(s=h),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(i=p)}let o=s&&s.parentNode==e.target?Ie(s)+1:0,a=r.localPosFromDOM(e.target,o,-1),l=i&&i.parentNode==e.target?Ie(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 uu=new WeakMap,hu=!1;function Wy(t){if(!uu.has(t)&&(uu.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=at,hu)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),hu=!0}}function pu(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return _n(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function Uy(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return pu(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?pu(t,n):null}function Jy(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Gy(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.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&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function Qy(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:a}=t.docView.parseRange(e,n),l=t.domSelectionRange(),d,u=l.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(d=[{node:u,offset:l.anchorOffset}],xo(l)||d.push({node:l.focusNode,offset:l.focusOffset})),Re&&t.input.lastKeyCode===8)for(let b=i;b>s;b--){let y=r.childNodes[b-1],k=y.pmViewDesc;if(y.nodeName=="BR"&&!k){i=b;break}if(!k||k.size)break}let h=t.state.doc,p=t.someProp("domParser")||dn.fromSchema(t.state.schema),f=h.resolve(o),m=null,g=p.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:Yy,context:f});if(d&&d[0].pos!=null){let b=d[0].pos,y=d[1]&&d[1].pos;y==null&&(y=b),m={anchor:b+o,head:y+o}}return{doc:g,sel:m,from:o,to:a}}function Yy(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ze&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||ze&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Xy=/^(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 Zy(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let N=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,P=Fl(t,N);if(P&&!t.state.selection.eq(P)){if(Re&&$t&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",L=>L(t,Tn(13,"Enter"))))return;let D=t.state.tr.setSelection(P);N=="pointer"?D.setMeta("pointer",!0):N=="key"&&D.scrollIntoView(),i&&D.setMeta("composition",i),t.dispatch(D)}return}let o=t.state.doc.resolve(e),a=o.sharedDepth(n);e=o.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,d=Qy(t,e,n),u=t.state.doc,h=u.slice(d.from,d.to),p,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,f="end"):(p=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let m=nv(h.content,d.doc.content,d.from,p,f);if(m&&t.input.domChangeCount++,(br&&t.input.lastIOSEnter>Date.now()-225||$t)&&s.some(N=>N.nodeType==1&&!Xy.test(N.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",N=>N(t,Tn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof $&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(d.sel&&d.sel.anchor!=d.sel.head)
vendor: 4,132 bytes, line 11
11)m={start:l.from,endA:l.to,endB:l.to};else{if(d.sel){let N=fu(t,t.state.doc,d.sel);if(N&&!N.eq(t.state.selection)){let P=t.state.tr.setSelection(N);i&&P.setMeta("composition",i),t.dispatch(P)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof $&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=d.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=d.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),We&&un<=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),b=d.doc.resolveNoCache(m.endB-d.from),y=u.resolve(m.start),k=g.sameParent(b)&&g.parent.inlineContent&&y.end()>=m.endA;if((br&&t.input.lastIOSEnter>Date.now()-225&&(!k||s.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!k&&g.pos<d.doc.content.size&&(!g.sameParent(b)||!g.parent.inlineContent)&&g.pos<b.pos&&!/\S/.test(d.doc.textBetween(g.pos,b.pos,"","")))&&t.someProp("handleKeyDown",N=>N(t,Tn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&tv(u,m.start,m.endA,g,b)&&t.someProp("handleKeyDown",N=>N(t,Tn(8,"Backspace")))){$t&&Re&&t.domObserver.suppressSelectionUpdates();return}Re&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),$t&&!k&&g.start()!=b.start()&&b.parentOffset==0&&g.depth==b.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==m.endA&&(m.endB-=2,b=d.doc.resolveNoCache(m.endB-d.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,Tn(13,"Enter"))})},20));let C=m.start,j=m.endA,O=N=>{let P=N||t.state.tr.replace(C,j,d.doc.slice(m.start-d.from,m.endB-d.from));if(d.sel){let D=fu(t,P.doc,d.sel);D&&!(Re&&t.composing&&D.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(D.head==C||D.head==P.mapping.map(j)-1)||We&&D.empty&&D.head==C)&&P.setSelection(D)}return i&&P.setMeta("composition",i),P.scrollIntoView()},S;if(k)if(g.pos==b.pos){We&&un<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ft(t),20));let N=O(t.state.tr.delete(C,j)),P=u.resolve(m.start).marksAcross(u.resolve(m.endA));P&&N.ensureMarks(P),t.dispatch(N)}else if(m.endA==m.endB&&(S=ev(g.parent.content.cut(g.parentOffset,b.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let N=O(t.state.tr);S.type=="add"?N.addMark(C,j,S.mark):N.removeMark(C,j,S.mark),t.dispatch(N)}else if(g.parent.child(g.index()).isText&&g.index()==b.index()-(b.textOffset?0:1)){let N=g.parent.textBetween(g.parentOffset,b.parentOffset),P=()=>O(t.state.tr.insertText(N,C,j));t.someProp("handleTextInput",D=>D(t,C,j,N,P))||t.dispatch(P())}else t.dispatch(O());else t.dispatch(O())}function fu(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Vl(t,e.resolve(n.anchor),e.resolve(n.head))}function ev(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,a,l;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)i=n[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(E.from(d).eq(t))return{mark:a,type:o}}function tv(t,e,n,r,s){if(n-e<=s.pos-r.pos||va(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let a=i.nodeAfter;return a!=null&&n==e+a.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(va(i,!0,!0));return!o.parent.isTextblock||o.pos>n||va(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function va(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function nv(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);
vendor: 4,448 bytes, line 11
11if(s=="end"){let l=Math.max(0,i-Math.min(o,a));r-=o+l-i}if(o<i&&t.size<e.size){let l=r<=i&&r>=o?i-r:0;i-=l,i&&i<e.size&&mu(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<t.size&&mu(t.textBetween(i-1,i+1))&&(i+=l?1:-1),o=i+(o-a),a=i}return{start:i,endA:o,endB:a}}function mu(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class mf{constructor(e,n){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 by,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(vu),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=bu(this),xu(this),this.nodeViews=yu(this),this.docView=Qd(this.state.doc,gu(this),ya(this),this.dom,this),this.domObserver=new Ky(this,(r,s,i,o)=>Zy(this,r,s,i,o)),this.domObserver.start(),yy(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 n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ol(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vu),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(lf(this),o=!0),this.state=e;let a=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=yu(this);sv(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&ol(this),this.editable=bu(this),xu(this);let l=ya(this),d=gu(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 p=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Pb(this);if(o){this.domObserver.stop();let f=h&&(We||Re)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&rv(s.selection,e.selection);if(h){let m=Re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Py(this)),(i||!this.docView.update(e.doc,d,l,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=Qd(e.doc,d,l,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ry(this))?Ft(this,f):(Gp(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():p&&Rb(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof B){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&qd(this,n.getBoundingClientRect(),e)}else qd(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 n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;
vendor: 6,060 bytes, line 11
11if(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-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new df(e.slice,e.move,s<0?void 0:B.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let a=this.directPlugins[o].props[e];if(a!=null&&(s=n?n(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=n?n(a):a))return s}}hasFocus(){if(We){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&&Db(this.dom),Ft(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return _b(this,e)}coordsAtPos(e,n=1){return Hp(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return Kb(this,n||this.state,e)}pasteHTML(e,n){return hs(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return hs(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return ql(this,e)}destroy(){this.docView&&(vy(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ya(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Nb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ky(this,e)}domSelectionRange(){let e=this.domSelection();return e?ze&&this.root.nodeType===11&&Mb(this.dom.ownerDocument)==this.dom&&Uy(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}mf.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function gu(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[je.node(0,t.state.doc.content.size,e)]}function xu(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:je.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function bu(t){return!t.someProp("editable",e=>e(t.state)===!1)}function rv(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function yu(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function sv(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function vu(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var fn={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:"'"},Ii={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},iv=typeof navigator<"u"&&/Mac/.test(navigator.platform),ov=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Pe=0;Pe<10;Pe++)fn[48+Pe]=fn[96+Pe]=String(Pe);for(var Pe=1;Pe<=24;Pe++)fn[Pe+111]="F"+Pe;for(var Pe=65;Pe<=90;Pe++)fn[Pe]=String.fromCharCode(Pe+32),Ii[Pe]=String.fromCharCode(Pe);for(var wa in fn)Ii.hasOwnProperty(wa)||(Ii[wa]=fn[wa]);function av(t){var e=iv&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||ov&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ii:fn)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const lv=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),cv=typeof navigator<"u"&&/Win/.test(navigator.platform);function dv(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");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))lv?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function uv(t){let e=Object.create(null);for(let n in t)e[dv(n)]=t[n];return e}
vendor: 5,057 bytes, line 11
11function ka(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function hv(t){return new te({props:{handleKeyDown:Ql(t)}})}function Ql(t){let e=uv(t);return function(n,r){let s=av(r),i,o=e[ka(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[ka(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(cv&&r.ctrlKey&&r.altKey)&&(i=fn[r.keyCode])&&i!=s){let a=e[ka(i,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}var pv=Object.defineProperty,Yl=(t,e)=>{for(var n in e)pv(t,n,{get:e[n],enumerable:!0})};function vo(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;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=n.selection,s=n.doc,i=n.storedMarks,n}}}var wo=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).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(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],a=!!t,l=t||s.tr,d=()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),o.every(h=>h===!0)),u={...Object.fromEntries(Object.entries(n).map(([h,p])=>[h,(...m)=>{const g=this.buildProps(l,e),b=p(...m)(g);return o.push(b),u}])),run:d};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.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(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:vo({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([a,l])=>[a,(...d)=>l(...d)(o)]))}};return o}},gf={};Yl(gf,{blur:()=>fv,clearContent:()=>mv,clearNodes:()=>gv,command:()=>xv,createParagraphNear:()=>bv,cut:()=>yv,deleteCurrentNode:()=>vv,deleteNode:()=>wv,deleteRange:()=>kv,deleteSelection:()=>Cv,enter:()=>jv,exitCode:()=>Tv,extendMarkRange:()=>Mv,first:()=>Ev,focus:()=>Ov,forEach:()=>Iv,insertContent:()=>Pv,insertContentAt:()=>Lv,joinBackward:()=>$v,joinDown:()=>Bv,joinForward:()=>_v,joinItemBackward:()=>Hv,joinItemForward:()=>Fv,joinTextblockBackward:()=>Vv,joinTextblockForward:()=>qv,joinUp:()=>zv,keyboardShortcut:()=>Wv,lift:()=>Uv,liftEmptyBlock:()=>Jv,liftListItem:()=>Gv,newlineInCode:()=>Qv,resetAttributes:()=>Yv,scrollIntoView:()=>Xv,selectAll:()=>Zv,selectNodeBackward:()=>ew,selectNodeForward:()=>tw,selectParentNode:()=>nw,selectTextblockEnd:()=>rw,selectTextblockStart:()=>sw,setContent:()=>iw,setMark:()=>Sw,setMeta:()=>Cw,setNode:()=>jw,setNodeSelection:()=>Tw,setTextDirection:()=>Mw,setTextSelection:()=>Ew,sinkListItem:()=>Aw,splitBlock:()=>Ow,splitListItem:()=>Iw,toggleList:()=>Rw,toggleMark:()=>Dw,toggleNode:()=>Lw,toggleWrap:()=>zw,undoInputRule:()=>Bw,unsetAllMarks:()=>$w,unsetMark:()=>_w,unsetTextDirection:()=>Hw,updateAttributes:()=>Fw,wrapIn:()=>Vw,wrapInList:()=>qw});var fv=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),mv=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),gv=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.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)),p=d.resolve(u.map(l+a.nodeSize)),f=h.blockRange(p);if(!f)return;const m=kr(f);if(a.type.isTextblock){const{defaultType:g}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(f.start,g)}(m||m===0)&&e.lift(f,m)})}),!0},xv=t=>e=>t(e),bv=()=>({state:t,dispatch:e})=>Ap(t,e),yv=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new $(r.doc.resolve(Math.max(o-1,0)))),!0},vv=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.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);t.delete(a,l).scrollIntoView()}return!0}return!1};function ke(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);
11return e.nodes[t]}return t}var wv=t=>({tr:e,state:n,dispatch:r})=>{const s=ke(t,n.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},kv=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},Nv=t=>t.content?/^text(\*|\+)/.test(t.content):!1,wu=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return Nv(r)?n==="left"?t.start()-1:t.end()+1:t.pos},Sv=(t,e,n)=>{const r=wu(t,n,"left"),s=wu(e,n,"right");return{from:r,to:s}},Cv=()=>({state:t,dispatch:e})=>{const{$from:n,$to:r}=t.selection;if(t.selection.empty)return!1;const{from:s,to:i}=Sv(n,r,t.schema);return e&&(t.tr.deleteRange(s,i).scrollIntoView(),e(t.tr)),!0},jv=()=>({commands:t})=>t.keyboardShortcut("Enter"),Tv=()=>({state:t,dispatch:e})=>lb(t,e);function Xl(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Pi(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Xl(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function xf(t,e,n={}){return t.find(r=>r.type===e&&Pi(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function ku(t,e,n={}){return!!xf(t,e,n)}function Zl(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(d=>d.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(d=>d.type===e))return;if(!n){const d=r.node.marks.find(u=>u.type===e);d&&(n=d.attrs)}if(!xf([...r.node.marks],e,n))return;let i=r.index,o=t.start()+r.offset,a=i+1,l=o+r.node.nodeSize;for(;i>0&&ku([...t.parent.child(i-1).marks],e,n);)i-=1,o-=t.parent.child(i).nodeSize;for(;a<t.parent.childCount&&ku([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function qt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var Mv=(t,e)=>({tr:n,state:r,dispatch:s})=>{const i=qt(t,r.schema),{doc:o,selection:a}=n,{$from:l,from:d,to:u}=a;if(s){const h=Zl(l,i,e);if(h&&h.from<=d&&h.to>=u){const p=$.create(o,h.from,h.to);n.setSelection(p)}}return!0},Ev=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function ec(t){return t instanceof $}function _t(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function bf(t,e=null){if(!e)return null;const n=F.atStart(t),r=F.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?$.create(t,_t(0,s,i),_t(t.content.size,s,i)):$.create(t,_t(e,s,i),_t(e,s,i))}function Nu(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ri(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Av(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Ov=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Ri()||Nu())&&r.dom.focus(),Av()&&!Ri()&&!Nu()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!ec(n.state.selection))return o(),!0;const a=bf(s.doc,t)||n.state.selection,l=n.state.selection.eq(a);return i&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},Iv=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),Pv=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),yf=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&yf(r)}return t};function Zs(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return yf(n)}function fs(t,e,n){if(t instanceof ft||t instanceof E)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return E.fromArray(t.map(a=>e.nodeFromJSON(a)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),fs("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,a="";const l=new np({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=>
vendor: 4,357 bytes, line 11
11(o=!0,a=typeof d=="string"?d:d.outerHTML,null)}]}})});if(n.slice?dn.fromSchema(l).parseSlice(Zs(t),n.parseOptions):dn.fromSchema(l).parse(Zs(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const i=dn.fromSchema(e);return n.slice?i.parseSlice(Zs(t),n.parseOptions).content:i.parse(Zs(t),n.parseOptions)}return fs("",e,n)}function Rv(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof ve||s instanceof Te))return;const i=t.mapping.maps[r];let o=0;i.forEach((a,l,d,u)=>{o===0&&(o=u)}),t.setSelection(F.near(t.doc.resolve(o),n))}var Dv=t=>!("type"in t),Lv=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const l=b=>{i.emit("contentError",{editor:i,error:b,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{fs(e,i.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(b){l(b)}try{a=fs(e,i.schema,{parseOptions:d,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(b){return l(b),!1}let{from:u,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,f=!0;if((Dv(a)?a:[a]).forEach(b=>{b.check(),p=p?b.isText&&b.marks.length===0:!1,f=f?b.isBlock:!1}),u===h&&f){const{parent:b}=r.doc.resolve(u);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(u-=1,h+=1)}let g;if(p){if(Array.isArray(e))g=e.map(b=>b.text||"").join("");else if(e instanceof E){let b="";e.forEach(y=>{y.text&&(b+=y.text)}),g=b}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,h)}else{g=a;const b=r.doc.resolve(u),y=b.node(),k=b.parentOffset===0,C=y.isText||y.isTextblock,j=y.content.size>0;k&&C&&j&&f&&(u=Math.max(0,u-1)),r.replaceWith(u,h,g)}n.updateSelection&&Rv(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},zv=()=>({state:t,dispatch:e})=>ib(t,e),Bv=()=>({state:t,dispatch:e})=>ob(t,e),$v=()=>({state:t,dispatch:e})=>Np(t,e),_v=()=>({state:t,dispatch:e})=>Tp(t,e),Hv=()=>({state:t,dispatch:e,tr:n})=>{try{const r=fo(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Fv=()=>({state:t,dispatch:e,tr:n})=>{try{const r=fo(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Vv=()=>({state:t,dispatch:e})=>rb(t,e),qv=()=>({state:t,dispatch:e})=>sb(t,e);function vf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Kv(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");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))Ri()||vf()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var Wv=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=Kv(t).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(()=>{n.someProp("handleKeyDown",d=>d(n,a))});return l?.steps.forEach(d=>{const u=d.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function mn(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?ke(e,t.schema):null,a=[];t.doc.nodesBetween(r,s,(h,p)=>{if(h.isText)return;const f=Math.max(r,p),m=Math.min(s,p+h.nodeSize);a.push({node:h,from:f,to:m})});const l=s-r,d=a.filter(h=>o?o.name===h.node.type.name:!0).filter(h=>Pi(h.node.attrs,n,{strict:!1}));return i?!!d.length:d.reduce((h,p)=>h+p.to-p.from,0)>=l}var Uv=(t,e={})=>({state:n,dispatch:r})=>{const s=ke(t,n.schema);return mn(n,s,e)?ab(n,r):!1},Jv=()=>({state:t,dispatch:e})=>Op(t,e),Gv=t=>({state:e,dispatch:n})=>{const r=ke(t,e.schema);
11return yb(r)(e,n)},Qv=()=>({state:t,dispatch:e})=>Ep(t,e);function ko(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Su(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var Yv=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const a=ko(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(i=ke(t,r.schema)),a==="mark"&&(o=qt(t,r.schema));let l=!1;return n.selection.ranges.forEach(d=>{r.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,h)=>{i&&i===u.type&&(l=!0,s&&n.setNodeMarkup(h,void 0,Su(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(p=>{o===p.type&&(l=!0,s&&n.addMark(h,h+u.nodeSize,o.create(Su(p.attrs,e))))})})}),l},Xv=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Zv=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ye(t.doc);t.setSelection(n)}return!0},ew=()=>({state:t,dispatch:e})=>Cp(t,e),tw=()=>({state:t,dispatch:e})=>Mp(t,e),nw=()=>({state:t,dispatch:e})=>ub(t,e),rw=()=>({state:t,dispatch:e})=>fb(t,e),sw=()=>({state:t,dispatch:e})=>pb(t,e);function al(t,e,n={},r={}){return fs(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var iw=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:a})=>{const{doc:l}=i;if(r.preserveWhitespace!=="full"){const d=al(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,l.content.size,d).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function wf(t,e){const n=qt(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function kf(t,e){const n=new Dl(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function ow(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function aw(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function Nf(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function No(t){return e=>Nf(e.$from,t)}function z(t,e,n){return t.config[e]===void 0&&t.parent?z(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?z(t.parent,e,n):null}):t.config[e]}function tc(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=z(e,"addExtensions",n);return r?[e,...tc(r())]:e}).flat(10)}function nc(t,e){const n=Wn.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Sf(t){return typeof t=="function"}function U(t,e=void 0,...n){return Sf(t)?e?t.bind(e)(...n):t(...n):t}function lw(t={}){return Object.keys(t).length===0&&t.constructor===Object}function yr(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Cf(t){const e=[],{nodeExtensions:n,markExtensions:r}=yr(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(d=>d.name!=="text").map(d=>d.name),a=r.map(d=>d.name),l=[...o,...a];return t.forEach(d=>{const u={name:d.name,options:d.options,storage:d.storage,extensions:s},h=z(d,"addGlobalAttributes",u);if(!h)return;h().forEach(f=>{let m;Array.isArray(f.types)?m=f.types:f.types==="*"?m=l:f.types==="nodes"?m=o:f.types==="marks"?m=a:m=[],m.forEach(g=>{Object.entries(f.attributes).forEach(([b,y])=>{e.push({type:g,name:b,attribute:{...i,...y}})})})})}),s.forEach(d=>{const u={name:d.name,options:d.options,storage:d.storage},h=z(d,"addAttributes",u);if(!h)return;const p=h();Object.entries(p).forEach(([f,m])=>{const g={...i,...m};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:d.name,name:f,attribute:g})})}),e}function cw(t){const e=[];let n="",r=!1,s=!1,i=0;const o=t.length;for(let a=0;a<o;a+=1){const l=t[a];if(l==="'"&&!s){r=!r,n+=l;continue}if(l==='"'&&!r){s=!s,n+=l;continue}if(!r&&!s){if(l==="("){i+=1,n+=l;continue}if(l===")"&&i>0){i-=1,n+=l;continue}if(l===";"&&i===0){e.push(n),n="";continue}}n+=l}return n&&e.push(n),e}function Cu(t){const e=[],n=cw(t||""),r=n.length;for(let s=0;s<r;s+=1){const i=n[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 ue(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};
vendor: 11,933 bytes, lines 11-13
11return Object.entries(n).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([...Cu(r[s]),...Cu(i)]);r[s]=Array.from(a.entries()).map(([l,d])=>`${l}: ${d}`).join("; ")}else r[s]=i}),r},{})}function ms(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>ue(n,r),{})}function dw(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function ju(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(n):dw(n.getAttribute(o.name));return a==null?i:{...i,[o.name]:a}},{});return{...r,...s}}}}function Tu(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&lw(n)?!1:n!=null))}function Mu(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function uw(t,e){var n;const r=Cf(t),{nodeExtensions:s,markExtensions:i}=yr(t),o=(n=s.find(d=>z(d,"topNode")))==null?void 0:n.name,a=Object.fromEntries(s.map(d=>{const u=r.filter(y=>y.type===d.name),h={name:d.name,options:d.options,storage:d.storage,editor:e},p=t.reduce((y,k)=>{const C=z(k,"extendNodeSchema",h);return{...y,...C?C(d):{}}},{}),f=Tu({...p,content:U(z(d,"content",h)),marks:U(z(d,"marks",h)),group:U(z(d,"group",h)),inline:U(z(d,"inline",h)),atom:U(z(d,"atom",h)),selectable:U(z(d,"selectable",h)),draggable:U(z(d,"draggable",h)),code:U(z(d,"code",h)),whitespace:U(z(d,"whitespace",h)),linebreakReplacement:U(z(d,"linebreakReplacement",h)),defining:U(z(d,"defining",h)),isolating:U(z(d,"isolating",h)),attrs:Object.fromEntries(u.map(Mu))}),m=U(z(d,"parseHTML",h));m&&(f.parseDOM=m.map(y=>ju(y,u)));const g=z(d,"renderHTML",h);g&&(f.toDOM=y=>g({node:y,HTMLAttributes:ms(y,u)}));const b=z(d,"renderText",h);return b&&(f.toText=b),[d.name,f]})),l=Object.fromEntries(i.map(d=>{const u=r.filter(b=>b.type===d.name),h={name:d.name,options:d.options,storage:d.storage,editor:e},p=t.reduce((b,y)=>{const k=z(y,"extendMarkSchema",h);return{...b,...k?k(d):{}}},{}),f=Tu({...p,inclusive:U(z(d,"inclusive",h)),excludes:U(z(d,"excludes",h)),group:U(z(d,"group",h)),spanning:U(z(d,"spanning",h)),code:U(z(d,"code",h)),attrs:Object.fromEntries(u.map(Mu))}),m=U(z(d,"parseHTML",h));m&&(f.parseDOM=m.map(b=>ju(b,u)));const g=z(d,"renderHTML",h);return g&&(f.toDOM=b=>g({mark:b,HTMLAttributes:ms(b,u)})),[d.name,f]}));return new np({topNode:o,nodes:a,marks:l})}function hw(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Gr(t){return t.sort((n,r)=>{const s=z(n,"priority")||100,i=z(r,"priority")||100;return s>i?-1:s<i?1:0})}function jf(t){const e=Gr(tc(t)),n=hw(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Tf(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=` 12 13`,textSerializers:o={}}=n||{};let a="";return t.nodesBetween(r,s,(l,d,u,h)=>{var p;l.isBlock&&d>r&&(a+=i);const f=o?.[l.type.name];if(f)return u&&(a+=f({node:l,pos:d,parent:u,index:h,range:e})),!1;l.isText&&(a+=(p=l?.text)==null?void 0:p.slice(Math.max(r,d)-d,s-d))}),a}function Mf(t,e){const n={from:0,to:t.content.size};return Tf(t,n,e)}function rc(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function pw(t,e){const n=ke(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,a=>{i.push(a)});const o=i.reverse().find(a=>a.type.name===n.name);return o?{...o.attrs}:{}}function Ef(t,e){const n=ko(typeof e=="string"?e:e.name,t.schema);return n==="node"?pw(t,e):n==="mark"?wf(t,e):{}}function fw(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function mw(t){const e=fw(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Af(t){const{mapping:e,steps:n}=t,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}=n[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),p=e.invert().map(u);r.push({oldRange:{from:h,to:p},newRange:{from:d,to:u}})})}),mw(r)}function sc(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=Zl(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var gw=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const a=s.node(i);a?.type.name===e?o=a:i-=1}return[o,i]};function Rr(t,e){return e.nodes[t]||e.marks[t]||null}function fi(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var xw=(t,e=500)=>{let n="";const r=t.parentOffset;return t.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%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),n};function ll(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?qt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>i?i.name===h.type.name:!0).find(h=>Pi(h.attrs,n,{strict:!1}));let o=0;const a=[];if(s.forEach(({$from:h,$to:p})=>{const f=h.pos,m=p.pos;t.doc.nodesBetween(f,m,(g,b)=>{if(i&&g.inlineContent&&!g.type.allowsMarkType(i))return!1;if(!g.isText&&!g.marks.length)return;const y=Math.max(f,b),k=Math.min(m,b+g.nodeSize),C=k-y;o+=C,a.push(...g.marks.map(j=>({mark:j,from:y,to:k})))})}),o===0)return!1;const l=a.filter(h=>i?i.name===h.mark.type.name:!0).filter(h=>Pi(h.mark.attrs,n,{strict:!1})).reduce((h,p)=>h+p.to-p.from,0),d=a.filter(h=>i?h.mark.type!==i&&h.mark.type.excludes(i):!0).reduce((h,p)=>h+p.to-p.from,0);return(l>0?l+d:l)>=o}function bw(t,e,n={}){if(!e)return mn(t,null,n)||ll(t,null,n);const r=ko(e,t.schema);return r==="node"?mn(t,e,n):r==="mark"?ll(t,e,n):!1}var yw=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=No(a=>a.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},vw=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Eu(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Na(t,e){const{nodeExtensions:n}=yr(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=U(z(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function gs(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(gs(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Of(t){return t instanceof B}var If=class Pf{constructor(e){this.position=e}static fromJSON(e){return new Pf(e.position)}toJSON(){return{position:this.position}}};function ww(t,e){const n=e.mapping.mapResult(t.position);return{position:new If(n.pos),mapResult:n}}function kw(t){return new If(t)}function Rf(t,e,n){const s=t.state.doc.content.size,i=_t(e,0,s),o=_t(n,0,s),a=t.coordsAtPos(i),l=t.coordsAtPos(o,-1),d=Math.min(a.top,l.top),u=Math.max(a.bottom,l.bottom),h=Math.min(a.left,l.left),p=Math.max(a.right,l.right),f=p-h,m=u-d,y={top:d,bottom:u,left:h,right:p,width:f,height:m,x:h,y:d};return{...y,toJSON:()=>y}}function Nw(t,e,n){var r;const{selection:s}=e;let i=null;if(ec(s)&&(i=s.$cursor),i){const a=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(d=>d.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:a,$to:l})=>{let d=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(u,h,p)=>{if(d)return!1;if(u.isInline){const f=!p||p.type.allowsMarkType(n),m=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));d=f&&m}return!d}),d})}var Sw=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:a}=i,l=qt(t,r.schema);if(s)if(o){const d=wf(r,l);n.addStoredMark(l.create({...d,...e}))}else a.forEach(d=>{const u=d.$from.pos,h=d.$to.pos;r.doc.nodesBetween(u,h,(p,f)=>{const m=Math.max(f,u),g=Math.min(f+p.nodeSize,h);p.marks.find(y=>y.type===l)?p.marks.forEach(y=>{l===y.type&&n.addMark(m,g,l.create({...y.attrs,...e}))}):n.addMark(m,g,l.create(e))})});return Nw(r,n,l)},Cw=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),jw=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=ke(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:a})=>Hd(i,{...o,...e})(n)?!0:a.clearNodes()).command(({state:a})=>Hd(i,{...o,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Tw=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=_t(t,0,r.content.size),i=B.create(r,s);e.setSelection(i)}return!0},Mw=(t,e)=>({tr:n,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&&n.doc.nodesBetween(o,a,(l,d)=>{l.isText||n.setNodeMarkup(d,void 0,{...l.attrs,dir:t})}),!0},Ew=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=$.atStart(r).from,a=$.atEnd(r).to,l=_t(s,o,a),d=_t(i,o,a),u=$.create(r,l,d);e.setSelection(u)}return!0},Aw=t=>({state:e,dispatch:n})=>{const r=ke(t,e.schema);return kb(r)(e,n)};function Au(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var Ow=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:a,$to:l}=i,d=s.extensionManager.attributes,u=fi(d,a.node().type.name,a.node().attrs);if(i instanceof B&&i.node.isBlock)return!a.parentOffset||!Ht(o,a.pos)?!1:(r&&(t&&Au(n,s.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const h=l.parentOffset===l.parent.content.size,p=a.depth===0?void 0:ow(a.node(-1).contentMatchAt(a.indexAfter(-1)));let f=h&&p?[{type:p,attrs:u}]:void 0,m=Ht(e.doc,e.mapping.map(a.pos),1,f);if(!f&&!m&&Ht(e.doc,e.mapping.map(a.pos),1,p?[{type:p}]:void 0)&&(m=!0,f=p?[{type:p,attrs:u}]:void 0),r){if(m&&(i instanceof $&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,f),p&&!h&&!a.parentOffset&&a.parent.type!==p)){const g=e.mapping.map(a.before()),b=e.doc.resolve(g);a.node(-1).canReplaceWith(b.index(),b.index()+1,p)&&e.setNodeMarkup(e.mapping.map(a.before()),p)}t&&Au(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},Iw=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const a=ke(t,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 p=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if
13(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){let y=E.empty;const k=l.index(-1)?1:l.index(-2)?2:3;for(let P=l.depth-k;P>=l.depth-3;P-=1)y=E.from(l.node(P).copy(y));const C=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,j={...fi(p,l.node().type.name,l.node().attrs),...e},O=((o=a.contentMatch.defaultType)==null?void 0:o.createAndFill(j))||void 0;y=y.append(E.from(a.createAndFill(null,O)||void 0));const S=l.before(l.depth-(k-1));n.replace(S,l.after(-C),new R(y,4-k,0));let N=-1;n.doc.nodesBetween(S,n.doc.content.size,(P,D)=>{if(N>-1)return!1;P.isTextblock&&P.content.size===0&&(N=D+1)}),N>-1&&n.setSelection($.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const f=d.pos===l.end()?h.contentMatchAt(0).defaultType:null,m={...fi(p,h.type.name,h.attrs),...e},g={...fi(p,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,d.pos);const b=f?[{type:a,attrs:m},{type:f,attrs:g}]:[{type:a,attrs:m}];if(!Ht(n.doc,l.pos,2))return!1;if(s){const{selection:y,storedMarks:k}=r,{splittableMarks:C}=i.extensionManager,j=k||y.$to.parentOffset&&y.$from.marks();if(n.split(l.pos,2,b).scrollIntoView(),!j||!s)return!0;const O=j.filter(S=>C.includes(S.type.name));n.ensureMarks(O)}return!0},Sa=(t,e)=>{const n=No(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&gn(t.doc,n.pos)&&t.join(n.pos),!0},Ca=(t,e)=>{const n=No(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&gn(t.doc,r)&&t.join(r),!0};function Pw(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),s=e.resolve(n.nodeSize-1);return $.between(r,s)}var Rw=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:a,chain:l,commands:d,can:u})=>{const{extensions:h,splittableMarks:p}=s.extensionManager,f=ke(t,o.schema),m=ke(e,o.schema),{selection:g,storedMarks:b}=o,{$from:y,$to:k}=g,C=y.blockRange(k),j=b||g.$to.parentOffset&&g.$from.marks();if(!C)return!1;const O=No(le=>Na(le.type.name,h))(g),S=g.from===0&&g.to===o.doc.content.size,N=o.doc.content.content,P=N.length===1?N[0]:null,D=S&&P&&Na(P.type.name,h)?{node:P,pos:0}:null,L=O??D,J=!!O&&C.depth>=1&&C.depth-O.depth<=1,Ee=!!D;if((J||Ee)&&L){if(L.node.type===f)return S&&Ee?l().command(({tr:le,dispatch:ce})=>{const ne=Pw(le);return ne?(le.setSelection(ne),ce&&ce(le),!0):!1}).liftListItem(m).run():d.liftListItem(m);if(Na(L.node.type.name,h)&&f.validContent(L.node.content))return l().command(()=>(i.setNodeMarkup(L.pos,f),!0)).command(()=>Sa(i,f)).command(()=>Ca(i,f)).run()}return!n||!j||!a?l().command(()=>u().wrapInList(f,r)?!0:d.clearNodes()).wrapInList(f,r).command(()=>Sa(i,f)).command(()=>Ca(i,f)).run():l().command(()=>{const le=u().wrapInList(f,r),ce=j.filter(ne=>p.includes(ne.type.name));return i.ensureMarks(ce),le?!0:d.clearNodes()}).wrapInList(f,r).command(()=>Sa(i,f)).command(()=>Ca(i,f)).run()},Dw=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=qt(t,r.schema);return ll(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},Lw=(t,e,n={})=>({state:r,commands:s})=>{const i=ke(t,r.schema),o=ke(e,r.schema),a=mn(r,i,n);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,...n})},zw=(t,e={})=>({state:n,commands:r})=>{const s=ke(t,n.schema);return mn(n,s,e)?r.lift(s):r.wrapIn(s,e)},Bw=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.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,t.schema.text(i.text,l))}else o.delete(i.from,i.to)}return!0}}return!1},$w=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},_w=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=n,l=qt(t,r.schema),{$from:d,empty:u,ranges:h}=a;if(!s)return!0;
vendor: 10,355 bytes, lines 13-14
13if(u&&o){let{from:p,to:f}=a;const m=(i=d.marks().find(b=>b.type===l))==null?void 0:i.attrs,g=Zl(d,l,m);g&&(p=g.from,f=g.to),n.removeMark(p,f,l)}else h.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,l)});return n.removeStoredMark(l),!0},Hw=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.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},Fw=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const a=ko(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(i=ke(t,r.schema)),a==="mark"&&(o=qt(t,r.schema));let l=!1;return n.selection.ranges.forEach(d=>{const u=d.$from.pos,h=d.$to.pos;let p,f,m,g;n.selection.empty?r.doc.nodesBetween(u,h,(b,y)=>{i&&i===b.type&&(l=!0,m=Math.max(y,u),g=Math.min(y+b.nodeSize,h),p=y,f=b)}):r.doc.nodesBetween(u,h,(b,y)=>{y<u&&i&&i===b.type&&(l=!0,m=Math.max(y,u),g=Math.min(y+b.nodeSize,h),p=y,f=b),y>=u&&y<=h&&(i&&i===b.type&&(l=!0,s&&n.setNodeMarkup(y,void 0,{...b.attrs,...e})),o&&b.marks.length&&b.marks.forEach(k=>{if(o===k.type&&(l=!0,s)){const C=Math.max(y,u),j=Math.min(y+b.nodeSize,h);n.addMark(C,j,o.create({...k.attrs,...e}))}}))}),f&&(p!==void 0&&s&&n.setNodeMarkup(p,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(b=>{o===b.type&&s&&n.addMark(m,g,o.create({...b.attrs,...e}))}))}),l},Vw=(t,e={})=>({state:n,dispatch:r})=>{const s=ke(t,n.schema);return mb(s,e)(n,r)},qw=(t,e={})=>({state:n,dispatch:r})=>{const s=ke(t,n.schema);return gb(s,e)(n,r)},Kw=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},So=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},Ww=(t,e)=>{if(Xl(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function ei(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:a}=t,{view:l}=n;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(p=>p.type.spec.code))return!1;let u=!1;const h=xw(d)+i;return o.forEach(p=>{if(u)return;const f=Ww(h,p.find);if(!f)return;const m=l.state.tr,g=vo({state:l.state,transaction:m}),b={from:r-(f[0].length-i.length),to:s},{commands:y,chain:k,can:C}=new wo({editor:n,state:g});p.handler({state:g,range:b,match:f,commands:y,chain:k,can:C})===null||!m.steps.length||(p.undoable&&m.setMeta(a,{transform:m,from:r,to:s,text:i}),l.dispatch(m),u=!0)}),u}function Uw(t){const{editor:e,rules:n}=t,r=new te({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=nc(E.from(u),o.schema);const{from:h}=l,p=h+u.length;ei({editor:e,from:h,to:p,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,a){return ei({editor:e,from:i,to:o,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&ei({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?ei({editor:e,from:o.pos,to:o.pos,text:` 14`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Jw(t){return Object.prototype.toString.call(t).slice(8,-1)}function ti(t){return Jw(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Df(t,e){const n={...t};return ti(t)&&ti(e)&&Object.keys(e).forEach(r=>{ti(e[r])&&ti(t[r])?n[r]=Df(t[r],e[r]):n[r]=e[r]}),n}var ic=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...U(z(this,"addOptions",{name:this.name}))}}get storage(){return{...U(z(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Df(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Un=class Lf extends ic{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Lf(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(d=>d?.type.name===n.name))return!1;const l=o.find(d=>d?.type.name===n.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 n=typeof e=="function"?e():e;return super.extend(n)}};function Gw(t){return typeof t=="number"}var Qw=class{constructor(t){this.find=t.find,this.handler=t.handler}},Yw=(t,e,n)=>{if(Xl(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function Xw(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:a}=t,{commands:l,chain:d,can:u}=new wo({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,s,(f,m)=>{var g,b,y,k,C;if((b=(g=f.type)==null?void 0:g.spec)!=null&&b.code||!(f.isText||f.isTextblock||f.isInline))return;const j=(C=(k=(y=f.content)==null?void 0:y.size)!=null?k:f.nodeSize)!=null?C:0,O=Math.max(r,m),S=Math.min(s,m+j);if(O>=S)return;const N=f.isText?f.text||"":f.textBetween(O-m,S-m,void 0,"");Yw(N,i.find,o).forEach(D=>{if(D.index===void 0)return;const L=O+D.index+1,J=L+D[0].length,Ee={from:n.tr.mapping.map(L),to:n.tr.mapping.map(J)},le=i.handler({state:n,range:Ee,match:D,commands:l,chain:d,can:u,pasteEvent:o,dropEvent:a});h.push(le)})}),h.every(f=>f!==null)}var ni=null,Zw=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function e1(t){const{editor:e,rules:n}=t;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:p,rule:f,pasteEvt:m})=>{const g=u.tr,b=vo({state:u,transaction:g});if(!(!Xw({editor:e,state:b,from:Math.max(h-1,0),to:p.b-1,rule:f,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 n.map(u=>new te({view(h){const p=m=>{var g;r=(g=h.dom.parentElement)!=null&&g.contains(m.target)?h.dom.parentElement:null,r&&(ni=e)},f=()=>{ni&&(ni=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(h,p)=>{if(i=r===h.dom.parentElement,a=p,!i){const f=ni;f?.isEditable&&setTimeout(()=>{const m=f.state.selection;m&&f.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(h,p)=>{var f;const m=(f=p.clipboardData)==null?void 0:f.getData("text/html");return o=p,s=!!m?.includes("data-pm-slice"),!1}}},appendTransaction:(h,p,f)=>{const m=h[0],g=m.getMeta("uiEvent")==="paste"&&!s,b=m.getMeta("uiEvent")==="drop"&&!i,y=m.getMeta("applyPasteRules"),k=!!y;if(!g&&!b&&!k)return;if(k){let{text:O}=y;typeof O=="string"?O=O:O=nc(E.from(O),f.schema);const{from:S}=y,N=S+O.length,P=Zw(O);return l({rule:u,state:f,from:S,to:{b:N},pasteEvt:P})}const C=p.doc.content.findDiffStart(f.doc.content),j=p.doc.content.findDiffEnd(f.doc.content);if(!(!Gw(C)||!j||C===j.b))return l({rule:u,state:f,from:C,to:j,pasteEvt:o})}}))}var Co=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=jf(t),this.schema=uw(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Rr(e.name,this.schema)},r=z(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Gr([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Rr(r.name,this.schema)},i=[],o=z(r,"addKeyboardShortcuts",s);let a={};if(r.type==="mark"&&z(r,"exitable",s)&&(a.ArrowRight=()=>Un.handleExit({editor:t,mark:r})),o){const p=Object.fromEntries(Object.entries(o()).map(([f,m])=>[f,()=>m({editor:t})]));a={...a,...p}}const l=hv(a);i.push(l);const d=z(r,"addInputRules",s);if(Eu(r,t.options.enableInputRules)&&d){const p=d();if(p&&p.length){const f=Uw({editor:t,rules:p}),m=Array.isArray(f)?f:[f];i.push(...m)}}const u=z(r,"addPasteRules",s);if(Eu(r,t.options.enablePasteRules)&&u){const p=u();if(p&&p.length){const f=e1({editor:t,rules:p});i.push(...f)}}const h=z(r,"addProseMirrorPlugins",s);if(h){const p=h();i.push(...p)}return i})}get attributes(){return Cf(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=yr(this.extensions);return Object.fromEntries(e.filter(n=>!!z(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ke(n.name,this.schema)},i=z(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const a=(l,d,u,h,p)=>{const f=ms(l,r);return o({node:l,view:d,getPos:u,decorations:h,innerDecorations:p,editor:t,extension:n,HTMLAttributes:f})};return[n.name,a]}
14))}dispatchTransaction(t){const{editor:e}=this;return Gr([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Rr(s.name,this.schema)},o=z(s,"dispatchTransaction",i);return o?a=>{o.call(i,{transaction:a,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return Gr([...this.extensions]).reduce((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Rr(s.name,this.schema)},o=z(s,"transformPastedHTML",i);return o?(a,l)=>{const d=r(a,l);return o.call(i,d)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=yr(this.extensions);return Object.fromEntries(e.filter(n=>!!z(n,"addMarkView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:qt(n.name,this.schema)},i=z(n,"addMarkView",s);if(!i)return[];const o=(a,l,d)=>{const u=ms(a,r);return i()({mark:a,view:l,inline:d,editor:t,extension:n,HTMLAttributes:u,updateAttributes:h=>{f1(a,t,h)}})};return[n.name,o]}))}destroy(){this.extensions.forEach(t=>{let e=t;for(;e.parent;){const n=e.parent;n.child===e&&(n.child=null),e=n}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Rr(e.name,this.schema)};e.type==="mark"&&((n=U(z(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=z(e,"onBeforeCreate",r),i=z(e,"onCreate",r),o=z(e,"onUpdate",r),a=z(e,"onSelectionUpdate",r),l=z(e,"onTransaction",r),d=z(e,"onFocus",r),u=z(e,"onBlur",r),h=z(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)})}};Co.resolve=jf;Co.sort=Gr;Co.flatten=tc;var t1={};Yl(t1,{ClipboardTextSerializer:()=>Bf,Commands:()=>$f,Delete:()=>_f,Drop:()=>Hf,Editable:()=>Ff,FocusEvents:()=>qf,Keymap:()=>Kf,Paste:()=>Wf,Tabindex:()=>Uf,TextDirection:()=>Jf,focusEventsPluginKey:()=>Vf});var he=class zf extends ic{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new zf(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Bf=he.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new te({key:new ae("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{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=rc(n);return Tf(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),$f=he.create({name:"commands",addCommands(){return{...gf}}}),_f=he.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,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,t))!=null?d:t.getMeta("y-sync$"))return;const u=kf(t.before,[t,...e]);Af(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(m,g)=>{const b=g+m.nodeSize-2,y=f.oldRange.from<=g&&b<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:g,to:b,newFrom:u.mapping.map(g),newTo:u.mapping.map(b),deletedRange:f.oldRange,newRange:f.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:u})})});const p=u.mapping;u.steps.forEach((f,m)=>{var g,b;if(f instanceof pt){const y=p.slice(m).map(f.from,-1),k=p.slice(m).map(f.to),C=p.invert().map(y,-1),j=p.invert().map(k),O=y>0?(g=u.doc.nodeAt(y-1))==null?void 0:g.marks.some(N=>N.eq(f.mark)):!1,S=(b=u.doc.nodeAt(k))==null?void 0:b.marks.some(N=>N.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:C,to:j},newRange:{from:y,to:k},partial:!!(S||O),editor:this.editor,transaction:t,combinedTransform:u})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),Hf=he.create({name:"drop",addProseMirrorPlugins(){return[new te({key:new ae("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>
vendor: 20,005 bytes, lines 14-86
14{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Ff=he.create({name:"editable",addProseMirrorPlugins(){return[new te({key:new ae("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Vf=new ae("focusEvents"),qf=he.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new te({key:Vf,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Kf=he.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:d}=a,{empty:u,$anchor:h}=l,{pos:p,parent:f}=h,m=h.parent.isTextblock&&p>0?a.doc.resolve(p-1):h,g=m.parent.type.spec.isolating,b=h.pos-h.parentOffset,y=g&&m.parent.childCount===1?b===h.pos:F.atStart(d).from===p;return!u||!f.type.isTextblock||f.textContent.length||!y||y&&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:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"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 Ri()||vf()?i:s},addProseMirrorPlugins(){return[new te({key:new ae("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),s=t.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:a}=e.selection,l=F.atStart(e.doc).from,d=F.atEnd(e.doc).to;if(i||!(o===l&&a===d)||!gs(n.doc))return;const p=n.tr,f=vo({state:n,transaction:p}),{commands:m}=new wo({editor:this.editor,state:f});if(m.clearNodes(),!!p.steps.length)return p}})]}}),Wf=he.create({name:"paste",addProseMirrorPlugins(){return[new te({key:new ae("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Uf=he.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new te({key:new ae("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),Jf=he.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=yr(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new te({key:new ae("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),n1=class Fr{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,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 n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You canât set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,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),n=this.resolvedPos.doc.resolve(e);return new Fr(n,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 Fr(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 Fr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.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 Fr(l,this.editor,s,s||o?n: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,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let a=0;a<o.length;a+=1){const l=o[a];if(i[l]!==n[l])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(l=>n[l]===o.node.attrs[l])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},r1=`.ProseMirror { 15 position: relative; 16} 17 18.ProseMirror { 19 word-wrap: break-word; 20 white-space: pre-wrap; 21 white-space: break-spaces; 22 -webkit-font-variant-ligatures: none; 23 font-variant-ligatures: none; 24 font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ 25} 26 27.ProseMirror [contenteditable="false"] { 28 white-space: normal; 29} 30 31.ProseMirror [contenteditable="false"] [contenteditable="true"] { 32 white-space: pre-wrap; 33} 34 35.ProseMirror pre { 36 white-space: pre-wrap; 37} 38 39img.ProseMirror-separator { 40 display: inline !important; 41 border: none !important; 42 margin: 0 !important; 43 width: 0 !important; 44 height: 0 !important; 45} 46 47.ProseMirror-gapcursor { 48 display: none; 49 pointer-events: none; 50 position: absolute; 51 margin: 0; 52} 53 54.ProseMirror-gapcursor:after { 55 content: ""; 56 display: block; 57 position: absolute; 58 top: -2px; 59 width: 20px; 60 border-top: 1px solid black; 61 animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; 62} 63 64@keyframes ProseMirror-cursor-blink { 65 to { 66 visibility: hidden; 67 } 68} 69 70.ProseMirror-hideselection *::selection { 71 background: transparent; 72} 73 74.ProseMirror-hideselection *::-moz-selection { 75 background: transparent; 76} 77 78.ProseMirror-hideselection * { 79 caret-color: transparent; 80} 81 82.ProseMirror-focused .ProseMirror-gapcursor { 83 display: block; 84}`;function s1(t,e,n){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=t,document.getElementsByTagName("head")[0].appendChild(s),s}var i1=class extends Kw{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!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:ww,createMappablePosition:kw},this.setOptions(t),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(),n=bf(e,this.options.autofocus);this.editorState=ur.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){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(t),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 t=this.editorView.dom;t?.editor&&delete t.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(t){console.warn("Failed to remove CSS element:",t)}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=s1(r1,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),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:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,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(t,e){const n=Sf(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e,n,r;const i=[...this.options.enableCoreExtensions?[Ff,Bf.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),$f,qf,Kf,Uf.configure({value:(r=(n=this.options.coreExtensionOptions)==null?void 0:n.tabindex)==null?void 0:r.value}),Hf,Wf,_f,Jf.configure({direction:this.options.textDirection})].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new Co(i,this)}createCommandManager(){this.commandManager=new wo({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=al(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(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=al(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new mf(t,{...e,attributes:{role:"textbox",...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(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(d=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(d)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(d=>d.getMeta("focus")||d.getMeta("blur")),a=o?.getMeta("focus"),l=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}),!(t.getMeta("preventUpdate")||!n.some(d=>d.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Ef(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return bw(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return nc(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` 85 86`,textSerializers:n={}}=t||{};return Mf(this.state.doc,{blockSeparator:e,textSerializers:{...rc(this.schema),...n}})}get isEmpty(){return gs(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText?e.nodeAfter:null;return new n1(e,this,!1,n)}get $doc(){return this.$pos(0)}};function vr(t){return new So({find:t.find,handler:({state:e,range:n,match:r})=>{const s=U(t.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=n.from+a.indexOf(o),u=d+o.length;if(sc(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(g=>g===t.type&&g!==f.mark.type)).filter(f=>f.to>d).length)return null;u<n.to&&i.delete(u,n.to),d>n.from&&i.delete(n.from+l,d);const p=n.from+l+o.length;i.addMark(n.from+l,p,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function o1(t){return new So({find:t.find,handler:({state:e,range:n,match:r})=>{const s=U(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let a=n.to;const l=t.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=t.type.isInline?o:o-1;i.insert(d,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(a))}i.scrollIntoView()},undoable:t.undoable})}function cl(t){return new So({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=U(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function wr(t){return new So({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=U(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),l=o.doc.resolve(n.from).blockRange(),d=l&&Rl(l,t.type,i);if(!d)return null;if(o.wrap(l,d),t.keepMarks&&t.editor){const{selection:h,storedMarks:p}=e,{splittableMarks:f}=t.editor.extensionManager,m=p||h.$to.parentOffset&&h.$from.marks();if(m){const g=m.filter(b=>f.includes(b.type.name));o.ensureMarks(g)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(h,i).run()}const u=o.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&gn(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&o.join(n.from-1)},undoable:t.undoable})}function a1(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof B){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 l1={};Yl(l1,{createAtomBlockMarkdownSpec:()=>c1,createBlockMarkdownSpec:()=>d1,createInlineMarkdownSpec:()=>p1,parseAttributes:()=>oc,parseIndentedBlocks:()=>dl,renderNestedMarkdownContent:()=>lc,serializeAttributes:()=>ac});function oc(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,d=>(n.push(d),`__QUOTED_${n.length-1}
86__`)),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 p=parseInt(((h=u.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),f=n[p];f&&(e[d]=f.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 ac(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function c1(t){const{nodeName:e,name:n,parseAttributes:r=oc,serializeAttributes:s=ac,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:a}=t,l=n||e,d=u=>{if(!a)return u;const h={};return a.forEach(p=>{p in u&&(h[p]=u[p])}),h};return{parseMarkdown:(u,h)=>{const p={...i,...u.attributes};return h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(u){var h;const p=new RegExp(`^:::${l}(?:\\s|$)`,"m"),f=(h=u.match(p))==null?void 0:h.index;return f!==void 0?f:-1},tokenize(u,h,p){const f=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(f);if(!m)return;const g=m[1]||"",b=r(g);if(!o.find(k=>!(k in b)))return{type:e,raw:m[0],attributes:b}}},renderMarkdown:u=>{const h=d(u.attrs||{}),p=s(h),f=p?` {${p}}`:"";return`:::${l}${f} :::`}}}function d1(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=oc,serializeAttributes:i=ac,defaultAttributes:o={},content:a="block",allowedAttributes:l}=t,d=n||e,u=h=>{if(!l)return h;const p={};return l.forEach(f=>{f in h&&(p[f]=h[f])}),p};return{parseMarkdown:(h,p)=>{let f;if(r){const g=r(h);f=typeof g=="string"?[{type:"text",text:g}]:g}else a==="block"?f=p.parseChildren(h.tokens||[]):f=p.parseInline(h.tokens||[]);const m={...o,...h.attributes};return p.createNode(e,m,f)},markdownTokenizer:{name:e,level:"block",start(h){var p;const f=new RegExp(`^:::${d}`,"m"),m=(p=h.match(f))==null?void 0:p.index;return m!==void 0?m:-1},tokenize(h,p,f){var m;const g=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),b=h.match(g);if(!b)return;const[y,k=""]=b,C=s(k);let j=1;const O=y.length;let S="";const N=/^:::([\w-]*)(\s.*)?/gm,P=h.slice(O);for(N.lastIndex=0;;){const D=N.exec(P);if(D===null)break;const L=D.index,J=D[1];if(!((m=D[2])!=null&&m.endsWith(":::"))){if(J)j+=1;else if(j-=1,j===0){const Ee=P.slice(0,L);S=Ee.trim();const le=h.slice(0,O+L+D[0].length);let ce=[];if(S)if(a==="block")for(ce=f.blockTokens(Ee),ce.forEach(ne=>{ne.text&&(!ne.tokens||ne.tokens.length===0)&&(ne.tokens=f.inlineTokens(ne.text))});ce.length>0;){const ne=ce[ce.length-1];if(ne.type==="paragraph"&&(!ne.text||ne.text.trim()===""))ce.pop();else break}else ce=f.inlineTokens(S);return{type:e,raw:le,attributes:C,content:S,tokens:ce}}}}}},renderMarkdown:(h,p)=>{const f=u(h.attrs||{}),m=i(f),g=m?` {${m}}`:"",b=p.renderChildren(h.content||[],` 87 88`);return`:::${d}${g} 89 90${b} 91 92:::`}}}function u1(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function h1(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function p1(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=u1,serializeAttributes:i=h1,defaultAttributes:o={},selfClosing:a=!1,allowedAttributes:l}=t,d=n||e,u=p=>{if(!l)return p;const f={};return l.forEach(m=>{const g=typeof m=="string"?m:m.name,b=typeof m=="string"?void 0:m.skipIfDefault;if(g in p){const y=p[g];if(b!==void 0&&y===b)return;f[g]=y}}),f},h=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,f)=>{const m={...o,...p.attributes};if(a)return f.createNode(e,m);const g=r?r(p):p.content||"";return g?f.createNode(e,m,[f.createTextNode(g)]):f.createNode(e,m,[])},markdownTokenizer:{name:e,level:"inline",start(p){const f=a?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),m=p.match(f),g=m?.index;return g!==void 0?g:-1},tokenize(p,f,m){const g=a?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),b=p.match(g);if(!b)return;let y="",k="";if(a){const[,j]=b;k=j}else{const[,j,O]=b;k=j,y=O||""}const C=s(k.trim());return{type:e,raw:b[0],content:y.trim(),attributes:C}}},renderMarkdown:p=>{let f="";r?f=r(p):p.content&&p.content.length>0&&(f=p.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const m=u(p.attrs||{}),g=i(m),b=g?` ${g}`:"";return a?`[${d}${b}]`:`[${d}${b}]${f}[/${d}]`}}}function dl(t,e,n){var r,s,i,o;const a=t.split(` 93`),l=[];let d="",u=0;const h=e.baseIndentSize||2;for(;u<a.length;){const p=a[u],f=p.match(e.itemPattern);if(!f){if(l.length>0)break;if(p.trim()===""){u+=1,d=`${d}${p} 94`;continue}else return}const m=e.extractItemData(f),{indentLevel:g,mainContent:b}=m;d=`${d}${p} 95`;const y=[b];for(u+=1;u<a.length;){const O=a[u];if(O.trim()===""){const N=a.slice(u+1).findIndex(L=>L.trim()!=="");if(N===-1)break;if((((s=(r=a[u+1+N].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>g){y.push(O),d=`${d}${O} 96`,u+=1;continue}else break}if((((o=(i=O.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>g)y.push(O),d=`${d}${O} 97`,u+=1;else break}let k;const C=y.slice(1);if(C.length>0){const O=C.map(S=>S.slice(g+h)).join(` 98`);O.trim()&&(e.customNestedParser?k=e.customNestedParser(O):k=n.blockTokens(O))}const j=e.createToken(m,k);l.push(j)}if(l.length!==0)return{items:l,raw:d}}function lc(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,a=e.renderChildren([i]);let l=`${s}${a}`;return o&&o.length>0&&o.forEach((d,u)=>{var h,p;const f=(p=(h=e.renderChild)==null?void 0:h.call(e,d,u+1))!=null?p:e.renderChildren([d]);if(f!=null){const m=f.split(` 99`).map(g=>g?e.indent(g):e.indent("")).join(` 100`);l+=d.type==="paragraph"?` 101 102${m}`:` 103${m}`}}),l}function f1(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((a,l)=>{const d=i.mapping.map(l),u=i.mapping.map(l)+a.nodeSize;let h=null;if(a.marks.forEach(f=>{if(f!==o)return!1;h=f}),!h)return;let p=!1;
103if(Object.keys(n).forEach(f=>{n[f]!==h.attrs[f]&&(p=!0)}),p){const f=t.type.create({...t.attrs,...n});i.removeMark(d,u,t.type),i.addMark(d,u,f)}}),i.docChanged&&e.view.dispatch(i)}var De=class Gf extends ic{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Gf(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Fn(t){return new Qw({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=U(t.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=n.to;if(a){const u=l.search(/\S/),h=n.from+l.indexOf(a),p=h+a.length;if(sc(n.from,n.to,e.doc).filter(g=>g.mark.type.excluded.find(y=>y===t.type&&y!==g.mark.type)).filter(g=>g.to>h).length)return null;p<n.to&&o.delete(p,n.to),h>n.from&&o.delete(n.from+u,h),d=n.from+u+a.length,o.addMark(n.from+u,d,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}var m1=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},g1=({contentComponent:t})=>{const e=Rh.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return c.jsx(c.Fragment,{children:Object.values(e)})};function x1(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Jg.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var b1=class extends Vt.Component{constructor(t){super(t),this.editorContentRef=Vt.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=x1(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var t;const e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return c.jsxs(c.Fragment,{children:[c.jsx("div",{ref:m1(e,this.editorContentRef),...n}),t?.contentComponent&&c.jsx(g1,{contentComponent:t.contentComponent})]})}},y1=v.forwardRef((t,e)=>{const n=Vt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Vt.createElement(b1,{key:n,innerRef:e,...t})}),Qf=Vt.memo(y1),v1=typeof window<"u"?v.useLayoutEffect:v.useEffect,w1=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},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(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function Yf(t){var e;const[n]=v.useState(()=>new w1(t.editor)),r=wx.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:vx);return v1(()=>n.watch(t.editor),[t.editor,n]),v.useDebugValue(r),r}var k1=!1,Xf=typeof window>"u",N1=Xf||!!(typeof window<"u"&&window.next),S1=class Zf{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.get
103ServerSnapshot=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(n=>n())}getInitialEditor(){const e=this.options.current.immediatelyRender;let n=e??!0;return Xf?(n&&k1&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),n=!1):N1&&e===void 0&&(n=!1),n?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 i1(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Zf.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):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,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function C1(t={},e=[]){const n=v.useRef(t);n.current=t;const[r]=v.useState(()=>new S1(n)),s=Rh.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return v.useDebugValue(s),v.useEffect(r.onRender(e)),Yf({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var cc=v.createContext({editor:null});cc.Consumer;var em=()=>v.useContext(cc),j1=v.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),T1=()=>v.useContext(j1);Vt.forwardRef((t,e)=>{const{onDragStart:n}=T1(),r=t.as||"div";return c.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Vt.createContext({markViewContentRef:()=>{}});var dc=v.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});dc.displayName="TiptapContext";var M1=()=>v.useContext(dc);function tm({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=v.useMemo(()=>({editor:r}),[r]),i=v.useMemo(()=>({editor:r}),[r]);return c.jsx(cc.Provider,{value:i,children:c.jsx(dc.Provider,{value:s,children:n})})}tm.displayName="Tiptap";function nm({...t}){const{editor:e}=M1();return c.jsx(Qf,{editor:e,...t})}nm.displayName="Tiptap.Content";Object.assign(tm,{Content:nm});let ul,hl;if(typeof WeakMap<"u"){let t=new WeakMap;ul=e=>t.get(e),hl=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;ul=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},hl=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var be=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let a=1;i<this.width&&this.map[e+a]==n;a++)i++;for(let a=1;o<this.height&&this.map[e+this.width*a]==n;a++)o++;
103return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:a,top:l,bottom:d}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,l),right:Math.max(r,a),bottom:Math.max(i,d)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const a=(t+1)*this.width;for(;o<a&&this.map[o]<s;)o++;return o==a?i-1:this.map[o]}s=i}}static get(t){return ul(t)||hl(t,E1(t))}};function E1(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=A1(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let d=0,u=e*n;d<u;d++)r[d]=0;for(let d=0,u=0;d<n;d++){const h=t.child(d);u++;for(let m=0;;m++){for(;s<r.length&&r[s]!=0;)s++;if(m==h.childCount)break;const g=h.child(m),{colspan:b,rowspan:y,colwidth:k}=g.attrs;for(let C=0;C<y;C++){if(C+d>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-C});break}const j=s+C*e;for(let O=0;O<b;O++){r[j+O]==0?r[j+O]=u:(i||(i=[])).push({type:"collision",row:d,pos:u,n:b-O});const S=k&&k[O];if(S){const N=(j+O)%e*2,P=o[N];P==null||P!=S&&o[N+1]==1?(o[N]=S,o[N+1]=1):P==S&&o[N+1]++}}}s+=b,u+=g.nodeSize}const p=(d+1)*e;let f=0;for(;s<p;)r[s++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:d,n:f}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const a=new be(e,n,r,i);let l=!1;for(let d=0;!l&&d<o.length;d+=2)o[d]!=null&&o[d+1]<n&&(l=!0);return l&&O1(a,o,t),a}function A1(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const a=t.child(o);for(let l=0;l<a.childCount;l++){const d=a.child(l);o+d.attrs.rowspan>r&&(i+=d.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const a=s.child(o);i+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function O1(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let a=null;const l=o.attrs;for(let d=0;d<l.colspan;d++){const u=e[(s+d)%t.width*2];u!=null&&(!l.colwidth||l.colwidth[d]!=u)&&((a||(a=I1(l)))[d]=u)}a&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function I1(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Be(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const on=new ae("selectingCells");function Vn(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function P1(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function mt(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function jo(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Vn(e.$head)||R1(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function R1(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function pl(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function D1(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function uc(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}
103function rm(t,e,n){const r=t.node(-1),s=be.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function qn(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function sm(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function L1(t,e,n){const r=Be(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var ee=class Dt extends F{constructor(e,n=e){const r=e.node(-1),s=be.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),a=e.node(0),l=s.cellsInRect(o).filter(u=>u!=n.pos-i);l.unshift(n.pos-i);const d=l.map(u=>{const h=r.nodeAt(u);if(!h)throw new RangeError(`No cell with offset ${u} found`);const p=i+u+1;return new bp(a.resolve(p),a.resolve(p+h.content.size))});super(d[0].$from,d[0].$to,d),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(pl(r)&&pl(s)&&uc(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Dt.rowSelection(r,s):i&&this.isColSelection()?Dt.colSelection(r,s):new Dt(r,s)}return $.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=be.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let l=s.top;l<s.bottom;l++){const d=[];for(let u=l*n.width+s.left,h=s.left;h<s.right;h++,u++){const p=n.map[u];if(i[p])continue;i[p]=!0;const f=n.findCell(p);let m=e.nodeAt(p);if(!m)throw new RangeError(`No cell with offset ${p} found`);const g=s.left-f.left,b=f.right-s.right;if(g>0||b>0){let y=m.attrs;if(g>0&&(y=qn(y,0,g)),b>0&&(y=qn(y,y.colspan-b,b)),f.left<s.left){if(m=m.type.createAndFill(y),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else m=m.type.create(y,m.content)}if(f.top<s.top||f.bottom>s.bottom){const y={...m.attrs,rowspan:Math.min(f.bottom,s.bottom)-Math.max(f.top,s.top)};f.top<s.top?m=m.type.createAndFill(y):m=m.type.create(y,m.content)}d.push(m)}o.push(e.child(l).copy(E.from(d)))}const a=this.isColSelection()&&this.isRowSelection()?e:o;return new R(E.from(a),1,1)}replace(e,n=R.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:a,$to:l}=s[o],d=e.mapping.slice(r);e.replace(d.map(a.pos),d.map(l.pos),o?R.empty:n)}const i=F.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new R(E.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=be.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=be.get(r),i=e.start(-1),o=s.findCell(e.pos-i),a=s.findCell(n.pos-i),l=e.node(0);return o.top<=a.top?(o.top>0&&(e=l.resolve(i+s.map[o.left])),a.bottom<s.height&&(n=l.resolve(i+s.map[s.width*(s.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(i+s.map[a.left])),o.bottom<s.height&&(e=l.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new Dt(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=be.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,a=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,a)==n.width}eq(e){return e instanceof Dt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=be.get(r),i=e.start(-1),o=s.findCell(e.pos-i),a=s.findCell(n.pos-i),l=e.node(0);return o.left<=a.left?(o.left>0&&(e=l.resolve(i+s.map[o.top*s.width])),a.right<s.width&&(n=l.resolve(i+s.map[s.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(i+s.map[a.top*s.width])),o.right<s.width&&(e=l.resolve(i+s.map[s.width*(o.top+1)-1]))),new Dt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Dt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Dt(e.resolve(n),e.resolve(r))}getBookmark(){return new z1(this.$anchorCell.pos,this.$headCell.pos)}};ee.prototype.visible=!1;F.jsonID("cell",ee);var z1=class im{constructor(e,n){this.anchor=e,this.head=n}map(e){return new im(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&uc(n,r)?new ee(n,r):F.near(r,1)}};function B1(t){if(!(t.selection instanceof ee))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(je.node(r,r+n.nodeSize,{class:"selectedCell"}))}),re.create(t.doc,e)}function $1({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);
103return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function _1({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function H1(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof B&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=ee.create(s,r.from);else if(o=="row"){const a=s.resolve(r.from+1);i=ee.rowSelection(a,a)}else if(!n){const a=be.get(r.node),l=r.from+1,d=l+a.map[a.width*a.height-1];i=ee.create(s,l+1,d)}}else r instanceof $&&$1(r)?i=$.create(s,r.from):r instanceof $&&_1(r)&&(i=$.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const F1=new ae("fix-tables");function om(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,a=0;o<i;o++){const l=e.child(o);for(let d=a,u=Math.min(s,o+3);d<u;d++)if(t.child(d)==l){a=d+1,n+=l.nodeSize;continue e}r(l,n),a<s&&t.child(a).sameMarkup(l)?om(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function am(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=V1(t,s,i,n))};return e?e.doc!=t.doc&&om(e.doc,t.doc,0,r):t.doc.descendants(r),n}function V1(t,e,n,r){const s=be.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let l=0;l<s.height;l++)i.push(0);for(let l=0;l<s.problems.length;l++){const d=s.problems[l];if(d.type=="collision"){const u=e.nodeAt(d.pos);if(!u)continue;const h=u.attrs;for(let p=0;p<h.rowspan;p++)i[d.row+p]+=d.n;r.setNodeMarkup(r.mapping.map(n+1+d.pos),null,qn(h,h.colspan-d.n,d.n))}else if(d.type=="missing")i[d.row]+=d.n;else if(d.type=="overlong_rowspan"){const u=e.nodeAt(d.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+d.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-d.n})}else if(d.type=="colwidth mismatch"){const u=e.nodeAt(d.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+d.pos),null,{...u.attrs,colwidth:d.colwidth})}else if(d.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let o,a;for(let l=0;l<i.length;l++)i[l]&&(o==null&&(o=l),a=l);for(let l=0,d=n+1;l<s.height;l++){const u=e.child(l),h=d+u.nodeSize,p=i[l];if(p>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const m=[];for(let b=0;b<p;b++){const y=Be(t.schema)[f].createAndFill();y&&m.push(y)}const g=(l==0||o==l-1)&&a==l?d+1:h-1;r.insert(r.mapping.map(g),m)}d=h}return r.setMeta(F1,{fixTables:!0})}function Tt(t){const e=t.selection,n=jo(t),r=n.node(-1),s=n.start(-1),i=be.get(r);return{...e instanceof ee?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function lm(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;L1(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const a=o*e.width+s;if(s>0&&s<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],d=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,sm(d.attrs,s-e.colCount(l))),o+=d.attrs.rowspan-1}else{const l=i==null?Be(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,d=e.positionAt(o,s,r);t.insert(t.mapping.map(n+d),l.createAndFill())}}return t}function q1(t,e){if(!mt(t))return!1;if(e){const n=Tt(t);e(lm(t.tr,n,n.left))}return!0}function K1(t,e){if(!mt(t))return!1;if(e){const n=Tt(t);e(lm(t.tr,n,n.right))}return!0}function W1(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const a=o*e.width+s,l=e.map[a],d=n.nodeAt(l),u=d.attrs;if(s>0&&e.map[a-1]==l||s<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(i).map(r+l),null,qn(u,s-e.colCount(l)));else{const h=t.mapping.slice(i).map(r+l);t.delete(h,h+d.nodeSize)}o+=u.rowspan}}function U1(t,e){if(!mt(t))return!1;if(e){const n=Tt(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;W1(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=be.get(i)}e(r)}return!0}function J1(t,e,n){var r;const s=Be(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function cm(t,{map:e,tableStart:n,table:r},s){let i=n;for(let d=0;d<s;d++)i+=r.child(d).nodeSize;const o=[];let a=s>0?-1:0;
103J1(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let d=0,u=e.width*s;d<e.width;d++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){const h=e.map[u],p=r.nodeAt(h).attrs;t.setNodeMarkup(n+h,null,{...p,rowspan:p.rowspan+1}),d+=p.colspan-1}else{var l;const h=a==null?Be(r.type.schema).cell:(l=r.nodeAt(e.map[u+a*e.width]))===null||l===void 0?void 0:l.type,p=h?.createAndFill();p&&o.push(p)}return t.insert(i,Be(r.type.schema).row.create(null,o)),t}function G1(t,e){if(!mt(t))return!1;if(e){const n=Tt(t);e(cm(t.tr,n,n.top))}return!0}function Q1(t,e){if(!mt(t))return!1;if(e){const n=Tt(t);e(cm(t.tr,n,n.bottom))}return!0}function Y1(t,{map:e,table:n,tableStart:r},s){let i=0;for(let d=0;d<s;d++)i+=n.child(d).nodeSize;const o=i+n.child(s).nodeSize,a=t.mapping.maps.length;t.delete(i+r,o+r);const l=new Set;for(let d=0,u=s*e.width;d<e.width;d++,u++){const h=e.map[u];if(!l.has(h)){if(l.add(h),s>0&&h==e.map[u-e.width]){const p=n.nodeAt(h).attrs;t.setNodeMarkup(t.mapping.slice(a).map(h+r),null,{...p,rowspan:p.rowspan-1}),d+=p.colspan-1}else if(s<e.height&&h==e.map[u+e.width]){const p=n.nodeAt(h),f=p.attrs,m=p.type.create({...f,rowspan:p.attrs.rowspan-1},p.content),g=e.positionAt(s+1,d,n);t.insert(t.mapping.slice(a).map(r+g),m),d+=f.colspan-1}}}}function X1(t,e){if(!mt(t))return!1;if(e){const n=Tt(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;Y1(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=be.get(n.table)}e(r)}return!0}function Ou(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Z1({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,a=s+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[a]==n[a+1])return!0;i+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Iu(t,e){const n=t.selection;if(!(n instanceof ee)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Tt(t),{map:s}=r;if(Z1(s,r))return!1;if(e){const i=t.tr,o={};let a=E.empty,l,d;for(let u=r.top;u<r.bottom;u++)for(let h=r.left;h<r.right;h++){const p=s.map[u*s.width+h],f=r.table.nodeAt(p);if(!(o[p]||!f))if(o[p]=!0,l==null)l=p,d=f;else{Ou(f)||(a=a.append(f.content));const m=i.mapping.map(p+r.tableStart);i.delete(m,m+f.nodeSize)}}if(l==null||d==null)return!0;if(i.setNodeMarkup(l+r.tableStart,null,{...sm(d.attrs,d.attrs.colspan,r.right-r.left-d.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const u=l+1+d.content.size,h=Ou(d)?l+1:u;i.replaceWith(h+r.tableStart,u+r.tableStart,a)}i.setSelection(new ee(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function Pu(t,e){const n=Be(t.schema);return ek(({node:r})=>n[r.type.spec.tableRole])(t,e)}function ek(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof ee){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=P1(r.$from),!s)return!1;i=(o=Vn(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let a=s.attrs;const l=[],d=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const u=Tt(e),h=e.tr;for(let f=0;f<u.right-u.left;f++)l.push(d?{...a,colwidth:d&&d[f]?[d[f]]:null}:a);let p;for(let f=u.top;f<u.bottom;f++){let m=u.map.positionAt(f,u.left,u.table);f==u.top&&(m+=s.nodeSize);for(let g=u.left,b=0;g<u.right;g++,b++)g==u.left&&f==u.top||h.insert(p=h.mapping.map(m+u.tableStart,1),t({node:s,row:f,col:g}).createAndFill(l[b]))}h.setNodeMarkup(i,t({node:s,row:u.top,col:u.left}),l[0]),r instanceof ee&&h.setSelection(new ee(h.doc.resolve(r.$anchorCell.pos),p?h.doc.resolve(p):void 0)),n(h)}return!0}}function tk(t,e){return function(n,r){if(!mt(n))return!1;const s=jo(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof ee?n.selection.forEachCell((o,a)=>{o.attrs[t]!==e&&i.setNodeMarkup(a,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function nk(t){return function(e,n){if(!mt(e))return!1;if(n){const r=Be(e.schema),s=Tt(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}
103:s),a=o.map(l=>s.table.nodeAt(l));for(let l=0;l<o.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[l],r.cell,a[l].attrs);if(i.steps.length===0)for(let l=0;l<o.length;l++)i.setNodeMarkup(s.tableStart+o[l],r.header_cell,a[l].attrs);n(i)}return!0}}function Ru(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function xs(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?nk(t):function(n,r){if(!mt(n))return!1;if(r){const s=Be(n.schema),i=Tt(n),o=n.tr,a=Ru("row",i,s),l=Ru("column",i,s),d=(t==="column"?a:t==="row"&&l)?1:0,u=t=="column"?{left:0,top:d,right:1,bottom:i.map.height}:t=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,h=t=="column"?l?s.cell:s.header_cell:t=="row"?a?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(p=>{const f=p+i.tableStart,m=o.doc.nodeAt(f);m&&o.setNodeMarkup(f,h,m.attrs)}),r(o)}return!0}}xs("row",{useDeprecatedLogic:!0});xs("column",{useDeprecatedLogic:!0});const rk=xs("cell",{useDeprecatedLogic:!0});function sk(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Du(t){return function(e,n){if(!mt(e))return!1;const r=sk(jo(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection($.between(s,D1(s))).scrollIntoView())}return!0}}function ik(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function ri(t,e){const n=t.selection;if(!(n instanceof ee))return!1;if(e){const r=t.tr,s=Be(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new R(s,0,0))}),r.docChanged&&e(r)}return!0}function ok(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let d=e.child(l).content;const u=l?0:Math.max(0,n-1),h=l<e.childCount-1?0:Math.max(0,r-1);(u||h)&&(d=fl(Be(o).row,new R(d,u,h)).content),a.push(d)}else if(i=="cell"||i=="header_cell")a.push(n||r?fl(Be(o).row,new R(e,n,r)).content:e);else return null;return ak(o,a)}function ak(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:a,colspan:l}=i.child(o).attrs;for(let d=s;d<s+a;d++)n[d]=(n[d]||0)+l}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(E.empty),n[s]<r){const i=Be(t).cell.createAndFill(),o=[];for(let a=n[s];a<r;a++)o.push(i);e[s]=e[s].append(E.from(o))}return{height:e.length,width:r,rows:e}}function fl(t,e){const n=t.createAndFill();return new Dl(n).replace(0,n.content.size,e).doc}function lk({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let a=0;a<n.length;a++){const l=n[a],d=[];for(let u=i[a]||0,h=0;u<r;h++){let p=l.child(h%l.childCount);u+p.attrs.colspan>r&&(p=p.type.createChecked(qn(p.attrs,p.attrs.colspan,u+p.attrs.colspan-r),p.content)),d.push(p),u+=p.attrs.colspan;for(let f=1;f<p.attrs.rowspan;f++)i[a+f]=(i[a+f]||0)+p.attrs.colspan}o.push(E.from(d))}n=o,t=r}if(e!=s){const i=[];for(let o=0,a=0;o<s;o++,a++){const l=[],d=n[a%e];for(let u=0;u<d.childCount;u++){let h=d.child(u);o+h.attrs.rowspan>s&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,s-h.attrs.rowspan)},h.content)),l.push(h)}i.push(E.from(l))}n=i,e=s}return{width:t,height:e,rows:n}}function ck(t,e,n,r,s,i,o){const a=t.doc.type.schema,l=Be(a);let d,u;if(s>e.width)for(let h=0,p=0;h<e.height;h++){const f=n.child(h);p+=f.nodeSize;const m=[];let g;f.lastChild==null||f.lastChild.type==l.cell?g=d||(d=l.cell.createAndFill()):g=u||(u=l.header_cell.createAndFill());for(let b=e.width;b<s;b++)m.push(g);t.insert(t.mapping.slice(o).map(p-1+r),m)}if(i>e.height){const h=[];for(let m=0,g=(e.height-1)*e.width;m<Math.max(e.width,s);m++){const b=m>=e.width?!1:n.nodeAt(e.map[g+m]).type==l.header_cell;h.push(b?u||(u=l.header_cell.createAndFill()):d||(d=l.cell.createAndFill()))}
103const p=l.row.create(null,E.from(h)),f=[];for(let m=e.height;m<i;m++)f.push(p);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(d||u)}function Lu(t,e,n,r,s,i,o,a){if(o==0||o==e.height)return!1;let l=!1;for(let d=s;d<i;d++){const u=o*e.width+d,h=e.map[u];if(e.map[u-e.width]==h){l=!0;const p=n.nodeAt(h),{top:f,left:m}=e.findCell(h);t.setNodeMarkup(t.mapping.slice(a).map(h+r),null,{...p.attrs,rowspan:o-f}),t.insert(t.mapping.slice(a).map(e.positionAt(o,m,n)),p.type.createAndFill({...p.attrs,rowspan:f+p.attrs.rowspan-o})),d+=p.attrs.colspan-1}}return l}function zu(t,e,n,r,s,i,o,a){if(o==0||o==e.width)return!1;let l=!1;for(let d=s;d<i;d++){const u=d*e.width+o,h=e.map[u];if(e.map[u-1]==h){l=!0;const p=n.nodeAt(h),f=e.colCount(h),m=t.mapping.slice(a).map(h+r);t.setNodeMarkup(m,null,qn(p.attrs,o-f,p.attrs.colspan-(o-f))),t.insert(m+p.nodeSize,p.type.createAndFill(qn(p.attrs,0,o-f))),d+=p.attrs.rowspan-1}}return l}function Bu(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=be.get(i);const{top:a,left:l}=r,d=l+s.width,u=a+s.height,h=t.tr;let p=0;function f(){if(i=n?h.doc.nodeAt(n-1):h.doc,!i)throw new Error("No table found");o=be.get(i),p=h.mapping.maps.length}ck(h,o,i,n,d,u,p)&&f(),Lu(h,o,i,n,l,d,a,p)&&f(),Lu(h,o,i,n,l,d,u,p)&&f(),zu(h,o,i,n,a,u,l,p)&&f(),zu(h,o,i,n,a,u,d,p)&&f();for(let m=a;m<u;m++){const g=o.positionAt(m,l,i),b=o.positionAt(m,d,i);h.replace(h.mapping.slice(p).map(g+n),h.mapping.slice(p).map(b+n),new R(s.rows[m-a],0,0))}f(),h.setSelection(new ee(h.doc.resolve(n+o.positionAt(a,l,i)),h.doc.resolve(n+o.positionAt(u-1,d-1,i)))),e(h)}const dk=Ql({ArrowLeft:si("horiz",-1),ArrowRight:si("horiz",1),ArrowUp:si("vert",-1),ArrowDown:si("vert",1),"Shift-ArrowLeft":ii("horiz",-1),"Shift-ArrowRight":ii("horiz",1),"Shift-ArrowUp":ii("vert",-1),"Shift-ArrowDown":ii("vert",1),Backspace:ri,"Mod-Backspace":ri,Delete:ri,"Mod-Delete":ri});function mi(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function si(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof ee)return mi(n,r,F.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=dm(s,t,e);if(o==null)return!1;if(t=="horiz")return mi(n,r,F.near(n.doc.resolve(i.head+e),e));{const a=n.doc.resolve(o),l=rm(a,t,e);let d;return l?d=F.near(l,1):e<0?d=F.near(n.doc.resolve(a.before(-1)),-1):d=F.near(n.doc.resolve(a.after(-1)),1),mi(n,r,d)}}}function ii(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof ee)o=i;else{const l=dm(s,t,e);if(l==null)return!1;o=new ee(n.doc.resolve(l))}const a=rm(o.$headCell,t,e);return a?mi(n,r,new ee(o.$anchorCell,a)):!1}}function uk(t,e){const n=t.state.doc,r=Vn(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new ee(r))),!0):!1}function hk(t,e,n){if(!mt(t.state))return!1;let r=ok(n);const s=t.state.selection;if(s instanceof ee){r||(r={width:1,height:1,rows:[E.from(fl(Be(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),a=be.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=lk(r,a.right-a.left,a.bottom-a.top),Bu(t.state,t.dispatch,o,a,r),!0}else if(r){const i=jo(t.state),o=i.start(-1);return Bu(t.state,t.dispatch,o,be.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function pk(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=$u(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof ee)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Vn(t.state.selection.$anchor))!=null&&((n=ja(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(l,d){let u=ja(t,d);const h=on.getState(t.state)==null;if(!u||!uc(l,u))if(h)u=l;else return;const p=new ee(l,u);if(h||!t.state.selection.eq(p)){const f=t.state.tr.setSelection(p);h&&f.setMeta(on,l.pos),t.dispatch(f)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",a),on.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(on,-1))}function a(l){const d=l,u=on.getState(t.state);let h;if(u!=null)h=t.state.doc.resolve(u);else if($u(t,d.target)!=r&&(h=ja(t,e),!h))return o();h&&i(h,d)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",a)}function dm(t,e,n){if(!(t.state.selection instanceof $))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);
103if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?o:null}}return null}function $u(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ja(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&Vn(t.state.doc.resolve(r))||Vn(t.state.doc.resolve(s))}var fk=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ml(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ml(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ml(t,e,n,r,s,i){let o=0,a=!0,l=e.firstChild;const d=t.firstChild;if(d){for(let h=0,p=0;h<d.childCount;h++){const{colspan:f,colwidth:m}=d.child(h).attrs;for(let g=0;g<f;g++,p++){const b=s==p?i:m&&m[g],y=b?b+"px":"";if(o+=b||r,b||(a=!1),l)l.style.width!=y&&(l.style.width=y),l=l.nextSibling;else{const k=document.createElement("col");k.style.width=y,e.appendChild(k)}}}for(;l;){var u;const h=l.nextSibling;(u=l.parentNode)===null||u===void 0||u.removeChild(l),l=h}a?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const Qe=new ae("tableColumnResizing");function mk({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=fk,lastColumnResizable:s=!0}={}){const i=new te({key:Qe,state:{init(o,a){var l;const d=(l=i.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,u=Be(a.schema).table.name;return r&&d&&(d[u]=(h,p)=>new r(h,n,p)),new gk(-1,!1)},apply(o,a){return a.apply(o)}},props:{attributes:o=>{const a=Qe.getState(o);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,a)=>{xk(o,a,t,s)},mouseleave:o=>{bk(o)},mousedown:(o,a)=>{yk(o,a,e,n)}},decorations:o=>{const a=Qe.getState(o);if(a&&a.activeHandle>-1)return Sk(o,a.activeHandle)},nodeViews:{}}});return i}var gk=class gi{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Qe);if(r&&r.setHandle!=null)return new gi(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new gi(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return pl(e.doc.resolve(s))||(s=-1),new gi(s,n.dragging)}return n}};function xk(t,e,n,r){if(!t.editable)return;const s=Qe.getState(t.state);if(s&&!s.dragging){const i=wk(e.target);let o=-1;if(i){const{left:a,right:l}=i.getBoundingClientRect();e.clientX-a<=n?o=_u(t,e,"left",n):l-e.clientX<=n&&(o=_u(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const a=t.state.doc.resolve(o),l=a.node(-1),d=be.get(l),u=a.start(-1);if(d.colCount(a.pos-u)+a.nodeAfter.attrs.colspan-1==d.width-1)return}um(t,o)}}}function bk(t){if(!t.editable)return;const e=Qe.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&um(t,-1)}function yk(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=Qe.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const a=t.state.doc.nodeAt(o.activeHandle),l=vk(t,o.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(Qe,{setDragging:{startX:e.clientX,startWidth:l}}));function d(h){i.removeEventListener("mouseup",d),i.removeEventListener("mousemove",u);const p=Qe.getState(t.state);p?.dragging&&(kk(t,p.activeHandle,Hu(p.dragging,h,n)),t.dispatch(t.state.tr.setMeta(Qe,{setDragging:null})))}function u(h){if(!h.which)return d(h);const p=Qe.getState(t.state);if(p&&p.dragging){const f=Hu(p.dragging,h,n);Fu(t,p.activeHandle,f,r)}}return Fu(t,o.activeHandle,l,r),i.addEventListener("mouseup",d),i.addEventListener("mousemove",u),e.preventDefault(),!0}function vk(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(o-=r[l],a--);return o/a}function wk(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function _u(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,a=Vn(t.state.doc.resolve(o));if(!a)return-1;if(n=="right")return a.pos;const l=be.get(a.node(-1)),d=a.start(-1),u=l.map.indexOf(a.pos-d);return u%l.width==0?-1:d+l.map[u-1]}function Hu(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function um(t,e){t.dispatch(t.state.tr.setMeta(Qe,{setHandle:e}))}
103function kk(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=be.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let d=0;d<i.height;d++){const u=d*i.width+a;if(d&&i.map[u]==i.map[u-i.width])continue;const h=i.map[u],p=s.nodeAt(h).attrs,f=p.colspan==1?0:a-i.colCount(h);if(p.colwidth&&p.colwidth[f]==n)continue;const m=p.colwidth?p.colwidth.slice():Nk(p.colspan);m[f]=n,l.setNodeMarkup(o+h,null,{...p,colwidth:m})}l.docChanged&&t.dispatch(l)}function Fu(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),a=be.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let l=t.domAtPos(s.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&ml(i,l.firstChild,l,r,a,n)}function Nk(t){return Array(t).fill(0)}function Sk(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return re.empty;const i=be.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let d=0;d<i.height;d++){const u=a+d*i.width;if((a==i.width-1||i.map[u]!=i.map[u+1])&&(d==0||i.map[u]!=i.map[u-i.width])){var l;const h=i.map[u],p=o+h+s.nodeAt(h).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((l=Qe.getState(t))===null||l===void 0)&&l.dragging&&n.push(je.node(o+h,o+h+s.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),n.push(je.widget(p,f))}}return re.create(t.doc,n)}function Ck({allowTableNodeSelection:t=!1}={}){return new te({key:on,state:{init(){return null},apply(e,n){const r=e.getMeta(on);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:B1,handleDOMEvents:{mousedown:pk},createSelectionBetween(e){return on.getState(e.state)!=null?e.state.selection:null},handleTripleClick:uk,handleKeyDown:dk,handlePaste:hk},appendTransaction(e,n,r){return H1(r,am(r,n),t)}})}function jk(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),s=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-s,a=r-n,l=s,d=n;return new DOMRect(l,d,o,a)}var Tk=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:s=250,resizeDelay:i=60,shouldShow:o,appendTo:a,getReferencedVirtualElement:l,options:d}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:h,state:p,from:f,to:m})=>{const{doc:g,selection:b}=p,{empty:y}=b,k=!g.textBetween(f,m).length&&ec(p.selection),C=this.element.contains(document.activeElement);return!(!(h.hasFocus()||C)||y||k||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:h})=>{var p;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}h?.relatedTarget&&((p=this.element.parentNode)!=null&&p.contains(h.relatedTarget))||h?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(h,p)=>{const f=!p?.selection.eq(h.state.selection),m=!p?.doc.eq(h.state.doc);!f&&!m||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(h,f,m,p)},this.updateDelay))},this.updateHandler=(h,p,f,m)=>{const{composing:g}=h;if(g||!p&&!f)return;if(!this.getShouldShow(m)){this.hide();return}this.show(),this.updatePosition()},this.transactionHandler=({transaction:h})=>{const p=h.getMeta(this.pluginKey);p==="updatePosition"?this.updatePosition():p&&typeof p=="object"&&p.type==="updateOptions"?this.updateOptions(p.options):p==="hide"?this.hide():p==="show"&&(this.updatePosition(),this.show())};var u;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=s,this.resizeDelay=i,this.appendTo=a,this.scrollTarget=(u=d?.scrollTarget)!=null?u:window,this.getReferencedVirtualElement=l,this.floatingUIOptions={...this.floatingUIOptions,...d},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.get
103ShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(vh(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(wh(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(kh(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(Nh(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Sh(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(Ch(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(jh(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(Th(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,s=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(s)return s;if(!((n=(e=this.view)==null?void 0:e.dom)!=null&&n.parentNode))return;const i=Rf(this.view,r.from,r.to);let o={getBoundingClientRect:()=>i,getClientRects:()=>[i]};if(r instanceof B){let a=this.view.nodeDOM(r.from);const l=a.dataset.nodeViewWrapper?a:a.querySelector("[data-node-view-wrapper]");l&&(a=l),a&&(o={getBoundingClientRect:()=>a.getBoundingClientRect(),getClientRects:()=>[a.getBoundingClientRect()]})}if(r instanceof ee){const{$anchorCell:a,$headCell:l}=r,d=a?a.pos:l.pos,u=l?l.pos:a.pos,h=this.view.nodeDOM(d),p=this.view.nodeDOM(u);if(!h||!p)return;const f=h===p?h.getBoundingClientRect():jk(h.getBoundingClientRect(),p.getBoundingClientRect());o={getBoundingClientRect:()=>f,getClientRects:()=>[f]}}return o}updatePosition(){if(!this.isVisible)return;const t=this.virtualElement;t&&Mh(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r,middlewareData:s})=>{var i,o;if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if((i=s.hide)!=null&&i.referenceHidden||(o=s.hide)!=null&&o.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const s=!e?.selection.eq(t.state.selection),i=!e?.doc.eq(t.state.doc);this.updateHandler(t,s,i,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(l=>l.$from.pos)),o=Math.max(...s.map(l=>l.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},hm=t=>new te({key:typeof t.pluginKey=="string"?new ae(t.pluginKey):t.pluginKey,view:e=>
103new Tk({view:e,...t})});he.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[hm({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var Mk=class{constructor({editor:t,element:e,view:n,pluginKey:r="floatingMenu",updateDelay:s=250,resizeDelay:i=60,options:o,appendTo:a,shouldShow:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:u,state:h})=>{const{selection:p}=h,{$anchor:f,empty:m}=p,g=f.depth===1,b=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!u.hasFocus()||!m||!g||!b||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(u,h,p,f)=>{const{composing:m}=u;if(m||!h&&!p)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var h;if(this.preventHide){this.preventHide=!1;return}u?.relatedTarget&&((h=this.element.parentNode)!=null&&h.contains(u.relatedTarget))||u?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:u})=>{const h=u.getMeta(this.pluginKey);h==="updatePosition"?this.updatePosition():h&&typeof h=="object"&&h.type==="updateOptions"?this.updateOptions(h.options):h==="hide"?this.hide():h==="show"&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var d;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=s,this.resizeDelay=i,this.appendTo=a,this.scrollTarget=(d=o?.scrollTarget)!=null?d:window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return Mf(t,{textSerializers:rc(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(vh(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(wh(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(kh(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(Nh(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Sh(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(Ch(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(jh(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(Th(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(l=>l.$from.pos)),o=Math.max(...s.map(l=>l.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:i,to:o})}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}updatePosition(){var t,e;if(!((e=(t=this.view)==null?void 0:t.dom)!=null&&e.parentNode))return;const{selection:n}=this.editor.state,r=Rf(this.view,n.from,n.to);Mh({getBoundingClientRect:()=>r,getClientRects:()=>[r]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:o,strategy:a,middlewareData:l})=>{var d,u;if((d=l.hide)!=null&&d.referenceHidden||(u=l.hide)!=null&&u.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=a,this.element.style.left=`${i}px`,this.element.style.top=`${o}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!e?.selection.eq(t.state.selection),r=!e?.doc.eq(t.state.doc);this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},pm=t=>new te({key:typeof t.pluginKey=="string"?new ae(t.pluginKey):t.pluginKey,view:e=>
103new Mk({view:e,...t})});he.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:t,dispatch:e})=>(e&&t.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[pm({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function fm(t,e){return t??new ae(e)}var Ek=typeof window<"u"?v.useLayoutEffect:v.useEffect,mm=new Set(["left","opacity","position","top","visibility","width"]),Ak=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),Ok=new Set(["children","className","style"]),Ik=new Set(["tabIndex"]),Pk=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),Rk={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function gl(t,e){return/^on[A-Z]/.test(t)&&typeof e=="function"}function Dk(t){return t.startsWith("aria-")||t.startsWith("data-"),t}function Lk(t){return t.startsWith("aria-")||t.startsWith("data-")||Pk.has(t)}function gm(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function zk(t){var e;const n=t.endsWith("Capture"),s=(n?t.slice(0,-7):t).slice(2);return{eventName:(e=Rk[s])!=null?e:s.toLowerCase(),options:n?{capture:!0}:void 0}}function Bk(t,e){let n=e.defaultPrevented,r=!1;const s=Object.create(e);return Object.defineProperties(s,{nativeEvent:{value:e},currentTarget:{value:t},target:{value:e.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,e.preventDefault()}},stopPropagation:{value:()=>{r=!0,e.stopPropagation()}}}),s}function Ta(t){return Ik.has(t)}function Vu(t,e,n){if(e==="tabIndex"){t.tabIndex=Number(n);return}t[e]=n}function $k(t,e){if(e==="tabIndex"){t.removeAttribute("tabindex");return}const n=t[e];if(typeof n=="boolean"){t[e]=!1;return}if(typeof n=="number"){t[e]=0;return}t[e]=""}function _k(t,e){return typeof e!="number"||e===0||t.startsWith("--")||Ak.has(t)?String(e):`${e}px`}function Hk(t,e){mm.has(e)||t.style.removeProperty(gm(e))}function Fk(t,e,n){mm.has(e)||t.style.setProperty(gm(e),_k(e,n))}function Vk(t,e,n){new Set([...Object.keys(e),...Object.keys(n)]).forEach(s=>{if(Ok.has(s)||!Lk(s)||gl(s,e[s])||gl(s,n[s]))return;const i=e[s],o=n[s];if(i===o)return;const a=Dk(s);if(o==null||o===!1){Ta(s)&&$k(t,s),t.removeAttribute(a);return}if(o===!0){Ta(s)&&Vu(t,s,!0),t.setAttribute(a,"");return}if(Ta(s)){Vu(t,s,o);return}t.setAttribute(a,String(o))})}function qk(t,e,n){if(e!==n){if(n){t.className=n;return}t.removeAttribute("class")}}function Kk(t,e,n){const r=e??{},s=n??{};new Set([...Object.keys(r),...Object.keys(s)]).forEach(o=>{const a=r[o],l=s[o];if(a!==l){if(l==null){Hk(t,o);return}Fk(t,o,l)}})}function Wk(t,e,n){e.forEach(({eventName:s,listener:i,options:o})=>{t.removeEventListener(s,i,o)});const r=[];return Object.entries(n).forEach(([s,i])=>{if(!gl(s,i))return;const{eventName:o,options:a}=zk(s),l=d=>{i(Bk(t,d))};t.addEventListener(o,l,a),r.push({eventName:o,listener:l,options:a})}),r}function xm(t,e){const n=v.useRef({}),r=v.useRef([]);Ek(()=>{const s=n.current;return qk(t,s.className,e.className),Kk(t,s.style,e.style),Vk(t,s,e),r.current=Wk(t,r.current,e),n.current=e,()=>{r.current.forEach(({eventName:i,listener:o,options:a})=>{t.removeEventListener(i,o,a)}),r.current=[]}},[t,e])}var Uk=Vt.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:s,shouldShow:i=null,getReferencedVirtualElement:o,options:a,children:l,...d},u)=>{const h=v.useRef(document.createElement("div")),p=v.useRef(fm(t,"bubbleMenu")).current;xm(h.current,d),typeof u=="function"?u(h.current):u&&(u.current=h.current);const{editor:f}=em(),m=e||f,g={updateDelay:n,resizeDelay:r,appendTo:s,pluginKey:p,shouldShow:i,getReferencedVirtualElement:o,options:a},b=v.useRef(g);b.current=g;const[y,k]=v.useState(!1),C=v.useRef(!0);return v.useEffect(()=>{if(m?.isDestroyed)return;if(!m){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const j=h.current;j.style.visibility="hidden",j.style.position="absolute";const O=hm({...b.current,editor:m,element:j});m.registerPlugin(O);const S=b.current.pluginKey;return C.current=!0,k(!0),()=>{k(!1),m.unregisterPlugin(S),window.requestAnimationFrame(()=>{j.parentNode&&j.parentNode.removeChild(j)})}},[m]),v.useEffect(()=>{if(!(!y||!m||m.isDestroyed)){if(C.current){C.current=!1;return}m.view.dispatch(m.state.tr.setMeta(p,{type:"updateOptions",options:b.current}))}},[y,m,n,r,i,a,s,o,p]),hr.createPortal(l,h.current)});Vt.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:s,shouldShow:i=null,options:o,children:a,...l},d)=>{const u=v.useRef(document.createElement("div")),h=v.useRef(fm(t,"floatingMenu")).current;xm(u.current,l),typeof d=="function"?d(u.current):d&&(d.current=u.current);const{editor:p}=em(),f=e||p,m={updateDelay:n,resizeDelay:r,appendTo:s,pluginKey:h,shouldShow:i,options:o},g=v.useRef(m);g.current=m;const[b,y]=v.useState(!1),k=v.useRef(!0);return v.useEffect(()=>{if(f?.isDestroyed)return;if(!f){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const C=u.current;C.style.visibility="hidden",C.style.position="absolute";const j=pm({...g.current,editor:f,element:C});f.registerPlugin(j);const O=g.current.pluginKey;return k.current=!0,y(!0),()=>{y(!1),f.unregisterPlugin(O),window.requestAnimationFrame(()=>{C.parentNode&&C.parentNode.removeChild(C)})}},[f]),v.useEffect(()=>{if(!(!b||!f||f.isDestroyed)){if(k.current){k.current=!1;return}f.view.dispatch(f.state.tr.setMeta(h,{type:"updateOptions",options:g.current}))}},[b,f,n,r,i,o,s,h]),hr.createPortal(a,u.current)});var Di=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},Jk=/^\s*>\s$/,Gk=De.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Di("blockquote",{...ue(this.options.HTMLAttributes,t),children:Di("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.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(` 104`).map(h=>h.trim()===""?n:`${n} ${h}`);r.push(u.join(` 105`))}),r.join(` 106${n} 107`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}}
vendor: 1,291 bytes, line 107
107,addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[wr({find:Jk,type:this.type})]}}),Qk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Yk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Xk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Zk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,eN=Un.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Di("strong",{...ue(this.options.HTMLAttributes,t),children:Di("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}}
vendor: 7,833 bytes, lines 107-128
107,addInputRules(){return[vr({find:Qk,type:this.type}),vr({find:Xk,type:this.type})]},addPasteRules(){return[Fn({find:Yk,type:this.type}),Fn({find:Zk,type:this.type})]}}),tN=/(^|[^`])`([^`]+)`(?!`)$/,nN=/(^|[^`])`([^`]+)`(?!`)/g,rN=Un.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",ue(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[vr({find:tN,type:this.type})]},addPasteRules(){return[Fn({find:nN,type:this.type})]}}),Ma=4,sN=/^```([a-z]+)?[\s\n]$/,iN=/^~~~([a-z]+)?[\s\n]$/,oN=De.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Ma,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",ue(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(` 108`):r=`\`\`\`${s} 109 110\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Ma,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const a=" ".repeat(n);return o?t.commands.insertContent(a):t.commands.command(({tr:l})=>{const{from:d,to:u}=s,f=r.doc.textBetween(d,u,` 111`,` 112`).split(` 113`).map(m=>a+m).join(` 114`);return l.replaceWith(d,u,r.schema.text(f)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Ma,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:a})=>{var l;const{pos:d}=i,u=i.start(),h=i.end(),f=r.doc.textBetween(u,h,` 115`,` 116`).split(` 117`);let m=0,g=0;const b=d-u;for(let S=0;S<f.length;S+=1){if(g+f[S].length>=b){m=S;break}g+=f[S].length+1}const k=((l=f[m].match(/^ */))==null?void 0:l[0])||"",C=Math.min(k.length,n);if(C===0)return!0;let j=u;for(let S=0;S<m;S+=1)j+=f[S].length+1;return a.delete(j,j+C),d-j<=C&&a.setSelection($.create(a.doc,j)),!0}):t.commands.command(({tr:a})=>{const{from:l,to:d}=s,p=r.doc.textBetween(l,d,` 118`,` 119`).split(` 120`).map(f=>{var m;const g=((m=f.match(/^ */))==null?void 0:m[0])||"",b=Math.min(g.length,n);return f.slice(b)}).join(` 121`);return a.replaceWith(l,d,r.schema.text(p)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` 122 123`);return!i||!o?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;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)?t.commands.command(({tr:d})=>(d.setSelection(F.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[cl({find:sN,type:this.type,getAttributes:t=>({language:t[1]})}),cl({find:iN,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new te({key:new ae("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:o,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,` 124`));return o.replaceSelectionWith(this.type.create({language:i},l)),o.selection.$from.parent.type!==this.type&&o.setSelection($.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),aN=De.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` 125 126`):""}),lN=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:t}){return["br",ue(this.options.HTMLAttributes,t)]},renderText(){return` 127`},renderMarkdown:()=>` 128`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;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(p=>a.includes(p.type.name));d.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),cN=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(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,ue(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>cl({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}}
128)\\s$`),type:this.type,getAttributes:{level:t}}))}}),dN=De.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",ue(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!a1(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Of(n)?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($.create(o.doc,l.pos+1)):l.nodeAfter.isBlock?o.setSelection(B.create(o.doc,l.pos)):o.setSelection($.create(o.doc,l.pos));else{const u=i.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,h=u?.create();h&&(o.insert(d,h),o.setSelection($.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[o1({find:/^(?:---|â-|___\s|\*\*\*\s)$/,type:this.t
vendor: 1,046 bytes, line 128
128ype})]}}),uN=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,hN=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,pN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,fN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,mN=Un.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",ue(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}}
128,addInputRules(){return[vr({find:uN,type:this.type}),vr({find:pN,type:this.type})]},addPasteRules(){return[Fn({find:hN,type:this.type}),Fn({find:fN,type:this.type})]}});const gN="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yac
128hts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",xN="ελ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",xl="numeric",bl="ascii",yl="alpha",Qr="asciinumeric",Vr="alphanumeric",vl="domain",bm="emoji",bN="scheme",yN="slashscheme",Ea="whitespace";function vN(t,e){return t in e||(e[t]=[]),e[t]}function On(t,e,n){e[xl]&&(e[Qr]=!0,e[Vr]=!0),e[bl]&&(e[Qr]=!0,e[yl]=!0),e[Qr]&&(e[Vr]=!0),e[yl]&&(e[Vr]=!0),e[Vr]&&(e[vl]=!0),e[bm]&&(e[vl]=!0);for(const r in e){const s=vN(r,n);s.indexOf(t)<0&&s.push(t)}}function wN(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ke(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ke.groups={};Ke.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||Ke.groups;let s;return e&&e.j?s=e:(s=new Ke(e),n&&r&&On(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Ke.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,a=s.go(t);if(a?(o=new Ke,Object.assign(o.j,a.j),o.jr.push.apply(o.jr,a.jr),o.jd=a.jd,o.t=a.t):o=new Ke,i){if(r)if(o.t&&typeof o.t=="string"){const l=Object.assign(wN(o.t,r),n);On(i,l,r)}else n&&On(i,n,r);o.t=i}return s.j[t]=o,o}};const q=(t,e,n,r,s)=>t.ta(e,n,r,s),me=(t,e,n,r,s)=>t.tr(e,n,r,s),qu=(t,e,n,r,s)=>t.ts(e,n,r,s),I=(t,e,n,r,s)=>t.tt(e,n,r,s),Lt="WORD",wl="UWORD",ym="ASCIINUMERICAL",vm="ALPHANUMERICAL",bs="LOCALHOST",kl="TLD",Nl="UTLD",xi="SCHEME",dr="SLASH_SCHEME",hc="NUM",Sl="WS",pc="NL",Yr="OPENBRACE",Xr="CLOSEBRACE",Li="OPENBRACKET",zi="CLOSEBRACKET",Bi="OPENPAREN",$i="CLOSEPAREN",_i="OPENANGLEBRACKET",Hi="CLOSEANGLEBRACKET",Fi="FULLWIDTHLEFTPAREN",Vi="FULLWIDTHRIGHTPAREN",qi="LEFTCORNERBRACKET",Ki="RIGHTCORNERBRACKET",Wi="LEFTWHITECORNERBRACKET",Ui="RIGHTWHITECORNERBRACKET",Ji="FULLWIDTHLESSTHAN",Gi="FULLWIDTHGREATERTHAN",Qi="AMPERSAND",Yi="APOSTROPHE",Xi="ASTERISK",Zt="AT",Zi="BACKSLASH",eo="BACKTICK",to="CARET",In="COLON",fc="COMMA",no="DOLLAR",vt="DOT",ro="EQUALS",mc="EXCLAMATION",rt="HYPHEN",Zr="PERCENT",so="PIPE",io="PLUS",oo="POUND",es="QUERY",gc="QUOTE",wm="FULLWIDTHMIDDLEDOT",xc="SEMI",wt="SLASH",ts="TILDE",ao="UNDERSCORE",km="EMOJI",lo="SYM";var Nm=Object.freeze({__proto__:null,ALPHANUMERICAL:vm,AMPERSAND:Qi,APOSTROPHE:Yi,ASCIINUMERICAL:ym,ASTERISK:Xi,AT:Zt,BACKSLASH:Zi,BACKTICK:eo,CARET:to,CLOSEANGLEBRACKET:Hi,CLOSEBRACE:Xr,CLOSEBRACKET:zi,CLOSEPAREN:$i,COLON:In,COMMA:fc,DOLLAR:no,DOT:vt,EMOJI:km,EQUALS:ro,EXCLAMATION:mc,FULLWIDTHGREATERTHAN:Gi,FULLWIDTHLEFTPAREN:Fi,FULLWIDTHLESSTHAN:Ji,FULLWIDTHMIDDLEDOT:wm,FULLWIDTHRIGHTPAREN:Vi,HYPHEN:rt,LEFTCORNERBRACKET:qi,LEFTWHITECORNERBRACKET:Wi,LOCALHOST:bs,NL:pc,NUM:hc,OPENANGLEBRACKET:_i,OPENBRACE:Yr,OPENBRACKET:Li,OPENPAREN:Bi,PERCENT:Zr,PIPE:so,PLUS:io,POUND:oo,QUERY:es,QUOTE:gc,RIGHTCORNERBRACKET:Ki,RIGHTWHITECORNERBRACKET:Ui,SCHEME:xi,SEMI:xc,SLASH:wt,SLASH_SCHEME:dr,SYM:lo,TILDE:ts,TLD:kl,
vendor: 9,359 bytes, lines 128-132
128UNDERSCORE:ao,UTLD:Nl,UWORD:wl,WORD:Lt,WS:Sl});const It=/[a-z]/,Dr=/\p{L}/u,Aa=/\p{Emoji}/u,Pt=/\d/,Oa=/\s/,Ku="\r",Ia=` 129`,kN="ï¸",NN="â",Pa="";let oi=null,ai=null;function SN(t=[]){const e={};Ke.groups=e;const n=new Ke;oi==null&&(oi=Wu(gN)),ai==null&&(ai=Wu(xN)),I(n,"'",Yi),I(n,"{",Yr),I(n,"}",Xr),I(n,"[",Li),I(n,"]",zi),I(n,"(",Bi),I(n,")",$i),I(n,"<",_i),I(n,">",Hi),I(n,"ï¼",Fi),I(n,"ï¼",Vi),I(n,"ã",qi),I(n,"ã",Ki),I(n,"ã",Wi),I(n,"ã",Ui),I(n,"ï¼",Ji),I(n,"ï¼",Gi),I(n,"&",Qi),I(n,"*",Xi),I(n,"@",Zt),I(n,"`",eo),I(n,"^",to),I(n,":",In),I(n,",",fc),I(n,"$",no),I(n,".",vt),I(n,"=",ro),I(n,"!",mc),I(n,"-",rt),I(n,"%",Zr),I(n,"|",so),I(n,"+",io),I(n,"#",oo),I(n,"?",es),I(n,'"',gc),I(n,"/",wt),I(n,";",xc),I(n,"~",ts),I(n,"_",ao),I(n,"\\",Zi),I(n,"ã»",wm);const r=me(n,Pt,hc,{[xl]:!0});me(r,Pt,r);const s=me(r,It,ym,{[Qr]:!0}),i=me(r,Dr,vm,{[Vr]:!0}),o=me(n,It,Lt,{[bl]:!0});me(o,Pt,s),me(o,It,o),me(s,Pt,s),me(s,It,s);const a=me(n,Dr,wl,{[yl]:!0});me(a,It),me(a,Pt,i),me(a,Dr,a),me(i,Pt,i),me(i,It),me(i,Dr,i);const l=I(n,Ia,pc,{[Ea]:!0}),d=I(n,Ku,Sl,{[Ea]:!0}),u=me(n,Oa,Sl,{[Ea]:!0});I(n,Pa,u),I(d,Ia,l),I(d,Pa,u),me(d,Oa,u),I(u,Ku),I(u,Ia),me(u,Oa,u),I(u,Pa,u);const h=me(n,Aa,km,{[bm]:!0});I(h,"#"),me(h,Aa,h),I(h,kN,h);const p=I(h,NN);I(p,"#"),me(p,Aa,h);const f=[[It,o],[Pt,s]],m=[[It,null],[Dr,a],[Pt,i]];for(let g=0;g<oi.length;g++)Jt(n,oi[g],kl,Lt,f);for(let g=0;g<ai.length;g++)Jt(n,ai[g],Nl,wl,m);On(kl,{tld:!0,ascii:!0},e),On(Nl,{utld:!0,alpha:!0},e),Jt(n,"file",xi,Lt,f),Jt(n,"mailto",xi,Lt,f),Jt(n,"http",dr,Lt,f),Jt(n,"https",dr,Lt,f),Jt(n,"ftp",dr,Lt,f),Jt(n,"ftps",dr,Lt,f),On(xi,{scheme:!0,ascii:!0},e),On(dr,{slashscheme:!0,ascii:!0},e),t=t.sort((g,b)=>g[0]>b[0]?1:-1);for(let g=0;g<t.length;g++){const b=t[g][0],k=t[g][1]?{[bN]:!0}:{[yN]:!0};b.indexOf("-")>=0?k[vl]=!0:It.test(b)?Pt.test(b)?k[Qr]=!0:k[bl]=!0:k[xl]=!0,qu(n,b,b,k)}return qu(n,"localhost",bs,{ascii:!0}),n.jd=new Ke(lo),{start:n,tokens:Object.assign({groups:e},Nm)}}function Sm(t,e){const n=CN(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let a=t,l=null,d=0,u=null,h=-1,p=-1;for(;o<r&&(l=a.go(n[o]));)a=l,a.accepts()?(h=0,p=0,u=a):h>=0&&(h+=n[o].length,p++),d+=n[o].length,i+=n[o].length,o++;i-=h,o-=p,d-=h,s.push({t:u.t,v:e.slice(i-d,i),s:i-d,e:i})}return s}function CN(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Jt(t,e,n,r,s){let i;const o=e.length;for(let a=0;a<o-1;a++){const l=e[a];t.j[l]?i=t.j[l]:(i=new Ke(r),i.jr=s.slice(),t.j[l]=i),t=i}return i=new Ke(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function Wu(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const ys={defaultProtocol:"http",events:null,format:Uu,formatHref:Uu,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function bc(t,e=null){let n=Object.assign({},ys);t&&(n=Object.assign(n,t instanceof bc?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}bc.prototype={o:ys,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:ys[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Uu(t){return t}function Cm(t,e){this.t="token",this.v=t,this.tk=e}Cm.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"â¦":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=ys.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},a=t.get("className",n,e),l=t.get("target",n,e),d=t.get("rel",n,e),u=t.getObj("attributes",n,e),h=t.getObj("events",n,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 To(t,e){class n extends Cm{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const jN=To("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ju=To("text"),TN=To("nl"),li=To("url",{isLink:!0,toHref(t=ys.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==bs&&t[1].t===In}}),nt=t=>new Ke(t);function MN({groups:t}){const e=t.domain.concat([Qi,Xi,Zt,Zi,eo,to,no,ro,rt,hc,Zr,so,io,oo,wt,lo,ts,ao]),n=[Yi,In,fc,vt,mc,Zr,es,gc,xc,_i,Hi,Yr,Xr,zi,Li,Bi,$i,Fi,Vi,qi,Ki,Wi,Ui,Ji,Gi],r=[Qi,Yi,Xi,Zi,eo,to,no,ro,rt,Yr,Xr,Zr,so,io,oo,es,wt,lo,ts,ao],s=nt(),i=I(s,ts);q(i,r,i),q(i,t.domain,i);const o=nt(),a=nt(),l=nt();q(s,t.domain,o),q(s,t.scheme,a),q(s,t.slashscheme,l),q(o,r,i),q(o,t.domain,o);const d=I(o,Zt);I(i,Zt,d),I(a,Zt,d),I(l,Zt,d);const u=I(i,vt);q(u,r,i),q(u,t.domain,i);const h=nt();q(d,t.domain,h),q(h,t.domain,h);const p=I(h,vt);q(p,t.domain,h);const f=nt(jN);q(p,t.tld,f),q(p,t.utld,f),I(d,bs,f);const m=I(h,rt);I(m,rt,m),q(m,t.domain,h),q(f,t.domain,h),I(f,vt,p),I(f,rt,m);const g=I(o,rt),b=I(o,vt);I(g,rt,g),q(g,t.domain,o),q(b,r,i),q(b,t.domain,o);const y=nt(li);q(b,t.tld,y),q(b,t.utld,y),q(y,t.domain,o),q(y,r,i),I(y,vt,b),I(y,rt,g),I(y,Zt,d);const k=I(y,In),C=nt(li);q(k,t.numeric,C);const j=nt(li),O=nt();q(j,e,j),q(j,n,O),q(O,e,j),q(O,n,O),I(y,wt,j),I(C,wt,j);const S=I(a,In),N=I(l,In),P=I(N,wt),D=I(P,wt);q(a,t.domain,o),I(a,vt,b),I(a,rt,g),q(l,t.domain,o),I(l,vt,b),I(l,rt,g),q(S,t.domain,j),I(S,wt,j),I(S,es,j),q(D,t.domain,j),q(D,e,j),I(D,wt,j);const L=[[Yr,Xr],[Li,zi],[Bi,$i],[_i,Hi],[Fi,Vi],[qi,Ki],[Wi,Ui],[Ji,Gi]];for(let J=0;J<L.length;J++){const[Ee,le]=L[J],ce=I(j,Ee);I(O,Ee,ce);const ne=nt(li);q(ce,e,ne);const X=nt();q(ce,n,X),I(ce,le,j),q(ne,e,ne),q(ne,n,X),q(X,e,ne),q(X,n,X),I(ne,le,j),I(X,le,j)}return I(s,bs,y),I(s,pc,TN),{start:s,tokens:Nm}}function EN(t,e,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let a=t,l=null,d=null,u=0,h=null,p=-1;for(;s<r&&!(l=a.go(n[s].t));)o.push(n[s++]);for(;s<r&&(d=l||a.go(n[s].t));)l=null,a=d,a.accepts()?(p=0,h=a):p>=0&&p++,s++,u++;if(p<0)s-=u,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(Ra(Ju,e,o)),o=[]),s-=p,u-=p;const f=h.t,m=n.slice(s-u,s);i.push(Ra(f,e,m))}}return o.length>0&&i.push(Ra(Ju,e,o)),i}function Ra(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const AN=typeof console<"u"&&console&&console.warn||(()=>{}),ON="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ie={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function IN(){return Ke.groups={},ie.scanner=null,ie.parser=null,ie.tokenQueue=[],ie.pluginQueue=[],ie.customSchemes=[],ie.initialized=!1,ie}function Gu(t,e=!1){if(ie.initialized&&AN(`linkifyjs: already initialized - will not register custom scheme "${t}" ${ON}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. 1301. Must only contain digits, lowercase ASCII letters or "-" 1312. Cannot start or end with "-" 1323. "-" cannot repeat`);ie.customSchemes.push([t,e])}function PN(){ie.scanner=SN(ie.customSchemes);for(let t=0;t<ie.tokenQueue.length;t++)ie.tokenQueue[t][1]({scanner:ie.scanner});ie.parser=MN(ie.scanner.tokens);for(let t=0;t<ie.pluginQueue.length;t++)ie.pluginQueue[t][1]({scanner:ie.scanner,parser:ie.parser});return ie.initialized=!0,ie}function yc(t){return ie.initialized||PN(),EN(ie.parser.start,t,Sm(ie.scanner.start,t))}yc.scan=Sm;function jm(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new bc(n),s=yc(t),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 vc="[\0-  áá â-\u2029âã]",RN=new RegExp(vc),DN=new RegExp(`${vc}$`),LN=new RegExp(vc,"g");function zN(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function BN(t){return new te({key:new ae("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(d=>d.docChanged)&&!n.doc.eq(r.doc),i=e.some(d=>d.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,a=kf(n.doc,[...e]);
132if(Af(a).forEach(({newRange:d})=>{const u=aw(r.doc,d,f=>f.isTextblock);let h,p;if(u.length>1)h=u[0],p=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(u.length){const f=r.doc.textBetween(d.from,d.to," "," ");if(!DN.test(f))return;h=u[0],p=r.doc.textBetween(h.pos,d.to,void 0," ")}if(h&&p){const f=p.split(RN).filter(Boolean);if(f.length<=0)return!1;const m=f[f.length-1],g=h.pos+p.lastIndexOf(m);if(!m)return!1;const b=yc(m).map(y=>y.toObject(t.defaultProtocol));if(!zN(b))return!1;b.filter(y=>y.isLink).map(y=>({...y,from:g+y.start+1,to:g+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{sc(y.from,y.to,r.doc).some(k=>k.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function $N(t){return new te({key:new ae("handleClickLink"),props:{handleClick:(e,n,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=t.editor.view.dom;o=l.closest("a"),o&&!d.contains(o)&&(o=null)}if(!o)return!1;let a=!1;if(t.enableClickSelection&&(a=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const l=Ef(e.state,t.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 _N(t){return new te({key:new ae("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(u=>{l+=u.textContent});const d=jm(l,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!d||s!==void 0&&!s(d.value)?!1:t.editor.commands.setMark(t.type,{href:d.href})}}})}function Sn(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(LN,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var HN=Un.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Gu(t);return}Gu(t.scheme,t.optionalSlashes)})},onDestroy(){IN()},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:(t,e)=>!!Sn(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.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:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Sn(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Sn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ue(this.options.HTMLAttributes,t),0]:["a",ue(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",a=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",l=e.renderChildren(t);return a?`[${l}](${o} "${a}")`:`[${l}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Sn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Sn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Fn({find:t=>{const e=[];
132if(t){const{protocols:n,defaultProtocol:r}=this.options,s=jm(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Sn(o,n),protocols:n,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:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(BN({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Sn(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push($N({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(_N({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),FN=Object.defineProperty,VN=(t,e)=>{for(var n in e)FN(t,n,{get:e[n],enumerable:!0})},qN="listItem",Qu="textStyle",Yu=/^\s*([-+*])\s$/,Tm=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:t}){return["ul",ue(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` 133`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(qN,this.editor.getAttributes(Qu)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=wr({find:Yu,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=wr({find:Yu,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Qu),editor:this.editor})),[t]}});function KN(t){var e,n;const r=(e=t.tokens)==null?void 0:e[0];return!!(t.text&&((n=t.tokens)==null?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function WN(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var Mm=De.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",ue(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;let s=[];if(t.tokens&&t.tokens.length>0){if(KN(t))return{type:"listItem",content:[{type:"paragraph",content:WN(t.text||"",e)}]};if(t.tokens.some(o=>o.type==="paragraph"))s=r(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const l=t.tokens.slice(1),d=r(l);s.push(...d)}}else s=r(t.tokens)}}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(t,e,n)=>lc(t,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}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),UN={};VN(UN,{findListItemPos:()=>Ts,getNextListDepth:()=>wc,handleBackspace:()=>Cl,handleDelete:()=>jl,hasListBefore:()=>Em,hasListItemAfter:()=>JN,hasListItemBefore:()=>Am,listItemHasSubList:()=>Om,nextListIsDeeper:()=>Im,nextListIsHigher:()=>Pm});var Ts=(t,e)=>{const{$from:n}=e.selection,r=ke(t,e.schema);let s=null,i=n.depth,o=n.pos,a=null;for(;i>0&&a===null;)s=n.node(i),s.type===r?a=i:(i-=1,o-=1);return a===null?null:{$pos:e.doc.resolve(o),depth:a}},wc=(t,e)=>{const n=Ts(t,e);if(!n)return!1;const[,r]=gw(e,t,n.$pos.pos+4);return r},Em=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},Am=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},Om=(t,e,n)=>{if(!n)return!1;const r=ke(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},Cl=(t,e,n)=>{if(t.commands.undoInputRule())return!0;
133if(t.state.selection.from!==t.state.selection.to)return!1;if(!mn(t.state,e)&&Em(t.state,e,n)){const{$anchor:a}=t.state.selection,l=t.state.doc.resolve(a.before()-1),d=[];l.node().descendants((p,f)=>{p.type.name===e&&d.push({node:p,pos:f})});const u=d.at(-1);if(!u)return!1;const h=t.state.doc.resolve(l.start()+u.pos+1);return t.chain().cut({from:a.start()-1,to:a.end()+1},h.end()).joinForward().run()}if(!mn(t.state,e)||!vw(t.state))return!1;const r=Ts(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Om(e,t.state,i);return Am(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Im=(t,e)=>{const n=wc(t,e),r=Ts(t,e);return!r||!n?!1:n>r.depth},Pm=(t,e)=>{const n=wc(t,e),r=Ts(t,e);return!r||!n?!1:n<r.depth},jl=(t,e)=>{if(!mn(t.state,e)||!yw(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:Im(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Pm(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},JN=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},Rm=he.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&jl(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&jl(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Cl(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Cl(t,n,r)&&(e=!0)}),e}}}}),Xu=/^(\s*)(\d+)\.\s+(.*)$/,GN=/^\s/;function QN(t){const e=t.trimStart();return/^[-+*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function YN(t){const e=[],n=[];let r=!1;return t.forEach(s=>{if(r){n.push(s);return}if(s.trim()===""){r=!0,n.push(s);return}if(e.length>0&&QN(s)){r=!0,n.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:n}}function XN(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(Xu);if(!i)break;const[,o,a,l]=i,d=o.length,u=[l];let h=n+1;const p=[s];let f=!1;for(;h<t.length;){const m=t[h];if(m.match(Xu))break;if(m.trim()==="")p.push(m),u.push(""),f=!0,h+=1;else if(m.match(GN))p.push(m),u.push(m.slice(d+2)),h+=1;else{if(f)break;p.push(m),u.push(m),h+=1}}e.push({indent:d,number:parseInt(a,10),content:u.join(` 134`).trim(),contentLines:u,raw:p.join(` 135`)}),r=h,n=h}return[e,r]}function Dm(t,e,n){const r=[];let s=0;for(;s<t.length;){const i=t[s];if(i.indent===e){const{paragraphLines:o,blockLines:a}=YN(i.contentLines),l=o.join(` 136`).trim(),d=[];l&&d.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const u=a.join(` 137`).trim();if(u){const f=n.blockTokens(u);d.push(...f)}let h=s+1;const p=[];for(;h<t.length&&t[h].indent>e;)p.push(t[h]),h+=1;if(p.length>0){const f=Math.min(...p.map(g=>g.indent)),m=Dm(p,f,n);d.push({type:"list",ordered:!0,start:p[0].number,items:m,raw:p.map(g=>g.raw).join(` 138`)})}r.push({type:"list_item",raw:i.raw,tokens:d}),s=h}else s+=1}return r}function ZN(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.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 eS="listItem",Zu="textStyle",eh=/^(\d+)\.\s$/,Lm=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:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",ue(this.options.HTMLAttributes,n),0]:["ol",ue(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?ZN(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` 139`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(` 140`),[i,o]=XN(s);if(i.length===0)return;const a=Dm(i,0,n);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(` 141`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(eS,this.editor.getAttributes(Zu)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}
141,addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=wr({find:eh,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=wr({find:eh,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Zu)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),tS=/^\s*(\[([( |x])?\])\s$/,nS=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:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",ue(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return lc(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,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 p,f;a.ariaLabel=((f=(p=this.options.a11y)==null?void 0:p.checkboxLabel)==null?void 0:f.call(p,h,a.checked))||`Task item checkbox for ${h.textContent||"empty task item"}`};d(t),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:p}=h.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const m=n();if(typeof m!="number")return!1;const g=f.doc.nodeAt(m);return f.setNodeMarkup(m,void 0,{...g?.attrs,checked:p}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,p)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([h,p])=>{s.setAttribute(h,p)}),s.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,i.append(a,o),s.append(i,l),Object.entries(e).forEach(([h,p])=>{s.setAttribute(h,p)});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 p=r.extensionManager.attributes,f=ms(h,p),m=new Set(Object.keys(f)),g=this.options.HTMLAttributes;return u.forEach(b=>{m.has(b)||(b in g?s.setAttribute(b,g[b]):s.removeAttribute(b))}),Object.entries(f).forEach(([b,y])=>{y==null?b in g?s.setAttribute(b,g[b]):s.removeAttribute(b):s.setAttribute(b,y)}),u=m,!0}}}}
141,addInputRules(){return[wr({find:tS,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),rS=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:t}){return["ul",ue(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` 142`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=dl(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:n.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=dl(t,{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:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});he.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Tm.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Mm.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Rm.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Lm.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(nS.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(rS.configure(this.options.taskList)),t}});var ci=" ",Da="Â ",sS=De.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",ue(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===ci||n[0].text===ci||n[0].raw===Da||n[0].text===Da)&&r.length===1&&r[0].type==="text"&&(r[0].text===ci||r[0].text===Da)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,s;if(!t)return"";const i=Array.isArray(t.content)?t.content:[];if(i.length===0){const o=Array.isArray((r=n?.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((s=n?.previousNode)==null?void 0:s.type)==="paragraph"&&o.length===0?ci:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),iS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,oS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,aS=Un.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",ue(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}}
vendor: 5,101 bytes, line 142
142,addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[vr({find:iS,type:this.type})]},addPasteRules(){return[Fn({find:oS,type:this.type})]}}),lS=De.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),cS=Un.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",ue(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function dS(t={}){return new te({view(e){return new uS(e,t)}})}class uS{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.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:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.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),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,a=i.height/s.offsetHeight;if(n){let h=e.nodeBefore,p=e.nodeAfter;if(h||p){let f=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(f){let m=f.getBoundingClientRect(),g=h?m.bottom:m.top;h&&p&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*a;r={left:m.left,right:m.right,top:g-b,bottom:g+b}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:h.left-p,right:h.left+p,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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let d,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")d=-pageXOffset,u=-pageYOffset;else{let h=l.getBoundingClientRect(),p=h.width/l.offsetWidth,f=h.height/l.offsetHeight;d=h.left-l.scrollLeft*p,u=h.top-l.scrollTop*f}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 n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=pp(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 xe extends F{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return xe.valid(r)?new xe(r):F.near(r)}content(){return R.empty}eq(e){return e instanceof xe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new xe(e.resolve(n.pos))}getBookmark(){return new kc(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!hS(e)||!pS(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&xe.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let a=e.node(o);if(n>
vendor: 10,612 bytes, line 142
1420?e.indexAfter(o)<a.childCount:e.index(o)>0){i=a.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let l=e.doc.resolve(s);if(xe.valid(l))return l}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!B.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let a=e.doc.resolve(s);if(xe.valid(a))return a}return null}}}xe.prototype.visible=!1;xe.findFrom=xe.findGapCursorFrom;F.jsonID("gapcursor",xe);class kc{constructor(e){this.pos=e}map(e){return new kc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return xe.valid(n)?new xe(n):F.near(n)}}function zm(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function hS(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||zm(s.type))return!0;if(s.inlineContent)return!1}}return!0}function pS(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||zm(s.type))return!0;if(s.inlineContent)return!1}}return!0}function fS(){return new te({props:{decorations:bS,createSelectionBetween(t,e,n){return e.pos==n.pos&&xe.valid(n)?new xe(n):null},handleClick:gS,handleKeyDown:mS,handleDOMEvents:{beforeinput:xS}}})}const mS=Ql({ArrowLeft:di("horiz",-1),ArrowRight:di("horiz",1),ArrowUp:di("vert",-1),ArrowDown:di("vert",1)});function di(t,e){const n=t=="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 $){if(!i.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let d=xe.findGapCursorFrom(a,e,l);return d?(s&&s(r.tr.setSelection(new xe(d))),!0):!1}}function gS(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!xe.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&B.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new xe(r))),!0)}function xS(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof xe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=E.empty;for(let o=r.length-1;o>=0;o--)s=E.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new R(s,0,0));return i.setSelection($.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function bS(t){if(!(t.selection instanceof xe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",re.create(t.doc,[je.widget(t.selection.head,e,{key:"gapcursor"})])}var co=200,Me=function(){};Me.prototype.append=function(e){return e.length?(e=Me.from(e),!this.length&&e||e.length<co&&this.leafAppend(e)||this.length<co&&e.leafPrepend(this)||this.appendInner(e)):this};Me.prototype.prepend=function(e){return e.length?Me.from(e).append(this):this};Me.prototype.appendInner=function(e){return new yS(this,e)};Me.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Me.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Me.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Me.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Me.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};Me.from=function(e){return e instanceof Me?e:e&&e.length?new Bm(e):Me.empty};var Bm=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={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<=co)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=co)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Me);Me.empty=new Bm([]);var yS=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.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})(Me);const vS=500;class ht{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){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;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,a,l,d=[],u=[];return this.items.forEach((h,p)=>{if(!h.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,u.push(h);return}if(s){u.push(new kt(h.map));let f=h.step.map(s.slice(i)),m;f&&o.maybeStep(f).doc&&(m=o.mapping.maps[o.mapping.maps.length-1],d.push(new kt(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 ht(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,n,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]),p=new kt(e.mapping.maps[u],h,n),f;(f=l&&l.merge(p))&&(p=f,u?i.pop():a=a.slice(0,a.length-1)),i.push(p),n&&(o++,n=void 0),s||(l=p)}let d=o-r.depth;return d>kS&&(a=wS(a,d),o-=d),new ht(a.append(i),o)}remapping(e,n){let r=new cs;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,n),r}addMaps(e){return this.eventCount==0?this:new ht(this.items.append(e.map(n=>new kt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(p=>{p.selection&&a--},s);let l=n;this.items.forEach(p=>{let f=i.getMirror(--l);if(f==null)return;o=Math.min(o,f);let m=i.maps[f];if(p.step){let g=e.steps[f].invert(e.docs[f]),b=p.selection&&p.selection.map(i.slice(l+1,f));b&&a++,r.push(new kt(m,g,b))}else r.push(new kt(m))},s);let d=[];for(let p=n;p<o;p++)d.push(new kt(i.maps[p]));let u=this.items.slice(0,s).append(d).append(r),h=new ht(u,a);return h.emptyItemCount()>vS&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.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(n.slice(r)),d=l&&l.getMap();if(r--,d&&n.appendMap(d,r),l){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let h=new kt(d.invert(),l,u),p,f=s.length-1;(p=s.length&&s[f].merge(h))?s[f]=p:s.push(h)}}else o.map&&r--},this.items.length,0),new ht(Me.from(s.reverse()),i)}}ht.empty=new ht(Me.empty,0);function wS(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class kt{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new kt(n.getMap().invert(),n,this.selection)}}}class en{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const kS=20;function NS(t,e,n,r){let s=n.getMeta(zn),i;if(s)return s.historyState;n.getMeta(jS)&&(t=new en(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(zn))return o.getMeta(zn).redo?new en(t.done.addTransform(n,void 0,r,bi(e)),t.undone,th(n.mapping.maps),t.prevTime,t.prevComposition):new en(t.done,t.undone.addTransform(n,void 0,r,bi(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!o&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!SS(n,t.prevRanges)),d=o?La(t.prevRanges,n.mapping):th(n.mapping.maps);return new en(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,bi(e)),ht.empty,d,n.time,a??t.prevComposition)}else return(i=n.getMeta("rebased"))?new en(t.done.rebased(n,i),t.undone.rebased(n,i),La(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new en(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),La(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function SS(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function th(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;
142n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function La(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function CS(t,e,n){let r=bi(e),s=zn.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),a=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),l=new en(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(zn,{redo:n,historyState:l})}let za=!1,nh=null;function bi(t){let e=t.plugins;if(nh!=e){za=!1,nh=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){za=!0;break}}return za}const zn=new ae("history"),jS=new ae("closeHistory");function TS(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new te({key:zn,state:{init(){return new en(ht.empty,ht.empty,null,0,-1)},apply(e,n,r){return NS(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?_m:r=="historyRedo"?Hm:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function $m(t,e){return(n,r)=>{let s=zn.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=CS(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const _m=$m(!1,!0),Hm=$m(!0,!0);he.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.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=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new te({key:new ae("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit,i=this.options.autoTrim;if(s==null||s===0||i===!1){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const a=o-s,l=0,d=a;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,d);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.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 MS=he.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[dS(this.options)]}});he.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new te({key:new ae("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return re.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((l,d)=>{if(l.isText)return;if(!(s>=d&&s<=d+l.nodeSize-1))return!1;o+=1});let a=0;return t.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(je.node(d,d+l.nodeSize,{class:this.options.className}))}),re.create(t,i)}}})]}});var ES=he.create({name:"gapCursor",addProseMirrorPlugins(){return[fS()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=U(z(t,"allowGapCursor",n)))!=null?e:null}}}),Fm="placeholder",vs=new ae("tiptap__placeholder"),rh=200;function sh(t){const{editor:e,placeholder:n,dataAttribute:r,pos:s,node:i,isEmptyDoc:o,hasAnchor:a,classes:{emptyNode:l,emptyEditor:d}}=t,u=[l];return o&&u.push(d),je.node(s,s+i.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:s,hasAnchor:a}):n})}function AS({editor:t,options:e,dataAttribute:n,doc:r,selection:s}){var i,o;if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:l}=s,d=[],u=t.isEmpty,h={emptyEditor:e.emptyEditorClass,emptyNode:e.emptyNodeClass};if(e.showOnlyCurrent&&!e.includeChildren){const f=r.resolve(l),m=f.depth>0?f.node(1):f.nodeAfter,g=f.depth>0?f.before(1):l;if(m&&m.type.isTextblock&&gs(m)){const b=l>=g&&l<=g+m.nodeSize;d.push(sh({editor:t,isEmptyDoc:u,dataAttribute:n,hasAnchor:b,placeholder:e.placeholder,classes:h,node:m,pos:g}))}}else{const f=vs.getState(t.state),m=(i=f?.topPos)!=null?i:0,g=(o=f?.bottomPos)!=null?o:r.content.size;r.nodesBetween(m,g,(b,y)=>{const k=l>=y&&l<=y+b.nodeSize,C=!b.isLeaf&&gs(b);return b.type.isTextblock&&(k||!e.showOnlyCurrent)&&C&&d.push(sh({editor:t,isEmptyDoc:u,dataAttribute:n,hasAnchor:k,placeholder:e.placeholder,classes:h,node:b,pos:y})),e.includeChildren})}return re.create(r,d)}function OS(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function IS(t){const e=getComputedStyle(t),n=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(n)}function PS(t){let e=t;for(;e;){if(IS(e))return e;const n=e.parentElement;if(!n){const r=e.getRootNode();if(r instanceof ShadowRoot){e=r.host;continue}return window}
142e=n}return window}function RS(t){return t===window?{top:0,bottom:window.innerHeight}:t.getBoundingClientRect()}function DS({doc:t,view:e,scrollContainer:n}){const r=e.dom.getBoundingClientRect(),s=n?RS(n):{top:0,bottom:window.innerHeight},i=Math.max(r.top,s.top)-rh,o=Math.min(r.bottom,s.bottom)+rh;if(i>=o)return{top:0,bottom:t.content.size};const l=getComputedStyle(e.dom).direction==="rtl"?Math.max(r.right-2,r.left+2):r.left+2,d=e.posAtCoords({left:l,top:i+2}),u=e.posAtCoords({left:l,top:o-2});return{top:d?d.pos:0,bottom:u?u.pos:t.content.size}}var LS={init(){return{topPos:null,bottomPos:null}},apply(t,e){const n=t.getMeta(vs);return n?.positions?{topPos:n.positions.top,bottomPos:n.positions.bottom}:t.docChanged?{topPos:e.topPos!==null?t.mapping.map(e.topPos):null,bottomPos:e.bottomPos!==null?t.mapping.map(e.bottomPos):null}:e}};function zS(t){const e=PS(t.dom),n=()=>{const a=DS({view:t,doc:t.state.doc,scrollContainer:e}),l=vs.getState(t.state);if(l?.topPos===a.top&&l?.bottomPos===a.bottom)return;const d=t.state.tr.setMeta(vs,{positions:a});t.dispatch(d)};let r=null,s=0;const i=150,o=()=>{r===null&&(r=requestAnimationFrame(()=>{r=null;const a=performance.now();a-s>=i?(s=a,n()):o()}))};return e.addEventListener("scroll",o,{passive:!0}),n(),{update(a,l){t.state.doc.content.size!==l.doc.content.size&&o()},destroy:()=>{r!==null&&cancelAnimationFrame(r),e.removeEventListener("scroll",o)}}}function BS({editor:t,options:e}){const n=e.dataAttribute?`data-${OS(e.dataAttribute)}`:`data-${Fm}`;return new te({key:vs,state:LS,view:zS,props:{decorations:({doc:r,selection:s})=>AS({editor:t,options:e,dataAttribute:n,doc:r,selection:s})}})}var $S=he.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Fm,placeholder:"Write something â¦",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[BS({editor:this.editor,options:this.options})]}});he.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new te({key:new ae("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Of(n.selection)||t.view.dragging?null:re.create(n.doc,[je.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});var _S="skipTrailingNode";function ih({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var HS=he.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ae(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new te({key:e,appendTransaction:(s,i,o)=>{const{doc:a,tr:l,schema:d}=o,u=e.getState(o),h=a.content.size,p=d.nodes[n];if(!s.some(f=>f.getMeta(_S))&&u)return l.insert(h,p.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!ih({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!ih({node:o,types:r})}}})]}}),FS=he.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>_m(t,e),redo:()=>({state:t,dispatch:e})=>Hm(t,e)}},addProseMirrorPlugins(){return[TS(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()}}}),VS=he.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(eN.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Gk.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Tm.configure(this.options.bulletList)),this.options.code!==!1&&s.push(rN.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(oN.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(aN.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(MS.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(ES.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(lN.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(cN.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(FS.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(dN.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(mN.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Mm.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Rm.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(HN.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(Lm.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(sS.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(aS.configure(this.options.strike)),this.options.text!==!1&&s.push(lS.configure(this.options.text)),this.options.underline!==!1&&s.push(cS.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(HS.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),qS=VS,KS=$S;function uo(t){return t==="left"||t==="right"||t==="center"?t:null}function WS(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return uo(e||n)}function US(t){return uo(t?.align)}function Vm(){return{default:null,parseHTML:t=>WS(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var qm=De.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const a=i[o].getAttribute("width");return a?[parseInt(a,10)]:null}}return s}},align:Vm()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",ue(this.options.HTMLAttributes,t),0]}}),Km=De.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}},align:Vm()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",ue(this.options.HTMLAttributes,t),0]}}),Wm=De.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",ue(this.options.HTMLAttributes,t),0]}});function Tl(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function oh(t,e,n,r,s,i){var o;let a=0,l=!0,d=e.firstChild;const u=t.firstChild;if(u!==null)for(let p=0,f=0;p<u.childCount;p+=1){const{colspan:m,colwidth:g}=u.child(p).attrs;for(let b=0;b<m;b+=1,f+=1){const y=s===f?i:g&&g[b],k=y?`${y}px`:"";if(a+=y||r,y||(l=!1),d){if(d.style.width!==k){const[C,j]=Tl(r,y);d.style.setProperty(C,j)}d=d.nextSibling}else{const C=document.createElement("col"),[j,O]=Tl(r,y);C.style.setProperty(j,O),e.appendChild(C)}}}for(;d;){const p=d.nextSibling;(o=d.parentNode)==null||o.removeChild(d),d=p}const h=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!h?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}var JS=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),oh(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,oh(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function GS(t,e,n,r){let s=0,i=!0;const o=[],a=t.firstChild;if(!a)return{};for(let h=0,p=0;h<a.childCount;h+=1){const{colspan:f,colwidth:m}=a.child(h).attrs;for(let g=0;g<f;g+=1,p+=1){const b=n===p?r:m&&m[g];s+=b||e,b||(i=!1);const[y,k]=Tl(e,b);o.push(["col",{style:`${y}: ${k}`}])}}const l=i?`${s}px`:"",d=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:l,tableMinWidth:d}}function ah(t,e){return t.createAndFill()}function QS(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};
142return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function YS(t,e,n,r,s){const i=QS(t),o=[],a=[];for(let d=0;d<n;d+=1){const u=ah(i.cell);if(u&&a.push(u),r){const h=ah(i.header_cell);h&&o.push(h)}}const l=[];for(let d=0;d<e;d+=1)l.push(i.row.createChecked(null,r&&d===0?o:a));return i.table.createChecked(null,l)}function XS(t){return t instanceof ee}var ui=({editor:t})=>{const{selection:e}=t.state;if(!XS(e))return!1;let n=0;const r=Nf(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},ZS="�";function eC(t){return(t||"").replace(/\s+/g," ").trim()}function tC(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:ZS;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(g=>{const b=[];g.content&&g.content.forEach(y=>{let k="";y.content&&Array.isArray(y.content)&&y.content.length>1?k=y.content.map(N=>e.renderChildren(N)).join(s):k=y.content?e.renderChildren(y.content):"";const C=eC(k),j=y.type==="tableHeader",O=US(y.attrs);b.push({text:C,isHeader:j,align:O})}),i.push(b)});const o=i.reduce((g,b)=>Math.max(g,b.length),0);if(o===0)return"";const a=Array.from({length:o}).fill(0);i.forEach(g=>{var b;for(let y=0;y<o;y+=1){const C=(((b=g[y])==null?void 0:b.text)||"").length;C>a[y]&&(a[y]=C),a[y]<3&&(a[y]=3)}});const l=(g,b)=>g+" ".repeat(Math.max(0,b-g.length)),d=i[0],u=d.some(g=>g.isHeader),h=Array.from({length:o}).fill(null);i.forEach(g=>{var b;for(let y=0;y<o;y+=1)!h[y]&&((b=g[y])!=null&&b.align)&&(h[y]=g[y].align)});let p=` 143`;const f=Array.from({length:o}).map((g,b)=>u&&d[b]&&d[b].text||"");return p+=`| ${f.map((g,b)=>l(g,a[b])).join(" | ")} | 144`,p+=`| ${a.map((g,b)=>{const y=Math.max(3,g),k=h[b];return k==="left"?`:${"-".repeat(y)}`:k==="right"?`${"-".repeat(y)}:`:k==="center"?`:${"-".repeat(y)}:`:"-".repeat(y)}).join(" | ")} | 145`,(u?i.slice(1):i).forEach(g=>{p+=`| ${Array.from({length:o}).fill(0).map((b,y)=>l(g[y]&&g[y].text||"",a[y])).join(" | ")} | 146`}),p}var nC=tC,Um=De.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:JS,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=GS(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const a=["table",ue(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},a]:a},parseMarkdown:(t,e)=>{const n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){const s=[];t.header.forEach((i,o)=>{var a;const l=uo((a=r[o])!=null?a:i.align),d=l?{align:l}:{};s.push(e.createNode("tableHeader",d,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{const i=[];s.forEach((o,a)=>{var l;const d=uo((l=r[a])!=null?l:o.align),u=d?{align:d}:{};i.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>nC(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=YS(i.schema,t,e,n);if(s){const a=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection($.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>q1(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>K1(t,e),deleteColumn:()=>({state:t,dispatch:e})=>U1(t,e),addRowBefore:()=>({state:t,dispatch:e})=>G1(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Q1(t,e),deleteRow:()=>({state:t,dispatch:e})=>X1(t,e),deleteTable:()=>({state:t,dispatch:e})=>ik(t,e),mergeCells:()=>({state:t,dispatch:e})=>Iu(t,e),splitCell:()=>({state:t,dispatch:e})=>Pu(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>xs("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>xs("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>rk(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Iu(t,e)?!0:Pu(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>tk(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Du(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Du(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&am(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=ee.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ui,"Mod-Backspace":ui,Delete:ui,"Mod-Delete":ui}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[mk({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Ck({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:r})=>new e(n,this.options.cellMinWidth,r)},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:U(z(t,"tableRole",e))}}});he.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(Um.configure(this.options.table)),this.options.tableCell!==!1&&t.push(qm.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(Km.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Wm.configure(this.options.tableRow)),t}});function rC(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Lr(t){let e=rC(t);return e=e.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),e=e.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),e=e.replace(/\*(.+?)\*/g,"<em>$1</em>"),e}function Ba(t){if(!t||!t.trim())return"<p></p>";const e=t.split(/\n\n+/),n=[];for(const r of e){const s=r.replace(/\s+$/,"");if(!s.trim())continue;const i=s.split(` 147`);if(i.length>=2&&i[0].includes("|")&&/^\s*\|?\s*[-:]+/.test(i[1])){const p=b=>b.split("|").map(y=>y.trim()).filter(y=>y!==""),f=p(i[0]),m=i.slice(2).filter(b=>b.includes("|"));let g="<table><tbody>";g+="<tr>";for(const b of f)g+=`<th>${Lr(b)}</th>`;g+="</tr>";for(const b of m){const y=p(b);g+="<tr>";for(const k of y)g+=`<td>${Lr(k)}</td>`;g+="</tr>"}g+="</tbody></table>",n.push(g);continue}let a=[],l=null,d=[];const u=()=>{if(a.length&&l){let p=`<${l}>`;for(const f of a)p+=`<li><p>${Lr(f)}</p></li>`;p+=`</${l}>`,n.push(p)}a=[],l=null},h=()=>
147{if(d.length){const p=d.map(f=>Lr(f)).join("<br>");p.replace(/<br>/g,"").trim()&&n.push(`<p>${p}</p>`)}d=[]};for(const p of i){const f=p.match(/^(#{1,6})\s+(.+)$/);if(f){u(),h();const b=f[1].length;n.push(`<h${b}>${Lr(f[2])}</h${b}>`);continue}const m=p.match(/^[\*\-]\s+(.+)$/);if(m){h(),l!=="ul"&&(u(),l="ul"),a.push(m[1]);continue}const g=p.match(/^(\d+)\.\s+(.+)$/);if(g){h(),l!=="ol"&&(u(),l="ol"),a.push(g[2]);continue}u(),d.push(p)}u(),h()}return n.join("")||"<p></p>"}function sC(t){let e=!1,n=!1;for(const r of t||[])(r.type==="bold"||r.type==="strong")&&(e=!0),(r.type==="italic"||r.type==="em")&&(n=!0);return{bold:e,italic:n}}function iC(t,e,n){return t?e&&n?`***${t}***`:e?`**${t}**`:n?`*${t}*`:t:""}function ns(t){if(!t||!t.length)return"";const e=[];for(const r of t){if(r.type==="hardBreak"){e.push({text:` 148`,bold:!1,italic:!1});continue}if(r.type!=="text"||r.text==null)continue;const{bold:s,italic:i}=sC(r.marks),o=e[e.length-1];o&&o.bold===s&&o.italic===i&&o.text!==` 149`?o.text+=r.text:e.push({text:r.text,bold:s,italic:i})}let n="";for(const r of e){if(r.text===` 150`){n+=` 151`;continue}if(!r.text.trim())n+=r.text;else{const s=r.text.match(/^\s*/)[0],i=r.text.match(/\s*$/)[0],o=r.text.slice(s.length,r.text.length-i.length);n+=s+iC(o,r.bold,r.italic)+i}}return n}function lh(t,e){const n=[],r=(s,i)=>{let o=0;for(const a of s.content||[]){if(a.type!=="listItem")continue;o++;const l=[],d=[];for(const p of a.content||[])p.type==="paragraph"?l.push(ns(p.content)):(p.type==="bulletList"||p.type==="orderedList")&&d.push(p);const u=l.join(" ").trim(),h=i?`${o}. `:"- ";u&&n.push(h+u);for(const p of d)r(p,p.type==="orderedList")}};return r(t,e),n.join(` 152`)}function oC(t){const e=[];for(const a of t.content||[]){if(a.type!=="tableRow")continue;const l=[];for(const d of a.content||[]){if(d.type!=="tableCell"&&d.type!=="tableHeader")continue;const u=[];for(const h of d.content||[])h.type==="paragraph"&&u.push(ns(h.content));l.push(u.join(" ").trim())}e.push(l)}if(!e.length)return"";const n=Math.max(...e.map(a=>a.length)),r=a=>{const l=a.slice();for(;l.length<n;)l.push("");return l},s=r(e[0]),i=e.slice(1).map(r),o=[];o.push("| "+s.join(" | ")+" |"),o.push("| "+s.map(()=>"---").join(" | ")+" |");for(const a of i)o.push("| "+a.join(" | ")+" |");return o.join(` 153`)}function aC(t){if(!t||!t.content)return"";const e=[];for(const r of t.content)switch(r.type){case"paragraph":{const s=ns(r.content);e.push(s);break}case"heading":{const s=Math.min(6,Math.max(1,r.attrs?.level||1)),i=ns(r.content);e.push("#".repeat(s)+" "+i);break}case"bulletList":{e.push(lh(r,!1));break}case"orderedList":{e.push(lh(r,!0));break}case"table":{e.push(oC(r));break}case"horizontalRule":break;default:{const s=ns(r.content);s&&e.push(s)}}const n=[];for(const r of e)r.trim()===""&&(n.length===0||n[n.length-1].trim()==="")||n.push(r);for(;n.length&&n[n.length-1].trim()==="";)n.pop();return n.join(` 154 155`).replace(/\n{3,}/g,` 156 157`).trimEnd()}const ch="sb-rte-styles",lC=` 158.sb-rte .ProseMirror { 159 outline: none; 160 font-family: Georgia, 'Crimson Text', serif; 161 color: #1f2937; 162 line-height: 1.95; 163 font-size: 15px; 164 caret-color: #0d9488; 165 min-height: 8em; 166} 167@media (min-width: 768px) { .sb-rte .ProseMirror { font-size: 16px; } } 168.sb-rte .ProseMirror p { margin: 0 0 0.85em 0; text-align: justify; text-indent: 1.5em; } 169.sb-rte .ProseMirror p:first-child { text-indent: 0; } 170.sb-rte .ProseMirror h1, .sb-rte .ProseMirror h2, .sb-rte .ProseMirror h3,
171.sb-rte .ProseMirror h4, .sb-rte .ProseMirror h5, .sb-rte .ProseMirror h6 { 172 font-family: Georgia, 'Crimson Text', serif; 173 font-weight: 700; line-height: 1.3; margin: 1.3em 0 0.55em 0; text-indent: 0; color: #111827; 174} 175.sb-rte .ProseMirror h1 { font-size: 1.5em; } 176.sb-rte .ProseMirror h2 { font-size: 1.3em; } 177.sb-rte .ProseMirror h3 { font-size: 1.13em; } 178.sb-rte .ProseMirror ul, .sb-rte .ProseMirror ol { padding-left: 1.6em; margin: 0.5em 0; } 179.sb-rte .ProseMirror ul { list-style: disc; } 180.sb-rte .ProseMirror ol { list-style: decimal; } 181.sb-rte .ProseMirror li { margin-bottom: 0.2em; } 182.sb-rte .ProseMirror li p { margin: 0; text-indent: 0; text-align: left; } 183.sb-rte .ProseMirror > *:last-child { margin-bottom: 0; } 184.sb-rte .ProseMirror table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 0.92em; table-layout: fixed; overflow: hidden; } 185.sb-rte .ProseMirror td, .sb-rte .ProseMirror th { border: 1px solid #d1d5db; padding: 7px 11px; vertical-align: top; text-align: left; position: relative; } 186.sb-rte .ProseMirror th { background: #f3f4f6; font-weight: 600; } 187.sb-rte .ProseMirror td p, .sb-rte .ProseMirror th p { text-indent: 0; text-align: left; margin: 0; } 188.sb-rte .ProseMirror .selectedCell:after { background: rgba(13,148,136,0.12); content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2; } 189.sb-rte .ProseMirror .column-resize-handle { background: #0d9488; bottom: -2px; position: absolute; right: -2px; top: 0; width: 3px; pointer-events: none; } 190.sb-rte .ProseMirror p.is-editor-empty:first-child::before { 191 color: #9ca3af; content: attr(data-placeholder); float: left; height: 0; pointer-events: none; font-style: italic; 192} 193`;function cC(){if(typeof document>"u"||document.getElementById(ch))return;const t=document.createElement("style");t.id=ch,t.textContent=lC,document.head.appendChild(t)}function dC({value:t,onSave:e,bookId:n,field:r,placeholder:s,className:i,testId:o,onStatusChange:a,isSaveAllowed:l}){cC();const[d,u]=v.useState(t),h=v.useRef(!1),p=v.useRef(d),f=v.useRef(0),m=v.useRef(!1),g=v.useRef(e),b=v.useRef(a),y=v.useRef(l),k=v.useRef(!1),C=v.useRef(!1),j=Kn();p.current=d,g.current=e,b.current=a,y.current=l;const O=v.useCallback(async()=>{if(!h.current||m.current||y.current?.()===!1)return;m.current=!0;const L=p.current;b.current?.("saving");try{if(await g.current(L),y.current?.()===!1)return;p.current===L?(h.current=!1,b.current?.("saved"),r&&n&&Ns(n,r)):b.current?.("unsaved"),j.invalidateQueries({queryKey:[`/api/books/${n}`]})}catch{y.current?.()!==!1&&b.current?.("unsaved")}finally{m.current=!1,h.current&&y.current?.()!==!1&&O()}},[n,j,r]),S=C1({immediatelyRender:!1,shouldRerenderOnTransaction:!1,extensions:[qS.configure({blockquote:!1,
193codeBlock:!1,code:!1,horizontalRule:!1,strike:!1,link:!1,underline:!1,heading:{levels:[1,2,3,4,5,6]}}),KS.configure({placeholder:s||"Comece a escreverâ¦"}),Um.configure({resizable:!0}),Wm,Km,qm],content:Ba(t),editorProps:{attributes:{class:"focus:outline-none","data-testid":o?`${o}-surface`:"rte-surface"}},onUpdate:({editor:L})=>{if(k.current)return;const J=aC(L.getJSON());u(J)}});v.useEffect(()=>{if(!S||C.current||!r||!n)return;C.current=!0;const L=Ol(n,r,t);L&&(k.current=!0,S.commands.setContent(Ba(L.value),{emitUpdate:!1}),k.current=!1,u(L.value),h.current=!0,b.current?.("unsaved"))},[S]),v.useEffect(()=>{S&&(h.current||d!==t&&(k.current=!0,S.commands.setContent(Ba(t),{emitUpdate:!1}),k.current=!1,u(t)))},[t,S]),v.useEffect(()=>{if(y.current?.()===!1)return;if(d===t){h.current=!1;return}if(h.current=!0,b.current?.("unsaved"),r&&n)try{Al(n,r,d,t)}catch{}const L=++f.current,J=setTimeout(async()=>{f.current===L&&await O()},1500);return()=>clearTimeout(J)},[d]),v.useEffect(()=>()=>{if(h.current&&y.current?.()!==!1){const L=p.current;g.current(L).then(()=>j.invalidateQueries({queryKey:[`/api/books/${n}`]})).catch(()=>{})}},[n,j]);const N=Yf({editor:S,selector:({editor:L})=>{if(!L)return null;const J=L.getText().trim(),Ee=J?J.split(/\s+/).filter(Boolean).length:0;return{isBold:L.isActive("bold"),isItalic:L.isActive("italic"),isBulletList:L.isActive("bulletList"),isOrderedList:L.isActive("orderedList"),isH1:L.isActive("heading",{level:1}),isH2:L.isActive("heading",{level:2}),isH3:L.isActive("heading",{level:3}),isParagraph:L.isActive("paragraph")&&!L.isActive("bulletList")&&!L.isActive("orderedList"),isTable:L.isActive("table"),canUndo:L.can().undo(),canRedo:L.can().redo(),words:Ee}}}),P=N?.isH1?"1":N?.isH2?"2":N?.isH3?"3":"p";if(!S)return c.jsx("div",{className:K("sb-rte animate-pulse text-gray-400 text-sm py-6",i),"data-testid":o,children:"Carregando editorâ¦"});const D=({active:L,disabled:J,onClick:Ee,title:le,testIdSuffix:ce,children:ne})=>c.jsx("button",{type:"button",title:le,"aria-label":le,disabled:J,onMouseDown:X=>X.preventDefault(),onClick:Ee,"data-testid":`rte-${ce}`,className:K("inline-flex items-center justify-center h-9 min-w-9 px-2 rounded-md text-sm transition-colors shrink-0","text-gray-600 hover:bg-emerald-50 hover:text-emerald-700",L&&"bg-emerald-100 text-emerald-800 ring-1 ring-emerald-300/40",J&&"opacity-40 cursor-not-allowed hover:bg-transparent hover:text-gray-600"),children:ne});return c.jsxs("div",{className:K("sb-rte w-full",i),"data-testid":o,children:[c.jsxs("div",{className:"sticky top-0 z-20 -mx-1 mb-3 flex items-center gap-0.5 overflow-x-auto rounded-xl border border-gray-200/80 bg-white/95 px-1.5 py-1 shadow-sm backdrop-blur supports-[backdrop-filter]:bg-white/80","data-testid":"rte-toolbar",children:[c.jsxs("select",{value:P,onMouseDown:L=>L.stopPropagation(),onChange:L=>{const J=L.target.value;J==="p"?S.chain().focus().setParagraph().run():S.chain().focus().toggleHeading({level:Number(J)}).run()},"data-testid":"rte-block-type",className:"h-9 shrink-0 rounded-md border border-gray-200 bg-white px-2 text-sm text-gray-700 focus:outline-none focus:ring-1 focus:ring-emerald-400/40",children:[c.jsx("option",{value:"p",children:"Parágrafo"}),c.jsx("option",{value:"1",children:"TÃtulo 1"}),c.jsx("option",{value:"2",children:"TÃtulo 2"}),c.jsx("option",{value:"3",children:"TÃtulo 3"})]}),c.jsx("span",{className:"mx-1 h-5 w-px bg-gray-200 shrink-0"}),c.jsx(D,{active:N?.isBold,onClick:()=>S.chain().focus().toggleBold().run(),title:"Negrito (Ctrl+B)",testIdSuffix:"bold",children:c.jsx(fd,{className:"h-4 w-4"})}),c.jsx(D,{active:N?.isItalic,onClick:()=>S.chain().focus().toggleItalic().run(),title:"Itálico (Ctrl+I)",testIdSuffix:"italic",children:c.jsx(md,{className:"h-4 w-4"})}),c.jsx("span",{className:"mx-1 h-5 w-px bg-gray-200 shrink-0"}),c.jsx(D,{active:N?.isH1,onClick:()=>S.chain().focus().toggleHeading({level:1}).run(),title:"TÃtulo 1",testIdSuffix:"h1",children:c.jsx(_x,{className:"h-4 w-4"})}),c.jsx(D,{active:N?.isH2,onClick:()=>S.chain().focus().toggleHeading({level:2}).run(),title:"TÃtulo 2",testIdSuffix:"h2",children:c.jsx(xd,{className:"h-4 w-4"})}),c.jsx(D,{active:N?.isH3,onClick:()=>S.chain().focus().toggleHeading({level:3}).run(),title:"TÃtulo 3",testIdSuffix:"h3",children:c.jsx(Vx,{className:"h-4 w-4"})}),c.jsx("span",{className:"mx-1 h-5 w-px bg-gray-200 shrink-0"}),c.jsx(D,{active:N?.isBulletList,onClick:()=>S.chain().focus().toggleBulletList().run(),title:"Lista com marcadores",testIdSuffix:"bullet",children:c.jsx(Nx,{className:"h-4 w-4"})}),c.jsx(D,{active:N?.isOrderedList,onClick:()=>S.chain().focus().toggleOrderedList().run(),title:"Lista numerada",testIdSuffix:"ordered",children:c.jsx(fx,{className:"h-4 w-4"})}),N?.isTable&&c.jsxs(c.Fragment,{children:[c.jsx(D,{onClick:()=>S.chain().focus().addColumnAfter().run(),title:"Adicionar coluna",testIdSuffix:"add-col",children:c.jsx(Bx,{className:"h-4 w-4"})}),c.jsx(D,{onClick:()=>S.chain().focus().addRowAfter().run(),title:"Adicionar linha",testIdSuffix:"add-row",children:c.jsx(Jx,{className:"h-4 w-4"})}),c.jsx(D,{onClick:()=>S.chain().focus().deleteTable().run(),title:"Remover tabela",testIdSuffix:"del-table",children:c.jsx(jn,{className:"h-4 w-4"})})]}),c.jsx("span",{className:"mx-1 h-5 w-px bg-gray-200 shrink-0"}),c.jsx(D,{disabled:!N?.canUndo,onClick:()=>
193S.chain().focus().undo().run(),title:"Desfazer (Ctrl+Z)",testIdSuffix:"undo",children:c.jsx(Gg,{className:"h-4 w-4"})}),c.jsx(D,{disabled:!N?.canRedo,onClick:()=>S.chain().focus().redo().run(),title:"Refazer (Ctrl+Y)",testIdSuffix:"redo",children:c.jsx(kx,{className:"h-4 w-4"})}),c.jsxs("span",{className:"ml-auto shrink-0 pl-2 pr-1 text-[11px] font-medium text-gray-400","data-testid":"rte-wordcount",children:[N?.words??0," ",N?.words===1?"palavra":"palavras"]})]}),c.jsx(Uk,{editor:S,options:{placement:"top"},children:c.jsxs("div",{className:"flex items-center gap-0.5 rounded-lg border border-gray-200 bg-white p-1 shadow-lg","data-testid":"rte-bubble",children:[c.jsx("button",{type:"button",onMouseDown:L=>L.preventDefault(),onClick:()=>S.chain().focus().toggleBold().run(),"data-testid":"rte-bubble-bold",className:K("inline-flex h-8 w-8 items-center justify-center rounded text-gray-600 hover:bg-emerald-50",N?.isBold&&"bg-emerald-100 text-emerald-800"),children:c.jsx(fd,{className:"h-4 w-4"})}),c.jsx("button",{type:"button",onMouseDown:L=>L.preventDefault(),onClick:()=>S.chain().focus().toggleItalic().run(),"data-testid":"rte-bubble-italic",className:K("inline-flex h-8 w-8 items-center justify-center rounded text-gray-600 hover:bg-emerald-50",N?.isItalic&&"bg-emerald-100 text-emerald-800"),children:c.jsx(md,{className:"h-4 w-4"})}),c.jsx("span",{className:"mx-0.5 h-5 w-px bg-gray-200"}),c.jsx("button",{type:"button",onMouseDown:L=>L.preventDefault(),onClick:()=>S.chain().focus().toggleHeading({level:2}).run(),"data-testid":"rte-bubble-h2",className:K("inline-flex h-8 w-8 items-center justify-center rounded text-gray-600 hover:bg-emerald-50",N?.isH2&&"bg-emerald-100 text-emerald-800"),children:c.jsx(xd,{className:"h-4 w-4"})}),c.jsx("button",{type:"button",onMouseDown:L=>L.preventDefault(),onClick:()=>S.chain().focus().setParagraph().run(),"data-testid":"rte-bubble-paragraph",className:K("inline-flex h-8 w-8 items-center justify-center rounded text-gray-600 hover:bg-emerald-50",N?.isParagraph&&"bg-emerald-100 text-emerald-800"),children:c.jsx(Wx,{className:"h-4 w-4"})})]})}),c.jsx(Qf,{editor:S})]})}function uC({open:t,checking:e,checkError:n,saving:r,saveError:s,onRetryCheck:i,onSave:o}){const[a,l]=v.useState(""),d=v.useRef(null),u=v.useRef(null),h=a.replace(/\D/g,""),p=h.length>=10&&h.length<=15&&!/[A-Za-z]/.test(a);return v.useEffect(()=>{if(!t)return;const f=Eh("plan-whatsapp-gate-modal"),m=document.activeElement instanceof HTMLElement?document.activeElement:null,g=document.getElementById("root"),b=g?.inert,y=g?.getAttribute("aria-hidden");g&&(g.inert=!0,g.setAttribute("aria-hidden","true")),window.setTimeout(()=>d.current?.focus(),0);const k=C=>{if(C.key==="Escape"){C.preventDefault(),C.stopPropagation();return}if(C.key!=="Tab"||!d.current)return;const j=Array.from(d.current.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(!j.length){C.preventDefault(),d.current.focus();return}const O=j[0],S=j[j.length-1];C.shiftKey&&document.activeElement===O?(C.preventDefault(),S.focus()):!C.shiftKey&&document.activeElement===S&&(C.preventDefault(),O.focus())};return document.addEventListener("keydown",k,!0),()=>{f(),document.removeEventListener("keydown",k,!0),g&&(g.inert=!!b,y==null?g.removeAttribute("aria-hidden"):g.setAttribute("aria-hidden",y)),m?.focus()}},[t]),v.useEffect(()=>{!t||e||r||window.setTimeout(()=>{n?d.current?.querySelector("button:not([disabled])")?.focus():u.current?.focus()},0)},[t,e,n,r]),t?hr.createPortal(c.jsx("div",{className:"modal-scroll-container fixed inset-0 z-[120] overflow-y-auto bg-slate-950/45 px-4 py-6","data-app-overlay-open":"true","data-scroll-lock-owner":"plan-whatsapp-gate-modal","data-testid":"plan-whatsapp-gate-overlay",children:c.jsx("div",{className:"flex min-h-full items-center justify-center",children:c.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-labelledby":"plan-whatsapp-title","aria-describedby":"plan-whatsapp-description","aria-busy":e||r,tabIndex:-1,className:"w-full max-w-md rounded-3xl border border-white/70 bg-white/95 p-5 shadow-2xl shadow-slate-950/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-700 sm:p-7","data-testid":"plan-whatsapp-gate-modal",children:[c.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-emerald-100 text-emerald-700",children:c.jsx(Qg,{className:"h-7 w-7","aria-hidden":"true"})}),e?c.jsxs("div",{className:"py-3 text-center",role:"status","aria-live":"polite",children:[c.jsx(ge,{className:"mx-auto mb-3 h-6 w-6 animate-spin text-emerald-600"}),c.jsx("h2",{id:"plan-whatsapp-title",className:"text-lg font-bold text-slate-900",children:"Verificando seu WhatsApp"}),c.jsx("p",{id:"plan-whatsapp-description",className:"mt-2 text-sm text-slate-600",children:"Seu planejamento ficará disponÃvel em instantes."})]}):n?c.jsxs("div",{className:"text-center",children:[c.jsx("h2",{id:"plan-whatsapp-title",className:"text-xl font-bold text-slate-900",children:"Não foi possÃvel verificar seu contato"}),c.jsx("p",{id:"plan-whatsapp-description",className:"mt-2 text-sm leading-relaxed text-slate-600",children:"Por segurança, o planejamento continua protegido. Tente verificar novamente."}),c.jsxs(Y,{onClick:i,className:"mt-5 w-full bg-emerald-600 text-white hover:bg-emerald-700",children:[c.jsx(Rt,{className:"mr-2 h-4 w-4"})," Tentar novamente"]})]}):c.jsxs(c.Fragment,{children:[c.jsx("h2",{id:"plan-whatsapp-title",className:"text-center text-xl font-bold text-slate-900",children:"Seu planejamento está pronto"}),c.jsx("p",{id:"plan-whatsapp-description",className:"mt-2 text-center text-sm leading-relaxed text-slate-600",children:"Informe seu WhatsApp para liberar o planejamento e receber o link de acesso por lá."}),c.jsxs("form",{className:"mt-5 space-y-3",onSubmit:f=>{f.preventDefault(),r||o(a)},children:[c.jsx("label",{htmlFor:"plan-whatsapp-phone",className:"block text-sm font-semibold text-slate-800",children:"WhatsApp com DDD"}),c.jsx(rs,{ref:u,id:"plan-whatsapp-phone",type:"tel",inputMode:"tel",autoComplete:"tel",value:a,onChange:f=>l(f.target.value),placeholder:"(11) 99999-9999",required:!0,minLength:10,pattern:"[+0-9()\\\\s-]{10,}",disabled:r,"aria-invalid":!!s,"aria-describedby":s?"plan-whatsapp-error":"plan-whatsapp-privacy",className:"h-12 border-slate-300 bg-white text-base text-slate-950","data-testid":"input-plan-whatsapp"}),s&&c.jsx("p",{id:"plan-whatsapp-error",role:"alert",className:"text-sm text-red-600","data-testid":"text-plan-whatsapp-error",children:s}),c.jsx("p",{id:"plan-whatsapp-privacy",className:"text-xs leading-relaxed text-slate-500",children:"Inclua DDD e, se estiver fora do Brasil, o código do paÃs. Usaremos este número somente para entregar este planejamento. Isso não autoriza mensagens promocionais."}),r&&c.jsx("p",{role:"status","aria-live":"polite",className:"sr-only",children:"Salvando seu WhatsApp."}),c.jsx(Y,{type:"submit",disabled:r||!p,className:"h-12 w-full bg-emerald-700 text-white hover:bg-emerald-800","data-testid":"button-save-plan-whatsapp",children:r?c.jsxs(c.Fragment,{children:[c.jsx(ge,{className:"mr-2 h-4 w-4 animate-spin"})," Salvando..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Mn,{className:"mr-2 h-4 w-4"})," Liberar meu planejamento"]})})]})]})]})})}),document.body):null}const Jm="sb_editor_mode",Ml=new Set;function dh(){return zt.getItem(Jm)==="markdown"?"markdown":"visual"}
193function uh(t){zt.setItem(Jm,t),Ml.forEach(e=>e())}function Gm(){const[t,e]=v.useState(dh);return v.useEffect(()=>{const n=()=>e(dh());return Ml.add(n),()=>{Ml.delete(n)}},[]),t}function qr(t){return Gm()==="visual"?c.jsx(dC,{...t}):c.jsx(gC,{...t})}function hC(t){if(!t||!t.trim())return'<p style="color:#9ca3af;font-style:italic;">...</p>';const e=i=>i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),n=i=>{let o=e(i);return o=o.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),o=o.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),o=o.replace(/\*(.+?)\*/g,"<em>$1</em>"),o},r=t.split(/\n\n+/),s=[];for(const i of r){const o=i.trim();if(!o)continue;const a=o.split(` 194`);if(a.length>=2&&a[0].includes("|")&&a[1].match(/^\s*\|?\s*[-:]+/)){const f=k=>k.split("|").map(C=>C.trim()).filter(C=>C!==""),m=f(a[0]),g=a.slice(2).filter(k=>k.includes("|"));let b='<table style="width:100%;border-collapse:collapse;margin:1em 0;font-size:14px;">';b+="<thead><tr>";for(const k of m)b+=`<th style="border:1px solid #e5e7eb;padding:8px 12px;background:#f9fafb;font-weight:600;text-align:left;">${n(k)}</th>`;b+="</tr></thead><tbody>";for(const k of g){const C=f(k);b+="<tr>";for(const j of C)b+=`<td style="border:1px solid #e5e7eb;padding:8px 12px;">${n(j)}</td>`;b+="</tr>"}b+="</tbody></table>";const y=`<div style="overflow-x:auto;">${b}</div>`;s.push(y);continue}let d=[],u=null,h=[];const p=()=>{if(d.length>0&&u){const f=u;let g=`<${f} style="${f==="ol"?"list-style:decimal;":"list-style:disc;"}padding-left:2em;margin:0.5em 0;">`;for(const b of d)g+=`<li style="margin-bottom:0.25em;line-height:1.9;">${n(b)}</li>`;g+=`</${f}>`,s.push(g),d=[],u=null}};for(const f of a){const m=f.match(/^(#{1,6})\s+(.+)$/);if(m){p();const y=m[1].length,k=y<=2?"1.25em":y===3?"1.1em":"1em";s.push(`<p style="font-size:${k};font-weight:700;margin:1.2em 0 0.6em 0;text-indent:0;">${n(m[2])}</p>`);continue}const g=f.match(/^[\*\-]\s+(.+)$/);if(g){u!=="ul"&&(p(),u="ul"),d.push(g[1]);continue}const b=f.match(/^(\d+)\.\s+(.+)$/);if(b){u!=="ol"&&(p(),u="ol"),d.push(b[2]);continue}p(),h.push(f)}if(p(),h.length>0){const f=h.join(" ").trim();if(f)if(/^\*\*\d+\.\s+.+\*\*$/.test(f)){const g=f.replace(/^\*\*/,"").replace(/\*\*$/,"");s.push(`<p style="font-size:1.1em;font-weight:700;margin:1.2em 0 0.6em 0;text-indent:0;">${e(g)}</p>`)}else{const b=f.startsWith("â")||f.startsWith("â")||f.startsWith('"')?"0":"1.5em";s.push(`<p style="text-indent:${b};margin-bottom:0.8em;line-height:1.9;text-align:justify;">${n(f)}</p>`)}}}return s.join("")}function pC({value:t,onSave:e,bookId:n,field:r,placeholder:s,className:i,testId:o,onStatusChange:a,isSaveAllowed:l}){const[d,u]=v.useState(!1),h=v.useRef(null);return d?c.jsx("div",{onBlur:p=>{p.currentTarget.contains(p.relatedTarget)||u(!1)},children:c.jsx(qr,{value:t,onSave:e,bookId:n,field:r,placeholder:s,className:i,testId:o,onStatusChange:a,isSaveAllowed:l})}):c.jsxs("div",{ref:h,"data-testid":o,onClick:()=>u(!0),className:K("w-full bg-transparent font-['Georgia','Crimson_Text',serif] text-gray-800 leading-[1.9] text-[15px] md:text-base cursor-text","min-h-[3em] rounded-md transition-all duration-200","hover:ring-1 hover:ring-gray-300/50 hover:bg-gray-50/30","relative group",i),children:[c.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",children:c.jsx("div",{className:"flex items-center gap-1 text-xs text-gray-400 bg-white/80 backdrop-blur-sm rounded px-2 py-1 shadow-sm",children:c.jsx(Qt,{className:"w-3 h-3"})})}),c.jsx("div",{dangerouslySetInnerHTML:{__html:hC(t)}})]})}const fC={Palette:wi,CheckCircle2:Mn,Languages:Oh,Printer:Sx};function mC({text:t,baseSpeed:e=12,className:n="",followUpdates:r=!1,onComplete:s,cursor:i=!0}){const[o,a]=v.useState(0),[l,d]=v.useState(!1),u=v.useRef(t),h=v.useRef(null),p=v.useRef(0);v.useEffect(()=>{r?(u.current=t,l&&t.length>p.current&&d(!1)):(a(0),p.current=0,d(!1),u.current=t)},[t,r]),v.useEffect(()=>{if(!u.current||l)return;const m=()=>{const g=u.current,b=p.current;if(b>=g.length){if(r){h.current=setTimeout(m,50);return}d(!0),s?.();return}const y=g[b],k=g.length;let C=e;k>2e3?C=Math.max(e*.3,2):k>1e3?C=Math.max(e*.5,4):k>500&&(C=Math.max(e*.7,6));let O=C*(.5+Math.random());y==="."||y==="!"||y==="?"?O+=C*4:y===","||y===";"||y===":"?O+=C*2:y===` 195`&&(O+=C*3);const S=k>3e3?4:k>1500?3:k>800?2:1,N=Math.min(b+S,g.length);p.current=N,a(N),h.current=setTimeout(m,O)};return h.current=setTimeout(m,e),()=>{h.current&&clearTimeout(h.current)}},[l,e,s,r,t]);const f=(r?t:u.current).slice(0,o);return c.jsxs("span",{className:n,children:[f,i&&!l&&c.jsx("span",{className:"inline-block w-[2px] h-[1em] bg-primary/70 ml-0.5 animate-[blink_0.8s_step-end_infinite] align-middle"})]})}function Cn({text:t,speed:e=20,className:n=""}){return c.jsx(mC,{text:t,baseSpeed:e,className:n})}function gC({value:t,onSave:e,bookId:n,field:r,placeholder:s,className:i,testId:o,onStatusChange:a,isSaveAllowed:l}){const[d,u]=v.useState(t),h=v.useRef(null),p=v.useRef(!1),f=v.useRef(d),m=v.useRef(0),g=v.useRef(!1),b=v.useRef(e),y=v.useRef(a),k=v.useRef(l),C=Kn();f.current=d,b.current=e,y.current=a,k.current=l;const j=v.useCallback(async()=>
195{if(!p.current||g.current||k.current?.()===!1)return;g.current=!0;const N=f.current;y.current?.("saving");try{if(await b.current(N),k.current?.()===!1)return;f.current===N?(p.current=!1,y.current?.("saved"),r&&n&&Ns(n,r)):y.current?.("unsaved"),C.invalidateQueries({queryKey:[`/api/books/${n}`]})}catch{k.current?.()!==!1&&y.current?.("unsaved")}finally{g.current=!1,p.current&&k.current?.()!==!1&&j()}},[n,C]);v.useEffect(()=>{if(!r||!n)return;const N=Ol(n,r,t);N&&(u(N.value),p.current=!0,y.current?.("unsaved"))},[]),v.useEffect(()=>{p.current||u(t)},[t]);const O=v.useCallback(()=>{const N=h.current;N&&(N.style.height="auto",N.style.height=N.scrollHeight+"px")},[]);v.useEffect(()=>{O()},[d,O]);const S=v.useRef(0);return v.useEffect(()=>{const N=h.current;if(!N||typeof ResizeObserver>"u")return;const P=new ResizeObserver(D=>{const L=D[0]?.contentRect.width??0;L!==S.current&&(S.current=L,O())});return P.observe(N),document.fonts?.ready?.then(()=>O()),()=>P.disconnect()},[O]),v.useEffect(()=>{if(k.current?.()===!1)return;if(d===t){p.current=!1;return}if(p.current=!0,a?.("unsaved"),r&&n)try{Al(n,r,d,t)}catch{}const N=++m.current,P=setTimeout(async()=>{m.current===N&&await j()},1500);return()=>clearTimeout(P)},[d]),v.useEffect(()=>()=>{if(p.current&&k.current?.()!==!1){const N=f.current;b.current(N).then(()=>{C.invalidateQueries({queryKey:[`/api/books/${n}`]})}).catch(()=>{})}},[n,C]),c.jsx("textarea",{ref:h,"data-testid":o,value:d,onChange:N=>u(N.target.value),onBlur:()=>{p.current&&j()},placeholder:s,className:K("w-full resize-none overflow-hidden bg-transparent focus:outline-none font-['Georgia','Crimson_Text',serif] text-gray-800 leading-[1.9] text-[15px] md:text-base",i),rows:3})}function $a({value:t,onSave:e,bookId:n,field:r,className:s,testId:i,onStatusChange:o,isSaveAllowed:a}){const[l,d]=v.useState(t),u=v.useRef(null),h=v.useRef(!1),p=v.useRef(l),f=v.useRef(0),m=v.useRef(!1),g=v.useRef(e),b=v.useRef(o),y=v.useRef(a),k=Kn();p.current=l,g.current=e,b.current=o,y.current=a;const C=v.useCallback(async()=>{if(!h.current||m.current||y.current?.()===!1)return;m.current=!0;const S=p.current;b.current?.("saving");try{if(await g.current(S),y.current?.()===!1)return;p.current===S?(h.current=!1,b.current?.("saved"),r&&n&&Ns(n,r)):b.current?.("unsaved"),k.invalidateQueries({queryKey:[`/api/books/${n}`]})}catch{y.current?.()!==!1&&b.current?.("unsaved")}finally{m.current=!1,h.current&&y.current?.()!==!1&&C()}},[n,k]);v.useEffect(()=>{if(!r||!n)return;const S=Ol(n,r,t);S&&(d(S.value),h.current=!0,b.current?.("unsaved"))},[]),v.useEffect(()=>{h.current||d(t)},[t]);const j=v.useCallback(()=>{const S=u.current;S&&(S.style.height="auto",S.style.height=S.scrollHeight+"px")},[]);v.useEffect(()=>{j()},[l,j]);const O=v.useRef(0);return v.useEffect(()=>{const S=u.current;if(!S||typeof ResizeObserver>"u")return;const N=new ResizeObserver(P=>{const D=P[0]?.contentRect.width??0;D!==O.current&&(O.current=D,j())});return N.observe(S),document.fonts?.ready?.then(()=>j()),()=>N.disconnect()},[j]),v.useEffect(()=>{if(y.current?.()===!1)return;if(l===t){h.current=!1;return}if(h.current=!0,o?.("unsaved"),r&&n)try{Al(n,r,l,t)}catch{}const S=++f.current,N=setTimeout(async()=>{f.current===S&&await C()},1500);return()=>clearTimeout(N)},[l]),v.useEffect(()=>()=>{if(h.current&&y.current?.()!==!1){const S=p.current;g.current(S).then(()=>{k.invalidateQueries({queryKey:[`/api/books/${n}`]})}).catch(()=>{})}},[n,k]),c.jsx("textarea",{ref:u,"data-testid":i,value:l,onChange:S=>d(S.target.value),onBlur:()=>{h.current&&C()},className:K("w-full resize-none bg-transparent focus:outline-none overflow-hidden overflow-wrap-anywhere","border-b border-transparent hover:border-gray-300/50 focus:border-gray-400/50 transition-colors",s),style:{overflowWrap:"anywhere",wordBreak:"break-word"},rows:1})}function xC({bookTitle:t,planData:e,generationPrice:n,onUnlock:r,outline:s,onHeightChange:i}){const{t:o}=ho("editor"),[a,l]=v.useState(0),[d,u]=v.useState(!1),h=v.useRef(null),p=px(),f=e?.chapters?.length||s?.length||10,m=f*15,g=n.toFixed(2).replace(".",","),b=zh(Bh(n)),y=t.length>30?t.substring(0,27)+"...":t,k=[{headline:c.jsx(c.Fragment,{children:c.jsx("span",{dangerouslySetInnerHTML:{__html:o("offer.planReady")}})}),subline:c.jsx(c.Fragment,{children:o("offer.planReadySubline",{chapters:f,pages:m})}),icon:ld},{headline:c.jsx(c.Fragment,{children:c.jsx("span",{dangerouslySetInnerHTML:{__html:o("offer.ghostwriter",{price:g})}})}),subline:c.jsx(c.Fragment,{children:o("offer.ghostwriterSubline")}),icon:Ox},{headline:c.jsx(c.Fragment,{children:c.jsx("span",{dangerouslySetInnerHTML:{__html:o("offer.deserves",{title:y})}})}),subline:c.jsx(c.Fragment,{children:o("offer.deservesSubline")}),icon:Ih},{headline:c.jsx(c.Fragment,{children:c.jsx("span",{dangerouslySetInnerHTML:{__html:o("offer.youPlanned")}})}),subline:c.jsx(c.Fragment,{children:o("offer.youPlannedSubline")}),icon:oe}];return v.useEffect(()=>{if(d)return;const j=setInterval(()=>{l(O=>(O+1)%k.length)},5e3);return()=>clearInterval(j)},[d,k.length]),v.useEffect(()=>{const j=h.current;if(!j||!i)return;const O=()=>i(j.offsetHeight);if(O(),typeof ResizeObserver>"u")return;const S=new ResizeObserver(O);return S.observe(j),()=>S.disconnect()},[i]),k[a].icon,c.jsx("div",{ref:j=>{h.current=j,p(j)},"data-fixed-surface":"route-action",className:"mobile-floating-bar-clearance fixed md:bottom-0 left-0 md:left-64 right-0 lg:right-[316px] z-[55] px-3 md:px-6 pb-3 md:pb-4 lg:pb-3 pt-2 lg:pt-1.5","data-testid":"offer-bar",children:c.jsxs(se.button,{onClick:r,className:"w-full relative overflow-hidden cursor-pointer rounded-2xl group","data-testid":"button-offer-unlock",animate:{boxShadow:["0 0 20px rgba(52,211,153,0.2), 0 0 60px rgba(52,211,153,0.1)","0 0 30px rgba(52,211,153,0.4), 0 0 80px rgba(52,211,153,0.2)","0 0 20px rgba(52,211,153,0.2), 0 0 60px rgba(52,211,153,0.1)"]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut"},whileHover:{scale:1.02},whileTap:{scale:.98},children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-emerald-500 via-emerald-400 to-emerald-500 rounded-2xl"}),c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-emerald-400/0 via-white/20 to-emerald-400/0 opacity-0 group-hover:opacity-100 transition-opacity duration-500 rounded-2xl"}),c.jsx(se.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/[0.15] to-transparent roun
195ded-2xl",animate:{x:["-100%","200%"]},transition:{duration:2.5,repeat:1/0,repeatDelay:1.5,ease:"easeInOut"}}),c.jsxs("div",{className:"relative px-5 md:px-8 py-4 md:py-5 lg:py-3 flex flex-col items-center justify-center text-center gap-1",children:[c.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[c.jsx(ld,{className:"w-5 h-5 md:w-6 md:h-6 lg:w-5 lg:h-5 text-black/80 fill-black/80"}),c.jsx("span",{className:"text-base md:text-xl lg:text-lg font-extrabold text-black tracking-tight leading-tight",children:o("offer.ctaMain",{price:g})})]}),c.jsxs("span",{className:"text-xs md:text-sm text-black/70 font-medium",children:[c.jsxs("span",{className:"line-through opacity-60 mr-1.5",children:["R$ ",b]}),o("offer.ctaSub")]})]})]})})}function bC({bookId:t}){const{t:e}=ho("editor"),[,n]=Ah(),[r,s]=v.useState(!1),{data:i}=Ce({queryKey:[`/api/books/${t}/next-upsell`],enabled:!!t,staleTime:3e4});if(r||!i?.nextUpsell)return null;const o=i.nextUpsell;if(o.step==="write")return null;const l={cover:wi,illustrate:wi,publish:Ax,marketing:Ex,translate:Oh}[o.step]||oe,d=o.price.toFixed(2).replace(".",",");return c.jsx("div",{className:"mb-6 font-sans","data-testid":"upsell-banner",children:c.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-primary/20 bg-gradient-to-r from-[#071512] via-[#0d2420] to-[#071512]",children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-primary/5 via-transparent to-primary/5 pointer-events-none"}),c.jsx("button",{onClick:()=>s(!0),className:"absolute top-3 right-3 text-white/30 hover:text-white/60 transition-colors z-10","data-testid":"button-dismiss-upsell",children:c.jsx(nn,{className:"w-4 h-4"})}),c.jsxs("div",{className:"relative p-4 md:p-6 flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-4",children:[c.jsxs("div",{className:"flex items-center gap-3 w-full sm:w-auto",children:[c.jsx("div",{className:"w-10 h-10 md:w-12 md:h-12 rounded-xl bg-primary/15 flex items-center justify-center shrink-0 ring-1 ring-primary/20",children:c.jsx(l,{className:"w-5 h-5 md:w-6 md:h-6 text-primary"})}),c.jsxs("div",{className:"flex-1 min-w-0 sm:hidden",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[c.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-primary/20 text-primary font-medium",children:e("upsell.nextStep")}),c.jsxs("span",{className:"text-[10px] text-white/40",children:[i.completedSteps,"/",i.totalSteps]})]}),c.jsx("p",{className:"text-sm font-bold text-white leading-tight truncate","data-testid":"text-upsell-cta",children:o.cta})]})]}),c.jsxs("div",{className:"flex-1 min-w-0 hidden sm:block",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-primary/20 text-primary font-medium",children:e("upsell.nextStep")}),c.jsxs("span",{className:"text-[10px] text-white/40",children:[i.completedSteps,"/",i.totalSteps," ",e("upsell.completed")]})]}),c.jsx("p",{className:"text-sm md:text-base font-bold text-white leading-tight","data-testid":"text-upsell-cta-desktop",children:o.cta}),c.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:o.message})]}),c.jsxs(Y,{onClick:()=>n(o.route),size:"sm",className:"w-full sm:w-auto shrink-0 bg-primary hover:bg-primary/90 text-black font-bold text-xs sm:text-sm px-4 sm:px-5 py-2 sm:py-2.5 rounded-xl shadow-lg shadow-primary/25 hover:shadow-primary/40 transition-all gap-2","data-testid":"button-upsell-action",children:["R$ ",d,c.jsx(xh,{className:"w-4 h-4"})]})]})]})})}function yC({bookId:t,isPaid:e,courtesyUsed:n}){const{toast:r}=ws(),s=Kn(),[i,o]=v.useState(!1),[a,l]=v.useState(""),[d,u]=v.useState(!1),[h,p]=v.useState(null),[f,m]=v.useState(!1),[g,b]=v.useState(!1);if(v.useEffect(()=>{if(!e||n)return;let S=!1;return fetch(`/api/books/${t}/courtesy-regeneration/eligibility`,{credentials:"include"}).then(N=>N.json()).then(N=>{S||p(N)}).catch(()=>{}),()=>{S=!0}},[t,e,n]),v.useEffect(()=>{if(h?.eligible){const S=setTimeout(()=>b(!0),50);return()=>clearTimeout(S)}},[h?.eligible]),v.useEffect(()=>{if(i)return Eh("book-editor-courtesy-regeneration")},[i]),v.useEffect(()=>{if(!i)return;const S=N=>{N.key==="Escape"&&!d&&o(!1)};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[i,d]),!e||n||!h?.eligible||f)return null;const y=h?.hoursRemaining??h?.windowHours??168,k=h?.kbCount??0,C=h?.briefingChars??0,j=h?.requiresFeedback===!0,O=async()=>
195{if(j&&a.trim().length<80){r({title:"Conte um pouco mais",description:"Como seu briefing foi curto, descreva com detalhes (mÃnimo 80 caracteres) o que não ficou bom â isso guia a nova versão.",variant:"destructive"});return}u(!0);try{const S=await fetch(`/api/books/${t}/courtesy-regeneration`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({userFeedback:a||void 0})}),N=await S.json().catch(()=>({}));S.ok?(r({title:"Regeneração iniciada",description:N.message||"Estamos reescrevendo todos os capÃtulos do seu livro. Você pode acompanhar o progresso aqui."}),o(!1),s.invalidateQueries({queryKey:[`/api/books/${t}`]}),s.invalidateQueries({queryKey:[`/api/books/${t}/chapters`]})):(r({title:"Não foi possÃvel regenerar",description:N.message||"Tente novamente em alguns instantes.",variant:"destructive"}),u(!1))}catch{r({title:"Erro de conexão",description:"Verifique sua internet e tente novamente.",variant:"destructive"}),u(!1)}};return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-3 mb-2 rounded-xl px-4 py-3 backdrop-blur-md border shadow-sm transition-all duration-500 ease-out",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.85), rgba(245,250,255,0.7))",borderColor:"hsl(178, 86%, 39%, 0.25)",opacity:g?1:0,transform:g?"translateY(0)":"translateY(-12px)"},"data-testid":"courtesy-regen-banner",children:[c.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center shrink-0",style:{background:"hsl(178, 86%, 39%, 0.12)"},children:c.jsx(oe,{className:"w-4 h-4",style:{color:"hsl(178, 86%, 35%)"}})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("p",{className:"text-[13px] font-semibold text-slate-800 leading-snug",children:["Não ficou como esperava? ",c.jsx("span",{className:"text-slate-600 font-normal",children:"Regenere uma vez, por conta da casa."})]}),c.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:y>0?c.jsxs(c.Fragment,{children:["DisponÃvel por mais ",c.jsxs("strong",{className:"text-emerald-700",children:[y,"h"]}),". Ajuste o briefing ou adicione materiais para um resultado ainda melhor."]}):c.jsx(c.Fragment,{children:"Janela final disponÃvel. Ajuste o briefing ou adicione materiais para um resultado ainda melhor."})})]}),c.jsx("button",{onClick:()=>o(!0),className:"shrink-0 px-4 py-2 text-[12px] font-semibold rounded-lg transition-colors border-2",style:{borderColor:"hsl(178, 86%, 35%)",color:"hsl(178, 86%, 30%)",background:"transparent"},onMouseEnter:S=>{S.currentTarget.style.background="hsl(178, 86%, 35%)",S.currentTarget.style.color="white"},onMouseLeave:S=>{S.currentTarget.style.background="transparent",S.currentTarget.style.color="hsl(178, 86%, 30%)"},"data-testid":"button-courtesy-regen",children:"Refazer agora"}),c.jsx("button",{onClick:()=>m(!0),className:"shrink-0 w-7 h-7 flex items-center justify-center rounded-md text-slate-400 hover:text-slate-600 hover:bg-slate-100 transition-colors","aria-label":"Dispensar","data-testid":"button-courtesy-dismiss",children:c.jsx(nn,{className:"w-4 h-4"})})]}),c.jsx(Ph,{children:i&&c.jsx(se.div,{initial:{opacity:0}
195,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"modal-scroll-container fixed inset-0 z-[100] flex items-center justify-center p-4 overflow-y-auto","data-app-overlay-open":"true","data-scroll-lock-owner":"book-editor-courtesy-regeneration",style:{background:"radial-gradient(circle at center, rgba(8, 47, 73, 0.85), rgba(2, 6, 23, 0.95))",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},onClick:()=>!d&&o(!1),"data-testid":"modal-courtesy-regen",role:"dialog","aria-modal":"true","aria-labelledby":"courtesy-regen-title",children:c.jsxs(se.div,{initial:{opacity:0,y:24,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:12,scale:.97},transition:{type:"spring",damping:22,stiffness:280},className:"relative w-full max-w-lg my-auto rounded-3xl overflow-hidden shadow-2xl",style:{background:"linear-gradient(180deg, #0b1220 0%, #0f1b2d 100%)",border:"1px solid rgba(20, 184, 166, 0.25)",boxShadow:"0 30px 80px -20px rgba(20, 184, 166, 0.35), 0 0 0 1px rgba(20, 184, 166, 0.1)"},onClick:S=>S.stopPropagation(),children:[c.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{background:"radial-gradient(600px circle at 50% -10%, rgba(20, 184, 166, 0.18), transparent 50%)"}}),c.jsx("div",{className:"relative px-6 pt-6 pb-5 border-b border-white/5",children:c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[c.jsx("div",{className:"w-12 h-12 rounded-2xl flex items-center justify-center shrink-0 relative",style:{background:"linear-gradient(135deg, rgba(20, 184, 166, 0.25), rgba(6, 182, 212, 0.15))",border:"1px solid rgba(20, 184, 166, 0.4)",boxShadow:"0 8px 24px -8px rgba(20, 184, 166, 0.5)"},children:c.jsx(oe,{className:"w-6 h-6 text-teal-300"})}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("h3",{id:"courtesy-regen-title",className:"text-lg md:text-xl font-bold text-white tracking-tight","data-testid":"text-courtesy-modal-title",children:"Refazer seu livro do zero"}),c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[c.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-bold uppercase tracking-wider",style:{background:"linear-gradient(135deg, rgba(250, 204, 21, 0.2), rgba(245, 158, 11, 0.15))",color:"#fbbf24",border:"1px solid rgba(250, 204, 21, 0.3)"},children:"Cortesia única"}),y>0&&c.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-teal-300/90 font-medium","data-testid":"text-courtesy-hours-remaining",children:[c.jsx(o
195x,{className:"w-3 h-3"}),c.jsxs("span",{children:[c.jsxs("strong",{children:[y,"h"]})," restantes"]})]})]})]})]}),c.jsx("button",{onClick:()=>!d&&o(!1),disabled:d,className:"shrink-0 w-8 h-8 flex items-center justify-center rounded-lg text-slate-400 hover:text-white hover:bg-white/5 transition-colors disabled:opacity-40","aria-label":"Fechar","data-testid":"button-courtesy-modal-close",children:c.jsx(nn,{className:"w-5 h-5"})})]})}),c.jsxs("div",{className:"relative px-6 py-5 space-y-4",children:[c.jsxs("p",{className:"text-[15px] text-slate-200 leading-relaxed",children:["Vamos reescrever ",c.jsx("strong",{className:"text-white",children:"todos os capÃtulos"})," do zero usando seus materiais e o que você ajustar abaixo. ",c.jsx("span",{className:"text-slate-400",children:"Esta cortesia só pode ser usada uma vez por livro."})]}),(k>0||C>=500)&&c.jsxs("div",{className:"flex flex-wrap gap-2",children:[k>0&&c.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs",style:{background:"rgba(20, 184, 166, 0.1)",border:"1px solid rgba(20, 184, 166, 0.25)",color:"#5eead4"},"data-testid":"chip-courtesy-kb",children:[c.jsx(it,{className:"w-3.5 h-3.5"}),c.jsxs("span",{children:[c.jsx("strong",{children:k})," ",k===1?"material":"materiais"," na Base de Conhecimento"]})]}),C>=500&&c.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs",style:{background:"rgba(20, 184, 166, 0.1)",border:"1px solid rgba(20, 184, 166, 0.25)",color:"#5eead4"},"data-testid":"chip-courtesy-briefing",children:[c.jsx(it,{className:"w-3.5 h-3.5"}),c.jsx("span",{children:"Briefing completo"})]})]}),c.jsxs("div",{children:[c.jsxs("label",{htmlFor:"courtesy-feedback",className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"text-xs font-semibold text-slate-300 uppercase tracking-wider",children:"O que poderia ficar melhor?"}),j?c.jsx("span",{className:"text-[10px] font-bold text-amber-400",children:"obrigatório â mÃn. 80 caracteres"}):c.jsx("span",{className:"text-[10px] text-slate-500",children:"opcional"})]}),c.jsx("textarea",{id:"courtesy-feedback",value:a,onChange:S=>l(S.target.value),placeholder:"Ex: o tom ficou mais formal do que eu queria, faltou desenvolver a personagem da Clarice, gostaria de mais diálogo...",maxLength:2e3,rows:5,className:"w-full px-4 py-3 rounded-xl text-sm text-white placeholder:text-slate-500 resize-none transition-all focus:outline-none",style:{background:"rgba(2, 6, 23, 0.6)",border:"1px solid rgba(148, 163, 184, 0.2)",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.4)"},onFocus:S=>{S.currentTarget.style.borderColor="rgba(20, 184, 166, 0.6)",S.currentTarget.style.boxShadow="inset 0 1px 2px rgba(0,0,0,0.4), 0 0 0 3px rgba(20, 184, 166, 0.15)"},onBlur:S=>{S.currentTarget.style.borderColor="rgba(148, 163, 184, 0.2)",S.currentTarget.style.boxShadow="inset 0 1px 2px rgba(0,0,0,0.4)"},"data-testid":"textarea-courtesy-feedback"}),c.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[c.jsx("span",{className:"text-[11px] text-slate-500",children:j?"Seu briefing foi curto â descreva o que não ficou bom pra guiarmos a nova versão.":"Quanto mais detalhes, melhor a regeneração."}),c.jsxs("span",{className:`text-[11px] tabular-nums ${j&&a.trim().length<80?"text-amber-400":"text-slate-500"}`,children:[a.length,"/2000"]})]})]}),c.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2.5 rounded-lg",style:{background:"rgba(245, 158, 11, 0.08)",border:"1px solid rgba(245, 158, 11, 0.2)"},children:[c.jsx(vi,{className:"w-4 h-4 text-amber-400 shrink-0 mt-0.5"}),c.jsxs("p",{className:"text-[12px] text-amber-200/90 leading-relaxed",children:["Os capÃtulos atuais serão ",c.jsx("strong",{children:"substituÃdos"}),". Se quiser preservar trechos editados manualmente, copie-os antes de iniciar."]})]})]}),c.jsxs("div",{className:"relative px-6 pb-6 pt-2 flex flex-col-reverse sm:flex-row gap-3",children:[c.jsx("button",{onClick:()=>o(!1),disabled:d,className:"flex-1 sm:flex-none sm:px-6 py-3 text-sm font-semibold rounded-xl text-slate-300 hover:text-white hover:bg-white/5 transition-colors disabled:opacity-40","data-testid":"button-courtesy-cancel",children:"Cancelar"}),c.jsxs("button",{onClick:O,disabled:d,className:"flex-1 relative inline-flex items-center justify-center gap-2 px-6 py-3 text-sm font-bold rounded-xl text-white transition-all disabled:opacity-70 disabled:cursor-not-allowed group overflow-hidden",style:{background:"linear-gradient(135deg, #14b8a6 0%, #0891b2 100%)",boxShadow:"0 10px 30px -8px rgba(20, 184, 166, 0.55), inset 0 1px 0 rgba(255,255,255,0.2)"},"data-testid":"button-courtesy-confirm",children:[c.jsx("span",{className:"absolute inset-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{background:"linear-gradient(135deg, #0d9488 0%, #0e7490 100%)"}}),c.jsx("span",{className:"relative inline-flex items-center gap-2",children:d?c.jsxs(c.Fragment,{children:[c.jsx(ge,{className:"w-4 h-4 animate-spin"}),"Iniciando regeneraçãoâ¦"]}):c.jsxs(c.Fragment,{children:[c.jsx(oe,{className:"w-4 h-4"}),"Regenerar agora â grátis"]})})]})]})]})})})]})}function Dj(){const{t}=ho("editor"),[,e]=sd("/book/:id/editor"),[,n]=sd("/book/:id"),r=e?.id||n?.id,[s,i]=v.useState("planning"),[o,a]=v.useState([]),[l,d]=v.useState(120),u=Kn(),[h,p]=v.useState(!1),[f,m]=v.useState(null),[g,b]=v.useState(null),[y,k]=v.useState(!1),[C,j]=v.useState(!1),[O,S]=v.useState(!1),[N,P]=v.useState(!1),[D,L]=v.useState("pix"),[J,Ee]=v.useState(null),[le,ce]=v.useState(null),[ne,X]=v.useState(!0),[Nr,Mt]=v.useState(!1),[Nc,Mo]=v.useState(!1),[Sr,Et]=v.useState("saved"),[bn,Sc]=v.useState(!1),Cc=Gm(),[jc,Tc]=v.useState(()=>{try{return!zt.getItem("sabhia_edit_hint_dismissed")}catch{return!0}}),[Eo,Ao]=v.useState(null),Xe=v.useRef(new Set),[Qm,Mc]=v.useState(!1),[Ym,Cr]=v.useState(!1);v.useEffect(()=>{Xx();const x=T=>{if(r)try{vd(r,Xe.current)}catch{}if(Sr!=="saved")return T.preventDefault(),T.returnValue="",""},w=()=>
195{if(r)try{vd(r,Xe.current)}catch{}};return window.addEventListener("beforeunload",x),window.addEventListener("pagehide",w),()=>{window.removeEventListener("beforeunload",x),window.removeEventListener("pagehide",w)}},[Sr,r]);const[Ms,Ec]=v.useState(!1),[jr,Ac]=v.useState(!1),[yn,Kt]=v.useState(""),[Oo,Io]=v.useState(""),[Xm,Jn]=v.useState(""),Oc=v.useRef(null),[Po,vC]=v.useState(null),[wC,Zm]=v.useState(""),[kC,eg]=v.useState(null),[pe,Es]=v.useState({}),[tg,At]=v.useState(null),[As,Gn]=v.useState(""),[vn,Wt]=v.useState(!1),[Ro,Os]=v.useState(0),[ng,Is]=v.useState([]),[Ps,Rs]=v.useState([]),[Do,Ic]=v.useState(!1),[wn,Lo]=v.useState([""]),[Pc,rg]=v.useState(10),[Ds,zo]=v.useState(null),[sg,Rc]=v.useState(!1),[kn,NC]=v.useState(null),[Dc,Bo]=v.useState(!1),[Lc,$o]=v.useState(!1),ct=v.useRef(null),dt=v.useRef(null),_e=v.useRef(null),Ls=v.useRef(null),gt=v.useRef({});v.useCallback(x=>{const w=gt.current[x];w&&w.scrollIntoView({behavior:"smooth",block:"center"})},[]),v.useEffect(()=>()=>{ct.current&&clearInterval(ct.current),dt.current&&clearInterval(dt.current)},[]);const{data:M,isLoading:ig}=Ce({queryKey:[`/api/books/${r}`],enabled:!!r,refetchInterval:x=>x.state.data?.status==="generating"?1e4:!1,select:x=>({...x,chapters:(x.chapters||[]).filter(w=>!Xe.current.has(String(w.id)))})}),Ze=v.useMemo(()=>bx(M?.language),[M?.language]),{data:og}=Ce({queryKey:["/api/services"]}),{data:zc}=Ce({queryKey:["/api/settings/book_generation_price"]}),{data:Ue}=Ce({queryKey:[`/api/books/${r}/sources`],enabled:!!r}),{data:_o,refetch:ag}=Ce({queryKey:[`/api/books/${r}/covers`],enabled:!!r}),{data:Ho,refetch:lg}=Ce({queryKey:[`/api/books/${r}/translations`],enabled:!!r}),{data:zs}=Ce({queryKey:[`/api/books/${r}/illustrations`],enabled:!!r}),{data:Bc}=Ce({queryKey:["/api/orders"]}),{data:et,isLoading:SC,refetch:Fo}=Ce({queryKey:[`/api/books/${r}/plan`],enabled:!!r,refetchInterval:x=>{const w=x.state.data;return w?.planStatus==="generating"?3e3:w&&!w.planData?.chapters&&w.planStatus!=="ready"?5e3:!1}}),Tr=Ae({mutationFn:async()=>(await G("POST",`/api/books/${r}/plan`)).json(),onSuccess:()=>{H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]}),H.invalidateQueries({queryKey:[`/api/books/${r}`]})},onError:()=>{H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]})}}),Bs=et?.planData||null,V=Bs?{...Bs,centralThemes:Array.isArray(Bs.centralThemes)?Bs.centralThemes.flat().filter(x=>typeof x=="string"&&x.trim()):[]}:null,Je=et?.planStatus||"none",$c=[`/api/books/${r}/plan-whatsapp-gate`],{data:Vo,isPending:_c,isError:Hc,refetch:cg}=Ce({queryKey:$c,enabled:!!r&&Je==="ready"&&et?.whatsappGateRequired===!0,retry:!1}),$s=Ae({mutationFn:async x=>(await G("POST",`/api/books/${r}/plan-whatsapp-gate`,{phone:x})).json(),onSuccess:async()=>{await Fo(),H.setQueryData($c,{gateRequired:!1,planReady:!0}),H.invalidateQueries({queryKey:["/api/auth/user"]}),de({title:"Planejamento liberado",description:"Seu WhatsApp foi salvo e a entrega já foi registrada."})}}),Qn=Je==="ready"&&et?.whatsappGateRequired===!0&&(_c||Hc||Vo?.gateRequired!==!1);v.useEffect(()=>{Je==="ready"&&et?.whatsappGateRequired===!0&&Vo?.gateRequired===!1&&Fo()},[Je,et?.whatsappGateRequired,Vo?.gateRequired,Fo]),v.useEffect(()=>{Ls.current&&(Ls.current.inert=Qn)},[Qn,V]);const{data:CC}=Ce({queryKey:[`/api/books/${r}/plan-versions`],enabled:!!r&&!!et?.planData});v.useEffect(()=>{if(!r||!V?.chapters?.length)return;const x=`sabhia_ga_plan_generated_${r}`;if(!zt.getItem(x)){try{Yg(Number(r),V.chapters.length)}catch{}zt.setItem(x,"1")}},[r,V]),Ae({mutationFn:async x=>{await G("POST",`/api/books/${r}/plan-versions/${x}/restore`)},onSuccess:()=>{H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]}),H.invalidateQueries({queryKey:[`/api/books/${r}/plan-versions`]}),eg(null)}});const qo=M?.chapters?.filter(x=>x.content&&x.content.length>200)||[];M?.chapters?.filter(x=>!x.content||x.content.length<=200);const _s=M?.chapters?.length||0,Hs=_s>0&&qo.length>=_s,dg=M?.status==="needs_review"&&M?.generationQuality?.editorialProviderBlock?.retryable===!0&&!M?.planDeviationDetected,W=(M?.status==="generating"||dg)&&!Hs,{data:ug}=Ce({queryKey:[`/api/books/${r}/generation-events`],enabled:!!r&&W}),Fc=Math.max(0,M?.updatedAt?new Date(M.updatedAt).getTime():0,M?.generationProgressAt?new Date(M.generationProgressAt).getTime():0,...(ug||[]).map(x=>x?.createdAt?new Date(x.createdAt).getTime():0)),Mr=W&&Fc>0&&Date.now()-Fc>600*1e3,hg=M?.chapters&&M.chapters.length>0&&qo.length===0,He=qo.length>0,xt=!!M?.isPaid&&!!hg&&!W;v.useEffect(()=>{Hs&&M&&(M.status==="generating"||M.status==="error")&&fetch(`/api/books/${M.id}/generate`,{method:"POST",credentials:"include"}).then(x=>x.json()).then(()=>{H.invalidateQueries({queryKey:[`/api/books/${r}`]})}).catch(()=>{})},[Hs,M?.status,M?.id]);const[pg,Fs]=v.useState(!1);v.useEffect(()=>{if(!r||!M)return;if(M.progress===100&&He&&!W&&M.isPaid){const w=`sabhia_ga_manuscript_complete_${r}`;if(!zt.getItem(w)){const T=M.chapters?.reduce((A,_)=>A+(_.content?.split(/\s+/).length||0),0)||0;try{Xg(Number(r),T)}catch{}try{Zg(r,M.title||"",T)}catch{}zt.setItem(w,"1")}}},[r,M,He,W]);const{data:Ko}=Ce({queryKey:[`/api/books/${r}/progress`],enabled:!!r&&!!W,refetchInterval:W?3e3:!1}
195),Vc=W&&Ko&&Ko.writtenChaptersCount===0&&(Ko.progress||0)>30,{data:Vs}=Ce({queryKey:[`/api/books/${r}/messages`],enabled:!!r}),fg=Ae({mutationFn:async x=>(await G("POST",`/api/books/${r}/messages`,{content:x})).json()});Ae({mutationFn:async({id:x,content:w})=>Xe.current.has(x)?null:(await G("PATCH",`/api/chapters/${x}`,{content:w})).json(),onSuccess:(x,w)=>{Xe.current.has(w.id)||H.invalidateQueries({queryKey:[`/api/books/${r}`]})}});const Wo=Ae({mutationFn:async x=>{await G("DELETE",`/api/chapters/${x}`)},onMutate:async x=>{Xe.current.add(x),Ao(null),Et("saved"),await H.cancelQueries({queryKey:[`/api/books/${r}`],exact:!0});const w=H.getQueryData([`/api/books/${r}`]);return H.setQueryData([`/api/books/${r}`],T=>T&&{...T,chapters:(T.chapters||[]).filter(A=>String(A.id)!==x)}),{chapterId:x,previous:w}},onSuccess:(x,w,T)=>{if(!(!T||!Xe.current.has(T.chapterId))){for(const A of["title","content","summary"])Ns(r,`chapter:${T.chapterId}:${A}`);de({title:"CapÃtulo excluÃdo",description:"O capÃtulo foi removido do seu livro."})}},onError:(x,w,T)=>{T&&(Xe.current.delete(T.chapterId),T.previous&&H.setQueryData([`/api/books/${r}`],{...T.previous,chapters:(T.previous.chapters||[]).filter(A=>!Xe.current.has(String(A.id)))}),de({title:"Erro",description:"Não foi possÃvel excluir o capÃtulo.",variant:"destructive"}))},onSettled:async(x,w,T,A)=>{A&&(await H.refetchQueries({queryKey:[`/api/books/${r}`],exact:!0}),H.setQueryData([`/api/books/${r}`],_=>_&&{..._,chapters:(_.chapters||[]).filter(ye=>!Xe.current.has(String(ye.id)))}))}}),[mg,Uo]=v.useState(!1),Jo=Ae({mutationFn:async()=>{await G("DELETE",`/api/books/${r}`)},onSuccess:()=>{H.invalidateQueries({queryKey:["/api/books"]}),de({title:"Livro excluÃdo",description:"O livro foi removido com sucesso."}),Yn("/dashboard")},onError:()=>{de({title:"Erro",description:"Não foi possÃvel excluir o livro.",variant:"destructive"})}}),qc=Ae({mutationFn:async({swaps:x})=>{await Promise.all(x.map(w=>G("PATCH",`/api/chapters/${w.id}`,{orderIndex:w.newIndex})))},onSuccess:()=>{H.invalidateQueries({queryKey:[`/api/books/${r}`]})}}),Kc=Ae({mutationFn:async x=>(await G("POST",`/api/books/${r}/chapters`,{title:"Novo CapÃtulo",summary:"",content:"",orderIndex:x})).json(),onSuccess:()=>{H.invalidateQueries({queryKey:[`/api/books/${r}`]}),de({title:"CapÃtulo adicionado",description:"Um novo capÃtulo foi adicionado ao seu livro."})}}),Wc=async()=>{try{const x=await fetch(`/api/books/${r}/recover-delivery`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}}),w=await x.json().catch(()=>({}));return{...w,status:x.status,ok:x.ok&&w?.ok!==!1}}catch(x){return{ok:!1,message:x?.message||"Falha de rede"}}},tt=Ae({mutationFn:async()=>{try{return{...await(await G("POST",`/api/books/${r}/generate`,{humanUnlock:!0})).json(),source:"generate"}}catch(x){const w=await Wc();if(!w.ok)throw new Error(w.message||x?.message?.replace(/^\d+:\s*/,"")||"Não foi possÃvel iniciar a geração");return{recovery:w,recoveredViaFallback:!0,source:"recovery"}}},onSuccess:x=>{H.invalidateQueries({queryKey:[`/api/books/${r}`]});try{ix(Number(r))}catch{}x?.recoveredViaFallback?de({title:"Verificando seu pedido",description:"Identificamos que a geração estava travada e já demos o próximo passo automaticamente. Recarregue em alguns instantes."}):x?.status==="writing"?de({title:"Livro pronto",description:x.message||"Todos os capÃtulos já foram escritos."}):de({title:"Geração iniciada",description:"A SÃBHIA está escrevendo seu livro. Acompanhe o progresso aqui."})},onError:x=>{de({title:"Não conseguimos iniciar agora",description:x?.message||"Tente novamente em alguns instantes. Se persistir, fale com a SÃBHIA pelo chat.",variant:"destructive"})}}),Go=Ae({mutationFn:async()=>{const x=await Wc();if(!x.ok)throw new Error(x.message||(x.needsAdmin?"Acionamos a equipe â você receberá retorno em breve.":"Não foi possÃvel concluir a verificação automática agora."));return x},onSuccess:x=>{H.invalidateQueries({queryKey:[`/api/books/${r}`]});const w=(x?.results||[]).flatMap(A=>A.actions||[]),T=w.length>0?`Já tomamos as próximas ações: ${w.slice(0,3).join(", ")}. Recarregue em alguns instantes.`:"Seu pedido já está OK ou em andamento â recarregue em alguns instantes.";de({title:"Verificação concluÃda",description:T})},onError:x=>{de({title:"Não foi possÃvel verificar agora",description:x?.message||"Tente novamente em 30 segundos.",variant:"destructive"})}}),Qo=Ae({mutationFn:async()=>
195{if(!Q||!Q.premise)return;const x={...Q,centralThemes:Array.isArray(Q.centralThemes)?Q.centralThemes:[],characters:Array.isArray(Q.characters)?Q.characters:[],chapters:Array.isArray(Q.chapters)?Q.chapters:[],researchNotes:Array.isArray(Q.researchNotes)?Q.researchNotes:[],generatedAt:new Date().toISOString()};await G("PATCH",`/api/books/${r}`,{title:Jc||bt,author:Gc,planData:x})},onSuccess:()=>{H.invalidateQueries({queryKey:[`/api/books/${r}`]}),H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]}),H.invalidateQueries({queryKey:[`/api/books/${r}/plan-versions`]}),Yo(!1),Ne(null)}}),qs=Ae({mutationFn:async x=>(await G("POST",`/api/books/${r}/chapter-outline`,x)).json(),onSuccess:x=>{zo(x)}}),gg=async()=>{if(!Ds)return;const w={...V||{},chapters:Ds};await G("PATCH",`/api/books/${r}`,{planData:w}),H.invalidateQueries({queryKey:[`/api/books/${r}`]}),H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]}),zo(null),Ic(!1)},xg=()=>{V&&(Ne({...V,centralThemes:Array.isArray(V.centralThemes)?[...V.centralThemes]:[],characters:Array.isArray(V.characters)?V.characters.map(x=>({...x})):[],chapters:Array.isArray(V.chapters)?V.chapters.map(x=>({...x})):[],researchNotes:Array.isArray(V.researchNotes)?[...V.researchNotes]:[]}),Xo(bt),Zo(M?.author||""),Yo(!0))},bg=()=>{Yo(!1),Ne(null),Xo(""),Zo("")},Uc=ex(),[,Yn]=Ah();v.useEffect(()=>{const x=new URLSearchParams(Uc);x.get("import")==="true"&&(Cr(!0),Yn(`/book/${r}`,{replace:!0}));const w=x.get("payment"),T=x.get("orderId");w==="success"&&T&&(G("GET",`/api/stripe/verify-session?orderId=${T}`).then(A=>A.json()).then(A=>{if(A.paid){H.invalidateQueries({queryKey:[`/api/books/${r}`]}),i("writing");try{tx(async()=>{const{gaPurchase:_}=await import("./index-CFAvyuXu.js").then(ye=>ye.fJ);return{gaPurchase:_}},__vite__mapDeps([0,1,2,3,4])).then(({gaPurchase:_})=>{_(T,A.serviceName||"Serviço SÃBHIA",(A.amount||0)/100)})}catch{}setTimeout(()=>{window.scrollTo({top:0,behavior:"smooth"})},100)}}).catch(()=>{}),Yn(`/book/${r}`,{replace:!0}))},[Uc,r,Yn]),v.useEffect(()=>{W&&(i("writing"),X(!0),setTimeout(()=>{window.scrollTo({top:0,behavior:"smooth"})},100))},[W]);const[fe,Yo]=v.useState(!1),[Q,Ne]=v.useState(null),[Jc,Xo]=v.useState(""),[Gc,Zo]=v.useState(""),bt=M?.title||t("loading"),yg=!!(Bc&&Bc.some(x=>x.bookId===r&&(x.status==="confirmed"||x.status==="completed")&&(x.type==="book_generation"||x.type==="book_and_cover"||x.type==="publish_bundle"||x.type==="apice_automated_v1"))),qe=M?.isPaid||yg;v.useEffect(()=>{qe&&!W&&s==="planning"&&i("writing")},[qe,He,W]);const Ut=M?.status==="completed"&&Array.isArray(M?.chapters)&&M.chapters.length>0,[Qc,vg]=v.useState(!1);v.useEffect(()=>{Ut&&!Qc&&s==="planning"&&!W&&(i("writing"),vg(!0))},[Ut,Qc,s,W]);const wg=M?.chapters?.map(x=>({id:x.id,title:x.title,summary:x.summary||""}))||[],ea=zc?.value?parseFloat(zc.value):49.99,Xn=vn||Tr.isPending||Je==="generating",Yc=300*1e3,[Zn,Xc]=v.useState(null);v.useEffect(()=>{if(Je==="generating"&&!vn&&!Tr.isPending){if(!Zn){const x=et?.updatedAt?new Date(et.updatedAt).getTime():0,w=x?Date.now()-x:0;Xc(w>Yc?1:Date.now())}}else Zn&&Xc(null)},[Je,vn,Tr.isPending,et?.updatedAt]);const[jC,kg]=v.useState(0);v.useEffect(()=>{if(!Zn)return;const x=setInterval(()=>kg(w=>w+1),1e4);return()=>clearInterval(x)},[Zn]);const Zc=!!(Zn&&Date.now()-Zn>Yc),Ks=Ae({mutationFn:async()=>{const x=await fetch(`/api/books/${r}/plan/reset`,{method:"POST",credentials:"include"});if(!x.ok)throw new Error("Erro ao resetar");return x.json()},onSuccess:()=>{H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]}),H.invalidateQueries({queryKey:[`/api/books/${r}`]})}}),Er=v.useCallback(()=>{_e.current&&_e.current.close(),Es({}),Rs([]),Is([]),At(null),Gn(""),Os(0),Wt(!0);const x=new EventSource(`/api/books/${r}/plan/stream`);_e.current=x;let w=!1,T=!1;const A=()=>{if(T)return;T=!0,x.close(),_e.current=null,Wt(!1),Tr.mutate();const ye=setInterval(()=>{H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]}),H.invalidateQueries({queryKey:[`/api/books/${r}/plan-versions`]})},4e3);setTimeout(()=>clearInterval(ye),12e4)},_=setTimeout(()=>{!w&&_e.current===x&&A()},3e4);x.onmessage=ye=>{w=!0,clearTimeout(_);try{const Se=JSON.parse(ye.data);switch(Se.type){case"connected":break;case"phase":At(Se.phase),Gn(Se.message);break;case"progress":Os(Se.chars);break;case"section":Se.key==="chapter"?Rs(ut=>[...ut,Se.data]):Es(ut=>({...ut,[Se.key]:Se.data})),Is(ut=>[...ut,Se.key==="chapter"?`chapter-${Se.data.number}`:Se.key]);break;case"done":x.close(),_e.current=null,Wt(!1),At(null),H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]}),H.invalidateQueries({queryKey:[`/api/books/${r}/plan-versions`]});break;case"error":x.close(),_e.current=null,Wt(!1),At(null),H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]});break}}catch{}},x.onerror=()=>{clearTimeout(_),A()}},[r,Tr]),Ng=v.useCallback(x=>{_e.current&&_e.current.close(),Wt(!0),At("analyzing"),Gn(t("planning.incorporatingChanges")),Es({}),Os(0),Is([]),Rs([]),i("planning");const w=`/api/books/${r}/plan/regenerate?editInstructions=${encodeURIComponent(x)}`,T=new EventSource(w);_e.current=T,T.onmessage=A=>{try{const _=JSON.parse(A.data);switch(_.type){case"connected":break;case"phase":At(_.phase),Gn(_.message||t("planning.regenerating"));break;case"progress":Os(_.chars);break;case"section":_.key==="chapter"?Rs(ye=>[...ye,_.data]):Es(ye=>({...ye,[_.key]:_.data})),Is(ye=>[...ye,_.key==="chapter"?`chapter-${_.data.number}`:_.key]);break;case"done":Wt(!1),At(null),Gn(""),H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]}),H.invalidateQueries({queryKey:[`/api/books/${r}`]}),H.invalidateQueries({queryKey:[`/api/books/${r}/plan-versions`]}),T.close(),_e.current=null;break;case"error":Wt(!1),At(null),Gn(""),T.close(),_e.current=null;break}}catch{}},T.onerror=()=>{Wt(!1),At(null),T.close(),_e.current=null,H.invalidateQueries({queryKey:[`/api/books/${r}/plan`]}),H.invalidateQueries({queryKey:[`/api/books/${r}/plan-versions`]})}},[r]),Sg=v.useCallback(()=>{Ks.mutate(void 0,{onSuccess:()=>{setTimeout(()=>{Er()},500)}})},[Ks,Er]);v.useEffect(()=>()=>{_e.current&&_e.current.close()},[]),v.useEffect(()=>{vn&&setTimeout(()=>{window.scrollTo({top:document.documentElement.scrollHeight,behavior:"smooth"})},100)},[ng,Ps.length,vn]),(og||[]).map(x=>
195({id:x.id,title:x.title,description:x.description||"",price:x.type==="cover_ebook"?Nt.cover:x.type==="illustration"||x.type==="illustration_pack"?Nt.illustration.tier3.pricePerImage:x.type==="translation"||x.type==="translation_en"||x.type==="translation_es"?Nt.translation.single:x.type==="audiobook"?Nt.audiobook:x.type==="publication_prep"?Nt.publication_prep:x.type==="marketing_content"?Nt.marketing.post:x.price,type:x.type,icon:fC[x.iconName||"Palette"]||wi,recurring:x.recurring||!1,status:"available"}));const[ta,er]=v.useState([]),[ed,Cg]=v.useState(!1),[Nn,na]=v.useState(""),[ra,sa]=v.useState(!1),[td,jg]=v.useState(!1),Ws=v.useRef(null),Us=v.useRef(null);v.useEffect(()=>{if(Vs&&!ed&&M)if(Cg(!0),Vs.length>0)er(Vs.map(x=>({id:x.id,role:x.role,content:x.content,timestamp:new Date(x.createdAt),agentLogs:x.agentLogs})));else{const x=Ue&&Ue.length>0,w=Je==="generating"||!V&&x;let T;x&&w?T=t("welcome.messageWithSourcesGenerating",{title:M.title||t("welcome.yourBook")}):x?T=t("welcome.messageWithSources",{title:M.title||t("welcome.yourBook")}):T=t("welcome.message"),er([{id:"welcome",role:"ai",content:T,timestamp:new Date}])}},[Vs,ed,M,Ue,V,Je]),v.useEffect(()=>{Ws.current&&(Ws.current.scrollTop=Ws.current.scrollHeight),Us.current&&(Us.current.scrollTop=Us.current.scrollHeight)},[ta,ra]),v.useEffect(()=>{const x=V&&!V.chapters,w=!V||x,T=M?.status==="completed"||Je==="approved"||Array.isArray(M?.chapters)&&M.chapters.length>0;r&&!td&&et&&w&&Je!=="generating"&&!T&&(jg(!0),Er())},[r,et,V,Je,Ue,td,M?.status,M?.chapters]),v.useEffect(()=>{if(Po&&M?.chapters){const x=M.chapters.find(w=>String(w.id)===String(Po));x&&Zm(x.content||"")}},[Po,M?.chapters]);const Js=async()=>{if(!Nn.trim()||!r)return;const x={id:Date.now().toString(),role:"user",content:Nn,timestamp:new Date},w=Nn;er(T=>[...T,x]),na(""),sa(!0);try{const T=await fg.mutateAsync(w);sa(!1);const A=T.aiResponse.agentLogs;er(_=>[..._,{id:T.aiResponse.id,role:"ai",content:T.aiResponse.content,timestamp:new Date(T.aiResponse.createdAt),agentLogs:A}]),T.shouldRegeneratePlan&&T.editSummary&&setTimeout(()=>{er(_=>[..._,{id:`system-${Date.now()}`,role:"ai",content:t("chat.regeneratingPlanMessage"),timestamp:new Date,agentLogs:[{agent:"Arquitetura",message:t("planning.regeneratingWithChanges"),status:"done"}]}]),Ng(T.editSummary)},1e3)}catch{sa(!1),er(T=>[...T,{id:Date.now().toString(),role:"ai",content:t("errors.tryAgain"),timestamp:new Date}])}},ia=()=>{P(!0)},Tg=x=>{P(!1),H.invalidateQueries({queryKey:[`/api/books/${r}`]}),H.invalidateQueries({queryKey:["/api/orders"]})},Mg=async x=>{S(!1),H.invalidateQueries({queryKey:[`/api/books/${r}`]}),H.invalidateQueries({queryKey:["/api/orders"]})},{toast:de}=ws(),Eg=async x=>{Rc(!1),kn&&(a(w=>[...w,kn.id]),kn.type==="cover_ebook"?(Bo(!0),ct.current&&clearInterval(ct.current),ct.current=setInterval(async()=>{try{const w=await fetch(`/api/books/${r}/covers`,{credentials:"include"});if(!w.ok)return;const T=await w.json();T&&T.length>0&&(ct.current&&clearInterval(ct.current),ct.current=null,Bo(!1),ag())}catch{}},5e3),setTimeout(()=>{ct.current&&(clearInterval(ct.current),ct.current=null),Bo(!1)},12e4)):(kn.type==="translation_en"||kn.type==="translation_es")&&($o(!0),dt.current&&clearInterval(dt.current),dt.current=setInterval(async()=>{try{const w=await fetch(`/api/books/${r}/translations`,{credentials:"include"});if(!w.ok)return;const T=await w.json();T&&T.some(A=>A.status==="completed")&&(dt.current&&clearInterval(dt.current),dt.current=null,$o(!1),lg())}catch{}},1e4),setTimeout(()=>{dt.current&&(clearInterval(dt.current),dt.current=null),$o(!1)},3e5)),de({title:t("service.paymentConfirmed"),description:t("service.processingByAI",{title:kn.title})}))},{user:oa,logout:TC}=nx(),[MC,EC]=v.useState(!1);oa?.name?oa.name.split(" ").map(x=>x[0]).join("").slice(0,2).toUpperCase():oa?.email?.slice(0,2).toUpperCase(),t("tabs.planning"),t(qe?"tabs.written":"tabs.writing"),Ir,t("tabs.publication"),Ih,(_o||[]).find(x=>x.selected),_o&&_o.length>0,Ho&&Ho.length>0,(Ho||[]).length,zs&&zs.length>0,(zs||[]).filter(x=>x.status==="completed").length;const aa=(zs||[]).filter(x=>x.status==="safety_blocked").length,Ag=async x=>{if(!(await fetch(`/api/books/${r}/select-cover`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({coverId:x})})).ok)throw new Error(t("service.coverSelectError"));de({title:t("service.coverSelected")})}
195,Og=async x=>{if(!(await fetch(`/api/books/${r}/select-cover`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({coverId:x})})).ok)throw new Error(t("service.coverSelectError"));de({title:t("service.coverSelected"),description:t("service.coverSelectedDescription")})};if(ig)return c.jsx(id,{children:c.jsx("div",{className:"min-h-screen flex items-center justify-center",children:c.jsx(ge,{className:"w-8 h-8 text-primary animate-spin"})})});const nd=!qe&&!W&&Je==="ready"&&M?.status!=="completed";return c.jsxs(id,{children:[c.jsxs("div",{className:"min-h-screen lg:pr-[316px]",children:[c.jsx("div",{className:"sticky top-0 z-40 border-b border-white/5 bg-background/80 backdrop-blur-xl",children:c.jsxs("div",{className:"max-w-6xl mx-auto px-4 md:px-6 h-14 flex items-center justify-between",children:[c.jsxs("button",{onClick:()=>Yn(`/book/${r}`),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-white transition-colors","data-testid":"link-back-dashboard",children:[c.jsx(Cx,{className:"w-4 h-4"}),c.jsx("span",{className:"hidden sm:inline",children:t("backToDashboard")}),c.jsx("span",{className:"sm:hidden",children:t("back")})]}),c.jsx("h1",{className:"text-sm font-medium text-white truncate max-w-[200px] md:max-w-md text-center","data-testid":"text-book-title",children:bt}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[c.jsxs(ar,{className:"bg-primary/20 text-primary border-primary/20 hover:bg-primary/20 text-xs",children:[c.jsx(tn,{className:"w-3 h-3 mr-1"}),t(qe?He?"bookStatus.written":"bookStatus.generating":"bookStatus.planning")]}),c.jsx("button",{onClick:()=>Uo(!0),className:"p-1.5 rounded-lg text-muted-foreground/40 hover:text-red-400 hover:bg-red-500/10 transition-all",title:"Apagar livro","data-testid":"button-delete-book",children:c.jsx(jn,{className:"w-4 h-4"})})]})]})}),Hs&&M?.isPaid&&c.jsx("div",{className:"max-w-6xl mx-auto px-4 md:px-6 mt-3","data-testid":"banner-book-ready",children:c.jsxs("div",{className:"rounded-xl border border-emerald-400/30 bg-gradient-to-r from-emerald-500/10 to-teal-500/10 p-4 flex items-start gap-3",children:[c.jsx(Mn,{className:"w-5 h-5 text-emerald-300 shrink-0 mt-0.5"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-sm font-semibold text-emerald-100",children:"â
Seu livro está pronto pra baixar"}),c.jsxs("div",{className:"text-xs text-emerald-100/70 mt-0.5",children:["Todos os ",_s," capÃtulos foram escritos. Baixe agora nos formatos abaixo."]})]}),c.jsxs("div",{className:"flex flex-wrap gap-1.5 shrink-0",children:[c.jsx("button",{onClick:()=>{rr(r,"pdf").catch(x=>de({title:"Download indisponÃvel",description:x.message,variant:"destructive"}));try{tr(parseInt(r||"0"),"pdf")}catch{}},className:"text-xs px-3 py-1.5 rounded-md bg-emerald-500/20 hover:bg-emerald-500/30 text-emerald-100 border border-emerald-400/30 font-medium","data-testid":"button-banner-download-pdf",children:"PDF"}),c.jsx("button",{onClick:()=>{rr(r,"docx").catch(x=>de({title:"Download indisponÃvel",description:x.message,variant:"destructive"}));try{tr(parseInt(r||"0"),"docx")}catch{}},className:"text-xs px-3 py-1.5 rounded-md bg-emerald-500/20 hover:bg-emerald-500/30 text-emerald-100 border border-emerald-400/30 font-medium","data-testid":"button-banner-download-docx",children:"DOCX"}),c.jsx("button",{onClick:()=>{rr(r,"epub").catch(x=>de({title:"Download indisponÃvel",description:x.message,variant:"destructive"}));try{tr(parseInt(r||"0"),"epub")}catch{}},className:"text-xs px-3 py-1.5 rounded-md bg-emerald-500/20 hover:bg-emerald-500/30 text-emerald-100 border border-emerald-400/30 font-medium","data-testid":"button-banner-download-epub",children:"EPUB"})]})]})}),aa>0&&c.jsx("div",{className:"max-w-6xl mx-auto px-4 md:px-6 mt-3","data-testid":"banner-safety-blocked",children:c.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 flex items-start gap-3",children:[c.jsx(jx,{className:"w-5 h-5 text-amber-400 shrink-0 mt-0.5"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"text-sm font-medium text-amber-200",children:[aa," ",aa===1?"ilustração foi bloqueada":"ilustrações foram bloqueadas"," pelo filtro de segurança"]}),c.jsx("div",{className:"text-xs text-amber-200/80 mt-1",children:"Reescreva as cenas afetadas, sugira uma nova ilustração ou aceite o placeholder no editor de ilustrações."})]}),c.jsx("button",{onClick:()=>Yn(`/illustrator/${r}`),className:"text-xs px-3 py-1.5 rounded-md bg-amber-500/20 hover:bg-amber-500/30 text-amber-100 border border-amber-500/30 shrink-0","data-testid":"button-open-illustrator-safety",children:"Abrir editor"})]})}),!h&&Array.isArray(M?.unclaimedKbUploads)&&M.unclaimedKbUploads.length>0&&c.jsx("div",{className:"max-w-6xl mx-auto px-4 md:px-6 mt-3","data-testid":"banner-unclaimed-kb-upload",children:c.jsxs("div",{className:"rounded-xl border border-primary/30 bg-primary/10 p-4 flex items-start gap-3",children:[c.jsx(Gt,{className:"w-5 h-5 text-primary shrink-0 mt-0.5"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-sm font-semibold text-primary-foreground
195/90",children:M.unclaimedKbUploads.length===1?"Você tem um arquivo enviado ao suporte que ainda não foi anexado a nenhum livro":`Você tem ${M.unclaimedKbUploads.length} arquivos enviados ao suporte que ainda não foram anexados a nenhum livro`}),c.jsx("div",{className:"text-xs text-muted-foreground mt-1 space-y-0.5",children:M.unclaimedKbUploads.map(x=>c.jsxs("div",{className:"truncate",children:["ð ",x.filename]},x.id))}),c.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2.5",children:M.unclaimedKbUploads.map(x=>c.jsxs("button",{disabled:f===x.id,onClick:async()=>{m(x.id);try{const w=await fetch(`/api/support/kb-queue/${x.id}/attach`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({bookId:r})});if(!w.ok){const T=await w.json().catch(()=>({message:""}));throw new Error(T.message||"Erro ao anexar")}b(`"${x.filename}" anexado a este livro`),u.invalidateQueries({queryKey:[`/api/books/${r}`]}),u.invalidateQueries({queryKey:[`/api/books/${r}/sources`]}),setTimeout(()=>b(null),6e3)}catch(w){b(`Falha ao anexar: ${w.message}`),setTimeout(()=>b(null),6e3)}finally{m(null)}},className:"text-xs px-3 py-1.5 rounded-md bg-primary/20 hover:bg-primary/30 text-primary border border-primary/30 font-medium shrink-0 disabled:opacity-50 flex items-center gap-1.5","data-testid":`button-attach-unclaimed-kb-${x.id}`,children:[f===x.id&&c.jsx(ge,{className:"w-3 h-3 animate-spin"}),'Anexar "',x.filename,'" a este livro']},x.id))}),g&&c.jsx("div",{className:"text-xs text-emerald-300 mt-2",children:g})]}),c.jsx("button",{onClick:()=>p(!0),className:"text-muted-foreground/50 hover:text-white shrink-0 p-1",title:"Dispensar","data-testid":"button-dismiss-unclaimed-kb",children:c.jsx(nn,{className:"w-4 h-4"})})]})}),c.jsx("div",{className:"sticky top-14 z-40 border-b border-white/5 bg-background/60 backdrop-blur-lg",children:c.jsx("div",{className:"max-w-6xl mx-auto px-4 md:px-6 flex items-center justify-between h-12",children:c.jsxs("div",{className:"flex bg-white/5 p-1 rounded-lg border border-white/5",children:[c.jsxs("button",{onClick:()=>i("planning"),className:K("px-3 md:px-4 py-1.5 rounded-md text-xs md:text-sm font-medium transition-all flex items-center gap-1.5 whitespace-nowrap",s==="planning"?"bg-white/10 text-white shadow-sm":"text-muted-foreground hover:text-white"),"data-testid":"tab-planning",children:[c.jsx(bd,{className:"w-3.5 h-3.5"}),t("tabs.planning")]}),c.jsxs("button",{onClick:()=>{qe||Ut?(i("writing"),setTimeout(()=>{window.scrollTo({top:0,behavior:"smooth"})},100)):ia()},className:K("px-3 md:px-4 py-1.5 rounded-md text-xs md:text-sm font-medium transition-all flex items-center gap-1.5 whitespace-nowrap",s==="writing"?"bg-primary/20 text-primary shadow-sm":"text-muted-foreground hover:text-white",!qe&&!Ut&&"opacity-90"),"data-testid":"tab-writing",children:[c.jsx(Ir,{className:"w-3.5 h-3.5"}),t(qe||Ut?"tabs.written":"tabs.writing"),!qe&&!Ut&&c.jsx(yi,{className:"w-3 h-3 ml-0.5"})]})]})})}),c.jsx("div",{className:"max-w-6xl mx-auto px-4 md:px-6 py-8",children:c.jsxs("div",{className:"flex gap-8",children:[c.jsxs("div",{className:"flex-1 min-w-0 relative pb-64 md:pb-0",children:[s==="writing"&&He&&!W&&!xt&&c.jsx("div",{className:"hidden xl:block fixed left-[calc(50%-580px)] top-[140px] w-[120px] z-30 overflow-y-auto overscroll-contain",style:{transform:"translateX(-100%)",maxHeight:"calc(100dvh - 140px - env(safe-area-inset-bottom))"},children:c.jsx("div",{className:"space-y-0.5 pr-4",children:[{id:"ms-title",label:t("chapters.cover")},{id:"ms-copyright",label:t("chapters.rights")},{id:"ms-toc",label:t("chapters.summary")},...M?.preface?[{id:"ms-preface",label:t("chapters.preface")}]:[],...M?.acknowledgments?[{id:"ms-acknowledgments",label:t("chapters.acknowledgments")}]:[],...[...M?.chapters||[]].sort((x,w)=>x.orderIndex-w.orderIndex).map((x,w)=>({id:`ms-chapter-${w}`,label:`${t("chapters.chapterShort")} ${w+1}`}))||[],...M?.closingMessage?[{id:"ms-closing",label:t("chapters.author")}]:[],...M?.bibliography?[{id:"ms-bibliography",label:t("chapters.references")}]:[]].map(x=>c.jsx("button",{onClick:()=>{const w=document.getElementById(x.id);w&&w.scrollIntoView({behavior:"smooth",block:"start"})},className:"block w-full text-right px-2 py-1 text-[9px] uppercase tracking-wider opacity-30 hover:opacity-70 transition-opacity text-white/80 font-sans","data-testid":`nav-${x.id}`,children:x.label},x.id))})}),c.jsx("div",{className:"mb-4",children:c.jsx(yC,{bookId:r,isPaid:!!M?.isPaid,courtesyUsed:!!M?.courtesyRegenUsed})}),s==="writing"&&He&&!xt&&!W&&c.jsx(bC,{bookId:r}),c.jsx(Ph,{mode:"wait",children:c.jsxs(se.div,{initial:{opacity:0,rotateX:5,y:20}
195,animate:{opacity:1,rotateX:0,y:0},exit:{opacity:0,rotateX:-5,y:-20},transition:{duration:.5,ease:"easeOut"},className:K("@container relative w-full max-w-[880px] min-h-[600px] md:min-h-[1100px] h-fit shadow-2xl rounded-[2px] mb-20 z-10 mx-auto",s==="planning"?"bg-[#f4f1ea] text-[#333]":s==="writing"&&He&&!xt&&!W?"bg-[#fffcf5] text-gray-900":"bg-transparent shadow-none"),style:s==="planning"||s==="writing"&&He&&!xt&&!W?{boxShadow:"0 4px 6px rgba(0,0,0,0.2), 0 30px 60px -10px rgba(0,0,0,0.6), inset 0 0 40px rgba(0,0,0,0.02)"}:{},children:[(s==="planning"||s==="writing"&&He&&!xt&&!W)&&c.jsx("div",{className:"absolute inset-0 bg-[url('https://www.transparenttextures.com/patterns/paper.png')] opacity-30 mix-blend-multiply pointer-events-none"}),c.jsxs("div",{className:K("min-h-full flex flex-col relative z-20",s==="services"||s==="writing"&&!(He&&!xt&&!W)?"p-0 overflow-visible w-full":"p-4 @sm:px-8 @sm:py-10 @lg:px-12 @lg:py-14 @2xl:px-16 @2xl:py-20 @3xl:px-20 @3xl:py-24"),children:[s==="writing"&&!(He&&!W&&!xt)&&!(W&&!Mr)&&c.jsx("div",{className:"px-4 md:px-8 pt-4 md:pt-6","data-testid":"banner-toolbar-hidden",children:W&&Mr?c.jsxs("div",{className:"flex items-start gap-3 bg-amber-50 border border-amber-200 rounded-lg px-4 py-3","data-testid":"banner-book-generation-stuck",children:[c.jsx(Rt,{className:"w-5 h-5 text-amber-600 shrink-0 mt-0.5"}),c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"A geração parece ter travado"}),c.jsx("p",{className:"text-xs text-amber-800 mt-0.5 mb-2",children:'Seu livro está marcado como "em geração" há mais de 10 minutos sem progresso visÃvel. Isso pode acontecer quando o servidor reinicia. Clique abaixo pra retomar de onde parou â você não precisa pagar nada de novo.'}),c.jsx(Y,{size:"sm",onClick:()=>Go.mutate(),disabled:Go.isPending,className:"h-8 px-3 text-xs bg-amber-600 hover:bg-amber-700 text-white rounded-lg","data-testid":"button-recover-stuck-generation",children:Go.isPending?c.jsxs(c.Fragment,{children:[c.jsx(ge,{className:"w-3 h-3 animate-spin mr-1.5"})," Verificando..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Rt,{className:"w-3 h-3 mr-1.5"})," Retomar geração agora"]})})]})]}):W?null:xt?c.jsxs("div",{className:"flex items-start gap-3 bg-amber-50 border border-amber-200 rounded-lg px-4 py-3","data-testid":"banner-book-needs-generation",children:[c.jsx(Rt,{className:"w-5 h-5 text-amber-600 shrink-0 mt-0.5"}),c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Livro pago, aguardando geração dos capÃtulos"}),c.jsx("p",{className:"text-xs text-amber-800 mt-0.5 mb-2",children:"Seu pagamento foi confirmado, mas os capÃtulos ainda não foram escritos. Clique abaixo pra começarmos agora."}),c.jsx(Y,{size:"sm",onClick:()=>tt.mutate(),disabled:tt.isPending,className:"h-8 px-3 text-xs bg-amber-600 hover:bg-amber-700 text-white rounded-lg","data-testid":"button-start-paid-generation",children:tt.isPending?c.jsxs(c.Fragment,{children:[c.jsx(ge,{className:"w-3 h-3 animate-spin mr-1.5"})," Iniciando..."]}):c.jsxs(c.Fragment,{children:[c.jsx(oe,{className:"w-3 h-3 mr-1.5"})," Começar a escrever agora"]})})]})]}):M?.importJob?.status==="done"&&_s>0&&!He?c.jsxs("div",{className:"flex items-start gap-3 bg-amber-50 border border-amber-200 rounded-lg px-4 py-3","data-testid":"banner-import-degraded",children:[c.jsx(Rt,{className:"w-5 h-5 text-amber-600 shrink-0 mt-0.5"}),c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"A importação criou os capÃtulos, mas o conteúdo ficou incompleto"}),c.jsx("p",{className:"text-xs text-amber-800 mt-0.5 mb-2",children:"O divisor automático provavelmente confundiu o sumário do PDF com a lista de capÃtulos. Reimporte o arquivo â agora o sistema preserva o livro inteiro mesmo quando a estrutura é difÃcil."}),c.jsx(rx,{href:"/book/import-finished",children:c.jsxs(Y,{size:"sm",className:"h-8 px-3 text-xs bg-amber-600 hover:bg-amber-700 text-white rounded-lg","data-testid":"button-reimport-file",children:[c.jsx(Ka,{className:"w-3 h-3 mr-1.5"})," Reimportar arquivo"]})})]})]}):He?null:c.jsxs("div",{className:"flex items-start gap-3 bg-gray-50 border border-gray-200 rounded-lg px-4 py-3","data-testid":"banner-no-content",children:[c.jsx(rn,{className:"w-5 h-5 text-gray-500 shrink-0 mt-0.5"}),c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"text-sm font-semibold text-gray-800",children:"Ainda não há conteúdo escrito"}),c.jsxs("p",{className:"text-xs text-gray-600 mt-0.5",children:["Volte para a aba ",c.jsx("strong",{children:'"Plano"'})," para revisar a estrutura do livro, ou inicie a geração dos capÃtulos. As ferramentas de edição aparecem aqui assim que houver texto."]})]})]})}),s==="writing"&&He&&!W&&!xt&&c.jsxs("div",{className:"sticky top-0 z-30 bg-[#fffcf5]/95 backdrop-blur-sm border-b border-black/10 py-3 mb-8 px-4 @lg:px-8 -mx-4 @sm:-mx-8 @lg:-mx-12 @2xl:-mx-16 @3xl:-mx-20 -mt-4 @sm:-mt-10 @lg:-mt-14 @2xl:-mt-20 @3xl:-mt-24",children:[jc&&!bn&&c.jsxs("div",{className:"flex items-center gap-2 bg-amber-50 border border-amber-200 rounded-lg px-3 py-2 mb-2 animate-in fade-in slide-in-from-top-2","data-testid":"edit-hint-banner",children:[c.jsx(Qt,{className:"w-4 h-4 text-amber-600 shrink-0"}),c.jsxs("p",{className:"text-xs text-amber-800 flex-1",children:["Clique em ",c.jsx("strong",{children:'"Editar"'})," para reordenar, adicionar ou remover capÃtulos. Você pode editar tÃtulos e textos clicando diretamente neles."]}),c.jsx("button",{onClick:()=>{Tc(!1);try{zt.setItem("sabhia_edit_hint_dismissed","1")}catch{}},className:"text-amber-400 hover:text-amber-600 transition-colors shrink-0","data-testid":"button-dismiss-edit-hint",children:c.jsx(nn,{className:"w-3.5 h-3.5"})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"text-[10px] uppercase tracking-wider font-sans",children:[Sr==="saved"&&c.jsx("span",{className:"text-emerald-600/70",children:t("toolbar.saved")}),Sr==="saving"&&c.jsx("span",{className:"text-amber-600/70",children:t("toolbar.saving")}),Sr==="unsaved"&&c.jsx("span",{className:"text-red-600/70",children:t("toolbar.unsaved")})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"flex items-center rounded-lg border border-gray-200 bg-white p-0.5 shadow-sm","data-testid":"editor-mode-toggle",title:"Alterne entre o editor Visual (estilo Word) e Markdown",children:[c.jsxs("button",{onClick:()=>uh("visual"),className:K("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-semibold font-sans transition-all",Cc==="visual"?"bg-emerald-500 text-white shadow-sm":"text-gray-500 hover:text-gray-700"),"data-testid":"button-editor-mode-visual",children:[c.jsx(oe,{className:"w-3.5 h-3.5"})," Visual"]}),c.jsxs("button",{onClick:()=>uh("markdown"),className:K("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-semibold font-sans transition-all",Cc==="markdown"?"bg-gray-800 text-white shadow-sm":"text-gray-500 hover:text-gray-700"),"data-testid":"button-editor-mode-markdown",children:[c.jsx(rn,{className:"w-3.5 h-3.5"})," Markdown"]})]}),c.jsx("button",{onClick:()=>
195{if(Sc(!bn),jc){Tc(!1);try{zt.setItem("sabhia_edit_hint_dismissed","1")}catch{}}},className:K("flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-semibold font-sans transition-all shadow-sm",bn?"bg-emerald-500 text-white hover:bg-emerald-600 shadow-emerald-500/25":"bg-white text-gray-700 hover:bg-gray-50 border border-gray-200 hover:border-gray-300 hover:shadow-md animate-pulse"),"data-testid":"button-toggle-edit-mode",children:bn?c.jsxs(c.Fragment,{children:[c.jsx(Qt,{className:"w-3.5 h-3.5"})," Editando"]}):c.jsxs(c.Fragment,{children:[c.jsx(Qt,{className:"w-3.5 h-3.5"})," Editar"]})}),c.jsxs("button",{onClick:()=>Mc(!0),className:"flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-semibold font-sans bg-white text-gray-700 hover:bg-gray-50 border border-gray-200 hover:border-gray-300 hover:shadow-md transition-all shadow-sm",title:"Ver e restaurar versões anteriores do livro","data-testid":"button-version-history",children:[c.jsx(Dh,{className:"w-3.5 h-3.5"})," Versões"]}),c.jsxs("div",{className:"relative",children:[c.jsxs("button",{onClick:()=>Mt(!Nr),className:"flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-semibold font-sans bg-[#0d9488] text-white hover:bg-[#0f766e] transition-all shadow-sm shadow-teal-500/25 hover:shadow-md hover:shadow-teal-500/30","data-testid":"button-download-menu",children:[c.jsx(qa,{className:"w-3.5 h-3.5"}),"Download"]}),Nr&&c.jsxs("div",{className:"absolute right-0 top-full mt-1.5 bg-white border border-gray-200 rounded-xl shadow-2xl z-50 min-w-[180px] overflow-hidden",children:[c.jsxs("button",{onClick:()=>{Mt(!1),rr(r,"pdf").catch(x=>de({title:"Download indisponÃvel",description:x.message,variant:"destructive"}));try{tr(parseInt(r||"0"),"pdf")}catch{}},className:"w-full text-left px-4 py-3 text-sm hover:bg-teal-50 transition-colors flex items-center gap-2.5 text-gray-700 font-sans font-medium","data-testid":"button-download-pdf",children:[c.jsx(sr,{className:"w-4 h-4 text-red-500"})," PDF"]}),c.jsxs("button",{onClick:()=>{Mt(!1),rr(r,"epub").catch(x=>de({title:"Download indisponÃvel",description:x.message,variant:"destructive"}));try{tr(parseInt(r||"0"),"epub")}catch{}},className:"w-full text-left px-4 py-3 text-sm hover:bg-teal-50 transition-colors flex items-center gap-2.5 text-gray-700 border-t border-gray-100 font-sans font-medium","data-testid":"button-download-epub",children:[c.jsx(tn,{className:"w-4 h-4 text-green-500"})," EPUB"]}),c.jsxs("button",{onClick:()=>{Mt(!1),rr(r,"docx").catch(x=>de({title:"Download indisponÃvel",description:x.message,variant:"destructive"}));try{tr(parseInt(r||"0"),"docx")}catch{}},className:"w-full text-left px-4 py-3 text-sm hover:bg-teal-50 transition-colors flex items-center gap-2.5 text-gray-700 border-t border-gray-100 font-sans font-medium","data-testid":"button-download-docx",children:[c.jsx(rn,{className:"w-4 h-4 text-blue-500"})," ",t("toolbar.docEditable")]})]})]})]})]})]}),s==="planning"?c.jsxs("div",{className:"font-['Courier_Prime']","data-testid":"planning-manuscript",children:[c.jsxs("div",{className:"mb-8 md:mb-12 border-b border-black/10 pb-6 flex flex-col gap-3",children:[c.jsxs("div",{className:"flex justify-between text-[10px] md:text-xs uppercase tracking-widest opacity-50",children:[c.jsx("span",{children:t("planning.editorialPlanning")}),c.jsx("span",{children:V?new Date(V.generatedAt).toLocaleDateString("pt-BR"):t("planning.draft")})]}),fe?c.jsx("input",{value:Jc,onChange:x=>Xo(x.target.value),className:"text-2xl md:text-4xl font-bold tracking-tighter leading-tight uppercase break-words bg-transparent border-b-2 border-primary/30 focus:border-primary outline-none w-full font-['Courier_Prime']","data-testid":"edit-plan-title"}):c.jsx("h1",{className:"text-2xl md:text-4xl font-bold tracking-tighter leading-tight uppercase break-words","data-testid":"text-plan-title",children:bt}),c.jsx("div",{className:"flex items-center gap-2 text-xs md:text-sm opacity-60 italic",children:fe?c.jsxs("span",{children:[t("planning.plannedByEditing")," ",c.jsx("input",{value:Gc,onChange:x=>Zo(x.target.value),className:"bg-transparent border-b border-primary/30 focus:border-primary outline-none font-['Courier_Prime'] italic w-32 inline","data-testid":"edit-plan-author"})," & SÃBHIA"]}):c.jsx("span",{children:t("planning.plannedBy",{author:M?.author||t("chapters.author")})})}),V&&c.jsx("div",{className:"flex items-center gap-4 flex-wrap",children:fe?c.jsxs(c.Fragment,{children:[c.jsxs("button",{onClick:()=>Qo.mutate(),disabled:Qo.isPending,className:"self-start mt-2 flex items-center gap-2 text-[10px] uppercase tracking-wider opacity-80 hover:opacity-100 transition-opacity cursor-pointer bg-transparent border-none p-0 text-emerald-700 font-bold","data-testid":"button-save-plan-edits",children:[Qo.isPending?c.jsx(ge,{className:"w-3 h-3 animate-spin"}):c.jsx(Lh,{className:"w-3 h-3"}),t("toolbar.save")]}),c.jsxs("button",{onClick:bg,className:"self-start mt-2 flex items-center gap-2 text-[10px] uppercase tracking-wider opacity-50 hover:opacity-100 transition-opacity cursor-pointer bg-transparent border-none p-0","data-testid":"button-cancel-plan-edits",children:[c.jsx(nn,{className:"w-3 h-3"}),t("toolbar.cancel")]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("button",{onClick:()=>Er(),disabled:Xn,className:"self-start mt-2 flex items-center gap-2 text-[11px] uppercase tracking-wider cursor-pointer rounded-lg px-3 py-1.5 bg-amber-800/10 text-amber-900 font-semibold border border-amber-800/20 hover:bg-amber-800/20 hover:border-amber-800/30 transition-all shadow-sm font-sans","data-testid":"button-regenerate-plan",children:[c.jsx(Rt,{className:K("w-3.5 h-3.5",Xn&&"animate-spin")}),t(Xn?"planning.regenerating":"planning.regeneratePlanning")]}),c.jsxs("button",{onClick:xg,className:"self-start mt-2 flex items-center gap-2 text-[11px] uppercase tracking-wider cursor-pointer rounded-lg px-3 py-1.5 bg-emerald-800/10 text-emerald-900 font-semibold border border-emerald-800/20 hover:bg-emerald-800/20 hover:border-emerald-800/30 transition-all shadow-sm font-sans","data-testid":"button-edit-plan",children:[c.jsx(Qt,{className:"w-3.5 h-3.5"}),t("toolbar.edit")]}),c.jsxs("div",{className:"relative self-start mt-2",children:[c.jsxs("button",{onClick:()=>Mo(!Nc),className:"flex items-center gap-2 text-[11px] uppercase tracking-wider cursor-pointer rounded-lg px-3 py-1.5 bg-sky-800/10 text-sky-900 font-semibold border border-sky-800/20 hover:bg-sky-800/20 hover:border-sky-800/30 transition-all shadow-sm font-sans","data-testid":"button-plan-download-menu",children:[c.jsx(qa,{className:"w-3.5 h-3.5"}),"Download"]}),Nc&&c.jsxs("div",{className:"absolute left-0 top-full mt-1 bg-white border border-black/10 rounded-lg shadow-xl z-50 min-w-[150px] overflow-hidden",children:[c.jsxs("button",{onClick:()=>{Mo(!1);const x=document.createElement("a");x.href=`/api/books/${r}/plan-pdf`,x.download="plano.pdf",document.body.appendChild(x),x.click(),document.body.removeChild(x)},className:"w-full text-left px-4 py-2.5 text-xs hover:bg-gray-50 transition-colors flex items-center gap-2 text-gray-700 font-sans","data-testid":"button-plan-download-pdf",children:[c.jsx(sr,{className:"w-3.5 h-3.5"})," PDF"]}),c.jsxs("button",{onClick:()=>{Mo(!1);const x=document.createElement("a");x.href=`/api/books/${r}/plan-docx`,x.download="plano.docx",document.body.appendChild(x),x.click(),document.body.removeChild(x)},className:"w-full text-left px-4 py-2.5 text-xs hover:bg-gray-50 transition-colors flex items-center gap-2 text-gray-700 border-t border-gray-100 font-sans","data-testid":"button-plan-download-docx",children:[c.jsx(rn,{className:"w-3.5 h-3.5"})," ",t("toolbar.docEditable")]})]})]})]})})]}),vn&&(Object.keys(pe).length>0||Ps.length>0)?c.jsxs("div",{className:"space-y-8 md:space-y-10","data-testid":"plan-streaming",children:[tg&&c.jsxs("div",{className:"flex items-center gap-3 mb-6 animate-pulse",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-ping"}),c.jsx("span",{className:"text-xs uppercase tracking-wider opacity-60 font-mono",children:As})]}),pe.premise&&c.jsxs(se.section,{initial:{opacity:0,y:20}
195,animate:{opacity:1,y:0},transition:{duration:.5},className:"pb-6 border-b border-black/5",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.premise")}),c.jsx(Cn,{text:pe.premise,speed:15})]}),(pe.targetAudience||pe.toneAndStyle)&&c.jsxs(se.section,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"grid grid-cols-1 md:grid-cols-2 gap-6 pb-6 border-b border-black/5",children:[pe.targetAudience&&c.jsxs("div",{children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.targetAudience")}),c.jsx(Cn,{text:pe.targetAudience,speed:10,className:"text-xs md:text-sm leading-relaxed opacity-80"})]}),pe.toneAndStyle&&c.jsxs("div",{children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.toneAndStyle")}),c.jsx(Cn,{text:pe.toneAndStyle,speed:10,className:"text-xs md:text-sm leading-relaxed opacity-80"})]})]}),pe.centralThemes&&c.jsxs(se.section,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"pb-6 border-b border-black/5",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.centralThemes")}),c.jsx("div",{className:"flex flex-wrap gap-2",children:pe.centralThemes.map((x,w)=>c.jsx(se.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{delay:w*.1,duration:.3},className:"inline-block bg-black/5 px-3 py-1.5 rounded-sm text-xs opacity-80 border border-black/5",children:x},w))})]}),pe.synopsis&&c.jsxs(se.section,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"pb-6 border-b border-black/5",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.synopsis")}),c.jsx("div",{className:"text-xs md:text-sm leading-relaxed opacity-80 space-y-3 italic",children:c.jsx(Cn,{text:pe.synopsis,speed:8})})]}),pe.narrativeArc&&c.jsxs(se.section,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"pb-6 border-b border-black/5",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.narrativeArc")}),c.jsx(Cn,{text:pe.narrativeArc,speed:10,className:"text-xs md:text-sm leading-relaxed opacity-80"})]}),pe.characters&&pe.characters.length>0&&c.jsxs(se.section,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"pb-6 border-b border-black/5",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-4",children:t("planning.characters")}),c.jsx("div",{className:"space-y-6",children:pe.characters.map((x,w)=>c.jsxs(se.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:w*.15,duration:.4},className:"pl-4 border-l-2 border-black/10",children:[c.jsxs("div",{className:"flex items-baseline gap-3 mb-1",children:[c.jsx("h3",{className:"text-sm md:text-base font-bold uppercase tracking-wide",children:x.name}),c.jsx("span",{className:"text-[10px] uppercase tracking-wider opacity-40 bg-black/5 px-2 py-0.5 rounded-sm",children:x.role})]}),c.jsx(Cn,{text:x.description,speed:10,className:"text-xs md:text-sm leading-relaxed opacity-70 mb-2"})]},w))})]}),Ps.length>0&&c.jsxs("section",{className:"pb-6",children:[c.jsxs("div",{className:"flex items-center gap-4 text-[10px] md:text-xs font-bold border-b border-black/10 pb-3 mb-8 uppercase tracking-wider",children:[c.jsx("span",{className:"w-10 md:w-14 opacity-40",children:t("chapters.chapterAbbr")}),c.jsx("span",{className:"flex-1 opacity-40",children:t("planning.chapterStructure")}),c.jsx("span",{className:"w-12 md:w-16 text-right opacity-40",children:t("planning.pages")})]}),c.jsx("div",{className:"space-y-8 md:space-y-10",children:Ps.map(x=>c.jsxs(se.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.5},className:"group relative",children:[c.jsxs("div",{className:"flex items-baseline gap-2 md:gap-4 mb-2",children:[c.jsx("span",{className:"w-10 md:w-14 text-sm md:text-lg font-bold opacity-30 tabular-nums",children:String(x.number).padStart(2,"0")}),c.jsx("h3",{className:"flex-1 text-sm md:text-base font-bold uppercase tracking-wide leading-tight",children:x.title}),c.jsxs("span",{className:"text-[10px] opacity-30 tabular-nums shrink-0",children:["~",x.estimatedPages,"p"]})]}),c.jsxs("div",{className:"pl-12 md:pl-[72px] pr-0 md:pr-4 border-l border-black/10 ml-[12px] md:ml-[18px] space-y-2",children:[c.jsx(Cn,{text:
195x.summary,speed:8,className:"text-xs md:text-sm leading-relaxed opacity-75"}),x.keyPoints&&x.keyPoints.length>0&&x.keyPoints[0]!=="A ser definido com base no material de referência"&&c.jsx("div",{className:"space-y-1 mt-2",children:x.keyPoints.map((w,T)=>c.jsxs(se.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:T*.1,duration:.3},className:"flex items-start gap-2 text-[10px] md:text-xs opacity-50",children:[c.jsx("span",{className:"mt-1 w-1 h-1 rounded-full bg-black/30 shrink-0"}),c.jsx("span",{children:w})]},T))})]})]},x.number))})]}),pe.researchNotes&&pe.researchNotes.length>0&&c.jsxs(se.section,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"pt-6 border-t border-black/10",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.researchNotes")}),c.jsx("div",{className:"space-y-2",children:pe.researchNotes.map((x,w)=>c.jsxs(se.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:w*.1},className:"flex items-start gap-2 text-xs opacity-60",children:[c.jsx("span",{className:"mt-1.5 w-1 h-1 rounded-full bg-black/30 shrink-0"}),c.jsx("span",{children:x})]},w))})]}),pe.estimatedTotalPages&&c.jsx(se.div,{initial:{opacity:0}
195,animate:{opacity:1},transition:{duration:.5},className:"text-center pt-6 border-t border-black/5",children:c.jsx("span",{className:"text-[10px] uppercase tracking-widest opacity-30",children:t("planning.estimatedTotal",{pages:pe.estimatedTotalPages})})}),vn&&c.jsxs(se.div,{initial:{opacity:0},animate:{opacity:1},className:"flex items-center justify-center gap-2 py-4",children:[c.jsxs("div",{className:"flex gap-1",children:[c.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-primary/60 animate-bounce",style:{animationDelay:"0ms"}}),c.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-primary/60 animate-bounce",style:{animationDelay:"150ms"}}),c.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-primary/60 animate-bounce",style:{animationDelay:"300ms"}})]}),c.jsx("span",{className:"text-[10px] uppercase tracking-wider opacity-40",children:t("planning.sabhiaWriting")})]})]}):Xn?c.jsxs("div",{className:"flex flex-col items-center justify-center py-20 gap-6","data-testid":"plan-generating",children:[c.jsx("div",{className:"relative",children:Zc?c.jsx("div",{className:"w-20 h-20 border-2 border-violet-400/30 rounded-full flex items-center justify-center bg-violet-500/5",children:c.jsx("img",{src:"/images/sabhia-logo.webp",alt:"SÃBHIA",className:"w-10 h-10 rounded-full object-cover opacity-60"})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"w-20 h-20 border-2 border-black/10 rounded-full animate-spin border-t-primary/60",style:{animationDuration:"2s"}}),c.jsx("img",{src:"/images/sabhia-logo.webp",alt:"SÃBHIA",className:"w-10 h-10 rounded-full absolute inset-0 m-auto object-cover"})]})}),c.jsx("div",{className:"text-center space-y-3",children:Zc?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-sm font-bold uppercase tracking-wider text-violet-400/80",children:"Seu planejamento está quase pronto"}),c.jsx("p",{className:"text-xs opacity-50 max-w-sm",children:"A geração demorou mais do que o esperado. Clique abaixo para reiniciar o planejamento â leva apenas alguns minutos."}),c.jsx("button",{onClick:Sg,disabled:Ks.isPending,className:"mt-4 px-6 py-2.5 bg-violet-600/90 hover:bg-violet-600 text-white text-sm font-medium rounded-full transition-all shadow-sm hover:shadow-md disabled:opacity-50","data-testid":"plan-retry-btn",children:Ks.isPending?"Preparando...":"⨠Tentar Novamente"})]}):c.jsxs(c.Fragment,{children:[As?c.jsx(se.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"text-sm font-bold uppercase tracking-wider opacity-60",children:As},As):c.jsx("p",{className:"text-sm font-bold uppercase tracking-wider opacity-60",children:t("planning.generatingFullPlan")}),Ro>0&&c.jsxs(se.div,{initial:{opacity:0}
195,animate:{opacity:1},className:"flex flex-col items-center gap-2",children:[c.jsx("div",{className:"w-48 h-1 bg-black/5 rounded-full overflow-hidden",children:c.jsx(se.div,{className:"h-full bg-primary/40 rounded-full",initial:{width:0},animate:{width:`${Math.min(Ro/15e3*100,95)}%`},transition:{duration:.5}})}),c.jsxs("span",{className:"text-[10px] opacity-30 font-mono",children:[Math.round(Ro/1e3),"k ",t("planning.charsGenerated")]})]}),c.jsx("p",{className:"text-xs opacity-40 max-w-sm",children:t("planning.sabhiaCreating")})]})})]}):Qn?c.jsx("div",{ref:Ls,className:"pointer-events-none select-none space-y-8 blur-md md:space-y-10","aria-hidden":"true","data-testid":"plan-content-locked",children:[0,1,2,3].map(x=>c.jsxs("section",{className:"space-y-3 border-b border-black/5 pb-7",children:[c.jsx("div",{className:"h-3 w-32 rounded bg-black/20"}),c.jsx("div",{className:"h-4 w-full rounded bg-black/15"}),c.jsx("div",{className:"h-4 w-11/12 rounded bg-black/15"}),c.jsx("div",{className:"h-4 w-4/5 rounded bg-black/15"})]},x))}):V?c.jsx("div",{children:c.jsxs("div",{ref:Ls,className:K("space-y-8 transition duration-200 md:space-y-10",Qn&&"pointer-events-none select-none blur-md"),"aria-hidden":Qn||void 0,"data-testid":"plan-content",children:[fe&&c.jsxs("div",{className:"flex items-center gap-2 mb-4 text-xs text-primary/70",children:[c.jsx(Qt,{className:"w-3 h-3"}),c.jsx("span",{className:"uppercase tracking-wider font-bold",children:t("planning.editMode")})]}),c.jsxs("section",{id:"plan-section-premise",ref:x=>{gt.current.premise=x},className:"pb-6 border-b border-black/5",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.premise")}),fe?c.jsx("textarea",{value:Q?.premise||"",onChange:x=>Ne(w=>({...w,premise:x.target.value})),className:"w-full bg-black/[0.02] border border-black/10 rounded p-2 text-sm md:text-base leading-relaxed opacity-90 resize-y min-h-[60px] focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']","data-testid":"edit-plan-premise"}):c.jsx("p",{className:"text-sm md:text-base leading-relaxed opacity-90","data-testid":"text-plan-premise",children:V.premise})]}),c.jsxs("section",{id:"plan-section-audience-tone",ref:x=>{gt.current.targetAudience=x,gt.current.toneAndStyle=x},className:"grid grid-cols-1 md:grid-cols-2 gap-6 pb-6 border-b border-black/5",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.targetAudience")}),fe?c.jsx("textarea",{value:Q?.targetAudience||"",onChange:x=>Ne(w=>({...w,targetAudience:x.target.value})),className:"w-full bg-black/[0.02] border border-black/10 rounded p-2 text-xs md:text-sm leading-relaxed opacity-80 resize-y min-h-[60px] focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']","data-testid":"edit-plan-audience"}):c.jsx("p",{className:"text-xs md:text-sm leading-relaxed opacity-80","data-testid":"text-plan-audience",children:V.targetAudience})]}),c.jsxs("div",{children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.toneAndStyle")}),fe?c.jsx("textarea",{value:Q?.toneAndStyle||"",onChange:x=>Ne(w=>({...w,toneAndStyle:x.target.value})),className:"w-full bg-black/[0.02] border border-black/10 rounded p-2 text-xs md:text-sm leading-relaxed opacity-80 resize-y min-h-[60px] focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']","data-testid":"edit-plan-tone"}):c.jsx("p",{className:"text-xs md:text-sm leading-relaxed opacity-80","data-testid":"text-plan-tone",children:V.toneAndStyle})]})]}),(M?.status==="planning"||M?.status==="planned")&&c.jsx(l0,{bookId:r||"",currentRef:M?.previousWorkRef||null}),(fe||V.centralThemes&&V.centralThemes.length>0)&&c.jsxs("section",{id:"plan-section-themes",ref:x=>{gt.current.centralThemes=x},className:"pb-6 border-b border-black/5",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.centralThemes")}),fe?c.jsx("textarea",{value:Q?.centralThemes?.join(` 196`)||"",onChange:x=>Ne(w=>({...w,centralThemes:x.target.value.split(` 197`).filter(T=>T.trim())})),className:"w-full bg-black/[0.02] border border-black/10 rounded p-2 text-xs leading-relaxed opacity-80 resize-y min-h-[60
197px] focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']",placeholder:t("placeholders.oneThemePerLine"),"data-testid":"edit-plan-themes"}):c.jsx("div",{className:"flex flex-wrap gap-2","data-testid":"plan-themes",children:V.centralThemes.map((x,w)=>c.jsx("span",{className:"inline-block bg-black/5 px-3 py-1.5 rounded-sm text-xs opacity-80 border border-black/5",children:x},w))})]}),c.jsxs("section",{id:"plan-section-synopsis",ref:x=>{gt.current.synopsis=x},className:"pb-6 border-b border-black/5",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.synopsis")}),fe?c.jsx("textarea",{value:Q?.synopsis||"",onChange:x=>Ne(w=>({...w,synopsis:x.target.value})),className:"w-full bg-black/[0.02] border border-black/10 rounded p-2 text-xs md:text-sm leading-relaxed opacity-80 italic resize-y min-h-[100px] focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']","data-testid":"edit-plan-synopsis"}):c.jsx("div",{className:"text-xs md:text-sm leading-relaxed opacity-80 space-y-3 italic","data-testid":"text-plan-synopsis",children:V.synopsis.split(` 198`).map((x,w)=>c.jsx("p",{children:x},w))})]}),(fe||V.narrativeArc)&&c.jsxs("section",{id:"plan-section-arc",ref:x=>{gt.current.narrativeArc=x},className:"pb-6 border-b border-black/5",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.narrativeArc")}),fe?c.jsx("textarea",{value:Q?.narrativeArc||"",onChange:x=>Ne(w=>({...w,narrativeArc:x.target.value})),className:"w-full bg-black/[0.02] border border-black/10 rounded p-2 text-xs md:text-sm leading-relaxed opacity-80 resize-y min-h-[60px] focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']","data-testid":"edit-plan-arc"}):c.jsx("p",{className:"text-xs md:text-sm leading-relaxed opacity-80","data-testid":"text-plan-arc",children:V.narrativeArc})]}),(fe||V.characters&&V.characters.length>0)&&c.jsxs("section",{id:"plan-section-characters",ref:x=>{gt.current.characters=x},className:"pb-6 border-b border-black/5",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-4",children:t("planning.characters")}),c.jsx("div",{className:"space-y-6","data-testid":"plan-characters",children:(fe?Q?.characters||[]:V.characters).map((x,w)=>c.jsx("div",{className:"pl-4 border-l-2 border-black/10",children:fe?c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-baseline gap-3 mb-1",children:[c.jsx("input",{value:x.name||"",onChange:T=>{const A=[...Q.characters||[]];A[w]={...A[w],name:T.target.value},Ne(_=>({..._,characters:A}))},className:"text-sm md:text-base font-bold uppercase tracking-wide bg-black/[0.02] border border-black/10 rounded px-2 py-1 focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime'] flex-1",placeholder:t("placeholders.name"),"data-testid":`edit-char-name-${w}`}),c.jsx("input",{value:x.role||"",onChange:T=>{const A=[...Q.characters||[]];A[w]={...A[w],role:T.target.value},Ne(_=>({..._,characters:A}))},className:"text-[10px] uppercase tracking-wider opacity-60 bg-black/[0.02] border border-black/10 rounded px-2 py-1 focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime'] w-32",placeholder:t("placeholders.role"),"data-testid":`edit-char-role-${w}`})]}),c.jsx("textarea",{value:x.description||"",onChange:T=>{const A=[...Q.characters||[]];A[w]={...A[w],description:T.target.value},Ne(_=>({..._,characters:A}))},className:"w-full bg-black/[0.02] border border-black/10 rounded p-2 text-xs md:text-sm leading-relaxed opacity-70 resize-y min-h-[40px] focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']",placeholder:t("placeholders.description"),"data-testid":`edit-char-desc-${w}`}),c.jsx("input",{value:x.arc||"",onChange:T=>{const A=[...Q.characters||[]];A[w]={...A[w],arc:T.target.value},Ne(_=>({..._,characters:A}))},className:"w-full bg-black/[0.02] border border-black/10 rounded px-2 py-1 text-[10px] md:text-xs leading-relaxed opacity-50 italic focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']",placeholder:t("placeholders.characterArc"),"data-testid":`edit-char-arc-${w}`})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-baseline gap-3 mb-1",children:[c.jsx("h3",{className:"text-sm md:text-base font-bold uppercase tracking-wide",children:x.name}),c.jsx("span",{className:"text-[10px] uppercase tracking-wider opacity-40 bg-black/5 px-2 py-0.5 rounded-sm",children:x.role})]}),c.jsx("p",{className:"text-xs md:text-sm leading-relaxed opacity-70 mb-2",children:x.description}),x.arc&&c.jsx("p",{className:"text-[10px] md:text-xs leading-relaxed opacity-50 italic",children:t("planning.arc",{arc:x.arc})}),x.keyTraits&&x.keyTraits.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:x.keyTraits.map((T,A)=>c.jsx("span",{className:"text-[9px] uppercase tracking-wider opacity-40 bg-black/5 px-2 py-0.5 rounded-sm border border-black/5",children:T},A))})]})},x.name||w))})]}
198),c.jsxs("section",{className:"pb-6 mb-6",children:[c.jsxs("button",{onClick:()=>Ic(!Do),"data-testid":"button-toggle-outline-generator",className:"flex items-center gap-2 text-[10px] md:text-xs font-bold uppercase tracking-wider opacity-50 hover:opacity-80 transition-opacity mb-4 font-['Courier_Prime']",children:[c.jsx(Tx,{className:"w-3.5 h-3.5"}),"Gerador de Estrutura",c.jsx(yh,{className:K("w-3 h-3 transition-transform",Do&&"rotate-180")})]}),Do&&c.jsxs("div",{className:"border border-black/10 rounded-lg bg-black/[0.02] p-4 md:p-6 space-y-5 font-['Courier_Prime']","data-testid":"outline-generator-panel",children:[c.jsx("p",{className:"text-xs md:text-sm opacity-60 leading-relaxed",children:"Gere sugestões de capÃtulos baseadas no gênero e nos pontos-chave da sua história."}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"text-[10px] md:text-xs font-bold uppercase tracking-wider opacity-40",children:"Pontos-chave da história"}),wn.map((x,w)=>c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{value:x,onChange:T=>{const A=[...wn];A[w]=T.target.value,Lo(A)},placeholder:`Ponto ${w+1}`,"data-testid":`input-plot-point-${w}`,className:"flex-1 bg-black/[0.02] border border-black/10 rounded px-3 py-2 text-xs md:text-sm focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']"}),wn.length>1&&c.jsx("button",{onClick:()=>Lo(wn.filter((T,A)=>A!==w)),"data-testid":`button-remove-plot-point-${w}`,className:"p-1.5 opacity-40 hover:opacity-70 transition-opacity",children:c.jsx(nn,{className:"w-3.5 h-3.5"})})]},w)),c.jsxs("button",{onClick:()=>Lo([...wn,""]),"data-testid":"button-add-plot-point",className:"flex items-center gap-1.5 text-[10px] md:text-xs opacity-50 hover:opacity-80 transition-opacity mt-1",children:[c.jsx(bh,{className:"w-3 h-3"}),"Adicionar ponto"]})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("label",{className:"text-[10px] md:text-xs font-bold uppercase tracking-wider opacity-40",children:t("outlineGenerator.chapterCount")}),c.jsx("input",{type:"number",min:3,max:30,value:Pc,onChange:x=>rg(Math.min(30,Math.max(3,parseInt(x.target.value)||3))),"data-testid":"input-chapter-count",className:"w-16 bg-black/[0.02] border border-black/10 rounded px-2 py-1.5 text-xs md:text-sm text-center focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']"})]}),c.jsxs("button",{onClick:()=>qs.mutate({plotPoints:wn.filter(x=>x.trim()),chapterCount:Pc}),disabled:qs.isPending||wn.every(x=>!x.trim()),"data-testid":"button-generate-outline",className:"flex items-center gap-2 bg-black/[0.06] hover:bg-black/[0.1] disabled:opacity-30 disabled:cursor-not-allowed border border-black/10 rounded px-4 py-2 text-xs md:text-sm font-bold uppercase tracking-wider transition-colors font-['Courier_Prime']",children:[qs.isPending?c.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"}):c.jsx(oe,{className:"w-3.5 h-3.5"}),qs.isPending?t("outlineGenerator.generating"):t("outlineGenerator.generate")]}),Ds&&c.jsxs("div",{className:"border-t border-black/10 pt-5 mt-5 space-y-5","data-testid":"outline-result",children:[c.jsx("p",{className:"text-[10px] md:text-xs font-bold uppercase tracking-wider opacity-40",children:t("outlineGenerator.generatedStructure")}),c.jsx("div",{className:"space-y-6",children:Ds.map((x,w)=>c.jsxs("div",{className:"group relative","data-testid":`outline-chapter-${w}`,children:[c.jsxs("div",{className:"flex items-baseline gap-2 md:gap-4 mb-2",children:[c.jsx("span",{className:"w-10 md:w-14 text-sm md:text-lg font-bold opacity-30 tabular-nums",children:String(x.number||w+1).padStart(2,"0")}),c.jsx("h3",{className:"flex-1 text-sm md:text-base font-bold uppercase tracking-wide leading-tight",children:x.title}),x.estimatedPages&&c.jsxs("span",{className:"text-[10px] opacity-30 tabular-nums shrink-0",children:["~",x.estimatedPages,"p"]})]}),c.jsxs("div",{className:"pl-12 md:pl-[72px] pr-0 md:pr-4 border-l border-black/10 ml-[12px] md:ml-[18px] space-y-2",children:[x.summary&&c.jsx("p",{className:"text-xs md:text-sm leading-relaxed opacity-75",children:x.summary}),x.keyPoints&&x.keyPoints.length>0&&c.jsx("div",{className:"space-y-1 mt-2",children:x.keyPoints.map((T,A)=>c.jsxs("div",{className:"flex items-start gap-2 text-[10px] md:text-xs opacity-50",children:[c.jsx("span",{className:"mt-1 w-1 h-1 rounded-full bg-black/30 shrink-0"}),c.jsx("span",{children:T})]},A))}),x.narrativePurpose&&c.jsx("p",{className:"text-[10px] md:text-xs italic opacity-40 mt-1",children:t("planning.purpose",{purpose:x.narrativePurpose})})]})]},w))}),c.jsxs("div",{className:"flex items-center gap-3 pt-3",children:[c.jsxs("button",{onClick:gg,"data-testid":"button-accept-outline",className:"flex items-center gap-2 bg-primary text-primary-foreground hover:bg-primary/90 rounded px-4 py-2 text-xs md:text-sm font-bold uppercase tracking-wider transition-colors font-['Courier_Prime']",children:[c.jsx(it,{className:"w-3.5 h-3.5"}),"Aceitar e Substituir"]}),c.jsxs("button",{onClick:()=>zo(null),"data-testid":"button-discard-outline",className:"flex items-center gap-2 bg-black/[0.04] hover:bg-black/[0.08] border border-black/10 rounded px-4 py-2 text-xs md:text-sm font-bold uppercase tracking-wider transition-colors font-['Courier_Prime']",children:[c.jsx(nn,{className:"w-3.5 h-3.5"}),"Descartar"]})]})]})]})]}),c.jsxs("section",{id:"plan-section-chapters",ref:x=>{gt.current.chapters=x},className:"pb-6",children:[c.jsxs("div",{className:"flex items-center gap-4 text-[10px] md:text-xs font-bold border-b border-black/10 pb-3 mb-8 uppercase tracking-wider",children:[c.jsx("span",{className:"w-10 md:w-14 opacity-40",children:t("chapters.chapterAbbr")}),c.jsx("span",{className:"flex-1 opacity-40",children:t("planning.chapterStructure")}),c.jsx("span",{className:"w-12 md:w-16 text-right opacity-40",children:t("planning.pages")})]}),c.jsx("div",{className:"space-y-8 md:space-y-10","data-testid":"plan-chapters",children:(fe?Q?.chapters||[]:V.chapters).map((x,w)=>c.jsxs("div",{className:"group relative",children:[c.jsxs("div",{className:"flex items-baseline gap-2 md:gap-4 mb-2",children:[c.jsx("span",{className:"w-10 md:w-14 text-sm md:text-lg font-bold opacity-30 tabular-nums",children:String(x.number||w+1).padStart(2,"0")}),fe?c.jsx("input",{value:x.title||"",onChange:T=>{const A=[...Q.chapters||[]];A[w]={...A[w],title:T.target.value},Ne(_=>({..._,chapters:A}))},className:"flex-1 text-sm md:text-base font-bold uppercase tracking-wide leading-tight bg-black/[0.02] border border-black/10 rounded px-2 py-1 focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']","data-testid":`edit-chapter-title-${w}`}):c.jsx("h3",{className:"flex-1 text-sm md:text-base font-bold uppercase tracking-wide leading-tight",children:x.title}),c.jsxs("span",{className:"text-[10px] opacity-30 tabular-nums shrink-0",children:["~",x.estimatedPages,"p"]})]}),c.jsx("div",{className:"pl-12 md:pl-[72px] pr-0 md:pr-4 border-l border-black/10 ml-[12px] md:ml-[18px] space-y-2",children:fe?c.jsxs(c.Fragment,{children:[c.jsx("textarea",{value:x.summary||"",onChange:T=>{const A=[...Q.chapters||[]];A[w]={...A[w],summary:T.target.value},Ne(_=>({..._,chapters:A}))},className:"w-full bg-black/[0.02] border border-black/10 rounded p-2 text-xs md:text-sm leading-relaxed opacity-75 resize-y min-h-[40px] focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']",placeholder:t("placeholders.chapterSummary"),"data-testid":`edit-chapter-summary-${w}`}),c.jsx("input",{value:x.narrativePurpose||"",onChange:T=>{const A=[...Q.chapters||[]];A[w]={...A[w],narrativePurpose:T.target.value},Ne(_=>({..._,chapters:A}))},className:"w-full bg-black/[0.02] border border-black/10 rounded px-2 py-1 text-[10px] md:text-xs italic opacity-40 focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']",placeholder:t("placeholders.narrativePurpose"),"data-testid":`edit-chapter-purpose-${w}`})]}):c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-xs md:text-sm leading-relaxed opacity-75",children:x.summary}),x.keyPoints&&x.keyPoints.length>0&&x.keyPoints[0]!=="A ser definido com base no material de referência"&&c.jsx("div",{className:"space-y-1 mt-2",children:x.keyPoints.map((T,A)=>c.jsxs("div",{className:"flex items-start gap-2 text-[10px] md:text-xs opacity-50",children:[c.jsx("span",{className:"mt-1 w-1 h-1 rounded-full bg-black/30 shrink-0"}),c.jsx("span",{children:T})]},A))}),x.narrativePurpose&&x.narrativePurpose!=="Contribui para a progressão geral da obra"&&c.jsx("p",{className:"text-[10px] md:text-xs italic opacity-40 mt-1",children:t("planning.purpose",{purpose:x.narrativePurpose})})]})})]},x.number||w))})]}),(fe||V.researchNotes&&V.researchNotes.length>0&&V.researchNotes[0]!=="Adicione materiais à Base de Conhecimento para gerar notas de pesquisa personalizadas")&&c.jsxs("section",{id:"plan-section-research",ref:x=>{gt.current.researchNotes=x},className:"pt-6 border-t border-black/10",children:[c.jsx("h2",{className:"text-[10px] md:text-xs uppercase tracking-[0.2em] font-bold opacity-40 mb-3",children:t("planning.researchNotes")}),fe?c.jsx("textarea",{value:Q?.researchNotes?.join(` 199`)||"",onChange:x=>Ne(w=>({...w,researchNotes:x.target.value.split(` 200`).filter(T=>T.trim())})),className:"w-full bg-black/[0.02] border border-black/10 rounded p-2 text-xs leading-relaxed opacity-60 resize-y min-h-[60
200px] focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']",placeholder:t("placeholders.oneNotePerLine"),"data-testid":"edit-plan-research-notes"}):c.jsx("div",{className:"space-y-2","data-testid":"plan-research-notes",children:V.researchNotes.map((x,w)=>c.jsxs("div",{className:"flex items-start gap-2 text-xs opacity-60",children:[c.jsx("span",{className:"mt-1.5 w-1 h-1 rounded-full bg-black/30 shrink-0"}),c.jsx("span",{children:x})]},w))})]}),(fe||V.estimatedTotalPages)&&c.jsx("div",{className:"text-center pt-6 border-t border-black/5",children:fe?c.jsxs("div",{className:"flex items-center justify-center gap-2",children:[c.jsxs("span",{className:"text-[10px] uppercase tracking-widest opacity-30",children:[t("planning.estimatedTotalPrefix")," ~"]}),c.jsx("input",{type:"number",value:Q?.estimatedTotalPages||"",onChange:x=>Ne(w=>({...w,estimatedTotalPages:parseInt(x.target.value)||0})),className:"w-16 bg-black/[0.02] border border-black/10 rounded px-2 py-0.5 text-[10px] uppercase tracking-widest opacity-50 text-center focus:border-primary/30 focus:ring-1 focus:ring-primary/20 outline-none font-['Courier_Prime']","data-testid":"edit-plan-pages"}),c.jsx("span",{className:"text-[10px] uppercase tracking-widest opacity-30",children:t("planning.pagesLabel")})]}):c.jsx("span",{className:"text-[10px] uppercase tracking-widest opacity-30",children:t("planning.estimatedTotal",{pages:V.estimatedTotalPages})})})]})}):Ut?c.jsxs("div",{className:"flex flex-col items-center justify-center py-16 md:py-24 gap-6 text-center","data-testid":"plan-empty-imported",children:[c.jsx("div",{className:"w-20 h-20 rounded-full bg-emerald-500/10 flex items-center justify-center",children:c.jsx(it,{className:"w-9 h-9 text-emerald-600"})}),c.jsxs("div",{className:"space-y-2 max-w-md",children:[c.jsx("h3",{className:"text-lg font-bold uppercase tracking-wide opacity-80",children:"Livro sem necessidade de planejamento"}),c.jsxs("p",{className:"text-sm leading-relaxed opacity-60",children:["Este livro foi enviado já escrito completo pelo autor. Vá direto pra aba ",c.jsx("strong",{children:"Escrita"})," pra ler o manuscrito e contratar capa, audiobook, tradução e demais serviços."]})]}),c.jsxs("button",{onClick:()=>{i("writing"),setTimeout(()=>{window.scrollTo({top:0,behavior:"smooth"})},100)},className:"flex items-center gap-2 bg-emerald-600 text-white px-6 py-3 rounded-lg text-sm font-bold uppercase tracking-wider hover:bg-emerald-700 transition-colors","data-testid":"button-go-to-writing",children:[c.jsx(Ir,{className:"w-4 h-4"}),"Ir pra Escrita"]})]}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-16 md:py-24 gap-6 text-center","data-testid":"plan-empty",children:[c.jsx("div",{className:"w-20 h-20 rounded-full bg-black/5 flex items-center justify-center",children:c.jsx(tn,{className:"w-8 h-8 opacity-30"})}),c.jsxs("div",{className:"space-y-2 max-w-md",children:[c.jsx("h3",{className:"text-lg font-bold uppercase tracking-wide opacity-60",children:t("planning.editorialPlanning")}),c.jsx("p",{className:"text-xs md:text-sm leading-relaxed opacity-50",children:Ue&&Ue.length>0?t("welcome.knowledgeBaseReady"):t("welcome.addMaterials")})]}),c.jsxs("button",{onClick:()=>Er(),disabled:Xn,className:"flex items-center gap-2 bg-[#1a1a1a] text-[#f4f1ea] px-6 py-3 rounded-lg text-sm font-bold uppercase tracking-wider hover:bg-black transition-colors disabled:opacity-50","data-testid":"button-generate-plan",children:[Xn?c.jsx(ge,{className:"w-4 h-4 animate-spin"}):c.jsx(oe,{className:"w-4 h-4"}),t("planning.generateFullPlan")]})]}),!qe&&V&&!Ut&&c.jsx("div",{className:"mt-12 md:mt-auto md:pt-16 flex justify-center pb-8 w-full",children:c.jsxs("div",{className:"relative group cursor-pointer w-full md:w-auto",onClick:ia,children:[c.jsx("div",{className:"absolute inset-0 bg-primary/20 blur-3xl rounded-full scale-110 opacity-60 group-hover:opacity-100 transition-opacity duration-700"}),c.jsxs("div",{className:"relative bg-[#1a1a1a] text-[#f4f1ea] px-6 py-4 md:px-10 md:py-5 rounded-lg shadow-2xl border border-white/10 flex flex-col md:flex-row items-center gap-4 md:gap-6 transform transition-all duration-500 hover:scale-105 hover:shadow-[0_0_40px_-10px_hsl(178_86%_39%_/_0.5)] overflow-hidden w-full md:w-auto",children:[c.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent -translate-x-[200%] group-hover:animate-[shimmer_2s_infinite]"}),c.jsxs("div",{className:"flex flex-col text-center md:text-left z-10 w-full md:w-auto",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-[0.25em] text-primary font-bold mb-1",children:t("unlock.finalApproval")}),c.jsx("span",{className:"font-heading font-bold text-lg md:text-2xl tracking-tight text-white group-hover:text-primary transition-colors duration-300",children:t("unlock.wantWritten",{title:bt.toUpperCase()})})]}),c.jsx("div",{className:"h-px w-full md:h-10 md:w-px bg-white/10 z-10"}),c.jsxs("div",{className:"flex flex-row md:flex-col items-center md:items-end justify-center gap-3 md:gap-0 z-10 w-full md:w-auto",children:[c.jsxs("span",{className:"font-mono text-white/40 text-[10px] md:text-xs line-through",children:["R$ ",zh(Bh(ea))]}),c.jsxs("span",{className:"font-heading text-xl md:text-2xl font-bold text-white",children:["R$ ",ea.toFixed(2).replace(".",",")]})]})]})]})})]}):s==="services"?c.jsx("div",{className:"min-h-full flex flex-col items-center justify-start p-4 pb-32 md:pb-4 space-y-8",children:c.jsx("div",{className:"w-full max-w-md mx-auto",children:c.jsx(pd,{bookId:r,currentStep:"write",inProgressSteps:{write:W,cover:Dc,translate:Lc},onSelectCover:Og,enableTranslationLinks:!0})})}):s==="writing"?c.jsx(c.Fragment,{children:W?c.jsxs("div",{className:"min-h-full flex flex-col items-center p-6 pt-8 pb-16 gap-10",children:[c.jsxs("div",{className:"w-full max-w-2xl mx-auto",children:[M&&c.jsx(dx,{book:M}),Vc&&!Mr&&c.jsxs("div",{className:"mt-6 flex items-center gap-3 px-4 py-3 rounded-xl bg-amber-500/5 border border-amber-500/15","data-testid":"notice-generation-struggling",children:[c.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/10 flex items-center justify-center shrink-0",children:c.jsx(vi,{className:"w-4 h-4 text-amber-400"})}),c.jsx("p",{className:"text-xs text-amber-400/80 leading-relaxed",children:"A SÃBHIA está enfrentando alta demanda. Seus capÃtulos estão na fila e serão escritos automaticamente. Você pode navegar pelo sistema normalmente."})]}),!Mr&&!Vc&&c.jsxs("div",{className:"mt-6 flex items-center gap-3 px-4 py-3 rounded-xl bg-emerald-500/5 border border-emerald-500/10","data-testid":"notice-can-navigate-away",children:[c.jsx("div",{className:"w-8 h-8 rounded-full bg-emerald-500/10 flex items-center justify-center shrink-0",children:c.jsx(sx,{className:"w-4 h-4 text-emerald-400"})}),c.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:t("generating.canNavigate")})]}),Mr&&c.jsxs("div",{className:"mt-8 text-center",children:[c.jsx("p",{className:"text-sm text-amber-400/80 mb-3",children:t("generating.stuckMessage")}),c.jsx(Y,{"data-testid":"button-resume-generation",onClick:()=>tt.mutate(),disabled:tt.isPending,variant:"outline",className:"border-amber-400/30 text-amber-400 hover:bg-amber-400/10 rounded-full px-8",children:tt.isPending?c.jsxs(c.Fragment,{children:[c.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"})," ",t("generating.resuming")]}):c.jsxs(c.Fragment,{children:[c.jsx(Rt,{className:"w-4 h-4 mr-2"})," ",t("generating.resumeWriting")]})})]})]}),c.jsx(ux,{bookId:r})]}):xt?c.jsx("div",{className:"min-h-full flex flex-col items-center justify-center p-4 pb-32 md:pb-4",children:c.jsxs("div",{className:"w-full max-w-lg mx-auto",children:[c.jsxs("div",{className:"flex flex-col items-center mb-8",children:[c.jsx("div",{className:"w-20 h-20 rounded-full bg-gradient-to-br from-emerald-400 to-teal-600 flex items-center justify-center mb-6 shadow-lg shadow-emerald-500/20",children:c.jsx(Ir,{className:"w-10 h-10 text-white"})}),c.jsx("h3",{className:"text-2xl md:text-3xl font-heading font-bold text-center text-white mb-2","data-testid":"text-needs-generation",children:t("needsGeneration.title")}),c.jsx("p",{className:"text-sm text-gray-400 text-center max-w-md",children:t("needsGeneration.subtitle")})]}),c.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-2xl p-6 mb-8",children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("span",{className:"text-xs uppercase tracking-widest text-gray-400 font-bold",children:t("needsGeneration.yourBook")}),c.jsxs(ar,{variant:"outline",className:"text-emerald-400 border-emerald-400/30 text-xs",children:[M?.chapters?.length||0," ",t("needsGeneration.chapters")]})]}),c.jsxs("div",{className:"space-y-2",children:[M?.chapters?.slice(0,5).map((x,w)=>c.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-300",children:[c.jsx("span",{className:"text-xs font-mono text-gray-500 w-6 text-right",children:String(w+1).padStart(2,"0")}),c.jsx("span",{className:"truncate",children:x.title})]},x.id)),(M?.chapters?.length||0)>5&&c.jsxs("div",{className:"text-xs text-gray-500 pl-9",children:["+ ",(M?.chapters?.length||0)-5," ",t("needsGeneration.remainingChapters")]})]})]}),c.jsx(Y,{"data-testid":"button-generate-book",onClick:()=>Fs(!0),disabled:tt.isPending||W,className:"w-full h-14 bg-gradient-to-r from-emerald-500 to-teal-500 hover:from-emerald-600 hover:to-teal-600 text-white rounded-2xl text-lg font-bold shadow-lg shadow-emerald-500/20 transition-all duration-300",children:tt.isPending?c.jsxs(c.Fragment,{children:[c.jsx(ge,{className:"w-5 h-5 animate-spin mr-2"}),t("needsGeneration.starting")]}):c.jsxs(c.Fragment,{children:[c.jsx(oe,{className:"w-5 h-5 mr-2"}),t("needsGeneration.writeFullBook")]})}),pg&&hr.createPortal(c.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 backdrop-blur-sm animate-in fade-in","data-testid":"modal-pre-generation",children:c.jsxs("div",{className:"bg-[#1a1a2e] border border-white/10 rounded-2xl max-w-md w-full mx-4 p-6 shadow-2xl animate-in zoom-in-95",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[c.jsx("div",{className:"w-10 h-10 rounded-xl bg-emerald-500/20 flex items-center justify-center",children:c.jsx(tn,{className:"w-5 h-5 text-emerald-400"})}),c.jsx("h3",{className:"text-lg font-bold text-white",children:"Antes de começar..."})]}),c.jsxs("div",{className:"space-y-3 mb-5",children:[c.jsxs("div",{className:"flex items-start gap-2.5",children:[c.jsx(it,{className:"w-4 h-4 text-emerald-400 shrink-0 mt-0.5"}),c.jsxs("p",{className:"text-sm text-gray-300",children:["A SÃBHIA vai criar uma ",c.jsx("strong",{className:"text-white",children:"versão inicial"})," do seu livro baseada no plano editorial",M?.kbMode==="faithful"?" e fiel ao material que você forneceu":"","."]})]}),c.jsxs("div",{className:"flex items-start gap-2.5",children:[c.jsx(Qt,{className:"w-4 h-4 text-amber-400 shrink-0 mt-0.5"}),c.jsxs("p",{className:"text-sm text-gray-300",children:["Depois, você poderá ",c.jsx("strong",{className:"text-white",children:"editar cada capÃtulo"})," para ajustar ao seu estilo e inserir sua voz pessoal."]})]}),c.jsxs("div",{className:"flex items-start gap-2.5",children:[c.jsx(Rt,{className:"w-4 h-4 text-sky-400 shrink-0 mt-0.5"}),c.jsxs("p",{className:"text-sm text-gray-300",children:["Se o resultado não refletir sua voz, você pode ",c.jsx("strong",{className:"text-white",children:"recalibrar"})," capÃtulos especÃficos ou o livro inteiro."]})]})]}),M?.kbMode!=="faithful"&&c.jsx("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-xl p-3 mb-5",children:c.jsxs("p",{className:"text-xs text-amber-300 leading-relaxed",children:[c.jsx("strong",{children:"Dica:"})," Se você enviou material autobiográfico na Base de Conhecimento, considere mudar para o modo ",c.jsx("strong",{children:'"Fiel ao conteúdo original"'})," antes de gerar."]})}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Y,{variant:"ghost",onClick:()=>Fs(!1),className:"flex-1 text-gray-400 hover:text-white","data-testid":"button-cancel-pre-gen",children:"Voltar"}),c.jsxs(Y,{onClick:()=>{Fs(!1),tt.mutate()},disabled:tt.isPending,className:"flex-1 bg-gradient-to-r from-emerald-500 to-teal-500 hover:from-emerald-600 hover:to-teal-600 text-white font-bold shadow-lg","data-testid":"button-confirm-generate",children:[c.jsx(oe,{className:"w-4 h-4 mr-2"})," Gerar Meu Livro"]})]})]})}),document.body),c.jsx("p",{className:"text-center text-xs text-gray-500 mt-4",children:t("needsGeneration.coherenceNote")})]})}):He?c.jsxs("div",{className:"font-['Georgia','Crimson_Text',serif]",children:[(M?.voiceFeedback==="partial"||M?.voiceFeedback==="negative")&&c.jsx("div",{className:"mb-8 mx-auto max-w-2xl animate-in fade-in","data-testid":"recalibration-panel",children:c.jsxs("div",{className:"bg-gradient-to-br from-amber-950/30 via-amber-900/20 to-transparent border border-amber-500/20 rounded-2xl p-5 md:p-6 font-sans",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-xl bg-amber-500/20 flex items-center justify-center",children:c.jsx(Rt,{className:"w-5 h-5 text-amber-400"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-base font-bold text-white",children:M?.voiceFeedback==="negative"?"Vamos recalibrar seu livro":"Ajuste fino disponÃvel"}),c.jsx("p",{className:"text-xs text-amber-400/70",children:"Opções para aproximar o texto da sua voz"})]})]}),c.jsxs("div",{className:"space-y-2",children:[M?.kbMode!=="faithful"&&c.jsxs("button",{onClick:async()=>{await G("PATCH",`/api/books/${r}`,{kbMode:"faithful"}),H.invalidateQueries({queryKey:[`/api/books/${r}`]}),de({title:"Modo alterado para Fiel",description:"O próximo re-gerar usará apenas seu material original."})},className:"w-full flex items-start gap-3 p-3 rounded-xl bg-white/5 border border-white/10 text-left hover:bg-white/10 transition-all","data-testid":"button-switch-to-faithful",children:[c.jsx(tn,{className:"w-5 h-5 text-amber-400 shrink-0 mt-0.5"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-white",children:'Mudar para modo "Fiel ao original"'}),c.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"A SÃBHIA usará apenas o que você escreveu, sem adicionar conteúdo artificial."})]})]}),c.jsxs("button",{onClick:()=>{i("writing"),Sc(!0),de({title:"Modo de edição ativado",description:"Clique em qualquer capÃtulo para reescrevê-lo com suas próprias palavras."})},className:"w-full flex items-start gap-3 p-3 rounded-xl bg-white/5 border border-white/10 text-left hover:bg-white/10 transition-all","data-testid":"button-enter-edit-mode-recalib",children:[c.jsx(Qt,{className:"w-5 h-5 text-emerald-400 shrink-0 mt-0.5"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-white",children:"Editar capÃtulos manualmente"}),c.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Reescreva ou ajuste qualquer trecho para refletir 100% da sua voz."})]})]}),c.jsxs("button",{onClick:()=>{const x=document.querySelector('[data-testid="chat-input"]');x&&(x.focus(),x.value="Preciso recalibrar meu livro. O texto gerado não reflete minha voz pessoal. "),de({title:"Fale com a SÃBHIA",description:"Descreva como você gostaria que o texto soasse."})},className:"w-full flex items-start gap-3 p-3 rounded-xl bg-white/5 border border-white/10 text-left hover:bg-white/10 transition-all","data-testid":"button-chat-recalibrate",children:[c.jsx(oe,{className:"w-5 h-5 text-sky-400 shrink-0 mt-0.5"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-white",children:"Pedir ajuda à SÃBHIA"}),c.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Descreva como deveria soar e a SÃBHIA vai ajustar o texto para você."})]})]})]}),c.jsx("button",{onClick:async()=>{await G("PATCH",`/api/books/${r}`,{voiceFeedback:"dismissed"}),H.invalidateQueries({queryKey:[`/api/books/${r}`]})}
200,className:"mt-3 text-xs text-muted-foreground/50 hover:text-muted-foreground transition-colors w-full text-center","data-testid":"button-dismiss-recalibration",children:"Dispensar este painel"})]})}),c.jsxs("div",{id:"ms-title",className:"min-h-[320px] @lg:min-h-[440px] @2xl:min-h-[560px] @3xl:min-h-[620px] flex flex-col items-center justify-center text-center relative","data-testid":"ms-section-title",children:[c.jsxs("div",{className:"space-y-8 max-w-lg mx-auto",children:[c.jsxs("div",{className:"flex items-center justify-center gap-3 opacity-20",children:[c.jsx("div",{className:"w-16 h-px bg-gradient-to-r from-transparent to-gray-400"}),c.jsx("div",{className:"w-2 h-2 rotate-45 border border-gray-400"}),c.jsx("div",{className:"w-16 h-px bg-gradient-to-l from-transparent to-gray-400"})]}),c.jsx($a,{value:M?.title||"",onSave:async x=>{await G("PATCH",`/api/books/${r}`,{title:x})},bookId:r,field:"book:title",testId:"ms-edit-title",className:"text-3xl @lg:text-4xl @3xl:text-5xl font-bold tracking-tight text-center font-['Georgia','Crimson_Text',serif] text-gray-900 leading-[1.3] py-1",onStatusChange:x=>Et(x)}),c.jsxs("div",{className:"flex items-center justify-center gap-4 py-2",children:[c.jsx("div",{className:"w-20 h-px bg-gradient-to-r from-transparent via-gray-300 to-transparent"}),c.jsx("div",{className:"text-gray-300 text-lg",children:"â¦"}),c.jsx("div",{className:"w-20 h-px bg-gradient-to-r from-transparent via-gray-300 to-transparent"})]}),c.jsx($a,{value:M?.author||"",onSave:async x=>{await G("PATCH",`/api/books/${r}`,{author:x})},bookId:r,field:"book:author",testId:"ms-edit-author",className:"text-base md:text-lg tracking-[0.25em] uppercase text-gray-500 text-center font-sans",onStatusChange:x=>Et(x)})]}),M?.genre&&c.jsx("p",{className:"absolute bottom-8 left-0 right-0 text-center text-[10px] uppercase tracking-[0.4em] opacity-25 font-sans",children:M.genre})]}),c.jsx("div",{className:"my-8 flex items-center justify-center",children:c.jsx("div",{className:"w-full max-w-xs h-px bg-gradient-to-r from-transparent via-black/10 to-transparent"})}),c.jsx("div",{id:"ms-copyright",className:"min-h-[140px] @3xl:min-h-[240px] flex flex-col justify-end items-center text-center pb-12","data-testid":"ms-section-copyright",children:c.jsxs("div",{className:"space-y-2 opacity-40",children:[c.jsxs("p",{className:"text-[11px] font-sans",children:["© ",new Date().getFullYear()," ",M?.author||"Autor"]}),c.jsx("p",{className:"text-[11px] font-sans",children:Ze.allRightsReserved}),c.jsx("p",{className:"text-[10px] font-sans italic mt-4 max-w-sm mx-auto leading-relaxed opacity-70",children:Ze.copyrightNotice})]})}),c.jsx("div",{className:"my-8 flex items-center justify-center",children:c.jsx("div",{className:"w-full max-w-xs h-px bg-gradient-to-r from-transparent via-black/10 to-transparent"})}),c.jsxs("div",{id:"ms-toc",className:"min-h-[260px] @3xl:min-h-[440px] py-12","data-testid":"ms-section-toc",children:[c.jsx("h2",{className:"text-center text-base @lg:text-lg @3xl:text-xl tracking-[0.3em] uppercase font-bold mb-12 text-gray-700",children:Ze.tableOfContents}),c.jsxs("div",{className:"max-w-md mx-auto space-y-3",children:[M?.preface&&c.jsxs("button",{onClick:()=>document.getElementById("ms-preface")?.scrollIntoView({behavior:"smooth"}),className:"flex items-center w-full py-1.5 text-sm hover:text-gray-600 transition-colors group font-sans","data-testid":"toc-preface",children:[c.jsx("span",{className:"italic text-gray-600",children:Ze.preface}),c.jsx("span",{className:"flex-1 mx-3 border-b border-dotted border-gray-300 min-w-[40px]"})]}),!!M?.acknowledgments?.trim()&&c.jsxs("button",{onClick:()=>document.getElementById("ms-acknowledgments")?.scrollIntoView({behavior:"smooth"}),className:"flex items-center w-full py-1.5 text-sm hover:text-gray-600 transition-colors group font-sans","data-testid":"toc-acknowledgments",children:[c.jsx("span",{className:"italic text-gray-600",children:Ze.acknowledgments}),c.jsx("span",{className:"flex-1 mx-3 border-b border-dotted border-gray-300 min-w-[40px]"})]}),[...M?.chapters||[]].sort((x,w)=>x.orderIndex-w.orderIndex).map((x,w)=>c.jsxs("button",{onClick:()=>document.getElementById(`ms-chapter-${w}`)?.scrollIntoView({behavior:"smooth"}),className:"flex items-center w-full py-1.5 text-sm hover:text-gray-600 transition-colors group font-sans","data-testid":`toc-chapter-${w}`,children:[c.jsxs("span",{className:"text-gray-400 w-6 text-right mr-3 tabular-nums text-xs",children:[w+1,"."]}),c.jsx("span",{className:"text-gray-700",children:x.title}),c.jsx("span",{className:"flex-1 mx-3 border-b border-dotted border-gray-300 min-w-[40px]"})]},x.id)),M?.closingMessage&&c.jsxs("button",{onClick:()=>document.getElementById("ms-closing")?.scrollIntoView({behavior:"smooth"}),className:"flex items-center w-full py-1.5 text-sm hover:text-gray-600 transition-colors group font-sans","data-testid":"toc-closing",children:[c.jsx("span",{className:"italic text-gray-600",children:Ze.authorMessage}),c.jsx("span",{className:"flex-1 mx-3 border-b border-dotted border-gray-300 min-w-[40px]"})]}),M?.bibliography&&c.jsxs("button",{onClick:()=>document.getElementById("ms-bibliography")?.scrollIntoView({behavior:"smooth"}),className:"flex items-center w-full py-1.5 text-sm hover:text-gray-600 transition-colors group font-sans","data-testid":"toc-bibliography",children:[c.jsx("span",{className:"italic text-gray-600",children:Ze.bibliography}),c.jsx("span",{className:"flex-1 mx-3 border-b border-dotted border-gray-300 min-w-[40px]"})]})]})]}),c.jsx("div",{className:"my-8 flex items-center justify-center",children:c.jsx("div",{className:"w-full max-w-xs h-px bg-gradient-to-r from-transparent via-black/10 to-transparent"})}),!!M?.preface?.trim()&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{id:"ms-preface",className:"py-12","data-testid":"ms-section-preface",children:[c.jsx("h2",{className:"text-center text-base @lg:text-lg @3xl:text-xl tracking-[0.3em] uppercase font-bold mb-10 text-gray-700",children:Ze.preface}),c.jsx(qr,{value:M?.preface||"",onSave:async x=>{await G("PATCH",`/api/books/${r}`,{preface:x})}
200,bookId:r,field:"book:preface",className:"text-sm md:text-[15px] leading-[1.95] text-gray-800 w-full",testId:"ms-edit-preface",onStatusChange:x=>Et(x)})]}),c.jsx("div",{className:"my-8 flex items-center justify-center",children:c.jsx("div",{className:"w-full max-w-xs h-px bg-gradient-to-r from-transparent via-black/10 to-transparent"})})]}),!!M?.acknowledgments?.trim()&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{id:"ms-acknowledgments",className:"py-12","data-testid":"ms-section-acknowledgments",children:[c.jsx("h2",{className:"text-center text-base @lg:text-lg @3xl:text-xl tracking-[0.3em] uppercase font-bold mb-10 text-gray-700",children:Ze.acknowledgments}),c.jsx(qr,{value:M?.acknowledgments||"",onSave:async x=>{await G("PATCH",`/api/books/${r}`,{acknowledgments:x})},bookId:r,field:"book:acknowledgments",className:"text-sm md:text-[15px] leading-[1.95] text-gray-800 w-full",testId:"ms-edit-acknowledgments",onStatusChange:x=>Et(x)})]}),c.jsx("div",{className:"my-8 flex items-center justify-center",children:c.jsx("div",{className:"w-full max-w-xs h-px bg-gradient-to-r from-transparent via-black/10 to-transparent"})})]}),(()=>{const x=[...M?.chapters||[]].sort((w,T)=>w.orderIndex-T.orderIndex);return x.map((w,T)=>c.jsxs("div",{children:[c.jsxs("div",{id:`ms-chapter-${T}`,className:K("py-12 relative group/chapter",bn&&"ring-1 ring-gray-200/50 rounded-lg px-2 md:px-4 bg-gray-50/30"),"data-testid":`ms-section-chapter-${w.id}`,children:[bn&&c.jsxs("div",{className:"absolute -top-3 right-2 md:right-4 flex items-center gap-1 opacity-0 group-hover/chapter:opacity-100 transition-opacity z-20 bg-white rounded-full shadow-md border border-gray-200 px-1.5 py-0.5","data-testid":`chapter-toolbar-${w.id}`,children:[c.jsx("button",{onClick:()=>{if(T>0){const A=x[T-1];qc.mutate({swaps:[{id:String(w.id),newIndex:A.orderIndex},{id:String(A.id),newIndex:w.orderIndex}]})}},disabled:T===0,className:"p-1 text-gray-400 hover:text-gray-700 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Mover para cima","data-testid":`button-move-up-${w.id}`,children:c.jsx(Dx,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>{if(T<x.length-1){const A=x[T+1];qc.mutate({swaps:[{id:String(w.id),newIndex:A.orderIndex},{id:String(A.id),newIndex:w.orderIndex}]})}},disabled:T===x.length-1,className:"p-1 text-gray-400 hover:text-gray-700 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Mover para baixo","data-testid":`button-move-down-${w.id}`,children:c.jsx(Px,{className:"w-4 h-4"})}),c.jsx("div",{className:"w-px h-4 bg-gray-200 mx-0.5"}),c.jsx("button",{onClick:()=>Kc.mutate(w.orderIndex+1),className:"p-1 text-gray-400 hover:text-emerald-600 transition-colors",title:"Adicionar capÃtulo depois","data-testid":`button-add-after-${w.id}`,children:c.jsx(gd,{className:"w-4 h-4"})}),c.jsx("div",{className:"w-px h-4 bg-gray-200 mx-0.5"}),c.jsx("button",{onClick:()=>Ao({id:String(w.id),title:w.title}),className:"p-1 text-gray-400 hover:text-red-500 transition-colors",title:"Excluir capÃtulo","data-testid":`button-delete-chapter-${w.id}`,children:c.jsx(jn,{className:"w-4 h-4"})})]}),c.jsxs("div",{className:"text-center mb-10",children:[c.jsx("p",{className:"text-[10px] md:text-xs uppercase tracking-[0.4em] text-gray-400 font-sans mb-2",children:yx(M?.language,T)}),c.jsx($a,{value:w.title,onSave:async A=>{await G("PATCH",`/api/chapters/${w.id}`,{title:A})},bookId:r,field:`chapter:${w.id}:title`,testId:`ms-edit-chapter-title-${T}`,className:"text-lg @lg:text-xl @3xl:text-2xl font-bold tracking-wide text-center text-gray-800",onStatusChange:A=>Et(A),isSaveAllowed:()=>!Xe.current.has(String(w.id))}),w.containsAdultContent?c.jsx("div",{className:"flex justify-center mt-3",children:c.jsxs("span",{title:"Este capÃtulo foi sinalizado como conteúdo adulto pelo detector automático. Pode ser rejeitado por Amazon KDP, Apple Books e Kobo.",className:"inline-flex items-center gap-1.5 text-[10px] md:text-xs font-bold uppercase tracking-widest px-2.5 py-1 rounded-full border border-amber-500/40 bg-amber-500/10 text-amber-700","data-testid":`badge-adult-content-${w.id}`,children:[c.jsx("span",{children:"â ï¸"}),c.jsx("span",{children:"18+ Conteúdo adulto"})]})}):null,c.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4 opacity-20",children:[c.jsx("div",{className:"w-12 h-px bg-gray-400"}),c.jsx("div",{className:"w-1.5 h-1.5 rotate-45 border border-gray-400"}),c.jsx("div",{className:"w-12 h-px bg-gray-400"})]})]}),c.jsx(pC,{value:w.content||"",onSave:async A=>
200{await G("PATCH",`/api/chapters/${w.id}`,{content:A})},bookId:r,field:`chapter:${w.id}:content`,className:"text-sm md:text-[15px] leading-[1.95] text-gray-800 w-full",testId:`ms-edit-chapter-content-${T}`,onStatusChange:A=>Et(A),isSaveAllowed:()=>!Xe.current.has(String(w.id))})]}),c.jsx("div",{className:"my-8 flex items-center justify-center",children:c.jsx("div",{className:"w-full max-w-xs h-px bg-gradient-to-r from-transparent via-black/10 to-transparent"})})]},w.id))})(),bn&&M?.chapters&&M.chapters.length>0&&c.jsxs("div",{className:"flex justify-center gap-3 py-4",children:[c.jsxs("button",{onClick:()=>{const x=[...M.chapters].sort((T,A)=>T.orderIndex-A.orderIndex),w=x[x.length-1]?.orderIndex||0;Kc.mutate(w+1)},className:"flex items-center gap-2 px-4 py-2 text-xs font-sans text-gray-500 hover:text-emerald-600 bg-white/80 hover:bg-emerald-50 border border-dashed border-gray-300 hover:border-emerald-300 rounded-lg transition-all","data-testid":"button-add-chapter-end",children:[c.jsx(gd,{className:"w-4 h-4"}),"Adicionar capÃtulo"]}),c.jsxs("button",{onClick:()=>Cr(!0),className:"flex items-center gap-2 px-4 py-2 text-xs font-sans text-blue-500 hover:text-blue-700 bg-white/80 hover:bg-blue-50 border border-dashed border-blue-300 hover:border-blue-400 rounded-lg transition-all","data-testid":"button-import-chapters",children:[c.jsx(sr,{className:"w-4 h-4"}),"Importar do PDF ou Word"]})]}),(!M?.chapters||M.chapters.length===0)&&c.jsx("div",{className:"flex justify-center py-6",children:c.jsxs("button",{onClick:()=>Cr(!0),className:"flex items-center gap-3 px-6 py-3 text-sm font-sans text-blue-600 hover:text-blue-800 bg-blue-50 hover:bg-blue-100 border border-blue-200 hover:border-blue-300 rounded-xl transition-all shadow-sm","data-testid":"button-import-chapters-empty",children:[c.jsx(sr,{className:"w-5 h-5"}),"Importar capÃtulos de um PDF ou Word"]})}),Eo&&hr.createPortal(c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm","data-testid":"delete-chapter-modal",children:c.jsxs("div",{className:"bg-white rounded-xl shadow-2xl p-6 max-w-sm mx-4 font-sans",children:[c.jsx("h3",{className:"text-lg font-bold text-gray-800 mb-2",children:"Excluir capÃtulo?"}),c.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Tem certeza que deseja excluir o capÃtulo:"}),c.jsxs("p",{className:"text-sm font-semibold text-gray-800 mb-4",children:['"',Eo.title,'"']}),c.jsx("p",{className:"text-xs text-gray-500 mb-6",children:"Esta ação não pode ser desfeita. O capÃtulo será removido permanentemente do seu livro e do sumário."}),c.jsxs("div",{className:"flex gap-3 justify-end",children:[c.jsx("button",{onClick:()=>Ao(null),className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800 bg-gray-100 hover:bg-gray-200 rounded-lg transition-colors","data-testid":"button-cancel-delete",children:"Cancelar"}),c.jsxs("button",{onClick:()=>Wo.mutate(Eo.id),disabled:Wo.isPending,className:"px-4 py-2 text-sm text-white bg-red-500 hover:bg-red-600 disabled:opacity-50 rounded-lg transition-colors flex items-center gap-2","data-testid":"button-confirm-delete",children:[Wo.isPending?c.jsx(ge,{className:"w-3 h-3 animate-spin"}):c.jsx(jn,{className:"w-3 h-3"}),"Excluir"]})]})]})}),document.body),Ym&&(()=>{const x=A=>!A?.extractedText||A.extractedText.length<=50?!1:A.type==="pdf"||A.type==="file",w=A=>{const _=(A?.title||"").toLowerCase(),ye=(A?.metadata?.mimetype||"").toLowerCase();return _.endsWith(".docx")||ye.includes("wordprocessingml")},T=(Ue||[]).filter(x);return hr.createPortal(c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm","data-testid":"import-chapters-modal",children:c.jsxs("div",{className:"bg-white rounded-xl shadow-2xl p-6 max-w-md mx-4 font-sans",children:[c.jsxs("h3",{className:"text-lg font-bold text-gray-800 mb-2 flex items-center gap-2",children:[c.jsx(sr,{className:"w-5 h-5 text-blue-500"}),"Importar capÃtulos do PDF ou Word"]}),c.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Envie um arquivo PDF ou Word (.docx) agora ou selecione um da sua Base de Conhecimento. A SÃBHIA vai dividir o texto automaticamente em capÃtulos, preservando o conteúdo original."}),c.jsxs("div",{className:"mb-4",children:[c.jsx("input",{ref:Oc,type:"file",accept:".pdf,.docx,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document",className:"hidden","data-testid":"input-import-upload-file",onChange:async A=>{const _=A.target.files?.[0];if(A.target&&(A.target.value=""),!_)return;const ye=_.name.toLowerCase().split(".").pop()||"";if(ye!=="pdf"&&ye!=="docx"){Kt("error"),Jn("Tipo de arquivo não suportado. Envie PDF ou DOCX.");return}if(_.size>500*1024*1024){Kt("error"),Jn("Arquivo muito grande. O tamanho máximo é 500MB.");return}
200Ac(!0),Io(_.name),Jn(""),Kt("uploading");try{const Se=new FormData;Se.append("file",_);const ut=await fetch(`/api/books/${r}/sources/upload`,{method:"POST",body:Se,credentials:"include"});if(!ut.ok){const yt=await ut.json().catch(()=>({}));throw new Error(yt.message||"Não foi possÃvel enviar o arquivo.")}const Ig=await ut.json();Kt("extracting"),H.invalidateQueries({queryKey:[`/api/books/${r}/sources`]});const Pg=Date.now(),Rg=300*1e3;let rd=!1;for(;Date.now()-Pg<Rg;){await new Promise(yt=>setTimeout(yt,1500));try{const yt=await fetch(`/api/books/${r}/sources`,{credentials:"include"});if(yt.ok){const la=await yt.json(),Ar=Array.isArray(la)?la.find(Dg=>Dg.id===Ig.id):null;if(Ar?.status==="ready"&&Ar?.extractedText&&Ar.extractedText.length>50){rd=!0,H.setQueryData([`/api/books/${r}/sources`],la);break}if(Ar?.status==="error")throw new Error(Ar.errorMessage||"Erro na extração do texto.")}}catch(yt){if(yt?.message&&/extra/i.test(yt.message))throw yt}}if(!rd)throw new Error("A extração demorou muito. Tente novamente em instantes.");Kt("ready"),H.invalidateQueries({queryKey:[`/api/books/${r}/sources`]})}catch(Se){Kt("error"),Jn(Se?.message||"Erro ao enviar arquivo.")}finally{Ac(!1)}}}),c.jsxs("button",{onClick:()=>Oc.current?.click(),disabled:jr||Ms,className:"w-full flex items-center justify-center gap-2 px-4 py-3 text-sm font-medium text-blue-700 bg-blue-50 hover:bg-blue-100 border border-dashed border-blue-300 hover:border-blue-400 rounded-lg transition-all disabled:opacity-60 disabled:cursor-not-allowed","data-testid":"button-upload-file-import-modal",children:[jr?c.jsx(ge,{className:"w-4 h-4 animate-spin"}):c.jsx(Ka,{className:"w-4 h-4"}),jr?"Enviando...":"Enviar arquivo .pdf ou .docx"]}),yn&&c.jsxs("div",{className:"mt-3","data-testid":`upload-status-${yn}`,children:[yn==="uploading"&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-600",children:[c.jsx("span",{className:"truncate pr-2",children:Oo}),c.jsx("span",{children:"Enviando arquivo..."})]}),c.jsx("div",{className:"h-1.5 w-full bg-gray-200 rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full w-1/3 bg-blue-500 animate-pulse"})})]}),yn==="extracting"&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-600",children:[c.jsx("span",{className:"truncate pr-2",children:Oo}),c.jsx("span",{children:"Extraindo texto..."})]}),c.jsx("div",{className:"h-1.5 w-full bg-gray-200 rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full w-2/3 bg-blue-500 animate-pulse"})})]}),yn==="ready"&&c.jsxs("div",{className:"flex items-center gap-2 text-xs text-emerald-700 bg-emerald-50 border border-emerald-200 rounded-lg px-3 py-2",children:[c.jsx(Mn,{className:"w-4 h-4"}),c.jsxs("span",{className:"truncate",children:['Pronto! Selecione "',Oo,'" abaixo para importar.']})]}),yn==="error"&&c.jsxs("div",{className:"flex items-start gap-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2","data-testid":"upload-error-message",children:[c.jsx(vi,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),c.jsx("span",{children:Xm||"Erro ao enviar arquivo."})]})]})]}),T.length>0?c.jsx("div",{className:"space-y-2 mb-4 max-h-48 overflow-y-auto",children:T.map(A=>c.jsxs("button",{disabled:Ms,onClick:async()=>{Ec(!0);try{const ye=M?.chapters&&M.chapters.length>0?confirm("Deseja substituir os capÃtulos existentes? Clique 'OK' para substituir ou 'Cancelar' para adicionar ao final."):!1,ut=await(await G("POST",`/api/books/${r}/import-chapters`,{sourceId:A.id,replaceExisting:ye})).json();H.invalidateQueries({queryKey:[`/api/books/${r}`]}),Cr(!1),Kt(""),Io(""),Jn(""),alert(`${ut.imported} capÃtulos importados com sucesso!`)}catch(_){alert(_.message||"Erro ao importar capÃtulos")}finally{Ec(!1)}},className:"w-full text-left px-4 py-3 rounded-lg border border-gray-200 hover:border-blue-300 hover:bg-blue-50 transition-all flex items-center gap-3 disabled:opacity-50","data-testid":`import-source-${A.id}`,children:[w(A)?c.jsx(rn,{className:"w-4 h-4 text-blue-600 flex-shrink-0","data-testid":`icon-word-${A.id}`}):c.jsx(sr,{className:"w-4 h-4 text-red-500 flex-shrink-0","data-testid":`icon-pdf-${A.id}`}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-sm font-medium text-gray-800 truncate",children:A.title}),c.jsxs("p",{className:"text-xs text-gray-500",children:[w(A)?"Word":"PDF"," · ",Math.round((A.extractedText?.length||0)/1e3),"k caracteres"]})]}),Ms&&c.jsx(ge,{className:"w-4 h-4 animate-spin text-blue-500"})]},A.id))}):!jr&&yn!=="extracting"?c.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-amber-50 border border-amber-200","data-testid":"empty-import-sources",children:[c.jsx("p",{className:"text-sm text-amber-800 font-medium mb-1",children:"Nenhum arquivo PDF ou Word disponÃvel ainda."}),c.jsx("p",{className:"text-xs text-amber-700",children:"Use o botão acima para enviar seu manuscrito (.pdf ou .docx) agora â ele também ficará salvo na sua Base de Conhecimento."})]}):null,c.jsx("div",{className:"flex justify-end",children:c.jsx("button",{onClick:()=>{Cr(!1),Kt(""),Io(""),Jn("")},disabled:Ms||jr,className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800 bg-gray-100 hover:bg-gray-200 rounded-lg transition-colors disabled:opacity-50","data-testid":"button-cancel-import",children:"Fechar"})})]})}),document.body)})(),!!M?.closingMessage?.trim()&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{id:"ms-closing",className:"py-12","data-testid":"ms-section-closing",children:[c.jsx("h2",{className:"text-center text-base @lg:text-lg @3xl:text-xl tracking-[0.3em] uppercase font-bold mb-10 text-gray-700",children:Ze.authorMessage}),c.jsx(qr,{value:M?.closingMessage||"",onSave:async x=>{await G("PATCH",`/api/books/${r}`,{closingMessage:x})},bookId:r,field:"book:closingMessage",className:"text-sm md:text-[15px] leading-[1.95] text-gray-800 w-full",testId:"ms-edit-closing",onStatusChange:x=>Et(x)})]}),c.jsx("div",{className:"my-8 flex items-center justify-center",children:c.jsx("div",{className:"w-full max-w-xs h-px bg-gradient-to-r from-transparent via-black/10 to-transparent"})})]}),!!M?.bibliography?.trim()&&c.jsxs("div",{id:"ms-bibliography",className:"py-12 pb-16","data-testid":"ms-section-bibliography",children:[c.jsx("h2",{className:"text-center text-base @lg:text-lg @3xl:text-xl tracking-[0.3em] uppercase font-bold mb-10 text-gray-700",children:Ze.bibliography}),c.jsx(qr,{value:M?.bibliography||"",onSave:async x=>{await G("PATCH",`/api/books/${r}`,{bibliography:x})},bookId:r,field:"book:bibliography",className:"text-xs md:text-sm leading-[1.8] text-gray-700 w-full",testId:"ms-edit-bibliography",onStatusChange:x=>Et(x)})]}),c.jsx("div",{className:"py-12 flex flex-col items-center gap-4 opacity-20",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-12 h-px bg-gray-400"}),c.jsx("div",{className:"text-gray-400 text-sm",children:Ze.end}),c.jsx("div",{className:"w-12 h-px bg-gray-400"})]})})]}):c.jsx("div",{className:"min-h-full flex flex-col items-center justify-center p-4 pb-32 md:pb-4",children:c.jsxs("div",{className:"w-full max-w-lg mx-auto",children:[c.jsxs("div",{className:"flex flex-col items-center mb-8",children:[c.jsx("div",{className:"w-20 h-20 rounded-full bg-gradient-to-br from-emerald-400 to-teal-600 flex items-center justify-center mb-6 shadow-lg shadow-emerald-500/20",children:c.jsx(Ir,{className:"w-10 h-10 text-white"})}),c.jsx("h3",{className:"text-2xl md:text-3xl font-heading font-bold text-center text-white mb-2","data-testid":"text-needs-generation",children:t("needsGeneration.title")}),c.jsx("p",{className:"text-sm text-gray-400 text-center max-w-md",children:t("needsGeneration.subtitle")})]}),c.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-2xl p-6 mb-8",children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("span",{className:"text-xs uppercase tracking-widest text-gray-400 font-bold",children:t("needsGeneration.yourBook")}),c.jsxs(ar,{variant:"outline",className:"text-emerald-400 border-emerald-400/30 text-xs",children:[M?.chapters?.length||0," ",t("needsGeneration.chapters")]})]}),c.jsxs("div",{className:"space-y-2",children:[M?.chapters?.slice(0,5).map((x,w)=>c.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-300",children:[c.jsx("span",{className:"text-xs font-mono text-gray-500 w-6 text-right",children:String(w+1).padStart(2,"0")}),c.jsx("span",{className:"truncate",children:x.title})]},x.id)),(M?.chapters?.length||0)>5&&c.jsxs("div",{className:"text-xs text-gray-500 pl-9",children:["+ ",(M?.chapters?.length||0)-5," ",t("needsGeneration.remainingChapters")]})]})]}),c.jsx(Y,{"data-testid":"button-generate-book",onClick:()=>Fs(!0),disabled:tt.isPending||W,className:"w-full h-14 bg-gradient-to-r from-emerald-500 to-teal-500 hover:from-emerald-600 hover:to-teal-600 text-white rounded-2xl text-lg font-bold shadow-lg shadow-emerald-500/20 transition-all duration-300",children:tt.isPending?c.jsxs(c.Fragment,{children:[c.jsx(ge,{className:"w-5 h-5 animate-spin mr-2"}),t("needsGeneration.starting")]}):c.jsxs(c.Fragment,{children:[c.jsx(oe,{className:"w-5 h-5 mr-2"}),t("needsGeneration.writeFullBook")]})}),c.jsx("p",{className:"text-center text-xs text-gray-500 mt-4",children:t("needsGeneration.coherenceNote")})]})})}):null]})]},s)})]}),c.jsx("div",{className:K("hidden lg:block fixed right-4 top-20 w-[300px] overflow-y-auto z-30",n
200d&&"pb-2"),style:{maxHeight:"calc(100vh - 6rem)"},children:c.jsx(pd,{bookId:r,currentStep:"write",inProgressSteps:{write:W,cover:Dc,translate:Lc},onSelectCover:Ag,enableTranslationLinks:!0})})]})})]}),c.jsx(zr,{open:C,onOpenChange:j,children:c.jsxs(Br,{side:"right",mobileViewport:"fullscreen",preventRootScroll:!0,className:"w-full max-w-[560px] border-l border-white/10 bg-[#0c0c0e] p-0 flex flex-col overflow-hidden",children:[c.jsxs(Ha,{className:"p-6 border-b border-white/5 bg-background/50 backdrop-blur-md",children:[c.jsxs(Fa,{className:"text-white flex items-center gap-2",children:[c.jsx(oe,{className:"w-5 h-5 text-amber-300"}),"Estilo Editorial"]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Ajuste como a IA escreve seu livro. Force um estilo especifico ou marque trechos verbatim que devem aparecer palavra-por-palavra."})]}),c.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:r&&c.jsx(a0,{bookId:r})})]})}),c.jsx(zr,{open:y,onOpenChange:k,children:c.jsxs(Br,{side:"right",mobileViewport:"fullscreen",preventRootScroll:!0,
200className:"w-full max-w-[440px] border-l border-white/10 bg-[#0c0c0e] p-0 flex flex-col overflow-hidden",children:[c.jsxs(Ha,{className:"p-6 border-b border-white/5 bg-background/50 backdrop-blur-md",children:[c.jsxs(Fa,{className:"text-white flex items-center gap-2",children:[c.jsx(Gt,{className:"w-5 h-5 text-primary"}),"Base de Conhecimento"]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"O cérebro do seu livro. Adicione textos, links, vÃdeos e arquivos."})]}),c.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r&&c.jsx(mx,{bookId:r})})]})}),!qe&&c.jsx("div",{className:"fixed bottom-6 right-6 z-50 hidden md:block",children:c.jsxs(zr,{children:[c.jsx(od,{asChild:!0,children:c.jsx("button",{className:"w-14 h-14 rounded-full bg-primary shadow-lg shadow-primary/30 flex items-center justify-center hover:scale-105 transition-transform",children:c.jsx("img",{src:"/images/sabhia-logo.webp",alt:"SÃBHIA",className:"w-10 h-10 rounded-full"})})}),c.jsxs(Br,{side:"right",mobileViewport:"fullscreen",preventRootScroll:!0,
200className:"w-[420px] p-0 bg-[#0c0c0e] border-l border-white/10 flex flex-col overflow-hidden",children:[c.jsxs("div",{className:"h-16 border-b border-white/5 flex items-center px-6 bg-white/5 justify-between shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"w-10 h-10 rounded-full overflow-hidden ring-2 ring-primary/30 shadow-lg shadow-primary/20 relative group",children:[c.jsx("img",{src:"/images/sabhia-logo.webp",alt:"SÃBHIA",className:"w-full h-full object-cover"}),c.jsx("div",{className:"absolute inset-0 bg-primary/30 blur-lg opacity-0 group-hover:opacity-100 transition-opacity rounded-full"})]}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-bold text-sm text-white",children:"SÃBHIA"}),c.jsxs("p",{className:"text-[10px] text-muted-foreground flex items-center gap-1.5",children:[c.jsx(oe,{className:"w-3 h-3 text-primary/60"}),"Arquitetura ⢠Planejamento ⢠Revisão"]})]})]}),c.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-white",children:c.jsx(Mx,{className:"w-4 h-4"})})]}),c.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 space-y-6",ref:Ws,children:[ta.map(x=>c.jsx("div",{className:`flex flex-col ${x.role==="user"?"items-end":"items-start"}`,children:c.jsxs("div",{className:`max-w-[90%] rounded-2xl p-4 text-sm leading-relaxed shadow-lg ${x.role==="user"?"bg-primary text-white shadow-primary/10 rounded-br-none":"bg-white/5 border border-white/5 text-muted-foreground rounded-bl-none"}`,children:[x.agentLogs&&x.agentLogs.length>0&&c.jsxs("div",{className:"mb-4 space-y-2 bg-black/20 p-3 rounded-lg border border-white/5",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("p",{className:"text-[10px] uppercase tracking-widest text-muted-foreground/50 font-bold",children:t("chat.workflowTitle")}),c.jsx(Gt,{className:"w-3 h-3 text-primary/50"})]}),x.agentLogs.map((w,T)=>c.jsxs("div",{className:"flex items-start gap-2 text-xs border-l border-white/10 pl-2 ml-1",children:[c.jsx("div",{className:"mt-0.5",children:w.status==="thinking"?c.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse shadow-[0_0_8px_hsl(178_86%_39%)]"}):c.jsx(Mn,{className:"w-3 h-3 text-emerald-500/80"})}),c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:K("font-bold text-[10px] uppercase",w.status==="thinking"?"text-primary":"text-muted-foreground"),children:w.agent}),c.jsx("span",{className:"text-muted-foreground/80 leading-snug",children:w.message})]})]},T))]}),x.content&&c.jsx("div",{className:"animate-in fade-in slide-in-from-bottom-2 duration-300",children:x.content})]})},x.id)),ra&&c.jsx("div",{className:"flex justify-start",children:c.jsxs("div",{className:"bg-white/5 border border-white/5 rounded-2xl rounded-bl-none p-4 flex items-center gap-2",children:[c.jsx("span",{className:"w-2 h-2 bg-primary/50 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),c.jsx("span",{className:"w-2 h-2 bg-primary/50 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),c.jsx("span",{className:"w-2 h-2 bg-primary/50 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})})]}),c.jsxs("div",{className:"p-4 border-t border-white/5 bg-background/50 backdrop-blur-md shrink-0",children:[c.jsx("div",{className:"flex items-center gap-2 mb-3 overflow-x-auto pb-2 scrollbar-none",children:c.jsxs(Y,{onClick:()=>k(!0),variant:"outline",size:"sm",className:"h-8 border-white/10 bg-primary/10 text-primary hover:text-primary hover:bg-primary/20 rounded-full px-3 text-xs gap-2 border-primary/20 transition-all hover:scale-105 shadow-[0_0_10px_hsl(178_86%_39%_/_0.2)]",children:[c.jsx(Gt,{className:"w-3.5 h-3.5"}),"Base de Conhecimento",Ue&&Ue.length>0&&c.jsx(ar,{variant:"secondary",className:"bg-primary/20 text-primary text-[10px] px-1.5 py-0 h-4 ml-1",children:Ue.length})]})}),c.jsxs("div",{className:"relative",children:[c.jsx(rs,{value:Nn,onChange:x=>na(x.target.value),onKeyDown:x=>x.key==="Enter"&&Js(),placeholder:t("chat.placeholder"),className:"bg-white/5 border-white/10 h-14 pr-12 pl-4 rounded-xl focus-visible:ring-primary/50 text-white placeholder:text-muted-foreground
200/50 shadow-inner"}),c.jsx("div",{className:"absolute right-2 top-2 bottom-2 flex items-center gap-1",children:c.jsx(Y,{size:"icon",onClick:Js,disabled:!Nn.trim(),className:"h-10 w-10 rounded-lg bg-primary text-white hover:bg-primary/90 transition-all shadow-[0_0_15px_-3px_hsl(178_86%_39%_/_0.5)] disabled:opacity-30 disabled:cursor-not-allowed",children:c.jsx(ad,{className:"w-4 h-4"})})})]}),c.jsxs("p",{className:"text-[10px] text-center text-muted-foreground/30 mt-3 flex items-center justify-center gap-1",children:[c.jsx(oe,{className:"w-3 h-3"}),"Powered by Gemini ⢠Multi-Agent System"]})]})]})]})}),nd&&c.jsx(xC,{bookTitle:bt,planData:V,generationPrice:ea,onUnlock:ia,outline:wg,onHeightChange:d}),qe&&c.jsx(hx,{bookId:r,currentStep:"write"}),!qe&&c.jsx("div",{className:"md:hidden",children:c.jsxs(zr,{children:[c.jsx(od,{asChild:!0,children:c.jsx("div",{className:"fixed left-0 right-0 z-50 cursor-pointer border-t border-white/10 bg-[#0c0c0e] p-4 pb-[max(2rem,env(safe-area-inset-bottom))]",style:{bottom:"calc(var(--mobile-route-fixed-action-clearance) + 12px)"},"data-fixed-surface":"editor-chat-trigger",children:c.jsx("div",{className:"relative pointer-events-none",children:c.jsxs("div",{className:"bg-white/5 border border-white/10 h-12 w-full rounded-xl flex items-center px-4 text-muted-foreground shadow-lg",children:[c.jsx("span",{className:"flex-1 text-sm","data-testid":"text-mobile-trigger",children:t("chat.placeholder")}),c.jsx("div",{className:"flex items-center gap-2",children:c.jsx("div",{className:"h-8 w-8 rounded-full overflow-hidden ring-2 ring-primary/30 shadow-[0_0_15px_-3px_hsl(178_86%_39%_/_0.5)]",children:c.jsx("img",{src:"/images/sabhia-logo.webp",alt:"SÃBHIA",className:"w-full h-full object-cover"})})})]})})})}),c.jsxs(Br,{side:"bottom",mobileViewport:"bottom-sheet",preventRootScroll:!0,
200className:"h-[85vh] p-0 bg-[#0c0c0e] border-t border-white/10 flex flex-col overflow-hidden rounded-t-[20px]",children:[c.jsx("div",{className:"h-1.5 w-12 bg-white/10 rounded-full mx-auto mt-3 mb-1"}),c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"h-14 border-b border-white/5 flex items-center px-6 justify-between shrink-0",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-full overflow-hidden ring-2 ring-primary/30 shadow-lg shadow-primary/20",children:c.jsx("img",{src:"/images/sabhia-logo.webp",alt:"SÃBHIA",className:"w-full h-full object-cover"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-bold text-sm text-white",children:"SÃBHIA"}),c.jsxs("p",{className:"text-[10px] text-muted-foreground flex items-center gap-1.5",children:[c.jsx(oe,{className:"w-3 h-3 text-primary/60"}),"Arquitetura ⢠Planejamento ⢠Revisão"]})]})]})}),c.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 space-y-4",ref:Us,children:[ta.map(x=>c.jsx("div",{className:`flex flex-col ${x.role==="user"?"items-end":"items-start"}`,children:c.jsxs("div",{className:`max-w-[90%] rounded-2xl p-4 text-sm leading-relaxed shadow-lg ${x.role==="user"?"bg-primary text-white shadow-primary/10 rounded-br-none":"bg-white/5 border border-white/5 text-muted-foreground rounded-bl-none"}`,children:[x.agentLogs&&x.agentLogs.length>0&&c.jsxs("div",{className:"mb-4 space-y-2 bg-black/20 p-3 rounded-lg border border-white/5",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("p",{className:"text-[10px] uppercase tracking-widest text-muted-foreground/50 font-bold",children:t("chat.workflowTitle")}),c.jsx(Gt,{className:"w-3 h-3 text-primary/50"})]}),x.agentLogs.map((w,T)=>c.jsxs("div",{className:"flex items-start gap-2 text-xs border-l border-white/10 pl-2 ml-1",children:[c.jsx("div",{className:"mt-0.5",children:w.status==="thinking"?c.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse shadow-[0_0_8px_hsl(178_86%_39%)]"}):c.jsx(Mn,{className:"w-3 h-3 text-emerald-500/80"})}),c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:K("font-bold text-[10px] uppercase",w.status==="thinking"?"text-primary":"text-muted-foreground"),children:w.agent}),c.jsx("span",{className:"text-muted-foreground/80 leading-snug",children:w.message})]})]},T))]}),x.content&&c.jsx("div",{className:"animate-in fade-in slide-in-from-bottom-2 duration-300",children:x.content})]})},x.id)),ra&&c.jsx("div",{className:"flex justify-start",children:c.jsxs("div",{className:"bg-white/5 border border-white/5 rounded-2xl rounded-bl-none p-4 flex items-center gap-2",children:[c.jsx("span",{className:"w-2 h-2 bg-primary/50 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),c.jsx("span",{className:"w-2 h-2 bg-primary/50 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),c.jsx("span",{className:"w-2 h-2 bg-primary/50 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})})]}),c.jsxs("div",{className:"shrink-0 border-t border-white/5 bg-background/50 p-4 pb-[max(2rem,env(safe-area-inset-bottom))] backdrop-blur-md md:pb-4",children:[c.jsx("div",{className:"flex items-center gap-2 mb-3 overflow-x-auto pb-1 scrollbar-none",children:c.jsxs(Y,{onClick:()=>k(!0),variant:"outline",size:"sm",className:"h-8 border-white/10 bg-primary/10 text-primary hover:text-primary hover:bg-primary/20 rounded-full px-3 text-xs gap-2 border-primary/20 shrink-0",children:[c.jsx(Gt,{className:"w-3.5 h-3.5"}),"Base de Conhecimento",Ue&&Ue.length>0&&c.jsx(ar,{variant:"secondary",className:"bg-primary/20 text-primary text-[10px] px-1.5 py-0 h-4 ml-1",children:Ue.length})]})}),c.jsxs("div",{className:"relative",children:[c.jsx(rs,{placeholder:t("chat.instructionPlaceholder"),className:"bg-white/5 border-white/10 text-white placeholder:text-muted-foreground/50 pr-24 h-12 rounded-xl focus-visible:ring-primary/50",value:Nn,onChange:x=>na(x.target.value),onKeyDown:x=>x.key==="Enter"&&Js()}),c.jsx("div",{className:"absolute right-2 top-2 bottom-2 flex items-center gap-1",children:Nn.trim()?c.jsx(Y,{size:"icon",className:"h-8 w-8 rounded-lg bg-primary hover:bg-primary/90 text-white transition-all",onClick:Js,children:c.jsx(ad,{
200className:"w-4 h-4"})}):c.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-lg text-muted-foreground hover:text-white hover:bg-white/10",onClick:()=>k(!0),children:c.jsx(Gt,{className:"w-4 h-4"})})})]})]})]})]})]})}),r&&c.jsx(s0,{bookId:r,open:Qm,onOpenChange:Mc}),c.jsx(i0,{open:!!le,onOpenChange:x=>!x&&ce(null),serviceTitle:le||"",status:"in_progress"}),c.jsx(Va,{open:O,onOpenChange:S,product:J,onConfirm:Mg,bookId:r,bookTitle:bt}),c.jsx(Qx,{open:N,onOpenChange:P,onConfirm:Tg,bookId:r,bookTitle:bt}),c.jsx(Va,{open:sg,onOpenChange:Rc,product:J,onConfirm:Eg,bookId:r,bookTitle:bt,orderType:kn?.type||"service_purchase"}),c.jsx(uC,{open:Qn,checking:_c,checkError:Hc,saving:$s.isPending,saveError:$s.error instanceof Error?$s.error.message:null,onRetryCheck:()=>void cg(),onSave:x=>$s.mutate(x)}),mg&&c.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 backdrop-blur-sm",onClick:()=>Uo(!1),children:c.jsxs("div",{className:"bg-[#1a1a2e] border border-white/10 rounded-2xl p-6 max-w-sm mx-4 shadow-2xl",onClick:x=>x.stopPropagation(),"data-testid":"dialog-delete-book",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/10 flex items-center justify-center",children:c.jsx(jn,{className:"w-5 h-5 text-red-400"})}),c.jsx("h3",{className:"text-lg font-bold text-white",children:"Apagar livro?"})]}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["Tem certeza que deseja apagar ",c.jsxs("strong",{className:"text-white",children:['"',bt,'"']}),"? Esta ação não pode ser desfeita e todos os dados do livro serão removidos."]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx(Y,{variant:"outline",className:"flex-1",onClick:()=>Uo(!1),"data-testid":"button-cancel-delete-book",children:"Cancelar"}),c.jsxs(Y,{className:"flex-1 bg-red-600 hover:bg-red-500 text-white",onClick:()=>Jo.mutate(),disabled:Jo.isPending,"data-testid":"button-confirm-delete-book",children:[Jo.isPending?c.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}):c.jsx(jn,{className:"w-4 h-4 mr-2"}),"Apagar"]})]})]})})]})}export{Dj 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.