showai-reader 0.13.15-reader.ytq46wui → 0.13.16-reader.6m5ebdeb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/chunks/{MultiLevelView-NDMQMWLQ.js → MultiLevelView-ZHIRKPVW.js} +1 -1
- package/chunks/RichTextEditor-FC2KCQQO.js +158 -0
- package/chunks/chunk-2RNYCCRC.js +1 -0
- package/chunks/{chunk-FTF6X2QC.js → chunk-RZVRGCWV.js} +1 -1
- package/chunks/chunk-Y6PMG2JD.js +8 -0
- package/index.js +1 -1
- package/manifest.json +4 -4
- package/package.json +1 -1
- package/{reader-YTQ46WUI.js → reader-6M5EBDEB.js} +45 -45
- package/chunks/RichTextEditor-QASVADBA.js +0 -158
- package/chunks/chunk-6IKOY4TJ.js +0 -8
- package/chunks/chunk-NFQ4LFVO.js +0 -1
- /package/{reader-YTQ46WUI.js.LEGAL.txt → reader-6M5EBDEB.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import{kb as Id,lb as $d,mb as Bd,nb as zd,ob as El,pb as Ml,qb as Al,rb as Hd,vb as oo,wb as _d}from"./chunk-RZVRGCWV.js";import"./chunk-3RZMLHCB.js";import"./chunk-JXKAISUX.js";import"./chunk-C4JCEMQN.js";import{A as pn,B as no,C as U,D as oe,E as yd,G as wd,K as vl,d as F,e as gd,f as ue,g as ti,h as wl,i as In,j as $n,k as ni,l as bd,m as Bn,n as Ot,o as qt,p as br,q as ht,r as xt,s as yr,t as ri,u as oi,v as ii,w as Q,x as kl,y as P,z as _}from"./chunk-KQR52I3G.js";import"./chunk-77DN5DLU.js";import"./chunk-4XY2ILUU.js";import"./chunk-FG7LVQNJ.js";import{a as xl,b as si,c as Ad,e as Td}from"./chunk-7G6RMB6W.js";import{a as gy,b as by}from"./chunk-DJ74RSYJ.js";import{K as Tu,P as mr,Q as ll,R as Ou,T as Lu,U as Pu,ba as vd,fa as Cd,ha as Ed,ia as Md,ja as Sl,ka as Nd,la as Rd,ma as Fe,na as Od,oa as Ld,qa as Pd,ra as ro}from"./chunk-Y6PMG2JD.js";import"./chunk-FEW7E4O3.js";import"./chunk-6EV5YHDY.js";import"./chunk-AIBH6MTQ.js";import{b as hr,c as Jo,d as Mu,e as Au}from"./chunk-5CXEJMFJ.js";import"./chunk-JPBV5VSZ.js";import{a as xd}from"./chunk-5AW2WUSZ.js";import{a as Vd}from"./chunk-RVTRPHGU.js";import"./chunk-DG67SWQA.js";import"./chunk-KF47DKNH.js";import{c as Cl,d as Sd}from"./chunk-263IJWXK.js";import{$ as Ku,A as $u,Ba as to,Bb as md,C as Bu,Ca as ul,D as Xo,E as zu,Ea as dl,Eb as ei,Fb as Ue,Gb as yl,Hb as kd,Ib as Pe,Ja as nd,Jb as Dd,Ka as rd,L as Hu,La as od,M as gr,N as Yo,Qa as id,T as _u,U as Vu,Va as Ut,W as ju,X as Fu,Ya as fl,Z as Wu,Za as sd,a as Go,aa as Uu,c as Kt,da as al,eb as pl,fb as hl,gb as ld,j as Nu,jb as ad,k as Ru,la as qu,lb as ml,mb as cd,n as Du,na as Gu,nb as gl,oa as Ju,ob as ud,pa as Xu,pb as dd,qa as Yu,qb as bl,ra as Qu,rb as On,sa as Zu,sb as Ln,ta as ed,tb as fd,ua as cl,ub as Pn,vb as Qo,xa as td,xb as Zo,y as Iu,yb as pd,zb as hd}from"./chunk-OMUYOHPU.js";import{a as wr,f as kr}from"./chunk-J6IRWTF7.js";import{a as my,c as he}from"./chunk-DCANE7XH.js";var bb=my((qR,gb)=>{function ob(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let n=e[t],r=typeof n;(r==="object"||r==="function")&&!Object.isFrozen(n)&&ob(n)}),e}var Ws=class{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function ib(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Mn(e,...t){let n=Object.create(null);for(let r in e)n[r]=e[r];return t.forEach(function(r){for(let o in r)n[o]=r[o]}),n}var ME="</span>",Qg=e=>!!e.scope,AE=(e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){let n=e.split(".");return[`${t}${n.shift()}`,...n.map((r,o)=>`${r}${"_".repeat(o+1)}`)].join(" ")}return`${t}${e}`},Xc=class{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=ib(t)}openNode(t){if(!Qg(t))return;let n=AE(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){Qg(t)&&(this.buffer+=ME)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}},Zg=(e={})=>{let t={children:[]};return Object.assign(t,e),t},Yc=class e{constructor(){this.rootNode=Zg(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(t){this.top.children.push(t)}openNode(t){let n=Zg({scope:t});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(t){return this.constructor._walk(t,this.rootNode)}static _walk(t,n){return typeof n=="string"?t.addText(n):n.children&&(t.openNode(n),n.children.forEach(r=>this._walk(t,r)),t.closeNode(n)),t}static _collapse(t){typeof t!="string"&&t.children&&(t.children.every(n=>typeof n=="string")?t.children=[t.children.join("")]:t.children.forEach(n=>{e._collapse(n)}))}},Qc=class extends Yc{constructor(t){super(),this.options=t}addText(t){t!==""&&this.add(t)}startScope(t){this.openNode(t)}endScope(){this.closeNode()}__addSublanguage(t,n){let r=t.root;n&&(r.scope=`language:${n}`),this.add(r)}toHTML(){return new Xc(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function jo(e){return e?typeof e=="string"?e:e.source:null}function sb(e){return sr("(?=",e,")")}function TE(e){return sr("(?:",e,")*")}function NE(e){return sr("(?:",e,")?")}function sr(...e){return e.map(n=>jo(n)).join("")}function RE(e){let t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function Us(...e){return"("+(RE(e).capture?"":"?:")+e.map(r=>jo(r)).join("|")+")"}function lb(e){return new RegExp(e.toString()+"|").exec("").length-1}function DE(e,t){let n=e&&e.exec(t);return n&&n.index===0}var OE=new RegExp(Us(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function eu(e,{joinWith:t}){let n=0;return e.map(r=>{n+=1;let o=n,i=jo(r),s="";for(;i.length>0;){let l=OE.exec(i);if(!l){s+=i;break}s+=i.substring(0,l.index),i=i.substring(l.index+l[0].length),l[0][0]==="\\"&&l[1]?s+="\\"+String(Number(l[1])+o):(s+=l[0],(l[0]==="("||/^\(\?[<']/.test(l[0]))&&n++)}return s}).map(r=>`(${r})`).join(t)}var LE=/\b\B/,ab="[a-zA-Z]\\w*",tu="[a-zA-Z_]\\w*",cb="\\b\\d+(\\.\\d+)?",ub="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",db="\\b(0b[01]+)",PE="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",IE=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=sr(t,/.*\b/,e.binary,/\b.*/)),Mn({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},e)},Fo={begin:"\\\\[\\s\\S]",relevance:0},$E={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Fo]},BE={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Fo]},zE={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},qs=function(e,t,n={}){let r=Mn({scope:"comment",begin:e,end:t,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let o=Us("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:sr(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},HE=qs("//","$"),_E=qs("/\\*","\\*/"),VE=qs("#","$"),jE={scope:"number",begin:cb,relevance:0},FE={scope:"number",begin:ub,relevance:0},WE={scope:"number",begin:db,relevance:0},KE={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Fo,{begin:/\[/,end:/\]/,relevance:0,contains:[Fo]}]},UE={scope:"title",begin:ab,relevance:0},qE={scope:"title",begin:tu,relevance:0},GE={begin:"\\.\\s*"+tu,relevance:0},JE=function(e){return Object.assign(e,{"on:begin":(t,n)=>{n.data._beginMatch=t[1]},"on:end":(t,n)=>{n.data._beginMatch!==t[1]&&n.ignoreMatch()}})},Fs=Object.freeze({__proto__:null,APOS_STRING_MODE:$E,BACKSLASH_ESCAPE:Fo,BINARY_NUMBER_MODE:WE,BINARY_NUMBER_RE:db,COMMENT:qs,C_BLOCK_COMMENT_MODE:_E,C_LINE_COMMENT_MODE:HE,C_NUMBER_MODE:FE,C_NUMBER_RE:ub,END_SAME_AS_BEGIN:JE,HASH_COMMENT_MODE:VE,IDENT_RE:ab,MATCH_NOTHING_RE:LE,METHOD_GUARD:GE,NUMBER_MODE:jE,NUMBER_RE:cb,PHRASAL_WORDS_MODE:zE,QUOTE_STRING_MODE:BE,REGEXP_MODE:KE,RE_STARTERS_RE:PE,SHEBANG:IE,TITLE_MODE:UE,UNDERSCORE_IDENT_RE:tu,UNDERSCORE_TITLE_MODE:qE});function XE(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function YE(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function QE(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=XE,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function ZE(e,t){Array.isArray(e.illegal)&&(e.illegal=Us(...e.illegal))}function e1(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function t1(e,t){e.relevance===void 0&&(e.relevance=1)}var n1=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");let n=Object.assign({},e);Object.keys(e).forEach(r=>{delete e[r]}),e.keywords=n.keywords,e.begin=sr(n.beforeMatch,sb(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},r1=["of","and","for","in","not","or","if","then","parent","list","value"],o1="keyword";function fb(e,t,n=o1){let r=Object.create(null);return typeof e=="string"?o(n,e.split(" ")):Array.isArray(e)?o(n,e):Object.keys(e).forEach(function(i){Object.assign(r,fb(e[i],t,i))}),r;function o(i,s){t&&(s=s.map(l=>l.toLowerCase())),s.forEach(function(l){let a=l.split("|");r[a[0]]=[i,i1(a[0],a[1])]})}}function i1(e,t){return t?Number(t):s1(e)?0:1}function s1(e){return r1.includes(e.toLowerCase())}var eb={},ir=e=>{console.error(e)},tb=(e,...t)=>{console.log(`WARN: ${e}`,...t)},qr=(e,t)=>{eb[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),eb[`${e}/${t}`]=!0)},Ks=new Error;function pb(e,t,{key:n}){let r=0,o=e[n],i={},s={};for(let l=1;l<=t.length;l++)s[l+r]=o[l],i[l+r]=!0,r+=lb(t[l-1]);e[n]=s,e[n]._emit=i,e[n]._multi=!0}function l1(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw ir("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Ks;if(typeof e.beginScope!="object"||e.beginScope===null)throw ir("beginScope must be object"),Ks;pb(e,e.begin,{key:"beginScope"}),e.begin=eu(e.begin,{joinWith:""})}}function a1(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw ir("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Ks;if(typeof e.endScope!="object"||e.endScope===null)throw ir("endScope must be object"),Ks;pb(e,e.end,{key:"endScope"}),e.end=eu(e.end,{joinWith:""})}}function c1(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function u1(e){c1(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),l1(e),a1(e)}function d1(e){function t(s,l){return new RegExp(jo(s),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(l?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(l,a){a.position=this.position++,this.matchIndexes[this.matchAt]=a,this.regexes.push([a,l]),this.matchAt+=lb(l)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let l=this.regexes.map(a=>a[1]);this.matcherRe=t(eu(l,{joinWith:"|"}),!0),this.lastIndex=0}exec(l){this.matcherRe.lastIndex=this.lastIndex;let a=this.matcherRe.exec(l);if(!a)return null;let c=a.findIndex((f,d)=>d>0&&f!==void 0),u=this.matchIndexes[c];return a.splice(0,c),Object.assign(a,u)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(l){if(this.multiRegexes[l])return this.multiRegexes[l];let a=new n;return this.rules.slice(l).forEach(([c,u])=>a.addRule(c,u)),a.compile(),this.multiRegexes[l]=a,a}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(l,a){this.rules.push([l,a]),a.type==="begin"&&this.count++}exec(l){let a=this.getMatcher(this.regexIndex);a.lastIndex=this.lastIndex;let c=a.exec(l);if(this.resumingScanAtSamePosition()&&!(c&&c.index===this.lastIndex)){let u=this.getMatcher(0);u.lastIndex=this.lastIndex+1,c=u.exec(l)}return c&&(this.regexIndex+=c.position+1,this.regexIndex===this.count&&this.considerAll()),c}}function o(s){let l=new r;return s.contains.forEach(a=>l.addRule(a.begin,{rule:a,type:"begin"})),s.terminatorEnd&&l.addRule(s.terminatorEnd,{type:"end"}),s.illegal&&l.addRule(s.illegal,{type:"illegal"}),l}function i(s,l){let a=s;if(s.isCompiled)return a;[YE,e1,u1,n1].forEach(u=>u(s,l)),e.compilerExtensions.forEach(u=>u(s,l)),s.__beforeBegin=null,[QE,ZE,t1].forEach(u=>u(s,l)),s.isCompiled=!0;let c=null;return typeof s.keywords=="object"&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),c=s.keywords.$pattern,delete s.keywords.$pattern),c=c||/\w+/,s.keywords&&(s.keywords=fb(s.keywords,e.case_insensitive)),a.keywordPatternRe=t(c,!0),l&&(s.begin||(s.begin=/\B|\b/),a.beginRe=t(a.begin),!s.end&&!s.endsWithParent&&(s.end=/\B|\b/),s.end&&(a.endRe=t(a.end)),a.terminatorEnd=jo(a.end)||"",s.endsWithParent&&l.terminatorEnd&&(a.terminatorEnd+=(s.end?"|":"")+l.terminatorEnd)),s.illegal&&(a.illegalRe=t(s.illegal)),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map(function(u){return f1(u==="self"?s:u)})),s.contains.forEach(function(u){i(u,a)}),s.starts&&i(s.starts,l),a.matcher=o(a),a}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=Mn(e.classNameAliases||{}),i(e)}function hb(e){return e?e.endsWithParent||hb(e.starts):!1}function f1(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return Mn(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:hb(e)?Mn(e,{starts:e.starts?Mn(e.starts):null}):Object.isFrozen(e)?Mn(e):e}var p1="11.12.0",Zc=class extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}},Jc=ib,nb=Mn,rb=Symbol("nomatch"),h1=7,mb=function(e){let t=Object.create(null),n=Object.create(null),r=[],o=!0,i="Could not find the language '{}', did you forget to load/include a language module?",s={disableAutodetect:!0,name:"Plain text",contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:Qc};function a(N){return l.noHighlightRe.test(N)}function c(N){let j=N.className+" ";j+=N.parentNode?N.parentNode.className:"";let ne=l.languageDetectRe.exec(j);if(ne){let Ce=L(ne[1]);return Ce||(tb(i.replace("{}",ne[1])),tb("Falling back to no-highlight mode for this block.",N)),Ce?ne[1]:"no-highlight"}return j.split(/\s+/).find(Ce=>a(Ce)||L(Ce))}function u(N,j,ne){let Ce="",me="";typeof j=="object"?(Ce=N,ne=j.ignoreIllegals,me=j.language):(qr("10.7.0","highlight(lang, code, ...args) has been deprecated."),qr("10.7.0",`Please use highlight(code, options) instead.
|
|
2
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),me=N,Ce=j),ne===void 0&&(ne=!0);let Se={code:Ce,language:me};De("before:highlight",Se);let wt=Se.result?Se.result:f(Se.language,Se.code,ne);return wt.code=Se.code,De("after:highlight",wt),wt}function f(N,j,ne,Ce){let me=Object.create(null);function Se(O,B){return O.keywords[B]}function wt(){if(!q.keywords){Re.addText(re);return}let O=0;q.keywordPatternRe.lastIndex=0;let B=q.keywordPatternRe.exec(re),J="";for(;B;){J+=re.substring(O,B.index);let ae=ut.case_insensitive?B[0].toLowerCase():B[0],Ee=Se(q,ae);if(Ee){let[Le,Zs]=Ee;if(Re.addText(J),J="",me[ae]=(me[ae]||0)+1,me[ae]<=h1&&(Y+=Zs),Le.startsWith("_"))J+=B[0];else{let Xr=ut.classNameAliases[Le]||Le;Ke(B[0],Xr)}}else J+=B[0];O=q.keywordPatternRe.lastIndex,B=q.keywordPatternRe.exec(re)}J+=re.substring(O),Re.addText(J)}function An(){if(re==="")return;let O=null;if(typeof q.subLanguage=="string"){if(!t[q.subLanguage]){Re.addText(re);return}O=f(q.subLanguage,re,!0,Ft[q.subLanguage]),Ft[q.subLanguage]=O._top}else O=p(re,q.subLanguage.length?q.subLanguage:null);q.relevance>0&&(Y+=O.relevance),Re.__addSublanguage(O._emitter,O.language)}function we(){q.subLanguage!=null?An():wt(),re=""}function Ke(O,B){O!==""&&(Re.startScope(B),Re.addText(O),Re.endScope())}function Tn(O,B){let J=1,ae=B.length-1;for(;J<=ae;){if(!O._emit[J]){J++;continue}let Ee=ut.classNameAliases[O[J]]||O[J],Le=B[J];Ee?Ke(Le,Ee):(re=Le,wt(),re=""),J++}}function Mt(O,B){return O.scope&&typeof O.scope=="string"&&Re.openNode(ut.classNameAliases[O.scope]||O.scope),O.beginScope&&(O.beginScope._wrap?(Ke(re,ut.classNameAliases[O.beginScope._wrap]||O.beginScope._wrap),re=""):O.beginScope._multi&&(Tn(O.beginScope,B),re="")),q=Object.create(O,{parent:{value:q}}),q}function se(O,B,J){let ae=DE(O.endRe,J);if(ae){if(O["on:end"]){let Ee=new Ws(O);O["on:end"](B,Ee),Ee.isMatchIgnored&&(ae=!1)}if(ae){for(;O.endsParent&&O.parent;)O=O.parent;return O}}if(O.endsWithParent)return se(O.parent,B,J)}function At(O){return q.matcher.regexIndex===0?(re+=O[0],1):(ar=!0,0)}function ct(O){let B=O[0],J=O.rule,ae=new Ws(J),Ee=[J.__beforeBegin,J["on:begin"]];for(let Le of Ee)if(Le&&(Le(O,ae),ae.isMatchIgnored))return At(B);return J.skip?re+=B:(J.excludeBegin&&(re+=B),we(),!J.returnBegin&&!J.excludeBegin&&(re=B)),Mt(J,O),J.returnBegin?0:B.length}function ze(O){let B=O[0],J=j.substring(O.index),ae=se(q,O,J);if(!ae)return rb;let Ee=q;q.endScope&&q.endScope._wrap?(we(),Ke(B,q.endScope._wrap)):q.endScope&&q.endScope._multi?(we(),Tn(q.endScope,O)):Ee.skip?re+=B:(Ee.returnEnd||Ee.excludeEnd||(re+=B),we(),Ee.excludeEnd&&(re=B));do q.scope&&Re.closeNode(),!q.skip&&!q.subLanguage&&(Y+=q.relevance),q=q.parent;while(q!==ae.parent);return ae.starts&&Mt(ae.starts,O),Ee.returnEnd?0:B.length}function cn(){let O=[];for(let B=q;B!==ut;B=B.parent)B.scope&&O.unshift(B.scope);O.forEach(B=>Re.openNode(B))}let Nn={};function Rn(O,B){let J=B&&B[0];if(re+=O,J==null)return we(),0;if(Nn.type==="begin"&&B.type==="end"&&Nn.index===B.index&&J===""){if(re+=j.slice(B.index,B.index+1),!o){let ae=new Error(`0 width match regex (${N})`);throw ae.languageName=N,ae.badRule=Nn.rule,ae}return 1}if(Nn=B,B.type==="begin")return ct(B);if(B.type==="illegal"&&!ne){let ae=new Error('Illegal lexeme "'+J+'" for mode "'+(q.scope||"<unnamed>")+'"');throw ae.mode=q,ae}else if(B.type==="end"){let ae=ze(B);if(ae!==rb)return ae}if(B.type==="illegal"&&J==="")return B.index===j.length||(re+=`
|
|
3
|
+
`),1;if(Nt>1e5&&Nt>B.index*3)throw new Error("potential infinite loop, way more iterations than matches");return re+=J,J.length}let ut=L(N);if(!ut)throw ir(i.replace("{}",N)),new Error('Unknown language: "'+N+'"');let Tt=d1(ut),lr="",q=Ce||Tt,Ft={},Re=new l.__emitter(l);cn();let re="",Y=0,Me=0,Nt=0,ar=!1;try{if(ut.__emitTokens)ut.__emitTokens(j,Re);else{for(q.matcher.considerAll();;){Nt++,ar?ar=!1:q.matcher.considerAll(),q.matcher.lastIndex=Me;let O=q.matcher.exec(j);if(!O)break;let B=j.substring(Me,O.index),J=Rn(B,O);Me=O.index+J}Rn(j.substring(Me))}return Re.finalize(),lr=Re.toHTML(),{language:N,value:lr,relevance:Y,illegal:!1,_emitter:Re,_top:q}}catch(O){if(O.message&&O.message.includes("Illegal"))return{language:N,value:Jc(j),illegal:!0,relevance:0,_illegalBy:{message:O.message,index:Me,context:j.slice(Me-100,Me+100),mode:O.mode,resultSoFar:lr},_emitter:Re};if(o)return{language:N,value:Jc(j),illegal:!1,relevance:0,errorRaised:O,_emitter:Re,_top:q};throw O}}function d(N){let j={value:Jc(N),illegal:!1,relevance:0,_top:s,_emitter:new l.__emitter(l)};return j._emitter.addText(N),j}function p(N,j){j=j||l.languages||Object.keys(t);let ne=d(N),Ce=j.filter(L).filter(G).map(we=>f(we,N,!1));Ce.unshift(ne);let me=Ce.sort((we,Ke)=>{if(we.relevance!==Ke.relevance)return Ke.relevance-we.relevance;if(we.language&&Ke.language){if(L(we.language).supersetOf===Ke.language)return 1;if(L(Ke.language).supersetOf===we.language)return-1}return 0}),[Se,wt]=me,An=Se;return An.secondBest=wt,An}function h(N,j,ne){let Ce=j&&n[j]||ne;N.classList.add("hljs"),N.classList.add(`language-${Ce}`)}function g(N){let j=null,ne=c(N);if(a(ne))return;if(De("before:highlightElement",{el:N,language:ne}),N.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",N);return}if(N.children.length>0&&(l.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(N)),l.throwUnescapedHTML))throw new Zc("One of your code blocks includes unescaped HTML.",N.innerHTML);j=N;let Ce=j.textContent,me=ne?u(Ce,{language:ne,ignoreIllegals:!0}):p(Ce);N.innerHTML=me.value,N.dataset.highlighted="yes",h(N,ne,me.language),N.result={language:me.language,re:me.relevance,relevance:me.relevance},me.secondBest&&(N.secondBest={language:me.secondBest.language,relevance:me.secondBest.relevance}),De("after:highlightElement",{el:N,result:me,text:Ce})}function m(N){l=nb(l,N)}let w=()=>{E(),qr("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function k(){E(),qr("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let x=!1;function E(){function N(){E()}if(document.readyState==="loading"){x||window.addEventListener("DOMContentLoaded",N,!1),x=!0;return}document.querySelectorAll(l.cssSelector).forEach(g)}function M(N,j){let ne=null;try{ne=j(e)}catch(Ce){if(ir("Language definition for '{}' could not be registered.".replace("{}",N)),o)ir(Ce);else throw Ce;ne=s}ne.name||(ne.name=N),t[N]=ne,ne.rawDefinition=j.bind(null,e),ne.aliases&&X(ne.aliases,{languageName:N})}function A(N){delete t[N];for(let j of Object.keys(n))n[j]===N&&delete n[j]}function S(){return Object.keys(t)}function L(N){return N=(N||"").toLowerCase(),t[N]||t[n[N]]}function X(N,{languageName:j}){typeof N=="string"&&(N=[N]),N.forEach(ne=>{n[ne.toLowerCase()]=j})}function G(N){let j=L(N);return j&&!j.disableAutodetect}function fe(N){N["before:highlightBlock"]&&!N["before:highlightElement"]&&(N["before:highlightElement"]=j=>{N["before:highlightBlock"](Object.assign({block:j.el},j))}),N["after:highlightBlock"]&&!N["after:highlightElement"]&&(N["after:highlightElement"]=j=>{N["after:highlightBlock"](Object.assign({block:j.el},j))})}function Be(N){fe(N),r.push(N)}function ye(N){let j=r.indexOf(N);j!==-1&&r.splice(j,1)}function De(N,j){let ne=N;r.forEach(function(Ce){Ce[ne]&&Ce[ne](j)})}function Oe(N){return qr("10.7.0","highlightBlock will be removed entirely in v12.0"),qr("10.7.0","Please use highlightElement now."),g(N)}Object.assign(e,{highlight:u,highlightAuto:p,highlightAll:E,highlightElement:g,highlightBlock:Oe,configure:m,initHighlighting:w,initHighlightingOnLoad:k,registerLanguage:M,unregisterLanguage:A,listLanguages:S,getLanguage:L,registerAliases:X,autoDetection:G,inherit:nb,addPlugin:Be,removePlugin:ye}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=p1,e.regex={concat:sr,lookahead:sb,either:Us,optional:NE,anyNumberOfTimes:TE};for(let N in Fs)typeof Fs[N]=="object"&&ob(Fs[N]);return Object.assign(e,Fs),e},Gr=mb({});Gr.newInstance=()=>mb({});gb.exports=Gr;Gr.HighlightJS=Gr;Gr.default=Gr});var li=he(Kt(),1);var jd=wr("primitives",{"zh-CN":{sharedData:"\u5171\u4EAB\u6570\u636E\u2026",imageFrame:"\u56FE\u7247",appearance:"\u5916\u89C2",color:"\u6587\u5B57\u989C\u8272",backgroundColor:"\u80CC\u666F\u989C\u8272",fontSize:"\u5B57\u53F7",padding:"\u5185\u8FB9\u8DDD",radius:"\u5706\u89D2",title:"\u6807\u9898",language:"\u8BED\u8A00",plainText:"\u7EAF\u6587\u672C",copy:"\u590D\u5236\u4EE3\u7801",copied:"\u5DF2\u590D\u5236",width:"\u5BBD\u5EA6",height:"\u9AD8\u5EA6",fit:"\u56FE\u7247\u9002\u914D",contain:"\u5B8C\u6574\u663E\u793A",cover:"\u88C1\u5207\u586B\u5145",addImage:"\u6DFB\u52A0\u56FE\u7247",editImage:"\u7F16\u8F91\u56FE\u7247",imageSrc:"\u56FE\u7247\u5730\u5740",imageAlt:"\u66FF\u4EE3\u6587\u5B57",imageCaption:"\u56FE\u6CE8",table:"\u57FA\u7840\u8868\u683C",scrollTable:"{title}\uFF1A\u5DE6\u53F3\u6EDA\u52A8\u67E5\u770B\u5168\u90E8\u5217",comparisonTable:"\u5BF9\u7167\u8868",columnName:"\u5217 {column} \u540D\u79F0",cell:"\u7B2C {row} \u884C\u7B2C {column} \u5217",addRow:"\u6DFB\u52A0\u884C",removeLastRow:"\u79FB\u9664\u672B\u884C",callout:"\u63D0\u793A\u6846",toggleSummary:"\u5C55\u5F00\u5185\u5BB9",code:"\u4EE3\u7801\u5757",codeContent:"\u4EE3\u7801\u5185\u5BB9"},en:{sharedData:"Shared data\u2026",imageFrame:"Image",appearance:"Appearance",color:"Text color",backgroundColor:"Background",fontSize:"Font size",padding:"Padding",radius:"Corner radius",title:"Title",language:"Language",plainText:"Plain text",copy:"Copy code",copied:"Copied",width:"Width",height:"Height",fit:"Image fit",contain:"Contain",cover:"Cover",addImage:"Add image",editImage:"Edit image",imageSrc:"Image URL",imageAlt:"Alt text",imageCaption:"Caption",table:"Basic table",scrollTable:"{title}: scroll sideways to see all columns",comparisonTable:"Comparison table",columnName:"Column {column} name",cell:"Row {row}, column {column}",addRow:"Add row",removeLastRow:"Remove last row",callout:"Callout",toggleSummary:"Show content",code:"Code block",codeContent:"Code"}});var ge=he(Ue(),1),Fd="showai:shared-data";function yy(){if(typeof window>"u")return!1;let e=new CustomEvent(Fd,{cancelable:!0,detail:null});return window.dispatchEvent(e),e.defaultPrevented}function Wd({editor:e,position:t,onDone:n}){let r=Pe(jd),o=(0,li.useContext)(Pd),[i,s]=(0,li.useState)(""),l=e.state.doc.nodeAt(t);if(!l||!e.isEditable)return null;let a=l.type.name,c=(k,x)=>{e.view.dispatch(e.state.tr.setNodeAttribute(t,k,x))},u=(k,x)=>(0,ge.jsxs)("label",{children:[x,(0,ge.jsx)("input",{className:"showai-input",value:l.attrs[k]??"",onChange:E=>c(k,E.target.value)})]},k),f=["image","table","codeBlock","callout","toggle","stepper","horizontalRule"].includes(a),d=l.attrs.componentStyle??{},p=(k,x)=>{let E={...d};x===void 0?delete E[k]:E[k]=x,c("componentStyle",E)},h=e.state.selection,g=h instanceof _&&h.node.type.name==="widget"&&h.from>t&&h.to<t+l.nodeSize?h.node:null,m=a==="widget"?l:g,w=null;if(m&&m.attrs.kind!=="text"&&yy()){let k=m.attrs.id,x=E=>{let M=-1;e.state.doc.descendants((A,S)=>(M<0&&A.attrs?.id===k&&(M=S),M<0)),M>=0&&e.view.dispatch(e.state.tr.setNodeAttribute(M,"data",E))};w=(0,ge.jsxs)("button",{type:"button",onClick:()=>{window.dispatchEvent(new CustomEvent(Fd,{cancelable:!0,detail:{kind:m.attrs.kind,data:m.attrs.data,apply:x}})),n?.()},children:[(0,ge.jsx)(Fu,{size:15}),r("sharedData")]})}return a==="widget"&&w?w:(0,ge.jsxs)("div",{className:"content-node-fields",children:[w,typeof l.attrs.id=="string"&&o?.(l.attrs.id,()=>n?.()),a==="image"&&(0,ge.jsxs)(ge.Fragment,{children:[u("src",r("imageSrc")),u("alt",r("imageAlt")),u("caption",r("imageCaption")),["width","height"].map(k=>(0,ge.jsxs)("label",{children:[r(k),(0,ge.jsx)("input",{className:"showai-input",inputMode:"decimal",value:l.attrs[k]??"",onChange:x=>{let E=x.target.value;(!E||/^\d+(?:px|%)?$/.test(E)&&parseInt(E)>0&&parseInt(E)<=1e4)&&c(k,E?/^\d+$/.test(E)?Number(E):E:null)}})]},k)),(0,ge.jsxs)("label",{children:[r("fit"),(0,ge.jsxs)("select",{className:"showai-select",value:l.attrs.fit??"contain",onChange:k=>c("fit",k.target.value),children:[(0,ge.jsx)("option",{value:"contain",children:r("contain")}),(0,ge.jsx)("option",{value:"cover",children:r("cover")})]})]})]}),["table","callout","toggle"].includes(a)&&u("title",r("title")),a==="codeBlock"&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("label",{children:[r("language"),(0,ge.jsxs)("select",{className:"showai-select",value:si(l.attrs.language),onChange:k=>c("language",k.target.value),children:[(0,ge.jsx)("option",{value:"plaintext",children:r("plainText")}),!xl.includes(si(l.attrs.language))&&(0,ge.jsxs)("option",{value:si(l.attrs.language),children:[l.attrs.language,Ad(l.attrs.language)?"":` (${r("plainText")})`]}),xl.filter(k=>k!=="plaintext").map(k=>(0,ge.jsx)("option",{value:k,children:k},k))]})]}),(0,ge.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(l.textContent).then(()=>s(r("copied"))).catch(k=>s(k.message))},children:r("copy")}),i&&(0,ge.jsx)("span",{role:"status",children:i})]}),f&&(0,ge.jsxs)("details",{children:[(0,ge.jsx)("summary",{children:r("appearance")}),["color","backgroundColor"].map(k=>(0,ge.jsxs)("label",{children:[r(k),(0,ge.jsx)("input",{className:"showai-input",value:d[k]??"",onChange:x=>p(k,x.target.value||void 0)})]},k)),["fontSize","padding","radius"].map(k=>(0,ge.jsxs)("label",{children:[r(k),(0,ge.jsx)("input",{className:"showai-input",type:"number",min:k==="fontSize"?8:0,max:"200",value:d[k]??"",onChange:x=>{let E=x.target.value;(!E||Number(E)>=(k==="fontSize"?8:0)&&Number(E)<=200)&&p(k,E?Number(E):void 0)}})]},k))]})]})}var Kd=wr("mentions",{"zh-CN":{backlinkCount:"{count} \u4E2A\u9875\u9762\u5F15\u7528\u4E86\u8FD9\u91CC",menu:"\u63D0\u53CA",sources:"\u63D0\u53CA\u6765\u6E90",pages:"\u9875\u9762",noResults:"\u6CA1\u6709\u5339\u914D\u7684\u7ED3\u679C",today:"\u4ECA\u5929",tomorrow:"\u660E\u5929",yesterday:"\u6628\u5929",typed:"\u8F93\u5165\u7684\u5185\u5BB9"},en:{backlinkCount:{one:"{count} page links here",other:"{count} pages link here"},menu:"Mention",sources:"Mention sources",pages:"Pages",noResults:"No matches",today:"Today",tomorrow:"Tomorrow",yesterday:"Yesterday",typed:"Typed text"}});function Tl(e){let t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function Ud(e,t=new Date){let n=e.trim(),r=(i,s,l)=>{let a=new Date(i,s-1,l);return a.getFullYear()===i&&a.getMonth()===s-1&&a.getDate()===l?Tl(a):null},o=/^(\d{4})[-/.\u5e74](\d{1,2})[-/.\u6708](\d{1,2})\u65e5?$/.exec(n);if(o){let i=r(+o[1],+o[2],+o[3]);return i?[i]:[]}if(o=/^(\d{1,2})[-/.\u6708](\d{1,2})\u65e5?$/.exec(n),o){let i=r(t.getFullYear(),+o[1],+o[2]);return i?[i]:[]}return[]}var wy=new Map;var qd={recent:8,matches:20},ky={id:"pages",label:e=>e.labels.pages,search(e){let t=e.query.trim(),n=e.projectId;return n?_d(e.pages.filter(r=>r.id!==e.pageId),t,{title:r=>r.title,updatedAt:r=>r.updatedAt},t?qd.matches:qd.recent).map(r=>({id:`page:${n}/${r.id}`,title:r.title,keywords:r.id,insertion:{type:"link",href:Jo({projectId:n,pageId:r.id}),text:r.title}})):[]}};function Gd(e,t){let[n,r,o]=e.split("-").map(Number);return new Intl.DateTimeFormat(t,{weekday:"short",year:"numeric",month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(n,r-1,o)))}function vy(e,t){let n="kind"in e?e.kind:`${e.id}@${e.version}#${e.integrity}`,r=(o,i,s,l)=>({id:`component:${n}:${o}`,title:i,keywords:s,...l?{detail:l}:{},insertion:{type:"component",component:e,prop:t.prop,value:o}});return{id:`component:${n}`,label:o=>o.displayName(e),search(o){let i=o.query.trim(),s=[];if(t.input==="date"){let l=u=>{let f=new Date(o.today);return f.setDate(f.getDate()+u),Tl(f)},a=[[o.labels.today,0,"today"],[o.labels.tomorrow,1,"tomorrow"],[o.labels.yesterday,-1,"yesterday"]];for(let[u,f,d]of a)s.push(r(l(f),u,`${d} ${l(f)}`,Gd(l(f),o.locale)));let c=new Set(a.map(([,u])=>l(u)));for(let u of Ud(i,o.today))c.has(u)||s.push(r(u,Gd(u,o.locale),`${i} ${u}`))}else t.input==="text"&&i&&s.push(r(i,i,i));for(let l of t.options??[])s.push(r(l.value,l.label,[l.value,...l.keywords??[]].join(" ")));return s}}}function Jd(e){return[ky,...e.components.flatMap(n=>n.contributes?.mention?[vy(n,n.contributes.mention)]:[]),...wy.values()].flatMap(n=>{let r=n.label(e);return n.search(e).map(o=>({id:o.id,title:o.title,keywords:o.keywords,group:r,entry:o}))})}var Cy=new Set(["chart","database","metrics","playground","gallery","bookmark","references","video","audio","pdf","archify","diagram-design","fireworks-tech-graph"]),xy=new Set(["mindmap","flowchart","text"]);function Xd(e){return Cy.has(e)||xy.has(e)||e.startsWith("g2-")}var ai=wr("richTextNotes",{"zh-CN":{"format.note":"\u6CE8\u91CA","dialog.addNote":"\u6DFB\u52A0\u6CE8\u91CA","dialog.editNote":"\u4FEE\u6539\u6CE8\u91CA","dialog.noteText":"\u6CE8\u91CA\u5185\u5BB9\uFF08\u8BFB\u8005\u628A\u9F20\u6807\u79FB\u5230\u6240\u9009\u6587\u5B57\u4E0A\u65F6\u663E\u793A\uFF09","dialog.noteFormula":"\u6CE8\u91CA\u5185\u5BB9\uFF08\u8BFB\u8005\u628A\u9F20\u6807\u79FB\u5230\u8FD9\u4E2A\u516C\u5F0F\u4E0A\u65F6\u663E\u793A\uFF09","dialog.notePlaceholder":"\u4F8B\u5982\uFF1A\u7B2C t \u6B65\u7684\u5E26\u566A\u6F5C\u53D8\u91CF\uFF0C\u5F62\u72B6\u4E0E\u56FE\u50CF\u6F5C\u53D8\u91CF\u76F8\u540C","dialog.noteHint":"\u53EF\u7528 $\u2026$ \u5199\u516C\u5F0F\uFF1B\u53EA\u6CE8\u91CA\u516C\u5F0F\u4E2D\u7684\u67D0\u4E2A\u53D8\u91CF\u65F6\uFF0C\u5728\u516C\u5F0F\u6E90\u7801\u91CC\u5199 \\note{x_t}{\u2026}\u3002\u2318\u21A9 \u4FDD\u5B58\u3002","dialog.removeNote":"\u5220\u9664\u6CE8\u91CA","dialog.noteNeedsSelection":"\u5148\u9009\u4E2D\u8981\u52A0\u6CE8\u91CA\u7684\u6587\u5B57\u6216\u516C\u5F0F\u3002","dialog.noteTargetMissing":"\u8981\u6CE8\u91CA\u7684\u516C\u5F0F\u5DF2\u7ECF\u4E0D\u5728\u539F\u4F4D\u7F6E\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002","dialog.noteTooLong":"\u6CE8\u91CA\u6700\u591A {max} \u4E2A\u5B57\u7B26\u3002"},en:{"format.note":"Note","dialog.addNote":"Add note","dialog.editNote":"Edit note","dialog.noteText":"Note (shown when readers hover the selected text)","dialog.noteFormula":"Note (shown when readers hover this formula)","dialog.notePlaceholder":"For example: the noisy latent at step t, shaped like the image latent","dialog.noteHint":"Use $\u2026$ for formulas. To annotate one variable inside a formula, write \\note{x_t}{\u2026} in its source. \u2318\u21A9 saves.","dialog.removeNote":"Remove note","dialog.noteNeedsSelection":"Select the text or formula to annotate first.","dialog.noteTargetMissing":"The formula moved. Select it again.","dialog.noteTooLong":"Notes can have at most {max} characters."}});function Yd(e,t){let n=e.cut(0,t).toJSON().content??[],r=e.cut(t).toJSON().content??[],o=l=>l?.type==="paragraph"&&!l.content?.length||l?.type==="richText"&&!Object.keys(l.attrs?.data??{}).length&&(l.content??[]).every(o);o(n.at(-1))&&n.pop(),o(r[0])&&r.shift();let i=new Set,s=l=>{let a=l.attrs?.id;a&&(i.has(a)&&(l.attrs={...l.attrs,id:crypto.randomUUID()}),i.add(l.attrs.id)),l.content?.forEach(s)};return n.forEach(s),r.forEach(s),{before:n,after:r}}var D=he(Kt(),1),Qs=he(yl(),1);var te=he(Kt(),1);var _i=he(yl(),1),Kh=he(gy(),1);var Qd=Object.defineProperty,Zd=(e,t)=>{let n={};for(var r in e)Qd(n,r,{get:e[r],enumerable:!0});return t||Qd(n,Symbol.toStringTag,{value:"Module"}),n};var tf=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function nf(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}var Rl=(e,t,n)=>{let r=nf(e,n);if(!r)return!1;let o=Ol(r);if(!o){let s=r.blockRange(),l=s&&qt(s);return l==null?!1:(t&&t(e.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(ff(e,o,t,-1))return!0;if(r.parent.content.size==0&&(vr(i,"end")||_.isSelectable(i)))for(let s=r.depth;;s--){let l=oi(e.doc,r.before(s),r.after(s),ue.empty);if(l&&l.slice.size<l.to-l.from){if(t){let a=e.tr.step(l);a.setSelection(vr(i,"end")?Q.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):_.create(a.doc,o.pos-i.nodeSize)),t(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},rf=(e,t,n)=>{let r=nf(e,n);if(!r)return!1;let o=Ol(r);return o?sf(e,o,t):!1},of=(e,t,n)=>{let r=lf(e,n);if(!r)return!1;let o=Il(r);return o?sf(e,o,t):!1};function sf(e,t,n){let r=t.nodeBefore,o=r,i=t.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let s=t.nodeAfter,l=s,a=t.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=oi(e.doc,i,a,ue.empty);if(!c||c.from!=i||c instanceof Bn&&c.slice.size>=a-i)return!1;if(n){let u=e.tr.step(c);u.setSelection(P.create(u.doc,i)),n(u.scrollIntoView())}return!0}function vr(e,t,n=!1){for(let r=e;r;r=t=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Dl=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=Ol(r)}let s=i&&i.nodeBefore;return!s||!_.isSelectable(s)?!1:(t&&t(e.tr.setSelection(_.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Ol(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function lf(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}var Ll=(e,t,n)=>{let r=lf(e,n);if(!r)return!1;let o=Il(r);if(!o)return!1;let i=o.nodeAfter;if(ff(e,o,t,1))return!0;if(r.parent.content.size==0&&(vr(i,"start")||_.isSelectable(i))){let s=oi(e.doc,r.before(),r.after(),ue.empty);if(s&&s.slice.size<s.to-s.from){if(t){let l=e.tr.step(s);l.setSelection(vr(i,"start")?Q.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):_.create(l.doc,l.mapping.map(o.pos))),t(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},Pl=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=Il(r)}let s=i&&i.nodeAfter;return!s||!_.isSelectable(s)?!1:(t&&t(e.tr.setSelection(_.create(e.doc,i.pos)).scrollIntoView()),!0)};function Il(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var af=(e,t)=>{let n=e.selection,r=n instanceof _,o;if(r){if(n.node.isTextblock||!xt(e.doc,n.from))return!1;o=n.from}else if(o=yr(e.doc,n.from,-1),o==null)return!1;if(t){let i=e.tr.join(o);r&&i.setSelection(_.create(i.doc,o-e.doc.resolve(o).nodeBefore.nodeSize)),t(i.scrollIntoView())}return!0},cf=(e,t)=>{let n=e.selection,r;if(n instanceof _){if(n.node.isTextblock||!xt(e.doc,n.to))return!1;r=n.to}else if(r=yr(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},uf=(e,t)=>{let{$from:n,$to:r}=e.selection,o=n.blockRange(r),i=o&&qt(o);return i==null?!1:(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)},$l=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
4
|
+
`).scrollIntoView()),!0)};function Bl(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var zl=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Bl(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let l=n.after(),a=e.tr.replaceWith(l,l,s.createAndFill());a.setSelection(Q.near(a.doc.resolve(l),1)),t(a.scrollIntoView())}return!0},Hl=(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof pn||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Bl(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=e.tr.insert(s,i.createAndFill());l.setSelection(P.create(l.doc,s+1)),t(l.scrollIntoView())}return!0},_l=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(ht(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&qt(r);return o==null?!1:(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)};function Sy(e){return(t,n)=>{if(t.selection instanceof _&&t.selection.node.isBlock){let{$from:p}=t.selection;return!p.parentOffset||!ht(t.doc,p.pos)?!1:(n&&n(t.tr.split(p.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof P||t.selection instanceof pn)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,c=!1,u=!1;for(let p=o.depth;;p--)if(o.node(p).isBlock){c=o.end(p)==o.pos+(o.depth-p),u=o.start(p)==o.pos-(o.depth-p),a=Bl(o.node(p-1).contentMatchAt(o.indexAfter(p-1)));let g=e&&e(o.parent,c,o);s.unshift(g||(c&&a?{type:a}:null)),l=p;break}else{if(p==1)return!1;s.unshift(null)}let f=o.pos,d=ht(r.doc,f,s.length,s);if(d||(s[0]=a?{type:a}:null,d=ht(r.doc,f,s.length,s)),!d)return!1;if(r.split(f,s.length,s),!c&&u&&o.node(l).type!=a){let p=r.mapping.slice(i),h=p.map(o.before(l)),g=r.doc.resolve(h);a&&o.node(l-1).canReplaceWith(g.index(),g.index()+1,a)&&r.setNodeMarkup(p.map(o.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}var Ey=Sy();var df=(e,t)=>{let{$from:n,to:r}=e.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),t&&t(e.tr.setSelection(_.create(e.doc,o))),!0)},My=(e,t)=>(t&&t(e.tr.setSelection(new pn(e.doc))),!0);function Ay(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(i,i+1)||!(o.isTextblock||xt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function ff(e,t,n,r){let o=t.nodeBefore,i=t.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Ay(e,t,n))return!0;let c=!a&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let p=t.pos+i.nodeSize,h=F.empty;for(let w=s.length-1;w>=0;w--)h=F.from(s[w].create(null,h));h=F.from(o.copy(h));let g=e.tr.step(new Ot(t.pos-1,p,t.pos,p,new ue(h,1,0),s.length,!0)),m=g.doc.resolve(p+2*s.length);m.nodeAfter&&m.nodeAfter.type==o.type&&xt(g.doc,m.pos)&&g.join(m.pos),n(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:Q.findFrom(t,1),f=u&&u.$from.blockRange(u.$to),d=f&&qt(f);if(d!=null&&d>=t.depth)return n&&n(e.tr.lift(f,d).scrollIntoView()),!0;if(c&&vr(i,"start",!0)&&vr(o,"end")){let p=o,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let g=i,m=1;for(;!g.isTextblock;g=g.firstChild)m++;if(p.canReplace(p.childCount,p.childCount,g.content)){if(n){let w=F.empty;for(let x=h.length-1;x>=0;x--)w=F.from(h[x].copy(w));let k=e.tr.step(new Ot(t.pos-h.length,t.pos+i.nodeSize,t.pos+m,t.pos+i.nodeSize-m,new ue(w,h.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function pf(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(t.tr.setSelection(P.create(t.doc,e<0?o.start(i):o.end(i)))),!0):!1}}var Vl=pf(-1),jl=pf(1);function hf(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&br(s,e,t);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Fl(e,t=null){return function(n,r){let o=!1;for(let i=0;i<n.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(e,t)))if(a.type==e)o=!0;else{let u=n.doc.resolve(c),f=u.index();o=u.parent.canReplaceWith(f,f+1,e)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];i.setBlockType(l,a,e,t)}r(i.scrollIntoView())}return!0}}function Wl(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}var Nl=Wl(tf,Rl,Dl),ef=Wl(tf,Ll,Pl),hn={Enter:Wl($l,Hl,_l,Ey),"Mod-Enter":zl,Backspace:Nl,"Mod-Backspace":Nl,"Shift-Backspace":Nl,Delete:ef,"Mod-Delete":ef,"Mod-a":My},Ty={"Ctrl-h":hn.Backspace,"Alt-Backspace":hn["Mod-Backspace"],"Ctrl-d":hn.Delete,"Ctrl-Alt-Backspace":hn["Mod-Delete"],"Alt-Delete":hn["Mod-Delete"],"Alt-d":hn["Mod-Delete"],"Ctrl-a":Vl,"Ctrl-e":jl};for(let e in hn)Ty[e]=hn[e];var OM=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function mf(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return Ny(l,s,e,t)?(r&&r(l.scrollIntoView()),!0):!1}}function Ny(e,t,n,r=null){let o=!1,i=t,s=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let a=s.resolve(t.start-2);i=new ti(a,a,t.depth),t.endIndex<t.parent.childCount&&(t=new ti(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let l=br(i,n,r,t);return l?(e&&Ry(e,t,l,o,n),!0):!1}function Ry(e,t,n,r,o){let i=F.empty;for(let u=n.length-1;u>=0;u--)i=F.from(n[u].type.create(n[u].attrs,i));e.step(new Ot(t.start-(r?2:0),t.end,t.start,t.end,new ue(i,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==o&&(s=u+1);let l=n.length-s,a=t.start+n.length-(r?2:0),c=t.parent;for(let u=t.startIndex,f=t.endIndex,d=!0;u<f;u++,d=!1)!d&&ht(e.doc,a,l)&&(e.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return e}function gf(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==e);return i?n?r.node(i.depth-1).type==e?Dy(t,n,e,i):Oy(t,n,i):!0:!1}}function Dy(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new Ot(i-1,s,i,s,new ue(F.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ti(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));let l=qt(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return xt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),t(o.scrollIntoView()),!0}function Oy(e,t,n){let r=e.tr,o=n.parent;for(let p=n.end,h=n.endIndex-1,g=n.startIndex;h>g;h--)p-=o.child(h).nodeSize,r.delete(p-1,p+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?F.empty:F.from(o))))return!1;let f=i.pos,d=f+s.nodeSize;return r.step(new Ot(f-(l?1:0),d+(a?1:0),f+1,d-1,new ue((l?F.empty:F.from(o.copy(F.empty))).append(a?F.empty:F.from(o.copy(F.empty))),l?0:1,a?0:1),l?0:1)),t(r.scrollIntoView()),!0}function bf(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==e);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=e)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=F.from(c?e.create():null),f=new ue(F.from(e.create(null,F.from(l.type.create(null,u)))),c?3:1,0),d=i.start,p=i.end;n(t.tr.step(new Ot(d-(c?3:1),p,d,p,f,1,!0)).scrollIntoView())}return!0}}var qe=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Er=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Jl=null,Jt=function(e,t,n){let r=Jl||(Jl=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Ly=function(){Jl=null},Kn=function(e,t,n,r){return n&&(yf(e,t,n,r,-1)||yf(e,t,n,r,1))},Py=/^(img|br|input|textarea|hr)$/i;function yf(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Ye(e))){let s=e.parentNode;if(!s||!W(s)||ho(e)||Py.test(e.nodeName)||e.contentEditable=="false")return!1;t=qe(e)+(o<0?0:1),e=s}else if(W(e)){let s=e.childNodes[t+(o<0?-1:0)];if(W(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)t+=o;else return!1;else e=s,t=o<0?Ye(e):0}else return!1}}function Ye(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function W(e){return e.nodeType==1}function Ve(e){return e.nodeType==3}function Un(e,t){return t?e.contains(W(t)?t:t.parentNode):!1}function Iy(e,t){for(;;){if(Ve(e)&&t)return e;if(W(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=Ye(e)}else if(e.parentNode&&!ho(e))t=qe(e),e=e.parentNode;else return null}}function $y(e,t){for(;;){if(Ve(e)&&t<e.nodeValue.length)return e;if(W(e)&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!ho(e))t=qe(e)+1,e=e.parentNode;else return null}}function By(e,t,n){for(let r=t==0,o=t==Ye(e);r||o;){if(e==n)return!0;let i=qe(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,o=o&&i==Ye(e)}}function ho(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var wi=function(e){return e.focusNode&&Kn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function zn(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function zy(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Hy(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Ye(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Ye(r.startContainer),r.startOffset)}}}var Lt=typeof navigator<"u"?navigator:null,wf=typeof document<"u"?document:null,wn=Lt&&Lt.userAgent||"",Xl=/Edge\/(\d+)/.exec(wn),Gf=/MSIE \d/.exec(wn),Yl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wn),st=!!(Gf||Yl||Xl),bn=Gf?document.documentMode:Yl?+Yl[1]:Xl?+Xl[1]:0,dt=!st&&/gecko\/(\d+)/i.test(wn);dt&&+(/Firefox\/(\d+)/.exec(wn)||[0,0])[1];var Ql=!st&&/Chrome\/(\d+)/.exec(wn),Ge=!!Ql,Jf=Ql?+Ql[1]:0,Qe=!st&&!!Lt&&/Apple Computer/.test(Lt.vendor),Mr=Qe&&(/Mobile\/\w+/.test(wn)||!!Lt&&Lt.maxTouchPoints>2),mt=Mr||(Lt?/Mac/.test(Lt.platform):!1),Xf=Lt?/Win/.test(Lt.platform):!1,Xt=/Android \d/.test(wn),ki=!!wf&&"webkitFontSmoothing"in wf.documentElement.style,_y=ki?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Vy(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Gt(e,t){return typeof e=="number"?e:e[t]}function jy(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function kf(e,t,n){if(!Zl(t)&&t.left==0)return;let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(!W(s)){s=Er(s);continue}let l=s==i.body,a=l?Vy(i):jy(s),c=0,u=0;if(t.top<a.top+Gt(r,"top")?u=-(a.top-t.top+Gt(o,"top")):t.bottom>a.bottom-Gt(r,"bottom")&&(u=t.bottom-t.top>a.bottom-a.top?t.top+Gt(o,"top")-a.top:t.bottom-a.bottom+Gt(o,"bottom")),t.left<a.left+Gt(r,"left")?c=-(a.left-t.left+Gt(o,"left")):t.right>a.right-Gt(r,"right")&&(c=t.right-a.right+Gt(o,"right")),c||u)if(l)i.defaultView.scrollBy(c,u);else{let d=s.scrollLeft,p=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let h=s.scrollLeft-d,g=s.scrollTop-p;t={left:t.left-h,top:t.top-g,right:t.right-h,bottom:t.bottom-g}}let f=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:Er(s)}}function Fy(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,o;for(let i=(t.left+t.right)/2,s=n+1;s<Math.min(innerHeight,t.bottom);s+=5){let l=e.root.elementFromPoint(i,s);if(!l||l==e.dom||!e.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Yf(e.dom)}}function Yf(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Er(r));return t}function Wy({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Qf(n,r==0?0:r-t)}function Qf(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}var Cr=null;function Ky(e){if(e.setActive)return e.setActive();if(Cr)return e.focus(Cr);let t=Yf(e);e.focus(Cr==null?{get preventScroll(){return Cr={preventScroll:!0},!0}}:void 0),Cr||(Cr=!1,Qf(t,0))}function Zf(e,t){let n,r=2e8,o,i=0,s=t.top,l=t.top,a,c;for(let u=e.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(W(u))d=u.getClientRects();else if(Ve(u))d=Jt(u).getClientRects();else continue;for(let p=0;p<d.length;p++){let h=d[p];if(h.top<=s&&h.bottom>=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let g=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(g<r){n=u,r=g,o=g&&Ve(n)?{left:h.right<t.left?h.right:h.left,top:t.top}:t,W(u)&&g&&(i=f+(t.left>=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!a&&h.left<=t.left&&h.right>=t.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!n&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(i=f+1)}}return!n&&a&&(n=a,o=c,r=0),n&&Ve(n)?Uy(n,o):!n||r?{node:e,offset:i}:Zf(n,o)}function Uy(e,t){let n=e.nodeValue.length,r=document.createRange(),o;for(let i=0;i<n;i++){r.setEnd(e,i+1),r.setStart(e,i);let s=mn(r,1);if(s.top!=s.bottom&&ma(t,s)){o={node:e,offset:i+(t.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:e,offset:0}}function ma(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function qy(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Gy(e,t,n){let{node:r,offset:o}=Zf(t,n),i=-1;if(W(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}function Jy(e,t,n,r){let o=-1;for(let i=t,s=!1;i!=e.dom;){let l=e.docView.nearestDesc(i,!0),a;if(!l)return null;if(W(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}function ep(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let s=e.childNodes[i];if(W(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ma(t,c))return ep(s,t,c)}}if((i=(i+1)%r)==o)break}return e}function Xy(e,t){let n=e.dom.ownerDocument,r,o=0,i=Hy(n,t.left,t.top);i&&({node:r,offset:o}=i);let s=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),l;if(!s||!e.dom.contains(s)){let c=e.dom.getBoundingClientRect();if(!ma(t,c)||(s=ep(e.dom,t,c),!s))return null}if(Qe)for(let c=s;r&&c;c=Er(c))c.draggable&&(r=void 0);if(s=qy(s,t),r){if(dt&&W(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=t.left&&f.bottom>t.top&&o++}let c;ki&&o&&W(r)&&W(c=r.childNodes[o-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=t.top&&o--,r==e.dom&&o==r.childNodes.length-1&&W(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom?l=e.state.doc.content.size:(o==0||!W(r)||r.childNodes[o-1].nodeName!="BR")&&(l=Jy(e,r,o,t))}l==null&&(l=Gy(e,s,t));let a=e.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Zl(e){return e.top<e.bottom||e.left<e.right}function mn(e,t){let n=e.getClientRects();if(n.length){let r=n[t<0?0:n.length-1];if(Zl(r))return r}return Array.prototype.find.call(n,Zl)||e.getBoundingClientRect()}var Yy=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function tp(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=ki||dt;if(Ve(r))if(s&&(Yy.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=mn(Jt(r,o,o),n);if(dt&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=mn(Jt(r,o-1,o-1),-1);if(c.top==a.top){let u=mn(Jt(r,o,o+1),-1);if(u.top!=a.top)return io(u,u.left<c.left)}}return a}else{let a=o,c=o,u=n<0?1:-1;return n<0&&!o?(c++,u=-1):n>=0&&o==r.nodeValue.length?(a--,u=1):n<0?a--:c++,io(mn(Jt(r,a,c),u),u<0)}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==Ye(r))){let a=r.childNodes[o-1];if(W(a))return Kl(a.getBoundingClientRect(),!1)}if(i==null&&o<Ye(r)){let a=r.childNodes[o];if(W(a))return Kl(a.getBoundingClientRect(),!0)}return Kl(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==Ye(r))){let a=r.childNodes[o-1],c=Ve(a)?Jt(a,Ye(a)-(s?0:1)):W(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return io(mn(c,1),!1)}if(i==null&&o<Ye(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?Ve(a)?Jt(a,0,s?0:1):W(a)?a:null:null;if(c)return io(mn(c,-1),!0)}return io(mn(Ve(r)?Jt(r):r,-n),n>=0)}function io(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Kl(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function np(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}function Qy(e,t,n){let r=t.selection,o=n=="up"?r.$from:r.$to;return np(e,t,()=>{let{node:i}=e.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=e.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=tp(e,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(W(l))a=l.getClientRects();else if(Ve(l))a=Jt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var Zy=/[\u0590-\u08ac]/;function e0(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=e.domSelection();return l?!Zy.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:np(e,t,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=e.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:h,focusOffset:g}=e.domSelectionRange(),m=h&&!Un(p,h)||a==h&&c==g;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),m}):r.pos==r.start()||r.pos==r.end()}var vf=null,Cf=null,xf=!1;function t0(e,t,n){return vf==t&&Cf==n?xf:(vf=t,Cf=n,xf=n=="up"||n=="down"?Qy(e,t,n):e0(e,t,n))}var gt=0,Sf=1,Hn=2,St=3,qn=class{constructor(t,n,r,o){this.parent=t,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=gt,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,n,r){return!1}matchesHack(t){return!1}parseRule(t){return null}stopEvent(t){return!1}get size(){let t=0;for(let n=0;n<this.children.length;n++)t+=this.children[n].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==t)return r;r+=o.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(t,n,r){if(this.contentDOM&&Un(this.contentDOM,t))if(r<0){let i,s;if(t==this.contentDOM)i=t.childNodes[n-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(t==this.contentDOM)i=t.childNodes[n];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(t==this.dom&&this.contentDOM)o=n>qe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=!!(t.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(n==0)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==t.childNodes.length)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(t,n=!1){for(let r=!0,o=t;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(W(s)?Un(s,t):s==t))r=!1;else return i}}getDesc(t){let n=t.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(t,n,r){for(let o=t;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(t,n,r)}return-1}descAt(t){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],i=r+o.size;if(r==t&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(t<i)return o.descAt(t-r-o.border);r=i}}domFromPos(t,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>t){o=t-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof di||i instanceof ci&&i.side>=0))break}if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?qe(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?qe(i.dom):this.contentDOM.childNodes.length}}}parseRange(t,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&t<=c){let u=s+a.border;if(t>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,n,u);t=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=qe(d.dom)+1;break}t-=d.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){i=qe(f.dom);break}n+=f.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:t,to:n,fromOffset:o,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[t<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(t)}domAfterPos(t){let{node:n,offset:r}=this.domFromPos(t,0);if(!W(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]}setSelection(t,n,r,o=!1){let i=Math.min(t,n),s=Math.max(t,n);for(let p=0,h=0;p<this.children.length;p++){let g=this.children[p],m=h+g.size;if(i>h&&s<m)return g.setSelection(t-h-g.border,n-h-g.border,r,o);h=m}let l=this.domFromPos(t,t?-1:1),a=n==t?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((dt||Qe)&&t==n){let{node:p,offset:h}=l;if(Ve(p)){if(f=!!(h&&p.nodeValue[h-1]==`
|
|
5
|
+
`),f&&h==p.nodeValue.length)for(let g=p,m;g;g=g.parentNode){if(m=g.nextSibling){m.nodeName=="BR"&&(l=a={node:m.parentNode,offset:qe(m)+1});break}let w=g.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{let g=p.childNodes[h-1];f=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(dt&&u.focusNode&&u.focusNode!=a.node&&W(u.focusNode)){let p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||f&&Qe)&&Kn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Kn(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||t==n)&&!(f&&dt)){c.collapse(l.node,l.offset);try{t!=n&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(t>n){let h=l;l=a,a=h}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,n){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?t<=s&&n>=r:t<s&&n>r){let l=r+i.border,a=s-i.border;if(t>=l&&n<=a){this.dirty=t==r||n==s?Hn:Sf,t==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=St:i.markDirty(t-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Hn:St}r=s}this.dirty=Hn}markParentsDirty(){let t=1;for(let n=this.parent;n;n=n.parent,t++){let r=t==1?Hn:Sf;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}},ci=class extends qn{constructor(t,n,r,o){let i,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){let l=W(s)?s:document.createElement("span");l!=s&&l.appendChild(s),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(t){return this.dirty==gt&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let n=this.widget.spec.stopEvent;return n?n(t):!1}ignoreMutation(t){return t.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}},ea=class extends qn{constructor(t,n,r,o){super(t,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(t,n){return t!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}},Vn=class e extends qn{constructor(t,n,r,o,i){super(t,[],r,o),this.mark=n,this.spec=i}static create(t,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=$n.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&St||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=St&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=gt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=gt}}slice(t,n,r){let o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=oa(i,n,s,r)),t>0&&(i=oa(i,0,t,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},yn=class e extends qn{constructor(t,n,r,o,i,s,l){super(t,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(t,n,r,o,i,s){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,f=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!Ve(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=$n.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let d=u;return u=ip(u,r,n),c?a=new ta(t,n,r,o,u,f||null,d,c):n.isText?new ui(t,n,r,o,u,d):new e(t,n,r,o,u,f||null,d)}parseRule(t){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){n.contentElement=o.dom.parentNode;break}}if(!n.contentElement){let r=t&&t.find(o=>W(o)&&t.indexOf(o.parentNode)<0&&this.dom.contains(o));r?n.contentElement=r:n.getContent=()=>F.empty}}return n}matchesNode(t,n,r){return this.dirty==gt&&t.eq(this.node)&&fi(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){let r=this.node.inlineContent,o=n,i=t.composing?this.localCompositionInfo(t,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new ra(this,s&&s.node,t),c=this.node.inlineContent,u=c&&this.node.isBlock;i0(this.node,this.innerDeco,(f,d,p)=>{f.spec.marks?a.syncToMarks(f.spec.marks,r,t,d):f.type.side>=0&&!p&&a.syncToMarks(d==this.node.childCount?gd.none:this.node.child(d).marks,r,t,d),a.placeWidget(f,t,o)},(f,d,p,h)=>{a.syncToMarks(f.marks,r,t,h),u&&f.isAtom&&!f.isText&&a.addHackNode("IMG",a.top);let g;a.findNodeMatch(f,d,p,h)||l&&t.state.selection.from>o&&t.state.selection.to<o+f.nodeSize&&(g=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(f,d,p,g,t)||a.updateNextNode(f,d,p,t,h,o)||a.addNode(f,d,p,t,o),o+=f.nodeSize,c&&(u=f.isAtom&&!f.isText)}),a.syncToMarks([],r,t,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Hn)&&(s&&this.protectLocalComposition(t,s),rp(this.contentDOM,this.children,t),Mr&&s0(this.dom))}localCompositionInfo(t,n){let{from:r,to:o}=t.state.selection;if(!(t.state.selection instanceof P)||r<n||o>n+this.node.content.size)return null;let i=t.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=l0(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(t,{node:n,pos:r,text:o}){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 s=new ea(this,i,n,o);t.input.compositionNodes.push(s),this.children=oa(this.children,r,r+o.length,t,s)}update(t,n,r,o){return this.dirty==St||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,r,o),!0)}updateInner(t,n,r,o){this.updateOuterDeco(n),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=gt}updateOuterDeco(t){if(fi(t,this.outerDeco))return;let n=!W(this.nodeDOM),r=this.dom;this.dom=op(this.dom,this.nodeDOM,na(this.outerDeco,this.node,n),na(t,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){W(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){W(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Ef(e,t,n,r,o){ip(r,t,e);let i=new yn(void 0,e,t,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var ui=class e extends yn{constructor(t,n,r,o,i,s){super(t,n,r,o,i,null,s)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,n,r,o){return this.dirty==St||this.dirty!=gt&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=gt||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=gt,!0)}inParent(){let t=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,n,r){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(t,n,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,n,r){let o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i)}markDirty(t,n){super.markDirty(t,n),this.dom!=this.nodeDOM&&(t==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=St)}get domAtom(){return!1}isText(t){return this.node.text==t}},di=class extends qn{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==gt&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},ta=class extends yn{constructor(t,n,r,o,i,s,l,a){super(t,n,r,o,i,s,l),this.spec=a}update(t,n,r,o){if(this.dirty==St)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let i=this.spec.update(t,n,r);return i&&this.updateInner(t,n,r,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,n,r,o){this.spec.setSelection?this.spec.setSelection(t,n,r.root):super.setSelection(t,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}};function rp(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=r;)r=Mf(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(l,r);if(s instanceof Vn){let a=r?r.previousSibling:e.lastChild;rp(s.contentDOM,s.children,n),r=a?a.nextSibling:e.firstChild}}for(;r;)r=Mf(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}var lo=function(e){e&&(this.nodeName=e)};lo.prototype=Object.create(null);var _n=[new lo];function na(e,t,n){if(e.length==0)return _n;let r=n?_n[0]:new lo,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new lo(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new lo(t.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function op(e,t,n,r){if(n==_n&&r==_n)return t;let o=t;for(let i=0;i<r.length;i++){let s=r[i],l=n[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=e&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=_n[0]),o=a}n0(o,l||_n[0],s)}return o}function n0(e,t,n){for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&e.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&e.classList.add(o[i]);e.classList.length==0&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(t.style);)e.style.removeProperty(o[1])}n.style&&(e.style.cssText+=n.style)}}function ip(e,t,n){return op(e,e,_n,na(t,n,!W(e)))}function fi(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Mf(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var ra=class{constructor(t,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=r0(t.node.content,t)}destroyBetween(t,n){if(t!=n){for(let r=t;r<n;r++)this.top.children[r].destroy();this.top.children.splice(t,n-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,n,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,t.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&t[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=gt,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<t.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let f=this.top.children[u];if(f.matchesMark(t[s])&&!this.isLocked(f.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof Vn&&u.dirty!=St&&u.mark.type==t[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(t[s])&&(u.mark=t[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Vn.create(this.top,t[s],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(t,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(t,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(t,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(t,n,r,o,i){let s=this.top.children[o];return s.dirty==St&&s.dom==s.contentDOM&&(s.dirty=Hn),s.update(t,n,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(t){for(;;){let n=t.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=t.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}t=n}}updateNextNode(t,n,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof yn){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(t.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==t.text&&a.dirty!=St&&fi(n,a.outerDeco));if(!d&&a.update(t,n,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,t,n,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Hn,f.updateChildren(o,s+1),f.dirty=gt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,n,r,o,i,s){if(t.dirty||n.isAtom||!t.children.length||!t.node.content.eq(n.content)||!fi(r,t.outerDeco)||!o.eq(t.innerDeco))return null;let l=yn.create(this.top,n,r,o,i,s);if(l.contentDOM){l.children=t.children,t.children=[];for(let a of l.children)a.parent=l}return t.destroy(),l}addNode(t,n,r,o,i){let s=yn.create(this.top,t,n,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(t,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(t)&&(t==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new ci(this.top,t,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let t=this.top.children[this.index-1],n=this.top;for(;t instanceof Vn;)n=t,t=n.children[n.children.length-1];(!t||!(t instanceof ui)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Qe||Ge)&&t&&t.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(t,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(t))this.index++;else{let r=document.createElement(t);t=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),t=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new di(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||W(t)&&t.contains(this.lock.parentNode))}};function r0(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof Vn)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function o0(e,t){return e.type.side-t.type.side}function i0(e,t,n,r){let o=t.locals(e),i=0;if(o.length==0){for(let c=0;c<e.childCount;c++){let u=e.child(c);r(u,o,t.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,f;for(;s<o.length&&o[s].to==i;){let m=o[s++];m.widget&&(u?(f||(f=[u])).push(m):u=m)}if(u)if(f){f.sort(o0);for(let m=0;m<f.length;m++)n(f[m],c,!!a)}else n(u,c,!!a);let d,p;if(a)p=-1,d=a,a=null;else if(c<e.childCount)p=c,d=e.child(c++);else break;for(let m=0;m<l.length;m++)l[m].to<=i&&l.splice(m--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+d.nodeSize;if(d.isText){let m=h;s<o.length&&o[s].from<m&&(m=o[s].from);for(let w=0;w<l.length;w++)l[w].to<m&&(m=l[w].to);m<h&&(a=d.cut(m-i),d=d.cut(0,m-i),h=m,p=-1)}else for(;s<o.length&&o[s].to<h;)s++;let g=d.isInline&&!d.isLeaf?l.filter(m=>!m.inline):l.slice();r(d,g,t.forChild(i,d),p),i=h}}function s0(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function l0(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<e.childCount;){let c=e.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-t.length-l,r-l)==t)return r-t.length;let c=l<r?a.lastIndexOf(t,r-l-1):-1;if(c>=0&&c+t.length+l>=n)return l+c;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}function oa(e,t,n,r,o){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],c=l,u=l+=a.size;c>=n||u<=t?i.push(a):(c<t&&i.push(a.slice(0,t-c,r)),o&&(i.push(o),o=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function ga(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(wi(n)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&_.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&By(n.focusNode,n.focusOffset,o.dom))){let f=o.posBefore;c=new _(s==f?l:r.resolve(f))}else if(dt&&t=="key"&&s>e.state.selection.to&&W(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&o&&o.posAtStart>e.state.selection.to)for(let f=n.focusNode;;f=f.parentNode){if(getComputedStyle(f).overflow!="visible"){c=Q.findFrom(r.resolve(o.posAtStart),1);break}if(f==o.dom||f.nextSibling||!f.parentNode||!W(f.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,d=s;for(let p=0;p<n.rangeCount;p++){let h=n.getRangeAt(p);f=Math.min(f,e.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,e.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,s]=d==e.state.selection.anchor?[d,f]:[f,d],l=r.resolve(s)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=t=="pointer"||e.state.selection.head<l.pos&&!i?1:-1;c=ba(e,u,l,f)}return c}function sp(e){return e.editable?e.hasFocus():ap(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Qt(e,t=!1){let n=e.state.selection;if(lp(e,n),!sp(e))return;let r=e.input.mouseDown;if(!t&&Ge&&r){let o=e.domSelectionRange(),i=e.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&Kn(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)c0(e);else{let{anchor:o,head:i}=n,s,l;Af&&!(n instanceof P)&&(n.$from.parent.inlineContent||(s=Tf(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Tf(e,n.to))),e.docView.setSelection(o,i,e,t),Af&&(s&&Nf(s),l&&Nf(l)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&a0(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}var Af=Qe||Ge&&Jf<63;function Tf(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Qe&&o&&o.contentEditable=="false")return Ul(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Ul(o);if(i)return Ul(i)}}function Ul(e){return e.contentEditable="true",Qe&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Nf(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function a0(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!sp(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function c0(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,qe(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&st&&bn<=11&&(n.disabled=!0,n.disabled=!1)}function lp(e,t){if(t instanceof _){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Rf(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Rf(e)}function Rf(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function ba(e,t,n,r){return e.someProp("createSelectionBetween",o=>o(e,t,n))||P.between(t,n,r)}function Df(e){return e.editable&&!e.hasFocus()?!1:ap(e)}function ap(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Un(e.dom,t.anchorNode)&&(e.editable||Un(e.dom,t.focusNode))}catch{return!1}}function u0(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Kn(t.node,t.offset,n.anchorNode,n.anchorOffset)}function ia(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&Q.findFrom(i,t)}function gn(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Of(e,t,n){let r=e.state.selection;if(r instanceof P)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=e.state.doc.resolve(o.pos+i.nodeSize*(t<0?-1:1));return gn(e,new P(r.$anchor,s))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=ia(e.state,t);return o&&o instanceof _?gn(e,o):!1}else if(!(mt&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=t<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=e.docView.descAt(l))&&!s.contentDOM?_.isSelectable(i)?gn(e,new _(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):gn(e,new P(e.state.doc.resolve(t<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof _&&r.node.isInline)return gn(e,new P(t>0?r.$to:r.$from));{let o=ia(e.state,t);return o?gn(e,o):!1}}}function ao(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR"):W(e)&&e.contentEditable=="false"}function xr(e,t){return t<0?d0(e):f0(e)}function d0(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;for(dt&&W(n)&&r<Ye(n)&&ao(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!W(n))break;let l=n.childNodes[r-1];if(ao(l,-1))o=n,i=--r;else if(Ve(l))n=l,r=n.nodeValue.length;else break}else{if(cp(n))break;{let l=n.previousSibling;for(;l&&ao(l,-1);)o=n.parentNode,i=qe(l),l=l.previousSibling;if(l)n=l,r=Ye(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?sa(e,n,r):o&&sa(e,o,i)}function f0(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o=Ye(n),i,s;for(;;)if(r<o){if(!W(n))break;let l=n.childNodes[r];if(ao(l,1))i=n,s=++r;else break}else{if(cp(n))break;{let l=n.nextSibling;for(;l&&ao(l,1);)i=l.parentNode,s=qe(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=Ye(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}i&&sa(e,i,s)}function cp(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function p0(e,t){for(;e&&t==e.childNodes.length&&!ho(e);)t=qe(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(Ve(n))return n;if(W(n)&&n.contentEditable=="false")break;e=n,t=0}}function h0(e,t){for(;e&&!t&&!ho(e);)t=qe(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(Ve(n))return n;if(W(n)&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function sa(e,t,n){if(!Ve(t)){let i,s;(s=p0(t,n))?(t=s,n=0):(i=h0(t,n))&&(t=i,n=i.nodeValue.length)}let r=e.domSelection();if(!r)return;if(wi(r)){let i=document.createRange();i.setEnd(t,n),i.setStart(t,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&Qt(e)},50)}function Lf(e,t){let n=e.state.doc.resolve(t);if(!(Ge||Xf)&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function Pf(e,t,n){let r=e.state.selection;if(r instanceof P&&!r.empty||n.indexOf("s")>-1||mt&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let s=ia(e.state,t);if(s&&s instanceof _)return gn(e,s)}if(!o.parent.inlineContent){let s=t<0?o:i,l=r instanceof pn?Q.near(s,t):Q.findFrom(s,t);return l?gn(e,l):!1}return!1}function If(e,t){if(!(e.state.selection instanceof P))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=e.state.tr;return t<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),e.dispatch(s),!0}return!1}function $f(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function m0(e){if(!Qe||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&W(t)&&n==0&&t.firstChild&&W(t.firstChild)&&t.firstChild.contentEditable=="false"){let r=t.firstChild;$f(e,r,"true"),setTimeout(()=>$f(e,r,"false"),20)}return!1}function g0(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function b0(e,t){let n=t.keyCode,r=g0(t);if(n==8||mt&&n==72&&r=="c")return If(e,-1)||xr(e,-1);if(n==46&&!t.shiftKey||mt&&n==68&&r=="c")return If(e,1)||xr(e,1);if(n==13||n==27)return!0;if(n==37||mt&&n==66&&r=="c"){let o=n==37?Lf(e,e.state.selection.from)=="ltr"?-1:1:-1;return Of(e,o,r)||xr(e,o)}else if(n==39||mt&&n==70&&r=="c"){let o=n==39?Lf(e,e.state.selection.from)=="ltr"?1:-1:1;return Of(e,o,r)||xr(e,o)}else{if(n==38||mt&&n==80&&r=="c")return Pf(e,-1,r)||xr(e,-1);if(n==40||mt&&n==78&&r=="c")return m0(e)||Pf(e,1,r)||xr(e,1);if(r==(mt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ya(e,t){e.someProp("transformCopied",p=>{t=p(t,e)});let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=e.someProp("clipboardSerializer")||$n.fromSchema(e.state.schema),l=mp(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&W(c)&&(u=hp[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&W(c)&&c.setAttribute("data-pm-slice",`${o} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let d=e.someProp("clipboardTextSerializer",p=>p(t,e))||t.content.textBetween(0,t.content.size,`
|
|
6
|
+
|
|
7
|
+
`);return{dom:a,text:d,slice:t}}function up(e,t,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!t)return null;let a=!!t&&(r||i||!n);if(a){if(e.someProp("transformPastedText",d=>{t=d(t,i||r,e)}),i)return l=new ue(F.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
8
|
+
`))),0,0),e.someProp("transformPasted",d=>{l=d(l,e,!0)}),l;let f=e.someProp("clipboardTextParser",d=>d(t,o,r,e));if(f)l=f;else{let d=o.marks(),{schema:p}=e.state,h=$n.fromSchema(p);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(g=>{let m=s.appendChild(document.createElement("p"));g&&m.appendChild(h.serializeNode(p.text(g,d)))})}}else e.someProp("transformPastedHTML",f=>{n=f(n,e)}),s=v0(n),ki&&C0(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=s.firstChild;for(;d&&!W(d);)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(e.someProp("clipboardParser")||e.someProp("domParser")||In.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!y0.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=x0(Bf(l,+u[1],+u[2]),u[4]);else if(l=ue.maxOpen(w0(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=Bf(l,f,d)}return e.someProp("transformPasted",f=>{l=f(l,e,a)}),l}var y0=/^(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 w0(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o=t.node(n).contentMatchAt(t.index(n)),i,s=[];if(e.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&fp(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=pp(s[s.length-1],i.length));let u=dp(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return F.from(s)}return e}function dp(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,F.from(e));return e}function fp(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=fp(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(F.from(dp(n,e,o+1))))}}function pp(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,pp(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(F.empty,!0);return e.copy(n.append(r))}function la(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,l=s.content;return e.childCount>1&&(i=0),o<r-1&&(l=la(l,t,n,r,o+1,i)),o>=n&&(l=t<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(F.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(l))}function Bf(e,t,n){return t<e.openStart&&(e=new ue(la(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new ue(la(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var hp={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function mp(){return document.implementation.createHTMLDocument("title")}var so=null;function k0(e){let t=window.trustedTypes;if(!t)return e;if(!so){if(so=t.defaultPolicy)try{return so.createHTML(e)}catch{}so=t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return so.createHTML(e)}function v0(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=mp(),r=n.body,o=/<([a-z][^>\s]+)/i.exec(e),i;if((i=o&&hp[o[1].toLowerCase()])&&(e=i.map(s=>"<"+s+">").join("")+e+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=k0(e),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[s])||r;for(let s=0;s<n.styleSheets.length;s++){let l=n.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let f=0;f<u.length;f++)u[f].style.cssText+=c.style.cssText}}}return r}function C0(e){let t=e.querySelectorAll(Ge?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function x0(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:o,openStart:i,openEnd:s}=e;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{o=F.from(a.create(r[l+1],o))}catch{break}i++,s++}return new ue(o,i,s)}var et={},tt={},S0={touchstart:!0,touchmove:!0},aa=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function E0(e){for(let t in et){let n=et[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=r=>{A0(e,r)&&!wa(e,r)&&(e.editable||!(r.type in tt))&&n(e,r)},S0[t]?{passive:!0}:void 0)}Qe&&e.dom.addEventListener("input",()=>null),ca(e)}function Yt(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function M0(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function ca(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=r=>wa(e,r))})}function wa(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function A0(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function T0(e,t){!wa(e,t)&&et[t.type]&&(e.editable||!(t.type in tt))&&et[t.type](e,t)}tt.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!yp(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Xt&&Ge&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),Mr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",o=>o(e,zn(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||b0(e,n)?n.preventDefault():Yt(e,"key")};tt.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};tt.keypress=(e,t)=>{let n=t;if(yp(e)||!n.charCode||n.ctrlKey&&!n.altKey||mt&&n.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!e.someProp("handleTextInput",s=>s(e,r.$from.pos,r.$to.pos,o,i))&&e.dispatch(i()),n.preventDefault()}};function mo(e){return{left:e.clientX,top:e.clientY}}function N0(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function ka(e,t,n,r,o){if(r==-1)return!1;let i=e.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(e.someProp(t,l=>s>i.depth?l(e,n,i.nodeAfter,i.before(s),o,!0):l(e,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function go(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function R0(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&_.isSelectable(r)?(go(e,new _(n)),!0):!1}function D0(e,t){if(t==-1)return!1;let n=e.state.selection,r,o;n instanceof _&&(r=n.node);let i=e.state.doc.resolve(t);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(_.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(go(e,_.create(e.state.doc,o)),!0):!1}function O0(e,t,n,r,o){return ka(e,"handleClickOn",t,n,r)||e.someProp("handleClick",i=>i(e,t,r))||(o?D0(e,n):R0(e,n))}function L0(e,t,n,r){return ka(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",o=>o(e,t,r))}function P0(e,t,n,r){return ka(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",o=>o(e,t,r))||I0(e,n,r)}function I0(e,t,n){if(n.button!=0)return!1;let r=gp(e,t,!0),o=e.state.doc;return r?(go(e,r),r instanceof P&&o.eq(e.state.doc)&&(e.input.mouseDown=new da(e,r)),!0):!1}function gp(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?P.create(r,0,r.content.size):null;let o=r.resolve(t);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)return P.create(r,l+1,l+1+s.content.size);if(n&&_.isSelectable(s))return _.create(r,l)}return null}function va(e){return hi(e)}var bp=mt?"metaKey":"ctrlKey";et.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=va(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&N0(n,e.input.lastClick)&&!n[bp]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(mo(n));s&&(i=="singleClick"?e.input.mouseDown=new ua(e,s,n,!!r):(i=="doubleClick"?L0:P0)(e,s.pos,s.inside,n)?n.preventDefault():Yt(e,"pointer"))};var pi=class{constructor(t){this.view=t,this.mightDrag=null,t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(t){this.done()}move(t){t.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},ua=class extends pi{constructor(t,n,r,o){super(t),this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=t.state.doc,this.selectNode=!!r[bp],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=t.state.doc.nodeAt(n.inside),s=n.inside;else{let u=t.state.doc.resolve(n.pos);i=u.parent,s=u.depth?u.before():0}let l=o?null:r.target,a=l?t.docView.nearestDesc(l,!0):null;this.target=a&&W(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=t.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof _&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&dt&&!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()),Yt(t,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||Qt(this.view)})}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(mo(t))),this.updateAllowDefault(t),this.allowDefault||!n?Yt(this.view,"pointer"):O0(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Qe&&this.mightDrag&&!this.mightDrag.node.isAtom||Ge&&!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)?(go(this.view,Q.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):Yt(this.view,"pointer")}move(t){this.updateAllowDefault(t),Yt(this.view,"pointer"),super.move(t)}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},da=class extends pi{constructor(t,n){super(t),this.startSelection=n,this.startDoc=t.state.doc}move(t){if(t.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}t.preventDefault(),Yt(this.view,"pointer");let n=this.view.posAtCoords(mo(t)),r=n&&gp(this.view,n.inside,!1);if(!r)return;let{doc:o}=this.view.state,i=this.startSelection,[s,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];go(this.view,P.create(o,s,l))}};et.touchstart=e=>{e.input.lastTouch=Date.now(),va(e),Yt(e,"pointer")};et.touchmove=e=>{e.input.lastTouch=Date.now(),Yt(e,"pointer")};et.contextmenu=e=>va(e);function yp(e,t){return e.composing?!0:Qe&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var $0=Xt?5e3:-1;tt.compositionstart=tt.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof P&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ge&&Xf&&B0(e)))e.markCursor=e.state.storedMarks||n.marks(),hi(e,!0),e.markCursor=null;else if(hi(e,!t.selection.empty),dt&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&W(o)&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(Ve(s)){let l=e.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}e.input.composing=!0}wp(e,$0)};function B0(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!W(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return W(r)&&r.contentEditable=="false"}tt.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,wp(e,20))};function wp(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>hi(e),t))}function kp(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function z0(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Iy(t.focusNode,t.focusOffset),r=$y(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function hi(e,t=!1){if(!(Xt&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),kp(e),t||e.docView&&e.docView.dirty){let n=ga(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function H0(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var co=st&&bn<15||Mr&&_y<604;et.copy=tt.cut=(e,t)=>{let n=t,r=e.state.selection,o=n.type=="cut";if(r.empty)return;let i=co?null:n.clipboardData,s=r.content(),{dom:l,text:a}=ya(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):H0(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function _0(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function V0(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?uo(e,r.value,null,o,t):uo(e,r.textContent,r.innerHTML,o,t)},50)}function uo(e,t,n,r,o){let i=up(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",a=>a(e,o,i||ue.empty)))return!0;if(!i)return!1;let s=_0(i),l=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function vp(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}tt.paste=(e,t)=>{let n=t;if(e.composing&&!Xt)return;let r=co?null:n.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&uo(e,vp(r),r.getData("text/html"),o,n)?n.preventDefault():V0(e,n)};var mi=class{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}},j0=mt?"altKey":"ctrlKey";function Cp(e,t){let n;return e.someProp("dragCopies",r=>{n=n||r(t)}),n!=null?!n:!t[j0]}et.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=e.state.selection,i=o.empty?null:e.posAtCoords(mo(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof _?o.to-1:o.to))){if(r&&r.mightDrag)s=_.create(e.state.doc,r.mightDrag.pos);else if(n.target&&W(n.target)){let f=e.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=e.docView&&(s=_.create(e.state.doc,f.posBefore))}}let l=(s||e.state.selection).content(),{dom:a,text:c,slice:u}=ya(e,l);(!n.dataTransfer.files.length||!Ge||Jf>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(co?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",co||n.dataTransfer.setData("text/plain",c),e.dragging=new mi(u,Cp(e,n),s)};et.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};tt.dragover=tt.dragenter=(e,t)=>t.preventDefault();tt.drop=(e,t)=>{try{F0(e,t,e.dragging)}finally{e.dragging=null}};function F0(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(mo(t));if(!r)return;let o=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",p=>{i=p(i,e,!1)}):i=up(e,vp(t.dataTransfer),co?null:t.dataTransfer.getData("text/html"),!1,o);let s=!!(n&&Cp(e,t));if(e.someProp("handleDrop",p=>p(e,t,i||ue.empty,s))){t.preventDefault();return}if(!i)return;t.preventDefault();let l=i?ri(e.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=e.state.tr;if(s){let{node:p}=n;p?p.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(f))return;let d=a.doc.resolve(c);if(u&&_.isSelectable(i.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new _(d));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,g,m,w)=>p=w),a.setSelection(ba(e,d,a.doc.resolve(p)))}e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))}et.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Qt(e)},20))};et.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};et.beforeinput=(e,t)=>{if(Xt&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,zn(8,"Backspace")))))return;let{$cursor:o}=e.state.selection;o&&o.pos>0&&e.dispatch(e.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let e in tt)et[e]=tt[e];function fo(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var gi=class e{constructor(t,n){this.toDOM=t,this.spec=n||Fn,this.side=this.spec.side||0}map(t,n,r,o){let{pos:i,deleted:s}=t.mapResult(n.from+o,this.side<0?-1:1);return s?null:new $e(i-r,i-r,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&fo(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},jn=class e{constructor(t,n){this.attrs=t,this.spec=n||Fn}map(t,n,r,o){let i=t.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=t.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new $e(i,s,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof e&&fo(this.attrs,t.attrs)&&fo(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},fa=class e{constructor(t,n){this.attrs=t,this.spec=n||Fn}map(t,n,r,o){let i=t.mapResult(n.from+o,1);if(i.deleted)return null;let s=t.mapResult(n.to+o,-1);return s.deleted||s.pos<=i.pos?null:new $e(i.pos-r,s.pos-r,this)}valid(t,n){let{index:r,offset:o}=t.content.findIndex(n.from),i;return o==n.from&&!(i=t.child(r)).isText&&o+i.nodeSize==n.to}eq(t){return this==t||t instanceof e&&fo(this.attrs,t.attrs)&&fo(this.spec,t.spec)}destroy(){}},$e=class e{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new e(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new e(t,t,new gi(n,r))}static inline(t,n,r,o){return new e(t,n,new jn(r,o))}static node(t,n,r,o){return new e(t,n,new fa(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof jn}get widget(){return this.type instanceof gi}},Sr=[],Fn={},de=class e{constructor(t,n){this.local=t.length?t:Sr,this.children=n.length?n:Sr}static create(t,n){return n.length?yi(n,t,0,Fn):Xe}find(t,n,r){let o=[];return this.findInner(t??0,n??1e9,o,0,r),o}findInner(t,n,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=t&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,n-l,r,o+l,i)}}map(t,n,r){return this==Xe||t.maps.length==0?this:this.mapInner(t,n,0,0,r||Fn)}mapInner(t,n,r,o,i){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(t,r,o);a&&a.type.valid(n,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?W0(this.children,s||[],t,n,r,o,i):s?new e(s.sort(Wn),Sr):Xe}add(t,n){return n.length?this==Xe?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let o,i=0;t.forEach((l,a)=>{let c=a+r,u;if(u=Sp(n,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,u,c+1):o.splice(i,0,a,a+l.nodeSize,yi(u,l,c+1,Fn)),i+=3}});let s=xp(i?Ep(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(t,s[l])||s.splice(l--,1);return new e(s.length?this.local.concat(s).sort(Wn):this.local,o||this.children)}remove(t){return t.length==0||this==Xe?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+n,a=r[i+1]+n;for(let u=0,f;u<t.length;u++)(f=t[u])&&f.from>l&&f.to<a&&(t[u]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=Xe?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<t.length;i++)if(s=t[i])for(let l=0;l<o.length;l++)o[l].eq(s,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new e(o,r):Xe}forChild(t,n){if(this==Xe)return this;if(n.isLeaf)return e.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=t){this.children[l]==t&&(r=this.children[l+2]);break}let i=t+1,s=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof jn){let c=Math.max(i,a.from)-i,u=Math.min(s,a.to)-i;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new e(o.sort(Wn),Sr);return r?new bi([l,r]):l}return r||Xe}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return Ca(this.localsInner(t))}localsInner(t){if(this==Xe)return Sr;if(t.inlineContent||!this.local.some(jn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof jn||n.push(this.local[r]);return n}forEachSet(t){t(this)}};de.empty=new de([],[]);de.removeOverlap=Ca;var Xe=de.empty,bi=class e{constructor(t){this.members=t}map(t,n){let r=this.members.map(o=>o.map(t,n,Fn));return e.from(r)}forChild(t,n){if(n.isLeaf)return de.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(t,n);i!=Xe&&(i instanceof e?r=r.concat(i.members):r.push(i))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(t);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let s=0;s<i.length;s++)n.push(i[s])}}return n?Ca(r?n:n.sort(Wn)):Sr}static from(t){switch(t.length){case 0:return Xe;case 1:return t[0];default:return new e(t.every(n=>n instanceof de)?t:t.reduce((n,r)=>n.concat(r instanceof de?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}};function W0(e,t,n,r,o,i,s){let l=e.slice();for(let c=0,u=i;c<n.maps.length;c++){let f=0;n.maps[c].forEach((d,p,h,g)=>{let m=g-h-(p-d);for(let w=0;w<l.length;w+=3){let k=l[w+1];if(k<0||d>k+u-f)continue;let x=l[w]+u-f;p>=x?l[w+1]=d<=x?-2:-1:d>=u&&m&&(l[w]+=m,l[w+1]+=m)}f+=m}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(e[c]+i),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=n.map(e[c+1]+i,-1),p=d-o,{index:h,offset:g}=r.content.findIndex(f),m=r.maybeChild(h);if(m&&g==f&&g+m.nodeSize==p){let w=l[c+2].mapInner(n,m,u+1,e[c]+i+1,s);w!=Xe?(l[c]=f,l[c+1]=p,l[c+2]=w):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=K0(l,e,t,n,o,i,s),u=yi(c,r,0,s);t=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let p=u.children[f];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new de(t.sort(Wn),l)}function xp(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new $e(o.from+t,o.to+t,o.type))}return n}function K0(e,t,n,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?n.push(f):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<e.length;a+=3)e[a+1]==-1&&l(e[a+2],t[a]+i+1);return n}function Sp(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let i=0,s;i<e.length;i++)(s=e[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),e[i]=null);return o}function Ep(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function yi(e,t,n,r){let o=[],i=!1;t.forEach((l,a)=>{let c=Sp(e,l,a+n);if(c){i=!0;let u=yi(c,l,n+a+1,r);u!=Xe&&o.push(a,a+l.nodeSize,u)}});let s=xp(i?Ep(e):e,-n).sort(Wn);for(let l=0;l<s.length;l++)s[l].type.valid(t,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new de(s,o):Xe}function Wn(e,t){return e.from-t.from||e.to-t.to}function Ca(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from==r.from){i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),zf(t,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),zf(t,o,r.copy(i.from,r.to)));break}}}return t}function zf(e,t,n){for(;t<e.length&&Wn(n,e[t])>0;)t++;e.splice(t,0,n)}function ql(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Xe&&t.push(r)}),e.cursorWrapper&&t.push(de.create(e.state.doc,[e.cursorWrapper.deco])),bi.from(t)}var U0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},q0=st&&bn<=11,pa=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}},ha=class{constructor(t,n){this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new pa,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);st&&bn<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():Qe&&t.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),q0&&(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,U0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let n=0;n<t.length;n++)this.queue.push(t[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(Df(this.view)){if(this.suppressingSelectionUpdates)return Qt(this.view);if(st&&bn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Kn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let n=new Set,r;for(let i=t.focusNode;i;i=Er(i))n.add(i);for(let i=t.anchorNode;i;i=Er(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:Ve(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Df(t)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(t.editable)for(let u=0;u<n.length;u++){let f=this.registerMutation(n[u],a);f&&(i=i<0?f.from:Math.min(f.from,i),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||Ge&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;for(;f&&W(f);){if(f.contentEditable=="false"){u.parentNode.removeChild(u);break}f=f.firstChild}}}else if(dt&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let p=d.parentNode;p&&p.nodeName=="LI"&&(!f||X0(t,f)!=p)&&d.remove()}}}let c=null;i<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&wi(r)&&(c=ga(t))&&c.eq(Q.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Qt(t),this.currentSelection.set(r),t.scrollToSelection()):(i>-1||o)&&(i>-1&&(t.docView.markDirty(i,s),G0(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,Y0(t,a)),this.handleDOMChange(i,s,l,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||Qt(t),this.currentSelection.set(r))}registerMutation(t,n){if(n.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let u=0;u<t.addedNodes.length;u++){let f=t.addedNodes[u];n.push(f),Ve(f)&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let o=t.previousSibling,i=t.nextSibling;if(st&&bn<=11&&t.addedNodes.length)for(let u=0;u<t.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=t.addedNodes[u];(!f||Array.prototype.indexOf.call(t.addedNodes,f)<0)&&(o=f),(!d||Array.prototype.indexOf.call(t.addedNodes,d)<0)&&(i=d)}let s=o&&o.parentNode==t.target?qe(o)+1:0,l=r.localPosFromDOM(t.target,s,-1),a=i&&i.parentNode==t.target?qe(i):t.target.childNodes.length,c=r.localPosFromDOM(t.target,a,1);return{from:l,to:c}}else return t.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=t.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}},Hf=new WeakMap,_f=!1;function G0(e){if(!Hf.has(e)&&(Hf.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=dt,_f)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."),_f=!0}}function Vf(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Kn(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function J0(e,t){if(t.getComposedRanges){let o=t.getComposedRanges(e.root)[0];if(o)return Vf(e,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Vf(e,n):null}function X0(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let r=e.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Y0(e,t){var n;let{focusNode:r,focusOffset:o}=e.domSelectionRange();for(let i of t)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!W(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&e.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}function Q0(e,t,n,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),c=e.domSelectionRange(),u,f=c.anchorNode;if(f&&Un(e.dom,f)&&(u=[{node:f,offset:c.anchorOffset}],wi(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ge&&e.input.lastKeyCode===8)for(let w=s;w>i;w--){let k=o.childNodes[w-1],x=k.pmViewDesc;if(k.nodeName=="BR"&&!x){s=w;break}if(!x||x.size)break}let d=e.state.doc,p=e.someProp("domParser")||In.fromSchema(e.state.schema),h=d.resolve(l),g=null,m=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Z0(r),context:h});if(u&&u[0].pos!=null){let w=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=w),g={anchor:w+l,head:k+l}}return{doc:m,sel:g,from:l,to:a}}var Z0=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName=="BR"&&t.parentNode){if(Qe&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||Qe&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},ew=/^(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 tw(e,t,n,r,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let S=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,L=ga(e,S);if(L&&!e.state.selection.eq(L)){if(Ge&&Xt&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",G=>G(e,zn(13,"Enter"))))return;let X=e.state.tr.setSelection(L);S=="pointer"?X.setMeta("pointer",!0):S=="key"&&X.scrollIntoView(),i&&X.setMeta("composition",i),e.dispatch(X)}return}let s=e.state.doc.resolve(t),l=s.sharedDepth(n);t=s.before(l+1),n=e.state.doc.resolve(n).after(l+1);let a=e.state.selection,c=Q0(e,t,n,o),u=e.state.doc,f=u.slice(c.from,c.to),d,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(d=e.state.selection.to,p="end"):(d=e.state.selection.from,p="start"),e.input.lastKeyCode=null;let h=iw(f.content,c.doc.content,c.from,d,p);if(h&&e.input.domChangeCount++,(Mr&&e.input.lastIOSEnter>Date.now()-225||Xt)&&o.some(S=>W(S)&&!ew.test(S.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",S=>S(e,zn(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof P&&!a.empty&&a.$head.sameParent(a.$anchor)&&!e.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let S=jf(e,e.state.doc,c.sel);if(S&&!S.eq(e.state.selection)){let L=e.state.tr.setSelection(S);i&&L.setMeta("composition",i),e.dispatch(L)}}return}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof P&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=c.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=c.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),st&&bn<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" \xA0"&&(h.start--,h.endA--,h.endB--);let g=c.doc.resolveNoCache(h.start-c.from),m=c.doc.resolveNoCache(h.endB-c.from),w=u.resolve(h.start),k=g.sameParent(m)&&g.parent.inlineContent&&w.end()>=h.endA;if((Mr&&e.input.lastIOSEnter>Date.now()-225&&(!k||o.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!k&&ow(c.doc,g.pos,m.pos))&&e.someProp("handleKeyDown",S=>S(e,zn(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&rw(u,h.start,h.endA,g,m)&&e.someProp("handleKeyDown",S=>S(e,zn(8,"Backspace")))){Xt&&Ge&&e.domObserver.suppressSelectionUpdates();return}Ge&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),Xt&&!k&&g.start()!=m.start()&&m.parentOffset==0&&g.depth==m.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,m=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{e.someProp("handleKeyDown",function(S){return S(e,zn(13,"Enter"))})},20));let x=h.start,E=h.endA,M=S=>{let L=S||e.state.tr.replace(x,E,c.doc.slice(h.start-c.from,h.endB-c.from));if(c.sel){let X=jf(e,L.doc,c.sel);X&&!(Ge&&e.composing&&X.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(X.head==x||X.head==L.mapping.map(E)-1)||st&&X.empty&&X.head==x)&&L.setSelection(X)}return i&&L.setMeta("composition",i),L.scrollIntoView()},A;if(k)if(g.pos==m.pos){st&&bn<=11&&g.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qt(e),20));let S=M(e.state.tr.delete(x,E)),L=u.resolve(h.start).marksAcross(u.resolve(h.endA));L&&S.ensureMarks(L),e.dispatch(S)}else if(h.endA==h.endB&&(A=nw(g.parent.content.cut(g.parentOffset,m.parentOffset),w.parent.content.cut(w.parentOffset,h.endA-w.start())))){let S=M(e.state.tr);A.type=="add"?S.addMark(x,E,A.mark):S.removeMark(x,E,A.mark),e.dispatch(S)}else if(g.parent.child(g.index()).isText&&g.index()==m.index()-(m.textOffset?0:1)){let S=g.parent.textBetween(g.parentOffset,m.parentOffset),L=()=>M(e.state.tr.insertText(S,x,E));e.someProp("handleTextInput",X=>X(e,x,E,S,L))||e.dispatch(L())}else e.dispatch(M());else e.dispatch(M())}function jf(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:ba(e,t.resolve(n.anchor),t.resolve(n.head))}function nw(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,o=n,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<t.childCount;u++)c.push(a(t.child(u)));if(F.from(c).eq(e))return{mark:l,type:s}}function rw(e,t,n,r,o){if(n-t<=o.pos-r.pos||Gl(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==t+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(Gl(i,!0,!0));return!s.parent.isTextblock||s.pos>n||Gl(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function ow(e,t,n){let r=0,o=0;return e.nodesBetween(t,n,(i,s)=>{i.isTextblock&&s>=t&&s<n?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,t-s),Math.min(i.nodeSize,n-s))):i.isLeaf)&&o++}),o==0&&r==1}function Gl(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let i=e.node(r).maybeChild(e.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function iw(e,t,n,r,o){let i=e.findDiffStart(t,n),s=n+e.size,l=n+t.size;if(i==null)return null;let{a,b:c}=e.findDiffEnd(t,s,l);if(o=="end"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&s<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var po=class{constructor(t,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 aa,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(qf),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Kf(this),Wf(this),this.nodeViews=Uf(this),this.docView=Ef(this.state.doc,Ff(this),ql(this),this.dom,this),this.domObserver=new ha(this,(r,o,i,s)=>tw(this,r,o,i,s)),this.domObserver.start(),E0(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let n in t)this._props[n]=t[n];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&ca(this);let n=this._props;this._props=t,t.plugins&&(t.plugins.forEach(qf),this.directPlugins=t.plugins),this.updateStateInner(t.state,n)}setProps(t){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in t)n[r]=t[r];this.update(n)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,n){var r;let o=this.state,i=!1,s=!1;t.storedMarks&&this.composing&&(kp(this),s=!0),this.state=t;let l=o.plugins!=t.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=Uf(this);lw(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&ca(this),this.editable=Kf(this),Wf(this);let a=ql(this),c=Ff(this),u=o.plugins!=t.plugins&&!o.doc.eq(t.doc)?"reset":t.scrollToSelection>o.scrollToSelection?"to selection":"preserve",f=i||!this.docView.matchesNode(t.doc,c,a);(f||!t.selection.eq(o.selection))&&(s=!0);let d=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Fy(this);if(s){this.domObserver.stop();let p=f&&(st||Ge)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&sw(o.selection,t.selection);if(f){let g=Ge?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=z0(this)),(i||!this.docView.update(t.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ef(t.doc,c,a,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let h=this.input.mouseDown;p||!(h&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&u0(this)&&h.delaySelUpdate())?Qt(this,p):(lp(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&Wy(d)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!Un(this.dom,t))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof _){let n=this.docView.domAfterPos(this.state.selection.from);W(n)&&kf(this,n.getBoundingClientRect(),t)}else kf(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.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,t)}}updateDraggedNode(t,n){let r=t.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=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&&(o=i)}this.dragging=new mi(t.slice,t.move,o<0?void 0:_.create(this.state.doc,o))}someProp(t,n){let r=this._props&&this._props[t],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[t];if(l!=null&&(o=n?n(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[t];if(l!=null&&(o=n?n(l):l))return o}}hasFocus(){if(st){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Ky(this.dom),Qt(this),this.domObserver.start()}get root(){let t=this._root;if(t==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 t||document}updateRoot(){this._root=null}posAtCoords(t){return Xy(this,t)}coordsAtPos(t,n=1){return tp(this,t,n)}domAtPos(t,n=0){return this.docView.domFromPos(t,n)}nodeDOM(t){let n=this.docView.descAt(t);return n?n.nodeDOM:null}posAtDOM(t,n,r=-1){let o=this.docView.posFromDOM(t,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(t,n){return t0(this,n||this.state,t)}pasteHTML(t,n){return uo(this,"",t,!1,n||new ClipboardEvent("paste"))}pasteText(t,n){return uo(this,t,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(t){return ya(this,t)}destroy(){this.docView&&(M0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ql(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ly())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return T0(this,t)}domSelectionRange(){let t=this.dom.isConnected!==!1&&this.domSelection();return t?Qe&&this.root.nodeType===11&&zy(this.dom.ownerDocument)==this.dom&&J0(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};po.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Ff(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(e.state)),n)for(let r in n)r=="class"?t.class+=" "+n[r]:r=="style"?t.style=(t.style?t.style+";":"")+n[r]:!t[r]&&r!="contenteditable"&&r!="nodeName"&&(t[r]=String(n[r]))}),t.translate||(t.translate="no"),[$e.node(0,e.state.doc.content.size,t)]}function Wf(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:$e.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Kf(e){return!e.someProp("editable",t=>t(e.state)===!1)}function sw(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Uf(e){let t=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(t,o)||(t[o]=r[o])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function lw(e,t){let n=0,r=0;for(let o in e){if(e[o]!=t[o])return!0;n++}for(let o in t)r++;return n!=r}function qf(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Zt={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:"'"},Ci={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},aw=typeof navigator<"u"&&/Mac/.test(navigator.platform),cw=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(He=0;He<10;He++)Zt[48+He]=Zt[96+He]=String(He);var He;for(He=1;He<=24;He++)Zt[He+111]="F"+He;var He;for(He=65;He<=90;He++)Zt[He]=String.fromCharCode(He+32),Ci[He]=String.fromCharCode(He);var He;for(vi in Zt)Ci.hasOwnProperty(vi)||(Ci[vi]=Zt[vi]);var vi;function Mp(e){var t=aw&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||cw&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Ci:Zt)[e.keyCode]||e.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}var uw=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),dw=typeof navigator<"u"&&/Win/.test(navigator.platform);function fw(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<t.length-1;l++){let a=t[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))uw?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),s&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function pw(e){let t=Object.create(null);for(let n in e)t[fw(n)]=e[n];return t}function xa(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Ap(e){return new U({props:{handleKeyDown:bo(e)}})}function bo(e){let t=pw(e);return function(n,r){let o=Mp(r),i,s=t[xa(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=t[xa(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(dw&&r.ctrlKey&&r.altKey)&&(i=Zt[r.keyCode])&&i!=o){let l=t[xa(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var xi=200,Je=function(){};Je.prototype.append=function(t){return t.length?(t=Je.from(t),!this.length&&t||t.length<xi&&this.leafAppend(t)||this.length<xi&&t.leafPrepend(this)||this.appendInner(t)):this};Je.prototype.prepend=function(t){return t.length?Je.from(t).append(this):this};Je.prototype.appendInner=function(t){return new hw(this,t)};Je.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?Je.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};Je.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};Je.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};Je.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(t(i,s))},n,r),o};Je.from=function(t){return t instanceof Je?t:t&&t.length?new Tp(t):Je.empty};var Tp=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new t(this.values.slice(o,i))},t.prototype.getInner=function(o){return this.values[o]},t.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},t.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},t.prototype.leafAppend=function(o){if(this.length+o.length<=xi)return new t(this.values.concat(o.flatten()))},t.prototype.leafPrepend=function(o){if(this.length+o.length<=xi)return new t(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(Je);Je.empty=new Tp([]);var hw=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},t.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},t.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},t.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new t(this.left,o)},t.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new t(o,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(Je),Sa=Je;var mw=500,Gn=class e{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=t.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){o||(o=this.remapping(r,d+1),i=o.maps.length),i--,u.push(f);return}if(o){u.push(new Pt(f.map));let p=f.step.map(o.slice(i)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new Pt(h,void 0,void 0,c.length+u.length))),i--,h&&o.appendMap(h,i)}else s.maybeStep(f.step);if(f.selection)return l=o?f.selection.map(o.slice(i)):f.selection,a=new e(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(t,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<t.steps.length;u++){let f=t.steps[u].invert(t.docs[u]),d=new Pt(t.mapping.maps[u],f,n),p;(p=a&&a.merge(d))&&(d=p,u?i.pop():l=l.slice(0,l.length-1)),i.push(d),n&&(s++,n=void 0),o||(a=d)}let c=s-r.depth;return c>bw&&(l=gw(l,c),s-=c),new e(l.append(i),s)}remapping(t,n){let r=new ni;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=t?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},t,n),r}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(n=>new Pt(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],o=this.items.length-n,i=t.mapping,s=t.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},o);let a=n;this.items.forEach(d=>{let p=i.getMirror(--a);if(p==null)return;s=Math.min(s,p);let h=i.maps[p];if(d.step){let g=t.steps[p].invert(t.docs[p]),m=d.selection&&d.selection.map(i.slice(a+1,p));m&&l++,r.push(new Pt(h,g,m))}else r.push(new Pt(h))},o);let c=[];for(let d=n;d<s;d++)c.push(new Pt(i.maps[d]));let u=this.items.slice(0,o).append(c).append(r),f=new e(u,l);return f.emptyItemCount()>mw&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=t)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=s.selection&&s.selection.map(n.slice(r));u&&i++;let f=new Pt(c.invert(),a,u),d,p=o.length-1;(d=o.length&&o[p].merge(f))?o[p]=d:o.push(f)}}else s.map&&r--},this.items.length,0),new e(Sa.from(o.reverse()),i)}};Gn.empty=new Gn(Sa.empty,0);function gw(e,t){let n;return e.forEach((r,o)=>{if(r.selection&&t--==0)return n=o,!1}),e.slice(n)}var Pt=class e{constructor(t,n,r,o){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},It=class{constructor(t,n,r,o,i){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},bw=20;function yw(e,t,n,r){let o=n.getMeta(kn),i;if(o)return o.historyState;n.getMeta(Dp)&&(e=new It(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(s&&s.getMeta(kn))return s.getMeta(kn).redo?new It(e.done.addTransform(n,void 0,r,Si(t)),e.undone,Np(n.mapping.maps),e.prevTime,e.prevComposition):new It(e.done,e.undone.addTransform(n,void 0,r,Si(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=e.prevTime==0||!s&&e.prevComposition!=l&&(e.prevTime<(n.time||0)-r.newGroupDelay||!ww(n,e.prevRanges)),c=s?Ea(e.prevRanges,n.mapping):Np(n.mapping.maps);return new It(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Si(t)),Gn.empty,c,n.time,l??e.prevComposition)}else return(i=n.getMeta("rebased"))?new It(e.done.rebased(n,i),e.undone.rebased(n,i),Ea(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new It(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ea(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function ww(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<t.length;i+=2)r<=t[i+1]&&o>=t[i]&&(n=!0)}),n}function Np(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,o,i,s)=>t.push(i,s));return t}function Ea(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}function kw(e,t,n){let r=Si(t),o=kn.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),a=new It(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(kn,{redo:n,historyState:a})}var Ma=!1,Rp=null;function Si(e){let t=e.plugins;if(Rp!=t){Ma=!1,Rp=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Ma=!0;break}}return Ma}function Ar(e){return e.setMeta(Dp,!0)}var kn=new oe("history"),Dp=new oe("closeHistory");function Op(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new U({key:kn,state:{init(){return new It(Gn.empty,Gn.empty,null,0,-1)},apply(t,n,r){return yw(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,o=r=="historyUndo"?Aa:r=="historyRedo"?Ta:null;return!o||!t.editable?!1:(n.preventDefault(),o(t.state,t.dispatch))}}}})}function Ei(e,t){return(n,r)=>{let o=kn.getState(n);if(!o||(e?o.undone:o.done).eventCount==0)return!1;if(r){let i=kw(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}var Aa=Ei(!1,!0),Ta=Ei(!0,!0),rA=Ei(!1,!1),oA=Ei(!0,!1);function Lp(e){return e.getMeta(kn)!=null}function Di(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var Or=class Jp{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(){let{rawCommands:t,editor:n,state:r}=this,{view:o}=n,{tr:i}=r,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...u)=>{let f=a(...u)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(i),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l=[],a=!!t,c=t||i.tr,u=()=>(!a&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),l.every(d=>d===!0)),f={...Object.fromEntries(Object.entries(r).map(([d,p])=>[d,(...g)=>{let m=this.buildProps(c,n),w=p(...g)(m);return l.push(w),f}])),run:u};return f}static createFakeChain(){let t=new Proxy({},{get:(n,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>t}});return t}createCan(t){let{rawCommands:n,state:r}=this,o=!1,i=t||r.tr,s=this.buildProps(i,o);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,o)}}static createFallbackCan(){let t=Jp.createFakeChain();return new Proxy({chain:()=>t},{get:(n,r)=>{if(r!=="then")return r==="chain"?n.chain:()=>!1}})}buildProps(t,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l={tr:t,editor:o,view:s,state:Di({state:i,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}},vw=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),Cw=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),xw=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{e.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:u}=t,f=c.resolve(u.map(a)),d=c.resolve(u.map(a+l.nodeSize)),p=f.blockRange(d);if(!p)return;let h=qt(p);if(l.type.isTextblock){let{defaultType:g}=f.parent.contentMatchAt(f.index());t.setNodeMarkup(p.start,g)}(h||h===0)&&t.lift(p,h)})}),!0},Sw=e=>t=>e(t),Ew=()=>({state:e,dispatch:t})=>Hl(e,t),Mw=(e,t)=>({editor:n,tr:r})=>{let{state:o}=n,i=o.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let s=r.mapping.map(t);return r.insert(s,i.content),r.setSelection(new P(r.doc.resolve(Math.max(s-1,0)))),!0},Aw=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(t){let s=o.before(i),l=o.after(i);e.delete(s,l).scrollIntoView()}return!0}return!1};function _e(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var Tw=e=>({tr:t,state:n,dispatch:r})=>{let o=_e(e,n.schema),i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let l=i.before(s),a=i.after(s);t.delete(l,a).scrollIntoView()}return!0}return!1},Nw=e=>({tr:t,dispatch:n})=>{let{from:r,to:o}=e;return n&&t.delete(r,o),!0},Rw=e=>e.content?/^text(\*|\+)/.test(e.content):!1,Pp=(e,t,n)=>{if(!e.parent.isInline||n==="left"&&e.pos>e.start()||n==="right"&&e.pos<e.end())return e.pos;let r=t.nodes[e.parent.type.name].spec;return Rw(r)?n==="left"?e.start()-1:e.end()+1:e.pos},Dw=(e,t,n)=>({from:Pp(e,n,"left"),to:Pp(t,n,"right")}),Ow=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,o=n.steps.length;r.forEach(i=>{let s=n.mapping.slice(o),l=n.doc.resolve(s.map(i.$from.pos)),a=n.doc.resolve(s.map(i.$to.pos)),{from:c,to:u}=Dw(l,a,e.schema);n.deleteRange(c,u)}),n.selection.empty||n.setSelection(P.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),t(n)}return!0},Lw=()=>({commands:e})=>e.keyboardShortcut("Enter"),Pw=()=>({state:e,dispatch:t})=>zl(e,t);function $a(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function Ri(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(o=>n.strict?t[o]===e[o]:$a(t[o])?t[o].test(e[o]):t[o]===e[o]):!0}function Xp(e,t,n={}){return e.find(r=>r.type===t&&Ri(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function Ip(e,t,n={}){return!!Xp(e,t,n)}function Ba(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===t))return;if(!n){let a=r.node.marks.find(c=>c.type===t);a&&(n=a.attrs)}if(!Xp([...r.node.marks],t,n))return;let o=r.index,i=e.start()+r.offset,s=o+1,l=i+r.node.nodeSize;for(;o>0&&Ip([...e.parent.child(o-1).marks],t,n);)o-=1,i-=e.parent.child(o).nodeSize;for(;s<e.parent.childCount&&Ip([...e.parent.child(s).marks],t,n);)l+=e.parent.child(s).nodeSize,s+=1;return{from:i,to:l}}function en(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var Iw=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=en(e,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:u}=l;if(o){let f=Ba(a,i,t);if(f&&f.from<=c&&f.to>=u){let d=P.create(s,f.from,f.to);n.setSelection(d)}}return!0},$w=e=>t=>{let n=typeof e=="function"?e(t):e;for(let r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1};function Oi(e){return e instanceof P}function Jn(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Oa(e,t=null){if(!t)return null;let n=Q.atStart(e),r=Q.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return r;let o=n.from,i=r.to;return t==="all"?P.create(e,Jn(0,o,i),Jn(e.content.size,o,i)):P.create(e,Jn(t,o,i),Jn(t,o,i))}function ko(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Xn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Bw(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var zw=(e=null,t={})=>({editor:n,view:r,tr:o,dispatch:i})=>{t={scrollIntoView:!0,...t};let s=()=>{(Xn()||ko())&&r.dom.focus(),Bw()&&!Xn()&&!ko()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(i&&e===null&&!Oi(n.state.selection))return s(),!0;let l=Oa(o.doc,e)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},Hw=(e,t)=>n=>e.every((r,o)=>t(r,{...n,index:o})),_w=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Yp=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&Yp(r)}return e};function Mi(e){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,"text/html").body;return Yp(n)}function Qp(e){return typeof e?.nodesBetween=="function"}function Lr(e,t,n){if(Qp(e))return e;let r=typeof e=="object"&&e!==null;n={slice:!0,parseOptions:{},...n};let o=typeof e=="string";if(r)try{if(Array.isArray(e)&&e.length>0)return F.fromArray(e.map(s=>t.nodeFromJSON(s)));let i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",i),Lr("",t,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="",a=new wl({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?In.fromSchema(a).parseSlice(Mi(e),n.parseOptions):In.fromSchema(a).parse(Mi(e),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=In.fromSchema(t);return n.slice?i.parseSlice(Mi(e),n.parseOptions).content:i.parse(Mi(e),n.parseOptions)}return Lr("",t,n)}function Zp(e){return!("type"in e)}function eh(e,t,n){let r=e.steps.length-1;if(r<t)return;let o=e.steps[r];if(!(o instanceof Bn||o instanceof Ot))return;let i=e.mapping.maps[r],s=0;i.forEach((l,a,c,u)=>{s===0&&(s=u)}),e.setSelection(Q.near(e.doc.resolve(s),n))}var Vw=(e,t,n)=>({tr:r,dispatch:o,editor:i})=>{if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=m=>{i.emit("contentError",{editor:i,error:m,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Lr(t,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(m){a(m)}try{var s;l=Lr(t,i.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:i.options.enableContentCheck})}catch(m){return a(m),!1}let{from:u,to:f}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},d=!0,p=!0,h=Zp(l)?l.content:[l];if(h.forEach(m=>{m.check(),d=d?m.isText&&m.marks.length===0:!1,p=p?m.isBlock:!1}),u===f&&p){let{parent:m}=r.doc.resolve(u);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(u-=1,f+=1)}let g;if(d)Array.isArray(t)?g=t.map(m=>m.text||"").join(""):Qp(t)?g=h.map(m=>{var w;return(w=m.text)!==null&&w!==void 0?w:""}).join(""):typeof t=="object"&&t&&t.text?g=t.text:g=t,r.insertText(g,u,f);else{g=F.from(h);let m=r.doc.resolve(u),w=m.node(),k=m.parentOffset===0,x=w.isText||w.isTextblock,E=w.content.size>0;k&&x&&E&&p&&(u=Math.max(0,u-1)),r.replaceWith(u,f,h)}n.updateSelection&&eh(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};function th(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var jw=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{pos:o,attrs:i,content:s,updateSelection:l=!0}=e,a;typeof o=="number"?a=t.doc.resolve(o):o?a=o:a=t.selection.$from;let c=th(a.parent.contentMatchAt(a.index()));if(!c)return!1;let u=Object.keys(c.spec.attrs||{}),f=i?Object.fromEntries(Object.entries(i).filter(([p])=>u.includes(p))):{},d;if(s){let p=Lr(s,r.schema);d=c.createAndFill(f,p)}else d=c.createAndFill(f);return d?(n&&(t.insert(a.pos,d),l&&eh(t,t.steps.length-1,-1)),!0):!1},Fw=()=>({state:e,dispatch:t})=>af(e,t),Ww=()=>({state:e,dispatch:t})=>cf(e,t),Kw=()=>({state:e,dispatch:t})=>Rl(e,t),Uw=()=>({state:e,dispatch:t})=>Ll(e,t),nh=(e,t)=>{let n=e.resolve(t),r=n.nodeBefore,o=n.nodeAfter;return!r||!o?!1:!r.type.spec.isolating&&!o.type.spec.isolating},qw=()=>({state:e,dispatch:t,tr:n})=>{try{let r=yr(e.doc,e.selection.$from.pos,-1);return r==null||!nh(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Gw=()=>({state:e,dispatch:t,tr:n})=>{try{let r=yr(e.doc,e.selection.$from.pos,1);return r==null||!nh(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Jw=()=>({state:e,dispatch:t})=>rf(e,t),Xw=()=>({state:e,dispatch:t})=>of(e,t);function rh(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Yw(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<t.length-1;l+=1){let a=t[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Xn()||rh()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var Qw=e=>({editor:t,view:n,tr:r,dispatch:o})=>{let i=Yw(e).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=t.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function $t(e,t,n={}){let{from:r,to:o,empty:i}=e.selection,s=t?_e(t,e.schema):null,l=[];e.doc.nodesBetween(r,o,(u,f)=>{if(u.isText)return;let d=Math.max(r,f),p=Math.min(o,f+u.nodeSize);l.push({node:u,from:d,to:p})});let a=o-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>Ri(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}var Zw=(e,t={})=>({state:n,dispatch:r})=>$t(n,_e(e,n.schema),t)?uf(n,r):!1,ek=()=>({state:e,dispatch:t})=>_l(e,t),tk=e=>({state:t,dispatch:n})=>{let r=_e(e,t.schema);return gf(r)(t,n)},nk=()=>({state:e,dispatch:t})=>$l(e,t);function Li(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function $p(e,t){let n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,o)=>(n.includes(o)||(r[o]=e[o]),r),{})}var rk=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=Li(typeof e=="string"?e:e.name,r.schema);if(!l)return!1;l==="node"&&(i=_e(e,r.schema)),l==="mark"&&(s=en(e,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,f)=>{i&&i===u.type&&(a=!0,o&&n.setNodeMarkup(f,void 0,$p(u.attrs,t))),s&&u.marks.length&&u.marks.forEach(d=>{s===d.type&&(a=!0,o&&n.addMark(f,f+u.nodeSize,s.create($p(d.attrs,t))))})})}),a},ok=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),ik=()=>({tr:e,dispatch:t})=>{if(t){let n=new pn(e.doc);e.setSelection(n)}return!0},sk=()=>({state:e,dispatch:t})=>Dl(e,t),lk=()=>({state:e,dispatch:t})=>Pl(e,t),ak=()=>({state:e,dispatch:t})=>df(e,t),ck=()=>({state:e,dispatch:t})=>jl(e,t),uk=()=>({state:e,dispatch:t})=>Vl(e,t);function La(e,t,n={},r={}){return Lr(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var dk=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!=="full"){let c=La(e,o.schema,r,{errorOnInvalidContent:t??o.options.enableContentCheck});if(s){let u=Zp(c)?c.content:[c];i.replaceWith(0,a.content.size,u).setMeta("preventUpdate",!n)}return!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},e,{parseOptions:r,errorOnInvalidContent:t??o.options.enableContentCheck})};function oh(e,t){let n=en(t,e.schema),{from:r,to:o,empty:i}=e.selection,s=[];i?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function za(e,t){let n=new ii(e);return t.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function Yn(e,t){let n=[];return e.descendants((r,o)=>{t(r)&&n.push({node:r,pos:o})}),n}function ih(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function Ir(e,t){for(let n=e.depth;n>0;n-=1){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function Pi(e){return t=>Ir(t.$from,e)}function H(e,t,n){return e.config[t]===void 0&&e.parent?H(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?H(e.parent,t,n):null}):e.config[t]}function Ha(e){return e.map(t=>{let n=H(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return n?[t,...Ha(n())]:t}).flat(10)}function _a(e,t){let n=$n.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Pa(e){return typeof e=="function"}function pe(e,t=void 0,...n){return Pa(e)?t?e.bind(t)(...n):e(...n):e}function fk(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Pr(e){return{baseExtensions:e.filter(t=>t.type==="extension"),nodeExtensions:e.filter(t=>t.type==="node"),markExtensions:e.filter(t=>t.type==="mark")}}function sh(e){let t=[],{nodeExtensions:n,markExtensions:r}=Pr(e),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...s,...l];return e.forEach(c=>{let u=H(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:o});u&&u().forEach(f=>{let d;Array.isArray(f.types)?d=f.types:f.types==="*"?d=a:f.types==="nodes"?d=s:f.types==="marks"?d=l:d=[],d.forEach(p=>{Object.entries(f.attributes).forEach(([h,g])=>{t.push({type:p,name:h,attribute:{...i,...g}})})})})}),o.forEach(c=>{let u=H(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!u)return;let f=u();Object.entries(f).forEach(([d,p])=>{let h={...i,...p};typeof h?.default=="function"&&(h.default=h.default()),h?.isRequired&&h?.default===void 0&&delete h.default,t.push({type:c.name,name:d,attribute:h})})}),t}function pk(e){let t=[],n="",r=!1,o=!1,i=0,s=e.length;for(let l=0;l<s;l+=1){let a=e[l];if(a==="'"&&!o){r=!r,n+=a;continue}if(a==='"'&&!r){o=!o,n+=a;continue}if(!r&&!o){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){t.push(n),n="";continue}}n+=a}return n&&t.push(n),t}function Bp(e){let t=[],n=pk(e||""),r=n.length;for(let o=0;o<r;o+=1){let i=n[o],s=i.indexOf(":");if(s===-1)continue;let l=i.slice(0,s).trim(),a=i.slice(s+1).trim();l&&a&&t.push([l,a])}return t}function K(...e){return e.filter(t=>!!t).reduce((t,n)=>{let r={...t};return Object.entries(n).forEach(([o,i])=>{if(o==="__proto__"){Object.defineProperty(r,o,{configurable:!0,enumerable:!0,value:i,writable:!0});return}if(!r[o]){r[o]=i;return}if(o==="class"){let s=i?String(i).split(" "):[],l=r[o]?r[o].split(" "):[],a=s.filter(c=>!l.includes(c));r[o]=[...l,...a].join(" ")}else if(o==="style"){let s=new Map([...Bp(r[o]),...Bp(i)]);r[o]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[o]=i}),r},{})}function Bt(e,t){return t.filter(n=>n.type===e.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,r)=>K(n,r),{})}function hk(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function zp(e,t){return"style"in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let o=t.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(n):hk(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function Hp(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&fk(n)?!1:n!=null))}function _p(e){var t,n;let r={};return!(!(e==null||(t=e.attribute)===null||t===void 0)&&t.isRequired)&&"default"in(e?.attribute||{})&&(r.default=e.attribute.default),(e==null||(n=e.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function mk(e,t){var n;let r=sh(e),{nodeExtensions:o,markExtensions:i}=Pr(e),s=(n=o.find(c=>H(c,"topNode")))===null||n===void 0?void 0:n.name,l=Object.fromEntries(o.map(c=>{let u=r.filter(m=>m.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:t},d=Hp({...e.reduce((m,w)=>{let k=H(w,"extendNodeSchema",f);return{...m,...k?k(c):{}}},{}),content:pe(H(c,"content",f)),marks:pe(H(c,"marks",f)),group:pe(H(c,"group",f)),inline:pe(H(c,"inline",f)),atom:pe(H(c,"atom",f)),selectable:pe(H(c,"selectable",f)),draggable:pe(H(c,"draggable",f)),code:pe(H(c,"code",f)),whitespace:pe(H(c,"whitespace",f)),linebreakReplacement:pe(H(c,"linebreakReplacement",f)),defining:pe(H(c,"defining",f)),isolating:pe(H(c,"isolating",f)),attrs:Object.fromEntries(u.map(_p))}),p=pe(H(c,"parseHTML",f));p&&(d.parseDOM=p.map(m=>zp(m,u)));let h=H(c,"renderHTML",f);h&&(d.toDOM=m=>h({node:m,HTMLAttributes:Bt(m,u)}));let g=H(c,"renderText",f);return g&&(d.toText=g),[c.name,d]})),a=Object.fromEntries(i.map(c=>{let u=r.filter(g=>g.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:t},d=Hp({...e.reduce((g,m)=>{let w=H(m,"extendMarkSchema",f);return{...g,...w?w(c):{}}},{}),inclusive:pe(H(c,"inclusive",f)),excludes:pe(H(c,"excludes",f)),group:pe(H(c,"group",f)),spanning:pe(H(c,"spanning",f)),code:pe(H(c,"code",f)),attrs:Object.fromEntries(u.map(_p))}),p=pe(H(c,"parseHTML",f));p&&(d.parseDOM=p.map(g=>zp(g,u)));let h=H(c,"renderHTML",f);return h&&(d.toDOM=g=>h({mark:g,HTMLAttributes:Bt(g,u)})),[c.name,d]}));return new wl({topNode:s,nodes:l,marks:a})}function gk(e){let t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}function wo(e){return e.sort((n,r)=>{let o=H(n,"priority")||100,i=H(r,"priority")||100;return o>i?-1:o<i?1:0})}function lh(e){let t=wo(Ha(e)),n=gk(t.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.`),t}function ah(e,t,n){let{from:r,to:o}=t,{blockSeparator:i=`
|
|
9
|
+
|
|
10
|
+
`,textSerializers:s={}}=n||{},l="";return e.nodesBetween(r,o,(a,c,u,f)=>{a.isBlock&&c>r&&(l+=i);let d=s?.[a.type.name];if(d)return u&&(l+=d({node:a,pos:c,parent:u,index:f,range:t})),!1;if(a.isText){var p;l+=a==null||(p=a.text)===null||p===void 0?void 0:p.slice(Math.max(r,c)-c,o-c)}}),l}function bk(e,t){return ah(e,{from:0,to:e.content.size},t)}function ch(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}function yk(e,t){let n=_e(t,e.schema),{from:r,to:o}=e.selection,i=[];e.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function Va(e,t){let n=Li(typeof t=="string"?t:t.name,e.schema);return n==="node"?yk(e,t):n==="mark"?oh(e,t):{}}function wk(e,t=JSON.stringify){let n={};return e.filter(r=>{let o=t(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function kk(e){let t=wk(e);return t.length===1?t:t.filter((n,r)=>!t.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function $r(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((o,i)=>{let s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let c=t.slice(i).map(l,-1),u=t.slice(i).map(a),f=t.invert().map(c,-1),d=t.invert().map(u);r.push({oldRange:{from:f,to:d},newRange:{from:c,to:u}})})}),kk(r)}function vo(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(o=>{let i=Ba(n.resolve(e),o.type);i&&r.push({mark:o,...i})}):n.nodesBetween(e,t,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var uh=(e,t,n,r=20)=>{let o=e.doc.resolve(n),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);l?.type.name===t?s=l:i-=1}return[s,i]},dh=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function Tr(e,t){return t.nodes[e]||t.marks[e]||null}function Ni(e,t,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let o=e.find(i=>i.type===t&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var vk=(e,t=500)=>{let n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(o,i,s,l)=>{var a,c;let u=((a=(c=o.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-i))}),n};function Ia(e,t,n={}){let{empty:r,ranges:o}=e.selection,i=t?en(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>Ri(u.attrs,n,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:u,$to:f})=>{let d=u.pos,p=f.pos;e.doc.nodesBetween(d,p,(h,g)=>{if(i&&h.inlineContent&&!h.type.allowsMarkType(i))return!1;if(!h.isText&&!h.marks.length)return;let m=Math.max(d,g),w=Math.min(p,g+h.nodeSize),k=w-m;s+=k,l.push(...h.marks.map(x=>({mark:x,from:m,to:w})))})}),s===0)return!1;let a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>Ri(u.mark.attrs,n,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=s}function Ck(e,t,n={}){if(!t)return $t(e,null,n)||Ia(e,null,n);let r=Li(t,e.schema);return r==="node"?$t(e,t,n):r==="mark"?Ia(e,t,n):!1}var fh=(e,t)=>{let{$from:n,$to:r,$anchor:o}=e.selection;if(t){let i=Pi(l=>l.type.name===t)(e.selection);if(!i)return!1;let s=e.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},ph=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function Vp(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function Na(e,t){let{nodeExtensions:n}=Pr(t),r=n.find(i=>i.name===e);if(!r)return!1;let o=pe(H(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof o!="string"?!1:o.split(" ").includes("list")}function Br(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name==="hardBreak")return!0;if(e.isText){var r;return!/\S/.test((r=e.text)!==null&&r!==void 0?r:"")}}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let o=!0;return e.content.forEach(i=>{o!==!1&&(Br(i,{ignoreWhitespace:n,checkChildren:t})||(o=!1))}),o}return!1}function Ii(e){return e instanceof _}var hh=class mh{constructor(t){this.position=t}static fromJSON(t){return new mh(t.position)}toJSON(){return{position:this.position}}};function xk(e,t){let n=t.mapping.mapResult(e.position);return{position:new hh(n.pos),mapResult:n}}function Sk(e){return new hh(e)}function Ek(e,t,n){let{selection:r}=t,o=null;if(Oi(r)&&(o=r.$cursor),o){var i;let l=(i=e.storedMarks)!==null&&i!==void 0?i:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}let{ranges:s}=r;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(l.pos,a.pos,(u,f,d)=>{if(c)return!1;if(u.isInline){let p=!d||d.type.allowsMarkType(n),h=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=p&&h}return!c}),c})}var Mk=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=en(e,r.schema);if(o)if(s){let c=oh(r,a);n.addStoredMark(a.create({...c,...t}))}else l.forEach(c=>{let u=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(u,f,(d,p)=>{let h=Math.max(p,u),g=Math.min(p+d.nodeSize,f);d.marks.find(m=>m.type===a)?d.marks.forEach(m=>{a===m.type&&n.addMark(h,g,a.create({...m.attrs,...t}))}):n.addMark(h,g,a.create(t))})});return Ek(r,n,a)},Ak=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Tk=(e,t={})=>({state:n,dispatch:r,chain:o})=>{let i=_e(e,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Fl(i,{...s,...t})(n)?!0:l.clearNodes()).command(({state:l})=>Fl(i,{...s,...t})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Nk=e=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,o=Jn(e,0,r.content.size),i=_.create(r,o);t.setSelection(i)}return!0},Rk=(e,t)=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=r,s,l;return typeof t=="number"?(s=t,l=t):t&&"from"in t&&"to"in t?(s=t.from,l=t.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:e})}),!0},Dk=e=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,{from:o,to:i}=typeof e=="number"?{from:e,to:e}:e,s=P.atStart(r).from,l=P.atEnd(r).to,a=Jn(o,s,l),c=Jn(i,s,l),u=P.create(r,a,c);t.setSelection(u)}return!0},Ok=e=>({state:t,dispatch:n})=>{let r=_e(e,t.schema);return bf(r)(t,n)};function jp(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(o=>t?.includes(o.type.name));e.tr.ensureMarks(r)}}var Lk=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:o})=>{let{selection:i,doc:s}=t,{$from:l,$to:a}=i,c=o.extensionManager.attributes,u=Ni(c,l.node().type.name,l.node().attrs);if(i instanceof _&&i.node.isBlock)return!l.parentOffset||!ht(s,l.pos)?!1:(r&&(e&&jp(n,o.extensionManager.splittableMarks),t.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let f=a.parentOffset===a.parent.content.size,d=l.depth===0?void 0:th(l.node(-1).contentMatchAt(l.indexAfter(-1))),p=f&&d?[{type:d,attrs:u}]:void 0,h=i instanceof P&&!i.empty?no.create({doc:t.doc,selection:i}).tr.deleteSelection():null,g=h?h.doc:t.doc,m=h?h.mapping.map(l.pos):l.pos,w=ht(g,m,1,p);if(!p&&!w&&ht(g,m,1,d?[{type:d}]:void 0)&&(w=!0,p=d?[{type:d,attrs:u}]:void 0),r){if(w){let k=t.steps.length;if(i instanceof P&&t.deleteSelection(),t.split(t.mapping.slice(k).map(l.pos),1,p),d&&!f&&!l.parentOffset&&l.parent.type!==d){let x=t.mapping.slice(k).map(l.before()),E=t.doc.resolve(x);l.node(-1).canReplaceWith(E.index(),E.index()+1,d)&&t.setNodeMarkup(t.mapping.slice(k).map(l.before()),d)}}e&&jp(n,o.extensionManager.splittableMarks),t.scrollIntoView()}return w},Pk=(e,t={})=>({tr:n,state:r,dispatch:o,editor:i})=>{let s=_e(e,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let u=l.node(-1);if(u.type!==s)return!1;let f=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==s||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){var d;let E=F.empty,M=l.index(-1)?1:l.index(-2)?2:3;for(let fe=l.depth-M;fe>=l.depth-3;fe-=1)E=F.from(l.node(fe).copy(E));let A=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,S={...Ni(f,l.node().type.name,l.node().attrs),...t},L=((d=s.contentMatch.defaultType)===null||d===void 0?void 0:d.createAndFill(S))||void 0;E=E.append(F.from(s.createAndFill(null,L)||void 0));let X=l.before(l.depth-(M-1));n.replace(X,l.after(-A),new ue(E,4-M,0));let G=-1;n.doc.nodesBetween(X,n.doc.content.size,(fe,Be)=>{if(G>-1)return!1;fe.isTextblock&&fe.content.size===0&&(G=Be+1)}),G>-1&&n.setSelection(P.near(n.doc.resolve(G))),n.scrollIntoView()}return!0}let p=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,h={...Ni(f,u.type.name,u.attrs),...t},g={...Ni(f,l.node().type.name,l.node().attrs),...t},m=l.parentOffset===0&&l.index(-1)===0,w=l.before(-1);n.delete(l.pos,a.pos);let k=m?u.attrs:h,x=p?[{type:s,attrs:k},{type:p,attrs:g}]:[{type:s,attrs:k}];if(!ht(n.doc,l.pos,2))return!1;if(o){let{selection:E,storedMarks:M}=r,{splittableMarks:A}=i.extensionManager,S=M||E.$to.parentOffset&&E.$from.marks();if(n.split(l.pos,2,x).scrollIntoView(),m&&n.setNodeMarkup(w,void 0,h),!S||!o)return!0;let L=S.filter(X=>A.includes(X.type.name));n.ensureMarks(L)}return!0};function Fp(e){return!e||e==="1"?null:e}function gh(e,t){return Fp(e)===Fp(t)}var Ra=(e,t)=>{let n=Pi(i=>i.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let o=e.doc.nodeAt(r);return!(n.node.type===o?.type&&xt(e.doc,n.pos))||!gh(n.node.attrs.type,o?.attrs.type)||e.join(n.pos),!0},Da=(e,t)=>{let n=Pi(i=>i.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let o=e.doc.nodeAt(r);return!(n.node.type===o?.type&&xt(e.doc,r))||!gh(n.node.attrs.type,o?.attrs.type)||e.join(r),!0};function Ik(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),o=t.resolve(n.nodeSize-1);return P.between(r,o)}var $k=(e,t,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:f,splittableMarks:d}=o.extensionManager,p=_e(e,s.schema),h=_e(t,s.schema),{selection:g,storedMarks:m}=s,{$from:w,$to:k}=g,x=w.blockRange(k),E=m||g.$to.parentOffset&&g.$from.marks();if(!x)return!1;let M=Pi(ye=>Na(ye.type.name,f))(g),A=g.from===0&&g.to===s.doc.content.size,S=s.doc.content.content,L=S.length===1?S[0]:null,X=A&&L&&Na(L.type.name,f)?{node:L,pos:0,depth:0}:null,G=M??X,fe=!!M&&x.depth>=1&&x.depth-M.depth<=1,Be=!!X;if((fe||Be)&&G){if(G.node.type===p)return A&&Be?a().command(({tr:ye,dispatch:De})=>{let Oe=Ik(ye);return Oe?(ye.setSelection(Oe),De&&De(ye),!0):!1}).liftListItem(h).run():c.liftListItem(h);if(Na(G.node.type.name,f)&&p.validContent(G.node.content))return a().command(()=>(i.setNodeMarkup(G.pos,p),!0)).command(()=>Ra(i,p)).command(()=>Da(i,p)).run()}return!n||!E||!l?a().command(()=>u().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>Ra(i,p)).command(()=>Da(i,p)).run():a().command(()=>{let ye=u().wrapInList(p,r),De=E.filter(Oe=>d.includes(Oe.type.name));return i.ensureMarks(De),ye?!0:c.clearNodes()}).wrapInList(p,r).command(()=>Ra(i,p)).command(()=>Da(i,p)).run()},Bk=(e,t={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=en(e,r.schema);return Ia(r,s,t)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,t)},zk=(e,t,n={})=>({state:r,commands:o})=>{let i=_e(e,r.schema),s=_e(t,r.schema),l=$t(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},Hk=(e,t={})=>({state:n,commands:r})=>{let o=_e(e,n.schema);return $t(n,o,t)?r.lift(o):r.wrapIn(o,t)},_k=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let o=n[r],i;if(o.spec.isInputRules&&(i=o.getState(e))){if(t){let s=e.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,e.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},Vk=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:o=!1}=e,{selection:i}=t,{empty:s,ranges:l}=i;if(s)return!0;let{nonClearableMarks:a}=r.extensionManager;if(n){let c=Object.values(r.schema.marks).filter(u=>o||!a.includes(u.name));l.forEach(u=>{for(let f of c)t.removeMark(u.$from.pos,u.$to.pos,f)})}return!0},jk=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let{extendEmptyMarkRange:i=!1}=t,{selection:s}=n,l=en(e,r.schema),{$from:a,empty:c,ranges:u}=s;if(!o)return!0;if(c&&i){var f;let{from:d,to:p}=s,h=Ba(a,l,(f=a.marks().find(g=>g.type===l))===null||f===void 0?void 0:f.attrs);h&&(d=h.from,p=h.to),n.removeMark(d,p,l)}else u.forEach(d=>{n.removeMark(d.$from.pos,d.$to.pos,l)});return n.removeStoredMark(l),!0},Fk=e=>({tr:t,state:n,dispatch:r})=>{let{selection:o}=n,i,s;return typeof e=="number"?(i=e,s=e):e&&"from"in e&&"to"in e?(i=e.from,s=e.to):(i=o.from,s=o.to),r&&t.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,t.setNodeMarkup(a,void 0,c)}),!0},Wk=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=Li(typeof e=="string"?e:e.name,r.schema);if(!l)return!1;l==="node"&&(i=_e(e,r.schema)),l==="mark"&&(s=en(e,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{let u=c.$from.pos,f=c.$to.pos,d,p,h,g;n.selection.empty?r.doc.nodesBetween(u,f,(m,w)=>{i&&i===m.type&&(a=!0,h=Math.max(w,u),g=Math.min(w+m.nodeSize,f),d=w,p=m)}):r.doc.nodesBetween(u,f,(m,w)=>{w<u&&i&&i===m.type&&(a=!0,h=Math.max(w,u),g=Math.min(w+m.nodeSize,f),d=w,p=m),w>=u&&w<=f&&(i&&i===m.type&&(a=!0,o&&n.setNodeMarkup(w,void 0,{...m.attrs,...t})),s&&m.marks.length&&m.marks.forEach(k=>{if(s===k.type&&(a=!0,o)){let x=Math.max(w,u),E=Math.min(w+m.nodeSize,f);n.addMark(x,E,s.create({...k.attrs,...t}))}}))}),p&&(d!==void 0&&o&&n.setNodeMarkup(d,void 0,{...p.attrs,...t}),s&&p.marks.length&&p.marks.forEach(m=>{s===m.type&&o&&n.addMark(h,g,s.create({...m.attrs,...t}))}))}),a},Rr=new oe("__tiptap_decorations__"),Kk=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(Rr,{type:"force",name:e}),!0),Uk=(e,t={})=>({state:n,dispatch:r})=>{let o=_e(e,n.schema);return hf(o,t)(n,r)},qk=(e,t={})=>({state:n,dispatch:r})=>{let o=_e(e,n.schema);return mf(o,t)(n,r)},Gk=Zd({blur:()=>vw,clearContent:()=>Cw,clearNodes:()=>xw,command:()=>Sw,createParagraphNear:()=>Ew,cut:()=>Mw,deleteCurrentNode:()=>Aw,deleteNode:()=>Tw,deleteRange:()=>Nw,deleteSelection:()=>Ow,enter:()=>Lw,exitCode:()=>Pw,extendMarkRange:()=>Iw,first:()=>$w,focus:()=>zw,forEach:()=>Hw,insertContent:()=>_w,insertContentAt:()=>Vw,insertDefaultBlock:()=>jw,joinBackward:()=>Kw,joinDown:()=>Ww,joinForward:()=>Uw,joinItemBackward:()=>qw,joinItemForward:()=>Gw,joinTextblockBackward:()=>Jw,joinTextblockForward:()=>Xw,joinUp:()=>Fw,keyboardShortcut:()=>Qw,lift:()=>Zw,liftEmptyBlock:()=>ek,liftListItem:()=>tk,newlineInCode:()=>nk,resetAttributes:()=>rk,scrollIntoView:()=>ok,selectAll:()=>ik,selectNodeBackward:()=>sk,selectNodeForward:()=>lk,selectParentNode:()=>ak,selectTextblockEnd:()=>ck,selectTextblockStart:()=>uk,setContent:()=>dk,setMark:()=>Mk,setMeta:()=>Ak,setNode:()=>Tk,setNodeSelection:()=>Nk,setTextDirection:()=>Rk,setTextSelection:()=>Dk,sinkListItem:()=>Ok,splitBlock:()=>Lk,splitListItem:()=>Pk,toggleList:()=>$k,toggleMark:()=>Bk,toggleNode:()=>zk,toggleWrap:()=>Hk,undoInputRule:()=>_k,unsetAllMarks:()=>Vk,unsetMark:()=>jk,unsetTextDirection:()=>Fk,updateAttributes:()=>Wk,updateDecorations:()=>Kk,wrapIn:()=>Uk,wrapInList:()=>qk}),Dr=new WeakMap;function Jk(e,t){var n;Dr.set(e,((n=Dr.get(e))!==null&&n!==void 0?n:0)+1);try{return t()}finally{var r;let o=((r=Dr.get(e))!==null&&r!==void 0?r:1)-1;o>0?Dr.set(e,o):Dr.delete(e)}}function Xk(e){return Dr.has(e)}var Yk=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(r=>r.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(r=>r!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},bh=typeof process<"u"&&!1;function Qk(e){return e.kind==="widget"}function yh(e,t){let n=[],r=new Set;for(let o of e)o.kind==="widget"&&Qk(o)&&r.add(o.key),n.push(o.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function Zk(e,t,n){let{decorations:r,widgetKeys:o}=yh(t,n);return{set:de.create(e,r),widgetKeys:o}}function wh({position:e,from:t,to:n,docSize:r}){return e<t?!1:e<n?!0:e===n&&n===r}function ev({decorations:e,from:t,to:n,docSize:r,extensionName:o,warnedExtensions:i}){return e.filter(s=>wh({position:s.anchor,from:t,to:n,docSize:r})?!0:(s.anchor===n||i.has(o)||(i.add(o),console.warn(`[tiptap warn]: Extension "${o}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function kh(e){var t;let n=(t=e.spec)===null||t===void 0?void 0:t.key;return typeof n=="string"?n:void 0}function tv(e){let t=new Map,n=new Map;for(let s of e.find()){var r,o,i;let l=kh(s);if(!l)continue;let a=(r=s.spec.extensionName)!==null&&r!==void 0?r:"unknown",c=(o=t.get(l))!==null&&o!==void 0?o:new Set;c.add(a),t.set(l,c),n.set(l,((i=n.get(l))!==null&&i!==void 0?i:0)+1)}return Array.from(t,([s,l])=>({key:s,extensions:l})).filter(({key:s})=>{var l;return((l=n.get(s))!==null&&l!==void 0?l:0)>1})}function vh(e){return e.jsonID==="attr"}function nv(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||vh(e))return!0;let n=e;return typeof n.from=="number"&&typeof n.to=="number"}function rv(e,t){let n=null,r=0,o=0;for(let i=0;i<e.childCount&&!(o>t.to);i+=1){let s=o+e.child(i).nodeSize;s>=t.from&&(n===null&&(n=o),r=s),o=s}return n===null?null:{from:n,to:r}}function ov(e,t){if(e.steps.some(i=>!nv(i)))return{type:"full"};let n=$r(e).map(({newRange:i})=>i);e.steps.forEach((i,s)=>{if(!vh(i))return;let l=e.mapping.slice(s);n.push({from:l.map(i.pos,-1),to:l.map(i.pos+1)})});let r=[];for(let i of n){let s=rv(t,i);s&&r.push(s)}r.sort((i,s)=>i.from-s.from);let o=[];for(let i of r){let s=o[o.length-1];s&&i.from<=s.to?s.to=Math.max(s.to,i.to):o.push({...i})}return{type:"ranges",ranges:o}}function Ch(e,t,n,r){return e.map(t,n,{onRemove:o=>{let i=o?.key;typeof i=="string"&&r.delete(i)}})}function iv(e,t,n){var r,o;let i=(r=t.decorationSetsByExtension[e])!==null&&r!==void 0?r:de.empty,s=new Set((o=t.widgetKeysByExtension[e])!==null&&o!==void 0?o:[]);return{set:Ch(i,n.mapping,n.doc,s),widgetKeys:s}}function Wp(e,t){let n=Object.values(t).flatMap(r=>r.find());return de.create(e,n)}function Kp(e){let t=new Set;for(let n of Object.values(e))for(let r of n)t.add(r);return t}function sv(e,t){var n;switch((n=t.update)!==null&&n!==void 0?n:"document"){case"document":if(t.createInRange)throw new Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!t.createInRange)throw new Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(t.createInRange)throw new Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw new Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function lv(e,t,n){return n?!0:e.update==="manual"?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var av=new Set;var cv=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:t})=>{let n=Rr.getState(t);n&&this.warnDuplicateWidgetKeys(n)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:t,spec:n})=>sv(t,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var e,t;return(e=(t=Rr.getState(this.editor.state))===null||t===void 0?void 0:t.widgetKeys)!==null&&e!==void 0?e:av}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let o=r();o&&t.push({name:n,spec:o})}return t}createPlugin(){let{editor:e,entries:t}=this;return new U({key:Rr,state:{init:(n,r)=>{let o={},i={};for(let{name:l,spec:a}of t){let{set:c,widgetKeys:u}=this.buildFullSet(l,a,r);o[l]=c,i[l]=u}let s={decorationSetsByExtension:o,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(r.doc,o),widgetKeys:Kp(i)};return this.warnDuplicateWidgetKeys(s),s},apply:(n,r,o,i)=>{let s=n.getMeta(Rr),l=s?.type==="force"&&!s.name,a=s?.type==="force"?s.name:void 0,c={},u={},f=new Set;return Jk(e,()=>{for(let{name:d,spec:p}of t){let h=l||a===d;if(lv(p,{editor:e,tr:n,oldState:o,newState:i},h))if(p.update==="changedRanges"&&n.docChanged&&!h){let g=this.applyChangedRangesRecompute(d,p,r,n,i);c[d]=g.set,u[d]=g.widgetKeys,f.add(d)}else{let{set:g,widgetKeys:m}=this.buildFullSet(d,p,i);c[d]=g,u[d]=m,f.add(d)}else{let g=iv(d,r,n);c[d]=g.set,u[d]=g.widgetKeys}}}),f.size===0&&!n.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:f}),widgetKeys:Kp(u)}}},props:{decorations(n){var r,o;return(r=(o=Rr.getState(n))===null||o===void 0?void 0:o.mergedDecorationSet)!==null&&r!==void 0?r:de.empty}}})}applyChangedRangesRecompute(e,t,n,r,o){let i=ov(r,o.doc);return i.type==="full"?this.buildFullSet(e,t,o):this.rebuildRanges(e,t,n,r,o,i.ranges)}rebuildRanges(e,t,n,r,o,i){var s,l;let a=(s=n.decorationSetsByExtension[e])!==null&&s!==void 0?s:de.empty,c=new Set((l=n.widgetKeysByExtension[e])!==null&&l!==void 0?l:[]),u=Ch(a,r.mapping,r.doc,c),f=o.doc.content.size;for(let{from:d,to:p}of i){let h=u.find(d,p).filter(w=>wh({position:w.from,from:d,to:p,docSize:f}));for(let w of h){let k=kh(w);k&&c.delete(k)}u=u.remove(h);let{decorations:g,widgetKeys:m}=yh(ev({decorations:this.runCreate(e,"createInRange",()=>t.createInRange({editor:this.editor,state:o,view:this.mountedView,from:d,to:p})),from:d,to:p,docSize:f,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);u=u.add(o.doc,g);for(let w of m)c.add(w)}return{set:u,widgetKeys:c}}buildFullSet(e,t,n){let r=this.runCreate(e,"create",()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return Zk(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(e){if(!bh)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=tv(e.mergedDecorationSet),n=new Set(t.map(({key:r})=>r));for(let{key:r,extensions:o}of t){if(this.warnedWidgetKeys.has(r))continue;let i=Array.from(o).map(s=>`"${s}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${o.size===1?"":"s"} ${i}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:Wp(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:o}){return e.length===1?r[e[0].name]:o.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):Wp(n.doc,r)}};function xh(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof _){let i=r.index();return r.parent.canReplaceWith(i,i+1,t)}let o=r.depth;for(;o>=0;){let i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(t))return!0;o-=1}return!1}function uv(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return t&&o.setAttribute("nonce",t),o.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),o.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(o),o}function Sh(e,t){let n=e.getAttribute("style");if(!n)return null;let r=n.split(";").map(i=>i.trim()).filter(Boolean),o=t.toLowerCase();for(let i=r.length-1;i>=0;i-=1){let s=r[i],l=s.indexOf(":");if(l!==-1&&s.slice(0,l).trim().toLowerCase()===o)return s.slice(l+1).trim()}return null}function dv(e){return typeof e=="number"}function fv(e){return Object.prototype.toString.call(e).slice(8,-1)}function Ai(e){return fv(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function zr(e){return typeof e=="string"&&e.trim().length>0&&!/[;{}]/.test(e)}function ja(e,t,n){let r=e.split(`
|
|
11
|
+
`),o=[],i="",s=0,l=t.baseIndentSize||2;for(;s<r.length;){let u=r[s],f=u.match(t.itemPattern);if(!f){if(o.length>0)break;if(u.trim()===""){s+=1,i=`${i}${u}
|
|
12
|
+
`;continue}else return}let d=t.extractItemData(f),{indentLevel:p,mainContent:h}=d;i=`${i}${u}
|
|
13
|
+
`;let g=[h];for(s+=1;s<r.length;){var a;let x=r[s];if(x.trim()===""){var c;let E=r.slice(s+1).findIndex(M=>M.trim()!=="");if(E===-1)break;if((((c=r[s+1+E].match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>p){g.push(x),i=`${i}${x}
|
|
14
|
+
`,s+=1;continue}else break}if((((a=x.match(/^(\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>p)g.push(x),i=`${i}${x}
|
|
15
|
+
`,s+=1;else break}let m,w=g.slice(1);if(w.length>0){let x=w.map(E=>E.slice(p+l)).join(`
|
|
16
|
+
`);x.trim()&&(t.customNestedParser?m=t.customNestedParser(x):m=n.blockTokens(x))}let k=t.createToken(d,m);o.push(k)}if(o.length!==0)return{items:o,raw:i}}var Up=4;function qp(e){let t=0;for(let n of e)t=n===" "?t+Up-t%Up:t+1;return t}function Fa(e,t,n,r,o){if(!e||!Array.isArray(e.content))return"";let i=typeof n=="function"?n(r):n,[s,...l]=e.content,a=`${i}${t.renderChildren([s])}`;return l&&l.length>0&&l.forEach((c,u)=>{var f,d;let p=(f=(d=t.renderChild)===null||d===void 0?void 0:d.call(t,c,u+1))!==null&&f!==void 0?f:t.renderChildren([c]);if(p!=null){let h=m=>{if(!o?.alignNestedToPrefix)return t.indent(m);let w=t.indent(""),k=qp(i);return(qp(w)>=k?w:" ".repeat(k))+m},g=p.split(`
|
|
17
|
+
`).map(m=>h(m||"")).join(`
|
|
18
|
+
`);a+=c.type==="paragraph"?`
|
|
19
|
+
|
|
20
|
+
${g}`:`
|
|
21
|
+
${g}`}}),a}function Eh(e,t){let n={...e};return Ai(e)&&Ai(t)&&Object.keys(t).forEach(r=>{Ai(t[r])&&Ai(e[r])?n[r]=Eh(e[r],t[r]):n[r]=t[r]}),n}function pv(e,t,n={}){let{state:r}=t,{doc:o,tr:i}=r,s=e;o.descendants((l,a)=>{let c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize,f=null;if(l.marks.forEach(p=>{if(p!==s)return!1;f=p}),!f)return;let d=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(d=!0)}),d){let p=e.type.create({...e.attrs,...n});i.removeMark(c,u,e.type),i.addMark(c,u,p)}}),i.docChanged&&t.view.dispatch(i)}var Hr=class{constructor(e){var t;this.find=e.find,this.handler=e.handler,this.undoable=(t=e.undoable)!==null&&t!==void 0?t:!0}},hv=(e,t)=>{if($a(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,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 mv(e){let{editor:t,from:n,to:r,text:o,insertText:i}=e;if(!i)return{inputTransaction:null,tr:t.view.state.tr};let s=t.view.state.tr.insertText(o,n,r);return{inputTransaction:s,tr:no.create({doc:s.doc,selection:s.selection,storedMarks:s.storedMarks}).tr}}function gv(e){let{editor:t,from:n,to:r,text:o,rule:i,match:s,plugin:l,insertText:a}=e,{view:c}=t,{inputTransaction:u,tr:f}=mv({editor:t,from:n,to:r,text:o,insertText:a}),d=u?n+o.length:r,p=Di({state:c.state,transaction:f}),h={from:n-(s[0].length-o.length),to:d},{commands:g,chain:m,can:w}=new Or({editor:t,state:p});return i.handler({state:p,range:h,match:s,commands:g,chain:m,can:w})===null||!f.steps.length?!1:(u&&(c.dispatch(u),!c.state.doc.eq(u.doc))||(Ar(f),f.setMeta("inputRule",!0),i.undoable&&f.setMeta(l,{transform:f,from:n,to:d,text:o}),c.dispatch(f)),!0)}function bv(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let o=e.parentOffset-r;return o>=0&&e.parent.textBetween(o,e.parentOffset)===t[0].slice(0,r)}function Ti(e){var t;let{editor:n,from:r,to:o,text:i,rules:s,plugin:l,insertText:a}=e,{view:c}=n;if(c.composing)return!1;let u=c.state.doc.resolve(r);if(u.parent.type.spec.code||!((t=u.nodeBefore||u.nodeAfter)===null||t===void 0)&&t.marks.find(d=>d.type.spec.code))return!1;let f=vk(u)+i;for(let d of s){let p=hv(f,d.find);if(!(!p||!bv(u,p,i))&&gv({editor:n,from:r,to:o,text:i,rule:d,match:p,plugin:l,insertText:a}))return!0}return!1}function yv(e){let{editor:t,rules:n}=e,r=new U({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:c}=a;typeof c=="string"?c=c:c=_a(F.from(c),s.schema);let{from:u}=a,f=u+c.length;Ti({editor:t,from:u,to:f,text:c,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return Ti({editor:t,from:i,to:s,text:l,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&Ti({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;let{$cursor:s}=o.state.selection;return s?Ti({editor:t,from:s.pos,to:s.pos,text:`
|
|
22
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Wa=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...pe(H(this,"addOptions",{name:this.name}))}}get storage(){return{...pe(H(this,"addStorage",{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>Eh(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}},We=class Mh extends Wa{constructor(...t){super(...t),this.type="mark"}static create(t={}){let n=typeof t=="function"?t():t;return new Mh(n)}static handleExit({editor:t,mark:n}){let{tr:r}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){let i=o.marks();if(!i.find(l=>l?.type.name===n.name))return!1;let s=i.find(l=>l?.type.name===n.name);return s&&r.removeStoredMark(s),r.insertText(" ",o.pos),t.view.dispatch(r),!0}return!1}configure(t){return super.configure(t)}extend(t){let n=typeof t=="function"?t():t;return super.extend(n)}},Ka=class{constructor(e){this.find=e.find,this.handler=e.handler}},wv=(e,t,n)=>{if($a(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=e,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function kv(e){let{editor:t,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=e,{commands:a,chain:c,can:u}=new Or({editor:t,state:n}),f=[];return n.doc.nodesBetween(r,o,(d,p)=>{var h,g,m,w;if(!((h=d.type)===null||h===void 0||(h=h.spec)===null||h===void 0)&&h.code||!(d.isText||d.isTextblock||d.isInline))return;let k=(g=(m=(w=d.content)===null||w===void 0?void 0:w.size)!==null&&m!==void 0?m:d.nodeSize)!==null&&g!==void 0?g:0,x=Math.max(r,p),E=Math.min(o,p+k);if(x>=E)return;let M=d.isText?d.text||"":d.textBetween(x-p,E-p,void 0,"\uFFFC");wv(M,i.find,s).forEach(A=>{if(A.index===void 0)return;let S=x+A.index+1,L=S+A[0].length,X={from:n.tr.mapping.map(S),to:n.tr.mapping.map(L)},G=i.handler({state:n,range:X,match:A,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});f.push(G)})}),f.every(d=>d!==null)}var Nr=null,vv=e=>{var t;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=n.clipboardData)===null||t===void 0||t.setData("text/html",e),n};function Cv(e){let{editor:t,rules:n}=e,r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:c,from:u,to:f,rule:d,pasteEvt:p})=>{let h=c.tr,g=Di({state:c,transaction:h});if(!(!kv({editor:t,state:g,from:Math.max(u-1,0),to:f.b-1,rule:d,pasteEvent:p,dropEvent:l})||!h.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,h}};return t.on("destroy",()=>{Nr===t&&(Nr=null)}),n.map(c=>new U({view(u){let f=p=>{var h;r=!((h=u.dom.parentElement)===null||h===void 0)&&h.contains(p.target)?u.dom.parentElement:null,r&&(Nr=t)},d=()=>{Nr&&(Nr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",d),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",d)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(i=r===u.dom.parentElement,l=f,!i){let d=Nr;d?.isEditable&&setTimeout(()=>{if(d.isDestroyed)return;let p=d.state.selection;p&&d.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var d;let p=(d=f.clipboardData)===null||d===void 0?void 0:d.getData("text/html");return s=f,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,f,d)=>{let p=u[0],h=p.getMeta("uiEvent")==="paste"&&!o,g=p.getMeta("uiEvent")==="drop"&&!i,m=p.getMeta("applyPasteRules"),w=!!m;if(!h&&!g&&!w)return;if(w){let{text:E}=m;typeof E=="string"?E=E:E=_a(F.from(E),d.schema);let{from:M}=m,A=M+E.length,S=vv(E);return a({rule:c,state:d,from:M,to:{b:A},pasteEvt:S})}let k=f.doc.content.findDiffStart(d.doc.content),x=f.doc.content.findDiffEnd(d.doc.content);if(!(!dv(k)||!x||k===x.b))return a({rule:c,state:d,from:k,to:x,pasteEvt:s})}}))}var $i=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=lh(e),this.schema=mk(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=H(t,"addCommands",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Tr(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=wo([...this.extensions].reverse()).flatMap(r=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Tr(r.name,this.schema)},i=[],s=H(r,"addKeyboardShortcuts",o),l={};if(r.type==="mark"&&H(r,"exitable",o)&&(l.ArrowRight=()=>We.handleExit({editor:e,mark:r})),s){let d=Object.fromEntries(Object.entries(s()).map(([p,h])=>[p,()=>h({editor:e})]));l={...l,...d}}let a=Ap(l);i.push(a);let c=H(r,"addInputRules",o);if(Vp(r,e.options.enableInputRules)&&c){let d=c();if(d&&d.length){let p=yv({editor:e,rules:d}),h=Array.isArray(p)?p:[p];i.push(...h)}}let u=H(r,"addPasteRules",o);if(Vp(r,e.options.enablePasteRules)&&u){let d=u();if(d&&d.length){let p=Cv({editor:e,rules:d});i.push(...p)}}let f=H(r,"addProseMirrorPlugins",o);if(f){let d=f();i.push(...d)}return i}),n=this.createDecorationPlugin();return n&&t.push(n),t}createDecorationPlugin(){var e;let{editor:t}=this;(e=this.decorationManager)===null||e===void 0||e.destroy();let n=[];return this.extensions.forEach(r=>{let o=H(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Tr(r.name,this.schema)});o&&n.push({name:r.name,addDecorations:o})}),this.decorationManager=new cv({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){return sh(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=Pr(this.extensions);return Object.fromEntries(t.filter(n=>!!H(n,"addNodeView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o=H(n,"addNodeView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:_e(n.name,this.schema)});if(!o)return[];let i=o();if(!i)return[];let s=(l,a,c,u,f)=>{let d=Bt(l,r);return i({node:l,view:a,getPos:c,decorations:u,innerDecorations:f,editor:e,extension:n,HTMLAttributes:d})};return[n.name,s]}))}dispatchTransaction(e){let{editor:t}=this;return wo([...this.extensions].reverse()).reduceRight((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Tr(r.name,this.schema)},i=H(r,"dispatchTransaction",o);return i?s=>{i.call(o,{transaction:s,next:n})}:n},e)}transformPastedHTML(e){let{editor:t}=this;return wo([...this.extensions]).reduce((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Tr(r.name,this.schema)},i=H(r,"transformPastedHTML",o);return i?(s,l)=>{let a=n(s,l);return i.call(o,a)}:n},e||(n=>n))}get markViews(){let{editor:e}=this,{markExtensions:t}=Pr(this.extensions);return Object.fromEntries(t.filter(n=>!!H(n,"addMarkView")).map(n=>{let r=this.attributes.filter(s=>s.type===n.name),o=H(n,"addMarkView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:en(n.name,this.schema)});if(!o)return[];let i=(s,l,a)=>{let c=Bt(s,r);return o()({mark:s,view:l,inline:a,editor:e,extension:n,HTMLAttributes:c,updateAttributes:u=>{pv(s,e,u)}})};return[n.name,i]}))}destroy(){var e;(e=this.decorationManager)===null||e===void 0||e.destroy(),this.extensions.forEach(t=>{let n=t;for(;n.parent;){let r=n.parent;r.child===n&&(r.child=null),n=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(t=>[t.name,t.storage])),e.forEach(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Tr(t.name,this.schema)};if(t.type==="mark"){var r,o;(!((r=pe(H(t,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(t.name),!((o=pe(H(t,"clearable",n)))!==null&&o!==void 0)||o||this.nonClearableMarks.push(t.name)}let i=H(t,"onBeforeCreate",n),s=H(t,"onCreate",n),l=H(t,"onUpdate",n),a=H(t,"onSelectionUpdate",n),c=H(t,"onTransaction",n),u=H(t,"onFocus",n),f=H(t,"onBlur",n),d=H(t,"onDestroy",n);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),f&&this.editor.on("blur",f),d&&this.editor.on("destroy",d)})}};$i.resolve=lh;$i.sort=wo;$i.flatten=Ha;var le=class Ah extends Wa{constructor(...t){super(...t),this.type="extension"}static create(t={}){let n=typeof t=="function"?t():t;return new Ah(n)}configure(t){return super.configure(t)}extend(t){let n=typeof t=="function"?t():t;return super.extend(n)}},xv=le.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new U({key:new oe("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:o}=t,i=ch(n),{blockSeparator:s}=this.options,l={...s!==void 0?{blockSeparator:s}:{},textSerializers:i};return[...o.ranges].sort((a,c)=>a.$from.pos-c.$from.pos).map(({$from:a,$to:c})=>ah(r,{from:a.pos,to:c.pos},l)).join(s??`
|
|
23
|
+
|
|
24
|
+
`)}}})]}}),Sv=le.create({name:"commands",addCommands(){return{...Gk}}}),Ev=le.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r;let o=()=>{var i,s,l;if((i=(s=this.editor.options.coreExtensionOptions)===null||s===void 0||(s=s.delete)===null||s===void 0||(l=s.filterTransaction)===null||l===void 0?void 0:l.call(s,e))!==null&&i!==void 0?i:e.getMeta("y-sync$"))return;let a=za(e.before,[e,...t]);$r(a).forEach(u=>{a.mapping.mapResult(u.oldRange.from).deletedAfter&&a.mapping.mapResult(u.oldRange.to).deletedBefore&&a.before.nodesBetween(u.oldRange.from,u.oldRange.to,(f,d)=>{let p=d+f.nodeSize-2,h=u.oldRange.from<=d&&p<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:f,from:d,to:p,newFrom:a.mapping.map(d),newTo:a.mapping.map(p),deletedRange:u.oldRange,newRange:u.newRange,partial:!h,editor:this.editor,transaction:e,combinedTransform:a})})});let c=a.mapping;a.steps.forEach((u,f)=>{if(u instanceof bd){var d,p;let h=c.slice(f).map(u.from,-1),g=c.slice(f).map(u.to),m=c.invert().map(h,-1),w=c.invert().map(g),k=h>0?(d=a.doc.nodeAt(h-1))===null||d===void 0?void 0:d.marks.some(E=>E.eq(u.mark)):!1,x=(p=a.doc.nodeAt(g))===null||p===void 0?void 0:p.marks.some(E=>E.eq(u.mark));this.editor.emit("delete",{type:"mark",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:m,to:w},newRange:{from:h,to:g},partial:!!(x||k),editor:this.editor,transaction:e,combinedTransform:a})}})};!((n=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&n!==void 0)||n?setTimeout(o,0):o()}}),Mv=le.create({name:"drop",addProseMirrorPlugins(){return[new U({key:new oe("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Av=le.create({name:"editable",addProseMirrorPlugins(){return[new U({key:new oe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Tv=new oe("focusEvents"),Nv=le.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return[new U({key:Tv,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),Rv=le.create({name:"keymap",addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:u,$anchor:f}=a,{pos:d,parent:p}=f,h=f.parent.isTextblock&&d>0?l.doc.resolve(d-1):f,g=h.parent.type.spec.isolating,m=f.pos-f.parentOffset,w=g&&h.parent.childCount===1?m===f.pos:Q.atStart(c).from===d;return!u||!p.type.isTextblock||p.textContent.length||!w||w&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Xn()||rh()?i:o},addProseMirrorPlugins(){return[new U({key:new oe("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(p=>p.getMeta("composition")))return;let r=e.some(p=>p.docChanged)&&!t.doc.eq(n.doc),o=e.some(p=>p.getMeta("preventClearDocument"));if(!r||o)return;let{empty:i,from:s,to:l}=t.selection,a=Q.atStart(t.doc).from,c=Q.atEnd(t.doc).to;if(i||!(s===a&&l===c)||!Br(n.doc))return;let u=n.tr,f=Di({state:n,transaction:u}),{commands:d}=new Or({editor:this.editor,state:f});if(d.clearNodes(),!!u.steps.length)return u}})]}}),Dv=le.create({name:"paste",addProseMirrorPlugins(){return[new U({key:new oe("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),Ov=le.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new U({key:new oe("tabindex"),props:{attributes:()=>{var e;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(e=this.options.value)!==null&&e!==void 0?e:"0"}}}})]}}),Lv=le.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=Pr(this.extensions);return[{types:e.filter(t=>t.name!=="text").map(t=>t.name),attributes:{dir:{default:this.options.direction,parseHTML:t=>{let n=t.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:t=>t.dir?{dir:t.dir}:{}}}}]},addProseMirrorPlugins(){return[new U({key:new oe("textDirection"),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}});var Gp=!1;function Pv(e){if(Gp)return;Gp=!0;let t;try{t=Bn.fromJSON(e,{from:0,to:0}).slice.content}catch{return}t instanceof F||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var Iv=class yo{get name(){return this.node.type.name}constructor(t,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!==null&&t!==void 0?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t 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},t)}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;let t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new yo(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new yo(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new yo(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!o&&!s&&a.depth<=this.depth)return;let c=new yo(a,this.editor,o,o||s?n:null);o&&(c.actualDepth=this.depth+1),t.push(c)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let t=this.children;return t[t.length-1]||null}closest(t,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===t)if(Object.keys(n).length>0){let i=o.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){let a=s[l];if(i[a]!==n[a])break}}else r=o;o=o.parent}return r}querySelector(t,n={}){return this.querySelectorAll(t,n,!0)[0]||null}querySelectorAll(t,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;let i=Object.keys(n);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===t&&i.every(l=>n[l]===s.node.attrs[l])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(t,n,r))))}),o}setAttribute(t){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(n)}},$v=`.ProseMirror {
|
|
25
|
+
position: relative;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ProseMirror {
|
|
29
|
+
word-wrap: break-word;
|
|
30
|
+
white-space: pre-wrap;
|
|
31
|
+
white-space: break-spaces;
|
|
32
|
+
-webkit-font-variant-ligatures: none;
|
|
33
|
+
font-variant-ligatures: none;
|
|
34
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ProseMirror [contenteditable="false"] {
|
|
38
|
+
white-space: normal;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
42
|
+
white-space: pre-wrap;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ProseMirror pre {
|
|
46
|
+
white-space: pre-wrap;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
img.ProseMirror-separator {
|
|
50
|
+
display: inline !important;
|
|
51
|
+
border: none !important;
|
|
52
|
+
margin: 0 !important;
|
|
53
|
+
width: 0 !important;
|
|
54
|
+
height: 0 !important;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ProseMirror-gapcursor {
|
|
58
|
+
display: none;
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
position: absolute;
|
|
61
|
+
margin: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.ProseMirror-gapcursor:after {
|
|
65
|
+
content: "";
|
|
66
|
+
display: block;
|
|
67
|
+
position: absolute;
|
|
68
|
+
top: -2px;
|
|
69
|
+
width: 20px;
|
|
70
|
+
border-top: 1px solid black;
|
|
71
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@keyframes ProseMirror-cursor-blink {
|
|
75
|
+
to {
|
|
76
|
+
visibility: hidden;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.ProseMirror-hideselection *::selection {
|
|
81
|
+
background: transparent;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
85
|
+
background: transparent;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.ProseMirror-hideselection * {
|
|
89
|
+
caret-color: transparent;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
93
|
+
display: block;
|
|
94
|
+
}`,Ua=class extends Yk{constructor(e={}){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.hasWarnedStaleDecorationRead=!1,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:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:xk,createMappablePosition:Sk},this.setOptions(e),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:n,slice:r,moved:o})=>this.options.onDrop(n,r,o)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);let t=this.createDoc();if(!this.editorState){let n=Oa(t,this.options.autofocus);this.editorState=no.create({doc:t,schema:this.schema,selection:n||void 0})}Pv(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){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(e),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){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.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(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Or.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Or.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=uv($v,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&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:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t==="state")return this.editorState;if(t in e)return Reflect.get(e,t);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return bh&&!this.hasWarnedStaleDecorationRead&&Xk(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=Pa(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(o=>{let i=typeof o=="string"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[Av,xv.configure({blockSeparator:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.clipboardTextSerializer)===null||e===void 0?void 0:e.blockSeparator}),Sv,Nv,Rv,Ov.configure({value:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.tabindex)===null||t===void 0?void 0:t.value}),Mv,Dv,Ev,Lv.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new $i(n,this)}createCommandManager(){this.commandManager=new Or({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=La(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message))throw t;let n=La(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=no.create({doc:n,schema:this.schema,selection:Oa(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:t,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(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return e}getEditorViewAttributes(){var e;let t=(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes;return Pa(t)?n=>({role:"textbox",...t(n)}):{role:"textbox",...t}}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,i=t.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new po(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.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(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(c=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),o=n.includes(e),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!o)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s?.getMeta("focus"),a=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(e.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(t.doc))&&this.emit("update",{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return Va(this.state,e)}isActive(e,t){let n=typeof e=="string"?e:null,r=typeof e=="string"?t:e;return Ck(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return _a(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
|
|
95
|
+
|
|
96
|
+
`,textSerializers:n={}}=e||{};return bk(this.state.doc,{blockSeparator:t,textSerializers:{...ch(this.schema),...n}})}get isEmpty(){return Br(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 e,t;return(e=(t=this.editorView)===null||t===void 0?void 0:t.isDestroyed)!==null&&e!==void 0?e:!0}$node(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(e,t))||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new Iv(t,this,!1,n)}get $doc(){return this.$pos(0)}};function lt(e){return new Hr({find:e.find,handler:({state:t,range:n,match:r})=>{let o=pe(e.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=t,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=n.from+l.indexOf(s),u=c+s.length;if(vo(n.from,n.to,t.doc).filter(d=>d.mark.type.excluded.find(p=>p===e.type&&p!==d.mark.type)).filter(d=>d.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);let f=n.from+a+s.length;i.addMark(n.from+a,f,e.type.create(o||{})),i.removeStoredMark(e.type)}},undoable:e.undoable})}function Bi(e){return new Hr({find:e.find,handler:({state:t,range:n,match:r})=>{let o=pe(e.getAttributes,void 0,r)||{},{tr:i}=t,s=n.from,l=n.to,a=e.type.create(o);if(r[1]){let c=s+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,s+r[0].length-1),i.replaceWith(c,l,a)}else if(r[0]){let c=e.type.isInline?s:s-1;i.insert(c,e.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:e.undoable})}function Co(e){return new Hr({find:e.find,handler:({state:t,range:n,match:r})=>{let o=t.doc.resolve(n.from),i=pe(e.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,i)},undoable:e.undoable})}function vn(e){return new Hr({find:e.find,handler:({state:t,range:n,match:r,chain:o})=>{let i=pe(e.getAttributes,void 0,r)||{},s=t.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&br(l,e.type,i);if(!a)return null;if(s.wrap(l,a),e.keepMarks&&e.editor){let{selection:u,storedMarks:f}=t,{splittableMarks:d}=e.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){let h=p.filter(g=>d.includes(g.type.name));s.ensureMarks(h)}}if(e.keepAttributes){let u=e.type.name==="bulletList"||e.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(u,i).run()}let c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===e.type&&xt(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,c))&&s.join(n.from-1)},undoable:e.undoable})}var Bv=e=>"touches"in e,Th=class{constructor(e){var t,n,r,o,i,s;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,!((t=e.options)===null||t===void 0)&&t.min&&(this.minSize={...this.minSize,...e.options.min}),!((n=e.options)===null||n===void 0)&&n.max&&(this.maxSize=e.options.max),!(e==null||(r=e.options)===null||r===void 0)&&r.directions&&(this.directions=e.options.directions),!((o=e.options)===null||o===void 0)&&o.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),!((i=e.options)===null||i===void 0)&&i.className&&(this.classNames={container:e.options.className.container||"",wrapper:e.options.className.wrapper||"",handle:e.options.className.handle||"",resizing:e.options.className.resizing||""}),!((s=e.options)===null||s===void 0)&&s.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var e;return(e=this.contentElement)!==null&&e!==void 0?e:null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type!==this.node.type?!1:(this.node=e,this.onUpdate?this.onUpdate(e,t,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement("div");return e.dataset.resizeContainer="",e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement("div");return e.style.position="relative",e.style.display="block",e.dataset.resizeWrapper="",this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement("div");return t.dataset.resizeHandle=e,t.style.position="absolute",this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes("top"),r=t.includes("bottom"),o=t.includes("left"),i=t.includes("right");n&&(e.style.top="0"),r&&(e.style.bottom="0"),o&&(e.style.left="0"),i&&(e.style.right="0"),(t==="top"||t==="bottom")&&(e.style.left="0",e.style.right="0"),(t==="left"||t==="right")&&(e.style.top="0",e.style.bottom="0")}attachHandles(){this.directions.forEach(e=>{let t;this.createCustomHandle?t=this.createCustomHandle(e):t=this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener("mousedown",n=>this.handleResizeStart(n,e)),t.addEventListener("touchstart",n=>this.handleResizeStart(n,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,Bv(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,e,t),i=this.applyConstraints(r,o,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,o=this.startHeight,i=e.includes("right"),s=e.includes("left"),l=e.includes("bottom"),a=e.includes("top");return i?r=this.startWidth+t:s&&(r=this.startWidth-t),l?o=this.startHeight+n:a&&(o=this.startHeight-n),(e==="right"||e==="left")&&(r=this.startWidth+(i?t:-t)),(e==="top"||e==="bottom")&&(o=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,e):{width:r,height:o}}applyConstraints(e,t,n){var r,o;if(!n){var i,s;let c=Math.max(this.minSize.width,e),u=Math.max(this.minSize.height,t);return!((i=this.maxSize)===null||i===void 0)&&i.width&&(c=Math.min(this.maxSize.width,c)),!((s=this.maxSize)===null||s===void 0)&&s.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=e,a=t;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),!((r=this.maxSize)===null||r===void 0)&&r.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((o=this.maxSize)===null||o===void 0)&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(e,t,n){let r=n==="left"||n==="right",o=n==="top"||n==="bottom";return r?{width:e,height:e/this.aspectRatio}:o?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}};var ee=class Nh extends Wa{constructor(...t){super(...t),this.type="node"}static create(t={}){let n=typeof t=="function"?t():t;return new Nh(n)}configure(t){return super.configure(t)}extend(t){let n=typeof t=="function"?t():t;return super.extend(n)}},zi=class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=()=>{try{return t.getPos()}catch{return}},this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n;let{view:r}=this.editor,o=e.target,i=o.nodeType===3?(t=o.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):o.closest("[data-drag-handle]");if(!this.dom||!((n=this.contentDOM)===null||n===void 0)&&n.contains(o)||!i)return;let s=0,l=0;if(this.dom!==i){var a,c,u,f;let k=this.dom.getBoundingClientRect(),x=i.getBoundingClientRect(),E=(a=e.offsetX)!==null&&a!==void 0?a:(c=e.nativeEvent)===null||c===void 0?void 0:c.offsetX,M=(u=e.offsetY)!==null&&u!==void 0?u:(f=e.nativeEvent)===null||f===void 0?void 0:f.offsetY;s=x.x-k.x+E,l=x.y-k.y+M}let d=this.dom.cloneNode(!0);try{let k=this.dom.getBoundingClientRect();d.style.width=`${Math.round(k.width)}px`,d.style.height=`${Math.round(k.height)}px`,d.style.boxSizing="border-box",d.style.pointerEvents="none"}catch{}let p=null;try{var h;p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(d),document.body.appendChild(p),(h=e.dataTransfer)===null||h===void 0||h.setDragImage(d,s,l)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}let g=this.getPos();if(typeof g!="number")return;let m=_.create(r.state.doc,g),w=r.state.tr.setSelection(m);r.dispatch(w)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});let n=e.target;if(!(this.dom.contains(n)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(n))))return!1;let r=e.type.startsWith("drag"),o=e.type==="dragover"||e.type==="dragenter",i=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!r)return!0;let{isEditable:s}=this.editor,{isDragging:l}=this,a=!!this.node.type.spec.draggable,c=_.isSelectable(this.node),u=e.type==="copy",f=e.type==="paste",d=e.type==="cut",p=e.type==="mousedown";if(!a&&c&&r&&e.target===this.dom&&e.preventDefault(),a&&r&&!l&&e.target===this.dom)return e.preventDefault(),!1;if(a&&s&&!l&&p){let h=n.closest("[data-drag-handle]");h&&(this.dom===h||this.dom.contains(h))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||o||i||u||f||d||p&&c)}ignoreMutation(e){return this.dom?this.contentDOM?typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.contentDOM.contains(e.target)&&e.type==="childList"&&(Xn()||ko())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target):e.type!=="selection":!0}updateAttributes(e){this.editor.commands.command(({tr:t})=>{let n=this.getPos();return typeof n!="number"?!1:(t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){let e=this.getPos();if(typeof e!="number")return;let t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};function nt(e){return new Ka({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:o})=>{let i=pe(e.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=t,l=r[r.length-1],a=r[0],c=n.to;if(l){let u=a.search(/\S/),f=n.from+a.indexOf(l),d=f+l.length;if(vo(n.from,n.to,t.doc).filter(p=>p.mark.type.excluded.find(h=>h===e.type&&h!==p.mark.type)).filter(p=>p.to>f).length)return null;d<n.to&&s.delete(d,n.to),f>n.from&&s.delete(n.from+u,f),c=n.from+u+l.length,s.addMark(n.from+u,c,e.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(e.type)}}})}var rt=he(Ue(),1);var{getOwnPropertyNames:zv,getOwnPropertySymbols:Hv}=Object,{hasOwnProperty:_v}=Object.prototype;function xo(e,t){return function(r,o,i){return e(r,o,i)&&t(r,o,i)}}function So(e){return function(n,r,o){if(!n||!r||typeof n!="object"||typeof r!="object")return e(n,r,o);let{cache:i}=o,s=i.get(n),l=i.get(r);if(s&&l)return s===r&&l===n;i.set(n,r),i.set(r,n);let a=e(n,r,o);return i.delete(n),i.delete(r),a}}function Vv(e){return e?.[Symbol.toStringTag]}function Rh(e){return zv(e).concat(Hv(e))}var jv=Object.hasOwn||((e,t)=>_v.call(e,t));function Qn(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var Fv="__v",Wv="__o",Kv="_owner",Uv=typeof Float16Array<"u",{getOwnPropertyDescriptor:Dh,keys:Oh}=Object;function qv(e,t){return e.byteLength===t.byteLength&&Hi(new Uint8Array(e),new Uint8Array(t))}function Gv(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function Jv(e,t){return e.byteLength===t.byteLength&&Hi(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function Xv(e,t){return Qn(e.getTime(),t.getTime())}function Lh(e,t,n){return e.name===t.name&&e.message===t.message&&e.stack===t.stack&&n.equals(e.cause,t.cause,"cause","cause",e,t,n)}function Yv(e,t){return e===t}function Ph(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let o=new Array(r),i=e.entries(),s,l,a=0;for(;(s=i.next())&&!s.done;){let c=t.entries(),u=!1,f=0;for(;(l=c.next())&&!l.done;){if(o[f]){f++;continue}let d=s.value,p=l.value;if(n.equals(d[0],p[0],a,f,e,t,n)&&n.equals(d[1],p[1],d[0],p[0],e,t,n)){u=o[f]=!0;break}f++}if(!u)return!1;a++}return!0}var Qv=Qn;function Ih(e,t,n){let r=Oh(e),o=r.length;if(Oh(t).length!==o)return!1;for(;o-- >0;)if(!zh(e,t,n,r[o]))return!1;return!0}function _r(e,t,n){let r=Rh(e),o=r.length;if(Rh(t).length!==o)return!1;let i,s,l;for(;o-- >0;)if(i=r[o],!zh(e,t,n,i)||(s=Dh(e,i),l=Dh(t,i),(s||l)&&(!s||!l||s.configurable!==l.configurable||s.enumerable!==l.enumerable||s.writable!==l.writable)))return!1;return!0}function Zv(e,t){return Qn(e.valueOf(),t.valueOf())}function eC(e,t){return e.source===t.source&&e.flags===t.flags}function $h(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let o=new Array(r),i=e.values(),s,l;for(;(s=i.next())&&!s.done;){let a=t.values(),c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!o[u]&&n.equals(s.value,l.value,s.value,l.value,e,t,n)){c=o[u]=!0;break}u++}if(!c)return!1}return!0}function Hi(e,t){let n=e.length;if(t.length!==n||e.byteOffset!==t.byteOffset)return!1;if(e instanceof Float64Array||e instanceof Float32Array||Uv&&e instanceof Float16Array){for(;n-- >0;)if(e[n]!==t[n]&&(e[n]===e[n]||t[n]===t[n]))return!1;return!0}for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function tC(e,t){return e.href===t.href?!0:e.protocol===t.protocol&&e.username===t.username&&e.password===t.password&&e.host===t.host&&e.pathname===t.pathname&&e.hash===t.hash&&nC(e.searchParams,t.searchParams)}function nC(e,t){let n=e.toString(),r=t.toString();return n===r||Bh(n)===Bh(r)}function Bh(e){return e.split("&").sort().join("&")}function zh(e,t,n,r){return(r===Kv||r===Wv||r===Fv)&&(e.$$typeof||t.$$typeof)?!0:jv(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var rC="[object ArrayBuffer]",oC="[object Arguments]",iC="[object Boolean]",sC="[object DataView]",lC="[object Date]",aC="[object Error]",cC="[object Map]",uC="[object Number]",dC="[object Object]",fC="[object RegExp]",pC="[object Set]",hC="[object String]",mC={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},gC="[object URL]",bC=Object.prototype.toString;function yC({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:o,areFunctionsEqual:i,areMapsEqual:s,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:f,areTypedArraysEqual:d,areUrlsEqual:p,unknownTagComparators:h}){return function(m,w,k){if(m===w)return!0;if(m==null||w==null)return!1;let x=typeof m;if(x!==typeof w)return!1;if(x!=="object")return x==="number"?l(m,w,k):x==="function"?i(m,w,k):!1;let E=m.constructor;if(E!==w.constructor)return!1;if(E===Object)return a(m,w,k);if(Array.isArray(m))return t(m,w,k);if(E===Date)return r(m,w,k);if(E===RegExp)return u(m,w,k);if(E===Map)return s(m,w,k);if(E===Set)return f(m,w,k);if(E==null)return a(m,w,k);let M=bC.call(m);if(M===lC)return r(m,w,k);if(M===fC)return u(m,w,k);if(M===cC)return s(m,w,k);if(M===pC)return f(m,w,k);if(M===dC)return typeof m.then!="function"&&typeof w.then!="function"&&a(m,w,k);if(M===gC)return p(m,w,k);if(M===aC)return o(m,w,k);if(M===oC)return a(m,w,k);if(mC[M])return d(m,w,k);if(M===rC)return e(m,w,k);if(M===sC)return n(m,w,k);if(M===iC||M===uC||M===hC)return c(m,w,k);if(h){let A=h[M];if(!A){let S=Vv(m);S&&(A=h[S])}if(A)return A(m,w,k)}return!1}}function wC({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:qv,areArraysEqual:n?_r:Gv,areDataViewsEqual:Jv,areDatesEqual:Xv,areErrorsEqual:n?xo(Lh,_r):xo(Lh,Ih),areFunctionsEqual:Yv,areMapsEqual:n?xo(Ph,_r):Ph,areNumbersEqual:Qv,areObjectsEqual:n?_r:Ih,arePrimitiveWrappersEqual:Zv,areRegExpsEqual:eC,areSetsEqual:n?xo($h,_r):$h,areTypedArraysEqual:n?xo(Hi,_r):Hi,areUrlsEqual:tC,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let o=So(r.areArraysEqual),i=So(r.areErrorsEqual),s=So(r.areMapsEqual),l=So(r.areObjectsEqual),a=So(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:o,areErrorsEqual:i,areMapsEqual:s,areObjectsEqual:l,areSetsEqual:a})}return r}function kC(e){return function(t,n,r,o,i,s,l){return e(t,n,l)}}function vC({circular:e,comparator:t,createState:n,equals:r,strict:o}){if(n)return function(l,a){let{cache:c=e?new WeakMap:void 0,meta:u}=n();return t(l,a,{cache:c,equals:r,meta:u,strict:o})};if(e)return function(l,a){return t(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:o})};let i={cache:void 0,equals:r,meta:void 0,strict:o};return function(l,a){return t(l,a,i)}}var Hh=Cn(),TA=Cn({strict:!0}),NA=Cn({circular:!0}),RA=Cn({circular:!0,strict:!0}),DA=Cn({createInternalComparator:()=>Qn}),OA=Cn({strict:!0,createInternalComparator:()=>Qn}),LA=Cn({circular:!0,createInternalComparator:()=>Qn}),PA=Cn({circular:!0,createInternalComparator:()=>Qn,strict:!0});function Cn(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:o=!1}=e,i=wC(e),s=yC(i),l=n?n(s):kC(s);return vC({circular:t,comparator:s,createState:r,equals:l,strict:o})}var Uh=he(by(),1);function CC(e,t){var n,r;if(e.isDestroyed||t.defaultPrevented||!t.cancelable||!e.isEditable||t.inputType!=="insertParagraph"&&t.inputType!=="insertLineBreak"||!Xn()&&!ko())return;let o=e.view,i=o.root,s=(n=(r=i.getSelection)===null||r===void 0?void 0:r.call(i))!==null&&n!==void 0?n:o.dom.ownerDocument.getSelection(),l=s?.anchorNode,a=l?.nodeType===1?l:l?.parentElement,c=a?.closest("[data-node-view-content-react]");if(!c||!o.dom.contains(c))return;let u=o.input.lastKeyCode;u===13&&(o.input.lastKeyCode=null),o.domObserver.forceFlush(),o.domObserver.flush();let f=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,shiftKey:t.inputType==="insertLineBreak",bubbles:!0,cancelable:!0});o.someProp("handleKeyDown",d=>d(o,f))?(t.preventDefault(),o.input.lastIOSEnter=0,clearTimeout(o.input.lastIOSEnterFallbackTimeout)):u===13&&(o.input.lastKeyCode=u)}var _h=new oe("reactMobileEnter"),xC=(...e)=>t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&(n.current=t)})},SC=({contentComponent:e})=>{let t=(0,Kh.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,rt.jsx)(rt.Fragment,{children:Object.values(t)})};function EC(){let e=new Set,t={},n=!1,r=()=>{n||!e.size||(n=!0,queueMicrotask(()=>{n=!1,e.forEach(o=>o())}))};return{subscribe(o){return e.add(o),()=>{e.delete(o)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(o,i){t={...t,[o]:_i.default.createPortal(i.reactElement,i.element,o)},r()},removeRenderer(o){let i={...t};delete i[o],t=i,r()}}}var qa=class extends te.default.Component{constructor(e){super(e),this.editorContentRef=te.default.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var e;let t=this.props.editor;if(t&&!t.isDestroyed&&(!((e=t.view.dom)===null||e===void 0)&&e.parentNode)){if(t.contentComponent)return;let n=this.editorContentRef.current;n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n}),t.contentComponent=EC(),t.createNodeViews(),t.registerPlugin(new U({key:_h,props:{handleDOMEvents:{beforeinput:(r,o)=>CC(t,o)}}})),t.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||(e.unregisterPlugin(_h),e.view.setProps({nodeViews:{}})),e.contentComponent=null;try{var t;if(!(!((t=e.view.dom)===null||t===void 0)&&t.parentNode))return;let n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,rt.jsxs)(rt.Fragment,{children:[(0,rt.jsx)("div",{ref:xC(t,this.editorContentRef),...n}),e?.contentComponent&&(0,rt.jsx)(SC,{contentComponent:e.contentComponent})]})}},MC=(0,te.forwardRef)((e,t)=>{let n=te.default.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return te.default.createElement(qa,{key:n,innerRef:t,...e})}),AC=te.default.memo(MC),TC=typeof window<"u"?te.useLayoutEffect:te.useEffect,NC=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,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(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let t,n=o=>{o?.transaction!==void 0&&o.transaction===t||(t=o?.transaction,this.transactionNumber+=1,this.subscribers.forEach(i=>i()))},r=this.editor;return r.on("transaction",n),r.on("update",n),()=>{r.off("transaction",n),r.off("update",n)}}}};function Vr(e){var t;let[n]=(0,te.useState)(()=>new NC(e.editor)),r=(0,Uh.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,(t=e.equalityFn)!==null&&t!==void 0?t:Hh);return TC(()=>n.watch(e.editor),[e.editor,n]),(0,te.useDebugValue)(r),r}var RC=typeof window>"u",VA=RC||!!(typeof window<"u"&&window.next);var qh=(0,te.createContext)({editor:null}),jA=qh.Consumer;var Gh=(0,te.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});var DC=()=>(0,te.useContext)(Gh);var Eo=te.default.forwardRef((e,t)=>{let{onDragStart:n}=DC(),r=e.as||"div";return(0,rt.jsx)(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function Vh(e){return!!(typeof e=="function"&&e.prototype&&e.prototype.isReactComponent)}function jh(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.forward_ref)"||e.$$typeof.description==="react.forward_ref"))}function OC(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.memo)"||e.$$typeof.description==="react.memo"))}function LC(e){if(Vh(e)||jh(e))return!0;if(OC(e)){let t=e.type;if(t)return Vh(t)||jh(t)}return!1}function PC(){try{if(te.version)return parseInt(te.version.split(".")[0],10)>=19}catch{}return!1}var Ga=class{constructor(e,{editor:t,props:n={},as:r="div",className:o=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isEditorContentInitialized?(0,_i.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,o=PC(),i=LC(t),s={...n};s.ref&&!(o||i)&&delete s.ref,!s.ref&&(o||i)&&(s.ref=l=>{this.ref=l}),this.reactElement=(0,rt.jsx)(t,{...s}),r==null||(e=r.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){if(this.destroyed)return;let t=!1,n=Object.keys(e);for(let r=0;r<n.length;r+=1){let o=n[r];if(e[o]!==this.props[o]){t=!0;break}}t&&(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0;let t=this.editor;t==null||(e=t.contentComponent)===null||e===void 0||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}},FA=te.default.createContext({markViewContentRef:()=>{}});function IC(e){var t;let n=e.getRootNode(),r=typeof n.getSelection=="function"?n.getSelection():(t=e.ownerDocument)===null||t===void 0||(t=t.defaultView)===null||t===void 0?void 0:t.getSelection();if(!r||r.rangeCount===0)return null;let{anchorNode:o,anchorOffset:i,focusNode:s,focusOffset:l}=r;return!o||!s||!e.contains(o)||!e.contains(s)?null:()=>{try{r.setBaseAndExtent(o,i,s,l)}catch{}}}function $C(e,t,n){return e.node(n)===t.node(n)&&e.before(n)===t.before(n)}function Jh(e){if(!Oi(e))return[];let{$from:t,$to:n}=e,r=[],o=Math.min(t.depth,n.depth);for(let i=1;i<=o&&$C(t,n,i);i+=1)r.push(t.before(i));return r}var BC=class{constructor(e){this.views=new WeakMap,this.viewCount=0,this.insideViews=new Set,this.syncQueued=!1,this.scheduleSync=()=>{this.syncQueued||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,this.sync()}))},this.handleTransaction=()=>this.scheduleSync(),this.editor=e}register(e){this.viewCount===0&&this.editor.on("transaction",this.handleTransaction),this.views.set(e.dom,e),this.viewCount+=1,this.scheduleSync()}unregister(e){this.views.delete(e.dom),this.viewCount-=1,this.insideViews.delete(e),this.viewCount===0&&this.editor.off("transaction",this.handleTransaction)}sync(){if(this.viewCount===0||this.editor.isDestroyed)return;let e=this.findInsideViews();this.updateViews(this.insideViews,e,!1),this.updateViews(e,this.insideViews,!0),this.insideViews=e}updateViews(e,t,n){for(let r of e)t.has(r)||r.setSelectionInside(n)}findInsideViews(){let e=new Set;for(let t of Jh(this.editor.state.selection)){let n=this.editor.view.nodeDOM(t),r=n?this.views.get(n):void 0;r&&e.add(r)}return e}},Fh=new WeakMap;function Wh(e){let t=Fh.get(e);return t||(t=new BC(e),Fh.set(e,t)),t}var zC=class extends zi{constructor(e,t,n){if(super(e,t,n),this.nodeSelected=!1,this.handlePositionUpdate=()=>{let r=this.getPos();typeof r!="number"||r===this.currentPos||(this.currentPos=r,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";let r=this.dom.querySelector("[data-node-view-content]");r?r.appendChild(this.contentDOMElement):this.dom.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,o){if(r==="storage"){var i;return(i=e.storage[t.name])!==null&&i!==void 0?i:{}}return Reflect.get(n,r,o)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,selectionInside:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:(0,te.createRef)()};if(!this.component.displayName){let a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}let r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{if(a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement){a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper");let c=IC(this.contentDOMElement);a.appendChild(this.contentDOMElement),c?.()}}},o=this.component,i=(0,te.memo)(a=>(0,rt.jsx)(Gh.Provider,{value:r,children:(0,te.createElement)(o,a)}));i.displayName="ReactNodeView";let s=this.node.isInline?"span":"div";this.options.as&&(s=this.options.as);let{className:l=""}=this.options;this.renderer=new Ga(i,{editor:this.editor,props:e,as:s,className:`node-${this.node.type.name} ${l}`.trim()}),Wh(this.editor).register(this),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}update(e,t,n){let r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){let s=this.node,l=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:s,oldDecorations:l,newNode:e,newDecorations:t,oldInnerDecorations:a,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(e===this.node)return this.node=e,this.decorations=t,this.innerDecorations=n,!0;let o=this.getPos();this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=o;let i={node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(i.getPos=()=>this.getPos()),r(i),!0}selectNode(){this.nodeSelected=!0,this.updateSelectedState(!0)}deselectNode(){this.nodeSelected=!1,this.updateSelectedState(this.options.selectedOnTextSelection===!0&&this.isTextSelectionInside())}setSelectionInside(e){let t=this.nodeSelected||this.options.selectedOnTextSelection===!0&&e;this.renderer.updateProps({selectionInside:e,selected:t}),this.renderer.element.classList.toggle("ProseMirror-selectednode",t)}updateSelectedState(e){this.renderer.updateProps({selected:e}),this.renderer.element.classList.toggle("ProseMirror-selectednode",e)}isTextSelectionInside(){let e=this.getPos();return typeof e=="number"&&Jh(this.editor.state.selection).includes(e)}destroy(){this.renderer.destroy(),Wh(this.editor).unregister(this),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){let t=this.editor.extensionManager.attributes,n=Bt(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function Mo(e,t){return n=>n.editor.contentComponent?new zC(e,n,t):{dom:document.createElement("span"),contentDOM:null,update:()=>!1,destroy:()=>{},selectNode:()=>{},deselectNode:()=>{},stopEvent:()=>!1,ignoreMutation:()=>!0}}var Ja=(0,te.createContext)({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Ja.displayName="TiptapContext";var HC=()=>(0,te.useContext)(Ja);function Xh({children:e,...t}){let n="editor"in t?t.editor:t.instance;if(!n)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,te.useMemo)(()=>({editor:n}),[n]),o=(0,te.useMemo)(()=>({editor:n}),[n]);return(0,rt.jsx)(qh.Provider,{value:o,children:(0,rt.jsx)(Ja.Provider,{value:r,children:e})})}Xh.displayName="Tiptap";function Yh({...e}){let{editor:t}=HC();return(0,rt.jsx)(AC,{editor:t,...e})}Yh.displayName="Tiptap.Content";var WA=Object.assign(Xh,{Content:Yh});var Vi=class extends qa{init(){let t=this.props.editor,n=this.editorContentRef.current,r=t;if(t&&!t.isDestroyed&&n&&r?.contentComponent){let o=t.view.dom.parentElement;if(o&&o!==n){if(o.isConnected)throw new Error("A retained editor cannot occupy two connected hosts.");n.append(...o.childNodes),t.setOptions({element:n})}return}super.init()}componentWillUnmount(){let t=this.editorContentRef.current,n=this.props.editor;queueMicrotask(()=>{t&&!t.isConnected&&n?.options.element===t&&super.componentWillUnmount()})}};var ot=he(Kt(),1);var _C=new WeakSet,Qh=e=>_C.has(e);var VC=(0,ot.createContext)(null),Zn=new WeakMap;function Zh(e){let t=(0,ot.useContext)(VC),n=(0,ot.useId)(),r=(0,ot.useRef)(e.retentionKey??n).current,o=(0,ot.useRef)(e);o.current=e;let i=(0,ot.useRef)(t?.find(r)??null),[s,l]=(0,ot.useState)(i.current),a=(0,ot.useRef)(void 0);return(0,ot.useLayoutEffect)(()=>{clearTimeout(a.current);let c=()=>{let{retentionKey:d,immediatelyRender:p,shouldRerenderOnTransaction:h,...g}=o.current,m;return m=new Ua({...g,onUpdate:w=>Zn.get(w.editor)?.current.onUpdate?.(w),editorProps:{...g.editorProps,handleKeyDown:(w,k)=>Zn.get(m)?.current.editorProps?.handleKeyDown?.(w,k)??!1,handleClick:(w,k,x)=>Zn.get(m)?.current.editorProps?.handleClick?.(w,k,x)??!1,handlePaste:(w,k,x)=>Zn.get(m)?.current.editorProps?.handlePaste?.(w,k,x)??!1}}),m},u=t?t.get(r,c):i.current&&!i.current.isDestroyed?i.current:c();i.current=u,Zn.set(u,o);let f=o.current.editable!==!1;return u.options.editable!==f&&u.setEditable(f,!1),l(u),()=>{Zn.get(u)===o&&(Zn.delete(u),!u.isDestroyed&&u.options.editable&&u.setEditable(!1,!1)),!t&&(a.current=setTimeout(()=>{i.current===u&&!u.isDestroyed&&u.destroy()},1))}},[t,r]),s}var Xa=new WeakMap;function Ya(e){let t=Xa.get(e);if(t)return t;let n={type:e.type.name};Object.keys(e.attrs).length&&(n.attrs=e.attrs),e.content.size&&(n.content=[],e.content.forEach(o=>n.content.push(Ya(o)))),e.marks.length&&(n.marks=e.marks.map(o=>o.toJSON())),e.isText&&(n.text=e.text);let r=oo(n);return Xa.set(e,r),r}function em(e,t){let n=Xa.get(e);if(n===t)return!0;if(!n||n.type!==t.type||n.text!==t.text||n.attrs!==t.attrs&&JSON.stringify(n.attrs)!==JSON.stringify(t.attrs)||n.marks!==t.marks&&JSON.stringify(n.marks)!==JSON.stringify(t.marks)||e.childCount!==(t.content?.length??0))return!1;for(let r=0;r<e.childCount;r++)if(!em(e.child(r),t.content[r]))return!1;return!0}function tm(e,t){if(t.type!==e.type.name||e.childCount!==(t.content?.length??0))return!1;for(let n=0;n<e.childCount;n++)if(!em(e.child(n),t.content[n]))return!1;return!0}function ji(e,t,n){let r=[],o=[];return e.nodesBetween(t,n,(i,s,l)=>{let a=i.attrs?.id;if(!(typeof a!="string"||a.startsWith("page-tail-")))if(i.isTextblock){let c=s+1,u=c+i.content.size;(Math.max(t,c)<Math.min(n,u)||i.content.size===0&&t<=s&&n>=s+i.nodeSize)&&r.push(a)}else l===e&&o.push(a)}),[...new Set(r.length?r:o)].slice(0,100)}var je=class e extends Q{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):Q.near(r)}content(){return ue.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new e(t.resolve(n.pos))}getBookmark(){return new Qa(this.anchor)}static valid(t){let n=t.parent;if(n.inlineContent||!jC(t)||!FC(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&e.valid(t))return t;let o=t.pos,i=null;for(let s=t.depth;;s--){let l=t.node(s);if(n>0?t.indexAfter(s)<l.childCount:t.index(s)>0){i=l.child(n>0?t.indexAfter(s):t.index(s)-1);break}else if(s==0)return null;o+=n;let a=t.doc.resolve(o);if(e.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!_.isSelectable(i)){t=t.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=t.doc.resolve(o);if(e.valid(l))return l}return null}}};je.prototype.visible=!1;je.findFrom=je.findGapCursorFrom;Q.jsonID("gapcursor",je);var Qa=class e{constructor(t){this.pos=t}map(t){return new e(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return je.valid(n)?new je(n):Q.near(n)}};function nm(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function jC(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||nm(o.type))return!0;if(o.inlineContent)return!1}}return!0}function FC(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||nm(o.type))return!0;if(o.inlineContent)return!1}}return!0}function rm(){return new U({props:{decorations:qC,createSelectionBetween(e,t,n){return t.pos==n.pos&&je.valid(n)?new je(n):null},handleClick:KC,handleKeyDown:WC,handleDOMEvents:{beforeinput:UC}}})}var WC=bo({ArrowLeft:Fi("horiz",-1),ArrowRight:Fi("horiz",1),ArrowUp:Fi("vert",-1),ArrowDown:Fi("vert",1)});function Fi(e,t){let n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,o,i){let s=r.selection,l=t>0?s.$to:s.$from,a=s.empty;if(s instanceof P){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(t>0?l.after():l.before())}let c=je.findGapCursorFrom(l,t,a);return c?(o&&o(r.tr.setSelection(new je(c))),!0):!1}}function KC(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!je.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&_.isSelectable(e.state.doc.nodeAt(o.inside))?!1:(e.dispatch(e.state.tr.setSelection(new je(r))),!0)}function UC(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof je))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let o=F.empty;for(let s=r.length-1;s>=0;s--)o=F.from(r[s].createAndFill(null,o));let i=e.state.tr.replace(n.pos,n.pos,new ue(o,0,0));return i.setSelection(P.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function qC(e){if(!(e.selection instanceof je))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",de.create(e.doc,[$e.widget(e.selection.head,t,{key:"gapcursor"})])}function jr(e){let t=e.selection;if(!(t instanceof _)||t.node.type.name!=="widget")return null;let n=Q.findFrom(t.$to,1,!0)??Q.findFrom(t.$from,-1,!0),r=n?null:new je(e.doc.resolve(e.doc.content.size)).map(e.doc,new ni),o=n??(r instanceof je?r:null);return o?e.tr.setSelection(o).setMeta("addToHistory",!1):null}function om(e,t){if(tm(e.doc,t))return null;let n=e.schema.nodeFromJSON(t),r=e.doc.content.findDiffStart(n.content);if(r===null)return null;let o=e.doc.content.findDiffEnd(n.content),i=o.a,s=o.b,l=r-Math.min(i,s);return l>0&&(i+=l,s+=l),e.tr.replace(r,i,n.slice(r,s)).setMeta("addToHistory",!1).setMeta("preventUpdate",!0)}var ec,tc;if(typeof WeakMap<"u"){let e=new WeakMap;ec=t=>e.get(t),tc=(t,n)=>(e.set(t,n),n)}else{let e=[],n=0;ec=r=>{for(let o=0;o<e.length;o+=2)if(e[o]==r)return e[o+1]},tc=(r,o)=>(n==10&&(n=0),e[n++]=r,e[n++]=o)}var ke=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,o=t/this.width|0,i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[t+l]==n;l++)i++;for(let l=1;s<this.height&&this.map[t+this.width*l]==n;l++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:o,top:i,bottom:s}=this.findCell(e);return t=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(e,t){let{left:n,right:r,top:o,bottom:i}=this.findCell(e),{left:s,right:l,top:a,bottom:c}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let o=e.left;o<e.right;o++){let i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==e.left&&o&&this.map[i-1]==s||r==e.top&&r&&this.map[i-this.width]==s)&&t.push(s))}return t}positionAt(e,t,n){for(let r=0,o=0;;r++){let i=o+n.child(r).nodeSize;if(r==e){let s=t+e*this.width,l=(e+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(e){return ec(e)||tc(e,GC(e))}};function GC(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);let t=JC(e),n=e.childCount,r=[],o=0,i=null,s=[];for(let c=0,u=t*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){let f=e.child(c);u++;for(let h=0;;h++){for(;o<r.length&&r[o]!=0;)o++;if(h==f.childCount)break;let g=f.child(h),{colspan:m,rowspan:w,colwidth:k}=g.attrs;for(let x=0;x<w;x++){if(x+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:w-x});break}let E=o+x*t;for(let M=0;M<m;M++){r[E+M]==0?r[E+M]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:m-M});let A=k&&k[M];if(A){let S=(E+M)%t*2,L=s[S];L==null||L!=A&&s[S+1]==1?(s[S]=A,s[S+1]=1):L==A&&s[S+1]++}}}o+=m,u+=g.nodeSize}let d=(c+1)*t,p=0;for(;o<d;)r[o++]==0&&p++;p&&(i||(i=[])).push({type:"missing",row:c,n:p}),u++}(t===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});let l=new ke(t,n,r,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(a=!0);return a&&XC(l,s,e),l}function JC(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let o=e.child(r),i=0;if(n)for(let s=0;s<r;s++){let l=e.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}t==-1?t=i:t!=i&&(t=Math.max(t,i))}return t}function XC(e,t,n){e.problems||(e.problems=[]);let r={};for(let o=0;o<e.map.length;o++){let i=e.map[o];if(r[i])continue;r[i]=!0;let s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=s.attrs;for(let c=0;c<a.colspan;c++){let u=t[(o+c)%e.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=YC(a)))[c]=u)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function YC(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Ze(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}}return t}var xn=new oe("selectingCells");function nn(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function QC(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function Et(e){let t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function Ji(e){let t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;let n=nn(t.$head)||ZC(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function ZC(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function nc(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function ex(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function ic(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function hm(e,t,n){let r=e.node(-1),o=ke.get(r),i=e.start(-1),s=o.nextCell(e.pos-i,t,n);return s==null?null:e.node(0).resolve(i+s)}function er(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function mm(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(t,0,0)}return r}function tx(e,t,n){let r=Ze(t.type.schema).header_cell;for(let o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0}var ie=class tn extends Q{constructor(t,n=t){let r=t.node(-1),o=ke.get(r),i=t.start(-1),s=o.rectBetween(t.pos-i,n.pos-i),l=t.node(0),a=o.cellsInRect(s).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);let c=a.map(u=>{let f=r.nodeAt(u);if(!f)throw new RangeError(`No cell with offset ${u} found`);let d=i+u+1;return new kl(l.resolve(d),l.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=t,this.$headCell=n}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),o=t.resolve(n.map(this.$headCell.pos));if(nc(r)&&nc(o)&&ic(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?tn.rowSelection(r,o):i&&this.isColSelection()?tn.colSelection(r,o):new tn(r,o)}return P.between(r,o)}content(){let t=this.$anchorCell.node(-1),n=ke.get(t),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let u=a*n.width+o.left,f=o.left;f<o.right;f++,u++){let d=n.map[u];if(i[d])continue;i[d]=!0;let p=n.findCell(d),h=t.nodeAt(d);if(!h)throw new RangeError(`No cell with offset ${d} found`);let g=o.left-p.left,m=p.right-o.right;if(g>0||m>0){let w=h.attrs;if(g>0&&(w=er(w,0,g)),m>0&&(w=er(w,w.colspan-m,m)),p.left<o.left){if(h=h.type.createAndFill(w),!h)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(w)}`)}else h=h.type.create(w,h.content)}if(p.top<o.top||p.bottom>o.bottom){let w={...h.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?h=h.type.createAndFill(w):h=h.type.create(w,h.content)}c.push(h)}s.push(t.child(a).copy(F.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?t:s;return new ue(F.from(l),1,1)}replace(t,n=ue.empty){let r=t.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],c=t.mapping.slice(r);t.replace(c.map(l.pos),c.map(a.pos),s?ue.empty:n)}let i=Q.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);i&&t.setSelection(i)}replaceWith(t,n){this.replace(t,new ue(F.from(n),0,0))}forEachCell(t){let n=this.$anchorCell.node(-1),r=ke.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)t(n.nodeAt(i[s]),o+i[s])}isColSelection(){let t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;let r=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),o=ke.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.top<=l.top?(s.top>0&&(t=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new tn(t,n)}isRowSelection(){let t=this.$anchorCell.node(-1),n=ke.get(t),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(t){return t instanceof tn&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),o=ke.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.left<=l.left?(s.left>0&&(t=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(t=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new tn(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new tn(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new tn(t.resolve(n),t.resolve(r))}getBookmark(){return new nx(this.$anchorCell.pos,this.$headCell.pos)}};ie.prototype.visible=!1;Q.jsonID("cell",ie);var nx=class gm{constructor(t,n){this.anchor=t,this.head=n}map(t){return new gm(t.map(this.anchor),t.map(this.head))}resolve(t){let n=t.resolve(this.anchor),r=t.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&&ic(n,r)?new ie(n,r):Q.near(r,1)}};function rx(e){if(!(e.selection instanceof ie))return null;let t=[];return e.selection.forEachCell((n,r)=>{t.push($e.node(r,r+n.nodeSize,{class:"selectedCell"}))}),de.create(e.doc,t)}function ox({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,o=e.depth;for(;o>=0&&!(e.after(o+1)<e.end(o));o--,n++);for(let i=t.depth;i>=0&&!(t.before(i+1)>t.start(i));i--,r--);return n==r&&/row|table/.test(e.node(o).type.spec.tableRole)}function ix({$from:e,$to:t}){let n,r;for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&t.parentOffset===0}function sx(e,t,n){let r=(t||e).selection,o=(t||e).doc,i,s;if(r instanceof _&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=ie.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=ie.rowSelection(l,l)}else if(!n){let l=ke.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=ie.create(o,a+1,c)}}else r instanceof P&&ox(r)?i=P.create(o,r.from):r instanceof P&&ix(r)&&(i=P.create(o,r.$from.start(),r.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}var lx=new oe("fix-tables");function bm(e,t,n,r){let o=e.childCount,i=t.childCount;e:for(let s=0,l=0;s<i;s++){let a=t.child(s);for(let c=l,u=Math.min(o,s+3);c<u;c++)if(e.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<o&&e.child(l).sameMarkup(a)?bm(e.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function sc(e,t){let n,r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=ax(e,o,i,n))};return t?t.doc!=e.doc&&bm(t.doc,e.doc,0,r):e.doc.descendants(r),n}function ax(e,t,n,r){let o=ke.get(t);if(!o.problems)return r;r||(r=e.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type=="collision"){let u=t.nodeAt(c.pos);if(!u)continue;let f=u.attrs;for(let d=0;d<f.rowspan;d++)i[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,er(f,f.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=t.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){let u=t.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let u=r.mapping.map(n);r.delete(u,u+t.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=n+1;a<o.height;a++){let u=t.child(a),f=c+u.nodeSize,d=i[a];if(d>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);let h=[];for(let m=0;m<d;m++){let w=Ze(e.schema)[p].createAndFill();w&&h.push(w)}let g=(a==0||s==a-1)&&l==a?c+1:f-1;r.insert(r.mapping.map(g),h)}c=f}return r.setMeta(lx,{fixTables:!0})}function zt(e){let t=e.selection,n=Ji(e),r=n.node(-1),o=n.start(-1),i=ke.get(r);return{...t instanceof ie?i.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function ym(e,{map:t,tableStart:n,table:r},o){let i=o>0?-1:0;tx(t,r,o+i)&&(i=o==0||o==t.width?null:0);for(let s=0;s<t.height;s++){let l=s*t.width+o;if(o>0&&o<t.width&&t.map[l-1]==t.map[l]){let a=t.map[l],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,mm(c.attrs,o-t.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?Ze(r.type.schema).cell:r.nodeAt(t.map[l+i]).type,c=t.positionAt(s,o,r);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function wm(e,t){if(!Et(e))return!1;if(t){let n=zt(e);t(ym(e.tr,n,n.left))}return!0}function km(e,t){if(!Et(e))return!1;if(t){let n=zt(e);t(ym(e.tr,n,n.right))}return!0}function cx(e,{map:t,table:n,tableStart:r},o){let i=e.mapping.maps.length;for(let s=0;s<t.height;){let l=s*t.width+o,a=t.map[l],c=n.nodeAt(a),u=c.attrs;if(o>0&&t.map[l-1]==a||o<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(r+a),null,er(u,o-t.colCount(a)));else{let f=e.mapping.slice(i).map(r+a);e.delete(f,f+c.nodeSize)}s+=u.rowspan}}function vm(e,t){if(!Et(e))return!1;if(t){let n=zt(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;cx(r,n,o),o!=n.left;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=ke.get(i)}t(r)}return!0}function ux(e,t,n){var r;let o=Ze(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(((r=t.nodeAt(e.map[i+n*e.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function Cm(e,{map:t,tableStart:n,table:r},o){let i=n;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;let s=[],l=o>0?-1:0;ux(t,r,o+l)&&(l=o==0||o==t.height?null:0);for(let c=0,u=t.width*o;c<t.width;c++,u++)if(o>0&&o<t.height&&t.map[u]==t.map[u-t.width]){let f=t.map[u],d=r.nodeAt(f).attrs;e.setNodeMarkup(n+f,null,{...d,rowspan:d.rowspan+1}),c+=d.colspan-1}else{var a;let f=l==null?Ze(r.type.schema).cell:(a=r.nodeAt(t.map[u+l*t.width]))===null||a===void 0?void 0:a.type,d=f?.createAndFill();d&&s.push(d)}return e.insert(i,Ze(r.type.schema).row.create(null,s)),e}function xm(e,t){if(!Et(e))return!1;if(t){let n=zt(e);t(Cm(e.tr,n,n.top))}return!0}function Sm(e,t){if(!Et(e))return!1;if(t){let n=zt(e);t(Cm(e.tr,n,n.bottom))}return!0}function dx(e,{map:t,table:n,tableStart:r},o){let i=0;for(let c=0;c<o;c++)i+=n.child(c).nodeSize;let s=i+n.child(o).nodeSize,l=e.mapping.maps.length;e.delete(i+r,s+r);let a=new Set;for(let c=0,u=o*t.width;c<t.width;c++,u++){let f=t.map[u];if(!a.has(f)){if(a.add(f),o>0&&f==t.map[u-t.width]){let d=n.nodeAt(f).attrs;e.setNodeMarkup(e.mapping.slice(l).map(f+r),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(o<t.height&&f==t.map[u+t.width]){let d=n.nodeAt(f),p=d.attrs,h=d.type.create({...p,rowspan:d.attrs.rowspan-1},d.content),g=t.positionAt(o+1,c,n);e.insert(e.mapping.slice(l).map(r+g),h),c+=p.colspan-1}}}}function Em(e,t){if(!Et(e))return!1;if(t){let n=zt(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;dx(r,n,o),o!=n.top;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=ke.get(n.table)}t(r)}return!0}function im(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function fx({width:e,height:t,map:n},r){let o=r.top*e+r.left,i=o,s=(r.bottom-1)*e+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<e&&n[l]==n[l+1])return!0;i+=e,l+=e}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[o]==n[o-e]||r.bottom<t&&n[s]==n[s+e])return!0;o++,s++}return!1}function lc(e,t){let n=e.selection;if(!(n instanceof ie)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=zt(e),{map:o}=r;if(fx(o,r))return!1;if(t){let i=e.tr,s={},l=F.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){let d=o.map[u*o.width+f],p=r.table.nodeAt(d);if(!(s[d]||!p))if(s[d]=!0,a==null)a=d,c=p;else{im(p)||(l=l.append(p.content));let h=i.mapping.map(d+r.tableStart);i.delete(h,h+p.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...mm(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let u=a+1+c.content.size,f=im(c)?a+1:u;i.replaceWith(f+r.tableStart,u+r.tableStart,l)}i.setSelection(new ie(i.doc.resolve(a+r.tableStart))),t(i)}return!0}function ac(e,t){let n=Ze(e.schema);return px(({node:r})=>n[r.type.spec.tableRole])(e,t)}function px(e){return(t,n)=>{let r=t.selection,o,i;if(r instanceof ie){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=QC(r.$from),!o)return!1;i=(s=nn(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let u=zt(t),f=t.tr;for(let p=0;p<u.right-u.left;p++)a.push(c?{...l,colwidth:c&&c[p]?[c[p]]:null}:l);let d;for(let p=u.top;p<u.bottom;p++){let h=u.map.positionAt(p,u.left,u.table);p==u.top&&(h+=o.nodeSize);for(let g=u.left,m=0;g<u.right;g++,m++)g==u.left&&p==u.top||f.insert(d=f.mapping.map(h+u.tableStart,1),e({node:o,row:p,col:g}).createAndFill(a[m]))}f.setNodeMarkup(i,e({node:o,row:u.top,col:u.left}),a[0]),r instanceof ie&&f.setSelection(new ie(f.doc.resolve(r.$anchorCell.pos),d?f.doc.resolve(d):void 0)),n(f)}return!0}}function Mm(e,t){return function(n,r){if(!Et(n))return!1;let o=Ji(n);if(o.nodeAfter.attrs[e]===t)return!1;if(r){let i=n.tr;n.selection instanceof ie?n.selection.forEachCell((s,l)=>{s.attrs[e]!==t&&i.setNodeMarkup(l,null,{...s.attrs,[e]:t})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[e]:t}),r(i)}return!0}}function hx(e){return function(t,n){if(!Et(t))return!1;if(n){let r=Ze(t.schema),o=zt(t),i=t.tr,s=o.map.cellsInRect(e=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:e=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);n(i)}return!0}}function sm(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let o=0;o<r.length;o++){let i=t.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function Fr(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?hx(e):function(n,r){if(!Et(n))return!1;if(r){let o=Ze(n.schema),i=zt(n),s=n.tr,l=sm("row",i,o),a=sm("column",i,o),c=(e==="column"?l:e==="row"&&a)?1:0,u=e=="column"?{left:0,top:c,right:1,bottom:i.map.height}:e=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,f=e=="column"?a?o.cell:o.header_cell:e=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(u).forEach(d=>{let p=d+i.tableStart,h=s.doc.nodeAt(p);h&&s.setNodeMarkup(p,f,h.attrs)}),r(s)}return!0}}var ST=Fr("row",{useDeprecatedLogic:!0}),ET=Fr("column",{useDeprecatedLogic:!0}),Am=Fr("cell",{useDeprecatedLogic:!0});function mx(e,t){if(t<0){let n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,o=e.before();r>=0;r--){let i=e.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let n=e.node(-1);for(let r=e.indexAfter(-1),o=e.after();r<n.childCount;r++){let i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function cc(e){return function(t,n){if(!Et(t))return!1;let r=mx(Ji(t),e);if(r==null)return!1;if(n){let o=t.doc.resolve(r);n(t.tr.setSelection(P.between(o,ex(o))).scrollIntoView())}return!0}}function Tm(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Wi(e,t){let n=e.selection;if(!(n instanceof ie))return!1;if(t){let r=e.tr,o=Ze(e.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new ue(o,0,0))}),r.docChanged&&t(r)}return!0}function gx(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;let o=t.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<t.childCount;a++){let c=t.child(a).content,u=a?0:Math.max(0,n-1),f=a<t.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=rc(Ze(s).row,new ue(c,u,f)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?rc(Ze(s).row,new ue(t,n,r)).content:t);else return null;return bx(s,l)}function bx(e,t){let n=[];for(let o=0;o<t.length;o++){let i=t[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=t.length&&t.push(F.empty),n[o]<r){let i=Ze(e).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);t[o]=t[o].append(F.from(s))}return{height:t.length,width:r,rows:t}}function rc(e,t){let n=e.createAndFill();return new ii(n).replace(0,n.content.size,t).doc}function yx({width:e,height:t,rows:n},r,o){if(e!=r){let i=[],s=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let u=i[l]||0,f=0;u<r;f++){let d=a.child(f%a.childCount);u+d.attrs.colspan>r&&(d=d.type.createChecked(er(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let p=1;p<d.attrs.rowspan;p++)i[l+p]=(i[l+p]||0)+d.attrs.colspan}s.push(F.from(c))}n=s,e=r}if(t!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],c=n[l%t];for(let u=0;u<c.childCount;u++){let f=c.child(u);s+f.attrs.rowspan>o&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,o-f.attrs.rowspan)},f.content)),a.push(f)}i.push(F.from(a))}n=i,t=o}return{width:e,height:t,rows:n}}function wx(e,t,n,r,o,i,s){let l=e.doc.type.schema,a=Ze(l),c,u;if(o>t.width)for(let f=0,d=0;f<t.height;f++){let p=n.child(f);d+=p.nodeSize;let h=[],g;p.lastChild==null||p.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let m=t.width;m<o;m++)h.push(g);e.insert(e.mapping.slice(s).map(d-1+r),h)}if(i>t.height){let f=[];for(let h=0,g=(t.height-1)*t.width;h<Math.max(t.width,o);h++){let m=h>=t.width?!1:n.nodeAt(t.map[g+h]).type==a.header_cell;f.push(m?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let d=a.row.create(null,F.from(f)),p=[];for(let h=t.height;h<i;h++)p.push(d);e.insert(e.mapping.slice(s).map(r+n.nodeSize-2),p)}return!!(c||u)}function lm(e,t,n,r,o,i,s,l){if(s==0||s==t.height)return!1;let a=!1;for(let c=o;c<i;c++){let u=s*t.width+c,f=t.map[u];if(t.map[u-t.width]==f){a=!0;let d=n.nodeAt(f),{top:p,left:h}=t.findCell(f);e.setNodeMarkup(e.mapping.slice(l).map(f+r),null,{...d.attrs,rowspan:s-p}),e.insert(e.mapping.slice(l).map(t.positionAt(s,h,n)),d.type.createAndFill({...d.attrs,rowspan:p+d.attrs.rowspan-s})),c+=d.attrs.colspan-1}}return a}function am(e,t,n,r,o,i,s,l){if(s==0||s==t.width)return!1;let a=!1;for(let c=o;c<i;c++){let u=c*t.width+s,f=t.map[u];if(t.map[u-1]==f){a=!0;let d=n.nodeAt(f),p=t.colCount(f),h=e.mapping.slice(l).map(f+r);e.setNodeMarkup(h,null,er(d.attrs,s-p,d.attrs.colspan-(s-p))),e.insert(h+d.nodeSize,d.type.createAndFill(er(d.attrs,0,s-p))),c+=d.attrs.rowspan-1}}return a}function cm(e,t,n,r,o){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let s=ke.get(i),{top:l,left:a}=r,c=a+o.width,u=l+o.height,f=e.tr,d=0;function p(){if(i=n?f.doc.nodeAt(n-1):f.doc,!i)throw new Error("No table found");s=ke.get(i),d=f.mapping.maps.length}wx(f,s,i,n,c,u,d)&&p(),lm(f,s,i,n,a,c,l,d)&&p(),lm(f,s,i,n,a,c,u,d)&&p(),am(f,s,i,n,l,u,a,d)&&p(),am(f,s,i,n,l,u,c,d)&&p();for(let h=l;h<u;h++){let g=s.positionAt(h,a,i),m=s.positionAt(h,c,i);f.replace(f.mapping.slice(d).map(g+n),f.mapping.slice(d).map(m+n),new ue(o.rows[h-l],0,0))}p(),f.setSelection(new ie(f.doc.resolve(n+s.positionAt(l,a,i)),f.doc.resolve(n+s.positionAt(u-1,c-1,i)))),t(f)}var kx=bo({ArrowLeft:Ki("horiz",-1),ArrowRight:Ki("horiz",1),ArrowUp:Ki("vert",-1),ArrowDown:Ki("vert",1),"Shift-ArrowLeft":Ui("horiz",-1),"Shift-ArrowRight":Ui("horiz",1),"Shift-ArrowUp":Ui("vert",-1),"Shift-ArrowDown":Ui("vert",1),Backspace:Wi,"Mod-Backspace":Wi,Delete:Wi,"Mod-Delete":Wi});function qi(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Ki(e,t){return(n,r,o)=>{if(!o)return!1;let i=n.selection;if(i instanceof ie)return qi(n,r,Q.near(i.$headCell,t));if(e!="horiz"&&!i.empty)return!1;let s=Nm(o,e,t);if(s==null)return!1;if(e=="horiz")return qi(n,r,Q.near(n.doc.resolve(i.head+t),t));{let l=n.doc.resolve(s),a=hm(l,e,t),c;return a?c=Q.near(a,1):t<0?c=Q.near(n.doc.resolve(l.before(-1)),-1):c=Q.near(n.doc.resolve(l.after(-1)),1),qi(n,r,c)}}}function Ui(e,t){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof ie)s=i;else{let a=Nm(o,e,t);if(a==null)return!1;s=new ie(n.doc.resolve(a))}let l=hm(s.$headCell,e,t);return l?qi(n,r,new ie(s.$anchorCell,l)):!1}}function vx(e,t){let n=e.state.doc,r=nn(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new ie(r))),!0):!1}function Cx(e,t,n){if(!Et(e.state))return!1;let r=gx(n),o=e.state.selection;if(o instanceof ie){r||(r={width:1,height:1,rows:[F.from(rc(Ze(e.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=ke.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=yx(r,l.right-l.left,l.bottom-l.top),cm(e.state,e.dispatch,s,l,r),!0}else if(r){let i=Ji(e.state),s=i.start(-1);return cm(e.state,e.dispatch,s,ke.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function xx(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;let r=um(e,t.target),o;if(t.shiftKey&&e.state.selection instanceof ie)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(o=nn(e.state.selection.$anchor))!=null&&((n=Za(e,t))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,t),t.preventDefault();else if(!r)return;function i(a,c){let u=Za(e,c),f=xn.getState(e.state)==null;if(!u||!ic(a,u))if(f)u=a;else return;let d=new ie(a,u);if(f||!e.state.selection.eq(d)){let p=e.state.tr.setSelection(d);f&&p.setMeta(xn,a.pos),e.dispatch(p)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),xn.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(xn,-1))}function l(a){let c=a,u=xn.getState(e.state),f;if(u!=null)f=e.state.doc.resolve(u);else if(um(e,c.target)!=r&&(f=Za(e,t),!f))return s();f&&i(f,c)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function Nm(e,t,n){if(!(e.state.selection instanceof P))return null;let{$head:r}=e.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let s=r.before(o),l=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(l)?s:null}}return null}function um(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function Za(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&nn(e.state.doc.resolve(r))||nn(e.state.doc.resolve(o))}var Sx=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),oc(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,oc(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function oc(e,t,n,r,o,i){let s=0,l=!0,a=t.firstChild,c=e.firstChild;if(c){for(let f=0,d=0;f<c.childCount;f++){let{colspan:p,colwidth:h}=c.child(f).attrs;for(let g=0;g<p;g++,d++){let m=o==d?i:h&&h[g],w=m?m+"px":"";if(s+=m||r,m||(l=!1),a)a.style.width!=w&&(a.style.width=w),a=a.nextSibling;else{let k=document.createElement("col");k.style.width=w,t.appendChild(k)}}}for(;a;){var u;let f=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=f}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}var ft=new oe("tableColumnResizing");function Rm({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Sx,lastColumnResizable:o=!0}={}){let i=new U({key:ft,state:{init(s,l){var a;let c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=Ze(l.schema).table.name;return r&&c&&(c[u]=(f,d)=>new r(f,n,d)),new Ex(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=ft.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{Mx(s,l,e,o)},mouseleave:s=>{Ax(s)},mousedown:(s,l)=>{Tx(s,l,t,n)}},decorations:s=>{let l=ft.getState(s);if(l&&l.activeHandle>-1)return Lx(s,l.activeHandle)},nodeViews:{}}});return i}var Ex=class Gi{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){let n=this,r=t.getMeta(ft);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&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return nc(t.doc.resolve(o))||(o=-1),new Gi(o,n.dragging)}return n}};function Mx(e,t,n,r){if(!e.editable)return;let o=ft.getState(e.state);if(o&&!o.dragging){let i=Rx(t.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();t.clientX-l<=n?s=dm(e,t,"left",n):a-t.clientX<=n&&(s=dm(e,t,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=e.state.doc.resolve(s),a=l.node(-1),c=ke.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Dm(e,s)}}}function Ax(e){if(!e.editable)return;let t=ft.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Dm(e,-1)}function Tx(e,t,n,r){var o;if(!e.editable)return!1;let i=(o=e.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=ft.getState(e.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=e.state.doc.nodeAt(s.activeHandle),a=Nx(e,s.activeHandle,l.attrs);e.dispatch(e.state.tr.setMeta(ft,{setDragging:{startX:t.clientX,startWidth:a}}));function c(f){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);let d=ft.getState(e.state);d?.dragging&&(Dx(e,d.activeHandle,fm(d.dragging,f,n)),e.dispatch(e.state.tr.setMeta(ft,{setDragging:null})))}function u(f){if(!f.which)return c(f);let d=ft.getState(e.state);if(d&&d.dragging){let p=fm(d.dragging,f,n);pm(e,d.activeHandle,p,r)}}return pm(e,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),t.preventDefault(),!0}function Nx(e,t,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=e.domAtPos(t),s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(s-=r[a],l--);return s/l}function Rx(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function dm(e,t,n,r){let o=n=="right"?-r:r,i=e.posAtCoords({left:t.clientX+o,top:t.clientY});if(!i)return-1;let{pos:s}=i,l=nn(e.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;let a=ke.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function fm(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Dm(e,t){e.dispatch(e.state.tr.setMeta(ft,{setHandle:t}))}function Dx(e,t,n){let r=e.state.doc.resolve(t),o=r.node(-1),i=ke.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;let f=i.map[u],d=o.nodeAt(f).attrs,p=d.colspan==1?0:l-i.colCount(f);if(d.colwidth&&d.colwidth[p]==n)continue;let h=d.colwidth?d.colwidth.slice():Ox(d.colspan);h[p]=n,a.setNodeMarkup(s+f,null,{...d,colwidth:h})}a.docChanged&&e.dispatch(a)}function pm(e,t,n,r){let o=e.state.doc.resolve(t),i=o.node(-1),s=o.start(-1),l=ke.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=e.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&oc(i,a.firstChild,a,r,l,n)}function Ox(e){return Array(e).fill(0)}function Lx(e,t){let n=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return de.empty;let i=ke.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){let u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;let f=i.map[u],d=s+f+o.nodeAt(f).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((a=ft.getState(e))===null||a===void 0)&&a.dragging&&n.push($e.node(s+f,s+f+o.nodeAt(f).nodeSize,{class:"column-resize-dragging"})),n.push($e.widget(d,p))}}return de.create(e.doc,n)}function Om({allowTableNodeSelection:e=!1}={}){return new U({key:xn,state:{init(){return null},apply(t,n){let r=t.getMeta(xn);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;let{deleted:o,pos:i}=t.mapping.mapResult(n);return o?null:i}},props:{decorations:rx,handleDOMEvents:{mousedown:xx},createSelectionBetween(t){return xn.getState(t.state)!=null?t.state.selection:null},handleTripleClick:vx,handleKeyDown:kx,handlePaste:Cx},appendTransaction(t,n,r){return sx(r,sc(r,n),e)}})}var Ao=he(Kt(),1);Go(`.editor-toolbar-panel{position:fixed;inset:auto;margin:0;box-sizing:border-box;width:280px;max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px);overflow:auto;padding:14px;border:1px solid var(--line, #e8e8eb);border-radius:12px;background:var(--paper, white);color:var(--text, #343a35);font:12px/1.4 var(--font-ui, system-ui, sans-serif);box-shadow:0 8px 32px #25233520}.editor-toolbar-panel .editor-modal{width:100%;padding:0;border:0;box-shadow:none;animation:none}.editor-toolbar-panel .editor-modal-heading{gap:8px}.editor-toolbar-panel .editor-modal-symbol{display:none}.editor-toolbar-panel .editor-modal-heading h3{font-size:14px}.editor-toolbar-panel .editor-modal-actions{margin-top:12px}@media print{.editor-toolbar-panel{display:none!important}}
|
|
97
|
+
`);var Lm=he(Ue(),1);function Xi({children:e,className:t="",onDismiss:n}){let r=(0,Ao.useRef)(null),o=(0,Ao.useRef)(n);return o.current=n,(0,Ao.useLayoutEffect)(()=>{let i=r.current,s=i.parentElement?.closest(".editor-bubble, .editor-toolbar");if(!s)return;let l=()=>{let f=s.getBoundingClientRect(),{width:d,height:p}=i.getBoundingClientRect();i.style.left=`${Math.max(8,Math.min(f.left+(f.width-d)/2,innerWidth-d-8))}px`;let h=f.top-p-8;i.style.top=`${Math.max(8,Math.min(h>=8?h:f.bottom+8,innerHeight-p-8))}px`};i.showPopover(),l();let a=new ResizeObserver(l);a.observe(i),a.observe(s);let c=new MutationObserver(l);c.observe(s,{attributes:!0,attributeFilter:["style"]});let u=f=>{f.target instanceof Node&&!i.contains(f.target)&&o.current()};return document.addEventListener("pointerdown",u),window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{a.disconnect(),c.disconnect(),document.removeEventListener("pointerdown",u),window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0),i.matches(":popover-open")&&i.hidePopover()}},[]),(0,Lm.jsx)("div",{ref:r,popover:"manual",className:`editor-toolbar-panel ${t}`,onKeyDown:i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),o.current())},children:e})}var tr="showaiTableAction";function Pm(e,t,n){let r=e.doc.nodeAt(t);if(r?.type.name!=="table")return null;let o=e.selection instanceof ie?e.selection.$headCell:nn(e.selection.$head),i=o&&o.before(-1)===t?o:e.doc.resolve(t+1+ke.get(r).map[0]),s=n==="row"?ie.rowSelection(i):n==="column"?ie.colSelection(i):new ie(i);return e.tr.setSelection(s)}function To(e){let t=e.selection;if(!(t instanceof ie))return null;let n=t.$anchorCell.node(-1),r=t.$anchorCell.start(-1),o=ke.get(n).rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r);return{tablePosition:r-1,rows:o.bottom-o.top,columns:o.right-o.left}}function Im(e,t){let n=t.$anchorCell.nodeAfter?.attrs.id,r=t.$headCell.nodeAfter?.attrs.id;if(!n||!r)return null;let o,i;if(e.descendants((a,c)=>{["tableCell","tableHeader"].includes(a.type.name)&&(a.attrs.id===n&&(o=c),a.attrs.id===r&&(i=c))}),o===void 0&&i===void 0||(o??=i,i??=o,o===void 0||i===void 0))return null;let s=e.resolve(o),l=e.resolve(i);return s.node(-1)!==l.node(-1)?null:new ie(s,l)}var pt=he(Ue(),1);function Yi({editor:e,context:t=!1,onAction:n}){let r=Pe(Fe),o=To(e.state);if(!o&&!t&&!e.can().splitCell())return null;let i=s=>{e.view.dispatch(Ar(e.state.tr)),e.chain().setMeta(tr,!0).focus()[s]().run(),n?.()};return(0,pt.jsxs)(pt.Fragment,{children:[!t&&(0,pt.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,pt.jsxs)("div",{className:"editor-table-actions",role:"group","aria-label":r("table.cellActions"),children:[o&&(0,pt.jsx)("span",{className:"editor-menu-status",role:"status",children:o.rows===1&&o.columns===1?r("table.shiftClickHint"):r("table.selectedCells",{rows:o.rows,columns:o.columns})}),[["mergeCells",r("table.mergeCells"),cd],["splitCell",r("table.splitCell"),ud]].map(([s,l,a])=>(0,pt.jsxs)("button",{type:"button",className:"editor-tool",role:t?"menuitem":void 0,"aria-label":l,title:l,disabled:!e.can()[s](),onMouseDown:c=>c.preventDefault(),onClick:()=>i(s),children:[(0,pt.jsx)(a,{size:16}),t&&(0,pt.jsx)("span",{children:l})]},s)),!t&&o&&(0,pt.jsx)("button",{type:"button",className:"editor-tool","aria-label":r("table.clearSelection"),title:r("table.clearSelection"),onMouseDown:s=>s.preventDefault(),onClick:()=>{e.view.dispatch(e.state.tr.setSelection(P.near(e.state.selection.$from))),e.view.focus()},children:(0,pt.jsx)(ei,{size:16})})]})]})}var No=he(Kt(),1),Vm=he(yl(),1);var Qi=he(Ue(),1),Px=[["left","Left",Pn],["center","Center",On],["right","Right",Ln]];function uc({scope:e,value:t,onChange:n}){let r=Pe(xd),o=i=>e==="table"?r(`align.table${i}`):typeof e=="number"?r(`align.column${i}`,{column:e+1}):r(`align.scope${i}`,{scope:e});return(0,Qi.jsx)("div",{className:"table-alignment-buttons",role:"group","aria-label":o("Group"),children:Px.map(([i,s,l])=>(0,Qi.jsx)("button",{type:"button","aria-label":o(s),title:o(s),"aria-pressed":t===i,onMouseDown:a=>a.preventDefault(),onClick:a=>{a.stopPropagation(),n(i)},children:(0,Qi.jsx)(l,{size:14})},i))})}var $m=kr(Fe),Bm=le.create({name:"tableAlignment",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textAlign:{default:null,parseHTML:e=>["left","center","right"].includes(e.style.textAlign)?e.style.textAlign:null,renderHTML:e=>["left","center","right"].includes(String(e.textAlign))?{style:`text-align: ${e.textAlign}`}:{}}}}]},addProseMirrorPlugins(){let e=this.editor;return[new U({appendTransaction(t,n,r){if(!e.isEditable||!t.some(i=>i.docChanged))return null;let o=r.tr;return r.doc.descendants((i,s)=>{if(i.type.name!=="table")return;let l=ke.get(i),a=Array.from({length:l.width},(c,u)=>{let f=new Set(Array.from({length:l.height},(d,p)=>i.nodeAt(l.map[p*l.width+u])?.attrs.textAlign).filter(Boolean));return f.size===1?[...f][0]:i.attrs.textAlign});Ix(i,s,(c,u)=>{if(c.attrs.textAlign)return;let f=l.findCell(u-s-1),d=new Set(a.slice(f.left,f.right)),p=d.size===1?[...d][0]:i.attrs.textAlign;p&&o.setNodeAttribute(u,"textAlign",p)})}),o.docChanged?o.setMeta("addToHistory",!1):null}})]}});function Ix(e,t,n){e.forEach((r,o)=>r.forEach((i,s)=>n(i,t+2+o+s)))}function dc(e,t){let r=zm(e,t).map(o=>e.nodeAt(o)?.attrs.textAlign??e.attrs.textAlign??"left");return r.every(o=>o===r[0])?r[0]??"left":null}function zm(e,t){let n=ke.get(e);if(t!==null&&(!Number.isInteger(t)||t<0||t>=n.width))throw new Error($m("table.columnOutOfRange"));return[...new Set(t===null?n.map:Array.from({length:n.height},(r,o)=>n.map[o*n.width+t]))]}function Hm(e,t,n,r){let o=e.doc.nodeAt(t);if(!o||o.type.name!=="table")throw new Error($m("table.notATable"));let i=e.tr;n===null&&i.setNodeAttribute(t,"textAlign",r);for(let s of zm(o,n)){let l=t+1+s,a=e.doc.nodeAt(l);i.setNodeAttribute(l,"textAlign",r),a.descendants((c,u)=>{if(c.type.name==="table")return!1;["paragraph","heading"].includes(c.type.name)&&c.attrs.textAlign&&i.setNodeAttribute(l+1+u,"textAlign",null)})}return i}var rn=he(Kt(),1),$x=()=>!0;function _m(e,t={}){let n=(0,rn.useId)(),[r,o]=(0,rn.useState)(null),[,i]=(0,rn.useState)(0),s=(0,rn.useRef)({target:r,options:t});s.current={target:r,options:t};let l=t.accept??$x;return(0,rn.useEffect)(()=>{if(!e)return;let a,c=()=>{clearTimeout(a),a=void 0},u=A=>A?.closest("[data-table-controls-owner]")?.getAttribute("data-table-controls-owner")===n,f=()=>{c(),o(null),s.current.options.onDismiss?.()},d=()=>{a||s.current.options.keepOpen||s.current.target?.context||u(document.activeElement)||(a=setTimeout(f,220))},p=A=>{let S=A.closest("table");if(!(S instanceof HTMLTableElement)||!e.contains(S)||!l(S))return null;let L=A.closest("td, th");return{table:S,cell:L?.parentElement===S.rows[0]?L:null,context:null}},h=A=>{c(),o(S=>S?.table===A.table&&S.cell===A.cell&&!S.context?S:A)},g=A=>{let S=A.target;if(u(S)){c();return}if(s.current.options.keepOpen||s.current.target?.context){c();return}let L=s.current.target;if(L?.cell?.isConnected){let G=L.cell.getBoundingClientRect(),fe=fc(L,0).column;if(A.clientX>=Math.min(G.left,fe.left)&&A.clientX<=Math.max(G.right,fe.left+88)&&A.clientY>=G.bottom&&A.clientY<=fe.top){c();return}}let X=p(S);if(X){h(X);return}if(L?.table.isConnected){let G=L.table.getBoundingClientRect();if(A.clientX>=G.left-8&&A.clientX<=G.right+8&&A.clientY>=G.top-44&&A.clientY<=G.bottom+8){c();return}}d()},m=A=>{let S=A.target;if(u(S)){c();return}let L=p(S);L?(s.current.options.onDismiss?.(),h(L)):f()},w=A=>{let S=p(A.target);S&&(A.preventDefault(),A.stopPropagation(),c(),s.current.options.onDismiss?.(),o({...S,cell:null,context:{left:Math.max(8,Math.min(A.clientX,window.innerWidth-140)),top:Math.max(8,Math.min(A.clientY,window.innerHeight-42))}}))},k=A=>{if(u(A.target))c();else{let S=p(A.target);S&&h(S)}},x=A=>{A.key==="Escape"&&f()},E=A=>{A.target instanceof HTMLElement&&A.target.contains(e)&&f()},M=()=>{s.current.target&&i(A=>A+1)};return document.addEventListener("pointermove",g),document.addEventListener("pointerdown",m),document.addEventListener("focusin",k),document.addEventListener("keydown",x),e.addEventListener("contextmenu",w),window.addEventListener("blur",f),window.addEventListener("showai:viewport-change",E),window.addEventListener("scroll",M,{capture:!0,passive:!0}),window.addEventListener("resize",M),()=>{c(),document.removeEventListener("pointermove",g),document.removeEventListener("pointerdown",m),document.removeEventListener("focusin",k),document.removeEventListener("keydown",x),e.removeEventListener("contextmenu",w),window.removeEventListener("blur",f),window.removeEventListener("showai:viewport-change",E),window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M)}},[e,l,n]),{target:r,setTarget:o,owner:n}}function fc(e,t){let n=e.table.getBoundingClientRect(),r=e.table.closest(".tableWrapper, .sb-table-scroll")?.getBoundingClientRect(),o=Math.min(n.right,r?.right??n.right,window.innerWidth-8),i=Math.max(8,o-t),s=Math.max(8,n.top-36),l=e.cell?.getBoundingClientRect(),a=l?(l.left+l.right-88)/2:i;return{global:e.context??{left:Math.max(t+8,o),top:s,transform:"translateX(-100%)"},column:{left:Math.max(8,Math.min(a,o-88)),top:l?l.bottom+4:s}}}var be=he(Ue(),1),Bx=e=>!e.closest(".document-widget");function jm({editor:e}){let t=Pe(Fe),[,n]=(0,No.useState)(0),[r,o]=(0,No.useState)(!1),i=To(e.state),{target:s,setTarget:l,owner:a}=_m(e.view.dom,{keepOpen:r,accept:Bx,onDismiss:()=>o(!1)});if((0,No.useEffect)(()=>{let M=()=>n(S=>S+1),A=S=>{S.key!=="Escape"||!To(e.state)||!e.view.hasFocus()&&document.activeElement?.closest("[data-table-controls-owner]")?.getAttribute("data-table-controls-owner")!==a||(e.view.dispatch(e.state.tr.setSelection(P.near(e.state.selection.$from))),o(!1),e.view.focus())};return e.on("transaction",M),document.addEventListener("keydown",A),()=>{e.off("transaction",M),document.removeEventListener("keydown",A)}},[e,a]),!s||!s.table.isConnected||!e.isEditable||!s.context&&(i||e.isFocused&&e.state.selection instanceof P&&!e.state.selection.empty))return null;let c=e.state.doc.resolve(e.view.posAtDOM(s.table,0)),u=c.depth;for(;u>0&&c.node(u).type.name!=="table";)u--;if(!u)return null;let f=c.node(u),d=c.before(u),p=null;if(s.cell?.isConnected){let M=e.view.posAtDOM(s.cell,0),A=e.state.doc.resolve(M),S=A.depth;for(;S>u&&!["tableCell","tableHeader"].includes(A.node(S).type.name);)S--;S>u&&(p=ke.get(f).findCell(A.before(S)-d-1).left)}let h=fc(s,128),g=h.global.top>window.innerHeight/2,m=()=>{let{$from:M}=e.state.selection;Array.from({length:M.depth},(S,L)=>L+1).some(S=>M.node(S).type.name==="table"&&M.before(S)===d)||e.view.dispatch(e.state.tr.setSelection(P.near(e.state.doc.resolve(d+3))))},w=M=>{m(),e.view.dispatch(Ar(e.state.tr)),M(),o(!1)},k=()=>e.chain().setMeta(tr,!0).focus(),x=M=>w(()=>{let A=Pm(e.state,d,M);A&&e.view.dispatch(A),e.view.focus()}),E=(M,A)=>{e.view.dispatch(Hm(e.state,d,M,A).setMeta(tr,!0)),s.context&&(l(null),e.view.focus())};return(0,Vm.createPortal)((0,be.jsxs)(be.Fragment,{children:[(0,be.jsxs)("div",{className:"document-table-controls table-global-alignment","data-editor-menu-trigger":s.context?"context":"hover",role:s.context?"dialog":void 0,"aria-label":t("table.alignment"),"data-table-controls-owner":a,style:h.global,children:[(0,be.jsx)(uc,{scope:"table",value:dc(f,null),onChange:M=>E(null,M)}),!s.context&&(0,be.jsx)("button",{className:"document-table-menu-trigger",type:"button","aria-label":t("table.actions"),title:t("table.actions"),"aria-expanded":r,"aria-haspopup":"menu",onMouseDown:M=>M.preventDefault(),onClick:()=>{m(),o(!r)},children:(0,be.jsx)(Wu,{size:16})}),(r||s.context)&&(0,be.jsxs)("div",{className:"document-table-menu",role:"menu","aria-label":t("table.actionsMenu"),style:{...g?{top:"auto",bottom:"calc(100% + 4px)"}:{},maxHeight:Math.max(120,g?h.global.top-12:window.innerHeight-h.global.top-46),overflowY:"auto"},onMouseDown:M=>M.preventDefault(),children:[(0,be.jsxs)("button",{role:"menuitem",onClick:()=>w(()=>{k().addRowAfter().run()}),children:[(0,be.jsx)(Ut,{size:14}),t("table.addRow")]}),(0,be.jsxs)("button",{role:"menuitem",onClick:()=>w(()=>{k().addColumnAfter().run()}),children:[(0,be.jsx)(Ut,{size:14}),t("table.addColumn")]}),(0,be.jsxs)("button",{role:"menuitem",onClick:()=>w(()=>{k().toggleHeaderRow().run()}),children:[(0,be.jsx)(dd,{size:14,"aria-hidden":"true"}),t("table.toggleHeader")]}),(0,be.jsxs)("button",{role:"menuitem",onClick:()=>x("cell"),children:[(0,be.jsx)(ld,{size:14,"aria-hidden":"true"}),t("table.selectCells")]}),(0,be.jsxs)("button",{role:"menuitem",onClick:()=>x("row"),children:[(0,be.jsx)(bl,{size:14,"aria-hidden":"true"}),t("table.selectRow")]}),(0,be.jsxs)("button",{role:"menuitem",onClick:()=>x("column"),children:[(0,be.jsx)(gl,{size:14,"aria-hidden":"true"}),t("table.selectColumn")]}),s.context&&(0,be.jsx)(Yi,{editor:e,context:!0,onAction:()=>{l(null),o(!1)}}),(0,be.jsxs)("button",{role:"menuitem",onClick:()=>w(()=>{k().deleteRow().run()}),children:[(0,be.jsx)(bl,{size:14,"aria-hidden":"true"}),t("table.deleteRow")]}),(0,be.jsxs)("button",{role:"menuitem",onClick:()=>w(()=>{k().deleteColumn().run()}),children:[(0,be.jsx)(gl,{size:14,"aria-hidden":"true"}),t("table.deleteColumn")]}),(0,be.jsxs)("button",{role:"menuitem",className:"danger",onClick:()=>w(()=>{k().deleteTable().run(),l(null)}),children:[(0,be.jsx)(Qo,{size:14}),t("table.deleteTable")]})]})]}),p!==null&&!s.context&&(0,be.jsx)("div",{className:"document-table-controls table-column-alignment","data-table-controls-owner":a,style:h.column,children:(0,be.jsx)(uc,{scope:p,value:dc(f,p),onChange:M=>E(p,M)})})]}),document.body)}var Ht=he(Kt(),1);Go(`.rich-format-controls{display:contents}.rich-format-group{display:inline-flex;align-items:center;flex:0 0 auto;gap:1px}.rich-format-divider{width:1px;height:18px;margin:0 5px;flex-shrink:0;background:var(--line, #e8e8eb)}.rich-format-select{position:relative;display:inline-flex;align-items:center;height:32px;border-radius:6px;color:var(--text, #343a35)}.rich-format-alignment>svg:last-child{position:absolute;inset-inline-end:8px;pointer-events:none;color:var(--muted, #777)}.rich-format-select select{appearance:none;width:100%;height:32px;padding:0 21px 0 8px;border:0;border-radius:inherit;background:transparent;color:inherit;font:12px/1.2 var(--font-ui, system-ui, sans-serif);cursor:pointer}.rich-format-block{width:70px}.rich-format-font{width:76px}.rich-format-size{width:58px}.rich-format-alignment{width:41px}.rich-format-alignment>svg:first-child{margin-left:6px}.rich-format-alignment select{position:absolute;inset:0;opacity:0}.rich-format-select:hover,.rich-format-colors-toggle:hover{background:var(--hover, #f5f5f7)}.rich-format-alignment:has(select:focus-visible){box-shadow:inset 0 -2px var(--dialog-accent, #120a8f)}.rich-format-colors-toggle{display:inline-flex;align-items:center;justify-content:center;gap:5px;width:43px;height:32px;padding:0;border:0;border-radius:6px;background:transparent;color:var(--text, #343a35);cursor:pointer}.rich-format-colors-toggle.is-active{background:var(--accent-soft, #eeedf9);color:var(--accent, #6c805f)}.rich-format-color-icon{display:inline-flex;flex-direction:column;align-items:center;gap:2px}.rich-format-color-icon i{width:16px;height:3px;border-radius:2px}.rich-text-selection-toolbar.editor-bubble{--editor-soft: var(--accent-soft, #eeedf9);gap:2px;width:max-content;box-sizing:border-box;max-width:calc(100vw - 24px);padding:6px;flex-wrap:wrap;overflow:visible;border:1px solid var(--line, #e8e8eb);border-radius:12px;box-shadow:0 4px 12px #25233508,0 12px 36px #25233514}.rich-text-selection-toolbar .rich-format-group{flex-shrink:1;flex-wrap:wrap;min-width:0;max-width:100%}.rich-text-selection-toolbar .editor-tool,.editor-toolbar .rich-format-group .editor-tool{width:30px;height:32px;border-radius:6px;color:var(--text, #343a35);cursor:pointer}.rich-text-selection-toolbar .editor-tool:hover,.rich-text-selection-toolbar .editor-tool.is-active{color:var(--accent, #6c805f);background:var(--editor-soft)}.rich-text-selection-toolbar .toolbar-divider{margin:0 5px;height:18px}.rich-text-selection-toolbar .editor-bubble-assistant{display:inline-flex;align-items:center;justify-content:center;gap:5px;height:30px;padding:0 10px;border:1px solid color-mix(in srgb,var(--accent, #6c805f) 12%,transparent);border-radius:7px;background:var(--accent-soft, #eeedf9);color:var(--accent, #6c805f);font:500 12px/1.2 var(--font-ui, system-ui, sans-serif);cursor:pointer}.rich-text-selection-toolbar .editor-bubble-reference{color:var(--accent, #6c805f)}.rich-text-selection-toolbar .editor-bubble-assistant:hover{background:color-mix(in srgb,var(--accent, #6c805f) 15%,var(--paper, white))}.rich-text-selection-toolbar :is(button,input):focus-visible,.rich-format-color-panel :is(button,input):focus-visible{outline:2px solid var(--accent, #6c805f);outline-offset:2px}.editor-toolbar:has(.rich-format-controls){flex-wrap:wrap}.editor-toolbar-panel.rich-format-color-panel{width:140px;padding:12px}.rich-format-swatches{display:grid;grid-template-columns:repeat(3,24px);justify-content:space-between;gap:10px}.rich-format-swatch,.rich-format-custom-color{position:relative;width:24px;height:24px;padding:0;border:1px solid #0000000a;border-radius:50%;cursor:pointer}.rich-format-swatch:hover{transform:scale(1.12)}.rich-format-swatch.is-active{outline:2px solid var(--accent, #6c805f);outline-offset:2px;box-shadow:inset 0 0 0 2px var(--paper, white)}.rich-format-custom-color{overflow:hidden;border-color:var(--line, #ddd)}.rich-format-custom-color input{width:100%;height:100%;padding:0;border:0;background:none;cursor:pointer}.rich-format-custom-color input::-webkit-color-swatch-wrapper{padding:3px}.rich-format-custom-color input::-webkit-color-swatch{border:0;border-radius:50%}.rich-format-highlight-modes{display:flex;flex-direction:column;gap:4px;margin-top:12px}.rich-format-highlight-modes button{display:inline-flex;align-items:center;gap:6px;padding:5px 7px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--muted, #777);font:11px/1.2 var(--font-ui, system-ui, sans-serif);white-space:nowrap;cursor:pointer}.rich-format-highlight-modes button[aria-pressed=true]{border-color:var(--line, #e8e8eb);background:var(--hover, #f5f5f7);color:var(--text, #343a35)}.rich-format-highlight-preview{color:#343a35;font:600 12px/1.3 Georgia,serif;background:linear-gradient(transparent 52%,var(--highlight-preview) 52%)}.rich-format-highlight-preview.is-full{background:var(--highlight-preview)}@media(max-width:740px){.rich-text-selection-toolbar .rich-format-divider,.rich-text-selection-toolbar .toolbar-divider{margin-inline:2px}}.rich-format-clear-highlight{margin-top:12px;padding:0;border:0;background:transparent;color:var(--muted, #777);font:inherit;cursor:pointer}.rich-format-clear-highlight:disabled{opacity:.4;cursor:default}.rich-text-selection-toolbar .editor-bubble-insert{display:inline-flex;align-items:center;gap:4px;height:30px;padding:0 8px;border-radius:7px;color:var(--editor-muted, #6b6b6b);font:500 12px/1.2 var(--font-ui, system-ui, sans-serif);cursor:pointer}.rich-text-selection-toolbar .editor-bubble-insert:hover{background:var(--editor-soft);color:var(--accent, #6c805f)}
|
|
98
|
+
`);var V=he(Ue(),1),zx=["#292733","#787774","#a85b3c","#c44343","#bd861e","#448361","#3979bf","#8864b4"],Hx=["#e8eed0","#f9e7a0","#f8d8bb","#f4cfd2","#e9d8f1","#d3e5f7","#cde9df","#e5e5e5"];function Fm({editor:e,onLink:t,onNote:n}){let r=Pe(Fe),o=Pe(ai),[i,s]=(0,Ht.useState)(null),l=(0,Ht.useRef)(null),a=(0,Ht.useRef)(null),c=(0,Ht.useRef)(null),u=(0,Ht.useId)(),f=e.getAttributes("textStyle").color??"#292733",d=e.getAttributes("highlight").color??"#e8eed0",p=e.getAttributes("highlight").mode??"lower",h=e.getAttributes(e.isActive("heading")?"heading":"paragraph").textAlign??"left",g=h==="center"?On:h==="right"?Ln:h==="justify"?fd:Pn;(0,Ht.useEffect)(()=>{if(!i)return;let k=()=>s(null),x=M=>{M.target instanceof Node&&!l.current?.contains(M.target)&&k()},E=M=>{M.key==="Escape"&&(M.preventDefault(),M.stopPropagation(),k(),(i==="highlight"?c:a).current?.focus())};return document.addEventListener("keydown",E,!0),document.addEventListener("pointerdown",x),e.on("selectionUpdate",k),()=>{document.removeEventListener("keydown",E,!0),document.removeEventListener("pointerdown",x),e.off("selectionUpdate",k)}},[i,e]);let m=(k,x,E,M)=>(0,V.jsx)("button",{type:"button",className:`editor-tool${E?" is-active":""}`,"aria-label":k,title:k,"aria-pressed":E,onMouseDown:A=>A.preventDefault(),onClick:M,children:x}),w=(k,x,E="")=>(0,V.jsxs)("label",{className:`rich-format-select ${E}`,title:k,children:[x,E==="rich-format-alignment"&&(0,V.jsx)(gr,{size:11,"aria-hidden":"true"})]});return(0,V.jsxs)("div",{ref:l,className:"rich-format-controls",onKeyDown:k=>{i&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),s(null),(i==="highlight"?c:a).current?.focus())},onClickCapture:k=>{k.target.closest(".rich-format-colors-toggle, .rich-format-color-panel")||s(null)},children:[(0,V.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":r("format.textStyle"),children:[w(r("format.textStyle"),(0,V.jsxs)("select",{className:"showai-select","aria-label":r("format.textStyle"),value:e.isActive("heading")?String(e.getAttributes("heading").level):"paragraph",onChange:k=>k.target.value==="paragraph"?e.chain().focus().setParagraph().run():e.chain().focus().setHeading({level:Number(k.target.value)}).run(),children:[(0,V.jsx)("option",{value:"paragraph",children:r("block.text")}),[1,2,3,4,5,6].map(k=>(0,V.jsx)("option",{value:k,children:r("block.heading",{level:k})},k))]}),"rich-format-block"),w(r("format.font"),(0,V.jsxs)("select",{className:"showai-select","aria-label":r("format.font"),value:e.getAttributes("textStyle").fontFamily??"",onChange:k=>e.chain().focus().setMark("textStyle",{fontFamily:k.target.value||null}).run(),children:[(0,V.jsx)("option",{value:"",children:r("format.fontCompact")}),(0,V.jsx)("option",{value:"sans-serif",children:r("format.fontSans")}),(0,V.jsx)("option",{value:"serif",children:r("format.fontSerif")}),(0,V.jsx)("option",{value:"monospace",children:r("format.fontMono")})]}),"rich-format-font"),w(r("format.fontSize"),(0,V.jsxs)("select",{className:"showai-select","aria-label":r("format.fontSize"),value:e.getAttributes("textStyle").fontSize??"",onChange:k=>e.chain().focus().setMark("textStyle",{fontSize:k.target.value||null}).run(),children:[(0,V.jsx)("option",{value:"",children:r("format.sizeCompact")}),[12,14,16,18,20,24,28,32,40,48].map(k=>(0,V.jsx)("option",{value:`${k}px`,children:k},k))]}),"rich-format-size")]}),(0,V.jsx)("span",{className:"rich-format-divider","aria-hidden":"true"}),(0,V.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":r("format.characterStyle"),children:[m(r("format.bold"),(0,V.jsx)(zu,{size:16}),e.isActive("bold"),()=>e.chain().focus().toggleBold().run()),m(r("format.italic"),(0,V.jsx)(td,{size:16}),e.isActive("italic"),()=>e.chain().focus().toggleItalic().run()),m(r("format.underline"),(0,V.jsx)(pd,{size:16}),e.isActive("underline"),()=>e.chain().focus().toggleUnderline().run()),m(r("format.strike"),(0,V.jsx)(ad,{size:16}),e.isActive("strike"),()=>e.chain().focus().toggleStrike().run()),m(r("format.inlineCode"),(0,V.jsx)(Vu,{size:16}),e.isActive("code"),()=>e.chain().focus().toggleCode().run())]}),(0,V.jsx)("span",{className:"rich-format-divider","aria-hidden":"true"}),(0,V.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":r("format.colors"),children:[(0,V.jsxs)("button",{ref:a,type:"button",className:`rich-format-colors-toggle${i==="text"?" is-active":""}`,"aria-label":r("format.textColor"),title:r("format.textColor"),"aria-expanded":i==="text","aria-controls":i==="text"?u:void 0,onMouseDown:k=>k.preventDefault(),onPointerDown:k=>k.stopPropagation(),onClick:()=>s(i==="text"?null:"text"),children:[(0,V.jsxs)("span",{className:"rich-format-color-icon",children:[(0,V.jsx)(Zo,{size:16}),(0,V.jsx)("i",{style:{background:f}})]}),(0,V.jsx)(gr,{size:11})]}),(0,V.jsxs)("button",{ref:c,type:"button",className:`rich-format-colors-toggle${i==="highlight"?" is-active":""}`,"aria-label":r("format.highlightColor"),title:r("format.highlightColor"),"aria-expanded":i==="highlight","aria-controls":i==="highlight"?u:void 0,onMouseDown:k=>k.preventDefault(),onPointerDown:k=>k.stopPropagation(),onClick:()=>s(i==="highlight"?null:"highlight"),children:[(0,V.jsxs)("span",{className:"rich-format-color-icon",children:[(0,V.jsx)(ed,{size:16}),(0,V.jsx)("i",{style:{background:d}})]}),(0,V.jsx)(gr,{size:11})]})]}),(0,V.jsx)("span",{className:"rich-format-divider","aria-hidden":"true"}),(0,V.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":r("format.alignment"),children:[w(r("format.alignment"),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(g,{size:16,"aria-hidden":"true"}),(0,V.jsxs)("select",{className:"showai-select","aria-label":r("format.alignment"),value:h,onChange:k=>e.chain().focus().setTextAlign(k.target.value).run(),children:[(0,V.jsx)("option",{value:"left",children:r("format.alignLeft")}),(0,V.jsx)("option",{value:"center",children:r("format.alignCenter")}),(0,V.jsx)("option",{value:"right",children:r("format.alignRight")}),(0,V.jsx)("option",{value:"justify",children:r("format.alignJustify")})]})]}),"rich-format-alignment"),m(r("format.addLink"),(0,V.jsx)(to,{size:16}),e.isActive("link"),t),n&&m(o("format.note"),(0,V.jsx)(rd,{size:16}),e.isActive("annotation")||/^\s*\\note\b/.test(String(e.state.selection.$from.nodeAfter?.attrs.latex??"")),n)]}),i&&(0,V.jsx)(Xi,{className:"rich-format-color-panel",onDismiss:()=>s(null),children:(0,V.jsx)("div",{id:u,role:"group","aria-label":r(i==="text"?"format.textColor":"format.highlightColor"),children:[i].map(k=>{let x=k==="text",E=x?f:d,M=r(x?"format.textColor":"format.highlightColor"),A=S=>x?e.chain().focus().setMark("textStyle",{color:S}).run():e.chain().focus().setMark("highlight",{color:S,mode:p}).run();return(0,V.jsxs)("div",{className:"rich-format-palette",children:[(0,V.jsxs)("div",{className:"rich-format-swatches",children:[(x?zx:Hx).map(S=>(0,V.jsx)("button",{type:"button",className:`rich-format-swatch${E===S?" is-active":""}`,style:{background:S},"aria-label":`${M} ${S}`,title:S,"aria-pressed":E===S,onMouseDown:L=>L.preventDefault(),onClick:()=>A(S)},S)),(0,V.jsx)("label",{className:"rich-format-custom-color",title:r("format.customColor"),children:(0,V.jsx)("input",{type:"color","aria-label":M,value:E,onChange:S=>A(S.target.value)})})]}),!x&&(0,V.jsx)("button",{type:"button",className:"rich-format-clear-highlight",disabled:!e.isActive("highlight"),onMouseDown:S=>S.preventDefault(),onClick:()=>e.chain().focus().unsetHighlight().run(),children:r("format.removeHighlight")}),!x&&(0,V.jsx)("div",{className:"rich-format-highlight-modes",role:"group","aria-label":r("format.highlightMode"),children:["lower","full"].map(S=>(0,V.jsxs)("button",{type:"button","aria-pressed":p===S,onMouseDown:L=>L.preventDefault(),onClick:()=>e.chain().focus().setMark("highlight",{color:d,mode:S}).run(),children:[(0,V.jsx)("span",{className:`rich-format-highlight-preview is-${S}`,style:{"--highlight-preview":d},children:"Aa"}),r(S==="lower"?"format.highlightLower":"format.highlightFull")]},S))})]},k)})})},i)]})}var Wm=new WeakSet,Km=new WeakSet;function nr(e){let t=e;return Wm.add(t),t}function pc(e){return Array.isArray(e)&&Wm.has(e)}function Um(e){return e.flatMap(t=>t==null?[]:Array.isArray(t)&&Km.has(t)&&!pc(t)?Um(t):[t])}function _x(e,t){if(e==="slot")return 0;if(e instanceof Function){let o=e(t);return Array.isArray(o)&&!pc(o)&&!Km.has(o)?nr(o):o}let{children:n,...r}=t??{};if(e==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(pc(n))return nr([e,r,n]);if(n.length===0)return nr([e,r]);let o=Um(n);return o.length===0?nr([e,r]):nr([e,r,...o])}return n!=null?nr([e,r,n]):nr([e,r])}var Wr=(e,t)=>_x(e,t);var Vx=(e,t)=>{var n;let{state:r}=e,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0)return!1;let s=i.depth-1;if(s<0)return!1;let l=i.node(s),a=i.index(s);if(a===0)return!1;if(l.type===t)return e.commands.lift(t.name);let c=l.child(a-1);if(c.type!==t||!(!((n=c.lastChild)===null||n===void 0)&&n.isTextblock))return!1;let u=i.before()-1-1;return e.commands.command(({tr:f,dispatch:d})=>{if(!d)return!0;let p=i.parent.content,h=new ue(p,0,0);return f.replace(u,i.after(),h),f.setSelection(P.create(f.doc,u+p.size)),f.scrollIntoView(),d(f),!0})},jx=/^\s*>\s$/,qm=ee.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return Wr("blockquote",{...K(this.options.HTMLAttributes,e),children:Wr("slot",{})})},parseMarkdown:(e,t)=>{var n;let r=(n=t.parseBlockChildren)!==null&&n!==void 0?n:t.parseChildren;return t.createNode("blockquote",void 0,r(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return"";let n=">",r=[];return e.content.forEach((o,i)=>{var s,l;let a=((s=(l=t.renderChild)===null||l===void 0?void 0:l.call(t,o,i))!==null&&s!==void 0?s:t.renderChildren([o])).split(`
|
|
99
|
+
`).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(a.join(`
|
|
100
|
+
`))}),r.join(`
|
|
101
|
+
${n}
|
|
102
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>Vx(this.editor,this.type)}},addInputRules(){return[vn({find:jx,type:this.type})]}});var Fx=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Wx=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Kx=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Ux=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Gm=We.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return Wr("strong",{...K(this.options.HTMLAttributes,e),children:Wr("slot",{})})},markdownTokenName:"strong",parseMarkdown:(e,t)=>t.applyMark("bold",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[lt({find:Fx,type:this.type}),lt({find:Kx,type:this.type})]},addPasteRules(){return[nt({find:Wx,type:this.type}),nt({find:Ux,type:this.type})]}});var qx=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},Gx=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function Jx(e){let t=new Set((e.match(/`+/g)||[]).map(r=>r.length)),n=1;for(;t.has(n);)n+=1;return n}var Jm=We.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",K(this.options.HTMLAttributes,e),0]},markdownTokenName:"codespan",parseMarkdown:(e,t)=>t.applyMark("code",[{type:"text",text:e.text||""}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return"";let o=typeof(n==null||(r=n.meta)===null||r===void 0?void 0:r.markText)=="string"?n.meta.markText:"",i="`".repeat(Jx(o)),s=o.startsWith("`")||o.endsWith("`")?" ":"";return`${i}${s}${t.renderChildren(e.content)}${s}${i}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[lt({find:qx,type:this.type})]},addPasteRules(){return[nt({find:Gx,type:this.type})]}});var hc=4,Xx=/^```([a-z]+)?[\s\n]$/,Yx=/^~~~([a-z]+)?[\s\n]$/,Zi=ee.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:hc,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",K(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(e,t)=>{var n,r;return((n=e.raw)===null||n===void 0?void 0:n.startsWith("```"))===!1&&((r=e.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&e.codeBlockStyle!=="indented"?[]:t.createNode("codeBlock",{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[])},renderMarkdown:(e,t)=>{var n;let r="",o=((n=e.attrs)===null||n===void 0?void 0:n.language)||"";return e.content?r=[`\`\`\`${o}`,t.renderChildren(e.content),"```"].join(`
|
|
103
|
+
`):r=`\`\`\`${o}
|
|
104
|
+
|
|
105
|
+
\`\`\``,r},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=(t=this.options.tabSize)!==null&&t!==void 0?t:hc,{state:r}=e,{selection:o}=r,{$from:i,empty:s}=o;if(i.parent.type!==this.type)return!1;let l=" ".repeat(n);return s?e.commands.insertContent(l):e.commands.command(({tr:a})=>{let{from:c,to:u}=o,f=r.doc.textBetween(c,u,`
|
|
106
|
+
`,`
|
|
107
|
+
`).split(`
|
|
108
|
+
`).map(d=>l+d).join(`
|
|
109
|
+
`);return a.replaceWith(c,u,r.schema.text(f)),!0})},"Shift-Tab":({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=(t=this.options.tabSize)!==null&&t!==void 0?t:hc,{state:r}=e,{selection:o}=r,{$from:i,empty:s}=o;return i.parent.type!==this.type?!1:s?e.commands.command(({tr:l})=>{var a;let{pos:c}=i,u=i.start(),f=i.end(),d=r.doc.textBetween(u,f,`
|
|
110
|
+
`,`
|
|
111
|
+
`).split(`
|
|
112
|
+
`),p=0,h=0,g=c-u;for(let x=0;x<d.length;x+=1){if(h+d[x].length>=g){p=x;break}h+=d[x].length+1}let m=((a=d[p].match(/^ */))===null||a===void 0?void 0:a[0])||"",w=Math.min(m.length,n);if(w===0)return!0;let k=u;for(let x=0;x<p;x+=1)k+=d[x].length+1;return l.delete(k,k+w),c-k<=w&&l.setSelection(P.create(l.doc,k)),!0}):e.commands.command(({tr:l})=>{let{from:a,to:c}=o,u=r.doc.textBetween(a,c,`
|
|
113
|
+
`,`
|
|
114
|
+
`).split(`
|
|
115
|
+
`).map(f=>{var d;let p=((d=f.match(/^ */))===null||d===void 0?void 0:d[0])||"",h=Math.min(p.length,n);return f.slice(h)}).join(`
|
|
116
|
+
`);return l.replaceWith(a,c,r.schema.text(u)),!0})},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
|
|
117
|
+
|
|
118
|
+
`);return!i||!s?!1:e.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type||r.parentOffset!==0)return!1;let i=r.before();return i>0?!1:e.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||o.parentOffset!==o.parent.nodeSize-2)return!1;let s=o.after();return s===void 0?!1:r.nodeAt(s)?e.commands.command(({tr:l})=>(l.setSelection(Q.near(r.resolve(s))),!0)):e.commands.exitCode()}}},addInputRules(){return[Co({find:Xx,type:this.type,getAttributes:e=>({language:e[1]})}),Co({find:Yx,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new U({key:new oe("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;let{tr:s,schema:l}=e.state,a=l.text(n.replace(/\r\n?/g,`
|
|
119
|
+
`));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(P.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),e.dispatch(s),!0}}})]}});var Xm=ee.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
120
|
+
|
|
121
|
+
`):""});var Ym=ee.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",K(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
122
|
+
`},renderMarkdown:()=>`
|
|
123
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return t().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&s){let f=a.filter(d=>l.includes(d.type.name));c.ensureMarks(f)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Qm=ee.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(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,K(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var n;let r=!((n=e.attrs)===null||n===void 0)&&n.level?parseInt(e.attrs.level,10):1,o="#".repeat(r);return e.content?`${o} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Co({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var Zm=ee.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",K(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!xh(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,o=e();return Ii(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:i,tr:s,dispatch:l})=>{if(l){let{$to:a}=s.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(P.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(_.create(s.doc,a.pos)):s.setSelection(P.create(s.doc,a.pos));else{let u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,f=u?.create();f&&(s.insert(c,f),s.setSelection(P.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Bi({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Qx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Zx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,eS=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,tS=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,eg=We.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",K(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,t)=>t.applyMark("italic",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[lt({find:Qx,type:this.type}),lt({find:eS,type:this.type})]},addPasteRules(){return[nt({find:Zx,type:this.type}),nt({find:tS,type:this.type})]}});var nS="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",rS="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",vc="numeric",Cc="ascii",xc="alpha",Oo="asciinumeric",Do="alphanumeric",Sc="domain",sg="emoji",oS="scheme",iS="slashscheme",mc="whitespace";function sS(e,t){return e in t||(t[e]=[]),t[e]}function rr(e,t,n){t[vc]&&(t[Oo]=!0,t[Do]=!0),t[Cc]&&(t[Oo]=!0,t[xc]=!0),t[Oo]&&(t[Do]=!0),t[xc]&&(t[Do]=!0),t[Do]&&(t[Sc]=!0),t[sg]&&(t[Sc]=!0);for(let r in t){let o=sS(r,n);o.indexOf(e)<0&&o.push(e)}}function lS(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function at(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}at.groups={};at.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let r=0;r<t.jr.length;r++){let o=t.jr[r][0],i=t.jr[r][1];if(i&&o.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let o=0;o<e.length;o++)this.tt(e[o],t,n,r)},tr(e,t,n,r){r=r||at.groups;let o;return t&&t.j?o=t:(o=new at(t),n&&r&&rr(t,n,r)),this.jr.push([e,o]),o},ts(e,t,n,r){let o=this,i=e.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(e[s]);return o.tt(e[i-1],t,n,r)},tt(e,t,n,r){r=r||at.groups;let o=this;if(t&&t.j)return o.j[e]=t,t;let i=t,s,l=o.go(e);if(l?(s=new at,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new at,i){if(r)if(s.t&&typeof s.t=="string"){let a=Object.assign(lS(s.t,r),n);rr(i,a,r)}else n&&rr(i,n,r);s.t=i}return o.j[e]=s,s}};var Z=(e,t,n,r,o)=>e.ta(t,n,r,o),Ie=(e,t,n,r,o)=>e.tr(t,n,r,o),tg=(e,t,n,r,o)=>e.ts(t,n,r,o),R=(e,t,n,r,o)=>e.tt(t,n,r,o),ln="WORD",Ec="UWORD",lg="ASCIINUMERICAL",ag="ALPHANUMERICAL",zo="LOCALHOST",Mc="TLD",Ac="UTLD",rs="SCHEME",Kr="SLASH_SCHEME",Nc="NUM",Tc="WS",Rc="NL",Lo="OPENBRACE",Po="CLOSEBRACE",is="OPENBRACKET",ss="CLOSEBRACKET",ls="OPENPAREN",as="CLOSEPAREN",cs="OPENANGLEBRACKET",us="CLOSEANGLEBRACKET",ds="FULLWIDTHLEFTPAREN",fs="FULLWIDTHRIGHTPAREN",ps="LEFTCORNERBRACKET",hs="RIGHTCORNERBRACKET",ms="LEFTWHITECORNERBRACKET",gs="RIGHTWHITECORNERBRACKET",bs="FULLWIDTHLESSTHAN",ys="FULLWIDTHGREATERTHAN",ws="AMPERSAND",ks="APOSTROPHE",vs="ASTERISK",En="AT",Cs="BACKSLASH",xs="BACKTICK",Ss="CARET",or="COLON",Dc="COMMA",Es="DOLLAR",_t="DOT",Ms="EQUALS",Oc="EXCLAMATION",yt="HYPHEN",Io="PERCENT",As="PIPE",Ts="PLUS",Ns="POUND",$o="QUERY",Lc="QUOTE",cg="FULLWIDTHMIDDLEDOT",Pc="SEMI",Vt="SLASH",Bo="TILDE",Rs="UNDERSCORE",ug="EMOJI",Ds="SYM",dg=Object.freeze({__proto__:null,ALPHANUMERICAL:ag,AMPERSAND:ws,APOSTROPHE:ks,ASCIINUMERICAL:lg,ASTERISK:vs,AT:En,BACKSLASH:Cs,BACKTICK:xs,CARET:Ss,CLOSEANGLEBRACKET:us,CLOSEBRACE:Po,CLOSEBRACKET:ss,CLOSEPAREN:as,COLON:or,COMMA:Dc,DOLLAR:Es,DOT:_t,EMOJI:ug,EQUALS:Ms,EXCLAMATION:Oc,FULLWIDTHGREATERTHAN:ys,FULLWIDTHLEFTPAREN:ds,FULLWIDTHLESSTHAN:bs,FULLWIDTHMIDDLEDOT:cg,FULLWIDTHRIGHTPAREN:fs,HYPHEN:yt,LEFTCORNERBRACKET:ps,LEFTWHITECORNERBRACKET:ms,LOCALHOST:zo,NL:Rc,NUM:Nc,OPENANGLEBRACKET:cs,OPENBRACE:Lo,OPENBRACKET:is,OPENPAREN:ls,PERCENT:Io,PIPE:As,PLUS:Ts,POUND:Ns,QUERY:$o,QUOTE:Lc,RIGHTCORNERBRACKET:hs,RIGHTWHITECORNERBRACKET:gs,SCHEME:rs,SEMI:Pc,SLASH:Vt,SLASH_SCHEME:Kr,SYM:Ds,TILDE:Bo,TLD:Mc,UNDERSCORE:Rs,UTLD:Ac,UWORD:Ec,WORD:ln,WS:Tc}),on=/[a-z]/,Ro=/\p{L}/u,gc=/\p{Emoji}/u;var sn=/\d/,bc=/\s/;var ng="\r",yc=`
|
|
124
|
+
`,aS="\uFE0F",cS="\u200D",wc="\uFFFC",es=null,ts=null;function uS(e=[]){let t={};at.groups=t;let n=new at;es==null&&(es=rg(nS)),ts==null&&(ts=rg(rS)),R(n,"'",ks),R(n,"{",Lo),R(n,"}",Po),R(n,"[",is),R(n,"]",ss),R(n,"(",ls),R(n,")",as),R(n,"<",cs),R(n,">",us),R(n,"\uFF08",ds),R(n,"\uFF09",fs),R(n,"\u300C",ps),R(n,"\u300D",hs),R(n,"\u300E",ms),R(n,"\u300F",gs),R(n,"\uFF1C",bs),R(n,"\uFF1E",ys),R(n,"&",ws),R(n,"*",vs),R(n,"@",En),R(n,"`",xs),R(n,"^",Ss),R(n,":",or),R(n,",",Dc),R(n,"$",Es),R(n,".",_t),R(n,"=",Ms),R(n,"!",Oc),R(n,"-",yt),R(n,"%",Io),R(n,"|",As),R(n,"+",Ts),R(n,"#",Ns),R(n,"?",$o),R(n,'"',Lc),R(n,"/",Vt),R(n,";",Pc),R(n,"~",Bo),R(n,"_",Rs),R(n,"\\",Cs),R(n,"\u30FB",cg);let r=Ie(n,sn,Nc,{[vc]:!0});Ie(r,sn,r);let o=Ie(r,on,lg,{[Oo]:!0}),i=Ie(r,Ro,ag,{[Do]:!0}),s=Ie(n,on,ln,{[Cc]:!0});Ie(s,sn,o),Ie(s,on,s),Ie(o,sn,o),Ie(o,on,o);let l=Ie(n,Ro,Ec,{[xc]:!0});Ie(l,on),Ie(l,sn,i),Ie(l,Ro,l),Ie(i,sn,i),Ie(i,on),Ie(i,Ro,i);let a=R(n,yc,Rc,{[mc]:!0}),c=R(n,ng,Tc,{[mc]:!0}),u=Ie(n,bc,Tc,{[mc]:!0});R(n,wc,u),R(c,yc,a),R(c,wc,u),Ie(c,bc,u),R(u,ng),R(u,yc),Ie(u,bc,u),R(u,wc,u);let f=Ie(n,gc,ug,{[sg]:!0});R(f,"#"),Ie(f,gc,f),R(f,aS,f);let d=R(f,cS);R(d,"#"),Ie(d,gc,f);let p=[[on,s],[sn,o]],h=[[on,null],[Ro,l],[sn,i]];for(let g=0;g<es.length;g++)Sn(n,es[g],Mc,ln,p);for(let g=0;g<ts.length;g++)Sn(n,ts[g],Ac,Ec,h);rr(Mc,{tld:!0,ascii:!0},t),rr(Ac,{utld:!0,alpha:!0},t),Sn(n,"file",rs,ln,p),Sn(n,"mailto",rs,ln,p),Sn(n,"http",Kr,ln,p),Sn(n,"https",Kr,ln,p),Sn(n,"ftp",Kr,ln,p),Sn(n,"ftps",Kr,ln,p),rr(rs,{scheme:!0,ascii:!0},t),rr(Kr,{slashscheme:!0,ascii:!0},t),e=e.sort((g,m)=>g[0]>m[0]?1:-1);for(let g=0;g<e.length;g++){let m=e[g][0],k=e[g][1]?{[oS]:!0}:{[iS]:!0};m.indexOf("-")>=0?k[Sc]=!0:on.test(m)?sn.test(m)?k[Oo]=!0:k[Cc]=!0:k[vc]=!0,tg(n,m,m,k)}return tg(n,"localhost",zo,{ascii:!0}),n.jd=new at(Ds),{start:n,tokens:Object.assign({groups:t},dg)}}function fg(e,t){let n=dS(t.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],i=0,s=0;for(;s<r;){let l=e,a=null,c=0,u=null,f=-1,d=-1;for(;s<r&&(a=l.go(n[s]));)l=a,l.accepts()?(f=0,d=0,u=l):f>=0&&(f+=n[s].length,d++),c+=n[s].length,i+=n[s].length,s++;i-=f,s-=d,c-=f,o.push({t:u.t,v:t.slice(i-c,i),s:i-c,e:i})}return o}function dS(e){let t=[],n=e.length,r=0;for(;r<n;){let o=e.charCodeAt(r),i,s=o<55296||o>56319||r+1===n||(i=e.charCodeAt(r+1))<56320||i>57343?e[r]:e.slice(r,r+2);t.push(s),r+=s.length}return t}function Sn(e,t,n,r,o){let i,s=t.length;for(let l=0;l<s-1;l++){let a=t[l];e.j[a]?i=e.j[a]:(i=new at(r),i.jr=o.slice(),e.j[a]=i),e=i}return i=new at(n),i.jr=o.slice(),e.j[t[s-1]]=i,i}function rg(e){let t=[],n=[],r=0,o="0123456789";for(;r<e.length;){let i=0;for(;o.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(""));for(let s=parseInt(e.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(e[r]),r++}return t}var Ho={defaultProtocol:"http",events:null,format:og,formatHref:og,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ic(e,t=null){let n=Object.assign({},Ho);e&&(n=Object.assign(n,e instanceof Ic?e.o:e));let r=n.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=o}Ic.prototype={o:Ho,ignoreTags:[],defaultRender(e){return e},check(e){return this.get("validate",e.toString(),e)},get(e,t,n){let r=t!=null,o=this.o[e];return o&&(typeof o=="object"?(o=n.t in o?o[n.t]:Ho[e],typeof o=="function"&&r&&(o=o(t,n))):typeof o=="function"&&r&&(o=o(t,n.t,n)),o)},getObj(e,t,n){let r=this.o[e];return typeof r=="function"&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}};function og(e){return e}function pg(e,t){this.t="token",this.v=e,this.tk=t}pg.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"\u2026":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=Ho.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){let t=this,n=this.toHref(e.get("defaultProtocol")),r=e.get("formatHref",n,this),o=e.get("tagName",n,t),i=this.toFormattedString(e),s={},l=e.get("className",n,t),a=e.get("target",n,t),c=e.get("rel",n,t),u=e.getObj("attributes",n,t),f=e.getObj("events",n,t);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:o,attributes:s,content:i,eventListeners:f}}};function Os(e,t){class n extends pg{constructor(o,i){super(o,i),this.t=e}}for(let r in t)n.prototype[r]=t[r];return n.t=e,n}var fS=Os("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ig=Os("text"),pS=Os("nl"),ns=Os("url",{isLink:!0,toHref(e=Ho.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==zo&&e[1].t===or}});var bt=e=>new at(e);function hS({groups:e}){let t=e.domain.concat([ws,vs,En,Cs,xs,Ss,Es,Ms,yt,Nc,Io,As,Ts,Ns,Vt,Ds,Bo,Rs]),n=[ks,or,Dc,_t,Oc,Io,$o,Lc,Pc,cs,us,Lo,Po,ss,is,ls,as,ds,fs,ps,hs,ms,gs,bs,ys],r=[ws,ks,vs,Cs,xs,Ss,Es,Ms,yt,Lo,Po,Io,As,Ts,Ns,$o,Vt,Ds,Bo,Rs],o=bt(),i=R(o,Bo);Z(i,r,i),Z(i,e.domain,i);let s=bt(),l=bt(),a=bt();Z(o,e.domain,s),Z(o,e.scheme,l),Z(o,e.slashscheme,a),Z(s,r,i),Z(s,e.domain,s);let c=R(s,En);R(i,En,c),R(l,En,c),R(a,En,c);let u=R(i,_t);Z(u,r,i),Z(u,e.domain,i);let f=bt();Z(c,e.domain,f),Z(f,e.domain,f);let d=R(f,_t);Z(d,e.domain,f);let p=bt(fS);Z(d,e.tld,p),Z(d,e.utld,p),R(c,zo,p);let h=R(f,yt);R(h,yt,h),Z(h,e.domain,f),Z(p,e.domain,f),R(p,_t,d),R(p,yt,h);let g=R(s,yt),m=R(s,_t);R(g,yt,g),Z(g,e.domain,s),Z(m,r,i),Z(m,e.domain,s);let w=bt(ns);Z(m,e.tld,w),Z(m,e.utld,w),Z(w,e.domain,s),Z(w,r,i),R(w,_t,m),R(w,yt,g),R(w,En,c);let k=R(w,or),x=bt(ns);Z(k,e.numeric,x);let E=bt(ns),M=bt();Z(E,t,E),Z(E,n,M),Z(M,t,E),Z(M,n,M),R(w,Vt,E),R(x,Vt,E);let A=R(l,or),S=R(a,or),L=R(S,Vt),X=R(L,Vt);Z(l,e.domain,s),R(l,_t,m),R(l,yt,g),Z(a,e.domain,s),R(a,_t,m),R(a,yt,g),Z(A,e.domain,E),R(A,Vt,E),R(A,$o,E),Z(X,e.domain,E),Z(X,t,E),R(X,Vt,E);let G=[[Lo,Po],[is,ss],[ls,as],[cs,us],[ds,fs],[ps,hs],[ms,gs],[bs,ys]];for(let fe=0;fe<G.length;fe++){let[Be,ye]=G[fe],De=R(E,Be);R(M,Be,De);let Oe=bt(ns);Z(De,t,Oe);let N=bt();Z(De,n,N),R(De,ye,E),Z(Oe,t,Oe),Z(Oe,n,N),Z(N,t,Oe),Z(N,n,N),R(Oe,ye,E),R(N,ye,E)}return R(o,zo,w),R(o,Rc,pS),{start:o,tokens:dg}}function mS(e,t,n){let r=n.length,o=0,i=[],s=[];for(;o<r;){let l=e,a=null,c=null,u=0,f=null,d=-1;for(;o<r&&!(a=l.go(n[o].t));)s.push(n[o++]);for(;o<r&&(c=a||l.go(n[o].t));)a=null,l=c,l.accepts()?(d=0,f=l):d>=0&&d++,o++,u++;if(d<0)o-=u,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(kc(ig,t,s)),s=[]),o-=d,u-=d;let p=f.t,h=n.slice(o-u,o);i.push(kc(p,t,h))}}return s.length>0&&i.push(kc(ig,t,s)),i}function kc(e,t,n){let r=n[0].s,o=n[n.length-1].e,i=t.slice(r,o);return new e(i,n)}var gS=typeof console<"u"&&console&&console.warn||(()=>{}),bS="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ne={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function hg(){return at.groups={},Ne.scanner=null,Ne.parser=null,Ne.tokenQueue=[],Ne.pluginQueue=[],Ne.customSchemes=[],Ne.initialized=!1,Ne}function $c(e,t=!1){if(Ne.initialized&&gS(`linkifyjs: already initialized - will not register custom scheme "${e}" ${bS}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw new Error(`linkifyjs: incorrect scheme format.
|
|
125
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
126
|
+
2. Cannot start or end with "-"
|
|
127
|
+
3. "-" cannot repeat`);Ne.customSchemes.push([e,t])}function yS(){Ne.scanner=uS(Ne.customSchemes);for(let e=0;e<Ne.tokenQueue.length;e++)Ne.tokenQueue[e][1]({scanner:Ne.scanner});Ne.parser=hS(Ne.scanner.tokens);for(let e=0;e<Ne.pluginQueue.length;e++)Ne.pluginQueue[e][1]({scanner:Ne.scanner,parser:Ne.parser});return Ne.initialized=!0,Ne}function Ls(e){return Ne.initialized||yS(),mS(Ne.parser.start,e,fg(Ne.scanner.start,e))}Ls.scan=fg;function Bc(e,t=null,n=null){if(t&&typeof t=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new Ic(n),o=Ls(e),i=[];for(let s=0;s<o.length;s++){let l=o[s];l.isLink&&(!t||l.t===t)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var Ps="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",wS=new RegExp(Ps),kS=new RegExp(`${Ps}$`),vS=new RegExp(`${Ps}+$`),CS=new RegExp(Ps,"g");function xS(e,t,n){var r,o;let i=e.doc.resolve(t.to);if(!(!((r=i.nodeBefore)===null||r===void 0)&&r.isText))return;let s=(o=e.doc.textBetween(t.from,t.to,"\uFFFC","\uFFFC").match(vS))===null||o===void 0?void 0:o[0];if(!s)return;let l=t.to-s.length,a=vo(l,t.to,e.doc).filter(f=>f.mark.type===n);if(!a.length)return;let{nodeAfter:c}=i;if(c&&a.some(f=>f.mark.isInSet(c.marks)))return;let u=e.storedMarks;e.removeMark(l,t.to,n),e.setStoredMarks(u),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function SS(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?["()","[]"].includes(e[0].value+e[2].value):!1}function ES(e){return new U({key:new oe("autolink"),appendTransaction:(t,n,r)=>{let o=t.some(a=>a.docChanged)&&!n.doc.eq(r.doc),i=t.some(a=>a.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=za(n.doc,[...t]);if(!t.some(Lp)){let a=[];l.steps.forEach((c,u)=>{if(!(c instanceof Bn)||!c.slice.size)return;let f=l.mapping.slice(u+1),d=f.map(c.from,1),p=f.map(c.from+c.slice.size,-1);d<p&&a.push({from:d,to:p})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>xS(s,c,e.type))}if($r(l).forEach(({newRange:a})=>{let c=ih(r.doc,a,d=>d.isTextblock),u,f;if(c.length>1)u=c[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(c.length){let d=r.doc.textBetween(a.from,a.to," "," ");if(!kS.test(d))return;u=c[0],f=r.doc.textBetween(u.pos,a.to,void 0," ")}if(u&&f){let d=f.split(wS).filter(Boolean);if(d.length<=0)return!1;let p=d[d.length-1],h=u.pos+f.lastIndexOf(p);if(!p)return!1;let g=Ls(p).map(m=>m.toObject(e.defaultProtocol));if(!SS(g))return!1;g.filter(m=>m.isLink).map(m=>({...m,from:h+m.start+1,to:h+m.end+1})).filter(m=>r.schema.marks.code?!r.doc.rangeHasMark(m.from,m.to,r.schema.marks.code):!0).filter(m=>e.validate(m.value)).filter(m=>e.shouldAutoLink(m.value)).forEach(m=>{vo(m.from,m.to,r.doc).some(w=>w.mark.type===e.type)||s.addMark(m.from,m.to,e.type.create({href:m.href}))})}}),!!s.steps.length)return s}})}function MS(e){return new U({key:new oe("handleClickLink"),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let c=e.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let i=!1;if(e.enableClickSelection&&(i=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){var s,l;let a=Va(t.state,e.type.name),c=(s=o.href)!==null&&s!==void 0?s:a.href,u=(l=o.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,u),i=!0)}return i}}})}var AS=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,TS=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function mg(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function NS(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&mg(e,r)){r+=1;continue}let o=0;for(;r<t&&e[r]==="`";)o+=1,r+=1;n===0?n=o:o===n&&(n=0)}return n>0}function gg(e,t,n){var r,o;let[,i,s]=t;return(t.index?e[t.index-1]:void 0)==="!"||mg(e,(r=t.index)!==null&&r!==void 0?r:0)||NS(e,(o=t.index)!==null&&o!==void 0?o:0)?!1:!!i.trim()&&n(s)}function bg(e){var t,n;let[r,o,i,,s,l,a]=e,c=(t=s??l)!==null&&t!==void 0?t:a;return{index:(n=e.index)!==null&&n!==void 0?n:0,text:r,replaceWith:o,data:{href:i,title:c||null,markdown:!0}}}function RS(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function yg(e){var t,n,r;return{href:(t=e.data)===null||t===void 0?void 0:t.href,title:(n=(r=e.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function DS(e){let t=lt({find:n=>{let r=AS.exec(n);return!r||!gg(n,r,e.isAllowedHref)?null:bg(r)},type:e.type,getAttributes:yg});return new Hr({find:t.find,handler:n=>{let r=t.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function OS(e){let t=nt({find:n=>{var r,o;let i=[];for(let l of n.matchAll(TS))gg(n,l,e.isAllowedHref)&&i.push(bg(l));let s=((r=(o=e.findPlainUrls)===null||o===void 0?void 0:o.call(e,n))!==null&&r!==void 0?r:[]).filter(l=>!i.some(a=>RS(a,l)));return[...i,...s]},type:e.type,getAttributes:yg});return new Ka({find:t.find,handler:n=>{var r;let o=t.handler(n);return o!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),o}})}function LS(e){return new U({key:new oe("handlePasteLink"),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:o}=e,{state:i}=t,{selection:s}=i,{empty:l}=s;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});let c=Bc(a,{defaultProtocol:e.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||o!==void 0&&!o(c.value)?!1:e.editor.commands.setMark(e.type,{href:c.href})}}})}function an(e,t){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!e||e.replace(CS,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var wg=We.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(e=>{if(typeof e=="string"){$c(e);return}$c(e.scheme,e.optionalSlashes)})},onDestroy(){hg()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(e,t)=>!!an(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes("@"))return!0;let r=(e.includes("@")?e.split("@").pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var e,t,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(e=this.options.HTMLAttributes.target)!==null&&e!==void 0?e:null},rel:{default:(t=this.options.HTMLAttributes.rel)!==null&&t!==void 0?t:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{let t=e.getAttribute("href");return!t||!this.options.isAllowedUri(t,{defaultValidate:n=>!!an(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:t=>!!an(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",K(this.options.HTMLAttributes,e),0]:["a",K(this.options.HTMLAttributes,{...e,href:""}),0]},markdownTokenName:"link",parseMarkdown:(e,t)=>t.applyMark("link",t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{var n,r,o,i;let s=(n=(r=e.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(o=(i=e.attrs)===null||i===void 0?void 0:i.title)!==null&&o!==void 0?o:"",a=t.renderChildren(e);return l?`[${a}](${s} "${l}")`:`[${a}](${s})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:r=>!!an(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta("preventAutolink",!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!an(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[DS({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:t=>!!an(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=t=>{let n=[];if(t){let{protocols:r,defaultProtocol:o}=this.options;Bc(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!an(s,r),protocols:r,defaultProtocol:o})).forEach(i=>{this.options.shouldAutoLink(i.value)&&n.push({text:i.value,data:{href:i.href},index:i.start})})}return n};return this.options.markdownLinks?[OS({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:n=>!!an(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[nt({find:e,type:this.type,getAttributes:t=>{var n;return{href:(n=t.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(ES({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!an(o,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(MS({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(LS({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}});var PS="listItem",kg="textStyle",vg=/^\s*([-+*])\s$/,zc=ee.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:e}){return["ul",K(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>e.type!=="list"||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
128
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(PS,this.editor.getAttributes(kg)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=vn({find:vg,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=vn({find:vg,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(kg),editor:this.editor})),[e]}}),IS=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let i=-1;for(let p=o.depth;p>0;p-=1)if(o.node(p).type.name===t){i=p;break}if(i<0)return null;let s=o.node(i),l=o.index(i);if(l+1>=s.childCount)return null;let a=s.child(l+1);if(!n.includes(a.type.name))return null;let c=e.schema.nodes[t],u=!1;if(a.forEach(p=>{p.type===c&&p.childCount>1&&(u=!0)}),!u)return null;let f=e.doc.resolve(o.after()).nodeAfter;if(!f||!n.includes(f.type.name))return null;let d=[];return f.forEach(p=>{d.push(p)}),d.length===0?null:{listItemDepth:i,nestedList:f,nestedListPos:o.after(),insertPos:o.after(i),items:d}},$S=(e,t,n,r)=>{let o=IS(e,n,r);if(!o)return!1;let{selection:i}=e,{nestedList:s,nestedListPos:l,insertPos:a,items:c}=o,u=e.tr;u.delete(l,l+s.nodeSize);let f=u.mapping.map(a);return u.insert(f,F.from(c)),u.setSelection(i.map(u.doc,u.mapping)),t&&t(u),!0},BS=(e,t,n)=>$S(e.state,e.view.dispatch,t,n),Ng=(e,t)=>le.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>BS(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),Rg=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Is="abcdefghijklmnopqrstuvwxyz",Dg=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function zs(e){let t=e,n="";for(let[r,o]of Rg)for(;t>=r;)n+=o,t-=r;return n}function Hc(e){return zs(e).toUpperCase()}function Og(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let o=!1;for(let[i,s]of Rg)if(t.startsWith(s,n)){r+=i,n+=s.length,o=!0;break}if(!o)return 0}return r}function zS(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=Og(e);return t<=0?!1:(e===e.toLowerCase()?zs(t):Hc(t))===e}function HS(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let n=t.charCodeAt(0)-97,r=t.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function $s(e){if(e<=26)return Is[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?Is[n]:Is[t]+Is[n]}function Hs(e){if(!(!e||/^\d+$/.test(e))){if(zS(e))return e===e.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(e))return"a";if(/^[A-Z]{1,2}$/.test(e))return"A"}}function _c(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=Hs(e);if(t==="i"||t==="I")return Og(e);if(t==="a"||t==="A"){let r=HS(e);return r>0?r:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function _S(e,t){if(e==="numeric")return String(t);switch(e){case"a":return $s(t);case"A":return $s(t).toUpperCase();case"i":return zs(t);case"I":return Hc(t);default:return String(t)}}function VS(e){var t;if(e.length===0)return!1;let n=(t=Hs(e[0]))!==null&&t!==void 0?t:"numeric",r=_c(e[0]);if(r<1)return!1;for(let o=0;o<e.length;o++){let i=_S(n,r+o);if(e[o]!==i)return!1}return!0}function jS(e){return{type:Hs(e),start:_c(e)}}function FS(e){let{type:t,start:n}=jS(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function WS(e,t,n=". "){let r=t+1;if(!e||e==="1")return`${r}${n}`;switch(e){case"a":return`${$s(r)}${n}`;case"A":return`${$s(r).toUpperCase()}${n}`;case"i":return`${zs(r)}${n}`;case"I":return`${Hc(r)}${n}`;default:return`${r}${n}`}}function KS(e){var t,n;let r=(t=e.tokens)===null||t===void 0?void 0:t[0];return!!(e.text&&((n=e.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===e.text)}function US(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:"text",raw:e,text:e}])}var Vc=ee.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",K(this.options.HTMLAttributes,e),0]},markdownTokenName:"list_item",parseMarkdown:(e,t)=>{var n;if(e.type!=="list_item")return[];let r=(n=t.parseBlockChildren)!==null&&n!==void 0?n:t.parseChildren,o=[];if(e.tokens&&e.tokens.length>0){if(KS(e))return{type:"listItem",content:[{type:"paragraph",content:US(e.text||"",t)}]};if(e.tokens.some(i=>i.type==="paragraph"))o=r(e.tokens);else{let i=e.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(o=[{type:"paragraph",content:t.parseInline(i.tokens)}],e.tokens.length>1){let s=r(e.tokens.slice(1));o.push(...s)}}else o=r(e.tokens)}}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:o}},renderMarkdown:(e,t,n)=>Fa(e,t,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var o,i;let s=((o=r.meta)===null||o===void 0||(o=o.parentAttrs)===null||o===void 0?void 0:o.start)||1;return WS((i=r.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.type,s-1+(r.index||0),". ")}return"- "},n,{alignNestedToPrefix:n?.parentType==="orderedList"}),addExtensions(){return[Ng(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),jc=(e,t)=>{let{$from:n}=t.selection,r=_e(e,t.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:t.doc.resolve(s),depth:l}},Lg=(e,t)=>{let n=jc(e,t);if(!n)return!1;let[,r]=uh(t,e,n.$pos.pos+4);return r},qS=(e,t,n)=>{let{$anchor:r}=e.selection,o=Math.max(0,r.pos-2),i=e.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},Cg=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!$t(e.state,t)&&qS(e.state,t,n)){let{$anchor:i}=e.state.selection,s=e.state.doc.resolve(i.before()-1),l=[];s.node().descendants((u,f)=>{u.type.name===t&&l.push({node:u,pos:f})});let a=l.at(-1);if(!a)return!1;let c=e.state.doc.resolve(s.start()+a.pos+1);return e.chain().cut({from:i.start()-1,to:i.end()+1},c.end()).joinForward().run()}if(!$t(e.state,t)||!ph(e.state))return!1;let{$from:r}=e.state.selection,o=r.depth-1;return r.node(o).type!==e.schema.nodes[t]||r.index(o)!==0?!1:e.chain().liftListItem(t).run()},GS=(e,t)=>{let n=Lg(e,t),r=jc(e,t);return!r||!n?!1:n>r.depth},JS=(e,t)=>{let n=Lg(e,t),r=jc(e,t);return!r||!n?!1:n<r.depth},xg=(e,t)=>{if(!$t(e.state,t)||!fh(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:GS(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():JS(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},XS=(e,t,n)=>{let{state:r}=e,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0||!i.parent.isTextblock||$t(r,t))return!1;let s=dh(i);if(!s||!n.includes(s.type.name))return!1;let l=s.lastChild;if(!l||l.type.name!==t)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,F.from(a)))return!1;let c=i.before(),u=i.after(),f=c-2;return e.commands.command(({tr:d,dispatch:p})=>(p&&(d.delete(c,u).insert(f,F.from(a)),d.setSelection(P.create(d.doc,f+1)),d.scrollIntoView()),!0))};var Fc=le.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&xg(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&xg(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Cg(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Cg(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&XS(e,t,n))return!0;return!1}}}}),Bs=new RegExp(`^(\\s*)(${Dg})([.)])\\s+(.*)$`),YS=/^\s/,Ur={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function QS(e){return Bs.test(e.trimStart())}function ZS(e){let t=e.trimStart();return Ur.bulletItem.test(t)||QS(t)||Ur.heading.test(t)||Ur.thematicBreak.test(t)&&!t.startsWith("-")||/^>\s?/.test(t)||Ur.codeFence.test(t)||Ur.blockMath.test(t)}function eE(e){return Object.values(Ur).some(t=>t.test(e))}function tE(e){let t=[],n=[],r=!1;return e.forEach(o=>{if(r){n.push(o);return}if(o.trim()===""){r=!0,n.push(o);return}if(t.length>0&&ZS(o)){r=!0,n.push(o);return}t.push(o)}),{paragraphLines:t,blockLines:n}}function Sg(e){let t=[],n=0,r=0;for(;n<e.length;){let o=e[n],i=o.match(Bs);if(!i)break;let[,s,l,a,c]=i,u=s.length,f=parseInt(l,10),d=isNaN(f)?Hs(l):void 0,p=isNaN(f)?_c(l):f,h=[c],g=n+1,m=[o],w=!1;for(;g<e.length;){let k=e[g];if(k.match(Bs))break;if(k.trim()==="")m.push(k),h.push(""),w=!0,g+=1;else if(k.match(YS)){let x=k.length-k.trimStart().length,E=u+l.length+1;m.push(k),h.push(k.slice(Math.min(x,E))),g+=1}else{if(w||eE(k))break;m.push(k),h.push(k),g+=1}}t.push({indent:u,number:p,type:d,content:h.join(`
|
|
129
|
+
`).trim(),contentLines:h,raw:m.join(`
|
|
130
|
+
`)}),r=g,n=g}return[t,r]}var nE=new RegExp(`^(${Dg})([.)])\\s+(.+)$`);function rE(e){let t=e.split(`
|
|
131
|
+
`).filter(r=>r.trim().length>0);if(t.length===0)return null;let n=[];for(let r of t){let o=r.trim().match(nE);if(!o)return null;n.push({marker:o[1],content:o[3]})}return VS(n.map(r=>r.marker))?{type:"orderedList",attrs:FS(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function Pg(e,t,n){let r=[],o=0;for(;o<e.length;){let i=e[o];if(i.indent===t){let{paragraphLines:s,blockLines:l}=tE(i.contentLines),a=s.join(`
|
|
132
|
+
`).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});let u=l.join(`
|
|
133
|
+
`).trim();if(u){let p=n.blockTokens(u);c.push(...p)}let f=o+1,d=[];for(;f<e.length&&e[f].indent>t;)d.push(e[f]),f+=1;if(d.length>0){let p=Pg(d,Math.min(...d.map(h=>h.indent)),n);c.push({type:"list",ordered:!0,start:d[0].number,typeMarker:d[0].type,items:p,raw:d.map(h=>h.raw).join(`
|
|
134
|
+
`)})}r.push({type:"list_item",raw:i.raw,tokens:c}),o=f}else o+=1}return r}function oE(e,t){return e.map(n=>{if(n.type!=="list_item")return t.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...t.parseChildren([o]));else if(o.type==="text"&&o.tokens){let i=t.parseChildren([o]);r.push({type:"paragraph",content:i})}else{let i=t.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var iE=64;function Eg(e,t){let n=[],r=0;for(;n.length<t;){let o=e.indexOf(`
|
|
135
|
+
`,r);if(o===-1)return n.push(e.slice(r)),n;n.push(e.slice(r,o)),r=o+1}return n}function sE(e){let t=e.indexOf(`
|
|
136
|
+
`),n=t===-1?e:e.slice(0,t);if(!Bs.test(n))return[[],0,[]];let r=iE,o=Eg(e,r),i=Sg(o);for(;i[1]===o.length&&o.length===r;)r*=2,o=Eg(e,r),i=Sg(o);return[i[0],i[1],o]}var lE="listItem",Mg="textStyle",Ag=/^(\d+)\.\s$/;function Tg(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var Wc=ee.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:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute("type");if(t)return t;let n=e.getAttribute("style");if(n){let o=Tg(n);if(o)return o}let r=e.querySelector("li");if(r){let o=r.getAttribute("style");if(o){let i=Tg(o);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,o=K(this.options.HTMLAttributes,r);return t!==1&&(o.start=t),n&&n!=="1"&&(o.type=n),["ol",o,0]},markdownTokenName:"list",parseMarkdown:(e,t)=>{if(e.type!=="list"||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,o=e.items?oE(e.items,t):[],i={};return n!==1&&(i.start=n),r&&(i.type=r),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:o}:{type:"orderedList",content:o}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
137
|
+
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(e,t,n)=>{var r,o;let[i,s,l]=sE(e);if(i.length===0)return;let a=Pg(i,i[0].indent,n);if(a.length!==0)return{type:"list",ordered:!0,start:((r=i[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(o=i[0])===null||o===void 0?void 0:o.type,items:a,raw:l.slice(0,s).join(`
|
|
138
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(lE,this.editor.getAttributes(Mg)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new U({props:{handlePaste:(e,t)=>{var n,r;let o=(n=t.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(o?.trim())return!1;let i=(r=t.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!i)return!1;let s=rE(i);if(!s)return!1;try{let l=e.state.schema.nodeFromJSON(s),a=e.state.tr.replaceSelectionWith(l);return e.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let e=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1],t=vn({find:Ag,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=vn({find:Ag,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Mg)}),joinPredicate:e,editor:this.editor})),[t]}}),aE=/^\s*(\[([( |x])?\])\s$/,cE="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",uE=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||"empty task item"}`},_s=ee.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:e=>{let t=e.getAttribute("data-checked");return t===""||t==="true"},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>{var t;return(t=e.querySelector("div"))!==null&&t!==void 0?t:e}}]},renderHTML({node:e,HTMLAttributes:t}){return["li",K(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode("paragraph",{},t.parseInline(e.tokens))):e.text?n.push(t.createNode("paragraph",{},[t.createNode("text",{text:e.text})])):n.push(t.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{var n;let r=`- [${!((n=e.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return Fa(e,t,r)},addExtensions(){return this.options.nested?[Ng(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");s.style.cssText=cE;let c=f=>{let d=uE(f,f.attrs.checked,this.options.a11y);l.setAttribute("aria-label",d),s.textContent=d};c(e),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",f=>f.preventDefault()),l.addEventListener("change",f=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:d}=f.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{let h=n();if(typeof h!="number")return!1;let g=p.doc.nodeAt(h);return p.setNodeMarkup(h,void 0,{...g?.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([f,d])=>{o.setAttribute(f,d)}),o.dataset.checked=e.attrs.checked,l.checked=e.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(t).forEach(([f,d])=>{o.setAttribute(f,d)});let u=new Set(Object.keys(t));return{dom:o,contentDOM:a,update:f=>{if(f.type!==this.type)return!1;o.dataset.checked=f.attrs.checked,l.checked=f.attrs.checked,c(f);let d=r.extensionManager.attributes,p=Bt(f,d),h=new Set(Object.keys(p)),g=this.options.HTMLAttributes;return u.forEach(m=>{h.has(m)||(m in g?o.setAttribute(m,g[m]):o.removeAttribute(m))}),Object.entries(p).forEach(([m,w])=>{w==null?m in g?o.setAttribute(m,g[m]):o.removeAttribute(m):o.setAttribute(m,w)}),u=h,!0}}}},addInputRules(){return[vn({find:aE,type:this.type,getAttributes:e=>({checked:e[e.length-1]==="x"})})]}}),Vs=ee.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:e}){return["ul",K(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode("taskList",{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
139
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;let n=(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||t===void 0?void 0:t.index;return n!==void 0?n:-1},tokenize(e,t,n){let r=i=>{let s=ja(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(s){let l={type:"taskList",raw:s.raw,items:s.items},a=i.slice(s.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},o=ja(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,s)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),oR=le.create({name:"listKit",addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(zc.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(Vc.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Fc.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Wc.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(_s.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Vs.configure(this.options.taskList)),e}});var js=" ",Kc="\xA0",Ig=ee.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",K(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type==="image")return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===js||n[0].text===js||n[0].raw===Kc||n[0].text===Kc)&&r.length===1&&r[0].type==="text"&&(r[0].text===js||r[0].text===Kc)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return"";let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var o,i;let s=Array.isArray(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.content)?n.previousNode.content:[];return(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.type)==="paragraph"&&s.length===0?js:""}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var dE=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,fE=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,$g=We.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",K(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[lt({find:dE,type:this.type})]},addPasteRules(){return[nt({find:fE,type:this.type})]}});var Bg=ee.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""});var zg=We.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",K(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:"underline",level:"inline",start(e){return e.indexOf("++")},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let o=r[2].trim();return{type:"underline",raw:r[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Hg(e={}){return new U({view(t){return new Uc(t,e)}})}var Uc=class{constructor(t,n){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,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(o=>{let i=s=>{this[o](s)};return t.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){if(this.cursorPos!=null&&n.doc!=t.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let f=t.nodeBefore,d=t.nodeAfter;if(f||d){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let h=p.getBoundingClientRect(),g=f?h.bottom:h.top;f&&d&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;r={left:h.left,right:h.right,top:g-m,bottom:g+m}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*s;r={left:f.left-d,right:f.left+d,top:f.top,bottom:f.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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 c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=a.getBoundingClientRect(),d=f.width/a.offsetWidth,p=f.height/a.offsetHeight;c=f.left-a.scrollLeft*d,u=f.top-a.scrollTop*p}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}computeTarget(t){let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,t):o;if(!n||i)return null;let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=ri(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(t){if(!this.editorView.editable)return;this.lastDragEvent=t;let n=this.computeTarget(t);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}};var ER=le.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(t=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)==="textSize"){let n=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(n)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new U({key:new oe("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;let o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){e=!0;return}let s=this.storage.characters({node:r.doc});if(s>o){let l=s-o,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(a,c);return e=!0,u}e=!0},filterTransaction:(t,n)=>{let r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:t.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!t.getMeta("paste"))return!1;let s=t.selection.$head.pos,l=s-(i-r),a=s;return t.deleteRange(l,a),!(this.storage.characters({node:t.doc})>r)}})]}}),jg=le.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Hg(this.options)]}}),MR=le.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new U({key:new oe("focus"),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=t,i=[];if(!n||!r)return de.create(e,[]);let s=0;this.options.mode==="deepest"&&e.descendants((a,c)=>{if(!a.isText){if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1}});let l=0;return e.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push($e.node(c,c+a.nodeSize,{class:this.options.className}))}),de.create(e,i)}}})]}}),Fg=le.create({name:"gapCursor",addProseMirrorPlugins(){return[rm()]},extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=pe(H(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),Wg="placeholder",_g=new oe("tiptap__placeholder");function Kg(e){let{editor:t,placeholder:n,dataAttribute:r,pos:o,node:i,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=e,u=[a];return s&&u.push(c),$e.node(o,o+i.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:t,node:i,pos:o,hasAnchor:l}):n})}function Ug(e,t){return typeof e=="function"?e(t):e}function qg({editor:e,options:t,dataAttribute:n,doc:r,selection:o,from:i,to:s}){let{anchor:l}=o,a=[],c=e.isEmpty;return r.nodesBetween(i,s,(u,f)=>{let d=l>=f&&l<=f+u.nodeSize,p=!u.isLeaf&&Br(u);return u.type.isTextblock&&(d||!t.showOnlyCurrent)&&p&&a.push(Kg({editor:e,isEmptyDoc:c,dataAttribute:n,hasAnchor:d,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Ug(t.emptyNodeClass,{editor:e,node:u,pos:f,hasAnchor:d})},node:u,pos:f})),t.includeChildren}),a}function Gg({editor:e,options:t,dataAttribute:n,doc:r,selection:o}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:i}=o,s=[],l=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let a=r.resolve(i),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):i;if(c&&c.type.isTextblock&&Br(c)){let f=i>=u&&i<=u+c.nodeSize;s.push(Kg({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:f,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Ug(t.emptyNodeClass,{editor:e,node:c,pos:u,hasAnchor:f})},node:c,pos:u}))}}else s.push(...qg({editor:e,options:t,dataAttribute:n,doc:r,selection:o,from:0,to:r.content.size}));return de.create(r,s)}function _o(e,t){let n=e.resolve(t);if(n.depth===0){var r;let i=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!i)return{from:t,to:t};let s=n.nodeAfter?t:t-i.nodeSize;return{from:s,to:s+i.nodeSize}}let o=n.before(1);return{from:o,to:o+n.node(1).nodeSize}}function Vo(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function pE(e,t,n){let r=[];return e.forEach((o,i)=>{let s=i,l=s+o.nodeSize,a=s+1,c=l+1;a<n&&c>t&&r.push({from:s,to:l})}),r}function hE(e){if(e.length===0)return[];let t=[...e].sort((r,o)=>r.from-o.from),n=[{...t[0]}];for(let r=1;r<t.length;r+=1){let o=n[n.length-1],i=t[r];i.from<=o.to?o.to=Math.max(o.to,i.to):n.push({...i})}return n}function mE(e,t){let n=pE(e,t.from,t.to);return n.push(Vo(e,_o(e,t.from))),t.to>t.from?n.push(Vo(e,_o(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(Vo(e,_o(e,Math.min(t.from+1,e.content.size)))),n}function gE(e,t,n){let r=[];if(e.docChanged){let o=$r(e);for(let i of o)r.push(...mE(n.doc,i.newRange))}return e.selectionSet&&(r.push(Vo(n.doc,_o(n.doc,e.mapping.map(t.selection.anchor)))),r.push(Vo(n.doc,_o(n.doc,n.selection.anchor)))),hE(r)}function bE(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function yE({decorations:e,ranges:t,editor:n,options:r,dataAttribute:o,doc:i,selection:s}){let l=e;for(let a of t){let{from:c,to:u}=bE(a.from,a.to,i),f=l.find(c,u).filter(p=>p.from>=c&&p.to<=u);f.length&&(l=l.remove(f));let d=qg({editor:n,options:r,dataAttribute:o,doc:i,selection:s,from:c,to:u});d.length&&(l=l.add(i,d))}return l}function wE({editor:e,options:t,dataAttribute:n}){return{init(r,o){let i=Gg({editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection});return i??de.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:yE({decorations:o.map(r.mapping,r.doc),ranges:gE(r,i,s),editor:e,options:t,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function kE(e){return e.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function vE({editor:e,options:t}){let n=t.dataAttribute?`data-${kE(t.dataAttribute)}`:`data-${Wg}`,r=t.showOnlyCurrent&&!t.includeChildren;return new U({key:_g,...r?{}:{state:wE({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:o,selection:i})=>Gg({editor:e,options:t,dataAttribute:n,doc:o,selection:i}):o=>{var i;return t.showOnlyWhenEditable&&!e.isEditable?de.empty:(i=_g.getState(o))!==null&&i!==void 0?i:de.empty}}})}var Gc=le.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Wg,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[vE({editor:this.editor,options:this.options})]}});function qc(e,t){return!e.selection.empty&&!Ii(e.selection)&&t.isEditable}function CE(e,t){return qc(e,t)&&!t.isFocused&&!t.view.dragging}function xE(){var e;(e=window.getSelection())===null||e===void 0||e.removeAllRanges()}function SE(e){e.focus()}var AR=le.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new U({key:new oe("selection"),props:{decorations(n){return CE(n,e)?de.create(n.doc,[$e.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(n){return qc(n.state,e)&&xE(),!1},focus(n){return qc(n.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&n.hasFocus()&&SE(n)}),!1}}}})]}});function Vg({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var Jg=le.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var e;let t=new oe(this.name),n=this.options.node||((e=this.editor.schema.topNodeType.contentMatch.defaultType)===null||e===void 0?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new U({key:t,appendTransaction:(o,i,s)=>{let{doc:l,tr:a,schema:c}=s,u=t.getState(s),f=l.content.size,d=c.nodes[n];if(!o.some(p=>p.getMeta("skipTrailingNode"))&&u)return a.insert(f,d.create())},state:{init:(o,i)=>{let s=i.tr.doc.lastChild;return!Vg({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;let s=o.doc.lastChild;return!Vg({node:s,types:r})}}})]}}),Xg=le.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Aa(e,t),redo:()=>({state:e,dispatch:t})=>Ta(e,t)}},addProseMirrorPlugins(){return[Op(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var EE=le.create({name:"starterKit",addExtensions(){let e=[];if(this.options.bold!==!1&&e.push(Gm.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(qm.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(zc.configure(this.options.bulletList)),this.options.code!==!1&&e.push(Jm.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Zi.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Xm.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(jg.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Fg.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(Ym.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Qm.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(Xg.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Zm.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(eg.configure(this.options.italic)),this.options.listItem!==!1&&e.push(Vc.configure(this.options.listItem)),this.options.listKeymap!==!1){var t;e.push(Fc.configure((t=this.options)===null||t===void 0?void 0:t.listKeymap))}if(this.options.link!==!1){var n;e.push(wg.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&e.push(Wc.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(Ig.configure(this.options.paragraph)),this.options.strike!==!1&&e.push($g.configure(this.options.strike)),this.options.text!==!1&&e.push(Bg.configure(this.options.text)),this.options.underline!==!1){var r;e.push(zg.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var o;e.push(Jg.configure((o=this.options)===null||o===void 0?void 0:o.trailingNode))}return e}}),Yg=EE;var yb=he(bb(),1);var wb=yb.default;function Cb(e,t=[]){return e.flatMap(n=>{let r=[...t,...n.properties?n.properties.className:[]];return n.children?Cb(n.children,r):{text:n.value,classes:r}})}function kb(e){return e.value||e.children||[]}function m1(e){return!!wb.getLanguage(e)}function vb({doc:e,name:t,lowlight:n,defaultLanguage:r}){let o=[];return Yn(e,i=>i.type.name===t).forEach(i=>{var s;let l=i.pos+1,a=i.node.attrs.language||r,c=n.listLanguages();Cb(a&&(c.includes(a)||m1(a)||!((s=n.registered)===null||s===void 0)&&s.call(n,a))?kb(n.highlight(a,i.node.textContent)):kb(n.highlightAuto(i.node.textContent))).forEach(u=>{let f=l+u.text.length;if(u.classes.length){let d=$e.inline(l,f,{class:u.classes.join(" ")});o.push(d)}l=f})}),de.create(e,o)}function g1(e){return typeof e=="function"}function b1({name:e,lowlight:t,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(o=>g1(t[o])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");let r=new U({key:new oe("lowlight"),state:{init:(o,{doc:i})=>vb({doc:i,name:e,lowlight:t,defaultLanguage:n}),apply:(o,i,s,l)=>{let a=s.selection.$head.parent.type.name,c=l.selection.$head.parent.type.name,u=Yn(s.doc,d=>d.type.name===e),f=Yn(l.doc,d=>d.type.name===e);return o.docChanged&&([a,c].includes(e)||f.length!==u.length||o.steps.some(d=>d.from!==void 0&&d.to!==void 0&&u.some(p=>p.pos>=d.from&&p.pos+p.node.nodeSize<=d.to)))?vb({doc:o.doc,name:e,lowlight:t,defaultLanguage:n}):i.map(o.mapping,o.doc)}},props:{decorations(o){return r.getState(o)}}});return r}var y1=Zi.extend({addOptions(){var e;return{...(e=this.parent)===null||e===void 0?void 0:e.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var e;return[...((e=this.parent)===null||e===void 0?void 0:e.call(this))||[],b1({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),xb=y1;var Sb=xb.extend({addProseMirrorPlugins(){return(this.parent?.()??[]).map(e=>{let t=e.spec.state;if(!t||!e.props.decorations)return e;let n=this.name;return new U({...e.spec,state:{...t,apply(r,o,i,s){if(r.docChanged){let l=Yn(i.doc,c=>c.type.name===n),a=Yn(s.doc,c=>c.type.name===n);if(l.length!==a.length||a.some((c,u)=>!c.node.eq(l[u].node)))return t.init.call(this,{},s)}return o.map(r.mapping,r.doc)}}})})}}).configure({lowlight:Td,HTMLAttributes:{class:"code-block"}});var Eb=Gc;var w1=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,k1=ee.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",K(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode("image",{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{var t,n,r,o,i,s;let l=(t=(n=e.attrs)===null||n===void 0?void 0:n.src)!==null&&t!==void 0?t:"",a=(r=(o=e.attrs)===null||o===void 0?void 0:o.alt)!==null&&r!==void 0?r:"",c=(i=(s=e.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:"";return c?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,o=new Set(["src","width","height"]);return({node:i,getPos:s,HTMLAttributes:l,editor:a})=>{let c=document.createElement("img");c.draggable=!1;let u=K(this.options.HTMLAttributes,l);Object.entries(u).forEach(([w,k])=>{if(k!=null)switch(w){case"src":case"width":case"height":break;default:c.setAttribute(w,k)}}),u.src!==null&&(c.src=u.src);let f={...l},d=w=>{if(typeof w=="string"&&w!==""){c.getAttribute("src")!==w&&(c.src=w);return}c.hasAttribute("src")&&c.removeAttribute("src"),c.src!==""&&(c.src="")};d(l.src);let p=w=>{if(w.type!==i.type)return!1;let k=a.extensionManager.attributes.filter(E=>E.type===w.type.name),x=Bt(w,k);return Object.keys(f).forEach(E=>{!o.has(E)&&!(E in x)&&c.removeAttribute(E)}),Object.entries(x).forEach(([E,M])=>{o.has(E)||(M!=null?c.setAttribute(E,M):c.removeAttribute(E))}),d(x.src),f=x,!0},h=new Th({element:c,editor:a,node:i,getPos:s,onResize:(w,k)=>{c.style.width=`${w}px`,c.style.height=`${k}px`},onCommit:(w,k)=>{let x=s();x!==void 0&&this.editor.chain().setNodeSelection(x).updateAttributes(this.name,{width:w,height:k}).run()},onUpdate:p,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),g=h.dom,m=()=>{g.style.visibility="",g.style.pointerEvents=""};return g.style.visibility="hidden",g.style.pointerEvents="none",c.complete&&c.naturalWidth>0?m():(c.onload=m,c.onerror=m),h}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Bi({find:w1,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),Mb=k1;function Wo(e){return e==="left"||e==="right"||e==="center"?e:null}function v1(e){let t=(e.style.textAlign||"").trim().toLowerCase(),n=(e.getAttribute("align")||"").trim().toLowerCase();return Wo(t||n)}function C1(e){return Wo(e?.align)}function Db(){return{default:null,parseHTML:e=>v1(e),renderHTML:e=>{let t=Wo(e.align);return zr(t)?{style:`text-align: ${t}`}:{}}}}function x1(e){var t;let n=e.parentElement,r=e.closest("table");if(!n||!r)return null;let o=Array.from(n.children).indexOf(e),i=(t=r.querySelectorAll("colgroup > col")[o])===null||t===void 0?void 0:t.getAttribute("width");return i?[parseInt(i,10)]:null}function Ob(e){let t=e.getAttribute("colwidth");return t?t.split(",").map(n=>parseInt(n,10)):x1(e)}var S1=/[ \t\r\n\f]+/g;function Lb(e){var t;return e.children.length>0?!1:((t=e.textContent)!==null&&t!==void 0?t:"").replace(S1,"")===""}function Pb(e){let t=e.createAndFill();if(!t)throw new Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function Js(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r==="1"||r===null||r===void 0)&&delete e[n]}var E1=ee.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Ob},align:Db()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:e=>Lb(e)?{}:!1,getContent:(e,t)=>Pb(t.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:e}){let t=K(this.options.HTMLAttributes,e);return Js(t,e,"colspan"),Js(t,e,"rowspan"),["td",t,0]}}),M1=ee.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Ob},align:Db()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:e=>Lb(e)?{}:!1,getContent:(e,t)=>Pb(t.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:e}){let t=K(this.options.HTMLAttributes,e);return Js(t,e,"colspan"),Js(t,e,"rowspan"),["th",t,0]}}),A1=ee.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",K(this.options.HTMLAttributes,e),0]}});function nu(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function Ab(e,t,n,r,o,i){let s=0,l=!0,a=t.firstChild,c=e.firstChild;if(c!==null)for(let d=0,p=0;d<c.childCount;d+=1){let{colspan:h,colwidth:g}=c.child(d).attrs;for(let m=0;m<h;m+=1,p+=1){let w=o===p?i:g&&g[m],k=w?`${w}px`:"";if(s+=w||r,w||(l=!1),a){if(a.style.width!==k){let[x,E]=nu(r,w);a.style.setProperty(x,E)}a=a.nextSibling}else{let x=document.createElement("col"),[E,M]=nu(r,w);x.style.setProperty(E,M),t.appendChild(x)}}}for(;a;){var u;let d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}let f=e.attrs.style&&typeof e.attrs.style=="string"&&/\bwidth\s*:/i.test(e.attrs.style);l&&!f?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}var ru=class{constructor(e,t,n,r={}){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(let[o,i]of Object.entries(r))i!=null&&(o==="style"?this.table.style.cssText=String(i):this.table.setAttribute(o,String(i)));e.attrs.style&&(this.table.style.cssText=e.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ab(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Ab(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){let t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!!(n&&!r&&(e.type==="attributes"||e.type==="childList"||e.type==="characterData"))}};function T1(e,t,n,r){let o=0,i=!0,s=[],l=e.firstChild;if(!l)return{};for(let u=0,f=0;u<l.childCount;u+=1){let{colspan:d,colwidth:p}=l.child(u).attrs;for(let h=0;h<d;h+=1,f+=1){let g=n===f?r:p&&p[h];o+=g||t,g||(i=!1);let[m,w]=nu(t,g);s.push(["col",{style:`${m}: ${w}`}])}}let a=i?`${o}px`:"",c=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:a,tableMinWidth:c}}function Tb(e,t){return t?e.createChecked(null,t):e.createAndFill()}function N1(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function R1(e,t,n,r,o){let i=N1(e),s=[],l=[];for(let c=0;c<n;c+=1){let u=Tb(i.cell,o);if(u&&l.push(u),r){let f=Tb(i.header_cell,o);f&&s.push(f)}}let a=[];for(let c=0;c<t;c+=1)a.push(i.row.createChecked(null,r&&c===0?s:l));return i.table.createChecked(null,a)}function Ib(e){return e instanceof ie}var Gs=({editor:e})=>{let{selection:t}=e.state;if(!Ib(t))return!1;let n=0,r=Ir(t.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n!==t.ranges.length?!1:(e.commands.deleteTable(),!0)};function Nb(e,t){let n=e.mapping.map(t),r=Ir(e.selection.$from,s=>s.type.name==="table");if(r?.pos===n)return;let o=e.doc.nodeAt(n);if(!o)return;let i=n+o.nodeSize-1;e.setSelection(P.near(e.doc.resolve(i),-1))}function D1(e){let t="",n=0;for(;n<e.length;){if(e[n]==="\\"&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}if(e[n]!=="`"){t+=e[n++];continue}let r=0;for(;n+r<e.length&&e[n+r]==="`";)r+=1;let o=n+r,i=!1;for(;o<e.length;){if(e[o]!=="`"){o+=1;continue}let s=0;for(;o+s<e.length&&e[o+s]==="`";)s+=1;if(s===r){let l=e.slice(n+r,o);t+=e.slice(n,n+r)+l.replace(/\\\||\|/g,a=>a==="|"?"\\|":a)+e.slice(o,o+r),n=o+r,i=!0;break}o+=s}i||(t+=e.slice(n,n+r),n+=r)}return t}function O1(e){return e.split(`
|
|
140
|
+
`).map(t=>!t.includes("|")||!t.includes("`")?t:D1(t)).join(`
|
|
141
|
+
`)}function L1(e){return(e||"").replaceAll(""," ").replace(/\s+/g," ").trim()}function Rb(e,t){return t?e.split(t).join(`
|
|
142
|
+
`):e}function P1(e){return e.replace(/\\.|\|/g,t=>t==="|"?"\\|":t)}function I1(e,t,n={}){if(!e||!e.content||e.content.length===0)return"";let r=[];e.content.forEach(d=>{let p=[];d.content&&d.content.forEach(h=>{let g="";h.content&&Array.isArray(h.content)&&h.content.length>1?g=h.content.map(x=>Rb(t.renderChildren(x),n.cellLineSeparator)).join(`
|
|
143
|
+
`):g=Rb(h.content?t.renderChildren(h.content):"",n.cellLineSeparator);let m=P1(L1(g.replace(/[ \t]*\r?\n[ \t]*/g,"<br>"))),w=h.type==="tableHeader",k=C1(h.attrs);p.push({text:m,isHeader:w,align:k})}),r.push(p)});let o=r.reduce((d,p)=>Math.max(d,p.length),0);if(o===0)return"";let i=Array.from({length:o}).fill(0);r.forEach(d=>{for(let h=0;h<o;h+=1){var p;let g=(((p=d[h])===null||p===void 0?void 0:p.text)||"").length;g>i[h]&&(i[h]=g),i[h]<3&&(i[h]=3)}});let s=(d,p)=>d+" ".repeat(Math.max(0,p-d.length)),l=r[0],a=l.some(d=>d.isHeader),c=Array.from({length:o}).fill(null);r.forEach(d=>{for(let h=0;h<o;h+=1){var p;!c[h]&&(!((p=d[h])===null||p===void 0)&&p.align)&&(c[h]=d[h].align)}});let u=`
|
|
144
|
+
`,f=Array.from({length:o}).map((d,p)=>a&&l[p]&&l[p].text||"");return u+=`| ${f.map((d,p)=>s(d,i[p])).join(" | ")} |
|
|
145
|
+
`,u+=`| ${i.map((d,p)=>{let h=Math.max(3,d),g=c[p];return g==="left"?`:${"-".repeat(h)}`:g==="right"?`${"-".repeat(h)}:`:g==="center"?`:${"-".repeat(h)}:`:"-".repeat(h)}).join(" | ")} |
|
|
146
|
+
`,(a?r.slice(1):r).forEach(d=>{u+=`| ${Array.from({length:o}).fill(0).map((p,h)=>s(d[h]&&d[h].text||"",i[h])).join(" | ")} |
|
|
147
|
+
`}),u}var $1=new oe("preserveCellSelectionOnContextMenu");function B1(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function z1(e,t){let n=!1;return e.forEachCell((r,o)=>{t>=o&&t<o+r.nodeSize&&(n=!0)}),n}function H1(){return new U({key:$1,props:{handleDOMEvents:{mousedown(e,t){if(t.button!==2)return!1;let{selection:n}=e.state;if(!Ib(n)||n.ranges.length<2)return!1;let r=B1(e,t);return r==null||!z1(n,r)?!1:(t.preventDefault(),!0)}}}})}var _1=ee.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:ru,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=T1(e,this.options.cellMinWidth),i=t.style;function s(){return i||(r?`width: ${r}`:`min-width: ${o}`)}let l=["table",K(this.options.HTMLAttributes,t,{style:s()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(e,t)=>{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let o=[];e.header.forEach((i,s)=>{var l;let a=Wo((l=r[s])!==null&&l!==void 0?l:i.align),c=a?{align:a}:{};o.push(t.createNode("tableHeader",c,[{type:"paragraph",content:t.parseInline(i.tokens)}]))}),n.push(t.createNode("tableRow",{},o))}return e.rows&&e.rows.forEach(o=>{let i=[];o.forEach((s,l)=>{var a;let c=Wo((a=r[l])!==null&&a!==void 0?a:s.align),u=c?{align:c}:{};i.push(t.createNode("tableCell",u,[{type:"paragraph",content:t.parseInline(s.tokens)}]))}),n.push(t.createNode("tableRow",{},i))}),t.createNode("table",void 0,n)},renderMarkdown:(e,t)=>I1(e,t),markdownTokenizer:{name:"table",level:"block",start:e=>{let t=e.split(`
|
|
148
|
+
`);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes("|")?-1:t[0].includes("|")?0:-1},tokenize(e,t,n){let r=e.indexOf(`
|
|
149
|
+
|
|
150
|
+
`),o=r>=0?e.slice(0,r):e,i=o.split(`
|
|
151
|
+
`);if(i.length<2)return;let s=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(s)||!s.includes("|"))return;let l=O1(o);if(l===o)return;let a=n.blockTokens(l)[0];if(a?.type!=="table"||!a.raw)return;let c=a.raw.split(`
|
|
152
|
+
`).length,u=e.split(`
|
|
153
|
+
`).slice(0,c).join(`
|
|
154
|
+
`);return{...a,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=R1(i.schema,e,t,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(P.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>wm(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>km(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=Ir(e.selection.$from,r=>r.type.name==="table");return vm(e,t&&(r=>{n&&Nb(r,n.pos),t(r)}))},addRowBefore:()=>({state:e,dispatch:t})=>xm(e,t),addRowAfter:()=>({state:e,dispatch:t})=>Sm(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=Ir(e.selection.$from,r=>r.type.name==="table");return Em(e,t&&(r=>{n&&Nb(r,n.pos),t(r)}))},deleteTable:()=>({state:e,dispatch:t})=>Tm(e,t),mergeCells:()=>({state:e,dispatch:t})=>lc(e,t),splitCell:()=>({state:e,dispatch:t})=>ac(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Fr("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Fr("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Am(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>lc(e,t)?!0:ac(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Mm(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>cc(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>cc(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&sc(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let r=ie.create(t.doc,e.anchorCell,e.headCell);t.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:Gs,"Mod-Backspace":Gs,Delete:Gs,"Mod-Delete":Gs}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Rm({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Om({allowTableNodeSelection:this.options.allowTableNodeSelection}),H1()]},addNodeView(){let e=this.options.resizable&&this.editor.isEditable,t=this.options.View;return e||!t?null:({node:n,view:r,HTMLAttributes:o})=>{let i=K(this.options.HTMLAttributes,o);return new t(n,this.options.cellMinWidth,r,i)}},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:pe(H(e,"tableRole",t))}}}),$b=le.create({name:"tableKit",addExtensions(){let e=[];return this.options.table!==!1&&e.push(_1.configure(this.options.table)),this.options.tableCell!==!1&&e.push(E1.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(M1.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(A1.configure(this.options.tableRow)),e}});var Bb=Vs;var zb=_s;var V1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,j1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,F1=We.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||Sh(e,"background-color")||e.style.backgroundColor,renderHTML:e=>zr(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",K(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark("highlight",t.parseInline(e.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:e=>e.indexOf("=="),tokenize(e,t,n){let r=/^(==)([^=]+)(==)/.exec(e);if(r){let o=r[2].trim(),i=n.inlineTokens(o);return{type:"highlight",raw:r[0],text:o,tokens:i}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[lt({find:V1,type:this.type})]},addPasteRules(){return[nt({find:j1,type:this.type})]}}),Hb=F1;var _b=Hb.extend({addAttributes(){let e={...this.parent?.(),mode:{default:"lower",parseHTML:t=>t.getAttribute("data-highlight-mode")==="full"?"full":"lower",renderHTML:({mode:t})=>({"data-highlight-mode":t==="full"?"full":"lower"})}};return this.options.multicolor?{...e,color:{...e.color,renderHTML:({color:t})=>t?{"data-color":t,style:`--showai-highlight-color: ${t}`}:{}}}:e}});var W1=le.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!zr(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).some(t=>t),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Vb=W1;var jb=le.create({name:"dropCursorCleanup",addProseMirrorPlugins(){return[new U({view(e){let t=e.dom.ownerDocument,n=t.defaultView,r=()=>{let o=t.createEvent("Event");o.initEvent("dragleave",!1,!1),e.dom.dispatchEvent(o)};return t.addEventListener("drop",r,!0),t.addEventListener("dragend",r,!0),n?.addEventListener("blur",r),{destroy(){t.removeEventListener("drop",r,!0),t.removeEventListener("dragend",r,!0),n?.removeEventListener("blur",r)}}}})]}});var ou=class extends zi{root;wrapper;content;title;controls;constructor(t,n,r){super(n,r);let o=r.view.dom.ownerDocument;this.root=o.createElement("div"),this.root.className=`react-renderer node-${t}`,this.wrapper=o.createElement("div"),this.wrapper.className=`document-${t}`,this.wrapper.dataset.nodeViewWrapper="",this.wrapper.style.whiteSpace="normal",this.root.append(this.wrapper);let i=o.createElement("div"),s=t==="toggle"?o.createElement("div"):i;s.dataset.nodeViewContent="",s.style.whiteSpace="pre-wrap",this.content=o.createElement("div"),this.content.dataset.nodeViewContentReact="",this.content.dataset.nodeViewWrapper="",this.content.style.whiteSpace="inherit",s.append(this.content);let l="";if(t==="callout"){l="callout-decoration",i.className="callout-content",this.title=o.createElement("strong"),this.title.contentEditable="false";let a=o.createElement("div");a.append(this.title,i),this.wrapper.append(a)}else t==="toggle"?(l="toggle-heading",i.className="toggle-body",i.hidden=!this.node.attrs.open,i.append(s),this.wrapper.append(i)):(i.className="stepper-steps",i.dataset.active="0",this.wrapper.append(i));this.syncAttributes(),this.controls=new Ga(n,{editor:this.editor,props:{editor:this.editor,node:this.node,getPos:this.getPos,updateAttributes:this.updateAttributes.bind(this),wrapper:this.wrapper,body:i}}),this.controls.element.contentEditable="false",this.controls.element.className=l,this.wrapper.prepend(this.controls.element)}get dom(){return this.root}get contentDOM(){return this.content}syncAttributes(t){let{attrs:n}=this.node;if(n.id!==t?.attrs.id&&(n.id==null?delete this.wrapper.dataset.blockId:this.wrapper.dataset.blockId=n.id),n.componentStyle!==(t?.attrs.componentStyle??null))for(let[r,o]of Object.entries(mr(n.componentStyle))){let i=r.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);this.wrapper.style.setProperty(i,typeof o=="number"?`${o}px`:o??"")}this.title&&(n.tone!==t?.attrs.tone&&(this.wrapper.className=`document-callout tone-${n.tone}`),n.title!==t?.attrs.title&&(this.title.textContent=n.title,this.title.hidden=!n.title))}update(t){if(t.type!==this.node.type)return!1;let n=this.node;return this.node=t,t.attrs!==n.attrs&&this.syncAttributes(n),this.controls.updateProps({node:t}),!0}destroy(){this.controls.destroy()}};function Xs(e,t){return n=>"contentComponent"in n.editor&&n.editor.contentComponent?new ou(e,t,n):{dom:n.view.dom.ownerDocument.createElement("span")}}var it=he(Kt(),1);var ve=he(Ue(),1);function Fb({node:e,updateAttributes:t,editor:n,selected:r,getPos:o}){let{renderWidget:i}=(0,it.useContext)(ro),s=Vr({editor:n,selector:({editor:c})=>c.isEditable}),l=(0,it.useRef)({editor:n,updateAttributes:t});l.current={editor:n,updateAttributes:t};let a=(0,it.useCallback)(c=>{l.current.editor.isEditable&&l.current.updateAttributes({data:oo(c)})},[]);return(0,ve.jsx)(Eo,{className:`document-widget${r&&s?" is-selected":""}`,"data-widget-kind":e.attrs.kind,"data-block-id":e.attrs.id??void 0,onPointerDownCapture:c=>{if(!s||c.button!==0||c.shiftKey||c.metaKey||c.ctrlKey)return;if(vl(c.target,c.clientX,c.clientY)){let f=jr(n.state);f&&n.view.dispatch(f);return}let u=o();!r&&typeof u=="number"&&n.commands.setNodeSelection(u)},onClick:c=>{if(!s||c.button!==0||c.shiftKey||c.metaKey||c.ctrlKey)return;if(vl(c.target,c.clientX,c.clientY)||c.target.closest('[data-text-selection="true"]')){c.stopPropagation();return}let u=o();typeof u=="number"&&(n.commands.setNodeSelection(u),c.stopPropagation())},children:(0,ve.jsx)(Sd,{id:e.attrs.id,children:i({kind:e.attrs.kind,data:e.attrs.data,onChange:a,readOnly:!s})})})}var iu=["\u{1F4A1}","\u{1F331}","\u{1F4CC}","\u2728","\u26A0\uFE0F","\u{1F50E}"],su=["sage","sand","blue","rose"];function Wb({node:e,updateAttributes:t,editor:n}){let r=Pe(Fe),o=Vr({editor:n,selector:({editor:i})=>i.isEditable});return(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)("button",{className:"callout-icon",disabled:!o,title:r("callout.changeIcon"),"aria-label":r("callout.changeIconLabel"),onClick:()=>t({icon:iu[(iu.indexOf(e.attrs.icon)+1)%iu.length]}),children:e.attrs.icon}),o&&(0,ve.jsx)("button",{className:"callout-color",title:r("callout.changeColor"),"aria-label":r("callout.changeColorLabel"),onClick:()=>t({tone:su[(su.indexOf(e.attrs.tone)+1)%su.length]})})]})}function Kb({node:e,updateAttributes:t,editor:n,wrapper:r,body:o}){let i=Pe(Fe),s=Vr({editor:n,selector:({editor:d})=>d.isEditable}),[l,a]=Cl("open",!!e.attrs.open,{block:e.attrs.id??null,accept:d=>typeof d=="boolean"}),c=(0,it.useRef)(r),u=Nd(c),f=!!u||(s?!!e.attrs.open:l);return(0,it.useLayoutEffect)(()=>{r.classList.toggle("is-open",f),o.hidden=!f},[r,o,f]),(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)("button",{"aria-label":i(f?"toggle.collapse":"toggle.expand"),"aria-expanded":f,onClick:()=>{let d=!f;if(u&&Sl(null),!n.isEditable)return a(d);d!==e.attrs.open&&t({open:d})},children:(0,ve.jsx)(Yo,{size:16})}),s?(0,ve.jsx)("input",{"aria-label":i("toggle.titleLabel"),value:e.attrs.title,onChange:d=>t({title:d.target.value}),placeholder:i("toggle.titlePlaceholder")}):(0,ve.jsx)("span",{children:e.attrs.title})]})}function Ub({node:e,editor:t,getPos:n,wrapper:r,body:o}){let i=Pe(Fe),s=Vr({editor:t,selector:({editor:M})=>M.isEditable}),[l,a]=Cl("step",0,{block:e.attrs.id??null,accept:Number.isInteger}),c=e.childCount,u=(0,it.useRef)(r),f=Rd(u,":scope > .stepper-steps > [data-node-view-content-react] > [data-step]"),d=Math.min(f>=0?f:l,c-1);(0,it.useLayoutEffect)(()=>{o.dataset.active=String(d)},[o,d]);let p=Array.from({length:c},(M,A)=>Od(e.child(A).attrs.title,A)),h=()=>{let M=n();if(typeof M!="number")throw new Error("The stepper is detached.");return M+1},g=M=>{let A=h();for(let S=0;S<M;S+=1)A+=e.child(S).nodeSize;return A};(0,it.useLayoutEffect)(()=>{let M=()=>{let A=n();if(typeof A!="number")return;let S=t.state.doc.nodeAt(A);if(S?.type.name!=="stepper")return;let{from:L}=t.state.selection;if(L<=A||L>=A+S.nodeSize)return;let X=A+1;for(let G=0;G<S.childCount;G+=1)if(X+=S.child(G).nodeSize,L<X)return a(G)};return t.isEditable&&t.isFocused&&M(),t.on("selectionUpdate",M),()=>{t.off("selectionUpdate",M)}},[t,n,a]);let m=M=>{let{tr:A}=t.state,S=M(A);return t.view.dispatch(A),a(S),S},w=M=>m(A=>(A.setNodeMarkup(g(d),void 0,{...e.child(d).attrs,title:M}),d)),k=()=>{m(M=>{let{schema:A}=t.state,S=g(d)+e.child(d).nodeSize;return M.insert(S,A.nodes.step.create({title:""},A.nodes.paragraph.create())),M.setSelection(P.create(M.doc,S+2)),d+1}),t.view.focus()},x=()=>m(M=>{let A=g(d);return M.delete(A,A+e.child(d).nodeSize),Math.max(0,d-1)}),E=M=>m(A=>{let S=d+M,L=e.child(d),X=g(d),G=M<0?g(S):g(S)+e.child(S).nodeSize;return A.delete(X,X+L.nodeSize),A.insert(A.mapping.map(G),L),S});return(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)(Ld,{titles:p,active:d,onSelect:M=>{f>=0&&Sl(null),a(M)}}),s&&(0,ve.jsxs)("div",{className:"stepper-edit",contentEditable:!1,children:[(0,ve.jsx)("input",{"aria-label":i("stepper.titleLabel"),placeholder:i("stepper.titlePlaceholder"),value:e.child(d).attrs.title??"",onChange:M=>w(M.target.value)}),(0,ve.jsx)("button",{type:"button",title:i("stepper.moveEarlier"),"aria-label":i("stepper.moveEarlier"),disabled:d===0,onClick:()=>E(-1),children:"\u21A4"}),(0,ve.jsx)("button",{type:"button",title:i("stepper.moveLater"),"aria-label":i("stepper.moveLater"),disabled:d===c-1,onClick:()=>E(1),children:"\u21A6"}),(0,ve.jsx)("button",{type:"button",title:i("stepper.add"),"aria-label":i("stepper.add"),disabled:c>=Pu,onClick:k,children:"+"}),(0,ve.jsx)("button",{type:"button",title:i("stepper.remove"),"aria-label":i("stepper.remove"),disabled:c<=1,onClick:x,children:"\xD7"})]})]})}function qb({node:e,updateAttributes:t,editor:n,selected:r}){let o=Pe(Fe),i=e.type.name==="mathBlock"||e.attrs.display;return Dd(),(0,ve.jsxs)(Eo,{as:i?"div":"span",className:i?"sb-math-display":"sb-math-inline",contentEditable:!1,children:[(0,ve.jsx)("span",{dangerouslySetInnerHTML:{__html:Du(e.attrs.latex,i)}}),r&&n.isEditable&&(0,ve.jsx)("input",{"aria-label":o("math.source"),value:e.attrs.latex,onChange:s=>t({latex:s.target.value}),onKeyDown:s=>{s.key==="Escape"&&(s.preventDefault(),n.commands.focus())}})]})}function Gb({node:e,editor:t,updateAttributes:n}){return(0,ve.jsx)(Eo,{"data-block-id":e.attrs.id,"data-drag-handle":!0,contentEditable:!1,children:(0,ve.jsx)(Md,{attrs:e.attrs,onSourceChange:t.isEditable?r=>n({src:r}):void 0})})}function Jb({node:e,updateAttributes:t,editor:n,selected:r}){let{renderWidget:o}=(0,it.useContext)(ro),i=Vr({editor:n,selector:({editor:a})=>a.isEditable}),s=(0,it.useRef)({editor:n,updateAttributes:t});s.current={editor:n,updateAttributes:t};let l=(0,it.useCallback)(a=>{s.current.editor.isEditable&&s.current.updateAttributes({data:oo(a)})},[]);return(0,ve.jsx)(Eo,{as:"span",className:`sb-inline-widget${r&&i?" is-selected":""}`,"data-widget-kind":e.attrs.kind,"data-block-id":e.attrs.id??void 0,contentEditable:!1,children:o({kind:e.attrs.kind,data:e.attrs.data,onChange:l,readOnly:!i,inline:!0})})}var au=["paragraph","heading","blockquote","bulletList","orderedList","listItem","taskList","taskItem","codeBlock","hardBreak","horizontalRule","image","table","tableRow","tableCell","tableHeader","callout","toggle","stepper","step","widget","inlineWidget","mathInline","mathBlock"],Jr=new oe("showaiBlockIds"),Xb=new WeakSet;function K1(e){let t=new Set([...au,"region","richText","pageModule"]);return new U({key:Jr,appendTransaction(n,r,o){if(!e()||!n.some(a=>a.docChanged||a.getMeta(Jr)||a.getMeta("editableChanged")))return null;let i=new Set,s=o.tr,l=(a,c)=>{let u=a.attrs.id;if(typeof u=="string"&&u.trim()&&!i.has(u)){i.add(u);return}let f;do f=globalThis.crypto.randomUUID();while(i.has(f));i.add(f),s.setNodeAttribute(c,"id",f)};return o.doc.descendants((a,c)=>{if(t.has(a.type.name)&&l(a,c),!a.isTextblock)return!0;if(Xb.has(a))return!1;let u=!0;return a.forEach(f=>{t.has(f.type.name)&&(u=!1)}),u&&Xb.add(a),!u}),s.docChanged?s.setMeta(Jr,!0).setMeta("addToHistory",!1):null}})}var U1=le.create({name:"showaiStableBlockIds",addOptions:()=>({readOnly:!1}),addGlobalAttributes(){return[{types:[...au,"region","richText","pageModule"],attributes:{id:{default:null,parseHTML:e=>e.getAttribute("data-block-id"),renderHTML:e=>typeof e.id=="string"&&e.id.trim()?{"data-block-id":e.id}:{}}}}]},addProseMirrorPlugins(){return[K1(()=>!this.options.readOnly&&this.editor.isEditable)]},onCreate(){!this.options.readOnly&&this.editor.isEditable&&this.editor.view.dispatch(this.editor.state.tr.setMeta(Jr,!0).setMeta("addToHistory",!1))}}),q1=ee.create({name:"widget",group:"block",atom:!0,draggable:!0,addAttributes(){return{kind:{default:"chart"},data:{default:{},parseHTML:e=>{let t=e.getAttribute("data-widget-content");if(!t)return{};try{return JSON.parse(t)}catch{return{}}},renderHTML:e=>({"data-widget-content":JSON.stringify(e.data)})}}},parseHTML:()=>[{tag:"div[data-showai-widget]"}],renderHTML:({HTMLAttributes:e})=>["div",K(e,{"data-showai-widget":""})],addNodeView:()=>Mo(Fb)}),G1=ee.create({name:"inlineWidget",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes(){return{kind:{default:"date"},data:{default:{date:"2026-01-01"},parseHTML:e=>{let t=e.getAttribute("data-widget-content");if(!t)return{};try{return JSON.parse(t)}catch{return{}}},renderHTML:e=>({"data-widget-content":JSON.stringify(e.data)})}}},parseHTML:()=>[{tag:"span[data-showai-inline-widget]",getAttrs:e=>({kind:e.getAttribute("data-widget-kind")})}],renderHTML:({node:e,HTMLAttributes:t})=>["span",K(t,{"data-showai-inline-widget":"","data-widget-kind":e.attrs.kind})],addNodeView:()=>Mo(Jb)}),J1=ee.create({name:"callout",group:"block",content:"block+",defining:!0,draggable:!0,addAttributes:()=>({icon:{default:"\u{1F4A1}"},tone:{default:"sage"},title:{default:""}}),parseHTML:()=>[{tag:"aside[data-callout]"}],renderHTML:({HTMLAttributes:e})=>["aside",K(e,{"data-callout":""}),0],addNodeView:()=>Xs("callout",Wb)}),X1=ee.create({name:"toggle",group:"block",content:"block+",defining:!0,draggable:!0,addAttributes:()=>({title:{default:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A"},open:{default:!0}}),parseHTML:()=>[{tag:"section[data-toggle]"}],renderHTML:({HTMLAttributes:e})=>["section",K(e,{"data-toggle":""}),0],addNodeView:()=>Xs("toggle",Kb)}),Y1=ee.create({name:"stepper",group:"block",content:"step+",defining:!0,draggable:!0,isolating:!0,parseHTML:()=>[{tag:"section[data-stepper]"}],renderHTML:({HTMLAttributes:e})=>["section",K(e,{"data-stepper":""}),0],addNodeView:()=>Xs("stepper",Ub)}),Q1=ee.create({name:"step",content:"block+",defining:!0,isolating:!0,addAttributes:()=>({title:{default:""}}),parseHTML:()=>[{tag:"section[data-step]"}],renderHTML:({HTMLAttributes:e})=>["section",K(e,{"data-step":""}),0]}),Z1=ee.create({name:"richText",priority:50,group:"block",content:"block*",defining:!0,addAttributes:()=>({id:{default:null},name:{default:"\u5BCC\u6587\u672C"},data:{default:{},parseHTML:e=>JSON.parse(e.getAttribute("data-rich-text-settings")||"{}"),renderHTML:()=>({})}}),parseHTML:()=>[{tag:'div[data-component-kind="text"]'},{tag:'div[data-page-flow="richText"]'}],renderHTML:({node:e,HTMLAttributes:t})=>["div",K(t,{"data-component-kind":"text","data-rich-text-settings":JSON.stringify(e.attrs.data),class:"page-document-flow rich-text-component",style:Object.entries(mr(e.attrs.data)).filter(([,n])=>n!==void 0).map(([n,r])=>`${n.replace(/[A-Z]/g,o=>"-"+o.toLowerCase())}:${typeof r=="number"?`${r}px`:r}`).join(";")}),0]}),eM=We.create({name:"textStyle",addAttributes:()=>Object.fromEntries(["color","fontFamily","fontSize"].map(e=>[e,{default:null,parseHTML:t=>t.style[e],renderHTML:t=>t[e]?{style:`${e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}: ${t[e]}`}:{}}])),parseHTML:()=>[{tag:"span[style]"}],renderHTML:({HTMLAttributes:e})=>["span",K(e),0]}),tM=We.create({name:"annotation",inclusive:!1,addAttributes:()=>({note:{default:"",parseHTML:e=>e.getAttribute("data-showai-note")??"",renderHTML:e=>({"data-showai-note":e.note??""})}}),parseHTML:()=>[{tag:"span[data-showai-note]"}],renderHTML:({HTMLAttributes:e})=>["span",K({class:"showai-note"},e),0]}),Yb=e=>ee.create({name:e?"mathInline":"mathBlock",group:e?"inline":"block",inline:e,atom:!0,addAttributes:()=>({latex:{default:""},display:{default:!e}}),parseHTML:()=>[{tag:e?"span[data-math]":"div[data-math]"}],renderHTML:({node:t,HTMLAttributes:n})=>[e?"span":"div",{...n,"data-math":t.attrs.latex}],addNodeView:()=>Mo(qb)}),Qb=kr(Fe);function Zb(e={}){return[nM,Z1,eM,tM,Yb(!0),Yb(!1),U1.configure({readOnly:e.readOnly??!1}),jb,Yg.configure({trailingNode:e.trailingNode===!1?!1:{},heading:{levels:[1,2,3,4,5,6]},link:{openOnClick:e.readOnly??!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"},isAllowedUri:(t,n)=>!!hr(t)||n.defaultValidate(t)},codeBlock:!1}),Sb,Eb.configure({placeholder:({node:t,editor:n})=>t.type.name==="heading"?Qb("placeholderHeading"):typeof e.placeholder=="function"?e.placeholder({empty:n.isEmpty}):e.placeholder??Qb("placeholderDefault"),includeChildren:!1}),Mb.extend({addNodeView:()=>Mo(Gb)}).configure({allowBase64:!0,HTMLAttributes:{class:"document-image"}}),$b.configure({table:{resizable:!0,View:lu}}),Bm,Bb,zb.configure({nested:!0}),_b.configure({multicolor:!0}),Vb.configure({types:["heading","paragraph"]}),J1,X1,Y1,Q1,q1,G1]}var nM=le.create({name:"showaiContentAttributes",addGlobalAttributes(){let e=t=>({default:null,parseHTML:n=>{let r=n.getAttribute(`data-content-${t.toLowerCase()}`);if(r===null)return null;try{return t==="title"?r:JSON.parse(r)}catch{return null}},renderHTML:n=>n[t]==null?{}:{[`data-content-${t.toLowerCase()}`]:t==="title"?String(n[t]):JSON.stringify(n[t]),...t==="componentStyle"?{style:Object.entries({...mr(n[t]),borderTopColor:n[t]?.color}).filter(([,r])=>r!==void 0).map(([r,o])=>`${r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}:${typeof o=="number"?`${o}px`:o}`).join(";")}:{}}});return[{types:au,attributes:{name:{...e("name"),default:"",parseHTML:t=>{let n=e("name").parseHTML(t);return typeof n=="string"?n:""}}}},{types:["image","codeBlock","table","callout","toggle","stepper","horizontalRule"],attributes:{componentStyle:e("componentStyle")}},{types:["image"],attributes:Object.fromEntries(["caption","fit","nativeInk","width","height","align"].map(t=>[t,e(t)]))},{types:["table"],attributes:{title:e("title")}}]}}),lu=class extends ru{constructor(...t){super(...t),this.syncMetadata()}syncMetadata(){let t=mr(this.node.attrs.componentStyle);this.dom.style.cssText="",Object.assign(this.dom.style,Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0).map(([r,o])=>[r,typeof o=="number"?`${o}px`:o]))),this.node.attrs.id&&(this.table.dataset.blockId=this.node.attrs.id);let n=this.node.attrs.title;if(n){let r=this.table.caption??this.table.createCaption();r.textContent=n}else this.table.caption?.remove();this.dom.tabIndex=0}update(t){return super.update(t)?(this.syncMetadata(),!0):!1}};var v=he(Ue(),1),ey=new WeakSet,ty=kr(Fe);function rM({children:e,className:t,onDismiss:n}){return(0,v.jsx)("div",{className:t,onMouseDown:r=>{r.target===r.currentTarget&&n()},children:e})}function jt({label:e,children:t,onClick:n,active:r,disabled:o}){return(0,v.jsx)("button",{type:"button",className:`editor-tool${r?" is-active":""}`,"aria-label":e,title:e,"aria-pressed":r,disabled:o,onMouseDown:i=>i.preventDefault(),onClick:n,children:t})}function oM(e){return/^https?:\/\//i.test(e)||/^data:image\/(png|jpe?g|gif|webp|avif);base64,/i.test(e)||Tu(e,"image")}function ny(e){return/^(https?:\/\/|mailto:|tel:|#)/i.test(e)||!!hr(e)}function uu(e){return e.startsWith("page-tail-")}function Ys(e,t){let n=e.view.coordsAtPos(Math.min(t,e.state.doc.content.size));return{left:Math.max(12,Math.min(n.left,window.innerWidth-340)),top:Math.max(70,Math.min(n.bottom+8,window.innerHeight-370))}}function iM({content:e,onChange:t,readOnly:n=!1,minimal:r=!0,onEditorReady:o,onInsertNative:i,onDetachBlock:s,additionalExtensions:l,trailingNode:a=!0,emitInitialUpdate:c=!0,retentionKey:u}){let f=(0,D.useMemo)(()=>Lu(e),[e]),d=Pe(Fe),p=Pe(Ed),h=Pe(ai),g=Pe(vd),m=Cd(),w=(0,D.useRef)(t),k=(0,D.useId)();w.current=t;let x=(0,D.useRef)(null),E=(0,D.useRef)(()=>!1),M=(0,D.useRef)(null),A=(0,D.useRef)(null),S=(0,D.useRef)(null),L=(0,D.useRef)(null),X=(0,D.useRef)(()=>!1),G=(0,D.useRef)(null),[fe,Be]=(0,D.useState)(null),[ye,De]=(0,D.useState)(null),Oe=(0,D.useRef)(null),N=(0,D.useRef)(null),j=(0,D.useRef)(()=>!1),{useCatalog:ne,registerComponent:Ce,assistant:me,pageLinks:Se,comments:wt}=(0,D.useContext)(ro),An=(0,D.useRef)(Se);An.current=Se;let we=ne(!!fe||!!ye),[Ke,Tn]=(0,D.useState)(!1),Mt=(0,D.useRef)(0);(0,D.useEffect)(()=>()=>{Mt.current++},[]);let[se,At]=(0,D.useState)(null),[ct,ze]=(0,D.useState)(!1),cn=(0,D.useRef)(null),Nn=(0,D.useRef)(ct);Nn.current=ct;let Rn=(0,D.useRef)(0),ut=(0,D.useRef)(0);(0,D.useEffect)(()=>()=>cancelAnimationFrame(Rn.current),[]);let Tt=(0,D.useCallback)(()=>{cn.current!==null&&(clearTimeout(cn.current),cn.current=null)},[]),lr=(0,D.useCallback)(()=>{cn.current===null&&(cn.current=setTimeout(()=>{cn.current=null;let b=x.current?.querySelector(".block-handle");Nn.current||G.current!==null||b?.contains(document.activeElement)||At(null)},450))},[]);(0,D.useEffect)(()=>Tt,[Tt]);let[q,Ft]=(0,D.useState)(!1),[Re,re]=(0,D.useState)(!1),[Y,Me]=(0,D.useState)(null),[Nt,ar]=(0,D.useState)(null),[O,B]=(0,D.useState)(""),[J,ae]=(0,D.useState)(""),[Ee,Le]=(0,D.useState)(null);(0,D.useEffect)(()=>{!Ee&&Nt&&(Me(null),ar(null))},[!!Ee,Nt]);let[Zs,Xr]=(0,D.useState)(!1),[du,ry]=(0,D.useState)(!1),cr=(0,D.useRef)(null),ur=(0,D.useRef)(null),kt=(0,D.useRef)(!1),[,fu]=(0,D.useState)(0),vt=(0,D.useRef)(null);S.current=fe,Oe.current=ye;let oy=(0,D.useMemo)(()=>[...Zb({placeholder:({empty:b})=>ty(b&&!a?"placeholderPage":"placeholder"),trailingNode:a}),...l??[]],[l,a]);(0,D.useLayoutEffect)(()=>{if(!ct)return;let b=x.current,C=b?.querySelector(".block-menu"),T=b?.querySelector(".block-handle");if(!C||!T)return;let I=()=>{let z=T.getBoundingClientRect(),ce=C.getBoundingClientRect();Object.assign(C.style,{position:"fixed",left:`${Math.max(12,Math.min(z.right,window.innerWidth-ce.width-12))}px`,top:`${Math.max(12,Math.min(z.top,window.innerHeight-ce.height-12))}px`})};I();let $=new ResizeObserver(I);return $.observe(C),window.addEventListener("resize",I),window.addEventListener("scroll",I,!0),()=>{$.disconnect(),window.removeEventListener("resize",I),window.removeEventListener("scroll",I,!0)}},[ct,se?.pos]);let y=Zh({retentionKey:u,extensions:oy,content:f,editable:!n,immediatelyRender:!1,shouldRerenderOnTransaction:!1,editorProps:{attributes:{class:"document-content","aria-label":ty("documentContent"),spellcheck:"false"},handleKeyDown:(b,C)=>C.isComposing?!1:C.key==="Escape"&&!S.current&&!b.state.selection.empty?(ur.current=`${b.state.selection.from}:${b.state.selection.to}`,Le(null),C.preventDefault(),!0):Oe.current?j.current(C)?!0:C.key==="Escape"?(el(),!0):!1:S.current?X.current(C)?!0:C.key==="Escape"?(tl(),!0):!1:!1,handleClick:(b,C,T)=>{let I=T.target.closest?.("a[href]");if(!I||!n&&!T.metaKey&&!T.ctrlKey||!n&&!I.isContentEditable)return!1;let $=I.getAttribute("href")??"";if(!ny($))return!0;let z=Mu($);return z&&Au(I,z,n?T:void 0)||($.startsWith("#")?document.getElementById($.slice(1))?.scrollIntoView({behavior:"smooth",block:"start"}):z||window.open($,"_blank","noopener,noreferrer")),!0},handlePaste:(b,C)=>{let T=C.clipboardData?.getData("text/plain").trim()??"";if(hr(T)){C.preventDefault();let{empty:z,from:ce,to:xe}=b.state.selection,Ae=b.state.schema.marks.link.create({href:T});return b.dispatch(z?b.state.tr.insert(ce,b.state.schema.text(mu(T),[Ae])):b.state.tr.addMark(ce,xe,Ae)),!0}let $=[...C.clipboardData?.files??[]].filter(z=>z.type.startsWith("image/"));return $.length?(C.preventDefault(),rl($),!0):!1}},onUpdate:({editor:b,transaction:C})=>{!c&&C.getMeta(Jr)||w.current(Ya(b.state.doc),{separateHistory:!!C.getMeta(tr),historyGroup:C.getMeta(yd)})}});(0,D.useEffect)(()=>y?wd(y):void 0,[y]),(0,D.useEffect)(()=>{y&&o?.(y)},[y,o]),(0,D.useEffect)(()=>{y&&y.isEditable===n&&(y.setEditable(!n,!1),y.view.dispatch(y.state.tr.setMeta("editableChanged",!0))),fu(b=>b+1),n&&(Be(null),De(null),At(null),ze(!1),Ft(!1),re(!1),Me(null),Le(null))},[y,n]);let pu=(0,D.useRef)(f);pu.current=f;let Ko=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(!y)return;let b=()=>{Ko.current=!0},C=()=>{Ko.current=!1};return y.on("beforeTransaction",b),y.on("transaction",C),()=>{y.off("beforeTransaction",b),y.off("transaction",C)}},[y]),(0,D.useLayoutEffect)(()=>{if(!y)return;let b,C=()=>{if(y.isDestroyed)return;if(y.view.composing||Ko.current){b=setTimeout(C,Ko.current?0:25);return}let I=om(y.state,pu.current);if(!I)return;let $=y.state.selection instanceof _&&y.state.selection.node.type.name==="widget"?y.state.selection.node.attrs.id:null,z=y.state.selection instanceof ie?y.state.selection:null;if(y.view.dispatch(I),z){let ce=Im(y.state.doc,z);ce&&y.view.dispatch(y.state.tr.setSelection(ce))}if($){let ce;if(y.state.doc.descendants((xe,Ae)=>{xe.type.name==="widget"&&xe.attrs.id===$&&(ce=Ae)}),ce!==void 0)y.commands.setNodeSelection(ce);else{let xe=jr(y.state);xe&&y.view.dispatch(xe)}}},T=()=>{b=setTimeout(C,25)};return y.view.composing?y.view.dom.addEventListener("compositionend",T):C(),()=>{b&&clearTimeout(b),y.view.dom.removeEventListener("compositionend",T)}},[f,y]),(0,D.useEffect)(()=>{if(!Y)return;let b=requestAnimationFrame(()=>document.querySelector(".editor-modal input, .editor-modal textarea")?.focus()),C=T=>{if(T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),Me(null),y?.commands.focus()),T.key!=="Tab")return;let I=Array.from(document.querySelectorAll(".editor-modal button:not(:disabled), .editor-modal input:not(:disabled), .editor-modal textarea:not(:disabled)")),$=I[0],z=I[I.length-1];T.shiftKey&&document.activeElement===$?(T.preventDefault(),z?.focus()):!T.shiftKey&&document.activeElement===z&&(T.preventDefault(),$?.focus())};return document.addEventListener("keydown",C,!0),()=>{cancelAnimationFrame(b),document.removeEventListener("keydown",C,!0)}},[!!Y,y]),(0,D.useEffect)(()=>{if(!y||n)return;let b=()=>{let C=jr(y.state);C&&y.view.dispatch(C)};return!ey.has(y)&&!Qh(y)&&(ey.add(y),y.isInitialized?b():y.on("create",b)),()=>{y.off("create",b)}},[y,n]),(0,D.useEffect)(()=>{if(!y||n||!du)return;let b=C=>{if(C.button!==0||!(C.target instanceof Element))return;let T=C.target,I=T.closest(".document-widget");if(I&&y.view.dom.contains(I)||!I&&T.closest('button, input, textarea, select, a, summary, [role="button"], [role="dialog"], .block-handle, .editor-toolbar, .editor-bubble, .editor-small-menu, .editor-modal'))return;let $=jr(y.state);if(!$)return;let z=document.activeElement;z instanceof HTMLElement&&y.view.dom.contains(z)&&z.blur(),y.view.dispatch($),y.view.dom.contains(T)&&!T.closest("[data-block-id]")&&C.preventDefault()};return document.addEventListener("pointerdown",b,!0),()=>{document.removeEventListener("pointerdown",b,!0)}},[y,n,du]),(0,D.useEffect)(()=>{if(!fe?.manual)return;let b=requestAnimationFrame(()=>A.current?.focus());return()=>cancelAnimationFrame(b)},[fe?.manual]),(0,D.useEffect)(()=>{if(!q&&!Re&&!ct)return;let b=C=>{C.key==="Escape"&&(C.preventDefault(),Ft(!1),re(!1),ze(!1),y?.commands.focus())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[q,Re,ct,y]),(0,D.useEffect)(()=>{if(!J)return;let b=window.setTimeout(()=>ae(""),4500);return()=>window.clearTimeout(b)},[J]),(0,D.useEffect)(()=>{if(!y)return;let b=null,C=0,T=()=>{if(ry(y.state.selection instanceof _&&y.state.selection.node.type.name==="widget"),(!r||!y.state.selection.empty)&&fu(Wt=>Wt+1),!y.isEditable)return;let{selection:Te}=y.state,{$from:dn,from:fn,to:eo,empty:qo}=Te;if((qo||ur.current&&ur.current!==`${fn}:${eo}`)&&(ur.current=null),!S.current?.manual){let Wt=dn.parent.isTextblock?dn.parent.textBetween(0,dn.parentOffset,`
|
|
155
|
+
`):"",Ct=qo&&Wt.match(/^\/([^\n/]*)$/);if(Ct){let Dn=fn-Ct[0].length;L.current!==`${Dn}:${eo}:${Ct[1]}`&&(L.current=null,Be({from:Dn,to:eo,query:Ct[1],...Ys(y,fn)}))}else Be(null),L.current=null}if(!y.view.composing){let Wt=qo&&dn.parent.isTextblock&&!dn.parent.type.spec.code?dn.parent.textBetween(0,dn.parentOffset,`
|
|
156
|
+
`,"\uFFFC"):"",Ct=!dn.marks().some(Dn=>Dn.type.name==="code")&&Wt.match(/(?:^|[\s((「“"'])@([^\s@\ufffc][^\n@\ufffc]{0,39}|)$/u);if(Ct){let Dn=fn-Ct[1].length-1;N.current!==Dn&&De({from:Dn,to:fn,query:Ct[1],...Ys(y,fn)})}else De(null),N.current=null}if(!qo&&b===null&&ur.current!==`${fn}:${eo}`&&(y.isFocused||kt.current)&&!y.isActive("codeBlock")&&!y.isActive("widget")&&!y.isActive("pageModule")){let Wt=y.view.coordsAtPos(fn),Ct=y.view.coordsAtPos(eo);Le({left:(Wt.left+Ct.right)/2,top:Wt.top,bottom:Math.max(Wt.bottom,Ct.bottom)})}else Le(null)},I=Te=>Te instanceof Element&&Te.closest(".editor-bubble")?.id===k,$=Te=>{I(Te.relatedTarget)&&(kt.current=!0)},z=()=>{kt.current=!1,Le(null)},ce=()=>{b=null,document.removeEventListener("pointerup",xe,!0),document.removeEventListener("pointercancel",Ae,!0),window.removeEventListener("blur",Ae)},xe=Te=>{Te.pointerId===b&&(ce(),C=requestAnimationFrame(T))},Ae=()=>{ce(),cancelAnimationFrame(C),z()},Dt=Te=>{Te.button!==0||!Te.isPrimary||!(Te.target instanceof Element)||Te.target.closest(".document-content")!==y.view.dom||(cancelAnimationFrame(C),b=Te.pointerId,z(),document.addEventListener("pointerup",xe,!0),document.addEventListener("pointercancel",Ae,!0),window.addEventListener("blur",Ae))},sl=Te=>{kt.current=I(Te.target),!kt.current&&(!(Te.target instanceof Node)||!y.view.dom.contains(Te.target))&&z()},Qr=({event:Te})=>{!kt.current&&!I(Te.relatedTarget)&&z()},Zr=Te=>{I(Te.target)||z()},hy=Te=>{!(Te.target instanceof Element)||!Te.target.contains(y.view.dom)||(Le(null),Be(null),De(null),ze(!1),At(null))},Su=()=>Xr(!0),Eu=()=>Xr(!1);return Xr(y.isFocused),cr.current={trackMenuInteraction:sl,scroll:Zr,resize:T,viewportChanged:hy},y.on("transaction",T),y.on("focus",T),y.on("focus",Su),y.on("blur",Qr),y.on("blur",Eu),y.view.dom.addEventListener("blur",$,!0),y.view.dom.addEventListener("pointerdown",Dt,!0),y.view.dom.addEventListener("contextmenu",z),()=>{ce(),cancelAnimationFrame(C),cr.current=null,y.off("transaction",T),y.off("focus",T),y.off("focus",Su),y.off("blur",Qr),y.off("blur",Eu),y.view.dom.removeEventListener("blur",$,!0),y.view.dom.removeEventListener("pointerdown",Dt,!0),y.view.dom.removeEventListener("contextmenu",z)}},[y,k,r]);let hu=Zs||!!Ee||!!fe||!!ye||ct||!!se;(0,D.useEffect)(()=>{if(!y||!hu)return;let b=z=>cr.current?.trackMenuInteraction(z),C=z=>cr.current?.scroll(z),T=()=>cr.current?.resize(),I=z=>cr.current?.viewportChanged(z),$=new ResizeObserver(T);return $.observe(y.view.dom),document.addEventListener("pointerdown",b,!0),document.addEventListener("focusin",b,!0),window.addEventListener("scroll",C,!0),window.addEventListener("resize",T),window.addEventListener("showai:viewport-change",I),()=>{$.disconnect(),document.removeEventListener("pointerdown",b,!0),document.removeEventListener("focusin",b,!0),window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",T),window.removeEventListener("showai:viewport-change",I)}},[y,hu]);function el(){let b=Oe.current;b&&(N.current=b.from),Oe.current=null,De(null)}function tl(){let b=S.current;b&&!b.manual&&(L.current=`${b.from}:${b.to}:${b.query}`),S.current=null,Be(null)}function mu(b){let C=hr(b),T=An.current;return C&&T?.projectId===C.projectId&&T.pages.find($=>$.id===C.pageId)?.title||b}function gu(b){y&&(vt.current&&y.commands.setTextSelection(vt.current),b?y.state.selection.empty&&!y.isActive("link")?y.chain().focus().insertContent({type:"text",text:mu(b),marks:[{type:"link",attrs:{href:b}}]}).run():y.chain().focus().extendMarkRange("link").setLink({href:b}).run():y.chain().focus().extendMarkRange("link").unsetLink().run(),Me(null))}let Yr=Y?.type==="link"&&Se&&!/^[a-z][a-z0-9+.-]*:|^#/i.test(Y.value.trim())?Y.value.trim().toLocaleLowerCase():null,Rt=(0,D.useMemo)(()=>Yr===null||!Se?[]:Se.pages.filter(b=>b.id!==Se.pageId&&(b.title||d("dialog.untitledPage")).toLocaleLowerCase().includes(Yr)).slice(0,6).map(b=>({...b,href:Jo({projectId:Se.projectId,pageId:b.id})})),[Yr,Se,d]),[Uo,nl]=(0,D.useState)(-1);(0,D.useEffect)(()=>nl(Yr?0:-1),[Yr]);let dr=(0,D.useCallback)(b=>{if(!y)return;let{selection:C}=y.state;vt.current={from:C.from,to:C.to};let T=b==="note"&&C instanceof _&&["mathInline","mathBlock"].includes(C.node.type.name)?C.node:null,I=T?Ru(String(T.attrs.latex??"")):null;Me({type:b,value:b==="link"?y.getAttributes("link").href??"":b==="note"?T?I?.note??"":y.getAttributes("annotation").note??"":"",alt:"",hadNote:b==="note"&&(T?!!I:y.isActive("annotation")),...T?{math:{pos:C.from,body:I?.body??String(T.attrs.latex??"")}}:{}}),B(""),re(!1);let $=b!=="image"?document.getElementById(k):null;ar($),$||Le(null)},[y,k]);function bu(b,C){if(!y)return!1;if(C.length>1e3)return B(h("dialog.noteTooLong",{max:1e3})),!1;if(b.math){let{pos:I,body:$}=b.math,z=y.state.doc.nodeAt(I);return!z||!["mathInline","mathBlock"].includes(z.type.name)?(B(h("dialog.noteTargetMissing")),!1):(y.chain().focus().command(({tr:ce})=>(ce.setNodeMarkup(I,void 0,{...z.attrs,latex:C?Nu($,C):$}),!0)).run(),!0)}if(vt.current&&y.commands.setTextSelection(vt.current),y.state.selection.empty&&!y.isActive("annotation"))return B(h("dialog.noteNeedsSelection")),!1;let T=y.chain().focus();return y.state.selection.empty&&T.extendMarkRange("annotation"),C?T.setMark("annotation",{note:C}):T.unsetMark("annotation"),T.run(),!0}async function iy(){if(!y||!y.isEditable||!m)return;let b=await m("image",!0).catch(C=>(B(C instanceof Error?C.message:String(C)),[]));if(!(!b.length||y.isDestroyed||!y.isEditable)){vt.current&&y.commands.setTextSelection(vt.current);for(let C of b)y.chain().focus().setImage({src:C.ref,alt:C.name.replace(/\.[^.]+$/,"")}).run();Me(null)}}async function rl(b,C=!1){if(!y||!y.isEditable)return;C&&vt.current&&y.commands.setTextSelection(vt.current);let T=y.state.selection.getBookmark(),I=({transaction:$})=>{T=T.map($.mapping)};y.on("transaction",I);for(let $ of b){let z=await Hd($);if("problem"in z){ae(z.problem);continue}if(y.isDestroyed||!y.isEditable)break;let ce=T.resolve(y.state.doc);y.view.dispatch(y.state.tr.setSelection(ce)),y.chain().focus().setImage({src:z.src,alt:$.name}).run(),T=y.state.selection.getBookmark()}y.off("transaction",I),Me(null)}let ol=(0,D.useMemo)(()=>[{id:"text",title:d("block.text"),keywords:`text paragraph ${d("block.textKeywords")}`,icon:(0,v.jsx)(Zo,{size:20}),group:d("group.basic"),run:b=>{b.chain().focus().setParagraph().run()}},...[1,2,3,4,5,6].map(b=>({id:`heading-${b}`,title:d("block.heading",{level:b}),keywords:`heading h${b} ${d("block.headingKeywords")}`,icon:[(0,v.jsx)(Gu,{size:20}),(0,v.jsx)(Ju,{size:20}),(0,v.jsx)(Xu,{size:20}),(0,v.jsx)(Yu,{size:20}),(0,v.jsx)(Qu,{size:20}),(0,v.jsx)(Zu,{size:20})][b-1],group:d("group.basic"),hidden:b>3,run:C=>{C.chain().focus().setHeading({level:b}).run()}})),{id:"bullet",title:d("block.bullet"),keywords:`bullet list ${d("block.bulletKeywords")}`,icon:(0,v.jsx)(dl,{size:20}),group:d("group.basic"),run:b=>{b.chain().focus().toggleBulletList().run()}},{id:"ordered",title:d("block.ordered"),keywords:`ordered numbered list ${d("block.orderedKeywords")}`,icon:(0,v.jsx)(ul,{size:20}),group:d("group.basic"),run:b=>{b.chain().focus().toggleOrderedList().run()}},{id:"todo",title:d("block.todo"),keywords:`todo task check ${d("block.todoKeywords")}`,icon:(0,v.jsx)(hl,{size:20}),group:d("group.basic"),run:b=>{b.chain().focus().toggleTaskList().run()}},{id:"quote",title:d("block.quote"),keywords:`blockquote quote ${d("block.quoteKeywords")}`,icon:(0,v.jsx)(fl,{size:20}),group:d("group.basic"),run:b=>{b.chain().focus().toggleBlockquote().run()}},{id:"callout",title:d("block.callout"),keywords:`callout note ${d("block.calloutKeywords")}`,icon:(0,v.jsx)(nd,{size:20}),group:d("group.basic"),run:b=>{b.chain().focus().insertContent({type:"callout",attrs:{icon:"\u{1F4A1}",tone:"sage"},content:[{type:"paragraph",content:[{type:"text",text:"\u5728\u8FD9\u91CC\u8BB0\u5F55\u4E00\u4E2A\u503C\u5F97\u6CE8\u610F\u7684\u53D1\u73B0\u3002"}]}]}).run()}},{id:"toggle",title:d("block.toggle"),keywords:`toggle details ${d("block.toggleKeywords")}`,icon:(0,v.jsx)(Yo,{size:20}),group:d("group.basic"),run:b=>{b.chain().focus().insertContent({type:"toggle",attrs:{title:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A",open:!0},content:[{type:"paragraph"}]}).run()}},{id:"stepper",title:d("block.stepper"),keywords:`stepper steps ${d("block.stepperKeywords")}`,icon:(0,v.jsx)($u,{size:20}),group:d("group.basic"),run:b=>{let C={type:"step",content:[{type:"paragraph"}]},{from:T}=b.state.selection;b.chain().focus().insertContent({type:"stepper",content:[C,C]}).command(({tr:I})=>{let $=-1;return I.doc.nodesBetween(Math.max(0,T-1),I.doc.content.size,(z,ce)=>($<0&&z.type.name==="stepper"&&($=ce),$<0)),$>=0&&I.setSelection(P.create(I.doc,$+3)),!0}).run()}},{id:"divider",title:d("block.divider"),keywords:`divider hr ${d("block.dividerKeywords")}`,icon:(0,v.jsx)(od,{size:20}),group:d("group.basic"),run:b=>{b.chain().focus().setHorizontalRule().run()}},{id:"image",title:d("block.image"),keywords:`image photo ${d("block.imageKeywords")}`,icon:(0,v.jsx)(cl,{size:20}),group:d("group.rich"),run:()=>dr("image")},{id:"code",title:d("block.code"),keywords:`code snippet ${d("block.codeKeywords")}`,icon:(0,v.jsx)(_u,{size:20}),group:d("group.rich"),run:b=>{b.chain().focus().toggleCodeBlock().run()}},{id:"table",title:d("block.table"),keywords:`table ${d("block.tableKeywords")}`,icon:(0,v.jsx)(ml,{size:20}),group:d("group.rich"),run:b=>{b.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},...we.items.filter(b=>Bd(b)&&!("kind"in b&&ll[b.kind])&&(!("kind"in b&&b.insertion)||!!i)).map(b=>({...zd(b,d("group.components"),{name:we.displayName,description:we.displayDescription}),icon:(0,v.jsx)(id,{size:20}),run:()=>{}}))],[dr,i,we.items,we.displayName,we.displayDescription,d]),yu=(b,C,T,I=!1)=>{if(y)if(b.component&&Ce(b.component),b.native&&i){let $=y.state.tr.delete(C,T);i(b.kind,b.data,Yd($.doc,C))}else y.chain().focus(I?"end":null).deleteRange({from:C,to:T}).insertContent({...ll[b.kind]?Ou(b.kind,b.data):{type:"widget",attrs:{kind:b.kind,data:b.data}}}).run()};E.current=b=>{if(!y||y.isDestroyed||n||b.native&&!i)return!1;let{from:C,to:T}=b.at==="end"?{from:y.state.doc.content.size,to:y.state.doc.content.size}:y.state.selection;return yu(b,C,T,b.at==="end"),!0},(0,D.useEffect)(()=>{let b=x.current;if(!b)return;let C=T=>{let I=T.detail;I&&E.current(I)&&T.preventDefault()};return b.addEventListener(El,C),()=>b.removeEventListener(El,C)},[y]);let sy=async b=>{let C=S.current;if(!(!y||!C||Ke)){if(b.component){let T=y.state.doc,I=++Mt.current;Tn(!0);try{let $=await we.resolve(b.component);if(I!==Mt.current||y.isDestroyed||S.current!==C||!y.state.doc.eq(T))return;Be(null),S.current=null,yu($,C.from,C.to)}catch($){ae($.message)}finally{I===Mt.current&&Tn(!1)}return}Be(null),S.current=null,C.from!==C.to?y.chain().focus().deleteRange({from:C.from,to:C.to}).run():y.commands.focus(),b.run(y)}},fr=Ml(ol,fe?.query??"",b=>{sy(b)},!!fe);X.current=fr.key;let un=Pe(Kd),wu=kd(),ly=(0,D.useMemo)(()=>ye?Jd({query:ye.query,projectId:Se?.projectId,pageId:Se?.pageId,pages:Se?.pages??[],components:we.items,locale:wu,today:new Date,labels:{pages:un("pages"),today:un("today"),tomorrow:un("tomorrow"),yesterday:un("yesterday")},displayName:we.displayName}):[],[ye?.query,Se,we.items,we.displayName,wu,un]),ay=async b=>{let C=Oe.current;if(!y||!C||Ke)return;let T=b.insertion;if(T.type==="link"){De(null),Oe.current=null,y.chain().focus().deleteRange({from:C.from,to:C.to}).insertContent([{type:"text",text:T.text||T.href,marks:[{type:"link",attrs:{href:T.href}}]},{type:"text",text:" "}]).run();return}let I=y.state.doc,$=++Mt.current;Tn(!0);try{let z=await we.resolve(T.component);if($!==Mt.current||y.isDestroyed||Oe.current!==C||!y.state.doc.eq(I))return;De(null),Oe.current=null,z.component&&Ce(z.component);let ce=z.kind==="custom"?{...z.data,props:{...z.data.props,[T.prop]:T.value}}:{...z.data,[T.prop]:T.value};y.chain().focus().deleteRange({from:C.from,to:C.to}).insertContent([{type:"inlineWidget",attrs:{kind:z.kind,data:ce}},{type:"text",text:" "}]).run()}catch(z){ae(z.message)}finally{$===Mt.current&&Tn(!1)}},pr=Ml(ly,ye?.query??"",b=>{ay(b.entry)},!!ye,$d);j.current=pr.key,(0,D.useEffect)(()=>{ye&&document.querySelector(".slash-menu .slash-item.is-selected")?.scrollIntoView({block:"nearest"})},[pr.selected]),(0,D.useEffect)(()=>{ye&&!pr.rows.length&&/\s$/.test(ye.query)&&el()},[ye,pr.rows.length]),(0,D.useEffect)(()=>{document.querySelector(".slash-menu .slash-item.is-selected")?.scrollIntoView({block:"nearest"})},[fr.selected,fr.charts]);let il=()=>{if(!y)return;L.current=null;let{from:b,to:C}=y.state.selection;Be({from:b,to:C,query:"",manual:!0,...Ys(y,b)}),re(!1)},cy=()=>{if(!y||!se)return;let b=se.pos+se.size;y.chain().focus().insertContentAt(b,{type:"paragraph"}).setTextSelection(b+1).run(),Be({from:b+1,to:b+1,query:"",manual:!0,...Ys(y,b+1)}),ze(!1)};function ku(b,C){if(!y)return;let T=[];y.state.doc.forEach((Ae,Dt)=>T.push({pos:Dt,size:Ae.nodeSize}));let I=T.findIndex(Ae=>Ae.pos===b),$=T[I+C],z=y.state.doc.nodeAt(b);if(!$||!z)return;let ce=C===-1?$.pos:$.pos+$.size-z.nodeSize,xe=y.state.tr.delete(b,b+z.nodeSize).insert(ce,z);xe.setSelection(Q.near(xe.doc.resolve(ce+1))),y.view.dispatch(xe),y.view.focus(),ze(!1),At(null)}function uy(b){if(!y||!y.isEditable)return;let C=G.current;if(C!==null){b.preventDefault(),b.stopPropagation(),G.current=null,At(null);let I=y.state.doc.nodeAt(C);if(!I)return;let $=y.state.doc.content.size,z=!1;if(y.state.doc.forEach((ce,xe)=>{let Ae=y.view.nodeDOM(xe);if(!(Ae instanceof HTMLElement)||z)return;let Dt=Ae.getBoundingClientRect();b.clientY<Dt.top+Dt.height/2&&($=xe,z=!0)}),$!==C&&$!==C+I.nodeSize){let ce=$>C?$-I.nodeSize:$,xe=y.state.tr.delete(C,C+I.nodeSize).insert(ce,I);xe.setSelection(Q.near(xe.doc.resolve(ce+1))),y.view.dispatch(xe)}return}let T=[...b.dataTransfer.files].filter(I=>I.type.startsWith("image/"));if(T.length){b.preventDefault(),b.stopPropagation();let I=y.view.posAtCoords({left:b.clientX,top:b.clientY});I&&y.commands.setTextSelection(I.pos),rl(T)}}if(!y)return(0,v.jsx)("div",{className:"editor-loading","aria-label":d("openingDocument")});let vu=se&&ct?y.state.doc.nodeAt(se.pos):null,Cu=vu?.type.name==="widget"&&!Xd(String(vu.attrs.kind??"")),dy=y.isActive("heading")?d("block.heading",{level:y.getAttributes("heading").level}):d("block.text"),fy=Ee&&me?ji(y.state.doc,y.state.selection.from,y.state.selection.to).length:0,py=Nt?Xi:rM,xu=(!r||Ee)&&(0,v.jsx)(Fm,{editor:y,onLink:()=>dr("link"),onNote:()=>dr("note")});return(0,v.jsxs)("div",{className:`document-editor${n?" is-readonly":""}${r?" is-minimal":""}`,children:[!n&&!r&&(0,v.jsxs)("div",{className:"editor-toolbar",role:"toolbar","aria-label":d("format.toolbar"),children:[(0,v.jsxs)("div",{className:"toolbar-style",children:[(0,v.jsxs)("button",{className:"text-style-button",onMouseDown:b=>b.preventDefault(),onClick:()=>{Ft(!q),re(!1)},"aria-expanded":q,children:[dy,(0,v.jsx)(gr,{size:13})]}),q&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>Ft(!1)}),(0,v.jsx)("div",{className:"editor-small-menu style-menu",children:ol.slice(0,7).map(b=>(0,v.jsxs)("button",{onMouseDown:C=>C.preventDefault(),onClick:()=>{b.run(y),Ft(!1)},children:[b.icon,(0,v.jsx)("span",{children:b.title})]},b.id))})]})]}),(0,v.jsx)("span",{className:"toolbar-divider"}),xu,(0,v.jsx)("span",{className:"toolbar-divider"}),(0,v.jsx)(jt,{label:d("block.bullet"),active:y.isActive("bulletList"),onClick:()=>y.chain().focus().toggleBulletList().run(),children:(0,v.jsx)(dl,{size:17})}),(0,v.jsx)(jt,{label:d("block.todo"),active:y.isActive("taskList"),onClick:()=>y.chain().focus().toggleTaskList().run(),children:(0,v.jsx)(hl,{size:16})}),(0,v.jsxs)("div",{className:"toolbar-insert",children:[(0,v.jsx)(jt,{label:d("format.more"),active:Re,onClick:()=>{re(!Re),Ft(!1)},children:(0,v.jsx)(Ut,{size:17})}),Re&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>re(!1)}),(0,v.jsxs)("div",{className:"editor-small-menu insert-menu",children:[(0,v.jsxs)("button",{onClick:il,children:[(0,v.jsx)(Ut,{size:16}),d("insert.content"),(0,v.jsx)("span",{className:"menu-key",children:"/"})]}),(0,v.jsxs)("button",{onClick:()=>{y.chain().focus().toggleOrderedList().run(),re(!1)},children:[(0,v.jsx)(ul,{size:16}),d("block.ordered")]}),(0,v.jsxs)("button",{onClick:()=>{y.chain().focus().toggleBlockquote().run(),re(!1)},children:[(0,v.jsx)(fl,{size:16}),d("block.quote")]}),(0,v.jsxs)("button",{onClick:()=>dr("image"),children:[(0,v.jsx)(cl,{size:16}),d("insert.image")]}),(0,v.jsxs)("button",{onClick:()=>{y.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),re(!1)},children:[(0,v.jsx)(ml,{size:16}),d("insert.table")]}),(0,v.jsx)("div",{className:"menu-rule"}),(0,v.jsxs)("div",{className:"align-tools",children:[(0,v.jsx)(jt,{label:d("format.alignLeft"),active:y.isActive({textAlign:"left"}),onClick:()=>y.chain().focus().setTextAlign("left").run(),children:(0,v.jsx)(Pn,{size:17})}),(0,v.jsx)(jt,{label:d("format.alignCenter"),active:y.isActive({textAlign:"center"}),onClick:()=>y.chain().focus().setTextAlign("center").run(),children:(0,v.jsx)(On,{size:17})}),(0,v.jsx)(jt,{label:d("format.alignRight"),active:y.isActive({textAlign:"right"}),onClick:()=>y.chain().focus().setTextAlign("right").run(),children:(0,v.jsx)(Ln,{size:17})})]})]})]})]}),(0,v.jsx)("div",{className:"toolbar-spacer"}),(0,v.jsx)(jt,{label:d("format.undo"),disabled:!y.can().undo(),onClick:()=>y.chain().focus().undo().run(),children:(0,v.jsx)(hd,{size:16})}),(0,v.jsx)(jt,{label:d("format.redo"),disabled:!y.can().redo(),onClick:()=>y.chain().focus().redo().run(),children:(0,v.jsx)(sd,{size:16})})]}),(0,v.jsxs)("div",{className:"editor-canvas",ref:x,onKeyDown:b=>{(b.metaKey||b.ctrlKey)&&b.shiftKey&&b.key.toLowerCase()==="k"&&!n&&(b.preventDefault(),b.stopPropagation(),dr("link"))},onMouseEnter:Tt,onMouseMove:b=>{if(n||ct||G.current!==null)return;if(b.target.closest(".block-handle")){Tt();return}let C=x.current;C&&b.target.closest(".document-editor")===C.closest(".document-editor")&&(ut.current=b.clientY,!Rn.current&&(Rn.current=requestAnimationFrame(()=>{Rn.current=0;let T=x.current;if(!T||G.current!==null||y.isDestroyed)return;let I=ut.current,$=T.getBoundingClientRect(),z=$.width/T.offsetWidth||1,ce=null;y.state.doc.forEach((Ae,Dt,sl)=>{let Qr=y.view.nodeDOM(Dt);if(!(Qr instanceof HTMLElement))return;let Zr=Qr.getBoundingClientRect();I>=Zr.top-3&&I<=Zr.bottom+3&&(ce={pos:Dt,size:Ae.nodeSize,index:sl,top:(Zr.top-$.top)/z})});let xe=ce;xe?(Tt(),At(Ae=>Ae&&Ae.pos===xe.pos&&Ae.size===xe.size&&Ae.index===xe.index&&Math.abs(Ae.top-xe.top)<.5?Ae:xe)):lr()})))},onMouseLeave:lr,onDragOver:b=>{(G.current!==null||[...b.dataTransfer.types].includes("Files"))&&b.preventDefault()},onDropCapture:uy,children:[(0,v.jsx)(Vi,{editor:y}),!n&&(0,v.jsx)(jm,{editor:y}),!n&&se&&(0,v.jsxs)("div",{className:"block-handle",style:{top:se.top},onMouseEnter:Tt,onFocus:Tt,children:[(0,v.jsx)("button",{"aria-label":d("insert.addBelow"),title:d("insert.addContent"),onMouseDown:b=>b.preventDefault(),onClick:cy,children:(0,v.jsx)(Ut,{size:15})}),(0,v.jsx)("button",{"aria-label":d("block.handle"),title:d("block.handleTitle"),draggable:!0,onDragStart:b=>{Tt(),G.current=se.pos,b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("application/x-showai-block",String(se.pos));let C=y.view.nodeDOM(se.pos);C instanceof HTMLElement&&b.dataTransfer.setDragImage(C,0,0),ze(!1)},onDragEnd:()=>{G.current=null},onClick:()=>ze(!ct),children:(0,v.jsx)(qu,{size:15})}),ct&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>ze(!1)}),(0,v.jsxs)("div",{className:"editor-small-menu block-menu",children:[r&&["paragraph","heading"].includes(y.state.doc.nodeAt(se.pos)?.type.name??"")&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"align-tools",role:"group","aria-label":d("block.style"),children:ol.slice(0,7).map((b,C)=>(0,v.jsx)(jt,{label:b.title,active:C===0?y.state.doc.nodeAt(se.pos)?.type.name==="paragraph":y.state.doc.nodeAt(se.pos)?.attrs.level===C,onClick:()=>{y.chain().focus().setTextSelection(se.pos+1).run(),b.run(y),ze(!1)},children:b.icon},b.id))}),(0,v.jsx)("div",{className:"align-tools",children:[["left",d("format.alignLeft"),(0,v.jsx)(Pn,{size:16},"left")],["center",d("format.alignCenter"),(0,v.jsx)(On,{size:16},"center")],["right",d("format.alignRight"),(0,v.jsx)(Ln,{size:16},"right")]].map(([b,C,T])=>(0,v.jsx)(jt,{label:C,active:y.state.doc.nodeAt(se.pos)?.attrs.textAlign===b,onClick:()=>{y.chain().focus().setTextSelection(se.pos+1).setTextAlign(b).run(),ze(!1)},children:T},b))}),(0,v.jsx)("div",{className:"menu-rule"})]}),(0,v.jsx)(Wd,{editor:y,position:se.pos,onDone:()=>ze(!1)}),s&&(0,v.jsxs)("button",{onClick:()=>{let b=y.state.doc.nodeAt(se.pos);b&&s(b.toJSON()),ze(!1),At(null)},children:[(0,v.jsx)(Ku,{size:15}),d("block.detach")]}),(0,v.jsxs)("button",{disabled:se.index===0,onClick:()=>ku(se.pos,-1),children:[(0,v.jsx)(Bu,{size:15}),d("block.moveUp")]}),(0,v.jsxs)("button",{disabled:se.index===y.state.doc.childCount-1,onClick:()=>ku(se.pos,1),children:[(0,v.jsx)(Iu,{size:15}),d("block.moveDown")]}),(0,v.jsxs)("button",{onClick:()=>{let b=y.state.doc.nodeAt(se.pos);b&&y.chain().focus().insertContentAt(se.pos+b.nodeSize,b.toJSON()).run(),ze(!1)},children:[(0,v.jsx)(ju,{size:15}),d("block.duplicate")]}),Cu&&(0,v.jsx)("p",{className:"block-menu-note",children:d("block.noManualEditing")}),me&&(0,v.jsxs)("button",{onClick:b=>{let C=y.state.doc.nodeAt(se.pos)?.attrs.id,T=b.currentTarget.closest(".block-handle").getBoundingClientRect();ze(!1),typeof C=="string"&&!uu(C)&&me.open({kind:"blocks",blockIds:[C],anchor:{left:T.right+160,top:T.top,bottom:T.bottom}})},children:[(0,v.jsx)(pl,{size:15}),Cu?d("assistant.editComponent"):p("askAgent")]}),me&&(0,v.jsxs)("button",{onClick:b=>{let C=y.state.doc.nodeAt(se.pos)?.attrs.id,T=b.currentTarget.closest(".block-handle").getBoundingClientRect();ze(!1),typeof C=="string"&&!uu(C)&&me.reference({kind:"blocks",blockIds:[C],anchor:{left:T.right,top:T.top,bottom:T.bottom}})},children:[(0,v.jsx)(Xo,{size:15}),me.referenceLabel??p("copyReference")]}),wt?.block(y.state.doc.nodeAt(se.pos)?.attrs.id,()=>ze(!1)),Se&&(0,v.jsxs)("button",{onClick:()=>{let b=y.state.doc.nodeAt(se.pos)?.attrs.id;ze(!1),typeof b=="string"&&!uu(b)&&Se.copyLink([b])},children:[(0,v.jsx)(to,{size:15}),p("copyLink")]}),(0,v.jsx)("div",{className:"menu-rule"}),(0,v.jsxs)("button",{className:"danger",onClick:()=>{y.chain().focus().deleteRange({from:se.pos,to:se.pos+se.size}).run(),ze(!1),At(null)},children:[(0,v.jsx)(Qo,{size:15}),p("delete")]})]})]})]})]}),!n&&!r&&(0,v.jsxs)("button",{className:"document-add-block",onClick:()=>{y.chain().focus("end").run(),(y.state.selection.$from.parent.type.name!=="paragraph"||y.state.selection.$from.parent.content.size)&&y.chain().insertContentAt(y.state.doc.content.size,{type:"paragraph"}).focus("end").run(),il()},children:[(0,v.jsx)(Ut,{size:15}),(0,v.jsx)("span",{children:d("insert.addContent")}),(0,v.jsx)("kbd",{children:"/"})]}),(0,v.jsx)("input",{ref:M,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"editor-hidden-input",onChange:b=>{let C=b.target.files?.[0];C&&rl([C],!0),b.target.value=""}}),J&&(0,v.jsxs)("div",{className:"editor-notice",role:"status",children:[J,(0,v.jsx)("button",{"aria-label":d("dismissNotice"),onClick:()=>ae(""),children:(0,v.jsx)(ei,{size:14})})]}),Ee&&!n&&(0,v.jsxs)(Vd,{id:k,className:"rich-text-selection-toolbar",anchor:Ee,scale:.8,boundaryElement:x.current?.closest(".container-page-column, .page-surface, .studio-scroll")??x.current,viewportTop:Math.max(0,...Array.from(x.current?.closest(".studio")?.querySelectorAll(".studio-window-topbar, .studio-topbar")??[],b=>b.getBoundingClientRect().bottom))+8,onEscape:()=>{kt.current=!1,ur.current=`${y.state.selection.from}:${y.state.selection.to}`,y.state.selection instanceof ie&&y.view.dispatch(y.state.tr.setSelection(P.near(y.state.selection.$from))),Le(null),y.view.focus()},children:[xu,(0,v.jsx)(Yi,{editor:y}),me&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,v.jsxs)("button",{type:"button",className:"editor-bubble-assistant","aria-label":p("askAgent"),title:p("askAgent"),onClick:()=>{let{from:b,to:C}=y.state.selection,T=Ee;kt.current=!1,Le(null),me.open({kind:"text",blockIds:ji(y.state.doc,b,C),text:y.state.doc.textBetween(b,C,`
|
|
157
|
+
`),anchor:T})},children:[(0,v.jsx)(pl,{size:15}),(0,v.jsx)("span",{children:p("askAgent")})]}),(0,v.jsx)("button",{type:"button",className:"editor-tool editor-bubble-reference","aria-label":me.referenceLabel??p("copyReference"),title:me.referenceLabel??d("assistant.referenceSelection",{count:fy}),onClick:()=>{let{from:b,to:C}=y.state.selection,T=Ee;kt.current=!1,Le(null),me.reference({kind:"text",blockIds:ji(y.state.doc,b,C),text:y.state.doc.textBetween(b,C,`
|
|
158
|
+
`),anchor:T})},children:(0,v.jsx)(Xo,{size:16})})]}),wt?.text(y,()=>{kt.current=!1,Le(null)}),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,v.jsxs)("button",{type:"button",className:"editor-bubble-insert","aria-label":d("insert.fromSelection"),title:d("insert.fromSelectionTitle"),onMouseDown:b=>b.preventDefault(),onClick:()=>{let b=y.state.selection.$to.end();kt.current=!1,Le(null),y.commands.setTextSelection(b),il(),setTimeout(()=>A.current?.focus(),0)},children:[(0,v.jsx)(Ut,{size:15}),(0,v.jsx)("span",{children:d("insert.fromSelection")})]})]})]}),fe&&!n&&(0,Qs.createPortal)((0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"slash-dismiss",onClick:()=>{tl(),y.commands.focus()}}),(0,v.jsxs)("div",{className:`slash-menu${r?" is-minimal":""}`,role:"dialog","aria-label":d("insert.content"),style:{left:fe.left,top:fe.top},children:[(0,v.jsxs)("div",{className:"slash-search",children:[fe.manual?(0,v.jsx)(Id,{label:d("insert.search"),placeholder:d("insert.searchPlaceholder"),defaultExpanded:!0,inputRef:A,value:fe.query,onChange:b=>Be({...fe,query:b}),onKeyDown:b=>{fr.key(b)||b.key==="Escape"&&(tl(),y.commands.focus())}}):(0,v.jsx)("span",{children:fe.query||d("insert.addToDocument")}),(0,v.jsx)("kbd",{children:"esc"})]}),(0,v.jsxs)("div",{className:"slash-items",role:"listbox","aria-label":d("insert.blockTypes"),"aria-busy":Ke||we.loading,children:[we.error&&(0,v.jsx)("p",{role:"alert",className:"slash-empty",children:we.error}),fr.rows.length===0&&(0,v.jsx)("div",{className:"slash-empty",children:d("insert.noResults")}),(0,v.jsx)(Al,{menu:fr,disabled:Ke,icon:b=>b.icon})]})]})]}),document.body),ye&&!n&&(0,Qs.createPortal)((0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"slash-dismiss",onClick:()=>{el(),y.commands.focus()}}),(0,v.jsxs)("div",{className:"slash-menu is-minimal",role:"dialog","aria-label":un("menu"),style:{left:ye.left,top:ye.top},children:[(0,v.jsxs)("div",{className:"slash-search",children:[(0,v.jsxs)("span",{children:["@",ye.query]}),(0,v.jsx)("kbd",{children:"esc"})]}),(0,v.jsxs)("div",{className:"slash-items",role:"listbox","aria-label":un("sources"),"aria-busy":Ke||we.loading,children:[pr.rows.length===0&&(0,v.jsx)("div",{className:"slash-empty",children:un("noResults")}),(0,v.jsx)(Al,{menu:pr,disabled:Ke,icon:b=>b.entry.insertion.type==="link"?(0,v.jsx)(al,{size:20}):(0,v.jsx)(Xo,{size:20}),detail:b=>b.entry.detail?(0,v.jsx)("small",{children:b.entry.detail}):null})]})]})]}),document.body),Y&&(0,Qs.createPortal)((0,v.jsx)(py,{className:Nt?"editor-format-panel":"editor-modal-backdrop",onDismiss:()=>{Me(null),y.commands.focus()},children:(0,v.jsxs)("form",{className:"editor-modal",role:"dialog","aria-modal":Nt?void 0:!0,"aria-labelledby":"editor-dialog-title",onKeyDown:b=>{b.key==="Escape"&&Me(null)},onSubmit:b=>{b.preventDefault();let C=Y.value.trim();if(Y.type==="image"&&!oM(C)){B(d("dialog.invalidImageUrl"));return}let T=Y.type==="link"?Rt[Uo]?.href??C:C;if(Y.type==="link"&&T&&!ny(T)){B(d("dialog.invalidLinkUrl"));return}if(Y.type==="note"){if(!bu(Y,C))return;Me(null);return}if(Y.type==="link"){gu(T);return}vt.current&&y.commands.setTextSelection(vt.current),y.chain().focus().setImage({src:C,alt:Y.alt}).run(),Me(null)},children:[(0,v.jsx)("div",{className:"editor-modal-heading",children:(0,v.jsx)("h3",{id:"editor-dialog-title",children:Y.type==="image"?d("insert.image"):Y.type==="note"?h(Y.hadNote?"dialog.editNote":"dialog.addNote"):d("dialog.addLink")})}),Y.type==="image"&&(0,v.jsxs)("div",{className:"image-source-choices",children:[(0,v.jsxs)("button",{className:"image-upload-area",type:"button",onClick:()=>M.current?.click(),children:[(0,v.jsx)(md,{size:23}),(0,v.jsx)("strong",{children:d("dialog.chooseImage")}),(0,v.jsx)("span",{children:d("dialog.imageFormats")})]}),m&&(0,v.jsxs)("button",{className:"image-upload-area",type:"button",onClick:()=>{iy()},children:[(0,v.jsx)(to,{size:23}),(0,v.jsx)("strong",{children:g("linkOriginal")})]})]}),Y.type==="note"&&(0,v.jsxs)("label",{className:"editor-field",children:[(0,v.jsx)("span",{children:Y.math?h("dialog.noteFormula"):h("dialog.noteText")}),(0,v.jsx)("textarea",{className:"showai-textarea",autoFocus:!0,rows:4,maxLength:1e3,placeholder:h("dialog.notePlaceholder"),value:Y.value,onChange:b=>{Me({...Y,value:b.target.value}),B("")},onKeyDown:b=>{b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),b.currentTarget.form?.requestSubmit())}}),(0,v.jsx)("small",{children:h("dialog.noteHint")})]}),Y.type!=="note"&&(0,v.jsxs)("label",{className:"editor-field",children:[(0,v.jsx)("span",{children:Y.type==="image"?d("dialog.imageUrl"):d("dialog.linkUrl")}),(0,v.jsx)("input",{className:"showai-input",autoFocus:!0,type:"text",placeholder:Y.type==="link"&&Se?d("dialog.linkOrPage"):"https://",value:Y.value,role:Rt.length?"combobox":void 0,"aria-expanded":Rt.length?!0:void 0,"aria-controls":Rt.length?"editor-link-pages":void 0,"aria-activedescendant":Rt[Uo]?`editor-link-page-${Uo}`:void 0,onChange:b=>{Me({...Y,value:b.target.value}),B("")},onKeyDown:b=>{if(!Rt.length||!["ArrowDown","ArrowUp"].includes(b.key))return;b.preventDefault();let C=b.key==="ArrowDown"?1:-1;nl(T=>(T+C+Rt.length)%Rt.length)}})]}),Rt.length>0&&(0,v.jsx)("ul",{className:"editor-link-pages",id:"editor-link-pages",role:"listbox","aria-label":d("dialog.linkPages"),children:Rt.map((b,C)=>(0,v.jsxs)("li",{id:`editor-link-page-${C}`,role:"option","aria-selected":C===Uo,onMouseEnter:()=>nl(C),onMouseDown:T=>T.preventDefault(),onClick:()=>gu(b.href),children:[(0,v.jsx)(al,{size:14}),(0,v.jsx)("span",{children:b.title||d("dialog.untitledPage")})]},b.id))}),Y.type==="image"&&(0,v.jsxs)("label",{className:"editor-field",children:[(0,v.jsxs)("span",{children:[d("dialog.imageAlt")," ",(0,v.jsx)("small",{children:d("dialog.optional")})]}),(0,v.jsx)("input",{className:"showai-input",placeholder:d("dialog.imageAltPlaceholder"),value:Y.alt,onChange:b=>Me({...Y,alt:b.target.value})})]}),O&&(0,v.jsx)("p",{className:"editor-field-error",role:"alert",children:O}),(0,v.jsxs)("div",{className:"editor-modal-actions",children:[Y.type==="link"&&y.isActive("link")&&(0,v.jsx)("button",{type:"button",className:"editor-text-action",onClick:()=>{y.chain().focus().extendMarkRange("link").unsetLink().run(),Me(null)},children:d("dialog.removeLink")}),Y.type==="note"&&Y.hadNote&&(0,v.jsx)("button",{type:"button",className:"editor-text-action",onClick:()=>{bu(Y,"")&&Me(null)},children:h("dialog.removeNote")}),(0,v.jsx)("button",{type:"button",className:"editor-secondary",onClick:()=>Me(null),children:d("dialog.cancel")}),(0,v.jsxs)("button",{type:"submit",className:"editor-primary",disabled:(Y.type==="image"||Y.type==="note")&&!Y.value.trim(),children:[(0,v.jsx)(Hu,{size:15}),Y.type==="image"?d("insert.image"):d("dialog.confirm")]})]})]})}),Nt??document.body),n&&(0,v.jsxs)("span",{className:"editor-readonly-note",children:[(0,v.jsx)(Uu,{size:12}),d("readOnlyNote")]})]})}export{iM as default};
|