showai-reader 0.11.0-reader.llcxplii → 0.11.0-reader.uxwqtzat

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  The [ShowAI](https://showai.renaissancemind.ai) page reader, built from ShowAI 0.11.0 as code-split ES modules. Inline conversation pages written by `render-artifact --cdn` import it and load each component's code only when the page uses it.
4
4
 
5
5
  ```js
6
- const { mount } = await import("https://cdn.jsdelivr.net/npm/showai-reader@0.11.0-reader.llcxplii/index.js");
6
+ const { mount } = await import("https://cdn.jsdelivr.net/npm/showai-reader@0.11.0-reader.uxwqtzat/index.js");
7
7
  mount(document.getElementById("page"), { artifact });
8
8
  ```
9
9
 
@@ -1,4 +1,4 @@
1
- import{c as Qs,d as Zs,hb as Vu,jb as Fu,ob as Ko,pb as ze,qb as Uo,sb as Wu,tb as Gu,ua as rn,ub as Ju,va as el,wa as Pu,ya as Iu}from"./chunk-W6XN463T.js";import"./chunk-3RZMLHCB.js";import"./chunk-JXKAISUX.js";import"./chunk-C4JCEMQN.js";import{A as on,B as Kr,C as q,D as oe,E as zu,G as Hu,K as rl,d as V,e as $u,f as ae,g as Ho,h as tl,i as Nn,j as Rn,k as _o,l as Bu,m as Dn,n as At,o as _t,p as ar,q as pt,r as wt,s as cr,t as Vo,u as jo,v as Fo,w as Q,x as nl,y as L,z as j}from"./chunk-KQR52I3G.js";import"./chunk-SNEZ3O5V.js";import"./chunk-77DN5DLU.js";import"./chunk-AIBH6MTQ.js";import"./chunk-4XYNKR7T.js";import"./chunk-354XB5AI.js";import{b as lr,c as Tu,d as Nu,e as Ru}from"./chunk-TRRO25IC.js";import{a as il,b as qo,c as Ku,e as Uu}from"./chunk-7G6RMB6W.js";import{a as hb,b as mb}from"./chunk-AW4RA5UH.js";import"./chunk-GLP5VV7P.js";import{a as _u}from"./chunk-5AW2WUSZ.js";import{a as Xu}from"./chunk-7NZRTGJL.js";import"./chunk-DG67SWQA.js";import"./chunk-KF47DKNH.js";import{b as ol,c as ju}from"./chunk-2YLUVQCJ.js";import{$a as Xs,A as sr,B as Po,Cb as Re,Db as qu,Ea as Ht,H as tu,Ha as Ks,I as nu,Ia as yu,K as ru,L as ou,N as iu,P as su,Pa as Us,Q as lu,Qa as qs,Ra as wu,S as au,Ua as ku,Wa as Gs,Xa as vu,Ya as Js,Za as Cu,_ as cu,_a as xu,a as Lo,aa as uu,ab as Mn,ba as du,bb as An,c as zt,ca as fu,cb as Su,da as pu,db as Tn,ea as Io,eb as Bo,ga as hu,gb as zo,hb as Eu,ib as Mu,ka as Fr,kb as Au,la as Fs,m as Xc,na as Ws,nb as Wr,o as Yc,ob as Fe,pb as Ys,q as Qc,r as js,s as Zc,sa as mu,ta as $o,ua as gu,vb as Du,wb as Ou,z as eu,za as bu,zb as Lu}from"./chunk-IJTLAUEC.js";import{a as Wo,f as ur}from"./chunk-J6IRWTF7.js";import{a as pb,c as pe}from"./chunk-DCANE7XH.js";var Sg=pb((ON,xg)=>{function dg(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)&&dg(n)}),e}var Rs=class{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function fg(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function yn(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 vS="</span>",ig=e=>!!e.scope,CS=(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}`},Mc=class{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=fg(t)}openNode(t){if(!ig(t))return;let n=CS(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){ig(t)&&(this.buffer+=vS)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}},sg=(e={})=>{let t={children:[]};return Object.assign(t,e),t},Ac=class e{constructor(){this.rootNode=sg(),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=sg({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)}))}},Tc=class extends Ac{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 Mc(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function To(e){return e?typeof e=="string"?e:e.source:null}function pg(e){return nr("(?=",e,")")}function xS(e){return nr("(?:",e,")*")}function SS(e){return nr("(?:",e,")?")}function nr(...e){return e.map(n=>To(n)).join("")}function ES(e){let t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function Os(...e){return"("+(ES(e).capture?"":"?:")+e.map(r=>To(r)).join("|")+")"}function hg(e){return new RegExp(e.toString()+"|").exec("").length-1}function MS(e,t){let n=e&&e.exec(t);return n&&n.index===0}var AS=new RegExp(Os(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function Rc(e,{joinWith:t}){let n=0;return e.map(r=>{n+=1;let o=n,i=To(r),s="";for(;i.length>0;){let l=AS.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 TS=/\b\B/,mg="[a-zA-Z]\\w*",Dc="[a-zA-Z_]\\w*",gg="\\b\\d+(\\.\\d+)?",bg="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",yg="\\b(0b[01]+)",NS="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",RS=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=nr(t,/.*\b/,e.binary,/\b.*/)),yn({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},e)},No={begin:"\\\\[\\s\\S]",relevance:0},DS={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[No]},OS={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[No]},LS={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/},Ls=function(e,t,n={}){let r=yn({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=Os("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:nr(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},PS=Ls("//","$"),IS=Ls("/\\*","\\*/"),$S=Ls("#","$"),BS={scope:"number",begin:gg,relevance:0},zS={scope:"number",begin:bg,relevance:0},HS={scope:"number",begin:yg,relevance:0},_S={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[No,{begin:/\[/,end:/\]/,relevance:0,contains:[No]}]},VS={scope:"title",begin:mg,relevance:0},jS={scope:"title",begin:Dc,relevance:0},FS={begin:"\\.\\s*"+Dc,relevance:0},WS=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()}})},Ns=Object.freeze({__proto__:null,APOS_STRING_MODE:DS,BACKSLASH_ESCAPE:No,BINARY_NUMBER_MODE:HS,BINARY_NUMBER_RE:yg,COMMENT:Ls,C_BLOCK_COMMENT_MODE:IS,C_LINE_COMMENT_MODE:PS,C_NUMBER_MODE:zS,C_NUMBER_RE:bg,END_SAME_AS_BEGIN:WS,HASH_COMMENT_MODE:$S,IDENT_RE:mg,MATCH_NOTHING_RE:TS,METHOD_GUARD:FS,NUMBER_MODE:BS,NUMBER_RE:gg,PHRASAL_WORDS_MODE:LS,QUOTE_STRING_MODE:OS,REGEXP_MODE:_S,RE_STARTERS_RE:NS,SHEBANG:RS,TITLE_MODE:VS,UNDERSCORE_IDENT_RE:Dc,UNDERSCORE_TITLE_MODE:jS});function KS(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function US(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function qS(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=KS,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function GS(e,t){Array.isArray(e.illegal)&&(e.illegal=Os(...e.illegal))}function JS(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 XS(e,t){e.relevance===void 0&&(e.relevance=1)}var YS=(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=nr(n.beforeMatch,pg(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},QS=["of","and","for","in","not","or","if","then","parent","list","value"],ZS="keyword";function wg(e,t,n=ZS){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,wg(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,e1(a[0],a[1])]})}}function e1(e,t){return t?Number(t):t1(e)?0:1}function t1(e){return QS.includes(e.toLowerCase())}var lg={},tr=e=>{console.error(e)},ag=(e,...t)=>{console.log(`WARN: ${e}`,...t)},$r=(e,t)=>{lg[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),lg[`${e}/${t}`]=!0)},Ds=new Error;function kg(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+=hg(t[l-1]);e[n]=s,e[n]._emit=i,e[n]._multi=!0}function n1(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw tr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Ds;if(typeof e.beginScope!="object"||e.beginScope===null)throw tr("beginScope must be object"),Ds;kg(e,e.begin,{key:"beginScope"}),e.begin=Rc(e.begin,{joinWith:""})}}function r1(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw tr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Ds;if(typeof e.endScope!="object"||e.endScope===null)throw tr("endScope must be object"),Ds;kg(e,e.end,{key:"endScope"}),e.end=Rc(e.end,{joinWith:""})}}function o1(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function i1(e){o1(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),n1(e),r1(e)}function s1(e){function t(s,l){return new RegExp(To(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+=hg(l)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let l=this.regexes.map(a=>a[1]);this.matcherRe=t(Rc(l,{joinWith:"|"}),!0),this.lastIndex=0}exec(l){this.matcherRe.lastIndex=this.lastIndex;let a=this.matcherRe.exec(l);if(!a)return null;let u=a.findIndex((d,f)=>f>0&&d!==void 0),c=this.matchIndexes[u];return a.splice(0,u),Object.assign(a,c)}}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(([u,c])=>a.addRule(u,c)),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 u=a.exec(l);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){let c=this.getMatcher(0);c.lastIndex=this.lastIndex+1,u=c.exec(l)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}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;[US,JS,i1,YS].forEach(c=>c(s,l)),e.compilerExtensions.forEach(c=>c(s,l)),s.__beforeBegin=null,[qS,GS,XS].forEach(c=>c(s,l)),s.isCompiled=!0;let u=null;return typeof s.keywords=="object"&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),u=s.keywords.$pattern,delete s.keywords.$pattern),u=u||/\w+/,s.keywords&&(s.keywords=wg(s.keywords,e.case_insensitive)),a.keywordPatternRe=t(u,!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=To(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(c){return l1(c==="self"?s:c)})),s.contains.forEach(function(c){i(c,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=yn(e.classNameAliases||{}),i(e)}function vg(e){return e?e.endsWithParent||vg(e.starts):!1}function l1(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return yn(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:vg(e)?yn(e,{starts:e.starts?yn(e.starts):null}):Object.isFrozen(e)?yn(e):e}var a1="11.12.0",Nc=class extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}},Ec=fg,cg=yn,ug=Symbol("nomatch"),c1=7,Cg=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:Tc};function a(N){return l.noHighlightRe.test(N)}function u(N){let _=N.className+" ";_+=N.parentNode?N.parentNode.className:"";let ee=l.languageDetectRe.exec(_);if(ee){let ue=O(ee[1]);return ue||(ag(i.replace("{}",ee[1])),ag("Falling back to no-highlight mode for this block.",N)),ue?ee[1]:"no-highlight"}return _.split(/\s+/).find(ue=>a(ue)||O(ue))}function c(N,_,ee){let ue="",Se="";typeof _=="object"?(ue=N,ee=_.ignoreIllegals,Se=_.language):($r("10.7.0","highlight(lang, code, ...args) has been deprecated."),$r("10.7.0",`Please use highlight(code, options) instead.
1
+ import{c as Qs,d as Zs,hb as Vu,jb as Fu,ob as Ko,pb as ze,qb as Uo,sb as Wu,tb as Gu,ua as rn,ub as Ju,va as el,wa as Pu,ya as Iu}from"./chunk-RE47W7O4.js";import"./chunk-3RZMLHCB.js";import"./chunk-JXKAISUX.js";import"./chunk-C4JCEMQN.js";import{A as on,B as Kr,C as q,D as oe,E as zu,G as Hu,K as rl,d as V,e as $u,f as ae,g as Ho,h as tl,i as Nn,j as Rn,k as _o,l as Bu,m as Dn,n as At,o as _t,p as ar,q as pt,r as wt,s as cr,t as Vo,u as jo,v as Fo,w as Q,x as nl,y as L,z as j}from"./chunk-KQR52I3G.js";import"./chunk-SNEZ3O5V.js";import"./chunk-77DN5DLU.js";import"./chunk-AIBH6MTQ.js";import"./chunk-4XYNKR7T.js";import"./chunk-354XB5AI.js";import{b as lr,c as Tu,d as Nu,e as Ru}from"./chunk-TRRO25IC.js";import{a as il,b as qo,c as Ku,e as Uu}from"./chunk-7G6RMB6W.js";import{a as hb,b as mb}from"./chunk-AW4RA5UH.js";import"./chunk-GLP5VV7P.js";import{a as _u}from"./chunk-5AW2WUSZ.js";import{a as Xu}from"./chunk-7NZRTGJL.js";import"./chunk-DG67SWQA.js";import"./chunk-KF47DKNH.js";import{b as ol,c as ju}from"./chunk-2YLUVQCJ.js";import{$a as Xs,A as sr,B as Po,Cb as Re,Db as qu,Ea as Ht,H as tu,Ha as Ks,I as nu,Ia as yu,K as ru,L as ou,N as iu,P as su,Pa as Us,Q as lu,Qa as qs,Ra as wu,S as au,Ua as ku,Wa as Gs,Xa as vu,Ya as Js,Za as Cu,_ as cu,_a as xu,a as Lo,aa as uu,ab as Mn,ba as du,bb as An,c as zt,ca as fu,cb as Su,da as pu,db as Tn,ea as Io,eb as Bo,ga as hu,gb as zo,hb as Eu,ib as Mu,ka as Fr,kb as Au,la as Fs,m as Xc,na as Ws,nb as Wr,o as Yc,ob as Fe,pb as Ys,q as Qc,r as js,s as Zc,sa as mu,ta as $o,ua as gu,vb as Du,wb as Ou,z as eu,za as bu,zb as Lu}from"./chunk-IJTLAUEC.js";import{a as Wo,f as ur}from"./chunk-J6IRWTF7.js";import{a as pb,c as pe}from"./chunk-DCANE7XH.js";var Sg=pb((ON,xg)=>{function dg(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)&&dg(n)}),e}var Rs=class{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function fg(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function yn(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 vS="</span>",ig=e=>!!e.scope,CS=(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}`},Mc=class{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=fg(t)}openNode(t){if(!ig(t))return;let n=CS(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){ig(t)&&(this.buffer+=vS)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}},sg=(e={})=>{let t={children:[]};return Object.assign(t,e),t},Ac=class e{constructor(){this.rootNode=sg(),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=sg({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)}))}},Tc=class extends Ac{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 Mc(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function To(e){return e?typeof e=="string"?e:e.source:null}function pg(e){return nr("(?=",e,")")}function xS(e){return nr("(?:",e,")*")}function SS(e){return nr("(?:",e,")?")}function nr(...e){return e.map(n=>To(n)).join("")}function ES(e){let t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function Os(...e){return"("+(ES(e).capture?"":"?:")+e.map(r=>To(r)).join("|")+")"}function hg(e){return new RegExp(e.toString()+"|").exec("").length-1}function MS(e,t){let n=e&&e.exec(t);return n&&n.index===0}var AS=new RegExp(Os(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function Rc(e,{joinWith:t}){let n=0;return e.map(r=>{n+=1;let o=n,i=To(r),s="";for(;i.length>0;){let l=AS.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 TS=/\b\B/,mg="[a-zA-Z]\\w*",Dc="[a-zA-Z_]\\w*",gg="\\b\\d+(\\.\\d+)?",bg="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",yg="\\b(0b[01]+)",NS="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",RS=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=nr(t,/.*\b/,e.binary,/\b.*/)),yn({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},e)},No={begin:"\\\\[\\s\\S]",relevance:0},DS={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[No]},OS={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[No]},LS={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/},Ls=function(e,t,n={}){let r=yn({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=Os("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:nr(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},PS=Ls("//","$"),IS=Ls("/\\*","\\*/"),$S=Ls("#","$"),BS={scope:"number",begin:gg,relevance:0},zS={scope:"number",begin:bg,relevance:0},HS={scope:"number",begin:yg,relevance:0},_S={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[No,{begin:/\[/,end:/\]/,relevance:0,contains:[No]}]},VS={scope:"title",begin:mg,relevance:0},jS={scope:"title",begin:Dc,relevance:0},FS={begin:"\\.\\s*"+Dc,relevance:0},WS=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()}})},Ns=Object.freeze({__proto__:null,APOS_STRING_MODE:DS,BACKSLASH_ESCAPE:No,BINARY_NUMBER_MODE:HS,BINARY_NUMBER_RE:yg,COMMENT:Ls,C_BLOCK_COMMENT_MODE:IS,C_LINE_COMMENT_MODE:PS,C_NUMBER_MODE:zS,C_NUMBER_RE:bg,END_SAME_AS_BEGIN:WS,HASH_COMMENT_MODE:$S,IDENT_RE:mg,MATCH_NOTHING_RE:TS,METHOD_GUARD:FS,NUMBER_MODE:BS,NUMBER_RE:gg,PHRASAL_WORDS_MODE:LS,QUOTE_STRING_MODE:OS,REGEXP_MODE:_S,RE_STARTERS_RE:NS,SHEBANG:RS,TITLE_MODE:VS,UNDERSCORE_IDENT_RE:Dc,UNDERSCORE_TITLE_MODE:jS});function KS(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function US(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function qS(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=KS,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function GS(e,t){Array.isArray(e.illegal)&&(e.illegal=Os(...e.illegal))}function JS(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 XS(e,t){e.relevance===void 0&&(e.relevance=1)}var YS=(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=nr(n.beforeMatch,pg(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},QS=["of","and","for","in","not","or","if","then","parent","list","value"],ZS="keyword";function wg(e,t,n=ZS){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,wg(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,e1(a[0],a[1])]})}}function e1(e,t){return t?Number(t):t1(e)?0:1}function t1(e){return QS.includes(e.toLowerCase())}var lg={},tr=e=>{console.error(e)},ag=(e,...t)=>{console.log(`WARN: ${e}`,...t)},$r=(e,t)=>{lg[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),lg[`${e}/${t}`]=!0)},Ds=new Error;function kg(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+=hg(t[l-1]);e[n]=s,e[n]._emit=i,e[n]._multi=!0}function n1(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw tr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Ds;if(typeof e.beginScope!="object"||e.beginScope===null)throw tr("beginScope must be object"),Ds;kg(e,e.begin,{key:"beginScope"}),e.begin=Rc(e.begin,{joinWith:""})}}function r1(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw tr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Ds;if(typeof e.endScope!="object"||e.endScope===null)throw tr("endScope must be object"),Ds;kg(e,e.end,{key:"endScope"}),e.end=Rc(e.end,{joinWith:""})}}function o1(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function i1(e){o1(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),n1(e),r1(e)}function s1(e){function t(s,l){return new RegExp(To(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+=hg(l)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let l=this.regexes.map(a=>a[1]);this.matcherRe=t(Rc(l,{joinWith:"|"}),!0),this.lastIndex=0}exec(l){this.matcherRe.lastIndex=this.lastIndex;let a=this.matcherRe.exec(l);if(!a)return null;let u=a.findIndex((d,f)=>f>0&&d!==void 0),c=this.matchIndexes[u];return a.splice(0,u),Object.assign(a,c)}}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(([u,c])=>a.addRule(u,c)),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 u=a.exec(l);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){let c=this.getMatcher(0);c.lastIndex=this.lastIndex+1,u=c.exec(l)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}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;[US,JS,i1,YS].forEach(c=>c(s,l)),e.compilerExtensions.forEach(c=>c(s,l)),s.__beforeBegin=null,[qS,GS,XS].forEach(c=>c(s,l)),s.isCompiled=!0;let u=null;return typeof s.keywords=="object"&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),u=s.keywords.$pattern,delete s.keywords.$pattern),u=u||/\w+/,s.keywords&&(s.keywords=wg(s.keywords,e.case_insensitive)),a.keywordPatternRe=t(u,!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=To(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(c){return l1(c==="self"?s:c)})),s.contains.forEach(function(c){i(c,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=yn(e.classNameAliases||{}),i(e)}function vg(e){return e?e.endsWithParent||vg(e.starts):!1}function l1(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return yn(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:vg(e)?yn(e,{starts:e.starts?yn(e.starts):null}):Object.isFrozen(e)?yn(e):e}var a1="11.12.0",Nc=class extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}},Ec=fg,cg=yn,ug=Symbol("nomatch"),c1=7,Cg=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:Tc};function a(N){return l.noHighlightRe.test(N)}function u(N){let _=N.className+" ";_+=N.parentNode?N.parentNode.className:"";let ee=l.languageDetectRe.exec(_);if(ee){let ue=O(ee[1]);return ue||(ag(i.replace("{}",ee[1])),ag("Falling back to no-highlight mode for this block.",N)),ue?ee[1]:"no-highlight"}return _.split(/\s+/).find(ue=>a(ue)||O(ue))}function c(N,_,ee){let ue="",Se="";typeof _=="object"?(ue=N,ee=_.ignoreIllegals,Se=_.language):($r("10.7.0","highlight(lang, code, ...args) has been deprecated."),$r("10.7.0",`Please use highlight(code, options) instead.
2
2
  https://github.com/highlightjs/highlight.js/issues/2277`),Se=N,ue=_),ee===void 0&&(ee=!0);let Y={code:ue,language:Se};_e("before:highlight",Y);let Ve=Y.result?Y.result:d(Y.language,Y.code,ee);return Ve.code=Y.code,_e("after:highlight",Ve),Ve}function d(N,_,ee,ue){let Se=Object.create(null);function Y(D,z){return D.keywords[z]}function Ve(){if(!J.keywords){Ce.addText(ge);return}let D=0;J.keywordPatternRe.lastIndex=0;let z=J.keywordPatternRe.exec(ge),G="";for(;z;){G+=ge.substring(D,z.index);let be=U.case_insensitive?z[0].toLowerCase():z[0],w=Y(J,be);if(w){let[ft,or]=w;if(Ce.addText(G),G="",Se[be]=(Se[be]||0)+1,Se[be]<=c1&&(yt+=or),ft.startsWith("_"))G+=z[0];else{let Vr=U.classNameAliases[ft]||ft;je(z[0],Vr)}}else G+=z[0];D=J.keywordPatternRe.lastIndex,z=J.keywordPatternRe.exec(ge)}G+=ge.substring(D),Ce.addText(G)}function Ze(){if(ge==="")return;let D=null;if(typeof J.subLanguage=="string"){if(!t[J.subLanguage]){Ce.addText(ge);return}D=d(J.subLanguage,ge,!0,_r[J.subLanguage]),_r[J.subLanguage]=D._top}else D=p(ge,J.subLanguage.length?J.subLanguage:null);J.relevance>0&&(yt+=D.relevance),Ce.__addSublanguage(D._emitter,D.language)}function me(){J.subLanguage!=null?Ze():Ve(),ge=""}function je(D,z){D!==""&&(Ce.startScope(z),Ce.addText(D),Ce.endScope())}function zr(D,z){let G=1,be=z.length-1;for(;G<=be;){if(!D._emit[G]){G++;continue}let w=U.classNameAliases[D[G]]||D[G],ft=z[G];w?je(ft,w):(ge=ft,Ve(),ge=""),G++}}function wn(D,z){return D.scope&&typeof D.scope=="string"&&Ce.openNode(U.classNameAliases[D.scope]||D.scope),D.beginScope&&(D.beginScope._wrap?(je(ge,U.classNameAliases[D.beginScope._wrap]||D.beginScope._wrap),ge=""):D.beginScope._multi&&(zr(D.beginScope,z),ge="")),J=Object.create(D,{parent:{value:J}}),J}function Hr(D,z,G){let be=MS(D.endRe,G);if(be){if(D["on:end"]){let w=new Rs(D);D["on:end"](z,w),w.isMatchIgnored&&(be=!1)}if(be){for(;D.endsParent&&D.parent;)D=D.parent;return D}}if(D.endsWithParent)return Hr(D.parent,z,G)}function Ct(D){return J.matcher.regexIndex===0?(ge+=D[0],1):(Et=!0,0)}function Do(D){let z=D[0],G=D.rule,be=new Rs(G),w=[G.__beforeBegin,G["on:begin"]];for(let ft of w)if(ft&&(ft(D,be),be.isMatchIgnored))return Ct(z);return G.skip?ge+=z:(G.excludeBegin&&(ge+=z),me(),!G.returnBegin&&!G.excludeBegin&&(ge=z)),wn(G,D),G.returnBegin?0:z.length}function kn(D){let z=D[0],G=_.substring(D.index),be=Hr(J,D,G);if(!be)return ug;let w=J;J.endScope&&J.endScope._wrap?(me(),je(z,J.endScope._wrap)):J.endScope&&J.endScope._multi?(me(),zr(J.endScope,D)):w.skip?ge+=z:(w.returnEnd||w.excludeEnd||(ge+=z),me(),w.excludeEnd&&(ge=z));do J.scope&&Ce.closeNode(),!J.skip&&!J.subLanguage&&(yt+=J.relevance),J=J.parent;while(J!==be.parent);return be.starts&&wn(be.starts,D),w.returnEnd?0:z.length}function tn(){let D=[];for(let z=J;z!==U;z=z.parent)z.scope&&D.unshift(z.scope);D.forEach(z=>Ce.openNode(z))}let xt={};function at(D,z){let G=z&&z[0];if(ge+=D,G==null)return me(),0;if(xt.type==="begin"&&z.type==="end"&&xt.index===z.index&&G===""){if(ge+=_.slice(z.index,z.index+1),!o){let be=new Error(`0 width match regex (${N})`);throw be.languageName=N,be.badRule=xt.rule,be}return 1}if(xt=z,z.type==="begin")return Do(z);if(z.type==="illegal"&&!ee){let be=new Error('Illegal lexeme "'+G+'" for mode "'+(J.scope||"<unnamed>")+'"');throw be.mode=J,be}else if(z.type==="end"){let be=kn(z);if(be!==ug)return be}if(z.type==="illegal"&&G==="")return z.index===_.length||(ge+=`
3
3
  `),1;if(et>1e5&&et>z.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ge+=G,G.length}let U=O(N);if(!U)throw tr(i.replace("{}",N)),new Error('Unknown language: "'+N+'"');let Le=s1(U),St="",J=ue||Le,_r={},Ce=new l.__emitter(l);tn();let ge="",yt=0,qe=0,et=0,Et=!1;try{if(U.__emitTokens)U.__emitTokens(_,Ce);else{for(J.matcher.considerAll();;){et++,Et?Et=!1:J.matcher.considerAll(),J.matcher.lastIndex=qe;let D=J.matcher.exec(_);if(!D)break;let z=_.substring(qe,D.index),G=at(z,D);qe=D.index+G}at(_.substring(qe))}return Ce.finalize(),St=Ce.toHTML(),{language:N,value:St,relevance:yt,illegal:!1,_emitter:Ce,_top:J}}catch(D){if(D.message&&D.message.includes("Illegal"))return{language:N,value:Ec(_),illegal:!0,relevance:0,_illegalBy:{message:D.message,index:qe,context:_.slice(qe-100,qe+100),mode:D.mode,resultSoFar:St},_emitter:Ce};if(o)return{language:N,value:Ec(_),illegal:!1,relevance:0,errorRaised:D,_emitter:Ce,_top:J};throw D}}function f(N){let _={value:Ec(N),illegal:!1,relevance:0,_top:s,_emitter:new l.__emitter(l)};return _._emitter.addText(N),_}function p(N,_){_=_||l.languages||Object.keys(t);let ee=f(N),ue=_.filter(O).filter(he).map(me=>d(me,N,!1));ue.unshift(ee);let Se=ue.sort((me,je)=>{if(me.relevance!==je.relevance)return je.relevance-me.relevance;if(me.language&&je.language){if(O(me.language).supersetOf===je.language)return 1;if(O(je.language).supersetOf===me.language)return-1}return 0}),[Y,Ve]=Se,Ze=Y;return Ze.secondBest=Ve,Ze}function h(N,_,ee){let ue=_&&n[_]||ee;N.classList.add("hljs"),N.classList.add(`language-${ue}`)}function g(N){let _=null,ee=u(N);if(a(ee))return;if(_e("before:highlightElement",{el:N,language:ee}),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 Nc("One of your code blocks includes unescaped HTML.",N.innerHTML);_=N;let ue=_.textContent,Se=ee?c(ue,{language:ee,ignoreIllegals:!0}):p(ue);N.innerHTML=Se.value,N.dataset.highlighted="yes",h(N,ee,Se.language),N.result={language:Se.language,re:Se.relevance,relevance:Se.relevance},Se.secondBest&&(N.secondBest={language:Se.secondBest.language,relevance:Se.secondBest.relevance}),_e("after:highlightElement",{el:N,result:Se,text:ue})}function m(N){l=cg(l,N)}let b=()=>{S(),$r("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function k(){S(),$r("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let C=!1;function S(){function N(){S()}if(document.readyState==="loading"){C||window.addEventListener("DOMContentLoaded",N,!1),C=!0;return}document.querySelectorAll(l.cssSelector).forEach(g)}function M(N,_){let ee=null;try{ee=_(e)}catch(ue){if(tr("Language definition for '{}' could not be registered.".replace("{}",N)),o)tr(ue);else throw ue;ee=s}ee.name||(ee.name=N),t[N]=ee,ee.rawDefinition=_.bind(null,e),ee.aliases&&X(ee.aliases,{languageName:N})}function T(N){delete t[N];for(let _ of Object.keys(n))n[_]===N&&delete n[_]}function E(){return Object.keys(t)}function O(N){return N=(N||"").toLowerCase(),t[N]||t[n[N]]}function X(N,{languageName:_}){typeof N=="string"&&(N=[N]),N.forEach(ee=>{n[ee.toLowerCase()]=_})}function he(N){let _=O(N);return _&&!_.disableAutodetect}function Ne(N){N["before:highlightBlock"]&&!N["before:highlightElement"]&&(N["before:highlightElement"]=_=>{N["before:highlightBlock"](Object.assign({block:_.el},_))}),N["after:highlightBlock"]&&!N["after:highlightElement"]&&(N["after:highlightElement"]=_=>{N["after:highlightBlock"](Object.assign({block:_.el},_))})}function $e(N){Ne(N),r.push(N)}function xe(N){let _=r.indexOf(N);_!==-1&&r.splice(_,1)}function _e(N,_){let ee=N;r.forEach(function(ue){ue[ee]&&ue[ee](_)})}function Me(N){return $r("10.7.0","highlightBlock will be removed entirely in v12.0"),$r("10.7.0","Please use highlightElement now."),g(N)}Object.assign(e,{highlight:c,highlightAuto:p,highlightAll:S,highlightElement:g,highlightBlock:Me,configure:m,initHighlighting:b,initHighlightingOnLoad:k,registerLanguage:M,unregisterLanguage:T,listLanguages:E,getLanguage:O,registerAliases:X,autoDetection:he,inherit:cg,addPlugin:$e,removePlugin:xe}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=a1,e.regex={concat:nr,lookahead:pg,either:Os,optional:SS,anyNumberOfTimes:xS};for(let N in Ns)typeof Ns[N]=="object"&&dg(Ns[N]);return Object.assign(e,Ns),e},Br=Cg({});Br.newInstance=()=>Cg({});xg.exports=Br;Br.HighlightJS=Br;Br.default=Br});var Qu=pe(zt(),1);var Yu=Wo("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 ye=pe(Fe(),1),Zu="showai:shared-data";function gb(){if(typeof window>"u")return!1;let e=new CustomEvent(Zu,{cancelable:!0,detail:null});return window.dispatchEvent(e),e.defaultPrevented}function ed({editor:e,position:t,onDone:n}){let r=Re(Yu),[o,i]=(0,Qu.useState)(""),s=e.state.doc.nodeAt(t);if(!s||!e.isEditable)return null;let l=s.type.name,a=(p,h)=>{e.view.dispatch(e.state.tr.setNodeAttribute(t,p,h))},u=(p,h)=>(0,ye.jsxs)("label",{children:[h,(0,ye.jsx)("input",{value:s.attrs[p]??"",onChange:g=>a(p,g.target.value)})]},p),c=["image","table","codeBlock","callout","toggle","stepper","horizontalRule"].includes(l),d=s.attrs.componentStyle??{},f=(p,h)=>{let g={...d};h===void 0?delete g[p]:g[p]=h,a("componentStyle",g)};if(l==="widget"&&s.attrs.kind!=="text"&&gb()){let p=s.attrs.id,h=g=>{let m=-1;e.state.doc.descendants((b,k)=>(m<0&&b.attrs?.id===p&&(m=k),m<0)),m>=0&&e.view.dispatch(e.state.tr.setNodeAttribute(m,"data",g))};return(0,ye.jsxs)("button",{type:"button",onClick:()=>{window.dispatchEvent(new CustomEvent(Zu,{cancelable:!0,detail:{kind:s.attrs.kind,data:s.attrs.data,apply:h}})),n?.()},children:[(0,ye.jsx)(ou,{size:15}),r("sharedData")]})}return(0,ye.jsxs)("div",{className:"content-node-fields",children:[l==="image"&&(0,ye.jsxs)(ye.Fragment,{children:[u("src",r("imageSrc")),u("alt",r("imageAlt")),u("caption",r("imageCaption")),["width","height"].map(p=>(0,ye.jsxs)("label",{children:[r(p),(0,ye.jsx)("input",{inputMode:"decimal",value:s.attrs[p]??"",onChange:h=>{let g=h.target.value;(!g||/^\d+(?:px|%)?$/.test(g)&&parseInt(g)>0&&parseInt(g)<=1e4)&&a(p,g?/^\d+$/.test(g)?Number(g):g:null)}})]},p)),(0,ye.jsxs)("label",{children:[r("fit"),(0,ye.jsxs)("select",{value:s.attrs.fit??"contain",onChange:p=>a("fit",p.target.value),children:[(0,ye.jsx)("option",{value:"contain",children:r("contain")}),(0,ye.jsx)("option",{value:"cover",children:r("cover")})]})]})]}),["table","callout","toggle"].includes(l)&&u("title",r("title")),l==="codeBlock"&&(0,ye.jsxs)(ye.Fragment,{children:[(0,ye.jsxs)("label",{children:[r("language"),(0,ye.jsxs)("select",{value:qo(s.attrs.language),onChange:p=>a("language",p.target.value),children:[(0,ye.jsx)("option",{value:"plaintext",children:r("plainText")}),!il.includes(qo(s.attrs.language))&&(0,ye.jsxs)("option",{value:qo(s.attrs.language),children:[s.attrs.language,Ku(s.attrs.language)?"":` (${r("plainText")})`]}),il.filter(p=>p!=="plaintext").map(p=>(0,ye.jsx)("option",{value:p,children:p},p))]})]}),(0,ye.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(s.textContent).then(()=>i(r("copied"))).catch(p=>i(p.message))},children:r("copy")}),o&&(0,ye.jsx)("span",{role:"status",children:o})]}),c&&(0,ye.jsxs)("details",{children:[(0,ye.jsx)("summary",{children:r("appearance")}),["color","backgroundColor"].map(p=>(0,ye.jsxs)("label",{children:[r(p),(0,ye.jsx)("input",{value:d[p]??"",onChange:h=>f(p,h.target.value||void 0)})]},p)),["fontSize","padding","radius"].map(p=>(0,ye.jsxs)("label",{children:[r(p),(0,ye.jsx)("input",{type:"number",min:p==="fontSize"?8:0,max:"200",value:d[p]??"",onChange:h=>{let g=h.target.value;(!g||Number(g)>=(p==="fontSize"?8:0)&&Number(g)<=200)&&f(p,g?Number(g):void 0)}})]},p))]})]})}var bb=new Set(["chart","database","metrics","playground","gallery","bookmark","references","video","audio","pdf","archify","diagram-design","fireworks-tech-graph"]),yb=new Set(["mindmap","flowchart","text"]);function td(e){return bb.has(e)||yb.has(e)||e.startsWith("g2-")}var Go=Wo("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 nd(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 P=pe(zt(),1),Vc=pe(Ys(),1);var re=pe(zt(),1);var Ei=pe(Ys(),1),Yp=pe(hb(),1);var rd=Object.defineProperty,od=(e,t)=>{let n={};for(var r in e)rd(n,r,{get:e[r],enumerable:!0});return t||rd(n,Symbol.toStringTag,{value:"Module"}),n};var sd=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function ld(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}var ll=(e,t,n)=>{let r=ld(e,n);if(!r)return!1;let o=cl(r);if(!o){let s=r.blockRange(),l=s&&_t(s);return l==null?!1:(t&&t(e.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(gd(e,o,t,-1))return!0;if(r.parent.content.size==0&&(dr(i,"end")||j.isSelectable(i)))for(let s=r.depth;;s--){let l=jo(e.doc,r.before(s),r.after(s),ae.empty);if(l&&l.slice.size<l.to-l.from){if(t){let a=e.tr.step(l);a.setSelection(dr(i,"end")?Q.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):j.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},ad=(e,t,n)=>{let r=ld(e,n);if(!r)return!1;let o=cl(r);return o?ud(e,o,t):!1},cd=(e,t,n)=>{let r=dd(e,n);if(!r)return!1;let o=fl(r);return o?ud(e,o,t):!1};function ud(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 c=o.lastChild;if(!c)return!1;o=c}let s=t.nodeAfter,l=s,a=t.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let c=l.firstChild;if(!c)return!1;l=c}let u=jo(e.doc,i,a,ae.empty);if(!u||u.from!=i||u instanceof Dn&&u.slice.size>=a-i)return!1;if(n){let c=e.tr.step(u);c.setSelection(L.create(c.doc,i)),n(c.scrollIntoView())}return!0}function dr(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 al=(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=cl(r)}let s=i&&i.nodeBefore;return!s||!j.isSelectable(s)?!1:(t&&t(e.tr.setSelection(j.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function cl(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 dd(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}var ul=(e,t,n)=>{let r=dd(e,n);if(!r)return!1;let o=fl(r);if(!o)return!1;let i=o.nodeAfter;if(gd(e,o,t,1))return!0;if(r.parent.content.size==0&&(dr(i,"start")||j.isSelectable(i))){let s=jo(e.doc,r.before(),r.after(),ae.empty);if(s&&s.slice.size<s.to-s.from){if(t){let l=e.tr.step(s);l.setSelection(dr(i,"start")?Q.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):j.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},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("forward",e):r.parentOffset<r.parent.content.size)return!1;i=fl(r)}let s=i&&i.nodeAfter;return!s||!j.isSelectable(s)?!1:(t&&t(e.tr.setSelection(j.create(e.doc,i.pos)).scrollIntoView()),!0)};function fl(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 fd=(e,t)=>{let n=e.selection,r=n instanceof j,o;if(r){if(n.node.isTextblock||!wt(e.doc,n.from))return!1;o=n.from}else if(o=cr(e.doc,n.from,-1),o==null)return!1;if(t){let i=e.tr.join(o);r&&i.setSelection(j.create(i.doc,o-e.doc.resolve(o).nodeBefore.nodeSize)),t(i.scrollIntoView())}return!0},pd=(e,t)=>{let n=e.selection,r;if(n instanceof j){if(n.node.isTextblock||!wt(e.doc,n.to))return!1;r=n.to}else if(r=cr(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},hd=(e,t)=>{let{$from:n,$to:r}=e.selection,o=n.blockRange(r),i=o&&_t(o);return i==null?!1:(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)},pl=(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
4
  `).scrollIntoView()),!0)};function hl(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 ml=(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=hl(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},gl=(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof on||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=hl(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(L.create(l.doc,s+1)),t(l.scrollIntoView())}return!0},bl=(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(pt(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&_t(r);return o==null?!1:(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)};function wb(e){return(t,n)=>{if(t.selection instanceof j&&t.selection.node.isBlock){let{$from:p}=t.selection;return!p.parentOffset||!pt(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 L||t.selection instanceof on)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,u=!1,c=!1;for(let p=o.depth;;p--)if(o.node(p).isBlock){u=o.end(p)==o.pos+(o.depth-p),c=o.start(p)==o.pos-(o.depth-p),a=hl(o.node(p-1).contentMatchAt(o.indexAfter(p-1)));let g=e&&e(o.parent,u,o);s.unshift(g||(u&&a?{type:a}:null)),l=p;break}else{if(p==1)return!1;s.unshift(null)}let d=o.pos,f=pt(r.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=pt(r.doc,d,s.length,s)),!f)return!1;if(r.split(d,s.length,s),!u&&c&&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 kb=wb();var md=(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(j.create(e.doc,o))),!0)},vb=(e,t)=>(t&&t(e.tr.setSelection(new on(e.doc))),!0);function Cb(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||wt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function gd(e,t,n,r){let o=t.nodeBefore,i=t.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Cb(e,t,n))return!0;let u=!a&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(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=V.empty;for(let b=s.length-1;b>=0;b--)h=V.from(s[b].create(null,h));h=V.from(o.copy(h));let g=e.tr.step(new At(t.pos-1,p,t.pos,p,new ae(h,1,0),s.length,!0)),m=g.doc.resolve(p+2*s.length);m.nodeAfter&&m.nodeAfter.type==o.type&&wt(g.doc,m.pos)&&g.join(m.pos),n(g.scrollIntoView())}return!0}let c=i.type.spec.isolating||r>0&&a?null:Q.findFrom(t,1),d=c&&c.$from.blockRange(c.$to),f=d&&_t(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(u&&dr(i,"start",!0)&&dr(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 b=V.empty;for(let C=h.length-1;C>=0;C--)b=V.from(h[C].copy(b));let k=e.tr.step(new At(t.pos-h.length,t.pos+i.nodeSize,t.pos+m,t.pos+i.nodeSize-m,new ae(b,h.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function bd(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(L.create(t.doc,e<0?o.start(i):o.end(i)))),!0):!1}}var yl=bd(-1),wl=bd(1);function yd(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&ar(s,e,t);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function kl(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,u)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(e,t)))if(a.type==e)o=!0;else{let c=n.doc.resolve(u),d=c.index();o=c.parent.canReplaceWith(d,d+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 vl(...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 sl=vl(sd,ll,al),id=vl(sd,ul,dl),sn={Enter:vl(pl,gl,bl,kb),"Mod-Enter":ml,Backspace:sl,"Mod-Backspace":sl,"Shift-Backspace":sl,Delete:id,"Mod-Delete":id,"Mod-a":vb},xb={"Ctrl-h":sn.Backspace,"Alt-Backspace":sn["Mod-Backspace"],"Ctrl-d":sn.Delete,"Ctrl-Alt-Backspace":sn["Mod-Delete"],"Alt-Delete":sn["Mod-Delete"],"Alt-d":sn["Mod-Delete"],"Ctrl-a":yl,"Ctrl-e":wl};for(let e in sn)xb[e]=sn[e];var bE=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function wd(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 Sb(l,s,e,t)?(r&&r(l.scrollIntoView()),!0):!1}}function Sb(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 Ho(a,a,t.depth),t.endIndex<t.parent.childCount&&(t=new Ho(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let l=ar(i,n,r,t);return l?(e&&Eb(e,t,l,o,n),!0):!1}function Eb(e,t,n,r,o){let i=V.empty;for(let c=n.length-1;c>=0;c--)i=V.from(n[c].type.create(n[c].attrs,i));e.step(new At(t.start-(r?2:0),t.end,t.start,t.end,new ae(i,0,0),n.length,!0));let s=0;for(let c=0;c<n.length;c++)n[c].type==o&&(s=c+1);let l=n.length-s,a=t.start+n.length-(r?2:0),u=t.parent;for(let c=t.startIndex,d=t.endIndex,f=!0;c<d;c++,f=!1)!f&&pt(e.doc,a,l)&&(e.split(a,l),a+=2*l),a+=u.child(c).nodeSize;return e}function kd(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?Mb(t,n,e,i):Ab(t,n,i):!0:!1}}function Mb(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new At(i-1,s,i,s,new ae(V.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Ho(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));let l=_t(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return wt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),t(o.scrollIntoView()),!0}function Ab(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,u=i.node(-1),c=i.index(-1);if(!u.canReplace(c+(l?0:1),c+1,s.content.append(a?V.empty:V.from(o))))return!1;let d=i.pos,f=d+s.nodeSize;return r.step(new At(d-(l?1:0),f+(a?1:0),d+1,f-1,new ae((l?V.empty:V.from(o.copy(V.empty))).append(a?V.empty:V.from(o.copy(V.empty))),l?0:1,a?0:1),l?0:1)),t(r.scrollIntoView()),!0}function vd(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,u=>u.childCount>0&&u.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 u=a.lastChild&&a.lastChild.type==l.type,c=V.from(u?e.create():null),d=new ae(V.from(e.create(null,V.from(l.type.create(null,c)))),u?3:1,0),f=i.start,p=i.end;n(t.tr.step(new At(f-(u?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}var We=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},mr=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Ml=null,jt=function(e,t,n){let r=Ml||(Ml=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Tb=function(){Ml=null},Hn=function(e,t,n,r){return n&&(Cd(e,t,n,r,-1)||Cd(e,t,n,r,1))},Nb=/^(img|br|input|textarea|hr)$/i;function Cd(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Je(e))){let s=e.parentNode;if(!s||!W(s)||eo(e)||Nb.test(e.nodeName)||e.contentEditable=="false")return!1;t=We(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?Je(e):0}else return!1}}function Je(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function W(e){return e.nodeType==1}function Pe(e){return e.nodeType==3}function _n(e,t){return t?e.contains(W(t)?t:t.parentNode):!1}function Rb(e,t){for(;;){if(Pe(e)&&t)return e;if(W(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=Je(e)}else if(e.parentNode&&!eo(e))t=We(e),e=e.parentNode;else return null}}function Db(e,t){for(;;){if(Pe(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&&!eo(e))t=We(e)+1,e=e.parentNode;else return null}}function Ob(e,t,n){for(let r=t==0,o=t==Je(e);r||o;){if(e==n)return!0;let i=We(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,o=o&&i==Je(e)}}function eo(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 ii=function(e){return e.focusNode&&Hn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function On(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function Lb(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Pb(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Je(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Je(r.startContainer),r.startOffset)}}}var Tt=typeof navigator<"u"?navigator:null,xd=typeof document<"u"?document:null,dn=Tt&&Tt.userAgent||"",Al=/Edge\/(\d+)/.exec(dn),Qd=/MSIE \d/.exec(dn),Tl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(dn),it=!!(Qd||Tl||Al),cn=Qd?document.documentMode:Tl?+Tl[1]:Al?+Al[1]:0,ct=!it&&/gecko\/(\d+)/i.test(dn);ct&&+(/Firefox\/(\d+)/.exec(dn)||[0,0])[1];var Nl=!it&&/Chrome\/(\d+)/.exec(dn),Ke=!!Nl,Zd=Nl?+Nl[1]:0,Xe=!it&&!!Tt&&/Apple Computer/.test(Tt.vendor),gr=Xe&&(/Mobile\/\w+/.test(dn)||!!Tt&&Tt.maxTouchPoints>2),ht=gr||(Tt?/Mac/.test(Tt.platform):!1),ef=Tt?/Win/.test(Tt.platform):!1,Ft=/Android \d/.test(dn),si=!!xd&&"webkitFontSmoothing"in xd.documentElement.style,Ib=si?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function $b(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 Vt(e,t){return typeof e=="number"?e:e[t]}function Bb(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 Sd(e,t,n){if(!Rl(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=mr(s);continue}let l=s==i.body,a=l?$b(i):Bb(s),u=0,c=0;if(t.top<a.top+Vt(r,"top")?c=-(a.top-t.top+Vt(o,"top")):t.bottom>a.bottom-Vt(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+Vt(o,"top")-a.top:t.bottom-a.bottom+Vt(o,"bottom")),t.left<a.left+Vt(r,"left")?u=-(a.left-t.left+Vt(o,"left")):t.right>a.right-Vt(r,"right")&&(u=t.right-a.right+Vt(o,"right")),u||c)if(l)i.defaultView.scrollBy(u,c);else{let f=s.scrollLeft,p=s.scrollTop;c&&(s.scrollTop+=c),u&&(s.scrollLeft+=u);let h=s.scrollLeft-f,g=s.scrollTop-p;t={left:t.left-h,top:t.top-g,right:t.right-h,bottom:t.bottom-g}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:mr(s)}}function zb(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:tf(e.dom)}}function tf(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=mr(r));return t}function Hb({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;nf(n,r==0?0:r-t)}function nf(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 fr=null;function _b(e){if(e.setActive)return e.setActive();if(fr)return e.focus(fr);let t=tf(e);e.focus(fr==null?{get preventScroll(){return fr={preventScroll:!0},!0}}:void 0),fr||(fr=!1,nf(t,0))}function rf(e,t){let n,r=2e8,o,i=0,s=t.top,l=t.top,a,u;for(let c=e.firstChild,d=0;c;c=c.nextSibling,d++){let f;if(W(c))f=c.getClientRects();else if(Pe(c))f=jt(c).getClientRects();else continue;for(let p=0;p<f.length;p++){let h=f[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=c,r=g,o=g&&Pe(n)?{left:h.right<t.left?h.right:h.left,top:t.top}:t,W(c)&&g&&(i=d+(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=c,u={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=d+1)}}return!n&&a&&(n=a,o=u,r=0),n&&Pe(n)?Vb(n,o):!n||r?{node:e,offset:i}:rf(n,o)}function Vb(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=ln(r,1);if(s.top!=s.bottom&&Ul(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 Ul(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function jb(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Fb(e,t,n){let{node:r,offset:o}=rf(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 Wb(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 of(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 u=l[a];if(Ul(t,u))return of(s,t,u)}}if((i=(i+1)%r)==o)break}return e}function Kb(e,t){let n=e.dom.ownerDocument,r,o=0,i=Pb(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 u=e.dom.getBoundingClientRect();if(!Ul(t,u)||(s=of(e.dom,t,u),!s))return null}if(Xe)for(let u=s;r&&u;u=mr(u))u.draggable&&(r=void 0);if(s=jb(s,t),r){if(ct&&W(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let c=r.childNodes[o],d;c.nodeName=="IMG"&&(d=c.getBoundingClientRect()).right<=t.left&&d.bottom>t.top&&o++}let u;si&&o&&W(r)&&W(u=r.childNodes[o-1])&&u.contentEditable=="false"&&u.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=Wb(e,r,o,t))}l==null&&(l=Fb(e,s,t));let a=e.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Rl(e){return e.top<e.bottom||e.left<e.right}function ln(e,t){let n=e.getClientRects();if(n.length){let r=n[t<0?0:n.length-1];if(Rl(r))return r}return Array.prototype.find.call(n,Rl)||e.getBoundingClientRect()}var Ub=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function sf(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=si||ct;if(Pe(r))if(s&&(Ub.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=ln(jt(r,o,o),n);if(ct&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let u=ln(jt(r,o-1,o-1),-1);if(u.top==a.top){let c=ln(jt(r,o,o+1),-1);if(c.top!=a.top)return Ur(c,c.left<u.left)}}return a}else{let a=o,u=o,c=n<0?1:-1;return n<0&&!o?(u++,c=-1):n>=0&&o==r.nodeValue.length?(a--,c=1):n<0?a--:u++,Ur(ln(jt(r,a,u),c),c<0)}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==Je(r))){let a=r.childNodes[o-1];if(W(a))return Cl(a.getBoundingClientRect(),!1)}if(i==null&&o<Je(r)){let a=r.childNodes[o];if(W(a))return Cl(a.getBoundingClientRect(),!0)}return Cl(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==Je(r))){let a=r.childNodes[o-1],u=Pe(a)?jt(a,Je(a)-(s?0:1)):W(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Ur(ln(u,1),!1)}if(i==null&&o<Je(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let u=a?Pe(a)?jt(a,0,s?0:1):W(a)?a:null:null;if(u)return Ur(ln(u,-1),!0)}return Ur(ln(Pe(r)?jt(r):r,-n),n>=0)}function Ur(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 Cl(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 lf(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 qb(e,t,n){let r=t.selection,o=n=="up"?r.$from:r.$to;return lf(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=sf(e,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(W(l))a=l.getClientRects();else if(Pe(l))a=jt(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<a.length;u++){let c=a[u];if(c.bottom>c.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}var Gb=/[\u0590-\u08ac]/;function Jb(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?!Gb.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:lf(e,t,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:d}=e.domSelectionRange(),f=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&&!_n(p,h)||a==h&&u==g;try{l.collapse(c,d),a&&(a!=c||u!=d)&&l.extend&&l.extend(a,u)}catch{}return f!=null&&(l.caretBidiLevel=f),m}):r.pos==r.start()||r.pos==r.end()}var Ed=null,Md=null,Ad=!1;function Xb(e,t,n){return Ed==t&&Md==n?Ad:(Ed=t,Md=n,Ad=n=="up"||n=="down"?qb(e,t,n):Jb(e,t,n))}var mt=0,Td=1,Ln=2,kt=3,Vn=class{constructor(t,n,r,o){this.parent=t,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=mt,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&&_n(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>We(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)?_n(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 Yo||i instanceof Jo&&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?We(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?We(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],u=s+a.size;if(o==-1&&t<=u){let c=s+a.border;if(t>=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,n,c);t=s;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=We(f.dom)+1;break}t-=f.size}o==-1&&(o=0)}if(o>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;c<this.children.length;c++){let d=this.children[c];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=We(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=u}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),u=r.root.getSelection(),c=r.domSelectionRange(),d=!1;if((ct||Xe)&&t==n){let{node:p,offset:h}=l;if(Pe(p)){if(d=!!(h&&p.nodeValue[h-1]==`
@@ -151,7 +151,7 @@ ${n}
151
151
  `);if(i.length<2)return;let s=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(s)||!s.includes("|"))return;let l=A1(o);if(l===o)return;let a=n.blockTokens(l)[0];if(a?.type!=="table"||!a.raw)return;let u=a.raw.split(`
152
152
  `).length,c=e.split(`
153
153
  `).slice(0,u).join(`
154
- `);return{...a,raw:c}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=E1(i.schema,e,t,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(L.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Mh(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Ah(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=Er(e.selection.$from,r=>r.type.name==="table");return Th(e,t&&(r=>{n&&$g(r,n.pos),t(r)}))},addRowBefore:()=>({state:e,dispatch:t})=>Rh(e,t),addRowAfter:()=>({state:e,dispatch:t})=>Dh(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=Er(e.selection.$from,r=>r.type.name==="table");return Oh(e,t&&(r=>{n&&$g(r,n.pos),t(r)}))},deleteTable:()=>({state:e,dispatch:t})=>Ih(e,t),mergeCells:()=>({state:e,dispatch:t})=>Ba(e,t),splitCell:()=>({state:e,dispatch:t})=>za(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Or("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Or("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Ph(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>Ba(e,t)?!0:za(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Lh(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Ha(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Ha(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&$a(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let r=se.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:Ps,"Mod-Backspace":Ps,Delete:Ps,"Mod-Delete":Ps}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Bh({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Hh({allowTableNodeSelection:this.options.allowTableNodeSelection}),P1()]},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:de(B(e,"tableRole",t))}}}),Fg=le.create({name:"tableKit",addExtensions(){let e=[];return this.options.table!==!1&&e.push(I1.configure(this.options.table)),this.options.tableCell!==!1&&e.push(k1.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(v1.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(C1.configure(this.options.tableRow)),e}});var Wg=As;var Kg=Ms;var $1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,B1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,z1=He.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||Np(e,"background-color")||e.style.backgroundColor,renderHTML:e=>Tr(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[st({find:$1,type:this.type})]},addPasteRules(){return[rt({find:B1,type:this.type})]}}),Ug=z1;var qg=Ug.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 H1=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=>!Tr(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")}}}),Gg=H1;var Jg=le.create({name:"dropCursorCleanup",addProseMirrorPlugins(){return[new q({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 rr=pe(zt(),1);var fe=pe(Fe(),1);function Xg({node:e,updateAttributes:t,editor:n,selected:r,getPos:o}){let{renderWidget:i}=(0,rr.useContext)(Uo),s=fo({editor:n,selector:({editor:l})=>l.isEditable});return(0,fe.jsx)(qn,{className:`document-widget${r&&s?" is-selected":""}`,"data-widget-kind":e.attrs.kind,"data-block-id":e.attrs.id??void 0,onPointerDownCapture:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;if(rl(l.target,l.clientX,l.clientY)){let u=Dr(n.state);u&&n.view.dispatch(u);return}let a=o();!r&&typeof a=="number"&&n.commands.setNodeSelection(a)},onClick:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;if(rl(l.target,l.clientX,l.clientY)||l.target.closest('[data-text-selection="true"]')){l.stopPropagation();return}let a=o();typeof a=="number"&&(n.commands.setNodeSelection(a),l.stopPropagation())},children:(0,fe.jsx)(ju,{id:e.attrs.id,children:i({kind:e.attrs.kind,data:e.attrs.data,onChange:l=>{n.isEditable&&t({data:Ko(l)})},readOnly:!s})})})}var Pc=["\u{1F4A1}","\u{1F331}","\u{1F4CC}","\u2728","\u26A0\uFE0F","\u{1F50E}"],Ic=["sage","sand","blue","rose"];function Yg({node:e,updateAttributes:t,editor:n}){let r=Re(ze),o=fo({editor:n,selector:({editor:i})=>i.isEditable});return(0,fe.jsxs)(qn,{style:rn(e.attrs.componentStyle),className:`document-callout tone-${e.attrs.tone}`,"data-block-id":e.attrs.id??void 0,children:[(0,fe.jsxs)("div",{className:"callout-decoration",contentEditable:!1,children:[(0,fe.jsx)("button",{className:"callout-icon",disabled:!o,title:r("callout.changeIcon"),"aria-label":r("callout.changeIconLabel"),onClick:()=>t({icon:Pc[(Pc.indexOf(e.attrs.icon)+1)%Pc.length]}),children:e.attrs.icon}),o&&(0,fe.jsx)("button",{className:"callout-color",title:r("callout.changeColor"),"aria-label":r("callout.changeColorLabel"),onClick:()=>t({tone:Ic[(Ic.indexOf(e.attrs.tone)+1)%Ic.length]})})]}),(0,fe.jsxs)("div",{children:[e.attrs.title&&(0,fe.jsx)("strong",{children:e.attrs.title}),(0,fe.jsx)(Mi,{className:"callout-content"})]})]})}function Qg({node:e,updateAttributes:t,editor:n}){let r=Re(ze),o=fo({editor:n,selector:({editor:c})=>c.isEditable}),[i,s]=(0,rr.useState)(!!e.attrs.open);(0,rr.useEffect)(()=>s(!!e.attrs.open),[e.attrs.open]);let[l,a]=ol("open",!!e.attrs.open,{block:e.attrs.id??null,accept:c=>typeof c=="boolean"}),u=o?i:l;return(0,fe.jsxs)(qn,{style:rn(e.attrs.componentStyle),className:`document-toggle${u?" is-open":""}`,"data-block-id":e.attrs.id??void 0,children:[(0,fe.jsxs)("div",{className:"toggle-heading",contentEditable:!1,children:[(0,fe.jsx)("button",{"aria-label":r(u?"toggle.collapse":"toggle.expand"),"aria-expanded":u,onClick:()=>{if(!n.isEditable)return a(!u);s(!u),t({open:!u})},children:(0,fe.jsx)(Po,{size:16})}),o?(0,fe.jsx)("input",{"aria-label":r("toggle.titleLabel"),value:e.attrs.title,onChange:c=>t({title:c.target.value}),placeholder:r("toggle.titlePlaceholder")}):(0,fe.jsx)("span",{children:e.attrs.title})]}),(0,fe.jsx)("div",{className:"toggle-body",hidden:!u,children:(0,fe.jsx)(Mi,{})})]})}function Zg({node:e,editor:t,getPos:n}){let r=Re(ze),o=fo({editor:t,selector:({editor:b})=>b.isEditable}),[i,s]=ol("step",0,{block:e.attrs.id??null,accept:Number.isInteger}),l=e.childCount,a=Math.min(i,l-1),u=Array.from({length:l},(b,k)=>Gu(e.child(k).attrs.title,k)),c=()=>{let b=n();if(typeof b!="number")throw new Error("The stepper is detached.");return b+1},d=b=>{let k=c();for(let C=0;C<b;C+=1)k+=e.child(C).nodeSize;return k};(0,rr.useEffect)(()=>{let b=()=>{let k=n(),C=typeof k=="number"?t.state.doc.nodeAt(k):null;if(!C||C.type.name!=="stepper")return;let{from:S}=t.state.selection;if(S<=k||S>=k+C.nodeSize)return;let M=k+1;for(let T=0;T<C.childCount;T+=1)if(M+=C.child(T).nodeSize,S<M)return s(T)};return t.on("selectionUpdate",b),()=>{t.off("selectionUpdate",b)}},[t,n]);let f=b=>{let{tr:k}=t.state,C=b(k);return t.view.dispatch(k),s(C),C},p=b=>f(k=>(k.setNodeMarkup(d(a),void 0,{...e.child(a).attrs,title:b}),a)),h=()=>{f(b=>{let{schema:k}=t.state,C=d(a)+e.child(a).nodeSize;return b.insert(C,k.nodes.step.create({title:""},k.nodes.paragraph.create())),b.setSelection(L.create(b.doc,C+2)),a+1}),t.view.focus()},g=()=>f(b=>{let k=d(a);return b.delete(k,k+e.child(a).nodeSize),Math.max(0,a-1)}),m=b=>f(k=>{let C=a+b,S=e.child(a),M=d(a),T=b<0?d(C):d(C)+e.child(C).nodeSize;return k.delete(M,M+S.nodeSize),k.insert(k.mapping.map(T),S),C});return(0,fe.jsxs)(qn,{style:rn(e.attrs.componentStyle),className:"document-stepper","data-block-id":e.attrs.id??void 0,children:[(0,fe.jsx)(Ju,{titles:u,active:a,onSelect:s}),o&&(0,fe.jsxs)("div",{className:"stepper-edit",contentEditable:!1,children:[(0,fe.jsx)("input",{"aria-label":r("stepper.titleLabel"),placeholder:r("stepper.titlePlaceholder"),value:e.child(a).attrs.title??"",onChange:b=>p(b.target.value)}),(0,fe.jsx)("button",{type:"button",title:r("stepper.moveEarlier"),"aria-label":r("stepper.moveEarlier"),disabled:a===0,onClick:()=>m(-1),children:"\u21A4"}),(0,fe.jsx)("button",{type:"button",title:r("stepper.moveLater"),"aria-label":r("stepper.moveLater"),disabled:a===l-1,onClick:()=>m(1),children:"\u21A6"}),(0,fe.jsx)("button",{type:"button",title:r("stepper.add"),"aria-label":r("stepper.add"),disabled:l>=Iu,onClick:h,children:"+"}),(0,fe.jsx)("button",{type:"button",title:r("stepper.remove"),"aria-label":r("stepper.remove"),disabled:l<=1,onClick:g,children:"\xD7"})]}),(0,fe.jsx)(Mi,{className:"stepper-steps","data-active":a})]})}function eb({node:e,updateAttributes:t,editor:n,selected:r}){let o=Re(ze),i=e.type.name==="mathBlock"||e.attrs.display;return qu(),(0,fe.jsxs)(qn,{as:i?"div":"span",className:i?"sb-math-display":"sb-math-inline",contentEditable:!1,children:[(0,fe.jsx)("span",{dangerouslySetInnerHTML:{__html:Lu(e.attrs.latex,i)}}),r&&n.isEditable&&(0,fe.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 tb({node:e}){return(0,fe.jsx)(qn,{"data-block-id":e.attrs.id,"data-drag-handle":!0,contentEditable:!1,children:(0,fe.jsx)(Wu,{attrs:e.attrs})})}var Bc=["paragraph","heading","blockquote","bulletList","orderedList","listItem","taskList","taskItem","codeBlock","hardBreak","horizontalRule","image","table","tableRow","tableCell","tableHeader","callout","toggle","stepper","step","widget","mathInline","mathBlock"],$s=new oe("showaiBlockIds");function _1(e){let t=new Set([...Bc,"region","richText","pageModule"]);return new q({key:$s,appendTransaction(n,r,o){if(!e()||!n.some(l=>l.docChanged||l.getMeta($s)||l.getMeta("editableChanged")))return null;let i=new Set,s=o.tr;return o.doc.descendants((l,a)=>{if(!t.has(l.type.name))return;let u=l.attrs.id;if(typeof u=="string"&&u.trim()&&!i.has(u)){i.add(u);return}let c;do c=globalThis.crypto.randomUUID();while(i.has(c));i.add(c),s.setNodeAttribute(a,"id",c)}),s.docChanged?s.setMeta($s,!0).setMeta("addToHistory",!1):null}})}var V1=le.create({name:"showaiStableBlockIds",addOptions:()=>({readOnly:!1}),addGlobalAttributes(){return[{types:[...Bc,"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[_1(()=>!this.options.readOnly&&this.editor.isEditable)]},onCreate(){!this.options.readOnly&&this.editor.isEditable&&this.editor.view.dispatch(this.editor.state.tr.setMeta($s,!0).setMeta("addToHistory",!1))}}),j1=ie.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:()=>Gn(Xg)}),F1=ie.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:()=>Gn(Yg)}),W1=ie.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:()=>Gn(Qg)}),K1=ie.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:()=>Gn(Zg)}),U1=ie.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]}),q1=ie.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(rn(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]}),G1=He.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]}),J1=He.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]}),nb=e=>ie.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:()=>Gn(eb)}),rb=ur(ze);function ob(e={}){return[X1,q1,G1,J1,nb(!0),nb(!1),V1.configure({readOnly:e.readOnly??!1}),Jg,og.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)=>!!lr(t)||n.defaultValidate(t)},codeBlock:!1}),Dg,Og.configure({placeholder:({node:t,editor:n})=>t.type.name==="heading"?rb("placeholderHeading"):typeof e.placeholder=="function"?e.placeholder({empty:n.isEmpty}):e.placeholder??rb("placeholderDefault"),includeChildren:!1}),Lg.extend({addNodeView:()=>Gn(tb)}).configure({allowBase64:!0,HTMLAttributes:{class:"document-image"}}),Fg.configure({table:{resizable:!0,View:$c}}),Wh,Wg,Kg.configure({nested:!0}),qg.configure({multicolor:!0}),Gg.configure({types:["heading","paragraph"]}),F1,W1,K1,U1,j1]}var X1=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({...rn(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:Bc,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")}}]}}),$c=class extends Lc{constructor(...t){super(...t),this.syncMetadata()}syncMetadata(){let t=rn(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=pe(Fe(),1),ib=new WeakSet,sb=ur(ze);function Y1({children:e,className:t,onDismiss:n}){return(0,v.jsx)("div",{className:t,onMouseDown:r=>{r.target===r.currentTarget&&n()},children:e})}function Bt({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 Q1(e){return/^https?:\/\//i.test(e)||/^data:image\/(png|jpe?g|gif|webp|avif);base64,/i.test(e)}function lb(e){return/^(https?:\/\/|mailto:|tel:|#)/i.test(e)||!!lr(e)}function Hc(e){return e.startsWith("page-tail-")}function _c(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 Z1({content:e,onChange:t,readOnly:n=!1,minimal:r=!0,onEditorReady:o,onInsertNative:i,onDetachBlock:s,additionalExtensions:l,trailingNode:a=!0,retentionKey:u}){let c=Re(ze),d=Re(Vu),f=Re(Go),p=(0,P.useRef)(t),h=(0,P.useId)();p.current=t;let g=(0,P.useRef)(null),m=(0,P.useRef)(null),b=(0,P.useRef)(null),k=(0,P.useRef)(null),C=(0,P.useRef)(null),S=(0,P.useRef)([]),M=(0,P.useRef)(()=>{}),T=(0,P.useRef)(0),E=(0,P.useRef)(null),[O,X]=(0,P.useState)(null),{useCatalog:he,registerComponent:Ne,assistant:$e,pageLinks:xe}=(0,P.useContext)(Uo),_e=(0,P.useRef)(xe);_e.current=xe;let Me=he(!!O),[N,_]=(0,P.useState)(!1),ee=(0,P.useRef)(0);(0,P.useEffect)(()=>()=>{ee.current++},[]);let[ue,Se]=(0,P.useState)(0),[Y,Ve]=(0,P.useState)(null),[Ze,me]=(0,P.useState)(!1),je=(0,P.useRef)(null),zr=(0,P.useRef)(Ze);zr.current=Ze;let wn=(0,P.useRef)(0),Hr=(0,P.useRef)(0);(0,P.useEffect)(()=>()=>cancelAnimationFrame(wn.current),[]);let Ct=(0,P.useCallback)(()=>{je.current!==null&&(clearTimeout(je.current),je.current=null)},[]),Do=(0,P.useCallback)(()=>{je.current===null&&(je.current=setTimeout(()=>{je.current=null;let y=g.current?.querySelector(".block-handle");zr.current||E.current!==null||y?.contains(document.activeElement)||Ve(null)},450))},[]);(0,P.useEffect)(()=>Ct,[Ct]);let[kn,tn]=(0,P.useState)(!1),[xt,at]=(0,P.useState)(!1),[U,Le]=(0,P.useState)(null),[St,J]=(0,P.useState)(null),[_r,Ce]=(0,P.useState)(""),[ge,yt]=(0,P.useState)(""),[qe,et]=(0,P.useState)(null);(0,P.useEffect)(()=>{!qe&&St&&(Le(null),J(null))},[!!qe,St]);let Et=(0,P.useRef)(null),D=(0,P.useRef)(!1),[,z]=(0,P.useState)(0),G=(0,P.useRef)(null);k.current=O,T.current=ue;let be=(0,P.useMemo)(()=>[...ob({placeholder:({empty:y})=>sb(y&&!a?"placeholderPage":"placeholder"),trailingNode:a}),...l??[]],[l,a]);(0,P.useLayoutEffect)(()=>{if(!Ze)return;let y=g.current,x=y?.querySelector(".block-menu"),A=y?.querySelector(".block-handle");if(!x||!A)return;let $=()=>{let F=A.getBoundingClientRect(),ne=x.getBoundingClientRect();Object.assign(x.style,{position:"fixed",left:`${Math.max(12,Math.min(F.right,window.innerWidth-ne.width-12))}px`,top:`${Math.max(12,Math.min(F.top,window.innerHeight-ne.height-12))}px`})};$();let I=new ResizeObserver($);return I.observe(x),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{I.disconnect(),window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[Ze,Y?.pos]);let w=sh({retentionKey:u,extensions:be,content:e,editable:!n,immediatelyRender:!1,shouldRerenderOnTransaction:!1,editorProps:{attributes:{class:"document-content","aria-label":sb("documentContent"),spellcheck:"false"},handleKeyDown:(y,x)=>{if(x.isComposing)return!1;if(x.key==="Escape"&&!k.current&&!y.state.selection.empty)return Et.current=`${y.state.selection.from}:${y.state.selection.to}`,et(null),x.preventDefault(),!0;if(!k.current)return!1;if(x.key==="Escape")return Vr(),!0;if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();let A=S.current.length;return Se($=>A?($+(x.key==="ArrowDown"?1:-1)+A)%A:0),!0}return x.key==="Enter"&&S.current.length?(M.current(T.current),!0):!1},handleClick:(y,x,A)=>{let $=A.target.closest?.("a[href]");if(!$||!n&&!A.metaKey&&!A.ctrlKey)return!1;let I=$.getAttribute("href")??"";if(!lb(I))return!0;let F=Nu(I);return F&&Ru($,F,n?A:void 0)||(I.startsWith("#")?document.getElementById(I.slice(1))?.scrollIntoView({behavior:"smooth",block:"start"}):F||window.open(I,"_blank","noopener,noreferrer")),!0},handlePaste:(y,x)=>{let A=x.clipboardData?.getData("text/plain").trim()??"";if(lr(A)){x.preventDefault();let{empty:F,from:ne,to:ke}=y.state.selection,Z=y.state.schema.marks.link.create({href:A});return y.dispatch(F?y.state.tr.insert(ne,y.state.schema.text(jc(A),[Z])):y.state.tr.addMark(ne,ke,Z)),!0}let I=[...x.clipboardData?.files??[]].filter(F=>F.type.startsWith("image/"));return I.length?(x.preventDefault(),zs(I),!0):!1}},onUpdate:({editor:y,transaction:x})=>p.current(Aa(y.state.doc),{separateHistory:!!x.getMeta(Yn),historyGroup:x.getMeta(zu)})});(0,P.useEffect)(()=>w?Hu(w):void 0,[w]),(0,P.useEffect)(()=>{w&&o?.(w)},[w,o]),(0,P.useEffect)(()=>{w&&w.isEditable===n&&(w.setEditable(!n,!1),w.view.dispatch(w.state.tr.setMeta("editableChanged",!0))),z(y=>y+1),n&&(X(null),Ve(null),me(!1),tn(!1),at(!1),Le(null),et(null))},[w,n]);let ft=(0,P.useRef)(e);ft.current=e;let or=(0,P.useRef)(!1);(0,P.useEffect)(()=>{if(!w)return;let y=()=>{or.current=!0},x=()=>{or.current=!1};return w.on("beforeTransaction",y),w.on("transaction",x),()=>{w.off("beforeTransaction",y),w.off("transaction",x)}},[w]),(0,P.useLayoutEffect)(()=>{if(!w)return;let y,x=()=>{if(w.isDestroyed)return;if(w.view.composing||or.current){y=setTimeout(x,or.current?0:25);return}let $=dh(w.state,ft.current);if(!$)return;let I=w.state.selection instanceof j&&w.state.selection.node.type.name==="widget"?w.state.selection.node.attrs.id:null,F=w.state.selection instanceof se?w.state.selection:null;if(w.view.dispatch($),F){let ne=jh(w.state.doc,F);ne&&w.view.dispatch(w.state.tr.setSelection(ne))}if(I){let ne;if(w.state.doc.descendants((ke,Z)=>{ke.type.name==="widget"&&ke.attrs.id===I&&(ne=Z)}),ne!==void 0)w.commands.setNodeSelection(ne);else{let ke=Dr(w.state);ke&&w.view.dispatch(ke)}}},A=()=>{y=setTimeout(x,25)};return w.view.composing?w.view.dom.addEventListener("compositionend",A):x(),()=>{y&&clearTimeout(y),w.view.dom.removeEventListener("compositionend",A)}},[e,w]),(0,P.useEffect)(()=>{if(!U)return;let y=requestAnimationFrame(()=>document.querySelector(".editor-modal input, .editor-modal textarea")?.focus()),x=A=>{if(A.key==="Escape"&&(A.preventDefault(),A.stopPropagation(),Le(null),w?.commands.focus()),A.key!=="Tab")return;let $=Array.from(document.querySelectorAll(".editor-modal button:not(:disabled), .editor-modal input:not(:disabled), .editor-modal textarea:not(:disabled)")),I=$[0],F=$[$.length-1];A.shiftKey&&document.activeElement===I?(A.preventDefault(),F?.focus()):!A.shiftKey&&document.activeElement===F&&(A.preventDefault(),I?.focus())};return document.addEventListener("keydown",x,!0),()=>{cancelAnimationFrame(y),document.removeEventListener("keydown",x,!0)}},[!!U,w]),(0,P.useEffect)(()=>{if(!w||n)return;let y=()=>{let A=Dr(w.state);A&&w.view.dispatch(A)};!ib.has(w)&&!ih(w)&&(ib.add(w),w.isInitialized?y():w.on("create",y));let x=A=>{if(A.button!==0||!(A.target instanceof Element))return;let $=A.target,I=$.closest(".document-widget");if(I&&w.view.dom.contains(I)||!I&&$.closest('button, input, textarea, select, a, summary, [role="button"], [role="dialog"], .block-handle, .editor-toolbar, .editor-bubble, .editor-small-menu, .editor-modal'))return;let F=Dr(w.state);if(!F)return;let ne=document.activeElement;ne instanceof HTMLElement&&w.view.dom.contains(ne)&&ne.blur(),w.view.dispatch(F),w.view.dom.contains($)&&!$.closest("[data-block-id]")&&A.preventDefault()};return document.addEventListener("pointerdown",x,!0),()=>{w.off("create",y),document.removeEventListener("pointerdown",x,!0)}},[w,n]),(0,P.useEffect)(()=>{if(!O?.manual)return;let y=requestAnimationFrame(()=>b.current?.focus());return()=>cancelAnimationFrame(y)},[O?.manual]),(0,P.useEffect)(()=>{if(!kn&&!xt&&!Ze)return;let y=x=>{x.key==="Escape"&&(x.preventDefault(),tn(!1),at(!1),me(!1),w?.commands.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[kn,xt,Ze,w]),(0,P.useEffect)(()=>{if(!ge)return;let y=window.setTimeout(()=>yt(""),4500);return()=>window.clearTimeout(y)},[ge]),(0,P.useEffect)(()=>{if(!w)return;let y=()=>{if((!r||!w.state.selection.empty)&&z(Sn=>Sn+1),!w.isEditable)return;let{selection:Z}=w.state,{$from:Be,from:Cn,to:nn,empty:xn}=Z;if((xn||Et.current&&Et.current!==`${Cn}:${nn}`)&&(Et.current=null),!k.current?.manual){let Sn=Be.parent.isTextblock?Be.parent.textBetween(0,Be.parentOffset,`
154
+ `);return{...a,raw:c}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=E1(i.schema,e,t,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(L.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Mh(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Ah(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=Er(e.selection.$from,r=>r.type.name==="table");return Th(e,t&&(r=>{n&&$g(r,n.pos),t(r)}))},addRowBefore:()=>({state:e,dispatch:t})=>Rh(e,t),addRowAfter:()=>({state:e,dispatch:t})=>Dh(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=Er(e.selection.$from,r=>r.type.name==="table");return Oh(e,t&&(r=>{n&&$g(r,n.pos),t(r)}))},deleteTable:()=>({state:e,dispatch:t})=>Ih(e,t),mergeCells:()=>({state:e,dispatch:t})=>Ba(e,t),splitCell:()=>({state:e,dispatch:t})=>za(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Or("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Or("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Ph(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>Ba(e,t)?!0:za(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Lh(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Ha(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Ha(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&$a(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let r=se.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:Ps,"Mod-Backspace":Ps,Delete:Ps,"Mod-Delete":Ps}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Bh({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Hh({allowTableNodeSelection:this.options.allowTableNodeSelection}),P1()]},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:de(B(e,"tableRole",t))}}}),Fg=le.create({name:"tableKit",addExtensions(){let e=[];return this.options.table!==!1&&e.push(I1.configure(this.options.table)),this.options.tableCell!==!1&&e.push(k1.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(v1.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(C1.configure(this.options.tableRow)),e}});var Wg=As;var Kg=Ms;var $1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,B1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,z1=He.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||Np(e,"background-color")||e.style.backgroundColor,renderHTML:e=>Tr(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[st({find:$1,type:this.type})]},addPasteRules(){return[rt({find:B1,type:this.type})]}}),Ug=z1;var qg=Ug.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 H1=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=>!Tr(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")}}}),Gg=H1;var Jg=le.create({name:"dropCursorCleanup",addProseMirrorPlugins(){return[new q({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 rr=pe(zt(),1);var fe=pe(Fe(),1);function Xg({node:e,updateAttributes:t,editor:n,selected:r,getPos:o}){let{renderWidget:i}=(0,rr.useContext)(Uo),s=fo({editor:n,selector:({editor:l})=>l.isEditable});return(0,fe.jsx)(qn,{className:`document-widget${r&&s?" is-selected":""}`,"data-widget-kind":e.attrs.kind,"data-block-id":e.attrs.id??void 0,onPointerDownCapture:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;if(rl(l.target,l.clientX,l.clientY)){let u=Dr(n.state);u&&n.view.dispatch(u);return}let a=o();!r&&typeof a=="number"&&n.commands.setNodeSelection(a)},onClick:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;if(rl(l.target,l.clientX,l.clientY)||l.target.closest('[data-text-selection="true"]')){l.stopPropagation();return}let a=o();typeof a=="number"&&(n.commands.setNodeSelection(a),l.stopPropagation())},children:(0,fe.jsx)(ju,{id:e.attrs.id,children:i({kind:e.attrs.kind,data:e.attrs.data,onChange:l=>{n.isEditable&&t({data:Ko(l)})},readOnly:!s})})})}var Pc=["\u{1F4A1}","\u{1F331}","\u{1F4CC}","\u2728","\u26A0\uFE0F","\u{1F50E}"],Ic=["sage","sand","blue","rose"];function Yg({node:e,updateAttributes:t,editor:n}){let r=Re(ze),o=fo({editor:n,selector:({editor:i})=>i.isEditable});return(0,fe.jsxs)(qn,{style:rn(e.attrs.componentStyle),className:`document-callout tone-${e.attrs.tone}`,"data-block-id":e.attrs.id??void 0,children:[(0,fe.jsxs)("div",{className:"callout-decoration",contentEditable:!1,children:[(0,fe.jsx)("button",{className:"callout-icon",disabled:!o,title:r("callout.changeIcon"),"aria-label":r("callout.changeIconLabel"),onClick:()=>t({icon:Pc[(Pc.indexOf(e.attrs.icon)+1)%Pc.length]}),children:e.attrs.icon}),o&&(0,fe.jsx)("button",{className:"callout-color",title:r("callout.changeColor"),"aria-label":r("callout.changeColorLabel"),onClick:()=>t({tone:Ic[(Ic.indexOf(e.attrs.tone)+1)%Ic.length]})})]}),(0,fe.jsxs)("div",{children:[e.attrs.title&&(0,fe.jsx)("strong",{children:e.attrs.title}),(0,fe.jsx)(Mi,{className:"callout-content"})]})]})}function Qg({node:e,updateAttributes:t,editor:n}){let r=Re(ze),o=fo({editor:n,selector:({editor:c})=>c.isEditable}),[i,s]=(0,rr.useState)(!!e.attrs.open);(0,rr.useEffect)(()=>s(!!e.attrs.open),[e.attrs.open]);let[l,a]=ol("open",!!e.attrs.open,{block:e.attrs.id??null,accept:c=>typeof c=="boolean"}),u=o?i:l;return(0,fe.jsxs)(qn,{style:rn(e.attrs.componentStyle),className:`document-toggle${u?" is-open":""}`,"data-block-id":e.attrs.id??void 0,children:[(0,fe.jsxs)("div",{className:"toggle-heading",contentEditable:!1,children:[(0,fe.jsx)("button",{"aria-label":r(u?"toggle.collapse":"toggle.expand"),"aria-expanded":u,onClick:()=>{if(!n.isEditable)return a(!u);s(!u),t({open:!u})},children:(0,fe.jsx)(Po,{size:16})}),o?(0,fe.jsx)("input",{"aria-label":r("toggle.titleLabel"),value:e.attrs.title,onChange:c=>t({title:c.target.value}),placeholder:r("toggle.titlePlaceholder")}):(0,fe.jsx)("span",{children:e.attrs.title})]}),(0,fe.jsx)("div",{className:"toggle-body",hidden:!u,children:(0,fe.jsx)(Mi,{})})]})}function Zg({node:e,editor:t,getPos:n}){let r=Re(ze),o=fo({editor:t,selector:({editor:b})=>b.isEditable}),[i,s]=ol("step",0,{block:e.attrs.id??null,accept:Number.isInteger}),l=e.childCount,a=Math.min(i,l-1),u=Array.from({length:l},(b,k)=>Gu(e.child(k).attrs.title,k)),c=()=>{let b=n();if(typeof b!="number")throw new Error("The stepper is detached.");return b+1},d=b=>{let k=c();for(let C=0;C<b;C+=1)k+=e.child(C).nodeSize;return k};(0,rr.useEffect)(()=>{let b=()=>{let k=n(),C=typeof k=="number"?t.state.doc.nodeAt(k):null;if(!C||C.type.name!=="stepper")return;let{from:S}=t.state.selection;if(S<=k||S>=k+C.nodeSize)return;let M=k+1;for(let T=0;T<C.childCount;T+=1)if(M+=C.child(T).nodeSize,S<M)return s(T)};return t.on("selectionUpdate",b),()=>{t.off("selectionUpdate",b)}},[t,n]);let f=b=>{let{tr:k}=t.state,C=b(k);return t.view.dispatch(k),s(C),C},p=b=>f(k=>(k.setNodeMarkup(d(a),void 0,{...e.child(a).attrs,title:b}),a)),h=()=>{f(b=>{let{schema:k}=t.state,C=d(a)+e.child(a).nodeSize;return b.insert(C,k.nodes.step.create({title:""},k.nodes.paragraph.create())),b.setSelection(L.create(b.doc,C+2)),a+1}),t.view.focus()},g=()=>f(b=>{let k=d(a);return b.delete(k,k+e.child(a).nodeSize),Math.max(0,a-1)}),m=b=>f(k=>{let C=a+b,S=e.child(a),M=d(a),T=b<0?d(C):d(C)+e.child(C).nodeSize;return k.delete(M,M+S.nodeSize),k.insert(k.mapping.map(T),S),C});return(0,fe.jsxs)(qn,{style:rn(e.attrs.componentStyle),className:"document-stepper","data-block-id":e.attrs.id??void 0,children:[(0,fe.jsx)(Ju,{titles:u,active:a,onSelect:s}),o&&(0,fe.jsxs)("div",{className:"stepper-edit",contentEditable:!1,children:[(0,fe.jsx)("input",{"aria-label":r("stepper.titleLabel"),placeholder:r("stepper.titlePlaceholder"),value:e.child(a).attrs.title??"",onChange:b=>p(b.target.value)}),(0,fe.jsx)("button",{type:"button",title:r("stepper.moveEarlier"),"aria-label":r("stepper.moveEarlier"),disabled:a===0,onClick:()=>m(-1),children:"\u21A4"}),(0,fe.jsx)("button",{type:"button",title:r("stepper.moveLater"),"aria-label":r("stepper.moveLater"),disabled:a===l-1,onClick:()=>m(1),children:"\u21A6"}),(0,fe.jsx)("button",{type:"button",title:r("stepper.add"),"aria-label":r("stepper.add"),disabled:l>=Iu,onClick:h,children:"+"}),(0,fe.jsx)("button",{type:"button",title:r("stepper.remove"),"aria-label":r("stepper.remove"),disabled:l<=1,onClick:g,children:"\xD7"})]}),(0,fe.jsx)(Mi,{className:"stepper-steps","data-active":a})]})}function eb({node:e,updateAttributes:t,editor:n,selected:r}){let o=Re(ze),i=e.type.name==="mathBlock"||e.attrs.display;return qu(),(0,fe.jsxs)(qn,{as:i?"div":"span",className:i?"sb-math-display":"sb-math-inline",contentEditable:!1,children:[(0,fe.jsx)("span",{dangerouslySetInnerHTML:{__html:Lu(e.attrs.latex,i)}}),r&&n.isEditable&&(0,fe.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 tb({node:e}){return(0,fe.jsx)(qn,{"data-block-id":e.attrs.id,"data-drag-handle":!0,contentEditable:!1,children:(0,fe.jsx)(Wu,{attrs:e.attrs})})}var Bc=["paragraph","heading","blockquote","bulletList","orderedList","listItem","taskList","taskItem","codeBlock","hardBreak","horizontalRule","image","table","tableRow","tableCell","tableHeader","callout","toggle","stepper","step","widget","mathInline","mathBlock"],$s=new oe("showaiBlockIds");function _1(e){let t=new Set([...Bc,"region","richText","pageModule"]);return new q({key:$s,appendTransaction(n,r,o){if(!e()||!n.some(l=>l.docChanged||l.getMeta($s)||l.getMeta("editableChanged")))return null;let i=new Set,s=o.tr;return o.doc.descendants((l,a)=>{if(!t.has(l.type.name))return;let u=l.attrs.id;if(typeof u=="string"&&u.trim()&&!i.has(u)){i.add(u);return}let c;do c=globalThis.crypto.randomUUID();while(i.has(c));i.add(c),s.setNodeAttribute(a,"id",c)}),s.docChanged?s.setMeta($s,!0).setMeta("addToHistory",!1):null}})}var V1=le.create({name:"showaiStableBlockIds",addOptions:()=>({readOnly:!1}),addGlobalAttributes(){return[{types:[...Bc,"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[_1(()=>!this.options.readOnly&&this.editor.isEditable)]},onCreate(){!this.options.readOnly&&this.editor.isEditable&&this.editor.view.dispatch(this.editor.state.tr.setMeta($s,!0).setMeta("addToHistory",!1))}}),j1=ie.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:()=>Gn(Xg)}),F1=ie.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:()=>Gn(Yg)}),W1=ie.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:()=>Gn(Qg)}),K1=ie.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:()=>Gn(Zg)}),U1=ie.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]}),q1=ie.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(rn(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]}),G1=He.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]}),J1=He.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]}),nb=e=>ie.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:()=>Gn(eb)}),rb=ur(ze);function ob(e={}){return[X1,q1,G1,J1,nb(!0),nb(!1),V1.configure({readOnly:e.readOnly??!1}),Jg,og.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)=>!!lr(t)||n.defaultValidate(t)},codeBlock:!1}),Dg,Og.configure({placeholder:({node:t,editor:n})=>t.type.name==="heading"?rb("placeholderHeading"):typeof e.placeholder=="function"?e.placeholder({empty:n.isEmpty}):e.placeholder??rb("placeholderDefault"),includeChildren:!1}),Lg.extend({addNodeView:()=>Gn(tb)}).configure({allowBase64:!0,HTMLAttributes:{class:"document-image"}}),Fg.configure({table:{resizable:!0,View:$c}}),Wh,Wg,Kg.configure({nested:!0}),qg.configure({multicolor:!0}),Gg.configure({types:["heading","paragraph"]}),F1,W1,K1,U1,j1]}var X1=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({...rn(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:Bc,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")}}]}}),$c=class extends Lc{constructor(...t){super(...t),this.syncMetadata()}syncMetadata(){let t=rn(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=pe(Fe(),1),ib=new WeakSet,sb=ur(ze);function Y1({children:e,className:t,onDismiss:n}){return(0,v.jsx)("div",{className:t,onMouseDown:r=>{r.target===r.currentTarget&&n()},children:e})}function Bt({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 Q1(e){return/^https?:\/\//i.test(e)||/^data:image\/(png|jpe?g|gif|webp|avif);base64,/i.test(e)}function lb(e){return/^(https?:\/\/|mailto:|tel:|#)/i.test(e)||!!lr(e)}function Hc(e){return e.startsWith("page-tail-")}function _c(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 Z1({content:e,onChange:t,readOnly:n=!1,minimal:r=!0,onEditorReady:o,onInsertNative:i,onDetachBlock:s,additionalExtensions:l,trailingNode:a=!0,retentionKey:u}){let c=Re(ze),d=Re(Vu),f=Re(Go),p=(0,P.useRef)(t),h=(0,P.useId)();p.current=t;let g=(0,P.useRef)(null),m=(0,P.useRef)(null),b=(0,P.useRef)(null),k=(0,P.useRef)(null),C=(0,P.useRef)(null),S=(0,P.useRef)([]),M=(0,P.useRef)(()=>{}),T=(0,P.useRef)(0),E=(0,P.useRef)(null),[O,X]=(0,P.useState)(null),{useCatalog:he,registerComponent:Ne,assistant:$e,pageLinks:xe}=(0,P.useContext)(Uo),_e=(0,P.useRef)(xe);_e.current=xe;let Me=he(!!O),[N,_]=(0,P.useState)(!1),ee=(0,P.useRef)(0);(0,P.useEffect)(()=>()=>{ee.current++},[]);let[ue,Se]=(0,P.useState)(0),[Y,Ve]=(0,P.useState)(null),[Ze,me]=(0,P.useState)(!1),je=(0,P.useRef)(null),zr=(0,P.useRef)(Ze);zr.current=Ze;let wn=(0,P.useRef)(0),Hr=(0,P.useRef)(0);(0,P.useEffect)(()=>()=>cancelAnimationFrame(wn.current),[]);let Ct=(0,P.useCallback)(()=>{je.current!==null&&(clearTimeout(je.current),je.current=null)},[]),Do=(0,P.useCallback)(()=>{je.current===null&&(je.current=setTimeout(()=>{je.current=null;let y=g.current?.querySelector(".block-handle");zr.current||E.current!==null||y?.contains(document.activeElement)||Ve(null)},450))},[]);(0,P.useEffect)(()=>Ct,[Ct]);let[kn,tn]=(0,P.useState)(!1),[xt,at]=(0,P.useState)(!1),[U,Le]=(0,P.useState)(null),[St,J]=(0,P.useState)(null),[_r,Ce]=(0,P.useState)(""),[ge,yt]=(0,P.useState)(""),[qe,et]=(0,P.useState)(null);(0,P.useEffect)(()=>{!qe&&St&&(Le(null),J(null))},[!!qe,St]);let Et=(0,P.useRef)(null),D=(0,P.useRef)(!1),[,z]=(0,P.useState)(0),G=(0,P.useRef)(null);k.current=O,T.current=ue;let be=(0,P.useMemo)(()=>[...ob({placeholder:({empty:y})=>sb(y&&!a?"placeholderPage":"placeholder"),trailingNode:a}),...l??[]],[l,a]);(0,P.useLayoutEffect)(()=>{if(!Ze)return;let y=g.current,x=y?.querySelector(".block-menu"),A=y?.querySelector(".block-handle");if(!x||!A)return;let $=()=>{let F=A.getBoundingClientRect(),ne=x.getBoundingClientRect();Object.assign(x.style,{position:"fixed",left:`${Math.max(12,Math.min(F.right,window.innerWidth-ne.width-12))}px`,top:`${Math.max(12,Math.min(F.top,window.innerHeight-ne.height-12))}px`})};$();let I=new ResizeObserver($);return I.observe(x),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{I.disconnect(),window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[Ze,Y?.pos]);let w=sh({retentionKey:u,extensions:be,content:e,editable:!n,immediatelyRender:!1,shouldRerenderOnTransaction:!1,editorProps:{attributes:{class:"document-content","aria-label":sb("documentContent"),spellcheck:"false"},handleKeyDown:(y,x)=>{if(x.isComposing)return!1;if(x.key==="Escape"&&!k.current&&!y.state.selection.empty)return Et.current=`${y.state.selection.from}:${y.state.selection.to}`,et(null),x.preventDefault(),!0;if(!k.current)return!1;if(x.key==="Escape")return Vr(),!0;if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();let A=S.current.length;return Se($=>A?($+(x.key==="ArrowDown"?1:-1)+A)%A:0),!0}return x.key==="Enter"&&S.current.length?(M.current(T.current),!0):!1},handleClick:(y,x,A)=>{let $=A.target.closest?.("a[href]");if(!$||!n&&!A.metaKey&&!A.ctrlKey||!n&&!$.isContentEditable)return!1;let I=$.getAttribute("href")??"";if(!lb(I))return!0;let F=Nu(I);return F&&Ru($,F,n?A:void 0)||(I.startsWith("#")?document.getElementById(I.slice(1))?.scrollIntoView({behavior:"smooth",block:"start"}):F||window.open(I,"_blank","noopener,noreferrer")),!0},handlePaste:(y,x)=>{let A=x.clipboardData?.getData("text/plain").trim()??"";if(lr(A)){x.preventDefault();let{empty:F,from:ne,to:ke}=y.state.selection,Z=y.state.schema.marks.link.create({href:A});return y.dispatch(F?y.state.tr.insert(ne,y.state.schema.text(jc(A),[Z])):y.state.tr.addMark(ne,ke,Z)),!0}let I=[...x.clipboardData?.files??[]].filter(F=>F.type.startsWith("image/"));return I.length?(x.preventDefault(),zs(I),!0):!1}},onUpdate:({editor:y,transaction:x})=>p.current(Aa(y.state.doc),{separateHistory:!!x.getMeta(Yn),historyGroup:x.getMeta(zu)})});(0,P.useEffect)(()=>w?Hu(w):void 0,[w]),(0,P.useEffect)(()=>{w&&o?.(w)},[w,o]),(0,P.useEffect)(()=>{w&&w.isEditable===n&&(w.setEditable(!n,!1),w.view.dispatch(w.state.tr.setMeta("editableChanged",!0))),z(y=>y+1),n&&(X(null),Ve(null),me(!1),tn(!1),at(!1),Le(null),et(null))},[w,n]);let ft=(0,P.useRef)(e);ft.current=e;let or=(0,P.useRef)(!1);(0,P.useEffect)(()=>{if(!w)return;let y=()=>{or.current=!0},x=()=>{or.current=!1};return w.on("beforeTransaction",y),w.on("transaction",x),()=>{w.off("beforeTransaction",y),w.off("transaction",x)}},[w]),(0,P.useLayoutEffect)(()=>{if(!w)return;let y,x=()=>{if(w.isDestroyed)return;if(w.view.composing||or.current){y=setTimeout(x,or.current?0:25);return}let $=dh(w.state,ft.current);if(!$)return;let I=w.state.selection instanceof j&&w.state.selection.node.type.name==="widget"?w.state.selection.node.attrs.id:null,F=w.state.selection instanceof se?w.state.selection:null;if(w.view.dispatch($),F){let ne=jh(w.state.doc,F);ne&&w.view.dispatch(w.state.tr.setSelection(ne))}if(I){let ne;if(w.state.doc.descendants((ke,Z)=>{ke.type.name==="widget"&&ke.attrs.id===I&&(ne=Z)}),ne!==void 0)w.commands.setNodeSelection(ne);else{let ke=Dr(w.state);ke&&w.view.dispatch(ke)}}},A=()=>{y=setTimeout(x,25)};return w.view.composing?w.view.dom.addEventListener("compositionend",A):x(),()=>{y&&clearTimeout(y),w.view.dom.removeEventListener("compositionend",A)}},[e,w]),(0,P.useEffect)(()=>{if(!U)return;let y=requestAnimationFrame(()=>document.querySelector(".editor-modal input, .editor-modal textarea")?.focus()),x=A=>{if(A.key==="Escape"&&(A.preventDefault(),A.stopPropagation(),Le(null),w?.commands.focus()),A.key!=="Tab")return;let $=Array.from(document.querySelectorAll(".editor-modal button:not(:disabled), .editor-modal input:not(:disabled), .editor-modal textarea:not(:disabled)")),I=$[0],F=$[$.length-1];A.shiftKey&&document.activeElement===I?(A.preventDefault(),F?.focus()):!A.shiftKey&&document.activeElement===F&&(A.preventDefault(),I?.focus())};return document.addEventListener("keydown",x,!0),()=>{cancelAnimationFrame(y),document.removeEventListener("keydown",x,!0)}},[!!U,w]),(0,P.useEffect)(()=>{if(!w||n)return;let y=()=>{let A=Dr(w.state);A&&w.view.dispatch(A)};!ib.has(w)&&!ih(w)&&(ib.add(w),w.isInitialized?y():w.on("create",y));let x=A=>{if(A.button!==0||!(A.target instanceof Element))return;let $=A.target,I=$.closest(".document-widget");if(I&&w.view.dom.contains(I)||!I&&$.closest('button, input, textarea, select, a, summary, [role="button"], [role="dialog"], .block-handle, .editor-toolbar, .editor-bubble, .editor-small-menu, .editor-modal'))return;let F=Dr(w.state);if(!F)return;let ne=document.activeElement;ne instanceof HTMLElement&&w.view.dom.contains(ne)&&ne.blur(),w.view.dispatch(F),w.view.dom.contains($)&&!$.closest("[data-block-id]")&&A.preventDefault()};return document.addEventListener("pointerdown",x,!0),()=>{w.off("create",y),document.removeEventListener("pointerdown",x,!0)}},[w,n]),(0,P.useEffect)(()=>{if(!O?.manual)return;let y=requestAnimationFrame(()=>b.current?.focus());return()=>cancelAnimationFrame(y)},[O?.manual]),(0,P.useEffect)(()=>{if(!kn&&!xt&&!Ze)return;let y=x=>{x.key==="Escape"&&(x.preventDefault(),tn(!1),at(!1),me(!1),w?.commands.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[kn,xt,Ze,w]),(0,P.useEffect)(()=>{if(!ge)return;let y=window.setTimeout(()=>yt(""),4500);return()=>window.clearTimeout(y)},[ge]),(0,P.useEffect)(()=>{if(!w)return;let y=()=>{if((!r||!w.state.selection.empty)&&z(Sn=>Sn+1),!w.isEditable)return;let{selection:Z}=w.state,{$from:Be,from:Cn,to:nn,empty:xn}=Z;if((xn||Et.current&&Et.current!==`${Cn}:${nn}`)&&(Et.current=null),!k.current?.manual){let Sn=Be.parent.isTextblock?Be.parent.textBetween(0,Be.parentOffset,`
155
155
  `):"",En=xn&&Sn.match(/^\/([^\n/]*)$/);if(En){let Jc=Cn-En[0].length;C.current!==`${Jc}:${nn}:${En[1]}`&&(C.current=null,X({from:Jc,to:nn,query:En[1],..._c(w,Cn)}))}else X(null),C.current=null}if(!xn&&Et.current!==`${Cn}:${nn}`&&(w.isFocused||D.current)&&!w.isActive("codeBlock")&&!w.isActive("widget")&&!w.isActive("pageModule")){let Sn=w.view.coordsAtPos(Cn),En=w.view.coordsAtPos(nn);et({left:(Sn.left+En.right)/2,top:Sn.top,bottom:Math.max(Sn.bottom,En.bottom)})}else et(null)},x=Z=>Z instanceof Element&&Z.closest(".editor-bubble")?.id===h,A=Z=>{x(Z.relatedTarget)&&(D.current=!0)},$=()=>{D.current=!1,et(null)},I=Z=>{D.current=x(Z.target),!D.current&&(!(Z.target instanceof Node)||!w.view.dom.contains(Z.target))&&$()},F=({event:Z})=>{!D.current&&!x(Z.relatedTarget)&&$()},ne=Z=>{x(Z.target)||$()},ke=Z=>{!(Z.target instanceof Element)||!Z.target.contains(w.view.dom)||(et(null),X(null),me(!1),Ve(null))};return w.on("transaction",y),w.on("focus",y),w.on("blur",F),w.view.dom.addEventListener("blur",A,!0),document.addEventListener("pointerdown",I,!0),document.addEventListener("focusin",I,!0),w.view.dom.addEventListener("contextmenu",$),window.addEventListener("scroll",ne,!0),window.addEventListener("resize",y),window.addEventListener("showai:viewport-change",ke),()=>{w.off("transaction",y),w.off("focus",y),w.off("blur",F),w.view.dom.removeEventListener("blur",A,!0),document.removeEventListener("pointerdown",I,!0),document.removeEventListener("focusin",I,!0),w.view.dom.removeEventListener("contextmenu",$),window.removeEventListener("scroll",ne,!0),window.removeEventListener("resize",y),window.removeEventListener("showai:viewport-change",ke)}},[w,h,r]),(0,P.useEffect)(()=>Se(0),[O?.query]),(0,P.useEffect)(()=>{document.querySelector(".slash-menu .slash-item.is-selected")?.scrollIntoView({block:"nearest"})},[ue]);function Vr(){let y=k.current;y&&!y.manual&&(C.current=`${y.from}:${y.to}:${y.query}`),k.current=null,X(null)}function jc(y){let x=lr(y),A=_e.current;return x&&A?.projectId===x.projectId&&A.pages.find(I=>I.id===x.pageId)?.title||y}function Fc(y){w&&(G.current&&w.commands.setTextSelection(G.current),y?w.state.selection.empty&&!w.isActive("link")?w.chain().focus().insertContent({type:"text",text:jc(y),marks:[{type:"link",attrs:{href:y}}]}).run():w.chain().focus().extendMarkRange("link").setLink({href:y}).run():w.chain().focus().extendMarkRange("link").unsetLink().run(),Le(null))}let jr=U?.type==="link"&&xe&&!/^[a-z][a-z0-9+.-]*:|^#/i.test(U.value.trim())?U.value.trim().toLocaleLowerCase():null,Mt=(0,P.useMemo)(()=>jr===null||!xe?[]:xe.pages.filter(y=>y.id!==xe.pageId&&(y.title||c("dialog.untitledPage")).toLocaleLowerCase().includes(jr)).slice(0,6).map(y=>({...y,href:Tu({projectId:xe.projectId,pageId:y.id})})),[jr,xe,c]),[Oo,Bs]=(0,P.useState)(-1);(0,P.useEffect)(()=>Bs(jr?0:-1),[jr]);let ir=(0,P.useCallback)(y=>{if(!w)return;let{selection:x}=w.state;G.current={from:x.from,to:x.to};let A=y==="note"&&x instanceof j&&["mathInline","mathBlock"].includes(x.node.type.name)?x.node:null,$=A?Ou(String(A.attrs.latex??"")):null;Le({type:y,value:y==="link"?w.getAttributes("link").href??"":y==="note"?A?$?.note??"":w.getAttributes("annotation").note??"":"",alt:"",hadNote:y==="note"&&(A?!!$:w.isActive("annotation")),...A?{math:{pos:x.from,body:$?.body??String(A.attrs.latex??"")}}:{}}),Ce(""),at(!1);let I=y!=="image"?document.getElementById(h):null;J(I),I||et(null)},[w,h]);function Wc(y,x){if(!w)return!1;if(x.length>1e3)return Ce(f("dialog.noteTooLong",{max:1e3})),!1;if(y.math){let{pos:$,body:I}=y.math,F=w.state.doc.nodeAt($);return!F||!["mathInline","mathBlock"].includes(F.type.name)?(Ce(f("dialog.noteTargetMissing")),!1):(w.chain().focus().command(({tr:ne})=>(ne.setNodeMarkup($,void 0,{...F.attrs,latex:x?Du(I,x):I}),!0)).run(),!0)}if(G.current&&w.commands.setTextSelection(G.current),w.state.selection.empty&&!w.isActive("annotation"))return Ce(f("dialog.noteNeedsSelection")),!1;let A=w.chain().focus();return w.state.selection.empty&&A.extendMarkRange("annotation"),x?A.setMark("annotation",{note:x}):A.unsetMark("annotation"),A.run(),!0}async function zs(y,x=!1){if(!w||!w.isEditable)return;x&&G.current&&w.commands.setTextSelection(G.current);let A=w.state.selection.getBookmark(),$=({transaction:I})=>{A=A.map(I.mapping)};w.on("transaction",$);for(let I of y){if(!/^image\/(png|jpeg|gif|webp|avif)$/.test(I.type)){yt(c("notice.imageTypes"));continue}if(I.size>Qs.resourceBytes){yt(c("notice.imageTooLarge",{name:I.name,size:Zs(I.size),limit:Zs(Qs.resourceBytes)}));continue}let F;try{F=await new Promise((ke,Z)=>{let Be=new FileReader;Be.onload=()=>ke(String(Be.result)),Be.onerror=()=>Z(Be.error),Be.onabort=()=>Z(new Error(c("notice.readCancelled"))),Be.readAsDataURL(I)})}catch{yt(c("notice.imageUnreadable",{name:I.name}));continue}if(w.isDestroyed||!w.isEditable)break;let ne=A.resolve(w.state.doc);w.view.dispatch(w.state.tr.setSelection(ne)),w.chain().focus().setImage({src:F,alt:I.name}).run(),A=w.state.selection.getBookmark()}w.off("transaction",$),Le(null)}let Hs=(0,P.useMemo)(()=>[{id:"text",title:c("block.text"),keywords:`text paragraph ${c("block.textKeywords")}`,icon:(0,v.jsx)(zo,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().setParagraph().run()}},...[1,2,3,4,5,6].map(y=>({id:`heading-${y}`,title:c("block.heading",{level:y}),keywords:`heading h${y} ${c("block.headingKeywords")}`,icon:y===1?(0,v.jsx)(uu,{size:20}):y===2?(0,v.jsx)(du,{size:20}):(0,v.jsx)(fu,{size:20}),group:c("group.basic"),run:x=>{x.chain().focus().setHeading({level:y}).run()}})),{id:"bullet",title:c("block.bullet"),keywords:`bullet list ${c("block.bulletKeywords")}`,icon:(0,v.jsx)(Ws,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleBulletList().run()}},{id:"ordered",title:c("block.ordered"),keywords:`ordered numbered list ${c("block.orderedKeywords")}`,icon:(0,v.jsx)(Fs,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleOrderedList().run()}},{id:"todo",title:c("block.todo"),keywords:`todo task check ${c("block.todoKeywords")}`,icon:(0,v.jsx)(qs,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleTaskList().run()}},{id:"quote",title:c("block.quote"),keywords:`blockquote quote ${c("block.quoteKeywords")}`,icon:(0,v.jsx)(Ks,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleBlockquote().run()}},{id:"callout",title:c("block.callout"),keywords:`callout note ${c("block.calloutKeywords")}`,icon:(0,v.jsx)(mu,{size:20}),group:c("group.basic"),run:y=>{y.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:c("block.toggle"),keywords:`toggle details ${c("block.toggleKeywords")}`,icon:(0,v.jsx)(Po,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().insertContent({type:"toggle",attrs:{title:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A",open:!0},content:[{type:"paragraph"}]}).run()}},{id:"stepper",title:c("block.stepper"),keywords:`stepper steps ${c("block.stepperKeywords")}`,icon:(0,v.jsx)(Yc,{size:20}),group:c("group.basic"),run:y=>{let x={type:"step",content:[{type:"paragraph"}]},{from:A}=y.state.selection;y.chain().focus().insertContent({type:"stepper",content:[x,x]}).command(({tr:$})=>{let I=-1;return $.doc.nodesBetween(Math.max(0,A-1),$.doc.content.size,(F,ne)=>(I<0&&F.type.name==="stepper"&&(I=ne),I<0)),I>=0&&$.setSelection(L.create($.doc,I+3)),!0}).run()}},{id:"divider",title:c("block.divider"),keywords:`divider hr ${c("block.dividerKeywords")}`,icon:(0,v.jsx)(gu,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().setHorizontalRule().run()}},{id:"image",title:c("block.image"),keywords:`image photo ${c("block.imageKeywords")}`,icon:(0,v.jsx)(Io,{size:20}),group:c("group.rich"),run:()=>ir("image")},{id:"code",title:c("block.code"),keywords:`code snippet ${c("block.codeKeywords")}`,icon:(0,v.jsx)(tu,{size:20}),group:c("group.rich"),run:y=>{y.chain().focus().toggleCodeBlock().run()}},{id:"table",title:c("block.table"),keywords:`table ${c("block.tableKeywords")}`,icon:(0,v.jsx)(Gs,{size:20}),group:c("group.rich"),run:y=>{y.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},...Me.items.filter(y=>("kind"in y||y.role!=="page-outline")&&!("kind"in y&&el[y.kind])&&(!("kind"in y&&y.insertion)||!!i)).map(y=>({id:"catalog:"+("kind"in y?y.kind:`${y.id}@${y.version}#${y.integrity}`),title:Me.displayName(y),keywords:`${"kind"in y?y.kind:y.id} ${y.name} ${y.description} ${Me.displayDescription(y)}`,icon:(0,v.jsx)(bu,{size:20}),group:c("group.components"),component:y,run:()=>{}}))],[ir,i,Me.items,Me.displayName,Me.displayDescription,c]),vn=Hs.filter(y=>`${y.title} ${y.keywords}`.toLowerCase().includes(O?.query.toLowerCase()??""));S.current=vn;let _s=async y=>{let x=k.current,A=S.current[y];if(!(!w||!x||!A||N)){if(A.component){let $=w.state.doc,I=++ee.current;_(!0);try{let F=await Me.resolve(A.component);if(I!==ee.current||w.isDestroyed||k.current!==x||!w.state.doc.eq($))return;if(X(null),k.current=null,F.component&&Ne(F.component),F.native&&i){let ne=w.state.tr.delete(x.from,x.to);i(F.kind,F.data,nd(ne.doc,x.from))}else w.chain().focus().deleteRange({from:x.from,to:x.to}).insertContent({...el[F.kind]?Pu(F.kind,F.data):{type:"widget",attrs:{kind:F.kind,data:F.data}}}).run()}catch(F){yt(F.message)}finally{I===ee.current&&_(!1)}return}X(null),k.current=null,x.from!==x.to?w.chain().focus().deleteRange({from:x.from,to:x.to}).run():w.commands.focus(),A.run(w)}};M.current=_s;let Vs=()=>{if(!w)return;C.current=null;let{from:y,to:x}=w.state.selection;X({from:y,to:x,query:"",manual:!0,..._c(w,y)}),Se(0),at(!1)},ab=()=>{if(!w||!Y)return;let y=Y.pos+Y.size;w.chain().focus().insertContentAt(y,{type:"paragraph"}).setTextSelection(y+1).run(),X({from:y+1,to:y+1,query:"",manual:!0,..._c(w,y+1)}),me(!1)};function Kc(y,x){if(!w)return;let A=[];w.state.doc.forEach((Z,Be)=>A.push({pos:Be,size:Z.nodeSize}));let $=A.findIndex(Z=>Z.pos===y),I=A[$+x],F=w.state.doc.nodeAt(y);if(!I||!F)return;let ne=x===-1?I.pos:I.pos+I.size-F.nodeSize,ke=w.state.tr.delete(y,y+F.nodeSize).insert(ne,F);ke.setSelection(Q.near(ke.doc.resolve(ne+1))),w.view.dispatch(ke),w.view.focus(),me(!1),Ve(null)}function cb(y){if(!w||!w.isEditable)return;let x=E.current;if(x!==null){y.preventDefault(),y.stopPropagation(),E.current=null,Ve(null);let $=w.state.doc.nodeAt(x);if(!$)return;let I=w.state.doc.content.size,F=!1;if(w.state.doc.forEach((ne,ke)=>{let Z=w.view.nodeDOM(ke);if(!(Z instanceof HTMLElement)||F)return;let Be=Z.getBoundingClientRect();y.clientY<Be.top+Be.height/2&&(I=ke,F=!0)}),I!==x&&I!==x+$.nodeSize){let ne=I>x?I-$.nodeSize:I,ke=w.state.tr.delete(x,x+$.nodeSize).insert(ne,$);ke.setSelection(Q.near(ke.doc.resolve(ne+1))),w.view.dispatch(ke)}return}let A=[...y.dataTransfer.files].filter($=>$.type.startsWith("image/"));if(A.length){y.preventDefault(),y.stopPropagation();let $=w.view.posAtCoords({left:y.clientX,top:y.clientY});$&&w.commands.setTextSelection($.pos),zs(A)}}if(!w)return(0,v.jsx)("div",{className:"editor-loading","aria-label":c("openingDocument")});let Uc=Y&&Ze?w.state.doc.nodeAt(Y.pos):null,qc=Uc?.type.name==="widget"&&!td(String(Uc.attrs.kind??"")),ub=w.isActive("heading")?c("block.heading",{level:w.getAttributes("heading").level}):c("block.text"),db=qe&&$e?Ti(w.state.doc,w.state.selection.from,w.state.selection.to).length:0,fb=St?$i:Y1,Gc=(!r||qe)&&(0,v.jsx)(Xh,{editor:w,onLink:()=>ir("link"),onNote:()=>ir("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":c("format.toolbar"),children:[(0,v.jsxs)("div",{className:"toolbar-style",children:[(0,v.jsxs)("button",{className:"text-style-button",onMouseDown:y=>y.preventDefault(),onClick:()=>{tn(!kn),at(!1)},"aria-expanded":kn,children:[ub,(0,v.jsx)(sr,{size:13})]}),kn&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>tn(!1)}),(0,v.jsx)("div",{className:"editor-small-menu style-menu",children:Hs.slice(0,7).map(y=>(0,v.jsxs)("button",{onMouseDown:x=>x.preventDefault(),onClick:()=>{y.run(w),tn(!1)},children:[y.icon,(0,v.jsx)("span",{children:y.title})]},y.id))})]})]}),(0,v.jsx)("span",{className:"toolbar-divider"}),Gc,(0,v.jsx)("span",{className:"toolbar-divider"}),(0,v.jsx)(Bt,{label:c("block.bullet"),active:w.isActive("bulletList"),onClick:()=>w.chain().focus().toggleBulletList().run(),children:(0,v.jsx)(Ws,{size:17})}),(0,v.jsx)(Bt,{label:c("block.todo"),active:w.isActive("taskList"),onClick:()=>w.chain().focus().toggleTaskList().run(),children:(0,v.jsx)(qs,{size:16})}),(0,v.jsxs)("div",{className:"toolbar-insert",children:[(0,v.jsx)(Bt,{label:c("format.more"),active:xt,onClick:()=>{at(!xt),tn(!1)},children:(0,v.jsx)(Ht,{size:17})}),xt&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>at(!1)}),(0,v.jsxs)("div",{className:"editor-small-menu insert-menu",children:[(0,v.jsxs)("button",{onClick:Vs,children:[(0,v.jsx)(Ht,{size:16}),c("insert.content"),(0,v.jsx)("span",{className:"menu-key",children:"/"})]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().toggleOrderedList().run(),at(!1)},children:[(0,v.jsx)(Fs,{size:16}),c("block.ordered")]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().toggleBlockquote().run(),at(!1)},children:[(0,v.jsx)(Ks,{size:16}),c("block.quote")]}),(0,v.jsxs)("button",{onClick:()=>ir("image"),children:[(0,v.jsx)(Io,{size:16}),c("insert.image")]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),at(!1)},children:[(0,v.jsx)(Gs,{size:16}),c("insert.table")]}),(0,v.jsx)("div",{className:"menu-rule"}),(0,v.jsxs)("div",{className:"align-tools",children:[(0,v.jsx)(Bt,{label:c("format.alignLeft"),active:w.isActive({textAlign:"left"}),onClick:()=>w.chain().focus().setTextAlign("left").run(),children:(0,v.jsx)(Tn,{size:17})}),(0,v.jsx)(Bt,{label:c("format.alignCenter"),active:w.isActive({textAlign:"center"}),onClick:()=>w.chain().focus().setTextAlign("center").run(),children:(0,v.jsx)(Mn,{size:17})}),(0,v.jsx)(Bt,{label:c("format.alignRight"),active:w.isActive({textAlign:"right"}),onClick:()=>w.chain().focus().setTextAlign("right").run(),children:(0,v.jsx)(An,{size:17})})]})]})]})]}),(0,v.jsx)("div",{className:"toolbar-spacer"}),(0,v.jsx)(Bt,{label:c("format.undo"),disabled:!w.can().undo(),onClick:()=>w.chain().focus().undo().run(),children:(0,v.jsx)(Mu,{size:16})}),(0,v.jsx)(Bt,{label:c("format.redo"),disabled:!w.can().redo(),onClick:()=>w.chain().focus().redo().run(),children:(0,v.jsx)(yu,{size:16})})]}),(0,v.jsxs)("div",{className:"editor-canvas",ref:g,onKeyDown:y=>{(y.metaKey||y.ctrlKey)&&y.shiftKey&&y.key.toLowerCase()==="k"&&!n&&(y.preventDefault(),y.stopPropagation(),ir("link"))},onMouseEnter:Ct,onMouseMove:y=>{if(n||Ze||E.current!==null)return;if(y.target.closest(".block-handle")){Ct();return}let x=g.current;x&&y.target.closest(".document-editor")===x.closest(".document-editor")&&(Hr.current=y.clientY,!wn.current&&(wn.current=requestAnimationFrame(()=>{wn.current=0;let A=g.current;if(!A||E.current!==null||w.isDestroyed)return;let $=Hr.current,I=A.getBoundingClientRect(),F=I.width/A.offsetWidth||1,ne=null;w.state.doc.forEach((Z,Be,Cn)=>{let nn=w.view.nodeDOM(Be);if(!(nn instanceof HTMLElement))return;let xn=nn.getBoundingClientRect();$>=xn.top-3&&$<=xn.bottom+3&&(ne={pos:Be,size:Z.nodeSize,index:Cn,top:(xn.top-I.top)/F})});let ke=ne;ke?(Ct(),Ve(Z=>Z&&Z.pos===ke.pos&&Z.size===ke.size&&Z.index===ke.index&&Math.abs(Z.top-ke.top)<.5?Z:ke)):Do()})))},onMouseLeave:Do,onDragOver:y=>{(E.current!==null||[...y.dataTransfer.types].includes("Files"))&&y.preventDefault()},onDropCapture:cb,children:[(0,v.jsx)(Ai,{editor:w}),!n&&(0,v.jsx)(Jh,{editor:w}),!n&&Y&&(0,v.jsxs)("div",{className:"block-handle",style:{top:Y.top},onMouseEnter:Ct,onFocus:Ct,children:[(0,v.jsx)("button",{"aria-label":c("insert.addBelow"),title:c("insert.addContent"),onMouseDown:y=>y.preventDefault(),onClick:ab,children:(0,v.jsx)(Ht,{size:15})}),(0,v.jsx)("button",{"aria-label":c("block.handle"),title:c("block.handleTitle"),draggable:!0,onDragStart:y=>{Ct(),E.current=Y.pos,y.dataTransfer.effectAllowed="move",y.dataTransfer.setData("application/x-showai-block",String(Y.pos));let x=w.view.nodeDOM(Y.pos);x instanceof HTMLElement&&y.dataTransfer.setDragImage(x,0,0),me(!1)},onDragEnd:()=>{E.current=null},onClick:()=>me(!Ze),children:(0,v.jsx)(cu,{size:15})}),Ze&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>me(!1)}),(0,v.jsxs)("div",{className:"editor-small-menu block-menu",children:[r&&["paragraph","heading"].includes(w.state.doc.nodeAt(Y.pos)?.type.name??"")&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"align-tools",role:"group","aria-label":c("block.style"),children:Hs.slice(0,7).map((y,x)=>(0,v.jsx)(Bt,{label:y.title,active:x===0?w.state.doc.nodeAt(Y.pos)?.type.name==="paragraph":w.state.doc.nodeAt(Y.pos)?.attrs.level===x,onClick:()=>{w.chain().focus().setTextSelection(Y.pos+1).run(),y.run(w),me(!1)},children:y.icon},y.id))}),(0,v.jsx)("div",{className:"align-tools",children:[["left",c("format.alignLeft"),(0,v.jsx)(Tn,{size:16},"left")],["center",c("format.alignCenter"),(0,v.jsx)(Mn,{size:16},"center")],["right",c("format.alignRight"),(0,v.jsx)(An,{size:16},"right")]].map(([y,x,A])=>(0,v.jsx)(Bt,{label:x,active:w.state.doc.nodeAt(Y.pos)?.attrs.textAlign===y,onClick:()=>{w.chain().focus().setTextSelection(Y.pos+1).setTextAlign(y).run(),me(!1)},children:A},y))}),(0,v.jsx)("div",{className:"menu-rule"})]}),(0,v.jsx)(ed,{editor:w,position:Y.pos,onDone:()=>me(!1)}),s&&(0,v.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(Y.pos);y&&s(y.toJSON()),me(!1),Ve(null)},children:[(0,v.jsx)(su,{size:15}),c("block.detach")]}),(0,v.jsxs)("button",{disabled:Y.index===0,onClick:()=>Kc(Y.pos,-1),children:[(0,v.jsx)(Qc,{size:15}),c("block.moveUp")]}),(0,v.jsxs)("button",{disabled:Y.index===w.state.doc.childCount-1,onClick:()=>Kc(Y.pos,1),children:[(0,v.jsx)(Xc,{size:15}),c("block.moveDown")]}),(0,v.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(Y.pos);y&&w.chain().focus().insertContentAt(Y.pos+y.nodeSize,y.toJSON()).run(),me(!1)},children:[(0,v.jsx)(ru,{size:15}),c("block.duplicate")]}),qc&&(0,v.jsx)("p",{className:"block-menu-note",children:c("block.noManualEditing")}),$e&&(0,v.jsxs)("button",{onClick:y=>{let x=w.state.doc.nodeAt(Y.pos)?.attrs.id,A=y.currentTarget.closest(".block-handle").getBoundingClientRect();me(!1),typeof x=="string"&&!Hc(x)&&$e.open({kind:"blocks",blockIds:[x],anchor:{left:A.right+160,top:A.top,bottom:A.bottom}})},children:[(0,v.jsx)(Us,{size:15}),qc?c("assistant.editComponent"):d("askAgent")]}),$e&&(0,v.jsxs)("button",{onClick:y=>{let x=w.state.doc.nodeAt(Y.pos)?.attrs.id,A=y.currentTarget.closest(".block-handle").getBoundingClientRect();me(!1),typeof x=="string"&&!Hc(x)&&$e.reference({kind:"blocks",blockIds:[x],anchor:{left:A.right,top:A.top,bottom:A.bottom}})},children:[(0,v.jsx)(js,{size:15}),d("copyReference")]}),xe&&(0,v.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(Y.pos)?.attrs.id;me(!1),typeof y=="string"&&!Hc(y)&&xe.copyLink([y])},children:[(0,v.jsx)(Fr,{size:15}),d("copyLink")]}),(0,v.jsx)("div",{className:"menu-rule"}),(0,v.jsxs)("button",{className:"danger",onClick:()=>{w.chain().focus().deleteRange({from:Y.pos,to:Y.pos+Y.size}).run(),me(!1),Ve(null)},children:[(0,v.jsx)(Bo,{size:15}),d("delete")]})]})]})]})]}),!n&&!r&&(0,v.jsxs)("button",{className:"document-add-block",onClick:()=>{w.chain().focus("end").run(),(w.state.selection.$from.parent.type.name!=="paragraph"||w.state.selection.$from.parent.content.size)&&w.chain().insertContentAt(w.state.doc.content.size,{type:"paragraph"}).focus("end").run(),Vs()},children:[(0,v.jsx)(Ht,{size:15}),(0,v.jsx)("span",{children:c("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:y=>{let x=y.target.files?.[0];x&&zs([x],!0),y.target.value=""}}),ge&&(0,v.jsxs)("div",{className:"editor-notice",role:"status",children:[ge,(0,v.jsx)("button",{"aria-label":c("dismissNotice"),onClick:()=>yt(""),children:(0,v.jsx)(Wr,{size:14})})]}),qe&&!n&&(0,v.jsxs)(Xu,{id:h,className:"rich-text-selection-toolbar",anchor:qe,viewportTop:Math.max(0,...Array.from(g.current?.closest(".studio")?.querySelectorAll(".studio-window-topbar, .studio-topbar")??[],y=>y.getBoundingClientRect().bottom))+8,onEscape:()=>{D.current=!1,Et.current=`${w.state.selection.from}:${w.state.selection.to}`,w.state.selection instanceof se&&w.view.dispatch(w.state.tr.setSelection(L.near(w.state.selection.$from))),et(null),w.view.focus()},children:[Gc,(0,v.jsx)(Bi,{editor:w}),$e&&(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":d("askAgent"),title:d("askAgent"),onClick:()=>{let{from:y,to:x}=w.state.selection,A=qe;D.current=!1,et(null),$e.open({kind:"text",blockIds:Ti(w.state.doc,y,x),text:w.state.doc.textBetween(y,x,`
156
156
  `),anchor:A})},children:[(0,v.jsx)(Us,{size:15}),(0,v.jsx)("span",{children:d("askAgent")})]}),(0,v.jsx)("button",{type:"button",className:"editor-tool editor-bubble-reference","aria-label":d("copyReference"),title:c("assistant.referenceSelection",{count:db}),onClick:()=>{let{from:y,to:x}=w.state.selection,A=qe;D.current=!1,et(null),$e.reference({kind:"text",blockIds:Ti(w.state.doc,y,x),text:w.state.doc.textBetween(y,x,`
157
157
  `),anchor:A})},children:(0,v.jsx)(js,{size:16})})]}),(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":c("insert.fromSelection"),title:c("insert.fromSelectionTitle"),onMouseDown:y=>y.preventDefault(),onClick:()=>{let y=w.state.selection.$to.end();D.current=!1,et(null),w.commands.setTextSelection(y),Vs(),setTimeout(()=>b.current?.focus(),0)},children:[(0,v.jsx)(Ht,{size:15}),(0,v.jsx)("span",{children:c("insert.fromSelection")})]})]})]}),O&&!n&&(0,Vc.createPortal)((0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"slash-dismiss",onClick:()=>{Vr(),w.commands.focus()}}),(0,v.jsxs)("div",{className:`slash-menu${r?" is-minimal":""}`,role:"dialog","aria-label":c("insert.content"),style:{left:O.left,top:O.top},children:[(0,v.jsxs)("div",{className:"slash-search",children:[O.manual?(0,v.jsx)(Fu,{label:c("insert.search"),placeholder:c("insert.searchPlaceholder"),defaultExpanded:!0,inputRef:b,value:O.query,onChange:y=>X({...O,query:y}),onKeyDown:y=>{y.key==="Escape"&&(Vr(),w.commands.focus()),y.key==="Enter"&&(y.preventDefault(),_s(ue)),(y.key==="ArrowDown"||y.key==="ArrowUp")&&(y.preventDefault(),Se(x=>vn.length?(x+(y.key==="ArrowDown"?1:-1)+vn.length)%vn.length:0))}}):(0,v.jsx)("span",{children:O.query||c("insert.addToDocument")}),(0,v.jsx)("kbd",{children:"esc"})]}),(0,v.jsxs)("div",{className:"slash-items",role:"listbox","aria-label":c("insert.blockTypes"),"aria-busy":N||Me.loading,children:[Me.error&&(0,v.jsx)("p",{role:"alert",className:"slash-empty",children:Me.error}),vn.length===0&&(0,v.jsx)("div",{className:"slash-empty",children:c("insert.noResults")}),vn.map((y,x)=>(0,v.jsxs)("div",{children:[(x===0||vn[x-1].group!==y.group)&&(0,v.jsx)("div",{className:"slash-group",children:y.group}),(0,v.jsxs)("button",{role:"option",disabled:N,"aria-selected":x===ue,className:`slash-item${x===ue?" is-selected":""}`,onMouseEnter:()=>Se(x),onMouseDown:A=>A.preventDefault(),onClick:()=>_s(x),children:[(0,v.jsx)("span",{className:"slash-item-icon",children:y.icon}),(0,v.jsx)("span",{children:(0,v.jsx)("strong",{children:y.title})}),x===ue&&(0,v.jsx)("span",{className:"slash-enter",children:"\u21B5"})]})]},y.id))]})]})]}),document.body),U&&(0,Vc.createPortal)((0,v.jsx)(fb,{className:St?"editor-format-panel":"editor-modal-backdrop",onDismiss:()=>{Le(null),w.commands.focus()},children:(0,v.jsxs)("form",{className:"editor-modal",role:"dialog","aria-modal":St?void 0:!0,"aria-labelledby":"editor-dialog-title",onKeyDown:y=>{y.key==="Escape"&&Le(null)},onSubmit:y=>{y.preventDefault();let x=U.value.trim();if(U.type==="image"&&!Q1(x)){Ce(c("dialog.invalidImageUrl"));return}let A=U.type==="link"?Mt[Oo]?.href??x:x;if(U.type==="link"&&A&&!lb(A)){Ce(c("dialog.invalidLinkUrl"));return}if(U.type==="note"){if(!Wc(U,x))return;Le(null);return}if(U.type==="link"){Fc(A);return}G.current&&w.commands.setTextSelection(G.current),w.chain().focus().setImage({src:x,alt:U.alt}).run(),Le(null)},children:[(0,v.jsxs)("div",{className:"editor-modal-heading",children:[(0,v.jsx)("div",{className:"editor-modal-symbol",children:U.type==="image"?(0,v.jsx)(Io,{size:21}):U.type==="note"?(0,v.jsx)($o,{size:21}):(0,v.jsx)(Fr,{size:21})}),(0,v.jsx)("h3",{id:"editor-dialog-title",children:U.type==="image"?c("insert.image"):U.type==="note"?f(U.hadNote?"dialog.editNote":"dialog.addNote"):c("dialog.addLink")}),(0,v.jsx)("button",{type:"button","aria-label":c("dialog.close"),"data-no-tooltip":!0,onClick:()=>Le(null),children:(0,v.jsx)(Wr,{size:18})})]}),U.type==="image"&&(0,v.jsxs)("button",{className:"image-upload-area",type:"button",onClick:()=>m.current?.click(),children:[(0,v.jsx)(Au,{size:23}),(0,v.jsx)("strong",{children:c("dialog.chooseImage")}),(0,v.jsx)("span",{children:c("dialog.imageFormats")})]}),U.type==="note"&&(0,v.jsxs)("label",{className:"editor-field",children:[(0,v.jsx)("span",{children:U.math?f("dialog.noteFormula"):f("dialog.noteText")}),(0,v.jsx)("textarea",{autoFocus:!0,rows:4,maxLength:1e3,placeholder:f("dialog.notePlaceholder"),value:U.value,onChange:y=>{Le({...U,value:y.target.value}),Ce("")},onKeyDown:y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),y.currentTarget.form?.requestSubmit())}}),(0,v.jsx)("small",{children:f("dialog.noteHint")})]}),U.type!=="note"&&(0,v.jsxs)("label",{className:"editor-field",children:[(0,v.jsx)("span",{children:U.type==="image"?c("dialog.imageUrl"):c("dialog.linkUrl")}),(0,v.jsx)("input",{autoFocus:!0,type:"text",placeholder:U.type==="link"&&xe?c("dialog.linkOrPage"):"https://",value:U.value,role:Mt.length?"combobox":void 0,"aria-expanded":Mt.length?!0:void 0,"aria-controls":Mt.length?"editor-link-pages":void 0,"aria-activedescendant":Mt[Oo]?`editor-link-page-${Oo}`:void 0,onChange:y=>{Le({...U,value:y.target.value}),Ce("")},onKeyDown:y=>{if(!Mt.length||!["ArrowDown","ArrowUp"].includes(y.key))return;y.preventDefault();let x=y.key==="ArrowDown"?1:-1;Bs(A=>(A+x+Mt.length)%Mt.length)}})]}),Mt.length>0&&(0,v.jsx)("ul",{className:"editor-link-pages",id:"editor-link-pages",role:"listbox","aria-label":c("dialog.linkPages"),children:Mt.map((y,x)=>(0,v.jsxs)("li",{id:`editor-link-page-${x}`,role:"option","aria-selected":x===Oo,onMouseEnter:()=>Bs(x),onMouseDown:A=>A.preventDefault(),onClick:()=>Fc(y.href),children:[(0,v.jsx)(au,{size:14}),(0,v.jsx)("span",{children:y.title||c("dialog.untitledPage")})]},y.id))}),U.type==="image"&&(0,v.jsxs)("label",{className:"editor-field",children:[(0,v.jsxs)("span",{children:[c("dialog.imageAlt")," ",(0,v.jsx)("small",{children:c("dialog.optional")})]}),(0,v.jsx)("input",{placeholder:c("dialog.imageAltPlaceholder"),value:U.alt,onChange:y=>Le({...U,alt:y.target.value})})]}),_r&&(0,v.jsx)("p",{className:"editor-field-error",role:"alert",children:_r}),(0,v.jsxs)("div",{className:"editor-modal-actions",children:[U.type==="link"&&w.isActive("link")&&(0,v.jsx)("button",{type:"button",className:"editor-text-action",onClick:()=>{w.chain().focus().extendMarkRange("link").unsetLink().run(),Le(null)},children:c("dialog.removeLink")}),U.type==="note"&&U.hadNote&&(0,v.jsx)("button",{type:"button",className:"editor-text-action",onClick:()=>{Wc(U,"")&&Le(null)},children:f("dialog.removeNote")}),(0,v.jsx)("button",{type:"button",className:"editor-secondary",onClick:()=>Le(null),children:c("dialog.cancel")}),(0,v.jsxs)("button",{type:"submit",className:"editor-primary",disabled:(U.type==="image"||U.type==="note")&&!U.value.trim(),children:[(0,v.jsx)(eu,{size:15}),U.type==="image"?c("insert.image"):c("dialog.confirm")]})]})]})}),St??document.body),n&&(0,v.jsxs)("span",{className:"editor-readonly-note",children:[(0,v.jsx)(lu,{size:12}),c("readOnlyNote")]})]})}export{Z1 as default};